lemon-mse 0.4.3 → 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/lemon/hls.js DELETED
@@ -1,30 +0,0 @@
1
- (function(g,f){if(typeof define=="function"&&define.amd){define(f)}else if(typeof exports=="object" && typeof module<"u"){module.exports=f()}else{var m=f();for(var i in m) g[i]=m[i]}}(typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : this,function(){var exports={};var __exports=exports;var module={exports};
2
- "use strict";var Tl=Object.create;var Nt=Object.defineProperty;var Sl=Object.getOwnPropertyDescriptor;var xl=Object.getOwnPropertyNames;var Ll=Object.getPrototypeOf,Al=Object.prototype.hasOwnProperty;var Rl=(se,oe)=>()=>(oe||se((oe={exports:{}}).exports,oe),oe.exports),bl=(se,oe)=>{for(var Se in oe)Nt(se,Se,{get:oe[Se],enumerable:!0})},wn=(se,oe,Se,Ue)=>{if(oe&&typeof oe=="object"||typeof oe=="function")for(let te of xl(oe))!Al.call(se,te)&&te!==Se&&Nt(se,te,{get:()=>oe[te],enumerable:!(Ue=Sl(oe,te))||Ue.enumerable});return se};var Il=(se,oe,Se)=>(Se=se!=null?Tl(Ll(se)):{},wn(oe||!se||!se.__esModule?Nt(Se,"default",{value:se,enumerable:!0}):Se,se)),_l=se=>wn(Nt({},"__esModule",{value:!0}),se);var Nn=Rl((Fn,Ir)=>{(function se(oe){(function(Se,Ue){typeof Fn=="object"&&typeof Ir<"u"?Ir.exports=Ue():typeof define=="function"&&define.amd?define(Ue):(Se=typeof globalThis<"u"?globalThis:Se||self,Se.Hls=Ue())})(this,function(){"use strict";function Se(n,s,i){if(_r())return Reflect.construct.apply(null,arguments);var t=[null];t.push.apply(t,s);var e=new(n.bind.apply(n,t));return i&&it(e,i.prototype),e}function Ue(n,s){for(var i=0;i<s.length;i++){var t=s[i];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(n,Cr(t.key),t)}}function te(n,s,i){return s&&Ue(n.prototype,s),i&&Ue(n,i),Object.defineProperty(n,"prototype",{writable:!1}),n}function Un(n,s,i){return(s=Cr(s))in n?Object.defineProperty(n,s,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[s]=i,n}function de(){return de=Object.assign?Object.assign.bind():function(n){for(var s=1;s<arguments.length;s++){var i=arguments[s];for(var t in i)({}).hasOwnProperty.call(i,t)&&(n[t]=i[t])}return n},de.apply(null,arguments)}function Bt(n){return Bt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(s){return s.__proto__||Object.getPrototypeOf(s)},Bt(n)}function he(n,s){n.prototype=Object.create(s.prototype),n.prototype.constructor=n,it(n,s)}function Gn(n){try{return Function.toString.call(n).indexOf("[native code]")!==-1}catch{return typeof n=="function"}}function _r(){try{var n=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(_r=function(){return!!n})()}function Dr(n,s){var i=Object.keys(n);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(n);s&&(t=t.filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})),i.push.apply(i,t)}return i}function xe(n){for(var s=1;s<arguments.length;s++){var i=arguments[s]!=null?arguments[s]:{};s%2?Dr(Object(i),!0).forEach(function(t){Un(n,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(i)):Dr(Object(i)).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(i,t))})}return n}function it(n,s){return it=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,t){return i.__proto__=t,i},it(n,s)}function Hn(n,s){if(typeof n!="object"||!n)return n;var i=n[Symbol.toPrimitive];if(i!==void 0){var t=i.call(n,s);if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(n)}function Cr(n){var s=Hn(n,"string");return typeof s=="symbol"?s:s+""}function nt(n){var s=typeof Map=="function"?new Map:void 0;return nt=function(i){if(i===null||!Gn(i))return i;if(typeof i!="function")throw new TypeError("Super expression must either be null or a function");if(s!==void 0){if(s.has(i))return s.get(i);s.set(i,t)}function t(){return Se(i,arguments,Bt(this).constructor)}return t.prototype=Object.create(i.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),it(t,i)},nt(n)}function Vn(){try{return crypto.randomUUID()}catch{try{var n=URL.createObjectURL(new Blob),s=n.toString();return URL.revokeObjectURL(n),s.slice(s.lastIndexOf("/")+1)}catch{var i=new Date().getTime(),t="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var o=(i+Math.random()*16)%16|0;return i=Math.floor(i/16),(a=="x"?o:o&3|8).toString(16)});return t}}}function kr(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Ut={exports:{}},Pr;function Kn(){return Pr||(Pr=1,function(n){var s=Object.prototype.hasOwnProperty,i="~";function t(){}Object.create&&(t.prototype=Object.create(null),new t().__proto__||(i=!1));function e(l,u,f){this.fn=l,this.context=u,this.once=f||!1}function r(l,u,f,d,h){if(typeof f!="function")throw new TypeError("The listener must be a function");var v=new e(f,d||l,h),c=i?i+u:u;return l._events[c]?l._events[c].fn?l._events[c]=[l._events[c],v]:l._events[c].push(v):(l._events[c]=v,l._eventsCount++),l}function a(l,u){--l._eventsCount===0?l._events=new t:delete l._events[u]}function o(){this._events=new t,this._eventsCount=0}o.prototype.eventNames=function(){var u=[],f,d;if(this._eventsCount===0)return u;for(d in f=this._events)s.call(f,d)&&u.push(i?d.slice(1):d);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(f)):u},o.prototype.listeners=function(u){var f=i?i+u:u,d=this._events[f];if(!d)return[];if(d.fn)return[d.fn];for(var h=0,v=d.length,c=new Array(v);h<v;h++)c[h]=d[h].fn;return c},o.prototype.listenerCount=function(u){var f=i?i+u:u,d=this._events[f];return d?d.fn?1:d.length:0},o.prototype.emit=function(u,f,d,h,v,c){var g=i?i+u:u;if(!this._events[g])return!1;var m=this._events[g],p=arguments.length,y,S;if(m.fn){switch(m.once&&this.removeListener(u,m.fn,void 0,!0),p){case 1:return m.fn.call(m.context),!0;case 2:return m.fn.call(m.context,f),!0;case 3:return m.fn.call(m.context,f,d),!0;case 4:return m.fn.call(m.context,f,d,h),!0;case 5:return m.fn.call(m.context,f,d,h,v),!0;case 6:return m.fn.call(m.context,f,d,h,v,c),!0}for(S=1,y=new Array(p-1);S<p;S++)y[S-1]=arguments[S];m.fn.apply(m.context,y)}else{var T=m.length,x;for(S=0;S<T;S++)switch(m[S].once&&this.removeListener(u,m[S].fn,void 0,!0),p){case 1:m[S].fn.call(m[S].context);break;case 2:m[S].fn.call(m[S].context,f);break;case 3:m[S].fn.call(m[S].context,f,d);break;case 4:m[S].fn.call(m[S].context,f,d,h);break;default:if(!y)for(x=1,y=new Array(p-1);x<p;x++)y[x-1]=arguments[x];m[S].fn.apply(m[S].context,y)}}return!0},o.prototype.on=function(u,f,d){return r(this,u,f,d,!1)},o.prototype.once=function(u,f,d){return r(this,u,f,d,!0)},o.prototype.removeListener=function(u,f,d,h){var v=i?i+u:u;if(!this._events[v])return this;if(!f)return a(this,v),this;var c=this._events[v];if(c.fn)c.fn===f&&(!h||c.once)&&(!d||c.context===d)&&a(this,v);else{for(var g=0,m=[],p=c.length;g<p;g++)(c[g].fn!==f||h&&!c[g].once||d&&c[g].context!==d)&&m.push(c[g]);m.length?this._events[v]=m.length===1?m[0]:m:a(this,v)}return this},o.prototype.removeAllListeners=function(u){var f;return u?(f=i?i+u:u,this._events[f]&&a(this,f)):(this._events=new t,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=i,o.EventEmitter=o,n.exports=o}(Ut)),Ut.exports}var Wn=Kn(),Gt=kr(Wn),Ht={exports:{}},Mr;function Yn(){return Mr||(Mr=1,function(n,s){(function(i){var t=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,e=/^(?=([^\/?#]*))\1([^]*)$/,r=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(l,u,f){if(f=f||{},l=l.trim(),u=u.trim(),!u){if(!f.alwaysNormalize)return l;var d=o.parseURL(l);if(!d)throw new Error("Error trying to parse base URL.");return d.path=o.normalizePath(d.path),o.buildURLFromParts(d)}var h=o.parseURL(u);if(!h)throw new Error("Error trying to parse relative URL.");if(h.scheme)return f.alwaysNormalize?(h.path=o.normalizePath(h.path),o.buildURLFromParts(h)):u;var v=o.parseURL(l);if(!v)throw new Error("Error trying to parse base URL.");if(!v.netLoc&&v.path&&v.path[0]!=="/"){var c=e.exec(v.path);v.netLoc=c[1],v.path=c[2]}v.netLoc&&!v.path&&(v.path="/");var g={scheme:v.scheme,netLoc:h.netLoc,path:null,params:h.params,query:h.query,fragment:h.fragment};if(!h.netLoc&&(g.netLoc=v.netLoc,h.path[0]!=="/"))if(!h.path)g.path=v.path,h.params||(g.params=v.params,h.query||(g.query=v.query));else{var m=v.path,p=m.substring(0,m.lastIndexOf("/")+1)+h.path;g.path=o.normalizePath(p)}return g.path===null&&(g.path=f.alwaysNormalize?o.normalizePath(h.path):h.path),o.buildURLFromParts(g)},parseURL:function(l){var u=t.exec(l);return u?{scheme:u[1]||"",netLoc:u[2]||"",path:u[3]||"",params:u[4]||"",query:u[5]||"",fragment:u[6]||""}:null},normalizePath:function(l){for(l=l.split("").reverse().join("").replace(r,"");l.length!==(l=l.replace(a,"")).length;);return l.split("").reverse().join("")},buildURLFromParts:function(l){return l.scheme+l.netLoc+l.path+l.params+l.query+l.fragment}};n.exports=o})()}(Ht)),Ht.exports}var Vt=Yn(),N=Number.isFinite||function(n){return typeof n=="number"&&isFinite(n)},qn=Number.isSafeInteger||function(n){return typeof n=="number"&&Math.abs(n)<=jn},jn=Number.MAX_SAFE_INTEGER||9007199254740991,K=function(n){return n.NETWORK_ERROR="networkError",n.MEDIA_ERROR="mediaError",n.KEY_SYSTEM_ERROR="keySystemError",n.MUX_ERROR="muxError",n.OTHER_ERROR="otherError",n}({}),D=function(n){return n.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",n.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",n.KEY_SYSTEM_NO_SESSION="keySystemNoSession",n.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",n.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",n.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",n.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",n.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",n.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",n.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",n.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",n.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",n.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",n.MANIFEST_LOAD_ERROR="manifestLoadError",n.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",n.MANIFEST_PARSING_ERROR="manifestParsingError",n.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",n.LEVEL_EMPTY_ERROR="levelEmptyError",n.LEVEL_LOAD_ERROR="levelLoadError",n.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",n.LEVEL_PARSING_ERROR="levelParsingError",n.LEVEL_SWITCH_ERROR="levelSwitchError",n.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",n.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",n.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",n.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",n.FRAG_LOAD_ERROR="fragLoadError",n.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",n.FRAG_DECRYPT_ERROR="fragDecryptError",n.FRAG_PARSING_ERROR="fragParsingError",n.FRAG_GAP="fragGap",n.REMUX_ALLOC_ERROR="remuxAllocError",n.KEY_LOAD_ERROR="keyLoadError",n.KEY_LOAD_TIMEOUT="keyLoadTimeOut",n.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",n.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",n.BUFFER_APPEND_ERROR="bufferAppendError",n.BUFFER_APPENDING_ERROR="bufferAppendingError",n.BUFFER_STALLED_ERROR="bufferStalledError",n.BUFFER_FULL_ERROR="bufferFullError",n.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",n.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",n.ASSET_LIST_LOAD_ERROR="assetListLoadError",n.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",n.ASSET_LIST_PARSING_ERROR="assetListParsingError",n.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",n.INTERNAL_EXCEPTION="internalException",n.INTERNAL_ABORTED="aborted",n.ATTACH_MEDIA_ERROR="attachMediaError",n.UNKNOWN="unknown",n}({}),E=function(n){return n.MEDIA_ATTACHING="hlsMediaAttaching",n.MEDIA_ATTACHED="hlsMediaAttached",n.MEDIA_DETACHING="hlsMediaDetaching",n.MEDIA_DETACHED="hlsMediaDetached",n.MEDIA_ENDED="hlsMediaEnded",n.STALL_RESOLVED="hlsStallResolved",n.BUFFER_RESET="hlsBufferReset",n.BUFFER_CODECS="hlsBufferCodecs",n.BUFFER_CREATED="hlsBufferCreated",n.BUFFER_APPENDING="hlsBufferAppending",n.BUFFER_APPENDED="hlsBufferAppended",n.BUFFER_EOS="hlsBufferEos",n.BUFFERED_TO_END="hlsBufferedToEnd",n.BUFFER_FLUSHING="hlsBufferFlushing",n.BUFFER_FLUSHED="hlsBufferFlushed",n.MANIFEST_LOADING="hlsManifestLoading",n.MANIFEST_LOADED="hlsManifestLoaded",n.MANIFEST_PARSED="hlsManifestParsed",n.LEVEL_SWITCHING="hlsLevelSwitching",n.LEVEL_SWITCHED="hlsLevelSwitched",n.LEVEL_LOADING="hlsLevelLoading",n.LEVEL_LOADED="hlsLevelLoaded",n.LEVEL_UPDATED="hlsLevelUpdated",n.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",n.LEVELS_UPDATED="hlsLevelsUpdated",n.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",n.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",n.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",n.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",n.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",n.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",n.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",n.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",n.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",n.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",n.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",n.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",n.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",n.CUES_PARSED="hlsCuesParsed",n.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",n.INIT_PTS_FOUND="hlsInitPtsFound",n.FRAG_LOADING="hlsFragLoading",n.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",n.FRAG_LOADED="hlsFragLoaded",n.FRAG_DECRYPTED="hlsFragDecrypted",n.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",n.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",n.FRAG_PARSING_METADATA="hlsFragParsingMetadata",n.FRAG_PARSED="hlsFragParsed",n.FRAG_BUFFERED="hlsFragBuffered",n.FRAG_CHANGED="hlsFragChanged",n.FPS_DROP="hlsFpsDrop",n.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",n.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",n.ERROR="hlsError",n.DESTROYING="hlsDestroying",n.KEY_LOADING="hlsKeyLoading",n.KEY_LOADED="hlsKeyLoaded",n.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",n.BACK_BUFFER_REACHED="hlsBackBufferReached",n.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",n.ASSET_LIST_LOADING="hlsAssetListLoading",n.ASSET_LIST_LOADED="hlsAssetListLoaded",n.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",n.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",n.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",n.INTERSTITIAL_STARTED="hlsInterstitialStarted",n.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",n.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",n.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",n.INTERSTITIAL_ENDED="hlsInterstitialEnded",n.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",n.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",n.EVENT_CUE_ENTER="hlsEventCueEnter",n}({}),j={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},W={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"},Xe=function(){function n(i,t,e){t===void 0&&(t=0),e===void 0&&(e=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=i,this.alpha_=i?Math.exp(Math.log(.5)/i):0,this.estimate_=t,this.totalWeight_=e}var s=n.prototype;return s.sample=function(t,e){var r=Math.pow(this.alpha_,t);this.estimate_=e*(1-r)+r*this.estimate_,this.totalWeight_+=t},s.getTotalWeight=function(){return this.totalWeight_},s.getEstimate=function(){if(this.alpha_){var t=1-Math.pow(this.alpha_,this.totalWeight_);if(t)return this.estimate_/t}return this.estimate_},n}(),Xn=function(){function n(i,t,e,r){r===void 0&&(r=100),this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=e,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new Xe(i),this.fast_=new Xe(t),this.defaultTTFB_=r,this.ttfb_=new Xe(i)}var s=n.prototype;return s.update=function(t,e){var r=this.slow_,a=this.fast_,o=this.ttfb_;r.halfLife!==t&&(this.slow_=new Xe(t,r.getEstimate(),r.getTotalWeight())),a.halfLife!==e&&(this.fast_=new Xe(e,a.getEstimate(),a.getTotalWeight())),o.halfLife!==t&&(this.ttfb_=new Xe(t,o.getEstimate(),o.getTotalWeight()))},s.sample=function(t,e){t=Math.max(t,this.minDelayMs_);var r=8*e,a=t/1e3,o=r/a;this.fast_.sample(a,o),this.slow_.sample(a,o)},s.sampleTTFB=function(t){var e=t/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(e,2)/2);this.ttfb_.sample(r,Math.max(t,5))},s.canEstimate=function(){return this.fast_.getTotalWeight()>=this.minWeight_},s.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},s.getEstimateTTFB=function(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_},s.destroy=function(){},te(n,[{key:"defaultEstimate",get:function(){return this.defaultEstimate_}}])}(),$e=function(s,i){this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;var t="["+s+"]:";this.trace=Ke,this.debug=i.debug.bind(null,t),this.log=i.log.bind(null,t),this.warn=i.warn.bind(null,t),this.info=i.info.bind(null,t),this.error=i.error.bind(null,t)},Ke=function(){},$n={trace:Ke,debug:Ke,log:Ke,warn:Ke,info:Ke,error:Ke};function Kt(){return de({},$n)}function zn(n,s){var i=self.console[n];return i?i.bind(self.console,(s?"["+s+"] ":"")+"["+n+"] >"):Ke}function Or(n,s,i){return s[n]?s[n].bind(s):zn(n,i)}var Wt=Kt();function wr(n,s,i){var t=Kt();if(typeof console=="object"&&n===!0||typeof n=="object"){var e=["debug","log","info","warn","error"];e.forEach(function(r){t[r]=Or(r,n,i)});try{t.log('Debug logs enabled for "'+s+'" in hls.js version 1.6.0')}catch{return Kt()}e.forEach(function(r){Wt[r]=Or(r,n)})}else de(Wt,t);return t}var X=Wt,Yt,Fr;function Qn(){return Fr||(Fr=1,Yt=void 0),Yt}var Nr=Qn(),Zn=kr(Nr);function Ce(n,s){if(s===void 0&&(s=!1),typeof TextDecoder<"u"){var i=new TextDecoder("utf-8"),t=i.decode(n);if(s){var e=t.indexOf("\0");return e!==-1?t.substring(0,e):t}return t.replace(/\0/g,"")}for(var r=n.length,a,o,l,u="",f=0;f<r;){if(a=n[f++],a===0&&s)return u;if(a===0||a===3)continue;switch(a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:u+=String.fromCharCode(a);break;case 12:case 13:o=n[f++],u+=String.fromCharCode((a&31)<<6|o&63);break;case 14:o=n[f++],l=n[f++],u+=String.fromCharCode((a&15)<<12|(o&63)<<6|(l&63)<<0);break}}return u}var Br={hexDump:function(s){for(var i="",t=0;t<s.length;t++){var e=s[t].toString(16);e.length<2&&(e="0"+e),i+=e}return i}},qt=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}},re={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"},Ur=function(){function n(i){this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,typeof i=="string"&&(i={url:i}),this.base=i,ea(this,"stats")}var s=n.prototype;return s.setByteRange=function(t,e){var r=t.split("@",2),a;r.length===1?a=e?.byteRangeEndOffset||0:a=parseInt(r[1]),this._byteRange=[a,parseInt(r[0])+a]},s.clearElementaryStreamInfo=function(){var t=this.elementaryStreams;t[re.AUDIO]=null,t[re.VIDEO]=null,t[re.AUDIOVIDEO]=null},te(n,[{key:"baseurl",get:function(){return this.base.url}},{key:"byteRange",get:function(){return this._byteRange===null?[]:this._byteRange}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"elementaryStreams",get:function(){if(this._streams===null){var t;this._streams=(t={},t[re.AUDIO]=null,t[re.VIDEO]=null,t[re.AUDIOVIDEO]=null,t)}return this._streams},set:function(t){this._streams=t}},{key:"hasStats",get:function(){return this._stats!==null}},{key:"hasStreams",get:function(){return this._streams!==null}},{key:"stats",get:function(){return this._stats===null&&(this._stats=new qt),this._stats},set:function(t){this._stats=t}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Vt.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(t){this._url=t}}])}();function we(n){return n.sn!=="initSegment"}var jt=function(n){function s(t,e){var r;return r=n.call(this,e)||this,r._decryptdata=null,r._programDateTime=null,r._ref=null,r._bitrate=void 0,r.rawProgramDateTime=null,r.tagList=[],r.duration=0,r.sn=0,r.levelkeys=void 0,r.type=void 0,r.loader=null,r.keyLoader=null,r.level=-1,r.cc=0,r.startPTS=void 0,r.endPTS=void 0,r.startDTS=void 0,r.endDTS=void 0,r.start=0,r.playlistOffset=0,r.deltaPTS=void 0,r.maxStartPTS=void 0,r.minEndPTS=void 0,r.data=void 0,r.bitrateTest=!1,r.title=null,r.initSegment=null,r.endList=void 0,r.gap=void 0,r.urlId=0,r.type=t,r}he(s,n);var i=s.prototype;return i.addStart=function(e){this.setStart(this.start+e)},i.setStart=function(e){this.start=e,this._ref&&(this._ref.start=e)},i.setDuration=function(e){this.duration=e,this._ref&&(this._ref.duration=e)},i.setKeyFormat=function(e){if(this.levelkeys){var r=this.levelkeys[e];r&&!this._decryptdata&&(this._decryptdata=r.getDecryptData(this.sn))}},i.abortRequests=function(){var e,r;(e=this.loader)==null||e.abort(),(r=this.keyLoader)==null||r.abort()},i.setElementaryStreamInfo=function(e,r,a,o,l,u){u===void 0&&(u=!1);var f=this.elementaryStreams,d=f[e];if(!d){f[e]={startPTS:r,endPTS:a,startDTS:o,endDTS:l,partial:u};return}d.startPTS=Math.min(d.startPTS,r),d.endPTS=Math.max(d.endPTS,a),d.startDTS=Math.min(d.startDTS,o),d.endDTS=Math.max(d.endDTS,l)},te(s,[{key:"byteLength",get:function(){if(this.hasStats){var e=this.stats.total;if(e)return e}if(this.byteRange){var r=this.byteRange[0],a=this.byteRange[1];if(N(r)&&N(a))return a-r}return null}},{key:"bitrate",get:function(){return this.byteLength?this.byteLength*8/this.duration:this._bitrate?this._bitrate:null},set:function(e){this._bitrate=e}},{key:"decryptdata",get:function(){var e=this.levelkeys;if(!e&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var r=this.levelkeys.identity;if(r)this._decryptdata=r.getDecryptData(this.sn);else{var a=Object.keys(this.levelkeys);if(a.length===1)return this._decryptdata=this.levelkeys[a[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null)return null;var e=N(this.duration)?this.duration:0;return this.programDateTime+e*1e3}},{key:"encrypted",get:function(){var e;if((e=this._decryptdata)!=null&&e.encrypted)return!0;if(this.levelkeys){var r=Object.keys(this.levelkeys),a=r.length;if(a>1||a===1&&this.levelkeys[r[0]].encrypted)return!0}return!1}},{key:"programDateTime",get:function(){return this._programDateTime===null&&this.rawProgramDateTime&&(this.programDateTime=Date.parse(this.rawProgramDateTime)),this._programDateTime},set:function(e){if(!N(e)){this._programDateTime=this.rawProgramDateTime=null;return}this._programDateTime=e}},{key:"ref",get:function(){return we(this)?(this._ref||(this._ref={base:this.base,start:this.start,duration:this.duration,sn:this.sn,programDateTime:this.programDateTime}),this._ref):null}}])}(Ur),Jn=function(n){function s(i,t,e,r,a){var o;o=n.call(this,e)||this,o.fragOffset=0,o.duration=0,o.gap=!1,o.independent=!1,o.relurl=void 0,o.fragment=void 0,o.index=void 0,o.duration=i.decimalFloatingPoint("DURATION"),o.gap=i.bool("GAP"),o.independent=i.bool("INDEPENDENT"),o.relurl=i.enumeratedString("URI"),o.fragment=t,o.index=r;var l=i.enumeratedString("BYTERANGE");return l&&o.setByteRange(l,a),a&&(o.fragOffset=a.fragOffset+a.duration),o}return he(s,n),te(s,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var t=this.elementaryStreams;return!!(t.audio||t.video||t.audiovideo)}}])}(Ur);function Gr(n,s){var i=Object.getPrototypeOf(n);if(i){var t=Object.getOwnPropertyDescriptor(i,s);return t||Gr(i,s)}}function ea(n,s){var i=Gr(n,s);i&&(i.enumerable=!0,Object.defineProperty(n,s,i))}var ct=Math.pow(2,32)-1,ta=[].push,Hr={video:1,audio:2,id3:3,text:4};function ce(n){return String.fromCharCode.apply(null,n)}function Vr(n,s){var i=n[s]<<8|n[s+1];return i<0?65536+i:i}function H(n,s){var i=Wr(n,s);return i<0?4294967296+i:i}function Kr(n,s){var i=H(n,s);return i*=Math.pow(2,32),i+=H(n,s+4),i}function Wr(n,s){return n[s]<<24|n[s+1]<<16|n[s+2]<<8|n[s+3]}function Xt(n,s,i){n[s]=i>>24,n[s+1]=i>>16&255,n[s+2]=i>>8&255,n[s+3]=i&255}function ra(n){for(var s=n.byteLength,i=0;i<s;){var t=H(n,i);if(t>8&&n[i+4]===109&&n[i+5]===111&&n[i+6]===111&&n[i+7]===102)return!0;i=t>1?i+t:s}return!1}function V(n,s){var i=[];if(!s.length)return i;for(var t=n.byteLength,e=0;e<t;){var r=H(n,e),a=ce(n.subarray(e+4,e+8)),o=r>1?e+r:t;if(a===s[0])if(s.length===1)i.push(n.subarray(e+8,o));else{var l=V(n.subarray(e+8,o),s.slice(1));l.length&&ta.apply(i,l)}e=o}return i}function ia(n){var s=[],i=n[0],t=8,e=H(n,t);t+=4;var r=0,a=0;i===0?(r=H(n,t),a=H(n,t+4),t+=8):(r=Kr(n,t),a=Kr(n,t+8),t+=16),t+=2;var o=n.length+a,l=Vr(n,t);t+=2;for(var u=0;u<l;u++){var f=t,d=H(n,f);f+=4;var h=d&2147483647,v=(d&2147483648)>>>31;if(v===1)return X.warn("SIDX has hierarchical references (not supported)"),null;var c=H(n,f);f+=4,s.push({referenceSize:h,subsegmentDuration:c,info:{duration:c/e,start:o,end:o+h-1}}),o+=h,f+=4,t=f}return{earliestPresentationTime:r,timescale:e,version:i,referencesCount:l,references:s}}function Yr(n){for(var s=[],i=V(n,["moov","trak"]),t=0;t<i.length;t++){var e=i[t],r=V(e,["tkhd"])[0];if(r){var a=r[0],o=H(r,a===0?12:20),l=V(e,["mdia","mdhd"])[0];if(l){a=l[0];var u=H(l,a===0?12:20),f=V(e,["mdia","hdlr"])[0];if(f){var d=ce(f.subarray(8,12)),h={soun:re.AUDIO,vide:re.VIDEO}[d],v=V(e,["mdia","minf","stbl","stsd"])[0],c=na(v);h?(s[o]={timescale:u,type:h,stsd:c},s[h]=xe({timescale:u,id:o},c)):s[o]={timescale:u,type:d,stsd:c}}}}}var g=V(n,["moov","mvex","trex"]);return g.forEach(function(m){var p=H(m,4),y=s[p];y&&(y.default={duration:H(m,12),flags:H(m,20)})}),s}function na(n){var s=n.subarray(8),i=s.subarray(86),t=ce(s.subarray(4,8)),e=t,r,a=t==="enca"||t==="encv";if(a){var o=V(s,[t])[0],l=o.subarray(t==="enca"?28:78),u=V(l,["sinf"]);u.forEach(function(Ee){var De=V(Ee,["schm"])[0];if(De){var ee=ce(De.subarray(4,8));if(ee==="cbcs"||ee==="cenc"){var ye=V(Ee,["frma"])[0];ye&&(e=ce(ye))}}})}var f=e;switch(e){case"avc1":case"avc2":case"avc3":case"avc4":{var d=V(i,["avcC"])[0];e+="."+gt(d[1])+gt(d[2])+gt(d[3]),r=vt(f==="avc1"?"dva1":"dvav",i);break}case"mp4a":{var h=V(s,[t])[0],v=V(h.subarray(28),["esds"])[0];if(v&&v.length>7){var c=4;if(v[c++]!==3)break;c=$t(v,c),c+=2;var g=v[c++];if(g&128&&(c+=2),g&64&&(c+=v[c++]),v[c++]!==4)break;c=$t(v,c);var m=v[c++];if(m===64)e+="."+gt(m);else break;if(c+=12,v[c++]!==5)break;c=$t(v,c);var p=v[c++],y=(p&248)>>3;y===31&&(y+=1+((p&7)<<3)+((v[c]&224)>>5)),e+="."+y}break}case"hvc1":case"hev1":{var S=V(i,["hvcC"]);if(S){var T=S[0],x=T[1],R=["","A","B","C"][x>>6],L=x&31,A=H(T,2),C=(x&32)>>5?"H":"L",_=T[12],b=T.subarray(6,12);e+="."+R+L,e+="."+A.toString(16).toUpperCase(),e+="."+C+_;for(var I="",k=b.length;k--;){var w=b[k];if(w||I){var M=w.toString(16).toUpperCase();I="."+M+I}}e+=I}r=vt(f=="hev1"?"dvhe":"dvh1",i);break}case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":{e=vt(e,i)||e;break}case"vp09":{var P=V(i,["vpcC"])[0],F=P[4],B=P[5],U=P[6]>>4&15;e+="."+Fe(F)+"."+Fe(B)+"."+Fe(U);break}case"av01":{var G=V(i,["av1C"])[0],z=G[1]>>>5,q=G[1]&31,Q=G[2]>>>7?"H":"M",Y=(G[2]&64)>>6,ae=(G[2]&32)>>5,Z=z===2&&Y?ae?12:10:Y?10:8,ne=(G[2]&16)>>4,Ae=(G[2]&8)>>3,ge=(G[2]&4)>>2,J=G[2]&3,Re=1,ue=1,ie=1,be=0;e+="."+z+"."+Fe(q)+Q+"."+Fe(Z)+"."+ne+"."+Ae+ge+J+"."+Fe(Re)+"."+Fe(ue)+"."+Fe(ie)+"."+be,r=vt("dav1",i);break}}return{codec:e,encrypted:a,supplemental:r}}function vt(n,s){var i=V(s,["dvvC"]),t=i.length?i[0]:V(s,["dvcC"])[0];if(t){var e=t[2]>>1&127,r=t[2]<<5&32|t[3]>>3&31;return n+"."+Fe(e)+"."+Fe(r)}}function $t(n,s){for(var i=s+5;n[s++]&128&&s<i;);return s}function gt(n){return("0"+n.toString(16).toUpperCase()).slice(-2)}function Fe(n){return(n<10?"0":"")+n}function aa(n,s){if(!n||!s)return n;var i=s.keyId;if(i&&s.isCommonEncryption){var t=V(n,["moov","trak"]);t.forEach(function(e){var r=V(e,["mdia","minf","stbl","stsd"])[0],a=r.subarray(8),o=V(a,["enca"]),l=o.length>0;l||(o=V(a,["encv"])),o.forEach(function(u){var f=l?u.subarray(28):u.subarray(78),d=V(f,["sinf"]);d.forEach(function(h){var v=sa(h);if(v){var c=v.subarray(8,24);c.some(function(g){return g!==0})||(X.log("[eme] Patching keyId in 'enc"+(l?"a":"v")+">sinf>>tenc' box: "+Br.hexDump(c)+" -> "+Br.hexDump(i)),v.set(i,8))}})})})}return n}function sa(n){var s=V(n,["schm"])[0];if(s){var i=ce(s.subarray(4,8));if(i==="cbcs"||i==="cenc")return V(n,["schi","tenc"])[0]}return null}function oa(n,s){return V(s,["moof","traf"]).reduce(function(i,t){var e=V(t,["tfdt"])[0],r=e[0],a=V(t,["tfhd"]).reduce(function(o,l){var u=H(l,4),f=n[u];if(f){var d=H(e,4);if(r===1){if(d===ct)return X.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),o;d*=ct+1,d+=H(e,8)}var h=f.timescale||9e4,v=d/h;if(N(v)&&(o===null||v<o))return v}return o},null);return a!==null&&N(a)&&(i===null||a<i)?a:i},null)}function la(n,s){for(var i=0,t=0,e=0,r=V(n,["moof","traf"]),a=0;a<r.length;a++){var o=r[a],l=V(o,["tfhd"])[0],u=H(l,4),f=s[u];if(f){var d=f.default,h=H(l,0)|d?.flags,v=d?.duration;h&8&&(h&2?v=H(l,12):v=H(l,8));for(var c=f.timescale||9e4,g=V(o,["trun"]),m=0;m<g.length;m++){if(i=ua(g[m]),!i&&v){var p=H(g[m],4);i=v*p}f.type===re.VIDEO?t+=i/c:f.type===re.AUDIO&&(e+=i/c)}}}if(t===0&&e===0){for(var y=1/0,S=0,T=0,x=V(n,["sidx"]),R=0;R<x.length;R++){var L=ia(x[R]);if(L!=null&&L.references){y=Math.min(y,L.earliestPresentationTime/L.timescale);var A=L.references.reduce(function(C,_){return C+_.info.duration||0},0);S=Math.max(S,A+L.earliestPresentationTime/L.timescale),T=S-y}}if(T&&N(T))return T}return t||e}function ua(n){var s=H(n,0),i=8;s&1&&(i+=4),s&4&&(i+=4);for(var t=0,e=H(n,4),r=0;r<e;r++){if(s&256){var a=H(n,i);t+=a,i+=4}s&512&&(i+=4),s&1024&&(i+=4),s&2048&&(i+=4)}return t}function fa(n,s,i){V(s,["moof","traf"]).forEach(function(t){V(t,["tfhd"]).forEach(function(e){var r=H(e,4),a=n[r];if(a){var o=a.timescale||9e4;V(t,["tfdt"]).forEach(function(l){var u=l[0],f=i*o;if(f){var d=H(l,4);if(u===0)d-=f,d=Math.max(d,0),Xt(l,4,d);else{d*=Math.pow(2,32),d+=H(l,8),d-=f,d=Math.max(d,0);var h=Math.floor(d/(ct+1)),v=Math.floor(d%(ct+1));Xt(l,4,h),Xt(l,8,v)}}})}})})}function da(n){var s={valid:null,remainder:null},i=V(n,["moof"]);if(i.length<2)return s.remainder=n,s;var t=i[i.length-1];return s.valid=n.slice(0,t.byteOffset-8),s.remainder=n.slice(t.byteOffset-8),s}function ke(n,s){var i=new Uint8Array(n.length+s.length);return i.set(n),i.set(s,n.length),i}function qr(n,s){var i=[],t=s.samples,e=s.timescale,r=s.id,a=!1,o=V(t,["moof"]);return o.map(function(l){var u=l.byteOffset-8,f=V(l,["traf"]);f.map(function(d){var h=V(d,["tfdt"]).map(function(v){var c=v[0],g=H(v,4);return c===1&&(g*=Math.pow(2,32),g+=H(v,8)),g/e})[0];return h!==void 0&&(n=h),V(d,["tfhd"]).map(function(v){var c=H(v,4),g=H(v,0)&16777215,m=(g&1)!==0,p=(g&2)!==0,y=(g&8)!==0,S=0,T=(g&16)!==0,x=0,R=(g&32)!==0,L=8;c===r&&(m&&(L+=8),p&&(L+=4),y&&(S=H(v,L),L+=4),T&&(x=H(v,L),L+=4),R&&(L+=4),s.type==="video"&&(a=zt(s.codec)),V(d,["trun"]).map(function(A){var C=A[0],_=H(A,0)&16777215,b=(_&1)!==0,I=0,k=(_&4)!==0,w=(_&256)!==0,M=0,P=(_&512)!==0,F=0,B=(_&1024)!==0,U=(_&2048)!==0,G=0,z=H(A,4),q=8;b&&(I=H(A,q),q+=4),k&&(q+=4);for(var Q=I+u,Y=0;Y<z;Y++){if(w?(M=H(A,q),q+=4):M=S,P?(F=H(A,q),q+=4):F=x,B&&(q+=4),U&&(C===0?G=H(A,q):G=Wr(A,q),q+=4),s.type===re.VIDEO)for(var ae=0;ae<F;){var Z=H(t,Q);if(Q+=4,ha(a,t[Q])){var ne=t.subarray(Q,Q+Z);jr(ne,a?2:1,n+G/e,i)}Q+=Z,ae+=Z+4}n+=M/e}}))})})}),i}function zt(n){if(!n)return!1;var s=n.substring(0,4);return s==="hvc1"||s==="hev1"||s==="dvh1"||s==="dvhe"}function ha(n,s){if(n){var i=s>>1&63;return i===39||i===40}else{var t=s&31;return t===6}}function jr(n,s,i,t){var e=Xr(n),r=0;r+=s;for(var a=0,o=0,l=0;r<e.length;){a=0;do{if(r>=e.length)break;l=e[r++],a+=l}while(l===255);o=0;do{if(r>=e.length)break;l=e[r++],o+=l}while(l===255);var u=e.length-r,f=r;if(o<u)r+=o;else if(o>u){X.error("Malformed SEI payload. "+o+" is too small, only "+u+" bytes left to parse.");break}if(a===4){var d=e[f++];if(d===181){var h=Vr(e,f);if(f+=2,h===49){var v=H(e,f);if(f+=4,v===1195456820){var c=e[f++];if(c===3){var g=e[f++],m=31&g,p=64&g,y=p?2+m*3:0,S=new Uint8Array(y);if(p){S[0]=g;for(var T=1;T<y;T++)S[T]=e[f++]}t.push({type:c,payloadType:a,pts:i,bytes:S})}}}}}else if(a===5&&o>16){for(var x=[],R=0;R<16;R++){var L=e[f++].toString(16);x.push(L.length==1?"0"+L:L),(R===3||R===5||R===7||R===9)&&x.push("-")}for(var A=o-16,C=new Uint8Array(A),_=0;_<A;_++)C[_]=e[f++];t.push({payloadType:a,pts:i,uuid:x.join(""),userData:Ce(C),userDataBytes:C})}}}function Xr(n){for(var s=n.byteLength,i=[],t=1;t<s-2;)n[t]===0&&n[t+1]===0&&n[t+2]===3?(i.push(t+2),t+=2):t++;if(i.length===0)return n;var e=s-i.length,r=new Uint8Array(e),a=0;for(t=0;t<e;a++,t++)a===i[0]&&(a++,i.shift()),r[t]=n[a];return r}function ca(n){var s=n[0],i="",t="",e=0,r=0,a=0,o=0,l=0,u=0;if(s===0){for(;ce(n.subarray(u,u+1))!=="\0";)i+=ce(n.subarray(u,u+1)),u+=1;for(i+=ce(n.subarray(u,u+1)),u+=1;ce(n.subarray(u,u+1))!=="\0";)t+=ce(n.subarray(u,u+1)),u+=1;t+=ce(n.subarray(u,u+1)),u+=1,e=H(n,12),r=H(n,16),o=H(n,20),l=H(n,24),u=28}else if(s===1){u+=4,e=H(n,u),u+=4;var f=H(n,u);u+=4;var d=H(n,u);for(u+=4,a=Math.pow(2,32)*f+d,qn(a)||(a=Number.MAX_SAFE_INTEGER,X.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=H(n,u),u+=4,l=H(n,u),u+=4;ce(n.subarray(u,u+1))!=="\0";)i+=ce(n.subarray(u,u+1)),u+=1;for(i+=ce(n.subarray(u,u+1)),u+=1;ce(n.subarray(u,u+1))!=="\0";)t+=ce(n.subarray(u,u+1)),u+=1;t+=ce(n.subarray(u,u+1)),u+=1}var h=n.subarray(u,n.byteLength);return{schemeIdUri:i,value:t,timeScale:e,presentationTime:a,presentationTimeDelta:r,eventDuration:o,id:l,payload:h}}function We(n){if(n===void 0&&(n=!0),!(typeof self>"u")){var s=(n||!self.MediaSource)&&self.ManagedMediaSource;return s||self.MediaSource||self.WebKitMediaSource}}function va(n){return typeof self<"u"&&n===self.ManagedMediaSource}function ga(n,s){var i=Object.keys(n),t=Object.keys(s),e=i.length,r=t.length;return!e||!r||e===r&&!i.some(function(a){return t.indexOf(a)===-1})}var $r=function(){return/\(Windows.+Firefox\//i.test(navigator.userAgent)},ze={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,dav1:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function zr(n,s){var i=ze[s];return!!i&&!!i[n.slice(0,4)]}function Qt(n,s,i){return i===void 0&&(i=!0),!n.split(",").some(function(t){return!Qr(t,s,i)})}function Qr(n,s,i){var t;i===void 0&&(i=!0);var e=We(i);return(t=e?.isTypeSupported(at(n,s)))!=null?t:!1}function at(n,s){return s+"/mp4;codecs="+n}function Zr(n){if(n){var s=n.substring(0,4);return ze.video[s]}return 2}function mt(n){var s=$r();return n.split(",").reduce(function(i,t){var e=s&&zt(t),r=e?9:ze.video[t];return r?(r*2+i)/(i?3:2):(ze.audio[t]+i)/(i?2:1)},0)}var Zt={};function ma(n,s){if(s===void 0&&(s=!0),Zt[n])return Zt[n];for(var i={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[n],t=0;t<i.length;t++){var e;if(Qr(i[t],"audio",s))return Zt[n]=i[t],i[t];if(i[t]==="mp3"&&(e=We(s))!=null&&e.isTypeSupported("audio/mpeg"))return""}return n}var pa=/flac|opus|mp4a\.40\.34/i;function pt(n,s){return s===void 0&&(s=!0),n.replace(pa,function(i){return ma(i.toLowerCase(),s)})}function Ea(n,s){var i=[];if(n)for(var t=n.split(","),e=0;e<t.length;e++)zr(t[e],"video")||i.push(t[e]);return s&&i.push(s),i.join(",")}function Et(n,s){if(n&&(n.length>4||["ac-3","ec-3","alac","fLaC","Opus"].indexOf(n)!==-1))return n;if(s){var i=s.split(",");if(i.length>1){if(n){for(var t=i.length;t--;)if(i[t].substring(0,4)===n.substring(0,4))return i[t]}return i[0]}}return s||n}function ya(n){for(var s=n.split(","),i=0;i<s.length;i++){var t=s[i].split(".");if(t.length>2){var e=t.shift()+".";e+=parseInt(t.shift()).toString(16),e+=("000"+parseInt(t.shift()).toString(16)).slice(-4),s[i]=e}}return s.join(",")}function Ta(n){if(n.startsWith("av01.")){for(var s=n.split("."),i=["0","111","01","01","01","0"],t=s.length;t>4&&t<10;t++)s[t]=i[t-4];return s.join(".")}return n}function Jr(n){var s=We(n)||{isTypeSupported:function(){return!1}};return{mpeg:s.isTypeSupported("audio/mpeg"),mp3:s.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:!1}}function ei(n){return n.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}var Jt=["NONE","TYPE-0","TYPE-1",null];function Sa(n){return Jt.indexOf(n)>-1}var yt=["SDR","PQ","HLG"];function xa(n){return!!n&&yt.indexOf(n)>-1}var Tt={No:"",Yes:"YES",v2:"v2"};function ti(n){var s=n.canSkipUntil,i=n.canSkipDateRanges,t=n.age,e=t<s/2;return s&&e?i?Tt.v2:Tt.Yes:Tt.No}var ri=function(){function n(i,t,e){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=i,this.part=t,this.skip=e}var s=n.prototype;return s.addDirectives=function(t){var e=new self.URL(t);return this.msn!==void 0&&e.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&e.searchParams.set("_HLS_part",this.part.toString()),this.skip&&e.searchParams.set("_HLS_skip",this.skip),e.href},n}(),ii=function(){function n(i){if(this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.supplemental=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[i.url],this._attrs=[i.attrs],this.bitrate=i.bitrate,i.details&&(this.details=i.details),this.id=i.id||0,this.name=i.name,this.width=i.width||0,this.height=i.height||0,this.frameRate=i.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=i.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=i.audioCodec,this.videoCodec=i.videoCodec,this.codecSet=[i.videoCodec,i.audioCodec].filter(function(r){return!!r}).map(function(r){return r.substring(0,4)}).join(","),"supplemental"in i){var t;this.supplemental=i.supplemental;var e=(t=i.supplemental)==null?void 0:t.videoCodec;e&&e!==i.videoCodec&&(this.codecSet+=","+e.substring(0,4))}this.addGroupId("audio",i.attrs.AUDIO),this.addGroupId("text",i.attrs.SUBTITLES)}var s=n.prototype;return s.hasAudioGroup=function(t){return ni(this._audioGroups,t)},s.hasSubtitleGroup=function(t){return ni(this._subtitleGroups,t)},s.addGroupId=function(t,e){if(e){if(t==="audio"){var r=this._audioGroups;r||(r=this._audioGroups=[]),r.indexOf(e)===-1&&r.push(e)}else if(t==="text"){var a=this._subtitleGroups;a||(a=this._subtitleGroups=[]),a.indexOf(e)===-1&&a.push(e)}}},s.addFallback=function(){},te(n,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"averageBitrate",get:function(){return this._avgBitrate||this.realBitrate||this.bitrate}},{key:"attrs",get:function(){return this._attrs[0]}},{key:"codecs",get:function(){return this.attrs.CODECS||""}},{key:"pathwayId",get:function(){return this.attrs["PATHWAY-ID"]||"."}},{key:"videoRange",get:function(){return this.attrs["VIDEO-RANGE"]||"SDR"}},{key:"score",get:function(){return this.attrs.optionalFloat("SCORE",0)}},{key:"uri",get:function(){return this.url[0]||""}},{key:"audioGroups",get:function(){return this._audioGroups}},{key:"subtitleGroups",get:function(){return this._subtitleGroups}},{key:"urlId",get:function(){return 0},set:function(t){}},{key:"audioGroupIds",get:function(){return this.audioGroups?[this.audioGroupId]:void 0}},{key:"textGroupIds",get:function(){return this.subtitleGroups?[this.textGroupId]:void 0}},{key:"audioGroupId",get:function(){var t;return(t=this.audioGroups)==null?void 0:t[0]}},{key:"textGroupId",get:function(){var t;return(t=this.subtitleGroups)==null?void 0:t[0]}}])}();function ni(n,s){return!s||!n?!1:n.indexOf(s)!==-1}function La(){if(typeof matchMedia=="function"){var n=matchMedia("(dynamic-range: high)"),s=matchMedia("bad query");if(n.media!==s.media)return n.matches===!0}return!1}function Aa(n,s){var i=!1,t=[];if(n&&(i=n!=="SDR",t=[n]),s){t=s.allowedVideoRanges||yt.slice(0);var e=t.join("")!=="SDR"&&!s.videoCodec;i=s.preferHDR!==void 0?s.preferHDR:e&&La(),i||(t=["SDR"])}return{preferHDR:i,allowedVideoRanges:t}}var Ra=function(s){var i=new WeakSet;return function(t,e){if(s&&(e=s(t,e)),typeof e=="object"&&e!==null){if(i.has(e))return;i.add(e)}return e}},Te=function(s,i){return JSON.stringify(s,Ra(i))};function ba(n,s,i,t,e){for(var r=Object.keys(n),a=t?.channels,o=t?.audioCodec,l=e?.videoCodec,u=a&&parseInt(a)===2,f=!1,d=!1,h=1/0,v=1/0,c=1/0,g=1/0,m=0,p=[],y=Aa(s,e),S=y.preferHDR,T=y.allowedVideoRanges,x=function(){var I=n[r[R]];f||(f=I.channels[2]>0),h=Math.min(h,I.minHeight),v=Math.min(v,I.minFramerate),c=Math.min(c,I.minBitrate);var k=T.filter(function(w){return I.videoRanges[w]>0});k.length>0&&(d=!0)},R=r.length;R--;)x();h=N(h)?h:0,v=N(v)?v:0;var L=Math.max(1080,h),A=Math.max(30,v);c=N(c)?c:i,i=Math.max(c,i),d||(s=void 0);var C=r.length>1,_=r.reduce(function(b,I){var k=n[I];if(I===b)return b;if(p=d?T.filter(function(w){return k.videoRanges[w]>0}):[],C){if(k.minBitrate>i)return Ne(I,"min bitrate of "+k.minBitrate+" > current estimate of "+i),b;if(!k.hasDefaultAudio)return Ne(I,"no renditions with default or auto-select sound found"),b;if(o&&I.indexOf(o.substring(0,4))%5!==0)return Ne(I,'audio codec preference "'+o+'" not found'),b;if(a&&!u){if(!k.channels[a])return Ne(I,"no renditions with "+a+" channel sound found (channels options: "+Object.keys(k.channels)+")"),b}else if((!o||u)&&f&&k.channels[2]===0)return Ne(I,"no renditions with stereo sound found"),b;if(k.minHeight>L)return Ne(I,"min resolution of "+k.minHeight+" > maximum of "+L),b;if(k.minFramerate>A)return Ne(I,"min framerate of "+k.minFramerate+" > maximum of "+A),b;if(!p.some(function(w){return k.videoRanges[w]>0}))return Ne(I,"no variants with VIDEO-RANGE of "+Te(p)+" found"),b;if(l&&I.indexOf(l.substring(0,4))%5!==0)return Ne(I,'video codec preference "'+l+'" not found'),b;if(k.maxScore<m)return Ne(I,"max score of "+k.maxScore+" < selected max of "+m),b}return b&&(mt(I)>=mt(b)||k.fragmentError>n[b].fragmentError)?b:(g=k.minIndex,m=k.maxScore,I)},void 0);return{codecSet:_,videoRanges:p,preferHDR:S,minFramerate:v,minBitrate:c,minIndex:g}}function Ne(n,s){X.log('[abr] start candidates with "'+n+'" ignored because '+s)}function ai(n){return n.reduce(function(s,i){var t=s.groups[i.groupId];t||(t=s.groups[i.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),t.tracks.push(i);var e=i.channels||"2";return t.channels[e]=(t.channels[e]||0)+1,t.hasDefault=t.hasDefault||i.default,t.hasAutoSelect=t.hasAutoSelect||i.autoselect,t.hasDefault&&(s.hasDefaultAudio=!0),t.hasAutoSelect&&(s.hasAutoSelectAudio=!0),s},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function Ia(n,s,i,t){return n.slice(i,t+1).reduce(function(e,r,a){if(!r.codecSet)return e;var o=r.audioGroups,l=e[r.codecSet];l||(e[r.codecSet]=l={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:a,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!o,fragmentError:0}),l.minBitrate=Math.min(l.minBitrate,r.bitrate);var u=Math.min(r.height,r.width);return l.minHeight=Math.min(l.minHeight,u),l.minFramerate=Math.min(l.minFramerate,r.frameRate),l.minIndex=Math.min(l.minIndex,a),l.maxScore=Math.max(l.maxScore,r.score),l.fragmentError+=r.fragmentError,l.videoRanges[r.videoRange]=(l.videoRanges[r.videoRange]||0)+1,e},{})}function si(n,s){var i;return!!n&&n!==((i=s.loadLevelObj)==null?void 0:i.uri)}var _a=function(n){function s(t){var e;return e=n.call(this,"abr",t.logger)||this,e.hls=void 0,e.lastLevelLoadSec=0,e.lastLoadedFragLevel=-1,e.firstSelection=-1,e._nextAutoLevel=-1,e.nextAutoLevelKey="",e.audioTracksByGroup=null,e.codecTiers=null,e.timer=-1,e.fragCurrent=null,e.partCurrent=null,e.bitrateTestDelay=0,e.rebufferNotice=-1,e.bwEstimator=void 0,e._abandonRulesCheck=function(r){var a,o=e,l=o.fragCurrent,u=o.partCurrent,f=o.hls,d=f.autoLevelEnabled,h=f.media;if(!(!l||!h)){var v=performance.now(),c=u?u.stats:l.stats,g=u?u.duration:l.duration,m=v-c.loading.start,p=f.minAutoLevel,y=l.level,S=e._nextAutoLevel;if(c.aborted||c.loaded&&c.loaded===c.total||y<=p){e.clearTimer(),e._nextAutoLevel=-1;return}if(d){var T=S>-1&&S!==y,x=!!r||T;if(!(!x&&(h.paused||!h.playbackRate||!h.readyState))){var R=f.mainForwardBufferInfo;if(!(!x&&R===null)){var L=e.bwEstimator.getEstimateTTFB(),A=Math.abs(h.playbackRate);if(!(m<=Math.max(L,1e3*(g/(A*2))))){var C=R?R.len/A:0,_=c.loading.first?c.loading.first-c.loading.start:-1,b=c.loaded&&_>-1,I=e.getBwEstimate(),k=f.levels,w=k[y],M=Math.max(c.loaded,Math.round(g*(l.bitrate||w.averageBitrate)/8)),P=b?m-_:m;P<1&&b&&(P=Math.min(m,c.loaded*8/I));var F=b?c.loaded*1e3/P:0,B=L/1e3,U=F?(M-c.loaded)/F:M*8/I+B;if(!(U<=C)){var G=F?F*8:I,z=((a=r?.details||e.hls.latestLevelDetails)==null?void 0:a.live)===!0,q=e.hls.config.abrBandWidthUpFactor,Q=Number.POSITIVE_INFINITY,Y;for(Y=y-1;Y>p;Y--){var ae=k[Y].maxBitrate,Z=!k[Y].details||z;if(Q=e.getTimeToLoadFrag(B,G,g*ae,Z),Q<Math.min(C,g+B))break}if(!(Q>=U)&&!(Q>g*10)){b?e.bwEstimator.sample(m-Math.min(L,_),c.loaded):e.bwEstimator.sampleTTFB(m);var ne=k[Y].maxBitrate;e.getBwEstimate()*q>ne&&e.resetEstimator(ne);var Ae=e.findBestLevel(ne,p,Y,0,C,1,1);Ae>-1&&(Y=Ae),e.warn("Fragment "+l.sn+(u?" part "+u.index:"")+" of level "+y+` is loading too slowly;
3
- Fragment duration: `+l.duration.toFixed(3)+`
4
- Time to underbuffer: `+C.toFixed(3)+` s
5
- Estimated load time for current fragment: `+U.toFixed(3)+` s
6
- Estimated load time for down switch fragment: `+Q.toFixed(3)+` s
7
- TTFB estimate: `+(_|0)+` ms
8
- Current BW estimate: `+(N(I)?I|0:"Unknown")+` bps
9
- New BW estimate: `+(e.getBwEstimate()|0)+` bps
10
- Switching to level `+Y+" @ "+(ne|0)+" bps"),f.nextLoadLevel=f.nextAutoLevel=Y,e.clearTimer();var ge=function(){if(e.clearTimer(),e.fragCurrent===l&&e.hls.loadLevel===Y&&Y>0){var Re=e.getStarvationDelay();if(e.warn("Aborting inflight request "+(Y>0?"and switching down":"")+`
11
- Fragment duration: `+l.duration.toFixed(3)+` s
12
- Time to underbuffer: `+Re.toFixed(3)+" s"),l.abortRequests(),e.fragCurrent=e.partCurrent=null,Y>p){var ue=e.findBestLevel(e.hls.levels[p].bitrate,p,Y,0,Re,1,1);ue===-1&&(ue=p),e.hls.nextLoadLevel=e.hls.nextAutoLevel=ue,e.resetEstimator(e.hls.levels[ue].bitrate)}}};T||U>Q*2?ge():e.timer=self.setInterval(ge,Q*1e3),f.trigger(E.FRAG_LOAD_EMERGENCY_ABORTED,{frag:l,part:u,stats:c})}}}}}}}},e.hls=t,e.bwEstimator=e.initEstimator(),e.registerListeners(),e}he(s,n);var i=s.prototype;return i.resetEstimator=function(e){e&&(this.log("setting initial bwe to "+e),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()},i.initEstimator=function(){var e=this.hls.config;return new Xn(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)},i.registerListeners=function(){var e=this.hls;e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.FRAG_LOADING,this.onFragLoading,this),e.on(E.FRAG_LOADED,this.onFragLoaded,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this),e.on(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(E.LEVEL_LOADED,this.onLevelLoaded,this),e.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(E.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(E.ERROR,this.onError,this)},i.unregisterListeners=function(){var e=this.hls;e&&(e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.FRAG_LOADING,this.onFragLoading,this),e.off(E.FRAG_LOADED,this.onFragLoaded,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this),e.off(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(E.LEVEL_LOADED,this.onLevelLoaded,this),e.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(E.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(E.ERROR,this.onError,this))},i.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null},i.onManifestLoading=function(e,r){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()},i.onLevelsUpdated=function(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null},i.onMaxAutoLevelUpdated=function(){this.firstSelection=-1,this.nextAutoLevelKey=""},i.onFragLoading=function(e,r){var a=r.frag;if(!this.ignoreFragment(a)){if(!a.bitrateTest){var o;this.fragCurrent=a,this.partCurrent=(o=r.part)!=null?o:null}this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}},i.onLevelSwitching=function(e,r){this.clearTimer()},i.onError=function(e,r){if(!r.fatal)switch(r.details){case D.BUFFER_ADD_CODEC_ERROR:case D.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case D.FRAG_LOAD_TIMEOUT:{var a=r.frag,o=this.fragCurrent,l=this.partCurrent;if(a&&o&&a.sn===o.sn&&a.level===o.level){var u=performance.now(),f=l?l.stats:a.stats,d=u-f.loading.start,h=f.loading.first?f.loading.first-f.loading.start:-1,v=f.loaded&&h>-1;if(v){var c=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(d-Math.min(c,h),f.loaded)}else this.bwEstimator.sampleTTFB(d)}break}}},i.getTimeToLoadFrag=function(e,r,a,o){var l=e+a/r,u=o?e+this.lastLevelLoadSec:0;return l+u},i.onLevelLoaded=function(e,r){var a=this.hls.config,o=r.stats.loading,l=o.end-o.first;N(l)&&(this.lastLevelLoadSec=l/1e3),r.details.live?this.bwEstimator.update(a.abrEwmaSlowLive,a.abrEwmaFastLive):this.bwEstimator.update(a.abrEwmaSlowVoD,a.abrEwmaFastVoD),this.timer>-1&&this._abandonRulesCheck(r.levelInfo)},i.onFragLoaded=function(e,r){var a=r.frag,o=r.part,l=o?o.stats:a.stats;if(a.type===W.MAIN&&this.bwEstimator.sampleTTFB(l.loading.first-l.loading.start),!this.ignoreFragment(a)){if(this.clearTimer(),a.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){var u=o?o.duration:a.duration,f=this.hls.levels[a.level],d=(f.loaded?f.loaded.bytes:0)+l.loaded,h=(f.loaded?f.loaded.duration:0)+u;f.loaded={bytes:d,duration:h},f.realBitrate=Math.round(8*d/h)}if(a.bitrateTest){var v={stats:l,frag:a,part:o,id:a.type};this.onFragBuffered(E.FRAG_BUFFERED,v),a.bitrateTest=!1}else this.lastLoadedFragLevel=a.level}},i.onFragBuffered=function(e,r){var a=r.frag,o=r.part,l=o!=null&&o.stats.loaded?o.stats:a.stats;if(!l.aborted&&!this.ignoreFragment(a)){var u=l.parsing.end-l.loading.start-Math.min(l.loading.first-l.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(u,l.loaded),l.bwEstimate=this.getBwEstimate(),a.bitrateTest?this.bitrateTestDelay=u/1e3:this.bitrateTestDelay=0}},i.ignoreFragment=function(e){return e.type!==W.MAIN||e.sn==="initSegment"},i.clearTimer=function(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)},i.getAutoLevelKey=function(){return this.getBwEstimate()+"_"+this.getStarvationDelay().toFixed(2)},i.getNextABRAutoLevel=function(){var e=this.fragCurrent,r=this.partCurrent,a=this.hls;if(a.levels.length<=1)return a.loadLevel;var o=a.maxAutoLevel,l=a.config,u=a.minAutoLevel,f=r?r.duration:e?e.duration:0,d=this.getBwEstimate(),h=this.getStarvationDelay(),v=l.abrBandWidthFactor,c=l.abrBandWidthUpFactor;if(h){var g=this.findBestLevel(d,u,o,h,0,v,c);if(g>=0)return this.rebufferNotice=-1,g}var m=f?Math.min(f,l.maxStarvationDelay):l.maxStarvationDelay;if(!h){var p=this.bitrateTestDelay;if(p){var y=f?Math.min(f,l.maxLoadingDelay):l.maxLoadingDelay;m=y-p,this.info("bitrate test took "+Math.round(1e3*p)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*m)+" ms"),v=c=1}}var S=this.findBestLevel(d,u,o,h,m,v,c);if(this.rebufferNotice!==S&&(this.rebufferNotice=S,this.info((h?"rebuffering expected":"buffer is empty")+", optimal quality level "+S)),S>-1)return S;var T=a.levels[u],x=a.loadLevelObj;return x&&T?.bitrate<x.bitrate?u:a.loadLevel},i.getStarvationDelay=function(){var e=this.hls,r=e.media;if(!r)return 1/0;var a=r&&r.playbackRate!==0?Math.abs(r.playbackRate):1,o=e.mainForwardBufferInfo;return(o?o.len:0)/a},i.getBwEstimate=function(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate},i.findBestLevel=function(e,r,a,o,l,u,f){var d,h=this,v=o+l,c=this.lastLoadedFragLevel,g=c===-1?this.hls.firstLevel:c,m=this.fragCurrent,p=this.partCurrent,y=this.hls,S=y.levels,T=y.allAudioTracks,x=y.loadLevel,R=y.config;if(S.length===1)return 0;var L=S[g],A=!!((d=this.hls.latestLevelDetails)!=null&&d.live),C=x===-1||c===-1,_,b="SDR",I=L?.frameRate||0,k=R.audioPreference,w=R.videoPreference,M=this.audioTracksByGroup||(this.audioTracksByGroup=ai(T)),P=-1;if(C){if(this.firstSelection!==-1)return this.firstSelection;var F=this.codecTiers||(this.codecTiers=Ia(S,M,r,a)),B=ba(F,b,e,k,w),U=B.codecSet,G=B.videoRanges,z=B.minFramerate,q=B.minBitrate,Q=B.minIndex,Y=B.preferHDR;P=Q,_=U,b=Y?G[G.length-1]:G[0],I=z,e=Math.max(e,q),this.log("picked start tier "+Te(B))}else _=L?.codecSet,b=L?.videoRange;for(var ae=p?p.duration:m?m.duration:0,Z=this.bwEstimator.getEstimateTTFB()/1e3,ne=[],Ae=function(){var ue,ie=S[J],be=J>g;if(!ie)return 0;if((_&&ie.codecSet!==_||b&&ie.videoRange!==b||be&&I>ie.frameRate||!be&&I>0&&I<ie.frameRate||ie.supportedResult&&!((ue=ie.supportedResult.decodingInfoResults)!=null&&ue[0].smooth))&&(!C||J!==P))return ne.push(J),0;var Ee=ie.details,De=(p?Ee?.partTarget:Ee?.averagetargetduration)||ae,ee;be?ee=f*e:ee=u*e;var ye=ae&&o>=ae*2&&l===0?ie.averageBitrate:ie.maxBitrate,fe=h.getTimeToLoadFrag(Z,ee,ye*De,Ee===void 0),Ie=ee>=ye&&(J===c||ie.loadError===0&&ie.fragmentError===0)&&(fe<=Z||!N(fe)||A&&!h.bitrateTestDelay||fe<v);if(Ie){var ht=h.forcedAutoLevel;return J!==x&&(ht===-1||ht!==x)&&(ne.length&&h.trace("Skipped level(s) "+ne.join(",")+" of "+a+' max with CODECS and VIDEO-RANGE:"'+S[ne[0]].codecs+'" '+S[ne[0]].videoRange+'; not compatible with "'+_+'" '+b),h.info("switch candidate:"+g+"->"+J+" adjustedbw("+Math.round(ee)+")-bitrate="+Math.round(ee-ye)+" ttfb:"+Z.toFixed(1)+" avgDuration:"+De.toFixed(1)+" maxFetchDuration:"+v.toFixed(1)+" fetchDuration:"+fe.toFixed(1)+" firstSelection:"+C+" codecSet:"+ie.codecSet+" videoRange:"+ie.videoRange+" hls.loadLevel:"+x)),C&&(h.firstSelection=J),{v:J}}},ge,J=a;J>=r;J--)if(ge=Ae(),ge!==0&&ge)return ge.v;return-1},i.deriveNextAutoLevel=function(e){var r=this.hls,a=r.maxAutoLevel,o=r.minAutoLevel;return Math.min(Math.max(e,o),a)},te(s,[{key:"firstAutoLevel",get:function(){var e=this.hls,r=e.maxAutoLevel,a=e.minAutoLevel,o=this.getBwEstimate(),l=this.hls.config.maxStarvationDelay,u=this.findBestLevel(o,a,r,0,l,1,1);if(u>-1)return u;var f=this.hls.firstLevel,d=Math.min(Math.max(f,a),r);return this.warn("Could not find best starting auto level. Defaulting to first in playlist "+f+" clamped to "+d),d}},{key:"forcedAutoLevel",get:function(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}},{key:"nextAutoLevel",get:function(){var e=this.forcedAutoLevel,r=this.bwEstimator,a=r.canEstimate(),o=this.lastLoadedFragLevel>-1;if(e!==-1&&(!a||!o||this.nextAutoLevelKey===this.getAutoLevelKey()))return e;var l=a&&o?this.getNextABRAutoLevel():this.firstAutoLevel;if(e!==-1){var u=this.hls.levels;if(u.length>Math.max(e,l)&&u[e].loadError<=u[l].loadError)return e}return this._nextAutoLevel=l,this.nextAutoLevelKey=this.getAutoLevelKey(),l},set:function(e){var r=this.deriveNextAutoLevel(e);this._nextAutoLevel!==r&&(this.nextAutoLevelKey="",this._nextAutoLevel=r)}}])}($e),Da=function(){function n(i){this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=i}var s=n.prototype;return s.destroy=function(){this.tracks=this.queues=null},s.append=function(t,e,r){if(!(this.queues===null||this.tracks===null)){var a=this.queues[e];a.push(t),a.length===1&&!r&&this.executeNext(e)}},s.appendBlocker=function(t){var e=this;return new Promise(function(r){var a={label:"async-blocker",execute:r,onStart:function(){},onComplete:function(){},onError:function(){}};e.append(a,t)})},s.prependBlocker=function(t){var e=this;return new Promise(function(r){if(e.queues){var a={label:"async-blocker-prepend",execute:r,onStart:function(){},onComplete:function(){},onError:function(){}};e.queues[t].unshift(a)}})},s.removeBlockers=function(){this.queues!==null&&[this.queues.video,this.queues.audio,this.queues.audiovideo].forEach(function(t){var e,r=(e=t[0])==null?void 0:e.label;(r==="async-blocker"||r==="async-blocker-prepend")&&(t[0].execute(),t.splice(0,1))})},s.unblockAudio=function(t){if(this.queues!==null){var e=this.queues.audio;e[0]===t&&this.shiftAndExecuteNext("audio")}},s.executeNext=function(t){if(!(this.queues===null||this.tracks===null)){var e=this.queues[t];if(e.length){var r=e[0];try{r.execute()}catch(l){var a;if(r.onError(l),this.queues===null||this.tracks===null)return;var o=(a=this.tracks[t])==null?void 0:a.buffer;o!=null&&o.updating||this.shiftAndExecuteNext(t)}}}},s.shiftAndExecuteNext=function(t){this.queues!==null&&(this.queues[t].shift(),this.executeNext(t))},s.current=function(t){var e;return((e=this.queues)==null?void 0:e[t][0])||null},s.toString=function(){var t=this.queues,e=this.tracks;return t===null||e===null?"<destroyed>":`
13
- `+this.list("video")+`
14
- `+this.list("audio")+`
15
- `+this.list("audiovideo")+"}"},s.list=function(t){var e,r;return(e=this.queues)!=null&&e[t]||(r=this.tracks)!=null&&r[t]?t+": ("+this.listSbInfo(t)+") "+this.listOps(t):""},s.listSbInfo=function(t){var e,r=(e=this.tracks)==null?void 0:e[t],a=r?.buffer;return a?"SourceBuffer"+(a.updating?" updating":"")+(r.ended?" ended":"")+(r.ending?" ending":""):"none"},s.listOps=function(t){var e;return((e=this.queues)==null?void 0:e[t].map(function(r){return r.label}).join(", "))||""},n}(),oi={search:function(s,i){for(var t=0,e=s.length-1,r=null,a=null;t<=e;){r=(t+e)/2|0,a=s[r];var o=i(a);if(o>0)t=r+1;else if(o<0)e=r-1;else return a}return null}};function Ca(n,s,i){if(s===null||!Array.isArray(n)||!n.length||!N(s))return null;var t=n[0].programDateTime;if(s<(t||0))return null;var e=n[n.length-1].endProgramDateTime;if(s>=(e||0))return null;i=i||0;for(var r=0;r<n.length;++r){var a=n[r];if(Pa(s,i,a))return a}return null}function er(n,s,i,t,e){i===void 0&&(i=0),t===void 0&&(t=0),e===void 0&&(e=.005);var r=null;if(n){r=s[1+n.sn-s[0].sn]||null;var a=n.endDTS-i;a>0&&a<15e-7&&(i+=15e-7),r&&n.level!==r.level&&r.end<=n.end&&(r=s[2+n.sn-s[0].sn]||null)}else i===0&&s[0].start===0&&(r=s[0]);if(r&&((!n||n.level===r.level)&&li(i,t,r)===0||ka(r,n,Math.min(e,t))))return r;var o=oi.search(s,li.bind(null,i,t));return o&&(o!==n||!r)?o:r}function ka(n,s,i){if(s&&s.start===0&&s.level<n.level&&(s.endPTS||0)>0){var t=s.tagList.reduce(function(e,r){return r[0]==="INF"&&(e+=parseFloat(r[1])),e},i);return n.start<=t}return!1}function li(n,s,i){if(n===void 0&&(n=0),s===void 0&&(s=0),i.start<=n&&i.start+i.duration>n)return 0;var t=Math.min(s,i.duration+(i.deltaPTS?i.deltaPTS:0));return i.start+i.duration-t<=n?1:i.start-t>n&&i.start?-1:0}function Pa(n,s,i){var t=Math.min(s,i.duration+(i.deltaPTS?i.deltaPTS:0))*1e3,e=i.endProgramDateTime||0;return e-t>n}function Ma(n,s){return oi.search(n,function(i){return i.cc<s?1:i.cc>s?-1:0})}function St(n){switch(n.details){case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_TIMEOUT:case D.LEVEL_LOAD_TIMEOUT:case D.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function ui(n,s){var i=St(s);return n.default[(i?"timeout":"error")+"Retry"]}function tr(n,s){var i=n.backoff==="linear"?1:Math.pow(2,s);return Math.min(i*n.retryDelayMs,n.maxRetryDelayMs)}function fi(n){return xe(xe({},n),{errorRetry:null,timeoutRetry:null})}function xt(n,s,i,t){if(!n)return!1;var e=t?.code,r=s<n.maxNumRetry&&(Oa(e)||!!i);return n.shouldRetry?n.shouldRetry(n,s,i,t,r):r}function Oa(n){return n===0&&navigator.onLine===!1||!!n&&(n<400||n>499)}var pe={DoNothing:0,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,RetryRequest:5},Pe={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2},wa=function(n){function s(t){var e;return e=n.call(this,"error-controller",t.logger)||this,e.hls=void 0,e.playlistError=0,e.penalizedRenditions={},e.hls=t,e.registerListeners(),e}he(s,n);var i=s.prototype;return i.registerListeners=function(){var e=this.hls;e.on(E.ERROR,this.onError,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.LEVEL_UPDATED,this.onLevelUpdated,this)},i.unregisterListeners=function(){var e=this.hls;e&&(e.off(E.ERROR,this.onError,this),e.off(E.ERROR,this.onErrorOut,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.LEVEL_UPDATED,this.onLevelUpdated,this))},i.destroy=function(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}},i.startLoad=function(e){},i.stopLoad=function(){this.playlistError=0},i.getVariantLevelIndex=function(e){return e?.type===W.MAIN?e.level:this.hls.loadLevel},i.onManifestLoading=function(){this.playlistError=0,this.penalizedRenditions={}},i.onLevelUpdated=function(){this.playlistError=0},i.onError=function(e,r){var a;if(!r.fatal){var o=this.hls,l=r.context;switch(r.details){case D.FRAG_LOAD_ERROR:case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_ERROR:case D.KEY_LOAD_TIMEOUT:r.errorAction=this.getFragRetryOrSwitchAction(r);return;case D.FRAG_PARSING_ERROR:if((a=r.frag)!=null&&a.gap){r.errorAction=Lt();return}case D.FRAG_GAP:case D.FRAG_DECRYPT_ERROR:{r.errorAction=this.getFragRetryOrSwitchAction(r),r.errorAction.action=pe.SendAlternateToPenaltyBox;return}case D.LEVEL_EMPTY_ERROR:case D.LEVEL_PARSING_ERROR:{var u,f,d=r.parent===W.MAIN?r.level:o.loadLevel;r.details===D.LEVEL_EMPTY_ERROR&&((u=r.context)!=null&&(f=u.levelDetails)!=null&&f.live)?r.errorAction=this.getPlaylistRetryOrSwitchAction(r,d):(r.levelRetry=!1,r.errorAction=this.getLevelSwitchAction(r,d))}return;case D.LEVEL_LOAD_ERROR:case D.LEVEL_LOAD_TIMEOUT:typeof l?.level=="number"&&(r.errorAction=this.getPlaylistRetryOrSwitchAction(r,l.level));return;case D.AUDIO_TRACK_LOAD_ERROR:case D.AUDIO_TRACK_LOAD_TIMEOUT:case D.SUBTITLE_LOAD_ERROR:case D.SUBTITLE_TRACK_LOAD_TIMEOUT:if(l){var h=o.loadLevelObj;if(h&&(l.type===j.AUDIO_TRACK&&h.hasAudioGroup(l.groupId)||l.type===j.SUBTITLE_TRACK&&h.hasSubtitleGroup(l.groupId))){r.errorAction=this.getPlaylistRetryOrSwitchAction(r,o.loadLevel),r.errorAction.action=pe.SendAlternateToPenaltyBox,r.errorAction.flags=Pe.MoveAllAlternatesMatchingHost;return}}return;case D.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{var v=o.loadLevelObj,c=v?.attrs["HDCP-LEVEL"];c?r.errorAction={action:pe.SendAlternateToPenaltyBox,flags:Pe.MoveAllAlternatesMatchingHDCP,hdcpLevel:c}:this.keySystemError(r)}return;case D.BUFFER_ADD_CODEC_ERROR:case D.REMUX_ALLOC_ERROR:case D.BUFFER_APPEND_ERROR:if(!r.errorAction){var g;r.errorAction=this.getLevelSwitchAction(r,(g=r.level)!=null?g:o.loadLevel)}return;case D.INTERNAL_EXCEPTION:case D.BUFFER_APPENDING_ERROR:case D.BUFFER_FULL_ERROR:case D.LEVEL_SWITCH_ERROR:case D.BUFFER_STALLED_ERROR:case D.BUFFER_SEEK_OVER_HOLE:case D.BUFFER_NUDGE_ON_STALL:r.errorAction=Lt();return}r.type===K.KEY_SYSTEM_ERROR&&this.keySystemError(r)}},i.keySystemError=function(e){var r=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,r)},i.getPlaylistRetryOrSwitchAction=function(e,r){var a=this.hls,o=ui(a.config.playlistLoadPolicy,e),l=this.playlistError++,u=xt(o,l,St(e),e.response);if(u)return{action:pe.RetryRequest,flags:Pe.None,retryConfig:o,retryCount:l};var f=this.getLevelSwitchAction(e,r);return o&&(f.retryConfig=o,f.retryCount=l),f},i.getFragRetryOrSwitchAction=function(e){var r=this.hls,a=this.getVariantLevelIndex(e.frag),o=r.levels[a],l=r.config,u=l.fragLoadPolicy,f=l.keyLoadPolicy,d=ui(e.details.startsWith("key")?f:u,e),h=r.levels.reduce(function(g,m){return g+m.fragmentError},0);if(o){e.details!==D.FRAG_GAP&&o.fragmentError++;var v=xt(d,h,St(e),e.response);if(v)return{action:pe.RetryRequest,flags:Pe.None,retryConfig:d,retryCount:h}}var c=this.getLevelSwitchAction(e,a);return d&&(c.retryConfig=d,c.retryCount=h),c},i.getLevelSwitchAction=function(e,r){var a=this.hls;r==null&&(r=a.loadLevel);var o=this.hls.levels[r];if(o){var l,u,f=e.details;o.loadError++,f===D.BUFFER_APPEND_ERROR&&o.fragmentError++;var d=-1,h=a.levels,v=a.loadLevel,c=a.minAutoLevel,g=a.maxAutoLevel;a.autoLevelEnabled||(a.loadLevel=-1);for(var m=(l=e.frag)==null?void 0:l.type,p=m===W.AUDIO&&f===D.FRAG_PARSING_ERROR||e.sourceBufferName==="audio"&&(f===D.BUFFER_ADD_CODEC_ERROR||f===D.BUFFER_APPEND_ERROR),y=p&&h.some(function(b){var I=b.audioCodec;return o.audioCodec!==I}),S=e.sourceBufferName==="video"&&(f===D.BUFFER_ADD_CODEC_ERROR||f===D.BUFFER_APPEND_ERROR),T=S&&h.some(function(b){var I=b.codecSet,k=b.audioCodec;return o.codecSet!==I&&o.audioCodec===k}),x=(u=e.context)!=null?u:{},R=x.type,L=x.groupId,A=function(){var I=(_+v)%h.length;if(I!==v&&I>=c&&I<=g&&h[I].loadError===0){var k,w,M=h[I];if(f===D.FRAG_GAP&&m===W.MAIN&&e.frag){var P=h[I].details;if(P){var F=er(e.frag,P.fragments,e.frag.start);if(F!=null&&F.gap)return 0}}else{if(R===j.AUDIO_TRACK&&M.hasAudioGroup(L)||R===j.SUBTITLE_TRACK&&M.hasSubtitleGroup(L))return 0;if(m===W.AUDIO&&(k=o.audioGroups)!=null&&k.some(function(B){return M.hasAudioGroup(B)})||m===W.SUBTITLE&&(w=o.subtitleGroups)!=null&&w.some(function(B){return M.hasSubtitleGroup(B)})||y&&o.audioCodec===M.audioCodec||!y&&o.audioCodec!==M.audioCodec||T&&o.codecSet===M.codecSet)return 0}return d=I,1}},C,_=h.length;_--&&(C=A(),!(C!==0&&C===1)););if(d>-1&&a.loadLevel!==d)return e.levelRetry=!0,this.playlistError=0,{action:pe.SendAlternateToPenaltyBox,flags:Pe.None,nextAutoLevel:d}}return{action:pe.SendAlternateToPenaltyBox,flags:Pe.MoveAllAlternatesMatchingHost}},i.onErrorOut=function(e,r){var a;switch((a=r.errorAction)==null?void 0:a.action){case pe.DoNothing:break;case pe.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(r),!r.errorAction.resolved&&r.details!==D.FRAG_GAP?r.fatal=!0:/MediaSource readyState: ended/.test(r.error.message)&&(this.warn('MediaSource ended after "'+r.sourceBufferName+'" sourceBuffer append error. Attempting to recover from media error.'),this.hls.recoverMediaError());break}if(r.fatal){this.hls.stopLoad();return}},i.sendAlternateToPenaltyBox=function(e){var r=this.hls,a=e.errorAction;if(a){var o=a.flags,l=a.hdcpLevel,u=a.nextAutoLevel;switch(o){case Pe.None:this.switchLevel(e,u);break;case Pe.MoveAllAlternatesMatchingHDCP:l&&(r.maxHdcpLevel=Jt[Jt.indexOf(l)-1],a.resolved=!0),this.warn('Restricting playback to HDCP-LEVEL of "'+r.maxHdcpLevel+'" or lower');break}a.resolved||this.switchLevel(e,u)}},i.switchLevel=function(e,r){if(r!==void 0&&e.errorAction&&(this.warn("switching to level "+r+" after "+e.details),this.hls.nextAutoLevel=r,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel,e.details===D.BUFFER_ADD_CODEC_ERROR&&e.mimeType&&e.sourceBufferName!=="audiovideo"))for(var a=ei(e.mimeType),o=this.hls.levels,l=o.length;l--;)o[l][e.sourceBufferName+"Codec"]===a&&this.hls.removeLevel(l)},s}($e);function Lt(n){var s={action:pe.DoNothing,flags:Pe.None};return n&&(s.resolved=!0),s}var di={length:0,start:function(){return 0},end:function(){return 0}},$=function(){function n(){}return n.isBuffered=function(i,t){if(i){for(var e=n.getBuffered(i),r=e.length;r--;)if(t>=e.start(r)&&t<=e.end(r))return!0}return!1},n.bufferedRanges=function(i){if(i){var t=n.getBuffered(i);return n.timeRangesToArray(t)}return[]},n.timeRangesToArray=function(i){for(var t=[],e=0;e<i.length;e++)t.push({start:i.start(e),end:i.end(e)});return t},n.bufferInfo=function(i,t,e){if(i){var r=n.bufferedRanges(i);if(r.length)return n.bufferedInfo(r,t,e)}return{len:0,start:t,end:t,bufferedIndex:-1}},n.bufferedInfo=function(i,t,e){t=Math.max(0,t),i.length>1&&i.sort(function(p,y){return p.start-y.start||y.end-p.end});var r=-1,a=[];if(e)for(var o=0;o<i.length;o++){t>=i[o].start&&t<=i[o].end&&(r=o);var l=a.length;if(l){var u=a[l-1].end;i[o].start-u<e?i[o].end>u&&(a[l-1].end=i[o].end):a.push(i[o])}else a.push(i[o])}else a=i;for(var f=0,d,h=t,v=t,c=0;c<a.length;c++){var g=a[c].start,m=a[c].end;if(r===-1&&t>=g&&t<=m&&(r=c),t+e>=g&&t<m)h=g,v=m,f=v-t;else if(t+e<g){d=g;break}}return{len:f,start:h||0,end:v||0,nextStart:d,buffered:i,bufferedIndex:r}},n.getBuffered=function(i){try{return i.buffered||di}catch(t){return X.log("failed to get media.buffered",t),di}},n}(),hi=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,ci="HlsJsTrackRemovedError",Fa=function(n){function s(i){var t;return t=n.call(this,i)||this,t.name=ci,t}return he(s,n),s}(nt(Error)),Na=function(n){function s(t,e){var r;return r=n.call(this,"buffer-controller",t.logger)||this,r.hls=void 0,r.fragmentTracker=void 0,r.details=null,r._objectUrl=null,r.operationQueue=null,r.bufferCodecEventsTotal=0,r.media=null,r.mediaSource=null,r.lastMpegAudioChunk=null,r.blockedAudioAppend=null,r.lastVideoAppendEnd=0,r.appendSource=void 0,r.transferData=void 0,r.overrides=void 0,r.appendErrors={audio:0,video:0,audiovideo:0},r.tracks={},r.sourceBuffers=[[null,null],[null,null]],r._onEndStreaming=function(a){var o;r.hls&&((o=r.mediaSource)==null?void 0:o.readyState)==="open"&&r.hls.pauseBuffering()},r._onStartStreaming=function(a){r.hls&&r.hls.resumeBuffering()},r._onMediaSourceOpen=function(a){var o=r,l=o.media,u=o.mediaSource;a&&r.log("Media source opened"),!(!l||!u)&&(u.removeEventListener("sourceopen",r._onMediaSourceOpen),l.removeEventListener("emptied",r._onMediaEmptied),r.updateDuration(),r.hls.trigger(E.MEDIA_ATTACHED,{media:l,mediaSource:u}),r.mediaSource!==null&&r.checkPendingTracks())},r._onMediaSourceClose=function(){r.log("Media source closed")},r._onMediaSourceEnded=function(){r.log("Media source ended")},r._onMediaEmptied=function(){var a=r,o=a.mediaSrc,l=a._objectUrl;o!==l&&r.error("Media element src was set while attaching MediaSource ("+l+" > "+o+")")},r.hls=t,r.fragmentTracker=e,r.appendSource=va(We(t.config.preferManagedMediaSource)),r.initTracks(),r.registerListeners(),r}he(s,n);var i=s.prototype;return i.hasSourceTypes=function(){return Object.keys(this.tracks).length>0},i.destroy=function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.transferData=this.overrides=void 0,this.operationQueue&&(this.operationQueue.destroy(),this.operationQueue=null),this.hls=this.fragmentTracker=null,this._onMediaSourceOpen=this._onMediaSourceClose=null,this._onMediaSourceEnded=null,this._onStartStreaming=this._onEndStreaming=null},i.registerListeners=function(){var e=this.hls;e.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.BUFFER_RESET,this.onBufferReset,this),e.on(E.BUFFER_APPENDING,this.onBufferAppending,this),e.on(E.BUFFER_CODECS,this.onBufferCodecs,this),e.on(E.BUFFER_EOS,this.onBufferEos,this),e.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(E.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(E.FRAG_PARSED,this.onFragParsed,this),e.on(E.FRAG_CHANGED,this.onFragChanged,this),e.on(E.ERROR,this.onError,this)},i.unregisterListeners=function(){var e=this.hls;e.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.BUFFER_RESET,this.onBufferReset,this),e.off(E.BUFFER_APPENDING,this.onBufferAppending,this),e.off(E.BUFFER_CODECS,this.onBufferCodecs,this),e.off(E.BUFFER_EOS,this.onBufferEos,this),e.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(E.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(E.FRAG_PARSED,this.onFragParsed,this),e.off(E.FRAG_CHANGED,this.onFragChanged,this),e.off(E.ERROR,this.onError,this)},i.transferMedia=function(){var e=this,r=this.media,a=this.mediaSource;if(!r)return null;var o={};if(this.operationQueue){var l=this.isUpdating();l||this.operationQueue.removeBlockers();var u=this.isQueued();(l||u)&&this.warn("Transfering MediaSource with"+(u?" operations in queue":"")+(l?" updating SourceBuffer(s)":"")+" "+this.operationQueue),this.operationQueue.destroy()}var f=this.transferData;return!this.sourceBufferCount&&f&&f.mediaSource===a?de(o,f.tracks):this.sourceBuffers.forEach(function(d){var h=d[0];h&&(o[h]=de({},e.tracks[h]),e.removeBuffer(h)),d[0]=d[1]=null}),{media:r,mediaSource:a,tracks:o}},i.initTracks=function(){var e={};this.sourceBuffers=[[null,null],[null,null]],this.tracks=e,this.resetQueue(),this.resetAppendErrors(),this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.lastVideoAppendEnd=0},i.onManifestLoading=function(){this.bufferCodecEventsTotal=0,this.details=null},i.onManifestParsed=function(e,r){var a,o=2;r.audio&&!r.video||r.altAudio,o=1,this.bufferCodecEventsTotal=o,this.log(o+" bufferCodec event(s) expected."),(a=this.transferData)!=null&&a.mediaSource&&this.sourceBufferCount&&o&&this.bufferCreated()},i.onMediaAttaching=function(e,r){var a=this.media=r.media,o=We(this.appendSource);if(this.transferData=this.overrides=void 0,a&&o){var l=!!r.mediaSource;(l||r.overrides)&&(this.transferData=r,this.overrides=r.overrides);var u=this.mediaSource=r.mediaSource||new o;if(this.assignMediaSource(u),l)this._objectUrl=a.src,this.attachTransferred();else{var f=this._objectUrl=self.URL.createObjectURL(u);if(this.appendSource)try{a.removeAttribute("src");var d=self.ManagedMediaSource;a.disableRemotePlayback=a.disableRemotePlayback||d&&u instanceof d,vi(a),Ba(a,f),a.load()}catch{a.src=f}else a.src=f}a.addEventListener("emptied",this._onMediaEmptied)}},i.assignMediaSource=function(e){var r,a;this.log((((r=this.transferData)==null?void 0:r.mediaSource)===e?"transferred":"created")+" media source: "+((a=e.constructor)==null?void 0:a.name)),e.addEventListener("sourceopen",this._onMediaSourceOpen),e.addEventListener("sourceended",this._onMediaSourceEnded),e.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(e.addEventListener("startstreaming",this._onStartStreaming),e.addEventListener("endstreaming",this._onEndStreaming))},i.attachTransferred=function(){var e=this,r=this.media,a=this.transferData;if(!(!a||!r)){var o=this.tracks,l=a.tracks,u=l?Object.keys(l):null,f=u?u.length:0,d=function(){e.media&&e.mediaSourceOpenOrEnded&&e._onMediaSourceOpen()};if(l&&u&&f){if(!this.tracksReady){this.hls.config.startFragPrefetch=!0,this.log("attachTransferred: waiting for SourceBuffer track info");return}if(this.log("attachTransferred: (bufferCodecEventsTotal "+this.bufferCodecEventsTotal+`)
16
- required tracks: `+Te(o,function(g,m){return g==="initSegment"?void 0:m})+`;
17
- transfer tracks: `+Te(l,function(g,m){return g==="initSegment"?void 0:m})+"}"),!ga(l,o)){a.mediaSource=null,a.tracks=void 0;var h=r.currentTime,v=this.details,c=Math.max(h,v?.fragments[0].start||0);if(c-h>1){this.log("attachTransferred: waiting for playback to reach new tracks start time "+h+" -> "+c);return}this.warn('attachTransferred: resetting MediaSource for incompatible tracks ("'+Object.keys(l)+'"->"'+Object.keys(o)+'") start time: '+c+" currentTime: "+h),this.onMediaDetaching(E.MEDIA_DETACHING,{}),this.onMediaAttaching(E.MEDIA_ATTACHING,a),r.currentTime=c;return}this.transferData=void 0,u.forEach(function(g){var m=g,p=l[m];if(p){var y=p.buffer;if(y){var S=e.fragmentTracker,T=p.id;if(S.hasFragments(T)||S.hasParts(T)){var x=$.getBuffered(y);S.detectEvictedFragments(m,x,T,null,!0)}var R=rr(m),L=[m,y];e.sourceBuffers[R]=L,y.updating&&e.operationQueue&&e.operationQueue.prependBlocker(m),e.trackSourceBuffer(m,p)}}}),d(),this.bufferCreated()}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),d()}},i.onMediaDetaching=function(e,r){var a=this,o=!!r.transferMedia;this.transferData=this.overrides=void 0;var l=this.media,u=this.mediaSource,f=this._objectUrl;if(u){if(this.log("media source "+(o?"transferring":"detaching")),o)this.sourceBuffers.forEach(function(c){var g=c[0];g&&a.removeBuffer(g)}),this.resetQueue();else{if(this.mediaSourceOpenOrEnded){var d=u.readyState==="open";try{for(var h=u.sourceBuffers,v=h.length;v--;)d&&h[v].abort(),u.removeSourceBuffer(h[v]);d&&u.endOfStream()}catch(c){this.warn("onMediaDetaching: "+c.message+" while calling endOfStream")}}this.sourceBufferCount&&this.onBufferReset()}u.removeEventListener("sourceopen",this._onMediaSourceOpen),u.removeEventListener("sourceended",this._onMediaSourceEnded),u.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(u.removeEventListener("startstreaming",this._onStartStreaming),u.removeEventListener("endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null}l&&(l.removeEventListener("emptied",this._onMediaEmptied),o||(f&&self.URL.revokeObjectURL(f),this.mediaSrc===f?(l.removeAttribute("src"),this.appendSource&&vi(l),l.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger(E.MEDIA_DETACHED,r)},i.onBufferReset=function(){var e=this;this.sourceBuffers.forEach(function(r){var a=r[0];a&&e.resetBuffer(a)}),this.initTracks()},i.resetBuffer=function(e){var r,a=(r=this.tracks[e])==null?void 0:r.buffer;if(this.removeBuffer(e),a)try{var o;(o=this.mediaSource)!=null&&o.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(a)}catch(l){this.warn("onBufferReset "+e,l)}delete this.tracks[e]},i.removeBuffer=function(e){this.removeBufferListeners(e),this.sourceBuffers[rr(e)]=[null,null];var r=this.tracks[e];r&&(r.buffer=void 0)},i.resetQueue=function(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new Da(this.tracks)},i.onBufferCodecs=function(e,r){var a=this,o=this.tracks,l=Object.keys(r);this.log('BUFFER_CODECS: "'+l+'" (current SB count '+this.sourceBufferCount+")");var u="audiovideo"in r&&(o.audio||o.video)||o.audiovideo&&("audio"in r||"video"in r),f=!u&&this.sourceBufferCount&&this.media&&l.some(function(d){return!o[d]});if(u||f){this.warn('Unsupported transition between "'+Object.keys(o)+'" and "'+l+'" SourceBuffers');return}l.forEach(function(d){var h,v,c,g=r[d],m=g.id,p=g.codec,y=g.levelCodec,S=g.container,T=g.metadata,x=g.supplemental,R=o[d],L=(h=a.transferData)==null||(v=h.tracks)==null?void 0:v[d],A=L!=null&&L.buffer?L:R,C=A?.pendingCodec||A?.codec,_=A?.levelCodec;R||(R=o[d]={buffer:void 0,listeners:[],codec:p,supplemental:x,container:S,levelCodec:y,metadata:T,id:m});var b=Et(C,_),I=b?.replace(hi,"$1"),k=Et(p,y),w=(c=k)==null?void 0:c.replace(hi,"$1");k&&b&&I!==w&&(d.slice(0,5)==="audio"&&(k=pt(k,a.appendSource)),a.log("switching codec "+C+" to "+k),k!==(R.pendingCodec||R.codec)&&(R.pendingCodec=k),R.container=S,a.appendChangeType(d,S,k))}),(this.tracksReady||this.sourceBufferCount)&&(r.tracks=this.sourceBufferTracks),!this.sourceBufferCount&&this.mediaSourceOpenOrEnded&&this.checkPendingTracks()},i.appendChangeType=function(e,r,a){var o=this,l=r+";codecs="+a,u={label:"change-type="+l,execute:function(){var d=o.tracks[e];if(d){var h=d.buffer;h!=null&&h.changeType&&(o.log("changing "+e+" sourceBuffer type to "+l),h.changeType(l),d.codec=a,d.container=r)}o.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(d){o.warn("Failed to change "+e+" SourceBuffer type",d)}};this.append(u,e,this.isPending(this.tracks[e]))},i.blockAudio=function(e){var r,a=this,o=e.start,l=o+e.duration*.05,u=((r=this.fragmentTracker.getAppendedFrag(o,W.MAIN))==null?void 0:r.gap)===!0;if(!u){var f={label:"block-audio",execute:function(){var h,v=a.tracks.video;(a.lastVideoAppendEnd>l||v!=null&&v.buffer&&$.isBuffered(v.buffer,l)||((h=a.fragmentTracker.getAppendedFrag(l,W.MAIN))==null?void 0:h.gap)===!0)&&(a.blockedAudioAppend=null,a.shiftAndExecuteNext("audio"))},onStart:function(){},onComplete:function(){},onError:function(h){a.warn("Error executing block-audio operation",h)}};this.blockedAudioAppend={op:f,frag:e},this.append(f,"audio",!0)}},i.unblockAudio=function(){var e=this.blockedAudioAppend,r=this.operationQueue;e&&r&&(this.blockedAudioAppend=null,r.unblockAudio(e.op))},i.onBufferAppending=function(e,r){var a=this,o=this.tracks,l=r.data,u=r.type,f=r.parent,d=r.frag,h=r.part,v=r.chunkMeta,c=v.buffering[u],g=d.sn,m=self.performance.now();c.start=m;var p=d.stats.buffering,y=h?h.stats.buffering:null;p.start===0&&(p.start=m),y&&y.start===0&&(y.start=m);var S=o.audio,T=!1;u==="audio"&&S?.container==="audio/mpeg"&&(T=!this.lastMpegAudioChunk||v.id===1||this.lastMpegAudioChunk.sn!==v.sn,this.lastMpegAudioChunk=v);var x=this.tracks.video,R=x?.buffer;if(R&&g!=="initSegment"){var L=h||d,A=this.blockedAudioAppend;if(u==="audio"&&f!=="main"&&!this.blockedAudioAppend){var C=L.start,_=C+L.duration*.05,b=R.buffered,I=this.currentOp("video");!b.length&&!I?this.blockAudio(L):!I&&!$.isBuffered(R,_)&&this.lastVideoAppendEnd<_&&this.blockAudio(L)}else if(u==="video"){var k=L.end;if(A){var w=A.frag.start;(k>w||k<this.lastVideoAppendEnd||$.isBuffered(R,w))&&this.unblockAudio()}this.lastVideoAppendEnd=k}}var M=(h||d).start,P={label:"append-"+u,execute:function(){if(c.executeStart=self.performance.now(),T){var B=a.tracks[u];if(B){var U=B.buffer;if(U){var G=M-U.timestampOffset;Math.abs(G)>=.1&&(a.log("Updating audio SourceBuffer timestampOffset to "+M+" (delta: "+G+") sn: "+g+")"),U.timestampOffset=M)}}}a.appendExecutor(l,u)},onStart:function(){},onComplete:function(){var B=self.performance.now();c.executeEnd=c.end=B,p.first===0&&(p.first=B),y&&y.first===0&&(y.first=B);var U={};a.sourceBuffers.forEach(function(G){var z=G[0],q=G[1];z&&(U[z]=$.getBuffered(q))}),a.appendErrors[u]=0,u==="audio"||u==="video"?a.appendErrors.audiovideo=0:(a.appendErrors.audio=0,a.appendErrors.video=0),a.hls.trigger(E.BUFFER_APPENDED,{type:u,frag:d,part:h,chunkMeta:v,parent:d.type,timeRanges:U})},onError:function(B){var U,G={type:K.MEDIA_ERROR,parent:d.type,details:D.BUFFER_APPEND_ERROR,sourceBufferName:u,frag:d,part:h,chunkMeta:v,error:B,err:B,fatal:!1};if(B.code===DOMException.QUOTA_EXCEEDED_ERR)G.details=D.BUFFER_FULL_ERROR;else if(B.code===DOMException.INVALID_STATE_ERR&&a.mediaSourceOpenOrEnded&&!((U=a.media)!=null&&U.error))G.errorAction=Lt(!0);else if(B.name===ci)a.sourceBufferCount===0?G.errorAction=Lt(!0):++a.appendErrors[u];else{var z=++a.appendErrors[u];a.warn("Failed "+z+"/"+a.hls.config.appendErrorMaxRetry+' times to append segment in "'+u+'" sourceBuffer'),z>=a.hls.config.appendErrorMaxRetry&&(G.fatal=!0)}a.hls.trigger(E.ERROR,G)}};this.append(P,u,this.isPending(this.tracks[u]))},i.getFlushOp=function(e,r,a){var o=this;return this.log('queuing "'+e+'" remove '+r+"-"+a),{label:"remove",execute:function(){o.removeExecutor(e,r,a)},onStart:function(){},onComplete:function(){o.hls.trigger(E.BUFFER_FLUSHED,{type:e})},onError:function(u){o.warn("Failed to remove "+r+"-"+a+' from "'+e+'" SourceBuffer',u)}}},i.onBufferFlushing=function(e,r){var a=this,o=r.type,l=r.startOffset,u=r.endOffset;o?this.append(this.getFlushOp(o,l,u),o):this.sourceBuffers.forEach(function(f){var d=f[0];d&&a.append(a.getFlushOp(d,l,u),d)})},i.onFragParsed=function(e,r){var a=this,o=r.frag,l=r.part,u=[],f=l?l.elementaryStreams:o.elementaryStreams;f[re.AUDIOVIDEO]?u.push("audiovideo"):(f[re.AUDIO]&&u.push("audio"),f[re.VIDEO]&&u.push("video"));var d=function(){var v=self.performance.now();o.stats.buffering.end=v,l&&(l.stats.buffering.end=v);var c=l?l.stats:o.stats;a.hls.trigger(E.FRAG_BUFFERED,{frag:o,part:l,stats:c,id:o.type})};u.length===0&&this.warn("Fragments must have at least one ElementaryStreamType set. type: "+o.type+" level: "+o.level+" sn: "+o.sn),this.blockBuffers(d,u)},i.onFragChanged=function(e,r){this.trimBuffers()},i.onBufferEos=function(e,r){var a=this,o;this.sourceBuffers.forEach(function(f){var d=f[0];if(d){var h=a.tracks[d];(!r.type||r.type===d)&&(h.ending=!0,h.ended||(h.ended=!0,a.log(d+" buffer reached EOS")))}});var l=((o=this.overrides)==null?void 0:o.endOfStream)!==!1,u=this.sourceBufferCount>0&&!this.sourceBuffers.some(function(f){var d,h=f[0];return h&&!((d=a.tracks[h])!=null&&d.ended)});u&&(l?(this.log("Queueing EOS"),this.blockUntilOpen(function(){a.tracksEnded();var f=a.mediaSource;if(!f||f.readyState!=="open"){f&&a.log("Could not call mediaSource.endOfStream(). mediaSource.readyState: "+f.readyState);return}a.log("Calling mediaSource.endOfStream()"),f.endOfStream(),a.hls.trigger(E.BUFFERED_TO_END,void 0)})):(this.tracksEnded(),this.hls.trigger(E.BUFFERED_TO_END,void 0)))},i.tracksEnded=function(){var e=this;this.sourceBuffers.forEach(function(r){var a=r[0];if(a!==null){var o=e.tracks[a];o&&(o.ending=!1)}})},i.onLevelUpdated=function(e,r){var a=r.details;a.fragments.length&&(this.details=a,this.updateDuration())},i.updateDuration=function(){var e=this,r=this.getDurationAndRange();r&&this.blockUntilOpen(function(){return e.updateMediaSource(r)})},i.onError=function(e,r){if(r.details===D.BUFFER_APPEND_ERROR&&r.frag){var a,o=(a=r.errorAction)==null?void 0:a.nextAutoLevel;N(o)&&o!==r.frag.level&&this.resetAppendErrors()}},i.resetAppendErrors=function(){this.appendErrors={audio:0,video:0,audiovideo:0}},i.trimBuffers=function(){var e=this.hls,r=this.details,a=this.media;if(!(!a||r===null)&&this.sourceBufferCount){var o=e.config,l=a.currentTime,u=r.levelTargetDuration,f=r.live&&o.liveBackBufferLength!==null?o.liveBackBufferLength:o.backBufferLength;if(N(f)&&f>=0){var d=Math.max(f,u),h=Math.floor(l/u)*u-d;this.flushBackBuffer(l,u,h)}if(N(o.frontBufferFlushThreshold)&&o.frontBufferFlushThreshold>0){var v=Math.max(o.maxBufferLength,o.frontBufferFlushThreshold),c=Math.max(v,u),g=Math.floor(l/u)*u+c;this.flushFrontBuffer(l,u,g)}}},i.flushBackBuffer=function(e,r,a){var o=this;this.sourceBuffers.forEach(function(l){var u=l[0],f=l[1];if(f){var d=$.getBuffered(f);if(d.length>0&&a>d.start(0)){var h;o.hls.trigger(E.BACK_BUFFER_REACHED,{bufferEnd:a});var v=o.tracks[u];if((h=o.details)!=null&&h.live)o.hls.trigger(E.LIVE_BACK_BUFFER_REACHED,{bufferEnd:a});else if(v!=null&&v.ended){o.log("Cannot flush "+u+" back buffer while SourceBuffer is in ended state");return}o.hls.trigger(E.BUFFER_FLUSHING,{startOffset:0,endOffset:a,type:u})}}})},i.flushFrontBuffer=function(e,r,a){var o=this;this.sourceBuffers.forEach(function(l){var u=l[0],f=l[1];if(f){var d=$.getBuffered(f),h=d.length;if(h<2)return;var v=d.start(h-1),c=d.end(h-1);if(a>v||e>=v&&e<=c)return;o.hls.trigger(E.BUFFER_FLUSHING,{startOffset:v,endOffset:1/0,type:u})}})},i.getDurationAndRange=function(){var e,r=this.details,a=this.mediaSource;if(!r||!this.media||a?.readyState!=="open")return null;var o=r.edge;if(r.live&&this.hls.config.liveDurationInfinity){var l=r.fragments.length;if(l&&r.live&&a.setLiveSeekableRange){var u=Math.max(0,r.fragmentStart),f=Math.max(u,o);return{duration:1/0,start:u,end:f}}return{duration:1/0}}var d=(e=this.overrides)==null?void 0:e.duration;if(d)return N(d)?{duration:d}:null;var h=this.media.duration,v=N(a.duration)?a.duration:0;return o>v&&o>h||!N(h)?{duration:o}:null},i.updateMediaSource=function(e){var r=e.duration,a=e.start,o=e.end,l=this.mediaSource;!this.media||!l||l.readyState!=="open"||(l.duration!==r&&(N(r)&&this.log("Updating MediaSource duration to "+r.toFixed(3)),l.duration=r),a!==void 0&&o!==void 0&&(this.log("MediaSource duration is set to "+l.duration+". Setting seekable range to "+a+"-"+o+"."),l.setLiveSeekableRange(a,o)))},i.checkPendingTracks=function(){var e=this.bufferCodecEventsTotal,r=this.pendingTrackCount,a=this.tracks;if(this.log("checkPendingTracks (pending: "+r+" codec events expected: "+e+") "+Te(a)),this.tracksReady){var o,l=(o=this.transferData)==null?void 0:o.tracks;l&&Object.keys(l).length?this.attachTransferred():this.createSourceBuffers()}},i.bufferCreated=function(){var e=this;if(this.sourceBufferCount){var r={};this.sourceBuffers.forEach(function(o){var l=o[0],u=o[1];if(l){var f=e.tracks[l];r[l]={buffer:u,container:f.container,codec:f.codec,supplemental:f.supplemental,levelCodec:f.levelCodec,id:f.id,metadata:f.metadata}}}),this.hls.trigger(E.BUFFER_CREATED,{tracks:r}),this.log("SourceBuffers created. Running queue: "+this.operationQueue),this.sourceBuffers.forEach(function(o){var l=o[0];e.executeNext(l)})}else{var a=new Error("could not create source buffer for media codec(s)");this.hls.trigger(E.ERROR,{type:K.MEDIA_ERROR,details:D.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:a,reason:a.message})}},i.createSourceBuffers=function(){var e=this.tracks,r=this.sourceBuffers,a=this.mediaSource;if(!a)throw new Error("createSourceBuffers called when mediaSource was null");for(var o in e){var l=o,u=e[l];if(this.isPending(u)){var f=this.getTrackCodec(u,l),d=u.container+";codecs="+f;u.codec=f,this.log("creating sourceBuffer("+d+")"+(this.currentOp(l)?" Queued":"")+" "+Te(u));try{var h=a.addSourceBuffer(d),v=rr(l),c=[l,h];r[v]=c,u.buffer=h}catch(m){var g;this.error("error while trying to add sourceBuffer: "+m.message),this.shiftAndExecuteNext(l),(g=this.operationQueue)==null||g.removeBlockers(),delete this.tracks[l],this.hls.trigger(E.ERROR,{type:K.MEDIA_ERROR,details:D.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:m,sourceBufferName:l,mimeType:d,parent:u.id});return}this.trackSourceBuffer(l,u)}}this.bufferCreated()},i.getTrackCodec=function(e,r){var a=e.supplemental,o=e.codec;a&&(r==="video"||r==="audiovideo")&&Qt(a,"video")&&(o=Ea(o,a));var l=Et(o,e.levelCodec);return l?r.slice(0,5)==="audio"?pt(l,this.appendSource):l:""},i.trackSourceBuffer=function(e,r){var a=this,o=r.buffer;if(o){var l=this.getTrackCodec(r,e);this.tracks[e]={buffer:o,codec:l,container:r.container,levelCodec:r.levelCodec,supplemental:r.supplemental,metadata:r.metadata,id:r.id,listeners:[]},this.removeBufferListeners(e),this.addBufferListener(e,"updatestart",this.onSBUpdateStart),this.addBufferListener(e,"updateend",this.onSBUpdateEnd),this.addBufferListener(e,"error",this.onSBUpdateError),this.appendSource&&this.addBufferListener(e,"bufferedchange",function(u,f){var d=f.removedRanges;d!=null&&d.length&&a.hls.trigger(E.BUFFER_FLUSHED,{type:u})})}},i.onSBUpdateStart=function(e){var r=this.currentOp(e);r&&r.onStart()},i.onSBUpdateEnd=function(e){var r;if(((r=this.mediaSource)==null?void 0:r.readyState)==="closed"){this.resetBuffer(e);return}var a=this.currentOp(e);a&&(a.onComplete(),this.shiftAndExecuteNext(e))},i.onSBUpdateError=function(e,r){var a,o=new Error(e+" SourceBuffer error. MediaSource readyState: "+((a=this.mediaSource)==null?void 0:a.readyState));this.error(""+o,r),this.hls.trigger(E.ERROR,{type:K.MEDIA_ERROR,details:D.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:o,fatal:!1});var l=this.currentOp(e);l&&l.onError(o)},i.removeExecutor=function(e,r,a){var o=this.media,l=this.mediaSource,u=this.tracks[e],f=u?.buffer;if(!o||!l||!f){this.warn("Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),this.shiftAndExecuteNext(e);return}var d=N(o.duration)?o.duration:1/0,h=N(l.duration)?l.duration:1/0,v=Math.max(0,r),c=Math.min(a,d,h);c>v&&(!u.ending||u.ended)?(u.ended=!1,this.log("Removing ["+v+","+c+"] from the "+e+" SourceBuffer"),f.remove(v,c)):this.shiftAndExecuteNext(e)},i.appendExecutor=function(e,r){var a=this.tracks[r],o=a?.buffer;if(!o)throw new Fa("Attempting to append to the "+r+" SourceBuffer, but it does not exist");a.ending=!1,a.ended=!1,o.appendBuffer(e)},i.blockUntilOpen=function(e){this.isUpdating()||this.isQueued()?this.blockBuffers(e):e()},i.isUpdating=function(){return this.sourceBuffers.some(function(e){var r=e[0],a=e[1];return r&&a.updating})},i.isQueued=function(){var e=this;return this.sourceBuffers.some(function(r){var a=r[0];return a&&!!e.currentOp(a)})},i.isPending=function(e){return!!e&&!e.buffer},i.blockBuffers=function(e,r){var a=this;if(r===void 0&&(r=this.sourceBufferTypes),!r.length){this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}var o=this.operationQueue,l=r.map(function(f){return a.appendBlocker(f)}),u=r.length>1&&!!this.blockedAudioAppend;u&&this.unblockAudio(),Promise.all(l).then(function(f){o===a.operationQueue&&(e(),a.stepOperationQueue(r))})},i.stepOperationQueue=function(e){var r=this;e.forEach(function(a){var o,l=(o=r.tracks[a])==null?void 0:o.buffer;!l||l.updating||r.shiftAndExecuteNext(a)})},i.append=function(e,r,a){this.operationQueue&&this.operationQueue.append(e,r,a)},i.appendBlocker=function(e){if(this.operationQueue)return this.operationQueue.appendBlocker(e)},i.currentOp=function(e){return this.operationQueue?this.operationQueue.current(e):null},i.executeNext=function(e){e&&this.operationQueue&&this.operationQueue.executeNext(e)},i.shiftAndExecuteNext=function(e){this.operationQueue&&this.operationQueue.shiftAndExecuteNext(e)},i.addBufferListener=function(e,r,a){var o=this.tracks[e];if(o){var l=o.buffer;if(l){var u=a.bind(this,e);o.listeners.push({event:r,listener:u}),l.addEventListener(r,u)}}},i.removeBufferListeners=function(e){var r=this.tracks[e];if(r){var a=r.buffer;a&&(r.listeners.forEach(function(o){a.removeEventListener(o.event,o.listener)}),r.listeners.length=0)}},te(s,[{key:"mediaSourceOpenOrEnded",get:function(){var e,r=(e=this.mediaSource)==null?void 0:e.readyState;return r==="open"||r==="ended"}},{key:"sourceBufferTracks",get:function(){var e=this;return Object.keys(this.tracks).reduce(function(r,a){var o=e.tracks[a];return r[a]={id:o.id,container:o.container,codec:o.codec,levelCodec:o.levelCodec},r},{})}},{key:"bufferedToEnd",get:function(){var e=this;return this.sourceBufferCount>0&&!this.sourceBuffers.some(function(r){var a,o,l=r[0];return l&&(!((a=e.tracks[l])!=null&&a.ended)||((o=e.tracks[l])==null?void 0:o.ending))})}},{key:"tracksReady",get:function(){var e=this.pendingTrackCount;return e>0&&(e>=this.bufferCodecEventsTotal||this.isPending(this.tracks.audiovideo))}},{key:"mediaSrc",get:function(){var e,r,a=((e=this.media)==null||(r=e.querySelector)==null?void 0:r.call(e,"source"))||this.media;return a?.src}},{key:"pendingTrackCount",get:function(){var e=this;return Object.keys(this.tracks).reduce(function(r,a){return r+(e.isPending(e.tracks[a])?1:0)},0)}},{key:"sourceBufferCount",get:function(){return this.sourceBuffers.reduce(function(e,r){var a=r[0];return e+(a?1:0)},0)}},{key:"sourceBufferTypes",get:function(){return this.sourceBuffers.map(function(e){var r=e[0];return r}).filter(function(e){return!!e})}}])}($e);function vi(n){var s=n.querySelectorAll("source");[].slice.call(s).forEach(function(i){n.removeChild(i)})}function Ba(n,s){var i=self.document.createElement("source");i.type="video/mp4",i.src=s,n.appendChild(i)}function rr(n){return n==="audio"?1:0}var Ua=function(){function n(i){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=i,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var s=n.prototype;return s.setStreamController=function(t){this.streamController=t},s.destroy=function(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},s.registerListeners=function(){var t=this.hls;t.on(E.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(E.MANIFEST_PARSED,this.onManifestParsed,this),t.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(E.BUFFER_CODECS,this.onBufferCodecs,this),t.on(E.MEDIA_DETACHING,this.onMediaDetaching,this)},s.unregisterListener=function(){var t=this.hls;t.off(E.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(E.MANIFEST_PARSED,this.onManifestParsed,this),t.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(E.BUFFER_CODECS,this.onBufferCodecs,this),t.off(E.MEDIA_DETACHING,this.onMediaDetaching,this)},s.onFpsDropLevelCapping=function(t,e){var r=this.hls.levels[e.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})},s.onMediaAttaching=function(t,e){this.media=e.media instanceof HTMLVideoElement?e.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()},s.onManifestParsed=function(t,e){var r=this.hls;this.restrictedLevels=[],this.firstLevel=e.firstLevel,r.config.capLevelToPlayerSize&&e.video&&this.startCapping()},s.onLevelsUpdated=function(t,e){this.timer&&N(this.autoLevelCapping)&&this.detectPlayerSize()},s.onBufferCodecs=function(t,e){var r=this.hls;r.config.capLevelToPlayerSize&&e.video&&this.startCapping()},s.onMediaDetaching=function(){this.stopCapping(),this.media=null},s.detectPlayerSize=function(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0){this.clientRect=null;return}var t=this.hls.levels;if(t.length){var e=this.hls,r=this.getMaxLevel(t.length-1);r!==this.autoLevelCapping&&e.logger.log("Setting autoLevelCapping to "+r+": "+t[r].height+"p@"+t[r].bitrate+" for media "+this.mediaWidth+"x"+this.mediaHeight),e.autoLevelCapping=r,e.autoLevelEnabled&&e.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=e.autoLevelCapping}}},s.getMaxLevel=function(t){var e=this,r=this.hls.levels;if(!r.length)return-1;var a=r.filter(function(o,l){return e.isLevelAllowed(o)&&l<=t});return this.clientRect=null,n.getMaxLevelByMediaSize(a,this.mediaWidth,this.mediaHeight)},s.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},s.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},s.getDimensions=function(){if(this.clientRect)return this.clientRect;var t=this.media,e={width:0,height:0};if(t){var r=t.getBoundingClientRect();e.width=r.width,e.height=r.height,!e.width&&!e.height&&(e.width=r.right-r.left||t.width||0,e.height=r.bottom-r.top||t.height||0)}return this.clientRect=e,e},s.isLevelAllowed=function(t){var e=this.restrictedLevels;return!e.some(function(r){return t.bitrate===r.bitrate&&t.width===r.width&&t.height===r.height})},n.getMaxLevelByMediaSize=function(t,e,r){if(!(t!=null&&t.length))return-1;for(var a=function(h,v){return v?h.width!==v.width||h.height!==v.height:!0},o=t.length-1,l=Math.max(e,r),u=0;u<t.length;u+=1){var f=t[u];if((f.width>=l||f.height>=l)&&a(f,t[u+1])){o=u;break}}return o},te(n,[{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var t=1;if(!this.hls.config.ignoreDevicePixelRatio)try{t=self.devicePixelRatio}catch{}return Math.min(t,this.hls.config.maxDevicePixelRatio)}}])}(),Ga=/^(\d+)x(\d+)$/,gi=/(.+?)=(".*?"|.*?)(?:,|$)/g,le=function(){function n(i,t){typeof i=="string"&&(i=n.parseAttrList(i,t)),de(this,i)}var s=n.prototype;return s.decimalInteger=function(t){var e=parseInt(this[t],10);return e>Number.MAX_SAFE_INTEGER?1/0:e},s.hexadecimalInteger=function(t){if(this[t]){var e=(this[t]||"0x").slice(2);e=(e.length&1?"0":"")+e;for(var r=new Uint8Array(e.length/2),a=0;a<e.length/2;a++)r[a]=parseInt(e.slice(a*2,a*2+2),16);return r}return null},s.hexadecimalIntegerAsNumber=function(t){var e=parseInt(this[t],16);return e>Number.MAX_SAFE_INTEGER?1/0:e},s.decimalFloatingPoint=function(t){return parseFloat(this[t])},s.optionalFloat=function(t,e){var r=this[t];return r?parseFloat(r):e},s.enumeratedString=function(t){return this[t]},s.enumeratedStringList=function(t,e){var r=this[t];return(r?r.split(/[ ,]+/):[]).reduce(function(a,o){return a[o.toLowerCase()]=!0,a},e)},s.bool=function(t){return this[t]==="YES"},s.decimalResolution=function(t){var e=Ga.exec(this[t]);if(e!==null)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}},n.parseAttrList=function(t,e){var r,a={},o='"';for(gi.lastIndex=0;(r=gi.exec(t))!==null;){var l=r[1].trim(),u=r[2],f=u.indexOf(o)===0&&u.lastIndexOf(o)===u.length-1,d=!1;if(f)u=u.slice(1,-1);else switch(l){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":d=!0}if(!(e&&(f||d))){if(!d&&!f)switch(l){case"CLOSED-CAPTIONS":if(u==="NONE")break;case"ALLOWED-CPC":case"CLASS":case"ASSOC-LANGUAGE":case"AUDIO":case"BYTERANGE":case"CHANNELS":case"CHARACTERISTICS":case"CODECS":case"DATA-ID":case"END-DATE":case"GROUP-ID":case"ID":case"IMPORT":case"INSTREAM-ID":case"KEYFORMAT":case"KEYFORMATVERSIONS":case"LANGUAGE":case"NAME":case"PATHWAY-ID":case"QUERYPARAM":case"RECENTLY-REMOVED-DATERANGES":case"SERVER-URI":case"STABLE-RENDITION-ID":case"STABLE-VARIANT-ID":case"START-DATE":case"SUBTITLES":case"SUPPLEMENTAL-CODECS":case"URI":case"VALUE":case"VIDEO":case"X-ASSET-LIST":case"X-ASSET-URI":X.warn(t+": attribute "+l+" is missing quotes")}}a[l]=u}return a},te(n,[{key:"clientAttrs",get:function(){return Object.keys(this).filter(function(t){return t.substring(0,2)==="X-"})}}])}(),Ha="com.apple.hls.interstitial";function Va(n){return n!=="ID"&&n!=="CLASS"&&n!=="CUE"&&n!=="START-DATE"&&n!=="DURATION"&&n!=="END-DATE"&&n!=="END-ON-NEXT"}function Ka(n){return n==="SCTE35-OUT"||n==="SCTE35-IN"||n==="SCTE35-CMD"}var mi=function(){function n(s,i,t){var e;if(t===void 0&&(t=0),this.attr=void 0,this.tagAnchor=void 0,this.tagOrder=void 0,this._startDate=void 0,this._endDate=void 0,this._dateAtEnd=void 0,this._cue=void 0,this._badValueForSameId=void 0,this.tagAnchor=i?.tagAnchor||null,this.tagOrder=(e=i?.tagOrder)!=null?e:t,i){var r=i.attr;for(var a in r)if(Object.prototype.hasOwnProperty.call(s,a)&&s[a]!==r[a]){X.warn('DATERANGE tag attribute: "'+a+'" does not match for tags with ID: "'+s.ID+'"'),this._badValueForSameId=a;break}s=de(new le({}),r,s)}if(this.attr=s,i?(this._startDate=i._startDate,this._cue=i._cue,this._endDate=i._endDate,this._dateAtEnd=i._dateAtEnd):this._startDate=new Date(s["START-DATE"]),"END-DATE"in this.attr){var o=i?.endDate||new Date(this.attr["END-DATE"]);N(o.getTime())&&(this._endDate=o)}}return te(n,[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"cue",get:function(){var i=this._cue;return i===void 0?this._cue=this.attr.enumeratedStringList(this.attr.CUE?"CUE":"X-CUE",{pre:!1,post:!1,once:!1}):i}},{key:"startTime",get:function(){var i=this.tagAnchor;return i===null||i.programDateTime===null?(X.warn('Expected tagAnchor Fragment with PDT set for DateRange "'+this.id+'": '+i),NaN):i.start+(this.startDate.getTime()-i.programDateTime)/1e3}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){var i=this._endDate||this._dateAtEnd;if(i)return i;var t=this.duration;return t!==null?this._dateAtEnd=new Date(this._startDate.getTime()+t*1e3):null}},{key:"duration",get:function(){if("DURATION"in this.attr){var i=this.attr.decimalFloatingPoint("DURATION");if(N(i))return i}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:"isInterstitial",get:function(){return this.class===Ha}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&N(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)&&(!this.attr.CUE||!this.cue.pre&&!this.cue.post||this.cue.pre!==this.cue.post)&&(!this.isInterstitial||"X-ASSET-URI"in this.attr||"X-ASSET-LIST"in this.attr)}}])}(),Wa=10,Ya=function(){function n(i){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.dateRangeTagCount=0,this.live=!0,this.requestScheduled=-1,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.appliedTimelineOffset=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=i}var s=n.prototype;return s.reloaded=function(t){if(!t){this.advanced=!0,this.updated=!0;return}var e=this.lastPartSn-t.lastPartSn,r=this.lastPartIndex-t.lastPartIndex;this.updated=this.endSN!==t.endSN||!!r||!!e||!this.live,this.advanced=this.endSN>t.endSN||e>0||e===0&&r>0,this.updated||this.advanced?this.misses=Math.floor(t.misses*.6):this.misses=t.misses+1},te(n,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?N(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||Wa}},{key:"drift",get:function(){var t=this.driftEndTime-this.driftStartTime;if(t>0){var e=this.driftEnd-this.driftStart;return e*1e3/t}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var t;return(t=this.partList)!=null&&t.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var t;return(t=this.fragments)!=null&&t.length?this.fragments[this.fragments.length-1].end:0}},{key:"fragmentStart",get:function(){var t;return(t=this.fragments)!=null&&t.length?this.fragments[0].start:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var t;return(t=this.partList)!=null&&t.length?this.partList[this.partList.length-1].index:-1}},{key:"maxPartIndex",get:function(){var t=this.partList;if(t){var e=this.lastPartIndex;if(e!==-1){for(var r=t.length;r--;)if(t[r].index>e)return t[r].index;return e}}return 0}},{key:"lastPartSn",get:function(){var t;return(t=this.partList)!=null&&t.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}},{key:"expired",get:function(){if(this.live&&this.age&&this.misses<3){var t=this.partEnd-this.fragmentStart;return this.age>Math.max(t,this.totalduration)+this.levelTargetDuration}return!1}}])}(),Ye={cbc:0,ctr:1};function st(n){return n==="AES-128"||n==="AES-256"||n==="AES-256-CTR"}function pi(n){switch(n){case"AES-128":case"AES-256":return Ye.cbc;case"AES-256-CTR":return Ye.ctr;default:throw new Error("invalid full segment method "+n)}}var qa=function(){function n(i,t,e,r,a){r===void 0&&(r=[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=i,this.uri=t,this.keyFormat=e,this.keyFormatVersions=r,this.iv=a,this.encrypted=i?i!=="NONE":!1,this.isCommonEncryption=this.encrypted&&!st(i)}n.clearKeyUriToKeyIdMap=function(){};var s=n.prototype;return s.isSupported=function(){if(this.method){if(st(this.method)||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES"}return!1},s.getDecryptData=function(t){if(!this.encrypted||!this.uri)return null;if(st(this.method)&&this.uri&&!this.iv){typeof t!="number"&&(X.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),t=0);var e=ja(t),r=new n(this.method,this.uri,"identity",this.keyFormatVersions,e);return r}return this},n}();function ja(n){for(var s=new Uint8Array(16),i=12;i<16;i++)s[i]=n>>8*(15-i)&255;return s}var Ei=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,yi=/#EXT-X-MEDIA:(.*)/g,Xa=/^#EXT(?:INF|-X-TARGETDURATION):/m,ir=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),$a=new RegExp([/#EXT-X-(PROGRAM-DATE-TIME|BYTERANGE|DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),ot=function(){function n(){}return n.findGroup=function(i,t){for(var e=0;e<i.length;e++){var r=i[e];if(r.id===t)return r}},n.resolve=function(i,t){return Vt.buildAbsoluteURL(t,i,{alwaysNormalize:!0})},n.isMediaPlaylist=function(i){return Xa.test(i)},n.parseMasterPlaylist=function(i,t){var e=!1,r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:e},a=[];Ei.lastIndex=0;for(var o;(o=Ei.exec(i))!=null;)if(o[1]){var l,u=new le(o[1],r),f=o[2],d={attrs:u,bitrate:u.decimalInteger("BANDWIDTH")||u.decimalInteger("AVERAGE-BANDWIDTH"),name:u.NAME,url:n.resolve(f,t)},h=u.decimalResolution("RESOLUTION");h&&(d.width=h.width,d.height=h.height),Li(u.CODECS,d);var v=u["SUPPLEMENTAL-CODECS"];v&&(d.supplemental={},Li(v,d.supplemental)),(l=d.unknownCodecs)!=null&&l.length||a.push(d),r.levels.push(d)}else if(o[3]){var c=o[3],g=o[4];switch(c){case"SESSION-DATA":{var m=new le(g,r),p=m["DATA-ID"];p&&(r.sessionData===null&&(r.sessionData={}),r.sessionData[p]=m);break}case"SESSION-KEY":{var y=Si(g,t,r);y.encrypted&&y.isSupported()?(r.sessionKeys===null&&(r.sessionKeys=[]),r.sessionKeys.push(y)):X.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+g+'"');break}case"DEFINE":break;case"CONTENT-STEERING":{var S=new le(g,r);r.contentSteering={uri:n.resolve(S["SERVER-URI"],t),pathwayId:S["PATHWAY-ID"]||"."};break}case"START":{r.startTimeOffset=xi(g);break}}}var T=a.length>0&&a.length<r.levels.length;return r.levels=T?a:r.levels,r.levels.length===0&&(r.playlistParsingError=new Error("no levels found in manifest")),r},n.parseMasterPlaylistMedia=function(i,t,e){var r,a={},o=e.levels,l={AUDIO:o.map(function(x){return{id:x.attrs.AUDIO,audioCodec:x.audioCodec}}),SUBTITLES:o.map(function(x){return{id:x.attrs.SUBTITLES,textCodec:x.textCodec}}),"CLOSED-CAPTIONS":[]},u=0;for(yi.lastIndex=0;(r=yi.exec(i))!==null;){var f=new le(r[1],e),d=f.TYPE;if(d){var h=l[d],v=a[d]||[];a[d]=v;var c=f.LANGUAGE,g=f["ASSOC-LANGUAGE"],m=f.CHANNELS,p=f.CHARACTERISTICS,y=f["INSTREAM-ID"],S={attrs:f,bitrate:0,id:u++,groupId:f["GROUP-ID"]||"",name:f.NAME||c||"",type:d,default:f.bool("DEFAULT"),autoselect:f.bool("AUTOSELECT"),forced:f.bool("FORCED"),lang:c,url:f.URI?n.resolve(f.URI,t):""};if(g&&(S.assocLang=g),m&&(S.channels=m),p&&(S.characteristics=p),y&&(S.instreamId=y),h!=null&&h.length){var T=n.findGroup(h,S.groupId)||h[0];Ai(S,T,"audioCodec"),Ai(S,T,"textCodec")}v.push(S)}}return a},n.parseLevelPlaylist=function(i,t,e,r,a,o){var l,u={url:t},f=new Ya(t),d=f.fragments,h=[],v=null,c=0,g=0,m=0,p=0,y=0,S=null,T=new jt(r,u),x,R,L,A=-1,C=!1,_=null,b;if(ir.lastIndex=0,f.m3u8=i,f.hasVariableRefs=!1,((l=ir.exec(i))==null?void 0:l[0])!=="#EXTM3U")return f.playlistParsingError=new Error("Missing format identifier #EXTM3U"),f;for(;(x=ir.exec(i))!==null;){C&&(C=!1,T=new jt(r,u),T.playlistOffset=m,T.start=m,T.sn=c,T.cc=p,y&&(T.bitrate=y),T.level=e,v&&(T.initSegment=v,v.rawProgramDateTime&&(T.rawProgramDateTime=v.rawProgramDateTime,v.rawProgramDateTime=null),_&&(T.setByteRange(_),_=null)));var I=x[1];if(I){T.duration=parseFloat(I);var k=(" "+x[2]).slice(1);T.title=k||null,T.tagList.push(k?["INF",I,k]:["INF",I])}else if(x[3]){if(N(T.duration)){T.playlistOffset=m,T.start=m,L&&bi(T,L,f),T.sn=c,T.level=e,T.cc=p,d.push(T);var w=(" "+x[3]).slice(1);T.relurl=w,nr(T,S,h),S=T,m+=T.duration,c++,g=0,C=!0}}else{if(x=x[0].match($a),!x){X.warn("No matches on slow regex match for level playlist!");continue}for(R=1;R<x.length&&x[R]===void 0;R++);var M=(" "+x[R]).slice(1),P=(" "+x[R+1]).slice(1),F=x[R+2]?(" "+x[R+2]).slice(1):null;switch(M){case"BYTERANGE":S?T.setByteRange(P,S):T.setByteRange(P);break;case"PROGRAM-DATE-TIME":T.rawProgramDateTime=P,T.tagList.push(["PROGRAM-DATE-TIME",P]),A===-1&&(A=d.length);break;case"PLAYLIST-TYPE":f.type&&Ge(f,M,x),f.type=P.toUpperCase();break;case"MEDIA-SEQUENCE":f.startSN!==0?Ge(f,M,x):d.length>0&&Ii(f,M,x),c=f.startSN=parseInt(P);break;case"SKIP":{f.skippedSegments&&Ge(f,M,x);var B=new le(P,f),U=B.decimalInteger("SKIPPED-SEGMENTS");if(N(U)){f.skippedSegments+=U;for(var G=U;G--;)d.push(null);c+=U}var z=B.enumeratedString("RECENTLY-REMOVED-DATERANGES");z&&(f.recentlyRemovedDateranges=(f.recentlyRemovedDateranges||[]).concat(z.split(" ")));break}case"TARGETDURATION":f.targetduration!==0&&Ge(f,M,x),f.targetduration=Math.max(parseInt(P),1);break;case"VERSION":f.version!==null&&Ge(f,M,x),f.version=parseInt(P);break;case"INDEPENDENT-SEGMENTS":break;case"ENDLIST":f.live||Ge(f,M,x),f.live=!1;break;case"#":(P||F)&&T.tagList.push(F?[P,F]:[P]);break;case"DISCONTINUITY":p++,T.tagList.push(["DIS"]);break;case"GAP":T.gap=!0,T.tagList.push([M]);break;case"BITRATE":T.tagList.push([M,P]),y=parseInt(P)*1e3,N(y)?T.bitrate=y:y=0;break;case"DATERANGE":{var q=new le(P,f),Q=new mi(q,f.dateRanges[q.ID],f.dateRangeTagCount);f.dateRangeTagCount++,Q.isValid||f.skippedSegments?f.dateRanges[Q.id]=Q:X.warn('Ignoring invalid DATERANGE tag: "'+P+'"'),T.tagList.push(["EXT-X-DATERANGE",P]);break}case"DEFINE":break;case"DISCONTINUITY-SEQUENCE":f.startCC!==0?Ge(f,M,x):d.length>0&&Ii(f,M,x),f.startCC=p=parseInt(P);break;case"KEY":{var Y=Si(P,t,f);if(Y.isSupported()){if(Y.method==="NONE"){L=void 0;break}L||(L={}),L[Y.keyFormat]&&(L=de({},L)),L[Y.keyFormat]=Y}else X.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+P+'"');break}case"START":f.startTimeOffset=xi(P);break;case"MAP":{var ae=new le(P,f);if(T.duration){var Z=new jt(r,u);Ri(Z,ae,e,L),v=Z,T.initSegment=v,v.rawProgramDateTime&&!T.rawProgramDateTime&&(T.rawProgramDateTime=v.rawProgramDateTime)}else{var ne=T.byteRangeEndOffset;if(ne){var Ae=T.byteRangeStartOffset;_=ne-Ae+"@"+Ae}else _=null;Ri(T,ae,e,L),v=T,C=!0}v.cc=p;break}case"SERVER-CONTROL":{b&&Ge(f,M,x),b=new le(P),f.canBlockReload=b.bool("CAN-BLOCK-RELOAD"),f.canSkipUntil=b.optionalFloat("CAN-SKIP-UNTIL",0),f.canSkipDateRanges=f.canSkipUntil>0&&b.bool("CAN-SKIP-DATERANGES"),f.partHoldBack=b.optionalFloat("PART-HOLD-BACK",0),f.holdBack=b.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{f.partTarget&&Ge(f,M,x);var ge=new le(P);f.partTarget=ge.decimalFloatingPoint("PART-TARGET");break}case"PART":{var J=f.partList;J||(J=f.partList=[]);var Re=g>0?J[J.length-1]:void 0,ue=g++,ie=new le(P,f),be=new Jn(ie,T,u,ue,Re);J.push(be),T.duration+=be.duration;break}case"PRELOAD-HINT":{var Ee=new le(P,f);f.preloadHint=Ee;break}case"RENDITION-REPORT":{var De=new le(P,f);f.renditionReports=f.renditionReports||[],f.renditionReports.push(De);break}default:X.warn("line parsed but not handled: "+x);break}}}S&&!S.relurl?(d.pop(),m-=S.duration,f.partList&&(f.fragmentHint=S)):f.partList&&(nr(T,S,h),T.cc=p,f.fragmentHint=T,L&&bi(T,L,f)),f.targetduration||(f.playlistParsingError=new Error("#EXT-X-TARGETDURATION is required"));var ee=d.length,ye=d[0],fe=d[ee-1];if(m+=f.skippedSegments*f.targetduration,m>0&&ee&&fe){f.averagetargetduration=m/ee;var Ie=fe.sn;f.endSN=Ie!=="initSegment"?Ie:0,f.live||(fe.endList=!0),ye&&f.startCC===void 0&&(f.startCC=ye.cc),A>0&&(Qa(d,A),ye&&h.unshift(ye))}else f.endSN=0,f.startCC=0;return f.fragmentHint&&(m+=f.fragmentHint.duration),f.totalduration=m,h.length&&f.dateRangeTagCount&&ye&&Ti(h,f),f.endCC=p,f},n}();function Ti(n,s){for(var i=n.length,t=n[i-1],e=s.live?1/0:s.totalduration,r=Object.keys(s.dateRanges),a=r.length;a--;){var o=s.dateRanges[r[a]],l=o.startDate.getTime();o.tagAnchor=t.ref;for(var u=i;u--;){var f=za(s,l,n,u,e);if(f!==-1){o.tagAnchor=s.fragments[f].ref;break}}}}function za(n,s,i,t,e){var r=i[t];if(r){var a=r.programDateTime;if(s>=a||t===0){var o,l=(((o=i[t+1])==null?void 0:o.start)||e)-r.start;if(s<=a+l*1e3){var u=i[t].sn-n.startSN,f=n.fragments;if(f.length>i.length)for(var d=i[t+1]||f[f.length-1],h=d.sn-n.startSN,v=h;v>u;v--){var c=f[v].programDateTime;if(s>=c&&s<c+f[v].duration*1e3)return v}return u}}}return-1}function Si(n,s,i){var t,e,r=new le(n,i),a=(t=r.METHOD)!=null?t:"",o=r.URI,l=r.hexadecimalInteger("IV"),u=r.KEYFORMATVERSIONS,f=(e=r.KEYFORMAT)!=null?e:"identity";o&&r.IV&&!l&&X.error("Invalid IV: "+r.IV);var d=o?ot.resolve(o,s):"",h=(u||"1").split("/").map(Number).filter(Number.isFinite);return new qa(a,d,f,h,l)}function xi(n){var s=new le(n),i=s.decimalFloatingPoint("TIME-OFFSET");return N(i)?i:null}function Li(n,s){var i=(n||"").split(/[ ,]+/).filter(function(t){return t});["video","audio","text"].forEach(function(t){var e=i.filter(function(r){return zr(r,t)});e.length&&(s[t+"Codec"]=e.map(function(r){return r.split("/")[0]}).join(","),i=i.filter(function(r){return e.indexOf(r)===-1}))}),s.unknownCodecs=i}function Ai(n,s,i){var t=s[i];t&&(n[i]=t)}function Qa(n,s){for(var i=n[s],t=s;t--;){var e=n[t];if(!e)return;e.programDateTime=i.programDateTime-e.duration*1e3,i=e}}function nr(n,s,i){n.rawProgramDateTime?i.push(n):s!=null&&s.programDateTime&&(n.programDateTime=s.endProgramDateTime)}function Ri(n,s,i,t){n.relurl=s.URI,s.BYTERANGE&&n.setByteRange(s.BYTERANGE),n.level=i,n.sn="initSegment",t&&(n.levelkeys=t),n.initSegment=null}function bi(n,s,i){n.levelkeys=s;var t=i.encryptedFragments;(!t.length||t[t.length-1].levelkeys!==s)&&Object.keys(s).some(function(e){return s[e].isCommonEncryption})&&t.push(n)}function Ge(n,s,i){n.playlistParsingError=new Error("#EXT-X-"+s+" must not appear more than once ("+i[0]+")")}function Ii(n,s,i){n.playlistParsingError=new Error("#EXT-X-"+s+" must appear before the first Media Segment ("+i[0]+")")}function ar(n,s){var i=s.startPTS;if(N(i)){var t=0,e;s.sn>n.sn?(t=i-n.start,e=n):(t=n.start-i,e=s),e.duration!==t&&e.setDuration(t)}else if(s.sn>n.sn){var r=n.cc===s.cc;r&&n.minEndPTS?s.setStart(n.start+(n.minEndPTS-n.start)):s.setStart(n.start+n.duration)}else s.setStart(Math.max(n.start-s.duration,0))}function _i(n,s,i,t,e,r){var a=t-i;a<=0&&(X.warn("Fragment should have a positive duration",s),t=i+s.duration,r=e+s.duration);var o=i,l=t,u=s.startPTS,f=s.endPTS;if(N(u)){var d=Math.abs(u-i);N(s.deltaPTS)?s.deltaPTS=Math.max(d,s.deltaPTS):s.deltaPTS=d,o=Math.max(i,u),i=Math.min(i,u),e=Math.min(e,s.startDTS),l=Math.min(t,f),t=Math.max(t,f),r=Math.max(r,s.endDTS)}var h=i-s.start;s.start!==0&&s.setStart(i),s.setDuration(t-s.start),s.startPTS=i,s.maxStartPTS=o,s.startDTS=e,s.endPTS=t,s.minEndPTS=l,s.endDTS=r;var v=s.sn;if(!n||v<n.startSN||v>n.endSN)return 0;var c,g=v-n.startSN,m=n.fragments;for(m[g]=s,c=g;c>0;c--)ar(m[c],m[c-1]);for(c=g;c<m.length-1;c++)ar(m[c],m[c+1]);return n.fragmentHint&&ar(m[m.length-1],n.fragmentHint),n.PTSKnown=n.alignedSliding=!0,h}function Za(n,s){if(n!==s){for(var i=null,t=n.fragments,e=t.length-1;e>=0;e--){var r=t[e].initSegment;if(r){i=r;break}}n.fragmentHint&&delete n.fragmentHint.endPTS;var a;ts(n,s,function(c,g,m,p){if(s.skippedSegments&&g.cc!==c.cc)for(var y=c.cc-g.cc,S=m;S<p.length;S++)p[S].cc+=y;N(c.startPTS)&&N(c.endPTS)&&(g.setStart(g.startPTS=c.startPTS),g.startDTS=c.startDTS,g.maxStartPTS=c.maxStartPTS,g.endPTS=c.endPTS,g.endDTS=c.endDTS,g.minEndPTS=c.minEndPTS,g.setDuration(c.endPTS-c.startPTS),g.duration&&(a=g),s.PTSKnown=s.alignedSliding=!0),c.hasStreams&&(g.elementaryStreams=c.elementaryStreams),g.loader=c.loader,c.hasStats&&(g.stats=c.stats),c.initSegment&&(g.initSegment=c.initSegment,i=c.initSegment)});var o=s.fragments,l=s.fragmentHint?o.concat(s.fragmentHint):o;if(i&&l.forEach(function(c){var g;c&&(!c.initSegment||c.initSegment.relurl===((g=i)==null?void 0:g.relurl))&&(c.initSegment=i)}),s.skippedSegments)if(s.deltaUpdateFailed=o.some(function(c){return!c}),s.deltaUpdateFailed){X.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var u=s.skippedSegments;u--;)o.shift();s.startSN=o[0].sn}else{s.endCC=o[o.length-1].cc,s.canSkipDateRanges&&(s.dateRanges=Ja(n.dateRanges,s));var f=n.fragments.filter(function(c){return c.rawProgramDateTime});if(n.hasProgramDateTime&&!s.hasProgramDateTime)for(var d=1;d<l.length;d++)l[d].programDateTime===null&&nr(l[d],l[d-1],f);Ti(f,s)}es(n.partList,s.partList,function(c,g){g.elementaryStreams=c.elementaryStreams,g.stats=c.stats}),a?_i(s,a,a.startPTS,a.endPTS,a.startDTS,a.endDTS):Ci(n,s),o.length&&(s.totalduration=s.edge-o[0].start),s.driftStartTime=n.driftStartTime,s.driftStart=n.driftStart;var h=s.advancedDateTime;if(s.advanced&&h){var v=s.edge;s.driftStart||(s.driftStartTime=h,s.driftStart=v),s.driftEndTime=h,s.driftEnd=v}else s.driftEndTime=n.driftEndTime,s.driftEnd=n.driftEnd,s.advancedDateTime=n.advancedDateTime;s.requestScheduled===-1&&(s.requestScheduled=n.requestScheduled)}}function Ja(n,s){var i=s.dateRanges,t=s.recentlyRemovedDateranges,e=de({},n);t&&t.forEach(function(o){delete e[o]});var r=Object.keys(e),a=r.length;return a&&Object.keys(i).forEach(function(o){var l=e[o],u=new mi(i[o].attr,l);u.isValid?(e[o]=u,l||(u.tagOrder+=a)):X.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+Te(i[o].attr)+'"')}),e}function es(n,s,i){if(n&&s)for(var t=0,e=0,r=n.length;e<=r;e++){var a=n[e],o=s[e+t];a&&o&&a.index===o.index&&a.fragment.sn===o.fragment.sn?i(a,o):t--}}function ts(n,s,i){for(var t=s.skippedSegments,e=Math.max(n.startSN,s.startSN)-s.startSN,r=(n.fragmentHint?1:0)+(t?s.endSN:Math.min(n.endSN,s.endSN))-s.startSN,a=s.startSN-n.startSN,o=s.fragmentHint?s.fragments.concat(s.fragmentHint):s.fragments,l=n.fragmentHint?n.fragments.concat(n.fragmentHint):n.fragments,u=e;u<=r;u++){var f=l[a+u],d=o[u];if(t&&!d&&f&&(d=s.fragments[u]=f),f&&d){if(i(f,d,u,o),f.url&&f.url!==d.url){s.playlistParsingError=Di("media sequence mismatch "+d.sn+":",n,s,f,d);return}else if(f.cc!==d.cc){s.playlistParsingError=Di("discontinuity sequence mismatch ("+f.cc+"!="+d.cc+")",n,s,f,d);return}}}}function Di(n,s,i,t,e){return new Error(n+" "+e.url+`
18
- Playlist starting @`+s.startSN+`
19
- `+s.m3u8+`
20
-
21
- Playlist starting @`+i.startSN+`
22
- `+i.m3u8)}function Ci(n,s,i){i===void 0&&(i=!0);var t=s.startSN+s.skippedSegments-n.startSN,e=n.fragments,r=t>=0,a=0;if(r&&t<e.length)a=e[t].start;else if(r&&s.startSN===n.endSN+1)a=n.fragmentEnd;else if(r&&i)a=n.fragmentStart+t*s.levelTargetDuration;else if(!s.skippedSegments&&s.fragmentStart===0)a=n.fragmentStart;else return;rs(s,a)}function rs(n,s){if(s){for(var i=n.fragments,t=n.skippedSegments;t<i.length;t++)i[t].addStart(s);n.fragmentHint&&n.fragmentHint.addStart(s)}}function ki(n,s){s===void 0&&(s=1/0);var i=1e3*n.targetduration;if(n.updated){var t=n.fragments,e=4;if(t.length&&i*e>s){var r=t[t.length-1].duration*1e3;r<i&&(i=r)}}else i/=2;return Math.round(i)}function is(n,s,i){if(!n)return null;var t=n.fragments[s-n.startSN];return t||(t=n.fragmentHint,t&&t.sn===s)?t:s<n.startSN&&i&&i.sn===s?i:null}function Pi(n,s,i){return n?Mi(n.partList,s,i):null}function Mi(n,s,i){if(n)for(var t=n.length;t--;){var e=n[t];if(e.index===i&&e.fragment.sn===s)return e}return null}function Oi(n){n.forEach(function(s,i){var t;(t=s.details)==null||t.fragments.forEach(function(e){e.level=i,e.initSegment&&(e.initSegment.level=i)})})}var ns=3e5,as=function(n){function s(t){var e;return e=n.call(this,"content-steering",t.logger)||this,e.hls=void 0,e.loader=null,e.uri=null,e.pathwayId=".",e._pathwayPriority=null,e.timeToLoad=300,e.reloadTimer=-1,e.updated=0,e.started=!1,e.enabled=!0,e.levels=null,e.audioTracks=null,e.subtitleTracks=null,e.penalizedPathways={},e.hls=t,e.registerListeners(),e}he(s,n);var i=s.prototype;return i.registerListeners=function(){var e=this.hls;e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.ERROR,this.onError,this)},i.unregisterListeners=function(){var e=this.hls;e&&(e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.ERROR,this.onError,this))},i.pathways=function(){return(this.levels||[]).reduce(function(e,r){return e.indexOf(r.pathwayId)===-1&&e.push(r.pathwayId),e},[])},i.startLoad=function(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){var e=this.timeToLoad*1e3-(performance.now()-this.updated);if(e>0){this.scheduleRefresh(this.uri,e);return}}this.loadSteeringManifest(this.uri)}},i.stopLoad=function(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()},i.clearTimeout=function(){this.reloadTimer!==-1&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)},i.destroy=function(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null},i.removeLevel=function(e){var r=this.levels;r&&(this.levels=r.filter(function(a){return a!==e}))},i.onManifestLoading=function(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null},i.onManifestLoaded=function(e,r){var a=r.contentSteering;a!==null&&(this.pathwayId=a.pathwayId,this.uri=a.uri,this.started&&this.startLoad())},i.onManifestParsed=function(e,r){this.audioTracks=r.audioTracks,this.subtitleTracks=r.subtitleTracks},i.onError=function(e,r){var a=r.errorAction;if(a?.action===pe.SendAlternateToPenaltyBox&&a.flags===Pe.MoveAllAlternatesMatchingHost){var o=this.levels,l=this._pathwayPriority,u=this.pathwayId;if(r.context){var f=r.context,d=f.groupId,h=f.pathwayId,v=f.type;d&&o?u=this.getPathwayForGroupId(d,v,u):h&&(u=h)}u in this.penalizedPathways||(this.penalizedPathways[u]=performance.now()),!l&&o&&(l=this.pathways()),l&&l.length>1&&(this.updatePathwayPriority(l),a.resolved=this.pathwayId!==u),a.resolved||this.warn("Could not resolve "+r.details+' ("'+r.error.message+'") with content-steering for Pathway: '+u+" levels: "+(o&&o.length)+" priorities: "+Te(l)+" penalized: "+Te(this.penalizedPathways))}},i.filterParsedLevels=function(e){this.levels=e;var r=this.getLevelsForPathway(this.pathwayId);if(r.length===0){var a=e[0].pathwayId;this.log("No levels found in Pathway "+this.pathwayId+'. Setting initial Pathway to "'+a+'"'),r=this.getLevelsForPathway(a),this.pathwayId=a}return r.length!==e.length&&this.log("Found "+r.length+"/"+e.length+' levels in Pathway "'+this.pathwayId+'"'),r},i.getLevelsForPathway=function(e){return this.levels===null?[]:this.levels.filter(function(r){return e===r.pathwayId})},i.updatePathwayPriority=function(e){this._pathwayPriority=e;var r,a=this.penalizedPathways,o=performance.now();Object.keys(a).forEach(function(v){o-a[v]>ns&&delete a[v]});for(var l=0;l<e.length;l++){var u=e[l];if(!(u in a)){if(u===this.pathwayId)return;var f=this.hls.nextLoadLevel,d=this.hls.levels[f];if(r=this.getLevelsForPathway(u),r.length>0){this.log('Setting Pathway to "'+u+'"'),this.pathwayId=u,Oi(r),this.hls.trigger(E.LEVELS_UPDATED,{levels:r});var h=this.hls.levels[f];d&&h&&this.levels&&(h.attrs["STABLE-VARIANT-ID"]!==d.attrs["STABLE-VARIANT-ID"]&&h.bitrate!==d.bitrate&&this.log("Unstable Pathways change from bitrate "+d.bitrate+" to "+h.bitrate),this.hls.nextLoadLevel=f);break}}}},i.getPathwayForGroupId=function(e,r,a){for(var o=this.getLevelsForPathway(a).concat(this.levels||[]),l=0;l<o.length;l++)if(r===j.AUDIO_TRACK&&o[l].hasAudioGroup(e)||r===j.SUBTITLE_TRACK&&o[l].hasSubtitleGroup(e))return o[l].pathwayId;return a},i.clonePathways=function(e){var r=this,a=this.levels;if(a){var o={},l={};e.forEach(function(u){var f=u.ID,d=u["BASE-ID"],h=u["URI-REPLACEMENT"];if(!a.some(function(c){return c.pathwayId===f})){var v=r.getLevelsForPathway(d).map(function(c){var g=new le(c.attrs);g["PATHWAY-ID"]=f;var m=g.AUDIO&&g.AUDIO+"_clone_"+f,p=g.SUBTITLES&&g.SUBTITLES+"_clone_"+f;m&&(o[g.AUDIO]=m,g.AUDIO=m),p&&(l[g.SUBTITLES]=p,g.SUBTITLES=p);var y=Fi(c.uri,g["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",h),S=new ii({attrs:g,audioCodec:c.audioCodec,bitrate:c.bitrate,height:c.height,name:c.name,url:y,videoCodec:c.videoCodec,width:c.width});if(c.audioGroups)for(var T=1;T<c.audioGroups.length;T++)S.addGroupId("audio",c.audioGroups[T]+"_clone_"+f);if(c.subtitleGroups)for(var x=1;x<c.subtitleGroups.length;x++)S.addGroupId("text",c.subtitleGroups[x]+"_clone_"+f);return S});a.push.apply(a,v),wi(r.audioTracks,o,h,f),wi(r.subtitleTracks,l,h,f)}})}},i.loadSteeringManifest=function(e){var r=this,a=this.hls.config,o=a.loader;this.loader&&this.loader.destroy(),this.loader=new o(a);var l;try{l=new self.URL(e)}catch{this.enabled=!1,this.log("Failed to parse Steering Manifest URI: "+e);return}if(l.protocol!=="data:"){var u=(this.hls.bandwidthEstimate||a.abrEwmaDefaultEstimate)|0;l.searchParams.set("_HLS_pathway",this.pathwayId),l.searchParams.set("_HLS_throughput",""+u)}var f={responseType:"json",url:l.href},d=a.steeringManifestLoadPolicy.default,h=d.errorRetry||d.timeoutRetry||{},v={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:h.maxNumRetry||0,retryDelay:h.retryDelayMs||0,maxRetryDelay:h.maxRetryDelayMs||0},c={onSuccess:function(m,p,y,S){r.log('Loaded steering manifest: "'+l+'"');var T=m.data;if(T?.VERSION!==1){r.log("Steering VERSION "+T.VERSION+" not supported!");return}r.updated=performance.now(),r.timeToLoad=T.TTL;var x=T["RELOAD-URI"],R=T["PATHWAY-CLONES"],L=T["PATHWAY-PRIORITY"];if(x)try{r.uri=new self.URL(x,l).href}catch{r.enabled=!1,r.log("Failed to parse Steering Manifest RELOAD-URI: "+x);return}r.scheduleRefresh(r.uri||y.url),R&&r.clonePathways(R);var A={steeringManifest:T,url:l.toString()};r.hls.trigger(E.STEERING_MANIFEST_LOADED,A),L&&r.updatePathwayPriority(L)},onError:function(m,p,y,S){if(r.log("Error loading steering manifest: "+m.code+" "+m.text+" ("+p.url+")"),r.stopLoad(),m.code===410){r.enabled=!1,r.log("Steering manifest "+p.url+" no longer available");return}var T=r.timeToLoad*1e3;if(m.code===429){var x=r.loader;if(typeof x?.getResponseHeader=="function"){var R=x.getResponseHeader("Retry-After");R&&(T=parseFloat(R)*1e3)}r.log("Steering manifest "+p.url+" rate limited");return}r.scheduleRefresh(r.uri||p.url,T)},onTimeout:function(m,p,y){r.log("Timeout loading steering manifest ("+p.url+")"),r.scheduleRefresh(r.uri||p.url)}};this.log("Requesting steering manifest: "+l),this.loader.load(f,v,c)},i.scheduleRefresh=function(e,r){var a=this;r===void 0&&(r=this.timeToLoad*1e3),this.clearTimeout(),this.reloadTimer=self.setTimeout(function(){var o,l=(o=a.hls)==null?void 0:o.media;if(l&&!l.ended){a.loadSteeringManifest(e);return}a.scheduleRefresh(e,a.timeToLoad*1e3)},r)},te(s,[{key:"pathwayPriority",get:function(){return this._pathwayPriority},set:function(e){this.updatePathwayPriority(e)}}])}($e);function wi(n,s,i,t){n&&Object.keys(s).forEach(function(e){var r=n.filter(function(a){return a.groupId===e}).map(function(a){var o=de({},a);return o.details=void 0,o.attrs=new le(o.attrs),o.url=o.attrs.URI=Fi(a.url,a.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",i),o.groupId=o.attrs["GROUP-ID"]=s[e],o.attrs["PATHWAY-ID"]=t,o});n.push.apply(n,r)})}function Fi(n,s,i,t){var e=t.HOST,r=t.PARAMS,a=t[i],o;s&&(o=a?.[s],o&&(n=o));var l=new self.URL(n);return e&&!o&&(l.host=e),r&&Object.keys(r).sort().forEach(function(u){u&&l.searchParams.set(u,r[u])}),l.href}var ss=function(){function n(i){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=i,this.registerListeners()}var s=n.prototype;return s.setStreamController=function(t){this.streamController=t},s.registerListeners=function(){this.hls.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(E.MEDIA_DETACHING,this.onMediaDetaching,this)},s.unregisterListeners=function(){this.hls.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(E.MEDIA_DETACHING,this.onMediaDetaching,this)},s.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},s.onMediaAttaching=function(t,e){var r=this.hls.config;if(r.capLevelOnFPSDrop){var a=e.media instanceof self.HTMLVideoElement?e.media:null;this.media=a,a&&typeof a.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}},s.onMediaDetaching=function(){this.media=null},s.checkFPS=function(t,e,r){var a=performance.now();if(e){if(this.lastTime){var o=a-this.lastTime,l=r-this.lastDroppedFrames,u=e-this.lastDecodedFrames,f=1e3*l/o,d=this.hls;if(d.trigger(E.FPS_DROP,{currentDropped:l,currentDecoded:u,totalDroppedFrames:r}),f>0&&l>d.config.fpsDroppedMonitoringThreshold*u){var h=d.currentLevel;d.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+h),h>0&&(d.autoLevelCapping===-1||d.autoLevelCapping>=h)&&(h=h-1,d.trigger(E.FPS_DROP_LEVEL_CAPPING,{level:h,droppedLevel:d.currentLevel}),d.autoLevelCapping=h,this.streamController.nextLevelSwitch())}}this.lastTime=a,this.lastDroppedFrames=r,this.lastDecodedFrames=e}},s.checkFPSInterval=function(){var t=this.media;if(t)if(this.isVideoPlaybackQualityAvailable){var e=t.getVideoPlaybackQuality();this.checkFPS(t,e.totalVideoFrames,e.droppedVideoFrames)}else this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount)},n}(),os=function(){function n(){this.chunks=[],this.dataLength=0}var s=n.prototype;return s.push=function(t){this.chunks.push(t),this.dataLength+=t.length},s.flush=function(){var t=this.chunks,e=this.dataLength,r;if(t.length)t.length===1?r=t[0]:r=ls(t,e);else return new Uint8Array(0);return this.reset(),r},s.reset=function(){this.chunks.length=0,this.dataLength=0},n}();function ls(n,s){for(var i=new Uint8Array(s),t=0,e=0;e<n.length;e++){var r=n[e];i.set(r,t),t+=r.length}return i}function Ni(n,s){return s+10<=n.length&&n[s]===51&&n[s+1]===68&&n[s+2]===73&&n[s+3]<255&&n[s+4]<255&&n[s+6]<128&&n[s+7]<128&&n[s+8]<128&&n[s+9]<128}function sr(n,s){return s+10<=n.length&&n[s]===73&&n[s+1]===68&&n[s+2]===51&&n[s+3]<255&&n[s+4]<255&&n[s+6]<128&&n[s+7]<128&&n[s+8]<128&&n[s+9]<128}function At(n,s){var i=0;return i=(n[s]&127)<<21,i|=(n[s+1]&127)<<14,i|=(n[s+2]&127)<<7,i|=n[s+3]&127,i}function Rt(n,s){for(var i=s,t=0;sr(n,s);){t+=10;var e=At(n,s+6);t+=e,Ni(n,s+10)&&(t+=10),s+=t}if(t>0)return n.subarray(i,i+t)}function us(n,s,i,t){var e=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],r=s[i+2],a=r>>2&15;if(a>12){var o=new Error("invalid ADTS sampling index:"+a);n.emit(E.ERROR,E.ERROR,{type:K.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!0,error:o,reason:o.message});return}var l=(r>>6&3)+1,u=s[i+3]>>6&3|(r&1)<<2,f="mp4a.40."+l,d=e[a],h=a;(l===5||l===29)&&(h-=3);var v=[l<<3|(h&14)>>1,(h&1)<<7|u<<3];return X.log("manifest codec:"+t+", parsed codec:"+f+", channels:"+u+", rate:"+d+" (ADTS object type:"+l+" sampling index:"+a+")"),{config:v,samplerate:d,channelCount:u,codec:f,parsedCodec:f,manifestCodec:t}}function Bi(n,s){return n[s]===255&&(n[s+1]&246)===240}function Ui(n,s){return n[s+1]&1?7:9}function or(n,s){return(n[s+3]&3)<<11|n[s+4]<<3|(n[s+5]&224)>>>5}function fs(n,s){return s+5<n.length}function bt(n,s){return s+1<n.length&&Bi(n,s)}function ds(n,s){return fs(n,s)&&Bi(n,s)&&or(n,s)<=n.length-s}function hs(n,s){if(bt(n,s)){var i=Ui(n,s);if(s+i>=n.length)return!1;var t=or(n,s);if(t<=i)return!1;var e=s+t;return e===n.length||bt(n,e)}return!1}function Gi(n,s,i,t,e){if(!n.samplerate){var r=us(s,i,t,e);if(!r)return;de(n,r)}}function Hi(n){return 1024*9e4/n}function cs(n,s){var i=Ui(n,s);if(s+i<=n.length){var t=or(n,s)-i;if(t>0)return{headerLength:i,frameLength:t}}}function Vi(n,s,i,t,e){var r=Hi(n.samplerate),a=t+e*r,o=cs(s,i),l;if(o){var u=o.frameLength,f=o.headerLength,d=f+u,h=Math.max(0,i+d-s.length);h?(l=new Uint8Array(d-f),l.set(s.subarray(i+f,s.length),0)):l=s.subarray(i+f,i+d);var v={unit:l,pts:a};return h||n.samples.push(v),{sample:v,length:d,missing:h}}var c=s.length-i;l=new Uint8Array(c),l.set(s.subarray(i,s.length),0);var g={unit:l,pts:a};return{sample:g,length:c,missing:-1}}function vs(n,s){return sr(n,s)&&At(n,s+6)+10<=n.length-s}function gs(n){if(!(n.size<2)){var s=Ce(n.data,!0),i=new Uint8Array(n.data.subarray(s.length+1));return{key:n.type,info:s,data:i.buffer}}}function ms(n){if(!(n.size<2)){if(n.type==="TXXX"){var s=1,i=Ce(n.data.subarray(s),!0);s+=i.length+1;var t=Ce(n.data.subarray(s));return{key:n.type,info:i,data:t}}var e=Ce(n.data.subarray(1));return{key:n.type,info:"",data:e}}}function ps(n){if(n.type==="WXXX"){if(n.size<2)return;var s=1,i=Ce(n.data.subarray(s),!0);s+=i.length+1;var t=Ce(n.data.subarray(s));return{key:n.type,info:i,data:t}}var e=Ce(n.data);return{key:n.type,info:"",data:e}}function Es(n){return n instanceof ArrayBuffer?n:n.byteOffset==0&&n.byteLength==n.buffer.byteLength?n.buffer:new Uint8Array(n).buffer}function lr(n,s,i){return s===void 0&&(s=0),i===void 0&&(i=1/0),ys(n,s,i,Uint8Array)}function ys(n,s,i,t){var e=Ts(n),r=1;"BYTES_PER_ELEMENT"in t&&(r=t.BYTES_PER_ELEMENT);var a=Ss(n)?n.byteOffset:0,o=(a+n.byteLength)/r,l=(a+s)/r,u=Math.floor(Math.max(0,Math.min(l,o))),f=Math.floor(Math.min(u+Math.max(i,0),o));return new t(e,u,f-u)}function Ts(n){return n instanceof ArrayBuffer?n:n.buffer}function Ss(n){return n&&n.buffer instanceof ArrayBuffer&&n.byteLength!==void 0&&n.byteOffset!==void 0}function xs(n){var s={key:n.type,description:"",data:"",mimeType:null,pictureType:null},i=3;if(!(n.size<2)){if(n.data[0]!==i){console.log("Ignore frame with unrecognized character encoding");return}var t=n.data.subarray(1).indexOf(0);if(t!==-1){var e=Ce(lr(n.data,1,t)),r=n.data[2+t],a=n.data.subarray(3+t).indexOf(0);if(a!==-1){var o=Ce(lr(n.data,3+t,a)),l;return e==="-->"?l=Ce(lr(n.data,4+t+a)):l=Es(n.data.subarray(4+t+a)),s.mimeType=e,s.pictureType=r,s.description=o,s.data=l,s}}}}function Ls(n){return n.type==="PRIV"?gs(n):n.type[0]==="W"?ps(n):n.type==="APIC"?xs(n):ms(n)}function As(n){var s=String.fromCharCode(n[0],n[1],n[2],n[3]),i=At(n,4),t=10;return{type:s,size:i,data:n.subarray(t,t+i)}}var It=10,Rs=10;function Ki(n){for(var s=0,i=[];sr(n,s);){var t=At(n,s+6);n[s+5]>>6&1&&(s+=It),s+=It;for(var e=s+t;s+Rs<e;){var r=As(n.subarray(s)),a=Ls(r);a&&i.push(a),s+=r.size+It}Ni(n,s)&&(s+=It)}return i}function Wi(n){return n&&n.key==="PRIV"&&n.info==="com.apple.streaming.transportStreamTimestamp"}function bs(n){if(n.data.byteLength===8){var s=new Uint8Array(n.data),i=s[3]&1,t=(s[4]<<23)+(s[5]<<15)+(s[6]<<7)+s[7];return t/=45,i&&(t+=4772185884e-2),Math.round(t)}}function Yi(n){for(var s=Ki(n),i=0;i<s.length;i++){var t=s[i];if(Wi(t))return bs(t)}}var _e=function(n){return n.audioId3="org.id3",n.dateRange="com.apple.quicktime.HLS",n.emsg="https://aomedia.org/emsg/ID3",n.misbklv="urn:misb:KLV:bin:1910.1",n}({});function Be(n,s){return n===void 0&&(n=""),s===void 0&&(s=9e4),{type:n,id:-1,pid:-1,inputTimeScale:s,sequenceNumber:-1,samples:[],dropped:0}}var qi=function(){function n(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var s=n.prototype;return s.resetInitSegment=function(t,e,r,a){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},s.resetTimeStamp=function(t){this.initPTS=t,this.resetContiguity()},s.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},s.canParse=function(t,e){return!1},s.appendFrame=function(t,e,r){},s.demux=function(t,e){this.cachedData&&(t=ke(this.cachedData,t),this.cachedData=null);var r=Rt(t,0),a=r?r.length:0,o,l=this._audioTrack,u=this._id3Track,f=r?Yi(r):void 0,d=t.length;for((this.basePTS===null||this.frameIndex===0&&N(f))&&(this.basePTS=Is(f,e,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),r&&r.length>0&&u.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:_e.audioId3,duration:Number.POSITIVE_INFINITY});a<d;){if(this.canParse(t,a)){var h=this.appendFrame(l,t,a);h?(this.frameIndex++,this.lastPTS=h.sample.pts,a+=h.length,o=a):a=d}else vs(t,a)?(r=Rt(t,a),u.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:_e.audioId3,duration:Number.POSITIVE_INFINITY}),a+=r.length,o=a):a++;if(a===d&&o!==d){var v=t.slice(o);this.cachedData?this.cachedData=ke(this.cachedData,v):this.cachedData=v}}return{audioTrack:l,videoTrack:Be(),id3Track:u,textTrack:Be()}},s.demuxSampleAes=function(t,e,r){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},s.flush=function(t){var e=this.cachedData;return e&&(this.cachedData=null,this.demux(e,0)),{audioTrack:this._audioTrack,videoTrack:Be(),id3Track:this._id3Track,textTrack:Be()}},s.destroy=function(){this.cachedData=null,this._audioTrack=this._id3Track=void 0},n}(),Is=function(s,i,t){if(N(s))return s*90;var e=t?t.baseTime*9e4/t.timescale:0;return i*9e4+e},_t=null,_s=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],Ds=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Cs=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],ks=[0,1,1,4];function ji(n,s,i,t,e){if(!(i+24>s.length)){var r=Xi(s,i);if(r&&i+r.frameLength<=s.length){var a=r.samplesPerFrame*9e4/r.sampleRate,o=t+e*a,l={unit:s.subarray(i,i+r.frameLength),pts:o,dts:o};return n.config=[],n.channelCount=r.channelCount,n.samplerate=r.sampleRate,n.samples.push(l),{sample:l,length:r.frameLength,missing:0}}}}function Xi(n,s){var i=n[s+1]>>3&3,t=n[s+1]>>1&3,e=n[s+2]>>4&15,r=n[s+2]>>2&3;if(i!==1&&e!==0&&e!==15&&r!==3){var a=n[s+2]>>1&1,o=n[s+3]>>6,l=i===3?3-t:t===3?3:4,u=_s[l*14+e-1]*1e3,f=i===3?0:i===2?1:2,d=Ds[f*3+r],h=o===3?1:2,v=Cs[i][t],c=ks[t],g=v*8*c,m=Math.floor(v*u/d+a)*c;if(_t===null){var p=navigator.userAgent||"",y=p.match(/Chrome\/(\d+)/i);_t=y?parseInt(y[1]):0}var S=!!_t&&_t<=87;return S&&t===2&&u>=224e3&&o===0&&(n[s+3]=n[s+3]|128),{sampleRate:d,channelCount:h,frameLength:m,samplesPerFrame:g}}}function ur(n,s){return n[s]===255&&(n[s+1]&224)===224&&(n[s+1]&6)!==0}function $i(n,s){return s+1<n.length&&ur(n,s)}function Ps(n,s){var i=4;return ur(n,s)&&i<=n.length-s}function zi(n,s){if(s+1<n.length&&ur(n,s)){var i=4,t=Xi(n,s),e=i;t!=null&&t.frameLength&&(e=t.frameLength);var r=s+e;return r===n.length||$i(n,r)}return!1}var Ms=function(n){function s(t,e){var r;return r=n.call(this)||this,r.observer=void 0,r.config=void 0,r.observer=t,r.config=e,r}he(s,n);var i=s.prototype;return i.resetInitSegment=function(e,r,a,o){n.prototype.resetInitSegment.call(this,e,r,a,o),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:r,duration:o,inputTimeScale:9e4,dropped:0}},s.probe=function(e,r){if(!e)return!1;var a=Rt(e,0),o=a?.length||0;if(zi(e,o))return!1;for(var l=e.length;o<l;o++)if(hs(e,o))return r.log("ADTS sync word found !"),!0;return!1},i.canParse=function(e,r){return ds(e,r)},i.appendFrame=function(e,r,a){Gi(e,this.observer,r,a,e.manifestCodec);var o=Vi(e,r,a,this.basePTS,this.frameIndex);if(o&&o.missing===0)return o},s}(qi),Os=function(s,i){var t=0,e=5;i+=e;for(var r=new Uint32Array(1),a=new Uint32Array(1),o=new Uint8Array(1);e>0;){o[0]=s[i];var l=Math.min(e,8),u=8-l;a[0]=4278190080>>>24+u<<u,r[0]=(o[0]&a[0])>>u,t=t?t<<l|r[0]:r[0],i+=1,e-=l}return t},ws=function(n){function s(){return n.apply(this,arguments)||this}he(s,n);var i=s.prototype;return i.resetInitSegment=function(e,r,a,o){n.prototype.resetInitSegment.call(this,e,r,a,o),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:r,duration:o,inputTimeScale:9e4,dropped:0}},s.probe=function(e){if(!e)return!1;var r=Rt(e,0),a=r?.length||0;if(r&&e[a]===11&&e[a+1]===119&&Yi(r)!==void 0&&Os(e,a)<=16)return!1;for(var o=e.length;a<o;a++)if(zi(e,a))return X.log("MPEG Audio sync word found !"),!0;return!1},i.canParse=function(e,r){return Ps(e,r)},i.appendFrame=function(e,r,a){if(this.basePTS!==null)return ji(e,r,a,this.basePTS,this.frameIndex)},s}(qi),Fs=function(){function n(i,t,e){this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=i,this.aesIV=t,this.aesMode=e}var s=n.prototype;return s.decrypt=function(t,e){switch(this.aesMode){case Ye.cbc:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},e,t);case Ye.ctr:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},e,t);default:throw new Error("[AESCrypto] invalid aes mode "+this.aesMode)}},n}();function Ns(n){var s=n.byteLength,i=s&&new DataView(n.buffer).getUint8(s-1);return i?n.slice(0,s-i):n}var Bs=function(){function n(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var s=n.prototype;return s.uint8ArrayToUint32Array_=function(t){for(var e=new DataView(t),r=new Uint32Array(4),a=0;a<4;a++)r[a]=e.getUint32(a*4);return r},s.initTable=function(){var t=this.sBox,e=this.invSBox,r=this.subMix,a=r[0],o=r[1],l=r[2],u=r[3],f=this.invSubMix,d=f[0],h=f[1],v=f[2],c=f[3],g=new Uint32Array(256),m=0,p=0,y=0;for(y=0;y<256;y++)y<128?g[y]=y<<1:g[y]=y<<1^283;for(y=0;y<256;y++){var S=p^p<<1^p<<2^p<<3^p<<4;S=S>>>8^S&255^99,t[m]=S,e[S]=m;var T=g[m],x=g[T],R=g[x],L=g[S]*257^S*16843008;a[m]=L<<24|L>>>8,o[m]=L<<16|L>>>16,l[m]=L<<8|L>>>24,u[m]=L,L=R*16843009^x*65537^T*257^m*16843008,d[S]=L<<24|L>>>8,h[S]=L<<16|L>>>16,v[S]=L<<8|L>>>24,c[S]=L,m?(m=T^g[g[g[R^T]]],p^=g[g[p]]):m=p=1}},s.expandKey=function(t){for(var e=this.uint8ArrayToUint32Array_(t),r=!0,a=0;a<e.length&&r;)r=e[a]===this.key[a],a++;if(!r){this.key=e;var o=this.keySize=e.length;if(o!==4&&o!==6&&o!==8)throw new Error("Invalid aes key size="+o);var l=this.ksRows=(o+6+1)*4,u,f,d=this.keySchedule=new Uint32Array(l),h=this.invKeySchedule=new Uint32Array(l),v=this.sBox,c=this.rcon,g=this.invSubMix,m=g[0],p=g[1],y=g[2],S=g[3],T,x;for(u=0;u<l;u++){if(u<o){T=d[u]=e[u];continue}x=T,u%o===0?(x=x<<8|x>>>24,x=v[x>>>24]<<24|v[x>>>16&255]<<16|v[x>>>8&255]<<8|v[x&255],x^=c[u/o|0]<<24):o>6&&u%o===4&&(x=v[x>>>24]<<24|v[x>>>16&255]<<16|v[x>>>8&255]<<8|v[x&255]),d[u]=T=(d[u-o]^x)>>>0}for(f=0;f<l;f++)u=l-f,f&3?x=d[u]:x=d[u-4],f<4||u<=4?h[f]=x:h[f]=m[v[x>>>24]]^p[v[x>>>16&255]]^y[v[x>>>8&255]]^S[v[x&255]],h[f]=h[f]>>>0}},s.networkToHostOrderSwap=function(t){return t<<24|(t&65280)<<8|(t&16711680)>>8|t>>>24},s.decrypt=function(t,e,r){for(var a=this.keySize+6,o=this.invKeySchedule,l=this.invSBox,u=this.invSubMix,f=u[0],d=u[1],h=u[2],v=u[3],c=this.uint8ArrayToUint32Array_(r),g=c[0],m=c[1],p=c[2],y=c[3],S=new Int32Array(t),T=new Int32Array(S.length),x,R,L,A,C,_,b,I,k,w,M,P,F,B,U=this.networkToHostOrderSwap;e<S.length;){for(k=U(S[e]),w=U(S[e+1]),M=U(S[e+2]),P=U(S[e+3]),C=k^o[0],_=P^o[1],b=M^o[2],I=w^o[3],F=4,B=1;B<a;B++)x=f[C>>>24]^d[_>>16&255]^h[b>>8&255]^v[I&255]^o[F],R=f[_>>>24]^d[b>>16&255]^h[I>>8&255]^v[C&255]^o[F+1],L=f[b>>>24]^d[I>>16&255]^h[C>>8&255]^v[_&255]^o[F+2],A=f[I>>>24]^d[C>>16&255]^h[_>>8&255]^v[b&255]^o[F+3],C=x,_=R,b=L,I=A,F=F+4;x=l[C>>>24]<<24^l[_>>16&255]<<16^l[b>>8&255]<<8^l[I&255]^o[F],R=l[_>>>24]<<24^l[b>>16&255]<<16^l[I>>8&255]<<8^l[C&255]^o[F+1],L=l[b>>>24]<<24^l[I>>16&255]<<16^l[C>>8&255]<<8^l[_&255]^o[F+2],A=l[I>>>24]<<24^l[C>>16&255]<<16^l[_>>8&255]<<8^l[b&255]^o[F+3],T[e]=U(x^g),T[e+1]=U(A^m),T[e+2]=U(L^p),T[e+3]=U(R^y),g=k,m=w,p=M,y=P,e=e+4}return T.buffer},n}(),Us=function(){function n(i,t,e){this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=i,this.key=t,this.aesMode=e}var s=n.prototype;return s.expandKey=function(){var t=Gs(this.aesMode);return this.subtle.importKey("raw",this.key,{name:t},!1,["encrypt","decrypt"])},n}();function Gs(n){switch(n){case Ye.cbc:return"AES-CBC";case Ye.ctr:return"AES-CTR";default:throw new Error("[FastAESKey] invalid aes mode "+n)}}var Hs=16,fr=function(){function n(i,t){var e=t===void 0?{}:t,r=e.removePKCS7Padding,a=r===void 0?!0:r;if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.enableSoftwareAES=void 0,this.enableSoftwareAES=i.enableSoftwareAES,this.removePKCS7Padding=a,a)try{var o=self.crypto;o&&(this.subtle=o.subtle||o.webkitSubtle)}catch{}this.useSoftware=!this.subtle}var s=n.prototype;return s.destroy=function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},s.isSync=function(){return this.useSoftware},s.flush=function(){var t=this.currentResult,e=this.remainderData;if(!t||e)return this.reset(),null;var r=new Uint8Array(t);return this.reset(),this.removePKCS7Padding?Ns(r):r},s.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},s.decrypt=function(t,e,r,a){var o=this;return this.useSoftware?new Promise(function(l,u){var f=ArrayBuffer.isView(t)?t:new Uint8Array(t);o.softwareDecrypt(f,e,r,a);var d=o.flush();d?l(d.buffer):u(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(t),e,r,a)},s.softwareDecrypt=function(t,e,r,a){var o=this.currentIV,l=this.currentResult,u=this.remainderData;if(a!==Ye.cbc||e.byteLength!==16)return X.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),u&&(t=ke(u,t),this.remainderData=null);var f=this.getValidChunk(t);if(!f.length)return null;o&&(r=o);var d=this.softwareDecrypter;d||(d=this.softwareDecrypter=new Bs),d.expandKey(e);var h=l;return this.currentResult=d.decrypt(f.buffer,0,r),this.currentIV=f.slice(-16).buffer,h||null},s.webCryptoDecrypt=function(t,e,r,a){var o=this;if(this.key!==e||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(t,e,r,a));this.key=e,this.fastAesKey=new Us(this.subtle,e,a)}return this.fastAesKey.expandKey().then(function(l){if(!o.subtle)return Promise.reject(new Error("web crypto not initialized"));o.logOnce("WebCrypto AES decrypt");var u=new Fs(o.subtle,new Uint8Array(r),a);return u.decrypt(t.buffer,l)}).catch(function(l){return X.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+l.name+": "+l.message),o.onWebCryptoError(t,e,r,a)})},s.onWebCryptoError=function(t,e,r,a){var o=this.enableSoftwareAES;if(o){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(t,e,r,a);var l=this.flush();if(l)return l.buffer}throw new Error("WebCrypto"+(o?" and softwareDecrypt":"")+": failed to decrypt data")},s.getValidChunk=function(t){var e=t,r=t.length-t.length%Hs;return r!==t.length&&(e=t.slice(0,r),this.remainderData=t.slice(r)),e},s.logOnce=function(t){this.logEnabled&&(X.log("[decrypter]: "+t),this.logEnabled=!1)},n}(),Vs=/\/emsg[-/]ID3/i,Ks=function(){function n(i,t){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=t}var s=n.prototype;return s.resetTimeStamp=function(){},s.resetInitSegment=function(t,e,r,a){var o=this.videoTrack=Be("video",1),l=this.audioTrack=Be("audio",1),u=this.txtTrack=Be("text",1);if(this.id3Track=Be("id3",1),this.timeOffset=0,!!(t!=null&&t.byteLength)){var f=Yr(t);if(f.video){var d=f.video,h=d.id,v=d.timescale,c=d.codec,g=d.supplemental;o.id=h,o.timescale=u.timescale=v,o.codec=c,o.supplemental=g}if(f.audio){var m=f.audio,p=m.id,y=m.timescale,S=m.codec;l.id=p,l.timescale=y,l.codec=S}u.id=Hr.text,o.sampleDuration=0,o.duration=l.duration=a}},s.resetContiguity=function(){this.remainderData=null},n.probe=function(t){return ra(t)},s.demux=function(t,e){this.timeOffset=e;var r=t,a=this.videoTrack,o=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=ke(this.remainderData,t));var l=da(r);this.remainderData=l.remainder,a.samples=l.valid||new Uint8Array}else a.samples=r;var u=this.extractID3Track(a,e);return o.samples=qr(e,a),{videoTrack:a,audioTrack:this.audioTrack,id3Track:u,textTrack:this.txtTrack}},s.flush=function(){var t=this.timeOffset,e=this.videoTrack,r=this.txtTrack;e.samples=this.remainderData||new Uint8Array,this.remainderData=null;var a=this.extractID3Track(e,this.timeOffset);return r.samples=qr(t,e),{videoTrack:e,audioTrack:Be(),id3Track:a,textTrack:Be()}},s.extractID3Track=function(t,e){var r=this,a=this.id3Track;if(t.samples.length){var o=V(t.samples,["emsg"]);o&&o.forEach(function(l){var u=ca(l);if(Vs.test(u.schemeIdUri)){var f=Qi(u,e),d=u.eventDuration===4294967295?Number.POSITIVE_INFINITY:u.eventDuration/u.timeScale;d<=.001&&(d=Number.POSITIVE_INFINITY);var h=u.payload;a.samples.push({data:h,len:h.byteLength,dts:f,pts:f,type:_e.emsg,duration:d})}else if(r.config.enableEmsgKLVMetadata&&u.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){var v=Qi(u,e);a.samples.push({data:u.payload,len:u.payload.byteLength,dts:v,pts:v,type:_e.misbklv,duration:Number.POSITIVE_INFINITY})}})}return a},s.demuxSampleAes=function(t,e,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},s.destroy=function(){this.config=null,this.remainderData=null,this.videoTrack=this.audioTrack=this.id3Track=this.txtTrack=void 0},n}();function Qi(n,s){return N(n.presentationTime)?n.presentationTime/n.timeScale:s+n.presentationTimeDelta/n.timeScale}var Ws=function(){function n(i,t,e){this.keyData=void 0,this.decrypter=void 0,this.keyData=e,this.decrypter=new fr(t,{removePKCS7Padding:!1})}var s=n.prototype;return s.decryptBuffer=function(t){return this.decrypter.decrypt(t,this.keyData.key.buffer,this.keyData.iv.buffer,Ye.cbc)},s.decryptAacSample=function(t,e,r){var a=this,o=t[e].unit;if(!(o.length<=16)){var l=o.subarray(16,o.length-o.length%16),u=l.buffer.slice(l.byteOffset,l.byteOffset+l.length);this.decryptBuffer(u).then(function(f){var d=new Uint8Array(f);o.set(d,16),a.decrypter.isSync()||a.decryptAacSamples(t,e+1,r)})}},s.decryptAacSamples=function(t,e,r){for(;;e++){if(e>=t.length){r();return}if(!(t[e].unit.length<32)&&(this.decryptAacSample(t,e,r),!this.decrypter.isSync()))return}},s.getAvcEncryptedData=function(t){for(var e=Math.floor((t.length-48)/160)*16+16,r=new Int8Array(e),a=0,o=32;o<t.length-16;o+=160,a+=16)r.set(t.subarray(o,o+16),a);return r},s.getAvcDecryptedUnit=function(t,e){for(var r=new Uint8Array(e),a=0,o=32;o<t.length-16;o+=160,a+=16)t.set(r.subarray(a,a+16),o);return t},s.decryptAvcSample=function(t,e,r,a,o){var l=this,u=Xr(o.data),f=this.getAvcEncryptedData(u);this.decryptBuffer(f.buffer).then(function(d){o.data=l.getAvcDecryptedUnit(u,d),l.decrypter.isSync()||l.decryptAvcSamples(t,e,r+1,a)})},s.decryptAvcSamples=function(t,e,r,a){if(t instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;e++,r=0){if(e>=t.length){a();return}for(var o=t[e].units;!(r>=o.length);r++){var l=o[r];if(!(l.data.length<=48||l.type!==1&&l.type!==5)&&(this.decryptAvcSample(t,e,r,a,l),!this.decrypter.isSync()))return}}},n}(),Ys=function(){function n(){this.VideoSample=null}var s=n.prototype;return s.createVideoSample=function(t,e,r){return{key:t,frame:!1,pts:e,dts:r,units:[],length:0}},s.getLastNalUnit=function(t){var e,r=this.VideoSample,a;if((!r||r.units.length===0)&&(r=t[t.length-1]),(e=r)!=null&&e.units){var o=r.units;a=o[o.length-1]}return a},s.pushAccessUnit=function(t,e){if(t.units.length&&t.frame){if(t.pts===void 0){var r=e.samples,a=r.length;if(a){var o=r[a-1];t.pts=o.pts,t.dts=o.dts}else{e.dropped++;return}}e.samples.push(t)}},s.parseNALu=function(t,e,r){var a=e.byteLength,o=t.naluState||0,l=o,u=[],f=0,d,h,v,c=-1,g=0;for(o===-1&&(c=0,g=this.getNALuType(e,0),o=0,f=1);f<a;){if(d=e[f++],!o){o=d?0:1;continue}if(o===1){o=d?0:2;continue}if(!d)o=3;else if(d===1){if(h=f-o-1,c>=0){var m={data:e.subarray(c,h),type:g};u.push(m)}else{var p=this.getLastNalUnit(t.samples);p&&(l&&f<=4-l&&p.state&&(p.data=p.data.subarray(0,p.data.byteLength-l)),h>0&&(p.data=ke(p.data,e.subarray(0,h)),p.state=0))}f<a?(v=this.getNALuType(e,f),c=f,g=v,o=0):o=-1}else o=0}if(c>=0&&o>=0){var y={data:e.subarray(c,a),type:g,state:o};u.push(y)}if(u.length===0){var S=this.getLastNalUnit(t.samples);S&&(S.data=ke(S.data,e))}return t.naluState=o,u},n}(),Zi=function(){function n(i){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=i,this.bytesAvailable=i.byteLength,this.word=0,this.bitsAvailable=0}var s=n.prototype;return s.loadWord=function(){var t=this.data,e=this.bytesAvailable,r=t.byteLength-e,a=new Uint8Array(4),o=Math.min(4,e);if(o===0)throw new Error("no bytes available");a.set(t.subarray(r,r+o)),this.word=new DataView(a.buffer).getUint32(0),this.bitsAvailable=o*8,this.bytesAvailable-=o},s.skipBits=function(t){var e;t=Math.min(t,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>t?(this.word<<=t,this.bitsAvailable-=t):(t-=this.bitsAvailable,e=t>>3,t-=e<<3,this.bytesAvailable-=e,this.loadWord(),this.word<<=t,this.bitsAvailable-=t)},s.readBits=function(t){var e=Math.min(this.bitsAvailable,t),r=this.word>>>32-e;if(t>32&&X.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=e,this.bitsAvailable>0)this.word<<=e;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return e=t-e,e>0&&this.bitsAvailable?r<<e|this.readBits(e):r},s.skipLZ=function(){var t;for(t=0;t<this.bitsAvailable;++t)if((this.word&2147483648>>>t)!==0)return this.word<<=t,this.bitsAvailable-=t,t;return this.loadWord(),t+this.skipLZ()},s.skipUEG=function(){this.skipBits(1+this.skipLZ())},s.skipEG=function(){this.skipBits(1+this.skipLZ())},s.readUEG=function(){var t=this.skipLZ();return this.readBits(t+1)-1},s.readEG=function(){var t=this.readUEG();return 1&t?1+t>>>1:-1*(t>>>1)},s.readBoolean=function(){return this.readBits(1)===1},s.readUByte=function(){return this.readBits(8)},s.readUShort=function(){return this.readBits(16)},s.readUInt=function(){return this.readBits(32)},n}(),Ji=function(n){function s(){return n.apply(this,arguments)||this}he(s,n);var i=s.prototype;return i.parsePES=function(e,r,a,o){var l=this,u=this.parseNALu(e,a.data,o),f=this.VideoSample,d,h=!1;a.data=null,f&&u.length&&!e.audFound&&(this.pushAccessUnit(f,e),f=this.VideoSample=this.createVideoSample(!1,a.pts,a.dts)),u.forEach(function(v){var c,g;switch(v.type){case 1:{var m=!1;d=!0;var p=v.data;if(h&&p.length>4){var y=l.readSliceType(p);(y===2||y===4||y===7||y===9)&&(m=!0)}if(m){var S;(S=f)!=null&&S.frame&&!f.key&&(l.pushAccessUnit(f,e),f=l.VideoSample=null)}f||(f=l.VideoSample=l.createVideoSample(!0,a.pts,a.dts)),f.frame=!0,f.key=m;break}case 5:d=!0,(c=f)!=null&&c.frame&&!f.key&&(l.pushAccessUnit(f,e),f=l.VideoSample=null),f||(f=l.VideoSample=l.createVideoSample(!0,a.pts,a.dts)),f.key=!0,f.frame=!0;break;case 6:{d=!0,jr(v.data,1,a.pts,r.samples);break}case 7:{var T,x;d=!0,h=!0;var R=v.data,L=l.readSPS(R);if(!e.sps||e.width!==L.width||e.height!==L.height||((T=e.pixelRatio)==null?void 0:T[0])!==L.pixelRatio[0]||((x=e.pixelRatio)==null?void 0:x[1])!==L.pixelRatio[1]){e.width=L.width,e.height=L.height,e.pixelRatio=L.pixelRatio,e.sps=[R];for(var A=R.subarray(1,4),C="avc1.",_=0;_<3;_++){var b=A[_].toString(16);b.length<2&&(b="0"+b),C+=b}e.codec=C}break}case 8:d=!0,e.pps=[v.data];break;case 9:d=!0,e.audFound=!0,(g=f)!=null&&g.frame&&(l.pushAccessUnit(f,e),f=null),f||(f=l.VideoSample=l.createVideoSample(!1,a.pts,a.dts));break;case 12:d=!0;break;default:d=!1;break}if(f&&d){var I=f.units;I.push(v)}}),o&&f&&(this.pushAccessUnit(f,e),this.VideoSample=null)},i.getNALuType=function(e,r){return e[r]&31},i.readSliceType=function(e){var r=new Zi(e);return r.readUByte(),r.readUEG(),r.readUEG()},i.skipScalingList=function(e,r){for(var a=8,o=8,l,u=0;u<e;u++)o!==0&&(l=r.readEG(),o=(a+l+256)%256),a=o===0?a:o},i.readSPS=function(e){var r=new Zi(e),a=0,o=0,l=0,u=0,f,d,h,v=r.readUByte.bind(r),c=r.readBits.bind(r),g=r.readUEG.bind(r),m=r.readBoolean.bind(r),p=r.skipBits.bind(r),y=r.skipEG.bind(r),S=r.skipUEG.bind(r),T=this.skipScalingList.bind(this);v();var x=v();if(c(5),p(3),v(),S(),x===100||x===110||x===122||x===244||x===44||x===83||x===86||x===118||x===128){var R=g();if(R===3&&p(1),S(),S(),p(1),m())for(d=R!==3?8:12,h=0;h<d;h++)m()&&(h<6?T(16,r):T(64,r))}S();var L=g();if(L===0)g();else if(L===1)for(p(1),y(),y(),f=g(),h=0;h<f;h++)y();S(),p(1);var A=g(),C=g(),_=c(1);_===0&&p(1),p(1),m()&&(a=g(),o=g(),l=g(),u=g());var b=[1,1];if(m()&&m()){var I=v();switch(I){case 1:b=[1,1];break;case 2:b=[12,11];break;case 3:b=[10,11];break;case 4:b=[16,11];break;case 5:b=[40,33];break;case 6:b=[24,11];break;case 7:b=[20,11];break;case 8:b=[32,11];break;case 9:b=[80,33];break;case 10:b=[18,11];break;case 11:b=[15,11];break;case 12:b=[64,33];break;case 13:b=[160,99];break;case 14:b=[4,3];break;case 15:b=[3,2];break;case 16:b=[2,1];break;case 255:{b=[v()<<8|v(),v()<<8|v()];break}}}return{width:Math.ceil((A+1)*16-a*2-o*2),height:(2-_)*(C+1)*16-(_?2:4)*(l+u),pixelRatio:b}},s}(Ys),ve=188,qs=function(){function n(i,t,e,r){this.logger=void 0,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._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=i,this.config=t,this.typeSupported=e,this.logger=r,this.videoParser=null}n.probe=function(t,e){var r=n.syncOffset(t);return r>0&&e.warn("MPEG2-TS detected but first sync word found @ offset "+r),r!==-1},n.syncOffset=function(t){for(var e=t.length,r=Math.min(ve*5,e-ve)+1,a=0;a<r;){for(var o=!1,l=-1,u=0,f=a;f<e;f+=ve)if(t[f]===71&&(e-f===ve||t[f+ve]===71)){if(u++,l===-1&&(l=f,l!==0&&(r=Math.min(l+ve*99,t.length-ve)+1)),o||(o=dr(t,f)===0),o&&u>1&&(l===0&&u>2||f+ve>r))return l}else{if(u)return-1;break}a++}return-1},n.createTrack=function(t,e){return{container:t==="video"||t==="audio"?"video/mp2t":void 0,type:t,id:Hr[t],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:t==="audio"?e:void 0}};var s=n.prototype;return s.resetInitSegment=function(t,e,r,a){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=n.createTrack("video"),this._videoTrack.duration=a,this._audioTrack=n.createTrack("audio",a),this._id3Track=n.createTrack("id3"),this._txtTrack=n.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=e,this.videoCodec=r},s.resetTimeStamp=function(){},s.resetContiguity=function(){var t=this._audioTrack,e=this._videoTrack,r=this._id3Track;t&&(t.pesData=null),e&&(e.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.remainderData=null},s.demux=function(t,e,r,a){r===void 0&&(r=!1),a===void 0&&(a=!1),r||(this.sampleAes=null);var o,l=this._videoTrack,u=this._audioTrack,f=this._id3Track,d=this._txtTrack,h=l.pid,v=l.pesData,c=u.pid,g=f.pid,m=u.pesData,p=f.pesData,y=null,S=this.pmtParsed,T=this._pmtId,x=t.length;if(this.remainderData&&(t=ke(this.remainderData,t),x=t.length,this.remainderData=null),x<ve&&!a)return this.remainderData=t,{audioTrack:u,videoTrack:l,id3Track:f,textTrack:d};var R=Math.max(0,n.syncOffset(t));x-=(x-R)%ve,x<t.byteLength&&!a&&(this.remainderData=new Uint8Array(t.buffer,x,t.buffer.byteLength-x));for(var L=0,A=R;A<x;A+=ve)if(t[A]===71){var C=!!(t[A+1]&64),_=dr(t,A),b=(t[A+3]&48)>>4,I=void 0;if(b>1){if(I=A+5+t[A+4],I===A+ve)continue}else I=A+4;switch(_){case h:if(C){if(v&&(o=Qe(v,this.logger))){if(this.videoParser===null)switch(l.segmentCodec){case"avc":this.videoParser=new Ji;break}this.videoParser!==null&&this.videoParser.parsePES(l,d,o,!1)}v={data:[],size:0}}v&&(v.data.push(t.subarray(I,A+ve)),v.size+=A+ve-I);break;case c:if(C){if(m&&(o=Qe(m,this.logger)))switch(u.segmentCodec){case"aac":this.parseAACPES(u,o);break;case"mp3":this.parseMPEGPES(u,o);break}m={data:[],size:0}}m&&(m.data.push(t.subarray(I,A+ve)),m.size+=A+ve-I);break;case g:C&&(p&&(o=Qe(p,this.logger))&&this.parseID3PES(f,o),p={data:[],size:0}),p&&(p.data.push(t.subarray(I,A+ve)),p.size+=A+ve-I);break;case 0:C&&(I+=t[I]+1),T=this._pmtId=js(t,I);break;case T:{C&&(I+=t[I]+1);var k=Xs(t,I,this.typeSupported,r,this.observer,this.logger);h=k.videoPid,h>0&&(l.pid=h,l.segmentCodec=k.segmentVideoCodec),c=k.audioPid,c>0&&(u.pid=c,u.segmentCodec=k.segmentAudioCodec),g=k.id3Pid,g>0&&(f.pid=g),y!==null&&!S&&(this.logger.warn("MPEG-TS PMT found at "+A+" after unknown PID '"+y+"'. Backtracking to sync byte @"+R+" to parse all TS packets."),y=null,A=R-188),S=this.pmtParsed=!0;break}case 17:case 8191:break;default:y=_;break}}else L++;L>0&&Dt(this.observer,new Error("Found "+L+" TS packet/s that do not start with 0x47"),void 0,this.logger),l.pesData=v,u.pesData=m,f.pesData=p;var w={audioTrack:u,videoTrack:l,id3Track:f,textTrack:d};return a&&this.extractRemainingSamples(w),w},s.flush=function(){var t=this.remainderData;this.remainderData=null;var e;return t?e=this.demux(t,-1,!1,!0):e={videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e},s.extractRemainingSamples=function(t){var e=t.audioTrack,r=t.videoTrack,a=t.id3Track,o=t.textTrack,l=r.pesData,u=e.pesData,f=a.pesData,d;if(l&&(d=Qe(l,this.logger))){if(this.videoParser===null)switch(r.segmentCodec){case"avc":this.videoParser=new Ji;break}this.videoParser!==null&&(this.videoParser.parsePES(r,o,d,!0),r.pesData=null)}else r.pesData=l;if(u&&(d=Qe(u,this.logger))){switch(e.segmentCodec){case"aac":this.parseAACPES(e,d);break;case"mp3":this.parseMPEGPES(e,d);break}e.pesData=null}else u!=null&&u.size&&this.logger.log("last AAC PES packet truncated,might overlap between fragments"),e.pesData=u;f&&(d=Qe(f,this.logger))?(this.parseID3PES(a,d),a.pesData=null):a.pesData=f},s.demuxSampleAes=function(t,e,r){var a=this.demux(t,r,!0,!this.config.progressive),o=this.sampleAes=new Ws(this.observer,this.config,e);return this.decrypt(a,o)},s.decrypt=function(t,e){return new Promise(function(r){var a=t.audioTrack,o=t.videoTrack;a.samples&&a.segmentCodec==="aac"?e.decryptAacSamples(a.samples,0,function(){o.samples?e.decryptAvcSamples(o.samples,0,0,function(){r(t)}):r(t)}):o.samples&&e.decryptAvcSamples(o.samples,0,0,function(){r(t)})})},s.destroy=function(){this.observer&&this.observer.removeAllListeners(),this.config=this.logger=this.observer=null,this.aacOverFlow=this.videoParser=this.remainderData=this.sampleAes=null,this._videoTrack=this._audioTrack=this._id3Track=this._txtTrack=void 0},s.parseAACPES=function(t,e){var r=0,a=this.aacOverFlow,o=e.data;if(a){this.aacOverFlow=null;var l=a.missing,u=a.sample.unit.byteLength;if(l===-1)o=ke(a.sample.unit,o);else{var f=u-l;a.sample.unit.set(o.subarray(0,l),f),t.samples.push(a.sample),r=a.missing}}var d,h;for(d=r,h=o.length;d<h-1&&!bt(o,d);d++);if(d!==r){var v,c=d<h-1;if(c?v="AAC PES did not start with ADTS header,offset:"+d:v="No ADTS header found in AAC PES",Dt(this.observer,new Error(v),c,this.logger),!c)return}Gi(t,this.observer,o,d,this.audioCodec);var g;if(e.pts!==void 0)g=e.pts;else if(a){var m=Hi(t.samplerate);g=a.sample.pts+m}else{this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var p=0,y;d<h;)if(y=Vi(t,o,d,g,p),d+=y.length,y.missing){this.aacOverFlow=y;break}else for(p++;d<h-1&&!bt(o,d);d++);},s.parseMPEGPES=function(t,e){var r=e.data,a=r.length,o=0,l=0,u=e.pts;if(u===void 0){this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;l<a;)if($i(r,l)){var f=ji(t,r,l,u,o);if(f)l+=f.length,o++;else break}else l++},s.parseAC3PES=function(t,e){},s.parseID3PES=function(t,e){if(e.pts===void 0){this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}var r=de({},e,{type:this._videoTrack?_e.emsg:_e.audioId3,duration:Number.POSITIVE_INFINITY});t.samples.push(r)},n}();function dr(n,s){return((n[s+1]&31)<<8)+n[s+2]}function js(n,s){return(n[s+10]&31)<<8|n[s+11]}function Xs(n,s,i,t,e,r){var a={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},o=(n[s+1]&15)<<8|n[s+2],l=s+3+o-4,u=(n[s+10]&15)<<8|n[s+11];for(s+=12+u;s<l;){var f=dr(n,s),d=(n[s+3]&15)<<8|n[s+4];switch(n[s]){case 207:if(!t){hr("ADTS AAC",r);break}case 15:a.audioPid===-1&&(a.audioPid=f);break;case 21:a.id3Pid===-1&&(a.id3Pid=f);break;case 219:if(!t){hr("H.264",r);break}case 27:a.videoPid===-1&&(a.videoPid=f);break;case 3:case 4:!i.mpeg&&!i.mp3?r.log("MPEG audio found, not supported in this browser"):a.audioPid===-1&&(a.audioPid=f,a.segmentAudioCodec="mp3");break;case 193:if(!t){hr("AC-3",r);break}case 129:r.warn("AC-3 in M2TS support not included in build");break;case 6:if(a.audioPid===-1&&d>0)for(var h=s+5,v=d;v>2;){var c=n[h];switch(c){case 106:r.warn("AC-3 in M2TS support not included in build");break}var g=n[h+1]+2;h+=g,v-=g}break;case 194:case 135:return Dt(e,new Error("Unsupported EC-3 in M2TS found"),void 0,r),a;case 36:return Dt(e,new Error("Unsupported HEVC in M2TS found"),void 0,r),a}s+=d+5}return a}function Dt(n,s,i,t){t.warn("parsing error: "+s.message),n.emit(E.ERROR,E.ERROR,{type:K.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,levelRetry:i,error:s,reason:s.message})}function hr(n,s){s.log(n+" with AES-128-CBC encryption found in unencrypted stream")}function Qe(n,s){var i=0,t,e,r,a,o,l=n.data;if(!n||n.size===0)return null;for(;l[0].length<19&&l.length>1;)l[0]=ke(l[0],l[1]),l.splice(1,1);t=l[0];var u=(t[0]<<16)+(t[1]<<8)+t[2];if(u===1){if(e=(t[4]<<8)+t[5],e&&e>n.size-6)return null;var f=t[7];f&192&&(a=(t[9]&14)*536870912+(t[10]&255)*4194304+(t[11]&254)*16384+(t[12]&255)*128+(t[13]&254)/2,f&64?(o=(t[14]&14)*536870912+(t[15]&255)*4194304+(t[16]&254)*16384+(t[17]&255)*128+(t[18]&254)/2,a-o>60*9e4&&(s.warn(Math.round((a-o)/9e4)+"s delta between PTS and DTS, align them"),a=o)):o=a),r=t[8];var d=r+9;if(n.size<=d)return null;n.size-=d;for(var h=new Uint8Array(n.size),v=0,c=l.length;v<c;v++){t=l[v];var g=t.byteLength;if(d)if(d>g){d-=g;continue}else t=t.subarray(d),g-=d,d=0;h.set(t,i),i+=g}return e&&(e-=r+3),{data:h,pts:a,dts:o,len:e}}return null}var $s=function(){function n(){}return n.getSilentFrame=function(i,t){switch(i){case"mp4a.40.2":if(t===1)return new Uint8Array([0,200,0,128,35,128]);if(t===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(t===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(t===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(t===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(t===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(t===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}},n}(),qe=Math.pow(2,32)-1,me=function(){function n(){}return n.init=function(){n.types={avc1:[],avcC:[],hvc1:[],hvcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var i;for(i in n.types)n.types.hasOwnProperty(i)&&(n.types[i]=[i.charCodeAt(0),i.charCodeAt(1),i.charCodeAt(2),i.charCodeAt(3)]);var t=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),e=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]);n.HDLR_TYPES={video:t,audio:e};var r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),a=new Uint8Array([0,0,0,0,0,0,0,0]);n.STTS=n.STSC=n.STCO=a,n.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),n.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),n.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),n.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var o=new Uint8Array([105,115,111,109]),l=new Uint8Array([97,118,99,49]),u=new Uint8Array([0,0,0,1]);n.FTYP=n.box(n.types.ftyp,o,u,o,l),n.DINF=n.box(n.types.dinf,n.box(n.types.dref,r))},n.box=function(i){for(var t=8,e=arguments.length,r=new Array(e>1?e-1:0),a=1;a<e;a++)r[a-1]=arguments[a];for(var o=r.length,l=o;o--;)t+=r[o].byteLength;var u=new Uint8Array(t);for(u[0]=t>>24&255,u[1]=t>>16&255,u[2]=t>>8&255,u[3]=t&255,u.set(i,4),o=0,t=8;o<l;o++)u.set(r[o],t),t+=r[o].byteLength;return u},n.hdlr=function(i){return n.box(n.types.hdlr,n.HDLR_TYPES[i])},n.mdat=function(i){return n.box(n.types.mdat,i)},n.mdhd=function(i,t){t*=i;var e=Math.floor(t/(qe+1)),r=Math.floor(t%(qe+1));return n.box(n.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,i>>24&255,i>>16&255,i>>8&255,i&255,e>>24,e>>16&255,e>>8&255,e&255,r>>24,r>>16&255,r>>8&255,r&255,85,196,0,0]))},n.mdia=function(i){return n.box(n.types.mdia,n.mdhd(i.timescale||0,i.duration||0),n.hdlr(i.type),n.minf(i))},n.mfhd=function(i){return n.box(n.types.mfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,i&255]))},n.minf=function(i){return i.type==="audio"?n.box(n.types.minf,n.box(n.types.smhd,n.SMHD),n.DINF,n.stbl(i)):n.box(n.types.minf,n.box(n.types.vmhd,n.VMHD),n.DINF,n.stbl(i))},n.moof=function(i,t,e){return n.box(n.types.moof,n.mfhd(i),n.traf(e,t))},n.moov=function(i){for(var t=i.length,e=[];t--;)e[t]=n.trak(i[t]);return n.box.apply(null,[n.types.moov,n.mvhd(i[0].timescale||0,i[0].duration||0)].concat(e).concat(n.mvex(i)))},n.mvex=function(i){for(var t=i.length,e=[];t--;)e[t]=n.trex(i[t]);return n.box.apply(null,[n.types.mvex].concat(e))},n.mvhd=function(i,t){t*=i;var e=Math.floor(t/(qe+1)),r=Math.floor(t%(qe+1)),a=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,i>>24&255,i>>16&255,i>>8&255,i&255,e>>24,e>>16&255,e>>8&255,e&255,r>>24,r>>16&255,r>>8&255,r&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 n.box(n.types.mvhd,a)},n.sdtp=function(i){var t=i.samples||[],e=new Uint8Array(4+t.length),r,a;for(r=0;r<t.length;r++)a=t[r].flags,e[r+4]=a.dependsOn<<4|a.isDependedOn<<2|a.hasRedundancy;return n.box(n.types.sdtp,e)},n.stbl=function(i){return n.box(n.types.stbl,n.stsd(i),n.box(n.types.stts,n.STTS),n.box(n.types.stsc,n.STSC),n.box(n.types.stsz,n.STSZ),n.box(n.types.stco,n.STCO))},n.avc1=function(i){var t=[],e=[],r,a,o;for(r=0;r<i.sps.length;r++)a=i.sps[r],o=a.byteLength,t.push(o>>>8&255),t.push(o&255),t=t.concat(Array.prototype.slice.call(a));for(r=0;r<i.pps.length;r++)a=i.pps[r],o=a.byteLength,e.push(o>>>8&255),e.push(o&255),e=e.concat(Array.prototype.slice.call(a));var l=n.box(n.types.avcC,new Uint8Array([1,t[3],t[4],t[5],255,224|i.sps.length].concat(t).concat([i.pps.length]).concat(e))),u=i.width,f=i.height,d=i.pixelRatio[0],h=i.pixelRatio[1];return n.box(n.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,u>>8&255,u&255,f>>8&255,f&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]),l,n.box(n.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),n.box(n.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,d&255,h>>24,h>>16&255,h>>8&255,h&255])))},n.esds=function(i){var t=i.config;return new Uint8Array([0,0,0,0,3,25,0,1,0,4,17,64,21,0,0,0,0,0,0,0,0,0,0,0,5,2].concat(t,[6,1,2]))},n.audioStsd=function(i){var t=i.samplerate||0;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,i.channelCount||0,0,16,0,0,0,0,t>>8&255,t&255,0,0])},n.mp4a=function(i){return n.box(n.types.mp4a,n.audioStsd(i),n.box(n.types.esds,n.esds(i)))},n.mp3=function(i){return n.box(n.types[".mp3"],n.audioStsd(i))},n.ac3=function(i){return n.box(n.types["ac-3"],n.audioStsd(i),n.box(n.types.dac3,i.config))},n.stsd=function(i){var t=i.segmentCodec;if(i.type==="audio"){if(t==="aac")return n.box(n.types.stsd,n.STSD,n.mp4a(i));if(t==="mp3"&&i.codec==="mp3")return n.box(n.types.stsd,n.STSD,n.mp3(i))}else if(i.pps&&i.sps){if(t==="avc")return n.box(n.types.stsd,n.STSD,n.avc1(i))}else throw new Error("video track missing pps or sps");throw new Error("unsupported "+i.type+" segment codec ("+t+"/"+i.codec+")")},n.tkhd=function(i){var t=i.id,e=(i.duration||0)*(i.timescale||0),r=i.width||0,a=i.height||0,o=Math.floor(e/(qe+1)),l=Math.floor(e%(qe+1));return n.box(n.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,t&255,0,0,0,0,o>>24,o>>16&255,o>>8&255,o&255,l>>24,l>>16&255,l>>8&255,l&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,r>>8&255,r&255,0,0,a>>8&255,a&255,0,0]))},n.traf=function(i,t){var e=n.sdtp(i),r=i.id,a=Math.floor(t/(qe+1)),o=Math.floor(t%(qe+1));return n.box(n.types.traf,n.box(n.types.tfhd,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,r&255])),n.box(n.types.tfdt,new Uint8Array([1,0,0,0,a>>24,a>>16&255,a>>8&255,a&255,o>>24,o>>16&255,o>>8&255,o&255])),n.trun(i,e.length+16+20+8+16+8+8),e)},n.trak=function(i){return i.duration=i.duration||4294967295,n.box(n.types.trak,n.tkhd(i),n.mdia(i))},n.trex=function(i){var t=i.id;return n.box(n.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},n.trun=function(i,t){var e=i.samples||[],r=e.length,a=12+16*r,o=new Uint8Array(a),l,u,f,d,h,v;for(t+=8+a,o.set([i.type==="video"?1:0,0,15,1,r>>>24&255,r>>>16&255,r>>>8&255,r&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255],0),l=0;l<r;l++)u=e[l],f=u.duration,d=u.size,h=u.flags,v=u.cts,o.set([f>>>24&255,f>>>16&255,f>>>8&255,f&255,d>>>24&255,d>>>16&255,d>>>8&255,d&255,h.isLeading<<2|h.dependsOn,h.isDependedOn<<6|h.hasRedundancy<<4|h.paddingValue<<1|h.isNonSync,h.degradPrio&61440,h.degradPrio&15,v>>>24&255,v>>>16&255,v>>>8&255,v&255],12+16*l);return n.box(n.types.trun,o)},n.initSegment=function(i){n.types||n.init();var t=n.moov(i),e=ke(n.FTYP,t);return e},n.hvc1=function(i){return new Uint8Array},n}();me.types=void 0,me.HDLR_TYPES=void 0,me.STTS=void 0,me.STSC=void 0,me.STCO=void 0,me.STSZ=void 0,me.VMHD=void 0,me.SMHD=void 0,me.STSD=void 0,me.FTYP=void 0,me.DINF=void 0;var zs=9e4;function Qs(n,s,i,t){var e=n*s*i;return Math.round(e)}function lt(n,s){return Qs(n,1e3,1/zs)}var Zs=10*1e3,Js=1024,eo=1152,to=1536,Ze=null,cr=null;function en(n,s,i,t){return{duration:s,size:i,cts:t,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:n?2:1,isNonSync:n?0:1}}}var vr=function(){function n(i,t,e,r){if(this.logger=void 0,this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=i,this.config=t,this.typeSupported=e,this.logger=r,this.ISGenerated=!1,Ze===null){var a=navigator.userAgent||"",o=a.match(/Chrome\/(\d+)/i);Ze=o?parseInt(o[1]):0}if(cr===null){var l=navigator.userAgent.match(/Safari\/(\d+)/i);cr=l?parseInt(l[1]):0}}var s=n.prototype;return s.destroy=function(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null},s.resetTimeStamp=function(t){this.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=t},s.resetNextTimestamp=function(){this.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},s.resetInitSegment=function(){this.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0},s.getVideoStartPts=function(t){var e=!1,r=t[0].pts,a=t.reduce(function(o,l){var u=l.pts,f=u-o;return f<-4294967296&&(e=!0,u=Me(u,r),f=u-o),f>0?o:u},r);return e&&this.logger.debug("PTS rollover detected"),a},s.remux=function(t,e,r,a,o,l,u,f){var d,h,v,c,g,m,p=o,y=o,S=t.pid>-1,T=e.pid>-1,x=e.samples.length,R=t.samples.length>0,L=u&&x>0||x>1,A=(!S||R)&&(!T||L)||this.ISGenerated||u;if(A){if(this.ISGenerated){var C,_,b,I,k=this.videoTrackConfig;(k&&(e.width!==k.width||e.height!==k.height||((C=e.pixelRatio)==null?void 0:C[0])!==((_=k.pixelRatio)==null?void 0:_[0])||((b=e.pixelRatio)==null?void 0:b[1])!==((I=k.pixelRatio)==null?void 0:I[1]))||!k&&L||this.nextAudioPts===null&&R)&&this.resetInitSegment()}this.ISGenerated||(v=this.generateIS(t,e,o,l));var w=this.isVideoContiguous,M=-1,P;if(L&&(M=ro(e.samples),!w&&this.config.forceKeyFrameOnDiscontinuity))if(m=!0,M>0){this.logger.warn("[mp4-remuxer]: Dropped "+M+" out of "+x+" video samples due to a missing keyframe");var F=this.getVideoStartPts(e.samples);e.samples=e.samples.slice(M),e.dropped+=M,y+=(e.samples[0].pts-F)/e.inputTimeScale,P=y}else M===-1&&(this.logger.warn("[mp4-remuxer]: No keyframe found out of "+x+" video samples"),m=!1);if(this.ISGenerated){if(R&&L){var B=this.getVideoStartPts(e.samples),U=Me(t.samples[0].pts,B)-B,G=U/e.inputTimeScale;p+=Math.max(0,G),y+=Math.max(0,-G)}if(R){if(t.samplerate||(this.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),v=this.generateIS(t,e,o,l)),h=this.remuxAudio(t,p,this.isAudioContiguous,l,T||L||f===W.AUDIO?y:void 0),L){var z=h?h.endPTS-h.startPTS:0;e.inputTimeScale||(this.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),v=this.generateIS(t,e,o,l)),d=this.remuxVideo(e,y,w,z)}}else L&&(d=this.remuxVideo(e,y,w,0));d&&(d.firstKeyFrame=M,d.independent=M!==-1,d.firstKeyFramePTS=P)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(g=tn(r,o,this._initPTS,this._initDTS)),a.samples.length&&(c=rn(a,o,this._initPTS))),{audio:h,video:d,initSegment:v,independent:m,text:c,id3:g}},s.generateIS=function(t,e,r,a){var o=t.samples,l=e.samples,u=this.typeSupported,f={},d=this._initPTS,h=!d||a,v="audio/mp4",c,g,m;if(h&&(c=g=1/0),t.config&&o.length){switch(t.timescale=t.samplerate,t.segmentCodec){case"mp3":u.mpeg?(v="audio/mpeg",t.codec=""):u.mp3&&(t.codec="mp3");break;case"ac3":t.codec="ac-3";break}f.audio={id:"audio",container:v,codec:t.codec,initSegment:t.segmentCodec==="mp3"&&u.mpeg?new Uint8Array(0):me.initSegment([t]),metadata:{channelCount:t.channelCount}},h&&(m=t.inputTimeScale,!d||m!==d.timescale?c=g=o[0].pts-Math.round(m*r):h=!1)}if(e.sps&&e.pps&&l.length){if(e.timescale=e.inputTimeScale,f.video={id:"main",container:"video/mp4",codec:e.codec,initSegment:me.initSegment([e]),metadata:{width:e.width,height:e.height}},h)if(m=e.inputTimeScale,!d||m!==d.timescale){var p=this.getVideoStartPts(l),y=Math.round(m*r);g=Math.min(g,Me(l[0].dts,p)-y),c=Math.min(c,p-y)}else h=!1;this.videoTrackConfig={width:e.width,height:e.height,pixelRatio:e.pixelRatio}}if(Object.keys(f).length)return this.ISGenerated=!0,h?(this._initPTS={baseTime:c,timescale:m},this._initDTS={baseTime:g,timescale:m}):c=m=void 0,{tracks:f,initPTS:c,timescale:m}},s.remuxVideo=function(t,e,r,a){var o=t.inputTimeScale,l=t.samples,u=[],f=l.length,d=this._initPTS,h=this.nextAvcDts,v=8,c=this.videoSampleDuration,g,m,p=Number.POSITIVE_INFINITY,y=Number.NEGATIVE_INFINITY,S=!1;if(!r||h===null){var T=e*o,x=l[0].pts-Me(l[0].dts,l[0].pts);Ze&&h!==null&&Math.abs(T-x-h)<15e3?r=!0:h=T-x}for(var R=d.baseTime*o/d.timescale,L=0;L<f;L++){var A=l[L];A.pts=Me(A.pts-R,h),A.dts=Me(A.dts-R,h),A.dts<l[L>0?L-1:L].dts&&(S=!0)}S&&l.sort(function(Ft,On){var El=Ft.dts-On.dts,yl=Ft.pts-On.pts;return El||yl}),g=l[0].dts,m=l[l.length-1].dts;var C=m-g,_=C?Math.round(C/(f-1)):c||t.inputTimeScale/30;if(r){var b=g-h,I=b>_,k=b<-1;if((I||k)&&(I?this.logger.warn((t.segmentCodec||"").toUpperCase()+": "+lt(b)+" ms ("+b+"dts) hole between fragments detected at "+e.toFixed(3)):this.logger.warn((t.segmentCodec||"").toUpperCase()+": "+lt(-b)+" ms ("+b+"dts) overlapping between fragments detected at "+e.toFixed(3)),!k||h>=l[0].pts||Ze)){g=h;var w=l[0].pts-b;if(I)l[0].dts=g,l[0].pts=w;else for(var M=!0,P=0;P<l.length&&!(l[P].dts>w&&M);P++){var F=l[P].pts;if(l[P].dts-=b,l[P].pts-=b,P<l.length-1){var B=l[P+1].pts,U=l[P].pts,G=B<=U,z=B<=F;M=G==z}}this.logger.log("Video: Initial PTS/DTS adjusted: "+lt(w)+"/"+lt(g)+", delta: "+lt(b)+" ms")}}g=Math.max(0,g);for(var q=0,Q=0,Y=g,ae=0;ae<f;ae++){for(var Z=l[ae],ne=Z.units,Ae=ne.length,ge=0,J=0;J<Ae;J++)ge+=ne[J].data.length;Q+=ge,q+=Ae,Z.length=ge,Z.dts<Y?(Z.dts=Y,Y+=_/4|0||1):Y=Z.dts,p=Math.min(Z.pts,p),y=Math.max(Z.pts,y)}m=l[f-1].dts;var Re=Q+4*q+8,ue;try{ue=new Uint8Array(Re)}catch(Ft){this.observer.emit(E.ERROR,E.ERROR,{type:K.MUX_ERROR,details:D.REMUX_ALLOC_ERROR,fatal:!1,error:Ft,bytes:Re,reason:"fail allocating video mdat "+Re});return}var ie=new DataView(ue.buffer);ie.setUint32(0,Re),ue.set(me.types.mdat,4);for(var be=!1,Ee=Number.POSITIVE_INFINITY,De=Number.POSITIVE_INFINITY,ee=Number.NEGATIVE_INFINITY,ye=Number.NEGATIVE_INFINITY,fe=0;fe<f;fe++){for(var Ie=l[fe],ht=Ie.units,_n=0,Lr=0,ul=ht.length;Lr<ul;Lr++){var Dn=ht[Lr],fl=Dn.data,Ar=Dn.data.byteLength;ie.setUint32(v,Ar),v+=4,ue.set(fl,v),v+=Ar,_n+=4+Ar}var Ot=void 0;if(fe<f-1)c=l[fe+1].dts-Ie.dts,Ot=l[fe+1].pts-Ie.pts;else{var Cn=this.config,wt=fe>0?Ie.dts-l[fe-1].dts:_;if(Ot=fe>0?Ie.pts-l[fe-1].pts:_,Cn.stretchShortVideoTrack&&this.nextAudioPts!==null){var dl=Math.floor(Cn.maxBufferHole*o),Rr=(a?p+a*o:this.nextAudioPts)-Ie.pts;Rr>dl?(c=Rr-wt,c<0?c=wt:be=!0,this.logger.log("[mp4-remuxer]: It is approximately "+Rr/90+" ms to the next segment; using duration "+c/90+" ms for the last video frame.")):c=wt}else c=wt}var hl=Math.round(Ie.pts-Ie.dts);Ee=Math.min(Ee,c),ee=Math.max(ee,c),De=Math.min(De,Ot),ye=Math.max(ye,Ot),u.push(en(Ie.key,c,_n,hl))}if(u.length){if(Ze){if(Ze<70){var kn=u[0].flags;kn.dependsOn=2,kn.isNonSync=0}}else if(cr&&ye-De<ee-Ee&&_/ee<.025&&u[0].cts===0){this.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var br=g,Oe=0,Pn=u.length;Oe<Pn;Oe++){var Mn=br+u[Oe].duration,cl=br+u[Oe].cts;if(Oe<Pn-1){var vl=Mn+u[Oe+1].cts;u[Oe].duration=vl-cl}else u[Oe].duration=Oe?u[Oe-1].duration:_;u[Oe].cts=0,br=Mn}}}c=be||!c?_:c,this.nextAvcDts=h=m+c,this.videoSampleDuration=c,this.isVideoContiguous=!0;var gl=me.moof(t.sequenceNumber++,g,de(t,{samples:u})),ml="video",pl={data1:gl,data2:ue,startPTS:p/o,endPTS:(y+c)/o,startDTS:g/o,endDTS:h/o,type:ml,hasAudio:!1,hasVideo:!0,nb:u.length,dropped:t.dropped};return t.samples=[],t.dropped=0,pl},s.getSamplesPerFrame=function(t){switch(t.segmentCodec){case"mp3":return eo;case"ac3":return to;default:return Js}},s.remuxAudio=function(t,e,r,a,o){var l=t.inputTimeScale,u=t.samplerate?t.samplerate:l,f=l/u,d=this.getSamplesPerFrame(t),h=d*f,v=this._initPTS,c=t.segmentCodec==="mp3"&&this.typeSupported.mpeg,g=[],m=o!==void 0,p=t.samples,y=c?0:8,S=this.nextAudioPts||-1,T=e*l,x=v.baseTime*l/v.timescale;if(this.isAudioContiguous=r=r||p.length&&S>0&&(a&&Math.abs(T-S)<9e3||Math.abs(Me(p[0].pts-x,T)-S)<20*h),p.forEach(function(ee){ee.pts=Me(ee.pts-x,T)}),!r||S<0){if(p=p.filter(function(ee){return ee.pts>=0}),!p.length)return;o===0?S=0:a&&!m?S=Math.max(0,T):S=p[0].pts}if(t.segmentCodec==="aac")for(var R=this.config.maxAudioFramesDrift,L=0,A=S;L<p.length;L++){var C=p[L],_=C.pts,b=_-A,I=Math.abs(1e3*b/l);if(b<=-R*h&&m)L===0&&(this.logger.warn("Audio frame @ "+(_/l).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*b/l)+" ms."),this.nextAudioPts=S=A=_);else if(b>=R*h&&I<Zs&&m){var k=Math.round(b/h);A=_-k*h,A<0&&(k--,A+=h),L===0&&(this.nextAudioPts=S=A),this.logger.warn("[mp4-remuxer]: Injecting "+k+" audio frame @ "+(A/l).toFixed(3)+"s due to "+Math.round(1e3*b/l)+" ms gap.");for(var w=0;w<k;w++){var M=Math.max(A,0),P=$s.getSilentFrame(t.parsedCodec||t.manifestCodec||t.codec,t.channelCount);P||(this.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),P=C.unit.subarray()),p.splice(L,0,{unit:P,pts:M}),A+=h,L++}}C.pts=A,A+=h}for(var F=null,B=null,U,G=0,z=p.length;z--;)G+=p[z].unit.byteLength;for(var q=0,Q=p.length;q<Q;q++){var Y=p[q],ae=Y.unit,Z=Y.pts;if(B!==null){var ne=g[q-1];ne.duration=Math.round((Z-B)/f)}else if(r&&t.segmentCodec==="aac"&&(Z=S),F=Z,G>0){G+=y;try{U=new Uint8Array(G)}catch(ee){this.observer.emit(E.ERROR,E.ERROR,{type:K.MUX_ERROR,details:D.REMUX_ALLOC_ERROR,fatal:!1,error:ee,bytes:G,reason:"fail allocating audio mdat "+G});return}if(!c){var Ae=new DataView(U.buffer);Ae.setUint32(0,G),U.set(me.types.mdat,4)}}else return;U.set(ae,y);var ge=ae.byteLength;y+=ge,g.push(en(!0,d,ge,0)),B=Z}var J=g.length;if(J){var Re=g[g.length-1];this.nextAudioPts=S=B+f*Re.duration;var ue=c?new Uint8Array(0):me.moof(t.sequenceNumber++,F/f,de({},t,{samples:g}));t.samples=[];var ie=F/l,be=S/l,Ee="audio",De={data1:ue,data2:U,startPTS:ie,endPTS:be,startDTS:ie,endDTS:be,type:Ee,hasAudio:!0,hasVideo:!1,nb:J};return this.isAudioContiguous=!0,De}},n}();function Me(n,s){var i;if(s===null)return n;for(s<n?i=-8589934592:i=8589934592;Math.abs(n-s)>4294967296;)n+=i;return n}function ro(n){for(var s=0;s<n.length;s++)if(n[s].key)return s;return-1}function tn(n,s,i,t){var e=n.samples.length;if(e){for(var r=n.inputTimeScale,a=0;a<e;a++){var o=n.samples[a];o.pts=Me(o.pts-i.baseTime*r/i.timescale,s*r)/r,o.dts=Me(o.dts-t.baseTime*r/t.timescale,s*r)/r}var l=n.samples;return n.samples=[],{samples:l}}}function rn(n,s,i){var t=n.samples.length;if(t){for(var e=n.inputTimeScale,r=0;r<t;r++){var a=n.samples[r];a.pts=Me(a.pts-i.baseTime*e/i.timescale,s*e)/e}n.samples.sort(function(l,u){return l.pts-u.pts});var o=n.samples;return n.samples=[],{samples:o}}}var io=function(){function n(i,t,e,r){this.logger=void 0,this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null,this.logger=r}var s=n.prototype;return s.destroy=function(){},s.resetTimeStamp=function(t){this.initPTS=t,this.lastEndTime=null},s.resetNextTimestamp=function(){this.lastEndTime=null},s.resetInitSegment=function(t,e,r,a){this.audioCodec=e,this.videoCodec=r,this.generateInitSegment(aa(t,a)),this.emitInitSegment=!0},s.generateInitSegment=function(t){var e=this.audioCodec,r=this.videoCodec;if(!(t!=null&&t.byteLength)){this.initTracks=void 0,this.initData=void 0;return}var a=this.initData=Yr(t);a.audio&&(e=nn(a.audio,re.AUDIO)),a.video&&(r=nn(a.video,re.VIDEO));var o={};a.audio&&a.video?o.audiovideo={container:"video/mp4",codec:e+","+r,supplemental:a.video.supplemental,initSegment:t,id:"main"}:a.audio?o.audio={container:"audio/mp4",codec:e,initSegment:t,id:"audio"}:a.video?o.video={container:"video/mp4",codec:r,supplemental:a.video.supplemental,initSegment:t,id:"main"}:this.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=o},s.remux=function(t,e,r,a,o,l){var u,f,d=this.initPTS,h=this.lastEndTime,v={audio:void 0,video:void 0,text:a,id3:r,initSegment:void 0};N(h)||(h=this.lastEndTime=o||0);var c=e.samples;if(!(c!=null&&c.length))return v;var g={initPTS:void 0,timescale:1},m=this.initData;if((u=m)!=null&&u.length||(this.generateInitSegment(c),m=this.initData),!((f=m)!=null&&f.length))return this.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),v;this.emitInitSegment&&(g.tracks=this.initTracks,this.emitInitSegment=!1);var p=la(c,m),y=oa(m,c),S=y===null?o:y;(l||!d)&&(no(d,S,o,p)||g.timescale!==d.timescale)&&(g.initPTS=S-o,d&&d.timescale===1&&this.logger.warn("Adjusting initPTS @"+o+" from "+d.baseTime/d.timescale+" to "+g.initPTS),this.initPTS=d={baseTime:g.initPTS,timescale:1});var T=t?S-d.baseTime/d.timescale:h,x=T+p;fa(m,c,d.baseTime/d.timescale),p>0?this.lastEndTime=x:(this.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var R=!!m.audio,L=!!m.video,A="";R&&(A+="audio"),L&&(A+="video");var C={data1:c,startPTS:T,startDTS:T,endPTS:x,endDTS:x,type:A,hasAudio:R,hasVideo:L,nb:1,dropped:0};return v.audio=C.type==="audio"?C:void 0,v.video=C.type!=="audio"?C:void 0,v.initSegment=g,v.id3=tn(r,o,d,d),a.samples.length&&(v.text=rn(a,o,d)),v},n}();function no(n,s,i,t){if(n===null)return!0;var e=Math.max(t,1),r=s-n.baseTime/n.timescale;return Math.abs(r-i)>e}function nn(n,s){var i=n?.codec;if(i&&i.length>4)return i;if(s===re.AUDIO){if(i==="ec-3"||i==="ac-3"||i==="alac")return i;if(i==="fLaC"||i==="Opus"){var t=!1;return pt(i,t)}return X.warn('Unhandled audio codec "'+i+'" in mp4 MAP'),i||"mp4a"}return X.warn('Unhandled video codec "'+i+'" in mp4 MAP'),i||"avc1"}var He;try{He=self.performance.now.bind(self.performance)}catch{He=Date.now}var gr=[{demux:Ks,remux:io},{demux:qs,remux:vr},{demux:Ms,remux:vr},{demux:ws,remux:vr}],mr=function(){function n(i,t,e,r,a,o){this.asyncResult=!1,this.logger=void 0,this.observer=void 0,this.typeSupported=void 0,this.config=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=i,this.typeSupported=t,this.config=e,this.id=a,this.logger=o}var s=n.prototype;return s.configure=function(t){this.transmuxConfig=t,this.decrypter&&this.decrypter.reset()},s.push=function(t,e,r,a){var o=this,l=r.transmuxing;l.executeStart=He();var u=new Uint8Array(t),f=this.currentTransmuxState,d=this.transmuxConfig;a&&(this.currentTransmuxState=a);var h=a||f,v=h.contiguous,c=h.discontinuity,g=h.trackSwitch,m=h.accurateTimeOffset,p=h.timeOffset,y=h.initSegmentChange,S=d.audioCodec,T=d.videoCodec,x=d.defaultInitPts,R=d.duration,L=d.initSegmentData,A=ao(u,e);if(A&&st(A.method)){var C=this.getDecrypter(),_=pi(A.method);if(C.isSync()){var b=C.softwareDecrypt(u,A.key.buffer,A.iv.buffer,_),I=r.part>-1;if(I){var k=C.flush();b=k&&k.buffer}if(!b)return l.executeEnd=He(),pr(r);u=new Uint8Array(b)}else return this.asyncResult=!0,this.decryptionPromise=C.webCryptoDecrypt(u,A.key.buffer,A.iv.buffer,_).then(function(B){var U=o.push(B,null,r);return o.decryptionPromise=null,U}),this.decryptionPromise}var w=this.needsProbing(c,g);if(w){var M=this.configureTransmuxer(u);if(M)return this.logger.warn("[transmuxer] "+M.message),this.observer.emit(E.ERROR,E.ERROR,{type:K.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,error:M,reason:M.message}),l.executeEnd=He(),pr(r)}(c||g||y||w)&&this.resetInitSegment(L,S,T,R,e),(c||y||w)&&this.resetInitialTimestamp(x),v||this.resetContiguity();var P=this.transmux(u,A,p,m,r);this.asyncResult=je(P);var F=this.currentTransmuxState;return F.contiguous=!0,F.discontinuity=!1,F.trackSwitch=!1,l.executeEnd=He(),P},s.flush=function(t){var e=this,r=t.transmuxing;r.executeStart=He();var a=this.decrypter,o=this.currentTransmuxState,l=this.decryptionPromise;if(l)return this.asyncResult=!0,l.then(function(){return e.flush(t)});var u=[],f=o.timeOffset;if(a){var d=a.flush();d&&u.push(this.push(d.buffer,null,t))}var h=this.demuxer,v=this.remuxer;if(!h||!v){r.executeEnd=He();var c=[pr(t)];return this.asyncResult?Promise.resolve(c):c}var g=h.flush(f);return je(g)?(this.asyncResult=!0,g.then(function(m){return e.flushRemux(u,m,t),u})):(this.flushRemux(u,g,t),this.asyncResult?Promise.resolve(u):u)},s.flushRemux=function(t,e,r){var a=e.audioTrack,o=e.videoTrack,l=e.id3Track,u=e.textTrack,f=this.currentTransmuxState,d=f.accurateTimeOffset,h=f.timeOffset;this.logger.log("[transmuxer.ts]: Flushed "+this.id+" sn: "+r.sn+(r.part>-1?" part: "+r.part:"")+" of "+(this.id===W.MAIN?"level":"track")+" "+r.level);var v=this.remuxer.remux(a,o,l,u,h,d,!0,this.id);t.push({remuxResult:v,chunkMeta:r}),r.transmuxing.executeEnd=He()},s.resetInitialTimestamp=function(t){var e=this.demuxer,r=this.remuxer;!e||!r||(e.resetTimeStamp(t),r.resetTimeStamp(t))},s.resetContiguity=function(){var t=this.demuxer,e=this.remuxer;!t||!e||(t.resetContiguity(),e.resetNextTimestamp())},s.resetInitSegment=function(t,e,r,a,o){var l=this.demuxer,u=this.remuxer;!l||!u||(l.resetInitSegment(t,e,r,a),u.resetInitSegment(t,e,r,o))},s.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},s.transmux=function(t,e,r,a,o){var l;return e&&e.method==="SAMPLE-AES"?l=this.transmuxSampleAes(t,e,r,a,o):l=this.transmuxUnencrypted(t,r,a,o),l},s.transmuxUnencrypted=function(t,e,r,a){var o=this.demuxer.demux(t,e,!1,!this.config.progressive),l=o.audioTrack,u=o.videoTrack,f=o.id3Track,d=o.textTrack,h=this.remuxer.remux(l,u,f,d,e,r,!1,this.id);return{remuxResult:h,chunkMeta:a}},s.transmuxSampleAes=function(t,e,r,a,o){var l=this;return this.demuxer.demuxSampleAes(t,e,r).then(function(u){var f=l.remuxer.remux(u.audioTrack,u.videoTrack,u.id3Track,u.textTrack,r,a,!1,l.id);return{remuxResult:f,chunkMeta:o}})},s.configureTransmuxer=function(t){for(var e=this.config,r=this.observer,a=this.typeSupported,o,l=0,u=gr.length;l<u;l++){var f;if((f=gr[l].demux)!=null&&f.probe(t,this.logger)){o=gr[l];break}}if(!o)return new Error("Failed to find demuxer by probing fragment data");var d=this.demuxer,h=this.remuxer,v=o.remux,c=o.demux;(!h||!(h instanceof v))&&(this.remuxer=new v(r,e,a,this.logger)),(!d||!(d instanceof c))&&(this.demuxer=new c(r,e,a,this.logger),this.probe=c.probe)},s.needsProbing=function(t,e){return!this.demuxer||!this.remuxer||t||e},s.getDecrypter=function(){var t=this.decrypter;return t||(t=this.decrypter=new fr(this.config)),t},n}();function ao(n,s){var i=null;return n.byteLength>0&&s?.key!=null&&s.iv!==null&&s.method!=null&&(i=s),i}var pr=function(s){return{remuxResult:{},chunkMeta:s}};function je(n){return"then"in n&&n.then instanceof Function}var so=function(s,i,t,e,r){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=s,this.videoCodec=i,this.initSegmentData=t,this.duration=e,this.defaultInitPts=r||null},oo=function(s,i,t,e,r,a){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=s,this.contiguous=i,this.accurateTimeOffset=t,this.trackSwitch=e,this.timeOffset=r,this.initSegmentChange=a};function lo(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var uo=/(\d+)-(\d+)\/(\d+)/,an=function(){function n(i){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=i.fetchSetup||vo,this.controller=new self.AbortController,this.stats=new qt}var s=n.prototype;return s.destroy=function(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null},s.abortInternal=function(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())},s.abort=function(){var t;this.abortInternal(),(t=this.callbacks)!=null&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},s.load=function(t,e,r){var a=this,o=this.stats;if(o.loading.start)throw new Error("Loader can only be used once.");o.loading.start=self.performance.now();var l=fo(t,this.controller.signal),u=t.responseType==="arraybuffer",f=u?"byteLength":"length",d=e.loadPolicy,h=d.maxTimeToFirstByteMs,v=d.maxLoadTimeMs;this.context=t,this.config=e,this.callbacks=r,this.request=this.fetchSetup(t,l),self.clearTimeout(this.requestTimeout),e.timeout=h&&N(h)?h:v,this.requestTimeout=self.setTimeout(function(){a.callbacks&&(a.abortInternal(),a.callbacks.onTimeout(o,t,a.response))},e.timeout);var c=je(this.request)?this.request.then(self.fetch):self.fetch(this.request);c.then(function(g){var m;a.response=a.loader=g;var p=Math.max(self.performance.now(),o.loading.start);if(self.clearTimeout(a.requestTimeout),e.timeout=v,a.requestTimeout=self.setTimeout(function(){a.callbacks&&(a.abortInternal(),a.callbacks.onTimeout(o,t,a.response))},v-(p-o.loading.start)),!g.ok){var y=g.status,S=g.statusText;throw new go(S||"fetch, bad network response",y,g)}o.loading.first=p,o.total=co(g.headers)||o.total;var T=(m=a.callbacks)==null?void 0:m.onProgress;return T&&N(e.highWaterMark)?a.loadProgressively(g,o,t,e.highWaterMark,T):u?g.arrayBuffer():t.responseType==="json"?g.json():g.text()}).then(function(g){var m,p,y=a.response;if(!y)throw new Error("loader destroyed");self.clearTimeout(a.requestTimeout),o.loading.end=Math.max(self.performance.now(),o.loading.first);var S=g[f];S&&(o.loaded=o.total=S);var T={url:y.url,data:g,code:y.status},x=(m=a.callbacks)==null?void 0:m.onProgress;x&&!N(e.highWaterMark)&&x(o,t,g,y),(p=a.callbacks)==null||p.onSuccess(T,o,t,y)}).catch(function(g){var m;if(self.clearTimeout(a.requestTimeout),!o.aborted){var p=g&&g.code||0,y=g?g.message:null;(m=a.callbacks)==null||m.onError({code:p,text:y},t,g?g.details:null,o)}})},s.getCacheAge=function(){var t=null;if(this.response){var e=this.response.headers.get("age");t=e?parseFloat(e):null}return t},s.getResponseHeader=function(t){return this.response?this.response.headers.get(t):null},s.loadProgressively=function(t,e,r,a,o){a===void 0&&(a=0);var l=new os,u=t.body.getReader(),f=function(){return u.read().then(function(h){if(h.done)return l.dataLength&&o(e,r,l.flush().buffer,t),Promise.resolve(new ArrayBuffer(0));var v=h.value,c=v.length;return e.loaded+=c,c<a||l.dataLength?(l.push(v),l.dataLength>=a&&o(e,r,l.flush().buffer,t)):o(e,r,v.buffer,t),f()}).catch(function(){return Promise.reject()})};return f()},n}();function fo(n,s){var i={method:"GET",mode:"cors",credentials:"same-origin",signal:s,headers:new self.Headers(de({},n.headers))};return n.rangeEnd&&i.headers.set("Range","bytes="+n.rangeStart+"-"+String(n.rangeEnd-1)),i}function ho(n){var s=uo.exec(n);if(s)return parseInt(s[2])-parseInt(s[1])+1}function co(n){var s=n.get("Content-Range");if(s){var i=ho(s);if(N(i))return i}var t=n.get("Content-Length");if(t)return parseInt(t)}function vo(n,s){return new self.Request(n.url,s)}var go=function(n){function s(i,t,e){var r;return r=n.call(this,i)||this,r.code=void 0,r.details=void 0,r.code=t,r.details=e,r}return he(s,n),s}(nt(Error)),mo=/^age:\s*[\d.]+\s*$/im,sn=function(){function n(i){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=i&&i.xhrSetup||null,this.stats=new qt,this.retryDelay=0}var s=n.prototype;return s.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null},s.abortInternal=function(){var t=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),t&&(t.onreadystatechange=null,t.onprogress=null,t.readyState!==4&&(this.stats.aborted=!0,t.abort()))},s.abort=function(){var t;this.abortInternal(),(t=this.callbacks)!=null&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},s.load=function(t,e,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=t,this.config=e,this.callbacks=r,this.loadInternal()},s.loadInternal=function(){var t=this,e=this.config,r=this.context;if(!(!e||!r)){var a=this.loader=new self.XMLHttpRequest,o=this.stats;o.loading.first=0,o.loaded=0,o.aborted=!1;var l=this.xhrSetup;l?Promise.resolve().then(function(){if(!(t.loader!==a||t.stats.aborted))return l(a,r.url)}).catch(function(u){if(!(t.loader!==a||t.stats.aborted))return a.open("GET",r.url,!0),l(a,r.url)}).then(function(){t.loader!==a||t.stats.aborted||t.openAndSendXhr(a,r,e)}).catch(function(u){var f;(f=t.callbacks)==null||f.onError({code:a.status,text:u.message},r,a,o)}):this.openAndSendXhr(a,r,e)}},s.openAndSendXhr=function(t,e,r){t.readyState||t.open("GET",e.url,!0);var a=e.headers,o=r.loadPolicy,l=o.maxTimeToFirstByteMs,u=o.maxLoadTimeMs;if(a)for(var f in a)t.setRequestHeader(f,a[f]);e.rangeEnd&&t.setRequestHeader("Range","bytes="+e.rangeStart+"-"+(e.rangeEnd-1)),t.onreadystatechange=this.readystatechange.bind(this),t.onprogress=this.loadprogress.bind(this),t.responseType=e.responseType,self.clearTimeout(this.requestTimeout),r.timeout=l&&N(l)?l:u,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),t.send()},s.readystatechange=function(){var t=this.context,e=this.loader,r=this.stats;if(!(!t||!e)){var a=e.readyState,o=this.config;if(!r.aborted&&a>=2&&(r.loading.first===0&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),o.timeout!==o.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),o.timeout=o.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),o.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),a===4)){self.clearTimeout(this.requestTimeout),e.onreadystatechange=null,e.onprogress=null;var l=e.status,u=e.responseType==="text"?e.responseText:null;if(l>=200&&l<300){var f=u??e.response;if(f!=null){var d,h;r.loading.end=Math.max(self.performance.now(),r.loading.first);var v=e.responseType==="arraybuffer"?f.byteLength:f.length;r.loaded=r.total=v,r.bwEstimate=r.total*8e3/(r.loading.end-r.loading.first);var c=(d=this.callbacks)==null?void 0:d.onProgress;c&&c(r,t,f,e);var g={url:e.responseURL,data:f,code:l};(h=this.callbacks)==null||h.onSuccess(g,r,t,e);return}}var m=o.loadPolicy.errorRetry,p=r.retry,y={url:t.url,data:void 0,code:l};if(xt(m,p,!1,y))this.retry(m);else{var S;X.error(l+" while loading "+t.url),(S=this.callbacks)==null||S.onError({code:l,text:e.statusText},t,e,r)}}}},s.loadtimeout=function(){if(this.config){var t=this.config.loadPolicy.timeoutRetry,e=this.stats.retry;if(xt(t,e,!0))this.retry(t);else{var r;X.warn("timeout while loading "+((r=this.context)==null?void 0:r.url));var a=this.callbacks;a&&(this.abortInternal(),a.onTimeout(this.stats,this.context,this.loader))}}},s.retry=function(t){var e=this.context,r=this.stats;this.retryDelay=tr(t,r.retry),r.retry++,X.warn((status?"HTTP Status "+status:"Timeout")+" while loading "+e?.url+", retrying "+r.retry+"/"+t.maxNumRetry+" in "+this.retryDelay+"ms"),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)},s.loadprogress=function(t){var e=this.stats;e.loaded=t.loaded,t.lengthComputable&&(e.total=t.total)},s.getCacheAge=function(){var t=null;if(this.loader&&mo.test(this.loader.getAllResponseHeaders())){var e=this.loader.getResponseHeader("age");t=e?parseFloat(e):null}return t},s.getResponseHeader=function(t){return this.loader&&new RegExp("^"+t+":\\s*[\\d.]+\\s*$","im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(t):null},n}(),on={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},po=xe(xe({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,maxDevicePixelRatio:Number.POSITIVE_INFINITY,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,maxBufferSize:60*1e3*1e3,maxFragLookUpTolerance:.25,maxBufferHole:.1,detectStallWithCurrentTimeMs:1250,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,nudgeOnVideoHole:!0,liveSyncDurationCount:3,liveSyncOnStallIncrease:1,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,ignorePlaylistParsingErrors:!1,loader:sn,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:_a,bufferController:Na,capLevelController:Ua,errorController:wa,fpsController:ss,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:null,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableEmsgKLVMetadata:!1,enableID3MetadataCues:!0,enableInterstitialPlayback:!1,interstitialAppendInPlace:!0,interstitialLiveLookAhead:10,useMediaCapabilities:!1,certLoadPolicy:{default:on},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},interstitialAssetListLoadPolicy:{default:on},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},Eo()),{},{subtitleStreamController:void 0,subtitleTrackController:void 0,timelineController:void 0,audioStreamController:void 0,audioTrackController:void 0,emeController:void 0,cmcdController:void 0,contentSteeringController:as,interstitialsController:void 0});function Eo(){return{cueHandler:Zn,enableWebVTT:!1,enableIMSC1:!1,enableCEA708Captions:!1,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function yo(n,s,i){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"');var t=Er(n),e=["manifest","level","frag"],r=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return e.forEach(function(a){var o=(a==="level"?"playlist":a)+"LoadPolicy",l=s[o]===void 0,u=[];r.forEach(function(f){var d=a+"Loading"+f,h=s[d];if(h!==void 0&&l){u.push(d);var v=t[o].default;switch(s[o]={default:v},f){case"TimeOut":v.maxLoadTimeMs=h,v.maxTimeToFirstByteMs=h;break;case"MaxRetry":v.errorRetry.maxNumRetry=h,v.timeoutRetry.maxNumRetry=h;break;case"RetryDelay":v.errorRetry.retryDelayMs=h,v.timeoutRetry.retryDelayMs=h;break;case"MaxRetryTimeout":v.errorRetry.maxRetryDelayMs=h,v.timeoutRetry.maxRetryDelayMs=h;break}}}),u.length&&i.warn('hls.js config: "'+u.join('", "')+'" setting(s) are deprecated, use "'+o+'": '+Te(s[o]))}),xe(xe({},t),s)}function Er(n){return n&&typeof n=="object"?Array.isArray(n)?n.map(Er):Object.keys(n).reduce(function(s,i){return s[i]=Er(n[i]),s},{}):n}function To(n,s){var i=n.loader;if(i!==an&&i!==sn)s.log("[config]: Custom loader detected, cannot enable progressive streaming"),n.progressive=!1;else{var t=lo();t&&(n.loader=an,n.progressive=!0,n.enableSoftwareAES=!0,s.log("[config]: Progressive streaming enabled, using FetchLoader"))}}var Le={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"},So=function(){function n(i){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=i,this._registerListeners()}var s=n.prototype;return s._registerListeners=function(){var t=this.hls;t.on(E.MANIFEST_LOADING,this.onManifestLoading,this),t.on(E.BUFFER_APPENDED,this.onBufferAppended,this),t.on(E.FRAG_BUFFERED,this.onFragBuffered,this),t.on(E.FRAG_LOADED,this.onFragLoaded,this)},s._unregisterListeners=function(){var t=this.hls;t.off(E.MANIFEST_LOADING,this.onManifestLoading,this),t.off(E.BUFFER_APPENDED,this.onBufferAppended,this),t.off(E.FRAG_BUFFERED,this.onFragBuffered,this),t.off(E.FRAG_LOADED,this.onFragLoaded,this)},s.destroy=function(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null},s.getAppendedFrag=function(t,e){var r=this.activePartLists[e];if(r)for(var a=r.length;a--;){var o=r[a];if(!o)break;var l=o.end;if(o.start<=t&&l!==null&&t<=l)return o}return this.getBufferedFrag(t,e)},s.getBufferedFrag=function(t,e){return this.getFragAtPos(t,e,!0)},s.getFragAtPos=function(t,e,r){for(var a=this.fragments,o=Object.keys(a),l=o.length;l--;){var u=a[o[l]];if(u?.body.type===e&&(!r||u.buffered)){var f=u.body;if(f.start<=t&&t<=f.end)return f}}return null},s.detectEvictedFragments=function(t,e,r,a,o){var l=this;this.timeRanges&&(this.timeRanges[t]=e);var u=a?.fragment.sn||-1;Object.keys(this.fragments).forEach(function(f){var d=l.fragments[f];if(d&&!(u>=d.body.sn)){if(!d.buffered&&(!d.loaded||o)){d.body.type===r&&l.removeFragment(d.body);return}var h=d.range[t];if(h){if(h.time.length===0){l.removeFragment(d.body);return}h.time.some(function(v){var c=!l.isTimeBuffered(v.startPTS,v.endPTS,e);return c&&l.removeFragment(d.body),c})}}})},s.detectPartialFragments=function(t){var e=this,r=this.timeRanges;if(!(!r||t.frag.sn==="initSegment")){var a=t.frag,o=Je(a),l=this.fragments[o];if(!(!l||l.buffered&&a.gap)){var u=!a.relurl;if(Object.keys(r).forEach(function(d){var h=a.elementaryStreams[d];if(h){var v=r[d],c=u||h.partial===!0;l.range[d]=e.getBufferedTimes(a,t.part,c,v)}}),l.loaded=null,Object.keys(l.range).length){l.buffered=!0;var f=l.body.endList=a.endList||l.body.endList;f&&(this.endListFragments[l.body.type]=l),Ct(l)||this.removeParts(a.sn-1,a.type)}else this.removeFragment(l.body)}}},s.removeParts=function(t,e){var r=this.activePartLists[e];r&&(this.activePartLists[e]=r.filter(function(a){return a.fragment.sn>=t}))},s.fragBuffered=function(t,e){var r=Je(t),a=this.fragments[r];!a&&e&&(a=this.fragments[r]={body:t,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},t.gap&&(this.hasGaps=!0)),a&&(a.loaded=null,a.buffered=!0)},s.getBufferedTimes=function(t,e,r,a){for(var o={time:[],partial:r},l=t.start,u=t.end,f=t.minEndPTS||u,d=t.maxStartPTS||l,h=0;h<a.length;h++){var v=a.start(h)-this.bufferPadding,c=a.end(h)+this.bufferPadding;if(d>=v&&f<=c){o.time.push({startPTS:Math.max(l,a.start(h)),endPTS:Math.min(u,a.end(h))});break}else if(l<c&&u>v){var g=Math.max(l,a.start(h)),m=Math.min(u,a.end(h));m>g&&(o.partial=!0,o.time.push({startPTS:g,endPTS:m}))}else if(u<=v)break}return o},s.getPartialFragment=function(t){var e=null,r,a,o,l=0,u=this.bufferPadding,f=this.fragments;return Object.keys(f).forEach(function(d){var h=f[d];h&&Ct(h)&&(a=h.body.start-u,o=h.body.end+u,t>=a&&t<=o&&(r=Math.min(t-a,o-t),l<=r&&(e=h.body,l=r)))}),e},s.isEndListAppended=function(t){var e=this.endListFragments[t];return e!==void 0&&(e.buffered||Ct(e))},s.getState=function(t){var e=Je(t),r=this.fragments[e];return r?r.buffered?Ct(r)?Le.PARTIAL:Le.OK:Le.APPENDING:Le.NOT_LOADED},s.isTimeBuffered=function(t,e,r){for(var a,o,l=0;l<r.length;l++){if(a=r.start(l)-this.bufferPadding,o=r.end(l)+this.bufferPadding,t>=a&&e<=o)return!0;if(e<=a)return!1}return!1},s.onManifestLoading=function(){this.removeAllFragments()},s.onFragLoaded=function(t,e){if(!(e.frag.sn==="initSegment"||e.frag.bitrateTest)){var r=e.frag,a=e.part?null:e,o=Je(r);this.fragments[o]={body:r,appendedPTS:null,loaded:a,buffered:!1,range:Object.create(null)}}},s.onBufferAppended=function(t,e){var r=e.frag,a=e.part,o=e.timeRanges,l=e.type;if(r.sn!=="initSegment"){var u=r.type;if(a){var f=this.activePartLists[u];f||(this.activePartLists[u]=f=[]),f.push(a)}this.timeRanges=o;var d=o[l];this.detectEvictedFragments(l,d,u,a)}},s.onFragBuffered=function(t,e){this.detectPartialFragments(e)},s.hasFragment=function(t){var e=Je(t);return!!this.fragments[e]},s.hasFragments=function(t){var e=this.fragments,r=Object.keys(e);if(!t)return r.length>0;for(var a=r.length;a--;){var o=e[r[a]];if(o?.body.type===t)return!0}return!1},s.hasParts=function(t){var e;return!!((e=this.activePartLists[t])!=null&&e.length)},s.removeFragmentsInRange=function(t,e,r,a,o){var l=this;a&&!this.hasGaps||Object.keys(this.fragments).forEach(function(u){var f=l.fragments[u];if(f){var d=f.body;d.type!==r||a&&!d.gap||d.start<e&&d.end>t&&(f.buffered||o)&&l.removeFragment(d)}})},s.removeFragment=function(t){var e=Je(t);t.clearElementaryStreamInfo();var r=this.activePartLists[t.type];if(r){var a=t.sn;this.activePartLists[t.type]=r.filter(function(o){return o.fragment.sn!==a})}delete this.fragments[e],t.endList&&delete this.endListFragments[t.type]},s.removeAllFragments=function(){var t,e;this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1;var r=(t=this.hls)==null||(e=t.latestLevelDetails)==null?void 0:e.partList;r&&r.forEach(function(a){return a.clearElementaryStreamInfo()})},n}();function Ct(n){var s,i,t;return n.buffered&&(n.body.gap||((s=n.range.video)==null?void 0:s.partial)||((i=n.range.audio)==null?void 0:i.partial)||((t=n.range.audiovideo)==null?void 0:t.partial))}function Je(n){return n.type+"_"+n.level+"_"+n.sn}var ln=Math.pow(2,17),xo=function(){function n(i){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=i}var s=n.prototype;return s.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},s.abort=function(){this.loader&&this.loader.abort()},s.load=function(t,e){var r=this,a=t.url;if(!a)return Promise.reject(new Ve({type:K.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:t,error:new Error("Fragment does not have a "+(a?"part list":"url")),networkDetails:null}));this.abort();var o=this.config,l=o.fLoader,u=o.loader;return new Promise(function(f,d){if(r.loader&&r.loader.destroy(),t.gap)if(t.tagList.some(function(p){return p[0]==="GAP"})){d(fn(t));return}else t.gap=!1;var h=r.loader=l?new l(o):new u(o),v=un(t);t.loader=h;var c=fi(o.fragLoadPolicy.default),g={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:t.sn==="initSegment"?1/0:ln};t.stats=h.stats;var m={onSuccess:function(y,S,T,x){r.resetLoader(t,h);var R=y.data;T.resetIV&&t.decryptdata&&(t.decryptdata.iv=new Uint8Array(R.slice(0,16)),R=R.slice(16)),f({frag:t,part:null,payload:R,networkDetails:x})},onError:function(y,S,T,x){r.resetLoader(t,h),d(new Ve({type:K.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:t,response:xe({url:a,data:void 0},y),error:new Error("HTTP Error "+y.code+" "+y.text),networkDetails:T,stats:x}))},onAbort:function(y,S,T){r.resetLoader(t,h),d(new Ve({type:K.NETWORK_ERROR,details:D.INTERNAL_ABORTED,fatal:!1,frag:t,error:new Error("Aborted"),networkDetails:T,stats:y}))},onTimeout:function(y,S,T){r.resetLoader(t,h),d(new Ve({type:K.NETWORK_ERROR,details:D.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,error:new Error("Timeout after "+g.timeout+"ms"),networkDetails:T,stats:y}))}};e&&(m.onProgress=function(p,y,S,T){return e({frag:t,part:null,payload:S,networkDetails:T})}),h.load(v,g,m)})},s.loadPart=function(t,e,r){var a=this;this.abort();var o=this.config,l=o.fLoader,u=o.loader;return new Promise(function(f,d){if(a.loader&&a.loader.destroy(),t.gap||e.gap){d(fn(t,e));return}var h=a.loader=l?new l(o):new u(o),v=un(t,e);t.loader=h;var c=fi(o.fragLoadPolicy.default),g={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:ln};e.stats=h.stats,h.load(v,g,{onSuccess:function(p,y,S,T){a.resetLoader(t,h),a.updateStatsFromPart(t,e);var x={frag:t,part:e,payload:p.data,networkDetails:T};r(x),f(x)},onError:function(p,y,S,T){a.resetLoader(t,h),d(new Ve({type:K.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:t,part:e,response:xe({url:v.url,data:void 0},p),error:new Error("HTTP Error "+p.code+" "+p.text),networkDetails:S,stats:T}))},onAbort:function(p,y,S){t.stats.aborted=e.stats.aborted,a.resetLoader(t,h),d(new Ve({type:K.NETWORK_ERROR,details:D.INTERNAL_ABORTED,fatal:!1,frag:t,part:e,error:new Error("Aborted"),networkDetails:S,stats:p}))},onTimeout:function(p,y,S){a.resetLoader(t,h),d(new Ve({type:K.NETWORK_ERROR,details:D.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,part:e,error:new Error("Timeout after "+g.timeout+"ms"),networkDetails:S,stats:p}))}})})},s.updateStatsFromPart=function(t,e){var r=t.stats,a=e.stats,o=a.total;if(r.loaded+=a.loaded,o){var l=Math.round(t.duration/e.duration),u=Math.min(Math.round(r.loaded/o),l),f=l-u,d=f*Math.round(r.loaded/u);r.total=r.loaded+d}else r.total=Math.max(r.loaded,r.total);var h=r.loading,v=a.loading;h.start?h.first+=v.first-v.start:(h.start=v.start,h.first=v.first),h.end=v.end},s.resetLoader=function(t,e){t.loader=null,this.loader===e&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),e.destroy()},n}();function un(n,s){s===void 0&&(s=null);var i=s||n,t={frag:n,part:s,responseType:"arraybuffer",url:i.url,headers:{},rangeStart:0,rangeEnd:0},e=i.byteRangeStartOffset,r=i.byteRangeEndOffset;if(N(e)&&N(r)){var a,o=e,l=r;if(n.sn==="initSegment"&&Lo((a=n.decryptdata)==null?void 0:a.method)){var u=r-e;u%16&&(l=r+(16-u%16)),e!==0&&(t.resetIV=!0,o=e-16)}t.rangeStart=o,t.rangeEnd=l}return t}function fn(n,s){var i=new Error("GAP "+(n.gap?"tag":"attribute")+" found"),t={type:K.MEDIA_ERROR,details:D.FRAG_GAP,fatal:!1,frag:n,error:i,networkDetails:null};return s&&(t.part=s),(s||n).stats.aborted=!0,new Ve(t)}function Lo(n){return n==="AES-128"||n==="AES-256"}var Ve=function(n){function s(i){var t;return t=n.call(this,i.error.message)||this,t.data=void 0,t.data=i,t}return he(s,n),s}(nt(Error)),dn=function(n){function s(t,e){var r;return r=n.call(this,t,e)||this,r._boundTick=void 0,r._tickTimer=null,r._tickInterval=null,r._tickCallCount=0,r._boundTick=r.tick.bind(r),r}he(s,n);var i=s.prototype;return i.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},i.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},i.onHandlerDestroyed=function(){},i.hasInterval=function(){return!!this._tickInterval},i.hasNextTick=function(){return!!this._tickTimer},i.setInterval=function(e){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)},i.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},i.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},i.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},i.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},i.doTick=function(){},s}($e),hn=function(s,i,t,e,r,a){e===void 0&&(e=0),r===void 0&&(r=-1),a===void 0&&(a=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=kt(),this.buffering={audio:kt(),video:kt(),audiovideo:kt()},this.level=s,this.sn=i,this.id=t,this.size=e,this.part=r,this.partial=a};function kt(){return{start:0,executeStart:0,executeEnd:0,end:0}}function ut(n,s){for(var i=0,t=n.length;i<t;i++){var e;if(((e=n[i])==null?void 0:e.cc)===s)return n[i]}return null}function Ao(n,s){return!!(n&&s.startCC<n.endCC&&s.endCC>n.startCC)}function cn(n,s){if(n){var i=n.start+s;n.start=n.startPTS=i,n.endPTS=i+n.duration}}function vn(n,s){for(var i=s.fragments,t=0,e=i.length;t<e;t++)cn(i[t],n);s.fragmentHint&&cn(s.fragmentHint,n),s.alignedSliding=!0}function Ro(n,s){n&&(bo(s,n),!s.alignedSliding&&n&&Io(s,n),!s.alignedSliding&&n&&!s.skippedSegments&&Ci(n,s,!1))}function bo(n,s){if(Ao(s,n)){var i=Math.min(s.endCC,n.endCC),t=ut(s.fragments,i),e=ut(n.fragments,i);if(!(!t||!e)){X.log("Aligning playlist at start of dicontinuity sequence "+i);var r=t.start-e.start;vn(r,n)}}}function Io(n,s){if(!(!n.hasProgramDateTime||!s.hasProgramDateTime)){var i=n.fragments,t=s.fragments;if(!(!i.length||!t.length)){var e,r,a=Math.min(s.endCC,n.endCC);s.startCC<a&&n.startCC<a&&(e=ut(t,a),r=ut(i,a)),(!e||!r)&&(e=t[Math.floor(t.length/2)],r=ut(i,e.cc)||i[Math.floor(i.length/2)]);var o=e.programDateTime,l=r.programDateTime;if(!(!o||!l)){var u=(l-o)/1e3-(r.start-e.start);vn(u,n)}}}}var _o={toString:function(s){for(var i="",t=s.length,e=0;e<t;e++)i+="["+s.start(e).toFixed(3)+"-"+s.end(e).toFixed(3)+"]";return i}},O={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_LEVEL:"WAITING_LEVEL"},Do=function(n){function s(t,e,r,a,o){var l;return l=n.call(this,a,t.logger)||this,l.hls=void 0,l.fragPrevious=null,l.fragCurrent=null,l.fragmentTracker=void 0,l.transmuxer=null,l._state=O.STOPPED,l.playlistType=void 0,l.media=null,l.mediaBuffer=null,l.config=void 0,l.bitrateTest=!1,l.lastCurrentTime=0,l.nextLoadPosition=0,l.startPosition=0,l.startTimeOffset=null,l.retryDate=0,l.levels=null,l.fragmentLoader=void 0,l.keyLoader=void 0,l.levelLastLoaded=null,l.startFragRequested=!1,l.decrypter=void 0,l.initPTS=[],l.buffering=!0,l.loadingParts=!1,l.loopSn=void 0,l.onMediaSeeking=function(){var u=l,f=u.config,d=u.fragCurrent,h=u.media,v=u.mediaBuffer,c=u.state,g=h?h.currentTime:0,m=$.bufferInfo(v||h,g,f.maxBufferHole);if(l.log("media seeking to "+(N(g)?g.toFixed(3):g)+", state: "+c),l.state===O.ENDED)l.resetLoadingState();else if(d){var p=f.maxFragLookUpTolerance,y=d.start-p,S=d.start+d.duration+p;if(!m.len||S<m.start||y>m.end){var T=g>S;(g<y||T)&&(T&&d.loader&&(l.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),d.abortRequests(),l.resetLoadingState()),l.fragPrevious=null)}}if(h){l.fragmentTracker.removeFragmentsInRange(g,1/0,l.playlistType,!0);var x=l.lastCurrentTime;if(g>x&&(l.lastCurrentTime=g),!l.loadingParts){var R=Math.max(m.end,g),L=l.shouldLoadParts(l.getLevelDetails(),R);L&&(l.log("LL-Part loading ON after seeking to "+g.toFixed(2)+" with buffer @"+R.toFixed(2)),l.loadingParts=L)}}!l.hls.hasEnoughToStart&&!m.len&&(l.log("setting startPosition to "+g+" because of seek before start"),l.nextLoadPosition=l.startPosition=g),l.tickImmediate()},l.onMediaEnded=function(){l.log("setting startPosition to 0 because media ended"),l.startPosition=l.lastCurrentTime=0},l.playlistType=o,l.hls=t,l.fragmentLoader=new xo(t.config),l.keyLoader=r,l.fragmentTracker=e,l.config=t.config,l.decrypter=new fr(t.config),l}he(s,n);var i=s.prototype;return i.registerListeners=function(){var e=this.hls;e.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(E.ERROR,this.onError,this)},i.unregisterListeners=function(){var e=this.hls;e.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(E.ERROR,this.onError,this)},i.doTick=function(){this.onTickEnd()},i.onTickEnd=function(){},i.startLoad=function(e){},i.stopLoad=function(){if(this.state!==O.STOPPED){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);var e=this.fragCurrent;e!=null&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=O.STOPPED}},i.pauseBuffering=function(){this.buffering=!1},i.resumeBuffering=function(){this.buffering=!0},i._streamEnded=function(e,r){if(r.live||!this.media)return!1;var a=e.end||0,o=this.config.timelineOffset||0;if(a<=o)return!1;var l=e.nextStart,u=l&&l>o&&l<r.edge;if(u||this.media.currentTime<e.start)return!1;var f=r.partList;if(f!=null&&f.length){var d=f[f.length-1],h=$.isBuffered(this.media,d.start+d.duration/2);return h}var v=r.fragments[r.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(v)},i.getLevelDetails=function(){if(this.levels&&this.levelLastLoaded!==null){var e;return(e=this.levelLastLoaded)==null?void 0:e.details}},i.onMediaAttached=function(e,r){var a=this.media=this.mediaBuffer=r.media;a.removeEventListener("seeking",this.onMediaSeeking),a.removeEventListener("ended",this.onMediaEnded),a.addEventListener("seeking",this.onMediaSeeking),a.addEventListener("ended",this.onMediaEnded);var o=this.config;this.levels&&o.autoStartLoad&&this.state===O.STOPPED&&this.startLoad(o.startPosition)},i.onMediaDetaching=function(e,r){var a=!!r.transferMedia,o=this.media;if(o!==null){if(o.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),o.removeEventListener("seeking",this.onMediaSeeking),o.removeEventListener("ended",this.onMediaEnded),this.keyLoader&&!a&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loopSn=void 0,a){this.resetLoadingState(),this.resetTransmuxer();return}this.loadingParts=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}},i.onManifestLoading=function(){this.initPTS=[],this.levels=this.levelLastLoaded=this.fragCurrent=null,this.lastCurrentTime=this.startPosition=0,this.startFragRequested=!1},i.onError=function(e,r){},i.onManifestLoaded=function(e,r){this.startTimeOffset=r.startTimeOffset},i.onHandlerDestroying=function(){this.stopLoad(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),n.prototype.onHandlerDestroying.call(this),this.hls=this.onMediaSeeking=this.onMediaEnded=null},i.onHandlerDestroyed=function(){this.state=O.STOPPED,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,n.prototype.onHandlerDestroyed.call(this)},i.loadFragment=function(e,r,a){this.startFragRequested=!0,this._loadFragForPlayback(e,r,a)},i._loadFragForPlayback=function(e,r,a){var o=this,l=function(f){var d=f.frag;if(o.fragContextChanged(d)){o.warn(d.type+" sn: "+d.sn+(f.part?" part: "+f.part.index:"")+" of "+o.fragInfo(d,!1,f.part)+") was dropped during download."),o.fragmentTracker.removeFragment(d);return}d.stats.chunkCount++,o._handleFragmentLoadProgress(f)};this._doFragLoad(e,r,a,l).then(function(u){if(u){var f=o.state,d=u.frag;if(o.fragContextChanged(d)){(f===O.FRAG_LOADING||!o.fragCurrent&&f===O.PARSING)&&(o.fragmentTracker.removeFragment(d),o.state=O.IDLE);return}"payload"in u&&(o.log("Loaded "+d.type+" sn: "+d.sn+" of "+o.playlistLabel()+" "+d.level),o.hls.trigger(E.FRAG_LOADED,u)),o._handleFragmentLoadComplete(u)}}).catch(function(u){o.state===O.STOPPED||o.state===O.ERROR||(o.warn("Frag error: "+(u?.message||u)),o.resetFragmentLoading(e))})},i.clearTrackerIfNeeded=function(e){var r,a=this.fragmentTracker,o=a.getState(e);if(o===Le.APPENDING){var l=e.type,u=this.getFwdBufferInfo(this.mediaBuffer,l),f=Math.max(e.duration,u?u.len:this.config.maxBufferLength),d=this.backtrackFragment,h=d?e.sn-d.sn:0;(h===1||this.reduceMaxBufferLength(f,e.duration))&&a.removeFragment(e)}else((r=this.mediaBuffer)==null?void 0:r.buffered.length)===0?a.removeAllFragments():a.hasParts(e.type)&&(a.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),a.getState(e)===Le.PARTIAL&&a.removeFragment(e))},i.checkLiveUpdate=function(e){if(e.updated&&!e.live){var r=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:r,part:null,stats:r.stats,id:r.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)},i.waitForLive=function(e){var r=e.details;return r?.live&&r.type!=="EVENT"&&(this.levelLastLoaded!==e||r.expired)},i.flushMainBuffer=function(e,r,a){if(a===void 0&&(a=null),!!(e-r)){var o={startOffset:e,endOffset:r,type:a};this.hls.trigger(E.BUFFER_FLUSHING,o)}},i._loadInitSegment=function(e,r){var a=this;this._doFragLoad(e,r).then(function(o){var l=o?.frag;if(!l||a.fragContextChanged(l)||!a.levels)throw new Error("init load aborted");return o}).then(function(o){var l=a.hls,u=o.frag,f=o.payload,d=u.decryptdata;if(f&&f.byteLength>0&&d!=null&&d.key&&d.iv&&st(d.method)){var h=self.performance.now();return a.decrypter.decrypt(new Uint8Array(f),d.key.buffer,d.iv.buffer,pi(d.method)).catch(function(v){throw l.trigger(E.ERROR,{type:K.MEDIA_ERROR,details:D.FRAG_DECRYPT_ERROR,fatal:!1,error:v,reason:v.message,frag:u}),v}).then(function(v){var c=self.performance.now();return l.trigger(E.FRAG_DECRYPTED,{frag:u,payload:v,stats:{tstart:h,tdecrypt:c}}),o.payload=v,a.completeInitSegmentLoad(o)})}return a.completeInitSegmentLoad(o)}).catch(function(o){a.state===O.STOPPED||a.state===O.ERROR||(a.warn(o),a.resetFragmentLoading(e))})},i.completeInitSegmentLoad=function(e){var r=this.levels;if(!r)throw new Error("init load aborted, missing levels");var a=e.frag.stats;this.state!==O.STOPPED&&(this.state=O.IDLE),e.frag.data=new Uint8Array(e.payload),a.parsing.start=a.buffering.start=self.performance.now(),a.parsing.end=a.buffering.end=self.performance.now(),this.tick()},i.fragContextChanged=function(e){var r=this.fragCurrent;return!e||!r||e.sn!==r.sn||e.level!==r.level},i.fragBufferedComplete=function(e,r){var a=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log("Buffered "+e.type+" sn: "+e.sn+(r?" part: "+r.index:"")+" of "+this.fragInfo(e,!1,r)+" > buffer:"+(a?_o.toString($.getBuffered(a)):"(detached)")+")"),we(e)){var o;if(e.type!==W.SUBTITLE){var l=e.elementaryStreams;if(!Object.keys(l).some(function(f){return!!l[f]})){this.state=O.IDLE;return}}var u=(o=this.levels)==null?void 0:o[e.level];u!=null&&u.fragmentError&&(this.log("Resetting level fragment error count of "+u.fragmentError+" on frag buffered"),u.fragmentError=0)}this.state=O.IDLE},i._handleFragmentLoadComplete=function(e){var r=this.transmuxer;if(r){var a=e.frag,o=e.part,l=e.partsLoaded,u=!l||l.length===0||l.some(function(d){return!d}),f=new hn(a.level,a.sn,a.stats.chunkCount+1,0,o?o.index:-1,!u);r.flush(f)}},i._handleFragmentLoadProgress=function(e){},i._doFragLoad=function(e,r,a,o){var l,u=this;a===void 0&&(a=null),this.fragCurrent=e;var f=r?.details;if(!this.levels||!f)throw new Error("frag load aborted, missing level"+(f?"":" detail")+"s");var d=null;e.encrypted&&!((l=e.decryptdata)!=null&&l.key)?(this.log("Loading key for "+e.sn+" of ["+f.startSN+"-"+f.endSN+"], "+this.playlistLabel()+" "+e.level),this.state=O.KEY_LOADING,this.fragCurrent=e,d=this.keyLoader.load(e).then(function(T){if(!u.fragContextChanged(T.frag))return u.hls.trigger(E.KEY_LOADED,T),u.state===O.KEY_LOADING&&(u.state=O.IDLE),T}),this.hls.trigger(E.KEY_LOADING,{frag:e}),this.fragCurrent===null&&(d=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!e.encrypted&&f.encryptedFragments.length&&this.keyLoader.loadClear(e,f.encryptedFragments);var h=this.fragPrevious;if(we(e)&&(!h||e.sn!==h.sn)){var v=this.shouldLoadParts(r.details,e.end);v!==this.loadingParts&&(this.log("LL-Part loading "+(v?"ON":"OFF")+" loading sn "+h?.sn+"->"+e.sn),this.loadingParts=v)}if(a=Math.max(e.start,a||0),this.loadingParts&&we(e)){var c=f.partList;if(c&&o){a>e.end&&f.fragmentHint&&(e=f.fragmentHint);var g=this.getNextPart(c,e,a);if(g>-1){var m=c[g];e=this.fragCurrent=m.fragment,this.log("Loading "+e.type+" sn: "+e.sn+" part: "+m.index+" ("+g+"/"+(c.length-1)+") of "+this.fragInfo(e,!1,m)+") cc: "+e.cc+" ["+f.startSN+"-"+f.endSN+"], target: "+parseFloat(a.toFixed(3))),this.nextLoadPosition=m.start+m.duration,this.state=O.FRAG_LOADING;var p;return d?p=d.then(function(T){return!T||u.fragContextChanged(T.frag)?null:u.doFragPartsLoad(e,m,r,o)}).catch(function(T){return u.handleFragLoadError(T)}):p=this.doFragPartsLoad(e,m,r,o).catch(function(T){return u.handleFragLoadError(T)}),this.hls.trigger(E.FRAG_LOADING,{frag:e,part:m,targetBufferTime:a}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):p}else if(!e.url||this.loadedEndOfParts(c,a))return Promise.resolve(null)}}if(we(e)&&this.loadingParts)this.log("LL-Part loading OFF after next part miss @"+a.toFixed(2)),this.loadingParts=!1;else if(!e.url)return Promise.resolve(null);this.log("Loading "+e.type+" sn: "+e.sn+" of "+this.fragInfo(e,!1)+") cc: "+e.cc+" "+(f?"["+f.startSN+"-"+f.endSN+"]":"")+", target: "+parseFloat(a.toFixed(3))),N(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=O.FRAG_LOADING;var y=this.config.progressive,S;return y&&d?S=d.then(function(T){return!T||u.fragContextChanged(T?.frag)?null:u.fragmentLoader.load(e,o)}).catch(function(T){return u.handleFragLoadError(T)}):S=Promise.all([this.fragmentLoader.load(e,y?o:void 0),d]).then(function(T){var x=T[0];return!y&&x&&o&&o(x),x}).catch(function(T){return u.handleFragLoadError(T)}),this.hls.trigger(E.FRAG_LOADING,{frag:e,targetBufferTime:a}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):S},i.doFragPartsLoad=function(e,r,a,o){var l=this;return new Promise(function(u,f){var d,h=[],v=(d=a.details)==null?void 0:d.partList,c=function(m){l.fragmentLoader.loadPart(e,m,o).then(function(p){h[m.index]=p;var y=p.part;l.hls.trigger(E.FRAG_LOADED,p);var S=Pi(a.details,e.sn,m.index+1)||Mi(v,e.sn,m.index+1);if(S)c(S);else return u({frag:e,part:y,partsLoaded:h})}).catch(f)};c(r)})},i.handleFragLoadError=function(e){if("data"in e){var r=e.data;e.data&&r.details===D.INTERNAL_ABORTED?this.handleFragLoadAborted(r.frag,r.part):this.hls.trigger(E.ERROR,r)}else this.hls.trigger(E.ERROR,{type:K.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null},i._handleTransmuxerFlush=function(e){var r=this.getCurrentContext(e);if(!r||this.state!==O.PARSING){!this.fragCurrent&&this.state!==O.STOPPED&&this.state!==O.ERROR&&(this.state=O.IDLE);return}var a=r.frag,o=r.part,l=r.level,u=self.performance.now();a.stats.parsing.end=u,o&&(o.stats.parsing.end=u);var f=this.getLevelDetails(),d=f&&a.sn>f.endSN,h=d||this.shouldLoadParts(f,a.end);h!==this.loadingParts&&(this.log("LL-Part loading "+(h?"ON":"OFF")+" after parsing segment ending @"+a.end.toFixed(2)),this.loadingParts=h),this.updateLevelTiming(a,o,l,e.partial)},i.shouldLoadParts=function(e,r){if(this.config.lowLatencyMode){if(!e)return this.loadingParts;if(e!=null&&e.partList){var a,o=e.partList[0],l=o.end+(((a=e.fragmentHint)==null?void 0:a.duration)||0);if(r>=l){var u,f=this.hls.hasEnoughToStart?((u=this.media)==null?void 0:u.currentTime)||this.lastCurrentTime:this.getLoadPosition();if(f>o.start-o.fragment.duration)return!0}}}return!1},i.getCurrentContext=function(e){var r=this.levels,a=this.fragCurrent,o=e.level,l=e.sn,u=e.part;if(!(r!=null&&r[o]))return this.warn("Levels object was unset while buffering fragment "+l+" of "+this.playlistLabel()+" "+o+". The current chunk will not be buffered."),null;var f=r[o],d=f.details,h=u>-1?Pi(d,l,u):null,v=h?h.fragment:is(d,l,a);return v?(a&&a!==v&&(v.stats=a.stats),{frag:v,part:h,level:f}):null},i.bufferFragmentData=function(e,r,a,o,l){var u;if(!(!e||this.state!==O.PARSING)){var f=e.data1,d=e.data2,h=f;if(f&&d&&(h=ke(f,d)),!!((u=h)!=null&&u.length)){var v={type:e.type,frag:r,part:a,chunkMeta:o,parent:r.type,data:h};if(this.hls.trigger(E.BUFFER_APPENDING,v),e.dropped&&e.independent&&!a){if(l)return;this.flushBufferGap(r)}}}},i.flushBufferGap=function(e){var r=this.media;if(r){if(!$.isBuffered(r,r.currentTime)){this.flushMainBuffer(0,e.start);return}var a=r.currentTime,o=$.bufferInfo(r,a,0),l=e.duration,u=Math.min(this.config.maxFragLookUpTolerance*2,l*.25),f=Math.max(Math.min(e.start-u,o.end-u),a+u);e.start-f>u&&this.flushMainBuffer(f,e.start)}},i.getFwdBufferInfo=function(e,r){var a,o=this.getLoadPosition();if(!N(o))return null;var l=this.lastCurrentTime>o,u=l||(a=this.media)!=null&&a.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(e,o,r,u)},i.getFwdBufferInfoAtPos=function(e,r,a,o){var l=$.bufferInfo(e,r,o);if(l.len===0&&l.nextStart!==void 0){var u=this.fragmentTracker.getBufferedFrag(r,a);if(u&&(l.nextStart<=u.end||u.gap)){var f=Math.max(Math.min(l.nextStart,u.end)-r,o);return $.bufferInfo(e,r,f)}}return l},i.getMaxBufferLength=function(e){var r=this.config,a;return e?a=Math.max(8*r.maxBufferSize/e,r.maxBufferLength):a=r.maxBufferLength,Math.min(a,r.maxMaxBufferLength)},i.reduceMaxBufferLength=function(e,r){var a=this.config,o=Math.max(Math.min(e-r,a.maxBufferLength),r),l=Math.max(e-r*3,a.maxMaxBufferLength/2,o);return l>=o?(a.maxMaxBufferLength=l,this.warn("Reduce max buffer length to "+l+"s"),!0):!1},i.getAppendedFrag=function(e,r){var a;r===void 0&&(r=W.MAIN);var o=(a=this.fragmentTracker)==null?void 0:a.getAppendedFrag(e,r);return o&&"fragment"in o?o.fragment:o},i.getNextFragment=function(e,r){var a=r.fragments,o=a.length;if(!o)return null;var l=this.config,u=a[0].start,f=l.lowLatencyMode&&!!r.partList,d=null;if(r.live){var h=l.initialLiveManifestSize;if(o<h)return this.warn("Not enough fragments to start playback (have: "+o+", need: "+h+")"),null;if(!r.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||e<u){var v;f&&!this.loadingParts&&(this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0),d=this.getInitialLiveFragment(r,a);var c=this.hls.startPosition,g=this.hls.liveSyncPosition,m=d?(c!==-1&&c>=u?c:g)||d.start:e;this.log("Setting startPosition to "+m+" to match start frag at live edge. mainStart: "+c+" liveSyncPosition: "+g+" frag.start: "+((v=d)==null?void 0:v.start)),this.startPosition=this.nextLoadPosition=m}}else e<=u&&(d=a[0]);if(!d){var p=this.loadingParts?r.partEnd:r.fragmentEnd;d=this.getFragmentAtPosition(e,p,r)}var y=this.filterReplacedPrimary(d,r);if(!y&&d){var S=d.sn-r.startSN;y=this.filterReplacedPrimary(a[S+1]||null,r)}return this.mapToInitFragWhenRequired(y)},i.isLoopLoading=function(e,r){var a=this.fragmentTracker.getState(e);return(a===Le.OK||a===Le.PARTIAL&&!!e.gap)&&this.nextLoadPosition>r},i.getNextFragmentLoopLoading=function(e,r,a,o,l){var u=null;if(e.gap&&(u=this.getNextFragment(this.nextLoadPosition,r),u&&!u.gap&&a.nextStart)){var f=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,a.nextStart,o,0);if(f!==null&&a.len+f.len>=l){var d=u.sn;return this.loopSn!==d&&(this.log('buffer full after gaps in "'+o+'" playlist starting at sn: '+d),this.loopSn=d),null}}return this.loopSn=void 0,u},i.filterReplacedPrimary=function(e,r){return e&&(gn(this.hls.config),e)},i.mapToInitFragWhenRequired=function(e){return e!=null&&e.initSegment&&!(e!=null&&e.initSegment.data)&&!this.bitrateTest?e.initSegment:e},i.getNextPart=function(e,r,a){for(var o=-1,l=!1,u=!0,f=0,d=e.length;f<d;f++){var h=e[f];if(u=u&&!h.independent,o>-1&&a<h.start)break;var v=h.loaded;v?o=-1:(l||h.independent||u)&&h.fragment===r&&(o=f),l=v}return o},i.loadedEndOfParts=function(e,r){var a=e[e.length-1];return a&&r>a.start&&a.loaded},i.getInitialLiveFragment=function(e,r){var a=this.fragPrevious,o=null;if(a){if(e.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+a.programDateTime),o=Ca(r,a.endProgramDateTime,this.config.maxFragLookUpTolerance)),!o){var l=a.sn+1;if(l>=e.startSN&&l<=e.endSN){var u=r[l-e.startSN];a.cc===u.cc&&(o=u,this.log("Live playlist, switching playlist, load frag with next SN: "+o.sn))}o||(o=Ma(r,a.cc),o&&this.log("Live playlist, switching playlist, load frag with same CC: "+o.sn))}}else{var f=this.hls.liveSyncPosition;f!==null&&(o=this.getFragmentAtPosition(f,this.bitrateTest?e.fragmentEnd:e.edge,e))}return o},i.getFragmentAtPosition=function(e,r,a){var o=this.config,l=this.fragPrevious,u=a.fragments,f=a.endSN,d=a.fragmentHint,h=o.maxFragLookUpTolerance,v=a.partList,c=!!(this.loadingParts&&v!=null&&v.length&&d);c&&d&&!this.bitrateTest&&v[v.length-1].fragment.sn===d.sn&&(u=u.concat(d),f=d.sn);var g;if(e<r){var m,p=e<this.lastCurrentTime,y=p||e>r-h||(m=this.media)!=null&&m.paused||!this.startFragRequested?0:h;g=er(l,u,e,y)}else g=u[u.length-1];if(g){var S=g.sn-a.startSN,T=this.fragmentTracker.getState(g);if((T===Le.OK||T===Le.PARTIAL&&g.gap)&&(l=g),l&&g.sn===l.sn&&(!c||v[0].fragment.sn>g.sn||!a.live&&!c)){var x=l&&g.level===l.level;if(x){var R=u[S+1];g.sn<f&&this.fragmentTracker.getState(R)!==Le.OK?g=R:g=null}}}return g},i.alignPlaylists=function(e,r,a){var o=e.fragments.length;if(!o)return this.warn("No fragments in live playlist"),0;var l=e.fragmentStart,u=!r,f=e.alignedSliding&&N(l);if(u||!f&&!l){Ro(a,e);var d=e.fragmentStart;return this.log("Live playlist sliding: "+d.toFixed(2)+" start-sn: "+(r?r.startSN:"na")+"->"+e.startSN+" fragments: "+o),d}return l},i.waitForCdnTuneIn=function(e){var r=3;return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,e.partTarget*r)},i.setStartPosition=function(e,r){var a=this.startPosition;a<r&&(a=-1);var o=this.timelineOffset;if(a===-1){var l=this.startTimeOffset!==null,u=l?this.startTimeOffset:e.startTimeOffset;u!==null&&N(u)?(a=r+u,u<0&&(a+=e.edge),a=Math.min(Math.max(r,a),r+e.totalduration),this.log("Setting startPosition to "+a+" for start time offset "+u+" found in "+(l?"multivariant":"media")+" playlist"),this.startPosition=a):e.live?(a=this.hls.liveSyncPosition||r,this.log("Setting startPosition to -1 to start at live edge "+a),this.startPosition=-1):(this.log("setting startPosition to 0 by default"),this.startPosition=a=0),this.lastCurrentTime=a+o}this.nextLoadPosition=a+o},i.getLoadPosition=function(){var e,r=this.media,a=0;return(e=this.hls)!=null&&e.hasEnoughToStart&&r?a=r.currentTime:this.nextLoadPosition>=0&&(a=this.nextLoadPosition),a},i.handleFragLoadAborted=function(e,r){this.transmuxer&&e.type===this.playlistType&&we(e)&&e.stats.aborted&&(this.warn("Fragment "+e.sn+(r?" part "+r.index:"")+" of "+this.playlistLabel()+" "+e.level+" was aborted"),this.resetFragmentLoading(e))},i.resetFragmentLoading=function(e){(!this.fragCurrent||!this.fragContextChanged(e)&&this.state!==O.FRAG_LOADING_WAITING_RETRY)&&(this.state=O.IDLE)},i.onFragmentOrKeyLoadError=function(e,r){if(r.chunkMeta&&!r.frag){var a=this.getCurrentContext(r.chunkMeta);a&&(r.frag=a.frag)}var o=r.frag;if(!(!o||o.type!==e||!this.levels)){if(this.fragContextChanged(o)){var l;this.warn("Frag load error must match current frag to retry "+o.url+" > "+((l=this.fragCurrent)==null?void 0:l.url));return}var u=r.details===D.FRAG_GAP;u&&this.fragmentTracker.fragBuffered(o,!0);var f=r.errorAction,d=f||{},h=d.action,v=d.flags,c=d.retryCount,g=c===void 0?0:c,m=d.retryConfig,p=!!f&&!!m,y=p&&h===pe.RetryRequest,S=p&&!f.resolved&&v===Pe.MoveAllAlternatesMatchingHost;if(!y&&S&&we(o)&&!o.endList)this.resetFragmentErrors(e),this.treatAsGap(o),f.resolved=!0;else if((y||S)&&g<m.maxNumRetry){this.resetStartWhenNotLoaded(this.levelLastLoaded);var T=tr(m,g);this.warn("Fragment "+o.sn+" of "+e+" "+o.level+" errored with "+r.details+", retrying loading "+(g+1)+"/"+m.maxNumRetry+" in "+T+"ms"),f.resolved=!0,this.retryDate=self.performance.now()+T,this.state=O.FRAG_LOADING_WAITING_RETRY}else if(m&&f)if(this.resetFragmentErrors(e),g<m.maxNumRetry)!u&&h!==pe.RemoveAlternatePermanently&&(f.resolved=!0);else{this.warn(r.details+" reached or exceeded max retry ("+g+")");return}else h===pe.SendAlternateToPenaltyBox?this.state=O.WAITING_LEVEL:this.state=O.ERROR;this.tickImmediate()}},i.reduceLengthAndFlushBuffer=function(e){if(this.state===O.PARSING||this.state===O.PARSED){var r=e.frag,a=e.parent,o=this.getFwdBufferInfo(this.mediaBuffer,a),l=o&&o.len>.5;l&&this.reduceMaxBufferLength(o.len,r?.duration||10);var u=!l;return u&&this.warn("Buffer full error while media.currentTime is not buffered, flush "+a+" buffer"),r&&(this.fragmentTracker.removeFragment(r),this.nextLoadPosition=r.start),this.resetLoadingState(),u}return!1},i.resetFragmentErrors=function(e){e===W.AUDIO&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==O.STOPPED&&(this.state=O.IDLE)},i.afterBufferFlushed=function(e,r,a){if(e){var o=$.getBuffered(e);this.fragmentTracker.detectEvictedFragments(r,o,a),this.state===O.ENDED&&this.resetLoadingState()}},i.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==O.STOPPED&&(this.state=O.IDLE)},i.resetStartWhenNotLoaded=function(e){if(!this.hls.hasEnoughToStart){this.startFragRequested=!1;var r=e?e.details:null;r!=null&&r.live?(this.log("resetting startPosition for live start"),this.startPosition=-1,this.setStartPosition(r,r.fragmentStart),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},i.resetWhenMissingContext=function(e){this.warn("The loading context changed while buffering fragment "+e.sn+" of "+this.playlistLabel()+" "+e.level+". This chunk will not be buffered."),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()},i.removeUnbufferedFrags=function(e){e===void 0&&(e=0),this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)},i.updateLevelTiming=function(e,r,a,o){var l=this,u=a.details;if(!u){this.warn("level.details undefined");return}var f=Object.keys(e.elementaryStreams).reduce(function(v,c){var g=e.elementaryStreams[c];if(g){var m=g.endPTS-g.startPTS;if(m<=0)return l.warn("Could not parse fragment "+e.sn+" "+c+" duration reliably ("+m+")"),v||!1;var p=o?0:_i(u,e,g.startPTS,g.endPTS,g.startDTS,g.endDTS);return l.hls.trigger(E.LEVEL_PTS_UPDATED,{details:u,level:a,drift:p,type:c,frag:e,start:g.startPTS,end:g.endPTS}),!0}return v},!1);if(!f){var d;if(a.fragmentError===0&&this.treatAsGap(e,a),((d=this.transmuxer)==null?void 0:d.error)===null){var h=new Error("Found no media in fragment "+e.sn+" of "+this.playlistLabel()+" "+e.level+" resetting transmuxer to fallback to playlist timing");if(this.warn(h.message),this.hls.trigger(E.ERROR,{type:K.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,error:h,frag:e,reason:"Found no media in msn "+e.sn+" of "+this.playlistLabel()+' "'+a.url+'"'}),!this.hls)return;this.resetTransmuxer()}}this.state=O.PARSED,this.log("Parsed "+e.type+" sn: "+e.sn+(r?" part: "+r.index:"")+" of "+this.fragInfo(e,!1,r)+")"),this.hls.trigger(E.FRAG_PARSED,{frag:e,part:r})},i.playlistLabel=function(){return this.playlistType===W.MAIN?"level":"track"},i.fragInfo=function(e,r,a){var o,l;return r===void 0&&(r=!0),this.playlistLabel()+" "+e.level+" ("+(a?"part":"frag")+":["+((o=r&&!a?e.startPTS:(a||e).start)!=null?o:NaN).toFixed(3)+"-"+((l=r&&!a?e.endPTS:(a||e).end)!=null?l:NaN).toFixed(3)+"]"+(a&&e.type==="main"?"INDEPENDENT="+(a.independent?"YES":"NO"):"")},i.treatAsGap=function(e,r){r&&r.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)},i.resetTransmuxer=function(){var e;(e=this.transmuxer)==null||e.reset()},i.recoverWorkerError=function(e){e.event==="demuxerWorker"&&(this.fragmentTracker.removeAllFragments(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())},te(s,[{key:"startPositionValue",get:function(){var e=this.nextLoadPosition,r=this.startPosition;return r===-1&&e?e:r}},{key:"bufferingEnabled",get:function(){return this.buffering}},{key:"inFlightFrag",get:function(){return{frag:this.fragCurrent,state:this.state}}},{key:"timelineOffset",get:function(){var e=this.config.timelineOffset;if(e){var r;return((r=this.getLevelDetails())==null?void 0:r.appliedTimelineOffset)||e}return 0}},{key:"primaryPrefetch",get:function(){return gn(this.hls.config),!1}},{key:"state",get:function(){return this._state},set:function(e){var r=this._state;r!==e&&(this._state=e,this.log(r+"->"+e))}}])}(dn);function gn(n){return!1}function ft(n,s,i){et(n,s,i),n.addEventListener(s,i)}function et(n,s,i){n.removeEventListener(s,i)}var Pt=2,Co=.1,ko=.05,Po=100,Mo=function(n){function s(t,e){var r;return r=n.call(this,"gap-controller",t.logger)||this,r.hls=null,r.fragmentTracker=null,r.media=null,r.mediaSource=void 0,r.nudgeRetry=0,r.stallReported=!1,r.stalled=null,r.moved=!1,r.seeking=!1,r.buffered={},r.lastCurrentTime=0,r.ended=0,r.waiting=0,r.onMediaPlaying=function(){r.ended=0,r.waiting=0},r.onMediaWaiting=function(){var a;(a=r.media)!=null&&a.seeking||(r.waiting=self.performance.now(),r.tick())},r.onMediaEnded=function(){if(r.hls){var a;r.ended=((a=r.media)==null?void 0:a.currentTime)||1,r.hls.trigger(E.MEDIA_ENDED,{stalled:!1})}},r.hls=t,r.fragmentTracker=e,r.registerListeners(),r}he(s,n);var i=s.prototype;return i.registerListeners=function(){var e=this.hls;e&&(e.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.BUFFER_APPENDED,this.onBufferAppended,this))},i.unregisterListeners=function(){var e=this.hls;e&&(e.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.BUFFER_APPENDED,this.onBufferAppended,this))},i.destroy=function(){n.prototype.destroy.call(this),this.unregisterListeners(),this.media=this.hls=this.fragmentTracker=null,this.mediaSource=void 0},i.onMediaAttached=function(e,r){this.setInterval(Po),this.mediaSource=r.mediaSource;var a=this.media=r.media;ft(a,"playing",this.onMediaPlaying),ft(a,"waiting",this.onMediaWaiting),ft(a,"ended",this.onMediaEnded)},i.onMediaDetaching=function(e,r){this.clearInterval();var a=this.media;a&&(et(a,"playing",this.onMediaPlaying),et(a,"waiting",this.onMediaWaiting),et(a,"ended",this.onMediaEnded),this.media=null),this.mediaSource=void 0},i.onBufferAppended=function(e,r){this.buffered=r.timeRanges},i.tick=function(){var e;if(!(!((e=this.media)!=null&&e.readyState)||!this.hasBuffered)){var r=this.media.currentTime;this.poll(r,this.lastCurrentTime),this.lastCurrentTime=r}},i.poll=function(e,r){var a,o,l=(a=this.hls)==null?void 0:a.config;if(l){var u=this.media,f=this.stalled;if(u){var d=u.seeking,h=this.seeking&&!d,v=!this.seeking&&d,c=u.paused&&!d||u.ended||u.playbackRate===0;if(this.seeking=d,e!==r){r&&(this.ended=0),this.moved=!0,d||(this.nudgeRetry=0,l.nudgeOnVideoHole&&!c&&e>r&&this.nudgeOnVideoHole(e,r)),this.waiting===0&&this.stallResolved(e);return}if(v||h){h&&this.stallResolved(e);return}if(c){this.nudgeRetry=0,this.stallResolved(e),!this.ended&&u.ended&&this.hls&&(this.ended=e||1,this.hls.trigger(E.MEDIA_ENDED,{stalled:!1}));return}if(!$.getBuffered(u).length){this.nudgeRetry=0;return}var g=$.bufferInfo(u,e,0),m=g.nextStart||0,p=this.fragmentTracker;if(d&&p&&this.hls){var y=mn(this.hls.inFlightFragments,e),S=g.len>Pt,T=!m||y||m-e>Pt&&!p.getPartialFragment(e);if(S||T)return;this.moved=!1}var x=(o=this.hls)==null?void 0:o.latestLevelDetails;if(!this.moved&&this.stalled!==null&&p){var R=g.len>0;if(!R&&!m)return;var L=Math.max(m,g.start||0)-e,A=!!(x!=null&&x.live),C=A?x.targetduration*2:Pt,_=p.getPartialFragment(e);if(L>0&&(L<=C||_)){u.paused||this._trySkipBufferHole(_);return}}var b=l.detectStallWithCurrentTimeMs,I=self.performance.now(),k=this.waiting;if(f===null){k>0&&I-k<b?this.stalled=k:this.stalled=I;return}var w=I-f;if(!d&&(w>=b||k)&&this.hls){var M;if(((M=this.mediaSource)==null?void 0:M.readyState)==="ended"&&!(x!=null&&x.live)&&Math.abs(e-(x?.edge||0))<1){if(this.ended)return;this.ended=e||1,this.hls.trigger(E.MEDIA_ENDED,{stalled:!0});return}if(this._reportStall(g),!this.media||!this.hls)return}var P=$.bufferInfo(u,e,l.maxBufferHole);this._tryFixBufferStall(P,w)}}},i.stallResolved=function(e){var r=this.stalled;if(r&&this.hls&&(this.stalled=null,this.stallReported)){var a=self.performance.now()-r;this.log("playback not stuck anymore @"+e+", after "+Math.round(a)+"ms"),this.stallReported=!1,this.waiting=0,this.hls.trigger(E.STALL_RESOLVED,{})}},i.nudgeOnVideoHole=function(e,r){var a,o=this.buffered.video;if(this.hls&&this.media&&this.fragmentTracker&&(a=this.buffered.audio)!=null&&a.length&&o&&o.length>1&&e>o.end(0)){var l=$.bufferedInfo($.timeRangesToArray(this.buffered.audio),e,0);if(l.len>1&&r>=l.start){var u=$.timeRangesToArray(o),f=$.bufferedInfo(u,r,0).bufferedIndex;if(f>-1&&f<u.length-1){var d=$.bufferedInfo(u,e,0).bufferedIndex,h=u[f].end,v=u[f+1].start;if((d===-1||d>f)&&v-h<1&&e-h<2){var c=new Error("nudging playhead to flush pipeline after video hole. currentTime: "+e+" hole: "+h+" -> "+v+" buffered index: "+d);this.warn(c.message),this.media.currentTime+=1e-6;var g=this.fragmentTracker.getPartialFragment(e)||void 0,m=$.bufferInfo(this.media,e,0);this.hls.trigger(E.ERROR,{type:K.MEDIA_ERROR,details:D.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:c,reason:c.message,frag:g,buffer:m.len,bufferInfo:m})}}}}},i._tryFixBufferStall=function(e,r){var a,o,l=this.fragmentTracker,u=this.media,f=(a=this.hls)==null?void 0:a.config;if(!(!u||!l||!f)){var d=u.currentTime,h=(o=this.hls)==null?void 0:o.latestLevelDetails,v=l.getPartialFragment(d);if(v||h!=null&&h.live&&d<h.fragmentStart){var c=this._trySkipBufferHole(v);if(c||!this.media)return}var g=e.buffered;(g&&g.length>1&&e.len>f.maxBufferHole||e.nextStart&&e.nextStart-d<f.maxBufferHole)&&(r>f.highBufferWatchdogPeriod*1e3||this.waiting)&&(this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(e))}},i._reportStall=function(e){var r=this.hls,a=this.media,o=this.stallReported,l=this.stalled;if(!o&&l!==null&&a&&r){this.stallReported=!0;var u=new Error("Playback stalling at @"+a.currentTime+" due to low buffer ("+Te(e)+")");this.warn(u.message),r.trigger(E.ERROR,{type:K.MEDIA_ERROR,details:D.BUFFER_STALLED_ERROR,fatal:!1,error:u,buffer:e.len,bufferInfo:e,stalled:{start:l}})}},i._trySkipBufferHole=function(e){var r,a=this.fragmentTracker,o=this.media,l=(r=this.hls)==null?void 0:r.config;if(!o||!a||!l)return 0;var u=o.currentTime,f=$.bufferInfo(o,u,0),d=u<f.start?f.start:f.nextStart;if(d&&this.hls){var h=f.len<=l.maxBufferHole,v=f.len>0&&f.len<1&&o.readyState<3,c=d-u;if(c>0&&(h||v)){if(c>l.maxBufferHole){var g=!1;if(u===0){var m=a.getAppendedFrag(0,W.MAIN);m&&d<m.end&&(g=!0)}if(!g){var p=e||a.getAppendedFrag(u,W.MAIN);if(p){var y;if(!((y=this.hls.loadLevelObj)!=null&&y.details))return 0;var S=mn(this.hls.inFlightFragments,d);if(S)return 0;for(var T=!1,x=p.end;x<d;){var R=a.getPartialFragment(x);if(R)x+=R.duration;else{T=!0;break}}if(T)return 0}}}var L=Math.max(d+ko,u+Co);if(this.warn("skipping hole, adjusting currentTime from "+u+" to "+L),this.moved=!0,o.currentTime=L,!(e!=null&&e.gap)){var A=new Error("fragment loaded with buffer holes, seeking from "+u+" to "+L);this.hls.trigger(E.ERROR,{type:K.MEDIA_ERROR,details:D.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:A,reason:A.message,frag:e||void 0,buffer:f.len,bufferInfo:f})}return L}}return 0},i._tryNudgeBuffer=function(e){var r=this.hls,a=this.media,o=this.nudgeRetry,l=r?.config;if(!a||!l)return 0;var u=a.currentTime;if(this.nudgeRetry++,o<l.nudgeMaxRetry){var f=u+(o+1)*l.nudgeOffset,d=new Error("Nudging 'currentTime' from "+u+" to "+f);this.warn(d.message),a.currentTime=f,r.trigger(E.ERROR,{type:K.MEDIA_ERROR,details:D.BUFFER_NUDGE_ON_STALL,error:d,fatal:!1,buffer:e.len,bufferInfo:e})}else{var h=new Error("Playhead still not moving while enough data buffered @"+u+" after "+l.nudgeMaxRetry+" nudges");this.error(h.message),r.trigger(E.ERROR,{type:K.MEDIA_ERROR,details:D.BUFFER_STALLED_ERROR,error:h,fatal:!0,buffer:e.len,bufferInfo:e})}},te(s,[{key:"hasBuffered",get:function(){return Object.keys(this.buffered).length>0}}])}(dn);function mn(n,s){var i=pn(n.main);if(i&&i.start<=s)return i;var t=pn(n.audio);return t&&t.start<=s?t:null}function pn(n){if(!n)return null;switch(n.state){case O.IDLE:case O.STOPPED:case O.ENDED:case O.ERROR:return null}return n.frag}function Oo(n,s){var i;try{i=new Event("addtrack")}catch{i=document.createEvent("Event"),i.initEvent("addtrack",!1,!1)}i.track=n,s.dispatchEvent(i)}function wo(n,s){var i=n.mode;if(i==="disabled"&&(n.mode="hidden"),n.cues)for(var t=n.cues.length;t--;)s&&n.cues[t].removeEventListener("enter",s),n.removeCue(n.cues[t]);i==="disabled"&&(n.mode=i)}function Fo(n,s,i,t){var e=n.mode;if(e==="disabled"&&(n.mode="hidden"),n.cues&&n.cues.length>0)for(var r=Bo(n.cues,s,i),a=0;a<r.length;a++)(!t||t(r[a]))&&n.removeCue(r[a]);e==="disabled"&&(n.mode=e)}function No(n,s){if(s<=n[0].startTime)return 0;var i=n.length-1;if(s>n[i].endTime)return-1;for(var t=0,e=i,r;t<=e;)if(r=Math.floor((e+t)/2),s<n[r].startTime)e=r-1;else if(s>n[r].startTime&&t<i)t=r+1;else return r;return n[t].startTime-s<s-n[e].startTime?t:e}function Bo(n,s,i){var t=[],e=No(n,s);if(e>-1)for(var r=e,a=n.length;r<a;r++){var o=n[r];if(o.startTime>=s&&o.endTime<=i)t.push(o);else if(o.startTime>i)return t}return t}var Uo=.25;function yr(){if(!(typeof self>"u"))return self.VTTCue||self.TextTrackCue}function En(n,s,i,t,e){var r=new n(s,i,"");try{r.value=t,e&&(r.type=e)}catch{r=new n(s,i,Te(e?xe({type:e},t):t))}return r}var Mt=function(){var n=yr();try{n&&new n(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function Go(n){return Uint8Array.from(n.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var Ho=function(){function n(i){var t=this;this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=!0,this.onEventCueEnter=function(){t.hls&&t.hls.trigger(E.EVENT_CUE_ENTER,{})},this.hls=i,this._registerListeners()}var s=n.prototype;return s.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null},s._registerListeners=function(){var t=this.hls;t.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(E.MANIFEST_LOADING,this.onManifestLoading,this),t.on(E.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(E.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(E.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this)},s._unregisterListeners=function(){var t=this.hls;t.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(E.MANIFEST_LOADING,this.onManifestLoading,this),t.off(E.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(E.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(E.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this)},s.onMediaAttaching=function(t,e){var r;this.media=e.media,((r=e.overrides)==null?void 0:r.cueRemoval)===!1&&(this.removeCues=!1)},s.onMediaAttached=function(){var t=this.hls.latestLevelDetails;t&&this.updateDateRangeCues(t)},s.onMediaDetaching=function(t,e){this.media=null;var r=!!e.transferMedia;r||(this.id3Track&&(this.removeCues&&wo(this.id3Track,this.onEventCueEnter),this.id3Track=null),this.dateRangeCuesAppended={})},s.onManifestLoading=function(){this.dateRangeCuesAppended={}},s.createTrack=function(t){var e=this.getID3Track(t.textTracks);return e.mode="hidden",e},s.getID3Track=function(t){if(this.media){for(var e=0;e<t.length;e++){var r=t[e];if(r.kind==="metadata"&&r.label==="id3")return Oo(r,this.media),r}return this.media.addTextTrack("metadata","id3")}},s.onFragParsingMetadata=function(t,e){if(this.media){var r=this.hls.config,a=r.enableEmsgMetadataCues,o=r.enableID3MetadataCues;if(!(!a&&!o)){var l=e.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));var u=yr();if(u)for(var f=0;f<l.length;f++){var d=l[f].type;if(!(d===_e.emsg&&!a||!o)){var h=Ki(l[f].data);if(h){var v=l[f].pts,c=v+l[f].duration;c>Mt&&(c=Mt);var g=c-v;g<=0&&(c=v+Uo);for(var m=0;m<h.length;m++){var p=h[m];if(!Wi(p)){this.updateId3CueEnds(v,d);var y=En(u,v,c,p,d);y&&this.id3Track.addCue(y)}}}}}}}},s.updateId3CueEnds=function(t,e){var r,a=(r=this.id3Track)==null?void 0:r.cues;if(a)for(var o=a.length;o--;){var l=a[o];l.type===e&&l.startTime<t&&l.endTime===Mt&&(l.endTime=t)}},s.onBufferFlushing=function(t,e){var r=e.startOffset,a=e.endOffset,o=e.type,l=this.id3Track,u=this.hls;if(u){var f=u.config,d=f.enableEmsgMetadataCues,h=f.enableID3MetadataCues;if(l&&(d||h)){var v;o==="audio"?v=function(g){return g.type===_e.audioId3&&h}:o==="video"?v=function(g){return g.type===_e.emsg&&d}:v=function(g){return g.type===_e.audioId3&&h||g.type===_e.emsg&&d},Fo(l,r,a,v)}}},s.onLevelUpdated=function(t,e){var r=e.details;this.updateDateRangeCues(r,!0)},s.onLevelPtsUpdated=function(t,e){Math.abs(e.drift)>.01&&this.updateDateRangeCues(e.details)},s.updateDateRangeCues=function(t,e){var r=this;if(!(!this.media||!t.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)){var a=this.id3Track,o=t.dateRanges,l=Object.keys(o),u=this.dateRangeCuesAppended;if(a&&e){var f;if((f=a.cues)!=null&&f.length)for(var d=Object.keys(u).filter(function(y){return!l.includes(y)}),h=function(){var S=d[v],T=u[S].cues;delete u[S],Object.keys(T).forEach(function(x){try{var R=T[x];R.removeEventListener("enter",r.onEventCueEnter),a.removeCue(R)}catch{}})},v=d.length;v--;)h();else u=this.dateRangeCuesAppended={}}var c=t.fragments[t.fragments.length-1];if(!(l.length===0||!N(c?.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var g=yr(),m=function(){var S=l[p],T=o[S],x=T.startTime,R=u[S],L=R?.cues||{},A=R?.durationKnown||!1,C=Mt,_=T.duration,b=T.endDate;if(b&&_!==null)C=x+_,A=!0;else if(T.endOnNext&&!A){var I=l.reduce(function(G,z){if(z!==T.id){var q=o[z];if(q.class===T.class&&q.startDate>T.startDate&&(!G||T.startDate<G.startDate))return q}return G},null);I&&(C=I.startTime,A=!0)}for(var k=Object.keys(T.attr),w=0;w<k.length;w++){var M=k[w];if(Va(M)){var P=L[M];if(P)A&&!R.durationKnown?P.endTime=C:Math.abs(P.startTime-x)>.01&&(P.startTime=x,P.endTime=C);else if(g){var F=T.attr[M];Ka(M)&&(F=Go(F));var B={key:M,data:F},U=En(g,x,C,B,_e.dateRange);U&&(U.id=S,r.id3Track.addCue(U),L[M]=U)}}}u[S]={cues:L,dateRange:T,durationKnown:A}},p=0;p<l.length;p++)m()}}},n}(),Vo=function(){function n(i){var t=this;this.hls=void 0,this.config=void 0,this.media=null,this.currentTime=0,this.stallCount=0,this._latency=null,this._targetLatencyUpdated=!1,this.onTimeupdate=function(){var e=t.media,r=t.levelDetails;if(!(!e||!r)){t.currentTime=e.currentTime;var a=t.computeLatency();if(a!==null){t._latency=a;var o=t.config,l=o.lowLatencyMode,u=o.maxLiveSyncPlaybackRate;if(!(!l||u===1||!r.live)){var f=t.targetLatency;if(f!==null){var d=a-f,h=Math.min(t.maxLatency,f+r.targetduration),v=d<h;if(v&&d>.05&&t.forwardBufferLength>1){var c=Math.min(2,Math.max(1,u)),g=Math.round(2/(1+Math.exp(-.75*d-t.edgeStalled))*20)/20,m=Math.min(c,Math.max(1,g));t.changeMediaPlaybackRate(e,m)}else e.playbackRate!==1&&e.playbackRate!==0&&t.changeMediaPlaybackRate(e,1)}}}}},this.hls=i,this.config=i.config,this.registerListeners()}var s=n.prototype;return s.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null},s.registerListeners=function(){var t=this.hls;t&&(t.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(E.MANIFEST_LOADING,this.onManifestLoading,this),t.on(E.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(E.ERROR,this.onError,this))},s.unregisterListeners=function(){var t=this.hls;t&&(t.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(E.MANIFEST_LOADING,this.onManifestLoading,this),t.off(E.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(E.ERROR,this.onError,this))},s.onMediaAttached=function(t,e){this.media=e.media,this.media.addEventListener("timeupdate",this.onTimeupdate)},s.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null)},s.onManifestLoading=function(){this._latency=null,this.stallCount=0},s.onLevelUpdated=function(t,e){var r=e.details;r.advanced&&this.onTimeupdate(),!r.live&&this.media&&this.media.removeEventListener("timeupdate",this.onTimeupdate)},s.onError=function(t,e){var r;e.details===D.BUFFER_STALLED_ERROR&&(this.stallCount++,this.hls&&(r=this.levelDetails)!=null&&r.live&&this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency"))},s.changeMediaPlaybackRate=function(t,e){var r,a;t.playbackRate!==e&&((r=this.hls)==null||r.logger.debug("[latency-controller]: latency="+this.latency.toFixed(3)+", targetLatency="+((a=this.targetLatency)==null?void 0:a.toFixed(3))+", forwardBufferLength="+this.forwardBufferLength.toFixed(3)+": adjusting playback rate from "+t.playbackRate+" to "+e),t.playbackRate=e)},s.estimateLiveEdge=function(){var t=this.levelDetails;return t===null?null:t.edge+t.age},s.computeLatency=function(){var t=this.estimateLiveEdge();return t===null?null:t-this.currentTime},te(n,[{key:"levelDetails",get:function(){var t;return((t=this.hls)==null?void 0:t.latestLevelDetails)||null}},{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var t=this.config;if(t.liveMaxLatencyDuration!==void 0)return t.liveMaxLatencyDuration;var e=this.levelDetails;return e?t.liveMaxLatencyDurationCount*e.targetduration:0}},{key:"targetLatency",get:function(){var t=this.levelDetails;if(t===null||this.hls===null)return null;var e=t.holdBack,r=t.partHoldBack,a=t.targetduration,o=this.config,l=o.liveSyncDuration,u=o.liveSyncDurationCount,f=o.lowLatencyMode,d=this.hls.userConfig,h=f&&r||e;(this._targetLatencyUpdated||d.liveSyncDuration||d.liveSyncDurationCount||h===0)&&(h=l!==void 0?l:u*a);var v=a;return h+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,v)},set:function(t){this.stallCount=0,this.config.liveSyncDuration=t,this._targetLatencyUpdated=!0}},{key:"liveSyncPosition",get:function(){var t=this.estimateLiveEdge(),e=this.targetLatency;if(t===null||e===null)return null;var r=this.levelDetails;if(r===null)return null;var a=r.edge,o=t-e-this.edgeStalled,l=a-r.totalduration,u=a-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(l,o),u)}},{key:"drift",get:function(){var t=this.levelDetails;return t===null?1:t.drift}},{key:"edgeStalled",get:function(){var t=this.levelDetails;if(t===null)return 0;var e=(this.config.lowLatencyMode&&t.partTarget||t.targetduration)*3;return Math.max(t.age-e,0)}},{key:"forwardBufferLength",get:function(){var t=this.media,e=this.levelDetails;if(!t||!e)return 0;var r=t.buffered.length;return(r?t.buffered.end(r-1):e.edge)-this.currentTime}}])}(),Ko=function(n){function s(t,e){var r;return r=n.call(this,e,t.logger)||this,r.hls=void 0,r.canLoad=!1,r.timer=-1,r.hls=t,r}he(s,n);var i=s.prototype;return i.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},i.clearTimer=function(){this.timer!==-1&&(self.clearTimeout(this.timer),this.timer=-1)},i.startLoad=function(){this.canLoad=!0,this.loadPlaylist()},i.stopLoad=function(){this.canLoad=!1,this.clearTimer()},i.switchParams=function(e,r,a){var o=r?.renditionReports;if(o){for(var l=-1,u=0;u<o.length;u++){var f=o[u],d=void 0;try{d=new self.URL(f.URI,r.url).href}catch(p){this.warn("Could not construct new URL for Rendition Report: "+p),d=f.URI||""}if(d===e){l=u;break}else d===e.substring(0,d.length)&&(l=u)}if(l!==-1){var h=o[l],v=parseInt(h["LAST-MSN"])||r?.lastPartSn,c=parseInt(h["LAST-PART"])||r?.lastPartIndex;if(this.hls.config.lowLatencyMode){var g=Math.min(r.age-r.partTarget,r.targetduration);c>=0&&g>r.partTarget&&(c+=1)}var m=a&&ti(a);return new ri(v,c>=0?c:void 0,m)}}},i.loadPlaylist=function(e){this.clearTimer()},i.loadingPlaylist=function(e,r){this.clearTimer()},i.shouldLoadPlaylist=function(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)},i.getUrlWithDirectives=function(e,r){if(r)try{return r.addDirectives(e)}catch(a){this.warn("Could not construct new URL with HLS Delivery Directives: "+a)}return e},i.playlistLoaded=function(e,r,a){var o=r.details,l=r.stats,u=self.performance.now(),f=l.loading.first?Math.max(0,u-l.loading.first):0;o.advancedDateTime=Date.now()-f;var d=this.hls.config.timelineOffset;if(d!==o.appliedTimelineOffset){var h=Math.max(d||0,0);o.appliedTimelineOffset=h,o.fragments.forEach(function(G){G.start=G.playlistOffset+h})}if(o.live||a!=null&&a.live){var v="levelInfo"in r?r.levelInfo:r.track;if(o.reloaded(a),a&&o.fragments.length>0){Za(a,o);var c=o.playlistParsingError;if(c){this.warn(c);var g=this.hls;if(!g.config.ignorePlaylistParsingErrors){var m,p=r.networkDetails;g.trigger(E.ERROR,{type:K.NETWORK_ERROR,details:D.LEVEL_PARSING_ERROR,fatal:!1,url:o.url,error:c,reason:c.message,level:r.level||void 0,parent:(m=o.fragments[0])==null?void 0:m.type,networkDetails:p,stats:l});return}o.playlistParsingError=null}}o.requestScheduled===-1&&(o.requestScheduled=l.loading.start);var y=this.hls.mainForwardBufferInfo,S=y?y.end-y.len:0,T=(o.edge-S)*1e3,x=ki(o,T);if(o.requestScheduled+x<u?o.requestScheduled=u:o.requestScheduled+=x,this.log("live playlist "+e+" "+(o.advanced?"REFRESHED "+o.lastPartSn+"-"+o.lastPartIndex:o.updated?"UPDATED":"MISSED")),!this.canLoad||!o.live)return;var R,L=void 0,A=void 0;if(o.canBlockReload&&o.endSN&&o.advanced){var C=this.hls.config.lowLatencyMode,_=o.lastPartSn,b=o.endSN,I=o.lastPartIndex,k=I!==-1,w=_===b;k?w?(L=b+1,A=C?0:I):(L=_,A=C?I+1:o.maxPartIndex):L=b+1;var M=o.age,P=M+o.ageHeader,F=Math.min(P-o.partTarget,o.targetduration*1.5);if(F>0){if(P>o.targetduration*3)this.log("Playlist last advanced "+M.toFixed(2)+"s ago. Omitting segment and part directives."),L=void 0,A=void 0;else if(a!=null&&a.tuneInGoal&&P-o.partTarget>a.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+a.tuneInGoal+" to: "+F+" with playlist age: "+o.age),F=0;else{var B=Math.floor(F/o.targetduration);if(L+=B,A!==void 0){var U=Math.round(F%o.targetduration/o.partTarget);A+=U}this.log("CDN Tune-in age: "+o.ageHeader+"s last advanced "+M.toFixed(2)+"s goal: "+F+" skip sn "+B+" to part "+A)}o.tuneInGoal=F}if(R=this.getDeliveryDirectives(o,r.deliveryDirectives,L,A),C||!w){o.requestScheduled=u,this.loadingPlaylist(v,R);return}}else(o.canBlockReload||o.canSkipUntil)&&(R=this.getDeliveryDirectives(o,r.deliveryDirectives,L,A));R&&L!==void 0&&o.canBlockReload&&(o.requestScheduled=l.loading.first+Math.max(x-f*2,x/2)),this.scheduleLoading(v,R,o)}else this.clearTimer()},i.scheduleLoading=function(e,r,a){var o=this,l=a||e.details;if(!l){this.loadingPlaylist(e,r);return}var u=self.performance.now(),f=l.requestScheduled;if(u>=f){this.loadingPlaylist(e,r);return}var d=f-u;this.log("reload live playlist "+(e.name||e.bitrate+"bps")+" in "+Math.round(d)+" ms"),this.clearTimer(),this.timer=self.setTimeout(function(){return o.loadingPlaylist(e,r)},d)},i.getDeliveryDirectives=function(e,r,a,o){var l=ti(e);return r!=null&&r.skip&&e.deltaUpdateFailed&&(a=r.msn,o=r.part,l=Tt.No),new ri(a,o,l)},i.checkRetry=function(e){var r=this,a=e.details,o=St(e),l=e.errorAction,u=l||{},f=u.action,d=u.retryCount,h=d===void 0?0:d,v=u.retryConfig,c=!!l&&!!v&&(f===pe.RetryRequest||!l.resolved&&f===pe.SendAlternateToPenaltyBox);if(c){var g;if(h>=v.maxNumRetry)return!1;if(o&&(g=e.context)!=null&&g.deliveryDirectives)this.warn("Retrying playlist loading "+(h+1)+"/"+v.maxNumRetry+' after "'+a+'" without delivery-directives'),this.loadPlaylist();else{var m=tr(v,h);this.clearTimer(),this.timer=self.setTimeout(function(){return r.loadPlaylist()},m),this.warn("Retrying playlist loading "+(h+1)+"/"+v.maxNumRetry+' after "'+a+'" in '+m+"ms")}e.levelRetry=!0,l.resolved=!0}return c},s}($e),Wo=function(n){function s(t,e){var r;return r=n.call(this,t,"level-controller")||this,r._levels=[],r._firstLevel=-1,r._maxAutoLevel=-1,r._startLevel=void 0,r.currentLevel=null,r.currentLevelIndex=-1,r.manualLevelIndex=-1,r.steering=void 0,r.onParsedComplete=void 0,r.steering=e,r._registerListeners(),r}he(s,n);var i=s.prototype;return i._registerListeners=function(){var e=this.hls;e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(E.LEVEL_LOADED,this.onLevelLoaded,this),e.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this),e.on(E.ERROR,this.onError,this)},i._unregisterListeners=function(){var e=this.hls;e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(E.LEVEL_LOADED,this.onLevelLoaded,this),e.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this),e.off(E.ERROR,this.onError,this)},i.destroy=function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),n.prototype.destroy.call(this)},i.stopLoad=function(){var e=this._levels;e.forEach(function(r){r.loadError=0,r.fragmentError=0}),n.prototype.stopLoad.call(this)},i.resetLevels=function(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1},i.onManifestLoading=function(e,r){this.resetLevels()},i.onManifestLoaded=function(e,r){var a=this,o=this.hls.config.preferManagedMediaSource,l=[],u={},f={},d=!1,h=!1,v=!1;r.levels.forEach(function(c){var g,m=c.attrs,p=c.audioCodec,y=c.videoCodec;p&&(c.audioCodec=p=pt(p,o)||void 0),((g=y)==null?void 0:g.indexOf("avc1"))===0&&(y=c.videoCodec=ya(y));var S=c.width,T=c.height,x=c.unknownCodecs,R=x?x.length:0;if(x)for(var L=R;L--;){var A=x[L];a.isAudioSupported(A)?(c.audioCodec=p=p?p+","+A:A,R--,ze.audio[p.substring(0,4)]=2):a.isVideoSupported(A)&&(c.videoCodec=y=y?y+","+A:A,R--,ze.video[y.substring(0,4)]=2)}if(d||(d=!!(S&&T)),h||(h=!!y),v||(v=!!p),R||p&&!a.isAudioSupported(p)||y&&!a.isVideoSupported(y)){a.log('Some or all CODECS not supported "'+m.CODECS+'"');return}var C=m.CODECS,_=m["FRAME-RATE"],b=m["HDCP-LEVEL"],I=m["PATHWAY-ID"],k=m.RESOLUTION,w=m["VIDEO-RANGE"],M=(I||".")+"-",P=""+M+c.bitrate+"-"+k+"-"+_+"-"+C+"-"+w+"-"+b;if(u[P])if(u[P].uri!==c.url&&!c.attrs["PATHWAY-ID"]){var B=f[P]+=1;c.attrs["PATHWAY-ID"]=new Array(B+1).join(".");var U=a.createLevel(c);u[P]=U,l.push(U)}else u[P].addGroupId("audio",m.AUDIO),u[P].addGroupId("text",m.SUBTITLES);else{var F=a.createLevel(c);u[P]=F,f[P]=1,l.push(F)}}),this.filterAndSortMediaOptions(l,r,d,h,v)},i.createLevel=function(e){var r=new ii(e),a=e.supplemental;if(a!=null&&a.videoCodec&&!this.isVideoSupported(a.videoCodec)){var o=new Error('SUPPLEMENTAL-CODECS not supported "'+a.videoCodec+'"');this.log(o.message),r.supportedResult=Nr.getUnsupportedResult(o,[])}return r},i.isAudioSupported=function(e){return Qt(e,"audio",this.hls.config.preferManagedMediaSource)},i.isVideoSupported=function(e){return Qt(e,"video",this.hls.config.preferManagedMediaSource)},i.filterAndSortMediaOptions=function(e,r,a,o,l){var u=this,f=[],d=[],h=e;if((a||o)&&l&&(h=h.filter(function(L){var A=L.videoCodec,C=L.videoRange,_=L.width,b=L.height;return(!!A||!!(_&&b))&&xa(C)})),h.length===0){Promise.resolve().then(function(){if(u.hls){var L="no level with compatible codecs found in manifest",A=L;r.levels.length&&(A="one or more CODECS in variant not supported: "+Te(r.levels.map(function(_){return _.attrs.CODECS}).filter(function(_,b,I){return I.indexOf(_)===b})),u.warn(A),L+=" ("+A+")");var C=new Error(L);u.hls.trigger(E.ERROR,{type:K.MEDIA_ERROR,details:D.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:r.url,error:C,reason:A})}});return}r.audioTracks&&(f=r.audioTracks.filter(function(L){return!L.audioCodec||u.isAudioSupported(L.audioCodec)}),yn(f)),r.subtitles&&(d=r.subtitles,yn(d));var v=h.slice(0);h.sort(function(L,A){if(L.attrs["HDCP-LEVEL"]!==A.attrs["HDCP-LEVEL"])return(L.attrs["HDCP-LEVEL"]||"")>(A.attrs["HDCP-LEVEL"]||"")?1:-1;if(a&&L.height!==A.height)return L.height-A.height;if(L.frameRate!==A.frameRate)return L.frameRate-A.frameRate;if(L.videoRange!==A.videoRange)return yt.indexOf(L.videoRange)-yt.indexOf(A.videoRange);if(L.videoCodec!==A.videoCodec){var C=Zr(L.videoCodec),_=Zr(A.videoCodec);if(C!==_)return _-C}if(L.uri===A.uri&&L.codecSet!==A.codecSet){var b=mt(L.codecSet),I=mt(A.codecSet);if(b!==I)return I-b}return L.averageBitrate!==A.averageBitrate?L.averageBitrate-A.averageBitrate:0});var c=v[0];if(this.steering&&(h=this.steering.filterParsedLevels(h),h.length!==v.length)){for(var g=0;g<v.length;g++)if(v[g].pathwayId===h[0].pathwayId){c=v[g];break}}this._levels=h;for(var m=0;m<h.length;m++)if(h[m]===c){var p;this._firstLevel=m;var y=c.bitrate,S=this.hls.bandwidthEstimate;if(this.log("manifest loaded, "+h.length+" level(s) found, first bitrate: "+y),((p=this.hls.userConfig)==null?void 0:p.abrEwmaDefaultEstimate)===void 0){var T=Math.min(y,this.hls.config.abrEwmaDefaultEstimateMax);T>S&&S===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=T)}break}var x=l&&!o,R={levels:h,audioTracks:f,subtitleTracks:d,sessionData:r.sessionData,sessionKeys:r.sessionKeys,firstLevel:this._firstLevel,stats:r.stats,audio:l,video:o,altAudio:!x&&f.some(function(L){return!!L.url})};this.hls.trigger(E.MANIFEST_PARSED,R)},i.onError=function(e,r){r.fatal||!r.context||r.context.type===j.LEVEL&&r.context.level===this.level&&this.checkRetry(r)},i.onFragBuffered=function(e,r){var a=r.frag;if(a!==void 0&&a.type===W.MAIN){var o=a.elementaryStreams;if(!Object.keys(o).some(function(u){return!!o[u]}))return;var l=this._levels[a.level];l!=null&&l.loadError&&(this.log("Resetting level error count of "+l.loadError+" on frag buffered"),l.loadError=0)}},i.onLevelLoaded=function(e,r){var a,o=r.level,l=r.details,u=r.levelInfo;if(!u){var f;this.warn("Invalid level index "+o),(f=r.deliveryDirectives)!=null&&f.skip&&(l.deltaUpdateFailed=!0);return}if(u===this.currentLevel||r.withoutMultiVariant){u.fragmentError===0&&(u.loadError=0);var d=u.details;d===r.details&&d.advanced&&(d=void 0),this.playlistLoaded(o,r,d)}else(a=r.deliveryDirectives)!=null&&a.skip&&(l.deltaUpdateFailed=!0)},i.loadPlaylist=function(e){n.prototype.loadPlaylist.call(this),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,e)},i.loadingPlaylist=function(e,r){n.prototype.loadingPlaylist.call(this,e,r);var a=this.getUrlWithDirectives(e.uri,r),o=this.currentLevelIndex,l=e.attrs["PATHWAY-ID"],u=e.details,f=u?.age;this.log("Loading level index "+o+(r?.msn!==void 0?" at sn "+r.msn+" part "+r.part:"")+(l?" Pathway "+l:"")+(f&&u.live?" age "+f.toFixed(1)+(u.type&&" "+u.type||""):"")+" "+a),this.hls.trigger(E.LEVEL_LOADING,{url:a,level:o,levelInfo:e,pathwayId:e.attrs["PATHWAY-ID"],id:0,deliveryDirectives:r||null})},i.removeLevel=function(e){var r=this,a;if(this._levels.length!==1){var o=this._levels.filter(function(u,f){return f!==e?!0:(r.steering&&r.steering.removeLevel(u),u===r.currentLevel&&(r.currentLevel=null,r.currentLevelIndex=-1,u.details&&u.details.fragments.forEach(function(d){return d.level=-1})),!1)});Oi(o),this._levels=o,this.currentLevelIndex>-1&&(a=this.currentLevel)!=null&&a.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.manualLevelIndex>-1&&(this.manualLevelIndex=this.currentLevelIndex);var l=o.length-1;this._firstLevel=Math.min(this._firstLevel,l),this._startLevel&&(this._startLevel=Math.min(this._startLevel,l)),this.hls.trigger(E.LEVELS_UPDATED,{levels:o})}},i.onLevelsUpdated=function(e,r){var a=r.levels;this._levels=a},i.checkMaxAutoUpdated=function(){var e=this.hls,r=e.autoLevelCapping,a=e.maxAutoLevel,o=e.maxHdcpLevel;this._maxAutoLevel!==a&&(this._maxAutoLevel=a,this.hls.trigger(E.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:r,levels:this.levels,maxAutoLevel:a,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:o}))},te(s,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"loadLevelObj",get:function(){return this.currentLevel}},{key:"level",get:function(){return this.currentLevelIndex},set:function(e){var r=this._levels;if(r.length!==0){if(e<0||e>=r.length){var a=new Error("invalid level idx"),o=e<0;if(this.hls.trigger(E.ERROR,{type:K.OTHER_ERROR,details:D.LEVEL_SWITCH_ERROR,level:e,fatal:o,error:a,reason:a.message}),o)return;e=Math.min(e,r.length-1)}var l=this.currentLevelIndex,u=this.currentLevel,f=u?u.attrs["PATHWAY-ID"]:void 0,d=r[e],h=d.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=d,!(l===e&&u&&f===h)){this.log("Switching to level "+e+" ("+(d.height?d.height+"p ":"")+(d.videoRange?d.videoRange+" ":"")+(d.codecSet?d.codecSet+" ":"")+"@"+d.bitrate+")"+(h?" with Pathway "+h:"")+" from level "+l+(f?" with Pathway "+f:""));var v={level:e,attrs:d.attrs,details:d.details,bitrate:d.bitrate,averageBitrate:d.averageBitrate,maxBitrate:d.maxBitrate,realBitrate:d.realBitrate,width:d.width,height:d.height,codecSet:d.codecSet,audioCodec:d.audioCodec,videoCodec:d.videoCodec,audioGroups:d.audioGroups,subtitleGroups:d.subtitleGroups,loaded:d.loaded,loadError:d.loadError,fragmentError:d.fragmentError,name:d.name,id:d.id,uri:d.uri,url:d.url,urlId:0,audioGroupIds:d.audioGroupIds,textGroupIds:d.textGroupIds};this.hls.trigger(E.LEVEL_SWITCHING,v);var c=d.details;if(!c||c.live){var g=this.switchParams(d.uri,u?.details,c);this.loadPlaylist(g)}}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(e){this.manualLevelIndex=e,this._startLevel===void 0&&(this._startLevel=e),e!==-1&&(this.level=e)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(e){this._firstLevel=e}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var e=this.hls.config.startLevel;return e!==void 0?e:this.hls.firstAutoLevel}return this._startLevel},set:function(e){this._startLevel=e}},{key:"pathways",get:function(){return this.steering?this.steering.pathways():[]}},{key:"pathwayPriority",get:function(){return this.steering?this.steering.pathwayPriority:null},set:function(e){if(this.steering){var r=this.steering.pathways(),a=e.filter(function(o){return r.indexOf(o)!==-1});if(e.length<1){this.warn("pathwayPriority "+e+" should contain at least one pathway from list: "+r);return}this.steering.pathwayPriority=a}}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(e){this.level=e,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=e)}}])}(Ko);function yn(n){var s={};n.forEach(function(i){var t=i.groupId||"";i.id=s[t]=s[t]||0,s[t]++})}var Tr=[];typeof oe<"u"&&oe&&Yo();function Yo(){self.addEventListener("message",function(n){var s=n.data,i=s.instanceNo;if(i!==void 0){var t=Tr[i];if(s.cmd==="reset"&&(delete Tr[s.resetNo],t&&t.destroy(),s.cmd="init"),s.cmd==="init"){var e=JSON.parse(s.config),r=new Gt;r.on(E.FRAG_DECRYPTED,tt),r.on(E.ERROR,tt);var a=wr(e.debug,s.id);qo(a,i),Tr[i]=new mr(r,s.typeSupported,e,"",s.id,a),tt("init",null,i);return}if(t)switch(s.cmd){case"configure":{t.configure(s.config);break}case"demux":{var o=t.push(s.data,s.decryptdata,s.chunkMeta,s.state);je(o)?o.then(function(f){Sr(self,f,i)}).catch(function(f){tt(E.ERROR,{instanceNo:i,type:K.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,chunkMeta:s.chunkMeta,fatal:!1,error:f,err:f,reason:"transmuxer-worker push error"},i)}):Sr(self,o,i);break}case"flush":{var l=s.chunkMeta,u=t.flush(l);je(u)?u.then(function(f){Sn(self,f,l,i)}).catch(function(f){tt(E.ERROR,{type:K.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,chunkMeta:s.chunkMeta,fatal:!1,error:f,err:f,reason:"transmuxer-worker flush error"},i)}):Sn(self,u,l,i);break}}}})}function Sr(n,s,i){if(jo(s.remuxResult))return!1;var t=[],e=s.remuxResult,r=e.audio,a=e.video;return r&&Tn(t,r),a&&Tn(t,a),n.postMessage({event:"transmuxComplete",data:s,instanceNo:i},t),!0}function Tn(n,s){s.data1&&n.push(s.data1.buffer),s.data2&&n.push(s.data2.buffer)}function Sn(n,s,i,t){var e=s.reduce(function(r,a){return Sr(n,a,t)||r},!1);e||n.postMessage({event:"transmuxComplete",data:s[0],instanceNo:t}),n.postMessage({event:"flush",data:i,instanceNo:t})}function tt(n,s,i){self.postMessage({event:n,data:s,instanceNo:i})}function qo(n,s){var i=function(r){var a=function(l){tt("workerLog",{logType:r,message:l},s)};n[r]=a};for(var t in n)i(t)}function jo(n){return!n.audio&&!n.video&&!n.text&&!n.id3&&!n.initSegment}var dt="1.6.0",rt={};function Xo(){return typeof se=="function"}function $o(){var n=rt[dt];if(n)return n.clientCount++,n;var s=new self.Blob(["var exports={};var module={exports:exports};function define(f){f()};define.amd=true;("+se.toString()+")(true);"],{type:"text/javascript"}),i=self.URL.createObjectURL(s),t=new self.Worker(i),e={worker:t,objectURL:i,clientCount:1};return rt[dt]=e,e}function zo(n){var s=rt[n];if(s)return s.clientCount++,s;var i=new self.URL(n,self.location.href).href,t=new self.Worker(i),e={worker:t,scriptURL:i,clientCount:1};return rt[n]=e,e}function Qo(n){var s=rt[n||dt];if(s){var i=s.clientCount--;if(i===1){var t=s.worker,e=s.objectURL;delete rt[n||dt],e&&self.URL.revokeObjectURL(e),t.terminate()}}}var xn=0,Zo=function(){function n(i,t,e,r){var a=this;this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=xn++,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.onWorkerMessage=function(v){var c=v.data,g=a.hls;if(!(!g||!(c!=null&&c.event)||c.instanceNo!==a.instanceNo))switch(c.event){case"init":{var m,p=(m=a.workerContext)==null?void 0:m.objectURL;p&&self.URL.revokeObjectURL(p);break}case"transmuxComplete":{a.handleTransmuxComplete(c.data);break}case"flush":{a.onFlush(c.data);break}case"workerLog":{g.logger[c.data.logType]&&g.logger[c.data.logType](c.data.message);break}default:{c.data=c.data||{},c.data.frag=a.frag,c.data.part=a.part,c.data.id=a.id,g.trigger(c.event,c.data);break}}},this.onWorkerError=function(v){if(a.hls){var c=new Error(v.message+" ("+v.filename+":"+v.lineno+")");a.hls.config.enableWorker=!1,a.hls.logger.warn('Error in "'+a.id+'" Web Worker, fallback to inline'),a.hls.trigger(E.ERROR,{type:K.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:c})}};var o=i.config;this.hls=i,this.id=t,this.useWorker=!!o.enableWorker,this.onTransmuxComplete=e,this.onFlush=r;var l=function(c,g){g=g||{},g.frag=a.frag||void 0,c===E.ERROR&&(g=g,g.parent=a.id,g.part=a.part,a.error=g.error),a.hls.trigger(c,g)};this.observer=new Gt,this.observer.on(E.FRAG_DECRYPTED,l),this.observer.on(E.ERROR,l);var u=Jr(o.preferManagedMediaSource);if(this.useWorker&&typeof Worker<"u"){var f=this.hls.logger,d=o.workerPath||Xo();if(d){try{o.workerPath?(f.log("loading Web Worker "+o.workerPath+' for "'+t+'"'),this.workerContext=zo(o.workerPath)):(f.log('injecting Web Worker for "'+t+'"'),this.workerContext=$o());var h=this.workerContext.worker;h.addEventListener("message",this.onWorkerMessage),h.addEventListener("error",this.onWorkerError),h.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:u,id:t,config:Te(o)})}catch(v){f.warn('Error setting up "'+t+'" Web Worker, fallback to inline',v),this.terminateWorker(),this.error=null,this.transmuxer=new mr(this.observer,u,o,"",t,i.logger)}return}}this.transmuxer=new mr(this.observer,u,o,"",t,i.logger)}var s=n.prototype;return s.reset=function(){if(this.frag=null,this.part=null,this.workerContext){var t=this.instanceNo;this.instanceNo=xn++;var e=this.hls.config,r=Jr(e.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:t,typeSupported:r,id:this.id,config:Te(e)})}},s.terminateWorker=function(){if(this.workerContext){var t=this.workerContext.worker;this.workerContext=null,t.removeEventListener("message",this.onWorkerMessage),t.removeEventListener("error",this.onWorkerError),Qo(this.hls.config.workerPath)}},s.destroy=function(){if(this.workerContext)this.terminateWorker(),this.onWorkerMessage=this.onWorkerError=null;else{var t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}var e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.part=null,this.observer=null,this.hls=null},s.push=function(t,e,r,a,o,l,u,f,d,h){var v,c,g=this;d.transmuxing.start=self.performance.now();var m=this.instanceNo,p=this.transmuxer,y=l?l.start:o.start,S=o.decryptdata,T=this.frag,x=!(T&&o.cc===T.cc),R=!(T&&d.level===T.level),L=T?d.sn-T.sn:-1,A=this.part?d.part-this.part.index:-1,C=L===0&&d.id>1&&d.id===T?.stats.chunkCount,_=!R&&(L===1||L===0&&(A===1||C&&A<=0)),b=self.performance.now();(R||L||o.stats.parsing.start===0)&&(o.stats.parsing.start=b),l&&(A||!_)&&(l.stats.parsing.start=b);var I=!(T&&((v=o.initSegment)==null?void 0:v.url)===((c=T.initSegment)==null?void 0:c.url)),k=new oo(x,_,f,R,y,I);if(!_||x||I){this.hls.logger.log("[transmuxer-interface]: Starting new transmux session for "+o.type+" sn: "+d.sn+(d.part>-1?" part: "+d.part:"")+" "+(this.id===W.MAIN?"level":"track")+": "+d.level+" id: "+d.id+`
23
- discontinuity: `+x+`
24
- trackSwitch: `+R+`
25
- contiguous: `+_+`
26
- accurateTimeOffset: `+f+`
27
- timeOffset: `+y+`
28
- initSegmentChange: `+I);var w=new so(r,a,e,u,h);this.configureTransmuxer(w)}if(this.frag=o,this.part=l,this.workerContext)this.workerContext.worker.postMessage({instanceNo:m,cmd:"demux",data:t,decryptdata:S,chunkMeta:d,state:k},t instanceof ArrayBuffer?[t]:[]);else if(p){var M=p.push(t,S,d,k);je(M)?M.then(function(P){g.handleTransmuxComplete(P)}).catch(function(P){g.transmuxerError(P,d,"transmuxer-interface push error")}):this.handleTransmuxComplete(M)}},s.flush=function(t){var e=this;t.transmuxing.start=self.performance.now();var r=this.instanceNo,a=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:r,cmd:"flush",chunkMeta:t});else if(a){var o=a.flush(t);je(o)?o.then(function(l){e.handleFlushResult(l,t)}).catch(function(l){e.transmuxerError(l,t,"transmuxer-interface flush error")}):this.handleFlushResult(o,t)}},s.transmuxerError=function(t,e,r){this.hls&&(this.error=t,this.hls.trigger(E.ERROR,{type:K.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,chunkMeta:e,frag:this.frag||void 0,part:this.part||void 0,fatal:!1,error:t,err:t,reason:r}))},s.handleFlushResult=function(t,e){var r=this;t.forEach(function(a){r.handleTransmuxComplete(a)}),this.onFlush(e)},s.configureTransmuxer=function(t){var e=this.instanceNo,r=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({instanceNo:e,cmd:"configure",config:t}):r&&r.configure(t)},s.handleTransmuxComplete=function(t){t.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(t)},n}();function Ln(){return self.SourceBuffer||self.WebKitSourceBuffer}function An(){var n=We();if(!n)return!1;var s=Ln();return!s||s.prototype&&typeof s.prototype.appendBuffer=="function"&&typeof s.prototype.remove=="function"}function Jo(){if(!An())return!1;var n=We();return typeof n?.isTypeSupported=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(function(s){return n.isTypeSupported(at(s,"video"))})||["mp4a.40.2","fLaC"].some(function(s){return n.isTypeSupported(at(s,"audio"))}))}function el(){var n,s=Ln();return typeof(s==null||(n=s.prototype)==null?void 0:n.changeType)=="function"}var tl=100,rl=function(n){function s(t,e,r){var a;return a=n.call(this,t,e,r,"stream-controller",W.MAIN)||this,a.audioCodecSwap=!1,a.level=-1,a._forceStartLoad=!1,a._hasEnoughToStart=!1,a.altAudio=0,a.audioOnly=!1,a.fragPlaying=null,a.fragLastKbps=0,a.couldBacktrack=!1,a.backtrackFragment=null,a.audioCodecSwitch=!1,a.videoBuffer=null,a.onMediaPlaying=function(){a.tick()},a.onMediaSeeked=function(){var o=a.media,l=o?o.currentTime:null;if(!(l===null||!N(l))&&(a.log("Media seeked to "+l.toFixed(3)),!!a.getBufferedFrag(l))){var u=a.getFwdBufferInfoAtPos(o,l,W.MAIN,0);if(u===null||u.len===0){a.warn("Main forward buffer length at "+l+' on "seeked" event '+(u?u.len:"empty")+")");return}a.tick()}},a.registerListeners(),a}he(s,n);var i=s.prototype;return i.registerListeners=function(){n.prototype.registerListeners.call(this);var e=this.hls;e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.LEVEL_LOADING,this.onLevelLoading,this),e.on(E.LEVEL_LOADED,this.onLevelLoaded,this),e.on(E.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(E.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(E.BUFFER_CREATED,this.onBufferCreated,this),e.on(E.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this)},i.unregisterListeners=function(){n.prototype.unregisterListeners.call(this);var e=this.hls;e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.LEVEL_LOADED,this.onLevelLoaded,this),e.off(E.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(E.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(E.BUFFER_CREATED,this.onBufferCreated,this),e.off(E.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this)},i.onHandlerDestroying=function(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),n.prototype.onHandlerDestroying.call(this)},i.startLoad=function(e,r){if(this.levels){var a=this.lastCurrentTime,o=this.hls;if(this.stopLoad(),this.setInterval(tl),this.level=-1,!this.startFragRequested){var l=o.startLevel;l===-1&&(o.config.testBandwidth&&this.levels.length>1?(l=0,this.bitrateTest=!0):l=o.firstAutoLevel),o.nextLoadLevel=l,this.level=o.loadLevel,this._hasEnoughToStart=!!r}a>0&&e===-1&&!r&&(this.log("Override startPosition with lastCurrentTime @"+a.toFixed(3)),e=a),this.state=O.IDLE,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=r?-1:e,this.tick()}else this._forceStartLoad=!0,this.state=O.STOPPED},i.stopLoad=function(){this._forceStartLoad=!1,n.prototype.stopLoad.call(this)},i.doTick=function(){switch(this.state){case O.WAITING_LEVEL:{var e=this.levels,r=this.level,a=e?.[r],o=a?.details;if(o&&(!o.live||this.levelLastLoaded===a&&!this.waitForLive(a))){if(this.waitForCdnTuneIn(o))break;this.state=O.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=O.IDLE;break}break}case O.FRAG_LOADING_WAITING_RETRY:{var l,u=self.performance.now(),f=this.retryDate;if(!f||u>=f||(l=this.media)!=null&&l.seeking){var d=this.levels,h=this.level,v=d?.[h];this.resetStartWhenNotLoaded(v||null),this.state=O.IDLE}}break}this.state===O.IDLE&&this.doTickIdle(),this.onTickEnd()},i.onTickEnd=function(){var e;n.prototype.onTickEnd.call(this),(e=this.media)!=null&&e.readyState&&this.media.seeking===!1&&(this.lastCurrentTime=this.media.currentTime),this.checkFragmentChanged()},i.doTickIdle=function(){var e=this.hls,r=this.levelLastLoaded,a=this.levels,o=this.media;if(!(r===null||!o&&!this.primaryPrefetch&&(this.startFragRequested||!e.config.startFragPrefetch))&&!(this.altAudio&&this.audioOnly)){var l=this.buffering?e.nextLoadLevel:e.loadLevel;if(a!=null&&a[l]){var u=a[l],f=this.getMainFwdBufferInfo();if(f!==null){var d=this.getLevelDetails();if(d&&this._streamEnded(f,d)){var h={};this.altAudio===2&&(h.type="video"),this.hls.trigger(E.BUFFER_EOS,h),this.state=O.ENDED;return}if(this.buffering){e.loadLevel!==l&&e.manualLevel===-1&&this.log("Adapting to level "+l+" from level "+this.level),this.level=e.nextLoadLevel=l;var v=u.details;if(!v||this.state===O.WAITING_LEVEL||this.waitForLive(u)){this.level=l,this.state=O.WAITING_LEVEL,this.startFragRequested=!1;return}var c=f.len,g=this.getMaxBufferLength(u.maxBitrate);if(!(c>=g)){this.backtrackFragment&&this.backtrackFragment.start>f.end&&(this.backtrackFragment=null);var m=this.backtrackFragment?this.backtrackFragment.start:f.end,p=this.getNextFragment(m,v);if(this.couldBacktrack&&!this.fragPrevious&&p&&we(p)&&this.fragmentTracker.getState(p)!==Le.OK){var y,S=((y=this.backtrackFragment)!=null?y:p).sn,T=S-v.startSN,x=v.fragments[T-1];x&&p.cc===x.cc&&(p=x,this.fragmentTracker.removeFragment(x))}else this.backtrackFragment&&f.len&&(this.backtrackFragment=null);if(p&&this.isLoopLoading(p,m)){var R=p.gap;if(!R){var L=this.audioOnly&&!this.altAudio?re.AUDIO:re.VIDEO,A=(L===re.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;A&&this.afterBufferFlushed(A,L,W.MAIN)}p=this.getNextFragmentLoopLoading(p,v,f,W.MAIN,g)}p&&(p.initSegment&&!p.initSegment.data&&!this.bitrateTest&&(p=p.initSegment),this.loadFragment(p,u,m))}}}}}},i.loadFragment=function(e,r,a){var o=this.fragmentTracker.getState(e);o===Le.NOT_LOADED||o===Le.PARTIAL?we(e)?this.bitrateTest?(this.log("Fragment "+e.sn+" of level "+e.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(e,r)):n.prototype.loadFragment.call(this,e,r,a):this._loadInitSegment(e,r):this.clearTrackerIfNeeded(e)},i.getBufferedFrag=function(e){return this.fragmentTracker.getBufferedFrag(e,W.MAIN)},i.followingBufferedFrag=function(e){return e?this.getBufferedFrag(e.end+.5):null},i.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},i.nextLevelSwitch=function(){var e=this.levels,r=this.media;if(r!=null&&r.readyState){var a,o=this.getAppendedFrag(r.currentTime);o&&o.start>1&&this.flushMainBuffer(0,o.start-1);var l=this.getLevelDetails();if(l!=null&&l.live){var u=this.getMainFwdBufferInfo();if(!u||u.len<l.targetduration*2)return}if(!r.paused&&e){var f=this.hls.nextLoadLevel,d=e[f],h=this.fragLastKbps;h&&this.fragCurrent?a=this.fragCurrent.duration*d.maxBitrate/(1e3*h)+1:a=0}else a=0;var v=this.getBufferedFrag(r.currentTime+a);if(v){var c=this.followingBufferedFrag(v);if(c){this.abortCurrentFrag();var g=c.maxStartPTS?c.maxStartPTS:c.start,m=c.duration,p=Math.max(v.end,g+Math.min(Math.max(m-this.config.maxFragLookUpTolerance,m*(this.couldBacktrack?.5:.125)),m*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(p,Number.POSITIVE_INFINITY)}}}},i.abortCurrentFrag=function(){var e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case O.KEY_LOADING:case O.FRAG_LOADING:case O.FRAG_LOADING_WAITING_RETRY:case O.PARSING:case O.PARSED:this.state=O.IDLE;break}this.nextLoadPosition=this.getLoadPosition()},i.flushMainBuffer=function(e,r){n.prototype.flushMainBuffer.call(this,e,r,this.altAudio===2?"video":null)},i.onMediaAttached=function(e,r){n.prototype.onMediaAttached.call(this,e,r);var a=r.media;ft(a,"playing",this.onMediaPlaying),ft(a,"seeked",this.onMediaSeeked)},i.onMediaDetaching=function(e,r){var a=this.media;a&&(et(a,"playing",this.onMediaPlaying),et(a,"seeked",this.onMediaSeeked)),this.videoBuffer=null,this.fragPlaying=null,n.prototype.onMediaDetaching.call(this,e,r);var o=!!r.transferMedia;o||(this._hasEnoughToStart=!1)},i.onManifestLoading=function(){n.prototype.onManifestLoading.call(this),this.log("Trigger BUFFER_RESET"),this.hls.trigger(E.BUFFER_RESET,void 0),this.couldBacktrack=!1,this.fragLastKbps=0,this.fragPlaying=this.backtrackFragment=null,this.altAudio=0,this.audioOnly=!1},i.onManifestParsed=function(e,r){var a=!1,o=!1;r.levels.forEach(function(l){var u=l.audioCodec;u&&(a=a||u.indexOf("mp4a.40.2")!==-1,o=o||u.indexOf("mp4a.40.5")!==-1)}),this.audioCodecSwitch=a&&o&&!el(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=r.levels,this.startFragRequested=!1},i.onLevelLoading=function(e,r){var a=this.levels;if(!(!a||this.state!==O.IDLE)){var o=r.levelInfo;(!o.details||o.details.live&&(this.levelLastLoaded!==o||o.details.expired)||this.waitForCdnTuneIn(o.details))&&(this.state=O.WAITING_LEVEL)}},i.onLevelLoaded=function(e,r){var a,o=this.levels,l=this.startFragRequested,u=r.level,f=r.details,d=f.totalduration;if(!o){this.warn("Levels were reset while loading level "+u);return}this.log("Level "+u+" loaded ["+f.startSN+","+f.endSN+"]"+(f.lastPartSn?"[part-"+f.lastPartSn+"-"+f.lastPartIndex+"]":"")+", cc ["+f.startCC+", "+f.endCC+"] duration:"+d);var h=r.levelInfo,v=this.fragCurrent;v&&(this.state===O.FRAG_LOADING||this.state===O.FRAG_LOADING_WAITING_RETRY)&&v.level!==r.level&&v.loader&&this.abortCurrentFrag();var c=0;if(f.live||(a=h.details)!=null&&a.live){var g;if(this.checkLiveUpdate(f),f.deltaUpdateFailed)return;c=this.alignPlaylists(f,h.details,(g=this.levelLastLoaded)==null?void 0:g.details)}if(h.details=f,this.levelLastLoaded=h,l||this.setStartPosition(f,c),this.hls.trigger(E.LEVEL_UPDATED,{details:f,level:u}),this.state===O.WAITING_LEVEL){if(this.waitForCdnTuneIn(f))return;this.state=O.IDLE}l&&f.live&&this.synchronizeToLiveEdge(f),this.tick()},i.synchronizeToLiveEdge=function(e){var r=this.config,a=this.media;if(a){var o=this.hls.liveSyncPosition,l=this.getLoadPosition(),u=e.fragmentStart,f=e.edge,d=l>=u-r.maxFragLookUpTolerance&&l<=f;if(o!==null&&a.duration>o&&(l<o||!d)){var h=r.liveMaxLatencyDuration!==void 0?r.liveMaxLatencyDuration:r.liveMaxLatencyDurationCount*e.targetduration;(!d&&a.readyState<4||l<f-h)&&(this._hasEnoughToStart||(this.nextLoadPosition=o),a.readyState&&(this.warn("Playback: "+l.toFixed(3)+" is located too far from the end of live sliding playlist: "+f+", reset currentTime to : "+o.toFixed(3)),a.currentTime=o))}}},i._handleFragmentLoadProgress=function(e){var r,a=e.frag,o=e.part,l=e.payload,u=this.levels;if(!u){this.warn("Levels were reset while fragment load was in progress. Fragment "+a.sn+" of level "+a.level+" will not be buffered");return}var f=u[a.level];if(!f){this.warn("Level "+a.level+" not found on progress");return}var d=f.details;if(!d){this.warn("Dropping fragment "+a.sn+" of level "+a.level+" after level details were reset"),this.fragmentTracker.removeFragment(a);return}var h=f.videoCodec,v=d.PTSKnown||!d.live,c=(r=a.initSegment)==null?void 0:r.data,g=this._getAudioCodec(f),m=this.transmuxer=this.transmuxer||new Zo(this.hls,W.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),p=o?o.index:-1,y=p!==-1,S=new hn(a.level,a.sn,a.stats.chunkCount,l.byteLength,p,y),T=this.initPTS[a.cc];m.push(l,c,g,h,a,o,d.totalduration,v,S,T)},i.onAudioTrackSwitching=function(e,r){var a=this,o=this.hls,l=this.altAudio===2,u=si(r.url,o);if(u)this.altAudio=1;else{if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var f=this.fragCurrent;f&&(this.log("Switching to main audio track, cancel main fragment load"),f.abortRequests(),this.fragmentTracker.removeFragment(f)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();if(l){this.fragmentTracker.removeAllFragments(),o.once(E.BUFFER_FLUSHED,function(){var d;(d=a.hls)==null||d.trigger(E.AUDIO_TRACK_SWITCHED,r)}),o.trigger(E.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});return}o.trigger(E.AUDIO_TRACK_SWITCHED,r)}},i.onAudioTrackSwitched=function(e,r){var a=si(r.url,this.hls);if(a){var o=this.videoBuffer;o&&this.mediaBuffer!==o&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=o)}this.altAudio=a?2:0,this.tick()},i.onBufferCreated=function(e,r){var a=r.tracks,o,l,u=!1;for(var f in a){var d=a[f];if(d.id==="main"){if(l=f,o=d,f==="video"){var h=a[f];h&&(this.videoBuffer=h.buffer)}}else u=!0}u&&o?(this.log("Alternate track found, use "+l+".buffered to schedule main fragment loading"),this.mediaBuffer=o.buffer):this.mediaBuffer=this.media},i.onFragBuffered=function(e,r){var a=r.frag,o=r.part,l=a.type===W.MAIN;if(l){if(this.fragContextChanged(a)){this.warn("Fragment "+a.sn+(o?" p: "+o.index:"")+" of level "+a.level+" finished buffering, but was aborted. state: "+this.state),this.state===O.PARSED&&(this.state=O.IDLE);return}var u=o?o.stats:a.stats;this.fragLastKbps=Math.round(8*u.total/(u.buffering.end-u.loading.first)),we(a)&&(this.fragPrevious=a),this.fragBufferedComplete(a,o)}var f=this.media;f&&(!this._hasEnoughToStart&&$.getBuffered(f).length&&(this._hasEnoughToStart=!0,this.seekToStartPos()),l&&this.tick())},i.onError=function(e,r){var a;if(r.fatal){this.state=O.ERROR;return}switch(r.details){case D.FRAG_GAP:case D.FRAG_PARSING_ERROR:case D.FRAG_DECRYPT_ERROR:case D.FRAG_LOAD_ERROR:case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_ERROR:case D.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(W.MAIN,r);break;case D.LEVEL_LOAD_ERROR:case D.LEVEL_LOAD_TIMEOUT:case D.LEVEL_PARSING_ERROR:!r.levelRetry&&this.state===O.WAITING_LEVEL&&((a=r.context)==null?void 0:a.type)===j.LEVEL&&(this.state=O.IDLE);break;case D.BUFFER_ADD_CODEC_ERROR:case D.BUFFER_APPEND_ERROR:if(r.parent!=="main")return;this.resetLoadingState();break;case D.BUFFER_FULL_ERROR:if(r.parent!=="main")return;this.reduceLengthAndFlushBuffer(r)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case D.INTERNAL_EXCEPTION:this.recoverWorkerError(r);break}},i.onFragLoadEmergencyAborted=function(){this.state=O.IDLE,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()},i.onBufferFlushed=function(e,r){var a=r.type;if(a!==re.AUDIO||!this.altAudio){var o=(a===re.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;o&&(this.afterBufferFlushed(o,a,W.MAIN),this.tick())}},i.onLevelsUpdated=function(e,r){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level,this.level===-1&&this.resetWhenMissingContext(this.fragCurrent)),this.levels=r.levels},i.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},i.seekToStartPos=function(){var e=this.media;if(e){var r=e.currentTime,a=this.startPosition;if(a>=0&&r<a){if(e.seeking){this.log("could not seek to "+a+", already seeking at "+r);return}var o=this.timelineOffset;o&&a&&(a+=o);var l=this.getLevelDetails(),u=$.getBuffered(e),f=u.length?u.start(0):0,d=f-a,h=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);d>0&&(d<h||this.loadingParts&&d<2*(l?.partTarget||0))&&(this.log("adjusting start position by "+d+" to match buffer start"),a+=d,this.startPosition=a),r<a&&(this.log("seek to target start position "+a+" from current time "+r+" buffer start "+f),e.currentTime=a)}}},i._getAudioCodec=function(e){var r=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&r&&(this.log("Swapping audio codec"),r.indexOf("mp4a.40.5")!==-1?r="mp4a.40.2":r="mp4a.40.5"),r},i._loadBitrateTestFrag=function(e,r){var a=this;e.bitrateTest=!0,this._doFragLoad(e,r).then(function(o){var l=a.hls,u=o?.frag;if(!(!u||a.fragContextChanged(u))){r.fragmentError=0,a.state=O.IDLE,a.startFragRequested=!1,a.bitrateTest=!1;var f=u.stats;f.parsing.start=f.parsing.end=f.buffering.start=f.buffering.end=self.performance.now(),l.trigger(E.FRAG_LOADED,o),u.bitrateTest=!1}})},i._handleTransmuxComplete=function(e){var r,a=this.playlistType,o=this.hls,l=e.remuxResult,u=e.chunkMeta,f=this.getCurrentContext(u);if(!f){this.resetWhenMissingContext(u);return}var d=f.frag,h=f.part,v=f.level,c=l.video,g=l.text,m=l.id3,p=l.initSegment,y=v.details,S=this.altAudio?void 0:l.audio;if(this.fragContextChanged(d)){this.fragmentTracker.removeFragment(d);return}if(this.state=O.PARSING,p){if(p!=null&&p.tracks){var T=d.initSegment||d;this._bufferInitSegment(v,p.tracks,T,u),o.trigger(E.FRAG_PARSING_INIT_SEGMENT,{frag:T,id:a,tracks:p.tracks})}var x=p.initPTS,R=p.timescale;N(x)&&(this.initPTS[d.cc]={baseTime:x,timescale:R},o.trigger(E.INIT_PTS_FOUND,{frag:d,id:a,initPTS:x,timescale:R}))}if(c&&y){var L=y.fragments[d.sn-1-y.startSN],A=d.sn===y.startSN,C=!L||d.cc>L.cc;if(l.independent!==!1){var _=c.startPTS,b=c.endPTS,I=c.startDTS,k=c.endDTS;if(h)h.elementaryStreams[c.type]={startPTS:_,endPTS:b,startDTS:I,endDTS:k};else if(c.firstKeyFrame&&c.independent&&u.id===1&&!C&&(this.couldBacktrack=!0),c.dropped&&c.independent){var w=this.getMainFwdBufferInfo(),M=(w?w.end:this.getLoadPosition())+this.config.maxBufferHole,P=c.firstKeyFramePTS?c.firstKeyFramePTS:_;if(!A&&M<P-this.config.maxBufferHole&&!C){this.backtrack(d);return}else C&&(d.gap=!0);d.setElementaryStreamInfo(c.type,d.start,b,d.start,k,!0)}else A&&_-(y.appliedTimelineOffset||0)>Pt&&(d.gap=!0);d.setElementaryStreamInfo(c.type,_,b,I,k),this.backtrackFragment&&(this.backtrackFragment=d),this.bufferFragmentData(c,d,h,u,A||C)}else if(A||C)d.gap=!0;else{this.backtrack(d);return}}if(S){var F=S.startPTS,B=S.endPTS,U=S.startDTS,G=S.endDTS;h&&(h.elementaryStreams[re.AUDIO]={startPTS:F,endPTS:B,startDTS:U,endDTS:G}),d.setElementaryStreamInfo(re.AUDIO,F,B,U,G),this.bufferFragmentData(S,d,h,u)}if(y&&m!=null&&(r=m.samples)!=null&&r.length){var z={id:a,frag:d,details:y,samples:m.samples};o.trigger(E.FRAG_PARSING_METADATA,z)}if(y&&g){var q={id:a,frag:d,details:y,samples:g.samples};o.trigger(E.FRAG_PARSING_USERDATA,q)}},i._bufferInitSegment=function(e,r,a,o){var l=this;if(this.state===O.PARSING){this.audioOnly=!!r.audio&&!r.video,this.altAudio&&!this.audioOnly&&delete r.audio;var u=r.audio,f=r.video,d=r.audiovideo;if(u){var h=Et(u.codec,e.audioCodec);h==="mp4a"&&(h="mp4a.40.5");var v=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){h&&(h.indexOf("mp4a.40.5")!==-1?h="mp4a.40.2":h="mp4a.40.5");var c=u.metadata;c&&"channelCount"in c&&(c.channelCount||1)!==1&&v.indexOf("firefox")===-1&&(h="mp4a.40.5")}h&&h.indexOf("mp4a.40.5")!==-1&&v.indexOf("android")!==-1&&u.container!=="audio/mpeg"&&(h="mp4a.40.2",this.log("Android: force audio codec to "+h)),e.audioCodec&&e.audioCodec!==h&&this.log('Swapping manifest audio codec "'+e.audioCodec+'" for "'+h+'"'),u.levelCodec=h,u.id=W.MAIN,this.log("Init audio buffer, container:"+u.container+", codecs[selected/level/parsed]=["+(h||"")+"/"+(e.audioCodec||"")+"/"+u.codec+"]"),delete r.audiovideo}if(f){f.levelCodec=e.videoCodec,f.id=W.MAIN;var g=f.codec;if(g?.length===4)switch(g){case"hvc1":case"hev1":f.codec="hvc1.1.6.L120.90";break;case"av01":f.codec="av01.0.04M.08";break;case"avc1":f.codec="avc1.42e01e";break}this.log("Init video buffer, container:"+f.container+", codecs[level/parsed]=["+(e.videoCodec||"")+"/"+g+"]"+(f.codec!==g?" parsed-corrected="+f.codec:"")+(f.supplemental?" supplemental="+f.supplemental:"")),delete r.audiovideo}d&&(this.log("Init audiovideo buffer, container:"+d.container+", codecs[level/parsed]=["+e.codecs+"/"+d.codec+"]"),delete r.video,delete r.audio);var m=Object.keys(r);if(m.length){if(this.hls.trigger(E.BUFFER_CODECS,r),!this.hls)return;m.forEach(function(p){var y=r[p],S=y.initSegment;S!=null&&S.byteLength&&l.hls.trigger(E.BUFFER_APPENDING,{type:p,data:S,frag:a,part:null,chunkMeta:o,parent:a.type})})}this.tickImmediate()}},i.getMainFwdBufferInfo=function(){var e=this.mediaBuffer&&this.altAudio===2?this.mediaBuffer:this.media;return this.getFwdBufferInfo(e,W.MAIN)},i.backtrack=function(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=O.IDLE},i.checkFragmentChanged=function(){var e=this.media,r=null;if(e&&e.readyState>1&&e.seeking===!1){var a=e.currentTime;if($.isBuffered(e,a)?r=this.getAppendedFrag(a):$.isBuffered(e,a+.1)&&(r=this.getAppendedFrag(a+.1)),r){this.backtrackFragment=null;var o=this.fragPlaying,l=r.level;(!o||r.sn!==o.sn||o.level!==l)&&(this.fragPlaying=r,this.hls.trigger(E.FRAG_CHANGED,{frag:r}),(!o||o.level!==l)&&this.hls.trigger(E.LEVEL_SWITCHED,{level:l}))}}},te(s,[{key:"hasEnoughToStart",get:function(){return this._hasEnoughToStart}},{key:"maxBufferLength",get:function(){var e=this.levels,r=this.level,a=e?.[r];return a?this.getMaxBufferLength(a.maxBitrate):this.config.maxBufferLength}},{key:"nextLevel",get:function(){var e=this.nextBufferedFrag;return e?e.level:-1}},{key:"currentFrag",get:function(){var e;if(this.fragPlaying)return this.fragPlaying;var r=((e=this.media)==null?void 0:e.currentTime)||this.lastCurrentTime;return N(r)?this.getAppendedFrag(r):null}},{key:"currentProgramDateTime",get:function(){var e,r=((e=this.media)==null?void 0:e.currentTime)||this.lastCurrentTime;if(N(r)){var a=this.getLevelDetails(),o=this.currentFrag||(a?er(null,a.fragments,r):null);if(o){var l=o.programDateTime;if(l!==null){var u=l+(r-o.start)*1e3;return new Date(u)}}}return null}},{key:"currentLevel",get:function(){var e=this.currentFrag;return e?e.level:-1}},{key:"nextBufferedFrag",get:function(){var e=this.currentFrag;return e?this.followingBufferedFrag(e):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}])}(Do),il=function(){function n(i){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=i}var s=n.prototype;return s.abort=function(t){for(var e in this.keyUriToKeyInfo){var r=this.keyUriToKeyInfo[e].loader;if(r){var a;if(t&&t!==((a=r.context)==null?void 0:a.frag.type))return;r.abort()}}},s.detach=function(){for(var t in this.keyUriToKeyInfo){var e=this.keyUriToKeyInfo[t];(e.mediaKeySessionContext||e.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[t]}},s.destroy=function(){this.detach();for(var t in this.keyUriToKeyInfo){var e=this.keyUriToKeyInfo[t].loader;e&&e.destroy()}this.keyUriToKeyInfo={}},s.createKeyLoadError=function(t,e,r,a,o){return e===void 0&&(e=D.KEY_LOAD_ERROR),new Ve({type:K.NETWORK_ERROR,details:e,fatal:!1,frag:t,response:o,error:r,networkDetails:a})},s.loadClear=function(t,e){var r=this;if(this.emeController&&this.config.emeEnabled)for(var a=t.sn,o=t.cc,l=function(){var d=e[u];if(o<=d.cc&&(a==="initSegment"||d.sn==="initSegment"||a<d.sn))return r.emeController.selectKeySystemFormat(d).then(function(h){d.setKeyFormat(h)}),1},u=0;u<e.length&&!l();u++);},s.load=function(t){var e=this;return!t.decryptdata&&t.encrypted&&this.emeController&&this.config.emeEnabled?this.emeController.selectKeySystemFormat(t).then(function(r){return e.loadInternal(t,r)}):this.loadInternal(t)},s.loadInternal=function(t,e){var r,a;e&&t.setKeyFormat(e);var o=t.decryptdata;if(!o){var l=new Error(e?"Expected frag.decryptdata to be defined after setting format "+e:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(t,D.KEY_LOAD_ERROR,l))}var u=o.uri;if(!u)return Promise.reject(this.createKeyLoadError(t,D.KEY_LOAD_ERROR,new Error('Invalid key URI: "'+u+'"')));var f=this.keyUriToKeyInfo[u];if((r=f)!=null&&r.decryptdata.key)return o.key=f.decryptdata.key,Promise.resolve({frag:t,keyInfo:f});if((a=f)!=null&&a.keyLoadPromise){var d;switch((d=f.mediaKeySessionContext)==null?void 0:d.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return f.keyLoadPromise.then(function(h){return o.key=h.keyInfo.decryptdata.key,{frag:t,keyInfo:f}})}}switch(f=this.keyUriToKeyInfo[u]={decryptdata:o,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},o.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return o.keyFormat==="identity"?this.loadKeyHTTP(f,t):this.loadKeyEME(f,t);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(f,t);default:return Promise.reject(this.createKeyLoadError(t,D.KEY_LOAD_ERROR,new Error('Key supplied with unsupported METHOD: "'+o.method+'"')))}},s.loadKeyEME=function(t,e){var r={frag:e,keyInfo:t};if(this.emeController&&this.config.emeEnabled){var a=this.emeController.loadKey(r);if(a)return(t.keyLoadPromise=a.then(function(o){return t.mediaKeySessionContext=o,r})).catch(function(o){throw t.keyLoadPromise=null,o})}return Promise.resolve(r)},s.loadKeyHTTP=function(t,e){var r=this,a=this.config,o=a.loader,l=new o(a);return e.keyLoader=t.loader=l,t.keyLoadPromise=new Promise(function(u,f){var d={keyInfo:t,frag:e,responseType:"arraybuffer",url:t.decryptdata.uri},h=a.keyLoadPolicy.default,v={loadPolicy:h,timeout:h.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:function(m,p,y,S){var T=y.frag,x=y.keyInfo,R=y.url;if(!T.decryptdata||x!==r.keyUriToKeyInfo[R])return f(r.createKeyLoadError(T,D.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),S));x.decryptdata.key=T.decryptdata.key=new Uint8Array(m.data),T.keyLoader=null,x.loader=null,u({frag:T,keyInfo:x})},onError:function(m,p,y,S){r.resetLoader(p),f(r.createKeyLoadError(e,D.KEY_LOAD_ERROR,new Error("HTTP Error "+m.code+" loading key "+m.text),y,xe({url:d.url,data:void 0},m)))},onTimeout:function(m,p,y){r.resetLoader(p),f(r.createKeyLoadError(e,D.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),y))},onAbort:function(m,p,y){r.resetLoader(p),f(r.createKeyLoadError(e,D.INTERNAL_ABORTED,new Error("key loading aborted"),y))}};l.load(d,v,c)})},s.resetLoader=function(t){var e=t.frag,r=t.keyInfo,a=t.url,o=r.loader;e.keyLoader===o&&(e.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[a],o&&o.destroy()},n}();function Rn(n){var s=n.type;switch(s){case j.AUDIO_TRACK:return W.AUDIO;case j.SUBTITLE_TRACK:return W.SUBTITLE;default:return W.MAIN}}function xr(n,s){var i=n.url;return(i===void 0||i.indexOf("data:")===0)&&(i=s.url),i}var nl=function(){function n(i){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=i,this.registerListeners()}var s=n.prototype;return s.startLoad=function(t){},s.stopLoad=function(){this.destroyInternalLoaders()},s.registerListeners=function(){var t=this.hls;t.on(E.MANIFEST_LOADING,this.onManifestLoading,this),t.on(E.LEVEL_LOADING,this.onLevelLoading,this),t.on(E.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.on(E.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),t.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this)},s.unregisterListeners=function(){var t=this.hls;t.off(E.MANIFEST_LOADING,this.onManifestLoading,this),t.off(E.LEVEL_LOADING,this.onLevelLoading,this),t.off(E.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.off(E.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),t.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this)},s.createInternalLoader=function(t){var e=this.hls.config,r=e.pLoader,a=e.loader,o=r||a,l=new o(e);return this.loaders[t.type]=l,l},s.getInternalLoader=function(t){return this.loaders[t.type]},s.resetInternalLoader=function(t){this.loaders[t]&&delete this.loaders[t]},s.destroyInternalLoaders=function(){for(var t in this.loaders){var e=this.loaders[t];e&&e.destroy(),this.resetInternalLoader(t)}},s.destroy=function(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()},s.onManifestLoading=function(t,e){var r=e.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:j.MANIFEST,url:r,deliveryDirectives:null,levelOrTrack:null})},s.onLevelLoading=function(t,e){var r=e.id,a=e.level,o=e.pathwayId,l=e.url,u=e.deliveryDirectives,f=e.levelInfo;this.load({id:r,level:a,pathwayId:o,responseType:"text",type:j.LEVEL,url:l,deliveryDirectives:u,levelOrTrack:f})},s.onAudioTrackLoading=function(t,e){var r=e.id,a=e.groupId,o=e.url,l=e.deliveryDirectives,u=e.track;this.load({id:r,groupId:a,level:null,responseType:"text",type:j.AUDIO_TRACK,url:o,deliveryDirectives:l,levelOrTrack:u})},s.onSubtitleTrackLoading=function(t,e){var r=e.id,a=e.groupId,o=e.url,l=e.deliveryDirectives,u=e.track;this.load({id:r,groupId:a,level:null,responseType:"text",type:j.SUBTITLE_TRACK,url:o,deliveryDirectives:l,levelOrTrack:u})},s.onLevelsUpdated=function(t,e){var r=this.loaders[j.LEVEL];if(r){var a=r.context;a&&!e.levels.some(function(o){return o===a.levelOrTrack})&&(r.abort(),delete this.loaders[j.LEVEL])}},s.load=function(t){var e,r=this,a=this.hls.config,o=this.getInternalLoader(t);if(o){var l=this.hls.logger,u=o.context;if(u&&u.levelOrTrack===t.levelOrTrack&&(u.url===t.url||u.deliveryDirectives&&!t.deliveryDirectives)){u.url===t.url?l.log("[playlist-loader]: ignore "+t.url+" ongoing request"):l.log("[playlist-loader]: ignore "+t.url+" in favor of "+u.url);return}l.log("[playlist-loader]: aborting previous loader for type: "+t.type),o.abort()}var f;if(t.type===j.MANIFEST?f=a.manifestLoadPolicy.default:f=de({},a.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),o=this.createInternalLoader(t),N((e=t.deliveryDirectives)==null?void 0:e.part)){var d;if(t.type===j.LEVEL&&t.level!==null?d=this.hls.levels[t.level].details:t.type===j.AUDIO_TRACK&&t.id!==null?d=this.hls.audioTracks[t.id].details:t.type===j.SUBTITLE_TRACK&&t.id!==null&&(d=this.hls.subtitleTracks[t.id].details),d){var h=d.partTarget,v=d.targetduration;if(h&&v){var c=Math.max(h*3,v*.8)*1e3;f=de({},f,{maxTimeToFirstByteMs:Math.min(c,f.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(c,f.maxTimeToFirstByteMs)})}}}var g=f.errorRetry||f.timeoutRetry||{},m={loadPolicy:f,timeout:f.maxLoadTimeMs,maxRetry:g.maxNumRetry||0,retryDelay:g.retryDelayMs||0,maxRetryDelay:g.maxRetryDelayMs||0},p={onSuccess:function(S,T,x,R){var L=r.getInternalLoader(x);r.resetInternalLoader(x.type);var A=S.data;if(A.indexOf("#EXTM3U")!==0){r.handleManifestParsingError(S,x,new Error("no EXTM3U delimiter"),R||null,T);return}T.parsing.start=performance.now(),ot.isMediaPlaylist(A)||x.type!==j.MANIFEST?r.handleTrackOrLevelPlaylist(S,T,x,R||null,L):r.handleMasterPlaylist(S,T,x,R)},onError:function(S,T,x,R){r.handleNetworkError(T,x,!1,S,R)},onTimeout:function(S,T,x){r.handleNetworkError(T,x,!0,void 0,S)}};o.load(t,m,p)},s.checkAutostartLoad=function(){if(this.hls){var t=this.hls,e=t.config,r=e.autoStartLoad,a=e.startPosition,o=t.forceStartLoad;(r||o)&&(this.hls.logger.log((r?"auto":"force")+" startLoad with configured startPosition "+a),this.hls.startLoad(a))}},s.handleMasterPlaylist=function(t,e,r,a){var o=this.hls,l=t.data,u=xr(t,r),f=ot.parseMasterPlaylist(l,u);if(f.playlistParsingError){this.handleManifestParsingError(t,r,f.playlistParsingError,a,e);return}var d=f.contentSteering,h=f.levels,v=f.sessionData,c=f.sessionKeys,g=f.startTimeOffset,m=f.variableList;this.variableList=m;var p=ot.parseMasterPlaylistMedia(l,u,f),y=p.AUDIO,S=y===void 0?[]:y,T=p.SUBTITLES,x=p["CLOSED-CAPTIONS"];if(S.length){var R=S.some(function(L){return!L.url});!R&&h[0].audioCodec&&!h[0].attrs.AUDIO&&(this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),S.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new le({}),bitrate:0,url:""}))}o.trigger(E.MANIFEST_LOADED,{levels:h,audioTracks:S,subtitles:T,captions:x,contentSteering:d,url:u,stats:e,networkDetails:a,sessionData:v,sessionKeys:c,startTimeOffset:g,variableList:m})},s.handleTrackOrLevelPlaylist=function(t,e,r,a,o){var l=this.hls,u=r.id,f=r.level,d=r.type,h=xr(t,r),v=N(f)?f:N(u)?u:0,c=Rn(r),g=ot.parseLevelPlaylist(t.data,h,v,c,0,this.variableList);if(d===j.MANIFEST){var m={attrs:new le({}),bitrate:0,details:g,name:"",url:h};g.requestScheduled=e.loading.start+ki(g,0),l.trigger(E.MANIFEST_LOADED,{levels:[m],audioTracks:[],url:h,stats:e,networkDetails:a,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}e.parsing.end=performance.now(),r.levelDetails=g,this.handlePlaylistLoaded(g,t,e,r,a,o)},s.handleManifestParsingError=function(t,e,r,a,o){this.hls.trigger(E.ERROR,{type:K.NETWORK_ERROR,details:D.MANIFEST_PARSING_ERROR,fatal:e.type===j.MANIFEST,url:t.url,err:r,error:r,reason:r.message,response:t,context:e,networkDetails:a,stats:o})},s.handleNetworkError=function(t,e,r,a,o){r===void 0&&(r=!1);var l="A network "+(r?"timeout":"error"+(a?" (status "+a.code+")":""))+" occurred while loading "+t.type;t.type===j.LEVEL?l+=": "+t.level+" id: "+t.id:(t.type===j.AUDIO_TRACK||t.type===j.SUBTITLE_TRACK)&&(l+=" id: "+t.id+' group-id: "'+t.groupId+'"');var u=new Error(l);this.hls.logger.warn("[playlist-loader]: "+l);var f=D.UNKNOWN,d=!1,h=this.getInternalLoader(t);switch(t.type){case j.MANIFEST:f=r?D.MANIFEST_LOAD_TIMEOUT:D.MANIFEST_LOAD_ERROR,d=!0;break;case j.LEVEL:f=r?D.LEVEL_LOAD_TIMEOUT:D.LEVEL_LOAD_ERROR,d=!1;break;case j.AUDIO_TRACK:f=r?D.AUDIO_TRACK_LOAD_TIMEOUT:D.AUDIO_TRACK_LOAD_ERROR,d=!1;break;case j.SUBTITLE_TRACK:f=r?D.SUBTITLE_TRACK_LOAD_TIMEOUT:D.SUBTITLE_LOAD_ERROR,d=!1;break}h&&this.resetInternalLoader(t.type);var v={type:K.NETWORK_ERROR,details:f,fatal:d,url:t.url,loader:h,context:t,error:u,networkDetails:e,stats:o};if(a){var c=e?.url||t.url;v.response=xe({url:c,data:void 0},a)}this.hls.trigger(E.ERROR,v)},s.handlePlaylistLoaded=function(t,e,r,a,o,l){var u=this.hls,f=a.type,d=a.level,h=a.id,v=a.groupId,c=a.deliveryDirectives,g=xr(e,a),m=Rn(a),p=typeof a.level=="number"&&m===W.MAIN?d:void 0;if(!t.fragments.length){var y=t.playlistParsingError=new Error("No Segments found in Playlist");u.trigger(E.ERROR,{type:K.NETWORK_ERROR,details:D.LEVEL_EMPTY_ERROR,fatal:!1,url:g,error:y,reason:y.message,response:e,context:a,level:p,parent:m,networkDetails:o,stats:r});return}t.targetduration||(t.playlistParsingError=new Error("Missing Target Duration"));var S=t.playlistParsingError;if(S){if(this.hls.logger.warn(S),!u.config.ignorePlaylistParsingErrors){u.trigger(E.ERROR,{type:K.NETWORK_ERROR,details:D.LEVEL_PARSING_ERROR,fatal:!1,url:g,error:S,reason:S.message,response:e,context:a,level:p,parent:m,networkDetails:o,stats:r});return}t.playlistParsingError=null}switch(t.live&&l&&(l.getCacheAge&&(t.ageHeader=l.getCacheAge()||0),(!l.getCacheAge||isNaN(t.ageHeader))&&(t.ageHeader=0)),f){case j.MANIFEST:case j.LEVEL:u.trigger(E.LEVEL_LOADED,{details:t,levelInfo:a.levelOrTrack||u.levels[0],level:p||0,id:h||0,stats:r,networkDetails:o,deliveryDirectives:c,withoutMultiVariant:f===j.MANIFEST});break;case j.AUDIO_TRACK:u.trigger(E.AUDIO_TRACK_LOADED,{details:t,track:a.levelOrTrack,id:h||0,groupId:v||"",stats:r,networkDetails:o,deliveryDirectives:c});break;case j.SUBTITLE_TRACK:u.trigger(E.SUBTITLE_TRACK_LOADED,{details:t,track:a.levelOrTrack,id:h||0,groupId:v||"",stats:r,networkDetails:o,deliveryDirectives:c});break}},n}(),al={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]};function sl(n,s){return{supported:!1,configurations:s,decodingInfoResults:[{supported:!1,smooth:!1,powerEfficient:!1}],error:n}}var bn={};function ol(n,s,i){var t=n.videoCodec,e=n.audioCodec;if(!t&&!e||!i)return Promise.resolve(al);var r=[];if(t){var a={width:n.width,height:n.height,bitrate:Math.ceil(Math.max(n.bitrate*.9,n.averageBitrate)),framerate:n.frameRate||30},o=n.videoRange;o!=="SDR"&&(a.transferFunction=o.toLowerCase());var l=t.split(","),u=navigator.userAgent;if(l.some(function(f){return zt(f)})&&$r())return Promise.resolve(sl(new Error("Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent sting: ("+u+")"),r));r.push.apply(r,l.map(function(f){return{type:"media-source",video:xe(xe({},a),{},{contentType:at(Ta(f),"video")})}}))}return e&&n.audioGroups&&n.audioGroups.forEach(function(f){var d;f&&((d=s.groups[f])==null||d.tracks.forEach(function(h){if(h.groupId===f){var v=h.channels||"",c=parseFloat(v);N(c)&&c>2&&r.push.apply(r,e.split(",").map(function(g){return{type:"media-source",audio:{contentType:at(g,"audio"),channels:""+c}}}))}}))}),Promise.all(r.map(function(f){var d=ll(f);return bn[d]||(bn[d]=i.decodingInfo(f))})).then(function(f){return{supported:!f.some(function(d){return!d.supported}),configurations:r,decodingInfoResults:f}}).catch(function(f){return{supported:!1,configurations:r,decodingInfoResults:[],error:f}})}function ll(n){var s=n.audio,i=n.video,t=i||s;if(t){var e=ei(t.contentType);if(i)return"r"+i.height+"x"+i.width+"f"+Math.ceil(i.framerate)+(i.transferFunction||"sd")+"_"+e+"_"+Math.ceil(i.bitrate/1e5);if(s)return"c"+s.channels+(s.spatialRendering?"s":"n")+"_"+e}return""}var In=function(){function n(i){i===void 0&&(i={}),this.config=void 0,this.userConfig=void 0,this.logger=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new Gt,this._autoLevelCapping=-1,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.audioStreamController=void 0,this.subtititleStreamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.interstitialsController=void 0,this.gapController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this._url=null,this._sessionId=void 0,this.triggeringException=void 0,this.started=!1;var t=this.logger=wr(i.debug||!1,"Hls instance",i.assetPlayerId),e=this.config=yo(n.DefaultConfig,i,t);this.userConfig=i,e.progressive&&To(e,t);var r=e.abrController,a=e.bufferController,o=e.capLevelController,l=e.errorController,u=e.fpsController,f=new l(this),d=this.abrController=new r(this),h=new So(this),v=e.interstitialsController,c=v?this.interstitialsController=new v(this,n):null,g=this.bufferController=new a(this,h),m=this.capLevelController=new o(this),p=new u(this),y=new nl(this),S=e.contentSteeringController,T=S?new S(this):null,x=this.levelController=new Wo(this,T),R=new Ho(this),L=new il(this.config),A=this.streamController=new rl(this,h,L),C=this.gapController=new Mo(this,h);m.setStreamController(A),p.setStreamController(A);var _=[y,x,A];c&&_.splice(1,0,c),T&&_.splice(1,0,T),this.networkControllers=_;var b=[d,g,C,m,p,R,h];this.audioTrackController=this.createController(e.audioTrackController,_);var I=e.audioStreamController;I&&_.push(this.audioStreamController=new I(this,h,L)),this.subtitleTrackController=this.createController(e.subtitleTrackController,_);var k=e.subtitleStreamController;k&&_.push(this.subtititleStreamController=new k(this,h,L)),this.createController(e.timelineController,b),L.emeController=this.emeController=this.createController(e.emeController,b),this.cmcdController=this.createController(e.cmcdController,b),this.latencyController=this.createController(Vo,b),this.coreComponents=b,_.push(f);var w=f.onErrorOut;typeof w=="function"&&this.on(E.ERROR,w,f),this.on(E.MANIFEST_LOADED,y.onManifestLoaded,y)}n.isMSESupported=function(){return An()},n.isSupported=function(){return Jo()},n.getMediaSource=function(){return We()};var s=n.prototype;return s.createController=function(t,e){if(t){var r=new t(this);return e&&e.push(r),r}return null},s.on=function(t,e,r){r===void 0&&(r=this),this._emitter.on(t,e,r)},s.once=function(t,e,r){r===void 0&&(r=this),this._emitter.once(t,e,r)},s.removeAllListeners=function(t){this._emitter.removeAllListeners(t)},s.off=function(t,e,r,a){r===void 0&&(r=this),this._emitter.off(t,e,r,a)},s.listeners=function(t){return this._emitter.listeners(t)},s.emit=function(t,e,r){return this._emitter.emit(t,e,r)},s.trigger=function(t,e){if(this.config.debug)return this.emit(t,t,e);try{return this.emit(t,t,e)}catch(a){if(this.logger.error("An internal error happened while handling event "+t+'. Error message: "'+a.message+'". Here is a stacktrace:',a),!this.triggeringException){this.triggeringException=!0;var r=t===E.ERROR;this.trigger(E.ERROR,{type:K.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,fatal:r,event:t,error:a}),this.triggeringException=!1}}return!1},s.listenerCount=function(t){return this._emitter.listenerCount(t)},s.destroy=function(){this.logger.log("destroy"),this.trigger(E.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this._url=null,this.networkControllers.forEach(function(e){return e.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(e){return e.destroy()}),this.coreComponents.length=0;var t=this.config;t.xhrSetup=t.fetchSetup=void 0,this.userConfig=null},s.attachMedia=function(t){if(!t||"media"in t&&!t.media){var e=new Error("attachMedia failed: invalid argument ("+t+")");this.trigger(E.ERROR,{type:K.OTHER_ERROR,details:D.ATTACH_MEDIA_ERROR,fatal:!0,error:e});return}this.logger.log("attachMedia"),this._media&&(this.logger.warn("media must be detached before attaching"),this.detachMedia());var r="media"in t,a=r?t.media:t,o=r?t:{media:a};this._media=a,this.trigger(E.MEDIA_ATTACHING,o)},s.detachMedia=function(){this.logger.log("detachMedia"),this.trigger(E.MEDIA_DETACHING,{}),this._media=null},s.transferMedia=function(){this._media=null;var t=this.bufferController.transferMedia();return this.trigger(E.MEDIA_DETACHING,{transferMedia:t}),t},s.loadSource=function(t){this.stopLoad();var e=this.media,r=this._url,a=this._url=Vt.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log("loadSource:"+a),e&&r&&(r!==a||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(e)),this.trigger(E.MANIFEST_LOADING,{url:t})},s.startLoad=function(t,e){t===void 0&&(t=-1),this.logger.log("startLoad("+(t+(e?", <skip seek to start>":""))+")"),this.started=!0,this.resumeBuffering();for(var r=0;r<this.networkControllers.length&&(this.networkControllers[r].startLoad(t,e),!(!this.started||!this.networkControllers));r++);},s.stopLoad=function(){this.logger.log("stopLoad"),this.started=!1;for(var t=0;t<this.networkControllers.length&&(this.networkControllers[t].stopLoad(),!(this.started||!this.networkControllers));t++);},s.resumeBuffering=function(){this.bufferingEnabled||(this.logger.log("resume buffering"),this.networkControllers.forEach(function(t){t.resumeBuffering&&t.resumeBuffering()}))},s.pauseBuffering=function(){this.bufferingEnabled&&(this.logger.log("pause buffering"),this.networkControllers.forEach(function(t){t.pauseBuffering&&t.pauseBuffering()}))},s.swapAudioCodec=function(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},s.recoverMediaError=function(){this.logger.log("recoverMediaError");var t=this._media,e=t?.currentTime;this.detachMedia(),t&&(this.attachMedia(t),e&&this.startLoad(e))},s.removeLevel=function(t){this.levelController.removeLevel(t)},s.setAudioOption=function(t){var e;return((e=this.audioTrackController)==null?void 0:e.setAudioOption(t))||null},s.setSubtitleOption=function(t){var e;return((e=this.subtitleTrackController)==null?void 0:e.setSubtitleOption(t))||null},s.getMediaDecodingInfo=function(t,e){e===void 0&&(e=this.allAudioTracks);var r=ai(e);return ol(t,r,navigator.mediaCapabilities)},te(n,[{key:"url",get:function(){return this._url}},{key:"hasEnoughToStart",get:function(){return this.streamController.hasEnoughToStart}},{key:"startPosition",get:function(){return this.streamController.startPositionValue}},{key:"loadingEnabled",get:function(){return this.started}},{key:"bufferingEnabled",get:function(){return this.streamController.bufferingEnabled}},{key:"inFlightFragments",get:function(){var t,e=(t={},t[W.MAIN]=this.streamController.inFlightFrag,t);return this.audioStreamController&&(e[W.AUDIO]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(e[W.SUBTITLE]=this.subtititleStreamController.inFlightFrag),e}},{key:"sessionId",get:function(){var t=this._sessionId;return t||(t=this._sessionId=Vn()),t}},{key:"levels",get:function(){var t=this.levelController.levels;return t||[]}},{key:"latestLevelDetails",get:function(){return this.streamController.getLevelDetails()||null}},{key:"loadLevelObj",get:function(){return this.levelController.loadLevelObj}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(t){this.logger.log("set currentLevel:"+t),this.levelController.manualLevel=t,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(t){this.logger.log("set nextLevel:"+t),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(t){this.logger.log("set loadLevel:"+t),this.levelController.manualLevel=t}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(t){this.levelController.nextLoadLevel=t}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(t){this.logger.log("set firstLevel:"+t),this.levelController.firstLevel=t}},{key:"startLevel",get:function(){var t=this.levelController.startLevel;return t===-1&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:t},set:function(t){this.logger.log("set startLevel:"+t),t!==-1&&(t=Math.max(t,this.minAutoLevel)),this.levelController.startLevel=t}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(t){var e=!!t;e!==this.config.capLevelToPlayerSize&&(e?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=e)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(t){this._autoLevelCapping!==t&&(this.logger.log("set autoLevelCapping:"+t),this._autoLevelCapping=t,this.levelController.checkMaxAutoUpdated())}},{key:"bandwidthEstimate",get:function(){var t=this.abrController.bwEstimator;return t?t.getEstimate():NaN},set:function(t){this.abrController.resetEstimator(t)}},{key:"abrEwmaDefaultEstimate",get:function(){var t=this.abrController.bwEstimator;return t?t.defaultEstimate:NaN}},{key:"ttfbEstimate",get:function(){var t=this.abrController.bwEstimator;return t?t.getEstimateTTFB():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(t){Sa(t)&&this._maxHdcpLevel!==t&&(this._maxHdcpLevel=t,this.levelController.checkMaxAutoUpdated())}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var t=this.levels,e=this.config.minAutoBitrate;if(!t)return 0;for(var r=t.length,a=0;a<r;a++)if(t[a].maxBitrate>=e)return a;return 0}},{key:"maxAutoLevel",get:function(){var t=this.levels,e=this.autoLevelCapping,r=this.maxHdcpLevel,a;if(e===-1&&t!=null&&t.length?a=t.length-1:a=e,r)for(var o=a;o--;){var l=t[o].attrs["HDCP-LEVEL"];if(l&&l<=r)return o}return a}},{key:"firstAutoLevel",get:function(){return this.abrController.firstAutoLevel}},{key:"nextAutoLevel",get:function(){return this.abrController.nextAutoLevel},set:function(t){this.abrController.nextAutoLevel=t}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"maxBufferLength",get:function(){return this.streamController.maxBufferLength}},{key:"allAudioTracks",get:function(){var t=this.audioTrackController;return t?t.allAudioTracks:[]}},{key:"audioTracks",get:function(){var t=this.audioTrackController;return t?t.audioTracks:[]}},{key:"audioTrack",get:function(){var t=this.audioTrackController;return t?t.audioTrack:-1},set:function(t){var e=this.audioTrackController;e&&(e.audioTrack=t)}},{key:"allSubtitleTracks",get:function(){var t=this.subtitleTrackController;return t?t.allSubtitleTracks:[]}},{key:"subtitleTracks",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTrack:-1},set:function(t){var e=this.subtitleTrackController;e&&(e.subtitleTrack=t)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var t=this.subtitleTrackController;return t?t.subtitleDisplay:!1},set:function(t){var e=this.subtitleTrackController;e&&(e.subtitleDisplay=t)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(t){this.config.lowLatencyMode=t}},{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},set:function(t){this.latencyController.targetLatency=t}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}},{key:"pathways",get:function(){return this.levelController.pathways}},{key:"pathwayPriority",get:function(){return this.levelController.pathwayPriority},set:function(t){this.levelController.pathwayPriority=t}},{key:"bufferedToEnd",get:function(){var t;return!!((t=this.bufferController)!=null&&t.bufferedToEnd)}},{key:"interstitialsManager",get:function(){var t;return((t=this.interstitialsController)==null?void 0:t.interstitialsManager)||null}}],[{key:"version",get:function(){return dt}},{key:"Events",get:function(){return E}},{key:"MetadataSchema",get:function(){return _e}},{key:"ErrorTypes",get:function(){return K}},{key:"ErrorDetails",get:function(){return D}},{key:"DefaultConfig",get:function(){return n.defaultConfig?n.defaultConfig:po},set:function(t){n.defaultConfig=t}}])}();return In.defaultConfig=void 0,In})})(!1)});var Dl={};bl(Dl,{Hls:()=>Bn.default});module.exports=_l(Dl);var Bn=Il(Nn(),1);
29
-
30
- if(__exports != exports)module.exports = exports;return module.exports}));