@mux/playback-core 0.16.0 → 0.16.1

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,11 +1,11 @@
1
- "use strict";(()=>{var Wi=Object.create;var kr=Object.defineProperty;var Gi=Object.getOwnPropertyDescriptor;var Hi=Object.getOwnPropertyNames;var ji=Object.getPrototypeOf,Vi=Object.prototype.hasOwnProperty;var Fr=(J,ee)=>()=>(ee||J((ee={exports:{}}).exports,ee),ee.exports);var Yi=(J,ee,ie,se)=>{if(ee&&typeof ee=="object"||typeof ee=="function")for(let z of Hi(ee))!Vi.call(J,z)&&z!==ie&&kr(J,z,{get:()=>ee[z],enumerable:!(se=Gi(ee,z))||se.enumerable});return J};var zt=(J,ee,ie)=>(ie=J!=null?Wi(ji(J)):{},Yi(ee||!J||!J.__esModule?kr(ie,"default",{value:J,enumerable:!0}):ie,J));var Ur=Fr((Qt,hr)=>{(function(){var J,ee;J=this,ee=function(){return function(){var ie={80:function(N,T,C){N.exports=C(728).default},728:function(N,T,C){"use strict";C.d(T,{default:function(){return Ni}});var L=C(48),M=C.n(L),P=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(U){var O=16*Math.random()|0;return(U==="x"?O:3&O|8).toString(16)})},B=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},A=function(U){return U&&U.nodeName!==void 0?(U.muxId||(U.muxId=U.id||B()),U.muxId):U},D=function(U){var O;U&&U.nodeName!==void 0?U=A(O=U):O=document.querySelector(U);var w=O&&O.nodeName?O.nodeName.toLowerCase():"";return[O,U,w]},x=C(640),_=C.n(x),S=_().methodFactory;_().methodFactory=function(U,O,w){var W=S(U,O,w);return function(){for(var G=["[mux]"],X=0;X<arguments.length;X++)G.push(arguments[X]);W.apply(void 0,G)}},_().setLevel(_().getLevel());var d=_();function E(){return(M().doNotTrack||M().navigator&&M().navigator.doNotTrack)==="1"}var p={now:function(){var U=M().performance,O=U&&U.timing,w=O&&O.navigationStart,W=typeof w=="number"&&typeof U.now=="function"?w+U.now():Date.now();return Math.round(W)}},h=C(678),a=C.n(h),o=function(U){return n(U)[0]},n=function(U){if(typeof U!="string"||U==="")return["localhost"];var O,w=(U.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/)||[])[4];return w&&(O=(w.match(/[^\.]+\.[^\.]+$/)||[])[0]),[w,O]},v={exists:function(){var U=M().performance;return(U&&U.timing)!==void 0},domContentLoadedEventEnd:function(){var U=M().performance,O=U&&U.timing;return O&&O.domContentLoadedEventEnd},navigationStart:function(){var U=M().performance,O=U&&U.timing;return O&&O.navigationStart}};function l(U,O,w){w=w===void 0?1:w,U[O]=U[O]||0,U[O]+=w}var i=["x-cdn","content-type","x-request-id"];function u(U){var O={};return(U=U||"").trim().split(/[\r\n]+/).forEach(function(w){if(w){var W=w.split(": "),G=W.shift();G&&(i.indexOf(G.toLowerCase())>=0||G.toLowerCase().indexOf("x-litix-")===0)&&(O[G]=W.join(": "))}}),O}var g=function(U){var O={};for(var w in U){var W=U[w];W["DATA-ID"].search("io.litix.data.")!==-1&&(O[W["DATA-ID"].replace("io.litix.data.","")]=W.VALUE)}return O};function c(U,O){var w=Object.keys(U);if(Object.getOwnPropertySymbols){var W=Object.getOwnPropertySymbols(U);O&&(W=W.filter(function(G){return Object.getOwnPropertyDescriptor(U,G).enumerable})),w.push.apply(w,W)}return w}function m(U){for(var O=1;O<arguments.length;O++){var w=arguments[O]!=null?arguments[O]:{};O%2?c(Object(w),!0).forEach(function(W){e(U,W,w[W])}):Object.getOwnPropertyDescriptors?Object.defineProperties(U,Object.getOwnPropertyDescriptors(w)):c(Object(w)).forEach(function(W){Object.defineProperty(U,W,Object.getOwnPropertyDescriptor(w,W))})}return U}function e(U,O,w){return O in U?Object.defineProperty(U,O,{value:w,enumerable:!0,configurable:!0,writable:!0}):U[O]=w,U}var r=function(U){if(!U)return{};var O=v.navigationStart(),w=U.loading,W=w?w.start:U.trequest,G=w?w.first:U.tfirst,X=w?w.end:U.tload;return{bytesLoaded:U.total,requestStart:Math.round(O+W),responseStart:Math.round(O+G),responseEnd:Math.round(O+X)}},t=function(U){if(U&&typeof U.getAllResponseHeaders=="function")return u(U.getAllResponseHeaders())};function s(U,O){var w=Object.keys(U);if(Object.getOwnPropertySymbols){var W=Object.getOwnPropertySymbols(U);O&&(W=W.filter(function(G){return Object.getOwnPropertyDescriptor(U,G).enumerable})),w.push.apply(w,W)}return w}function y(U){for(var O=1;O<arguments.length;O++){var w=arguments[O]!=null?arguments[O]:{};O%2?s(Object(w),!0).forEach(function(W){f(U,W,w[W])}):Object.getOwnPropertyDescriptors?Object.defineProperties(U,Object.getOwnPropertyDescriptors(w)):s(Object(w)).forEach(function(W){Object.defineProperty(U,W,Object.getOwnPropertyDescriptor(w,W))})}return U}function f(U,O,w){return O in U?Object.defineProperty(U,O,{value:w,enumerable:!0,configurable:!0,writable:!0}):U[O]=w,U}var b=function(U,O){if(!U||typeof U.getRequests!="function")return{};var w=U.getRequests({state:"executed"});if(w.length===0)return{};var W,G=w[w.length-1],X=o(G.url),V=G.url,$=G.bytesLoaded,re=new Date(G.requestStartDate).getTime(),Z=new Date(G.firstByteDate).getTime(),oe=new Date(G.requestEndDate).getTime(),Ee=isNaN(G.duration)?0:G.duration,ve=typeof O.getMetricsFor=="function"?O.getMetricsFor(G.mediaType).HttpList:O.getDashMetrics().getHttpRequests(G.mediaType);return ve.length>0&&(W=u(ve[ve.length-1]._responseHeaders||"")),{requestStart:re,requestResponseStart:Z,requestResponseEnd:oe,requestBytesLoaded:$,requestResponseHeaders:W,requestMediaDuration:Ee,requestHostname:X,requestUrl:V}},R=function(U,O){var w=O.getQualityFor(U),W=O.getCurrentTrackFor(U).bitrateList;return W?{currentLevel:w,renditionWidth:W[w].width||null,renditionHeight:W[w].height||null,renditionBitrate:W[w].bandwidth}:{}},I=function(U){var O;return(O=U.match(/.*codecs\*?="(.*)"/))===null||O===void 0?void 0:O[1]};function k(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}var F=0,K=function(){function U(){(function(G,X){if(!(G instanceof X))throw new TypeError("Cannot call a class as a function")})(this,U)}var O,w,W;return O=U,w=[{key:"on",value:function(G,X,V){return X._eventEmitterGuid=X._eventEmitterGuid||++F,this._listeners=this._listeners||{},this._listeners[G]=this._listeners[G]||[],V&&(X=X.bind(V)),this._listeners[G].push(X),X}},{key:"off",value:function(G,X){var V=this._listeners&&this._listeners[G];V&&V.forEach(function($,re){$._eventEmitterGuid===X._eventEmitterGuid&&V.splice(re,1)})}},{key:"one",value:function(G,X,V){var $=this;X._eventEmitterGuid=X._eventEmitterGuid||++F;var re=function Z(){$.off(G,Z),X.apply(V||this,arguments)};re._eventEmitterGuid=X._eventEmitterGuid,this.on(G,re)}},{key:"emit",value:function(G,X){var V=this;if(this._listeners){X=X||{};var $=this._listeners["before*"]||[],re=this._listeners[G]||[],Z=this._listeners["after"+G]||[],oe=function(Ee,ve){(Ee=Ee.slice()).forEach(function(pe){pe.call(V,{type:G},ve)})};oe($,X),oe(re,X),oe(Z,X)}}}],w&&k(O.prototype,w),W&&k(O,W),Object.defineProperty(O,"prototype",{writable:!1}),U}(),H=K;function j(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}var Y=function(){function U(G){var X=this;(function(V,$){if(!(V instanceof $))throw new TypeError("Cannot call a class as a function")})(this,U),this.pm=G,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,G.on("playing",function(){X._playheadShouldBeProgressing=!0}),G.on("play",this._startPlaybackHeartbeatInterval.bind(this)),G.on("playing",this._startPlaybackHeartbeatInterval.bind(this)),G.on("adbreakstart",this._startPlaybackHeartbeatInterval.bind(this)),G.on("adplay",this._startPlaybackHeartbeatInterval.bind(this)),G.on("adplaying",this._startPlaybackHeartbeatInterval.bind(this)),G.on("seeking",this._startPlaybackHeartbeatInterval.bind(this)),G.on("devicewake",this._startPlaybackHeartbeatInterval.bind(this)),G.on("viewstart",this._startPlaybackHeartbeatInterval.bind(this)),G.on("rebufferstart",this._startPlaybackHeartbeatInterval.bind(this)),G.on("pause",this._stopPlaybackHeartbeatInterval.bind(this)),G.on("ended",this._stopPlaybackHeartbeatInterval.bind(this)),G.on("viewend",this._stopPlaybackHeartbeatInterval.bind(this)),G.on("error",this._stopPlaybackHeartbeatInterval.bind(this)),G.on("aderror",this._stopPlaybackHeartbeatInterval.bind(this)),G.on("adpause",this._stopPlaybackHeartbeatInterval.bind(this)),G.on("adended",this._stopPlaybackHeartbeatInterval.bind(this)),G.on("adbreakend",this._stopPlaybackHeartbeatInterval.bind(this)),G.on("seeked",function(){G.data.player_is_paused?X._stopPlaybackHeartbeatInterval():X._startPlaybackHeartbeatInterval()}),G.on("timeupdate",function(){X._playbackHeartbeatInterval!==null&&G.emit("playbackheartbeat")}),G.on("devicesleep",function(V,$){X._playbackHeartbeatInterval!==null&&(M().clearInterval(X._playbackHeartbeatInterval),G.emit("playbackheartbeatend",{viewer_time:$.viewer_time}),X._playbackHeartbeatInterval=null)})}var O,w,W;return O=U,(w=[{key:"_startPlaybackHeartbeatInterval",value:function(){var G=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=M().setInterval(function(){G.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(M().clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}])&&j(O.prototype,w),W&&j(O,W),Object.defineProperty(O,"prototype",{writable:!1}),U}();function Q(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}function q(U,O,w){return O&&Q(U.prototype,O),w&&Q(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var ne=q(function U(O){var w=this;(function(W,G){if(!(W instanceof G))throw new TypeError("Cannot call a class as a function")})(this,U),O.on("viewinit",function(){w.viewErrored=!1}),O.on("error",function(W,G){try{var X=O.errorTranslator({player_error_code:G.player_error_code,player_error_message:G.player_error_message,player_error_context:G.player_error_context});X?(O.data.player_error_code=X.player_error_code||G.player_error_code,O.data.player_error_message=X.player_error_message||G.player_error_message,O.data.player_error_context=X.player_error_context||G.player_error_context,w.viewErrored=!0):(delete O.data.player_error_code,delete O.data.player_error_message,delete O.data.player_error_context)}catch(V){O.mux.log.warn("Exception in error translator callback.",V),w.viewErrored=!0}})});function te(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}var ae=function(){function U(G){(function(X,V){if(!(X instanceof V))throw new TypeError("Cannot call a class as a function")})(this,U),this.pm=G,this._watchTimeTrackerLastCheckedTime=null,G.on("playbackheartbeat",this._updateWatchTime.bind(this)),G.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}var O,w,W;return O=U,(w=[{key:"_updateWatchTime",value:function(G,X){var V=X.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=V),l(this.pm.data,"view_watch_time",V-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=V}},{key:"_clearWatchTimeState",value:function(G,X){this._updateWatchTime(G,X),this._watchTimeTrackerLastCheckedTime=null}}])&&te(O.prototype,w),W&&te(O,W),Object.defineProperty(O,"prototype",{writable:!1}),U}();function ue(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}var ce=function(){function U(G){(function(X,V){if(!(X instanceof V))throw new TypeError("Cannot call a class as a function")})(this,U),this.pm=G,this._playbackTimeTrackerLastPlayheadPosition=-1,G.on("playbackheartbeat",this._updatePlaybackTime.bind(this)),G.on("playbackheartbeatend",this._clearPlaybackTimeState.bind(this)),G.on("seeking",this._clearPlaybackTimeState.bind(this))}var O,w,W;return O=U,(w=[{key:"_updatePlaybackTime",value:function(){var G=this.pm.data.player_playhead_time;if(this._playbackTimeTrackerLastPlayheadPosition>=0&&G>this._playbackTimeTrackerLastPlayheadPosition){var X=G-this._playbackTimeTrackerLastPlayheadPosition;X<=1e3&&l(this.pm.data,"view_content_playback_time",X)}this._playbackTimeTrackerLastPlayheadPosition=G}},{key:"_clearPlaybackTimeState",value:function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1}}])&&ue(O.prototype,w),W&&ue(O,W),Object.defineProperty(O,"prototype",{writable:!1}),U}();function le(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}var fe=function(){function U(G){(function(V,$){if(!(V instanceof $))throw new TypeError("Cannot call a class as a function")})(this,U),this.pm=G;var X=this._updatePlayheadTime.bind(this);G.on("playbackheartbeat",X),G.on("playbackheartbeatend",X),G.on("timeupdate",X),G.on("destroy",function(){G.off("timeupdate",X)})}var O,w,W;return O=U,(w=[{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(G,X){var V=this,$=function(){V.pm.currentFragmentPDT&&V.pm.currentFragmentStart&&(V.pm.data.player_program_time=V.pm.currentFragmentPDT+V.pm.data.player_playhead_time-V.pm.currentFragmentStart)};if(X&&X.player_playhead_time)this.pm.data.player_playhead_time=X.player_playhead_time,$(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var re=this.pm.getPlayheadTime();re!==void 0&&(this.pm.data.player_playhead_time=re,$(),this._updateMaxPlayheadPosition())}}}])&&le(O.prototype,w),W&&le(O,W),Object.defineProperty(O,"prototype",{writable:!1}),U}();function de(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}function xe(U,O,w){return O&&de(U.prototype,O),w&&de(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var Ae=xe(function U(O){if(function(X,V){if(!(X instanceof V))throw new TypeError("Cannot call a class as a function")}(this,U),!O.disableRebufferTracking){var w,W=function(X,V){G(V),w=void 0},G=function(X){if(w){var V=X.viewer_time-w;l(O.data,"view_rebuffer_duration",V),w=X.viewer_time}O.data.view_watch_time>=0&&O.data.view_rebuffer_count>0&&(O.data.view_rebuffer_frequency=O.data.view_rebuffer_count/O.data.view_watch_time,O.data.view_rebuffer_percentage=O.data.view_rebuffer_duration/O.data.view_watch_time)};O.on("playbackheartbeat",function(X,V){return G(V)}),O.on("rebufferstart",function(X,V){w||(l(O.data,"view_rebuffer_count",1),w=V.viewer_time,O.one("rebufferend",W))}),O.on("viewinit",function(){w=void 0,O.off("rebufferend",W)})}});function Ie(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}var Re=function(){function U(G){var X=this;(function(V,$){if(!(V instanceof $))throw new TypeError("Cannot call a class as a function")})(this,U),this.pm=G,G.disableRebufferTracking||G.disablePlayheadRebufferTracking||(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,G.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),G.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),G.on("seeking",function(){X._cleanupRebufferTracker(null,{viewer_time:p.now()})}))}var O,w,W;return O=U,w=[{key:"_checkIfRebuffering",value:function(G,X){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing)this._cleanupRebufferTracker(G,X);else if(this._lastCheckedTime!==null)if(this._lastPlayheadTime===this.pm.data.player_playhead_time){var V=X.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&V>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=X.viewer_time}else this._cleanupRebufferTracker(G,X,!0);else this._prepareRebufferTrackerState(X.viewer_time)}},{key:"_clearRebufferTrackerState",value:function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null}},{key:"_prepareRebufferTrackerState",value:function(G){this._lastCheckedTime=G,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=G}},{key:"_cleanupRebufferTracker",value:function(G,X){var V=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:X.viewer_time});else{if(this._lastCheckedTime===null)return;var $=this.pm.data.player_playhead_time-this._lastPlayheadTime,re=X.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&$>0&&re-$>this.pm.minimumRebufferDuration&&(this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+re-$}))}V?this._prepareRebufferTrackerState(X.viewer_time):this._clearRebufferTrackerState()}}],w&&Ie(O.prototype,w),W&&Ie(O,W),Object.defineProperty(O,"prototype",{writable:!1}),U}(),Oe=Re;function Pe(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}var Ce=function(){function U(G){var X=this;(function(V,$){if(!(V instanceof $))throw new TypeError("Cannot call a class as a function")})(this,U),this.pm=G,G.on("viewinit",function(){var V=G.data,$=V.view_id;if(!V.view_program_changed){var re=function(Z,oe){var Ee=oe.viewer_time;Z.type==="playing"&&G.data.view_time_to_first_frame===void 0?X.calculateTimeToFirstFrame(Ee||p.now(),$):Z.type!=="adplaying"||G.data.view_time_to_first_frame!==void 0&&!X._inPrerollPosition()||X.calculateTimeToFirstFrame(Ee||p.now(),$)};G.one("playing",re),G.one("adplaying",re),G.one("viewend",function(){G.off("playing",re),G.off("adplaying",re)})}})}var O,w,W;return O=U,(w=[{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(G,X){X===this.pm.data.view_id&&(this.pm.watchTimeTracker._updateWatchTime(null,{viewer_time:G}),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))}}])&&Pe(O.prototype,w),W&&Pe(O,W),Object.defineProperty(O,"prototype",{writable:!1}),U}();function Le(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}function ke(U,O,w){return O&&Le(U.prototype,O),w&&Le(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var Be=ke(function U(O){var w=this;(function(W,G){if(!(W instanceof G))throw new TypeError("Cannot call a class as a function")})(this,U),O.on("viewinit",function(){w._lastPlayheadPosition=-1}),["pause","rebufferstart","seeking","error","adbreakstart","hb"].forEach(function(W){O.on(W,function(){if(w._lastPlayheadPosition>=0&&O.data.player_playhead_time>=0&&w._lastPlayerWidth>=0&&w._lastSourceWidth>0&&w._lastPlayerHeight>=0&&w._lastSourceHeight>0){var G=O.data.player_playhead_time-w._lastPlayheadPosition;if(G<0)return void(w._lastPlayheadPosition=-1);var X=Math.min(w._lastPlayerWidth/w._lastSourceWidth,w._lastPlayerHeight/w._lastSourceHeight),V=Math.max(0,X-1),$=Math.max(0,1-X);O.data.view_max_upscale_percentage=Math.max(O.data.view_max_upscale_percentage||0,V),O.data.view_max_downscale_percentage=Math.max(O.data.view_max_downscale_percentage||0,$),l(O.data,"view_total_content_playback_time",G),l(O.data,"view_total_upscaling",V*G),l(O.data,"view_total_downscaling",$*G)}w._lastPlayheadPosition=-1})}),["playing","hb"].forEach(function(W){O.on(W,function(){w._lastPlayheadPosition=O.data.player_playhead_time,w._lastPlayerWidth=O.data.player_width,w._lastPlayerHeight=O.data.player_height,w._lastSourceWidth=O.data.video_source_width,w._lastSourceHeight=O.data.video_source_height})})});function we(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}function Ye(U,O,w){return O&&we(U.prototype,O),w&&we(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var Xe=Ye(function U(O){var w=this;(function(W,G){if(!(W instanceof G))throw new TypeError("Cannot call a class as a function")})(this,U),this.isSeeking=!1,O.on("seeking",function(W,G){a()(O.data,G),w._lastSeekingTime=p.now(),w.isSeeking===!1&&(w.isSeeking=!0,O.send("seeking"))}),O.on("seeked",function(){w.isSeeking=!1;var W=w._lastSeekingTime||p.now(),G=p.now()-W;l(O.data,"view_seek_count",1),l(O.data,"view_seek_duration",G);var X=O.data.view_max_seek_time||0;O.data.view_max_seek_time=Math.max(X,G)}),O.on("viewend",function(){w.isSeeking=!1})});function rt(U,O){return function(w){if(Array.isArray(w))return w}(U)||function(w,W){var G=w==null?null:typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(G!=null){var X,V,$=[],re=!0,Z=!1;try{for(G=G.call(w);!(re=(X=G.next()).done)&&($.push(X.value),!W||$.length!==W);re=!0);}catch(oe){Z=!0,V=oe}finally{try{re||G.return==null||G.return()}finally{if(Z)throw V}}return $}}(U,O)||function(w,W){if(w){if(typeof w=="string")return ze(w,W);var G=Object.prototype.toString.call(w).slice(8,-1);return G==="Object"&&w.constructor&&(G=w.constructor.name),G==="Map"||G==="Set"?Array.from(w):G==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(G)?ze(w,W):void 0}}(U,O)||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 ze(U,O){(O==null||O>U.length)&&(O=U.length);for(var w=0,W=new Array(O);w<O;w++)W[w]=U[w];return W}function it(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}var nt=function(U,O){U.push(O),U.sort(function(w,W){return w.viewer_time-W.viewer_time})},Je=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],Ne=function(){function U(G){var X=this;(function($,re){if(!($ instanceof re))throw new TypeError("Cannot call a class as a function")})(this,U),this.pm=G,G.on("viewinit",function(){X.isAdBreak=!1,X._currentAdRequestNumber=0,X._currentAdResponseNumber=0,X._adRequests=[],X._adResponses=[],X._adHasPlayed=!1,X._wouldBeNewAdPlay=!0,X._prerollPlayTime=void 0}),Je.forEach(function($){return G.on($,X._updateAdData.bind(X))});var V=function(){X.isAdBreak=!1};G.on("adbreakstart",function(){X.isAdBreak=!0}),G.on("play",V),G.on("playing",V),G.on("viewend",V),G.on("adrequest",function($,re){re=a()({ad_request_id:"generatedAdRequestId"+X._currentAdRequestNumber++},re),nt(X._adRequests,re),l(G.data,"view_ad_request_count"),X.inPrerollPosition()&&(G.data.view_preroll_requested=!0,X._adHasPlayed||l(G.data,"view_preroll_request_count"))}),G.on("adresponse",function($,re){re=a()({ad_request_id:"generatedAdRequestId"+X._currentAdResponseNumber++},re),nt(X._adResponses,re);var Z=X.findAdRequest(re.ad_request_id);Z&&l(G.data,"view_ad_request_time",Math.max(0,re.viewer_time-Z.viewer_time))}),G.on("adplay",function($,re){X._adHasPlayed=!0,X._wouldBeNewAdPlay&&(X._wouldBeNewAdPlay=!1,l(G.data,"view_ad_played_count")),X.inPrerollPosition()&&!G.data.view_preroll_played&&(G.data.view_preroll_played=!0,X._adRequests.length>0&&(G.data.view_preroll_request_time=Math.max(0,re.viewer_time-X._adRequests[0].viewer_time)),G.data.view_start&&(G.data.view_startup_preroll_request_time=Math.max(0,re.viewer_time-G.data.view_start)),X._prerollPlayTime=re.viewer_time)}),G.on("adplaying",function($,re){X.inPrerollPosition()&&G.data.view_preroll_load_time===void 0&&X._prerollPlayTime!==void 0&&(G.data.view_preroll_load_time=re.viewer_time-X._prerollPlayTime,G.data.view_startup_preroll_load_time=re.viewer_time-X._prerollPlayTime)}),G.on("adended",function(){X._wouldBeNewAdPlay=!0}),G.on("aderror",function(){X._wouldBeNewAdPlay=!0})}var O,w,W;return O=U,(w=[{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(G){for(var X=0;X<this._adRequests.length;X++)if(this._adRequests[X].ad_request_id===G)return this._adRequests[X]}},{key:"_updateAdData",value:function(G,X){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&X.ad_tag_url){var V=rt(n(X.ad_tag_url),2),$=V[0],re=V[1];this.pm.data.view_preroll_ad_tag_domain=re,this.pm.data.view_preroll_ad_tag_hostname=$}if(!this.pm.data.view_preroll_ad_asset_hostname&&X.ad_asset_url){var Z=rt(n(X.ad_asset_url),2),oe=Z[0],Ee=Z[1];this.pm.data.view_preroll_ad_asset_domain=Ee,this.pm.data.view_preroll_ad_asset_hostname=oe}}}}])&&it(O.prototype,w),W&&it(O,W),Object.defineProperty(O,"prototype",{writable:!1}),U}();function Ke(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}function Ze(U,O,w){return O&&Ke(U.prototype,O),w&&Ke(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var ft=Ze(function U(O){var w,W;(function($,re){if(!($ instanceof re))throw new TypeError("Cannot call a class as a function")})(this,U);var G=function(){O.disableRebufferTracking||w&&(l(O.data,"view_waiting_rebuffer_duration",p.now()-w),w=!1,M().clearInterval(W))},X=!1,V=function(){X=!1,G()};O.on("waiting",function(){X&&(O.disableRebufferTracking||(l(O.data,"view_waiting_rebuffer_count",1),w=p.now(),W=M().setInterval(function(){if(w){var $=p.now();l(O.data,"view_waiting_rebuffer_duration",$-w),w=$}},250)))}),O.on("playing",function(){G(),X=!0}),O.on("pause",V),O.on("seeking",V)});function Me(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}function qe(U,O,w){return O&&Me(U.prototype,O),w&&Me(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var et=qe(function U(O){var w=this;(function(X,V){if(!(X instanceof V))throw new TypeError("Cannot call a class as a function")})(this,U);var W=function(){w.lastWallClockTime=p.now(),O.on("before*",G)},G=function(X){var V=p.now(),$=w.lastWallClockTime;w.lastWallClockTime=V,V-$>3e4&&(O.emit("devicesleep",{viewer_time:$}),a()(O.data,{viewer_time:$}),O.send("devicesleep"),O.emit("devicewake",{viewer_time:V}),a()(O.data,{viewer_time:V}),O.send("devicewake"))};O.one("playbackheartbeat",W),O.on("playbackheartbeatend",function(){O.off("before*",G),O.one("playbackheartbeat",W)})}),_t=C(375),mt=C(655),pt=C.n(mt),Rt="muxData",Tt=function(){var U;try{U=_t.parse(pt().get(Rt)||"")}catch{U={}}return U},Gt=function(U){try{pt().set(Rt,_t.stringify(U),{expires:7300})}catch{}},It=function(){var U=Tt();return U.mux_viewer_id=U.mux_viewer_id||P(),U.msn=U.msn||Math.random(),Gt(U),{mux_viewer_id:U.mux_viewer_id,mux_sample_number:U.msn}};function tr(U,O){var w=O.beaconCollectionDomain,W=O.beaconDomain;if(w)return"https://"+w;var G=W||"litix.io";return(U=U||"inferred").match(/^[a-z0-9]+$/)?"https://"+U+"."+G:"https://img.litix.io/a.gif"}var Ot=function(){var U;switch(St()){case"cellular":U="cellular";break;case"ethernet":U="wired";break;case"wifi":U="wifi";break;case void 0:break;default:U="other"}return U},St=function(){var U=M().navigator,O=U&&(U.connection||U.mozConnection||U.webkitConnection);return O&&O.type};Ot.getConnectionFromAPI=St;var lt=Ot,Ht=jt({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"}),Ct=jt({ad:"ad",ag:"aggregate",ap:"api",al:"application",ar:"architecture",as:"asset",au:"autoplay",av:"average",bi:"bitrate",br:"break",bw:"browser",by:"bytes",ca:"cached",cb:"cancel",cc:"codec",cd:"code",cg:"category",ch:"changed",cn:"config",co:"count",ce:"counter",cp:"complete",cr:"creative",ct:"content",cu:"current",cx:"connection",cz:"context",dg:"downscaling",dm:"domain",dn:"cdn",do:"downscale",dr:"drm",dp:"dropped",du:"duration",dv:"device",ec:"encoding",ed:"edge",en:"end",eg:"engine",em:"embed",er:"error",es:"errorcode",et:"errortext",ee:"event",ev:"events",ex:"expires",ep:"experiments",fi:"first",fm:"family",ft:"format",fp:"fps",fq:"frequency",fr:"frame",fs:"fullscreen",hb:"holdback",he:"headers",ho:"host",hn:"hostname",ht:"height",id:"id",ii:"init",in:"instance",ip:"ip",is:"is",ke:"key",la:"language",lb:"labeled",le:"level",li:"live",ld:"loaded",lo:"load",ls:"lists",lt:"latency",ma:"max",md:"media",me:"message",mf:"manifest",mi:"mime",ml:"midroll",mm:"min",mn:"manufacturer",mo:"model",mx:"mux",ne:"newest",nm:"name",no:"number",on:"on",os:"os",pa:"paused",pb:"playback",pd:"producer",pe:"percentage",pf:"played",pg:"program",ph:"playhead",pi:"plugin",pl:"preroll",pn:"playing",po:"poster",pr:"preload",ps:"position",pt:"part",py:"property",ra:"rate",rd:"requested",re:"rebuffer",rf:"rendition",rm:"remote",ro:"ratio",rp:"response",rq:"request",rs:"requests",sa:"sample",se:"session",sk:"seek",sm:"stream",so:"source",sq:"sequence",sr:"series",st:"start",su:"startup",sv:"server",sw:"software",ta:"tag",tc:"tech",te:"text",tg:"target",th:"throughput",ti:"time",tl:"total",to:"to",tt:"title",ty:"type",ug:"upscaling",un:"universal",up:"upscale",ur:"url",us:"user",va:"variant",vd:"viewed",vi:"video",ve:"version",vw:"view",vr:"viewer",wd:"width",wa:"watch",wt:"waiting"});function jt(U){var O={};for(var w in U)U.hasOwnProperty(w)&&(O[U[w]]=w);return O}function Mt(U){var O={},w={};return Object.keys(U).forEach(function(W){var G=!1;if(U.hasOwnProperty(W)&&U[W]!==void 0){var X=W.split("_"),V=X[0],$=Ht[V];$||(d.info("Data key word `"+X[0]+"` not expected in "+W),$=V+"_"),X.splice(1).forEach(function(re){re==="url"&&(G=!0),Ct[re]?$+=Ct[re]:Number(re)&&Math.floor(Number(re))===Number(re)?$+=re:(d.info("Data key word `"+re+"` not expected in "+W),$+="_"+re+"_")}),G?w[$]=U[W]:O[$]=U[W]}}),a()(O,w)}var rr={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},ir=["hb","requestcompleted","requestfailed","requestcanceled"],nr="https://img.litix.io",ut=function(U){var O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this._beaconUrl=U||nr,this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=a()({},rr,O)};ut.prototype.queueEvent=function(U,O){var w=a()({},O);return(this._eventQueue.length<=this._options.maxQueueLength||U==="eventrateexceeded")&&(this._eventQueue.push(w),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength)},ut.prototype.flushEvents=function(){var U=arguments.length>0&&arguments[0]!==void 0&&arguments[0];U&&this._eventQueue.length===1?this._eventQueue.pop():(this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending())},ut.prototype.destroy=function(){var U=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,U?this._clearBeaconQueue():this.flushEvents(),M().clearTimeout(this._sendTimeout)},ut.prototype._clearBeaconQueue=function(){var U=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,O=this._eventQueue.slice(U);U>0&&a()(O[O.length-1],Mt({mux_view_message:"event queue truncated"}));var w=this._createPayload(O);wt(this._beaconUrl,w,!0,function(){})},ut.prototype._sendBeaconQueue=function(){var U=this;if(!this._postInFlight){var O=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0;var w=this._createPayload(O),W=p.now();wt(this._beaconUrl,w,!1,function(G,X){X?(U._eventQueue=O.concat(U._eventQueue),U._failureCount+=1,d.info("Error sending beacon: "+X)):U._failureCount=0,U._roundTripTime=p.now()-W,U._postInFlight=!1})}},ut.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var U=Math.pow(2,this._failureCount-1);return(1+(U*=Math.random()))*this._options.baseTimeBetweenBeacons},ut.prototype._startBeaconSending=function(){var U=this;M().clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=M().setTimeout(function(){U._eventQueue.length&&U._sendBeaconQueue(),U._startBeaconSending()},this._getNextBeaconTime()))},ut.prototype._createPayload=function(U){var O,w,W,G=this,X={transmission_timestamp:Math.round(p.now())};this._roundTripTime&&(X.rtt_ms=Math.round(this._roundTripTime));var V=function(){O=JSON.stringify({metadata:X,events:w||U}),W=O.length/1024},$=function(){return W<=G._options.maxPayloadKBSize};return V(),$()||(d.info("Payload size is too big ("+W+" kb). Removing unnecessary events."),w=U.filter(function(re){return ir.indexOf(re.e)===-1}),V()),$()||(d.info("Payload size still too big ("+W+" kb). Cropping fields.."),w.forEach(function(re){for(var Z in re){var oe=re[Z];typeof oe=="string"&&oe.length>51200&&(re[Z]=oe.substring(0,51200))}}),V()),O};var wt=function(U,O,w,W){if(w&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(U,O))W();else if(M().fetch)M().fetch(U,{method:"POST",body:O,headers:{"Content-Type":"text/plain"},keepalive:!0}).then(function(X){return W(null,X.ok?null:"Error")}).catch(function(X){return W(null,X)});else{if(M().XMLHttpRequest){var G=new(M()).XMLHttpRequest;return G.onreadystatechange=function(){if(G.readyState===4)return W(null,G.status!==200?"error":void 0)},G.open("POST",U),G.setRequestHeader("Content-Type","text/plain"),void G.send(O)}W()}},ar=ut;function sr(U,O){return function(w){if(Array.isArray(w))return w}(U)||function(w,W){var G=w==null?null:typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(G!=null){var X,V,$=[],re=!0,Z=!1;try{for(G=G.call(w);!(re=(X=G.next()).done)&&($.push(X.value),!W||$.length!==W);re=!0);}catch(oe){Z=!0,V=oe}finally{try{re||G.return==null||G.return()}finally{if(Z)throw V}}return $}}(U,O)||function(w,W){if(w){if(typeof w=="string")return Dr(w,W);var G=Object.prototype.toString.call(w).slice(8,-1);return G==="Object"&&w.constructor&&(G=w.constructor.name),G==="Map"||G==="Set"?Array.from(w):G==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(G)?Dr(w,W):void 0}}(U,O)||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 Dr(U,O){(O==null||O>U.length)&&(O=U.length);for(var w=0,W=new Array(O);w<O;w++)W[w]=U[w];return W}function Lr(U,O){var w=Object.keys(U);if(Object.getOwnPropertySymbols){var W=Object.getOwnPropertySymbols(U);O&&(W=W.filter(function(G){return Object.getOwnPropertyDescriptor(U,G).enumerable})),w.push.apply(w,W)}return w}function Dt(U){for(var O=1;O<arguments.length;O++){var w=arguments[O]!=null?arguments[O]:{};O%2?Lr(Object(w),!0).forEach(function(W){Vt(U,W,w[W])}):Object.getOwnPropertyDescriptors?Object.defineProperties(U,Object.getOwnPropertyDescriptors(w)):Lr(Object(w)).forEach(function(W){Object.defineProperty(U,W,Object.getOwnPropertyDescriptor(w,W))})}return U}function kt(U){return kt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(O){return typeof O}:function(O){return O&&typeof Symbol=="function"&&O.constructor===Symbol&&O!==Symbol.prototype?"symbol":typeof O},kt(U)}function ni(U,O){if(!(U instanceof O))throw new TypeError("Cannot call a class as a function")}function Ar(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}function Vt(U,O,w){return O in U?Object.defineProperty(U,O,{value:w,enumerable:!0,configurable:!0,writable:!0}):U[O]=w,U}var ai=["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"],si=["adplay","adplaying","adpause","adfirstquartile","admidpoint","adthirdquartile","adended"],oi=["viewstart","error","ended","viewend"],li=function(){function U(G,X){var V,$,re,Z,oe,Ee,ve,pe,he,ye,be,He,je,at,Se,Ve=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};ni(this,U),Vt(this,"previousBeaconData",null),Vt(this,"lastEventTime",0),Vt(this,"rateLimited",!1),this.mux=G,this.envKey=X,this.options=Ve,this.eventQueue=new ar(tr(this.envKey,this.options)),this.sampleRate=(V=this.options.sampleRate)!==null&&V!==void 0?V:1,this.disableCookies=($=this.options.disableCookies)!==null&&$!==void 0&&$,this.respectDoNotTrack=(re=this.options.respectDoNotTrack)!==null&&re!==void 0&&re,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:(Z=this.options.platform)===null||Z===void 0?void 0:Z.name,viewer_application_version:(oe=this.options.platform)===null||oe===void 0?void 0:oe.version,viewer_application_engine:(Ee=this.options.platform)===null||Ee===void 0?void 0:Ee.layout,viewer_device_name:(ve=this.options.platform)===null||ve===void 0?void 0:ve.product,viewer_device_category:"",viewer_device_manufacturer:(pe=this.options.platform)===null||pe===void 0?void 0:pe.manufacturer,viewer_os_family:(he=this.options.platform)===null||he===void 0||(ye=he.os)===null||ye===void 0?void 0:ye.family,viewer_os_architecture:(be=this.options.platform)===null||be===void 0||(He=be.os)===null||He===void 0?void 0:He.architecture,viewer_os_version:(je=this.options.platform)===null||je===void 0||(at=je.os)===null||at===void 0?void 0:at.version,viewer_connection_type:lt(),page_url:M()===null||M()===void 0||(Se=M().location)===null||Se===void 0?void 0:Se.href},this.viewerData=this.disableCookies?{}:It()}var O,w,W;return O=U,(w=[{key:"send",value:function(G,X){var V;if(G){if(this.respectDoNotTrack&&E())return d.info("Not sending `"+G+"` because Do Not Track is enabled");if(!X||kt(X)!=="object")return d.error("A data object was expected in send() but was not provided");var $,re,Z=this.disableCookies?{}:($=Tt(),re=p.now(),$.session_start&&($.sst=$.session_start,delete $.session_start),$.session_id&&($.sid=$.session_id,delete $.session_id),$.session_expires&&($.sex=$.session_expires,delete $.session_expires),(!$.sex||$.sex<re)&&($.sid=P(),$.sst=re),$.sex=re+15e5,Gt($),{session_id:$.sid,session_start:$.sst,session_expires:$.sex}),oe=Dt(Dt(Dt(Dt(Dt({},this.pageLevelData),X),Z),this.viewerData),{},{event:G,env_key:this.envKey});oe.user_id&&(oe.viewer_user_id=oe.user_id,delete oe.user_id);var Ee=((V=oe.mux_sample_number)!==null&&V!==void 0?V:0)>=this.sampleRate,ve=Mt(this._deduplicateBeaconData(G,oe));if(this.lastEventTime=this.mux.utils.now(),Ee)return d.info("Not sending event due to sample rate restriction",G,oe,ve);if(this.envKey||d.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",G,oe,ve),!this.rateLimited){if(d.info("Sending event",G,oe,ve),this.rateLimited=!this.eventQueue.queueEvent(G,ve),this.mux.WINDOW_UNLOADING&&G==="viewend")this.eventQueue.destroy(!0);else if(this.mux.WINDOW_HIDDEN&&G==="hb"?this.eventQueue.flushEvents(!0):oi.indexOf(G)>=0&&this.eventQueue.flushEvents(),this.rateLimited)return oe.event="eventrateexceeded",ve=Mt(oe),this.eventQueue.queueEvent(oe.event,ve),d.error("Beaconing disabled due to rate limit.")}}}},{key:"destroy",value:function(){this.eventQueue.destroy(!1)}},{key:"_deduplicateBeaconData",value:function(G,X){var V=this,$={},re=X.view_id;if(!re||G==="viewstart"||G==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=6e5)$=Dt({},X),re&&(this.previousBeaconData=$),re&&G==="viewend"&&(this.previousBeaconData=null);else{var Z=G.indexOf("request")===0;Object.entries(X).forEach(function(oe){var Ee=sr(oe,2),ve=Ee[0],pe=Ee[1];V.previousBeaconData&&(pe!==V.previousBeaconData[ve]||ai.indexOf(ve)>-1||V.objectHasChanged(Z,ve,pe,V.previousBeaconData[ve])||V.eventRequiresKey(G,ve))&&($[ve]=pe,V.previousBeaconData[ve]=pe)})}return $}},{key:"objectHasChanged",value:function(G,X,V,$){return!(!G||X.indexOf("request_")!==0||X!=="request_response_headers"&&kt(V)==="object"&&kt($)==="object"&&Object.keys(V||{}).length===Object.keys($||{}).length)}},{key:"eventRequiresKey",value:function(G,X){return G==="renditionchange"&&X.indexOf("video_source_")===0||!(X.indexOf("ad_")!==0||!si.includes(G))}}])&&Ar(O.prototype,w),W&&Ar(O,W),Object.defineProperty(O,"prototype",{writable:!1}),U}();function br(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}function ui(U,O,w){return O&&br(U.prototype,O),w&&br(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var fi=ui(function U(O){(function(Z,oe){if(!(Z instanceof oe))throw new TypeError("Cannot call a class as a function")})(this,U);var w=0,W=0,G=0,X=0,V=0,$=0,re=0;O.on("requestcompleted",function(Z,oe){var Ee,ve,pe=oe.request_start,he=oe.request_response_start,ye=oe.request_response_end,be=oe.request_bytes_loaded;if(X++,he?(Ee=he-pe,ve=ye-he):ve=ye-pe,ve>0&&be>0){var He=be/ve*8e3;V++,W+=be,G+=ve,O.data.view_min_request_throughput=Math.min(O.data.view_min_request_throughput||1/0,He),O.data.view_average_request_throughput=W/G*8e3,O.data.view_request_count=X,Ee>0&&(w+=Ee,O.data.view_max_request_latency=Math.max(O.data.view_max_request_latency||0,Ee),O.data.view_average_request_latency=w/V)}}),O.on("requestfailed",function(Z,oe){X++,$++,O.data.view_request_count=X,O.data.view_request_failed_count=$}),O.on("requestcanceled",function(Z,oe){X++,re++,O.data.view_request_count=X,O.data.view_request_canceled_count=re})});function Pr(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}function di(U,O,w){return O&&Pr(U.prototype,O),w&&Pr(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var ci=di(function U(O){var w=this;(function(W,G){if(!(W instanceof G))throw new TypeError("Cannot call a class as a function")})(this,U),O.on("before*",function(W,G){var X=G.viewer_time,V=p.now(),$=w._lastEventTime;if(w._lastEventTime=V,$&&V-$>36e5){var re=Object.keys(O.data).reduce(function(Z,oe){return oe.indexOf("video_")===0?a()(Z,function(Ee,ve,pe){return ve in Ee?Object.defineProperty(Ee,ve,{value:pe,enumerable:!0,configurable:!0,writable:!0}):Ee[ve]=pe,Ee}({},oe,O.data[oe])):Z},{});O.mux.log.info("Received event after at least an hour inactivity, creating a new view"),O.emit("viewinit",a()({viewer_time:X},re)),O.playbackHeartbeat._playheadShouldBeProgressing&&W.type!=="play"&&W.type!=="adbreakstart"&&(O.emit("play",{viewer_time:X}),W.type!=="playing"&&O.emit("playing",{viewer_time:X}))}})});function or(U){return or=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(O){return typeof O}:function(O){return O&&typeof Symbol=="function"&&O.constructor===Symbol&&O!==Symbol.prototype?"symbol":typeof O},or(U)}function hi(U,O){return function(w){if(Array.isArray(w))return w}(U)||function(w,W){var G=w==null?null:typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(G!=null){var X,V,$=[],re=!0,Z=!1;try{for(G=G.call(w);!(re=(X=G.next()).done)&&($.push(X.value),!W||$.length!==W);re=!0);}catch(oe){Z=!0,V=oe}finally{try{re||G.return==null||G.return()}finally{if(Z)throw V}}return $}}(U,O)||function(w,W){if(w){if(typeof w=="string")return Rr(w,W);var G=Object.prototype.toString.call(w).slice(8,-1);return G==="Object"&&w.constructor&&(G=w.constructor.name),G==="Map"||G==="Set"?Array.from(w):G==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(G)?Rr(w,W):void 0}}(U,O)||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 Rr(U,O){(O==null||O>U.length)&&(O=U.length);for(var w=0,W=new Array(O);w<O;w++)W[w]=U[w];return W}function Ir(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}function lr(U,O){return lr=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(w,W){return w.__proto__=W,w},lr(U,O)}function vi(U){var O=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 w,W=Yt(U);if(O){var G=Yt(this).constructor;w=Reflect.construct(W,arguments,G)}else w=W.apply(this,arguments);return gi(this,w)}}function gi(U,O){if(O&&(or(O)==="object"||typeof O=="function"))return O;if(O!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return We(U)}function We(U){if(U===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return U}function Yt(U){return Yt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(O){return O.__proto__||Object.getPrototypeOf(O)},Yt(U)}var mi=["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"],pi=function(U){(function(V,$){if(typeof $!="function"&&$!==null)throw new TypeError("Super expression must either be null or a function");V.prototype=Object.create($&&$.prototype,{constructor:{value:V,writable:!0,configurable:!0}}),Object.defineProperty(V,"prototype",{writable:!1}),$&&lr(V,$)})(X,U);var O,w,W,G=vi(X);function X(V,$,re){var Z;(function(he,ye){if(!(he instanceof ye))throw new TypeError("Cannot call a class as a function")})(this,X),(Z=G.call(this)).DOM_CONTENT_LOADED_EVENT_END=v.domContentLoadedEventEnd(),Z.NAVIGATION_START=v.navigationStart(),Z.mux=V,Z.id=$,(re=a()({debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(he){return he}},re)).data=re.data||{},re.data.property_key&&(re.data.env_key=re.data.property_key,delete re.data.property_key),d.setLevel(re.debug?"debug":"warn"),Z.getPlayheadTime=re.getPlayheadTime,Z.getStateData=re.getStateData||function(){return{}},Z.getAdData=re.getAdData||function(){},Z.minimumRebufferDuration=re.minimumRebufferDuration,Z.sustainedRebufferThreshold=re.sustainedRebufferThreshold,Z.playbackHeartbeatTime=re.playbackHeartbeatTime,Z.disableRebufferTracking=re.disableRebufferTracking,Z.disableRebufferTracking&&Z.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."),Z.disablePlayheadRebufferTracking=re.disablePlayheadRebufferTracking,Z.errorTranslator=re.errorTranslator,Z.playbackEventDispatcher=new li(V,re.data.env_key,re),Z.data={player_instance_id:P(),mux_sample_rate:re.sampleRate,beacon_domain:re.beaconCollectionDomain?re.beaconCollectionDomain:re.beaconDomain},Z.data.view_sequence_number=1,Z.data.player_sequence_number=1,Z.oldEmit=Z.emit,Z.emit=function(he,ye){ye=a()({viewer_time:this.mux.utils.now()},ye),this.oldEmit(he,ye)};var oe=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(We(Z));Z.on("viewinit",function(he,ye){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),a()(this.data,ye),this._initializeViewData(),this.one("play",oe),this.one("adbreakstart",oe)});var Ee=function(he){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",he)}.bind(We(Z));if(Z.on("videochange",function(he,ye){Ee(ye)}),Z.on("programchange",function(he,ye){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."),Ee(a()(ye,{view_program_changed:!0})),oe(),this.emit("play"),this.emit("playing")}),Z.on("fragmentchange",function(he,ye){this.currentFragmentPDT=ye.currentFragmentPDT,this.currentFragmentStart=ye.currentFragmentStart}),Z.on("destroy",Z.destroy),typeof window!="undefined"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var ve=function(){var he=Z.data.view_start!==void 0;Z.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",he&&Z.mux.WINDOW_HIDDEN&&(Z.data.player_is_paused||Z.emit("hb"))};window.addEventListener("visibilitychange",ve,!1);var pe=function(he){he.persisted||Z.destroy()};window.addEventListener("pagehide",pe,!1),Z.on("destroy",function(){window.removeEventListener("visibilitychange",ve),window.removeEventListener("pagehide",pe)})}return Z.on("playerready",function(he,ye){a()(this.data,ye)}),mi.forEach(function(he){Z.on(he,function(ye,be){he.indexOf("ad")!==0&&this._updateStateData(),a()(this.data,be),this._sanitizeData()}),Z.on("after"+he,function(){(he!=="error"||this.errorTracker.viewErrored)&&this.send(he)})}),Z.on("viewend",function(he,ye){a()(Z.data,ye)}),Z.one("playerready",function(he){var ye=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=ye-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}),Z.longResumeTracker=new ci(We(Z)),Z.errorTracker=new ne(We(Z)),new et(We(Z)),Z.seekingTracker=new Xe(We(Z)),Z.playheadTime=new fe(We(Z)),Z.playbackHeartbeat=new Y(We(Z)),new Be(We(Z)),Z.watchTimeTracker=new ae(We(Z)),new ce(We(Z)),Z.adTracker=new Ne(We(Z)),new Oe(We(Z)),new Ae(We(Z)),new Ce(We(Z)),new ft(We(Z)),new fi(We(Z)),re.hlsjs&&Z.addHLSJS(re),re.dashjs&&Z.addDashJS(re),Z.emit("viewinit",re.data),Z}return O=X,w=[{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(V){var $=a()({},this.data);if($.video_source_is_live===void 0&&($.player_source_duration===1/0||$.video_source_duration===1/0?$.video_source_is_live=!0:($.player_source_duration>0||$.video_source_duration>0)&&($.video_source_is_live=!1)),$.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(Ee){$[Ee]=void 0}),$.video_source_url=$.video_source_url||$.player_source_url,$.video_source_url){var re=hi(n($.video_source_url),2),Z=re[0],oe=re[1];$.video_source_domain=oe,$.video_source_hostname=Z}delete $.ad_request_id,this.playbackEventDispatcher.send(V,$),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat()}},{key:"_updateStateData",value:function(){a()(this.data,this.getStateData()),this.playheadTime._updatePlayheadTime(),this._sanitizeData()}},{key:"_sanitizeData",value:function(){var V=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function($){var re=parseInt(V.data[$],10);V.data[$]=isNaN(re)?void 0:re}),["player_source_url","video_source_url"].forEach(function($){if(V.data[$]){var re=V.data[$].toLowerCase();re.indexOf("data:")!==0&&re.indexOf("blob:")!==0||(V.data[$]="MSE style URL")}})}},{key:"_resetVideoData",value:function(V,$){var re=this;Object.keys(this.data).forEach(function(Z){Z.indexOf("video_")===0&&delete re.data[Z]})}},{key:"_resetViewData",value:function(){var V=this;Object.keys(this.data).forEach(function($){$.indexOf("view_")===0&&delete V.data[$]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(V,$){delete this.data.player_error_code,delete this.data.player_error_message}},{key:"_initializeViewData",value:function(){var V=this,$=this.data.view_id=P(),re=function(){$===V.data.view_id&&l(V.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",re):re()}},{key:"_restartHeartBeat",value:function(){var V=this;window.clearTimeout(this._heartBeatTimeout),this.errorTracker.viewErrored||(this._heartBeatTimeout=window.setTimeout(function(){V.data.player_is_paused||V.emit("hb")},1e4))}},{key:"addHLSJS",value:function(V){V.hlsjs?this.hlsjs?this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=V.hlsjs,function($,re,Z){var oe=arguments.length>4?arguments[4]:void 0,Ee=$.log,ve=$.utils.secondsToMs,pe=function(De){var me,_e=parseInt(oe.version);return _e===1&&De.programDateTime!==null&&(me=De.programDateTime),_e===0&&De.pdt!==null&&(me=De.pdt),me};if(v.exists()){var he=function(De,me){return $.emit(re,De,me)},ye=function(De,me){var _e=me.levels,ge=me.audioTracks,Te=me.url,Fe=me.stats,Ue=me.networkDetails,st=me.sessionData,tt={},ct={};_e.forEach(function(gt,Bt){tt[Bt]={width:gt.width,height:gt.height,bitrate:gt.bitrate,attrs:gt.attrs}}),ge.forEach(function(gt,Bt){ct[Bt]={name:gt.name,language:gt.lang,bitrate:gt.bitrate}});var ot=r(Fe),vt=ot.bytesLoaded,Ge=ot.requestStart,ht=ot.responseStart,cr=ot.responseEnd;he("requestcompleted",m(m({},g(st)),{},{request_event_type:De,request_bytes_loaded:vt,request_start:Ge,request_response_start:ht,request_response_end:cr,request_type:"manifest",request_hostname:o(Te),request_response_headers:t(Ue),request_rendition_lists:{media:tt,audio:ct,video:{}}}))};Z.on(oe.Events.MANIFEST_LOADED,ye);var be=function(De,me){var _e=me.details,ge=me.level,Te=me.networkDetails,Fe=me.stats,Ue=r(Fe),st=Ue.bytesLoaded,tt=Ue.requestStart,ct=Ue.responseStart,ot=Ue.responseEnd,vt=_e.fragments[_e.fragments.length-1],Ge=pe(vt)+ve(vt.duration);he("requestcompleted",{request_event_type:De,request_bytes_loaded:st,request_start:tt,request_response_start:ct,request_response_end:ot,request_current_level:ge,request_type:"manifest",request_hostname:o(_e.url),request_response_headers:t(Te),video_holdback:_e.holdBack&&ve(_e.holdBack),video_part_holdback:_e.partHoldBack&&ve(_e.partHoldBack),video_part_target_duration:_e.partTarget&&ve(_e.partTarget),video_target_duration:_e.targetduration&&ve(_e.targetduration),video_source_is_live:_e.live,player_manifest_newest_program_time:isNaN(Ge)?void 0:Ge})};Z.on(oe.Events.LEVEL_LOADED,be);var He=function(De,me){var _e=me.details,ge=me.networkDetails,Te=me.stats,Fe=r(Te),Ue=Fe.bytesLoaded,st=Fe.requestStart,tt=Fe.responseStart,ct=Fe.responseEnd;he("requestcompleted",{request_event_type:De,request_bytes_loaded:Ue,request_start:st,request_response_start:tt,request_response_end:ct,request_type:"manifest",request_hostname:o(_e.url),request_response_headers:t(ge)})};Z.on(oe.Events.AUDIO_TRACK_LOADED,He);var je=function(De,me){var _e=me.stats,ge=me.networkDetails,Te=me.frag;_e=_e||Te.stats;var Fe=r(_e),Ue=Fe.bytesLoaded,st=Fe.requestStart,tt=Fe.responseStart,ct=Fe.responseEnd,ot=t(ge),vt=ot==null?void 0:ot["x-request-id"],Ge={request_event_type:De,request_bytes_loaded:Ue,request_start:st,request_response_start:tt,request_response_end:ct,request_hostname:ge?o(ge.responseURL):void 0,request_id:vt,request_response_headers:ot,request_media_duration:Te.duration,request_url:ge==null?void 0:ge.responseURL};Te.type==="main"?(Ge.request_type="media",Ge.request_current_level=Te.level,Ge.request_video_width=(Z.levels[Te.level]||{}).width,Ge.request_video_height=(Z.levels[Te.level]||{}).height,Ge.request_labeled_bitrate=(Z.levels[Te.level]||{}).bitrate):Ge.request_type=Te.type,he("requestcompleted",Ge)};Z.on(oe.Events.FRAG_LOADED,je);var at=function(De,me){var _e=me.frag,ge=_e.start,Te={currentFragmentPDT:pe(_e),currentFragmentStart:ve(ge)};he("fragmentchange",Te)};Z.on(oe.Events.FRAG_CHANGED,at);var Se=function(De,me){var _e=me.type,ge=me.details,Te=me.response,Fe=me.fatal,Ue=me.context,st=me.frag;if(ge===oe.ErrorDetails.MANIFEST_LOAD_ERROR||ge===oe.ErrorDetails.MANIFEST_LOAD_TIMEOUT||ge===oe.ErrorDetails.FRAG_LOAD_ERROR||ge===oe.ErrorDetails.FRAG_LOAD_TIMEOUT||ge===oe.ErrorDetails.LEVEL_LOAD_ERROR||ge===oe.ErrorDetails.LEVEL_LOAD_TIMEOUT){var tt=st&&st.url||Ue&&Ue.url||"";he("requestfailed",{request_error:ge,request_url:tt,request_hostname:o(tt),request_type:ge===oe.ErrorDetails.FRAG_LOAD_ERROR||ge===oe.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":"manifest",request_error_code:Te&&Te.code,request_error_text:Te&&Te.text})}Fe&&he("error",{player_error_code:_e,player_error_message:ge})};Z.on(oe.Events.ERROR,Se);var Ve=function(De,me){var _e=me.frag,ge=_e&&_e._url||"";he("requestcanceled",{request_event_type:De,request_url:ge,request_type:"media",request_hostname:o(ge)})};Z.on(oe.Events.FRAG_LOAD_EMERGENCY_ABORTED,Ve);var Qe=function(De,me){var _e=me.level,ge=Z.levels[_e];if(ge&&ge.attrs&&ge.attrs.BANDWIDTH){var Te,Fe=ge.attrs.BANDWIDTH,Ue=parseFloat(ge.attrs["FRAME-RATE"]);isNaN(Ue)||(Te=Ue),Fe?he("renditionchange",{video_source_fps:Te,video_source_bitrate:Fe,video_source_width:ge.width,video_source_height:ge.height,video_source_rendition_name:ge.name,video_source_codec:ge==null?void 0:ge.videoCodec}):Ee.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};Z.on(oe.Events.LEVEL_SWITCHED,Qe),Z._stopMuxMonitor=function(){Z.off(oe.Events.MANIFEST_LOADED,ye),Z.off(oe.Events.LEVEL_LOADED,be),Z.off(oe.Events.AUDIO_TRACK_LOADED,He),Z.off(oe.Events.FRAG_LOADED,je),Z.off(oe.Events.FRAG_CHANGED,at),Z.off(oe.Events.ERROR,Se),Z.off(oe.Events.FRAG_LOAD_EMERGENCY_ABORTED,Ve),Z.off(oe.Events.LEVEL_SWITCHED,Qe),Z.off(oe.Events.DESTROYING,Z._stopMuxMonitor),delete Z._stopMuxMonitor},Z.on(oe.Events.DESTROYING,Z._stopMuxMonitor)}else Ee.warn("performance timing not supported. Not tracking HLS.js.")}(this.mux,this.id,V.hlsjs,{},V.Hls||window.Hls)):this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")}},{key:"removeHLSJS",value:function(){var V;this.hlsjs&&((V=this.hlsjs)&&typeof V._stopMuxMonitor=="function"&&V._stopMuxMonitor(),this.hlsjs=void 0)}},{key:"addDashJS",value:function(V){V.dashjs?this.dashjs?this.mux.log.warn("An instance of Dash.js is already being monitored for this player."):(this.dashjs=V.dashjs,function($,re,Z){var oe=$.log;if(Z&&Z.on){var Ee=function(Se,Ve){return $.emit(re,Se,Ve)},ve=function(Se){var Ve=Se.type,Qe=(Se.data||{}).url;Ee("requestcompleted",{request_event_type:Ve,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:o(Qe),request_url:Qe})};Z.on("manifestLoaded",ve);var pe={},he=function(Se){var Ve=Se.type,Qe=Se.fragmentModel,De=(Se.chunk||{}).mediaInfo||{},me=De.type,_e=De.bitrateList,ge={};(_e=_e||[]).forEach(function(Ge,ht){ge[ht]={},ge[ht].width=Ge.width,ge[ht].height=Ge.height,ge[ht].bitrate=Ge.bandwidth,ge[ht].attrs={}}),me==="video"?pe.video=ge:me==="audio"?pe.audio=ge:pe.media=ge;var Te=b(Qe,Z),Fe=Te.requestStart,Ue=Te.requestResponseStart,st=Te.requestResponseEnd,tt=Te.requestResponseHeaders,ct=Te.requestMediaDuration,ot=Te.requestHostname,vt=Te.requestUrl;Ee("requestcompleted",{request_event_type:Ve,request_start:Fe,request_response_start:Ue,request_response_end:st,request_bytes_loaded:-1,request_type:me+"_init",request_response_headers:tt,request_hostname:ot,request_url:vt,request_media_duration:ct,request_rendition_lists:pe})};Z.on("initFragmentLoaded",he);var ye=function(Se){var Ve=Se.type,Qe=Se.fragmentModel,De=Se.chunk||{},me=De.mediaInfo,_e=De.start,ge=(me||{}).type,Te=b(Qe,Z),Fe=Te.requestStart,Ue=Te.requestResponseStart,st=Te.requestResponseEnd,tt=Te.requestBytesLoaded,ct=Te.requestResponseHeaders,ot=Te.requestMediaDuration,vt=Te.requestHostname,Ge=Te.requestUrl,ht=R(ge,Z),cr=ht.currentLevel,gt=ht.renditionWidth,Bt=ht.renditionHeight,Ki=ht.renditionBitrate;Ee("requestcompleted",{request_event_type:Ve,request_start:Fe,request_response_start:Ue,request_response_end:st,request_bytes_loaded:tt,request_type:ge,request_response_headers:ct,request_hostname:vt,request_url:Ge,request_media_start_time:_e,request_media_duration:ot,request_current_level:cr,request_labeled_bitrate:Ki,request_video_width:gt,request_video_height:Bt})};Z.on("mediaFragmentLoaded",ye);var be={video:void 0,audio:void 0,totalBitrate:void 0},He=function(){if(be.video&&typeof be.video.bitrate=="number"){if(be.video.width&&be.video.height){var Se=be.video.bitrate;return be.audio&&typeof be.audio.bitrate=="number"&&(Se+=be.audio.bitrate),Se!==be.totalBitrate?(be.totalBitrate=Se,{video_source_bitrate:Se,video_source_height:be.video.height,video_source_width:be.video.width,video_source_codec:I(be.video.codec)}):void 0}oe.warn("have bitrate info for video but missing width/height")}},je=function(Se,Ve,Qe){if(typeof Se.newQuality=="number"){var De=Se.mediaType;if(De==="audio"||De==="video"){var me=Z.getBitrateInfoListFor(De).find(function(ge){return ge.qualityIndex===Se.newQuality});if(me&&typeof me.bitrate=="number"){be[De]=y(y({},me),{},{codec:Z.getCurrentTrackFor(De).codec});var _e=He();_e&&Ee("renditionchange",_e)}else oe.warn("missing bitrate info for ".concat(De))}}else oe.warn("missing evt.newQuality in qualityChangeRendered event",Se)};Z.on("qualityChangeRendered",je);var at=function(Se){var Ve=Se.error,Qe=Se.event,De=(Qe=Qe||{}).request||{},me=M().event&&M().event.currentTarget||{};Ee("requestfailed",{request_error:Ve+"_"+Qe.id+"_"+De.type,request_url:Qe.url,request_hostname:o(Qe.url),request_type:De.mediaType,request_error_code:me.status,request_error_type:me.statusText})};Z.on("error",at),Z._stopMuxMonitor=function(){Z.off("manifestLoaded",ve),Z.off("initFragmentLoaded",he),Z.off("mediaFragmentLoaded",ye),Z.off("qualityChangeRendered",je),Z.off("error",at),delete Z._stopMuxMonitor}}else oe.warn("Invalid dash.js player reference. Monitoring blocked.")}(this.mux,this.id,V.dashjs)):this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")}},{key:"removeDashJS",value:function(){var V;this.dashjs&&((V=this.dashjs)&&typeof V._stopMuxMonitor=="function"&&V._stopMuxMonitor(),this.dashjs=void 0)}}],w&&Ir(O.prototype,w),W&&Ir(O,W),Object.defineProperty(O,"prototype",{writable:!1}),X}(H),yi=pi,Ei=C(153),Ft=C.n(Ei);function ur(U){return ur=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(O){return typeof O}:function(O){return O&&typeof Symbol=="function"&&O.constructor===Symbol&&O!==Symbol.prototype?"symbol":typeof O},ur(U)}function Or(U,O){return function(w){if(Array.isArray(w))return w}(U)||function(w,W){var G=w==null?null:typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(G!=null){var X,V,$=[],re=!0,Z=!1;try{for(G=G.call(w);!(re=(X=G.next()).done)&&($.push(X.value),!W||$.length!==W);re=!0);}catch(oe){Z=!0,V=oe}finally{try{re||G.return==null||G.return()}finally{if(Z)throw V}}return $}}(U,O)||function(w,W){if(w){if(typeof w=="string")return Cr(w,W);var G=Object.prototype.toString.call(w).slice(8,-1);return G==="Object"&&w.constructor&&(G=w.constructor.name),G==="Map"||G==="Set"?Array.from(w):G==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(G)?Cr(w,W):void 0}}(U,O)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
1
+ "use strict";(()=>{var Wi=Object.create;var kr=Object.defineProperty;var Gi=Object.getOwnPropertyDescriptor;var Hi=Object.getOwnPropertyNames;var ji=Object.getPrototypeOf,Vi=Object.prototype.hasOwnProperty;var Fr=(J,ee)=>()=>(ee||J((ee={exports:{}}).exports,ee),ee.exports);var Yi=(J,ee,ie,se)=>{if(ee&&typeof ee=="object"||typeof ee=="function")for(let z of Hi(ee))!Vi.call(J,z)&&z!==ie&&kr(J,z,{get:()=>ee[z],enumerable:!(se=Gi(ee,z))||se.enumerable});return J};var zt=(J,ee,ie)=>(ie=J!=null?Wi(ji(J)):{},Yi(ee||!J||!J.__esModule?kr(ie,"default",{value:J,enumerable:!0}):ie,J));var Ur=Fr((Qt,vr)=>{(function(){var J,ee;J=this,ee=function(){return function(){var ie={80:function(N,T,C){N.exports=C(728).default},728:function(N,T,C){"use strict";C.d(T,{default:function(){return Ni}});var L=C(48),M=C.n(L),P=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(U){var O=16*Math.random()|0;return(U==="x"?O:3&O|8).toString(16)})},B=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},A=function(U){return U&&U.nodeName!==void 0?(U.muxId||(U.muxId=U.id||B()),U.muxId):U},D=function(U){var O;U&&U.nodeName!==void 0?U=A(O=U):O=document.querySelector(U);var w=O&&O.nodeName?O.nodeName.toLowerCase():"";return[O,U,w]},x=C(640),_=C.n(x),S=_().methodFactory;_().methodFactory=function(U,O,w){var W=S(U,O,w);return function(){for(var G=["[mux]"],X=0;X<arguments.length;X++)G.push(arguments[X]);W.apply(void 0,G)}},_().setLevel(_().getLevel());var d=_();function E(){return(M().doNotTrack||M().navigator&&M().navigator.doNotTrack)==="1"}var p={now:function(){var U=M().performance,O=U&&U.timing,w=O&&O.navigationStart,W=typeof w=="number"&&typeof U.now=="function"?w+U.now():Date.now();return Math.round(W)}},h=C(678),a=C.n(h),o=function(U){return n(U)[0]},n=function(U){if(typeof U!="string"||U==="")return["localhost"];var O,w=(U.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/)||[])[4];return w&&(O=(w.match(/[^\.]+\.[^\.]+$/)||[])[0]),[w,O]},v={exists:function(){var U=M().performance;return(U&&U.timing)!==void 0},domContentLoadedEventEnd:function(){var U=M().performance,O=U&&U.timing;return O&&O.domContentLoadedEventEnd},navigationStart:function(){var U=M().performance,O=U&&U.timing;return O&&O.navigationStart}};function l(U,O,w){w=w===void 0?1:w,U[O]=U[O]||0,U[O]+=w}var i=["x-cdn","content-type","x-request-id"];function u(U){var O={};return(U=U||"").trim().split(/[\r\n]+/).forEach(function(w){if(w){var W=w.split(": "),G=W.shift();G&&(i.indexOf(G.toLowerCase())>=0||G.toLowerCase().indexOf("x-litix-")===0)&&(O[G]=W.join(": "))}}),O}var g=function(U){var O={};for(var w in U){var W=U[w];W["DATA-ID"].search("io.litix.data.")!==-1&&(O[W["DATA-ID"].replace("io.litix.data.","")]=W.VALUE)}return O};function c(U,O){var w=Object.keys(U);if(Object.getOwnPropertySymbols){var W=Object.getOwnPropertySymbols(U);O&&(W=W.filter(function(G){return Object.getOwnPropertyDescriptor(U,G).enumerable})),w.push.apply(w,W)}return w}function m(U){for(var O=1;O<arguments.length;O++){var w=arguments[O]!=null?arguments[O]:{};O%2?c(Object(w),!0).forEach(function(W){e(U,W,w[W])}):Object.getOwnPropertyDescriptors?Object.defineProperties(U,Object.getOwnPropertyDescriptors(w)):c(Object(w)).forEach(function(W){Object.defineProperty(U,W,Object.getOwnPropertyDescriptor(w,W))})}return U}function e(U,O,w){return O in U?Object.defineProperty(U,O,{value:w,enumerable:!0,configurable:!0,writable:!0}):U[O]=w,U}var r=function(U){if(!U)return{};var O=v.navigationStart(),w=U.loading,W=w?w.start:U.trequest,G=w?w.first:U.tfirst,X=w?w.end:U.tload;return{bytesLoaded:U.total,requestStart:Math.round(O+W),responseStart:Math.round(O+G),responseEnd:Math.round(O+X)}},t=function(U){if(U&&typeof U.getAllResponseHeaders=="function")return u(U.getAllResponseHeaders())};function s(U,O){var w=Object.keys(U);if(Object.getOwnPropertySymbols){var W=Object.getOwnPropertySymbols(U);O&&(W=W.filter(function(G){return Object.getOwnPropertyDescriptor(U,G).enumerable})),w.push.apply(w,W)}return w}function y(U){for(var O=1;O<arguments.length;O++){var w=arguments[O]!=null?arguments[O]:{};O%2?s(Object(w),!0).forEach(function(W){f(U,W,w[W])}):Object.getOwnPropertyDescriptors?Object.defineProperties(U,Object.getOwnPropertyDescriptors(w)):s(Object(w)).forEach(function(W){Object.defineProperty(U,W,Object.getOwnPropertyDescriptor(w,W))})}return U}function f(U,O,w){return O in U?Object.defineProperty(U,O,{value:w,enumerable:!0,configurable:!0,writable:!0}):U[O]=w,U}var b=function(U,O){if(!U||typeof U.getRequests!="function")return{};var w=U.getRequests({state:"executed"});if(w.length===0)return{};var W,G=w[w.length-1],X=o(G.url),V=G.url,$=G.bytesLoaded,re=new Date(G.requestStartDate).getTime(),Z=new Date(G.firstByteDate).getTime(),oe=new Date(G.requestEndDate).getTime(),Ee=isNaN(G.duration)?0:G.duration,ve=typeof O.getMetricsFor=="function"?O.getMetricsFor(G.mediaType).HttpList:O.getDashMetrics().getHttpRequests(G.mediaType);return ve.length>0&&(W=u(ve[ve.length-1]._responseHeaders||"")),{requestStart:re,requestResponseStart:Z,requestResponseEnd:oe,requestBytesLoaded:$,requestResponseHeaders:W,requestMediaDuration:Ee,requestHostname:X,requestUrl:V}},R=function(U,O){var w=O.getQualityFor(U),W=O.getCurrentTrackFor(U).bitrateList;return W?{currentLevel:w,renditionWidth:W[w].width||null,renditionHeight:W[w].height||null,renditionBitrate:W[w].bandwidth}:{}},I=function(U){var O;return(O=U.match(/.*codecs\*?="(.*)"/))===null||O===void 0?void 0:O[1]};function k(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}var F=0,K=function(){function U(){(function(G,X){if(!(G instanceof X))throw new TypeError("Cannot call a class as a function")})(this,U)}var O,w,W;return O=U,w=[{key:"on",value:function(G,X,V){return X._eventEmitterGuid=X._eventEmitterGuid||++F,this._listeners=this._listeners||{},this._listeners[G]=this._listeners[G]||[],V&&(X=X.bind(V)),this._listeners[G].push(X),X}},{key:"off",value:function(G,X){var V=this._listeners&&this._listeners[G];V&&V.forEach(function($,re){$._eventEmitterGuid===X._eventEmitterGuid&&V.splice(re,1)})}},{key:"one",value:function(G,X,V){var $=this;X._eventEmitterGuid=X._eventEmitterGuid||++F;var re=function Z(){$.off(G,Z),X.apply(V||this,arguments)};re._eventEmitterGuid=X._eventEmitterGuid,this.on(G,re)}},{key:"emit",value:function(G,X){var V=this;if(this._listeners){X=X||{};var $=this._listeners["before*"]||[],re=this._listeners[G]||[],Z=this._listeners["after"+G]||[],oe=function(Ee,ve){(Ee=Ee.slice()).forEach(function(pe){pe.call(V,{type:G},ve)})};oe($,X),oe(re,X),oe(Z,X)}}}],w&&k(O.prototype,w),W&&k(O,W),Object.defineProperty(O,"prototype",{writable:!1}),U}(),H=K;function j(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}var Y=function(){function U(G){var X=this;(function(V,$){if(!(V instanceof $))throw new TypeError("Cannot call a class as a function")})(this,U),this.pm=G,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,G.on("playing",function(){X._playheadShouldBeProgressing=!0}),G.on("play",this._startPlaybackHeartbeatInterval.bind(this)),G.on("playing",this._startPlaybackHeartbeatInterval.bind(this)),G.on("adbreakstart",this._startPlaybackHeartbeatInterval.bind(this)),G.on("adplay",this._startPlaybackHeartbeatInterval.bind(this)),G.on("adplaying",this._startPlaybackHeartbeatInterval.bind(this)),G.on("seeking",this._startPlaybackHeartbeatInterval.bind(this)),G.on("devicewake",this._startPlaybackHeartbeatInterval.bind(this)),G.on("viewstart",this._startPlaybackHeartbeatInterval.bind(this)),G.on("rebufferstart",this._startPlaybackHeartbeatInterval.bind(this)),G.on("pause",this._stopPlaybackHeartbeatInterval.bind(this)),G.on("ended",this._stopPlaybackHeartbeatInterval.bind(this)),G.on("viewend",this._stopPlaybackHeartbeatInterval.bind(this)),G.on("error",this._stopPlaybackHeartbeatInterval.bind(this)),G.on("aderror",this._stopPlaybackHeartbeatInterval.bind(this)),G.on("adpause",this._stopPlaybackHeartbeatInterval.bind(this)),G.on("adended",this._stopPlaybackHeartbeatInterval.bind(this)),G.on("adbreakend",this._stopPlaybackHeartbeatInterval.bind(this)),G.on("seeked",function(){G.data.player_is_paused?X._stopPlaybackHeartbeatInterval():X._startPlaybackHeartbeatInterval()}),G.on("timeupdate",function(){X._playbackHeartbeatInterval!==null&&G.emit("playbackheartbeat")}),G.on("devicesleep",function(V,$){X._playbackHeartbeatInterval!==null&&(M().clearInterval(X._playbackHeartbeatInterval),G.emit("playbackheartbeatend",{viewer_time:$.viewer_time}),X._playbackHeartbeatInterval=null)})}var O,w,W;return O=U,(w=[{key:"_startPlaybackHeartbeatInterval",value:function(){var G=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=M().setInterval(function(){G.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(M().clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}])&&j(O.prototype,w),W&&j(O,W),Object.defineProperty(O,"prototype",{writable:!1}),U}();function Q(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}function q(U,O,w){return O&&Q(U.prototype,O),w&&Q(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var ne=q(function U(O){var w=this;(function(W,G){if(!(W instanceof G))throw new TypeError("Cannot call a class as a function")})(this,U),O.on("viewinit",function(){w.viewErrored=!1}),O.on("error",function(W,G){try{var X=O.errorTranslator({player_error_code:G.player_error_code,player_error_message:G.player_error_message,player_error_context:G.player_error_context});X?(O.data.player_error_code=X.player_error_code||G.player_error_code,O.data.player_error_message=X.player_error_message||G.player_error_message,O.data.player_error_context=X.player_error_context||G.player_error_context,w.viewErrored=!0):(delete O.data.player_error_code,delete O.data.player_error_message,delete O.data.player_error_context)}catch(V){O.mux.log.warn("Exception in error translator callback.",V),w.viewErrored=!0}})});function te(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}var ae=function(){function U(G){(function(X,V){if(!(X instanceof V))throw new TypeError("Cannot call a class as a function")})(this,U),this.pm=G,this._watchTimeTrackerLastCheckedTime=null,G.on("playbackheartbeat",this._updateWatchTime.bind(this)),G.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}var O,w,W;return O=U,(w=[{key:"_updateWatchTime",value:function(G,X){var V=X.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=V),l(this.pm.data,"view_watch_time",V-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=V}},{key:"_clearWatchTimeState",value:function(G,X){this._updateWatchTime(G,X),this._watchTimeTrackerLastCheckedTime=null}}])&&te(O.prototype,w),W&&te(O,W),Object.defineProperty(O,"prototype",{writable:!1}),U}();function ue(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}var ce=function(){function U(G){(function(X,V){if(!(X instanceof V))throw new TypeError("Cannot call a class as a function")})(this,U),this.pm=G,this._playbackTimeTrackerLastPlayheadPosition=-1,G.on("playbackheartbeat",this._updatePlaybackTime.bind(this)),G.on("playbackheartbeatend",this._clearPlaybackTimeState.bind(this)),G.on("seeking",this._clearPlaybackTimeState.bind(this))}var O,w,W;return O=U,(w=[{key:"_updatePlaybackTime",value:function(){var G=this.pm.data.player_playhead_time;if(this._playbackTimeTrackerLastPlayheadPosition>=0&&G>this._playbackTimeTrackerLastPlayheadPosition){var X=G-this._playbackTimeTrackerLastPlayheadPosition;X<=1e3&&l(this.pm.data,"view_content_playback_time",X)}this._playbackTimeTrackerLastPlayheadPosition=G}},{key:"_clearPlaybackTimeState",value:function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1}}])&&ue(O.prototype,w),W&&ue(O,W),Object.defineProperty(O,"prototype",{writable:!1}),U}();function le(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}var fe=function(){function U(G){(function(V,$){if(!(V instanceof $))throw new TypeError("Cannot call a class as a function")})(this,U),this.pm=G;var X=this._updatePlayheadTime.bind(this);G.on("playbackheartbeat",X),G.on("playbackheartbeatend",X),G.on("timeupdate",X),G.on("destroy",function(){G.off("timeupdate",X)})}var O,w,W;return O=U,(w=[{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(G,X){var V=this,$=function(){V.pm.currentFragmentPDT&&V.pm.currentFragmentStart&&(V.pm.data.player_program_time=V.pm.currentFragmentPDT+V.pm.data.player_playhead_time-V.pm.currentFragmentStart)};if(X&&X.player_playhead_time)this.pm.data.player_playhead_time=X.player_playhead_time,$(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var re=this.pm.getPlayheadTime();re!==void 0&&(this.pm.data.player_playhead_time=re,$(),this._updateMaxPlayheadPosition())}}}])&&le(O.prototype,w),W&&le(O,W),Object.defineProperty(O,"prototype",{writable:!1}),U}();function de(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}function xe(U,O,w){return O&&de(U.prototype,O),w&&de(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var Ae=xe(function U(O){if(function(X,V){if(!(X instanceof V))throw new TypeError("Cannot call a class as a function")}(this,U),!O.disableRebufferTracking){var w,W=function(X,V){G(V),w=void 0},G=function(X){if(w){var V=X.viewer_time-w;l(O.data,"view_rebuffer_duration",V),w=X.viewer_time}O.data.view_watch_time>=0&&O.data.view_rebuffer_count>0&&(O.data.view_rebuffer_frequency=O.data.view_rebuffer_count/O.data.view_watch_time,O.data.view_rebuffer_percentage=O.data.view_rebuffer_duration/O.data.view_watch_time)};O.on("playbackheartbeat",function(X,V){return G(V)}),O.on("rebufferstart",function(X,V){w||(l(O.data,"view_rebuffer_count",1),w=V.viewer_time,O.one("rebufferend",W))}),O.on("viewinit",function(){w=void 0,O.off("rebufferend",W)})}});function Ie(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}var Re=function(){function U(G){var X=this;(function(V,$){if(!(V instanceof $))throw new TypeError("Cannot call a class as a function")})(this,U),this.pm=G,G.disableRebufferTracking||G.disablePlayheadRebufferTracking||(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,G.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),G.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),G.on("seeking",function(){X._cleanupRebufferTracker(null,{viewer_time:p.now()})}))}var O,w,W;return O=U,w=[{key:"_checkIfRebuffering",value:function(G,X){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing)this._cleanupRebufferTracker(G,X);else if(this._lastCheckedTime!==null)if(this._lastPlayheadTime===this.pm.data.player_playhead_time){var V=X.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&V>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=X.viewer_time}else this._cleanupRebufferTracker(G,X,!0);else this._prepareRebufferTrackerState(X.viewer_time)}},{key:"_clearRebufferTrackerState",value:function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null}},{key:"_prepareRebufferTrackerState",value:function(G){this._lastCheckedTime=G,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=G}},{key:"_cleanupRebufferTracker",value:function(G,X){var V=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:X.viewer_time});else{if(this._lastCheckedTime===null)return;var $=this.pm.data.player_playhead_time-this._lastPlayheadTime,re=X.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&$>0&&re-$>this.pm.minimumRebufferDuration&&(this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+re-$}))}V?this._prepareRebufferTrackerState(X.viewer_time):this._clearRebufferTrackerState()}}],w&&Ie(O.prototype,w),W&&Ie(O,W),Object.defineProperty(O,"prototype",{writable:!1}),U}(),Oe=Re;function Pe(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}var Ce=function(){function U(G){var X=this;(function(V,$){if(!(V instanceof $))throw new TypeError("Cannot call a class as a function")})(this,U),this.pm=G,G.on("viewinit",function(){var V=G.data,$=V.view_id;if(!V.view_program_changed){var re=function(Z,oe){var Ee=oe.viewer_time;Z.type==="playing"&&G.data.view_time_to_first_frame===void 0?X.calculateTimeToFirstFrame(Ee||p.now(),$):Z.type!=="adplaying"||G.data.view_time_to_first_frame!==void 0&&!X._inPrerollPosition()||X.calculateTimeToFirstFrame(Ee||p.now(),$)};G.one("playing",re),G.one("adplaying",re),G.one("viewend",function(){G.off("playing",re),G.off("adplaying",re)})}})}var O,w,W;return O=U,(w=[{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(G,X){X===this.pm.data.view_id&&(this.pm.watchTimeTracker._updateWatchTime(null,{viewer_time:G}),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))}}])&&Pe(O.prototype,w),W&&Pe(O,W),Object.defineProperty(O,"prototype",{writable:!1}),U}();function Le(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}function ke(U,O,w){return O&&Le(U.prototype,O),w&&Le(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var Be=ke(function U(O){var w=this;(function(W,G){if(!(W instanceof G))throw new TypeError("Cannot call a class as a function")})(this,U),O.on("viewinit",function(){w._lastPlayheadPosition=-1}),["pause","rebufferstart","seeking","error","adbreakstart","hb"].forEach(function(W){O.on(W,function(){if(w._lastPlayheadPosition>=0&&O.data.player_playhead_time>=0&&w._lastPlayerWidth>=0&&w._lastSourceWidth>0&&w._lastPlayerHeight>=0&&w._lastSourceHeight>0){var G=O.data.player_playhead_time-w._lastPlayheadPosition;if(G<0)return void(w._lastPlayheadPosition=-1);var X=Math.min(w._lastPlayerWidth/w._lastSourceWidth,w._lastPlayerHeight/w._lastSourceHeight),V=Math.max(0,X-1),$=Math.max(0,1-X);O.data.view_max_upscale_percentage=Math.max(O.data.view_max_upscale_percentage||0,V),O.data.view_max_downscale_percentage=Math.max(O.data.view_max_downscale_percentage||0,$),l(O.data,"view_total_content_playback_time",G),l(O.data,"view_total_upscaling",V*G),l(O.data,"view_total_downscaling",$*G)}w._lastPlayheadPosition=-1})}),["playing","hb"].forEach(function(W){O.on(W,function(){w._lastPlayheadPosition=O.data.player_playhead_time,w._lastPlayerWidth=O.data.player_width,w._lastPlayerHeight=O.data.player_height,w._lastSourceWidth=O.data.video_source_width,w._lastSourceHeight=O.data.video_source_height})})});function we(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}function Ye(U,O,w){return O&&we(U.prototype,O),w&&we(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var Xe=Ye(function U(O){var w=this;(function(W,G){if(!(W instanceof G))throw new TypeError("Cannot call a class as a function")})(this,U),this.isSeeking=!1,O.on("seeking",function(W,G){a()(O.data,G),w._lastSeekingTime=p.now(),w.isSeeking===!1&&(w.isSeeking=!0,O.send("seeking"))}),O.on("seeked",function(){w.isSeeking=!1;var W=w._lastSeekingTime||p.now(),G=p.now()-W;l(O.data,"view_seek_count",1),l(O.data,"view_seek_duration",G);var X=O.data.view_max_seek_time||0;O.data.view_max_seek_time=Math.max(X,G)}),O.on("viewend",function(){w.isSeeking=!1})});function rt(U,O){return function(w){if(Array.isArray(w))return w}(U)||function(w,W){var G=w==null?null:typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(G!=null){var X,V,$=[],re=!0,Z=!1;try{for(G=G.call(w);!(re=(X=G.next()).done)&&($.push(X.value),!W||$.length!==W);re=!0);}catch(oe){Z=!0,V=oe}finally{try{re||G.return==null||G.return()}finally{if(Z)throw V}}return $}}(U,O)||function(w,W){if(w){if(typeof w=="string")return ze(w,W);var G=Object.prototype.toString.call(w).slice(8,-1);return G==="Object"&&w.constructor&&(G=w.constructor.name),G==="Map"||G==="Set"?Array.from(w):G==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(G)?ze(w,W):void 0}}(U,O)||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 ze(U,O){(O==null||O>U.length)&&(O=U.length);for(var w=0,W=new Array(O);w<O;w++)W[w]=U[w];return W}function it(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}var nt=function(U,O){U.push(O),U.sort(function(w,W){return w.viewer_time-W.viewer_time})},Je=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],Ne=function(){function U(G){var X=this;(function($,re){if(!($ instanceof re))throw new TypeError("Cannot call a class as a function")})(this,U),this.pm=G,G.on("viewinit",function(){X.isAdBreak=!1,X._currentAdRequestNumber=0,X._currentAdResponseNumber=0,X._adRequests=[],X._adResponses=[],X._adHasPlayed=!1,X._wouldBeNewAdPlay=!0,X._prerollPlayTime=void 0}),Je.forEach(function($){return G.on($,X._updateAdData.bind(X))});var V=function(){X.isAdBreak=!1};G.on("adbreakstart",function(){X.isAdBreak=!0}),G.on("play",V),G.on("playing",V),G.on("viewend",V),G.on("adrequest",function($,re){re=a()({ad_request_id:"generatedAdRequestId"+X._currentAdRequestNumber++},re),nt(X._adRequests,re),l(G.data,"view_ad_request_count"),X.inPrerollPosition()&&(G.data.view_preroll_requested=!0,X._adHasPlayed||l(G.data,"view_preroll_request_count"))}),G.on("adresponse",function($,re){re=a()({ad_request_id:"generatedAdRequestId"+X._currentAdResponseNumber++},re),nt(X._adResponses,re);var Z=X.findAdRequest(re.ad_request_id);Z&&l(G.data,"view_ad_request_time",Math.max(0,re.viewer_time-Z.viewer_time))}),G.on("adplay",function($,re){X._adHasPlayed=!0,X._wouldBeNewAdPlay&&(X._wouldBeNewAdPlay=!1,l(G.data,"view_ad_played_count")),X.inPrerollPosition()&&!G.data.view_preroll_played&&(G.data.view_preroll_played=!0,X._adRequests.length>0&&(G.data.view_preroll_request_time=Math.max(0,re.viewer_time-X._adRequests[0].viewer_time)),G.data.view_start&&(G.data.view_startup_preroll_request_time=Math.max(0,re.viewer_time-G.data.view_start)),X._prerollPlayTime=re.viewer_time)}),G.on("adplaying",function($,re){X.inPrerollPosition()&&G.data.view_preroll_load_time===void 0&&X._prerollPlayTime!==void 0&&(G.data.view_preroll_load_time=re.viewer_time-X._prerollPlayTime,G.data.view_startup_preroll_load_time=re.viewer_time-X._prerollPlayTime)}),G.on("adended",function(){X._wouldBeNewAdPlay=!0}),G.on("aderror",function(){X._wouldBeNewAdPlay=!0})}var O,w,W;return O=U,(w=[{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(G){for(var X=0;X<this._adRequests.length;X++)if(this._adRequests[X].ad_request_id===G)return this._adRequests[X]}},{key:"_updateAdData",value:function(G,X){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&X.ad_tag_url){var V=rt(n(X.ad_tag_url),2),$=V[0],re=V[1];this.pm.data.view_preroll_ad_tag_domain=re,this.pm.data.view_preroll_ad_tag_hostname=$}if(!this.pm.data.view_preroll_ad_asset_hostname&&X.ad_asset_url){var Z=rt(n(X.ad_asset_url),2),oe=Z[0],Ee=Z[1];this.pm.data.view_preroll_ad_asset_domain=Ee,this.pm.data.view_preroll_ad_asset_hostname=oe}}}}])&&it(O.prototype,w),W&&it(O,W),Object.defineProperty(O,"prototype",{writable:!1}),U}();function Ke(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}function Ze(U,O,w){return O&&Ke(U.prototype,O),w&&Ke(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var ft=Ze(function U(O){var w,W;(function($,re){if(!($ instanceof re))throw new TypeError("Cannot call a class as a function")})(this,U);var G=function(){O.disableRebufferTracking||w&&(l(O.data,"view_waiting_rebuffer_duration",p.now()-w),w=!1,M().clearInterval(W))},X=!1,V=function(){X=!1,G()};O.on("waiting",function(){X&&(O.disableRebufferTracking||(l(O.data,"view_waiting_rebuffer_count",1),w=p.now(),W=M().setInterval(function(){if(w){var $=p.now();l(O.data,"view_waiting_rebuffer_duration",$-w),w=$}},250)))}),O.on("playing",function(){G(),X=!0}),O.on("pause",V),O.on("seeking",V)});function Me(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}function qe(U,O,w){return O&&Me(U.prototype,O),w&&Me(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var et=qe(function U(O){var w=this;(function(X,V){if(!(X instanceof V))throw new TypeError("Cannot call a class as a function")})(this,U);var W=function(){w.lastWallClockTime=p.now(),O.on("before*",G)},G=function(X){var V=p.now(),$=w.lastWallClockTime;w.lastWallClockTime=V,V-$>3e4&&(O.emit("devicesleep",{viewer_time:$}),a()(O.data,{viewer_time:$}),O.send("devicesleep"),O.emit("devicewake",{viewer_time:V}),a()(O.data,{viewer_time:V}),O.send("devicewake"))};O.one("playbackheartbeat",W),O.on("playbackheartbeatend",function(){O.off("before*",G),O.one("playbackheartbeat",W)})}),_t=C(375),mt=C(655),pt=C.n(mt),Rt="muxData",Tt=function(){var U;try{U=_t.parse(pt().get(Rt)||"")}catch{U={}}return U},Gt=function(U){try{pt().set(Rt,_t.stringify(U),{expires:7300})}catch{}},It=function(){var U=Tt();return U.mux_viewer_id=U.mux_viewer_id||P(),U.msn=U.msn||Math.random(),Gt(U),{mux_viewer_id:U.mux_viewer_id,mux_sample_number:U.msn}};function rr(U,O){var w=O.beaconCollectionDomain,W=O.beaconDomain;if(w)return"https://"+w;var G=W||"litix.io";return(U=U||"inferred").match(/^[a-z0-9]+$/)?"https://"+U+"."+G:"https://img.litix.io/a.gif"}var Ot=function(){var U;switch(St()){case"cellular":U="cellular";break;case"ethernet":U="wired";break;case"wifi":U="wifi";break;case void 0:break;default:U="other"}return U},St=function(){var U=M().navigator,O=U&&(U.connection||U.mozConnection||U.webkitConnection);return O&&O.type};Ot.getConnectionFromAPI=St;var lt=Ot,Ht=jt({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"}),Ct=jt({ad:"ad",ag:"aggregate",ap:"api",al:"application",ar:"architecture",as:"asset",au:"autoplay",av:"average",bi:"bitrate",br:"break",bw:"browser",by:"bytes",ca:"cached",cb:"cancel",cc:"codec",cd:"code",cg:"category",ch:"changed",cn:"config",co:"count",ce:"counter",cp:"complete",cr:"creative",ct:"content",cu:"current",cx:"connection",cz:"context",dg:"downscaling",dm:"domain",dn:"cdn",do:"downscale",dr:"drm",dp:"dropped",du:"duration",dv:"device",ec:"encoding",ed:"edge",en:"end",eg:"engine",em:"embed",er:"error",es:"errorcode",et:"errortext",ee:"event",ev:"events",ex:"expires",ep:"experiments",fi:"first",fm:"family",ft:"format",fp:"fps",fq:"frequency",fr:"frame",fs:"fullscreen",hb:"holdback",he:"headers",ho:"host",hn:"hostname",ht:"height",id:"id",ii:"init",in:"instance",ip:"ip",is:"is",ke:"key",la:"language",lb:"labeled",le:"level",li:"live",ld:"loaded",lo:"load",ls:"lists",lt:"latency",ma:"max",md:"media",me:"message",mf:"manifest",mi:"mime",ml:"midroll",mm:"min",mn:"manufacturer",mo:"model",mx:"mux",ne:"newest",nm:"name",no:"number",on:"on",os:"os",pa:"paused",pb:"playback",pd:"producer",pe:"percentage",pf:"played",pg:"program",ph:"playhead",pi:"plugin",pl:"preroll",pn:"playing",po:"poster",pr:"preload",ps:"position",pt:"part",py:"property",ra:"rate",rd:"requested",re:"rebuffer",rf:"rendition",rm:"remote",ro:"ratio",rp:"response",rq:"request",rs:"requests",sa:"sample",se:"session",sk:"seek",sm:"stream",so:"source",sq:"sequence",sr:"series",st:"start",su:"startup",sv:"server",sw:"software",ta:"tag",tc:"tech",te:"text",tg:"target",th:"throughput",ti:"time",tl:"total",to:"to",tt:"title",ty:"type",ug:"upscaling",un:"universal",up:"upscale",ur:"url",us:"user",va:"variant",vd:"viewed",vi:"video",ve:"version",vw:"view",vr:"viewer",wd:"width",wa:"watch",wt:"waiting"});function jt(U){var O={};for(var w in U)U.hasOwnProperty(w)&&(O[U[w]]=w);return O}function Mt(U){var O={},w={};return Object.keys(U).forEach(function(W){var G=!1;if(U.hasOwnProperty(W)&&U[W]!==void 0){var X=W.split("_"),V=X[0],$=Ht[V];$||(d.info("Data key word `"+X[0]+"` not expected in "+W),$=V+"_"),X.splice(1).forEach(function(re){re==="url"&&(G=!0),Ct[re]?$+=Ct[re]:Number(re)&&Math.floor(Number(re))===Number(re)?$+=re:(d.info("Data key word `"+re+"` not expected in "+W),$+="_"+re+"_")}),G?w[$]=U[W]:O[$]=U[W]}}),a()(O,w)}var ir={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},nr=["hb","requestcompleted","requestfailed","requestcanceled"],ar="https://img.litix.io",ut=function(U){var O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this._beaconUrl=U||ar,this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=a()({},ir,O)};ut.prototype.queueEvent=function(U,O){var w=a()({},O);return(this._eventQueue.length<=this._options.maxQueueLength||U==="eventrateexceeded")&&(this._eventQueue.push(w),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength)},ut.prototype.flushEvents=function(){var U=arguments.length>0&&arguments[0]!==void 0&&arguments[0];U&&this._eventQueue.length===1?this._eventQueue.pop():(this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending())},ut.prototype.destroy=function(){var U=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,U?this._clearBeaconQueue():this.flushEvents(),M().clearTimeout(this._sendTimeout)},ut.prototype._clearBeaconQueue=function(){var U=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,O=this._eventQueue.slice(U);U>0&&a()(O[O.length-1],Mt({mux_view_message:"event queue truncated"}));var w=this._createPayload(O);wt(this._beaconUrl,w,!0,function(){})},ut.prototype._sendBeaconQueue=function(){var U=this;if(!this._postInFlight){var O=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0;var w=this._createPayload(O),W=p.now();wt(this._beaconUrl,w,!1,function(G,X){X?(U._eventQueue=O.concat(U._eventQueue),U._failureCount+=1,d.info("Error sending beacon: "+X)):U._failureCount=0,U._roundTripTime=p.now()-W,U._postInFlight=!1})}},ut.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var U=Math.pow(2,this._failureCount-1);return(1+(U*=Math.random()))*this._options.baseTimeBetweenBeacons},ut.prototype._startBeaconSending=function(){var U=this;M().clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=M().setTimeout(function(){U._eventQueue.length&&U._sendBeaconQueue(),U._startBeaconSending()},this._getNextBeaconTime()))},ut.prototype._createPayload=function(U){var O,w,W,G=this,X={transmission_timestamp:Math.round(p.now())};this._roundTripTime&&(X.rtt_ms=Math.round(this._roundTripTime));var V=function(){O=JSON.stringify({metadata:X,events:w||U}),W=O.length/1024},$=function(){return W<=G._options.maxPayloadKBSize};return V(),$()||(d.info("Payload size is too big ("+W+" kb). Removing unnecessary events."),w=U.filter(function(re){return nr.indexOf(re.e)===-1}),V()),$()||(d.info("Payload size still too big ("+W+" kb). Cropping fields.."),w.forEach(function(re){for(var Z in re){var oe=re[Z];typeof oe=="string"&&oe.length>51200&&(re[Z]=oe.substring(0,51200))}}),V()),O};var wt=function(U,O,w,W){if(w&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(U,O))W();else if(M().fetch)M().fetch(U,{method:"POST",body:O,headers:{"Content-Type":"text/plain"},keepalive:!0}).then(function(X){return W(null,X.ok?null:"Error")}).catch(function(X){return W(null,X)});else{if(M().XMLHttpRequest){var G=new(M()).XMLHttpRequest;return G.onreadystatechange=function(){if(G.readyState===4)return W(null,G.status!==200?"error":void 0)},G.open("POST",U),G.setRequestHeader("Content-Type","text/plain"),void G.send(O)}W()}},sr=ut;function or(U,O){return function(w){if(Array.isArray(w))return w}(U)||function(w,W){var G=w==null?null:typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(G!=null){var X,V,$=[],re=!0,Z=!1;try{for(G=G.call(w);!(re=(X=G.next()).done)&&($.push(X.value),!W||$.length!==W);re=!0);}catch(oe){Z=!0,V=oe}finally{try{re||G.return==null||G.return()}finally{if(Z)throw V}}return $}}(U,O)||function(w,W){if(w){if(typeof w=="string")return Dr(w,W);var G=Object.prototype.toString.call(w).slice(8,-1);return G==="Object"&&w.constructor&&(G=w.constructor.name),G==="Map"||G==="Set"?Array.from(w):G==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(G)?Dr(w,W):void 0}}(U,O)||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 Dr(U,O){(O==null||O>U.length)&&(O=U.length);for(var w=0,W=new Array(O);w<O;w++)W[w]=U[w];return W}function Lr(U,O){var w=Object.keys(U);if(Object.getOwnPropertySymbols){var W=Object.getOwnPropertySymbols(U);O&&(W=W.filter(function(G){return Object.getOwnPropertyDescriptor(U,G).enumerable})),w.push.apply(w,W)}return w}function Dt(U){for(var O=1;O<arguments.length;O++){var w=arguments[O]!=null?arguments[O]:{};O%2?Lr(Object(w),!0).forEach(function(W){Vt(U,W,w[W])}):Object.getOwnPropertyDescriptors?Object.defineProperties(U,Object.getOwnPropertyDescriptors(w)):Lr(Object(w)).forEach(function(W){Object.defineProperty(U,W,Object.getOwnPropertyDescriptor(w,W))})}return U}function kt(U){return kt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(O){return typeof O}:function(O){return O&&typeof Symbol=="function"&&O.constructor===Symbol&&O!==Symbol.prototype?"symbol":typeof O},kt(U)}function ni(U,O){if(!(U instanceof O))throw new TypeError("Cannot call a class as a function")}function Ar(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}function Vt(U,O,w){return O in U?Object.defineProperty(U,O,{value:w,enumerable:!0,configurable:!0,writable:!0}):U[O]=w,U}var ai=["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"],si=["adplay","adplaying","adpause","adfirstquartile","admidpoint","adthirdquartile","adended"],oi=["viewstart","error","ended","viewend"],li=function(){function U(G,X){var V,$,re,Z,oe,Ee,ve,pe,he,ye,be,He,je,at,Se,Ve=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};ni(this,U),Vt(this,"previousBeaconData",null),Vt(this,"lastEventTime",0),Vt(this,"rateLimited",!1),this.mux=G,this.envKey=X,this.options=Ve,this.eventQueue=new sr(rr(this.envKey,this.options)),this.sampleRate=(V=this.options.sampleRate)!==null&&V!==void 0?V:1,this.disableCookies=($=this.options.disableCookies)!==null&&$!==void 0&&$,this.respectDoNotTrack=(re=this.options.respectDoNotTrack)!==null&&re!==void 0&&re,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:(Z=this.options.platform)===null||Z===void 0?void 0:Z.name,viewer_application_version:(oe=this.options.platform)===null||oe===void 0?void 0:oe.version,viewer_application_engine:(Ee=this.options.platform)===null||Ee===void 0?void 0:Ee.layout,viewer_device_name:(ve=this.options.platform)===null||ve===void 0?void 0:ve.product,viewer_device_category:"",viewer_device_manufacturer:(pe=this.options.platform)===null||pe===void 0?void 0:pe.manufacturer,viewer_os_family:(he=this.options.platform)===null||he===void 0||(ye=he.os)===null||ye===void 0?void 0:ye.family,viewer_os_architecture:(be=this.options.platform)===null||be===void 0||(He=be.os)===null||He===void 0?void 0:He.architecture,viewer_os_version:(je=this.options.platform)===null||je===void 0||(at=je.os)===null||at===void 0?void 0:at.version,viewer_connection_type:lt(),page_url:M()===null||M()===void 0||(Se=M().location)===null||Se===void 0?void 0:Se.href},this.viewerData=this.disableCookies?{}:It()}var O,w,W;return O=U,(w=[{key:"send",value:function(G,X){var V;if(G){if(this.respectDoNotTrack&&E())return d.info("Not sending `"+G+"` because Do Not Track is enabled");if(!X||kt(X)!=="object")return d.error("A data object was expected in send() but was not provided");var $,re,Z=this.disableCookies?{}:($=Tt(),re=p.now(),$.session_start&&($.sst=$.session_start,delete $.session_start),$.session_id&&($.sid=$.session_id,delete $.session_id),$.session_expires&&($.sex=$.session_expires,delete $.session_expires),(!$.sex||$.sex<re)&&($.sid=P(),$.sst=re),$.sex=re+15e5,Gt($),{session_id:$.sid,session_start:$.sst,session_expires:$.sex}),oe=Dt(Dt(Dt(Dt(Dt({},this.pageLevelData),X),Z),this.viewerData),{},{event:G,env_key:this.envKey});oe.user_id&&(oe.viewer_user_id=oe.user_id,delete oe.user_id);var Ee=((V=oe.mux_sample_number)!==null&&V!==void 0?V:0)>=this.sampleRate,ve=Mt(this._deduplicateBeaconData(G,oe));if(this.lastEventTime=this.mux.utils.now(),Ee)return d.info("Not sending event due to sample rate restriction",G,oe,ve);if(this.envKey||d.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",G,oe,ve),!this.rateLimited){if(d.info("Sending event",G,oe,ve),this.rateLimited=!this.eventQueue.queueEvent(G,ve),this.mux.WINDOW_UNLOADING&&G==="viewend")this.eventQueue.destroy(!0);else if(this.mux.WINDOW_HIDDEN&&G==="hb"?this.eventQueue.flushEvents(!0):oi.indexOf(G)>=0&&this.eventQueue.flushEvents(),this.rateLimited)return oe.event="eventrateexceeded",ve=Mt(oe),this.eventQueue.queueEvent(oe.event,ve),d.error("Beaconing disabled due to rate limit.")}}}},{key:"destroy",value:function(){this.eventQueue.destroy(!1)}},{key:"_deduplicateBeaconData",value:function(G,X){var V=this,$={},re=X.view_id;if(!re||G==="viewstart"||G==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=6e5)$=Dt({},X),re&&(this.previousBeaconData=$),re&&G==="viewend"&&(this.previousBeaconData=null);else{var Z=G.indexOf("request")===0;Object.entries(X).forEach(function(oe){var Ee=or(oe,2),ve=Ee[0],pe=Ee[1];V.previousBeaconData&&(pe!==V.previousBeaconData[ve]||ai.indexOf(ve)>-1||V.objectHasChanged(Z,ve,pe,V.previousBeaconData[ve])||V.eventRequiresKey(G,ve))&&($[ve]=pe,V.previousBeaconData[ve]=pe)})}return $}},{key:"objectHasChanged",value:function(G,X,V,$){return!(!G||X.indexOf("request_")!==0||X!=="request_response_headers"&&kt(V)==="object"&&kt($)==="object"&&Object.keys(V||{}).length===Object.keys($||{}).length)}},{key:"eventRequiresKey",value:function(G,X){return G==="renditionchange"&&X.indexOf("video_source_")===0||!(X.indexOf("ad_")!==0||!si.includes(G))}}])&&Ar(O.prototype,w),W&&Ar(O,W),Object.defineProperty(O,"prototype",{writable:!1}),U}();function br(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}function ui(U,O,w){return O&&br(U.prototype,O),w&&br(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var fi=ui(function U(O){(function(Z,oe){if(!(Z instanceof oe))throw new TypeError("Cannot call a class as a function")})(this,U);var w=0,W=0,G=0,X=0,V=0,$=0,re=0;O.on("requestcompleted",function(Z,oe){var Ee,ve,pe=oe.request_start,he=oe.request_response_start,ye=oe.request_response_end,be=oe.request_bytes_loaded;if(X++,he?(Ee=he-pe,ve=ye-he):ve=ye-pe,ve>0&&be>0){var He=be/ve*8e3;V++,W+=be,G+=ve,O.data.view_min_request_throughput=Math.min(O.data.view_min_request_throughput||1/0,He),O.data.view_average_request_throughput=W/G*8e3,O.data.view_request_count=X,Ee>0&&(w+=Ee,O.data.view_max_request_latency=Math.max(O.data.view_max_request_latency||0,Ee),O.data.view_average_request_latency=w/V)}}),O.on("requestfailed",function(Z,oe){X++,$++,O.data.view_request_count=X,O.data.view_request_failed_count=$}),O.on("requestcanceled",function(Z,oe){X++,re++,O.data.view_request_count=X,O.data.view_request_canceled_count=re})});function Pr(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}function di(U,O,w){return O&&Pr(U.prototype,O),w&&Pr(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var ci=di(function U(O){var w=this;(function(W,G){if(!(W instanceof G))throw new TypeError("Cannot call a class as a function")})(this,U),O.on("before*",function(W,G){var X=G.viewer_time,V=p.now(),$=w._lastEventTime;if(w._lastEventTime=V,$&&V-$>36e5){var re=Object.keys(O.data).reduce(function(Z,oe){return oe.indexOf("video_")===0?a()(Z,function(Ee,ve,pe){return ve in Ee?Object.defineProperty(Ee,ve,{value:pe,enumerable:!0,configurable:!0,writable:!0}):Ee[ve]=pe,Ee}({},oe,O.data[oe])):Z},{});O.mux.log.info("Received event after at least an hour inactivity, creating a new view"),O.emit("viewinit",a()({viewer_time:X},re)),O.playbackHeartbeat._playheadShouldBeProgressing&&W.type!=="play"&&W.type!=="adbreakstart"&&(O.emit("play",{viewer_time:X}),W.type!=="playing"&&O.emit("playing",{viewer_time:X}))}})});function lr(U){return lr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(O){return typeof O}:function(O){return O&&typeof Symbol=="function"&&O.constructor===Symbol&&O!==Symbol.prototype?"symbol":typeof O},lr(U)}function hi(U,O){return function(w){if(Array.isArray(w))return w}(U)||function(w,W){var G=w==null?null:typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(G!=null){var X,V,$=[],re=!0,Z=!1;try{for(G=G.call(w);!(re=(X=G.next()).done)&&($.push(X.value),!W||$.length!==W);re=!0);}catch(oe){Z=!0,V=oe}finally{try{re||G.return==null||G.return()}finally{if(Z)throw V}}return $}}(U,O)||function(w,W){if(w){if(typeof w=="string")return Rr(w,W);var G=Object.prototype.toString.call(w).slice(8,-1);return G==="Object"&&w.constructor&&(G=w.constructor.name),G==="Map"||G==="Set"?Array.from(w):G==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(G)?Rr(w,W):void 0}}(U,O)||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 Rr(U,O){(O==null||O>U.length)&&(O=U.length);for(var w=0,W=new Array(O);w<O;w++)W[w]=U[w];return W}function Ir(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}function ur(U,O){return ur=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(w,W){return w.__proto__=W,w},ur(U,O)}function vi(U){var O=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 w,W=Yt(U);if(O){var G=Yt(this).constructor;w=Reflect.construct(W,arguments,G)}else w=W.apply(this,arguments);return gi(this,w)}}function gi(U,O){if(O&&(lr(O)==="object"||typeof O=="function"))return O;if(O!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return We(U)}function We(U){if(U===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return U}function Yt(U){return Yt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(O){return O.__proto__||Object.getPrototypeOf(O)},Yt(U)}var mi=["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"],pi=function(U){(function(V,$){if(typeof $!="function"&&$!==null)throw new TypeError("Super expression must either be null or a function");V.prototype=Object.create($&&$.prototype,{constructor:{value:V,writable:!0,configurable:!0}}),Object.defineProperty(V,"prototype",{writable:!1}),$&&ur(V,$)})(X,U);var O,w,W,G=vi(X);function X(V,$,re){var Z;(function(he,ye){if(!(he instanceof ye))throw new TypeError("Cannot call a class as a function")})(this,X),(Z=G.call(this)).DOM_CONTENT_LOADED_EVENT_END=v.domContentLoadedEventEnd(),Z.NAVIGATION_START=v.navigationStart(),Z.mux=V,Z.id=$,(re=a()({debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(he){return he}},re)).data=re.data||{},re.data.property_key&&(re.data.env_key=re.data.property_key,delete re.data.property_key),d.setLevel(re.debug?"debug":"warn"),Z.getPlayheadTime=re.getPlayheadTime,Z.getStateData=re.getStateData||function(){return{}},Z.getAdData=re.getAdData||function(){},Z.minimumRebufferDuration=re.minimumRebufferDuration,Z.sustainedRebufferThreshold=re.sustainedRebufferThreshold,Z.playbackHeartbeatTime=re.playbackHeartbeatTime,Z.disableRebufferTracking=re.disableRebufferTracking,Z.disableRebufferTracking&&Z.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."),Z.disablePlayheadRebufferTracking=re.disablePlayheadRebufferTracking,Z.errorTranslator=re.errorTranslator,Z.playbackEventDispatcher=new li(V,re.data.env_key,re),Z.data={player_instance_id:P(),mux_sample_rate:re.sampleRate,beacon_domain:re.beaconCollectionDomain?re.beaconCollectionDomain:re.beaconDomain},Z.data.view_sequence_number=1,Z.data.player_sequence_number=1,Z.oldEmit=Z.emit,Z.emit=function(he,ye){ye=a()({viewer_time:this.mux.utils.now()},ye),this.oldEmit(he,ye)};var oe=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(We(Z));Z.on("viewinit",function(he,ye){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),a()(this.data,ye),this._initializeViewData(),this.one("play",oe),this.one("adbreakstart",oe)});var Ee=function(he){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",he)}.bind(We(Z));if(Z.on("videochange",function(he,ye){Ee(ye)}),Z.on("programchange",function(he,ye){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."),Ee(a()(ye,{view_program_changed:!0})),oe(),this.emit("play"),this.emit("playing")}),Z.on("fragmentchange",function(he,ye){this.currentFragmentPDT=ye.currentFragmentPDT,this.currentFragmentStart=ye.currentFragmentStart}),Z.on("destroy",Z.destroy),typeof window!="undefined"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var ve=function(){var he=Z.data.view_start!==void 0;Z.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",he&&Z.mux.WINDOW_HIDDEN&&(Z.data.player_is_paused||Z.emit("hb"))};window.addEventListener("visibilitychange",ve,!1);var pe=function(he){he.persisted||Z.destroy()};window.addEventListener("pagehide",pe,!1),Z.on("destroy",function(){window.removeEventListener("visibilitychange",ve),window.removeEventListener("pagehide",pe)})}return Z.on("playerready",function(he,ye){a()(this.data,ye)}),mi.forEach(function(he){Z.on(he,function(ye,be){he.indexOf("ad")!==0&&this._updateStateData(),a()(this.data,be),this._sanitizeData()}),Z.on("after"+he,function(){(he!=="error"||this.errorTracker.viewErrored)&&this.send(he)})}),Z.on("viewend",function(he,ye){a()(Z.data,ye)}),Z.one("playerready",function(he){var ye=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=ye-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}),Z.longResumeTracker=new ci(We(Z)),Z.errorTracker=new ne(We(Z)),new et(We(Z)),Z.seekingTracker=new Xe(We(Z)),Z.playheadTime=new fe(We(Z)),Z.playbackHeartbeat=new Y(We(Z)),new Be(We(Z)),Z.watchTimeTracker=new ae(We(Z)),new ce(We(Z)),Z.adTracker=new Ne(We(Z)),new Oe(We(Z)),new Ae(We(Z)),new Ce(We(Z)),new ft(We(Z)),new fi(We(Z)),re.hlsjs&&Z.addHLSJS(re),re.dashjs&&Z.addDashJS(re),Z.emit("viewinit",re.data),Z}return O=X,w=[{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(V){var $=a()({},this.data);if($.video_source_is_live===void 0&&($.player_source_duration===1/0||$.video_source_duration===1/0?$.video_source_is_live=!0:($.player_source_duration>0||$.video_source_duration>0)&&($.video_source_is_live=!1)),$.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(Ee){$[Ee]=void 0}),$.video_source_url=$.video_source_url||$.player_source_url,$.video_source_url){var re=hi(n($.video_source_url),2),Z=re[0],oe=re[1];$.video_source_domain=oe,$.video_source_hostname=Z}delete $.ad_request_id,this.playbackEventDispatcher.send(V,$),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat()}},{key:"_updateStateData",value:function(){a()(this.data,this.getStateData()),this.playheadTime._updatePlayheadTime(),this._sanitizeData()}},{key:"_sanitizeData",value:function(){var V=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function($){var re=parseInt(V.data[$],10);V.data[$]=isNaN(re)?void 0:re}),["player_source_url","video_source_url"].forEach(function($){if(V.data[$]){var re=V.data[$].toLowerCase();re.indexOf("data:")!==0&&re.indexOf("blob:")!==0||(V.data[$]="MSE style URL")}})}},{key:"_resetVideoData",value:function(V,$){var re=this;Object.keys(this.data).forEach(function(Z){Z.indexOf("video_")===0&&delete re.data[Z]})}},{key:"_resetViewData",value:function(){var V=this;Object.keys(this.data).forEach(function($){$.indexOf("view_")===0&&delete V.data[$]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(V,$){delete this.data.player_error_code,delete this.data.player_error_message}},{key:"_initializeViewData",value:function(){var V=this,$=this.data.view_id=P(),re=function(){$===V.data.view_id&&l(V.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",re):re()}},{key:"_restartHeartBeat",value:function(){var V=this;window.clearTimeout(this._heartBeatTimeout),this.errorTracker.viewErrored||(this._heartBeatTimeout=window.setTimeout(function(){V.data.player_is_paused||V.emit("hb")},1e4))}},{key:"addHLSJS",value:function(V){V.hlsjs?this.hlsjs?this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=V.hlsjs,function($,re,Z){var oe=arguments.length>4?arguments[4]:void 0,Ee=$.log,ve=$.utils.secondsToMs,pe=function(De){var me,_e=parseInt(oe.version);return _e===1&&De.programDateTime!==null&&(me=De.programDateTime),_e===0&&De.pdt!==null&&(me=De.pdt),me};if(v.exists()){var he=function(De,me){return $.emit(re,De,me)},ye=function(De,me){var _e=me.levels,ge=me.audioTracks,Te=me.url,Fe=me.stats,Ue=me.networkDetails,st=me.sessionData,tt={},ct={};_e.forEach(function(gt,Bt){tt[Bt]={width:gt.width,height:gt.height,bitrate:gt.bitrate,attrs:gt.attrs}}),ge.forEach(function(gt,Bt){ct[Bt]={name:gt.name,language:gt.lang,bitrate:gt.bitrate}});var ot=r(Fe),vt=ot.bytesLoaded,Ge=ot.requestStart,ht=ot.responseStart,hr=ot.responseEnd;he("requestcompleted",m(m({},g(st)),{},{request_event_type:De,request_bytes_loaded:vt,request_start:Ge,request_response_start:ht,request_response_end:hr,request_type:"manifest",request_hostname:o(Te),request_response_headers:t(Ue),request_rendition_lists:{media:tt,audio:ct,video:{}}}))};Z.on(oe.Events.MANIFEST_LOADED,ye);var be=function(De,me){var _e=me.details,ge=me.level,Te=me.networkDetails,Fe=me.stats,Ue=r(Fe),st=Ue.bytesLoaded,tt=Ue.requestStart,ct=Ue.responseStart,ot=Ue.responseEnd,vt=_e.fragments[_e.fragments.length-1],Ge=pe(vt)+ve(vt.duration);he("requestcompleted",{request_event_type:De,request_bytes_loaded:st,request_start:tt,request_response_start:ct,request_response_end:ot,request_current_level:ge,request_type:"manifest",request_hostname:o(_e.url),request_response_headers:t(Te),video_holdback:_e.holdBack&&ve(_e.holdBack),video_part_holdback:_e.partHoldBack&&ve(_e.partHoldBack),video_part_target_duration:_e.partTarget&&ve(_e.partTarget),video_target_duration:_e.targetduration&&ve(_e.targetduration),video_source_is_live:_e.live,player_manifest_newest_program_time:isNaN(Ge)?void 0:Ge})};Z.on(oe.Events.LEVEL_LOADED,be);var He=function(De,me){var _e=me.details,ge=me.networkDetails,Te=me.stats,Fe=r(Te),Ue=Fe.bytesLoaded,st=Fe.requestStart,tt=Fe.responseStart,ct=Fe.responseEnd;he("requestcompleted",{request_event_type:De,request_bytes_loaded:Ue,request_start:st,request_response_start:tt,request_response_end:ct,request_type:"manifest",request_hostname:o(_e.url),request_response_headers:t(ge)})};Z.on(oe.Events.AUDIO_TRACK_LOADED,He);var je=function(De,me){var _e=me.stats,ge=me.networkDetails,Te=me.frag;_e=_e||Te.stats;var Fe=r(_e),Ue=Fe.bytesLoaded,st=Fe.requestStart,tt=Fe.responseStart,ct=Fe.responseEnd,ot=t(ge),vt=ot==null?void 0:ot["x-request-id"],Ge={request_event_type:De,request_bytes_loaded:Ue,request_start:st,request_response_start:tt,request_response_end:ct,request_hostname:ge?o(ge.responseURL):void 0,request_id:vt,request_response_headers:ot,request_media_duration:Te.duration,request_url:ge==null?void 0:ge.responseURL};Te.type==="main"?(Ge.request_type="media",Ge.request_current_level=Te.level,Ge.request_video_width=(Z.levels[Te.level]||{}).width,Ge.request_video_height=(Z.levels[Te.level]||{}).height,Ge.request_labeled_bitrate=(Z.levels[Te.level]||{}).bitrate):Ge.request_type=Te.type,he("requestcompleted",Ge)};Z.on(oe.Events.FRAG_LOADED,je);var at=function(De,me){var _e=me.frag,ge=_e.start,Te={currentFragmentPDT:pe(_e),currentFragmentStart:ve(ge)};he("fragmentchange",Te)};Z.on(oe.Events.FRAG_CHANGED,at);var Se=function(De,me){var _e=me.type,ge=me.details,Te=me.response,Fe=me.fatal,Ue=me.context,st=me.frag;if(ge===oe.ErrorDetails.MANIFEST_LOAD_ERROR||ge===oe.ErrorDetails.MANIFEST_LOAD_TIMEOUT||ge===oe.ErrorDetails.FRAG_LOAD_ERROR||ge===oe.ErrorDetails.FRAG_LOAD_TIMEOUT||ge===oe.ErrorDetails.LEVEL_LOAD_ERROR||ge===oe.ErrorDetails.LEVEL_LOAD_TIMEOUT){var tt=st&&st.url||Ue&&Ue.url||"";he("requestfailed",{request_error:ge,request_url:tt,request_hostname:o(tt),request_type:ge===oe.ErrorDetails.FRAG_LOAD_ERROR||ge===oe.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":"manifest",request_error_code:Te&&Te.code,request_error_text:Te&&Te.text})}Fe&&he("error",{player_error_code:_e,player_error_message:ge})};Z.on(oe.Events.ERROR,Se);var Ve=function(De,me){var _e=me.frag,ge=_e&&_e._url||"";he("requestcanceled",{request_event_type:De,request_url:ge,request_type:"media",request_hostname:o(ge)})};Z.on(oe.Events.FRAG_LOAD_EMERGENCY_ABORTED,Ve);var Qe=function(De,me){var _e=me.level,ge=Z.levels[_e];if(ge&&ge.attrs&&ge.attrs.BANDWIDTH){var Te,Fe=ge.attrs.BANDWIDTH,Ue=parseFloat(ge.attrs["FRAME-RATE"]);isNaN(Ue)||(Te=Ue),Fe?he("renditionchange",{video_source_fps:Te,video_source_bitrate:Fe,video_source_width:ge.width,video_source_height:ge.height,video_source_rendition_name:ge.name,video_source_codec:ge==null?void 0:ge.videoCodec}):Ee.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};Z.on(oe.Events.LEVEL_SWITCHED,Qe),Z._stopMuxMonitor=function(){Z.off(oe.Events.MANIFEST_LOADED,ye),Z.off(oe.Events.LEVEL_LOADED,be),Z.off(oe.Events.AUDIO_TRACK_LOADED,He),Z.off(oe.Events.FRAG_LOADED,je),Z.off(oe.Events.FRAG_CHANGED,at),Z.off(oe.Events.ERROR,Se),Z.off(oe.Events.FRAG_LOAD_EMERGENCY_ABORTED,Ve),Z.off(oe.Events.LEVEL_SWITCHED,Qe),Z.off(oe.Events.DESTROYING,Z._stopMuxMonitor),delete Z._stopMuxMonitor},Z.on(oe.Events.DESTROYING,Z._stopMuxMonitor)}else Ee.warn("performance timing not supported. Not tracking HLS.js.")}(this.mux,this.id,V.hlsjs,{},V.Hls||window.Hls)):this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")}},{key:"removeHLSJS",value:function(){var V;this.hlsjs&&((V=this.hlsjs)&&typeof V._stopMuxMonitor=="function"&&V._stopMuxMonitor(),this.hlsjs=void 0)}},{key:"addDashJS",value:function(V){V.dashjs?this.dashjs?this.mux.log.warn("An instance of Dash.js is already being monitored for this player."):(this.dashjs=V.dashjs,function($,re,Z){var oe=$.log;if(Z&&Z.on){var Ee=function(Se,Ve){return $.emit(re,Se,Ve)},ve=function(Se){var Ve=Se.type,Qe=(Se.data||{}).url;Ee("requestcompleted",{request_event_type:Ve,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:o(Qe),request_url:Qe})};Z.on("manifestLoaded",ve);var pe={},he=function(Se){var Ve=Se.type,Qe=Se.fragmentModel,De=(Se.chunk||{}).mediaInfo||{},me=De.type,_e=De.bitrateList,ge={};(_e=_e||[]).forEach(function(Ge,ht){ge[ht]={},ge[ht].width=Ge.width,ge[ht].height=Ge.height,ge[ht].bitrate=Ge.bandwidth,ge[ht].attrs={}}),me==="video"?pe.video=ge:me==="audio"?pe.audio=ge:pe.media=ge;var Te=b(Qe,Z),Fe=Te.requestStart,Ue=Te.requestResponseStart,st=Te.requestResponseEnd,tt=Te.requestResponseHeaders,ct=Te.requestMediaDuration,ot=Te.requestHostname,vt=Te.requestUrl;Ee("requestcompleted",{request_event_type:Ve,request_start:Fe,request_response_start:Ue,request_response_end:st,request_bytes_loaded:-1,request_type:me+"_init",request_response_headers:tt,request_hostname:ot,request_url:vt,request_media_duration:ct,request_rendition_lists:pe})};Z.on("initFragmentLoaded",he);var ye=function(Se){var Ve=Se.type,Qe=Se.fragmentModel,De=Se.chunk||{},me=De.mediaInfo,_e=De.start,ge=(me||{}).type,Te=b(Qe,Z),Fe=Te.requestStart,Ue=Te.requestResponseStart,st=Te.requestResponseEnd,tt=Te.requestBytesLoaded,ct=Te.requestResponseHeaders,ot=Te.requestMediaDuration,vt=Te.requestHostname,Ge=Te.requestUrl,ht=R(ge,Z),hr=ht.currentLevel,gt=ht.renditionWidth,Bt=ht.renditionHeight,Ki=ht.renditionBitrate;Ee("requestcompleted",{request_event_type:Ve,request_start:Fe,request_response_start:Ue,request_response_end:st,request_bytes_loaded:tt,request_type:ge,request_response_headers:ct,request_hostname:vt,request_url:Ge,request_media_start_time:_e,request_media_duration:ot,request_current_level:hr,request_labeled_bitrate:Ki,request_video_width:gt,request_video_height:Bt})};Z.on("mediaFragmentLoaded",ye);var be={video:void 0,audio:void 0,totalBitrate:void 0},He=function(){if(be.video&&typeof be.video.bitrate=="number"){if(be.video.width&&be.video.height){var Se=be.video.bitrate;return be.audio&&typeof be.audio.bitrate=="number"&&(Se+=be.audio.bitrate),Se!==be.totalBitrate?(be.totalBitrate=Se,{video_source_bitrate:Se,video_source_height:be.video.height,video_source_width:be.video.width,video_source_codec:I(be.video.codec)}):void 0}oe.warn("have bitrate info for video but missing width/height")}},je=function(Se,Ve,Qe){if(typeof Se.newQuality=="number"){var De=Se.mediaType;if(De==="audio"||De==="video"){var me=Z.getBitrateInfoListFor(De).find(function(ge){return ge.qualityIndex===Se.newQuality});if(me&&typeof me.bitrate=="number"){be[De]=y(y({},me),{},{codec:Z.getCurrentTrackFor(De).codec});var _e=He();_e&&Ee("renditionchange",_e)}else oe.warn("missing bitrate info for ".concat(De))}}else oe.warn("missing evt.newQuality in qualityChangeRendered event",Se)};Z.on("qualityChangeRendered",je);var at=function(Se){var Ve=Se.error,Qe=Se.event,De=(Qe=Qe||{}).request||{},me=M().event&&M().event.currentTarget||{};Ee("requestfailed",{request_error:Ve+"_"+Qe.id+"_"+De.type,request_url:Qe.url,request_hostname:o(Qe.url),request_type:De.mediaType,request_error_code:me.status,request_error_type:me.statusText})};Z.on("error",at),Z._stopMuxMonitor=function(){Z.off("manifestLoaded",ve),Z.off("initFragmentLoaded",he),Z.off("mediaFragmentLoaded",ye),Z.off("qualityChangeRendered",je),Z.off("error",at),delete Z._stopMuxMonitor}}else oe.warn("Invalid dash.js player reference. Monitoring blocked.")}(this.mux,this.id,V.dashjs)):this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")}},{key:"removeDashJS",value:function(){var V;this.dashjs&&((V=this.dashjs)&&typeof V._stopMuxMonitor=="function"&&V._stopMuxMonitor(),this.dashjs=void 0)}}],w&&Ir(O.prototype,w),W&&Ir(O,W),Object.defineProperty(O,"prototype",{writable:!1}),X}(H),yi=pi,Ei=C(153),Ft=C.n(Ei);function fr(U){return fr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(O){return typeof O}:function(O){return O&&typeof Symbol=="function"&&O.constructor===Symbol&&O!==Symbol.prototype?"symbol":typeof O},fr(U)}function Or(U,O){return function(w){if(Array.isArray(w))return w}(U)||function(w,W){var G=w==null?null:typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(G!=null){var X,V,$=[],re=!0,Z=!1;try{for(G=G.call(w);!(re=(X=G.next()).done)&&($.push(X.value),!W||$.length!==W);re=!0);}catch(oe){Z=!0,V=oe}finally{try{re||G.return==null||G.return()}finally{if(Z)throw V}}return $}}(U,O)||function(w,W){if(w){if(typeof w=="string")return Cr(w,W);var G=Object.prototype.toString.call(w).slice(8,-1);return G==="Object"&&w.constructor&&(G=w.constructor.name),G==="Map"||G==="Set"?Array.from(w):G==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(G)?Cr(w,W):void 0}}(U,O)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
5
5
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function Cr(U,O){(O==null||O>U.length)&&(O=U.length);for(var w=0,W=new Array(O);w<O;w++)W[w]=U[w];return W}var Lt,_i=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],Ti={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"};M()&&M().WeakMap&&(Lt=new WeakMap);var xi="#EXT-X-TARGETDURATION",Si="#EXT-X-PART-INF",Di="#EXT-X-SERVER-CONTROL",Li="#EXTINF",Ai="#EXT-X-PROGRAM-DATE-TIME",bi="#EXT-X-VERSION",Pi="#EXT-X-SESSION-DATA",Xt=function(U){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(U),this.manifest};Xt.prototype.process=function(U){var O;for(this.buffer+=U,O=this.buffer.indexOf(`
6
6
  `);O>-1;O=this.buffer.indexOf(`
7
- `))this.processLine(this.buffer.substring(0,O)),this.buffer=this.buffer.substring(O+1)},Xt.prototype.processLine=function(U){var O=U.indexOf(":"),w=Ci(U,O),W=w[0],G=w.length===2?dr(w[1]):void 0;if(W[0]!=="#")this.currentUri.uri=W,this.manifest.segments.push(this.currentUri),this.manifest.targetDuration&&!("duration"in this.currentUri)&&(this.currentUri.duration=this.manifest.targetDuration),this.currentUri={};else switch(W){case xi:if(!isFinite(G)||G<0)return;this.manifest.targetDuration=G,this.setHoldBack();break;case Si:fr(this.manifest,w),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break;case Di:fr(this.manifest,w),this.setHoldBack();break;case Li:G===0?this.currentUri.duration=.01:G>0&&(this.currentUri.duration=G);break;case Ai:var X=G,V=new Date(X);this.manifest.dateTimeString||(this.manifest.dateTimeString=X,this.manifest.dateTimeObject=V),this.currentUri.dateTimeString=X,this.currentUri.dateTimeObject=V;break;case bi:fr(this.manifest,w);break;case Pi:var $=Mi(w[1]),re=g($);a()(this.manifest.sessionData,re)}},Xt.prototype.setHoldBack=function(){var U=this.manifest,O=U.serverControl,w=U.targetDuration,W=U.partTargetDuration;if(O){var G="holdBack",X="partHoldBack",V=w&&3*w,$=W&&2*W;w&&!O.hasOwnProperty(G)&&(O[G]=V),V&&O[G]<V&&(O[G]=V),W&&!O.hasOwnProperty(X)&&(O[X]=3*W),W&&O[X]<$&&(O[X]=$)}};var fr=function(U,O){var w,W=Mr(O[0].replace("#EXT-X-",""));Oi(O[1])?(w={},w=a()(Ii(O[1]),w)):w=dr(O[1]),U[W]=w},Mr=function(U){return U.toLowerCase().replace(/-(\w)/g,function(O){return O[1].toUpperCase()})},dr=function(U){if(U.toLowerCase()==="yes"||U.toLowerCase()==="no")return U.toLowerCase()==="yes";var O=U.indexOf(":")!==-1?U:parseFloat(U);return isNaN(O)?U:O},Ri=function(U){var O={},w=U.split("=");return w.length>1&&(O[Mr(w[0])]=dr(w[1])),O},Ii=function(U){for(var O=U.split(","),w={},W=0;O.length>W;W++){var G=O[W],X=Ri(G);w=a()(X,w)}return w},Oi=function(U){return U.indexOf("=")>-1},Ci=function(U,O){return O===-1?[U]:[U.substring(0,O),U.substring(O+1)]},Mi=function(U){var O={};if(U){var w=U.search(",");return[U.slice(0,w),U.slice(w+1)].forEach(function(W,G){for(var X=W.replace(/['"]+/g,"").split("="),V=0;V<X.length;V++)X[V]==="DATA-ID"&&(O["DATA-ID"]=X[1-V]),X[V]==="VALUE"&&(O.VALUE=X[1-V])}),{data:O}}},wi=Xt,ki={safeCall:function(U,O,w,W){var G=W;if(U&&typeof U[O]=="function")try{G=U[O].apply(U,w)}catch(X){d.info("safeCall error",X)}return G},safeIncrement:l,getComputedStyle:function(U,O){var w;if(U&&O&&M()&&typeof M().getComputedStyle=="function")return Lt&&Lt.has(U)&&(w=Lt.get(U)),w||(w=M().getComputedStyle(U,null),Lt&&Lt.set(U,w)),w.getPropertyValue(O)},secondsToMs:function(U){return Math.floor(1e3*U)},assign:a(),headersStringToObject:u,extractHostnameAndDomain:n,extractHostname:o,manifestParser:wi,generateShortID:B,generateUUID:P,now:p.now},Fi={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 Ui(U,O){return function(w){if(Array.isArray(w))return w}(U)||function(w,W){var G=w==null?null:typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(G!=null){var X,V,$=[],re=!0,Z=!1;try{for(G=G.call(w);!(re=(X=G.next()).done)&&($.push(X.value),!W||$.length!==W);re=!0);}catch(oe){Z=!0,V=oe}finally{try{re||G.return==null||G.return()}finally{if(Z)throw V}}return $}}(U,O)||function(w,W){if(w){if(typeof w=="string")return wr(w,W);var G=Object.prototype.toString.call(w).slice(8,-1);return G==="Object"&&w.constructor&&(G=w.constructor.name),G==="Map"||G==="Set"?Array.from(w):G==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(G)?wr(w,W):void 0}}(U,O)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
8
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function wr(U,O){(O==null||O>U.length)&&(O=U.length);for(var w=0,W=new Array(O);w<O;w++)W[w]=U[w];return W}var dt={},Ut=function U(O){var w=arguments;typeof O=="string"?U.hasOwnProperty(O)?M().setTimeout(function(){w=Array.prototype.splice.call(w,1),U[O].apply(null,w)},0):d.warn("`"+O+"` is an unknown task"):typeof O=="function"?M().setTimeout(function(){O(U)},0):d.warn("`"+O+"` is invalid.")},Bi={loaded:p.now(),NAME:"mux-embed",VERSION:"4.17.0",API_VERSION:"2.1",PLAYER_TRACKED:!1,monitor:function(U,O){return function(w,W,G){var X=Or(D(W),3),V=X[0],$=X[1],re=X[2],Z=w.log,oe=w.utils.getComputedStyle,Ee=w.utils.secondsToMs;if(!V)return Z.error("No element was found with the `"+$+"` query selector.");if(re!=="video"&&re!=="audio")return Z.error("The element of `"+$+"` was not a media element.");V.mux&&(V.mux.destroy(),delete V.mux,Z.warn("Already monitoring this video element, replacing existing event listeners")),(G=a()({automaticErrorTracking:!0},G)).data=a()({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:w.VERSION},G.data),G.getPlayheadTime=function(){return Ee(V.currentTime)},G.getStateData=function(){var pe,he,ye=this.hlsjs&&this.hlsjs.url,be=this.dashjs&&ur(this.dashjs.getSource==="function")&&this.dashjs.getSource(),He={player_is_paused:V.paused,player_playhead_time:Ee(V.currentTime),player_width:parseInt(oe(V,"width")),player_height:parseInt(oe(V,"height")),player_autoplay_on:V.autoplay,player_preload_on:V.preload,player_language_code:V.lang,player_is_fullscreen:Ft()&&!!(Ft().fullscreenElement||Ft().webkitFullscreenElement||Ft().mozFullScreenElement||Ft().msFullscreenElement),video_poster_url:V.poster,video_source_url:ye||be||V.currentSrc,video_source_duration:Ee(V.duration),video_source_height:V.videoHeight,video_source_width:V.videoWidth,view_dropped_frame_count:(pe=V)===null||pe===void 0||(he=pe.getVideoPlaybackQuality)===null||he===void 0?void 0:he.call(pe).droppedVideoFrames},je=G.getPlayheadTime();if(V.getStartDate&&je>0){var at=V.getStartDate();if(at&&typeof at.getTime=="function"&&at.getTime()){var Se=at.getTime();if(He.player_program_time=Se+je,V.seekable.length>0){var Ve=Se+V.seekable.end(V.seekable.length-1);He.player_live_edge_program_time=Ve}}}return He},V.mux=V.mux||{},V.mux.deleted=!1,V.mux.emit=function(pe,he){w.emit($,pe,he)};var ve=function(){Z.error("The monitor for this video element has already been destroyed.")};V.mux.destroy=function(){Object.keys(V.mux.listeners).forEach(function(pe){V.removeEventListener(pe,V.mux.listeners[pe],!1)}),delete V.mux.listeners,V.mux.destroy=ve,V.mux.swapElement=ve,V.mux.emit=ve,V.mux.addHLSJS=ve,V.mux.addDashJS=ve,V.mux.removeHLSJS=ve,V.mux.removeDashJS=ve,V.mux.deleted=!0,w.emit($,"destroy")},V.mux.swapElement=function(pe){var he=Or(D(pe),3),ye=he[0],be=he[1],He=he[2];return ye?He!=="video"&&He!=="audio"?w.log.error("The element of `"+be+"` was not a media element."):(ye.muxId=V.muxId,delete V.muxId,ye.mux=ye.mux||{},ye.mux.listeners=a()({},V.mux.listeners),delete V.mux.listeners,Object.keys(ye.mux.listeners).forEach(function(je){V.removeEventListener(je,ye.mux.listeners[je],!1),ye.addEventListener(je,ye.mux.listeners[je],!1)}),ye.mux.swapElement=V.mux.swapElement,ye.mux.destroy=V.mux.destroy,delete V.mux,void(V=ye)):w.log.error("No element was found with the `"+be+"` query selector.")},V.mux.addHLSJS=function(pe){w.addHLSJS($,pe)},V.mux.addDashJS=function(pe){w.addDashJS($,pe)},V.mux.removeHLSJS=function(){w.removeHLSJS($)},V.mux.removeDashJS=function(){w.removeDashJS($)},w.init($,G),w.emit($,"playerready"),V.paused||(w.emit($,"play"),V.readyState>2&&w.emit($,"playing")),V.mux.listeners={},_i.forEach(function(pe){(pe!=="error"||G.automaticErrorTracking)&&(V.mux.listeners[pe]=function(){var he={};if(pe==="error"){if(!V.error||V.error.code===1)return;he.player_error_code=V.error.code,he.player_error_message=Ti[V.error.code]||V.error.message}w.emit($,pe,he)},V.addEventListener(pe,V.mux.listeners[pe],!1))})}(Ut,U,O)},destroyMonitor:function(U){var O=Ui(D(U),1)[0];O&&O.mux&&typeof O.mux.destroy=="function"?O.mux.destroy():d.error("A video element monitor for `"+U+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(U,O){var w=A(U);dt[w]?dt[w].addHLSJS(O):d.error("A monitor for `"+w+"` has not been initialized.")},addDashJS:function(U,O){var w=A(U);dt[w]?dt[w].addDashJS(O):d.error("A monitor for `"+w+"` has not been initialized.")},removeHLSJS:function(U){var O=A(U);dt[O]?dt[O].removeHLSJS():d.error("A monitor for `"+O+"` has not been initialized.")},removeDashJS:function(U){var O=A(U);dt[O]?dt[O].removeDashJS():d.error("A monitor for `"+O+"` has not been initialized.")},init:function(U,O){E()&&O&&O.respectDoNotTrack&&d.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var w=A(U);dt[w]=new yi(Ut,w,O)},emit:function(U,O,w){var W=A(U);dt[W]?(dt[W].emit(O,w),O==="destroy"&&delete dt[W]):d.error("A monitor for `"+W+"` has not been initialized.")},checkDoNotTrack:E,log:d,utils:ki,events:Fi,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(Ut,Bi),M()!==void 0&&typeof M().addEventListener=="function"&&M().addEventListener("pagehide",function(U){U.persisted||(Ut.WINDOW_UNLOADING=!0)},!1);var Ni=Ut},655:function(N,T,C){var L,M;function P(B){return P=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(A){return typeof A}:function(A){return A&&typeof Symbol=="function"&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":typeof A},P(B);}(function(B){var A=!1;if((M=typeof(L=B)=="function"?L.call(T,C,T,N):L)===void 0||(N.exports=M),A=!0,P(T)==="object"&&(N.exports=B(),A=!0),!A){var D=window.Cookies,x=window.Cookies=B();x.noConflict=function(){return window.Cookies=D,x}}})(function(){var B=function(){for(var A=0,D={};A<arguments.length;A++){var x=arguments[A];for(var _ in x)D[_]=x[_]}return D};return function A(D){function x(_,S,d){var E;if(typeof document!="undefined"){if(arguments.length>1){if(typeof(d=B({path:"/"},x.defaults,d)).expires=="number"){var p=new Date;p.setMilliseconds(p.getMilliseconds()+864e5*d.expires),d.expires=p}try{E=JSON.stringify(S),/^[\{\[]/.test(E)&&(S=E)}catch{}return S=D.write?D.write(S,_):encodeURIComponent(String(S)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),_=(_=(_=encodeURIComponent(String(_))).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent)).replace(/[\(\)]/g,escape),document.cookie=[_,"=",S,d.expires?"; expires="+d.expires.toUTCString():"",d.path?"; path="+d.path:"",d.domain?"; domain="+d.domain:"",d.secure?"; secure":""].join("")}_||(E={});for(var h=document.cookie?document.cookie.split("; "):[],a=/(%[0-9A-Z]{2})+/g,o=0;o<h.length;o++){var n=h[o].split("="),v=n.slice(1).join("=");v.charAt(0)==='"'&&(v=v.slice(1,-1));try{var l=n[0].replace(a,decodeURIComponent);if(v=D.read?D.read(v,l):D(v,l)||v.replace(a,decodeURIComponent),this.json)try{v=JSON.parse(v)}catch{}if(_===l){E=v;break}_||(E[l]=v)}catch{}}return E}}return x.set=x,x.get=function(_){return x.call(x,_)},x.getJSON=function(){return x.apply({json:!0},[].slice.call(arguments))},x.defaults={},x.remove=function(_,S){x(_,"",B(S,{expires:-1}))},x.withConverter=A,x}(function(){})})},153:function(N,T,C){var L,M=C.g!==void 0?C.g:typeof window!="undefined"?window:{},P=C(558);typeof document!="undefined"?L=document:(L=M["__GLOBAL_DOCUMENT_CACHE@4"])||(L=M["__GLOBAL_DOCUMENT_CACHE@4"]=P),N.exports=L},48:function(N,T,C){var L;L=typeof window!="undefined"?window:C.g!==void 0?C.g:typeof self!="undefined"?self:{},N.exports=L},678:function(N){var T=9007199254740991,C="[object Arguments]",L="[object Function]",M="[object GeneratorFunction]",P=/^(?:0|[1-9]\d*)$/;function B(e,r,t){switch(t.length){case 0:return e.call(r);case 1:return e.call(r,t[0]);case 2:return e.call(r,t[0],t[1]);case 3:return e.call(r,t[0],t[1],t[2])}return e.apply(r,t)}var A,D,x=Object.prototype,_=x.hasOwnProperty,S=x.toString,d=x.propertyIsEnumerable,E=(A=Object.keys,D=Object,function(e){return A(D(e))}),p=Math.max,h=!d.call({valueOf:1},"valueOf");function a(e,r){var t=i(e)||function(b){return function(R){return function(I){return!!I&&typeof I=="object"}(R)&&u(R)}(b)&&_.call(b,"callee")&&(!d.call(b,"callee")||S.call(b)==C)}(e)?function(b,R){for(var I=-1,k=Array(b);++I<b;)k[I]=R(I);return k}(e.length,String):[],s=t.length,y=!!s;for(var f in e)!r&&!_.call(e,f)||y&&(f=="length"||n(f,s))||t.push(f);return t}function o(e,r,t){var s=e[r];_.call(e,r)&&l(s,t)&&(t!==void 0||r in e)||(e[r]=t)}function n(e,r){return!!(r=r==null?T:r)&&(typeof e=="number"||P.test(e))&&e>-1&&e%1==0&&e<r}function v(e){var r=e&&e.constructor;return e===(typeof r=="function"&&r.prototype||x)}function l(e,r){return e===r||e!=e&&r!=r}var i=Array.isArray;function u(e){return e!=null&&function(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=T}(e.length)&&!function(r){var t=g(r)?S.call(r):"";return t==L||t==M}(e)}function g(e){var r=typeof e;return!!e&&(r=="object"||r=="function")}var c,m=(c=function(e,r){if(h||v(r)||u(r))(function(s,y,f,b){f||(f={});for(var R=-1,I=y.length;++R<I;){var k=y[R],F=b?b(f[k],s[k],k,f,s):void 0;o(f,k,F===void 0?s[k]:F)}})(r,function(s){return u(s)?a(s):function(y){if(!v(y))return E(y);var f=[];for(var b in Object(y))_.call(y,b)&&b!="constructor"&&f.push(b);return f}(s)}(r),e);else for(var t in r)_.call(r,t)&&o(e,t,r[t])},function(e,r){return r=p(r===void 0?e.length-1:r,0),function(){for(var t=arguments,s=-1,y=p(t.length-r,0),f=Array(y);++s<y;)f[s]=t[r+s];s=-1;for(var b=Array(r+1);++s<r;)b[s]=t[s];return b[r]=f,B(e,this,b)}}(function(e,r){var t=-1,s=r.length,y=s>1?r[s-1]:void 0,f=s>2?r[2]:void 0;for(y=c.length>3&&typeof y=="function"?(s--,y):void 0,f&&function(R,I,k){if(!g(k))return!1;var F=typeof I;return!!(F=="number"?u(k)&&n(I,k.length):F=="string"&&I in k)&&l(k[I],R)}(r[0],r[1],f)&&(y=s<3?void 0:y,s=1),e=Object(e);++t<s;){var b=r[t];b&&c(e,b,t,y)}return e}));N.exports=m},640:function(N,T,C){var L,M;(function(P,B){"use strict";L=function(){var A=function(){},D="undefined",x=typeof window!==D&&typeof window.navigator!==D&&/Trident\/|MSIE /.test(window.navigator.userAgent),_=["trace","debug","info","warn","error"];function S(i,u){var g=i[u];if(typeof g.bind=="function")return g.bind(i);try{return Function.prototype.bind.call(g,i)}catch{return function(){return Function.prototype.apply.apply(g,[i,arguments])}}}function d(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function E(i){return i==="debug"&&(i="log"),typeof console!==D&&(i==="trace"&&x?d:console[i]!==void 0?S(console,i):console.log!==void 0?S(console,"log"):A)}function p(i,u){for(var g=0;g<_.length;g++){var c=_[g];this[c]=g<i?A:this.methodFactory(c,i,u)}this.log=this.debug}function h(i,u,g){return function(){typeof console!==D&&(p.call(this,u,g),this[i].apply(this,arguments))}}function a(i,u,g){return E(i)||h.apply(this,arguments)}function o(i,u,g){var c,m=this;u=u==null?"WARN":u;var e="loglevel";function r(f){var b=(_[f]||"silent").toUpperCase();if(typeof window!==D&&e){try{return void(window.localStorage[e]=b)}catch{}try{window.document.cookie=encodeURIComponent(e)+"="+b+";"}catch{}}}function t(){var f;if(typeof window!==D&&e){try{f=window.localStorage[e]}catch{}if(typeof f===D)try{var b=window.document.cookie,R=b.indexOf(encodeURIComponent(e)+"=");R!==-1&&(f=/^([^;]+)/.exec(b.slice(R))[1])}catch{}return m.levels[f]===void 0&&(f=void 0),f}}function s(){if(typeof window!==D&&e){try{return void window.localStorage.removeItem(e)}catch{}try{window.document.cookie=encodeURIComponent(e)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}typeof i=="string"?e+=":"+i:typeof i=="symbol"&&(e=void 0),m.name=i,m.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},m.methodFactory=g||a,m.getLevel=function(){return c},m.setLevel=function(f,b){if(typeof f=="string"&&m.levels[f.toUpperCase()]!==void 0&&(f=m.levels[f.toUpperCase()]),!(typeof f=="number"&&f>=0&&f<=m.levels.SILENT))throw"log.setLevel() called with invalid level: "+f;if(c=f,b!==!1&&r(f),p.call(m,f,i),typeof console===D&&f<m.levels.SILENT)return"No console available for logging"},m.setDefaultLevel=function(f){u=f,t()||m.setLevel(f,!1)},m.resetLevel=function(){m.setLevel(u,!1),s()},m.enableAll=function(f){m.setLevel(m.levels.TRACE,f)},m.disableAll=function(f){m.setLevel(m.levels.SILENT,f)};var y=t();y==null&&(y=u),m.setLevel(y,!1)}var n=new o,v={};n.getLogger=function(i){if(typeof i!="symbol"&&typeof i!="string"||i==="")throw new TypeError("You must supply a name when creating a logger.");var u=v[i];return u||(u=v[i]=new o(i,n.getLevel(),n.methodFactory)),u};var l=typeof window!==D?window.log:void 0;return n.noConflict=function(){return typeof window!==D&&window.log===n&&(window.log=l),n},n.getLoggers=function(){return v},n.default=n,n},(M=typeof L=="function"?L.call(T,C,T,N):L)===void 0||(N.exports=M)})()},375:function(N,T){"use strict";var C=Object.prototype.hasOwnProperty;function L(P){try{return decodeURIComponent(P.replace(/\+/g," "))}catch{return null}}function M(P){try{return encodeURIComponent(P)}catch{return null}}T.stringify=function(P,B){B=B||"";var A,D,x=[];for(D in typeof B!="string"&&(B="?"),P)if(C.call(P,D)){if((A=P[D])||A!=null&&!isNaN(A)||(A=""),D=M(D),A=M(A),D===null||A===null)continue;x.push(D+"="+A)}return x.length?B+x.join("&"):""},T.parse=function(P){for(var B,A=/([^=?#&]+)=?([^&]*)/g,D={};B=A.exec(P);){var x=L(B[1]),_=L(B[2]);x===null||_===null||x in D||(D[x]=_)}return D}},558:function(){}},se={};function z(N){var T=se[N];if(T!==void 0)return T.exports;var C=se[N]={exports:{}};return ie[N].call(C.exports,C,C.exports,z),C.exports}return z.n=function(N){var T=N&&N.__esModule?function(){return N.default}:function(){return N};return z.d(T,{a:T}),T},z.d=function(N,T){for(var C in T)z.o(T,C)&&!z.o(N,C)&&Object.defineProperty(N,C,{enumerable:!0,get:T[C]})},z.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),z.o=function(N,T){return Object.prototype.hasOwnProperty.call(N,T)},z(80)}()},typeof Qt=="object"&&typeof hr=="object"?hr.exports=ee():typeof Qt=="object"?Qt.mux=ee():J.mux=ee()})()});var $t=Fr((Nt,vr)=>{typeof window!="undefined"&&function(ee,ie){typeof Nt=="object"&&typeof vr=="object"?vr.exports=ie():typeof define=="function"&&define.amd?define([],ie):typeof Nt=="object"?Nt.Hls=ie():ee.Hls=ie()}(Nt,()=>(()=>{var J={"./src/config.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{enableStreamingMode:()=>r,hlsDefaultConfig:()=>c,mergeConfig:()=>e});var C=T("./src/controller/abr-controller.ts"),L=T("./src/controller/audio-stream-controller.ts"),M=T("./src/controller/audio-track-controller.ts"),P=T("./src/controller/subtitle-stream-controller.ts"),B=T("./src/controller/subtitle-track-controller.ts"),A=T("./src/controller/buffer-controller.ts"),D=T("./src/controller/timeline-controller.ts"),x=T("./src/controller/cap-level-controller.ts"),_=T("./src/controller/fps-controller.ts"),S=T("./src/controller/eme-controller.ts"),d=T("./src/controller/cmcd-controller.ts"),E=T("./src/utils/xhr-loader.ts"),p=T("./src/utils/fetch-loader.ts"),h=T("./src/utils/cues.ts"),a=T("./src/utils/mediakeys-helper.ts"),o=T("./src/utils/logger.ts");function n(){return n=Object.assign?Object.assign.bind():function(t){for(var s=1;s<arguments.length;s++){var y=arguments[s];for(var f in y)Object.prototype.hasOwnProperty.call(y,f)&&(t[f]=y[f])}return t},n.apply(this,arguments)}function v(t,s){var y=Object.keys(t);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(t);s&&(f=f.filter(function(b){return Object.getOwnPropertyDescriptor(t,b).enumerable})),y.push.apply(y,f)}return y}function l(t){for(var s=1;s<arguments.length;s++){var y=arguments[s]!=null?arguments[s]:{};s%2?v(Object(y),!0).forEach(function(f){i(t,f,y[f])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(y)):v(Object(y)).forEach(function(f){Object.defineProperty(t,f,Object.getOwnPropertyDescriptor(y,f))})}return t}function i(t,s,y){return s=u(s),s in t?Object.defineProperty(t,s,{value:y,enumerable:!0,configurable:!0,writable:!0}):t[s]=y,t}function u(t){var s=g(t,"string");return typeof s=="symbol"?s:String(s)}function g(t,s){if(typeof t!="object"||t===null)return t;var y=t[Symbol.toPrimitive];if(y!==void 0){var f=y.call(t,s||"default");if(typeof f!="object")return f;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(t)}var c=l(l({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,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:void 0,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:E.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:C.default,bufferController:A.default,capLevelController:x.default,fpsController:_.default,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:a.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0},m()),{},{subtitleStreamController:P.SubtitleStreamController,subtitleTrackController:B.default,timelineController:D.TimelineController,audioStreamController:L.default,audioTrackController:M.default,emeController:S.default,cmcdController:d.default});function m(){return{cueHandler:h.default,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 e(t,s){if((s.liveSyncDurationCount||s.liveMaxLatencyDurationCount)&&(s.liveSyncDuration||s.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(s.liveMaxLatencyDurationCount!==void 0&&(s.liveSyncDurationCount===void 0||s.liveMaxLatencyDurationCount<=s.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(s.liveMaxLatencyDuration!==void 0&&(s.liveSyncDuration===void 0||s.liveMaxLatencyDuration<=s.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return n({},t,s)}function r(t){var s=t.loader;if(s!==p.default&&s!==E.default)o.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),t.progressive=!1;else{var y=(0,p.fetchSupported)();y&&(t.loader=p.default,t.progressive=!0,t.enableSoftwareAES=!0,o.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>E});var C=T("./src/polyfills/number.ts"),L=T("./src/utils/ewma-bandwidth-estimator.ts"),M=T("./src/events.ts"),P=T("./src/errors.ts"),B=T("./src/types/loader.ts"),A=T("./src/utils/logger.ts");function D(p,h){for(var a=0;a<h.length;a++){var o=h[a];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(p,_(o.key),o)}}function x(p,h,a){return h&&D(p.prototype,h),a&&D(p,a),Object.defineProperty(p,"prototype",{writable:!1}),p}function _(p){var h=S(p,"string");return typeof h=="symbol"?h:String(h)}function S(p,h){if(typeof p!="object"||p===null)return p;var a=p[Symbol.toPrimitive];if(a!==void 0){var o=a.call(p,h||"default");if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(h==="string"?String:Number)(p)}var d=function(){function p(a){this.hls=void 0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=void 0,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=a;var o=a.config;this.bwEstimator=new L.default(o.abrEwmaSlowVoD,o.abrEwmaFastVoD,o.abrEwmaDefaultEstimate),this.registerListeners()}var h=p.prototype;return h.registerListeners=function(){var o=this.hls;o.on(M.Events.FRAG_LOADING,this.onFragLoading,this),o.on(M.Events.FRAG_LOADED,this.onFragLoaded,this),o.on(M.Events.FRAG_BUFFERED,this.onFragBuffered,this),o.on(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),o.on(M.Events.ERROR,this.onError,this)},h.unregisterListeners=function(){var o=this.hls;o.off(M.Events.FRAG_LOADING,this.onFragLoading,this),o.off(M.Events.FRAG_LOADED,this.onFragLoaded,this),o.off(M.Events.FRAG_BUFFERED,this.onFragBuffered,this),o.off(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),o.off(M.Events.ERROR,this.onError,this)},h.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},h.onFragLoading=function(o,n){var v=n.frag;if(v.type===B.PlaylistLevelType.MAIN&&!this.timer){var l;this.fragCurrent=v,this.partCurrent=(l=n.part)!=null?l:null,this.timer=self.setInterval(this.onCheck,100)}},h.onLevelLoaded=function(o,n){var v=this.hls.config;n.details.live?this.bwEstimator.update(v.abrEwmaSlowLive,v.abrEwmaFastLive):this.bwEstimator.update(v.abrEwmaSlowVoD,v.abrEwmaFastVoD)},h._abandonRulesCheck=function(){var o=this.fragCurrent,n=this.partCurrent,v=this.hls,l=v.autoLevelEnabled,i=v.media;if(!(!o||!i)){var u=n?n.stats:o.stats,g=n?n.duration:o.duration;if(u.aborted||u.loaded&&u.loaded===u.total||o.level===0){this.clearTimer(),this._nextAutoLevel=-1;return}if(!(!l||i.paused||!i.playbackRate||!i.readyState)){var c=v.mainForwardBufferInfo;if(c!==null){var m=performance.now()-u.loading.start,e=Math.abs(i.playbackRate);if(!(m<=500*g/e)){var r=u.loaded&&u.loading.first,t=this.bwEstimator.getEstimate(),s=v.levels,y=v.minAutoLevel,f=s[o.level],b=u.total||Math.max(u.loaded,Math.round(g*f.maxBitrate/8)),R=r?u.loaded*1e3/m:0,I=R?(b-u.loaded)/R:b*8/t,k=c.len/e;if(!(I<=k)){var F=Number.POSITIVE_INFINITY,K;for(K=o.level-1;K>y;K--){var H=s[K].maxBitrate;if(F=R?g*H/(8*.8*R):g*H/t,F<k)break}F>=I||(A.logger.warn("Fragment "+o.sn+(n?" part "+n.index:"")+" of level "+o.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+K+`
7
+ `))this.processLine(this.buffer.substring(0,O)),this.buffer=this.buffer.substring(O+1)},Xt.prototype.processLine=function(U){var O=U.indexOf(":"),w=Ci(U,O),W=w[0],G=w.length===2?cr(w[1]):void 0;if(W[0]!=="#")this.currentUri.uri=W,this.manifest.segments.push(this.currentUri),this.manifest.targetDuration&&!("duration"in this.currentUri)&&(this.currentUri.duration=this.manifest.targetDuration),this.currentUri={};else switch(W){case xi:if(!isFinite(G)||G<0)return;this.manifest.targetDuration=G,this.setHoldBack();break;case Si:dr(this.manifest,w),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break;case Di:dr(this.manifest,w),this.setHoldBack();break;case Li:G===0?this.currentUri.duration=.01:G>0&&(this.currentUri.duration=G);break;case Ai:var X=G,V=new Date(X);this.manifest.dateTimeString||(this.manifest.dateTimeString=X,this.manifest.dateTimeObject=V),this.currentUri.dateTimeString=X,this.currentUri.dateTimeObject=V;break;case bi:dr(this.manifest,w);break;case Pi:var $=Mi(w[1]),re=g($);a()(this.manifest.sessionData,re)}},Xt.prototype.setHoldBack=function(){var U=this.manifest,O=U.serverControl,w=U.targetDuration,W=U.partTargetDuration;if(O){var G="holdBack",X="partHoldBack",V=w&&3*w,$=W&&2*W;w&&!O.hasOwnProperty(G)&&(O[G]=V),V&&O[G]<V&&(O[G]=V),W&&!O.hasOwnProperty(X)&&(O[X]=3*W),W&&O[X]<$&&(O[X]=$)}};var dr=function(U,O){var w,W=Mr(O[0].replace("#EXT-X-",""));Oi(O[1])?(w={},w=a()(Ii(O[1]),w)):w=cr(O[1]),U[W]=w},Mr=function(U){return U.toLowerCase().replace(/-(\w)/g,function(O){return O[1].toUpperCase()})},cr=function(U){if(U.toLowerCase()==="yes"||U.toLowerCase()==="no")return U.toLowerCase()==="yes";var O=U.indexOf(":")!==-1?U:parseFloat(U);return isNaN(O)?U:O},Ri=function(U){var O={},w=U.split("=");return w.length>1&&(O[Mr(w[0])]=cr(w[1])),O},Ii=function(U){for(var O=U.split(","),w={},W=0;O.length>W;W++){var G=O[W],X=Ri(G);w=a()(X,w)}return w},Oi=function(U){return U.indexOf("=")>-1},Ci=function(U,O){return O===-1?[U]:[U.substring(0,O),U.substring(O+1)]},Mi=function(U){var O={};if(U){var w=U.search(",");return[U.slice(0,w),U.slice(w+1)].forEach(function(W,G){for(var X=W.replace(/['"]+/g,"").split("="),V=0;V<X.length;V++)X[V]==="DATA-ID"&&(O["DATA-ID"]=X[1-V]),X[V]==="VALUE"&&(O.VALUE=X[1-V])}),{data:O}}},wi=Xt,ki={safeCall:function(U,O,w,W){var G=W;if(U&&typeof U[O]=="function")try{G=U[O].apply(U,w)}catch(X){d.info("safeCall error",X)}return G},safeIncrement:l,getComputedStyle:function(U,O){var w;if(U&&O&&M()&&typeof M().getComputedStyle=="function")return Lt&&Lt.has(U)&&(w=Lt.get(U)),w||(w=M().getComputedStyle(U,null),Lt&&Lt.set(U,w)),w.getPropertyValue(O)},secondsToMs:function(U){return Math.floor(1e3*U)},assign:a(),headersStringToObject:u,extractHostnameAndDomain:n,extractHostname:o,manifestParser:wi,generateShortID:B,generateUUID:P,now:p.now},Fi={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 Ui(U,O){return function(w){if(Array.isArray(w))return w}(U)||function(w,W){var G=w==null?null:typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(G!=null){var X,V,$=[],re=!0,Z=!1;try{for(G=G.call(w);!(re=(X=G.next()).done)&&($.push(X.value),!W||$.length!==W);re=!0);}catch(oe){Z=!0,V=oe}finally{try{re||G.return==null||G.return()}finally{if(Z)throw V}}return $}}(U,O)||function(w,W){if(w){if(typeof w=="string")return wr(w,W);var G=Object.prototype.toString.call(w).slice(8,-1);return G==="Object"&&w.constructor&&(G=w.constructor.name),G==="Map"||G==="Set"?Array.from(w):G==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(G)?wr(w,W):void 0}}(U,O)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
8
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function wr(U,O){(O==null||O>U.length)&&(O=U.length);for(var w=0,W=new Array(O);w<O;w++)W[w]=U[w];return W}var dt={},Ut=function U(O){var w=arguments;typeof O=="string"?U.hasOwnProperty(O)?M().setTimeout(function(){w=Array.prototype.splice.call(w,1),U[O].apply(null,w)},0):d.warn("`"+O+"` is an unknown task"):typeof O=="function"?M().setTimeout(function(){O(U)},0):d.warn("`"+O+"` is invalid.")},Bi={loaded:p.now(),NAME:"mux-embed",VERSION:"4.17.0",API_VERSION:"2.1",PLAYER_TRACKED:!1,monitor:function(U,O){return function(w,W,G){var X=Or(D(W),3),V=X[0],$=X[1],re=X[2],Z=w.log,oe=w.utils.getComputedStyle,Ee=w.utils.secondsToMs;if(!V)return Z.error("No element was found with the `"+$+"` query selector.");if(re!=="video"&&re!=="audio")return Z.error("The element of `"+$+"` was not a media element.");V.mux&&(V.mux.destroy(),delete V.mux,Z.warn("Already monitoring this video element, replacing existing event listeners")),(G=a()({automaticErrorTracking:!0},G)).data=a()({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:w.VERSION},G.data),G.getPlayheadTime=function(){return Ee(V.currentTime)},G.getStateData=function(){var pe,he,ye=this.hlsjs&&this.hlsjs.url,be=this.dashjs&&fr(this.dashjs.getSource==="function")&&this.dashjs.getSource(),He={player_is_paused:V.paused,player_playhead_time:Ee(V.currentTime),player_width:parseInt(oe(V,"width")),player_height:parseInt(oe(V,"height")),player_autoplay_on:V.autoplay,player_preload_on:V.preload,player_language_code:V.lang,player_is_fullscreen:Ft()&&!!(Ft().fullscreenElement||Ft().webkitFullscreenElement||Ft().mozFullScreenElement||Ft().msFullscreenElement),video_poster_url:V.poster,video_source_url:ye||be||V.currentSrc,video_source_duration:Ee(V.duration),video_source_height:V.videoHeight,video_source_width:V.videoWidth,view_dropped_frame_count:(pe=V)===null||pe===void 0||(he=pe.getVideoPlaybackQuality)===null||he===void 0?void 0:he.call(pe).droppedVideoFrames},je=G.getPlayheadTime();if(V.getStartDate&&je>0){var at=V.getStartDate();if(at&&typeof at.getTime=="function"&&at.getTime()){var Se=at.getTime();if(He.player_program_time=Se+je,V.seekable.length>0){var Ve=Se+V.seekable.end(V.seekable.length-1);He.player_live_edge_program_time=Ve}}}return He},V.mux=V.mux||{},V.mux.deleted=!1,V.mux.emit=function(pe,he){w.emit($,pe,he)};var ve=function(){Z.error("The monitor for this video element has already been destroyed.")};V.mux.destroy=function(){Object.keys(V.mux.listeners).forEach(function(pe){V.removeEventListener(pe,V.mux.listeners[pe],!1)}),delete V.mux.listeners,V.mux.destroy=ve,V.mux.swapElement=ve,V.mux.emit=ve,V.mux.addHLSJS=ve,V.mux.addDashJS=ve,V.mux.removeHLSJS=ve,V.mux.removeDashJS=ve,V.mux.deleted=!0,w.emit($,"destroy")},V.mux.swapElement=function(pe){var he=Or(D(pe),3),ye=he[0],be=he[1],He=he[2];return ye?He!=="video"&&He!=="audio"?w.log.error("The element of `"+be+"` was not a media element."):(ye.muxId=V.muxId,delete V.muxId,ye.mux=ye.mux||{},ye.mux.listeners=a()({},V.mux.listeners),delete V.mux.listeners,Object.keys(ye.mux.listeners).forEach(function(je){V.removeEventListener(je,ye.mux.listeners[je],!1),ye.addEventListener(je,ye.mux.listeners[je],!1)}),ye.mux.swapElement=V.mux.swapElement,ye.mux.destroy=V.mux.destroy,delete V.mux,void(V=ye)):w.log.error("No element was found with the `"+be+"` query selector.")},V.mux.addHLSJS=function(pe){w.addHLSJS($,pe)},V.mux.addDashJS=function(pe){w.addDashJS($,pe)},V.mux.removeHLSJS=function(){w.removeHLSJS($)},V.mux.removeDashJS=function(){w.removeDashJS($)},w.init($,G),w.emit($,"playerready"),V.paused||(w.emit($,"play"),V.readyState>2&&w.emit($,"playing")),V.mux.listeners={},_i.forEach(function(pe){(pe!=="error"||G.automaticErrorTracking)&&(V.mux.listeners[pe]=function(){var he={};if(pe==="error"){if(!V.error||V.error.code===1)return;he.player_error_code=V.error.code,he.player_error_message=Ti[V.error.code]||V.error.message}w.emit($,pe,he)},V.addEventListener(pe,V.mux.listeners[pe],!1))})}(Ut,U,O)},destroyMonitor:function(U){var O=Ui(D(U),1)[0];O&&O.mux&&typeof O.mux.destroy=="function"?O.mux.destroy():d.error("A video element monitor for `"+U+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(U,O){var w=A(U);dt[w]?dt[w].addHLSJS(O):d.error("A monitor for `"+w+"` has not been initialized.")},addDashJS:function(U,O){var w=A(U);dt[w]?dt[w].addDashJS(O):d.error("A monitor for `"+w+"` has not been initialized.")},removeHLSJS:function(U){var O=A(U);dt[O]?dt[O].removeHLSJS():d.error("A monitor for `"+O+"` has not been initialized.")},removeDashJS:function(U){var O=A(U);dt[O]?dt[O].removeDashJS():d.error("A monitor for `"+O+"` has not been initialized.")},init:function(U,O){E()&&O&&O.respectDoNotTrack&&d.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var w=A(U);dt[w]=new yi(Ut,w,O)},emit:function(U,O,w){var W=A(U);dt[W]?(dt[W].emit(O,w),O==="destroy"&&delete dt[W]):d.error("A monitor for `"+W+"` has not been initialized.")},checkDoNotTrack:E,log:d,utils:ki,events:Fi,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(Ut,Bi),M()!==void 0&&typeof M().addEventListener=="function"&&M().addEventListener("pagehide",function(U){U.persisted||(Ut.WINDOW_UNLOADING=!0)},!1);var Ni=Ut},655:function(N,T,C){var L,M;function P(B){return P=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(A){return typeof A}:function(A){return A&&typeof Symbol=="function"&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":typeof A},P(B);}(function(B){var A=!1;if((M=typeof(L=B)=="function"?L.call(T,C,T,N):L)===void 0||(N.exports=M),A=!0,P(T)==="object"&&(N.exports=B(),A=!0),!A){var D=window.Cookies,x=window.Cookies=B();x.noConflict=function(){return window.Cookies=D,x}}})(function(){var B=function(){for(var A=0,D={};A<arguments.length;A++){var x=arguments[A];for(var _ in x)D[_]=x[_]}return D};return function A(D){function x(_,S,d){var E;if(typeof document!="undefined"){if(arguments.length>1){if(typeof(d=B({path:"/"},x.defaults,d)).expires=="number"){var p=new Date;p.setMilliseconds(p.getMilliseconds()+864e5*d.expires),d.expires=p}try{E=JSON.stringify(S),/^[\{\[]/.test(E)&&(S=E)}catch{}return S=D.write?D.write(S,_):encodeURIComponent(String(S)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),_=(_=(_=encodeURIComponent(String(_))).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent)).replace(/[\(\)]/g,escape),document.cookie=[_,"=",S,d.expires?"; expires="+d.expires.toUTCString():"",d.path?"; path="+d.path:"",d.domain?"; domain="+d.domain:"",d.secure?"; secure":""].join("")}_||(E={});for(var h=document.cookie?document.cookie.split("; "):[],a=/(%[0-9A-Z]{2})+/g,o=0;o<h.length;o++){var n=h[o].split("="),v=n.slice(1).join("=");v.charAt(0)==='"'&&(v=v.slice(1,-1));try{var l=n[0].replace(a,decodeURIComponent);if(v=D.read?D.read(v,l):D(v,l)||v.replace(a,decodeURIComponent),this.json)try{v=JSON.parse(v)}catch{}if(_===l){E=v;break}_||(E[l]=v)}catch{}}return E}}return x.set=x,x.get=function(_){return x.call(x,_)},x.getJSON=function(){return x.apply({json:!0},[].slice.call(arguments))},x.defaults={},x.remove=function(_,S){x(_,"",B(S,{expires:-1}))},x.withConverter=A,x}(function(){})})},153:function(N,T,C){var L,M=C.g!==void 0?C.g:typeof window!="undefined"?window:{},P=C(558);typeof document!="undefined"?L=document:(L=M["__GLOBAL_DOCUMENT_CACHE@4"])||(L=M["__GLOBAL_DOCUMENT_CACHE@4"]=P),N.exports=L},48:function(N,T,C){var L;L=typeof window!="undefined"?window:C.g!==void 0?C.g:typeof self!="undefined"?self:{},N.exports=L},678:function(N){var T=9007199254740991,C="[object Arguments]",L="[object Function]",M="[object GeneratorFunction]",P=/^(?:0|[1-9]\d*)$/;function B(e,r,t){switch(t.length){case 0:return e.call(r);case 1:return e.call(r,t[0]);case 2:return e.call(r,t[0],t[1]);case 3:return e.call(r,t[0],t[1],t[2])}return e.apply(r,t)}var A,D,x=Object.prototype,_=x.hasOwnProperty,S=x.toString,d=x.propertyIsEnumerable,E=(A=Object.keys,D=Object,function(e){return A(D(e))}),p=Math.max,h=!d.call({valueOf:1},"valueOf");function a(e,r){var t=i(e)||function(b){return function(R){return function(I){return!!I&&typeof I=="object"}(R)&&u(R)}(b)&&_.call(b,"callee")&&(!d.call(b,"callee")||S.call(b)==C)}(e)?function(b,R){for(var I=-1,k=Array(b);++I<b;)k[I]=R(I);return k}(e.length,String):[],s=t.length,y=!!s;for(var f in e)!r&&!_.call(e,f)||y&&(f=="length"||n(f,s))||t.push(f);return t}function o(e,r,t){var s=e[r];_.call(e,r)&&l(s,t)&&(t!==void 0||r in e)||(e[r]=t)}function n(e,r){return!!(r=r==null?T:r)&&(typeof e=="number"||P.test(e))&&e>-1&&e%1==0&&e<r}function v(e){var r=e&&e.constructor;return e===(typeof r=="function"&&r.prototype||x)}function l(e,r){return e===r||e!=e&&r!=r}var i=Array.isArray;function u(e){return e!=null&&function(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=T}(e.length)&&!function(r){var t=g(r)?S.call(r):"";return t==L||t==M}(e)}function g(e){var r=typeof e;return!!e&&(r=="object"||r=="function")}var c,m=(c=function(e,r){if(h||v(r)||u(r))(function(s,y,f,b){f||(f={});for(var R=-1,I=y.length;++R<I;){var k=y[R],F=b?b(f[k],s[k],k,f,s):void 0;o(f,k,F===void 0?s[k]:F)}})(r,function(s){return u(s)?a(s):function(y){if(!v(y))return E(y);var f=[];for(var b in Object(y))_.call(y,b)&&b!="constructor"&&f.push(b);return f}(s)}(r),e);else for(var t in r)_.call(r,t)&&o(e,t,r[t])},function(e,r){return r=p(r===void 0?e.length-1:r,0),function(){for(var t=arguments,s=-1,y=p(t.length-r,0),f=Array(y);++s<y;)f[s]=t[r+s];s=-1;for(var b=Array(r+1);++s<r;)b[s]=t[s];return b[r]=f,B(e,this,b)}}(function(e,r){var t=-1,s=r.length,y=s>1?r[s-1]:void 0,f=s>2?r[2]:void 0;for(y=c.length>3&&typeof y=="function"?(s--,y):void 0,f&&function(R,I,k){if(!g(k))return!1;var F=typeof I;return!!(F=="number"?u(k)&&n(I,k.length):F=="string"&&I in k)&&l(k[I],R)}(r[0],r[1],f)&&(y=s<3?void 0:y,s=1),e=Object(e);++t<s;){var b=r[t];b&&c(e,b,t,y)}return e}));N.exports=m},640:function(N,T,C){var L,M;(function(P,B){"use strict";L=function(){var A=function(){},D="undefined",x=typeof window!==D&&typeof window.navigator!==D&&/Trident\/|MSIE /.test(window.navigator.userAgent),_=["trace","debug","info","warn","error"];function S(i,u){var g=i[u];if(typeof g.bind=="function")return g.bind(i);try{return Function.prototype.bind.call(g,i)}catch{return function(){return Function.prototype.apply.apply(g,[i,arguments])}}}function d(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function E(i){return i==="debug"&&(i="log"),typeof console!==D&&(i==="trace"&&x?d:console[i]!==void 0?S(console,i):console.log!==void 0?S(console,"log"):A)}function p(i,u){for(var g=0;g<_.length;g++){var c=_[g];this[c]=g<i?A:this.methodFactory(c,i,u)}this.log=this.debug}function h(i,u,g){return function(){typeof console!==D&&(p.call(this,u,g),this[i].apply(this,arguments))}}function a(i,u,g){return E(i)||h.apply(this,arguments)}function o(i,u,g){var c,m=this;u=u==null?"WARN":u;var e="loglevel";function r(f){var b=(_[f]||"silent").toUpperCase();if(typeof window!==D&&e){try{return void(window.localStorage[e]=b)}catch{}try{window.document.cookie=encodeURIComponent(e)+"="+b+";"}catch{}}}function t(){var f;if(typeof window!==D&&e){try{f=window.localStorage[e]}catch{}if(typeof f===D)try{var b=window.document.cookie,R=b.indexOf(encodeURIComponent(e)+"=");R!==-1&&(f=/^([^;]+)/.exec(b.slice(R))[1])}catch{}return m.levels[f]===void 0&&(f=void 0),f}}function s(){if(typeof window!==D&&e){try{return void window.localStorage.removeItem(e)}catch{}try{window.document.cookie=encodeURIComponent(e)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}typeof i=="string"?e+=":"+i:typeof i=="symbol"&&(e=void 0),m.name=i,m.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},m.methodFactory=g||a,m.getLevel=function(){return c},m.setLevel=function(f,b){if(typeof f=="string"&&m.levels[f.toUpperCase()]!==void 0&&(f=m.levels[f.toUpperCase()]),!(typeof f=="number"&&f>=0&&f<=m.levels.SILENT))throw"log.setLevel() called with invalid level: "+f;if(c=f,b!==!1&&r(f),p.call(m,f,i),typeof console===D&&f<m.levels.SILENT)return"No console available for logging"},m.setDefaultLevel=function(f){u=f,t()||m.setLevel(f,!1)},m.resetLevel=function(){m.setLevel(u,!1),s()},m.enableAll=function(f){m.setLevel(m.levels.TRACE,f)},m.disableAll=function(f){m.setLevel(m.levels.SILENT,f)};var y=t();y==null&&(y=u),m.setLevel(y,!1)}var n=new o,v={};n.getLogger=function(i){if(typeof i!="symbol"&&typeof i!="string"||i==="")throw new TypeError("You must supply a name when creating a logger.");var u=v[i];return u||(u=v[i]=new o(i,n.getLevel(),n.methodFactory)),u};var l=typeof window!==D?window.log:void 0;return n.noConflict=function(){return typeof window!==D&&window.log===n&&(window.log=l),n},n.getLoggers=function(){return v},n.default=n,n},(M=typeof L=="function"?L.call(T,C,T,N):L)===void 0||(N.exports=M)})()},375:function(N,T){"use strict";var C=Object.prototype.hasOwnProperty;function L(P){try{return decodeURIComponent(P.replace(/\+/g," "))}catch{return null}}function M(P){try{return encodeURIComponent(P)}catch{return null}}T.stringify=function(P,B){B=B||"";var A,D,x=[];for(D in typeof B!="string"&&(B="?"),P)if(C.call(P,D)){if((A=P[D])||A!=null&&!isNaN(A)||(A=""),D=M(D),A=M(A),D===null||A===null)continue;x.push(D+"="+A)}return x.length?B+x.join("&"):""},T.parse=function(P){for(var B,A=/([^=?#&]+)=?([^&]*)/g,D={};B=A.exec(P);){var x=L(B[1]),_=L(B[2]);x===null||_===null||x in D||(D[x]=_)}return D}},558:function(){}},se={};function z(N){var T=se[N];if(T!==void 0)return T.exports;var C=se[N]={exports:{}};return ie[N].call(C.exports,C,C.exports,z),C.exports}return z.n=function(N){var T=N&&N.__esModule?function(){return N.default}:function(){return N};return z.d(T,{a:T}),T},z.d=function(N,T){for(var C in T)z.o(T,C)&&!z.o(N,C)&&Object.defineProperty(N,C,{enumerable:!0,get:T[C]})},z.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),z.o=function(N,T){return Object.prototype.hasOwnProperty.call(N,T)},z(80)}()},typeof Qt=="object"&&typeof vr=="object"?vr.exports=ee():typeof Qt=="object"?Qt.mux=ee():J.mux=ee()})()});var $t=Fr((Nt,gr)=>{typeof window!="undefined"&&function(ee,ie){typeof Nt=="object"&&typeof gr=="object"?gr.exports=ie():typeof define=="function"&&define.amd?define([],ie):typeof Nt=="object"?Nt.Hls=ie():ee.Hls=ie()}(Nt,()=>(()=>{var J={"./src/config.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{enableStreamingMode:()=>r,hlsDefaultConfig:()=>c,mergeConfig:()=>e});var C=T("./src/controller/abr-controller.ts"),L=T("./src/controller/audio-stream-controller.ts"),M=T("./src/controller/audio-track-controller.ts"),P=T("./src/controller/subtitle-stream-controller.ts"),B=T("./src/controller/subtitle-track-controller.ts"),A=T("./src/controller/buffer-controller.ts"),D=T("./src/controller/timeline-controller.ts"),x=T("./src/controller/cap-level-controller.ts"),_=T("./src/controller/fps-controller.ts"),S=T("./src/controller/eme-controller.ts"),d=T("./src/controller/cmcd-controller.ts"),E=T("./src/utils/xhr-loader.ts"),p=T("./src/utils/fetch-loader.ts"),h=T("./src/utils/cues.ts"),a=T("./src/utils/mediakeys-helper.ts"),o=T("./src/utils/logger.ts");function n(){return n=Object.assign?Object.assign.bind():function(t){for(var s=1;s<arguments.length;s++){var y=arguments[s];for(var f in y)Object.prototype.hasOwnProperty.call(y,f)&&(t[f]=y[f])}return t},n.apply(this,arguments)}function v(t,s){var y=Object.keys(t);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(t);s&&(f=f.filter(function(b){return Object.getOwnPropertyDescriptor(t,b).enumerable})),y.push.apply(y,f)}return y}function l(t){for(var s=1;s<arguments.length;s++){var y=arguments[s]!=null?arguments[s]:{};s%2?v(Object(y),!0).forEach(function(f){i(t,f,y[f])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(y)):v(Object(y)).forEach(function(f){Object.defineProperty(t,f,Object.getOwnPropertyDescriptor(y,f))})}return t}function i(t,s,y){return s=u(s),s in t?Object.defineProperty(t,s,{value:y,enumerable:!0,configurable:!0,writable:!0}):t[s]=y,t}function u(t){var s=g(t,"string");return typeof s=="symbol"?s:String(s)}function g(t,s){if(typeof t!="object"||t===null)return t;var y=t[Symbol.toPrimitive];if(y!==void 0){var f=y.call(t,s||"default");if(typeof f!="object")return f;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(t)}var c=l(l({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,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:void 0,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:E.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:C.default,bufferController:A.default,capLevelController:x.default,fpsController:_.default,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:a.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0},m()),{},{subtitleStreamController:P.SubtitleStreamController,subtitleTrackController:B.default,timelineController:D.TimelineController,audioStreamController:L.default,audioTrackController:M.default,emeController:S.default,cmcdController:d.default});function m(){return{cueHandler:h.default,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 e(t,s){if((s.liveSyncDurationCount||s.liveMaxLatencyDurationCount)&&(s.liveSyncDuration||s.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(s.liveMaxLatencyDurationCount!==void 0&&(s.liveSyncDurationCount===void 0||s.liveMaxLatencyDurationCount<=s.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(s.liveMaxLatencyDuration!==void 0&&(s.liveSyncDuration===void 0||s.liveMaxLatencyDuration<=s.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return n({},t,s)}function r(t){var s=t.loader;if(s!==p.default&&s!==E.default)o.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),t.progressive=!1;else{var y=(0,p.fetchSupported)();y&&(t.loader=p.default,t.progressive=!0,t.enableSoftwareAES=!0,o.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>E});var C=T("./src/polyfills/number.ts"),L=T("./src/utils/ewma-bandwidth-estimator.ts"),M=T("./src/events.ts"),P=T("./src/errors.ts"),B=T("./src/types/loader.ts"),A=T("./src/utils/logger.ts");function D(p,h){for(var a=0;a<h.length;a++){var o=h[a];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(p,_(o.key),o)}}function x(p,h,a){return h&&D(p.prototype,h),a&&D(p,a),Object.defineProperty(p,"prototype",{writable:!1}),p}function _(p){var h=S(p,"string");return typeof h=="symbol"?h:String(h)}function S(p,h){if(typeof p!="object"||p===null)return p;var a=p[Symbol.toPrimitive];if(a!==void 0){var o=a.call(p,h||"default");if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(h==="string"?String:Number)(p)}var d=function(){function p(a){this.hls=void 0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=void 0,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=a;var o=a.config;this.bwEstimator=new L.default(o.abrEwmaSlowVoD,o.abrEwmaFastVoD,o.abrEwmaDefaultEstimate),this.registerListeners()}var h=p.prototype;return h.registerListeners=function(){var o=this.hls;o.on(M.Events.FRAG_LOADING,this.onFragLoading,this),o.on(M.Events.FRAG_LOADED,this.onFragLoaded,this),o.on(M.Events.FRAG_BUFFERED,this.onFragBuffered,this),o.on(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),o.on(M.Events.ERROR,this.onError,this)},h.unregisterListeners=function(){var o=this.hls;o.off(M.Events.FRAG_LOADING,this.onFragLoading,this),o.off(M.Events.FRAG_LOADED,this.onFragLoaded,this),o.off(M.Events.FRAG_BUFFERED,this.onFragBuffered,this),o.off(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),o.off(M.Events.ERROR,this.onError,this)},h.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},h.onFragLoading=function(o,n){var v=n.frag;if(v.type===B.PlaylistLevelType.MAIN&&!this.timer){var l;this.fragCurrent=v,this.partCurrent=(l=n.part)!=null?l:null,this.timer=self.setInterval(this.onCheck,100)}},h.onLevelLoaded=function(o,n){var v=this.hls.config;n.details.live?this.bwEstimator.update(v.abrEwmaSlowLive,v.abrEwmaFastLive):this.bwEstimator.update(v.abrEwmaSlowVoD,v.abrEwmaFastVoD)},h._abandonRulesCheck=function(){var o=this.fragCurrent,n=this.partCurrent,v=this.hls,l=v.autoLevelEnabled,i=v.media;if(!(!o||!i)){var u=n?n.stats:o.stats,g=n?n.duration:o.duration;if(u.aborted||u.loaded&&u.loaded===u.total||o.level===0){this.clearTimer(),this._nextAutoLevel=-1;return}if(!(!l||i.paused||!i.playbackRate||!i.readyState)){var c=v.mainForwardBufferInfo;if(c!==null){var m=performance.now()-u.loading.start,e=Math.abs(i.playbackRate);if(!(m<=500*g/e)){var r=u.loaded&&u.loading.first,t=this.bwEstimator.getEstimate(),s=v.levels,y=v.minAutoLevel,f=s[o.level],b=u.total||Math.max(u.loaded,Math.round(g*f.maxBitrate/8)),R=r?u.loaded*1e3/m:0,I=R?(b-u.loaded)/R:b*8/t,k=c.len/e;if(!(I<=k)){var F=Number.POSITIVE_INFINITY,K;for(K=o.level-1;K>y;K--){var H=s[K].maxBitrate;if(F=R?g*H/(8*.8*R):g*H/t,F<k)break}F>=I||(A.logger.warn("Fragment "+o.sn+(n?" part "+n.index:"")+" of level "+o.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+K+`
9
9
  Current BW estimate: `+((0,C.isFiniteNumber)(t)?(t/1024).toFixed(3):"Unknown")+` Kb/s
10
10
  Estimated load time for current fragment: `+I.toFixed(3)+` s
11
11
  Estimated load time for the next fragment: `+F.toFixed(3)+` s
@@ -18,7 +18,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
18
18
  accurateTimeOffset: `+u+`
19
19
  timeOffset: `+y+`
20
20
  initSegmentChange: `+Y);var q=new M.TransmuxConfig(o,n,a,i,c);this.configureTransmuxer(q)}if(this.frag=v,this.part=l,s)s.postMessage({cmd:"demux",data:h,decryptdata:f,chunkMeta:g,state:Q},h instanceof ArrayBuffer?[h]:[]);else if(t){var ne=t.push(h,f,g,Q);(0,M.isPromise)(ne)?(t.async=!0,ne.then(function(te){r.handleTransmuxComplete(te)}).catch(function(te){r.transmuxerError(te,g,"transmuxer-interface push error")})):(t.async=!1,this.handleTransmuxComplete(ne))}},E.flush=function(h){var a=this;h.transmuxing.start=self.performance.now();var o=this.transmuxer,n=this.worker;if(n)n.postMessage({cmd:"flush",chunkMeta:h});else if(o){var v=o.flush(h),l=(0,M.isPromise)(v);l||o.async?((0,M.isPromise)(v)||(v=Promise.resolve(v)),v.then(function(i){a.handleFlushResult(i,h)}).catch(function(i){a.transmuxerError(i,h,"transmuxer-interface flush error")})):this.handleFlushResult(v,h)}},E.transmuxerError=function(h,a,o){!this.hls||this.hls.trigger(L.Events.ERROR,{type:B.ErrorTypes.MEDIA_ERROR,details:B.ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:a,fatal:!1,error:h,err:h,reason:o})},E.handleFlushResult=function(h,a){var o=this;h.forEach(function(n){o.handleTransmuxComplete(n)}),this.onFlush(a)},E.onWorkerMessage=function(h){var a=h.data,o=this.hls;switch(a.event){case"init":{self.URL.revokeObjectURL(this.worker.objectURL);break}case"transmuxComplete":{this.handleTransmuxComplete(a.data);break}case"flush":{this.onFlush(a.data);break}case"workerLog":P.logger[a.data.logType]&&P.logger[a.data.logType](a.data.message);break;default:{a.data=a.data||{},a.data.frag=this.frag,a.data.id=this.id,o.trigger(a.event,a.data);break}}},E.configureTransmuxer=function(h){var a=this.worker,o=this.transmuxer;a?a.postMessage({cmd:"configure",config:h}):o&&o.configure(h)},E.handleTransmuxComplete=function(h){h.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(h)},d}()},"./src/demux/transmuxer-worker.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>D});var C=T("./src/demux/transmuxer.ts"),L=T("./src/events.ts"),M=T("./src/utils/logger.ts"),P=T("./node_modules/eventemitter3/index.js"),B=T.n(P),A=T("./src/errors.ts");function D(E){var p=new P.EventEmitter,h=function(n,v){E.postMessage({event:n,data:v})};p.on(L.Events.FRAG_DECRYPTED,h),p.on(L.Events.ERROR,h);var a=function(){var n=function(i){var u=function(c){h("workerLog",{logType:i,message:c})};M.logger[i]=u};for(var v in M.logger)n(v)};E.addEventListener("message",function(o){var n=o.data;switch(n.cmd){case"init":{var v=JSON.parse(n.config);E.transmuxer=new C.default(p,n.typeSupported,v,n.vendor,n.id),(0,M.enableLogs)(v.debug,n.id),a(),h("init",null);break}case"configure":{E.transmuxer.configure(n.config);break}case"demux":{var l=E.transmuxer.push(n.data,n.decryptdata,n.chunkMeta,n.state);(0,C.isPromise)(l)?(E.transmuxer.async=!0,l.then(function(c){x(E,c)}).catch(function(c){h(L.Events.ERROR,{type:A.ErrorTypes.MEDIA_ERROR,details:A.ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:n.chunkMeta,fatal:!1,error:c,err:c,reason:"transmuxer-worker push error"})})):(E.transmuxer.async=!1,x(E,l));break}case"flush":{var i=n.chunkMeta,u=E.transmuxer.flush(i),g=(0,C.isPromise)(u);g||E.transmuxer.async?((0,C.isPromise)(u)||(u=Promise.resolve(u)),u.then(function(c){S(E,c,i)}).catch(function(c){h(L.Events.ERROR,{type:A.ErrorTypes.MEDIA_ERROR,details:A.ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:n.chunkMeta,fatal:!1,error:c,err:c,reason:"transmuxer-worker flush error"})})):S(E,u,i);break}default:break}})}function x(E,p){if(d(p.remuxResult))return!1;var h=[],a=p.remuxResult,o=a.audio,n=a.video;return o&&_(h,o),n&&_(h,n),E.postMessage({event:"transmuxComplete",data:p},h),!0}function _(E,p){p.data1&&E.push(p.data1.buffer),p.data2&&E.push(p.data2.buffer)}function S(E,p,h){var a=p.reduce(function(o,n){return x(E,n)||o},!1);a||E.postMessage({event:"transmuxComplete",data:p[0]}),E.postMessage({event:"flush",data:h})}function d(E){return!E.audio&&!E.video&&!E.text&&!E.id3&&!E.initSegment}},"./src/demux/transmuxer.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{TransmuxConfig:()=>n,TransmuxState:()=>v,default:()=>p,isPromise:()=>o});var C=T("./src/events.ts"),L=T("./src/errors.ts"),M=T("./src/crypt/decrypter.ts"),P=T("./src/demux/aacdemuxer.ts"),B=T("./src/demux/mp4demuxer.ts"),A=T("./src/demux/tsdemuxer.ts"),D=T("./src/demux/mp3demuxer.ts"),x=T("./src/remux/mp4-remuxer.ts"),_=T("./src/remux/passthrough-remuxer.ts"),S=T("./src/utils/logger.ts"),d;try{d=self.performance.now.bind(self.performance)}catch{S.logger.debug("Unable to use Performance API on this environment"),d=self.Date.now}var E=[{demux:B.default,remux:_.default},{demux:A.default,remux:x.default},{demux:P.default,remux:x.default},{demux:D.default,remux:x.default}],p=function(){function l(u,g,c,m,e){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=u,this.typeSupported=g,this.config=c,this.vendor=m,this.id=e}var i=l.prototype;return i.configure=function(g){this.transmuxConfig=g,this.decrypter&&this.decrypter.reset()},i.push=function(g,c,m,e){var r=this,t=m.transmuxing;t.executeStart=d();var s=new Uint8Array(g),y=this.currentTransmuxState,f=this.transmuxConfig;e&&(this.currentTransmuxState=e);var b=e||y,R=b.contiguous,I=b.discontinuity,k=b.trackSwitch,F=b.accurateTimeOffset,K=b.timeOffset,H=b.initSegmentChange,j=f.audioCodec,Y=f.videoCodec,Q=f.defaultInitPts,q=f.duration,ne=f.initSegmentData,te=h(s,c);if(te&&te.method==="AES-128"){var ae=this.getDecrypter();if(ae.isSync()){var ue=ae.softwareDecrypt(s,te.key.buffer,te.iv.buffer);if(!ue)return t.executeEnd=d(),a(m);s=new Uint8Array(ue)}else return this.decryptionPromise=ae.webCryptoDecrypt(s,te.key.buffer,te.iv.buffer).then(function(de){var xe=r.push(de,null,m);return r.decryptionPromise=null,xe}),this.decryptionPromise}var ce=this.needsProbing(I,k);ce&&this.configureTransmuxer(s),(I||k||H||ce)&&this.resetInitSegment(ne,j,Y,q,c),(I||H||ce)&&this.resetInitialTimestamp(Q),R||this.resetContiguity();var le=this.transmux(s,te,K,F,m),fe=this.currentTransmuxState;return fe.contiguous=!0,fe.discontinuity=!1,fe.trackSwitch=!1,t.executeEnd=d(),le},i.flush=function(g){var c=this,m=g.transmuxing;m.executeStart=d();var e=this.decrypter,r=this.currentTransmuxState,t=this.decryptionPromise;if(t)return t.then(function(){return c.flush(g)});var s=[],y=r.timeOffset;if(e){var f=e.flush();f&&s.push(this.push(f,null,g))}var b=this.demuxer,R=this.remuxer;if(!b||!R)return this.observer.emit(C.Events.ERROR,C.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),m.executeEnd=d(),[a(g)];var I=b.flush(y);return o(I)?I.then(function(k){return c.flushRemux(s,k,g),s}):(this.flushRemux(s,I,g),s)},i.flushRemux=function(g,c,m){var e=c.audioTrack,r=c.videoTrack,t=c.id3Track,s=c.textTrack,y=this.currentTransmuxState,f=y.accurateTimeOffset,b=y.timeOffset;S.logger.log("[transmuxer.ts]: Flushed fragment "+m.sn+(m.part>-1?" p: "+m.part:"")+" of level "+m.level);var R=this.remuxer.remux(e,r,t,s,b,f,!0,this.id);g.push({remuxResult:R,chunkMeta:m}),m.transmuxing.executeEnd=d()},i.resetInitialTimestamp=function(g){var c=this.demuxer,m=this.remuxer;!c||!m||(c.resetTimeStamp(g),m.resetTimeStamp(g))},i.resetContiguity=function(){var g=this.demuxer,c=this.remuxer;!g||!c||(g.resetContiguity(),c.resetNextTimestamp())},i.resetInitSegment=function(g,c,m,e,r){var t=this.demuxer,s=this.remuxer;!t||!s||(t.resetInitSegment(g,c,m,e),s.resetInitSegment(g,c,m,r))},i.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},i.transmux=function(g,c,m,e,r){var t;return c&&c.method==="SAMPLE-AES"?t=this.transmuxSampleAes(g,c,m,e,r):t=this.transmuxUnencrypted(g,m,e,r),t},i.transmuxUnencrypted=function(g,c,m,e){var r=this.demuxer.demux(g,c,!1,!this.config.progressive),t=r.audioTrack,s=r.videoTrack,y=r.id3Track,f=r.textTrack,b=this.remuxer.remux(t,s,y,f,c,m,!1,this.id);return{remuxResult:b,chunkMeta:e}},i.transmuxSampleAes=function(g,c,m,e,r){var t=this;return this.demuxer.demuxSampleAes(g,c,m).then(function(s){var y=t.remuxer.remux(s.audioTrack,s.videoTrack,s.id3Track,s.textTrack,m,e,!1,t.id);return{remuxResult:y,chunkMeta:r}})},i.configureTransmuxer=function(g){for(var c=this.config,m=this.observer,e=this.typeSupported,r=this.vendor,t,s=0,y=E.length;s<y;s++)if(E[s].demux.probe(g)){t=E[s];break}t||(S.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),t={demux:B.default,remux:_.default});var f=this.demuxer,b=this.remuxer,R=t.remux,I=t.demux;(!b||!(b instanceof R))&&(this.remuxer=new R(m,c,e,r)),(!f||!(f instanceof I))&&(this.demuxer=new I(m,c,e),this.probe=I.probe)},i.needsProbing=function(g,c){return!this.demuxer||!this.remuxer||g||c},i.getDecrypter=function(){var g=this.decrypter;return g||(g=this.decrypter=new M.default(this.config)),g},l}();function h(l,i){var u=null;return l.byteLength>0&&i!=null&&i.key!=null&&i.iv!==null&&i.method!=null&&(u=i),u}var a=function(i){return{remuxResult:{},chunkMeta:i}};function o(l){return"then"in l&&l.then instanceof Function}var n=function(i,u,g,c,m){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=i,this.videoCodec=u,this.initSegmentData=g,this.duration=c,this.defaultInitPts=m},v=function(i,u,g,c,m,e){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=i,this.contiguous=u,this.accurateTimeOffset=g,this.trackSwitch=c,this.timeOffset=m,this.initSegmentChange=e}},"./src/demux/tsdemuxer.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>v});var C=T("./src/demux/adts.ts"),L=T("./src/demux/mpegaudio.ts"),M=T("./src/demux/exp-golomb.ts"),P=T("./src/demux/sample-aes.ts"),B=T("./src/events.ts"),A=T("./src/utils/mp4-tools.ts"),D=T("./src/utils/logger.ts"),x=T("./src/errors.ts"),_=T("./src/types/demuxer.ts");function S(){return S=Object.assign?Object.assign.bind():function(l){for(var i=1;i<arguments.length;i++){var u=arguments[i];for(var g in u)Object.prototype.hasOwnProperty.call(u,g)&&(l[g]=u[g])}return l},S.apply(this,arguments)}var d=188,E=function(){function l(u,g,c){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=u,this.config=g,this.typeSupported=c}l.probe=function(g){var c=l.syncOffset(g);return c>0&&D.logger.warn("MPEG2-TS detected but first sync word found @ offset "+c),c!==-1},l.syncOffset=function(g){for(var c=Math.min(d*5,g.length-d*2)+1,m=0;m<c;){if(g[m]===71&&g[m+d]===71)return m;m++}return-1},l.createTrack=function(g,c){return{container:g==="video"||g==="audio"?"video/mp2t":void 0,type:g,id:A.RemuxerTrackIdConfig[g],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:g==="audio"?c:void 0}};var i=l.prototype;return i.resetInitSegment=function(g,c,m,e){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=l.createTrack("video"),this._audioTrack=l.createTrack("audio",e),this._id3Track=l.createTrack("id3"),this._txtTrack=l.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=c,this.videoCodec=m,this._duration=e},i.resetTimeStamp=function(){},i.resetContiguity=function(){var g=this._audioTrack,c=this._avcTrack,m=this._id3Track;g&&(g.pesData=null),c&&(c.pesData=null),m&&(m.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null},i.demux=function(g,c,m,e){m===void 0&&(m=!1),e===void 0&&(e=!1),m||(this.sampleAes=null);var r,t=this._avcTrack,s=this._audioTrack,y=this._id3Track,f=this._txtTrack,b=t.pid,R=t.pesData,I=s.pid,k=y.pid,F=s.pesData,K=y.pesData,H=null,j=this.pmtParsed,Y=this._pmtId,Q=g.length;if(this.remainderData&&(g=(0,A.appendUint8Array)(this.remainderData,g),Q=g.length,this.remainderData=null),Q<d&&!e)return this.remainderData=g,{audioTrack:s,videoTrack:t,id3Track:y,textTrack:f};var q=Math.max(0,l.syncOffset(g));Q-=(Q-q)%d,Q<g.byteLength&&!e&&(this.remainderData=new Uint8Array(g.buffer,Q,g.buffer.byteLength-Q));for(var ne=0,te=q;te<Q;te+=d)if(g[te]===71){var ae=!!(g[te+1]&64),ue=((g[te+1]&31)<<8)+g[te+2],ce=(g[te+3]&48)>>4,le=void 0;if(ce>1){if(le=te+5+g[te+4],le===te+d)continue}else le=te+4;switch(ue){case b:ae&&(R&&(r=o(R))&&this.parseAVCPES(t,f,r,!1),R={data:[],size:0}),R&&(R.data.push(g.subarray(le,te+d)),R.size+=te+d-le);break;case I:if(ae){if(F&&(r=o(F)))switch(s.segmentCodec){case"aac":this.parseAACPES(s,r);break;case"mp3":this.parseMPEGPES(s,r);break}F={data:[],size:0}}F&&(F.data.push(g.subarray(le,te+d)),F.size+=te+d-le);break;case k:ae&&(K&&(r=o(K))&&this.parseID3PES(y,r),K={data:[],size:0}),K&&(K.data.push(g.subarray(le,te+d)),K.size+=te+d-le);break;case 0:ae&&(le+=g[le]+1),Y=this._pmtId=h(g,le);break;case Y:{ae&&(le+=g[le]+1);var fe=a(g,le,this.typeSupported,m);b=fe.avc,b>0&&(t.pid=b),I=fe.audio,I>0&&(s.pid=I,s.segmentCodec=fe.segmentCodec),k=fe.id3,k>0&&(y.pid=k),H!==null&&!j&&(D.logger.log("unknown PID '"+H+"' in TS found"),H=null,te=q-188),j=this.pmtParsed=!0;break}case 17:case 8191:break;default:H=ue;break}}else ne++;ne>0&&this.observer.emit(B.Events.ERROR,B.Events.ERROR,{type:x.ErrorTypes.MEDIA_ERROR,details:x.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"Found "+ne+" TS packet/s that do not start with 0x47"}),t.pesData=R,s.pesData=F,y.pesData=K;var de={audioTrack:s,videoTrack:t,id3Track:y,textTrack:f};return e&&this.extractRemainingSamples(de),de},i.flush=function(){var g=this.remainderData;this.remainderData=null;var c;return g?c=this.demux(g,-1,!1,!0):c={videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(c),this.sampleAes?this.decrypt(c,this.sampleAes):c},i.extractRemainingSamples=function(g){var c=g.audioTrack,m=g.videoTrack,e=g.id3Track,r=g.textTrack,t=m.pesData,s=c.pesData,y=e.pesData,f;if(t&&(f=o(t))?(this.parseAVCPES(m,r,f,!0),m.pesData=null):m.pesData=t,s&&(f=o(s))){switch(c.segmentCodec){case"aac":this.parseAACPES(c,f);break;case"mp3":this.parseMPEGPES(c,f);break}c.pesData=null}else s!=null&&s.size&&D.logger.log("last AAC PES packet truncated,might overlap between fragments"),c.pesData=s;y&&(f=o(y))?(this.parseID3PES(e,f),e.pesData=null):e.pesData=y},i.demuxSampleAes=function(g,c,m){var e=this.demux(g,m,!0,!this.config.progressive),r=this.sampleAes=new P.default(this.observer,this.config,c);return this.decrypt(e,r)},i.decrypt=function(g,c){return new Promise(function(m){var e=g.audioTrack,r=g.videoTrack;e.samples&&e.segmentCodec==="aac"?c.decryptAacSamples(e.samples,0,function(){r.samples?c.decryptAvcSamples(r.samples,0,0,function(){m(g)}):m(g)}):r.samples&&c.decryptAvcSamples(r.samples,0,0,function(){m(g)})})},i.destroy=function(){this._duration=0},i.parseAVCPES=function(g,c,m,e){var r=this,t=this.parseAVCNALu(g,m.data),s=!1,y=this.avcSample,f,b=!1;m.data=null,y&&t.length&&!g.audFound&&(n(y,g),y=this.avcSample=p(!1,m.pts,m.dts,"")),t.forEach(function(R){switch(R.type){case 1:{f=!0,y||(y=r.avcSample=p(!0,m.pts,m.dts,"")),s&&(y.debug+="NDR "),y.frame=!0;var I=R.data;if(b&&I.length>4){var k=new M.default(I).readSliceType();(k===2||k===4||k===7||k===9)&&(y.key=!0)}break}case 5:f=!0,y||(y=r.avcSample=p(!0,m.pts,m.dts,"")),s&&(y.debug+="IDR "),y.key=!0,y.frame=!0;break;case 6:{f=!0,s&&y&&(y.debug+="SEI "),(0,A.parseSEIMessageFromNALu)(R.data,1,m.pts,c.samples);break}case 7:if(f=!0,b=!0,s&&y&&(y.debug+="SPS "),!g.sps){var F=new M.default(R.data),K=F.readSPS();g.width=K.width,g.height=K.height,g.pixelRatio=K.pixelRatio,g.sps=[R.data],g.duration=r._duration;for(var H=R.data.subarray(1,4),j="avc1.",Y=0;Y<3;Y++){var Q=H[Y].toString(16);Q.length<2&&(Q="0"+Q),j+=Q}g.codec=j}break;case 8:f=!0,s&&y&&(y.debug+="PPS "),g.pps||(g.pps=[R.data]);break;case 9:f=!1,g.audFound=!0,y&&n(y,g),y=r.avcSample=p(!1,m.pts,m.dts,s?"AUD ":"");break;case 12:f=!0;break;default:f=!1,y&&(y.debug+="unknown NAL "+R.type+" ");break}if(y&&f){var q=y.units;q.push(R)}}),e&&y&&(n(y,g),this.avcSample=null)},i.getLastNalUnit=function(g){var c,m=this.avcSample,e;if((!m||m.units.length===0)&&(m=g[g.length-1]),(c=m)!==null&&c!==void 0&&c.units){var r=m.units;e=r[r.length-1]}return e},i.parseAVCNALu=function(g,c){var m=c.byteLength,e=g.naluState||0,r=e,t=[],s=0,y,f,b,R=-1,I=0;for(e===-1&&(R=0,I=c[0]&31,e=0,s=1);s<m;){if(y=c[s++],!e){e=y?0:1;continue}if(e===1){e=y?0:2;continue}if(!y)e=3;else if(y===1){if(R>=0){var k={data:c.subarray(R,s-e-1),type:I};t.push(k)}else{var F=this.getLastNalUnit(g.samples);if(F&&(r&&s<=4-r&&F.state&&(F.data=F.data.subarray(0,F.data.byteLength-r)),f=s-e-1,f>0)){var K=new Uint8Array(F.data.byteLength+f);K.set(F.data,0),K.set(c.subarray(0,f),F.data.byteLength),F.data=K,F.state=0}}s<m?(b=c[s]&31,R=s,I=b,e=0):e=-1}else e=0}if(R>=0&&e>=0){var H={data:c.subarray(R,m),type:I,state:e};t.push(H)}if(t.length===0){var j=this.getLastNalUnit(g.samples);if(j){var Y=new Uint8Array(j.data.byteLength+c.byteLength);Y.set(j.data,0),Y.set(c,j.data.byteLength),j.data=Y}}return g.naluState=e,t},i.parseAACPES=function(g,c){var m=0,e=this.aacOverFlow,r=c.data;if(e){this.aacOverFlow=null;var t=e.missing,s=e.sample.unit.byteLength;if(t===-1){var y=new Uint8Array(s+r.byteLength);y.set(e.sample.unit,0),y.set(r,s),r=y}else{var f=s-t;e.sample.unit.set(r.subarray(0,t),f),g.samples.push(e.sample),m=e.missing}}var b,R;for(b=m,R=r.length;b<R-1&&!C.isHeader(r,b);b++);if(b!==m){var I,k;if(b<R-1?(I="AAC PES did not start with ADTS header,offset:"+b,k=!1):(I="no ADTS header found in AAC PES",k=!0),D.logger.warn("parsing error:"+I),this.observer.emit(B.Events.ERROR,B.Events.ERROR,{type:x.ErrorTypes.MEDIA_ERROR,details:x.ErrorDetails.FRAG_PARSING_ERROR,fatal:k,reason:I}),k)return}C.initTrackConfig(g,this.observer,r,b,this.audioCodec);var F;if(c.pts!==void 0)F=c.pts;else if(e){var K=C.getFrameDuration(g.samplerate);F=e.sample.pts+K}else{D.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var H=0,j;b<R;)if(j=C.appendFrame(g,r,b,F,H),b+=j.length,j.missing){this.aacOverFlow=j;break}else for(H++;b<R-1&&!C.isHeader(r,b);b++);},i.parseMPEGPES=function(g,c){var m=c.data,e=m.length,r=0,t=0,s=c.pts;if(s===void 0){D.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;t<e;)if(L.isHeader(m,t)){var y=L.appendFrame(g,m,t,s,r);if(y)t+=y.length,r++;else break}else t++},i.parseID3PES=function(g,c){if(c.pts===void 0){D.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}var m=S({},c,{type:this._avcTrack?_.MetadataSchema.emsg:_.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY});g.samples.push(m)},l}();function p(l,i,u,g){return{key:l,frame:!1,pts:i,dts:u,units:[],debug:g,length:0}}function h(l,i){return(l[i+10]&31)<<8|l[i+11]}function a(l,i,u,g){var c={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},m=(l[i+1]&15)<<8|l[i+2],e=i+3+m-4,r=(l[i+10]&15)<<8|l[i+11];for(i+=12+r;i<e;){var t=(l[i+1]&31)<<8|l[i+2];switch(l[i]){case 207:if(!g){D.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:c.audio===-1&&(c.audio=t);break;case 21:c.id3===-1&&(c.id3=t);break;case 219:if(!g){D.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:c.avc===-1&&(c.avc=t);break;case 3:case 4:u.mpeg!==!0&&u.mp3!==!0?D.logger.log("MPEG audio found, not supported in this browser"):c.audio===-1&&(c.audio=t,c.segmentCodec="mp3");break;case 36:D.logger.warn("Unsupported HEVC stream type found");break;default:break}i+=((l[i+3]&15)<<8|l[i+4])+5}return c}function o(l){var i=0,u,g,c,m,e,r=l.data;if(!l||l.size===0)return null;for(;r[0].length<19&&r.length>1;){var t=new Uint8Array(r[0].length+r[1].length);t.set(r[0]),t.set(r[1],r[0].length),r[0]=t,r.splice(1,1)}u=r[0];var s=(u[0]<<16)+(u[1]<<8)+u[2];if(s===1){if(g=(u[4]<<8)+u[5],g&&g>l.size-6)return null;var y=u[7];y&192&&(m=(u[9]&14)*536870912+(u[10]&255)*4194304+(u[11]&254)*16384+(u[12]&255)*128+(u[13]&254)/2,y&64?(e=(u[14]&14)*536870912+(u[15]&255)*4194304+(u[16]&254)*16384+(u[17]&255)*128+(u[18]&254)/2,m-e>54e5&&(D.logger.warn(Math.round((m-e)/9e4)+"s delta between PTS and DTS, align them"),m=e)):e=m),c=u[8];var f=c+9;if(l.size<=f)return null;l.size-=f;for(var b=new Uint8Array(l.size),R=0,I=r.length;R<I;R++){u=r[R];var k=u.byteLength;if(f)if(f>k){f-=k;continue}else u=u.subarray(f),k-=f,f=0;b.set(u,i),i+=k}return g&&(g-=c+3),{data:b,pts:m,dts:e,len:g}}return null}function n(l,i){if(l.units.length&&l.frame){if(l.pts===void 0){var u=i.samples,g=u.length;if(g){var c=u[g-1];l.pts=c.pts,l.dts=c.dts}else{i.dropped++;return}}i.samples.push(l)}l.debug.length&&D.logger.log(l.pts+"/"+l.dts+":"+l.debug)}let v=E},"./src/demux/webworkify-webpack.js":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>d});var C=function(){var p=ENTRY_MODULE,h={},a=function n(v){var l=h[v];if(l!==void 0)return l.exports;var i=h[v]={exports:{}};return p[v].call(i.exports,i,i.exports,n),i.exports};a.m=p,function(){a.n=function(n){var v=n&&n.__esModule?function(){return n.default}:function(){return n};return a.d(v,{a:v}),v}}(),function(){a.d=function(n,v){for(var l in v)a.o(v,l)&&!a.o(n,l)&&Object.defineProperty(n,l,{enumerable:!0,get:v[l]})}}(),function(){a.o=function(n,v){return Object.prototype.hasOwnProperty.call(n,v)}}(),function(){a.r=function(n){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})}}();var o=a(ENTRY_MODULE);return o.default||o},L=C.toString().split("ENTRY_MODULE"),M="[\\.|\\-|\\+|\\w|/|@]+",P="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+M+").*?\\)";function B(E){return(E+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function A(E){return!isNaN(1*E)}function D(E,p,h){var a={};a[h]=[];var o=p.toString().replace(/^"[^"]+"/,"function"),n=o.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/)||o.match(/^\(\w+,\s*\w+,\s*(\w+)\)\s?\=\s?\>/);if(!n)return a;for(var v=n[1],l=new RegExp("(\\\\n|\\W)"+B(v)+P,"g"),i;i=l.exec(o);)i[3]!=="dll-reference"&&a[h].push(i[3]);for(l=new RegExp("\\("+B(v)+'\\("(dll-reference\\s('+M+'))"\\)\\)'+P,"g");i=l.exec(o);)E[i[2]]||(a[h].push(i[1]),E[i[2]]=T(i[1]).m),a[i[2]]=a[i[2]]||[],a[i[2]].push(i[4]);for(var u=Object.keys(a),g=0;g<u.length;g++)for(var c=0;c<a[u[g]].length;c++)A(a[u[g]][c])&&(a[u[g]][c]=1*a[u[g]][c]);return a}function x(E){var p=Object.keys(E);return p.reduce(function(h,a){return h||E[a].length>0},!1)}function _(E,p){for(var h={main:[p]},a={main:[]},o={main:{}};x(h);)for(var n=Object.keys(h),v=0;v<n.length;v++){var l=n[v],i=h[l],u=i.pop();if(o[l]=o[l]||{},!(o[l][u]||!E[l][u])){o[l][u]=!0,a[l]=a[l]||[],a[l].push(u);for(var g=D(E,E[l][u],l),c=Object.keys(g),m=0;m<c.length;m++)h[c[m]]=h[c[m]]||[],h[c[m]]=h[c[m]].concat(g[c[m]])}}return a}function S(E,p,h,a){var o=E[a].map(function(n){return'"'+n+'": '+p[a][n].toString().replace(/^"[^"]+"/,"function")}).join(",");return L[0]+"{"+o+"}"+L[1]+'"'+h+'"'+L[2]}function d(E,p){p=p||{};var h={main:T.m},a=p.all?{main:Object.keys(h.main)}:_(h,E),o="";Object.keys(a).filter(function(u){return u!=="main"}).forEach(function(u){for(var g=0;a[u][g];)g++;a[u].push(g),h[u][g]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",o=o+("var "+u+" = ("+S(a,h,g,modules)+`)();
21
- `)}),o=o+("new (("+S(a,h,E,"main")+")())(self);");var n=new window.Blob([o],{type:"text/javascript"}),v=window.URL||window.webkitURL||window.mozURL||window.msURL,l=v.createObjectURL(n),i=new window.Worker(l);return i.objectURL=l,i}},"./src/errors.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{ErrorDetails:()=>L,ErrorTypes:()=>C});var C;(function(M){M.NETWORK_ERROR="networkError",M.MEDIA_ERROR="mediaError",M.KEY_SYSTEM_ERROR="keySystemError",M.MUX_ERROR="muxError",M.OTHER_ERROR="otherError"})(C||(C={}));var L;(function(M){M.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",M.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",M.KEY_SYSTEM_NO_SESSION="keySystemNoSession",M.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",M.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",M.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",M.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",M.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",M.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",M.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",M.MANIFEST_LOAD_ERROR="manifestLoadError",M.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",M.MANIFEST_PARSING_ERROR="manifestParsingError",M.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",M.LEVEL_EMPTY_ERROR="levelEmptyError",M.LEVEL_LOAD_ERROR="levelLoadError",M.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",M.LEVEL_SWITCH_ERROR="levelSwitchError",M.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",M.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",M.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",M.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",M.FRAG_LOAD_ERROR="fragLoadError",M.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",M.FRAG_DECRYPT_ERROR="fragDecryptError",M.FRAG_PARSING_ERROR="fragParsingError",M.REMUX_ALLOC_ERROR="remuxAllocError",M.KEY_LOAD_ERROR="keyLoadError",M.KEY_LOAD_TIMEOUT="keyLoadTimeOut",M.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",M.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",M.BUFFER_APPEND_ERROR="bufferAppendError",M.BUFFER_APPENDING_ERROR="bufferAppendingError",M.BUFFER_STALLED_ERROR="bufferStalledError",M.BUFFER_FULL_ERROR="bufferFullError",M.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",M.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",M.INTERNAL_EXCEPTION="internalException",M.INTERNAL_ABORTED="aborted",M.UNKNOWN="unknown"})(L||(L={}))},"./src/events.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{Events:()=>C});var C;(function(L){L.MEDIA_ATTACHING="hlsMediaAttaching",L.MEDIA_ATTACHED="hlsMediaAttached",L.MEDIA_DETACHING="hlsMediaDetaching",L.MEDIA_DETACHED="hlsMediaDetached",L.BUFFER_RESET="hlsBufferReset",L.BUFFER_CODECS="hlsBufferCodecs",L.BUFFER_CREATED="hlsBufferCreated",L.BUFFER_APPENDING="hlsBufferAppending",L.BUFFER_APPENDED="hlsBufferAppended",L.BUFFER_EOS="hlsBufferEos",L.BUFFER_FLUSHING="hlsBufferFlushing",L.BUFFER_FLUSHED="hlsBufferFlushed",L.MANIFEST_LOADING="hlsManifestLoading",L.MANIFEST_LOADED="hlsManifestLoaded",L.MANIFEST_PARSED="hlsManifestParsed",L.LEVEL_SWITCHING="hlsLevelSwitching",L.LEVEL_SWITCHED="hlsLevelSwitched",L.LEVEL_LOADING="hlsLevelLoading",L.LEVEL_LOADED="hlsLevelLoaded",L.LEVEL_UPDATED="hlsLevelUpdated",L.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",L.LEVELS_UPDATED="hlsLevelsUpdated",L.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",L.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",L.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",L.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",L.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",L.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",L.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",L.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",L.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",L.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",L.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",L.CUES_PARSED="hlsCuesParsed",L.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",L.INIT_PTS_FOUND="hlsInitPtsFound",L.FRAG_LOADING="hlsFragLoading",L.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",L.FRAG_LOADED="hlsFragLoaded",L.FRAG_DECRYPTED="hlsFragDecrypted",L.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",L.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",L.FRAG_PARSING_METADATA="hlsFragParsingMetadata",L.FRAG_PARSED="hlsFragParsed",L.FRAG_BUFFERED="hlsFragBuffered",L.FRAG_CHANGED="hlsFragChanged",L.FPS_DROP="hlsFpsDrop",L.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",L.ERROR="hlsError",L.DESTROYING="hlsDestroying",L.KEY_LOADING="hlsKeyLoading",L.KEY_LOADED="hlsKeyLoaded",L.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",L.BACK_BUFFER_REACHED="hlsBackBufferReached"})(C||(C={}))},"./src/hls.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>g});var C=T("./node_modules/url-toolkit/src/url-toolkit.js"),L=T.n(C),M=T("./src/loader/playlist-loader.ts"),P=T("./src/controller/id3-track-controller.ts"),B=T("./src/controller/latency-controller.ts"),A=T("./src/controller/level-controller.ts"),D=T("./src/controller/fragment-tracker.ts"),x=T("./src/loader/key-loader.ts"),_=T("./src/controller/stream-controller.ts"),S=T("./src/is-supported.ts"),d=T("./src/utils/logger.ts"),E=T("./src/config.ts"),p=T("./node_modules/eventemitter3/index.js"),h=T.n(p),a=T("./src/events.ts"),o=T("./src/errors.ts"),n=T("./src/types/level.ts");function v(c,m){for(var e=0;e<m.length;e++){var r=m[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(c,i(r.key),r)}}function l(c,m,e){return m&&v(c.prototype,m),e&&v(c,e),Object.defineProperty(c,"prototype",{writable:!1}),c}function i(c){var m=u(c,"string");return typeof m=="symbol"?m:String(m)}function u(c,m){if(typeof c!="object"||c===null)return c;var e=c[Symbol.toPrimitive];if(e!==void 0){var r=e.call(c,m||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(m==="string"?String:Number)(c)}var g=function(){c.isSupported=function(){return(0,S.isSupported)()};function c(e){e===void 0&&(e={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new p.EventEmitter,this._autoLevelCapping=void 0,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null;var r=this.config=(0,E.mergeConfig)(c.DefaultConfig,e);this.userConfig=e,(0,d.enableLogs)(r.debug,"Hls instance"),this._autoLevelCapping=-1,r.progressive&&(0,E.enableStreamingMode)(r);var t=r.abrController,s=r.bufferController,y=r.capLevelController,f=r.fpsController,b=this.abrController=new t(this),R=this.bufferController=new s(this),I=this.capLevelController=new y(this),k=new f(this),F=new M.default(this),K=new P.default(this),H=this.levelController=new A.default(this),j=new D.FragmentTracker(this),Y=new x.default(this.config),Q=this.streamController=new _.default(this,j,Y);I.setStreamController(Q),k.setStreamController(Q);var q=[F,H,Q];this.networkControllers=q;var ne=[b,R,I,k,K,j];this.audioTrackController=this.createController(r.audioTrackController,q);var te=r.audioStreamController;te&&q.push(new te(this,j,Y)),this.subtitleTrackController=this.createController(r.subtitleTrackController,q);var ae=r.subtitleStreamController;ae&&q.push(new ae(this,j,Y)),this.createController(r.timelineController,ne),Y.emeController=this.emeController=this.createController(r.emeController,ne),this.cmcdController=this.createController(r.cmcdController,ne),this.latencyController=this.createController(B.default,ne),this.coreComponents=ne}var m=c.prototype;return m.createController=function(r,t){if(r){var s=new r(this);return t&&t.push(s),s}return null},m.on=function(r,t,s){s===void 0&&(s=this),this._emitter.on(r,t,s)},m.once=function(r,t,s){s===void 0&&(s=this),this._emitter.once(r,t,s)},m.removeAllListeners=function(r){this._emitter.removeAllListeners(r)},m.off=function(r,t,s,y){s===void 0&&(s=this),this._emitter.off(r,t,s,y)},m.listeners=function(r){return this._emitter.listeners(r)},m.emit=function(r,t,s){return this._emitter.emit(r,t,s)},m.trigger=function(r,t){if(this.config.debug)return this.emit(r,r,t);try{return this.emit(r,r,t)}catch(s){d.logger.error("An internal error happened while handling event "+r+'. Error message: "'+s.message+'". Here is a stacktrace:',s),this.trigger(a.Events.ERROR,{type:o.ErrorTypes.OTHER_ERROR,details:o.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:r,error:s})}return!1},m.listenerCount=function(r){return this._emitter.listenerCount(r)},m.destroy=function(){d.logger.log("destroy"),this.trigger(a.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(r){return r.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(r){return r.destroy()}),this.coreComponents.length=0},m.attachMedia=function(r){d.logger.log("attachMedia"),this._media=r,this.trigger(a.Events.MEDIA_ATTACHING,{media:r})},m.detachMedia=function(){d.logger.log("detachMedia"),this.trigger(a.Events.MEDIA_DETACHING,void 0),this._media=null},m.loadSource=function(r){this.stopLoad();var t=this.media,s=this.url,y=this.url=C.buildAbsoluteURL(self.location.href,r,{alwaysNormalize:!0});d.logger.log("loadSource:"+y),t&&s&&s!==y&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(t)),this.trigger(a.Events.MANIFEST_LOADING,{url:r})},m.startLoad=function(r){r===void 0&&(r=-1),d.logger.log("startLoad("+r+")"),this.networkControllers.forEach(function(t){t.startLoad(r)})},m.stopLoad=function(){d.logger.log("stopLoad"),this.networkControllers.forEach(function(r){r.stopLoad()})},m.swapAudioCodec=function(){d.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},m.recoverMediaError=function(){d.logger.log("recoverMediaError");var r=this._media;this.detachMedia(),r&&this.attachMedia(r)},m.removeLevel=function(r,t){t===void 0&&(t=0),this.levelController.removeLevel(r,t)},l(c,[{key:"levels",get:function(){var r=this.levelController.levels;return r||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(r){d.logger.log("set currentLevel:"+r),this.loadLevel=r,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(r){d.logger.log("set nextLevel:"+r),this.levelController.manualLevel=r,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(r){d.logger.log("set loadLevel:"+r),this.levelController.manualLevel=r}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(r){this.levelController.nextLoadLevel=r}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(r){d.logger.log("set firstLevel:"+r),this.levelController.firstLevel=r}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(r){d.logger.log("set startLevel:"+r),r!==-1&&(r=Math.max(r,this.minAutoLevel)),this.levelController.startLevel=r}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(r){var t=!!r;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(r){this._autoLevelCapping!==r&&(d.logger.log("set autoLevelCapping:"+r),this._autoLevelCapping=r)}},{key:"bandwidthEstimate",get:function(){var r=this.abrController.bwEstimator;return r?r.getEstimate():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(r){n.HdcpLevels.indexOf(r)>-1&&(this._maxHdcpLevel=r)}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var r=this.levels,t=this.config.minAutoBitrate;if(!r)return 0;for(var s=r.length,y=0;y<s;y++)if(r[y].maxBitrate>=t)return y;return 0}},{key:"maxAutoLevel",get:function(){var r=this.levels,t=this.autoLevelCapping,s=this.maxHdcpLevel,y;if(t===-1&&r&&r.length?y=r.length-1:y=t,s)for(var f=y;f--;){var b=r[f].attrs["HDCP-LEVEL"];if(b&&b<=s)return f}return y}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(r){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,r)}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"audioTracks",get:function(){var r=this.audioTrackController;return r?r.audioTracks:[]}},{key:"audioTrack",get:function(){var r=this.audioTrackController;return r?r.audioTrack:-1},set:function(r){var t=this.audioTrackController;t&&(t.audioTrack=r)}},{key:"subtitleTracks",get:function(){var r=this.subtitleTrackController;return r?r.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var r=this.subtitleTrackController;return r?r.subtitleTrack:-1},set:function(r){var t=this.subtitleTrackController;t&&(t.subtitleTrack=r)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var r=this.subtitleTrackController;return r?r.subtitleDisplay:!1},set:function(r){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=r)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(r){this.config.lowLatencyMode=r}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.3.1"}},{key:"Events",get:function(){return a.Events}},{key:"ErrorTypes",get:function(){return o.ErrorTypes}},{key:"ErrorDetails",get:function(){return o.ErrorDetails}},{key:"DefaultConfig",get:function(){return c.defaultConfig?c.defaultConfig:E.hlsDefaultConfig},set:function(r){c.defaultConfig=r}}]),c}();g.defaultConfig=void 0},"./src/is-supported.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{changeTypeSupported:()=>P,isSupported:()=>M});var C=T("./src/utils/mediasource-helper.ts");function L(){return self.SourceBuffer||self.WebKitSourceBuffer}function M(){var B=(0,C.getMediaSource)();if(!B)return!1;var A=L(),D=B&&typeof B.isTypeSupported=="function"&&B.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),x=!A||A.prototype&&typeof A.prototype.appendBuffer=="function"&&typeof A.prototype.remove=="function";return!!D&&!!x}function P(){var B,A=L();return typeof(A==null||(B=A.prototype)===null||B===void 0?void 0:B.changeType)=="function"}},"./src/loader/date-range.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{DateRange:()=>S,DateRangeAttribute:()=>_});var C=T("./src/polyfills/number.ts"),L=T("./src/utils/attr-list.ts"),M=T("./src/utils/logger.ts");function P(){return P=Object.assign?Object.assign.bind():function(d){for(var E=1;E<arguments.length;E++){var p=arguments[E];for(var h in p)Object.prototype.hasOwnProperty.call(p,h)&&(d[h]=p[h])}return d},P.apply(this,arguments)}function B(d,E){for(var p=0;p<E.length;p++){var h=E[p];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(d,D(h.key),h)}}function A(d,E,p){return E&&B(d.prototype,E),p&&B(d,p),Object.defineProperty(d,"prototype",{writable:!1}),d}function D(d){var E=x(d,"string");return typeof E=="symbol"?E:String(E)}function x(d,E){if(typeof d!="object"||d===null)return d;var p=d[Symbol.toPrimitive];if(p!==void 0){var h=p.call(d,E||"default");if(typeof h!="object")return h;throw new TypeError("@@toPrimitive must return a primitive value.")}return(E==="string"?String:Number)(d)}var _;(function(d){d.ID="ID",d.CLASS="CLASS",d.START_DATE="START-DATE",d.DURATION="DURATION",d.END_DATE="END-DATE",d.END_ON_NEXT="END-ON-NEXT",d.PLANNED_DURATION="PLANNED-DURATION",d.SCTE35_OUT="SCTE35-OUT",d.SCTE35_IN="SCTE35-IN"})(_||(_={}));var S=function(){function d(E,p){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,p){var h=p.attr;for(var a in h)if(Object.prototype.hasOwnProperty.call(E,a)&&E[a]!==h[a]){M.logger.warn('DATERANGE tag attribute: "'+a+'" does not match for tags with ID: "'+E.ID+'"'),this._badValueForSameId=a;break}E=P(new L.AttrList({}),h,E)}if(this.attr=E,this._startDate=new Date(E[_.START_DATE]),_.END_DATE in this.attr){var o=new Date(this.attr[_.END_DATE]);(0,C.isFiniteNumber)(o.getTime())&&(this._endDate=o)}}return A(d,[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){if(this._endDate)return this._endDate;var p=this.duration;return p!==null?new Date(this._startDate.getTime()+p*1e3):null}},{key:"duration",get:function(){if(_.DURATION in this.attr){var p=this.attr.decimalFloatingPoint(_.DURATION);if((0,C.isFiniteNumber)(p))return p}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return _.PLANNED_DURATION in this.attr?this.attr.decimalFloatingPoint(_.PLANNED_DURATION):null}},{key:"endOnNext",get:function(){return this.attr.bool(_.END_ON_NEXT)}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&(0,C.isFiniteNumber)(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),d}()},"./src/loader/fragment-loader.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{LoadError:()=>p,default:()=>d});var C=T("./src/polyfills/number.ts"),L=T("./src/errors.ts");function M(h,a){h.prototype=Object.create(a.prototype),h.prototype.constructor=h,x(h,a)}function P(h){var a=typeof Map=="function"?new Map:void 0;return P=function(n){if(n===null||!D(n))return n;if(typeof n!="function")throw new TypeError("Super expression must either be null or a function");if(typeof a!="undefined"){if(a.has(n))return a.get(n);a.set(n,v)}function v(){return B(n,arguments,_(this).constructor)}return v.prototype=Object.create(n.prototype,{constructor:{value:v,enumerable:!1,writable:!0,configurable:!0}}),x(v,n)},P(h)}function B(h,a,o){return A()?B=Reflect.construct.bind():B=function(v,l,i){var u=[null];u.push.apply(u,l);var g=Function.bind.apply(v,u),c=new g;return i&&x(c,i.prototype),c},B.apply(null,arguments)}function A(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function D(h){return Function.toString.call(h).indexOf("[native code]")!==-1}function x(h,a){return x=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,v){return n.__proto__=v,n},x(h,a)}function _(h){return _=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(o){return o.__proto__||Object.getPrototypeOf(o)},_(h)}var S=Math.pow(2,17),d=function(){function h(o){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=o}var a=h.prototype;return a.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},a.abort=function(){this.loader&&this.loader.abort()},a.load=function(n,v){var l=this,i=n.url;if(!i)return Promise.reject(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:n,networkDetails:null},"Fragment does not have a "+(i?"part list":"url")));this.abort();var u=this.config,g=u.fLoader,c=u.loader;return new Promise(function(m,e){l.loader&&l.loader.destroy();var r=l.loader=n.loader=g?new g(u):new c(u),t=E(n),s={timeout:u.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:u.fragLoadingMaxRetryTimeout,highWaterMark:n.sn==="initSegment"?1/0:S};n.stats=r.stats,r.load(t,s,{onSuccess:function(f,b,R,I){l.resetLoader(n,r);var k=f.data;R.resetIV&&n.decryptdata&&(n.decryptdata.iv=new Uint8Array(k.slice(0,16)),k=k.slice(16)),m({frag:n,part:null,payload:k,networkDetails:I})},onError:function(f,b,R){l.resetLoader(n,r),e(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:n,response:f,networkDetails:R}))},onAbort:function(f,b,R){l.resetLoader(n,r),e(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:n,networkDetails:R}))},onTimeout:function(f,b,R){l.resetLoader(n,r),e(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:n,networkDetails:R}))},onProgress:function(f,b,R,I){v&&v({frag:n,part:null,payload:R,networkDetails:I})}})})},a.loadPart=function(n,v,l){var i=this;this.abort();var u=this.config,g=u.fLoader,c=u.loader;return new Promise(function(m,e){i.loader&&i.loader.destroy();var r=i.loader=n.loader=g?new g(u):new c(u),t=E(n,v),s={timeout:u.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:u.fragLoadingMaxRetryTimeout,highWaterMark:S};v.stats=r.stats,r.load(t,s,{onSuccess:function(f,b,R,I){i.resetLoader(n,r),i.updateStatsFromPart(n,v);var k={frag:n,part:v,payload:f.data,networkDetails:I};l(k),m(k)},onError:function(f,b,R){i.resetLoader(n,r),e(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:n,part:v,response:f,networkDetails:R}))},onAbort:function(f,b,R){n.stats.aborted=v.stats.aborted,i.resetLoader(n,r),e(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:n,part:v,networkDetails:R}))},onTimeout:function(f,b,R){i.resetLoader(n,r),e(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:n,part:v,networkDetails:R}))}})})},a.updateStatsFromPart=function(n,v){var l=n.stats,i=v.stats,u=i.total;if(l.loaded+=i.loaded,u){var g=Math.round(n.duration/v.duration),c=Math.min(Math.round(l.loaded/u),g),m=g-c,e=m*Math.round(l.loaded/c);l.total=l.loaded+e}else l.total=Math.max(l.loaded,l.total);var r=l.loading,t=i.loading;r.start?r.first+=t.first-t.start:(r.start=t.start,r.first=t.first),r.end=t.end},a.resetLoader=function(n,v){n.loader=null,this.loader===v&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),v.destroy()},h}();function E(h,a){a===void 0&&(a=null);var o=a||h,n={frag:h,part:a,responseType:"arraybuffer",url:o.url,headers:{},rangeStart:0,rangeEnd:0},v=o.byteRangeStartOffset,l=o.byteRangeEndOffset;if((0,C.isFiniteNumber)(v)&&(0,C.isFiniteNumber)(l)){var i,u=v,g=l;if(h.sn==="initSegment"&&((i=h.decryptdata)===null||i===void 0?void 0:i.method)==="AES-128"){var c=l-v;c%16&&(g=l+(16-c%16)),v!==0&&(n.resetIV=!0,u=v-16)}n.rangeStart=u,n.rangeEnd=g}return n}var p=function(h){M(a,h);function a(o){for(var n,v=arguments.length,l=new Array(v>1?v-1:0),i=1;i<v;i++)l[i-1]=arguments[i];return n=h.call.apply(h,[this].concat(l))||this,n.data=void 0,n.data=o,n}return a}(P(Error))},"./src/loader/fragment.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{BaseSegment:()=>E,ElementaryStreamTypes:()=>d,Fragment:()=>p,Part:()=>h});var C=T("./src/polyfills/number.ts"),L=T("./node_modules/url-toolkit/src/url-toolkit.js"),M=T.n(L),P=T("./src/loader/load-stats.ts");function B(a,o){a.prototype=Object.create(o.prototype),a.prototype.constructor=a,A(a,o)}function A(a,o){return A=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(v,l){return v.__proto__=l,v},A(a,o)}function D(a,o){for(var n=0;n<o.length;n++){var v=o[n];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(a,_(v.key),v)}}function x(a,o,n){return o&&D(a.prototype,o),n&&D(a,n),Object.defineProperty(a,"prototype",{writable:!1}),a}function _(a){var o=S(a,"string");return typeof o=="symbol"?o:String(o)}function S(a,o){if(typeof a!="object"||a===null)return a;var n=a[Symbol.toPrimitive];if(n!==void 0){var v=n.call(a,o||"default");if(typeof v!="object")return v;throw new TypeError("@@toPrimitive must return a primitive value.")}return(o==="string"?String:Number)(a)}var d;(function(a){a.AUDIO="audio",a.VIDEO="video",a.AUDIOVIDEO="audiovideo"})(d||(d={}));var E=function(){function a(n){var v;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(v={},v[d.AUDIO]=null,v[d.VIDEO]=null,v[d.AUDIOVIDEO]=null,v),this.baseurl=n}var o=a.prototype;return o.setByteRange=function(v,l){var i=v.split("@",2),u=[];i.length===1?u[0]=l?l.byteRangeEndOffset:0:u[0]=parseInt(i[1]),u[1]=parseInt(i[0])+u[0],this._byteRange=u},x(a,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=(0,L.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(v){this._url=v}}]),a}(),p=function(a){B(o,a);function o(v,l){var i;return i=a.call(this,l)||this,i._decryptdata=null,i.rawProgramDateTime=null,i.programDateTime=null,i.tagList=[],i.duration=0,i.sn=0,i.levelkeys=void 0,i.type=void 0,i.loader=null,i.keyLoader=null,i.level=-1,i.cc=0,i.startPTS=void 0,i.endPTS=void 0,i.appendedPTS=void 0,i.startDTS=void 0,i.endDTS=void 0,i.start=0,i.deltaPTS=void 0,i.maxStartPTS=void 0,i.minEndPTS=void 0,i.stats=new P.LoadStats,i.urlId=0,i.data=void 0,i.bitrateTest=!1,i.title=null,i.initSegment=null,i.endList=void 0,i.type=v,i}var n=o.prototype;return n.setKeyFormat=function(l){if(this.levelkeys){var i=this.levelkeys[l];i&&!this._decryptdata&&(this._decryptdata=i.getDecryptData(this.sn))}},n.abortRequests=function(){var l,i;(l=this.loader)===null||l===void 0||l.abort(),(i=this.keyLoader)===null||i===void 0||i.abort()},n.setElementaryStreamInfo=function(l,i,u,g,c,m){m===void 0&&(m=!1);var e=this.elementaryStreams,r=e[l];if(!r){e[l]={startPTS:i,endPTS:u,startDTS:g,endDTS:c,partial:m};return}r.startPTS=Math.min(r.startPTS,i),r.endPTS=Math.max(r.endPTS,u),r.startDTS=Math.min(r.startDTS,g),r.endDTS=Math.max(r.endDTS,c)},n.clearElementaryStreamInfo=function(){var l=this.elementaryStreams;l[d.AUDIO]=null,l[d.VIDEO]=null,l[d.AUDIOVIDEO]=null},x(o,[{key:"decryptdata",get:function(){var l=this.levelkeys;if(!l&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var i=this.levelkeys.identity;if(i)this._decryptdata=i.getDecryptData(this.sn);else{var u=Object.keys(this.levelkeys);if(u.length===1)return this._decryptdata=this.levelkeys[u[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null||!(0,C.isFiniteNumber)(this.programDateTime))return null;var l=(0,C.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+l*1e3}},{key:"encrypted",get:function(){var l;if((l=this._decryptdata)!==null&&l!==void 0&&l.encrypted)return!0;if(this.levelkeys){var i=Object.keys(this.levelkeys),u=i.length;if(u>1||u===1&&this.levelkeys[i[0]].encrypted)return!0}return!1}}]),o}(E),h=function(a){B(o,a);function o(n,v,l,i,u){var g;g=a.call(this,l)||this,g.fragOffset=0,g.duration=0,g.gap=!1,g.independent=!1,g.relurl=void 0,g.fragment=void 0,g.index=void 0,g.stats=new P.LoadStats,g.duration=n.decimalFloatingPoint("DURATION"),g.gap=n.bool("GAP"),g.independent=n.bool("INDEPENDENT"),g.relurl=n.enumeratedString("URI"),g.fragment=v,g.index=i;var c=n.enumeratedString("BYTERANGE");return c&&g.setByteRange(c,u),u&&(g.fragOffset=u.fragOffset+u.duration),g}return x(o,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var v=this.elementaryStreams;return!!(v.audio||v.video||v.audiovideo)}}]),o}(E)},"./src/loader/key-loader.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>M});var C=T("./src/errors.ts"),L=T("./src/loader/fragment-loader.ts"),M=function(){function P(A){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=A}var B=P.prototype;return B.abort=function(){for(var D in this.keyUriToKeyInfo){var x=this.keyUriToKeyInfo[D].loader;x&&x.abort()}},B.detach=function(){for(var D in this.keyUriToKeyInfo){var x=this.keyUriToKeyInfo[D];(x.mediaKeySessionContext||x.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[D]}},B.destroy=function(){this.detach();for(var D in this.keyUriToKeyInfo){var x=this.keyUriToKeyInfo[D].loader;x&&x.destroy()}this.keyUriToKeyInfo={}},B.createKeyLoadError=function(D,x,_,S){return x===void 0&&(x=C.ErrorDetails.KEY_LOAD_ERROR),new L.LoadError({type:C.ErrorTypes.NETWORK_ERROR,details:x,fatal:!1,frag:D,networkDetails:_})},B.loadClear=function(D,x){var _=this;if(this.emeController&&this.config.emeEnabled)for(var S=D.sn,d=D.cc,E=function(o){var n=x[o];if(d<=n.cc&&(S==="initSegment"||S<n.sn))return _.emeController.selectKeySystemFormat(n).then(function(v){n.setKeyFormat(v)}),"break"},p=0;p<x.length;p++){var h=E(p);if(h==="break")break}},B.load=function(D){var x=this;return!D.decryptdata&&D.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(D).then(function(_){return x.loadInternal(D,_)}):this.loadInternal(D)},B.loadInternal=function(D,x){var _,S;x&&D.setKeyFormat(x);var d=D.decryptdata;if(!d){var E=x?"Expected frag.decryptdata to be defined after setting format "+x:"Missing decryption data on fragment in onKeyLoading";return Promise.reject(this.createKeyLoadError(D,C.ErrorDetails.KEY_LOAD_ERROR,null,E))}var p=d.uri;if(!p)return Promise.reject(this.createKeyLoadError(D,C.ErrorDetails.KEY_LOAD_ERROR,null,'Invalid key URI: "'+p+'"'));var h=this.keyUriToKeyInfo[p];if((_=h)!==null&&_!==void 0&&_.decryptdata.key)return d.key=h.decryptdata.key,Promise.resolve({frag:D,keyInfo:h});if((S=h)!==null&&S!==void 0&&S.keyLoadPromise){var a;switch((a=h.mediaKeySessionContext)===null||a===void 0?void 0:a.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return h.keyLoadPromise}}switch(h=this.keyUriToKeyInfo[p]={decryptdata:d,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},d.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return d.keyFormat==="identity"?this.loadKeyHTTP(h,D):this.loadKeyEME(h,D);case"AES-128":return this.loadKeyHTTP(h,D);default:return Promise.reject(this.createKeyLoadError(D,C.ErrorDetails.KEY_LOAD_ERROR,null,'Key supplied with unsupported METHOD: "'+d.method+'"'))}},B.loadKeyEME=function(D,x){var _={frag:x,keyInfo:D};if(this.emeController&&this.config.emeEnabled){var S=this.emeController.loadKey(_);if(S)return(D.keyLoadPromise=S.then(function(d){return D.mediaKeySessionContext=d,_})).catch(function(d){throw D.keyLoadPromise=null,d})}return Promise.resolve(_)},B.loadKeyHTTP=function(D,x){var _=this,S=this.config,d=S.loader,E=new d(S);return x.keyLoader=D.loader=E,D.keyLoadPromise=new Promise(function(p,h){var a={keyInfo:D,frag:x,responseType:"arraybuffer",url:D.decryptdata.uri},o={timeout:S.fragLoadingTimeOut,maxRetry:0,retryDelay:S.fragLoadingRetryDelay,maxRetryDelay:S.fragLoadingMaxRetryTimeout,highWaterMark:0},n={onSuccess:function(l,i,u,g){var c=u.frag,m=u.keyInfo,e=u.url;if(!c.decryptdata||m!==_.keyUriToKeyInfo[e])return h(_.createKeyLoadError(c,C.ErrorDetails.KEY_LOAD_ERROR,g,"after key load, decryptdata unset or changed"));m.decryptdata.key=c.decryptdata.key=new Uint8Array(l.data),c.keyLoader=null,m.loader=null,p({frag:c,keyInfo:m})},onError:function(l,i,u){_.resetLoader(i),h(_.createKeyLoadError(x,C.ErrorDetails.KEY_LOAD_ERROR,u))},onTimeout:function(l,i,u){_.resetLoader(i),h(_.createKeyLoadError(x,C.ErrorDetails.KEY_LOAD_TIMEOUT,u))},onAbort:function(l,i,u){_.resetLoader(i),h(_.createKeyLoadError(x,C.ErrorDetails.INTERNAL_ABORTED,u))}};E.load(a,o,n)})},B.resetLoader=function(D){var x=D.frag,_=D.keyInfo,S=D.url,d=_.loader;x.keyLoader===d&&(x.keyLoader=null,_.loader=null),delete this.keyUriToKeyInfo[S],d&&d.destroy()},P}()},"./src/loader/level-details.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{LevelDetails:()=>D});var C=T("./src/polyfills/number.ts");function L(x,_){for(var S=0;S<_.length;S++){var d=_[S];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(x,P(d.key),d)}}function M(x,_,S){return _&&L(x.prototype,_),S&&L(x,S),Object.defineProperty(x,"prototype",{writable:!1}),x}function P(x){var _=B(x,"string");return typeof _=="symbol"?_:String(_)}function B(x,_){if(typeof x!="object"||x===null)return x;var S=x[Symbol.toPrimitive];if(S!==void 0){var d=S.call(x,_||"default");if(typeof d!="object")return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return(_==="string"?String:Number)(x)}var A=10,D=function(){function x(S){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=S}var _=x.prototype;return _.reloaded=function(d){if(!d){this.advanced=!0,this.updated=!0;return}var E=this.lastPartSn-d.lastPartSn,p=this.lastPartIndex-d.lastPartIndex;this.updated=this.endSN!==d.endSN||!!p||!!E,this.advanced=this.endSN>d.endSN||E>0||E===0&&p>0,this.updated||this.advanced?this.misses=Math.floor(d.misses*.6):this.misses=d.misses+1,this.availabilityDelay=d.availabilityDelay},M(x,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?(0,C.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||A}},{key:"drift",get:function(){var d=this.driftEndTime-this.driftStartTime;if(d>0){var E=this.driftEnd-this.driftStart;return E*1e3/d}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var d;return(d=this.partList)!==null&&d!==void 0&&d.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var d;return(d=this.fragments)!==null&&d!==void 0&&d.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var d;return(d=this.partList)!==null&&d!==void 0&&d.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var d;return(d=this.partList)!==null&&d!==void 0&&d.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),x}()},"./src/loader/level-key.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{LevelKey:()=>D});var C=T("./src/utils/keysystem-util.ts"),L=T("./src/utils/mediakeys-helper.ts"),M=T("./src/utils/mp4-tools.ts"),P=T("./src/utils/logger.ts"),B=T("./src/utils/numeric-encoding-utils.ts"),A={},D=function(){_.clearKeyUriToKeyIdMap=function(){A={}};function _(d,E,p,h,a){h===void 0&&(h=[1]),a===void 0&&(a=null),this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=d,this.uri=E,this.keyFormat=p,this.keyFormatVersions=h,this.iv=a,this.encrypted=d?d!=="NONE":!1,this.isCommonEncryption=this.encrypted&&d!=="AES-128"}var S=_.prototype;return S.isSupported=function(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;switch(this.keyFormat){case"identity":return this.method==="SAMPLE-AES";case L.KeySystemFormats.FAIRPLAY:case L.KeySystemFormats.WIDEVINE:case L.KeySystemFormats.PLAYREADY:case L.KeySystemFormats.CLEARKEY:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1},S.getDecryptData=function(E){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof E!="number"&&(this.method==="AES-128"&&!this.iv&&P.logger.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),E=0);var p=x(E),h=new _(this.method,this.uri,"identity",this.keyFormatVersions,p);return h}var a=(0,C.convertDataUriToArrayBytes)(this.uri);if(a)switch(this.keyFormat){case L.KeySystemFormats.WIDEVINE:this.pssh=a,a.length>=22&&(this.keyId=a.subarray(a.length-22,a.length-6));break;case L.KeySystemFormats.PLAYREADY:{var o=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=(0,M.mp4pssh)(o,null,a);var n=new Uint16Array(a.buffer,a.byteOffset,a.byteLength/2),v=String.fromCharCode.apply(null,Array.from(n)),l=v.substring(v.indexOf("<"),v.length),i=new DOMParser,u=i.parseFromString(l,"text/xml"),g=u.getElementsByTagName("KID")[0];if(g){var c=g.childNodes[0]?g.childNodes[0].nodeValue:g.getAttribute("VALUE");if(c){var m=(0,B.base64Decode)(c).subarray(0,16);(0,C.changeEndianness)(m),this.keyId=m}}break}default:{var e=a.subarray(0,16);if(e.length!==16){var r=new Uint8Array(16);r.set(e,16-e.length),e=r}this.keyId=e;break}}if(!this.keyId||this.keyId.byteLength!==16){var t=A[this.uri];if(!t){var s=Object.keys(A).length%Number.MAX_SAFE_INTEGER;t=new Uint8Array(16);var y=new DataView(t.buffer,12,4);y.setUint32(0,s),A[this.uri]=t}this.keyId=t}return this},_}();function x(_){for(var S=new Uint8Array(16),d=12;d<16;d++)S[d]=_>>8*(15-d)&255;return S}},"./src/loader/load-stats.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{LoadStats:()=>C});var C=function(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}},"./src/loader/m3u8-parser.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>o});var C=T("./src/polyfills/number.ts"),L=T("./node_modules/url-toolkit/src/url-toolkit.js"),M=T.n(L),P=T("./src/loader/date-range.ts"),B=T("./src/loader/fragment.ts"),A=T("./src/loader/level-details.ts"),D=T("./src/loader/level-key.ts"),x=T("./src/utils/attr-list.ts"),_=T("./src/utils/logger.ts"),S=T("./src/utils/codecs.ts");function d(){return d=Object.assign?Object.assign.bind():function(c){for(var m=1;m<arguments.length;m++){var e=arguments[m];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(c[r]=e[r])}return c},d.apply(this,arguments)}var E=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+|#EXT-X-SESSION-KEY:([^\n\r]*)[\r\n]+/g,p=/#EXT-X-MEDIA:(.*)/g,h=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),a=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),o=function(){function c(){}return c.findGroup=function(e,r){for(var t=0;t<e.length;t++){var s=e[t];if(s.id===r)return s}},c.convertAVC1ToAVCOTI=function(e){var r=e.split(".");if(r.length>2){var t=r.shift()+".";return t+=parseInt(r.shift()).toString(16),t+=("000"+parseInt(r.shift()).toString(16)).slice(-4),t}return e},c.resolve=function(e,r){return(0,L.buildAbsoluteURL)(r,e,{alwaysNormalize:!0})},c.parseMasterPlaylist=function(e,r){var t=[],s=[],y={},f=[],b=!1;E.lastIndex=0;for(var R;(R=E.exec(e))!=null;)if(R[1]){var I,k=new x.AttrList(R[1]),F={attrs:k,bitrate:k.decimalInteger("AVERAGE-BANDWIDTH")||k.decimalInteger("BANDWIDTH"),name:k.NAME,url:c.resolve(R[2],r)},K=k.decimalResolution("RESOLUTION");K&&(F.width=K.width,F.height=K.height),v((k.CODECS||"").split(/[ ,]+/).filter(function(q){return q}),F),F.videoCodec&&F.videoCodec.indexOf("avc1")!==-1&&(F.videoCodec=c.convertAVC1ToAVCOTI(F.videoCodec)),(I=F.unknownCodecs)!==null&&I!==void 0&&I.length||s.push(F),t.push(F)}else if(R[3]){var H=new x.AttrList(R[3]);H["DATA-ID"]&&(b=!0,y[H["DATA-ID"]]=H)}else if(R[4]){var j=R[4],Y=n(j,r);Y.encrypted&&Y.isSupported()?f.push(Y):_.logger.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+j+'"')}var Q=s.length>0&&s.length<t.length;return{levels:Q?s:t,sessionData:b?y:null,sessionKeys:f.length?f:null}},c.parseMasterPlaylistMedia=function(e,r,t,s){s===void 0&&(s=[]);var y,f=[],b=0;for(p.lastIndex=0;(y=p.exec(e))!==null;){var R=new x.AttrList(y[1]);if(R.TYPE===t){var I={attrs:R,bitrate:0,id:b++,groupId:R["GROUP-ID"],instreamId:R["INSTREAM-ID"],name:R.NAME||R.LANGUAGE||"",type:t,default:R.bool("DEFAULT"),autoselect:R.bool("AUTOSELECT"),forced:R.bool("FORCED"),lang:R.LANGUAGE,url:R.URI?c.resolve(R.URI,r):""};if(s.length){var k=c.findGroup(s,I.groupId)||s[0];l(I,k,"audioCodec"),l(I,k,"textCodec")}f.push(I)}}return f},c.parseLevelPlaylist=function(e,r,t,s,y){var f=new A.LevelDetails(r),b=f.fragments,R=null,I=0,k=0,F=0,K=0,H=null,j=new B.Fragment(s,r),Y,Q,q,ne=-1,te=!1;for(h.lastIndex=0,f.m3u8=e;(Y=h.exec(e))!==null;){te&&(te=!1,j=new B.Fragment(s,r),j.start=F,j.sn=I,j.cc=K,j.level=t,R&&(j.initSegment=R,j.rawProgramDateTime=R.rawProgramDateTime,R.rawProgramDateTime=null));var ae=Y[1];if(ae){j.duration=parseFloat(ae);var ue=(" "+Y[2]).slice(1);j.title=ue||null,j.tagList.push(ue?["INF",ae,ue]:["INF",ae])}else if(Y[3]){if((0,C.isFiniteNumber)(j.duration)){if(j.start=F,q){j.levelkeys=q;var ce=f.encryptedFragments;j.levelkeys&&Object.keys(j.levelkeys).some(function(et){return j.levelkeys[et].isCommonEncryption})&&(!ce.length||ce[ce.length-1].levelkeys!==q)&&ce.push(j)}j.sn=I,j.level=t,j.cc=K,j.urlId=y,b.push(j),j.relurl=(" "+Y[3]).slice(1),u(j,H),H=j,F+=j.duration,I++,k=0,te=!0}}else if(Y[4]){var le=(" "+Y[4]).slice(1);H?j.setByteRange(le,H):j.setByteRange(le)}else if(Y[5])j.rawProgramDateTime=(" "+Y[5]).slice(1),j.tagList.push(["PROGRAM-DATE-TIME",j.rawProgramDateTime]),ne===-1&&(ne=b.length);else{if(Y=Y[0].match(a),!Y){_.logger.warn("No matches on slow regex match for level playlist!");continue}for(Q=1;Q<Y.length&&typeof Y[Q]=="undefined";Q++);var fe=(" "+Y[Q]).slice(1),de=(" "+Y[Q+1]).slice(1),xe=Y[Q+2]?(" "+Y[Q+2]).slice(1):"";switch(fe){case"PLAYLIST-TYPE":f.type=de.toUpperCase();break;case"MEDIA-SEQUENCE":I=f.startSN=parseInt(de);break;case"SKIP":{var Ae=new x.AttrList(de),Ie=Ae.decimalInteger("SKIPPED-SEGMENTS");if((0,C.isFiniteNumber)(Ie)){f.skippedSegments=Ie;for(var Re=Ie;Re--;)b.unshift(null);I+=Ie}var Oe=Ae.enumeratedString("RECENTLY-REMOVED-DATERANGES");Oe&&(f.recentlyRemovedDateranges=Oe.split(" "));break}case"TARGETDURATION":f.targetduration=parseFloat(de);break;case"VERSION":f.version=parseInt(de);break;case"EXTM3U":break;case"ENDLIST":f.live=!1;break;case"#":(de||xe)&&j.tagList.push(xe?[de,xe]:[de]);break;case"DISCONTINUITY":K++,j.tagList.push(["DIS"]);break;case"GAP":j.tagList.push([fe]);break;case"BITRATE":j.tagList.push([fe,de]);break;case"DATERANGE":{var Pe=new x.AttrList(de),Ce=new P.DateRange(Pe,f.dateRanges[Pe.ID]);Ce.isValid||f.skippedSegments?f.dateRanges[Ce.id]=Ce:_.logger.warn('Ignoring invalid DATERANGE tag: "'+de+'"'),j.tagList.push(["EXT-X-DATERANGE",de]);break}case"DISCONTINUITY-SEQUENCE":K=parseInt(de);break;case"KEY":{var Le=n(de,r);if(Le.isSupported()){if(Le.method==="NONE"){q=void 0;break}q||(q={}),q[Le.keyFormat]&&(q=d({},q)),q[Le.keyFormat]=Le}else _.logger.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+de+'"');break}case"START":{var ke=new x.AttrList(de),Be=ke.decimalFloatingPoint("TIME-OFFSET");(0,C.isFiniteNumber)(Be)&&(f.startTimeOffset=Be);break}case"MAP":{var we=new x.AttrList(de);if(j.duration){var Ye=new B.Fragment(s,r);g(Ye,we,t,q),R=Ye,j.initSegment=R,R.rawProgramDateTime&&!j.rawProgramDateTime&&(j.rawProgramDateTime=R.rawProgramDateTime)}else g(j,we,t,q),R=j,te=!0;break}case"SERVER-CONTROL":{var Xe=new x.AttrList(de);f.canBlockReload=Xe.bool("CAN-BLOCK-RELOAD"),f.canSkipUntil=Xe.optionalFloat("CAN-SKIP-UNTIL",0),f.canSkipDateRanges=f.canSkipUntil>0&&Xe.bool("CAN-SKIP-DATERANGES"),f.partHoldBack=Xe.optionalFloat("PART-HOLD-BACK",0),f.holdBack=Xe.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var rt=new x.AttrList(de);f.partTarget=rt.decimalFloatingPoint("PART-TARGET");break}case"PART":{var ze=f.partList;ze||(ze=f.partList=[]);var it=k>0?ze[ze.length-1]:void 0,nt=k++,Je=new B.Part(new x.AttrList(de),j,r,nt,it);ze.push(Je),j.duration+=Je.duration;break}case"PRELOAD-HINT":{var Ne=new x.AttrList(de);f.preloadHint=Ne;break}case"RENDITION-REPORT":{var Ke=new x.AttrList(de);f.renditionReports=f.renditionReports||[],f.renditionReports.push(Ke);break}default:_.logger.warn("line parsed but not handled: "+Y);break}}}H&&!H.relurl?(b.pop(),F-=H.duration,f.partList&&(f.fragmentHint=H)):f.partList&&(u(j,H),j.cc=K,f.fragmentHint=j);var Ze=b.length,ft=b[0],Me=b[Ze-1];if(F+=f.skippedSegments*f.targetduration,F>0&&Ze&&Me){f.averagetargetduration=F/Ze;var qe=Me.sn;f.endSN=qe!=="initSegment"?qe:0,f.live||(Me.endList=!0),ft&&(f.startCC=ft.cc)}else f.endSN=0,f.startCC=0;return f.fragmentHint&&(F+=f.fragmentHint.duration),f.totalduration=F,f.endCC=K,ne>0&&i(b,ne),f},c}();function n(c,m){var e,r,t=new x.AttrList(c),s=(e=t.enumeratedString("METHOD"))!=null?e:"",y=t.URI,f=t.hexadecimalInteger("IV"),b=t.enumeratedString("KEYFORMATVERSIONS"),R=(r=t.enumeratedString("KEYFORMAT"))!=null?r:"identity";y&&t.IV&&!f&&_.logger.error("Invalid IV: "+t.IV);var I=y?o.resolve(y,m):"",k=(b||"1").split("/").map(Number).filter(Number.isFinite);return new D.LevelKey(s,I,R,k,f)}function v(c,m){["video","audio","text"].forEach(function(e){var r=c.filter(function(s){return(0,S.isCodecType)(s,e)});if(r.length){var t=r.filter(function(s){return s.lastIndexOf("avc1",0)===0||s.lastIndexOf("mp4a",0)===0});m[e+"Codec"]=t.length>0?t[0]:r[0],c=c.filter(function(s){return r.indexOf(s)===-1})}}),m.unknownCodecs=c}function l(c,m,e){var r=m[e];r&&(c[e]=r)}function i(c,m){for(var e=c[m],r=m;r--;){var t=c[r];if(!t)return;t.programDateTime=e.programDateTime-t.duration*1e3,e=t}}function u(c,m){c.rawProgramDateTime?c.programDateTime=Date.parse(c.rawProgramDateTime):m!=null&&m.programDateTime&&(c.programDateTime=m.endProgramDateTime),(0,C.isFiniteNumber)(c.programDateTime)||(c.programDateTime=null,c.rawProgramDateTime=null)}function g(c,m,e,r){c.relurl=m.URI,m.BYTERANGE&&c.setByteRange(m.BYTERANGE),c.level=e,c.sn="initSegment",r&&(c.levelkeys=r),c.initSegment=null}},"./src/loader/playlist-loader.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>d});var C=T("./src/polyfills/number.ts"),L=T("./src/events.ts"),M=T("./src/errors.ts"),P=T("./src/utils/logger.ts"),B=T("./src/loader/m3u8-parser.ts"),A=T("./src/types/loader.ts"),D=T("./src/utils/attr-list.ts");function x(E){var p=E.type;switch(p){case A.PlaylistContextType.AUDIO_TRACK:return A.PlaylistLevelType.AUDIO;case A.PlaylistContextType.SUBTITLE_TRACK:return A.PlaylistLevelType.SUBTITLE;default:return A.PlaylistLevelType.MAIN}}function _(E,p){var h=E.url;return(h===void 0||h.indexOf("data:")===0)&&(h=p.url),h}var S=function(){function E(h){this.hls=void 0,this.loaders=Object.create(null),this.hls=h,this.registerListeners()}var p=E.prototype;return p.startLoad=function(a){},p.stopLoad=function(){this.destroyInternalLoaders()},p.registerListeners=function(){var a=this.hls;a.on(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.on(L.Events.LEVEL_LOADING,this.onLevelLoading,this),a.on(L.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),a.on(L.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},p.unregisterListeners=function(){var a=this.hls;a.off(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.off(L.Events.LEVEL_LOADING,this.onLevelLoading,this),a.off(L.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),a.off(L.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},p.createInternalLoader=function(a){var o=this.hls.config,n=o.pLoader,v=o.loader,l=n||v,i=new l(o);return a.loader=i,this.loaders[a.type]=i,i},p.getInternalLoader=function(a){return this.loaders[a.type]},p.resetInternalLoader=function(a){this.loaders[a]&&delete this.loaders[a]},p.destroyInternalLoaders=function(){for(var a in this.loaders){var o=this.loaders[a];o&&o.destroy(),this.resetInternalLoader(a)}},p.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},p.onManifestLoading=function(a,o){var n=o.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:A.PlaylistContextType.MANIFEST,url:n,deliveryDirectives:null})},p.onLevelLoading=function(a,o){var n=o.id,v=o.level,l=o.url,i=o.deliveryDirectives;this.load({id:n,groupId:null,level:v,responseType:"text",type:A.PlaylistContextType.LEVEL,url:l,deliveryDirectives:i})},p.onAudioTrackLoading=function(a,o){var n=o.id,v=o.groupId,l=o.url,i=o.deliveryDirectives;this.load({id:n,groupId:v,level:null,responseType:"text",type:A.PlaylistContextType.AUDIO_TRACK,url:l,deliveryDirectives:i})},p.onSubtitleTrackLoading=function(a,o){var n=o.id,v=o.groupId,l=o.url,i=o.deliveryDirectives;this.load({id:n,groupId:v,level:null,responseType:"text",type:A.PlaylistContextType.SUBTITLE_TRACK,url:l,deliveryDirectives:i})},p.load=function(a){var o,n=this.hls.config,v=this.getInternalLoader(a);if(v){var l=v.context;if(l&&l.url===a.url){P.logger.trace("[playlist-loader]: playlist request ongoing");return}P.logger.log("[playlist-loader]: aborting previous loader for type: "+a.type),v.abort()}var i,u,g,c;switch(a.type){case A.PlaylistContextType.MANIFEST:i=n.manifestLoadingMaxRetry,u=n.manifestLoadingTimeOut,g=n.manifestLoadingRetryDelay,c=n.manifestLoadingMaxRetryTimeout;break;case A.PlaylistContextType.LEVEL:case A.PlaylistContextType.AUDIO_TRACK:case A.PlaylistContextType.SUBTITLE_TRACK:i=0,u=n.levelLoadingTimeOut;break;default:i=n.levelLoadingMaxRetry,u=n.levelLoadingTimeOut,g=n.levelLoadingRetryDelay,c=n.levelLoadingMaxRetryTimeout;break}if(v=this.createInternalLoader(a),(o=a.deliveryDirectives)!==null&&o!==void 0&&o.part){var m;if(a.type===A.PlaylistContextType.LEVEL&&a.level!==null?m=this.hls.levels[a.level].details:a.type===A.PlaylistContextType.AUDIO_TRACK&&a.id!==null?m=this.hls.audioTracks[a.id].details:a.type===A.PlaylistContextType.SUBTITLE_TRACK&&a.id!==null&&(m=this.hls.subtitleTracks[a.id].details),m){var e=m.partTarget,r=m.targetduration;e&&r&&(u=Math.min(Math.max(e*3,r*.8)*1e3,u))}}var t={timeout:u,maxRetry:i,retryDelay:g,maxRetryDelay:c,highWaterMark:0},s={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};v.load(a,t,s)},p.loadsuccess=function(a,o,n,v){v===void 0&&(v=null),this.resetInternalLoader(n.type);var l=a.data;if(l.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(a,n,"no EXTM3U delimiter",v);return}o.parsing.start=performance.now(),l.indexOf("#EXTINF:")>0||l.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(a,o,n,v):this.handleMasterPlaylist(a,o,n,v)},p.loaderror=function(a,o,n){n===void 0&&(n=null),this.handleNetworkError(o,n,!1,a)},p.loadtimeout=function(a,o,n){n===void 0&&(n=null),this.handleNetworkError(o,n,!0)},p.handleMasterPlaylist=function(a,o,n,v){var l=this.hls,i=a.data,u=_(a,n),g=B.default.parseMasterPlaylist(i,u),c=g.levels,m=g.sessionData,e=g.sessionKeys;if(!c.length){this.handleManifestParsingError(a,n,"no level found in manifest",v);return}var r=c.map(function(R){return{id:R.attrs.AUDIO,audioCodec:R.audioCodec}}),t=c.map(function(R){return{id:R.attrs.SUBTITLES,textCodec:R.textCodec}}),s=B.default.parseMasterPlaylistMedia(i,u,"AUDIO",r),y=B.default.parseMasterPlaylistMedia(i,u,"SUBTITLES",t),f=B.default.parseMasterPlaylistMedia(i,u,"CLOSED-CAPTIONS");if(s.length){var b=s.some(function(R){return!R.url});!b&&c[0].audioCodec&&!c[0].attrs.AUDIO&&(P.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),s.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new D.AttrList({}),bitrate:0,url:""}))}l.trigger(L.Events.MANIFEST_LOADED,{levels:c,audioTracks:s,subtitles:y,captions:f,url:u,stats:o,networkDetails:v,sessionData:m,sessionKeys:e})},p.handleTrackOrLevelPlaylist=function(a,o,n,v){var l=this.hls,i=n.id,u=n.level,g=n.type,c=_(a,n),m=(0,C.isFiniteNumber)(i)?i:0,e=(0,C.isFiniteNumber)(u)?u:m,r=x(n),t=B.default.parseLevelPlaylist(a.data,c,e,r,m);if(!t.fragments.length){l.trigger(L.Events.ERROR,{type:M.ErrorTypes.NETWORK_ERROR,details:M.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:c,reason:"no fragments found in level",level:typeof n.level=="number"?n.level:void 0});return}if(g===A.PlaylistContextType.MANIFEST){var s={attrs:new D.AttrList({}),bitrate:0,details:t,name:"",url:c};l.trigger(L.Events.MANIFEST_LOADED,{levels:[s],audioTracks:[],url:c,stats:o,networkDetails:v,sessionData:null,sessionKeys:null})}o.parsing.end=performance.now(),n.levelDetails=t,this.handlePlaylistLoaded(a,o,n,v)},p.handleManifestParsingError=function(a,o,n,v){this.hls.trigger(L.Events.ERROR,{type:M.ErrorTypes.NETWORK_ERROR,details:M.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:o.type===A.PlaylistContextType.MANIFEST,url:a.url,reason:n,response:a,context:o,networkDetails:v})},p.handleNetworkError=function(a,o,n,v){n===void 0&&(n=!1),P.logger.warn("[playlist-loader]: A network "+(n?"timeout":"error")+" occurred while loading "+a.type+" level: "+a.level+" id: "+a.id+' group-id: "'+a.groupId+'"');var l=M.ErrorDetails.UNKNOWN,i=!1,u=this.getInternalLoader(a);switch(a.type){case A.PlaylistContextType.MANIFEST:l=n?M.ErrorDetails.MANIFEST_LOAD_TIMEOUT:M.ErrorDetails.MANIFEST_LOAD_ERROR,i=!0;break;case A.PlaylistContextType.LEVEL:l=n?M.ErrorDetails.LEVEL_LOAD_TIMEOUT:M.ErrorDetails.LEVEL_LOAD_ERROR,i=!1;break;case A.PlaylistContextType.AUDIO_TRACK:l=n?M.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:M.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,i=!1;break;case A.PlaylistContextType.SUBTITLE_TRACK:l=n?M.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:M.ErrorDetails.SUBTITLE_LOAD_ERROR,i=!1;break}u&&this.resetInternalLoader(a.type);var g={type:M.ErrorTypes.NETWORK_ERROR,details:l,fatal:i,url:a.url,loader:u,context:a,networkDetails:o};v&&(g.response=v),this.hls.trigger(L.Events.ERROR,g)},p.handlePlaylistLoaded=function(a,o,n,v){var l=n.type,i=n.level,u=n.id,g=n.groupId,c=n.loader,m=n.levelDetails,e=n.deliveryDirectives;if(!(m!=null&&m.targetduration)){this.handleManifestParsingError(a,n,"invalid target duration",v);return}if(!!c)switch(m.live&&(c.getCacheAge&&(m.ageHeader=c.getCacheAge()||0),(!c.getCacheAge||isNaN(m.ageHeader))&&(m.ageHeader=0)),l){case A.PlaylistContextType.MANIFEST:case A.PlaylistContextType.LEVEL:this.hls.trigger(L.Events.LEVEL_LOADED,{details:m,level:i||0,id:u||0,stats:o,networkDetails:v,deliveryDirectives:e});break;case A.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(L.Events.AUDIO_TRACK_LOADED,{details:m,id:u||0,groupId:g||"",stats:o,networkDetails:v,deliveryDirectives:e});break;case A.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(L.Events.SUBTITLE_TRACK_LOADED,{details:m,id:u||0,groupId:g||"",stats:o,networkDetails:v,deliveryDirectives:e});break}},E}();let d=S},"./src/polyfills/number.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{MAX_SAFE_INTEGER:()=>L,isFiniteNumber:()=>C});var C=Number.isFinite||function(M){return typeof M=="number"&&isFinite(M)},L=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>L});var C=function(){function M(){}return M.getSilentFrame=function(B,A){switch(B){case"mp4a.40.2":if(A===1)return new Uint8Array([0,200,0,128,35,128]);if(A===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(A===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(A===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(A===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(A===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(A===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(A===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(A===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}},M}();let L=C},"./src/remux/mp4-generator.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>M});var C=Math.pow(2,32)-1,L=function(){function P(){}return P.init=function(){P.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:[]};var A;for(A in P.types)P.types.hasOwnProperty(A)&&(P.types[A]=[A.charCodeAt(0),A.charCodeAt(1),A.charCodeAt(2),A.charCodeAt(3)]);var D=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),x=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]);P.HDLR_TYPES={video:D,audio:x};var _=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),S=new Uint8Array([0,0,0,0,0,0,0,0]);P.STTS=P.STSC=P.STCO=S,P.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),P.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),P.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),P.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var d=new Uint8Array([105,115,111,109]),E=new Uint8Array([97,118,99,49]),p=new Uint8Array([0,0,0,1]);P.FTYP=P.box(P.types.ftyp,d,p,d,E),P.DINF=P.box(P.types.dinf,P.box(P.types.dref,_))},P.box=function(A){for(var D=8,x=arguments.length,_=new Array(x>1?x-1:0),S=1;S<x;S++)_[S-1]=arguments[S];for(var d=_.length,E=d;d--;)D+=_[d].byteLength;var p=new Uint8Array(D);for(p[0]=D>>24&255,p[1]=D>>16&255,p[2]=D>>8&255,p[3]=D&255,p.set(A,4),d=0,D=8;d<E;d++)p.set(_[d],D),D+=_[d].byteLength;return p},P.hdlr=function(A){return P.box(P.types.hdlr,P.HDLR_TYPES[A])},P.mdat=function(A){return P.box(P.types.mdat,A)},P.mdhd=function(A,D){D*=A;var x=Math.floor(D/(C+1)),_=Math.floor(D%(C+1));return P.box(P.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,A>>24&255,A>>16&255,A>>8&255,A&255,x>>24,x>>16&255,x>>8&255,x&255,_>>24,_>>16&255,_>>8&255,_&255,85,196,0,0]))},P.mdia=function(A){return P.box(P.types.mdia,P.mdhd(A.timescale,A.duration),P.hdlr(A.type),P.minf(A))},P.mfhd=function(A){return P.box(P.types.mfhd,new Uint8Array([0,0,0,0,A>>24,A>>16&255,A>>8&255,A&255]))},P.minf=function(A){return A.type==="audio"?P.box(P.types.minf,P.box(P.types.smhd,P.SMHD),P.DINF,P.stbl(A)):P.box(P.types.minf,P.box(P.types.vmhd,P.VMHD),P.DINF,P.stbl(A))},P.moof=function(A,D,x){return P.box(P.types.moof,P.mfhd(A),P.traf(x,D))},P.moov=function(A){for(var D=A.length,x=[];D--;)x[D]=P.trak(A[D]);return P.box.apply(null,[P.types.moov,P.mvhd(A[0].timescale,A[0].duration)].concat(x).concat(P.mvex(A)))},P.mvex=function(A){for(var D=A.length,x=[];D--;)x[D]=P.trex(A[D]);return P.box.apply(null,[P.types.mvex].concat(x))},P.mvhd=function(A,D){D*=A;var x=Math.floor(D/(C+1)),_=Math.floor(D%(C+1)),S=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,A>>24&255,A>>16&255,A>>8&255,A&255,x>>24,x>>16&255,x>>8&255,x&255,_>>24,_>>16&255,_>>8&255,_&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 P.box(P.types.mvhd,S)},P.sdtp=function(A){var D=A.samples||[],x=new Uint8Array(4+D.length),_,S;for(_=0;_<D.length;_++)S=D[_].flags,x[_+4]=S.dependsOn<<4|S.isDependedOn<<2|S.hasRedundancy;return P.box(P.types.sdtp,x)},P.stbl=function(A){return P.box(P.types.stbl,P.stsd(A),P.box(P.types.stts,P.STTS),P.box(P.types.stsc,P.STSC),P.box(P.types.stsz,P.STSZ),P.box(P.types.stco,P.STCO))},P.avc1=function(A){var D=[],x=[],_,S,d;for(_=0;_<A.sps.length;_++)S=A.sps[_],d=S.byteLength,D.push(d>>>8&255),D.push(d&255),D=D.concat(Array.prototype.slice.call(S));for(_=0;_<A.pps.length;_++)S=A.pps[_],d=S.byteLength,x.push(d>>>8&255),x.push(d&255),x=x.concat(Array.prototype.slice.call(S));var E=P.box(P.types.avcC,new Uint8Array([1,D[3],D[4],D[5],255,224|A.sps.length].concat(D).concat([A.pps.length]).concat(x))),p=A.width,h=A.height,a=A.pixelRatio[0],o=A.pixelRatio[1];return P.box(P.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,p>>8&255,p&255,h>>8&255,h&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]),E,P.box(P.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),P.box(P.types.pasp,new Uint8Array([a>>24,a>>16&255,a>>8&255,a&255,o>>24,o>>16&255,o>>8&255,o&255])))},P.esds=function(A){var D=A.config.length;return new Uint8Array([0,0,0,0,3,23+D,0,1,0,4,15+D,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([D]).concat(A.config).concat([6,1,2]))},P.mp4a=function(A){var D=A.samplerate;return P.box(P.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,A.channelCount,0,16,0,0,0,0,D>>8&255,D&255,0,0]),P.box(P.types.esds,P.esds(A)))},P.mp3=function(A){var D=A.samplerate;return P.box(P.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,A.channelCount,0,16,0,0,0,0,D>>8&255,D&255,0,0]))},P.stsd=function(A){return A.type==="audio"?A.segmentCodec==="mp3"&&A.codec==="mp3"?P.box(P.types.stsd,P.STSD,P.mp3(A)):P.box(P.types.stsd,P.STSD,P.mp4a(A)):P.box(P.types.stsd,P.STSD,P.avc1(A))},P.tkhd=function(A){var D=A.id,x=A.duration*A.timescale,_=A.width,S=A.height,d=Math.floor(x/(C+1)),E=Math.floor(x%(C+1));return P.box(P.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,D>>24&255,D>>16&255,D>>8&255,D&255,0,0,0,0,d>>24,d>>16&255,d>>8&255,d&255,E>>24,E>>16&255,E>>8&255,E&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,_>>8&255,_&255,0,0,S>>8&255,S&255,0,0]))},P.traf=function(A,D){var x=P.sdtp(A),_=A.id,S=Math.floor(D/(C+1)),d=Math.floor(D%(C+1));return P.box(P.types.traf,P.box(P.types.tfhd,new Uint8Array([0,0,0,0,_>>24,_>>16&255,_>>8&255,_&255])),P.box(P.types.tfdt,new Uint8Array([1,0,0,0,S>>24,S>>16&255,S>>8&255,S&255,d>>24,d>>16&255,d>>8&255,d&255])),P.trun(A,x.length+16+20+8+16+8+8),x)},P.trak=function(A){return A.duration=A.duration||4294967295,P.box(P.types.trak,P.tkhd(A),P.mdia(A))},P.trex=function(A){var D=A.id;return P.box(P.types.trex,new Uint8Array([0,0,0,0,D>>24,D>>16&255,D>>8&255,D&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},P.trun=function(A,D){var x=A.samples||[],_=x.length,S=12+16*_,d=new Uint8Array(S),E,p,h,a,o,n;for(D+=8+S,d.set([A.type==="video"?1:0,0,15,1,_>>>24&255,_>>>16&255,_>>>8&255,_&255,D>>>24&255,D>>>16&255,D>>>8&255,D&255],0),E=0;E<_;E++)p=x[E],h=p.duration,a=p.size,o=p.flags,n=p.cts,d.set([h>>>24&255,h>>>16&255,h>>>8&255,h&255,a>>>24&255,a>>>16&255,a>>>8&255,a&255,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,o.degradPrio&240<<8,o.degradPrio&15,n>>>24&255,n>>>16&255,n>>>8&255,n&255],12+16*E);return P.box(P.types.trun,d)},P.initSegment=function(A){P.types||P.init();var D=P.moov(A),x=new Uint8Array(P.FTYP.byteLength+D.byteLength);return x.set(P.FTYP),x.set(D,P.FTYP.byteLength),x},P}();L.types=void 0,L.HDLR_TYPES=void 0,L.STTS=void 0,L.STSC=void 0,L.STCO=void 0,L.STSZ=void 0,L.VMHD=void 0,L.SMHD=void 0,L.STSD=void 0,L.FTYP=void 0,L.DINF=void 0;let M=L},"./src/remux/mp4-remuxer.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>a,flushTextTrackMetadataCueSamples:()=>v,flushTextTrackUserdataCueSamples:()=>l,normalizePts:()=>o});var C=T("./src/polyfills/number.ts"),L=T("./src/remux/aac-helper.ts"),M=T("./src/remux/mp4-generator.ts"),P=T("./src/events.ts"),B=T("./src/errors.ts"),A=T("./src/utils/logger.ts"),D=T("./src/types/loader.ts"),x=T("./src/utils/timescale-conversion.ts");function _(){return _=Object.assign?Object.assign.bind():function(g){for(var c=1;c<arguments.length;c++){var m=arguments[c];for(var e in m)Object.prototype.hasOwnProperty.call(m,e)&&(g[e]=m[e])}return g},_.apply(this,arguments)}var S=10*1e3,d=1024,E=1152,p=null,h=null,a=function(){function g(m,e,r,t){if(t===void 0&&(t=""),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=void 0,this._initDTS=void 0,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=m,this.config=e,this.typeSupported=r,this.ISGenerated=!1,p===null){var s=navigator.userAgent||"",y=s.match(/Chrome\/(\d+)/i);p=y?parseInt(y[1]):0}if(h===null){var f=navigator.userAgent.match(/Safari\/(\d+)/i);h=f?parseInt(f[1]):0}}var c=g.prototype;return c.destroy=function(){},c.resetTimeStamp=function(e){A.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e},c.resetNextTimestamp=function(){A.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},c.resetInitSegment=function(){A.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},c.getVideoStartPts=function(e){var r=!1,t=e.reduce(function(s,y){var f=y.pts-s;return f<-4294967296?(r=!0,o(s,y.pts)):f>0?s:y.pts},e[0].pts);return r&&A.logger.debug("PTS rollover detected"),t},c.remux=function(e,r,t,s,y,f,b,R){var I,k,F,K,H,j,Y=y,Q=y,q=e.pid>-1,ne=r.pid>-1,te=r.samples.length,ae=e.samples.length>0,ue=b&&te>0||te>1,ce=(!q||ae)&&(!ne||ue)||this.ISGenerated||b;if(ce){this.ISGenerated||(F=this.generateIS(e,r,y));var le=this.isVideoContiguous,fe=-1,de;if(ue&&(fe=n(r.samples),!le&&this.config.forceKeyFrameOnDiscontinuity))if(j=!0,fe>0){A.logger.warn("[mp4-remuxer]: Dropped "+fe+" out of "+te+" video samples due to a missing keyframe");var xe=this.getVideoStartPts(r.samples);r.samples=r.samples.slice(fe),r.dropped+=fe,Q+=(r.samples[0].pts-xe)/r.inputTimeScale,de=Q}else fe===-1&&(A.logger.warn("[mp4-remuxer]: No keyframe found out of "+te+" video samples"),j=!1);if(this.ISGenerated){if(ae&&ue){var Ae=this.getVideoStartPts(r.samples),Ie=o(e.samples[0].pts,Ae)-Ae,Re=Ie/r.inputTimeScale;Y+=Math.max(0,Re),Q+=Math.max(0,-Re)}if(ae){if(e.samplerate||(A.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),F=this.generateIS(e,r,y)),k=this.remuxAudio(e,Y,this.isAudioContiguous,f,ne||ue||R===D.PlaylistLevelType.AUDIO?Q:void 0),ue){var Oe=k?k.endPTS-k.startPTS:0;r.inputTimeScale||(A.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),F=this.generateIS(e,r,y)),I=this.remuxVideo(r,Q,le,Oe)}}else ue&&(I=this.remuxVideo(r,Q,le,0));I&&(I.firstKeyFrame=fe,I.independent=fe!==-1,I.firstKeyFramePTS=de)}}return this.ISGenerated&&(t.samples.length&&(H=v(t,y,this._initPTS,this._initDTS)),s.samples.length&&(K=l(s,y,this._initPTS))),{audio:k,video:I,initSegment:F,independent:j,text:K,id3:H}},c.generateIS=function(e,r,t){var s=e.samples,y=r.samples,f=this.typeSupported,b={},R=!(0,C.isFiniteNumber)(this._initPTS),I="audio/mp4",k,F,K;if(R&&(k=F=1/0),e.config&&s.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":f.mpeg?(I="audio/mpeg",e.codec=""):f.mp3&&(e.codec="mp3");break}b.audio={id:"audio",container:I,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&f.mpeg?new Uint8Array(0):M.default.initSegment([e]),metadata:{channelCount:e.channelCount}},R&&(K=e.inputTimeScale,k=F=s[0].pts-Math.round(K*t))}if(r.sps&&r.pps&&y.length&&(r.timescale=r.inputTimeScale,b.video={id:"main",container:"video/mp4",codec:r.codec,initSegment:M.default.initSegment([r]),metadata:{width:r.width,height:r.height}},R)){K=r.inputTimeScale;var H=this.getVideoStartPts(y),j=Math.round(K*t);F=Math.min(F,o(y[0].dts,H)-j),k=Math.min(k,H-j)}if(Object.keys(b).length)return this.ISGenerated=!0,R&&(this._initPTS=k,this._initDTS=F),{tracks:b,initPTS:k,timescale:K}},c.remuxVideo=function(e,r,t,s){var y=e.inputTimeScale,f=e.samples,b=[],R=f.length,I=this._initPTS,k=this.nextAvcDts,F=8,K=this.videoSampleDuration,H,j,Y=Number.POSITIVE_INFINITY,Q=Number.NEGATIVE_INFINITY,q=!1;if(!t||k===null){var ne=r*y,te=f[0].pts-o(f[0].dts,f[0].pts);k=ne-te}for(var ae=0;ae<R;ae++){var ue=f[ae];ue.pts=o(ue.pts-I,k),ue.dts=o(ue.dts-I,k),ue.dts<f[ae>0?ae-1:ae].dts&&(q=!0)}q&&f.sort(function(ut,wt){var ar=ut.dts-wt.dts,sr=ut.pts-wt.pts;return ar||sr}),H=f[0].dts,j=f[f.length-1].dts;var ce=j-H,le=ce?Math.round(ce/(R-1)):K||e.inputTimeScale/30;if(t){var fe=H-k,de=fe>le,xe=fe<-1;if((de||xe)&&(de?A.logger.warn("AVC: "+(0,x.toMsFromMpegTsClock)(fe,!0)+" ms ("+fe+"dts) hole between fragments detected, filling it"):A.logger.warn("AVC: "+(0,x.toMsFromMpegTsClock)(-fe,!0)+" ms ("+fe+"dts) overlapping between fragments detected"),!xe||k>f[0].pts)){H=k;var Ae=f[0].pts-fe;f[0].dts=H,f[0].pts=Ae,A.logger.log("Video: First PTS/DTS adjusted: "+(0,x.toMsFromMpegTsClock)(Ae,!0)+"/"+(0,x.toMsFromMpegTsClock)(H,!0)+", delta: "+(0,x.toMsFromMpegTsClock)(fe,!0)+" ms")}}H=Math.max(0,H);for(var Ie=0,Re=0,Oe=0;Oe<R;Oe++){for(var Pe=f[Oe],Ce=Pe.units,Le=Ce.length,ke=0,Be=0;Be<Le;Be++)ke+=Ce[Be].data.length;Re+=ke,Ie+=Le,Pe.length=ke,Pe.dts=Math.max(Pe.dts,H),Y=Math.min(Pe.pts,Y),Q=Math.max(Pe.pts,Q)}j=f[R-1].dts;var we=Re+4*Ie+8,Ye;try{Ye=new Uint8Array(we)}catch{this.observer.emit(P.Events.ERROR,P.Events.ERROR,{type:B.ErrorTypes.MUX_ERROR,details:B.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:we,reason:"fail allocating video mdat "+we});return}var Xe=new DataView(Ye.buffer);Xe.setUint32(0,we),Ye.set(M.default.types.mdat,4);for(var rt=!1,ze=Number.POSITIVE_INFINITY,it=Number.POSITIVE_INFINITY,nt=Number.NEGATIVE_INFINITY,Je=Number.NEGATIVE_INFINITY,Ne=0;Ne<R;Ne++){for(var Ke=f[Ne],Ze=Ke.units,ft=0,Me=0,qe=Ze.length;Me<qe;Me++){var et=Ze[Me],_t=et.data,mt=et.data.byteLength;Xe.setUint32(F,mt),F+=4,Ye.set(_t,F),F+=mt,ft+=4+mt}var pt=void 0;if(Ne<R-1)K=f[Ne+1].dts-Ke.dts,pt=f[Ne+1].pts-Ke.pts;else{var Rt=this.config,Tt=Ne>0?Ke.dts-f[Ne-1].dts:le;if(pt=Ne>0?Ke.pts-f[Ne-1].pts:le,Rt.stretchShortVideoTrack&&this.nextAudioPts!==null){var Gt=Math.floor(Rt.maxBufferHole*y),It=(s?Y+s*y:this.nextAudioPts)-Ke.pts;It>Gt?(K=It-Tt,K<0?K=Tt:rt=!0,A.logger.log("[mp4-remuxer]: It is approximately "+It/90+" ms to the next segment; using duration "+K/90+" ms for the last video frame.")):K=Tt}else K=Tt}var tr=Math.round(Ke.pts-Ke.dts);ze=Math.min(ze,K),nt=Math.max(nt,K),it=Math.min(it,pt),Je=Math.max(Je,pt),b.push(new i(Ke.key,K,ft,tr))}if(b.length){if(p){if(p<70){var Ot=b[0].flags;Ot.dependsOn=2,Ot.isNonSync=0}}else if(h&&Je-it<nt-ze&&le/nt<.025&&b[0].cts===0){A.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var St=H,lt=0,Ht=b.length;lt<Ht;lt++){var Ct=St+b[lt].duration,jt=St+b[lt].cts;if(lt<Ht-1){var Mt=Ct+b[lt+1].cts;b[lt].duration=Mt-jt}else b[lt].duration=lt?b[lt-1].duration:le;b[lt].cts=0,St=Ct}}}console.assert(K!==null,"mp4SampleDuration must be computed"),K=rt||!K?le:K,this.nextAvcDts=k=j+K,this.videoSampleDuration=K,this.isVideoContiguous=!0;var rr=M.default.moof(e.sequenceNumber++,H,_({},e,{samples:b})),ir="video",nr={data1:rr,data2:Ye,startPTS:Y/y,endPTS:(Q+K)/y,startDTS:H/y,endDTS:k/y,type:ir,hasAudio:!1,hasVideo:!0,nb:b.length,dropped:e.dropped};return e.samples=[],e.dropped=0,console.assert(Ye.length,"MDAT length must not be zero"),nr},c.remuxAudio=function(e,r,t,s,y){var f=e.inputTimeScale,b=e.samplerate?e.samplerate:f,R=f/b,I=e.segmentCodec==="aac"?d:E,k=I*R,F=this._initPTS,K=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,H=[],j=y!==void 0,Y=e.samples,Q=K?0:8,q=this.nextAudioPts||-1,ne=r*f;if(this.isAudioContiguous=t=t||Y.length&&q>0&&(s&&Math.abs(ne-q)<9e3||Math.abs(o(Y[0].pts-F,ne)-q)<20*k),Y.forEach(function(et){et.pts=o(et.pts-F,ne)}),!t||q<0){if(Y=Y.filter(function(et){return et.pts>=0}),!Y.length)return;y===0?q=0:s&&!j?q=Math.max(0,ne):q=Y[0].pts}if(e.segmentCodec==="aac")for(var te=this.config.maxAudioFramesDrift,ae=0,ue=q;ae<Y.length;ae++){var ce=Y[ae],le=ce.pts,fe=le-ue,de=Math.abs(1e3*fe/f);if(fe<=-te*k&&j)ae===0&&(A.logger.warn("Audio frame @ "+(le/f).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*fe/f)+" ms."),this.nextAudioPts=q=ue=le);else if(fe>=te*k&&de<S&&j){var xe=Math.round(fe/k);ue=le-xe*k,ue<0&&(xe--,ue+=k),ae===0&&(this.nextAudioPts=q=ue),A.logger.warn("[mp4-remuxer]: Injecting "+xe+" audio frame @ "+(ue/f).toFixed(3)+"s due to "+Math.round(1e3*fe/f)+" ms gap.");for(var Ae=0;Ae<xe;Ae++){var Ie=Math.max(ue,0),Re=L.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);Re||(A.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Re=ce.unit.subarray()),Y.splice(ae,0,{unit:Re,pts:Ie}),ue+=k,ae++}}ce.pts=ue,ue+=k}for(var Oe=null,Pe=null,Ce,Le=0,ke=Y.length;ke--;)Le+=Y[ke].unit.byteLength;for(var Be=0,we=Y.length;Be<we;Be++){var Ye=Y[Be],Xe=Ye.unit,rt=Ye.pts;if(Pe!==null){var ze=H[Be-1];ze.duration=Math.round((rt-Pe)/R)}else if(t&&e.segmentCodec==="aac"&&(rt=q),Oe=rt,Le>0){Le+=Q;try{Ce=new Uint8Array(Le)}catch{this.observer.emit(P.Events.ERROR,P.Events.ERROR,{type:B.ErrorTypes.MUX_ERROR,details:B.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Le,reason:"fail allocating audio mdat "+Le});return}if(!K){var it=new DataView(Ce.buffer);it.setUint32(0,Le),Ce.set(M.default.types.mdat,4)}}else return;Ce.set(Xe,Q);var nt=Xe.byteLength;Q+=nt,H.push(new i(!0,I,nt,0)),Pe=rt}var Je=H.length;if(!!Je){var Ne=H[H.length-1];this.nextAudioPts=q=Pe+R*Ne.duration;var Ke=K?new Uint8Array(0):M.default.moof(e.sequenceNumber++,Oe/R,_({},e,{samples:H}));e.samples=[];var Ze=Oe/f,ft=q/f,Me="audio",qe={data1:Ke,data2:Ce,startPTS:Ze,endPTS:ft,startDTS:Ze,endDTS:ft,type:Me,hasAudio:!0,hasVideo:!1,nb:Je};return this.isAudioContiguous=!0,console.assert(Ce.length,"MDAT length must not be zero"),qe}},c.remuxEmptyAudio=function(e,r,t,s){var y=e.inputTimeScale,f=e.samplerate?e.samplerate:y,b=y/f,R=this.nextAudioPts,I=(R!==null?R:s.startDTS*y)+this._initDTS,k=s.endDTS*y+this._initDTS,F=b*d,K=Math.ceil((k-I)/F),H=L.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(A.logger.warn("[mp4-remuxer]: remux empty Audio"),!H){A.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var j=[],Y=0;Y<K;Y++){var Q=I+Y*F;j.push({unit:H,pts:Q,dts:Q})}return e.samples=j,this.remuxAudio(e,r,t,!1)},g}();function o(g,c){var m;if(c===null)return g;for(c<g?m=-8589934592:m=8589934592;Math.abs(g-c)>4294967296;)g+=m;return g}function n(g){for(var c=0;c<g.length;c++)if(g[c].key)return c;return-1}function v(g,c,m,e){var r=g.samples.length;if(!!r){for(var t=g.inputTimeScale,s=0;s<r;s++){var y=g.samples[s];y.pts=o(y.pts-m,c*t)/t,y.dts=o(y.dts-e,c*t)/t}var f=g.samples;return g.samples=[],{samples:f}}}function l(g,c,m){var e=g.samples.length;if(!!e){for(var r=g.inputTimeScale,t=0;t<e;t++){var s=g.samples[t];s.pts=o(s.pts-m,c*r)/r}g.samples.sort(function(f,b){return f.pts-b.pts});var y=g.samples;return g.samples=[],{samples:y}}}var i=function(c,m,e,r){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=m,this.size=e,this.cts=r,this.flags=new u(c)},u=function(c){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=c?2:1,this.isNonSync=c?0:1}},"./src/remux/passthrough-remuxer.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>x});var C=T("./src/polyfills/number.ts"),L=T("./src/remux/mp4-remuxer.ts"),M=T("./src/utils/mp4-tools.ts"),P=T("./src/loader/fragment.ts"),B=T("./src/utils/logger.ts"),A=function(){function _(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndTime=null}var S=_.prototype;return S.destroy=function(){},S.resetTimeStamp=function(E){this.initPTS=E,this.lastEndTime=null},S.resetNextTimestamp=function(){this.lastEndTime=null},S.resetInitSegment=function(E,p,h,a){this.audioCodec=p,this.videoCodec=h,this.generateInitSegment((0,M.patchEncyptionData)(E,a)),this.emitInitSegment=!0},S.generateInitSegment=function(E){var p=this.audioCodec,h=this.videoCodec;if(!E||!E.byteLength){this.initTracks=void 0,this.initData=void 0;return}var a=this.initData=(0,M.parseInitSegment)(E);p||(p=D(a.audio,P.ElementaryStreamTypes.AUDIO)),h||(h=D(a.video,P.ElementaryStreamTypes.VIDEO));var o={};a.audio&&a.video?o.audiovideo={container:"video/mp4",codec:p+","+h,initSegment:E,id:"main"}:a.audio?o.audio={container:"audio/mp4",codec:p,initSegment:E,id:"audio"}:a.video?o.video={container:"video/mp4",codec:h,initSegment:E,id:"main"}:B.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=o},S.remux=function(E,p,h,a,o){var n,v=this.initPTS,l=this.lastEndTime,i={audio:void 0,video:void 0,text:a,id3:h,initSegment:void 0};(0,C.isFiniteNumber)(l)||(l=this.lastEndTime=o||0);var u=p.samples;if(!u||!u.length)return i;var g={initPTS:void 0,timescale:1},c=this.initData;if((!c||!c.length)&&(this.generateInitSegment(u),c=this.initData),!c||!c.length)return B.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),i;this.emitInitSegment&&(g.tracks=this.initTracks,this.emitInitSegment=!1);var m=(0,M.getStartDTS)(c,u);(0,C.isFiniteNumber)(v)||(this.initPTS=g.initPTS=v=m-o);var e=(0,M.getDuration)(u,c),r=E?m-v:l,t=r+e;(0,M.offsetStartDTS)(c,u,v),e>0?this.lastEndTime=t:(B.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var s=!!c.audio,y=!!c.video,f="";s&&(f+="audio"),y&&(f+="video");var b={data1:u,startPTS:r,startDTS:r,endPTS:t,endDTS:t,type:f,hasAudio:s,hasVideo:y,nb:1,dropped:0};i.audio=b.type==="audio"?b:void 0,i.video=b.type!=="audio"?b:void 0,i.initSegment=g;var R=(n=this.initPTS)!=null?n:0;return i.id3=(0,L.flushTextTrackMetadataCueSamples)(h,o,R,R),a.samples.length&&(i.text=(0,L.flushTextTrackUserdataCueSamples)(a,o,R)),i},_}();function D(_,S){var d=_==null?void 0:_.codec;return d&&d.length>4?d:d==="hvc1"||d==="hev1"?"hvc1.1.c.L120.90":d==="av01"?"av01.0.04M.08":d==="avc1"||S===P.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}let x=A},"./src/task-loop.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>C});var C=function(){function L(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var M=L.prototype;return M.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},M.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},M.onHandlerDestroyed=function(){},M.hasInterval=function(){return!!this._tickInterval},M.hasNextTick=function(){return!!this._tickTimer},M.setInterval=function(B){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,B),!0)},M.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},M.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},M.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},M.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},M.doTick=function(){},L}()},"./src/types/cmcd.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{CMCDObjectType:()=>L,CMCDStreamType:()=>P,CMCDStreamingFormat:()=>M,CMCDVersion:()=>C});var C=1,L;(function(B){B.MANIFEST="m",B.AUDIO="a",B.VIDEO="v",B.MUXED="av",B.INIT="i",B.CAPTION="c",B.TIMED_TEXT="tt",B.KEY="k",B.OTHER="o"})(L||(L={}));var M;(function(B){B.DASH="d",B.HLS="h",B.SMOOTH="s",B.OTHER="o"})(M||(M={}));var P;(function(B){B.VOD="v",B.LIVE="l"})(P||(P={}))},"./src/types/demuxer.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{MetadataSchema:()=>C});var C;(function(L){L.audioId3="org.id3",L.dateRange="com.apple.quicktime.HLS",L.emsg="https://aomedia.org/emsg/ID3"})(C||(C={}))},"./src/types/level.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{HdcpLevels:()=>B,HlsSkip:()=>A,HlsUrlParameters:()=>x,Level:()=>_,getSkipValue:()=>D});function C(S,d){for(var E=0;E<d.length;E++){var p=d[E];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(S,M(p.key),p)}}function L(S,d,E){return d&&C(S.prototype,d),E&&C(S,E),Object.defineProperty(S,"prototype",{writable:!1}),S}function M(S){var d=P(S,"string");return typeof d=="symbol"?d:String(d)}function P(S,d){if(typeof S!="object"||S===null)return S;var E=S[Symbol.toPrimitive];if(E!==void 0){var p=E.call(S,d||"default");if(typeof p!="object")return p;throw new TypeError("@@toPrimitive must return a primitive value.")}return(d==="string"?String:Number)(S)}var B=["NONE","TYPE-0","TYPE-1","TYPE-2",null],A;(function(S){S.No="",S.Yes="YES",S.v2="v2"})(A||(A={}));function D(S,d){var E=S.canSkipUntil,p=S.canSkipDateRanges,h=S.endSN,a=d!==void 0?d-h:0;return E&&a<E?p?A.v2:A.Yes:A.No}var x=function(){function S(E,p,h){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=E,this.part=p,this.skip=h}var d=S.prototype;return d.addDirectives=function(p){var h=new self.URL(p);return this.msn!==void 0&&h.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&h.searchParams.set("_HLS_part",this.part.toString()),this.skip&&h.searchParams.set("_HLS_skip",this.skip),h.href},S}(),_=function(){function S(d){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=[d.url],this.attrs=d.attrs,this.bitrate=d.bitrate,d.details&&(this.details=d.details),this.id=d.id||0,this.name=d.name,this.width=d.width||0,this.height=d.height||0,this.audioCodec=d.audioCodec,this.videoCodec=d.videoCodec,this.unknownCodecs=d.unknownCodecs,this.codecSet=[d.videoCodec,d.audioCodec].filter(function(E){return E}).join(",").replace(/\.[^.,]+/g,"")}return L(S,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(E){var p=E%this.url.length;this._urlId!==p&&(this.details=void 0,this._urlId=p)}}]),S}()},"./src/types/loader.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{PlaylistContextType:()=>C,PlaylistLevelType:()=>L});var C;(function(M){M.MANIFEST="manifest",M.LEVEL="level",M.AUDIO_TRACK="audioTrack",M.SUBTITLE_TRACK="subtitleTrack"})(C||(C={}));var L;(function(M){M.MAIN="main",M.AUDIO="audio",M.SUBTITLE="subtitle"})(L||(L={}))},"./src/types/transmuxer.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{ChunkMetadata:()=>C});var C=function(P,B,A,D,x,_){D===void 0&&(D=0),x===void 0&&(x=-1),_===void 0&&(_=!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=L(),this.buffering={audio:L(),video:L(),audiovideo:L()},this.level=P,this.sn=B,this.id=A,this.size=D,this.part=x,this.partial=_};function L(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{AttrList:()=>M});var C=/^(\d+)x(\d+)$/,L=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,M=function(){function P(A){typeof A=="string"&&(A=P.parseAttrList(A));for(var D in A)A.hasOwnProperty(D)&&(this[D]=A[D])}var B=P.prototype;return B.decimalInteger=function(D){var x=parseInt(this[D],10);return x>Number.MAX_SAFE_INTEGER?1/0:x},B.hexadecimalInteger=function(D){if(this[D]){var x=(this[D]||"0x").slice(2);x=(x.length&1?"0":"")+x;for(var _=new Uint8Array(x.length/2),S=0;S<x.length/2;S++)_[S]=parseInt(x.slice(S*2,S*2+2),16);return _}else return null},B.hexadecimalIntegerAsNumber=function(D){var x=parseInt(this[D],16);return x>Number.MAX_SAFE_INTEGER?1/0:x},B.decimalFloatingPoint=function(D){return parseFloat(this[D])},B.optionalFloat=function(D,x){var _=this[D];return _?parseFloat(_):x},B.enumeratedString=function(D){return this[D]},B.bool=function(D){return this[D]==="YES"},B.decimalResolution=function(D){var x=C.exec(this[D]);if(x!==null)return{width:parseInt(x[1],10),height:parseInt(x[2],10)}},P.parseAttrList=function(D){var x,_={},S='"';for(L.lastIndex=0;(x=L.exec(D))!==null;){var d=x[2];d.indexOf(S)===0&&d.lastIndexOf(S)===d.length-1&&(d=d.slice(1,-1)),_[x[1]]=d}return _},P}()},"./src/utils/binary-search.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>L});var C={search:function(P,B){for(var A=0,D=P.length-1,x=null,_=null;A<=D;){x=(A+D)/2|0,_=P[x];var S=B(_);if(S>0)A=x+1;else if(S<0)D=x-1;else return _}return null}};let L=C},"./src/utils/buffer-helper.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{BufferHelper:()=>M});var C=T("./src/utils/logger.ts"),L={length:0,start:function(){return 0},end:function(){return 0}},M=function(){function P(){}return P.isBuffered=function(A,D){try{if(A){for(var x=P.getBuffered(A),_=0;_<x.length;_++)if(D>=x.start(_)&&D<=x.end(_))return!0}}catch{}return!1},P.bufferInfo=function(A,D,x){try{if(A){var _=P.getBuffered(A),S=[],d;for(d=0;d<_.length;d++)S.push({start:_.start(d),end:_.end(d)});return this.bufferedInfo(S,D,x)}}catch{}return{len:0,start:D,end:D,nextStart:void 0}},P.bufferedInfo=function(A,D,x){D=Math.max(0,D),A.sort(function(i,u){var g=i.start-u.start;return g||u.end-i.end});var _=[];if(x)for(var S=0;S<A.length;S++){var d=_.length;if(d){var E=_[d-1].end;A[S].start-E<x?A[S].end>E&&(_[d-1].end=A[S].end):_.push(A[S])}else _.push(A[S])}else _=A;for(var p=0,h,a=D,o=D,n=0;n<_.length;n++){var v=_[n].start,l=_[n].end;if(D+x>=v&&D<l)a=v,o=l,p=o-D;else if(D+x<v){h=v;break}}return{len:p,start:a||0,end:o||0,nextStart:h}},P.getBuffered=function(A){try{return A.buffered}catch(D){return C.logger.log("failed to get media.buffered",D),L}},P}()},"./src/utils/cea-608-parser.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{CaptionScreen:()=>n,Row:()=>o,default:()=>c});var C=T("./src/utils/logger.ts"),L={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},M=function(e){var r=e;return L.hasOwnProperty(e)&&(r=L[e]),String.fromCharCode(r)},P=15,B=100,A={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},D={17:2,18:4,21:6,22:8,23:10,19:13,20:15},x={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},_={25:2,26:4,29:6,30:8,31:10,27:13,28:15},S=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],d;(function(m){m[m.ERROR=0]="ERROR",m[m.TEXT=1]="TEXT",m[m.WARNING=2]="WARNING",m[m.INFO=2]="INFO",m[m.DEBUG=3]="DEBUG",m[m.DATA=3]="DATA"})(d||(d={}));var E=function(){function m(){this.time=null,this.verboseLevel=d.ERROR}var e=m.prototype;return e.log=function(t,s){if(this.verboseLevel>=t){var y=typeof s=="function"?s():s;C.logger.log(this.time+" ["+t+"] "+y)}},m}(),p=function(e){for(var r=[],t=0;t<e.length;t++)r.push(e[t].toString(16));return r},h=function(){function m(r,t,s,y,f){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=r||"white",this.underline=t||!1,this.italics=s||!1,this.background=y||"black",this.flash=f||!1}var e=m.prototype;return e.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},e.setStyles=function(t){for(var s=["foreground","underline","italics","background","flash"],y=0;y<s.length;y++){var f=s[y];t.hasOwnProperty(f)&&(this[f]=t[f])}},e.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},e.equals=function(t){return this.foreground===t.foreground&&this.underline===t.underline&&this.italics===t.italics&&this.background===t.background&&this.flash===t.flash},e.copy=function(t){this.foreground=t.foreground,this.underline=t.underline,this.italics=t.italics,this.background=t.background,this.flash=t.flash},e.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},m}(),a=function(){function m(r,t,s,y,f,b){this.uchar=void 0,this.penState=void 0,this.uchar=r||" ",this.penState=new h(t,s,y,f,b)}var e=m.prototype;return e.reset=function(){this.uchar=" ",this.penState.reset()},e.setChar=function(t,s){this.uchar=t,this.penState.copy(s)},e.setPenState=function(t){this.penState.copy(t)},e.equals=function(t){return this.uchar===t.uchar&&this.penState.equals(t.penState)},e.copy=function(t){this.uchar=t.uchar,this.penState.copy(t.penState)},e.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},m}(),o=function(){function m(r){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var t=0;t<B;t++)this.chars.push(new a);this.logger=r,this.pos=0,this.currPenState=new h}var e=m.prototype;return e.equals=function(t){for(var s=!0,y=0;y<B;y++)if(!this.chars[y].equals(t.chars[y])){s=!1;break}return s},e.copy=function(t){for(var s=0;s<B;s++)this.chars[s].copy(t.chars[s])},e.isEmpty=function(){for(var t=!0,s=0;s<B;s++)if(!this.chars[s].isEmpty()){t=!1;break}return t},e.setCursor=function(t){this.pos!==t&&(this.pos=t),this.pos<0?(this.logger.log(d.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>B&&(this.logger.log(d.DEBUG,"Too large cursor position "+this.pos),this.pos=B)},e.moveCursor=function(t){var s=this.pos+t;if(t>1)for(var y=this.pos+1;y<s+1;y++)this.chars[y].setPenState(this.currPenState);this.setCursor(s)},e.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},e.insertChar=function(t){var s=this;t>=144&&this.backSpace();var y=M(t);if(this.pos>=B){this.logger.log(d.ERROR,function(){return"Cannot insert "+t.toString(16)+" ("+y+") at position "+s.pos+". Skipping it!"});return}this.chars[this.pos].setChar(y,this.currPenState),this.moveCursor(1)},e.clearFromPos=function(t){var s;for(s=t;s<B;s++)this.chars[s].reset()},e.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},e.clearToEndOfRow=function(){this.clearFromPos(this.pos)},e.getTextString=function(){for(var t=[],s=!0,y=0;y<B;y++){var f=this.chars[y].uchar;f!==" "&&(s=!1),t.push(f)}return s?"":t.join("")},e.setPenStyles=function(t){this.currPenState.setStyles(t);var s=this.chars[this.pos];s.setPenState(this.currPenState)},m}(),n=function(){function m(r){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var t=0;t<P;t++)this.rows.push(new o(r));this.logger=r,this.currRow=P-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var e=m.prototype;return e.reset=function(){for(var t=0;t<P;t++)this.rows[t].clear();this.currRow=P-1},e.equals=function(t){for(var s=!0,y=0;y<P;y++)if(!this.rows[y].equals(t.rows[y])){s=!1;break}return s},e.copy=function(t){for(var s=0;s<P;s++)this.rows[s].copy(t.rows[s])},e.isEmpty=function(){for(var t=!0,s=0;s<P;s++)if(!this.rows[s].isEmpty()){t=!1;break}return t},e.backSpace=function(){var t=this.rows[this.currRow];t.backSpace()},e.clearToEndOfRow=function(){var t=this.rows[this.currRow];t.clearToEndOfRow()},e.insertChar=function(t){var s=this.rows[this.currRow];s.insertChar(t)},e.setPen=function(t){var s=this.rows[this.currRow];s.setPenStyles(t)},e.moveCursor=function(t){var s=this.rows[this.currRow];s.moveCursor(t)},e.setCursor=function(t){this.logger.log(d.INFO,"setCursor: "+t);var s=this.rows[this.currRow];s.setCursor(t)},e.setPAC=function(t){this.logger.log(d.INFO,function(){return"pacData = "+JSON.stringify(t)});var s=t.row-1;if(this.nrRollUpRows&&s<this.nrRollUpRows-1&&(s=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==s){for(var y=0;y<P;y++)this.rows[y].clear();var f=this.currRow+1-this.nrRollUpRows,b=this.lastOutputScreen;if(b){var R=b.rows[f].cueStartTime,I=this.logger.time;if(R&&I!==null&&R<I)for(var k=0;k<this.nrRollUpRows;k++)this.rows[s-this.nrRollUpRows+k+1].copy(b.rows[f+k])}}this.currRow=s;var F=this.rows[this.currRow];if(t.indent!==null){var K=t.indent,H=Math.max(K-1,0);F.setCursor(t.indent),t.color=F.chars[H].penState.foreground}var j={foreground:t.color,underline:t.underline,italics:t.italics,background:"black",flash:!1};this.setPen(j)},e.setBkgData=function(t){this.logger.log(d.INFO,function(){return"bkgData = "+JSON.stringify(t)}),this.backSpace(),this.setPen(t),this.insertChar(32)},e.setRollUpRows=function(t){this.nrRollUpRows=t},e.rollUp=function(){var t=this;if(this.nrRollUpRows===null){this.logger.log(d.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(d.TEXT,function(){return t.getDisplayText()});var s=this.currRow+1-this.nrRollUpRows,y=this.rows.splice(s,1)[0];y.clear(),this.rows.splice(this.currRow,0,y),this.logger.log(d.INFO,"Rolling up")},e.getDisplayText=function(t){t=t||!1;for(var s=[],y="",f=-1,b=0;b<P;b++){var R=this.rows[b].getTextString();R&&(f=b+1,t?s.push("Row "+f+": '"+R+"'"):s.push(R.trim()))}return s.length>0&&(t?y="["+s.join(" | ")+"]":y=s.join(`
21
+ `)}),o=o+("new (("+S(a,h,E,"main")+")())(self);");var n=new window.Blob([o],{type:"text/javascript"}),v=window.URL||window.webkitURL||window.mozURL||window.msURL,l=v.createObjectURL(n),i=new window.Worker(l);return i.objectURL=l,i}},"./src/errors.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{ErrorDetails:()=>L,ErrorTypes:()=>C});var C;(function(M){M.NETWORK_ERROR="networkError",M.MEDIA_ERROR="mediaError",M.KEY_SYSTEM_ERROR="keySystemError",M.MUX_ERROR="muxError",M.OTHER_ERROR="otherError"})(C||(C={}));var L;(function(M){M.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",M.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",M.KEY_SYSTEM_NO_SESSION="keySystemNoSession",M.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",M.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",M.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",M.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",M.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",M.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",M.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",M.MANIFEST_LOAD_ERROR="manifestLoadError",M.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",M.MANIFEST_PARSING_ERROR="manifestParsingError",M.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",M.LEVEL_EMPTY_ERROR="levelEmptyError",M.LEVEL_LOAD_ERROR="levelLoadError",M.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",M.LEVEL_SWITCH_ERROR="levelSwitchError",M.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",M.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",M.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",M.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",M.FRAG_LOAD_ERROR="fragLoadError",M.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",M.FRAG_DECRYPT_ERROR="fragDecryptError",M.FRAG_PARSING_ERROR="fragParsingError",M.REMUX_ALLOC_ERROR="remuxAllocError",M.KEY_LOAD_ERROR="keyLoadError",M.KEY_LOAD_TIMEOUT="keyLoadTimeOut",M.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",M.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",M.BUFFER_APPEND_ERROR="bufferAppendError",M.BUFFER_APPENDING_ERROR="bufferAppendingError",M.BUFFER_STALLED_ERROR="bufferStalledError",M.BUFFER_FULL_ERROR="bufferFullError",M.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",M.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",M.INTERNAL_EXCEPTION="internalException",M.INTERNAL_ABORTED="aborted",M.UNKNOWN="unknown"})(L||(L={}))},"./src/events.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{Events:()=>C});var C;(function(L){L.MEDIA_ATTACHING="hlsMediaAttaching",L.MEDIA_ATTACHED="hlsMediaAttached",L.MEDIA_DETACHING="hlsMediaDetaching",L.MEDIA_DETACHED="hlsMediaDetached",L.BUFFER_RESET="hlsBufferReset",L.BUFFER_CODECS="hlsBufferCodecs",L.BUFFER_CREATED="hlsBufferCreated",L.BUFFER_APPENDING="hlsBufferAppending",L.BUFFER_APPENDED="hlsBufferAppended",L.BUFFER_EOS="hlsBufferEos",L.BUFFER_FLUSHING="hlsBufferFlushing",L.BUFFER_FLUSHED="hlsBufferFlushed",L.MANIFEST_LOADING="hlsManifestLoading",L.MANIFEST_LOADED="hlsManifestLoaded",L.MANIFEST_PARSED="hlsManifestParsed",L.LEVEL_SWITCHING="hlsLevelSwitching",L.LEVEL_SWITCHED="hlsLevelSwitched",L.LEVEL_LOADING="hlsLevelLoading",L.LEVEL_LOADED="hlsLevelLoaded",L.LEVEL_UPDATED="hlsLevelUpdated",L.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",L.LEVELS_UPDATED="hlsLevelsUpdated",L.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",L.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",L.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",L.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",L.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",L.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",L.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",L.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",L.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",L.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",L.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",L.CUES_PARSED="hlsCuesParsed",L.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",L.INIT_PTS_FOUND="hlsInitPtsFound",L.FRAG_LOADING="hlsFragLoading",L.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",L.FRAG_LOADED="hlsFragLoaded",L.FRAG_DECRYPTED="hlsFragDecrypted",L.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",L.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",L.FRAG_PARSING_METADATA="hlsFragParsingMetadata",L.FRAG_PARSED="hlsFragParsed",L.FRAG_BUFFERED="hlsFragBuffered",L.FRAG_CHANGED="hlsFragChanged",L.FPS_DROP="hlsFpsDrop",L.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",L.ERROR="hlsError",L.DESTROYING="hlsDestroying",L.KEY_LOADING="hlsKeyLoading",L.KEY_LOADED="hlsKeyLoaded",L.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",L.BACK_BUFFER_REACHED="hlsBackBufferReached"})(C||(C={}))},"./src/hls.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>g});var C=T("./node_modules/url-toolkit/src/url-toolkit.js"),L=T.n(C),M=T("./src/loader/playlist-loader.ts"),P=T("./src/controller/id3-track-controller.ts"),B=T("./src/controller/latency-controller.ts"),A=T("./src/controller/level-controller.ts"),D=T("./src/controller/fragment-tracker.ts"),x=T("./src/loader/key-loader.ts"),_=T("./src/controller/stream-controller.ts"),S=T("./src/is-supported.ts"),d=T("./src/utils/logger.ts"),E=T("./src/config.ts"),p=T("./node_modules/eventemitter3/index.js"),h=T.n(p),a=T("./src/events.ts"),o=T("./src/errors.ts"),n=T("./src/types/level.ts");function v(c,m){for(var e=0;e<m.length;e++){var r=m[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(c,i(r.key),r)}}function l(c,m,e){return m&&v(c.prototype,m),e&&v(c,e),Object.defineProperty(c,"prototype",{writable:!1}),c}function i(c){var m=u(c,"string");return typeof m=="symbol"?m:String(m)}function u(c,m){if(typeof c!="object"||c===null)return c;var e=c[Symbol.toPrimitive];if(e!==void 0){var r=e.call(c,m||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(m==="string"?String:Number)(c)}var g=function(){c.isSupported=function(){return(0,S.isSupported)()};function c(e){e===void 0&&(e={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new p.EventEmitter,this._autoLevelCapping=void 0,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null;var r=this.config=(0,E.mergeConfig)(c.DefaultConfig,e);this.userConfig=e,(0,d.enableLogs)(r.debug,"Hls instance"),this._autoLevelCapping=-1,r.progressive&&(0,E.enableStreamingMode)(r);var t=r.abrController,s=r.bufferController,y=r.capLevelController,f=r.fpsController,b=this.abrController=new t(this),R=this.bufferController=new s(this),I=this.capLevelController=new y(this),k=new f(this),F=new M.default(this),K=new P.default(this),H=this.levelController=new A.default(this),j=new D.FragmentTracker(this),Y=new x.default(this.config),Q=this.streamController=new _.default(this,j,Y);I.setStreamController(Q),k.setStreamController(Q);var q=[F,H,Q];this.networkControllers=q;var ne=[b,R,I,k,K,j];this.audioTrackController=this.createController(r.audioTrackController,q);var te=r.audioStreamController;te&&q.push(new te(this,j,Y)),this.subtitleTrackController=this.createController(r.subtitleTrackController,q);var ae=r.subtitleStreamController;ae&&q.push(new ae(this,j,Y)),this.createController(r.timelineController,ne),Y.emeController=this.emeController=this.createController(r.emeController,ne),this.cmcdController=this.createController(r.cmcdController,ne),this.latencyController=this.createController(B.default,ne),this.coreComponents=ne}var m=c.prototype;return m.createController=function(r,t){if(r){var s=new r(this);return t&&t.push(s),s}return null},m.on=function(r,t,s){s===void 0&&(s=this),this._emitter.on(r,t,s)},m.once=function(r,t,s){s===void 0&&(s=this),this._emitter.once(r,t,s)},m.removeAllListeners=function(r){this._emitter.removeAllListeners(r)},m.off=function(r,t,s,y){s===void 0&&(s=this),this._emitter.off(r,t,s,y)},m.listeners=function(r){return this._emitter.listeners(r)},m.emit=function(r,t,s){return this._emitter.emit(r,t,s)},m.trigger=function(r,t){if(this.config.debug)return this.emit(r,r,t);try{return this.emit(r,r,t)}catch(s){d.logger.error("An internal error happened while handling event "+r+'. Error message: "'+s.message+'". Here is a stacktrace:',s),this.trigger(a.Events.ERROR,{type:o.ErrorTypes.OTHER_ERROR,details:o.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:r,error:s})}return!1},m.listenerCount=function(r){return this._emitter.listenerCount(r)},m.destroy=function(){d.logger.log("destroy"),this.trigger(a.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(r){return r.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(r){return r.destroy()}),this.coreComponents.length=0},m.attachMedia=function(r){d.logger.log("attachMedia"),this._media=r,this.trigger(a.Events.MEDIA_ATTACHING,{media:r})},m.detachMedia=function(){d.logger.log("detachMedia"),this.trigger(a.Events.MEDIA_DETACHING,void 0),this._media=null},m.loadSource=function(r){this.stopLoad();var t=this.media,s=this.url,y=this.url=C.buildAbsoluteURL(self.location.href,r,{alwaysNormalize:!0});d.logger.log("loadSource:"+y),t&&s&&s!==y&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(t)),this.trigger(a.Events.MANIFEST_LOADING,{url:r})},m.startLoad=function(r){r===void 0&&(r=-1),d.logger.log("startLoad("+r+")"),this.networkControllers.forEach(function(t){t.startLoad(r)})},m.stopLoad=function(){d.logger.log("stopLoad"),this.networkControllers.forEach(function(r){r.stopLoad()})},m.swapAudioCodec=function(){d.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},m.recoverMediaError=function(){d.logger.log("recoverMediaError");var r=this._media;this.detachMedia(),r&&this.attachMedia(r)},m.removeLevel=function(r,t){t===void 0&&(t=0),this.levelController.removeLevel(r,t)},l(c,[{key:"levels",get:function(){var r=this.levelController.levels;return r||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(r){d.logger.log("set currentLevel:"+r),this.loadLevel=r,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(r){d.logger.log("set nextLevel:"+r),this.levelController.manualLevel=r,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(r){d.logger.log("set loadLevel:"+r),this.levelController.manualLevel=r}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(r){this.levelController.nextLoadLevel=r}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(r){d.logger.log("set firstLevel:"+r),this.levelController.firstLevel=r}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(r){d.logger.log("set startLevel:"+r),r!==-1&&(r=Math.max(r,this.minAutoLevel)),this.levelController.startLevel=r}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(r){var t=!!r;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(r){this._autoLevelCapping!==r&&(d.logger.log("set autoLevelCapping:"+r),this._autoLevelCapping=r)}},{key:"bandwidthEstimate",get:function(){var r=this.abrController.bwEstimator;return r?r.getEstimate():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(r){n.HdcpLevels.indexOf(r)>-1&&(this._maxHdcpLevel=r)}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var r=this.levels,t=this.config.minAutoBitrate;if(!r)return 0;for(var s=r.length,y=0;y<s;y++)if(r[y].maxBitrate>=t)return y;return 0}},{key:"maxAutoLevel",get:function(){var r=this.levels,t=this.autoLevelCapping,s=this.maxHdcpLevel,y;if(t===-1&&r&&r.length?y=r.length-1:y=t,s)for(var f=y;f--;){var b=r[f].attrs["HDCP-LEVEL"];if(b&&b<=s)return f}return y}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(r){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,r)}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"audioTracks",get:function(){var r=this.audioTrackController;return r?r.audioTracks:[]}},{key:"audioTrack",get:function(){var r=this.audioTrackController;return r?r.audioTrack:-1},set:function(r){var t=this.audioTrackController;t&&(t.audioTrack=r)}},{key:"subtitleTracks",get:function(){var r=this.subtitleTrackController;return r?r.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var r=this.subtitleTrackController;return r?r.subtitleTrack:-1},set:function(r){var t=this.subtitleTrackController;t&&(t.subtitleTrack=r)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var r=this.subtitleTrackController;return r?r.subtitleDisplay:!1},set:function(r){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=r)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(r){this.config.lowLatencyMode=r}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.3.1"}},{key:"Events",get:function(){return a.Events}},{key:"ErrorTypes",get:function(){return o.ErrorTypes}},{key:"ErrorDetails",get:function(){return o.ErrorDetails}},{key:"DefaultConfig",get:function(){return c.defaultConfig?c.defaultConfig:E.hlsDefaultConfig},set:function(r){c.defaultConfig=r}}]),c}();g.defaultConfig=void 0},"./src/is-supported.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{changeTypeSupported:()=>P,isSupported:()=>M});var C=T("./src/utils/mediasource-helper.ts");function L(){return self.SourceBuffer||self.WebKitSourceBuffer}function M(){var B=(0,C.getMediaSource)();if(!B)return!1;var A=L(),D=B&&typeof B.isTypeSupported=="function"&&B.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),x=!A||A.prototype&&typeof A.prototype.appendBuffer=="function"&&typeof A.prototype.remove=="function";return!!D&&!!x}function P(){var B,A=L();return typeof(A==null||(B=A.prototype)===null||B===void 0?void 0:B.changeType)=="function"}},"./src/loader/date-range.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{DateRange:()=>S,DateRangeAttribute:()=>_});var C=T("./src/polyfills/number.ts"),L=T("./src/utils/attr-list.ts"),M=T("./src/utils/logger.ts");function P(){return P=Object.assign?Object.assign.bind():function(d){for(var E=1;E<arguments.length;E++){var p=arguments[E];for(var h in p)Object.prototype.hasOwnProperty.call(p,h)&&(d[h]=p[h])}return d},P.apply(this,arguments)}function B(d,E){for(var p=0;p<E.length;p++){var h=E[p];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(d,D(h.key),h)}}function A(d,E,p){return E&&B(d.prototype,E),p&&B(d,p),Object.defineProperty(d,"prototype",{writable:!1}),d}function D(d){var E=x(d,"string");return typeof E=="symbol"?E:String(E)}function x(d,E){if(typeof d!="object"||d===null)return d;var p=d[Symbol.toPrimitive];if(p!==void 0){var h=p.call(d,E||"default");if(typeof h!="object")return h;throw new TypeError("@@toPrimitive must return a primitive value.")}return(E==="string"?String:Number)(d)}var _;(function(d){d.ID="ID",d.CLASS="CLASS",d.START_DATE="START-DATE",d.DURATION="DURATION",d.END_DATE="END-DATE",d.END_ON_NEXT="END-ON-NEXT",d.PLANNED_DURATION="PLANNED-DURATION",d.SCTE35_OUT="SCTE35-OUT",d.SCTE35_IN="SCTE35-IN"})(_||(_={}));var S=function(){function d(E,p){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,p){var h=p.attr;for(var a in h)if(Object.prototype.hasOwnProperty.call(E,a)&&E[a]!==h[a]){M.logger.warn('DATERANGE tag attribute: "'+a+'" does not match for tags with ID: "'+E.ID+'"'),this._badValueForSameId=a;break}E=P(new L.AttrList({}),h,E)}if(this.attr=E,this._startDate=new Date(E[_.START_DATE]),_.END_DATE in this.attr){var o=new Date(this.attr[_.END_DATE]);(0,C.isFiniteNumber)(o.getTime())&&(this._endDate=o)}}return A(d,[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){if(this._endDate)return this._endDate;var p=this.duration;return p!==null?new Date(this._startDate.getTime()+p*1e3):null}},{key:"duration",get:function(){if(_.DURATION in this.attr){var p=this.attr.decimalFloatingPoint(_.DURATION);if((0,C.isFiniteNumber)(p))return p}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return _.PLANNED_DURATION in this.attr?this.attr.decimalFloatingPoint(_.PLANNED_DURATION):null}},{key:"endOnNext",get:function(){return this.attr.bool(_.END_ON_NEXT)}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&(0,C.isFiniteNumber)(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),d}()},"./src/loader/fragment-loader.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{LoadError:()=>p,default:()=>d});var C=T("./src/polyfills/number.ts"),L=T("./src/errors.ts");function M(h,a){h.prototype=Object.create(a.prototype),h.prototype.constructor=h,x(h,a)}function P(h){var a=typeof Map=="function"?new Map:void 0;return P=function(n){if(n===null||!D(n))return n;if(typeof n!="function")throw new TypeError("Super expression must either be null or a function");if(typeof a!="undefined"){if(a.has(n))return a.get(n);a.set(n,v)}function v(){return B(n,arguments,_(this).constructor)}return v.prototype=Object.create(n.prototype,{constructor:{value:v,enumerable:!1,writable:!0,configurable:!0}}),x(v,n)},P(h)}function B(h,a,o){return A()?B=Reflect.construct.bind():B=function(v,l,i){var u=[null];u.push.apply(u,l);var g=Function.bind.apply(v,u),c=new g;return i&&x(c,i.prototype),c},B.apply(null,arguments)}function A(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function D(h){return Function.toString.call(h).indexOf("[native code]")!==-1}function x(h,a){return x=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,v){return n.__proto__=v,n},x(h,a)}function _(h){return _=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(o){return o.__proto__||Object.getPrototypeOf(o)},_(h)}var S=Math.pow(2,17),d=function(){function h(o){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=o}var a=h.prototype;return a.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},a.abort=function(){this.loader&&this.loader.abort()},a.load=function(n,v){var l=this,i=n.url;if(!i)return Promise.reject(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:n,networkDetails:null},"Fragment does not have a "+(i?"part list":"url")));this.abort();var u=this.config,g=u.fLoader,c=u.loader;return new Promise(function(m,e){l.loader&&l.loader.destroy();var r=l.loader=n.loader=g?new g(u):new c(u),t=E(n),s={timeout:u.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:u.fragLoadingMaxRetryTimeout,highWaterMark:n.sn==="initSegment"?1/0:S};n.stats=r.stats,r.load(t,s,{onSuccess:function(f,b,R,I){l.resetLoader(n,r);var k=f.data;R.resetIV&&n.decryptdata&&(n.decryptdata.iv=new Uint8Array(k.slice(0,16)),k=k.slice(16)),m({frag:n,part:null,payload:k,networkDetails:I})},onError:function(f,b,R){l.resetLoader(n,r),e(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:n,response:f,networkDetails:R}))},onAbort:function(f,b,R){l.resetLoader(n,r),e(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:n,networkDetails:R}))},onTimeout:function(f,b,R){l.resetLoader(n,r),e(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:n,networkDetails:R}))},onProgress:function(f,b,R,I){v&&v({frag:n,part:null,payload:R,networkDetails:I})}})})},a.loadPart=function(n,v,l){var i=this;this.abort();var u=this.config,g=u.fLoader,c=u.loader;return new Promise(function(m,e){i.loader&&i.loader.destroy();var r=i.loader=n.loader=g?new g(u):new c(u),t=E(n,v),s={timeout:u.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:u.fragLoadingMaxRetryTimeout,highWaterMark:S};v.stats=r.stats,r.load(t,s,{onSuccess:function(f,b,R,I){i.resetLoader(n,r),i.updateStatsFromPart(n,v);var k={frag:n,part:v,payload:f.data,networkDetails:I};l(k),m(k)},onError:function(f,b,R){i.resetLoader(n,r),e(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:n,part:v,response:f,networkDetails:R}))},onAbort:function(f,b,R){n.stats.aborted=v.stats.aborted,i.resetLoader(n,r),e(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:n,part:v,networkDetails:R}))},onTimeout:function(f,b,R){i.resetLoader(n,r),e(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:n,part:v,networkDetails:R}))}})})},a.updateStatsFromPart=function(n,v){var l=n.stats,i=v.stats,u=i.total;if(l.loaded+=i.loaded,u){var g=Math.round(n.duration/v.duration),c=Math.min(Math.round(l.loaded/u),g),m=g-c,e=m*Math.round(l.loaded/c);l.total=l.loaded+e}else l.total=Math.max(l.loaded,l.total);var r=l.loading,t=i.loading;r.start?r.first+=t.first-t.start:(r.start=t.start,r.first=t.first),r.end=t.end},a.resetLoader=function(n,v){n.loader=null,this.loader===v&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),v.destroy()},h}();function E(h,a){a===void 0&&(a=null);var o=a||h,n={frag:h,part:a,responseType:"arraybuffer",url:o.url,headers:{},rangeStart:0,rangeEnd:0},v=o.byteRangeStartOffset,l=o.byteRangeEndOffset;if((0,C.isFiniteNumber)(v)&&(0,C.isFiniteNumber)(l)){var i,u=v,g=l;if(h.sn==="initSegment"&&((i=h.decryptdata)===null||i===void 0?void 0:i.method)==="AES-128"){var c=l-v;c%16&&(g=l+(16-c%16)),v!==0&&(n.resetIV=!0,u=v-16)}n.rangeStart=u,n.rangeEnd=g}return n}var p=function(h){M(a,h);function a(o){for(var n,v=arguments.length,l=new Array(v>1?v-1:0),i=1;i<v;i++)l[i-1]=arguments[i];return n=h.call.apply(h,[this].concat(l))||this,n.data=void 0,n.data=o,n}return a}(P(Error))},"./src/loader/fragment.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{BaseSegment:()=>E,ElementaryStreamTypes:()=>d,Fragment:()=>p,Part:()=>h});var C=T("./src/polyfills/number.ts"),L=T("./node_modules/url-toolkit/src/url-toolkit.js"),M=T.n(L),P=T("./src/loader/load-stats.ts");function B(a,o){a.prototype=Object.create(o.prototype),a.prototype.constructor=a,A(a,o)}function A(a,o){return A=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(v,l){return v.__proto__=l,v},A(a,o)}function D(a,o){for(var n=0;n<o.length;n++){var v=o[n];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(a,_(v.key),v)}}function x(a,o,n){return o&&D(a.prototype,o),n&&D(a,n),Object.defineProperty(a,"prototype",{writable:!1}),a}function _(a){var o=S(a,"string");return typeof o=="symbol"?o:String(o)}function S(a,o){if(typeof a!="object"||a===null)return a;var n=a[Symbol.toPrimitive];if(n!==void 0){var v=n.call(a,o||"default");if(typeof v!="object")return v;throw new TypeError("@@toPrimitive must return a primitive value.")}return(o==="string"?String:Number)(a)}var d;(function(a){a.AUDIO="audio",a.VIDEO="video",a.AUDIOVIDEO="audiovideo"})(d||(d={}));var E=function(){function a(n){var v;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(v={},v[d.AUDIO]=null,v[d.VIDEO]=null,v[d.AUDIOVIDEO]=null,v),this.baseurl=n}var o=a.prototype;return o.setByteRange=function(v,l){var i=v.split("@",2),u=[];i.length===1?u[0]=l?l.byteRangeEndOffset:0:u[0]=parseInt(i[1]),u[1]=parseInt(i[0])+u[0],this._byteRange=u},x(a,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=(0,L.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(v){this._url=v}}]),a}(),p=function(a){B(o,a);function o(v,l){var i;return i=a.call(this,l)||this,i._decryptdata=null,i.rawProgramDateTime=null,i.programDateTime=null,i.tagList=[],i.duration=0,i.sn=0,i.levelkeys=void 0,i.type=void 0,i.loader=null,i.keyLoader=null,i.level=-1,i.cc=0,i.startPTS=void 0,i.endPTS=void 0,i.appendedPTS=void 0,i.startDTS=void 0,i.endDTS=void 0,i.start=0,i.deltaPTS=void 0,i.maxStartPTS=void 0,i.minEndPTS=void 0,i.stats=new P.LoadStats,i.urlId=0,i.data=void 0,i.bitrateTest=!1,i.title=null,i.initSegment=null,i.endList=void 0,i.type=v,i}var n=o.prototype;return n.setKeyFormat=function(l){if(this.levelkeys){var i=this.levelkeys[l];i&&!this._decryptdata&&(this._decryptdata=i.getDecryptData(this.sn))}},n.abortRequests=function(){var l,i;(l=this.loader)===null||l===void 0||l.abort(),(i=this.keyLoader)===null||i===void 0||i.abort()},n.setElementaryStreamInfo=function(l,i,u,g,c,m){m===void 0&&(m=!1);var e=this.elementaryStreams,r=e[l];if(!r){e[l]={startPTS:i,endPTS:u,startDTS:g,endDTS:c,partial:m};return}r.startPTS=Math.min(r.startPTS,i),r.endPTS=Math.max(r.endPTS,u),r.startDTS=Math.min(r.startDTS,g),r.endDTS=Math.max(r.endDTS,c)},n.clearElementaryStreamInfo=function(){var l=this.elementaryStreams;l[d.AUDIO]=null,l[d.VIDEO]=null,l[d.AUDIOVIDEO]=null},x(o,[{key:"decryptdata",get:function(){var l=this.levelkeys;if(!l&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var i=this.levelkeys.identity;if(i)this._decryptdata=i.getDecryptData(this.sn);else{var u=Object.keys(this.levelkeys);if(u.length===1)return this._decryptdata=this.levelkeys[u[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null||!(0,C.isFiniteNumber)(this.programDateTime))return null;var l=(0,C.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+l*1e3}},{key:"encrypted",get:function(){var l;if((l=this._decryptdata)!==null&&l!==void 0&&l.encrypted)return!0;if(this.levelkeys){var i=Object.keys(this.levelkeys),u=i.length;if(u>1||u===1&&this.levelkeys[i[0]].encrypted)return!0}return!1}}]),o}(E),h=function(a){B(o,a);function o(n,v,l,i,u){var g;g=a.call(this,l)||this,g.fragOffset=0,g.duration=0,g.gap=!1,g.independent=!1,g.relurl=void 0,g.fragment=void 0,g.index=void 0,g.stats=new P.LoadStats,g.duration=n.decimalFloatingPoint("DURATION"),g.gap=n.bool("GAP"),g.independent=n.bool("INDEPENDENT"),g.relurl=n.enumeratedString("URI"),g.fragment=v,g.index=i;var c=n.enumeratedString("BYTERANGE");return c&&g.setByteRange(c,u),u&&(g.fragOffset=u.fragOffset+u.duration),g}return x(o,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var v=this.elementaryStreams;return!!(v.audio||v.video||v.audiovideo)}}]),o}(E)},"./src/loader/key-loader.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>M});var C=T("./src/errors.ts"),L=T("./src/loader/fragment-loader.ts"),M=function(){function P(A){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=A}var B=P.prototype;return B.abort=function(){for(var D in this.keyUriToKeyInfo){var x=this.keyUriToKeyInfo[D].loader;x&&x.abort()}},B.detach=function(){for(var D in this.keyUriToKeyInfo){var x=this.keyUriToKeyInfo[D];(x.mediaKeySessionContext||x.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[D]}},B.destroy=function(){this.detach();for(var D in this.keyUriToKeyInfo){var x=this.keyUriToKeyInfo[D].loader;x&&x.destroy()}this.keyUriToKeyInfo={}},B.createKeyLoadError=function(D,x,_,S){return x===void 0&&(x=C.ErrorDetails.KEY_LOAD_ERROR),new L.LoadError({type:C.ErrorTypes.NETWORK_ERROR,details:x,fatal:!1,frag:D,networkDetails:_})},B.loadClear=function(D,x){var _=this;if(this.emeController&&this.config.emeEnabled)for(var S=D.sn,d=D.cc,E=function(o){var n=x[o];if(d<=n.cc&&(S==="initSegment"||S<n.sn))return _.emeController.selectKeySystemFormat(n).then(function(v){n.setKeyFormat(v)}),"break"},p=0;p<x.length;p++){var h=E(p);if(h==="break")break}},B.load=function(D){var x=this;return!D.decryptdata&&D.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(D).then(function(_){return x.loadInternal(D,_)}):this.loadInternal(D)},B.loadInternal=function(D,x){var _,S;x&&D.setKeyFormat(x);var d=D.decryptdata;if(!d){var E=x?"Expected frag.decryptdata to be defined after setting format "+x:"Missing decryption data on fragment in onKeyLoading";return Promise.reject(this.createKeyLoadError(D,C.ErrorDetails.KEY_LOAD_ERROR,null,E))}var p=d.uri;if(!p)return Promise.reject(this.createKeyLoadError(D,C.ErrorDetails.KEY_LOAD_ERROR,null,'Invalid key URI: "'+p+'"'));var h=this.keyUriToKeyInfo[p];if((_=h)!==null&&_!==void 0&&_.decryptdata.key)return d.key=h.decryptdata.key,Promise.resolve({frag:D,keyInfo:h});if((S=h)!==null&&S!==void 0&&S.keyLoadPromise){var a;switch((a=h.mediaKeySessionContext)===null||a===void 0?void 0:a.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return h.keyLoadPromise}}switch(h=this.keyUriToKeyInfo[p]={decryptdata:d,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},d.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return d.keyFormat==="identity"?this.loadKeyHTTP(h,D):this.loadKeyEME(h,D);case"AES-128":return this.loadKeyHTTP(h,D);default:return Promise.reject(this.createKeyLoadError(D,C.ErrorDetails.KEY_LOAD_ERROR,null,'Key supplied with unsupported METHOD: "'+d.method+'"'))}},B.loadKeyEME=function(D,x){var _={frag:x,keyInfo:D};if(this.emeController&&this.config.emeEnabled){var S=this.emeController.loadKey(_);if(S)return(D.keyLoadPromise=S.then(function(d){return D.mediaKeySessionContext=d,_})).catch(function(d){throw D.keyLoadPromise=null,d})}return Promise.resolve(_)},B.loadKeyHTTP=function(D,x){var _=this,S=this.config,d=S.loader,E=new d(S);return x.keyLoader=D.loader=E,D.keyLoadPromise=new Promise(function(p,h){var a={keyInfo:D,frag:x,responseType:"arraybuffer",url:D.decryptdata.uri},o={timeout:S.fragLoadingTimeOut,maxRetry:0,retryDelay:S.fragLoadingRetryDelay,maxRetryDelay:S.fragLoadingMaxRetryTimeout,highWaterMark:0},n={onSuccess:function(l,i,u,g){var c=u.frag,m=u.keyInfo,e=u.url;if(!c.decryptdata||m!==_.keyUriToKeyInfo[e])return h(_.createKeyLoadError(c,C.ErrorDetails.KEY_LOAD_ERROR,g,"after key load, decryptdata unset or changed"));m.decryptdata.key=c.decryptdata.key=new Uint8Array(l.data),c.keyLoader=null,m.loader=null,p({frag:c,keyInfo:m})},onError:function(l,i,u){_.resetLoader(i),h(_.createKeyLoadError(x,C.ErrorDetails.KEY_LOAD_ERROR,u))},onTimeout:function(l,i,u){_.resetLoader(i),h(_.createKeyLoadError(x,C.ErrorDetails.KEY_LOAD_TIMEOUT,u))},onAbort:function(l,i,u){_.resetLoader(i),h(_.createKeyLoadError(x,C.ErrorDetails.INTERNAL_ABORTED,u))}};E.load(a,o,n)})},B.resetLoader=function(D){var x=D.frag,_=D.keyInfo,S=D.url,d=_.loader;x.keyLoader===d&&(x.keyLoader=null,_.loader=null),delete this.keyUriToKeyInfo[S],d&&d.destroy()},P}()},"./src/loader/level-details.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{LevelDetails:()=>D});var C=T("./src/polyfills/number.ts");function L(x,_){for(var S=0;S<_.length;S++){var d=_[S];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(x,P(d.key),d)}}function M(x,_,S){return _&&L(x.prototype,_),S&&L(x,S),Object.defineProperty(x,"prototype",{writable:!1}),x}function P(x){var _=B(x,"string");return typeof _=="symbol"?_:String(_)}function B(x,_){if(typeof x!="object"||x===null)return x;var S=x[Symbol.toPrimitive];if(S!==void 0){var d=S.call(x,_||"default");if(typeof d!="object")return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return(_==="string"?String:Number)(x)}var A=10,D=function(){function x(S){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=S}var _=x.prototype;return _.reloaded=function(d){if(!d){this.advanced=!0,this.updated=!0;return}var E=this.lastPartSn-d.lastPartSn,p=this.lastPartIndex-d.lastPartIndex;this.updated=this.endSN!==d.endSN||!!p||!!E,this.advanced=this.endSN>d.endSN||E>0||E===0&&p>0,this.updated||this.advanced?this.misses=Math.floor(d.misses*.6):this.misses=d.misses+1,this.availabilityDelay=d.availabilityDelay},M(x,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?(0,C.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||A}},{key:"drift",get:function(){var d=this.driftEndTime-this.driftStartTime;if(d>0){var E=this.driftEnd-this.driftStart;return E*1e3/d}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var d;return(d=this.partList)!==null&&d!==void 0&&d.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var d;return(d=this.fragments)!==null&&d!==void 0&&d.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var d;return(d=this.partList)!==null&&d!==void 0&&d.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var d;return(d=this.partList)!==null&&d!==void 0&&d.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),x}()},"./src/loader/level-key.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{LevelKey:()=>D});var C=T("./src/utils/keysystem-util.ts"),L=T("./src/utils/mediakeys-helper.ts"),M=T("./src/utils/mp4-tools.ts"),P=T("./src/utils/logger.ts"),B=T("./src/utils/numeric-encoding-utils.ts"),A={},D=function(){_.clearKeyUriToKeyIdMap=function(){A={}};function _(d,E,p,h,a){h===void 0&&(h=[1]),a===void 0&&(a=null),this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=d,this.uri=E,this.keyFormat=p,this.keyFormatVersions=h,this.iv=a,this.encrypted=d?d!=="NONE":!1,this.isCommonEncryption=this.encrypted&&d!=="AES-128"}var S=_.prototype;return S.isSupported=function(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;switch(this.keyFormat){case"identity":return this.method==="SAMPLE-AES";case L.KeySystemFormats.FAIRPLAY:case L.KeySystemFormats.WIDEVINE:case L.KeySystemFormats.PLAYREADY:case L.KeySystemFormats.CLEARKEY:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1},S.getDecryptData=function(E){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof E!="number"&&(this.method==="AES-128"&&!this.iv&&P.logger.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),E=0);var p=x(E),h=new _(this.method,this.uri,"identity",this.keyFormatVersions,p);return h}var a=(0,C.convertDataUriToArrayBytes)(this.uri);if(a)switch(this.keyFormat){case L.KeySystemFormats.WIDEVINE:this.pssh=a,a.length>=22&&(this.keyId=a.subarray(a.length-22,a.length-6));break;case L.KeySystemFormats.PLAYREADY:{var o=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=(0,M.mp4pssh)(o,null,a);var n=new Uint16Array(a.buffer,a.byteOffset,a.byteLength/2),v=String.fromCharCode.apply(null,Array.from(n)),l=v.substring(v.indexOf("<"),v.length),i=new DOMParser,u=i.parseFromString(l,"text/xml"),g=u.getElementsByTagName("KID")[0];if(g){var c=g.childNodes[0]?g.childNodes[0].nodeValue:g.getAttribute("VALUE");if(c){var m=(0,B.base64Decode)(c).subarray(0,16);(0,C.changeEndianness)(m),this.keyId=m}}break}default:{var e=a.subarray(0,16);if(e.length!==16){var r=new Uint8Array(16);r.set(e,16-e.length),e=r}this.keyId=e;break}}if(!this.keyId||this.keyId.byteLength!==16){var t=A[this.uri];if(!t){var s=Object.keys(A).length%Number.MAX_SAFE_INTEGER;t=new Uint8Array(16);var y=new DataView(t.buffer,12,4);y.setUint32(0,s),A[this.uri]=t}this.keyId=t}return this},_}();function x(_){for(var S=new Uint8Array(16),d=12;d<16;d++)S[d]=_>>8*(15-d)&255;return S}},"./src/loader/load-stats.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{LoadStats:()=>C});var C=function(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}},"./src/loader/m3u8-parser.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>o});var C=T("./src/polyfills/number.ts"),L=T("./node_modules/url-toolkit/src/url-toolkit.js"),M=T.n(L),P=T("./src/loader/date-range.ts"),B=T("./src/loader/fragment.ts"),A=T("./src/loader/level-details.ts"),D=T("./src/loader/level-key.ts"),x=T("./src/utils/attr-list.ts"),_=T("./src/utils/logger.ts"),S=T("./src/utils/codecs.ts");function d(){return d=Object.assign?Object.assign.bind():function(c){for(var m=1;m<arguments.length;m++){var e=arguments[m];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(c[r]=e[r])}return c},d.apply(this,arguments)}var E=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+|#EXT-X-SESSION-KEY:([^\n\r]*)[\r\n]+/g,p=/#EXT-X-MEDIA:(.*)/g,h=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),a=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),o=function(){function c(){}return c.findGroup=function(e,r){for(var t=0;t<e.length;t++){var s=e[t];if(s.id===r)return s}},c.convertAVC1ToAVCOTI=function(e){var r=e.split(".");if(r.length>2){var t=r.shift()+".";return t+=parseInt(r.shift()).toString(16),t+=("000"+parseInt(r.shift()).toString(16)).slice(-4),t}return e},c.resolve=function(e,r){return(0,L.buildAbsoluteURL)(r,e,{alwaysNormalize:!0})},c.parseMasterPlaylist=function(e,r){var t=[],s=[],y={},f=[],b=!1;E.lastIndex=0;for(var R;(R=E.exec(e))!=null;)if(R[1]){var I,k=new x.AttrList(R[1]),F={attrs:k,bitrate:k.decimalInteger("AVERAGE-BANDWIDTH")||k.decimalInteger("BANDWIDTH"),name:k.NAME,url:c.resolve(R[2],r)},K=k.decimalResolution("RESOLUTION");K&&(F.width=K.width,F.height=K.height),v((k.CODECS||"").split(/[ ,]+/).filter(function(q){return q}),F),F.videoCodec&&F.videoCodec.indexOf("avc1")!==-1&&(F.videoCodec=c.convertAVC1ToAVCOTI(F.videoCodec)),(I=F.unknownCodecs)!==null&&I!==void 0&&I.length||s.push(F),t.push(F)}else if(R[3]){var H=new x.AttrList(R[3]);H["DATA-ID"]&&(b=!0,y[H["DATA-ID"]]=H)}else if(R[4]){var j=R[4],Y=n(j,r);Y.encrypted&&Y.isSupported()?f.push(Y):_.logger.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+j+'"')}var Q=s.length>0&&s.length<t.length;return{levels:Q?s:t,sessionData:b?y:null,sessionKeys:f.length?f:null}},c.parseMasterPlaylistMedia=function(e,r,t,s){s===void 0&&(s=[]);var y,f=[],b=0;for(p.lastIndex=0;(y=p.exec(e))!==null;){var R=new x.AttrList(y[1]);if(R.TYPE===t){var I={attrs:R,bitrate:0,id:b++,groupId:R["GROUP-ID"],instreamId:R["INSTREAM-ID"],name:R.NAME||R.LANGUAGE||"",type:t,default:R.bool("DEFAULT"),autoselect:R.bool("AUTOSELECT"),forced:R.bool("FORCED"),lang:R.LANGUAGE,url:R.URI?c.resolve(R.URI,r):""};if(s.length){var k=c.findGroup(s,I.groupId)||s[0];l(I,k,"audioCodec"),l(I,k,"textCodec")}f.push(I)}}return f},c.parseLevelPlaylist=function(e,r,t,s,y){var f=new A.LevelDetails(r),b=f.fragments,R=null,I=0,k=0,F=0,K=0,H=null,j=new B.Fragment(s,r),Y,Q,q,ne=-1,te=!1;for(h.lastIndex=0,f.m3u8=e;(Y=h.exec(e))!==null;){te&&(te=!1,j=new B.Fragment(s,r),j.start=F,j.sn=I,j.cc=K,j.level=t,R&&(j.initSegment=R,j.rawProgramDateTime=R.rawProgramDateTime,R.rawProgramDateTime=null));var ae=Y[1];if(ae){j.duration=parseFloat(ae);var ue=(" "+Y[2]).slice(1);j.title=ue||null,j.tagList.push(ue?["INF",ae,ue]:["INF",ae])}else if(Y[3]){if((0,C.isFiniteNumber)(j.duration)){if(j.start=F,q){j.levelkeys=q;var ce=f.encryptedFragments;j.levelkeys&&Object.keys(j.levelkeys).some(function(et){return j.levelkeys[et].isCommonEncryption})&&(!ce.length||ce[ce.length-1].levelkeys!==q)&&ce.push(j)}j.sn=I,j.level=t,j.cc=K,j.urlId=y,b.push(j),j.relurl=(" "+Y[3]).slice(1),u(j,H),H=j,F+=j.duration,I++,k=0,te=!0}}else if(Y[4]){var le=(" "+Y[4]).slice(1);H?j.setByteRange(le,H):j.setByteRange(le)}else if(Y[5])j.rawProgramDateTime=(" "+Y[5]).slice(1),j.tagList.push(["PROGRAM-DATE-TIME",j.rawProgramDateTime]),ne===-1&&(ne=b.length);else{if(Y=Y[0].match(a),!Y){_.logger.warn("No matches on slow regex match for level playlist!");continue}for(Q=1;Q<Y.length&&typeof Y[Q]=="undefined";Q++);var fe=(" "+Y[Q]).slice(1),de=(" "+Y[Q+1]).slice(1),xe=Y[Q+2]?(" "+Y[Q+2]).slice(1):"";switch(fe){case"PLAYLIST-TYPE":f.type=de.toUpperCase();break;case"MEDIA-SEQUENCE":I=f.startSN=parseInt(de);break;case"SKIP":{var Ae=new x.AttrList(de),Ie=Ae.decimalInteger("SKIPPED-SEGMENTS");if((0,C.isFiniteNumber)(Ie)){f.skippedSegments=Ie;for(var Re=Ie;Re--;)b.unshift(null);I+=Ie}var Oe=Ae.enumeratedString("RECENTLY-REMOVED-DATERANGES");Oe&&(f.recentlyRemovedDateranges=Oe.split(" "));break}case"TARGETDURATION":f.targetduration=parseFloat(de);break;case"VERSION":f.version=parseInt(de);break;case"EXTM3U":break;case"ENDLIST":f.live=!1;break;case"#":(de||xe)&&j.tagList.push(xe?[de,xe]:[de]);break;case"DISCONTINUITY":K++,j.tagList.push(["DIS"]);break;case"GAP":j.tagList.push([fe]);break;case"BITRATE":j.tagList.push([fe,de]);break;case"DATERANGE":{var Pe=new x.AttrList(de),Ce=new P.DateRange(Pe,f.dateRanges[Pe.ID]);Ce.isValid||f.skippedSegments?f.dateRanges[Ce.id]=Ce:_.logger.warn('Ignoring invalid DATERANGE tag: "'+de+'"'),j.tagList.push(["EXT-X-DATERANGE",de]);break}case"DISCONTINUITY-SEQUENCE":K=parseInt(de);break;case"KEY":{var Le=n(de,r);if(Le.isSupported()){if(Le.method==="NONE"){q=void 0;break}q||(q={}),q[Le.keyFormat]&&(q=d({},q)),q[Le.keyFormat]=Le}else _.logger.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+de+'"');break}case"START":{var ke=new x.AttrList(de),Be=ke.decimalFloatingPoint("TIME-OFFSET");(0,C.isFiniteNumber)(Be)&&(f.startTimeOffset=Be);break}case"MAP":{var we=new x.AttrList(de);if(j.duration){var Ye=new B.Fragment(s,r);g(Ye,we,t,q),R=Ye,j.initSegment=R,R.rawProgramDateTime&&!j.rawProgramDateTime&&(j.rawProgramDateTime=R.rawProgramDateTime)}else g(j,we,t,q),R=j,te=!0;break}case"SERVER-CONTROL":{var Xe=new x.AttrList(de);f.canBlockReload=Xe.bool("CAN-BLOCK-RELOAD"),f.canSkipUntil=Xe.optionalFloat("CAN-SKIP-UNTIL",0),f.canSkipDateRanges=f.canSkipUntil>0&&Xe.bool("CAN-SKIP-DATERANGES"),f.partHoldBack=Xe.optionalFloat("PART-HOLD-BACK",0),f.holdBack=Xe.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var rt=new x.AttrList(de);f.partTarget=rt.decimalFloatingPoint("PART-TARGET");break}case"PART":{var ze=f.partList;ze||(ze=f.partList=[]);var it=k>0?ze[ze.length-1]:void 0,nt=k++,Je=new B.Part(new x.AttrList(de),j,r,nt,it);ze.push(Je),j.duration+=Je.duration;break}case"PRELOAD-HINT":{var Ne=new x.AttrList(de);f.preloadHint=Ne;break}case"RENDITION-REPORT":{var Ke=new x.AttrList(de);f.renditionReports=f.renditionReports||[],f.renditionReports.push(Ke);break}default:_.logger.warn("line parsed but not handled: "+Y);break}}}H&&!H.relurl?(b.pop(),F-=H.duration,f.partList&&(f.fragmentHint=H)):f.partList&&(u(j,H),j.cc=K,f.fragmentHint=j);var Ze=b.length,ft=b[0],Me=b[Ze-1];if(F+=f.skippedSegments*f.targetduration,F>0&&Ze&&Me){f.averagetargetduration=F/Ze;var qe=Me.sn;f.endSN=qe!=="initSegment"?qe:0,f.live||(Me.endList=!0),ft&&(f.startCC=ft.cc)}else f.endSN=0,f.startCC=0;return f.fragmentHint&&(F+=f.fragmentHint.duration),f.totalduration=F,f.endCC=K,ne>0&&i(b,ne),f},c}();function n(c,m){var e,r,t=new x.AttrList(c),s=(e=t.enumeratedString("METHOD"))!=null?e:"",y=t.URI,f=t.hexadecimalInteger("IV"),b=t.enumeratedString("KEYFORMATVERSIONS"),R=(r=t.enumeratedString("KEYFORMAT"))!=null?r:"identity";y&&t.IV&&!f&&_.logger.error("Invalid IV: "+t.IV);var I=y?o.resolve(y,m):"",k=(b||"1").split("/").map(Number).filter(Number.isFinite);return new D.LevelKey(s,I,R,k,f)}function v(c,m){["video","audio","text"].forEach(function(e){var r=c.filter(function(s){return(0,S.isCodecType)(s,e)});if(r.length){var t=r.filter(function(s){return s.lastIndexOf("avc1",0)===0||s.lastIndexOf("mp4a",0)===0});m[e+"Codec"]=t.length>0?t[0]:r[0],c=c.filter(function(s){return r.indexOf(s)===-1})}}),m.unknownCodecs=c}function l(c,m,e){var r=m[e];r&&(c[e]=r)}function i(c,m){for(var e=c[m],r=m;r--;){var t=c[r];if(!t)return;t.programDateTime=e.programDateTime-t.duration*1e3,e=t}}function u(c,m){c.rawProgramDateTime?c.programDateTime=Date.parse(c.rawProgramDateTime):m!=null&&m.programDateTime&&(c.programDateTime=m.endProgramDateTime),(0,C.isFiniteNumber)(c.programDateTime)||(c.programDateTime=null,c.rawProgramDateTime=null)}function g(c,m,e,r){c.relurl=m.URI,m.BYTERANGE&&c.setByteRange(m.BYTERANGE),c.level=e,c.sn="initSegment",r&&(c.levelkeys=r),c.initSegment=null}},"./src/loader/playlist-loader.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>d});var C=T("./src/polyfills/number.ts"),L=T("./src/events.ts"),M=T("./src/errors.ts"),P=T("./src/utils/logger.ts"),B=T("./src/loader/m3u8-parser.ts"),A=T("./src/types/loader.ts"),D=T("./src/utils/attr-list.ts");function x(E){var p=E.type;switch(p){case A.PlaylistContextType.AUDIO_TRACK:return A.PlaylistLevelType.AUDIO;case A.PlaylistContextType.SUBTITLE_TRACK:return A.PlaylistLevelType.SUBTITLE;default:return A.PlaylistLevelType.MAIN}}function _(E,p){var h=E.url;return(h===void 0||h.indexOf("data:")===0)&&(h=p.url),h}var S=function(){function E(h){this.hls=void 0,this.loaders=Object.create(null),this.hls=h,this.registerListeners()}var p=E.prototype;return p.startLoad=function(a){},p.stopLoad=function(){this.destroyInternalLoaders()},p.registerListeners=function(){var a=this.hls;a.on(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.on(L.Events.LEVEL_LOADING,this.onLevelLoading,this),a.on(L.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),a.on(L.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},p.unregisterListeners=function(){var a=this.hls;a.off(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.off(L.Events.LEVEL_LOADING,this.onLevelLoading,this),a.off(L.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),a.off(L.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},p.createInternalLoader=function(a){var o=this.hls.config,n=o.pLoader,v=o.loader,l=n||v,i=new l(o);return a.loader=i,this.loaders[a.type]=i,i},p.getInternalLoader=function(a){return this.loaders[a.type]},p.resetInternalLoader=function(a){this.loaders[a]&&delete this.loaders[a]},p.destroyInternalLoaders=function(){for(var a in this.loaders){var o=this.loaders[a];o&&o.destroy(),this.resetInternalLoader(a)}},p.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},p.onManifestLoading=function(a,o){var n=o.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:A.PlaylistContextType.MANIFEST,url:n,deliveryDirectives:null})},p.onLevelLoading=function(a,o){var n=o.id,v=o.level,l=o.url,i=o.deliveryDirectives;this.load({id:n,groupId:null,level:v,responseType:"text",type:A.PlaylistContextType.LEVEL,url:l,deliveryDirectives:i})},p.onAudioTrackLoading=function(a,o){var n=o.id,v=o.groupId,l=o.url,i=o.deliveryDirectives;this.load({id:n,groupId:v,level:null,responseType:"text",type:A.PlaylistContextType.AUDIO_TRACK,url:l,deliveryDirectives:i})},p.onSubtitleTrackLoading=function(a,o){var n=o.id,v=o.groupId,l=o.url,i=o.deliveryDirectives;this.load({id:n,groupId:v,level:null,responseType:"text",type:A.PlaylistContextType.SUBTITLE_TRACK,url:l,deliveryDirectives:i})},p.load=function(a){var o,n=this.hls.config,v=this.getInternalLoader(a);if(v){var l=v.context;if(l&&l.url===a.url){P.logger.trace("[playlist-loader]: playlist request ongoing");return}P.logger.log("[playlist-loader]: aborting previous loader for type: "+a.type),v.abort()}var i,u,g,c;switch(a.type){case A.PlaylistContextType.MANIFEST:i=n.manifestLoadingMaxRetry,u=n.manifestLoadingTimeOut,g=n.manifestLoadingRetryDelay,c=n.manifestLoadingMaxRetryTimeout;break;case A.PlaylistContextType.LEVEL:case A.PlaylistContextType.AUDIO_TRACK:case A.PlaylistContextType.SUBTITLE_TRACK:i=0,u=n.levelLoadingTimeOut;break;default:i=n.levelLoadingMaxRetry,u=n.levelLoadingTimeOut,g=n.levelLoadingRetryDelay,c=n.levelLoadingMaxRetryTimeout;break}if(v=this.createInternalLoader(a),(o=a.deliveryDirectives)!==null&&o!==void 0&&o.part){var m;if(a.type===A.PlaylistContextType.LEVEL&&a.level!==null?m=this.hls.levels[a.level].details:a.type===A.PlaylistContextType.AUDIO_TRACK&&a.id!==null?m=this.hls.audioTracks[a.id].details:a.type===A.PlaylistContextType.SUBTITLE_TRACK&&a.id!==null&&(m=this.hls.subtitleTracks[a.id].details),m){var e=m.partTarget,r=m.targetduration;e&&r&&(u=Math.min(Math.max(e*3,r*.8)*1e3,u))}}var t={timeout:u,maxRetry:i,retryDelay:g,maxRetryDelay:c,highWaterMark:0},s={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};v.load(a,t,s)},p.loadsuccess=function(a,o,n,v){v===void 0&&(v=null),this.resetInternalLoader(n.type);var l=a.data;if(l.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(a,n,"no EXTM3U delimiter",v);return}o.parsing.start=performance.now(),l.indexOf("#EXTINF:")>0||l.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(a,o,n,v):this.handleMasterPlaylist(a,o,n,v)},p.loaderror=function(a,o,n){n===void 0&&(n=null),this.handleNetworkError(o,n,!1,a)},p.loadtimeout=function(a,o,n){n===void 0&&(n=null),this.handleNetworkError(o,n,!0)},p.handleMasterPlaylist=function(a,o,n,v){var l=this.hls,i=a.data,u=_(a,n),g=B.default.parseMasterPlaylist(i,u),c=g.levels,m=g.sessionData,e=g.sessionKeys;if(!c.length){this.handleManifestParsingError(a,n,"no level found in manifest",v);return}var r=c.map(function(R){return{id:R.attrs.AUDIO,audioCodec:R.audioCodec}}),t=c.map(function(R){return{id:R.attrs.SUBTITLES,textCodec:R.textCodec}}),s=B.default.parseMasterPlaylistMedia(i,u,"AUDIO",r),y=B.default.parseMasterPlaylistMedia(i,u,"SUBTITLES",t),f=B.default.parseMasterPlaylistMedia(i,u,"CLOSED-CAPTIONS");if(s.length){var b=s.some(function(R){return!R.url});!b&&c[0].audioCodec&&!c[0].attrs.AUDIO&&(P.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),s.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new D.AttrList({}),bitrate:0,url:""}))}l.trigger(L.Events.MANIFEST_LOADED,{levels:c,audioTracks:s,subtitles:y,captions:f,url:u,stats:o,networkDetails:v,sessionData:m,sessionKeys:e})},p.handleTrackOrLevelPlaylist=function(a,o,n,v){var l=this.hls,i=n.id,u=n.level,g=n.type,c=_(a,n),m=(0,C.isFiniteNumber)(i)?i:0,e=(0,C.isFiniteNumber)(u)?u:m,r=x(n),t=B.default.parseLevelPlaylist(a.data,c,e,r,m);if(!t.fragments.length){l.trigger(L.Events.ERROR,{type:M.ErrorTypes.NETWORK_ERROR,details:M.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:c,reason:"no fragments found in level",level:typeof n.level=="number"?n.level:void 0});return}if(g===A.PlaylistContextType.MANIFEST){var s={attrs:new D.AttrList({}),bitrate:0,details:t,name:"",url:c};l.trigger(L.Events.MANIFEST_LOADED,{levels:[s],audioTracks:[],url:c,stats:o,networkDetails:v,sessionData:null,sessionKeys:null})}o.parsing.end=performance.now(),n.levelDetails=t,this.handlePlaylistLoaded(a,o,n,v)},p.handleManifestParsingError=function(a,o,n,v){this.hls.trigger(L.Events.ERROR,{type:M.ErrorTypes.NETWORK_ERROR,details:M.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:o.type===A.PlaylistContextType.MANIFEST,url:a.url,reason:n,response:a,context:o,networkDetails:v})},p.handleNetworkError=function(a,o,n,v){n===void 0&&(n=!1),P.logger.warn("[playlist-loader]: A network "+(n?"timeout":"error")+" occurred while loading "+a.type+" level: "+a.level+" id: "+a.id+' group-id: "'+a.groupId+'"');var l=M.ErrorDetails.UNKNOWN,i=!1,u=this.getInternalLoader(a);switch(a.type){case A.PlaylistContextType.MANIFEST:l=n?M.ErrorDetails.MANIFEST_LOAD_TIMEOUT:M.ErrorDetails.MANIFEST_LOAD_ERROR,i=!0;break;case A.PlaylistContextType.LEVEL:l=n?M.ErrorDetails.LEVEL_LOAD_TIMEOUT:M.ErrorDetails.LEVEL_LOAD_ERROR,i=!1;break;case A.PlaylistContextType.AUDIO_TRACK:l=n?M.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:M.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,i=!1;break;case A.PlaylistContextType.SUBTITLE_TRACK:l=n?M.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:M.ErrorDetails.SUBTITLE_LOAD_ERROR,i=!1;break}u&&this.resetInternalLoader(a.type);var g={type:M.ErrorTypes.NETWORK_ERROR,details:l,fatal:i,url:a.url,loader:u,context:a,networkDetails:o};v&&(g.response=v),this.hls.trigger(L.Events.ERROR,g)},p.handlePlaylistLoaded=function(a,o,n,v){var l=n.type,i=n.level,u=n.id,g=n.groupId,c=n.loader,m=n.levelDetails,e=n.deliveryDirectives;if(!(m!=null&&m.targetduration)){this.handleManifestParsingError(a,n,"invalid target duration",v);return}if(!!c)switch(m.live&&(c.getCacheAge&&(m.ageHeader=c.getCacheAge()||0),(!c.getCacheAge||isNaN(m.ageHeader))&&(m.ageHeader=0)),l){case A.PlaylistContextType.MANIFEST:case A.PlaylistContextType.LEVEL:this.hls.trigger(L.Events.LEVEL_LOADED,{details:m,level:i||0,id:u||0,stats:o,networkDetails:v,deliveryDirectives:e});break;case A.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(L.Events.AUDIO_TRACK_LOADED,{details:m,id:u||0,groupId:g||"",stats:o,networkDetails:v,deliveryDirectives:e});break;case A.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(L.Events.SUBTITLE_TRACK_LOADED,{details:m,id:u||0,groupId:g||"",stats:o,networkDetails:v,deliveryDirectives:e});break}},E}();let d=S},"./src/polyfills/number.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{MAX_SAFE_INTEGER:()=>L,isFiniteNumber:()=>C});var C=Number.isFinite||function(M){return typeof M=="number"&&isFinite(M)},L=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>L});var C=function(){function M(){}return M.getSilentFrame=function(B,A){switch(B){case"mp4a.40.2":if(A===1)return new Uint8Array([0,200,0,128,35,128]);if(A===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(A===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(A===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(A===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(A===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(A===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(A===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(A===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}},M}();let L=C},"./src/remux/mp4-generator.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>M});var C=Math.pow(2,32)-1,L=function(){function P(){}return P.init=function(){P.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:[]};var A;for(A in P.types)P.types.hasOwnProperty(A)&&(P.types[A]=[A.charCodeAt(0),A.charCodeAt(1),A.charCodeAt(2),A.charCodeAt(3)]);var D=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),x=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]);P.HDLR_TYPES={video:D,audio:x};var _=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),S=new Uint8Array([0,0,0,0,0,0,0,0]);P.STTS=P.STSC=P.STCO=S,P.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),P.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),P.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),P.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var d=new Uint8Array([105,115,111,109]),E=new Uint8Array([97,118,99,49]),p=new Uint8Array([0,0,0,1]);P.FTYP=P.box(P.types.ftyp,d,p,d,E),P.DINF=P.box(P.types.dinf,P.box(P.types.dref,_))},P.box=function(A){for(var D=8,x=arguments.length,_=new Array(x>1?x-1:0),S=1;S<x;S++)_[S-1]=arguments[S];for(var d=_.length,E=d;d--;)D+=_[d].byteLength;var p=new Uint8Array(D);for(p[0]=D>>24&255,p[1]=D>>16&255,p[2]=D>>8&255,p[3]=D&255,p.set(A,4),d=0,D=8;d<E;d++)p.set(_[d],D),D+=_[d].byteLength;return p},P.hdlr=function(A){return P.box(P.types.hdlr,P.HDLR_TYPES[A])},P.mdat=function(A){return P.box(P.types.mdat,A)},P.mdhd=function(A,D){D*=A;var x=Math.floor(D/(C+1)),_=Math.floor(D%(C+1));return P.box(P.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,A>>24&255,A>>16&255,A>>8&255,A&255,x>>24,x>>16&255,x>>8&255,x&255,_>>24,_>>16&255,_>>8&255,_&255,85,196,0,0]))},P.mdia=function(A){return P.box(P.types.mdia,P.mdhd(A.timescale,A.duration),P.hdlr(A.type),P.minf(A))},P.mfhd=function(A){return P.box(P.types.mfhd,new Uint8Array([0,0,0,0,A>>24,A>>16&255,A>>8&255,A&255]))},P.minf=function(A){return A.type==="audio"?P.box(P.types.minf,P.box(P.types.smhd,P.SMHD),P.DINF,P.stbl(A)):P.box(P.types.minf,P.box(P.types.vmhd,P.VMHD),P.DINF,P.stbl(A))},P.moof=function(A,D,x){return P.box(P.types.moof,P.mfhd(A),P.traf(x,D))},P.moov=function(A){for(var D=A.length,x=[];D--;)x[D]=P.trak(A[D]);return P.box.apply(null,[P.types.moov,P.mvhd(A[0].timescale,A[0].duration)].concat(x).concat(P.mvex(A)))},P.mvex=function(A){for(var D=A.length,x=[];D--;)x[D]=P.trex(A[D]);return P.box.apply(null,[P.types.mvex].concat(x))},P.mvhd=function(A,D){D*=A;var x=Math.floor(D/(C+1)),_=Math.floor(D%(C+1)),S=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,A>>24&255,A>>16&255,A>>8&255,A&255,x>>24,x>>16&255,x>>8&255,x&255,_>>24,_>>16&255,_>>8&255,_&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 P.box(P.types.mvhd,S)},P.sdtp=function(A){var D=A.samples||[],x=new Uint8Array(4+D.length),_,S;for(_=0;_<D.length;_++)S=D[_].flags,x[_+4]=S.dependsOn<<4|S.isDependedOn<<2|S.hasRedundancy;return P.box(P.types.sdtp,x)},P.stbl=function(A){return P.box(P.types.stbl,P.stsd(A),P.box(P.types.stts,P.STTS),P.box(P.types.stsc,P.STSC),P.box(P.types.stsz,P.STSZ),P.box(P.types.stco,P.STCO))},P.avc1=function(A){var D=[],x=[],_,S,d;for(_=0;_<A.sps.length;_++)S=A.sps[_],d=S.byteLength,D.push(d>>>8&255),D.push(d&255),D=D.concat(Array.prototype.slice.call(S));for(_=0;_<A.pps.length;_++)S=A.pps[_],d=S.byteLength,x.push(d>>>8&255),x.push(d&255),x=x.concat(Array.prototype.slice.call(S));var E=P.box(P.types.avcC,new Uint8Array([1,D[3],D[4],D[5],255,224|A.sps.length].concat(D).concat([A.pps.length]).concat(x))),p=A.width,h=A.height,a=A.pixelRatio[0],o=A.pixelRatio[1];return P.box(P.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,p>>8&255,p&255,h>>8&255,h&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]),E,P.box(P.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),P.box(P.types.pasp,new Uint8Array([a>>24,a>>16&255,a>>8&255,a&255,o>>24,o>>16&255,o>>8&255,o&255])))},P.esds=function(A){var D=A.config.length;return new Uint8Array([0,0,0,0,3,23+D,0,1,0,4,15+D,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([D]).concat(A.config).concat([6,1,2]))},P.mp4a=function(A){var D=A.samplerate;return P.box(P.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,A.channelCount,0,16,0,0,0,0,D>>8&255,D&255,0,0]),P.box(P.types.esds,P.esds(A)))},P.mp3=function(A){var D=A.samplerate;return P.box(P.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,A.channelCount,0,16,0,0,0,0,D>>8&255,D&255,0,0]))},P.stsd=function(A){return A.type==="audio"?A.segmentCodec==="mp3"&&A.codec==="mp3"?P.box(P.types.stsd,P.STSD,P.mp3(A)):P.box(P.types.stsd,P.STSD,P.mp4a(A)):P.box(P.types.stsd,P.STSD,P.avc1(A))},P.tkhd=function(A){var D=A.id,x=A.duration*A.timescale,_=A.width,S=A.height,d=Math.floor(x/(C+1)),E=Math.floor(x%(C+1));return P.box(P.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,D>>24&255,D>>16&255,D>>8&255,D&255,0,0,0,0,d>>24,d>>16&255,d>>8&255,d&255,E>>24,E>>16&255,E>>8&255,E&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,_>>8&255,_&255,0,0,S>>8&255,S&255,0,0]))},P.traf=function(A,D){var x=P.sdtp(A),_=A.id,S=Math.floor(D/(C+1)),d=Math.floor(D%(C+1));return P.box(P.types.traf,P.box(P.types.tfhd,new Uint8Array([0,0,0,0,_>>24,_>>16&255,_>>8&255,_&255])),P.box(P.types.tfdt,new Uint8Array([1,0,0,0,S>>24,S>>16&255,S>>8&255,S&255,d>>24,d>>16&255,d>>8&255,d&255])),P.trun(A,x.length+16+20+8+16+8+8),x)},P.trak=function(A){return A.duration=A.duration||4294967295,P.box(P.types.trak,P.tkhd(A),P.mdia(A))},P.trex=function(A){var D=A.id;return P.box(P.types.trex,new Uint8Array([0,0,0,0,D>>24,D>>16&255,D>>8&255,D&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},P.trun=function(A,D){var x=A.samples||[],_=x.length,S=12+16*_,d=new Uint8Array(S),E,p,h,a,o,n;for(D+=8+S,d.set([A.type==="video"?1:0,0,15,1,_>>>24&255,_>>>16&255,_>>>8&255,_&255,D>>>24&255,D>>>16&255,D>>>8&255,D&255],0),E=0;E<_;E++)p=x[E],h=p.duration,a=p.size,o=p.flags,n=p.cts,d.set([h>>>24&255,h>>>16&255,h>>>8&255,h&255,a>>>24&255,a>>>16&255,a>>>8&255,a&255,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,o.degradPrio&240<<8,o.degradPrio&15,n>>>24&255,n>>>16&255,n>>>8&255,n&255],12+16*E);return P.box(P.types.trun,d)},P.initSegment=function(A){P.types||P.init();var D=P.moov(A),x=new Uint8Array(P.FTYP.byteLength+D.byteLength);return x.set(P.FTYP),x.set(D,P.FTYP.byteLength),x},P}();L.types=void 0,L.HDLR_TYPES=void 0,L.STTS=void 0,L.STSC=void 0,L.STCO=void 0,L.STSZ=void 0,L.VMHD=void 0,L.SMHD=void 0,L.STSD=void 0,L.FTYP=void 0,L.DINF=void 0;let M=L},"./src/remux/mp4-remuxer.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>a,flushTextTrackMetadataCueSamples:()=>v,flushTextTrackUserdataCueSamples:()=>l,normalizePts:()=>o});var C=T("./src/polyfills/number.ts"),L=T("./src/remux/aac-helper.ts"),M=T("./src/remux/mp4-generator.ts"),P=T("./src/events.ts"),B=T("./src/errors.ts"),A=T("./src/utils/logger.ts"),D=T("./src/types/loader.ts"),x=T("./src/utils/timescale-conversion.ts");function _(){return _=Object.assign?Object.assign.bind():function(g){for(var c=1;c<arguments.length;c++){var m=arguments[c];for(var e in m)Object.prototype.hasOwnProperty.call(m,e)&&(g[e]=m[e])}return g},_.apply(this,arguments)}var S=10*1e3,d=1024,E=1152,p=null,h=null,a=function(){function g(m,e,r,t){if(t===void 0&&(t=""),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=void 0,this._initDTS=void 0,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=m,this.config=e,this.typeSupported=r,this.ISGenerated=!1,p===null){var s=navigator.userAgent||"",y=s.match(/Chrome\/(\d+)/i);p=y?parseInt(y[1]):0}if(h===null){var f=navigator.userAgent.match(/Safari\/(\d+)/i);h=f?parseInt(f[1]):0}}var c=g.prototype;return c.destroy=function(){},c.resetTimeStamp=function(e){A.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e},c.resetNextTimestamp=function(){A.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},c.resetInitSegment=function(){A.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},c.getVideoStartPts=function(e){var r=!1,t=e.reduce(function(s,y){var f=y.pts-s;return f<-4294967296?(r=!0,o(s,y.pts)):f>0?s:y.pts},e[0].pts);return r&&A.logger.debug("PTS rollover detected"),t},c.remux=function(e,r,t,s,y,f,b,R){var I,k,F,K,H,j,Y=y,Q=y,q=e.pid>-1,ne=r.pid>-1,te=r.samples.length,ae=e.samples.length>0,ue=b&&te>0||te>1,ce=(!q||ae)&&(!ne||ue)||this.ISGenerated||b;if(ce){this.ISGenerated||(F=this.generateIS(e,r,y));var le=this.isVideoContiguous,fe=-1,de;if(ue&&(fe=n(r.samples),!le&&this.config.forceKeyFrameOnDiscontinuity))if(j=!0,fe>0){A.logger.warn("[mp4-remuxer]: Dropped "+fe+" out of "+te+" video samples due to a missing keyframe");var xe=this.getVideoStartPts(r.samples);r.samples=r.samples.slice(fe),r.dropped+=fe,Q+=(r.samples[0].pts-xe)/r.inputTimeScale,de=Q}else fe===-1&&(A.logger.warn("[mp4-remuxer]: No keyframe found out of "+te+" video samples"),j=!1);if(this.ISGenerated){if(ae&&ue){var Ae=this.getVideoStartPts(r.samples),Ie=o(e.samples[0].pts,Ae)-Ae,Re=Ie/r.inputTimeScale;Y+=Math.max(0,Re),Q+=Math.max(0,-Re)}if(ae){if(e.samplerate||(A.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),F=this.generateIS(e,r,y)),k=this.remuxAudio(e,Y,this.isAudioContiguous,f,ne||ue||R===D.PlaylistLevelType.AUDIO?Q:void 0),ue){var Oe=k?k.endPTS-k.startPTS:0;r.inputTimeScale||(A.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),F=this.generateIS(e,r,y)),I=this.remuxVideo(r,Q,le,Oe)}}else ue&&(I=this.remuxVideo(r,Q,le,0));I&&(I.firstKeyFrame=fe,I.independent=fe!==-1,I.firstKeyFramePTS=de)}}return this.ISGenerated&&(t.samples.length&&(H=v(t,y,this._initPTS,this._initDTS)),s.samples.length&&(K=l(s,y,this._initPTS))),{audio:k,video:I,initSegment:F,independent:j,text:K,id3:H}},c.generateIS=function(e,r,t){var s=e.samples,y=r.samples,f=this.typeSupported,b={},R=!(0,C.isFiniteNumber)(this._initPTS),I="audio/mp4",k,F,K;if(R&&(k=F=1/0),e.config&&s.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":f.mpeg?(I="audio/mpeg",e.codec=""):f.mp3&&(e.codec="mp3");break}b.audio={id:"audio",container:I,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&f.mpeg?new Uint8Array(0):M.default.initSegment([e]),metadata:{channelCount:e.channelCount}},R&&(K=e.inputTimeScale,k=F=s[0].pts-Math.round(K*t))}if(r.sps&&r.pps&&y.length&&(r.timescale=r.inputTimeScale,b.video={id:"main",container:"video/mp4",codec:r.codec,initSegment:M.default.initSegment([r]),metadata:{width:r.width,height:r.height}},R)){K=r.inputTimeScale;var H=this.getVideoStartPts(y),j=Math.round(K*t);F=Math.min(F,o(y[0].dts,H)-j),k=Math.min(k,H-j)}if(Object.keys(b).length)return this.ISGenerated=!0,R&&(this._initPTS=k,this._initDTS=F),{tracks:b,initPTS:k,timescale:K}},c.remuxVideo=function(e,r,t,s){var y=e.inputTimeScale,f=e.samples,b=[],R=f.length,I=this._initPTS,k=this.nextAvcDts,F=8,K=this.videoSampleDuration,H,j,Y=Number.POSITIVE_INFINITY,Q=Number.NEGATIVE_INFINITY,q=!1;if(!t||k===null){var ne=r*y,te=f[0].pts-o(f[0].dts,f[0].pts);k=ne-te}for(var ae=0;ae<R;ae++){var ue=f[ae];ue.pts=o(ue.pts-I,k),ue.dts=o(ue.dts-I,k),ue.dts<f[ae>0?ae-1:ae].dts&&(q=!0)}q&&f.sort(function(ut,wt){var sr=ut.dts-wt.dts,or=ut.pts-wt.pts;return sr||or}),H=f[0].dts,j=f[f.length-1].dts;var ce=j-H,le=ce?Math.round(ce/(R-1)):K||e.inputTimeScale/30;if(t){var fe=H-k,de=fe>le,xe=fe<-1;if((de||xe)&&(de?A.logger.warn("AVC: "+(0,x.toMsFromMpegTsClock)(fe,!0)+" ms ("+fe+"dts) hole between fragments detected, filling it"):A.logger.warn("AVC: "+(0,x.toMsFromMpegTsClock)(-fe,!0)+" ms ("+fe+"dts) overlapping between fragments detected"),!xe||k>f[0].pts)){H=k;var Ae=f[0].pts-fe;f[0].dts=H,f[0].pts=Ae,A.logger.log("Video: First PTS/DTS adjusted: "+(0,x.toMsFromMpegTsClock)(Ae,!0)+"/"+(0,x.toMsFromMpegTsClock)(H,!0)+", delta: "+(0,x.toMsFromMpegTsClock)(fe,!0)+" ms")}}H=Math.max(0,H);for(var Ie=0,Re=0,Oe=0;Oe<R;Oe++){for(var Pe=f[Oe],Ce=Pe.units,Le=Ce.length,ke=0,Be=0;Be<Le;Be++)ke+=Ce[Be].data.length;Re+=ke,Ie+=Le,Pe.length=ke,Pe.dts=Math.max(Pe.dts,H),Y=Math.min(Pe.pts,Y),Q=Math.max(Pe.pts,Q)}j=f[R-1].dts;var we=Re+4*Ie+8,Ye;try{Ye=new Uint8Array(we)}catch{this.observer.emit(P.Events.ERROR,P.Events.ERROR,{type:B.ErrorTypes.MUX_ERROR,details:B.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:we,reason:"fail allocating video mdat "+we});return}var Xe=new DataView(Ye.buffer);Xe.setUint32(0,we),Ye.set(M.default.types.mdat,4);for(var rt=!1,ze=Number.POSITIVE_INFINITY,it=Number.POSITIVE_INFINITY,nt=Number.NEGATIVE_INFINITY,Je=Number.NEGATIVE_INFINITY,Ne=0;Ne<R;Ne++){for(var Ke=f[Ne],Ze=Ke.units,ft=0,Me=0,qe=Ze.length;Me<qe;Me++){var et=Ze[Me],_t=et.data,mt=et.data.byteLength;Xe.setUint32(F,mt),F+=4,Ye.set(_t,F),F+=mt,ft+=4+mt}var pt=void 0;if(Ne<R-1)K=f[Ne+1].dts-Ke.dts,pt=f[Ne+1].pts-Ke.pts;else{var Rt=this.config,Tt=Ne>0?Ke.dts-f[Ne-1].dts:le;if(pt=Ne>0?Ke.pts-f[Ne-1].pts:le,Rt.stretchShortVideoTrack&&this.nextAudioPts!==null){var Gt=Math.floor(Rt.maxBufferHole*y),It=(s?Y+s*y:this.nextAudioPts)-Ke.pts;It>Gt?(K=It-Tt,K<0?K=Tt:rt=!0,A.logger.log("[mp4-remuxer]: It is approximately "+It/90+" ms to the next segment; using duration "+K/90+" ms for the last video frame.")):K=Tt}else K=Tt}var rr=Math.round(Ke.pts-Ke.dts);ze=Math.min(ze,K),nt=Math.max(nt,K),it=Math.min(it,pt),Je=Math.max(Je,pt),b.push(new i(Ke.key,K,ft,rr))}if(b.length){if(p){if(p<70){var Ot=b[0].flags;Ot.dependsOn=2,Ot.isNonSync=0}}else if(h&&Je-it<nt-ze&&le/nt<.025&&b[0].cts===0){A.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var St=H,lt=0,Ht=b.length;lt<Ht;lt++){var Ct=St+b[lt].duration,jt=St+b[lt].cts;if(lt<Ht-1){var Mt=Ct+b[lt+1].cts;b[lt].duration=Mt-jt}else b[lt].duration=lt?b[lt-1].duration:le;b[lt].cts=0,St=Ct}}}console.assert(K!==null,"mp4SampleDuration must be computed"),K=rt||!K?le:K,this.nextAvcDts=k=j+K,this.videoSampleDuration=K,this.isVideoContiguous=!0;var ir=M.default.moof(e.sequenceNumber++,H,_({},e,{samples:b})),nr="video",ar={data1:ir,data2:Ye,startPTS:Y/y,endPTS:(Q+K)/y,startDTS:H/y,endDTS:k/y,type:nr,hasAudio:!1,hasVideo:!0,nb:b.length,dropped:e.dropped};return e.samples=[],e.dropped=0,console.assert(Ye.length,"MDAT length must not be zero"),ar},c.remuxAudio=function(e,r,t,s,y){var f=e.inputTimeScale,b=e.samplerate?e.samplerate:f,R=f/b,I=e.segmentCodec==="aac"?d:E,k=I*R,F=this._initPTS,K=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,H=[],j=y!==void 0,Y=e.samples,Q=K?0:8,q=this.nextAudioPts||-1,ne=r*f;if(this.isAudioContiguous=t=t||Y.length&&q>0&&(s&&Math.abs(ne-q)<9e3||Math.abs(o(Y[0].pts-F,ne)-q)<20*k),Y.forEach(function(et){et.pts=o(et.pts-F,ne)}),!t||q<0){if(Y=Y.filter(function(et){return et.pts>=0}),!Y.length)return;y===0?q=0:s&&!j?q=Math.max(0,ne):q=Y[0].pts}if(e.segmentCodec==="aac")for(var te=this.config.maxAudioFramesDrift,ae=0,ue=q;ae<Y.length;ae++){var ce=Y[ae],le=ce.pts,fe=le-ue,de=Math.abs(1e3*fe/f);if(fe<=-te*k&&j)ae===0&&(A.logger.warn("Audio frame @ "+(le/f).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*fe/f)+" ms."),this.nextAudioPts=q=ue=le);else if(fe>=te*k&&de<S&&j){var xe=Math.round(fe/k);ue=le-xe*k,ue<0&&(xe--,ue+=k),ae===0&&(this.nextAudioPts=q=ue),A.logger.warn("[mp4-remuxer]: Injecting "+xe+" audio frame @ "+(ue/f).toFixed(3)+"s due to "+Math.round(1e3*fe/f)+" ms gap.");for(var Ae=0;Ae<xe;Ae++){var Ie=Math.max(ue,0),Re=L.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);Re||(A.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Re=ce.unit.subarray()),Y.splice(ae,0,{unit:Re,pts:Ie}),ue+=k,ae++}}ce.pts=ue,ue+=k}for(var Oe=null,Pe=null,Ce,Le=0,ke=Y.length;ke--;)Le+=Y[ke].unit.byteLength;for(var Be=0,we=Y.length;Be<we;Be++){var Ye=Y[Be],Xe=Ye.unit,rt=Ye.pts;if(Pe!==null){var ze=H[Be-1];ze.duration=Math.round((rt-Pe)/R)}else if(t&&e.segmentCodec==="aac"&&(rt=q),Oe=rt,Le>0){Le+=Q;try{Ce=new Uint8Array(Le)}catch{this.observer.emit(P.Events.ERROR,P.Events.ERROR,{type:B.ErrorTypes.MUX_ERROR,details:B.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Le,reason:"fail allocating audio mdat "+Le});return}if(!K){var it=new DataView(Ce.buffer);it.setUint32(0,Le),Ce.set(M.default.types.mdat,4)}}else return;Ce.set(Xe,Q);var nt=Xe.byteLength;Q+=nt,H.push(new i(!0,I,nt,0)),Pe=rt}var Je=H.length;if(!!Je){var Ne=H[H.length-1];this.nextAudioPts=q=Pe+R*Ne.duration;var Ke=K?new Uint8Array(0):M.default.moof(e.sequenceNumber++,Oe/R,_({},e,{samples:H}));e.samples=[];var Ze=Oe/f,ft=q/f,Me="audio",qe={data1:Ke,data2:Ce,startPTS:Ze,endPTS:ft,startDTS:Ze,endDTS:ft,type:Me,hasAudio:!0,hasVideo:!1,nb:Je};return this.isAudioContiguous=!0,console.assert(Ce.length,"MDAT length must not be zero"),qe}},c.remuxEmptyAudio=function(e,r,t,s){var y=e.inputTimeScale,f=e.samplerate?e.samplerate:y,b=y/f,R=this.nextAudioPts,I=(R!==null?R:s.startDTS*y)+this._initDTS,k=s.endDTS*y+this._initDTS,F=b*d,K=Math.ceil((k-I)/F),H=L.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(A.logger.warn("[mp4-remuxer]: remux empty Audio"),!H){A.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var j=[],Y=0;Y<K;Y++){var Q=I+Y*F;j.push({unit:H,pts:Q,dts:Q})}return e.samples=j,this.remuxAudio(e,r,t,!1)},g}();function o(g,c){var m;if(c===null)return g;for(c<g?m=-8589934592:m=8589934592;Math.abs(g-c)>4294967296;)g+=m;return g}function n(g){for(var c=0;c<g.length;c++)if(g[c].key)return c;return-1}function v(g,c,m,e){var r=g.samples.length;if(!!r){for(var t=g.inputTimeScale,s=0;s<r;s++){var y=g.samples[s];y.pts=o(y.pts-m,c*t)/t,y.dts=o(y.dts-e,c*t)/t}var f=g.samples;return g.samples=[],{samples:f}}}function l(g,c,m){var e=g.samples.length;if(!!e){for(var r=g.inputTimeScale,t=0;t<e;t++){var s=g.samples[t];s.pts=o(s.pts-m,c*r)/r}g.samples.sort(function(f,b){return f.pts-b.pts});var y=g.samples;return g.samples=[],{samples:y}}}var i=function(c,m,e,r){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=m,this.size=e,this.cts=r,this.flags=new u(c)},u=function(c){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=c?2:1,this.isNonSync=c?0:1}},"./src/remux/passthrough-remuxer.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>x});var C=T("./src/polyfills/number.ts"),L=T("./src/remux/mp4-remuxer.ts"),M=T("./src/utils/mp4-tools.ts"),P=T("./src/loader/fragment.ts"),B=T("./src/utils/logger.ts"),A=function(){function _(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndTime=null}var S=_.prototype;return S.destroy=function(){},S.resetTimeStamp=function(E){this.initPTS=E,this.lastEndTime=null},S.resetNextTimestamp=function(){this.lastEndTime=null},S.resetInitSegment=function(E,p,h,a){this.audioCodec=p,this.videoCodec=h,this.generateInitSegment((0,M.patchEncyptionData)(E,a)),this.emitInitSegment=!0},S.generateInitSegment=function(E){var p=this.audioCodec,h=this.videoCodec;if(!E||!E.byteLength){this.initTracks=void 0,this.initData=void 0;return}var a=this.initData=(0,M.parseInitSegment)(E);p||(p=D(a.audio,P.ElementaryStreamTypes.AUDIO)),h||(h=D(a.video,P.ElementaryStreamTypes.VIDEO));var o={};a.audio&&a.video?o.audiovideo={container:"video/mp4",codec:p+","+h,initSegment:E,id:"main"}:a.audio?o.audio={container:"audio/mp4",codec:p,initSegment:E,id:"audio"}:a.video?o.video={container:"video/mp4",codec:h,initSegment:E,id:"main"}:B.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=o},S.remux=function(E,p,h,a,o){var n,v=this.initPTS,l=this.lastEndTime,i={audio:void 0,video:void 0,text:a,id3:h,initSegment:void 0};(0,C.isFiniteNumber)(l)||(l=this.lastEndTime=o||0);var u=p.samples;if(!u||!u.length)return i;var g={initPTS:void 0,timescale:1},c=this.initData;if((!c||!c.length)&&(this.generateInitSegment(u),c=this.initData),!c||!c.length)return B.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),i;this.emitInitSegment&&(g.tracks=this.initTracks,this.emitInitSegment=!1);var m=(0,M.getStartDTS)(c,u);(0,C.isFiniteNumber)(v)||(this.initPTS=g.initPTS=v=m-o);var e=(0,M.getDuration)(u,c),r=E?m-v:l,t=r+e;(0,M.offsetStartDTS)(c,u,v),e>0?this.lastEndTime=t:(B.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var s=!!c.audio,y=!!c.video,f="";s&&(f+="audio"),y&&(f+="video");var b={data1:u,startPTS:r,startDTS:r,endPTS:t,endDTS:t,type:f,hasAudio:s,hasVideo:y,nb:1,dropped:0};i.audio=b.type==="audio"?b:void 0,i.video=b.type!=="audio"?b:void 0,i.initSegment=g;var R=(n=this.initPTS)!=null?n:0;return i.id3=(0,L.flushTextTrackMetadataCueSamples)(h,o,R,R),a.samples.length&&(i.text=(0,L.flushTextTrackUserdataCueSamples)(a,o,R)),i},_}();function D(_,S){var d=_==null?void 0:_.codec;return d&&d.length>4?d:d==="hvc1"||d==="hev1"?"hvc1.1.c.L120.90":d==="av01"?"av01.0.04M.08":d==="avc1"||S===P.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}let x=A},"./src/task-loop.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>C});var C=function(){function L(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var M=L.prototype;return M.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},M.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},M.onHandlerDestroyed=function(){},M.hasInterval=function(){return!!this._tickInterval},M.hasNextTick=function(){return!!this._tickTimer},M.setInterval=function(B){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,B),!0)},M.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},M.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},M.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},M.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},M.doTick=function(){},L}()},"./src/types/cmcd.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{CMCDObjectType:()=>L,CMCDStreamType:()=>P,CMCDStreamingFormat:()=>M,CMCDVersion:()=>C});var C=1,L;(function(B){B.MANIFEST="m",B.AUDIO="a",B.VIDEO="v",B.MUXED="av",B.INIT="i",B.CAPTION="c",B.TIMED_TEXT="tt",B.KEY="k",B.OTHER="o"})(L||(L={}));var M;(function(B){B.DASH="d",B.HLS="h",B.SMOOTH="s",B.OTHER="o"})(M||(M={}));var P;(function(B){B.VOD="v",B.LIVE="l"})(P||(P={}))},"./src/types/demuxer.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{MetadataSchema:()=>C});var C;(function(L){L.audioId3="org.id3",L.dateRange="com.apple.quicktime.HLS",L.emsg="https://aomedia.org/emsg/ID3"})(C||(C={}))},"./src/types/level.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{HdcpLevels:()=>B,HlsSkip:()=>A,HlsUrlParameters:()=>x,Level:()=>_,getSkipValue:()=>D});function C(S,d){for(var E=0;E<d.length;E++){var p=d[E];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(S,M(p.key),p)}}function L(S,d,E){return d&&C(S.prototype,d),E&&C(S,E),Object.defineProperty(S,"prototype",{writable:!1}),S}function M(S){var d=P(S,"string");return typeof d=="symbol"?d:String(d)}function P(S,d){if(typeof S!="object"||S===null)return S;var E=S[Symbol.toPrimitive];if(E!==void 0){var p=E.call(S,d||"default");if(typeof p!="object")return p;throw new TypeError("@@toPrimitive must return a primitive value.")}return(d==="string"?String:Number)(S)}var B=["NONE","TYPE-0","TYPE-1","TYPE-2",null],A;(function(S){S.No="",S.Yes="YES",S.v2="v2"})(A||(A={}));function D(S,d){var E=S.canSkipUntil,p=S.canSkipDateRanges,h=S.endSN,a=d!==void 0?d-h:0;return E&&a<E?p?A.v2:A.Yes:A.No}var x=function(){function S(E,p,h){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=E,this.part=p,this.skip=h}var d=S.prototype;return d.addDirectives=function(p){var h=new self.URL(p);return this.msn!==void 0&&h.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&h.searchParams.set("_HLS_part",this.part.toString()),this.skip&&h.searchParams.set("_HLS_skip",this.skip),h.href},S}(),_=function(){function S(d){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=[d.url],this.attrs=d.attrs,this.bitrate=d.bitrate,d.details&&(this.details=d.details),this.id=d.id||0,this.name=d.name,this.width=d.width||0,this.height=d.height||0,this.audioCodec=d.audioCodec,this.videoCodec=d.videoCodec,this.unknownCodecs=d.unknownCodecs,this.codecSet=[d.videoCodec,d.audioCodec].filter(function(E){return E}).join(",").replace(/\.[^.,]+/g,"")}return L(S,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(E){var p=E%this.url.length;this._urlId!==p&&(this.details=void 0,this._urlId=p)}}]),S}()},"./src/types/loader.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{PlaylistContextType:()=>C,PlaylistLevelType:()=>L});var C;(function(M){M.MANIFEST="manifest",M.LEVEL="level",M.AUDIO_TRACK="audioTrack",M.SUBTITLE_TRACK="subtitleTrack"})(C||(C={}));var L;(function(M){M.MAIN="main",M.AUDIO="audio",M.SUBTITLE="subtitle"})(L||(L={}))},"./src/types/transmuxer.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{ChunkMetadata:()=>C});var C=function(P,B,A,D,x,_){D===void 0&&(D=0),x===void 0&&(x=-1),_===void 0&&(_=!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=L(),this.buffering={audio:L(),video:L(),audiovideo:L()},this.level=P,this.sn=B,this.id=A,this.size=D,this.part=x,this.partial=_};function L(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{AttrList:()=>M});var C=/^(\d+)x(\d+)$/,L=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,M=function(){function P(A){typeof A=="string"&&(A=P.parseAttrList(A));for(var D in A)A.hasOwnProperty(D)&&(this[D]=A[D])}var B=P.prototype;return B.decimalInteger=function(D){var x=parseInt(this[D],10);return x>Number.MAX_SAFE_INTEGER?1/0:x},B.hexadecimalInteger=function(D){if(this[D]){var x=(this[D]||"0x").slice(2);x=(x.length&1?"0":"")+x;for(var _=new Uint8Array(x.length/2),S=0;S<x.length/2;S++)_[S]=parseInt(x.slice(S*2,S*2+2),16);return _}else return null},B.hexadecimalIntegerAsNumber=function(D){var x=parseInt(this[D],16);return x>Number.MAX_SAFE_INTEGER?1/0:x},B.decimalFloatingPoint=function(D){return parseFloat(this[D])},B.optionalFloat=function(D,x){var _=this[D];return _?parseFloat(_):x},B.enumeratedString=function(D){return this[D]},B.bool=function(D){return this[D]==="YES"},B.decimalResolution=function(D){var x=C.exec(this[D]);if(x!==null)return{width:parseInt(x[1],10),height:parseInt(x[2],10)}},P.parseAttrList=function(D){var x,_={},S='"';for(L.lastIndex=0;(x=L.exec(D))!==null;){var d=x[2];d.indexOf(S)===0&&d.lastIndexOf(S)===d.length-1&&(d=d.slice(1,-1)),_[x[1]]=d}return _},P}()},"./src/utils/binary-search.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>L});var C={search:function(P,B){for(var A=0,D=P.length-1,x=null,_=null;A<=D;){x=(A+D)/2|0,_=P[x];var S=B(_);if(S>0)A=x+1;else if(S<0)D=x-1;else return _}return null}};let L=C},"./src/utils/buffer-helper.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{BufferHelper:()=>M});var C=T("./src/utils/logger.ts"),L={length:0,start:function(){return 0},end:function(){return 0}},M=function(){function P(){}return P.isBuffered=function(A,D){try{if(A){for(var x=P.getBuffered(A),_=0;_<x.length;_++)if(D>=x.start(_)&&D<=x.end(_))return!0}}catch{}return!1},P.bufferInfo=function(A,D,x){try{if(A){var _=P.getBuffered(A),S=[],d;for(d=0;d<_.length;d++)S.push({start:_.start(d),end:_.end(d)});return this.bufferedInfo(S,D,x)}}catch{}return{len:0,start:D,end:D,nextStart:void 0}},P.bufferedInfo=function(A,D,x){D=Math.max(0,D),A.sort(function(i,u){var g=i.start-u.start;return g||u.end-i.end});var _=[];if(x)for(var S=0;S<A.length;S++){var d=_.length;if(d){var E=_[d-1].end;A[S].start-E<x?A[S].end>E&&(_[d-1].end=A[S].end):_.push(A[S])}else _.push(A[S])}else _=A;for(var p=0,h,a=D,o=D,n=0;n<_.length;n++){var v=_[n].start,l=_[n].end;if(D+x>=v&&D<l)a=v,o=l,p=o-D;else if(D+x<v){h=v;break}}return{len:p,start:a||0,end:o||0,nextStart:h}},P.getBuffered=function(A){try{return A.buffered}catch(D){return C.logger.log("failed to get media.buffered",D),L}},P}()},"./src/utils/cea-608-parser.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{CaptionScreen:()=>n,Row:()=>o,default:()=>c});var C=T("./src/utils/logger.ts"),L={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},M=function(e){var r=e;return L.hasOwnProperty(e)&&(r=L[e]),String.fromCharCode(r)},P=15,B=100,A={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},D={17:2,18:4,21:6,22:8,23:10,19:13,20:15},x={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},_={25:2,26:4,29:6,30:8,31:10,27:13,28:15},S=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],d;(function(m){m[m.ERROR=0]="ERROR",m[m.TEXT=1]="TEXT",m[m.WARNING=2]="WARNING",m[m.INFO=2]="INFO",m[m.DEBUG=3]="DEBUG",m[m.DATA=3]="DATA"})(d||(d={}));var E=function(){function m(){this.time=null,this.verboseLevel=d.ERROR}var e=m.prototype;return e.log=function(t,s){if(this.verboseLevel>=t){var y=typeof s=="function"?s():s;C.logger.log(this.time+" ["+t+"] "+y)}},m}(),p=function(e){for(var r=[],t=0;t<e.length;t++)r.push(e[t].toString(16));return r},h=function(){function m(r,t,s,y,f){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=r||"white",this.underline=t||!1,this.italics=s||!1,this.background=y||"black",this.flash=f||!1}var e=m.prototype;return e.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},e.setStyles=function(t){for(var s=["foreground","underline","italics","background","flash"],y=0;y<s.length;y++){var f=s[y];t.hasOwnProperty(f)&&(this[f]=t[f])}},e.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},e.equals=function(t){return this.foreground===t.foreground&&this.underline===t.underline&&this.italics===t.italics&&this.background===t.background&&this.flash===t.flash},e.copy=function(t){this.foreground=t.foreground,this.underline=t.underline,this.italics=t.italics,this.background=t.background,this.flash=t.flash},e.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},m}(),a=function(){function m(r,t,s,y,f,b){this.uchar=void 0,this.penState=void 0,this.uchar=r||" ",this.penState=new h(t,s,y,f,b)}var e=m.prototype;return e.reset=function(){this.uchar=" ",this.penState.reset()},e.setChar=function(t,s){this.uchar=t,this.penState.copy(s)},e.setPenState=function(t){this.penState.copy(t)},e.equals=function(t){return this.uchar===t.uchar&&this.penState.equals(t.penState)},e.copy=function(t){this.uchar=t.uchar,this.penState.copy(t.penState)},e.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},m}(),o=function(){function m(r){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var t=0;t<B;t++)this.chars.push(new a);this.logger=r,this.pos=0,this.currPenState=new h}var e=m.prototype;return e.equals=function(t){for(var s=!0,y=0;y<B;y++)if(!this.chars[y].equals(t.chars[y])){s=!1;break}return s},e.copy=function(t){for(var s=0;s<B;s++)this.chars[s].copy(t.chars[s])},e.isEmpty=function(){for(var t=!0,s=0;s<B;s++)if(!this.chars[s].isEmpty()){t=!1;break}return t},e.setCursor=function(t){this.pos!==t&&(this.pos=t),this.pos<0?(this.logger.log(d.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>B&&(this.logger.log(d.DEBUG,"Too large cursor position "+this.pos),this.pos=B)},e.moveCursor=function(t){var s=this.pos+t;if(t>1)for(var y=this.pos+1;y<s+1;y++)this.chars[y].setPenState(this.currPenState);this.setCursor(s)},e.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},e.insertChar=function(t){var s=this;t>=144&&this.backSpace();var y=M(t);if(this.pos>=B){this.logger.log(d.ERROR,function(){return"Cannot insert "+t.toString(16)+" ("+y+") at position "+s.pos+". Skipping it!"});return}this.chars[this.pos].setChar(y,this.currPenState),this.moveCursor(1)},e.clearFromPos=function(t){var s;for(s=t;s<B;s++)this.chars[s].reset()},e.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},e.clearToEndOfRow=function(){this.clearFromPos(this.pos)},e.getTextString=function(){for(var t=[],s=!0,y=0;y<B;y++){var f=this.chars[y].uchar;f!==" "&&(s=!1),t.push(f)}return s?"":t.join("")},e.setPenStyles=function(t){this.currPenState.setStyles(t);var s=this.chars[this.pos];s.setPenState(this.currPenState)},m}(),n=function(){function m(r){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var t=0;t<P;t++)this.rows.push(new o(r));this.logger=r,this.currRow=P-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var e=m.prototype;return e.reset=function(){for(var t=0;t<P;t++)this.rows[t].clear();this.currRow=P-1},e.equals=function(t){for(var s=!0,y=0;y<P;y++)if(!this.rows[y].equals(t.rows[y])){s=!1;break}return s},e.copy=function(t){for(var s=0;s<P;s++)this.rows[s].copy(t.rows[s])},e.isEmpty=function(){for(var t=!0,s=0;s<P;s++)if(!this.rows[s].isEmpty()){t=!1;break}return t},e.backSpace=function(){var t=this.rows[this.currRow];t.backSpace()},e.clearToEndOfRow=function(){var t=this.rows[this.currRow];t.clearToEndOfRow()},e.insertChar=function(t){var s=this.rows[this.currRow];s.insertChar(t)},e.setPen=function(t){var s=this.rows[this.currRow];s.setPenStyles(t)},e.moveCursor=function(t){var s=this.rows[this.currRow];s.moveCursor(t)},e.setCursor=function(t){this.logger.log(d.INFO,"setCursor: "+t);var s=this.rows[this.currRow];s.setCursor(t)},e.setPAC=function(t){this.logger.log(d.INFO,function(){return"pacData = "+JSON.stringify(t)});var s=t.row-1;if(this.nrRollUpRows&&s<this.nrRollUpRows-1&&(s=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==s){for(var y=0;y<P;y++)this.rows[y].clear();var f=this.currRow+1-this.nrRollUpRows,b=this.lastOutputScreen;if(b){var R=b.rows[f].cueStartTime,I=this.logger.time;if(R&&I!==null&&R<I)for(var k=0;k<this.nrRollUpRows;k++)this.rows[s-this.nrRollUpRows+k+1].copy(b.rows[f+k])}}this.currRow=s;var F=this.rows[this.currRow];if(t.indent!==null){var K=t.indent,H=Math.max(K-1,0);F.setCursor(t.indent),t.color=F.chars[H].penState.foreground}var j={foreground:t.color,underline:t.underline,italics:t.italics,background:"black",flash:!1};this.setPen(j)},e.setBkgData=function(t){this.logger.log(d.INFO,function(){return"bkgData = "+JSON.stringify(t)}),this.backSpace(),this.setPen(t),this.insertChar(32)},e.setRollUpRows=function(t){this.nrRollUpRows=t},e.rollUp=function(){var t=this;if(this.nrRollUpRows===null){this.logger.log(d.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(d.TEXT,function(){return t.getDisplayText()});var s=this.currRow+1-this.nrRollUpRows,y=this.rows.splice(s,1)[0];y.clear(),this.rows.splice(this.currRow,0,y),this.logger.log(d.INFO,"Rolling up")},e.getDisplayText=function(t){t=t||!1;for(var s=[],y="",f=-1,b=0;b<P;b++){var R=this.rows[b].getTextString();R&&(f=b+1,t?s.push("Row "+f+": '"+R+"'"):s.push(R.trim()))}return s.length>0&&(t?y="["+s.join(" | ")+"]":y=s.join(`
22
22
  `)),y},e.getTextAndFormat=function(){return this.rows},m}(),v=function(){function m(r,t,s){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=r,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new n(s),this.nonDisplayedMemory=new n(s),this.lastOutputScreen=new n(s),this.currRollUpRow=this.displayedMemory.rows[P-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=s}var e=m.prototype;return e.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[P-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},e.getHandler=function(){return this.outputFilter},e.setHandler=function(t){this.outputFilter=t},e.setPAC=function(t){this.writeScreen.setPAC(t)},e.setBkgData=function(t){this.writeScreen.setBkgData(t)},e.setMode=function(t){t!==this.mode&&(this.mode=t,this.logger.log(d.INFO,function(){return"MODE="+t}),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=t)},e.insertChars=function(t){for(var s=this,y=0;y<t.length;y++)this.writeScreen.insertChar(t[y]);var f=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(d.INFO,function(){return f+": "+s.writeScreen.getDisplayText(!0)}),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(d.TEXT,function(){return"DISPLAYED: "+s.displayedMemory.getDisplayText(!0)}),this.outputDataUpdate())},e.ccRCL=function(){this.logger.log(d.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},e.ccBS=function(){this.logger.log(d.INFO,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},e.ccAOF=function(){},e.ccAON=function(){},e.ccDER=function(){this.logger.log(d.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},e.ccRU=function(t){this.logger.log(d.INFO,"RU("+t+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(t)},e.ccFON=function(){this.logger.log(d.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},e.ccRDC=function(){this.logger.log(d.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},e.ccTR=function(){this.logger.log(d.INFO,"TR"),this.setMode("MODE_TEXT")},e.ccRTD=function(){this.logger.log(d.INFO,"RTD"),this.setMode("MODE_TEXT")},e.ccEDM=function(){this.logger.log(d.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},e.ccCR=function(){this.logger.log(d.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},e.ccENM=function(){this.logger.log(d.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},e.ccEOC=function(){var t=this;if(this.logger.log(d.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var s=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=s,this.writeScreen=this.nonDisplayedMemory,this.logger.log(d.TEXT,function(){return"DISP: "+t.displayedMemory.getDisplayText()})}this.outputDataUpdate(!0)},e.ccTO=function(t){this.logger.log(d.INFO,"TO("+t+") - Tab Offset"),this.writeScreen.moveCursor(t)},e.ccMIDROW=function(t){var s={flash:!1};if(s.underline=t%2===1,s.italics=t>=46,s.italics)s.foreground="white";else{var y=Math.floor(t/2)-16,f=["white","green","blue","cyan","red","yellow","magenta"];s.foreground=f[y]}this.logger.log(d.INFO,"MIDROW: "+JSON.stringify(s)),this.writeScreen.setPen(s)},e.outputDataUpdate=function(t){t===void 0&&(t=!1);var s=this.logger.time;s!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=s:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,s,this.lastOutputScreen),t&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:s),this.lastOutputScreen.copy(this.displayedMemory))},e.cueSplitAtTime=function(t){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,t,this.displayedMemory),this.cueStartTime=t))},m}(),l=function(){function m(r,t,s){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var y=new E;this.channels=[null,new v(r,t,y),new v(r+1,s,y)],this.cmdHistory=g(),this.logger=y}var e=m.prototype;return e.getHandler=function(t){return this.channels[t].getHandler()},e.setHandler=function(t,s){this.channels[t].setHandler(s)},e.addData=function(t,s){var y,f,b,R=!1;this.logger.time=t;for(var I=0;I<s.length;I+=2)if(f=s[I]&127,b=s[I+1]&127,!(f===0&&b===0)){if(this.logger.log(d.DATA,"["+p([s[I],s[I+1]])+"] -> ("+p([f,b])+")"),y=this.parseCmd(f,b),y||(y=this.parseMidrow(f,b)),y||(y=this.parsePAC(f,b)),y||(y=this.parseBackgroundAttributes(f,b)),!y&&(R=this.parseChars(f,b),R)){var k=this.currentChannel;if(k&&k>0){var F=this.channels[k];F.insertChars(R)}else this.logger.log(d.WARNING,"No channel found yet. TEXT-MODE?")}!y&&!R&&this.logger.log(d.WARNING,"Couldn't parse cleaned data "+p([f,b])+" orig: "+p([s[I],s[I+1]]))}},e.parseCmd=function(t,s){var y=this.cmdHistory,f=(t===20||t===28||t===21||t===29)&&s>=32&&s<=47,b=(t===23||t===31)&&s>=33&&s<=35;if(!(f||b))return!1;if(u(t,s,y))return i(null,null,y),this.logger.log(d.DEBUG,"Repeated command ("+p([t,s])+") is dropped"),!0;var R=t===20||t===21||t===23?1:2,I=this.channels[R];return t===20||t===21||t===28||t===29?s===32?I.ccRCL():s===33?I.ccBS():s===34?I.ccAOF():s===35?I.ccAON():s===36?I.ccDER():s===37?I.ccRU(2):s===38?I.ccRU(3):s===39?I.ccRU(4):s===40?I.ccFON():s===41?I.ccRDC():s===42?I.ccTR():s===43?I.ccRTD():s===44?I.ccEDM():s===45?I.ccCR():s===46?I.ccENM():s===47&&I.ccEOC():I.ccTO(s-32),i(t,s,y),this.currentChannel=R,!0},e.parseMidrow=function(t,s){var y=0;if((t===17||t===25)&&s>=32&&s<=47){if(t===17?y=1:y=2,y!==this.currentChannel)return this.logger.log(d.ERROR,"Mismatch channel in midrow parsing"),!1;var f=this.channels[y];return f?(f.ccMIDROW(s),this.logger.log(d.DEBUG,"MIDROW ("+p([t,s])+")"),!0):!1}return!1},e.parsePAC=function(t,s){var y,f=this.cmdHistory,b=(t>=17&&t<=23||t>=25&&t<=31)&&s>=64&&s<=127,R=(t===16||t===24)&&s>=64&&s<=95;if(!(b||R))return!1;if(u(t,s,f))return i(null,null,f),!0;var I=t<=23?1:2;s>=64&&s<=95?y=I===1?A[t]:x[t]:y=I===1?D[t]:_[t];var k=this.channels[I];return k?(k.setPAC(this.interpretPAC(y,s)),i(t,s,f),this.currentChannel=I,!0):!1},e.interpretPAC=function(t,s){var y,f={color:null,italics:!1,indent:null,underline:!1,row:t};return s>95?y=s-96:y=s-64,f.underline=(y&1)===1,y<=13?f.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(y/2)]:y<=15?(f.italics=!0,f.color="white"):f.indent=Math.floor((y-16)/2)*4,f},e.parseChars=function(t,s){var y,f=null,b=null;if(t>=25?(y=2,b=t-8):(y=1,b=t),b>=17&&b<=19){var R;b===17?R=s+80:b===18?R=s+112:R=s+144,this.logger.log(d.INFO,"Special char '"+M(R)+"' in channel "+y),f=[R]}else t>=32&&t<=127&&(f=s===0?[t]:[t,s]);if(f){var I=p(f);this.logger.log(d.DEBUG,"Char codes = "+I.join(",")),i(t,s,this.cmdHistory)}return f},e.parseBackgroundAttributes=function(t,s){var y=(t===16||t===24)&&s>=32&&s<=47,f=(t===23||t===31)&&s>=45&&s<=47;if(!(y||f))return!1;var b,R={};t===16||t===24?(b=Math.floor((s-32)/2),R.background=S[b],s%2===1&&(R.background=R.background+"_semi")):s===45?R.background="transparent":(R.foreground="black",s===47&&(R.underline=!0));var I=t<=23?1:2,k=this.channels[I];return k.setBkgData(R),i(t,s,this.cmdHistory),!0},e.reset=function(){for(var t=0;t<Object.keys(this.channels).length;t++){var s=this.channels[t];s&&s.reset()}this.cmdHistory=g()},e.cueSplitAtTime=function(t){for(var s=0;s<this.channels.length;s++){var y=this.channels[s];y&&y.cueSplitAtTime(t)}},m}();function i(m,e,r){r.a=m,r.b=e}function u(m,e,r){return r.a===m&&r.b===e}function g(){return{a:null,b:null}}let c=l},"./src/utils/codecs.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{isCodecSupportedInMp4:()=>M,isCodecType:()=>L});var C={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dva1:!0,dvav:!0,dvh1:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}};function L(P,B){var A=C[B];return!!A&&A[P.slice(0,4)]===!0}function M(P,B){return MediaSource.isTypeSupported((B||"video")+'/mp4;codecs="'+P+'"')}},"./src/utils/cues.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>A});var C=T("./src/utils/vttparser.ts"),L=T("./src/utils/webvtt-parser.ts"),M=T("./src/utils/texttrack-utils.ts"),P=/\s/,B={newCue:function(x,_,S,d){for(var E=[],p,h,a,o,n,v=self.VTTCue||self.TextTrackCue,l=0;l<d.rows.length;l++)if(p=d.rows[l],a=!0,o=0,n="",!p.isEmpty()){for(var i=0;i<p.chars.length;i++)P.test(p.chars[i].uchar)&&a?o++:(n+=p.chars[i].uchar,a=!1);p.cueStartTime=_,_===S&&(S+=1e-4),o>=16?o--:o++;var u=(0,C.fixLineBreaks)(n.trim()),g=(0,L.generateCueId)(_,S,u);(!x||!x.cues||!x.cues.getCueById(g))&&(h=new v(_,S,u),h.id=g,h.line=l+1,h.align="left",h.position=10+Math.min(80,Math.floor(o*8/32)*10),E.push(h))}return x&&E.length&&(E.sort(function(c,m){return c.line==="auto"||m.line==="auto"?0:c.line>8&&m.line>8?m.line-c.line:c.line-m.line}),E.forEach(function(c){return(0,M.addCueToTrack)(x,c)})),E}};let A=B},"./src/utils/discontinuities.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{adjustSlidingStart:()=>x,alignMediaPlaylistByPDT:()=>E,alignPDT:()=>d,alignStream:()=>_,findDiscontinuousReferenceFrag:()=>A,findFirstFragWithCC:()=>P,shouldAlignOnDiscontinuities:()=>B});var C=T("./src/polyfills/number.ts"),L=T("./src/utils/logger.ts"),M=T("./src/controller/level-helper.ts");function P(p,h){for(var a=null,o=0,n=p.length;o<n;o++){var v=p[o];if(v&&v.cc===h){a=v;break}}return a}function B(p,h,a){return!!(h.details&&(a.endCC>a.startCC||p&&p.cc<a.startCC))}function A(p,h,a){a===void 0&&(a=0);var o=p.fragments,n=h.fragments;if(!n.length||!o.length){L.logger.log("No fragments to align");return}var v=P(o,n[0].cc);if(!v||v&&!v.startPTS){L.logger.log("No frag in previous level to align on");return}return v}function D(p,h){if(p){var a=p.start+h;p.start=p.startPTS=a,p.endPTS=a+p.duration}}function x(p,h){for(var a=h.fragments,o=0,n=a.length;o<n;o++)D(a[o],p);h.fragmentHint&&D(h.fragmentHint,p),h.alignedSliding=!0}function _(p,h,a){!h||(S(p,a,h),!a.alignedSliding&&h.details&&d(a,h.details),!a.alignedSliding&&h.details&&!a.skippedSegments&&(0,M.adjustSliding)(h.details,a))}function S(p,h,a){if(B(p,a,h)){var o=A(a.details,h);o&&(0,C.isFiniteNumber)(o.start)&&(L.logger.log("Adjusting PTS using last level due to CC increase within current level "+h.url),x(o.start,h))}}function d(p,h){if(!(!h.fragments.length||!p.hasProgramDateTime||!h.hasProgramDateTime)){var a=h.fragments[0].programDateTime,o=p.fragments[0].programDateTime,n=(o-a)/1e3+h.fragments[0].start;n&&(0,C.isFiniteNumber)(n)&&(L.logger.log("Adjusting PTS using programDateTime delta "+(o-a)+"ms, sliding:"+n.toFixed(3)+" "+p.url+" "),x(n,p))}}function E(p,h){if(!(!p.hasProgramDateTime||!h.hasProgramDateTime)){var a=p.fragments,o=h.fragments;if(!(!a.length||!o.length)){var n=Math.round(o.length/2)-1,v=o[n],l=P(a,v.cc)||a[Math.round(a.length/2)-1],i=v.programDateTime,u=l.programDateTime;if(!(i===null||u===null)){var g=(u-i)/1e3-(l.start-v.start);x(g,p)}}}}},"./src/utils/ewma-bandwidth-estimator.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>M});var C=T("./src/utils/ewma.ts"),L=function(){function P(A,D,x){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=x,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new C.default(A),this.fast_=new C.default(D)}var B=P.prototype;return B.update=function(D,x){var _=this.slow_,S=this.fast_;this.slow_.halfLife!==D&&(this.slow_=new C.default(D,_.getEstimate(),_.getTotalWeight())),this.fast_.halfLife!==x&&(this.fast_=new C.default(x,S.getEstimate(),S.getTotalWeight()))},B.sample=function(D,x){D=Math.max(D,this.minDelayMs_);var _=8*x,S=D/1e3,d=_/S;this.fast_.sample(S,d),this.slow_.sample(S,d)},B.canEstimate=function(){var D=this.fast_;return D&&D.getTotalWeight()>=this.minWeight_},B.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},B.destroy=function(){},P}();let M=L},"./src/utils/ewma.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>L});var C=function(){function M(B,A,D){A===void 0&&(A=0),D===void 0&&(D=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=B,this.alpha_=B?Math.exp(Math.log(.5)/B):0,this.estimate_=A,this.totalWeight_=D}var P=M.prototype;return P.sample=function(A,D){var x=Math.pow(this.alpha_,A);this.estimate_=D*(1-x)+x*this.estimate_,this.totalWeight_+=A},P.getTotalWeight=function(){return this.totalWeight_},P.getEstimate=function(){if(this.alpha_){var A=1-Math.pow(this.alpha_,this.totalWeight_);if(A)return this.estimate_/A}return this.estimate_},M}();let L=C},"./src/utils/fetch-loader.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>n,fetchSupported:()=>E});var C=T("./src/polyfills/number.ts"),L=T("./src/loader/load-stats.ts"),M=T("./src/demux/chunk-cache.ts");function P(v,l){v.prototype=Object.create(l.prototype),v.prototype.constructor=v,_(v,l)}function B(v){var l=typeof Map=="function"?new Map:void 0;return B=function(u){if(u===null||!x(u))return u;if(typeof u!="function")throw new TypeError("Super expression must either be null or a function");if(typeof l!="undefined"){if(l.has(u))return l.get(u);l.set(u,g)}function g(){return A(u,arguments,S(this).constructor)}return g.prototype=Object.create(u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),_(g,u)},B(v)}function A(v,l,i){return D()?A=Reflect.construct.bind():A=function(g,c,m){var e=[null];e.push.apply(e,c);var r=Function.bind.apply(g,e),t=new r;return m&&_(t,m.prototype),t},A.apply(null,arguments)}function D(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function x(v){return Function.toString.call(v).indexOf("[native code]")!==-1}function _(v,l){return _=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(u,g){return u.__proto__=g,u},_(v,l)}function S(v){return S=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},S(v)}function d(){return d=Object.assign?Object.assign.bind():function(v){for(var l=1;l<arguments.length;l++){var i=arguments[l];for(var u in i)Object.prototype.hasOwnProperty.call(i,u)&&(v[u]=i[u])}return v},d.apply(this,arguments)}function E(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var p=function(){function v(i){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=i.fetchSetup||a,this.controller=new self.AbortController,this.stats=new L.LoadStats}var l=v.prototype;return l.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},l.abortInternal=function(){var u=this.response;(!u||!u.ok)&&(this.stats.aborted=!0,this.controller.abort())},l.abort=function(){var u;this.abortInternal(),(u=this.callbacks)!==null&&u!==void 0&&u.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},l.load=function(u,g,c){var m=this,e=this.stats;if(e.loading.start)throw new Error("Loader can only be used once.");e.loading.start=self.performance.now();var r=h(u,this.controller.signal),t=c.onProgress,s=u.responseType==="arraybuffer",y=s?"byteLength":"length";this.context=u,this.config=g,this.callbacks=c,this.request=this.fetchSetup(u,r),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){m.abortInternal(),c.onTimeout(e,u,m.response)},g.timeout),self.fetch(this.request).then(function(f){if(m.response=m.loader=f,!f.ok){var b=f.status,R=f.statusText;throw new o(R||"fetch, bad network response",b,f)}return e.loading.first=Math.max(self.performance.now(),e.loading.start),e.total=parseInt(f.headers.get("Content-Length")||"0"),t&&(0,C.isFiniteNumber)(g.highWaterMark)?m.loadProgressively(f,e,u,g.highWaterMark,t):s?f.arrayBuffer():f.text()}).then(function(f){var b=m.response;self.clearTimeout(m.requestTimeout),e.loading.end=Math.max(self.performance.now(),e.loading.first);var R=f[y];R&&(e.loaded=e.total=R);var I={url:b.url,data:f};t&&!(0,C.isFiniteNumber)(g.highWaterMark)&&t(e,u,f,b),c.onSuccess(I,e,u,b)}).catch(function(f){if(self.clearTimeout(m.requestTimeout),!e.aborted){var b=f&&f.code||0,R=f?f.message:null;c.onError({code:b,text:R},u,f?f.details:null)}})},l.getCacheAge=function(){var u=null;if(this.response){var g=this.response.headers.get("age");u=g?parseFloat(g):null}return u},l.loadProgressively=function(u,g,c,m,e){m===void 0&&(m=0);var r=new M.default,t=u.body.getReader(),s=function y(){return t.read().then(function(f){if(f.done)return r.dataLength&&e(g,c,r.flush(),u),Promise.resolve(new ArrayBuffer(0));var b=f.value,R=b.length;return g.loaded+=R,R<m||r.dataLength?(r.push(b),r.dataLength>=m&&e(g,c,r.flush(),u)):e(g,c,b,u),y()}).catch(function(){return Promise.reject()})};return s()},v}();function h(v,l){var i={method:"GET",mode:"cors",credentials:"same-origin",signal:l,headers:new self.Headers(d({},v.headers))};return v.rangeEnd&&i.headers.set("Range","bytes="+v.rangeStart+"-"+String(v.rangeEnd-1)),i}function a(v,l){return new self.Request(v.url,l)}var o=function(v){P(l,v);function l(i,u,g){var c;return c=v.call(this,i)||this,c.code=void 0,c.details=void 0,c.code=u,c.details=g,c}return l}(B(Error));let n=p},"./src/utils/hex.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>L});var C={hexDump:function(P){for(var B="",A=0;A<P.length;A++){var D=P[A].toString(16);D.length<2&&(D="0"+D),B+=D}return B}};let L=C},"./src/utils/imsc1-ttml-parser.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{IMSC1_CODEC:()=>x,parseIMSC1:()=>E});var C=T("./src/utils/mp4-tools.ts"),L=T("./src/utils/vttparser.ts"),M=T("./src/utils/vttcue.ts"),P=T("./src/demux/id3.ts"),B=T("./src/utils/timescale-conversion.ts"),A=T("./src/utils/webvtt-parser.ts");function D(){return D=Object.assign?Object.assign.bind():function(c){for(var m=1;m<arguments.length;m++){var e=arguments[m];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(c[r]=e[r])}return c},D.apply(this,arguments)}var x="stpp.ttml.im1t",_=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,S=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,d={left:"start",center:"center",right:"end",start:"start",end:"end"};function E(c,m,e,r,t){var s=(0,C.findBox)(new Uint8Array(c),["mdat"]);if(s.length===0){t(new Error("Could not parse IMSC1 mdat"));return}var y=s.map(function(b){return(0,P.utf8ArrayToStr)(b)}),f=(0,B.toTimescaleFromScale)(m,1,e);try{y.forEach(function(b){return r(p(b,f))})}catch(b){t(b)}}function p(c,m){var e=new DOMParser,r=e.parseFromString(c,"text/xml"),t=r.getElementsByTagName("tt")[0];if(!t)throw new Error("Invalid ttml");var s={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},y=Object.keys(s).reduce(function(k,F){return k[F]=t.getAttribute("ttp:"+F)||s[F],k},{}),f=t.getAttribute("xml:space")!=="preserve",b=a(h(t,"styling","style")),R=a(h(t,"layout","region")),I=h(t,"body","[begin]");return[].map.call(I,function(k){var F=o(k,f);if(!F||!k.hasAttribute("begin"))return null;var K=i(k.getAttribute("begin"),y),H=i(k.getAttribute("dur"),y),j=i(k.getAttribute("end"),y);if(K===null)throw l(k);if(j===null){if(H===null)throw l(k);j=K+H}var Y=new M.default(K-m,j-m,F);Y.id=(0,A.generateCueId)(Y.startTime,Y.endTime,Y.text);var Q=R[k.getAttribute("region")],q=b[k.getAttribute("style")],ne=n(Q,q,b),te=ne.textAlign;if(te){var ae=d[te];ae&&(Y.lineAlign=ae),Y.align=te}return D(Y,ne),Y}).filter(function(k){return k!==null})}function h(c,m,e){var r=c.getElementsByTagName(m)[0];return r?[].slice.call(r.querySelectorAll(e)):[]}function a(c){return c.reduce(function(m,e){var r=e.getAttribute("xml:id");return r&&(m[r]=e),m},{})}function o(c,m){return[].slice.call(c.childNodes).reduce(function(e,r,t){var s;return r.nodeName==="br"&&t?e+`
23
23
  `:(s=r.childNodes)!==null&&s!==void 0&&s.length?o(r,m):m?e+r.textContent.trim().replace(/\s+/g," "):e+r.textContent},"")}function n(c,m,e){var r="http://www.w3.org/ns/ttml#styling",t=null,s=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],y=c!=null&&c.hasAttribute("style")?c.getAttribute("style"):null;return y&&e.hasOwnProperty(y)&&(t=e[y]),s.reduce(function(f,b){var R=v(m,r,b)||v(c,r,b)||v(t,r,b);return R&&(f[b]=R),f},{})}function v(c,m,e){return c&&c.hasAttributeNS(m,e)?c.getAttributeNS(m,e):null}function l(c){return new Error("Could not parse ttml timestamp "+c)}function i(c,m){if(!c)return null;var e=(0,L.parseTimeStamp)(c);return e===null&&(_.test(c)?e=u(c,m):S.test(c)&&(e=g(c,m))),e}function u(c,m){var e=_.exec(c),r=(e[4]|0)+(e[5]|0)/m.subFrameRate;return(e[1]|0)*3600+(e[2]|0)*60+(e[3]|0)+r/m.frameRate}function g(c,m){var e=S.exec(c),r=Number(e[1]),t=e[2];switch(t){case"h":return r*3600;case"m":return r*60;case"ms":return r*1e3;case"f":return r/m.frameRate;case"t":return r/m.tickRate}return r}},"./src/utils/keysystem-util.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{changeEndianness:()=>M,convertDataUriToArrayBytes:()=>P,strToUtf8array:()=>B});var C=T("./src/utils/numeric-encoding-utils.ts");function L(A){var D=B(A).subarray(0,16),x=new Uint8Array(16);return x.set(D,16-D.length),x}function M(A){var D=function(_,S,d){var E=_[S];_[S]=_[d],_[d]=E};D(A,0,3),D(A,1,2),D(A,4,5),D(A,6,7)}function P(A){var D=A.split(":"),x=null;if(D[0]==="data"&&D.length===2){var _=D[1].split(";"),S=_[_.length-1].split(",");if(S.length===2){var d=S[0]==="base64",E=S[1];d?(_.splice(-1,1),x=(0,C.base64Decode)(E)):x=L(E)}}return x}function B(A){return Uint8Array.from(unescape(encodeURIComponent(A)),function(D){return D.charCodeAt(0)})}},"./src/utils/logger.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{enableLogs:()=>A,logger:()=>D});var C=function(){},L={trace:C,debug:C,log:C,warn:C,info:C,error:C},M=L;function P(x){var _=self.console[x];return _?_.bind(self.console,"["+x+"] >"):C}function B(x){for(var _=arguments.length,S=new Array(_>1?_-1:0),d=1;d<_;d++)S[d-1]=arguments[d];S.forEach(function(E){M[E]=x[E]?x[E].bind(x):P(E)})}function A(x,_){if(self.console&&x===!0||typeof x=="object"){B(x,"debug","log","info","warn","error");try{M.log('Debug logs enabled for "'+_+'"')}catch{M=L}}else M=L}var D=M},"./src/utils/mediakeys-helper.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{KeySystemFormats:()=>L,KeySystemIds:()=>P,KeySystems:()=>C,getKeySystemsForConfig:()=>D,getSupportedMediaKeySystemConfigurations:()=>_,keySystemDomainToKeySystemFormat:()=>A,keySystemFormatToKeySystemDomain:()=>M,keySystemIdToKeySystemDomain:()=>B,requestMediaKeySystemAccess:()=>x});var C;(function(d){d.CLEARKEY="org.w3.clearkey",d.FAIRPLAY="com.apple.fps",d.PLAYREADY="com.microsoft.playready",d.WIDEVINE="com.widevine.alpha"})(C||(C={}));var L;(function(d){d.CLEARKEY="org.w3.clearkey",d.FAIRPLAY="com.apple.streamingkeydelivery",d.PLAYREADY="com.microsoft.playready",d.WIDEVINE="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"})(L||(L={}));function M(d){switch(d){case L.FAIRPLAY:return C.FAIRPLAY;case L.PLAYREADY:return C.PLAYREADY;case L.WIDEVINE:return C.WIDEVINE;case L.CLEARKEY:return C.CLEARKEY}}var P;(function(d){d.WIDEVINE="edef8ba979d64acea3c827dcd51d21ed"})(P||(P={}));function B(d){if(d===P.WIDEVINE)return C.WIDEVINE}function A(d){switch(d){case C.FAIRPLAY:return L.FAIRPLAY;case C.PLAYREADY:return L.PLAYREADY;case C.WIDEVINE:return L.WIDEVINE;case C.CLEARKEY:return L.CLEARKEY}}function D(d){var E=d.drmSystems,p=d.widevineLicenseUrl,h=E?[C.FAIRPLAY,C.WIDEVINE,C.PLAYREADY,C.CLEARKEY].filter(function(a){return!!E[a]}):[];return!h[C.WIDEVINE]&&p&&h.push(C.WIDEVINE),h}var x=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function _(d,E,p,h){var a;switch(d){case C.FAIRPLAY:a=["cenc","sinf"];break;case C.WIDEVINE:case C.PLAYREADY:a=["cenc"];break;case C.CLEARKEY:a=["cenc","keyids"];break;default:throw new Error("Unknown key-system: "+d)}return S(a,E,p,h)}function S(d,E,p,h){var a={initDataTypes:d,persistentState:h.persistentState||"not-allowed",distinctiveIdentifier:h.distinctiveIdentifier||"not-allowed",sessionTypes:h.sessionTypes||[h.sessionType||"temporary"],audioCapabilities:E.map(function(o){return{contentType:'audio/mp4; codecs="'+o+'"',robustness:h.audioRobustness||"",encryptionScheme:h.audioEncryptionScheme||null}}),videoCapabilities:p.map(function(o){return{contentType:'video/mp4; codecs="'+o+'"',robustness:h.videoRobustness||"",encryptionScheme:h.videoEncryptionScheme||null}})};return[a]}},"./src/utils/mediasource-helper.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{getMediaSource:()=>C});function C(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{RemuxerTrackIdConfig:()=>x,appendUint8Array:()=>m,bin2str:()=>_,computeRawDurationFromSamples:()=>u,discardEPB:()=>y,findBox:()=>h,getDuration:()=>i,getStartDTS:()=>l,mp4Box:()=>b,mp4pssh:()=>R,offsetStartDTS:()=>g,parseEmsg:()=>f,parseInitSegment:()=>o,parsePssh:()=>I,parseSEIMessageFromNALu:()=>s,parseSamples:()=>e,parseSegmentIndex:()=>a,parseSinf:()=>v,patchEncyptionData:()=>n,readSint32:()=>E,readUint16:()=>S,readUint32:()=>d,segmentValidRange:()=>c,writeUint32:()=>p});var C=T("./src/loader/fragment.ts"),L=T("./src/utils/typed-array.ts"),M=T("./src/demux/id3.ts"),P=T("./src/utils/logger.ts"),B=T("./src/utils/hex.ts"),A=Math.pow(2,32)-1,D=[].push,x={video:1,audio:2,id3:3,text:4};function _(k){return String.fromCharCode.apply(null,k)}function S(k,F){var K=k[F]<<8|k[F+1];return K<0?65536+K:K}function d(k,F){var K=E(k,F);return K<0?4294967296+K:K}function E(k,F){return k[F]<<24|k[F+1]<<16|k[F+2]<<8|k[F+3]}function p(k,F,K){k[F]=K>>24,k[F+1]=K>>16&255,k[F+2]=K>>8&255,k[F+3]=K&255}function h(k,F){var K=[];if(!F.length)return K;for(var H=k.byteLength,j=0;j<H;){var Y=d(k,j),Q=_(k.subarray(j+4,j+8)),q=Y>1?j+Y:H;if(Q===F[0])if(F.length===1)K.push(k.subarray(j+8,q));else{var ne=h(k.subarray(j+8,q),F.slice(1));ne.length&&D.apply(K,ne)}j=q}return K}function a(k){var F=[],K=k[0],H=8,j=d(k,H);H+=4;var Y=0,Q=0;K===0?H+=8:H+=16,H+=2;var q=k.length+Q,ne=S(k,H);H+=2;for(var te=0;te<ne;te++){var ae=H,ue=d(k,ae);ae+=4;var ce=ue&2147483647,le=(ue&2147483648)>>>31;if(le===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var fe=d(k,ae);ae+=4,F.push({referenceSize:ce,subsegmentDuration:fe,info:{duration:fe/j,start:q,end:q+ce-1}}),q+=ce,ae+=4,H=ae}return{earliestPresentationTime:Y,timescale:j,version:K,referencesCount:ne,references:F}}function o(k){for(var F=[],K=h(k,["moov","trak"]),H=0;H<K.length;H++){var j=K[H],Y=h(j,["tkhd"])[0];if(Y){var Q=Y[0],q=Q===0?12:20,ne=d(Y,q),te=h(j,["mdia","mdhd"])[0];if(te){Q=te[0],q=Q===0?12:20;var ae=d(te,q),ue=h(j,["mdia","hdlr"])[0];if(ue){var ce=_(ue.subarray(8,12)),le={soun:C.ElementaryStreamTypes.AUDIO,vide:C.ElementaryStreamTypes.VIDEO}[ce];if(le){var fe=h(j,["mdia","minf","stbl","stsd"])[0],de=void 0;fe&&(de=_(fe.subarray(12,16))),F[ne]={timescale:ae,type:le},F[le]={timescale:ae,id:ne,codec:de}}}}}}var xe=h(k,["moov","mvex","trex"]);return xe.forEach(function(Ae){var Ie=d(Ae,4),Re=F[Ie];Re&&(Re.default={duration:d(Ae,12),flags:d(Ae,20)})}),F}function n(k,F){if(!k||!F)return k;var K=F.keyId;if(K&&F.isCommonEncryption){var H=h(k,["moov","trak"]);H.forEach(function(j){var Y=h(j,["mdia","minf","stbl","stsd"])[0],Q=Y.subarray(8),q=h(Q,["enca"]),ne=q.length>0;ne||(q=h(Q,["encv"])),q.forEach(function(te){var ae=ne?te.subarray(28):te.subarray(78),ue=h(ae,["sinf"]);ue.forEach(function(ce){var le=v(ce);if(le){var fe=le.subarray(8,24);fe.some(function(de){return de!==0})||(P.logger.log("[eme] Patching keyId in 'enc"+(ne?"a":"v")+">sinf>>tenc' box: "+B.default.hexDump(fe)+" -> "+B.default.hexDump(K)),le.set(K,8))}})})})}return k}function v(k){var F=h(k,["schm"])[0];if(F){var K=_(F.subarray(4,8));if(K==="cbcs"||K==="cenc")return h(k,["schi","tenc"])[0]}return P.logger.error("[eme] missing 'schm' box"),null}function l(k,F){return h(F,["moof","traf"]).reduce(function(K,H){var j=h(H,["tfdt"])[0],Y=j[0],Q=h(H,["tfhd"]).reduce(function(q,ne){var te=d(ne,4),ae=k[te];if(ae){var ue=d(j,4);Y===1&&(ue*=Math.pow(2,32),ue+=d(j,8));var ce=ae.timescale||9e4,le=ue/ce;if(isFinite(le)&&(q===null||le<q))return le}return q},null);return Q!==null&&isFinite(Q)&&(K===null||Q<K)?Q:K},null)||0}function i(k,F){for(var K=0,H=0,j=0,Y=h(k,["moof","traf"]),Q=0;Q<Y.length;Q++){var q=Y[Q],ne=h(q,["tfhd"])[0],te=d(ne,4),ae=F[te];if(!!ae){var ue=ae.default,ce=d(ne,0)|(ue==null?void 0:ue.flags),le=ue==null?void 0:ue.duration;ce&8&&(ce&2?le=d(ne,12):le=d(ne,8));for(var fe=ae.timescale||9e4,de=h(q,["trun"]),xe=0;xe<de.length;xe++){if(K=u(de[xe]),!K&&le){var Ae=d(de[xe],4);K=le*Ae}ae.type===C.ElementaryStreamTypes.VIDEO?H+=K/fe:ae.type===C.ElementaryStreamTypes.AUDIO&&(j+=K/fe)}}}if(H===0&&j===0){for(var Ie=0,Re=h(k,["sidx"]),Oe=0;Oe<Re.length;Oe++){var Pe=a(Re[Oe]);Pe!=null&&Pe.references&&(Ie+=Pe.references.reduce(function(Ce,Le){return Ce+Le.info.duration||0},0))}return Ie}return H||j}function u(k){var F=d(k,0),K=8;F&1&&(K+=4),F&4&&(K+=4);for(var H=0,j=d(k,4),Y=0;Y<j;Y++){if(F&256){var Q=d(k,K);H+=Q,K+=4}F&512&&(K+=4),F&1024&&(K+=4),F&2048&&(K+=4)}return H}function g(k,F,K){h(F,["moof","traf"]).forEach(function(H){h(H,["tfhd"]).forEach(function(j){var Y=d(j,4),Q=k[Y];if(!!Q){var q=Q.timescale||9e4;h(H,["tfdt"]).forEach(function(ne){var te=ne[0],ae=d(ne,4);if(te===0)ae-=K*q,ae=Math.max(ae,0),p(ne,4,ae);else{ae*=Math.pow(2,32),ae+=d(ne,8),ae-=K*q,ae=Math.max(ae,0);var ue=Math.floor(ae/(A+1)),ce=Math.floor(ae%(A+1));p(ne,4,ue),p(ne,8,ce)}})}})})}function c(k){var F={valid:null,remainder:null},K=h(k,["moof"]);if(K){if(K.length<2)return F.remainder=k,F}else return F;var H=K[K.length-1];return F.valid=(0,L.sliceUint8)(k,0,H.byteOffset-8),F.remainder=(0,L.sliceUint8)(k,H.byteOffset-8),F}function m(k,F){var K=new Uint8Array(k.length+F.length);return K.set(k),K.set(F,k.length),K}function e(k,F){var K=[],H=F.samples,j=F.timescale,Y=F.id,Q=!1,q=h(H,["moof"]);return q.map(function(ne){var te=ne.byteOffset-8,ae=h(ne,["traf"]);ae.map(function(ue){var ce=h(ue,["tfdt"]).map(function(le){var fe=le[0],de=d(le,4);return fe===1&&(de*=Math.pow(2,32),de+=d(le,8)),de/j})[0];return ce!==void 0&&(k=ce),h(ue,["tfhd"]).map(function(le){var fe=d(le,4),de=d(le,0)&16777215,xe=(de&1)!==0,Ae=(de&2)!==0,Ie=(de&8)!==0,Re=0,Oe=(de&16)!==0,Pe=0,Ce=(de&32)!==0,Le=8;fe===Y&&(xe&&(Le+=8),Ae&&(Le+=4),Ie&&(Re=d(le,Le),Le+=4),Oe&&(Pe=d(le,Le),Le+=4),Ce&&(Le+=4),F.type==="video"&&(Q=r(F.codec)),h(ue,["trun"]).map(function(ke){var Be=ke[0],we=d(ke,0)&16777215,Ye=(we&1)!==0,Xe=0,rt=(we&4)!==0,ze=(we&256)!==0,it=0,nt=(we&512)!==0,Je=0,Ne=(we&1024)!==0,Ke=(we&2048)!==0,Ze=0,ft=d(ke,4),Me=8;Ye&&(Xe=d(ke,Me),Me+=4),rt&&(Me+=4);for(var qe=Xe+te,et=0;et<ft;et++){if(ze?(it=d(ke,Me),Me+=4):it=Re,nt?(Je=d(ke,Me),Me+=4):Je=Pe,Ne&&(Me+=4),Ke&&(Be===0?Ze=d(ke,Me):Ze=E(ke,Me),Me+=4),F.type===C.ElementaryStreamTypes.VIDEO)for(var _t=0;_t<Je;){var mt=d(H,qe);if(qe+=4,t(Q,H[qe])){var pt=H.subarray(qe,qe+mt);s(pt,Q?2:1,k+Ze/j,K)}qe+=mt,_t+=mt+4}k+=it/j}}))})})}),K}function r(k){if(!k)return!1;var F=k.indexOf("."),K=F<0?k:k.substring(0,F);return K==="hvc1"||K==="hev1"||K==="dvh1"||K==="dvhe"}function t(k,F){if(k){var K=F>>1&63;return K===39||K===40}else{var H=F&31;return H===6}}function s(k,F,K,H){var j=y(k),Y=0;Y+=F;for(var Q=0,q=0,ne=!1,te=0;Y<j.length;){Q=0;do{if(Y>=j.length)break;te=j[Y++],Q+=te}while(te===255);q=0;do{if(Y>=j.length)break;te=j[Y++],q+=te}while(te===255);var ae=j.length-Y;if(!ne&&Q===4&&Y<j.length){ne=!0;var ue=j[Y++];if(ue===181){var ce=S(j,Y);if(Y+=2,ce===49){var le=d(j,Y);if(Y+=4,le===1195456820){var fe=j[Y++];if(fe===3){var de=j[Y++],xe=31&de,Ae=64&de,Ie=Ae?2+xe*3:0,Re=new Uint8Array(Ie);if(Ae){Re[0]=de;for(var Oe=1;Oe<Ie;Oe++)Re[Oe]=j[Y++]}H.push({type:fe,payloadType:Q,pts:K,bytes:Re})}}}}}else if(Q===5&&q<ae){if(ne=!0,q>16){for(var Pe=[],Ce=0;Ce<16;Ce++){var Le=j[Y++].toString(16);Pe.push(Le.length==1?"0"+Le:Le),(Ce===3||Ce===5||Ce===7||Ce===9)&&Pe.push("-")}for(var ke=q-16,Be=new Uint8Array(ke),we=0;we<ke;we++)Be[we]=j[Y++];H.push({payloadType:Q,pts:K,uuid:Pe.join(""),userData:(0,M.utf8ArrayToStr)(Be),userDataBytes:Be})}}else if(q<ae)Y+=q;else if(q>ae)break}}function y(k){for(var F=k.byteLength,K=[],H=1;H<F-2;)k[H]===0&&k[H+1]===0&&k[H+2]===3?(K.push(H+2),H+=2):H++;if(K.length===0)return k;var j=F-K.length,Y=new Uint8Array(j),Q=0;for(H=0;H<j;Q++,H++)Q===K[0]&&(Q++,K.shift()),Y[H]=k[Q];return Y}function f(k){var F=k[0],K="",H="",j=0,Y=0,Q=0,q=0,ne=0,te=0;if(F===0){for(;_(k.subarray(te,te+1))!=="\0";)K+=_(k.subarray(te,te+1)),te+=1;for(K+=_(k.subarray(te,te+1)),te+=1;_(k.subarray(te,te+1))!=="\0";)H+=_(k.subarray(te,te+1)),te+=1;H+=_(k.subarray(te,te+1)),te+=1,j=d(k,12),Y=d(k,16),q=d(k,20),ne=d(k,24),te=28}else if(F===1){te+=4,j=d(k,te),te+=4;var ae=d(k,te);te+=4;var ue=d(k,te);for(te+=4,Q=Math.pow(2,32)*ae+ue,Number.isSafeInteger(Q)||(Q=Number.MAX_SAFE_INTEGER,console.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),q=d(k,te),te+=4,ne=d(k,te),te+=4;_(k.subarray(te,te+1))!=="\0";)K+=_(k.subarray(te,te+1)),te+=1;for(K+=_(k.subarray(te,te+1)),te+=1;_(k.subarray(te,te+1))!=="\0";)H+=_(k.subarray(te,te+1)),te+=1;H+=_(k.subarray(te,te+1)),te+=1}var ce=k.subarray(te,k.byteLength);return{schemeIdUri:K,value:H,timeScale:j,presentationTime:Q,presentationTimeDelta:Y,eventDuration:q,id:ne,payload:ce}}function b(k){for(var F=arguments.length,K=new Array(F>1?F-1:0),H=1;H<F;H++)K[H-1]=arguments[H];for(var j=K.length,Y=8,Q=j;Q--;)Y+=K[Q].byteLength;var q=new Uint8Array(Y);for(q[0]=Y>>24&255,q[1]=Y>>16&255,q[2]=Y>>8&255,q[3]=Y&255,q.set(k,4),Q=0,Y=8;Q<j;Q++)q.set(K[Q],Y),Y+=K[Q].byteLength;return q}function R(k,F,K){if(k.byteLength!==16)throw new RangeError("Invalid system id");var H,j;if(F){H=1,j=new Uint8Array(F.length*16);for(var Y=0;Y<F.length;Y++){var Q=F[Y];if(Q.byteLength!==16)throw new RangeError("Invalid key");j.set(Q,Y*16)}}else H=0,j=new Uint8Array;var q;H>0?(q=new Uint8Array(4),F.length>0&&new DataView(q.buffer).setUint32(0,F.length,!1)):q=new Uint8Array;var ne=new Uint8Array(4);return K&&K.byteLength>0&&new DataView(ne.buffer).setUint32(0,K.byteLength,!1),b([112,115,115,104],new Uint8Array([H,0,0,0]),k,q,j,ne,K||new Uint8Array)}function I(k){if(!(k instanceof ArrayBuffer)||k.byteLength<32)return null;var F={version:0,systemId:"",kids:null,data:null},K=new DataView(k),H=K.getUint32(0);if(k.byteLength!==H&&H>44)return null;var j=K.getUint32(4);if(j!==1886614376||(F.version=K.getUint32(8)>>>24,F.version>1))return null;F.systemId=B.default.hexDump(new Uint8Array(k,12,16));var Y=K.getUint32(28);if(F.version===0){if(H-32<Y)return null;F.data=new Uint8Array(k,32,Y)}else if(F.version===1){F.kids=[];for(var Q=0;Q<Y;Q++)F.kids.push(new Uint8Array(k,32+Q*16,16))}return F}},"./src/utils/numeric-encoding-utils.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{base64Decode:()=>A,base64DecodeToStr:()=>M,base64Encode:()=>P,base64ToBase64Url:()=>C,base64UrlEncode:()=>B,strToBase64Encode:()=>L});function C(D){return D.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function L(D){return btoa(D)}function M(D){return atob(D)}function P(D){return btoa(String.fromCharCode.apply(String,D))}function B(D){return C(P(D))}function A(D){return Uint8Array.from(atob(D),function(x){return x.charCodeAt(0)})}},"./src/utils/output-filter.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>C});var C=function(){function L(P,B){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=P,this.trackName=B}var M=L.prototype;return M.dispatchCue=function(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},M.newCue=function(B,A,D){(this.startTime===null||this.startTime>B)&&(this.startTime=B),this.endTime=A,this.screen=D,this.timelineController.createCaptionsTrack(this.trackName)},M.reset=function(){this.cueRanges=[],this.startTime=null},L}()},"./src/utils/texttrack-utils.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{addCueToTrack:()=>M,clearCurrentCues:()=>P,getCuesInRange:()=>D,removeCuesInRange:()=>B,sendAddTrackEvent:()=>L});var C=T("./src/utils/logger.ts");function L(x,_){var S;try{S=new Event("addtrack")}catch{S=document.createEvent("Event"),S.initEvent("addtrack",!1,!1)}S.track=x,_.dispatchEvent(S)}function M(x,_){var S=x.mode;if(S==="disabled"&&(x.mode="hidden"),x.cues&&!x.cues.getCueById(_.id))try{if(x.addCue(_),!x.cues.getCueById(_.id))throw new Error("addCue is failed for: "+_)}catch(E){C.logger.debug("[texttrack-utils]: "+E);var d=new self.TextTrackCue(_.startTime,_.endTime,_.text);d.id=_.id,x.addCue(d)}S==="disabled"&&(x.mode=S)}function P(x){var _=x.mode;if(_==="disabled"&&(x.mode="hidden"),x.cues)for(var S=x.cues.length;S--;)x.removeCue(x.cues[S]);_==="disabled"&&(x.mode=_)}function B(x,_,S,d){var E=x.mode;if(E==="disabled"&&(x.mode="hidden"),x.cues&&x.cues.length>0)for(var p=D(x.cues,_,S),h=0;h<p.length;h++)(!d||d(p[h]))&&x.removeCue(p[h]);E==="disabled"&&(x.mode=E)}function A(x,_){if(_<x[0].startTime)return 0;var S=x.length-1;if(_>x[S].endTime)return-1;for(var d=0,E=S;d<=E;){var p=Math.floor((E+d)/2);if(_<x[p].startTime)E=p-1;else if(_>x[p].startTime&&d<S)d=p+1;else return p}return x[d].startTime-_<_-x[E].startTime?d:E}function D(x,_,S){var d=[],E=A(x,_);if(E>-1)for(var p=E,h=x.length;p<h;p++){var a=x[p];if(a.startTime>=_&&a.endTime<=S)d.push(a);else if(a.startTime>S)return d}return d}},"./src/utils/time-ranges.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>L});var C={toString:function(P){for(var B="",A=P.length,D=0;D<A;D++)B+="["+P.start(D).toFixed(3)+","+P.end(D).toFixed(3)+"]";return B}};let L=C},"./src/utils/timescale-conversion.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{toMpegTsClockFromTimescale:()=>B,toMsFromMpegTsClock:()=>P,toTimescaleFromBase:()=>L,toTimescaleFromScale:()=>M});var C=9e4;function L(A,D,x,_){x===void 0&&(x=1),_===void 0&&(_=!1);var S=A*D*x;return _?Math.round(S):S}function M(A,D,x,_){return x===void 0&&(x=1),_===void 0&&(_=!1),L(A,D,1/x,_)}function P(A,D){return D===void 0&&(D=!1),L(A,1e3,1/C,D)}function B(A,D){return D===void 0&&(D=1),L(A,C,1/D)}},"./src/utils/typed-array.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{sliceUint8:()=>C});function C(L,M,P){return Uint8Array.prototype.slice?L.slice(M,P):new Uint8Array(Array.prototype.slice.call(L,M,P))}},"./src/utils/vttcue.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>C});let C=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var L=["","lr","rl"],M=["start","middle","end","left","right"];function P(_,S){if(typeof S!="string"||!Array.isArray(_))return!1;var d=S.toLowerCase();return~_.indexOf(d)?d:!1}function B(_){return P(L,_)}function A(_){return P(M,_)}function D(_){for(var S=arguments.length,d=new Array(S>1?S-1:0),E=1;E<S;E++)d[E-1]=arguments[E];for(var p=1;p<arguments.length;p++){var h=arguments[p];for(var a in h)_[a]=h[a]}return _}function x(_,S,d){var E=this,p={enumerable:!0};E.hasBeenReset=!1;var h="",a=!1,o=_,n=S,v=d,l=null,i="",u=!0,g="auto",c="start",m=50,e="middle",r=50,t="middle";Object.defineProperty(E,"id",D({},p,{get:function(){return h},set:function(y){h=""+y}})),Object.defineProperty(E,"pauseOnExit",D({},p,{get:function(){return a},set:function(y){a=!!y}})),Object.defineProperty(E,"startTime",D({},p,{get:function(){return o},set:function(y){if(typeof y!="number")throw new TypeError("Start time must be set to a number.");o=y,this.hasBeenReset=!0}})),Object.defineProperty(E,"endTime",D({},p,{get:function(){return n},set:function(y){if(typeof y!="number")throw new TypeError("End time must be set to a number.");n=y,this.hasBeenReset=!0}})),Object.defineProperty(E,"text",D({},p,{get:function(){return v},set:function(y){v=""+y,this.hasBeenReset=!0}})),Object.defineProperty(E,"region",D({},p,{get:function(){return l},set:function(y){l=y,this.hasBeenReset=!0}})),Object.defineProperty(E,"vertical",D({},p,{get:function(){return i},set:function(y){var f=B(y);if(f===!1)throw new SyntaxError("An invalid or illegal string was specified.");i=f,this.hasBeenReset=!0}})),Object.defineProperty(E,"snapToLines",D({},p,{get:function(){return u},set:function(y){u=!!y,this.hasBeenReset=!0}})),Object.defineProperty(E,"line",D({},p,{get:function(){return g},set:function(y){if(typeof y!="number"&&y!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");g=y,this.hasBeenReset=!0}})),Object.defineProperty(E,"lineAlign",D({},p,{get:function(){return c},set:function(y){var f=A(y);if(!f)throw new SyntaxError("An invalid or illegal string was specified.");c=f,this.hasBeenReset=!0}})),Object.defineProperty(E,"position",D({},p,{get:function(){return m},set:function(y){if(y<0||y>100)throw new Error("Position must be between 0 and 100.");m=y,this.hasBeenReset=!0}})),Object.defineProperty(E,"positionAlign",D({},p,{get:function(){return e},set:function(y){var f=A(y);if(!f)throw new SyntaxError("An invalid or illegal string was specified.");e=f,this.hasBeenReset=!0}})),Object.defineProperty(E,"size",D({},p,{get:function(){return r},set:function(y){if(y<0||y>100)throw new Error("Size must be between 0 and 100.");r=y,this.hasBeenReset=!0}})),Object.defineProperty(E,"align",D({},p,{get:function(){return t},set:function(y){var f=A(y);if(!f)throw new SyntaxError("An invalid or illegal string was specified.");t=f,this.hasBeenReset=!0}})),E.displayState=void 0}return x.prototype.getCueAsHTML=function(){var _=self.WebVTT;return _.convertCueToDOMTree(self,this.text)},x}()},"./src/utils/vttparser.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{VTTParser:()=>S,fixLineBreaks:()=>_,parseTimeStamp:()=>M});var C=T("./src/utils/vttcue.ts"),L=function(){function d(){}var E=d.prototype;return E.decode=function(h,a){if(!h)return"";if(typeof h!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(h))},d}();function M(d){function E(h,a,o,n){return(h|0)*3600+(a|0)*60+(o|0)+parseFloat(n||0)}var p=d.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return p?parseFloat(p[2])>59?E(p[2],p[3],0,p[4]):E(p[1],p[2],p[3],p[4]):null}var P=function(){function d(){this.values=Object.create(null)}var E=d.prototype;return E.set=function(h,a){!this.get(h)&&a!==""&&(this.values[h]=a)},E.get=function(h,a,o){return o?this.has(h)?this.values[h]:a[o]:this.has(h)?this.values[h]:a},E.has=function(h){return h in this.values},E.alt=function(h,a,o){for(var n=0;n<o.length;++n)if(a===o[n]){this.set(h,a);break}},E.integer=function(h,a){/^-?\d+$/.test(a)&&this.set(h,parseInt(a,10))},E.percent=function(h,a){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(a)){var o=parseFloat(a);if(o>=0&&o<=100)return this.set(h,o),!0}return!1},d}();function B(d,E,p,h){var a=h?d.split(h):[d];for(var o in a)if(typeof a[o]=="string"){var n=a[o].split(p);if(n.length===2){var v=n[0],l=n[1];E(v,l)}}}var A=new C.default(0,0,""),D=A.align==="middle"?"middle":"center";function x(d,E,p){var h=d;function a(){var v=M(d);if(v===null)throw new Error("Malformed timestamp: "+h);return d=d.replace(/^[^\sa-zA-Z-]+/,""),v}function o(v,l){var i=new P;B(v,function(c,m){var e;switch(c){case"region":for(var r=p.length-1;r>=0;r--)if(p[r].id===m){i.set(c,p[r].region);break}break;case"vertical":i.alt(c,m,["rl","lr"]);break;case"line":e=m.split(","),i.integer(c,e[0]),i.percent(c,e[0])&&i.set("snapToLines",!1),i.alt(c,e[0],["auto"]),e.length===2&&i.alt("lineAlign",e[1],["start",D,"end"]);break;case"position":e=m.split(","),i.percent(c,e[0]),e.length===2&&i.alt("positionAlign",e[1],["start",D,"end","line-left","line-right","auto"]);break;case"size":i.percent(c,m);break;case"align":i.alt(c,m,["start",D,"end","left","right"]);break}},/:/,/\s/),l.region=i.get("region",null),l.vertical=i.get("vertical","");var u=i.get("line","auto");u==="auto"&&A.line===-1&&(u=-1),l.line=u,l.lineAlign=i.get("lineAlign","start"),l.snapToLines=i.get("snapToLines",!0),l.size=i.get("size",100),l.align=i.get("align",D);var g=i.get("position","auto");g==="auto"&&A.position===50&&(g=l.align==="start"||l.align==="left"?0:l.align==="end"||l.align==="right"?100:50),l.position=g}function n(){d=d.replace(/^\s+/,"")}if(n(),E.startTime=a(),n(),d.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+h);d=d.slice(3),n(),E.endTime=a(),n(),o(d,E)}function _(d){return d.replace(/<br(?: \/)?>/gi,`
24
24
  `)}var S=function(){function d(){this.state="INITIAL",this.buffer="",this.decoder=new L,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var E=d.prototype;return E.parse=function(h){var a=this;h&&(a.buffer+=a.decoder.decode(h,{stream:!0}));function o(){var g=a.buffer,c=0;for(g=_(g);c<g.length&&g[c]!=="\r"&&g[c]!==`
@@ -29,7 +29,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
29
29
  `,h.parse()),h.state==="INITIAL"||h.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(a){h.onparsingerror&&h.onparsingerror(a)}return h.onflush&&h.onflush(),this},d}()},"./src/utils/webvtt-parser.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{generateCueId:()=>S,parseWebVTT:()=>E});var C=T("./src/polyfills/number.ts"),L=T("./src/utils/vttparser.ts"),M=T("./src/demux/id3.ts"),P=T("./src/utils/timescale-conversion.ts"),B=T("./src/remux/mp4-remuxer.ts"),A=/\r\n|\n\r|\n|\r/g,D=function(h,a,o){return o===void 0&&(o=0),h.slice(o,o+a.length)===a},x=function(h){var a=parseInt(h.slice(-3)),o=parseInt(h.slice(-6,-4)),n=parseInt(h.slice(-9,-7)),v=h.length>9?parseInt(h.substring(0,h.indexOf(":"))):0;if(!(0,C.isFiniteNumber)(a)||!(0,C.isFiniteNumber)(o)||!(0,C.isFiniteNumber)(n)||!(0,C.isFiniteNumber)(v))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+h);return a+=1e3*o,a+=60*1e3*n,a+=60*60*1e3*v,a},_=function(h){for(var a=5381,o=h.length;o;)a=a*33^h.charCodeAt(--o);return(a>>>0).toString()};function S(p,h,a){return _(p.toString())+_(h.toString())+_(a)}var d=function(h,a,o){var n=h[a],v=h[n.prevCC];if(!v||!v.new&&n.new){h.ccOffset=h.presentationOffset=n.start,n.new=!1;return}for(;(l=v)!==null&&l!==void 0&&l.new;){var l;h.ccOffset+=n.start-v.start,n.new=!1,n=v,v=h[n.prevCC]}h.presentationOffset=o};function E(p,h,a,o,n,v,l,i){var u=new L.VTTParser,g=(0,M.utf8ArrayToStr)(new Uint8Array(p)).trim().replace(A,`
30
30
  `).split(`
31
31
  `),c=[],m=(0,P.toMpegTsClockFromTimescale)(h,a),e="00:00.000",r=0,t=0,s,y=!0;u.oncue=function(f){var b=o[n],R=o.ccOffset,I=(r-m)/9e4;b!=null&&b.new&&(t!==void 0?R=o.ccOffset=b.start:d(o,n,I)),I&&(R=I-o.presentationOffset);var k=f.endTime-f.startTime,F=(0,B.normalizePts)((f.startTime+R-t)*9e4,v*9e4)/9e4;f.startTime=Math.max(F,0),f.endTime=Math.max(F+k,0);var K=f.text.trim();f.text=decodeURIComponent(encodeURIComponent(K)),f.id||(f.id=S(f.startTime,f.endTime,K)),f.endTime>0&&c.push(f)},u.onparsingerror=function(f){s=f},u.onflush=function(){if(s){i(s);return}l(c)},g.forEach(function(f){if(y)if(D(f,"X-TIMESTAMP-MAP=")){y=!1,f.slice(16).split(",").forEach(function(b){D(b,"LOCAL:")?e=b.slice(6):D(b,"MPEGTS:")&&(r=parseInt(b.slice(7)))});try{t=x(e)/1e3}catch(b){s=b}return}else f===""&&(y=!1);u.parse(f+`
32
- `)}),u.flush()}},"./src/utils/xhr-loader.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>B});var C=T("./src/utils/logger.ts"),L=T("./src/loader/load-stats.ts"),M=/^age:\s*[\d.]+\s*$/m,P=function(){function A(x){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=x?x.xhrSetup:null,this.stats=new L.LoadStats,this.retryDelay=0}var D=A.prototype;return D.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},D.abortInternal=function(){var _=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),_&&(_.onreadystatechange=null,_.onprogress=null,_.readyState!==4&&(this.stats.aborted=!0,_.abort()))},D.abort=function(){var _;this.abortInternal(),(_=this.callbacks)!==null&&_!==void 0&&_.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},D.load=function(_,S,d){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=_,this.config=S,this.callbacks=d,this.retryDelay=S.retryDelay,this.loadInternal()},D.loadInternal=function(){var _=this.config,S=this.context;if(!!_){var d=this.loader=new self.XMLHttpRequest,E=this.stats;E.loading.first=0,E.loaded=0;var p=this.xhrSetup;try{if(p)try{p(d,S.url)}catch{d.open("GET",S.url,!0),p(d,S.url)}d.readyState||d.open("GET",S.url,!0);var h=this.context.headers;if(h)for(var a in h)d.setRequestHeader(a,h[a])}catch(o){this.callbacks.onError({code:d.status,text:o.message},S,d);return}S.rangeEnd&&d.setRequestHeader("Range","bytes="+S.rangeStart+"-"+(S.rangeEnd-1)),d.onreadystatechange=this.readystatechange.bind(this),d.onprogress=this.loadprogress.bind(this),d.responseType=S.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),_.timeout),d.send()}},D.readystatechange=function(){var _=this.context,S=this.loader,d=this.stats;if(!(!_||!S)){var E=S.readyState,p=this.config;if(!d.aborted&&E>=2)if(self.clearTimeout(this.requestTimeout),d.loading.first===0&&(d.loading.first=Math.max(self.performance.now(),d.loading.start)),E===4){S.onreadystatechange=null,S.onprogress=null;var h=S.status,a=S.responseType==="arraybuffer";if(h>=200&&h<300&&(a&&S.response||S.responseText!==null)){d.loading.end=Math.max(self.performance.now(),d.loading.first);var o,n;if(a?(o=S.response,n=o.byteLength):(o=S.responseText,n=o.length),d.loaded=d.total=n,!this.callbacks)return;var v=this.callbacks.onProgress;if(v&&v(d,_,o,S),!this.callbacks)return;var l={url:S.responseURL,data:o};this.callbacks.onSuccess(l,d,_,S)}else d.retry>=p.maxRetry||h>=400&&h<499?(C.logger.error(h+" while loading "+_.url),this.callbacks.onError({code:h,text:S.statusText},_,S)):(C.logger.warn(h+" while loading "+_.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,p.maxRetryDelay),d.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),p.timeout)}},D.loadtimeout=function(){C.logger.warn("timeout while loading "+this.context.url);var _=this.callbacks;_&&(this.abortInternal(),_.onTimeout(this.stats,this.context,this.loader))},D.loadprogress=function(_){var S=this.stats;S.loaded=_.loaded,_.lengthComputable&&(S.total=_.total)},D.getCacheAge=function(){var _=null;if(this.loader&&M.test(this.loader.getAllResponseHeaders())){var S=this.loader.getResponseHeader("age");_=S?parseFloat(S):null}return _},A}();let B=P},"./node_modules/eventemitter3/index.js":z=>{"use strict";var N=Object.prototype.hasOwnProperty,T="~";function C(){}Object.create&&(C.prototype=Object.create(null),new C().__proto__||(T=!1));function L(A,D,x){this.fn=A,this.context=D,this.once=x||!1}function M(A,D,x,_,S){if(typeof x!="function")throw new TypeError("The listener must be a function");var d=new L(x,_||A,S),E=T?T+D:D;return A._events[E]?A._events[E].fn?A._events[E]=[A._events[E],d]:A._events[E].push(d):(A._events[E]=d,A._eventsCount++),A}function P(A,D){--A._eventsCount===0?A._events=new C:delete A._events[D]}function B(){this._events=new C,this._eventsCount=0}B.prototype.eventNames=function(){var D=[],x,_;if(this._eventsCount===0)return D;for(_ in x=this._events)N.call(x,_)&&D.push(T?_.slice(1):_);return Object.getOwnPropertySymbols?D.concat(Object.getOwnPropertySymbols(x)):D},B.prototype.listeners=function(D){var x=T?T+D:D,_=this._events[x];if(!_)return[];if(_.fn)return[_.fn];for(var S=0,d=_.length,E=new Array(d);S<d;S++)E[S]=_[S].fn;return E},B.prototype.listenerCount=function(D){var x=T?T+D:D,_=this._events[x];return _?_.fn?1:_.length:0},B.prototype.emit=function(D,x,_,S,d,E){var p=T?T+D:D;if(!this._events[p])return!1;var h=this._events[p],a=arguments.length,o,n;if(h.fn){switch(h.once&&this.removeListener(D,h.fn,void 0,!0),a){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,x),!0;case 3:return h.fn.call(h.context,x,_),!0;case 4:return h.fn.call(h.context,x,_,S),!0;case 5:return h.fn.call(h.context,x,_,S,d),!0;case 6:return h.fn.call(h.context,x,_,S,d,E),!0}for(n=1,o=new Array(a-1);n<a;n++)o[n-1]=arguments[n];h.fn.apply(h.context,o)}else{var v=h.length,l;for(n=0;n<v;n++)switch(h[n].once&&this.removeListener(D,h[n].fn,void 0,!0),a){case 1:h[n].fn.call(h[n].context);break;case 2:h[n].fn.call(h[n].context,x);break;case 3:h[n].fn.call(h[n].context,x,_);break;case 4:h[n].fn.call(h[n].context,x,_,S);break;default:if(!o)for(l=1,o=new Array(a-1);l<a;l++)o[l-1]=arguments[l];h[n].fn.apply(h[n].context,o)}}return!0},B.prototype.on=function(D,x,_){return M(this,D,x,_,!1)},B.prototype.once=function(D,x,_){return M(this,D,x,_,!0)},B.prototype.removeListener=function(D,x,_,S){var d=T?T+D:D;if(!this._events[d])return this;if(!x)return P(this,d),this;var E=this._events[d];if(E.fn)E.fn===x&&(!S||E.once)&&(!_||E.context===_)&&P(this,d);else{for(var p=0,h=[],a=E.length;p<a;p++)(E[p].fn!==x||S&&!E[p].once||_&&E[p].context!==_)&&h.push(E[p]);h.length?this._events[d]=h.length===1?h[0]:h:P(this,d)}return this},B.prototype.removeAllListeners=function(D){var x;return D?(x=T?T+D:D,this._events[x]&&P(this,x)):(this._events=new C,this._eventsCount=0),this},B.prototype.off=B.prototype.removeListener,B.prototype.addListener=B.prototype.on,B.prefixed=T,B.EventEmitter=B,z.exports=B},"./node_modules/url-toolkit/src/url-toolkit.js":function(z){(function(N){var T=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,C=/^(?=([^\/?#]*))\1([^]*)$/,L=/(?:\/|^)\.(?=\/)/g,M=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,P={buildAbsoluteURL:function(B,A,D){if(D=D||{},B=B.trim(),A=A.trim(),!A){if(!D.alwaysNormalize)return B;var x=P.parseURL(B);if(!x)throw new Error("Error trying to parse base URL.");return x.path=P.normalizePath(x.path),P.buildURLFromParts(x)}var _=P.parseURL(A);if(!_)throw new Error("Error trying to parse relative URL.");if(_.scheme)return D.alwaysNormalize?(_.path=P.normalizePath(_.path),P.buildURLFromParts(_)):A;var S=P.parseURL(B);if(!S)throw new Error("Error trying to parse base URL.");if(!S.netLoc&&S.path&&S.path[0]!=="/"){var d=C.exec(S.path);S.netLoc=d[1],S.path=d[2]}S.netLoc&&!S.path&&(S.path="/");var E={scheme:S.scheme,netLoc:_.netLoc,path:null,params:_.params,query:_.query,fragment:_.fragment};if(!_.netLoc&&(E.netLoc=S.netLoc,_.path[0]!=="/"))if(!_.path)E.path=S.path,_.params||(E.params=S.params,_.query||(E.query=S.query));else{var p=S.path,h=p.substring(0,p.lastIndexOf("/")+1)+_.path;E.path=P.normalizePath(h)}return E.path===null&&(E.path=D.alwaysNormalize?P.normalizePath(_.path):_.path),P.buildURLFromParts(E)},parseURL:function(B){var A=T.exec(B);return A?{scheme:A[1]||"",netLoc:A[2]||"",path:A[3]||"",params:A[4]||"",query:A[5]||"",fragment:A[6]||""}:null},normalizePath:function(B){for(B=B.split("").reverse().join("").replace(L,"");B.length!==(B=B.replace(M,"")).length;);return B.split("").reverse().join("")},buildURLFromParts:function(B){return B.scheme+B.netLoc+B.path+B.params+B.query+B.fragment}};z.exports=P})(this)}},ee={};function ie(z){var N=ee[z];if(N!==void 0)return N.exports;var T=ee[z]={exports:{}};return J[z].call(T.exports,T,T.exports,ie),T.exports}ie.m=J,ie.n=z=>{var N=z&&z.__esModule?()=>z.default:()=>z;return ie.d(N,{a:N}),N},ie.d=(z,N)=>{for(var T in N)ie.o(N,T)&&!ie.o(z,T)&&Object.defineProperty(z,T,{enumerable:!0,get:N[T]})},ie.o=(z,N)=>Object.prototype.hasOwnProperty.call(z,N),ie.r=z=>{typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(z,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(z,"__esModule",{value:!0})};var se=ie("./src/hls.ts");return se=se.default,se})())});var er=zt(Ur()),xt=zt($t());var At=class extends Error{constructor(ie,se=At.MEDIA_ERR_CUSTOM,z){var N;super(ie);this.name="MediaError",this.code=se,this.fatal=z!=null?z:se>=At.MEDIA_ERR_NETWORK&&se<=At.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(N=At.defaultMessages[this.code])!=null?N:"")}},$e=At;$e.MEDIA_ERR_ABORTED=1,$e.MEDIA_ERR_NETWORK=2,$e.MEDIA_ERR_DECODE=3,$e.MEDIA_ERR_SRC_NOT_SUPPORTED=4,$e.MEDIA_ERR_ENCRYPTED=5,$e.MEDIA_ERR_CUSTOM=100,$e.defaultMessages={1:"You aborted the media playback",2:"A network error caused the media download to fail.",3:"A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.",4:"An unsupported error occurred. The server or network failed, or your browser does not support this format.",5:"The media is encrypted and there are no keys to decrypt it."};var Er=zt($t());var Xi=J=>J==null,gr=(J,ee)=>Xi(ee)?!1:J in ee,Jt={ANY:"any",MUTED:"muted"},Kt={VOD:"on-demand",ON_DEMAND:"on-demand",LIVE:"live",LL_LIVE:"ll-live",DVR:"live:dvr",LL_DVR:"ll-live:dvr"},mr={MSE:"mse",NATIVE:"native"},Zt={HEADER:"header",QUERY:"query",NONE:"none"},hn=Object.values(Zt),Et={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},qt={HLS:Et.M3U8},vn=Object.keys(qt),gn=[...Object.values(Et),"hls","HLS"];var yt=(J,ee,ie,se,z=J)=>{z.addEventListener(ee,ie,se),J.addEventListener("teardown",()=>{z.removeEventListener(ee,ie)},{once:!0})};function Br(J,ee,ie){ee&&ie>ee&&(ie=ee);for(let se=0;se<J.length;se++)if(J.start(se)<=ie&&J.end(se)>=ie)return!0;return!1}var Nr=J=>{let ee=J.indexOf("?");if(ee<0)return[J];let ie=J.slice(0,ee),se=J.slice(ee);return[ie,se]},pr=J=>{let ee=J.type;if(ee){let se=ee.toUpperCase();return gr(se,qt)?qt[se]:ee}let{src:ie}=J;return ie?zi(ie):""},zi=J=>{let ee="";try{ee=new URL(J).pathname}catch{console.error("invalid url")}let ie=ee.lastIndexOf(".");if(ie<0)return"";let z=ee.slice(ie+1).toUpperCase();return gr(z,Et)?Et[z]:""};var Qi=Object.values(Jt),Kr=J=>typeof J=="boolean"||typeof J=="string"&&Qi.includes(J),Wr=({autoplay:J},ee,ie)=>{let se=!1,z=!1,N=Kr(J)?J:!!J,T=()=>{se||yt(ee,"playing",()=>{se=!0},{once:!0})};if(T(),yt(ee,"loadstart",()=>{se=!1,T(),yr(ee,N)},{once:!0}),yt(ee,"loadstart",()=>{ie||(z=!Number.isFinite(ee.duration)),yr(ee,N)},{once:!0}),ie&&ie.once(Er.default.Events.LEVEL_LOADED,(L,M)=>{var P;z=(P=M.details.live)!=null?P:!1}),!N){let L=()=>{!z||(ie!=null&&ie.liveSyncPosition?ee.currentTime=ie.liveSyncPosition:Number.isFinite(ee.seekable.end(0))&&(ee.currentTime=ee.seekable.end(0)))};ie&&yt(ee,"play",()=>{ee.preload==="metadata"?ie.once(Er.default.Events.LEVEL_UPDATED,L):L()},{once:!0})}return L=>{se||(N=Kr(L)?L:!!L,yr(ee,N))}},yr=(J,ee)=>{if(!ee)return;let ie=J.muted,se=()=>J.muted=ie;switch(ee){case Jt.ANY:J.play().catch(()=>{J.muted=!0,J.play().catch(se)});break;case Jt.MUTED:J.muted=!0,J.play().catch(se);break;default:J.play().catch(()=>{});break}};var Gr=({preload:J,src:ee},ie,se)=>{let z=B=>{B!=null&&["","none","metadata","auto"].includes(B)?ie.setAttribute("preload",B):ie.removeAttribute("preload")};if(!se)return z(J),z;let N=!1,T=!1,C=se.config.maxBufferLength,L=se.config.maxBufferSize,M=B=>{z(B);let A=B!=null?B:ie.preload;T||A==="none"||(A==="metadata"?(se.config.maxBufferLength=1,se.config.maxBufferSize=1):(se.config.maxBufferLength=C,se.config.maxBufferSize=L),P())},P=()=>{!N&&ee&&(N=!0,se.loadSource(ee))};return yt(ie,"play",()=>{T=!0,se.config.maxBufferLength=C,se.config.maxBufferSize=L,P()},{once:!0}),M(J),M};var bt=zt($t());function Hr(J,ee){ee.on(bt.default.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(z,{tracks:N})=>{N.forEach(T=>{var M;let C=(M=T.subtitleTrack)!=null?M:T.closedCaptions,L=ee.subtitleTracks.findIndex(({lang:P,name:B,type:A})=>P==(C==null?void 0:C.lang)&&B===T.label&&A.toLowerCase()===T.kind);_r(J,T.kind,T.label,C==null?void 0:C.lang,`${T.kind}${L}`)})});let ie=()=>{var T;if(!ee.subtitleTracks.length)return;let z=Array.from(J.textTracks).find(C=>C.id&&C.mode==="showing"&&["subtitles","captions"].includes(C.kind)),N=`${(T=ee.subtitleTracks[ee.subtitleTrack])==null?void 0:T.type.toLowerCase()}${ee.subtitleTrack}`;if(z&&(ee.subtitleTrack<0||(z==null?void 0:z.id)!==N)){let C=ee.subtitleTracks.findIndex(({lang:L,name:M,type:P})=>L==z.language&&M===z.label&&P.toLowerCase()===z.kind);ee.subtitleTrack=C}z&&(z==null?void 0:z.id)===N&&z.cues&&Array.from(z.cues).forEach(C=>{z.addCue(C)})};J.textTracks.addEventListener("change",ie),ee.on(bt.default.Events.CUES_PARSED,(z,{track:N,cues:T})=>{let C=J.textTracks.getTrackById(N);if(!C)return;let L=C.mode==="disabled";L&&(C.mode="hidden"),T.forEach(M=>{var P;(P=C.cues)!=null&&P.getCueById(M.id)||C.addCue(M)}),L&&(C.mode="disabled")}),ee.once(bt.default.Events.DESTROYING,()=>{J.textTracks.removeEventListener("change",ie),J.querySelectorAll("track[data-removeondestroy]").forEach(N=>{N.remove()})});let se=()=>{Array.from(J.textTracks).forEach(z=>{var N,T;if(!["subtitles","caption"].includes(z.kind)&&z.label==="thumbnails"){if(!((N=z.cues)!=null&&N.length)){let C=J.querySelector('track[label="thumbnails"]'),L=(T=C==null?void 0:C.getAttribute("src"))!=null?T:"";C==null||C.removeAttribute("src"),setTimeout(()=>{C==null||C.setAttribute("src",L)},0)}z.mode!=="hidden"&&(z.mode="hidden")}})};ee.once(bt.default.Events.MANIFEST_LOADED,se),ee.once(bt.default.Events.MEDIA_ATTACHED,se)}function _r(J,ee,ie,se,z){let N=document.createElement("track");return N.kind=ee,N.label=ie,se&&(N.srclang=se),z&&(N.id=z),N.track.mode="disabled",N.setAttribute("data-removeondestroy",""),J.append(N),N.track}function $i(J,ee){let ie=Array.prototype.find.call(J.querySelectorAll("track"),se=>se.track===ee);ie==null||ie.remove()}var Wt="cuepoints",Tr=Object.freeze({label:Wt}),xr=(J,{label:ee=Wt}=Tr)=>{var ie;return(ie=Array.from(J.querySelectorAll("track")).find(se=>se.track.label===ee&&se.track.kind==="metadata"))==null?void 0:ie.track};async function jr(J,ee,ie=Tr){let se=xr(J,ie);if(!se){let{label:z=Wt}=ie;se=_r(J,"metadata",z),se.mode="hidden",await new Promise(N=>setTimeout(()=>N(void 0),0))}return[...ee].sort(({time:z},{time:N})=>N-z).forEach(({time:z,value:N})=>{var B,A;let T=Array.prototype.findIndex.call(se==null?void 0:se.cues,D=>D.startTime>=z),C=(B=se==null?void 0:se.cues)==null?void 0:B[T],L=C?C.startTime:Number.isFinite(J.duration)?J.duration:Number.MAX_SAFE_INTEGER,M=(A=se==null?void 0:se.cues)==null?void 0:A[T-1];M&&(M.endTime=z);let P=new VTTCue(z,L,JSON.stringify(N!=null?N:null));se.addCue(P)}),se}var Vr=J=>({time:J.startTime,value:JSON.parse(J.text)});function Ji(J,ee={label:Wt}){let ie=xr(J,ee);return ie!=null&&ie.cues?Array.from(ie.cues,se=>Vr(se)):[]}function Yr(J,ee={label:Wt}){var se;let ie=xr(J,ee);if(!!((se=ie==null?void 0:ie.activeCues)!=null&&se.length))return Vr(ie.activeCues[0])}async function Xr(J,ee=Tr){let ie=await jr(J,[],ee);return yt(J,"cuechange",()=>{let se=Yr(J);if(se){let z=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:se});J.dispatchEvent(z)}},{},ie),ie}var zr,Qr,Zi=(Qr=(zr=globalThis==null?void 0:globalThis.navigator)==null?void 0:zr.userAgent)!=null?Qr:"",qi=Zi.toLowerCase().indexOf("android")!==-1,Pt=new WeakMap,Zr="mux.com",$r,Jr,qr=(Jr=($r=xt.default).isSupported)==null?void 0:Jr.call($r),en=qi,Fn=()=>er.default.utils.now(),tn=er.default.utils.generateUUID,Un=(J,{domain:ee=Zr}={})=>{if(!J)return;let[ie,se=""]=Nr(J);return`https://stream.${ee}/${ie}.m3u8${se}`},rn=J=>{if(!J)return;let[ee]=J.split("?");return ee||void 0},nn=J=>{if(!J||!J.startsWith("https://stream."))return;let[ee]=new URL(J).pathname.slice(1).split(".m3u8");return ee||void 0},an=J=>{var ee,ie,se;return(ee=J==null?void 0:J.metadata)!=null&&ee.video_id?J.metadata.video_id:ti(J)&&(se=(ie=rn(J.playbackId))!=null?ie:nn(J.src))!=null?se:J.src},Bn=J=>{var ee;return(ee=Pt.get(J))==null?void 0:ee.error},Nn=(J,ee,ie)=>{sn(ee,ie);let{metadata:se={}}=J,{view_session_id:z=tn()}=se,N=an(J);se.view_session_id=z,se.video_id=N,J.metadata=se,Pt.set(ee,{});let T=on(J,ee);un(J,ee,T),fn(J,ee,T),Xr(ee);let C=Wr(J,ee,T),L=Gr(J,ee,T);return{engine:T,setAutoplay:C,setPreload:L}},sn=(J,ee)=>{let ie=ee==null?void 0:ee.engine;ie&&(ie.detachMedia(),ie.destroy()),(J==null?void 0:J.mux)&&!J.mux.deleted&&(J.mux.destroy(),delete J.mux),J&&(J.removeAttribute("src"),J.load(),J.removeEventListener("error",ii),J.removeEventListener("error",Sr),J.removeEventListener("durationchange",ri),Pt.delete(J),J.dispatchEvent(new Event("teardown")))};function ei(J,ee){var M;let ie=pr(J);if(!(ie===Et.M3U8))return!0;let z=!ie||((M=ee.canPlayType(ie))!=null?M:!0),{preferPlayback:N}=J,T=N===mr.MSE,C=N===mr.NATIVE;return z&&(C||!(qr&&(T||en)))}var on=(J,ee)=>{let{debug:ie,streamType:se,startTime:z=-1,metadata:N,preferCmcd:T}=J,L=pr(J)===Et.M3U8,M=ei(J,ee);if(L&&!M&&qr){let P={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0},B=ln(se),A=T!==Zt.NONE?{useHeaders:T===Zt.HEADER,sessionId:N.view_session_id,contentId:N.video_id}:void 0;return new xt.default({debug:ie,startPosition:z,cmcd:A,...P,...B})}},ln=J=>[Kt.LIVE,Kt.DVR].includes(J)?{backBufferLength:8}:[Kt.LL_LIVE,Kt.LL_DVR].includes(J)?{backBufferLength:4,maxFragLookUpTolerance:.001}:{},ti=({playbackId:J,src:ee,customDomain:ie})=>{if(J)return!0;if(typeof ee!="string")return!1;let se=window==null?void 0:window.location.href,z=new URL(ee,se).hostname.toLocaleLowerCase();return z.includes(Zr)||!!ie&&z.includes(ie.toLocaleLowerCase())},un=(J,ee,ie)=>{var N;let{envKey:se}=J,z=ti(J);if(se||z){let{playerInitTime:T,playerSoftwareName:C,playerSoftwareVersion:L,beaconCollectionDomain:M,debug:P,disableCookies:B}=J,A={...J.metadata,video_title:((N=J==null?void 0:J.metadata)==null?void 0:N.video_title)||void 0},D=x=>typeof x.player_error_code=="string"?!1:typeof J.errorTranslator=="function"?J.errorTranslator(x):x;er.default.monitor(ee,{debug:P,beaconCollectionDomain:M,hlsjs:ie,Hls:ie?xt.default:void 0,automaticErrorTracking:!1,errorTranslator:D,disableCookies:B,data:{...se?{env_key:se}:{},player_software_name:C,player_software:C,player_software_version:L,player_init_time:T,...A}})}},fn=(J,ee,ie)=>{var N;let se=ei(J,ee),{src:z}=J;ee&&se?(typeof z=="string"?(ee.setAttribute("src",z),J.startTime&&(((N=Pt.get(ee))!=null?N:{}).startTime=J.startTime,ee.addEventListener("durationchange",ri,{once:!0}))):ee.removeAttribute("src"),ee.addEventListener("error",ii),ee.addEventListener("error",Sr)):ie&&z?(ie.on(xt.default.Events.ERROR,(T,C)=>{let L={[xt.default.ErrorTypes.NETWORK_ERROR]:$e.MEDIA_ERR_NETWORK,[xt.default.ErrorTypes.MEDIA_ERROR]:$e.MEDIA_ERR_DECODE},M=new $e("",L[C.type]);M.fatal=C.fatal,M.data=C,ee.dispatchEvent(new CustomEvent("error",{detail:M}))}),ee.addEventListener("error",Sr),Hr(ee,ie),ie.attachMedia(ee)):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 ri(J){var se;let ee=J.target,ie=(se=Pt.get(ee))==null?void 0:se.startTime;if(!!ie&&Br(ee.seekable,ee.duration,ie)){let z=ee.preload==="auto";z&&(ee.preload="none"),ee.currentTime=ie,z&&(ee.preload="auto")}}async function ii(J){if(!J.isTrusted)return;J.stopImmediatePropagation();let ee=J.target;if(!(ee!=null&&ee.error))return;let{message:ie,code:se}=ee.error,z=new $e(ie,se);if(ee.src&&(se!==$e.MEDIA_ERR_DECODE||se!==void 0))try{let{status:N}=await fetch(ee.src);z.data={response:{code:N}}}catch{}ee.dispatchEvent(new CustomEvent("error",{detail:z}))}function Sr(J){var se,z;if(!(J instanceof CustomEvent)||!(J.detail instanceof $e))return;let ee=J.target,ie=J.detail;!ie||!ie.fatal||(((se=Pt.get(ee))!=null?se:{}).error=ie,(z=ee.mux)==null||z.emit("error",{player_error_code:ie.code,player_error_message:ie.message}))}})();
32
+ `)}),u.flush()}},"./src/utils/xhr-loader.ts":(z,N,T)=>{"use strict";T.r(N),T.d(N,{default:()=>B});var C=T("./src/utils/logger.ts"),L=T("./src/loader/load-stats.ts"),M=/^age:\s*[\d.]+\s*$/m,P=function(){function A(x){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=x?x.xhrSetup:null,this.stats=new L.LoadStats,this.retryDelay=0}var D=A.prototype;return D.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},D.abortInternal=function(){var _=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),_&&(_.onreadystatechange=null,_.onprogress=null,_.readyState!==4&&(this.stats.aborted=!0,_.abort()))},D.abort=function(){var _;this.abortInternal(),(_=this.callbacks)!==null&&_!==void 0&&_.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},D.load=function(_,S,d){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=_,this.config=S,this.callbacks=d,this.retryDelay=S.retryDelay,this.loadInternal()},D.loadInternal=function(){var _=this.config,S=this.context;if(!!_){var d=this.loader=new self.XMLHttpRequest,E=this.stats;E.loading.first=0,E.loaded=0;var p=this.xhrSetup;try{if(p)try{p(d,S.url)}catch{d.open("GET",S.url,!0),p(d,S.url)}d.readyState||d.open("GET",S.url,!0);var h=this.context.headers;if(h)for(var a in h)d.setRequestHeader(a,h[a])}catch(o){this.callbacks.onError({code:d.status,text:o.message},S,d);return}S.rangeEnd&&d.setRequestHeader("Range","bytes="+S.rangeStart+"-"+(S.rangeEnd-1)),d.onreadystatechange=this.readystatechange.bind(this),d.onprogress=this.loadprogress.bind(this),d.responseType=S.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),_.timeout),d.send()}},D.readystatechange=function(){var _=this.context,S=this.loader,d=this.stats;if(!(!_||!S)){var E=S.readyState,p=this.config;if(!d.aborted&&E>=2)if(self.clearTimeout(this.requestTimeout),d.loading.first===0&&(d.loading.first=Math.max(self.performance.now(),d.loading.start)),E===4){S.onreadystatechange=null,S.onprogress=null;var h=S.status,a=S.responseType==="arraybuffer";if(h>=200&&h<300&&(a&&S.response||S.responseText!==null)){d.loading.end=Math.max(self.performance.now(),d.loading.first);var o,n;if(a?(o=S.response,n=o.byteLength):(o=S.responseText,n=o.length),d.loaded=d.total=n,!this.callbacks)return;var v=this.callbacks.onProgress;if(v&&v(d,_,o,S),!this.callbacks)return;var l={url:S.responseURL,data:o};this.callbacks.onSuccess(l,d,_,S)}else d.retry>=p.maxRetry||h>=400&&h<499?(C.logger.error(h+" while loading "+_.url),this.callbacks.onError({code:h,text:S.statusText},_,S)):(C.logger.warn(h+" while loading "+_.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,p.maxRetryDelay),d.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),p.timeout)}},D.loadtimeout=function(){C.logger.warn("timeout while loading "+this.context.url);var _=this.callbacks;_&&(this.abortInternal(),_.onTimeout(this.stats,this.context,this.loader))},D.loadprogress=function(_){var S=this.stats;S.loaded=_.loaded,_.lengthComputable&&(S.total=_.total)},D.getCacheAge=function(){var _=null;if(this.loader&&M.test(this.loader.getAllResponseHeaders())){var S=this.loader.getResponseHeader("age");_=S?parseFloat(S):null}return _},A}();let B=P},"./node_modules/eventemitter3/index.js":z=>{"use strict";var N=Object.prototype.hasOwnProperty,T="~";function C(){}Object.create&&(C.prototype=Object.create(null),new C().__proto__||(T=!1));function L(A,D,x){this.fn=A,this.context=D,this.once=x||!1}function M(A,D,x,_,S){if(typeof x!="function")throw new TypeError("The listener must be a function");var d=new L(x,_||A,S),E=T?T+D:D;return A._events[E]?A._events[E].fn?A._events[E]=[A._events[E],d]:A._events[E].push(d):(A._events[E]=d,A._eventsCount++),A}function P(A,D){--A._eventsCount===0?A._events=new C:delete A._events[D]}function B(){this._events=new C,this._eventsCount=0}B.prototype.eventNames=function(){var D=[],x,_;if(this._eventsCount===0)return D;for(_ in x=this._events)N.call(x,_)&&D.push(T?_.slice(1):_);return Object.getOwnPropertySymbols?D.concat(Object.getOwnPropertySymbols(x)):D},B.prototype.listeners=function(D){var x=T?T+D:D,_=this._events[x];if(!_)return[];if(_.fn)return[_.fn];for(var S=0,d=_.length,E=new Array(d);S<d;S++)E[S]=_[S].fn;return E},B.prototype.listenerCount=function(D){var x=T?T+D:D,_=this._events[x];return _?_.fn?1:_.length:0},B.prototype.emit=function(D,x,_,S,d,E){var p=T?T+D:D;if(!this._events[p])return!1;var h=this._events[p],a=arguments.length,o,n;if(h.fn){switch(h.once&&this.removeListener(D,h.fn,void 0,!0),a){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,x),!0;case 3:return h.fn.call(h.context,x,_),!0;case 4:return h.fn.call(h.context,x,_,S),!0;case 5:return h.fn.call(h.context,x,_,S,d),!0;case 6:return h.fn.call(h.context,x,_,S,d,E),!0}for(n=1,o=new Array(a-1);n<a;n++)o[n-1]=arguments[n];h.fn.apply(h.context,o)}else{var v=h.length,l;for(n=0;n<v;n++)switch(h[n].once&&this.removeListener(D,h[n].fn,void 0,!0),a){case 1:h[n].fn.call(h[n].context);break;case 2:h[n].fn.call(h[n].context,x);break;case 3:h[n].fn.call(h[n].context,x,_);break;case 4:h[n].fn.call(h[n].context,x,_,S);break;default:if(!o)for(l=1,o=new Array(a-1);l<a;l++)o[l-1]=arguments[l];h[n].fn.apply(h[n].context,o)}}return!0},B.prototype.on=function(D,x,_){return M(this,D,x,_,!1)},B.prototype.once=function(D,x,_){return M(this,D,x,_,!0)},B.prototype.removeListener=function(D,x,_,S){var d=T?T+D:D;if(!this._events[d])return this;if(!x)return P(this,d),this;var E=this._events[d];if(E.fn)E.fn===x&&(!S||E.once)&&(!_||E.context===_)&&P(this,d);else{for(var p=0,h=[],a=E.length;p<a;p++)(E[p].fn!==x||S&&!E[p].once||_&&E[p].context!==_)&&h.push(E[p]);h.length?this._events[d]=h.length===1?h[0]:h:P(this,d)}return this},B.prototype.removeAllListeners=function(D){var x;return D?(x=T?T+D:D,this._events[x]&&P(this,x)):(this._events=new C,this._eventsCount=0),this},B.prototype.off=B.prototype.removeListener,B.prototype.addListener=B.prototype.on,B.prefixed=T,B.EventEmitter=B,z.exports=B},"./node_modules/url-toolkit/src/url-toolkit.js":function(z){(function(N){var T=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,C=/^(?=([^\/?#]*))\1([^]*)$/,L=/(?:\/|^)\.(?=\/)/g,M=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,P={buildAbsoluteURL:function(B,A,D){if(D=D||{},B=B.trim(),A=A.trim(),!A){if(!D.alwaysNormalize)return B;var x=P.parseURL(B);if(!x)throw new Error("Error trying to parse base URL.");return x.path=P.normalizePath(x.path),P.buildURLFromParts(x)}var _=P.parseURL(A);if(!_)throw new Error("Error trying to parse relative URL.");if(_.scheme)return D.alwaysNormalize?(_.path=P.normalizePath(_.path),P.buildURLFromParts(_)):A;var S=P.parseURL(B);if(!S)throw new Error("Error trying to parse base URL.");if(!S.netLoc&&S.path&&S.path[0]!=="/"){var d=C.exec(S.path);S.netLoc=d[1],S.path=d[2]}S.netLoc&&!S.path&&(S.path="/");var E={scheme:S.scheme,netLoc:_.netLoc,path:null,params:_.params,query:_.query,fragment:_.fragment};if(!_.netLoc&&(E.netLoc=S.netLoc,_.path[0]!=="/"))if(!_.path)E.path=S.path,_.params||(E.params=S.params,_.query||(E.query=S.query));else{var p=S.path,h=p.substring(0,p.lastIndexOf("/")+1)+_.path;E.path=P.normalizePath(h)}return E.path===null&&(E.path=D.alwaysNormalize?P.normalizePath(_.path):_.path),P.buildURLFromParts(E)},parseURL:function(B){var A=T.exec(B);return A?{scheme:A[1]||"",netLoc:A[2]||"",path:A[3]||"",params:A[4]||"",query:A[5]||"",fragment:A[6]||""}:null},normalizePath:function(B){for(B=B.split("").reverse().join("").replace(L,"");B.length!==(B=B.replace(M,"")).length;);return B.split("").reverse().join("")},buildURLFromParts:function(B){return B.scheme+B.netLoc+B.path+B.params+B.query+B.fragment}};z.exports=P})(this)}},ee={};function ie(z){var N=ee[z];if(N!==void 0)return N.exports;var T=ee[z]={exports:{}};return J[z].call(T.exports,T,T.exports,ie),T.exports}ie.m=J,ie.n=z=>{var N=z&&z.__esModule?()=>z.default:()=>z;return ie.d(N,{a:N}),N},ie.d=(z,N)=>{for(var T in N)ie.o(N,T)&&!ie.o(z,T)&&Object.defineProperty(z,T,{enumerable:!0,get:N[T]})},ie.o=(z,N)=>Object.prototype.hasOwnProperty.call(z,N),ie.r=z=>{typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(z,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(z,"__esModule",{value:!0})};var se=ie("./src/hls.ts");return se=se.default,se})())});var tr=zt(Ur()),xt=zt($t());var At=class extends Error{constructor(ie,se=At.MEDIA_ERR_CUSTOM,z){var N;super(ie);this.name="MediaError",this.code=se,this.fatal=z!=null?z:se>=At.MEDIA_ERR_NETWORK&&se<=At.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(N=At.defaultMessages[this.code])!=null?N:"")}},$e=At;$e.MEDIA_ERR_ABORTED=1,$e.MEDIA_ERR_NETWORK=2,$e.MEDIA_ERR_DECODE=3,$e.MEDIA_ERR_SRC_NOT_SUPPORTED=4,$e.MEDIA_ERR_ENCRYPTED=5,$e.MEDIA_ERR_CUSTOM=100,$e.defaultMessages={1:"You aborted the media playback",2:"A network error caused the media download to fail.",3:"A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.",4:"An unsupported error occurred. The server or network failed, or your browser does not support this format.",5:"The media is encrypted and there are no keys to decrypt it."};var _r=zt($t());var Xi=J=>J==null,mr=(J,ee)=>Xi(ee)?!1:J in ee,Jt={ANY:"any",MUTED:"muted"},Kt={VOD:"on-demand",ON_DEMAND:"on-demand",LIVE:"live",LL_LIVE:"ll-live",DVR:"live:dvr",LL_DVR:"ll-live:dvr"},pr={MSE:"mse",NATIVE:"native"},Zt={HEADER:"header",QUERY:"query",NONE:"none"},hn=Object.values(Zt),Et={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},qt={HLS:Et.M3U8},vn=Object.keys(qt),gn=[...Object.values(Et),"hls","HLS"];var yt=(J,ee,ie,se,z=J)=>{z.addEventListener(ee,ie,se),J.addEventListener("teardown",()=>{z.removeEventListener(ee,ie)},{once:!0})};function Br(J,ee,ie){ee&&ie>ee&&(ie=ee);for(let se=0;se<J.length;se++)if(J.start(se)<=ie&&J.end(se)>=ie)return!0;return!1}var Nr=J=>{let ee=J.indexOf("?");if(ee<0)return[J];let ie=J.slice(0,ee),se=J.slice(ee);return[ie,se]},yr=J=>{let ee=J.type;if(ee){let se=ee.toUpperCase();return mr(se,qt)?qt[se]:ee}let{src:ie}=J;return ie?zi(ie):""},zi=J=>{let ee="";try{ee=new URL(J).pathname}catch{console.error("invalid url")}let ie=ee.lastIndexOf(".");if(ie<0)return"";let z=ee.slice(ie+1).toUpperCase();return mr(z,Et)?Et[z]:""};var Qi=Object.values(Jt),Kr=J=>typeof J=="boolean"||typeof J=="string"&&Qi.includes(J),Wr=({autoplay:J},ee,ie)=>{let se=!1,z=!1,N=Kr(J)?J:!!J,T=()=>{se||yt(ee,"playing",()=>{se=!0},{once:!0})};if(T(),yt(ee,"loadstart",()=>{se=!1,T(),Er(ee,N)},{once:!0}),yt(ee,"loadstart",()=>{ie||(z=!Number.isFinite(ee.duration)),Er(ee,N)},{once:!0}),ie&&ie.once(_r.default.Events.LEVEL_LOADED,(L,M)=>{var P;z=(P=M.details.live)!=null?P:!1}),!N){let L=()=>{!z||(ie!=null&&ie.liveSyncPosition?ee.currentTime=ie.liveSyncPosition:Number.isFinite(ee.seekable.end(0))&&(ee.currentTime=ee.seekable.end(0)))};ie&&yt(ee,"play",()=>{ee.preload==="metadata"?ie.once(_r.default.Events.LEVEL_UPDATED,L):L()},{once:!0})}return L=>{se||(N=Kr(L)?L:!!L,Er(ee,N))}},Er=(J,ee)=>{if(!ee)return;let ie=J.muted,se=()=>J.muted=ie;switch(ee){case Jt.ANY:J.play().catch(()=>{J.muted=!0,J.play().catch(se)});break;case Jt.MUTED:J.muted=!0,J.play().catch(se);break;default:J.play().catch(()=>{});break}};var Gr=({preload:J,src:ee},ie,se)=>{let z=B=>{B!=null&&["","none","metadata","auto"].includes(B)?ie.setAttribute("preload",B):ie.removeAttribute("preload")};if(!se)return z(J),z;let N=!1,T=!1,C=se.config.maxBufferLength,L=se.config.maxBufferSize,M=B=>{z(B);let A=B!=null?B:ie.preload;T||A==="none"||(A==="metadata"?(se.config.maxBufferLength=1,se.config.maxBufferSize=1):(se.config.maxBufferLength=C,se.config.maxBufferSize=L),P())},P=()=>{!N&&ee&&(N=!0,se.loadSource(ee))};return yt(ie,"play",()=>{T=!0,se.config.maxBufferLength=C,se.config.maxBufferSize=L,P()},{once:!0}),M(J),M};var bt=zt($t());function Hr(J,ee){ee.on(bt.default.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(z,{tracks:N})=>{N.forEach(T=>{var M;let C=(M=T.subtitleTrack)!=null?M:T.closedCaptions,L=ee.subtitleTracks.findIndex(({lang:P,name:B,type:A})=>P==(C==null?void 0:C.lang)&&B===T.label&&A.toLowerCase()===T.kind);Tr(J,T.kind,T.label,C==null?void 0:C.lang,`${T.kind}${L}`)})});let ie=()=>{var T;if(!ee.subtitleTracks.length)return;let z=Array.from(J.textTracks).find(C=>C.id&&C.mode==="showing"&&["subtitles","captions"].includes(C.kind)),N=`${(T=ee.subtitleTracks[ee.subtitleTrack])==null?void 0:T.type.toLowerCase()}${ee.subtitleTrack}`;if(z&&(ee.subtitleTrack<0||(z==null?void 0:z.id)!==N)){let C=ee.subtitleTracks.findIndex(({lang:L,name:M,type:P})=>L==z.language&&M===z.label&&P.toLowerCase()===z.kind);ee.subtitleTrack=C}z&&(z==null?void 0:z.id)===N&&z.cues&&Array.from(z.cues).forEach(C=>{z.addCue(C)})};J.textTracks.addEventListener("change",ie),ee.on(bt.default.Events.CUES_PARSED,(z,{track:N,cues:T})=>{let C=J.textTracks.getTrackById(N);if(!C)return;let L=C.mode==="disabled";L&&(C.mode="hidden"),T.forEach(M=>{var P;(P=C.cues)!=null&&P.getCueById(M.id)||C.addCue(M)}),L&&(C.mode="disabled")}),ee.once(bt.default.Events.DESTROYING,()=>{J.textTracks.removeEventListener("change",ie),J.querySelectorAll("track[data-removeondestroy]").forEach(N=>{N.remove()})});let se=()=>{Array.from(J.textTracks).forEach(z=>{var N,T;if(!["subtitles","caption"].includes(z.kind)&&z.label==="thumbnails"){if(!((N=z.cues)!=null&&N.length)){let C=J.querySelector('track[label="thumbnails"]'),L=(T=C==null?void 0:C.getAttribute("src"))!=null?T:"";C==null||C.removeAttribute("src"),setTimeout(()=>{C==null||C.setAttribute("src",L)},0)}z.mode!=="hidden"&&(z.mode="hidden")}})};ee.once(bt.default.Events.MANIFEST_LOADED,se),ee.once(bt.default.Events.MEDIA_ATTACHED,se)}function Tr(J,ee,ie,se,z){let N=document.createElement("track");return N.kind=ee,N.label=ie,se&&(N.srclang=se),z&&(N.id=z),N.track.mode="disabled",N.setAttribute("data-removeondestroy",""),J.append(N),N.track}function $i(J,ee){let ie=Array.prototype.find.call(J.querySelectorAll("track"),se=>se.track===ee);ie==null||ie.remove()}var Wt="cuepoints",xr=Object.freeze({label:Wt}),er=(J,{label:ee=Wt}=xr)=>{var ie;return(ie=Array.from(J.querySelectorAll("track")).find(se=>se.track.label===ee&&se.track.kind==="metadata"))==null?void 0:ie.track};async function jr(J,ee,ie=xr){let se=er(J,ie);if(!se){let{label:z=Wt}=ie;se=Tr(J,"metadata",z),se.mode="hidden",await new Promise(N=>setTimeout(()=>N(void 0),0))}return[...ee].sort(({time:z},{time:N})=>N-z).forEach(({time:z,value:N})=>{var B,A;let T=Array.prototype.findIndex.call(se==null?void 0:se.cues,D=>D.startTime>=z),C=(B=se==null?void 0:se.cues)==null?void 0:B[T],L=C?C.startTime:Number.isFinite(J.duration)?J.duration:Number.MAX_SAFE_INTEGER,M=(A=se==null?void 0:se.cues)==null?void 0:A[T-1];M&&(M.endTime=z);let P=new VTTCue(z,L,JSON.stringify(N!=null?N:null));se.addCue(P)}),se}var Vr=J=>({time:J.startTime,value:JSON.parse(J.text)});function Ji(J,ee={label:Wt}){let ie=er(J,ee);return ie!=null&&ie.cues?Array.from(ie.cues,se=>Vr(se)):[]}function Yr(J,ee={label:Wt}){var se;let ie=er(J,ee);if(!!((se=ie==null?void 0:ie.activeCues)!=null&&se.length))return Vr(ie.activeCues[0])}async function Xr(J,ee=xr){let ie=await jr(J,[],ee);return yt(J,"cuechange",()=>{let se=Yr(J);if(se){let z=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:se});J.dispatchEvent(z)}},{},ie),ie}var zr,Qr,Zi=(Qr=(zr=globalThis==null?void 0:globalThis.navigator)==null?void 0:zr.userAgent)!=null?Qr:"",qi=Zi.toLowerCase().indexOf("android")!==-1,Pt=new WeakMap,Zr="mux.com",$r,Jr,qr=(Jr=($r=xt.default).isSupported)==null?void 0:Jr.call($r),en=qi,Fn=()=>tr.default.utils.now(),tn=tr.default.utils.generateUUID,Un=(J,{domain:ee=Zr}={})=>{if(!J)return;let[ie,se=""]=Nr(J);return`https://stream.${ee}/${ie}.m3u8${se}`},rn=J=>{if(!J)return;let[ee]=J.split("?");return ee||void 0},nn=J=>{if(!J||!J.startsWith("https://stream."))return;let[ee]=new URL(J).pathname.slice(1).split(".m3u8");return ee||void 0},an=J=>{var ee,ie,se;return(ee=J==null?void 0:J.metadata)!=null&&ee.video_id?J.metadata.video_id:ti(J)&&(se=(ie=rn(J.playbackId))!=null?ie:nn(J.src))!=null?se:J.src},Bn=J=>{var ee;return(ee=Pt.get(J))==null?void 0:ee.error},Nn=(J,ee,ie)=>{sn(ee,ie);let{metadata:se={}}=J,{view_session_id:z=tn()}=se,N=an(J);se.view_session_id=z,se.video_id=N,J.metadata=se,Pt.set(ee,{});let T=on(J,ee);un(J,ee,T),fn(J,ee,T),T&&Xr(ee);let C=Wr(J,ee,T),L=Gr(J,ee,T);return{engine:T,setAutoplay:C,setPreload:L}},sn=(J,ee)=>{let ie=ee==null?void 0:ee.engine;ie&&(ie.detachMedia(),ie.destroy()),(J==null?void 0:J.mux)&&!J.mux.deleted&&(J.mux.destroy(),delete J.mux),J&&(J.removeAttribute("src"),J.load(),J.removeEventListener("error",ii),J.removeEventListener("error",Sr),J.removeEventListener("durationchange",ri),Pt.delete(J),J.dispatchEvent(new Event("teardown")))};function ei(J,ee){var M;let ie=yr(J);if(!(ie===Et.M3U8))return!0;let z=!ie||((M=ee.canPlayType(ie))!=null?M:!0),{preferPlayback:N}=J,T=N===pr.MSE,C=N===pr.NATIVE;return z&&(C||!(qr&&(T||en)))}var on=(J,ee)=>{let{debug:ie,streamType:se,startTime:z=-1,metadata:N,preferCmcd:T}=J,L=yr(J)===Et.M3U8,M=ei(J,ee);if(L&&!M&&qr){let P={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0},B=ln(se),A=T!==Zt.NONE?{useHeaders:T===Zt.HEADER,sessionId:N.view_session_id,contentId:N.video_id}:void 0;return new xt.default({debug:ie,startPosition:z,cmcd:A,...P,...B})}},ln=J=>[Kt.LIVE,Kt.DVR].includes(J)?{backBufferLength:8}:[Kt.LL_LIVE,Kt.LL_DVR].includes(J)?{backBufferLength:4,maxFragLookUpTolerance:.001}:{},ti=({playbackId:J,src:ee,customDomain:ie})=>{if(J)return!0;if(typeof ee!="string")return!1;let se=window==null?void 0:window.location.href,z=new URL(ee,se).hostname.toLocaleLowerCase();return z.includes(Zr)||!!ie&&z.includes(ie.toLocaleLowerCase())},un=(J,ee,ie)=>{var N;let{envKey:se}=J,z=ti(J);if(se||z){let{playerInitTime:T,playerSoftwareName:C,playerSoftwareVersion:L,beaconCollectionDomain:M,debug:P,disableCookies:B}=J,A={...J.metadata,video_title:((N=J==null?void 0:J.metadata)==null?void 0:N.video_title)||void 0},D=x=>typeof x.player_error_code=="string"?!1:typeof J.errorTranslator=="function"?J.errorTranslator(x):x;tr.default.monitor(ee,{debug:P,beaconCollectionDomain:M,hlsjs:ie,Hls:ie?xt.default:void 0,automaticErrorTracking:!1,errorTranslator:D,disableCookies:B,data:{...se?{env_key:se}:{},player_software_name:C,player_software:C,player_software_version:L,player_init_time:T,...A}})}},fn=(J,ee,ie)=>{var N;let se=ei(J,ee),{src:z}=J;ee&&se?(typeof z=="string"?(ee.setAttribute("src",z),J.startTime&&(((N=Pt.get(ee))!=null?N:{}).startTime=J.startTime,ee.addEventListener("durationchange",ri,{once:!0}))):ee.removeAttribute("src"),ee.addEventListener("error",ii),ee.addEventListener("error",Sr)):ie&&z?(ie.on(xt.default.Events.ERROR,(T,C)=>{let L={[xt.default.ErrorTypes.NETWORK_ERROR]:$e.MEDIA_ERR_NETWORK,[xt.default.ErrorTypes.MEDIA_ERROR]:$e.MEDIA_ERR_DECODE},M=new $e("",L[C.type]);M.fatal=C.fatal,M.data=C,ee.dispatchEvent(new CustomEvent("error",{detail:M}))}),ee.addEventListener("error",Sr),Hr(ee,ie),ie.attachMedia(ee)):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 ri(J){var se;let ee=J.target,ie=(se=Pt.get(ee))==null?void 0:se.startTime;if(!!ie&&Br(ee.seekable,ee.duration,ie)){let z=ee.preload==="auto";z&&(ee.preload="none"),ee.currentTime=ie,z&&(ee.preload="auto")}}async function ii(J){if(!J.isTrusted)return;J.stopImmediatePropagation();let ee=J.target;if(!(ee!=null&&ee.error))return;let{message:ie,code:se}=ee.error,z=new $e(ie,se);if(ee.src&&(se!==$e.MEDIA_ERR_DECODE||se!==void 0))try{let{status:N}=await fetch(ee.src);z.data={response:{code:N}}}catch{}ee.dispatchEvent(new CustomEvent("error",{detail:z}))}function Sr(J){var se,z;if(!(J instanceof CustomEvent)||!(J.detail instanceof $e))return;let ee=J.target,ie=J.detail;!ie||!ie.fatal||(((se=Pt.get(ee))!=null?se:{}).error=ie,(z=ee.mux)==null||z.emit("error",{player_error_code:ie.code,player_error_message:ie.message}))}})();
33
33
  /*!
34
34
  * JavaScript Cookie v2.1.3
35
35
  * https://github.com/js-cookie/js-cookie