lemon-mse 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/flv.js +698 -675
- package/dist/hls.js +19959 -19477
- package/dist/index.js +20584 -20086
- package/dist/lemon/flv.js +9 -6
- package/dist/lemon/hls.js +27 -24
- package/dist/lemon/index.js +32 -29
- package/package.json +6 -3
package/dist/lemon/hls.js
CHANGED
@@ -1,27 +1,30 @@
|
|
1
|
-
(()=>{var Oq=Object.create;var{getPrototypeOf:Rq,defineProperty:UY,getOwnPropertyNames:_J,getOwnPropertyDescriptor:Mq}=Object,hJ=Object.prototype.hasOwnProperty;var Iq=(Z0,H0,$0)=>{$0=Z0!=null?Oq(Rq(Z0)):{};let E0=H0||!Z0||!Z0.__esModule?UY($0,"default",{value:Z0,enumerable:!0}):$0;for(let q0 of _J(Z0))if(!hJ.call(E0,q0))UY(E0,q0,{get:()=>Z0[q0],enumerable:!0});return E0},kJ=new WeakMap,wq=(Z0)=>{var H0=kJ.get(Z0),$0;if(H0)return H0;if(H0=UY({},"__esModule",{value:!0}),Z0&&typeof Z0==="object"||typeof Z0==="function")_J(Z0).map((E0)=>!hJ.call(H0,E0)&&UY(H0,E0,{get:()=>Z0[E0],enumerable:!($0=Mq(Z0,E0))||$0.enumerable}));return kJ.set(Z0,H0),H0},Lq=(Z0,H0)=>()=>(H0||Z0((H0={exports:{}}).exports,H0),H0.exports);var bq=(Z0,H0)=>{for(var $0 in H0)UY(Z0,$0,{get:H0[$0],enumerable:!0,configurable:!0,set:(E0)=>H0[$0]=()=>E0})};var gJ=Lq((vJ,C7)=>{(function Z0(H0){(function($0,E0){typeof vJ==="object"&&typeof C7!=="undefined"?C7.exports=E0():typeof define==="function"&&define.amd?define(E0):($0=typeof globalThis!=="undefined"?globalThis:$0||self,$0.Hls=E0())})(this,function(){function $0(q,H,Z){if(P7())return Reflect.construct.apply(null,arguments);var Q=[null];Q.push.apply(Q,H);var Y=new(q.bind.apply(q,Q));return Z&&ZY(Y,Z.prototype),Y}function E0(q,H){for(var Z=0;Z<H.length;Z++){var Q=H[Z];Q.enumerable=Q.enumerable||!1,Q.configurable=!0,"value"in Q&&(Q.writable=!0),Object.defineProperty(q,S7(Q.key),Q)}}function q0(q,H,Z){return H&&E0(q.prototype,H),Z&&E0(q,Z),Object.defineProperty(q,"prototype",{writable:!1}),q}function pJ(q,H,Z){return(H=S7(H))in q?Object.defineProperty(q,H,{value:Z,enumerable:!0,configurable:!0,writable:!0}):q[H]=Z,q}function K0(){return K0=Object.assign?Object.assign.bind():function(q){for(var H=1;H<arguments.length;H++){var Z=arguments[H];for(var Q in Z)({}).hasOwnProperty.call(Z,Q)&&(q[Q]=Z[Q])}return q},K0.apply(null,arguments)}function gY(q){return gY=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(H){return H.__proto__||Object.getPrototypeOf(H)},gY(q)}function j0(q,H){q.prototype=Object.create(H.prototype),q.prototype.constructor=q,ZY(q,H)}function uJ(q){try{return Function.toString.call(q).indexOf("[native code]")!==-1}catch(H){return typeof q=="function"}}function P7(){try{var q=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(H){}return(P7=function(){return!!q})()}function D7(q,H){var Z=Object.keys(q);if(Object.getOwnPropertySymbols){var Q=Object.getOwnPropertySymbols(q);H&&(Q=Q.filter(function(Y){return Object.getOwnPropertyDescriptor(q,Y).enumerable})),Z.push.apply(Z,Q)}return Z}function I0(q){for(var H=1;H<arguments.length;H++){var Z=arguments[H]!=null?arguments[H]:{};H%2?D7(Object(Z),!0).forEach(function(Q){pJ(q,Q,Z[Q])}):Object.getOwnPropertyDescriptors?Object.defineProperties(q,Object.getOwnPropertyDescriptors(Z)):D7(Object(Z)).forEach(function(Q){Object.defineProperty(q,Q,Object.getOwnPropertyDescriptor(Z,Q))})}return q}function ZY(q,H){return ZY=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(Z,Q){return Z.__proto__=Q,Z},ZY(q,H)}function cJ(q,H){if(typeof q!="object"||!q)return q;var Z=q[Symbol.toPrimitive];if(Z!==void 0){var Q=Z.call(q,H);if(typeof Q!="object")return Q;throw new TypeError("@@toPrimitive must return a primitive value.")}return(H==="string"?String:Number)(q)}function S7(q){var H=cJ(q,"string");return typeof H=="symbol"?H:H+""}function qY(q){var H=typeof Map=="function"?new Map:void 0;return qY=function(Z){if(Z===null||!uJ(Z))return Z;if(typeof Z!="function")throw new TypeError("Super expression must either be null or a function");if(H!==void 0){if(H.has(Z))return H.get(Z);H.set(Z,Q)}function Q(){return $0(Z,arguments,gY(this).constructor)}return Q.prototype=Object.create(Z.prototype,{constructor:{value:Q,enumerable:!1,writable:!0,configurable:!0}}),ZY(Q,Z)},qY(q)}function fJ(){try{return crypto.randomUUID()}catch(Y){try{var q=URL.createObjectURL(new Blob),H=q.toString();return URL.revokeObjectURL(q),H.slice(H.lastIndexOf("/")+1)}catch(J){var Z=new Date().getTime(),Q="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(X){var z=(Z+Math.random()*16)%16|0;return Z=Math.floor(Z/16),(X=="x"?z:z&3|8).toString(16)});return Q}}}function x7(q){return q&&q.__esModule&&Object.prototype.hasOwnProperty.call(q,"default")?q.default:q}var mY={exports:{}},T7;function dJ(){if(T7)return mY.exports;return T7=1,function(q){var H=Object.prototype.hasOwnProperty,Z="~";function Q(){}if(Object.create){if(Q.prototype=Object.create(null),!new Q().__proto__)Z=!1}function Y(N,W,G){this.fn=N,this.context=W,this.once=G||!1}function J(N,W,G,K,j){if(typeof G!=="function")throw new TypeError("The listener must be a function");var V=new Y(G,K||N,j),U=Z?Z+W:W;if(!N._events[U])N._events[U]=V,N._eventsCount++;else if(!N._events[U].fn)N._events[U].push(V);else N._events[U]=[N._events[U],V];return N}function X(N,W){if(--N._eventsCount===0)N._events=new Q;else delete N._events[W]}function z(){this._events=new Q,this._eventsCount=0}z.prototype.eventNames=function N(){var W=[],G,K;if(this._eventsCount===0)return W;for(K in G=this._events)if(H.call(G,K))W.push(Z?K.slice(1):K);if(Object.getOwnPropertySymbols)return W.concat(Object.getOwnPropertySymbols(G));return W},z.prototype.listeners=function N(W){var G=Z?Z+W:W,K=this._events[G];if(!K)return[];if(K.fn)return[K.fn];for(var j=0,V=K.length,U=new Array(V);j<V;j++)U[j]=K[j].fn;return U},z.prototype.listenerCount=function N(W){var G=Z?Z+W:W,K=this._events[G];if(!K)return 0;if(K.fn)return 1;return K.length},z.prototype.emit=function N(W,G,K,j,V,U){var A=Z?Z+W:W;if(!this._events[A])return!1;var E=this._events[A],B=arguments.length,F,R;if(E.fn){if(E.once)this.removeListener(W,E.fn,void 0,!0);switch(B){case 1:return E.fn.call(E.context),!0;case 2:return E.fn.call(E.context,G),!0;case 3:return E.fn.call(E.context,G,K),!0;case 4:return E.fn.call(E.context,G,K,j),!0;case 5:return E.fn.call(E.context,G,K,j,V),!0;case 6:return E.fn.call(E.context,G,K,j,V,U),!0}for(R=1,F=new Array(B-1);R<B;R++)F[R-1]=arguments[R];E.fn.apply(E.context,F)}else{var O=E.length,M;for(R=0;R<O;R++){if(E[R].once)this.removeListener(W,E[R].fn,void 0,!0);switch(B){case 1:E[R].fn.call(E[R].context);break;case 2:E[R].fn.call(E[R].context,G);break;case 3:E[R].fn.call(E[R].context,G,K);break;case 4:E[R].fn.call(E[R].context,G,K,j);break;default:if(!F)for(M=1,F=new Array(B-1);M<B;M++)F[M-1]=arguments[M];E[R].fn.apply(E[R].context,F)}}}return!0},z.prototype.on=function N(W,G,K){return J(this,W,G,K,!1)},z.prototype.once=function N(W,G,K){return J(this,W,G,K,!0)},z.prototype.removeListener=function N(W,G,K,j){var V=Z?Z+W:W;if(!this._events[V])return this;if(!G)return X(this,V),this;var U=this._events[V];if(U.fn){if(U.fn===G&&(!j||U.once)&&(!K||U.context===K))X(this,V)}else{for(var A=0,E=[],B=U.length;A<B;A++)if(U[A].fn!==G||j&&!U[A].once||K&&U[A].context!==K)E.push(U[A]);if(E.length)this._events[V]=E.length===1?E[0]:E;else X(this,V)}return this},z.prototype.removeAllListeners=function N(W){var G;if(W){if(G=Z?Z+W:W,this._events[G])X(this,G)}else this._events=new Q,this._eventsCount=0;return this},z.prototype.off=z.prototype.removeListener,z.prototype.addListener=z.prototype.on,z.prefixed=Z,z.EventEmitter=z,q.exports=z}(mY),mY.exports}var lJ=dJ(),pY=x7(lJ),uY={exports:{}},y7;function nJ(){if(y7)return uY.exports;return y7=1,function(q,H){(function(Z){var Q=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,Y=/^(?=([^\/?#]*))\1([^]*)$/,J=/(?:\/|^)\.(?=\/)/g,X=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,z={buildAbsoluteURL:function(N,W,G){if(G=G||{},N=N.trim(),W=W.trim(),!W){if(!G.alwaysNormalize)return N;var K=z.parseURL(N);if(!K)throw new Error("Error trying to parse base URL.");return K.path=z.normalizePath(K.path),z.buildURLFromParts(K)}var j=z.parseURL(W);if(!j)throw new Error("Error trying to parse relative URL.");if(j.scheme){if(!G.alwaysNormalize)return W;return j.path=z.normalizePath(j.path),z.buildURLFromParts(j)}var V=z.parseURL(N);if(!V)throw new Error("Error trying to parse base URL.");if(!V.netLoc&&V.path&&V.path[0]!=="/"){var U=Y.exec(V.path);V.netLoc=U[1],V.path=U[2]}if(V.netLoc&&!V.path)V.path="/";var A={scheme:V.scheme,netLoc:j.netLoc,path:null,params:j.params,query:j.query,fragment:j.fragment};if(!j.netLoc){if(A.netLoc=V.netLoc,j.path[0]!=="/")if(!j.path){if(A.path=V.path,!j.params){if(A.params=V.params,!j.query)A.query=V.query}}else{var E=V.path,B=E.substring(0,E.lastIndexOf("/")+1)+j.path;A.path=z.normalizePath(B)}}if(A.path===null)A.path=G.alwaysNormalize?z.normalizePath(j.path):j.path;return z.buildURLFromParts(A)},parseURL:function(N){var W=Q.exec(N);if(!W)return null;return{scheme:W[1]||"",netLoc:W[2]||"",path:W[3]||"",params:W[4]||"",query:W[5]||"",fragment:W[6]||""}},normalizePath:function(N){N=N.split("").reverse().join("").replace(J,"");while(N.length!==(N=N.replace(X,"")).length);return N.split("").reverse().join("")},buildURLFromParts:function(N){return N.scheme+N.netLoc+N.path+N.params+N.query+N.fragment}};q.exports=z})()}(uY),uY.exports}var cY=nJ(),v=Number.isFinite||function(q){return typeof q==="number"&&isFinite(q)},oJ=Number.isSafeInteger||function(q){return typeof q==="number"&&Math.abs(q)<=sJ},sJ=Number.MAX_SAFE_INTEGER||9007199254740991,f=function(q){return q.NETWORK_ERROR="networkError",q.MEDIA_ERROR="mediaError",q.KEY_SYSTEM_ERROR="keySystemError",q.MUX_ERROR="muxError",q.OTHER_ERROR="otherError",q}({}),D=function(q){return q.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",q.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",q.KEY_SYSTEM_NO_SESSION="keySystemNoSession",q.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",q.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",q.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",q.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",q.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",q.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",q.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",q.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",q.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",q.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",q.MANIFEST_LOAD_ERROR="manifestLoadError",q.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",q.MANIFEST_PARSING_ERROR="manifestParsingError",q.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",q.LEVEL_EMPTY_ERROR="levelEmptyError",q.LEVEL_LOAD_ERROR="levelLoadError",q.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",q.LEVEL_PARSING_ERROR="levelParsingError",q.LEVEL_SWITCH_ERROR="levelSwitchError",q.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",q.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",q.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",q.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",q.FRAG_LOAD_ERROR="fragLoadError",q.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",q.FRAG_DECRYPT_ERROR="fragDecryptError",q.FRAG_PARSING_ERROR="fragParsingError",q.FRAG_GAP="fragGap",q.REMUX_ALLOC_ERROR="remuxAllocError",q.KEY_LOAD_ERROR="keyLoadError",q.KEY_LOAD_TIMEOUT="keyLoadTimeOut",q.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",q.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",q.BUFFER_APPEND_ERROR="bufferAppendError",q.BUFFER_APPENDING_ERROR="bufferAppendingError",q.BUFFER_STALLED_ERROR="bufferStalledError",q.BUFFER_FULL_ERROR="bufferFullError",q.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",q.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",q.ASSET_LIST_LOAD_ERROR="assetListLoadError",q.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",q.ASSET_LIST_PARSING_ERROR="assetListParsingError",q.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",q.INTERNAL_EXCEPTION="internalException",q.INTERNAL_ABORTED="aborted",q.ATTACH_MEDIA_ERROR="attachMediaError",q.UNKNOWN="unknown",q}({}),$=function(q){return q.MEDIA_ATTACHING="hlsMediaAttaching",q.MEDIA_ATTACHED="hlsMediaAttached",q.MEDIA_DETACHING="hlsMediaDetaching",q.MEDIA_DETACHED="hlsMediaDetached",q.MEDIA_ENDED="hlsMediaEnded",q.STALL_RESOLVED="hlsStallResolved",q.BUFFER_RESET="hlsBufferReset",q.BUFFER_CODECS="hlsBufferCodecs",q.BUFFER_CREATED="hlsBufferCreated",q.BUFFER_APPENDING="hlsBufferAppending",q.BUFFER_APPENDED="hlsBufferAppended",q.BUFFER_EOS="hlsBufferEos",q.BUFFERED_TO_END="hlsBufferedToEnd",q.BUFFER_FLUSHING="hlsBufferFlushing",q.BUFFER_FLUSHED="hlsBufferFlushed",q.MANIFEST_LOADING="hlsManifestLoading",q.MANIFEST_LOADED="hlsManifestLoaded",q.MANIFEST_PARSED="hlsManifestParsed",q.LEVEL_SWITCHING="hlsLevelSwitching",q.LEVEL_SWITCHED="hlsLevelSwitched",q.LEVEL_LOADING="hlsLevelLoading",q.LEVEL_LOADED="hlsLevelLoaded",q.LEVEL_UPDATED="hlsLevelUpdated",q.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",q.LEVELS_UPDATED="hlsLevelsUpdated",q.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",q.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",q.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",q.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",q.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",q.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",q.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",q.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",q.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",q.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",q.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",q.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",q.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",q.CUES_PARSED="hlsCuesParsed",q.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",q.INIT_PTS_FOUND="hlsInitPtsFound",q.FRAG_LOADING="hlsFragLoading",q.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",q.FRAG_LOADED="hlsFragLoaded",q.FRAG_DECRYPTED="hlsFragDecrypted",q.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",q.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",q.FRAG_PARSING_METADATA="hlsFragParsingMetadata",q.FRAG_PARSED="hlsFragParsed",q.FRAG_BUFFERED="hlsFragBuffered",q.FRAG_CHANGED="hlsFragChanged",q.FPS_DROP="hlsFpsDrop",q.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",q.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",q.ERROR="hlsError",q.DESTROYING="hlsDestroying",q.KEY_LOADING="hlsKeyLoading",q.KEY_LOADED="hlsKeyLoaded",q.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",q.BACK_BUFFER_REACHED="hlsBackBufferReached",q.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",q.ASSET_LIST_LOADING="hlsAssetListLoading",q.ASSET_LIST_LOADED="hlsAssetListLoaded",q.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",q.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",q.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",q.INTERSTITIAL_STARTED="hlsInterstitialStarted",q.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",q.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",q.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",q.INTERSTITIAL_ENDED="hlsInterstitialEnded",q.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",q.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",q.EVENT_CUE_ENTER="hlsEventCueEnter",q}({}),o={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},d={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"},s0=function(){function q(Z,Q,Y){if(Q===void 0)Q=0;if(Y===void 0)Y=0;this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=Z,this.alpha_=Z?Math.exp(Math.log(0.5)/Z):0,this.estimate_=Q,this.totalWeight_=Y}var H=q.prototype;return H.sample=function Z(Q,Y){var J=Math.pow(this.alpha_,Q);this.estimate_=Y*(1-J)+J*this.estimate_,this.totalWeight_+=Q},H.getTotalWeight=function Z(){return this.totalWeight_},H.getEstimate=function Z(){if(this.alpha_){var Q=1-Math.pow(this.alpha_,this.totalWeight_);if(Q)return this.estimate_/Q}return this.estimate_},q}(),iJ=function(){function q(Z,Q,Y,J){if(J===void 0)J=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_=Y,this.minWeight_=0.001,this.minDelayMs_=50,this.slow_=new s0(Z),this.fast_=new s0(Q),this.defaultTTFB_=J,this.ttfb_=new s0(Z)}var H=q.prototype;return H.update=function Z(Q,Y){var J=this.slow_,X=this.fast_,z=this.ttfb_;if(J.halfLife!==Q)this.slow_=new s0(Q,J.getEstimate(),J.getTotalWeight());if(X.halfLife!==Y)this.fast_=new s0(Y,X.getEstimate(),X.getTotalWeight());if(z.halfLife!==Q)this.ttfb_=new s0(Q,z.getEstimate(),z.getTotalWeight())},H.sample=function Z(Q,Y){Q=Math.max(Q,this.minDelayMs_);var J=8*Y,X=Q/1000,z=J/X;this.fast_.sample(X,z),this.slow_.sample(X,z)},H.sampleTTFB=function Z(Q){var Y=Q/1000,J=Math.sqrt(2)*Math.exp(-Math.pow(Y,2)/2);this.ttfb_.sample(J,Math.max(Q,5))},H.canEstimate=function Z(){return this.fast_.getTotalWeight()>=this.minWeight_},H.getEstimate=function Z(){if(this.canEstimate())return Math.min(this.fast_.getEstimate(),this.slow_.getEstimate());else return this.defaultEstimate_},H.getEstimateTTFB=function Z(){if(this.ttfb_.getTotalWeight()>=this.minWeight_)return this.ttfb_.getEstimate();else return this.defaultTTFB_},H.destroy=function Z(){},q0(q,[{key:"defaultEstimate",get:function Z(){return this.defaultEstimate_}}])}(),i0=function q(H,Z){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 Q="["+H+"]:";this.trace=f0,this.debug=Z.debug.bind(null,Q),this.log=Z.log.bind(null,Q),this.warn=Z.warn.bind(null,Q),this.info=Z.info.bind(null,Q),this.error=Z.error.bind(null,Q)},f0=function q(){},rJ={trace:f0,debug:f0,log:f0,warn:f0,info:f0,error:f0};function fY(){return K0({},rJ)}function aJ(q,H){var Z=self.console[q];return Z?Z.bind(self.console,(H?"["+H+"] ":"")+"["+q+"] >"):f0}function k7(q,H,Z){return H[q]?H[q].bind(H):aJ(q,Z)}var dY=fY();function _7(q,H,Z){var Q=fY();if(typeof console==="object"&&q===!0||typeof q==="object"){var Y=["debug","log","info","warn","error"];Y.forEach(function(J){Q[J]=k7(J,q,Z)});try{Q.log('Debug logs enabled for "'+H+'" in hls.js version 1.6.0')}catch(J){return fY()}Y.forEach(function(J){dY[J]=k7(J,q)})}else K0(dY,Q);return Q}var s=dY,lY,h7;function tJ(){if(h7)return lY;return h7=1,lY=void 0,lY}var v7=tJ(),eJ=x7(v7);function x0(q,H){if(H===void 0)H=!1;if(typeof TextDecoder!=="undefined"){var Z=new TextDecoder("utf-8"),Q=Z.decode(q);if(H){var Y=Q.indexOf("\x00");return Y!==-1?Q.substring(0,Y):Q}return Q.replace(/\0/g,"")}var J=q.length,X,z,N,W="",G=0;while(G<J){if(X=q[G++],X===0&&H)return W;else if(X===0||X===3)continue;switch(X>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:W+=String.fromCharCode(X);break;case 12:case 13:z=q[G++],W+=String.fromCharCode((X&31)<<6|z&63);break;case 14:z=q[G++],N=q[G++],W+=String.fromCharCode((X&15)<<12|(z&63)<<6|(N&63)<<0);break}}return W}var g7={hexDump:function q(H){var Z="";for(var Q=0;Q<H.length;Q++){var Y=H[Q].toString(16);if(Y.length<2)Y="0"+Y;Z+=Y}return Z}},nY=function q(){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}},Q0={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"},m7=function(){function q(Z){if(this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,typeof Z==="string")Z={url:Z};this.base=Z,Q8(this,"stats")}var H=q.prototype;return H.setByteRange=function Z(Q,Y){var J=Q.split("@",2),X;if(J.length===1)X=(Y==null?void 0:Y.byteRangeEndOffset)||0;else X=parseInt(J[1]);this._byteRange=[X,parseInt(J[0])+X]},H.clearElementaryStreamInfo=function Z(){var Q=this.elementaryStreams;Q[Q0.AUDIO]=null,Q[Q0.VIDEO]=null,Q[Q0.AUDIOVIDEO]=null},q0(q,[{key:"baseurl",get:function Z(){return this.base.url}},{key:"byteRange",get:function Z(){if(this._byteRange===null)return[];return this._byteRange}},{key:"byteRangeStartOffset",get:function Z(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function Z(){return this.byteRange[1]}},{key:"elementaryStreams",get:function Z(){if(this._streams===null){var Q;this._streams=(Q={},Q[Q0.AUDIO]=null,Q[Q0.VIDEO]=null,Q[Q0.AUDIOVIDEO]=null,Q)}return this._streams},set:function Z(Q){this._streams=Q}},{key:"hasStats",get:function Z(){return this._stats!==null}},{key:"hasStreams",get:function Z(){return this._streams!==null}},{key:"stats",get:function Z(){if(this._stats===null)this._stats=new nY;return this._stats},set:function Z(Q){this._stats=Q}},{key:"url",get:function Z(){if(!this._url&&this.baseurl&&this.relurl)this._url=cY.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0});return this._url||""},set:function Z(Q){this._url=Q}}])}();function h0(q){return q.sn!=="initSegment"}var oY=function(q){function H(Q,Y){var J=q.call(this,Y)||this;return J._decryptdata=null,J._programDateTime=null,J._ref=null,J._bitrate=void 0,J.rawProgramDateTime=null,J.tagList=[],J.duration=0,J.sn=0,J.levelkeys=void 0,J.type=void 0,J.loader=null,J.keyLoader=null,J.level=-1,J.cc=0,J.startPTS=void 0,J.endPTS=void 0,J.startDTS=void 0,J.endDTS=void 0,J.start=0,J.playlistOffset=0,J.deltaPTS=void 0,J.maxStartPTS=void 0,J.minEndPTS=void 0,J.data=void 0,J.bitrateTest=!1,J.title=null,J.initSegment=null,J.endList=void 0,J.gap=void 0,J.urlId=0,J.type=Q,J}j0(H,q);var Z=H.prototype;return Z.addStart=function Q(Y){this.setStart(this.start+Y)},Z.setStart=function Q(Y){if(this.start=Y,this._ref)this._ref.start=Y},Z.setDuration=function Q(Y){if(this.duration=Y,this._ref)this._ref.duration=Y},Z.setKeyFormat=function Q(Y){if(this.levelkeys){var J=this.levelkeys[Y];if(J&&!this._decryptdata)this._decryptdata=J.getDecryptData(this.sn)}},Z.abortRequests=function Q(){var Y,J;(Y=this.loader)==null||Y.abort(),(J=this.keyLoader)==null||J.abort()},Z.setElementaryStreamInfo=function Q(Y,J,X,z,N,W){if(W===void 0)W=!1;var G=this.elementaryStreams,K=G[Y];if(!K){G[Y]={startPTS:J,endPTS:X,startDTS:z,endDTS:N,partial:W};return}K.startPTS=Math.min(K.startPTS,J),K.endPTS=Math.max(K.endPTS,X),K.startDTS=Math.min(K.startDTS,z),K.endDTS=Math.max(K.endDTS,N)},q0(H,[{key:"byteLength",get:function Q(){if(this.hasStats){var Y=this.stats.total;if(Y)return Y}if(this.byteRange){var J=this.byteRange[0],X=this.byteRange[1];if(v(J)&&v(X))return X-J}return null}},{key:"bitrate",get:function Q(){if(this.byteLength)return this.byteLength*8/this.duration;if(this._bitrate)return this._bitrate;return null},set:function Q(Y){this._bitrate=Y}},{key:"decryptdata",get:function Q(){var Y=this.levelkeys;if(!Y&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var J=this.levelkeys.identity;if(J)this._decryptdata=J.getDecryptData(this.sn);else{var X=Object.keys(this.levelkeys);if(X.length===1)return this._decryptdata=this.levelkeys[X[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function Q(){return this.start+this.duration}},{key:"endProgramDateTime",get:function Q(){if(this.programDateTime===null)return null;var Y=!v(this.duration)?0:this.duration;return this.programDateTime+Y*1000}},{key:"encrypted",get:function Q(){var Y;if((Y=this._decryptdata)!=null&&Y.encrypted)return!0;else if(this.levelkeys){var J=Object.keys(this.levelkeys),X=J.length;if(X>1||X===1&&this.levelkeys[J[0]].encrypted)return!0}return!1}},{key:"programDateTime",get:function Q(){if(this._programDateTime===null&&this.rawProgramDateTime)this.programDateTime=Date.parse(this.rawProgramDateTime);return this._programDateTime},set:function Q(Y){if(!v(Y)){this._programDateTime=this.rawProgramDateTime=null;return}this._programDateTime=Y}},{key:"ref",get:function Q(){if(!h0(this))return null;if(!this._ref)this._ref={base:this.base,start:this.start,duration:this.duration,sn:this.sn,programDateTime:this.programDateTime};return this._ref}}])}(m7),Y8=function(q){function H(Z,Q,Y,J,X){var z=q.call(this,Y)||this;z.fragOffset=0,z.duration=0,z.gap=!1,z.independent=!1,z.relurl=void 0,z.fragment=void 0,z.index=void 0,z.duration=Z.decimalFloatingPoint("DURATION"),z.gap=Z.bool("GAP"),z.independent=Z.bool("INDEPENDENT"),z.relurl=Z.enumeratedString("URI"),z.fragment=Q,z.index=J;var N=Z.enumeratedString("BYTERANGE");if(N)z.setByteRange(N,X);if(X)z.fragOffset=X.fragOffset+X.duration;return z}return j0(H,q),q0(H,[{key:"start",get:function Z(){return this.fragment.start+this.fragOffset}},{key:"end",get:function Z(){return this.start+this.duration}},{key:"loaded",get:function Z(){var Q=this.elementaryStreams;return!!(Q.audio||Q.video||Q.audiovideo)}}])}(m7);function p7(q,H){var Z=Object.getPrototypeOf(q);if(Z){var Q=Object.getOwnPropertyDescriptor(Z,H);if(Q)return Q;return p7(Z,H)}}function Q8(q,H){var Z=p7(q,H);if(Z)Z.enumerable=!0,Object.defineProperty(q,H,Z)}var VY=Math.pow(2,32)-1,J8=[].push,u7={video:1,audio:2,id3:3,text:4};function U0(q){return String.fromCharCode.apply(null,q)}function c7(q,H){var Z=q[H]<<8|q[H+1];return Z<0?65536+Z:Z}function u(q,H){var Z=d7(q,H);return Z<0?4294967296+Z:Z}function f7(q,H){var Z=u(q,H);return Z*=Math.pow(2,32),Z+=u(q,H+4),Z}function d7(q,H){return q[H]<<24|q[H+1]<<16|q[H+2]<<8|q[H+3]}function sY(q,H,Z){q[H]=Z>>24,q[H+1]=Z>>16&255,q[H+2]=Z>>8&255,q[H+3]=Z&255}function Z8(q){var H=q.byteLength;for(var Z=0;Z<H;){var Q=u(q,Z);if(Q>8&&q[Z+4]===109&&q[Z+5]===111&&q[Z+6]===111&&q[Z+7]===102)return!0;Z=Q>1?Z+Q:H}return!1}function c(q,H){var Z=[];if(!H.length)return Z;var Q=q.byteLength;for(var Y=0;Y<Q;){var J=u(q,Y),X=U0(q.subarray(Y+4,Y+8)),z=J>1?Y+J:Q;if(X===H[0])if(H.length===1)Z.push(q.subarray(Y+8,z));else{var N=c(q.subarray(Y+8,z),H.slice(1));if(N.length)J8.apply(Z,N)}Y=z}return Z}function q8(q){var H=[],Z=q[0],Q=8,Y=u(q,Q);Q+=4;var J=0,X=0;if(Z===0)J=u(q,Q),X=u(q,Q+4),Q+=8;else J=f7(q,Q),X=f7(q,Q+8),Q+=16;Q+=2;var z=q.length+X,N=c7(q,Q);Q+=2;for(var W=0;W<N;W++){var G=Q,K=u(q,G);G+=4;var j=K&2147483647,V=(K&2147483648)>>>31;if(V===1)return s.warn("SIDX has hierarchical references (not supported)"),null;var U=u(q,G);G+=4,H.push({referenceSize:j,subsegmentDuration:U,info:{duration:U/Y,start:z,end:z+j-1}}),z+=j,G+=4,Q=G}return{earliestPresentationTime:J,timescale:Y,version:Z,referencesCount:N,references:H}}function l7(q){var H=[],Z=c(q,["moov","trak"]);for(var Q=0;Q<Z.length;Q++){var Y=Z[Q],J=c(Y,["tkhd"])[0];if(J){var X=J[0],z=u(J,X===0?12:20),N=c(Y,["mdia","mdhd"])[0];if(N){X=N[0];var W=u(N,X===0?12:20),G=c(Y,["mdia","hdlr"])[0];if(G){var K=U0(G.subarray(8,12)),j={soun:Q0.AUDIO,vide:Q0.VIDEO}[K],V=c(Y,["mdia","minf","stbl","stsd"])[0],U=X8(V);if(j)H[z]={timescale:W,type:j,stsd:U},H[j]=I0({timescale:W,id:z},U);else H[z]={timescale:W,type:K,stsd:U}}}}}var A=c(q,["moov","mvex","trex"]);return A.forEach(function(E){var B=u(E,4),F=H[B];if(F)F.default={duration:u(E,12),flags:u(E,20)}}),H}function X8(q){var H=q.subarray(8),Z=H.subarray(86),Q=U0(H.subarray(4,8)),Y=Q,J,X=Q==="enca"||Q==="encv";if(X){var z=c(H,[Q])[0],N=z.subarray(Q==="enca"?28:78),W=c(N,["sinf"]);W.forEach(function(O0){var S0=c(O0,["schm"])[0];if(S0){var Y0=U0(S0.subarray(4,8));if(Y0==="cbcs"||Y0==="cenc"){var R0=c(O0,["frma"])[0];if(R0)Y=U0(R0)}}})}var G=Y;switch(Y){case"avc1":case"avc2":case"avc3":case"avc4":{var K=c(Z,["avcC"])[0];Y+="."+EY(K[1])+EY(K[2])+EY(K[3]),J=AY(G==="avc1"?"dva1":"dvav",Z);break}case"mp4a":{var j=c(H,[Q])[0],V=c(j.subarray(28),["esds"])[0];if(V&&V.length>7){var U=4;if(V[U++]!==3)break;U=iY(V,U),U+=2;var A=V[U++];if(A&128)U+=2;if(A&64)U+=V[U++];if(V[U++]!==4)break;U=iY(V,U);var E=V[U++];if(E===64)Y+="."+EY(E);else break;if(U+=12,V[U++]!==5)break;U=iY(V,U);var B=V[U++],F=(B&248)>>3;if(F===31)F+=1+((B&7)<<3)+((V[U]&224)>>5);Y+="."+F}break}case"hvc1":case"hev1":{var R=c(Z,["hvcC"]);if(R){var O=R[0],M=O[1],L=["","A","B","C"][M>>6],I=M&31,w=u(O,2),S=(M&32)>>5?"H":"L",P=O[12],b=O.subarray(6,12);Y+="."+L+I,Y+="."+w.toString(16).toUpperCase(),Y+="."+S+P;var C="";for(var x=b.length;x--;){var _=b[x];if(_||C){var y=_.toString(16).toUpperCase();C="."+y+C}}Y+=C}J=AY(G=="hev1"?"dvhe":"dvh1",Z);break}case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":{Y=AY(Y,Z)||Y;break}case"vp09":{var T=c(Z,["vpcC"])[0],h=T[4],g=T[5],m=T[6]>>4&15;Y+="."+v0(h)+"."+v0(g)+"."+v0(m);break}case"av01":{var p=c(Z,["av1C"])[0],r=p[1]>>>5,n=p[1]&31,a=p[2]>>>7?"H":"M",l=(p[2]&64)>>6,z0=(p[2]&32)>>5,t=r===2&&l?z0?12:10:l?10:8,X0=(p[2]&16)>>4,L0=(p[2]&8)>>3,A0=(p[2]&4)>>2,e=p[2]&3,b0=1,W0=1,J0=1,C0=0;Y+="."+r+"."+v0(n)+a+"."+v0(t)+"."+X0+"."+L0+A0+e+"."+v0(b0)+"."+v0(W0)+"."+v0(J0)+"."+C0,J=AY("dav1",Z);break}}return{codec:Y,encrypted:X,supplemental:J}}function AY(q,H){var Z=c(H,["dvvC"]),Q=Z.length?Z[0]:c(H,["dvcC"])[0];if(Q){var Y=Q[2]>>1&127,J=Q[2]<<5&32|Q[3]>>3&31;return q+"."+v0(Y)+"."+v0(J)}}function iY(q,H){var Z=H+5;while(q[H++]&128&&H<Z);return H}function EY(q){return("0"+q.toString(16).toUpperCase()).slice(-2)}function v0(q){return(q<10?"0":"")+q}function H8(q,H){if(!q||!H)return q;var Z=H.keyId;if(Z&&H.isCommonEncryption){var Q=c(q,["moov","trak"]);Q.forEach(function(Y){var J=c(Y,["mdia","minf","stbl","stsd"])[0],X=J.subarray(8),z=c(X,["enca"]),N=z.length>0;if(!N)z=c(X,["encv"]);z.forEach(function(W){var G=N?W.subarray(28):W.subarray(78),K=c(G,["sinf"]);K.forEach(function(j){var V=z8(j);if(V){var U=V.subarray(8,24);if(!U.some(function(A){return A!==0}))s.log("[eme] Patching keyId in 'enc"+(N?"a":"v")+">sinf>>tenc' box: "+g7.hexDump(U)+" -> "+g7.hexDump(Z)),V.set(Z,8)}})})})}return q}function z8(q){var H=c(q,["schm"])[0];if(H){var Z=U0(H.subarray(4,8));if(Z==="cbcs"||Z==="cenc")return c(q,["schi","tenc"])[0]}return null}function N8(q,H){return c(H,["moof","traf"]).reduce(function(Z,Q){var Y=c(Q,["tfdt"])[0],J=Y[0],X=c(Q,["tfhd"]).reduce(function(z,N){var W=u(N,4),G=q[W];if(G){var K=u(Y,4);if(J===1){if(K===VY)return s.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),z;K*=VY+1,K+=u(Y,8)}var j=G.timescale||90000,V=K/j;if(v(V)&&(z===null||V<z))return V}return z},null);if(X!==null&&v(X)&&(Z===null||X<Z))return X;return Z},null)}function W8(q,H){var Z=0,Q=0,Y=0,J=c(q,["moof","traf"]);for(var X=0;X<J.length;X++){var z=J[X],N=c(z,["tfhd"])[0],W=u(N,4),G=H[W];if(!G)continue;var K=G.default,j=u(N,0)|(K==null?void 0:K.flags),V=K==null?void 0:K.duration;if(j&8)if(j&2)V=u(N,12);else V=u(N,8);var U=G.timescale||90000,A=c(z,["trun"]);for(var E=0;E<A.length;E++){if(Z=G8(A[E]),!Z&&V){var B=u(A[E],4);Z=V*B}if(G.type===Q0.VIDEO)Q+=Z/U;else if(G.type===Q0.AUDIO)Y+=Z/U}}if(Q===0&&Y===0){var F=1/0,R=0,O=0,M=c(q,["sidx"]);for(var L=0;L<M.length;L++){var I=q8(M[L]);if(I!=null&&I.references){F=Math.min(F,I.earliestPresentationTime/I.timescale);var w=I.references.reduce(function(S,P){return S+P.info.duration||0},0);R=Math.max(R,w+I.earliestPresentationTime/I.timescale),O=R-F}}if(O&&v(O))return O}if(Q)return Q;return Y}function G8(q){var H=u(q,0),Z=8;if(H&1)Z+=4;if(H&4)Z+=4;var Q=0,Y=u(q,4);for(var J=0;J<Y;J++){if(H&256){var X=u(q,Z);Q+=X,Z+=4}if(H&512)Z+=4;if(H&1024)Z+=4;if(H&2048)Z+=4}return Q}function K8(q,H,Z){c(H,["moof","traf"]).forEach(function(Q){c(Q,["tfhd"]).forEach(function(Y){var J=u(Y,4),X=q[J];if(!X)return;var z=X.timescale||90000;c(Q,["tfdt"]).forEach(function(N){var W=N[0],G=Z*z;if(G){var K=u(N,4);if(W===0)K-=G,K=Math.max(K,0),sY(N,4,K);else{K*=Math.pow(2,32),K+=u(N,8),K-=G,K=Math.max(K,0);var j=Math.floor(K/(VY+1)),V=Math.floor(K%(VY+1));sY(N,4,j),sY(N,8,V)}}})})})}function j8(q){var H={valid:null,remainder:null},Z=c(q,["moof"]);if(Z.length<2)return H.remainder=q,H;var Q=Z[Z.length-1];return H.valid=q.slice(0,Q.byteOffset-8),H.remainder=q.slice(Q.byteOffset-8),H}function T0(q,H){var Z=new Uint8Array(q.length+H.length);return Z.set(q),Z.set(H,q.length),Z}function n7(q,H){var Z=[],Q=H.samples,Y=H.timescale,J=H.id,X=!1,z=c(Q,["moof"]);return z.map(function(N){var W=N.byteOffset-8,G=c(N,["traf"]);G.map(function(K){var j=c(K,["tfdt"]).map(function(V){var U=V[0],A=u(V,4);if(U===1)A*=Math.pow(2,32),A+=u(V,8);return A/Y})[0];if(j!==void 0)q=j;return c(K,["tfhd"]).map(function(V){var U=u(V,4),A=u(V,0)&16777215,E=(A&1)!==0,B=(A&2)!==0,F=(A&8)!==0,R=0,O=(A&16)!==0,M=0,L=(A&32)!==0,I=8;if(U===J){if(E)I+=8;if(B)I+=4;if(F)R=u(V,I),I+=4;if(O)M=u(V,I),I+=4;if(L)I+=4;if(H.type==="video")X=rY(H.codec);c(K,["trun"]).map(function(w){var S=w[0],P=u(w,0)&16777215,b=(P&1)!==0,C=0,x=(P&4)!==0,_=(P&256)!==0,y=0,T=(P&512)!==0,h=0,g=(P&1024)!==0,m=(P&2048)!==0,p=0,r=u(w,4),n=8;if(b)C=u(w,n),n+=4;if(x)n+=4;var a=C+W;for(var l=0;l<r;l++){if(_)y=u(w,n),n+=4;else y=R;if(T)h=u(w,n),n+=4;else h=M;if(g)n+=4;if(m){if(S===0)p=u(w,n);else p=d7(w,n);n+=4}if(H.type===Q0.VIDEO){var z0=0;while(z0<h){var t=u(Q,a);if(a+=4,U8(X,Q[a])){var X0=Q.subarray(a,a+t);o7(X0,X?2:1,q+p/Y,Z)}a+=t,z0+=t+4}}q+=y/Y}})}})})}),Z}function rY(q){if(!q)return!1;var H=q.substring(0,4);return H==="hvc1"||H==="hev1"||H==="dvh1"||H==="dvhe"}function U8(q,H){if(q){var Z=H>>1&63;return Z===39||Z===40}else{var Q=H&31;return Q===6}}function o7(q,H,Z,Q){var Y=s7(q),J=0;J+=H;var X=0,z=0,N=0;while(J<Y.length){X=0;do{if(J>=Y.length)break;N=Y[J++],X+=N}while(N===255);z=0;do{if(J>=Y.length)break;N=Y[J++],z+=N}while(N===255);var W=Y.length-J,G=J;if(z<W)J+=z;else if(z>W){s.error("Malformed SEI payload. "+z+" is too small, only "+W+" bytes left to parse.");break}if(X===4){var K=Y[G++];if(K===181){var j=c7(Y,G);if(G+=2,j===49){var V=u(Y,G);if(G+=4,V===1195456820){var U=Y[G++];if(U===3){var A=Y[G++],E=31&A,B=64&A,F=B?2+E*3:0,R=new Uint8Array(F);if(B){R[0]=A;for(var O=1;O<F;O++)R[O]=Y[G++]}Q.push({type:U,payloadType:X,pts:Z,bytes:R})}}}}}else if(X===5){if(z>16){var M=[];for(var L=0;L<16;L++){var I=Y[G++].toString(16);if(M.push(I.length==1?"0"+I:I),L===3||L===5||L===7||L===9)M.push("-")}var w=z-16,S=new Uint8Array(w);for(var P=0;P<w;P++)S[P]=Y[G++];Q.push({payloadType:X,pts:Z,uuid:M.join(""),userData:x0(S),userDataBytes:S})}}}}function s7(q){var H=q.byteLength,Z=[],Q=1;while(Q<H-2)if(q[Q]===0&&q[Q+1]===0&&q[Q+2]===3)Z.push(Q+2),Q+=2;else Q++;if(Z.length===0)return q;var Y=H-Z.length,J=new Uint8Array(Y),X=0;for(Q=0;Q<Y;X++,Q++){if(X===Z[0])X++,Z.shift();J[Q]=q[X]}return J}function V8(q){var H=q[0],Z="",Q="",Y=0,J=0,X=0,z=0,N=0,W=0;if(H===0){while(U0(q.subarray(W,W+1))!=="\x00")Z+=U0(q.subarray(W,W+1)),W+=1;Z+=U0(q.subarray(W,W+1)),W+=1;while(U0(q.subarray(W,W+1))!=="\x00")Q+=U0(q.subarray(W,W+1)),W+=1;Q+=U0(q.subarray(W,W+1)),W+=1,Y=u(q,12),J=u(q,16),z=u(q,20),N=u(q,24),W=28}else if(H===1){W+=4,Y=u(q,W),W+=4;var G=u(q,W);W+=4;var K=u(q,W);if(W+=4,X=Math.pow(2,32)*G+K,!oJ(X))X=Number.MAX_SAFE_INTEGER,s.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box");z=u(q,W),W+=4,N=u(q,W),W+=4;while(U0(q.subarray(W,W+1))!=="\x00")Z+=U0(q.subarray(W,W+1)),W+=1;Z+=U0(q.subarray(W,W+1)),W+=1;while(U0(q.subarray(W,W+1))!=="\x00")Q+=U0(q.subarray(W,W+1)),W+=1;Q+=U0(q.subarray(W,W+1)),W+=1}var j=q.subarray(W,q.byteLength);return{schemeIdUri:Z,value:Q,timeScale:Y,presentationTime:X,presentationTimeDelta:J,eventDuration:z,id:N,payload:j}}function d0(q){if(q===void 0)q=!0;if(typeof self==="undefined")return;var H=(q||!self.MediaSource)&&self.ManagedMediaSource;return H||self.MediaSource||self.WebKitMediaSource}function A8(q){return typeof self!=="undefined"&&q===self.ManagedMediaSource}function E8(q,H){var Z=Object.keys(q),Q=Object.keys(H),Y=Z.length,J=Q.length;return!Y||!J||Y===J&&!Z.some(function(X){return Q.indexOf(X)===-1})}var i7=function q(){return/\(Windows.+Firefox\//i.test(navigator.userAgent)},r0={audio:{a3ds:1,"ac-3":0.95,"ac-4":1,alac:0.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":0.9,enca:1,fLaC:0.9,flac:0.9,FLAC:0.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:0.8,dav1:0.8,drac:1,dva1:1,dvav:1,dvh1:0.7,dvhe:0.7,encv:1,hev1:0.75,hvc1:0.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:0.9},text:{stpp:1,wvtt:1}};function r7(q,H){var Z=r0[H];return!!Z&&!!Z[q.slice(0,4)]}function aY(q,H,Z){if(Z===void 0)Z=!0;return!q.split(",").some(function(Q){return!a7(Q,H,Z)})}function a7(q,H,Z){var Q;if(Z===void 0)Z=!0;var Y=d0(Z);return(Q=Y==null?void 0:Y.isTypeSupported(XY(q,H)))!=null?Q:!1}function XY(q,H){return H+"/mp4;codecs="+q}function t7(q){if(q){var H=q.substring(0,4);return r0.video[H]}return 2}function BY(q){var H=i7();return q.split(",").reduce(function(Z,Q){var Y=H&&rY(Q),J=Y?9:r0.video[Q];if(J)return(J*2+Z)/(Z?3:2);return(r0.audio[Q]+Z)/(Z?2:1)},0)}var tY={};function B8(q,H){if(H===void 0)H=!0;if(tY[q])return tY[q];var Z={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[q];for(var Q=0;Q<Z.length;Q++){var Y;if(a7(Z[Q],"audio",H))return tY[q]=Z[Q],Z[Q];else if(Z[Q]==="mp3"&&(Y=d0(H))!=null&&Y.isTypeSupported("audio/mpeg"))return""}return q}var $8=/flac|opus|mp4a\.40\.34/i;function $Y(q,H){if(H===void 0)H=!0;return q.replace($8,function(Z){return B8(Z.toLowerCase(),H)})}function F8(q,H){var Z=[];if(q){var Q=q.split(",");for(var Y=0;Y<Q.length;Y++)if(!r7(Q[Y],"video"))Z.push(Q[Y])}if(H)Z.push(H);return Z.join(",")}function FY(q,H){if(q&&(q.length>4||["ac-3","ec-3","alac","fLaC","Opus"].indexOf(q)!==-1))return q;if(H){var Z=H.split(",");if(Z.length>1){if(q){for(var Q=Z.length;Q--;)if(Z[Q].substring(0,4)===q.substring(0,4))return Z[Q]}return Z[0]}}return H||q}function O8(q){var H=q.split(",");for(var Z=0;Z<H.length;Z++){var Q=H[Z].split(".");if(Q.length>2){var Y=Q.shift()+".";Y+=parseInt(Q.shift()).toString(16),Y+=("000"+parseInt(Q.shift()).toString(16)).slice(-4),H[Z]=Y}}return H.join(",")}function R8(q){if(q.startsWith("av01.")){var H=q.split("."),Z=["0","111","01","01","01","0"];for(var Q=H.length;Q>4&&Q<10;Q++)H[Q]=Z[Q-4];return H.join(".")}return q}function e7(q){var H=d0(q)||{isTypeSupported:function Z(){return!1}};return{mpeg:H.isTypeSupported("audio/mpeg"),mp3:H.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:!1}}function YQ(q){return q.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}var eY=["NONE","TYPE-0","TYPE-1",null];function M8(q){return eY.indexOf(q)>-1}var OY=["SDR","PQ","HLG"];function I8(q){return!!q&&OY.indexOf(q)>-1}var RY={No:"",Yes:"YES",v2:"v2"};function QQ(q){var{canSkipUntil:H,canSkipDateRanges:Z,age:Q}=q,Y=Q<H/2;if(H&&Y){if(Z)return RY.v2;return RY.Yes}return RY.No}var JQ=function(){function q(Z,Q,Y){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=Z,this.part=Q,this.skip=Y}var H=q.prototype;return H.addDirectives=function Z(Q){var Y=new self.URL(Q);if(this.msn!==void 0)Y.searchParams.set("_HLS_msn",this.msn.toString());if(this.part!==void 0)Y.searchParams.set("_HLS_part",this.part.toString());if(this.skip)Y.searchParams.set("_HLS_skip",this.skip);return Y.href},q}(),ZQ=function(){function q(Z){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=[Z.url],this._attrs=[Z.attrs],this.bitrate=Z.bitrate,Z.details)this.details=Z.details;if(this.id=Z.id||0,this.name=Z.name,this.width=Z.width||0,this.height=Z.height||0,this.frameRate=Z.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=Z.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=Z.audioCodec,this.videoCodec=Z.videoCodec,this.codecSet=[Z.videoCodec,Z.audioCodec].filter(function(J){return!!J}).map(function(J){return J.substring(0,4)}).join(","),"supplemental"in Z){var Q;this.supplemental=Z.supplemental;var Y=(Q=Z.supplemental)==null?void 0:Q.videoCodec;if(Y&&Y!==Z.videoCodec)this.codecSet+=","+Y.substring(0,4)}this.addGroupId("audio",Z.attrs.AUDIO),this.addGroupId("text",Z.attrs.SUBTITLES)}var H=q.prototype;return H.hasAudioGroup=function Z(Q){return qQ(this._audioGroups,Q)},H.hasSubtitleGroup=function Z(Q){return qQ(this._subtitleGroups,Q)},H.addGroupId=function Z(Q,Y){if(!Y)return;if(Q==="audio"){var J=this._audioGroups;if(!J)J=this._audioGroups=[];if(J.indexOf(Y)===-1)J.push(Y)}else if(Q==="text"){var X=this._subtitleGroups;if(!X)X=this._subtitleGroups=[];if(X.indexOf(Y)===-1)X.push(Y)}},H.addFallback=function Z(){},q0(q,[{key:"maxBitrate",get:function Z(){return Math.max(this.realBitrate,this.bitrate)}},{key:"averageBitrate",get:function Z(){return this._avgBitrate||this.realBitrate||this.bitrate}},{key:"attrs",get:function Z(){return this._attrs[0]}},{key:"codecs",get:function Z(){return this.attrs.CODECS||""}},{key:"pathwayId",get:function Z(){return this.attrs["PATHWAY-ID"]||"."}},{key:"videoRange",get:function Z(){return this.attrs["VIDEO-RANGE"]||"SDR"}},{key:"score",get:function Z(){return this.attrs.optionalFloat("SCORE",0)}},{key:"uri",get:function Z(){return this.url[0]||""}},{key:"audioGroups",get:function Z(){return this._audioGroups}},{key:"subtitleGroups",get:function Z(){return this._subtitleGroups}},{key:"urlId",get:function Z(){return 0},set:function Z(Q){}},{key:"audioGroupIds",get:function Z(){return this.audioGroups?[this.audioGroupId]:void 0}},{key:"textGroupIds",get:function Z(){return this.subtitleGroups?[this.textGroupId]:void 0}},{key:"audioGroupId",get:function Z(){var Q;return(Q=this.audioGroups)==null?void 0:Q[0]}},{key:"textGroupId",get:function Z(){var Q;return(Q=this.subtitleGroups)==null?void 0:Q[0]}}])}();function qQ(q,H){if(!H||!q)return!1;return q.indexOf(H)!==-1}function w8(){if(typeof matchMedia==="function"){var q=matchMedia("(dynamic-range: high)"),H=matchMedia("bad query");if(q.media!==H.media)return q.matches===!0}return!1}function L8(q,H){var Z=!1,Q=[];if(q)Z=q!=="SDR",Q=[q];if(H){Q=H.allowedVideoRanges||OY.slice(0);var Y=Q.join("")!=="SDR"&&!H.videoCodec;if(Z=H.preferHDR!==void 0?H.preferHDR:Y&&w8(),!Z)Q=["SDR"]}return{preferHDR:Z,allowedVideoRanges:Q}}var b8=function q(H){var Z=new WeakSet;return function(Q,Y){if(H)Y=H(Q,Y);if(typeof Y==="object"&&Y!==null){if(Z.has(Y))return;Z.add(Y)}return Y}},M0=function q(H,Z){return JSON.stringify(H,b8(Z))};function C8(q,H,Z,Q,Y){var J=Object.keys(q),X=Q==null?void 0:Q.channels,z=Q==null?void 0:Q.audioCodec,N=Y==null?void 0:Y.videoCodec,W=X&&parseInt(X)===2,G=!1,K=!1,j=1/0,V=1/0,U=1/0,A=1/0,E=0,B=[],F=L8(H,Y),R=F.preferHDR,O=F.allowedVideoRanges,M=function b(){var C=q[J[L]];G||(G=C.channels[2]>0),j=Math.min(j,C.minHeight),V=Math.min(V,C.minFramerate),U=Math.min(U,C.minBitrate);var x=O.filter(function(_){return C.videoRanges[_]>0});if(x.length>0)K=!0};for(var L=J.length;L--;)M();j=v(j)?j:0,V=v(V)?V:0;var I=Math.max(1080,j),w=Math.max(30,V);if(U=v(U)?U:Z,Z=Math.max(U,Z),!K)H=void 0;var S=J.length>1,P=J.reduce(function(b,C){var x=q[C];if(C===b)return b;if(B=K?O.filter(function(_){return x.videoRanges[_]>0}):[],S){if(x.minBitrate>Z)return g0(C,"min bitrate of "+x.minBitrate+" > current estimate of "+Z),b;if(!x.hasDefaultAudio)return g0(C,"no renditions with default or auto-select sound found"),b;if(z&&C.indexOf(z.substring(0,4))%5!==0)return g0(C,'audio codec preference "'+z+'" not found'),b;if(X&&!W){if(!x.channels[X])return g0(C,"no renditions with "+X+" channel sound found (channels options: "+Object.keys(x.channels)+")"),b}else if((!z||W)&&G&&x.channels["2"]===0)return g0(C,"no renditions with stereo sound found"),b;if(x.minHeight>I)return g0(C,"min resolution of "+x.minHeight+" > maximum of "+I),b;if(x.minFramerate>w)return g0(C,"min framerate of "+x.minFramerate+" > maximum of "+w),b;if(!B.some(function(_){return x.videoRanges[_]>0}))return g0(C,"no variants with VIDEO-RANGE of "+M0(B)+" found"),b;if(N&&C.indexOf(N.substring(0,4))%5!==0)return g0(C,'video codec preference "'+N+'" not found'),b;if(x.maxScore<E)return g0(C,"max score of "+x.maxScore+" < selected max of "+E),b}if(b&&(BY(C)>=BY(b)||x.fragmentError>q[b].fragmentError))return b;return A=x.minIndex,E=x.maxScore,C},void 0);return{codecSet:P,videoRanges:B,preferHDR:R,minFramerate:V,minBitrate:U,minIndex:A}}function g0(q,H){s.log('[abr] start candidates with "'+q+'" ignored because '+H)}function XQ(q){return q.reduce(function(H,Z){var Q=H.groups[Z.groupId];if(!Q)Q=H.groups[Z.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1};Q.tracks.push(Z);var Y=Z.channels||"2";if(Q.channels[Y]=(Q.channels[Y]||0)+1,Q.hasDefault=Q.hasDefault||Z.default,Q.hasAutoSelect=Q.hasAutoSelect||Z.autoselect,Q.hasDefault)H.hasDefaultAudio=!0;if(Q.hasAutoSelect)H.hasAutoSelectAudio=!0;return H},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function P8(q,H,Z,Q){return q.slice(Z,Q+1).reduce(function(Y,J,X){if(!J.codecSet)return Y;var z=J.audioGroups,N=Y[J.codecSet];if(!N)Y[J.codecSet]=N={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:X,maxScore:0,videoRanges:{SDR:0},channels:{"2":0},hasDefaultAudio:!z,fragmentError:0};N.minBitrate=Math.min(N.minBitrate,J.bitrate);var W=Math.min(J.height,J.width);return N.minHeight=Math.min(N.minHeight,W),N.minFramerate=Math.min(N.minFramerate,J.frameRate),N.minIndex=Math.min(N.minIndex,X),N.maxScore=Math.max(N.maxScore,J.score),N.fragmentError+=J.fragmentError,N.videoRanges[J.videoRange]=(N.videoRanges[J.videoRange]||0)+1,Y},{})}function HQ(q,H){var Z;return!!q&&q!==((Z=H.loadLevelObj)==null?void 0:Z.uri)}var D8=function(q){function H(Q){var Y=q.call(this,"abr",Q.logger)||this;return Y.hls=void 0,Y.lastLevelLoadSec=0,Y.lastLoadedFragLevel=-1,Y.firstSelection=-1,Y._nextAutoLevel=-1,Y.nextAutoLevelKey="",Y.audioTracksByGroup=null,Y.codecTiers=null,Y.timer=-1,Y.fragCurrent=null,Y.partCurrent=null,Y.bitrateTestDelay=0,Y.rebufferNotice=-1,Y.bwEstimator=void 0,Y._abandonRulesCheck=function(J){var X,z=Y,N=z.fragCurrent,W=z.partCurrent,G=z.hls,K=G.autoLevelEnabled,j=G.media;if(!N||!j)return;var V=performance.now(),U=W?W.stats:N.stats,A=W?W.duration:N.duration,E=V-U.loading.start,B=G.minAutoLevel,F=N.level,R=Y._nextAutoLevel;if(U.aborted||U.loaded&&U.loaded===U.total||F<=B){Y.clearTimer(),Y._nextAutoLevel=-1;return}if(!K)return;var O=R>-1&&R!==F,M=!!J||O;if(!M&&(j.paused||!j.playbackRate||!j.readyState))return;var L=G.mainForwardBufferInfo;if(!M&&L===null)return;var I=Y.bwEstimator.getEstimateTTFB(),w=Math.abs(j.playbackRate);if(E<=Math.max(I,1000*(A/(w*2))))return;var S=L?L.len/w:0,P=U.loading.first?U.loading.first-U.loading.start:-1,b=U.loaded&&P>-1,C=Y.getBwEstimate(),x=G.levels,_=x[F],y=Math.max(U.loaded,Math.round(A*(N.bitrate||_.averageBitrate)/8)),T=b?E-P:E;if(T<1&&b)T=Math.min(E,U.loaded*8/C);var h=b?U.loaded*1000/T:0,g=I/1000,m=h?(y-U.loaded)/h:y*8/C+g;if(m<=S)return;var p=h?h*8:C,r=((X=(J==null?void 0:J.details)||Y.hls.latestLevelDetails)==null?void 0:X.live)===!0,n=Y.hls.config.abrBandWidthUpFactor,a=Number.POSITIVE_INFINITY,l;for(l=F-1;l>B;l--){var z0=x[l].maxBitrate,t=!x[l].details||r;if(a=Y.getTimeToLoadFrag(g,p,A*z0,t),a<Math.min(S,A+g))break}if(a>=m)return;if(a>A*10)return;if(b)Y.bwEstimator.sample(E-Math.min(I,P),U.loaded);else Y.bwEstimator.sampleTTFB(E);var X0=x[l].maxBitrate;if(Y.getBwEstimate()*n>X0)Y.resetEstimator(X0);var L0=Y.findBestLevel(X0,B,l,0,S,1,1);if(L0>-1)l=L0;Y.warn("Fragment "+N.sn+(W?" part "+W.index:"")+" of level "+F+` is loading too slowly;
|
2
|
-
Fragment duration: `+N.duration.toFixed(3)+`
|
3
|
-
|
4
|
-
|
5
|
-
Estimated load time for
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
Time to underbuffer: `+b0.toFixed(3)+" s"),N.abortRequests(),Y.fragCurrent=Y.partCurrent=null,l>B){var W0=Y.findBestLevel(Y.hls.levels[B].bitrate,B,l,0,b0,1,1);if(W0===-1)W0=B;Y.hls.nextLoadLevel=Y.hls.nextAutoLevel=W0,Y.resetEstimator(Y.hls.levels[W0].bitrate)}}};if(O||m>a*2)A0();else Y.timer=self.setInterval(A0,a*1000);G.trigger($.FRAG_LOAD_EMERGENCY_ABORTED,{frag:N,part:W,stats:U})},Y.hls=Q,Y.bwEstimator=Y.initEstimator(),Y.registerListeners(),Y}j0(H,q);var Z=H.prototype;return Z.resetEstimator=function Q(Y){if(Y)this.log("setting initial bwe to "+Y),this.hls.config.abrEwmaDefaultEstimate=Y;this.firstSelection=-1,this.bwEstimator=this.initEstimator()},Z.initEstimator=function Q(){var Y=this.hls.config;return new iJ(Y.abrEwmaSlowVoD,Y.abrEwmaFastVoD,Y.abrEwmaDefaultEstimate)},Z.registerListeners=function Q(){var Y=this.hls;Y.on($.MANIFEST_LOADING,this.onManifestLoading,this),Y.on($.FRAG_LOADING,this.onFragLoading,this),Y.on($.FRAG_LOADED,this.onFragLoaded,this),Y.on($.FRAG_BUFFERED,this.onFragBuffered,this),Y.on($.LEVEL_SWITCHING,this.onLevelSwitching,this),Y.on($.LEVEL_LOADED,this.onLevelLoaded,this),Y.on($.LEVELS_UPDATED,this.onLevelsUpdated,this),Y.on($.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),Y.on($.ERROR,this.onError,this)},Z.unregisterListeners=function Q(){var Y=this.hls;if(!Y)return;Y.off($.MANIFEST_LOADING,this.onManifestLoading,this),Y.off($.FRAG_LOADING,this.onFragLoading,this),Y.off($.FRAG_LOADED,this.onFragLoaded,this),Y.off($.FRAG_BUFFERED,this.onFragBuffered,this),Y.off($.LEVEL_SWITCHING,this.onLevelSwitching,this),Y.off($.LEVEL_LOADED,this.onLevelLoaded,this),Y.off($.LEVELS_UPDATED,this.onLevelsUpdated,this),Y.off($.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),Y.off($.ERROR,this.onError,this)},Z.destroy=function Q(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null},Z.onManifestLoading=function Q(Y,J){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()},Z.onLevelsUpdated=function Q(){if(this.lastLoadedFragLevel>-1&&this.fragCurrent)this.lastLoadedFragLevel=this.fragCurrent.level;this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null},Z.onMaxAutoLevelUpdated=function Q(){this.firstSelection=-1,this.nextAutoLevelKey=""},Z.onFragLoading=function Q(Y,J){var X=J.frag;if(this.ignoreFragment(X))return;if(!X.bitrateTest){var z;this.fragCurrent=X,this.partCurrent=(z=J.part)!=null?z:null}this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)},Z.onLevelSwitching=function Q(Y,J){this.clearTimer()},Z.onError=function Q(Y,J){if(J.fatal)return;switch(J.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 X=J.frag,z=this.fragCurrent,N=this.partCurrent;if(X&&z&&X.sn===z.sn&&X.level===z.level){var W=performance.now(),G=N?N.stats:X.stats,K=W-G.loading.start,j=G.loading.first?G.loading.first-G.loading.start:-1,V=G.loaded&&j>-1;if(V){var U=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(K-Math.min(U,j),G.loaded)}else this.bwEstimator.sampleTTFB(K)}break}}},Z.getTimeToLoadFrag=function Q(Y,J,X,z){var N=Y+X/J,W=z?Y+this.lastLevelLoadSec:0;return N+W},Z.onLevelLoaded=function Q(Y,J){var X=this.hls.config,z=J.stats.loading,N=z.end-z.first;if(v(N))this.lastLevelLoadSec=N/1000;if(J.details.live)this.bwEstimator.update(X.abrEwmaSlowLive,X.abrEwmaFastLive);else this.bwEstimator.update(X.abrEwmaSlowVoD,X.abrEwmaFastVoD);if(this.timer>-1)this._abandonRulesCheck(J.levelInfo)},Z.onFragLoaded=function Q(Y,J){var{frag:X,part:z}=J,N=z?z.stats:X.stats;if(X.type===d.MAIN)this.bwEstimator.sampleTTFB(N.loading.first-N.loading.start);if(this.ignoreFragment(X))return;if(this.clearTimer(),X.level===this._nextAutoLevel)this._nextAutoLevel=-1;if(this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){var W=z?z.duration:X.duration,G=this.hls.levels[X.level],K=(G.loaded?G.loaded.bytes:0)+N.loaded,j=(G.loaded?G.loaded.duration:0)+W;G.loaded={bytes:K,duration:j},G.realBitrate=Math.round(8*K/j)}if(X.bitrateTest){var V={stats:N,frag:X,part:z,id:X.type};this.onFragBuffered($.FRAG_BUFFERED,V),X.bitrateTest=!1}else this.lastLoadedFragLevel=X.level},Z.onFragBuffered=function Q(Y,J){var{frag:X,part:z}=J,N=z!=null&&z.stats.loaded?z.stats:X.stats;if(N.aborted)return;if(this.ignoreFragment(X))return;var W=N.parsing.end-N.loading.start-Math.min(N.loading.first-N.loading.start,this.bwEstimator.getEstimateTTFB());if(this.bwEstimator.sample(W,N.loaded),N.bwEstimate=this.getBwEstimate(),X.bitrateTest)this.bitrateTestDelay=W/1000;else this.bitrateTestDelay=0},Z.ignoreFragment=function Q(Y){return Y.type!==d.MAIN||Y.sn==="initSegment"},Z.clearTimer=function Q(){if(this.timer>-1)self.clearInterval(this.timer),this.timer=-1},Z.getAutoLevelKey=function Q(){return this.getBwEstimate()+"_"+this.getStarvationDelay().toFixed(2)},Z.getNextABRAutoLevel=function Q(){var Y=this.fragCurrent,J=this.partCurrent,X=this.hls;if(X.levels.length<=1)return X.loadLevel;var{maxAutoLevel:z,config:N,minAutoLevel:W}=X,G=J?J.duration:Y?Y.duration:0,K=this.getBwEstimate(),j=this.getStarvationDelay(),V=N.abrBandWidthFactor,U=N.abrBandWidthUpFactor;if(j){var A=this.findBestLevel(K,W,z,j,0,V,U);if(A>=0)return this.rebufferNotice=-1,A}var E=G?Math.min(G,N.maxStarvationDelay):N.maxStarvationDelay;if(!j){var B=this.bitrateTestDelay;if(B){var F=G?Math.min(G,N.maxLoadingDelay):N.maxLoadingDelay;E=F-B,this.info("bitrate test took "+Math.round(1000*B)+"ms, set first fragment max fetchDuration to "+Math.round(1000*E)+" ms"),V=U=1}}var R=this.findBestLevel(K,W,z,j,E,V,U);if(this.rebufferNotice!==R)this.rebufferNotice=R,this.info((j?"rebuffering expected":"buffer is empty")+", optimal quality level "+R);if(R>-1)return R;var O=X.levels[W],M=X.loadLevelObj;if(M&&(O==null?void 0:O.bitrate)<M.bitrate)return W;return X.loadLevel},Z.getStarvationDelay=function Q(){var Y=this.hls,J=Y.media;if(!J)return 1/0;var X=J&&J.playbackRate!==0?Math.abs(J.playbackRate):1,z=Y.mainForwardBufferInfo;return(z?z.len:0)/X},Z.getBwEstimate=function Q(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate},Z.findBestLevel=function Q(Y,J,X,z,N,W,G){var K,j=this,V=z+N,U=this.lastLoadedFragLevel,A=U===-1?this.hls.firstLevel:U,E=this.fragCurrent,B=this.partCurrent,F=this.hls,R=F.levels,O=F.allAudioTracks,M=F.loadLevel,L=F.config;if(R.length===1)return 0;var I=R[A],w=!!((K=this.hls.latestLevelDetails)!=null&&K.live),S=M===-1||U===-1,P,b="SDR",C=(I==null?void 0:I.frameRate)||0,x=L.audioPreference,_=L.videoPreference,y=this.audioTracksByGroup||(this.audioTracksByGroup=XQ(O)),T=-1;if(S){if(this.firstSelection!==-1)return this.firstSelection;var h=this.codecTiers||(this.codecTiers=P8(R,y,J,X)),g=C8(h,b,Y,x,_),m=g.codecSet,p=g.videoRanges,r=g.minFramerate,n=g.minBitrate,a=g.minIndex,l=g.preferHDR;T=a,P=m,b=l?p[p.length-1]:p[0],C=r,Y=Math.max(Y,n),this.log("picked start tier "+M0(g))}else P=I==null?void 0:I.codecSet,b=I==null?void 0:I.videoRange;var z0=B?B.duration:E?E.duration:0,t=this.bwEstimator.getEstimateTTFB()/1000,X0=[],L0=function b0(){var W0,J0=R[e],C0=e>A;if(!J0)return 0;if(P&&J0.codecSet!==P||b&&J0.videoRange!==b||C0&&C>J0.frameRate||!C0&&C>0&&C<J0.frameRate||J0.supportedResult&&!((W0=J0.supportedResult.decodingInfoResults)!=null&&W0[0].smooth)){if(!S||e!==T)return X0.push(e),0}var O0=J0.details,S0=(B?O0==null?void 0:O0.partTarget:O0==null?void 0:O0.averagetargetduration)||z0,Y0;if(!C0)Y0=W*Y;else Y0=G*Y;var R0=z0&&z>=z0*2&&N===0?J0.averageBitrate:J0.maxBitrate,G0=j.getTimeToLoadFrag(t,Y0,R0*S0,O0===void 0),P0=Y0>=R0&&(e===U||J0.loadError===0&&J0.fragmentError===0)&&(G0<=t||!v(G0)||w&&!j.bitrateTestDelay||G0<V);if(P0){var jY=j.forcedAutoLevel;if(e!==M&&(jY===-1||jY!==M)){if(X0.length)j.trace("Skipped level(s) "+X0.join(",")+" of "+X+' max with CODECS and VIDEO-RANGE:"'+R[X0[0]].codecs+'" '+R[X0[0]].videoRange+'; not compatible with "'+P+'" '+b);j.info("switch candidate:"+A+"->"+e+" adjustedbw("+Math.round(Y0)+")-bitrate="+Math.round(Y0-R0)+" ttfb:"+t.toFixed(1)+" avgDuration:"+S0.toFixed(1)+" maxFetchDuration:"+V.toFixed(1)+" fetchDuration:"+G0.toFixed(1)+" firstSelection:"+S+" codecSet:"+J0.codecSet+" videoRange:"+J0.videoRange+" hls.loadLevel:"+M)}if(S)j.firstSelection=e;return{v:e}}},A0;for(var e=X;e>=J;e--){if(A0=L0(),A0===0)continue;if(A0)return A0.v}return-1},Z.deriveNextAutoLevel=function Q(Y){var J=this.hls,X=J.maxAutoLevel,z=J.minAutoLevel;return Math.min(Math.max(Y,z),X)},q0(H,[{key:"firstAutoLevel",get:function Q(){var Y=this.hls,J=Y.maxAutoLevel,X=Y.minAutoLevel,z=this.getBwEstimate(),N=this.hls.config.maxStarvationDelay,W=this.findBestLevel(z,X,J,0,N,1,1);if(W>-1)return W;var G=this.hls.firstLevel,K=Math.min(Math.max(G,X),J);return this.warn("Could not find best starting auto level. Defaulting to first in playlist "+G+" clamped to "+K),K}},{key:"forcedAutoLevel",get:function Q(){if(this.nextAutoLevelKey)return-1;return this._nextAutoLevel}},{key:"nextAutoLevel",get:function Q(){var Y=this.forcedAutoLevel,J=this.bwEstimator,X=J.canEstimate(),z=this.lastLoadedFragLevel>-1;if(Y!==-1&&(!X||!z||this.nextAutoLevelKey===this.getAutoLevelKey()))return Y;var N=X&&z?this.getNextABRAutoLevel():this.firstAutoLevel;if(Y!==-1){var W=this.hls.levels;if(W.length>Math.max(Y,N)&&W[Y].loadError<=W[N].loadError)return Y}return this._nextAutoLevel=N,this.nextAutoLevelKey=this.getAutoLevelKey(),N},set:function Q(Y){var J=this.deriveNextAutoLevel(Y);if(this._nextAutoLevel!==J)this.nextAutoLevelKey="",this._nextAutoLevel=J}}])}(i0),S8=function(){function q(Z){this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=Z}var H=q.prototype;return H.destroy=function Z(){this.tracks=this.queues=null},H.append=function Z(Q,Y,J){if(this.queues===null||this.tracks===null)return;var X=this.queues[Y];if(X.push(Q),X.length===1&&!J)this.executeNext(Y)},H.appendBlocker=function Z(Q){var Y=this;return new Promise(function(J){var X={label:"async-blocker",execute:J,onStart:function z(){},onComplete:function z(){},onError:function z(){}};Y.append(X,Q)})},H.prependBlocker=function Z(Q){var Y=this;return new Promise(function(J){if(Y.queues){var X={label:"async-blocker-prepend",execute:J,onStart:function z(){},onComplete:function z(){},onError:function z(){}};Y.queues[Q].unshift(X)}})},H.removeBlockers=function Z(){if(this.queues===null)return;[this.queues.video,this.queues.audio,this.queues.audiovideo].forEach(function(Q){var Y,J=(Y=Q[0])==null?void 0:Y.label;if(J==="async-blocker"||J==="async-blocker-prepend")Q[0].execute(),Q.splice(0,1)})},H.unblockAudio=function Z(Q){if(this.queues===null)return;var Y=this.queues.audio;if(Y[0]===Q)this.shiftAndExecuteNext("audio")},H.executeNext=function Z(Q){if(this.queues===null||this.tracks===null)return;var Y=this.queues[Q];if(Y.length){var J=Y[0];try{J.execute()}catch(N){var X;if(J.onError(N),this.queues===null||this.tracks===null)return;var z=(X=this.tracks[Q])==null?void 0:X.buffer;if(!(z!=null&&z.updating))this.shiftAndExecuteNext(Q)}}},H.shiftAndExecuteNext=function Z(Q){if(this.queues===null)return;this.queues[Q].shift(),this.executeNext(Q)},H.current=function Z(Q){var Y;return((Y=this.queues)==null?void 0:Y[Q][0])||null},H.toString=function Z(){var Q=this.queues,Y=this.tracks;if(Q===null||Y===null)return"<destroyed>";return`
|
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>":`
|
12
13
|
`+this.list("video")+`
|
13
14
|
`+this.list("audio")+`
|
14
|
-
`+this.list("audiovideo")+"}"},H.list=function Z(Q){var Y,J;return(Y=this.queues)!=null&&Y[Q]||(J=this.tracks)!=null&&J[Q]?Q+": ("+this.listSbInfo(Q)+") "+this.listOps(Q):""},H.listSbInfo=function Z(Q){var Y,J=(Y=this.tracks)==null?void 0:Y[Q],X=J==null?void 0:J.buffer;if(!X)return"none";return"SourceBuffer"+(X.updating?" updating":"")+(J.ended?" ended":"")+(J.ending?" ending":"")},H.listOps=function Z(Q){var Y;return((Y=this.queues)==null?void 0:Y[Q].map(function(J){return J.label}).join(", "))||""},q}(),zQ={search:function q(H,Z){var Q=0,Y=H.length-1,J=null,X=null;while(Q<=Y){J=(Q+Y)/2|0,X=H[J];var z=Z(X);if(z>0)Q=J+1;else if(z<0)Y=J-1;else return X}return null}};function x8(q,H,Z){if(H===null||!Array.isArray(q)||!q.length||!v(H))return null;var Q=q[0].programDateTime;if(H<(Q||0))return null;var Y=q[q.length-1].endProgramDateTime;if(H>=(Y||0))return null;Z=Z||0;for(var J=0;J<q.length;++J){var X=q[J];if(y8(H,Z,X))return X}return null}function Y7(q,H,Z,Q,Y){if(Z===void 0)Z=0;if(Q===void 0)Q=0;if(Y===void 0)Y=0.005;var J=null;if(q){J=H[1+q.sn-H[0].sn]||null;var X=q.endDTS-Z;if(X>0&&X<0.0000015)Z+=0.0000015;if(J&&q.level!==J.level&&J.end<=q.end)J=H[2+q.sn-H[0].sn]||null}else if(Z===0&&H[0].start===0)J=H[0];if(J&&((!q||q.level===J.level)&&NQ(Z,Q,J)===0||T8(J,q,Math.min(Y,Q))))return J;var z=zQ.search(H,NQ.bind(null,Z,Q));if(z&&(z!==q||!J))return z;return J}function T8(q,H,Z){if(H&&H.start===0&&H.level<q.level&&(H.endPTS||0)>0){var Q=H.tagList.reduce(function(Y,J){if(J[0]==="INF")Y+=parseFloat(J[1]);return Y},Z);return q.start<=Q}return!1}function NQ(q,H,Z){if(q===void 0)q=0;if(H===void 0)H=0;if(Z.start<=q&&Z.start+Z.duration>q)return 0;var Q=Math.min(H,Z.duration+(Z.deltaPTS?Z.deltaPTS:0));if(Z.start+Z.duration-Q<=q)return 1;else if(Z.start-Q>q&&Z.start)return-1;return 0}function y8(q,H,Z){var Q=Math.min(H,Z.duration+(Z.deltaPTS?Z.deltaPTS:0))*1000,Y=Z.endProgramDateTime||0;return Y-Q>q}function k8(q,H){return zQ.search(q,function(Z){if(Z.cc<H)return 1;else if(Z.cc>H)return-1;else return 0})}function MY(q){switch(q.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 WQ(q,H){var Z=MY(H);return q.default[(Z?"timeout":"error")+"Retry"]}function Q7(q,H){var Z=q.backoff==="linear"?1:Math.pow(2,H);return Math.min(Z*q.retryDelayMs,q.maxRetryDelayMs)}function GQ(q){return I0(I0({},q),{errorRetry:null,timeoutRetry:null})}function IY(q,H,Z,Q){if(!q)return!1;var Y=Q==null?void 0:Q.code,J=H<q.maxNumRetry&&(_8(Y)||!!Z);return q.shouldRetry?q.shouldRetry(q,H,Z,Q,J):J}function _8(q){return q===0&&navigator.onLine===!1||!!q&&(q<400||q>499)}var F0={DoNothing:0,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,RetryRequest:5},y0={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2},h8=function(q){function H(Q){var Y=q.call(this,"error-controller",Q.logger)||this;return Y.hls=void 0,Y.playlistError=0,Y.penalizedRenditions={},Y.hls=Q,Y.registerListeners(),Y}j0(H,q);var Z=H.prototype;return Z.registerListeners=function Q(){var Y=this.hls;Y.on($.ERROR,this.onError,this),Y.on($.MANIFEST_LOADING,this.onManifestLoading,this),Y.on($.LEVEL_UPDATED,this.onLevelUpdated,this)},Z.unregisterListeners=function Q(){var Y=this.hls;if(!Y)return;Y.off($.ERROR,this.onError,this),Y.off($.ERROR,this.onErrorOut,this),Y.off($.MANIFEST_LOADING,this.onManifestLoading,this),Y.off($.LEVEL_UPDATED,this.onLevelUpdated,this)},Z.destroy=function Q(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}},Z.startLoad=function Q(Y){},Z.stopLoad=function Q(){this.playlistError=0},Z.getVariantLevelIndex=function Q(Y){return(Y==null?void 0:Y.type)===d.MAIN?Y.level:this.hls.loadLevel},Z.onManifestLoading=function Q(){this.playlistError=0,this.penalizedRenditions={}},Z.onLevelUpdated=function Q(){this.playlistError=0},Z.onError=function Q(Y,J){var X;if(J.fatal)return;var z=this.hls,N=J.context;switch(J.details){case D.FRAG_LOAD_ERROR:case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_ERROR:case D.KEY_LOAD_TIMEOUT:J.errorAction=this.getFragRetryOrSwitchAction(J);return;case D.FRAG_PARSING_ERROR:if((X=J.frag)!=null&&X.gap){J.errorAction=wY();return}case D.FRAG_GAP:case D.FRAG_DECRYPT_ERROR:{J.errorAction=this.getFragRetryOrSwitchAction(J),J.errorAction.action=F0.SendAlternateToPenaltyBox;return}case D.LEVEL_EMPTY_ERROR:case D.LEVEL_PARSING_ERROR:{var W,G,K=J.parent===d.MAIN?J.level:z.loadLevel;if(J.details===D.LEVEL_EMPTY_ERROR&&!!((W=J.context)!=null&&(G=W.levelDetails)!=null&&G.live))J.errorAction=this.getPlaylistRetryOrSwitchAction(J,K);else J.levelRetry=!1,J.errorAction=this.getLevelSwitchAction(J,K)}return;case D.LEVEL_LOAD_ERROR:case D.LEVEL_LOAD_TIMEOUT:if(typeof(N==null?void 0:N.level)==="number")J.errorAction=this.getPlaylistRetryOrSwitchAction(J,N.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(N){var j=z.loadLevelObj;if(j&&(N.type===o.AUDIO_TRACK&&j.hasAudioGroup(N.groupId)||N.type===o.SUBTITLE_TRACK&&j.hasSubtitleGroup(N.groupId))){J.errorAction=this.getPlaylistRetryOrSwitchAction(J,z.loadLevel),J.errorAction.action=F0.SendAlternateToPenaltyBox,J.errorAction.flags=y0.MoveAllAlternatesMatchingHost;return}}return;case D.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{var V=z.loadLevelObj,U=V==null?void 0:V.attrs["HDCP-LEVEL"];if(U)J.errorAction={action:F0.SendAlternateToPenaltyBox,flags:y0.MoveAllAlternatesMatchingHDCP,hdcpLevel:U};else this.keySystemError(J)}return;case D.BUFFER_ADD_CODEC_ERROR:case D.REMUX_ALLOC_ERROR:case D.BUFFER_APPEND_ERROR:if(!J.errorAction){var A;J.errorAction=this.getLevelSwitchAction(J,(A=J.level)!=null?A:z.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:J.errorAction=wY();return}if(J.type===f.KEY_SYSTEM_ERROR)this.keySystemError(J)},Z.keySystemError=function Q(Y){var J=this.getVariantLevelIndex(Y.frag);Y.levelRetry=!1,Y.errorAction=this.getLevelSwitchAction(Y,J)},Z.getPlaylistRetryOrSwitchAction=function Q(Y,J){var X=this.hls,z=WQ(X.config.playlistLoadPolicy,Y),N=this.playlistError++,W=IY(z,N,MY(Y),Y.response);if(W)return{action:F0.RetryRequest,flags:y0.None,retryConfig:z,retryCount:N};var G=this.getLevelSwitchAction(Y,J);if(z)G.retryConfig=z,G.retryCount=N;return G},Z.getFragRetryOrSwitchAction=function Q(Y){var J=this.hls,X=this.getVariantLevelIndex(Y.frag),z=J.levels[X],N=J.config,W=N.fragLoadPolicy,G=N.keyLoadPolicy,K=WQ(Y.details.startsWith("key")?G:W,Y),j=J.levels.reduce(function(A,E){return A+E.fragmentError},0);if(z){if(Y.details!==D.FRAG_GAP)z.fragmentError++;var V=IY(K,j,MY(Y),Y.response);if(V)return{action:F0.RetryRequest,flags:y0.None,retryConfig:K,retryCount:j}}var U=this.getLevelSwitchAction(Y,X);if(K)U.retryConfig=K,U.retryCount=j;return U},Z.getLevelSwitchAction=function Q(Y,J){var X=this.hls;if(J===null||J===void 0)J=X.loadLevel;var z=this.hls.levels[J];if(z){var N,W,G=Y.details;if(z.loadError++,G===D.BUFFER_APPEND_ERROR)z.fragmentError++;var K=-1,j=X.levels,V=X.loadLevel,U=X.minAutoLevel,A=X.maxAutoLevel;if(!X.autoLevelEnabled)X.loadLevel=-1;var E=(N=Y.frag)==null?void 0:N.type,B=E===d.AUDIO&&G===D.FRAG_PARSING_ERROR||Y.sourceBufferName==="audio"&&(G===D.BUFFER_ADD_CODEC_ERROR||G===D.BUFFER_APPEND_ERROR),F=B&&j.some(function(b){var C=b.audioCodec;return z.audioCodec!==C}),R=Y.sourceBufferName==="video"&&(G===D.BUFFER_ADD_CODEC_ERROR||G===D.BUFFER_APPEND_ERROR),O=R&&j.some(function(b){var{codecSet:C,audioCodec:x}=b;return z.codecSet!==C&&z.audioCodec===x}),M=(W=Y.context)!=null?W:{},L=M.type,I=M.groupId,w=function b(){var C=(P+V)%j.length;if(C!==V&&C>=U&&C<=A&&j[C].loadError===0){var x,_,y=j[C];if(G===D.FRAG_GAP&&E===d.MAIN&&Y.frag){var T=j[C].details;if(T){var h=Y7(Y.frag,T.fragments,Y.frag.start);if(h!=null&&h.gap)return 0}}else if(L===o.AUDIO_TRACK&&y.hasAudioGroup(I)||L===o.SUBTITLE_TRACK&&y.hasSubtitleGroup(I))return 0;else if(E===d.AUDIO&&(x=z.audioGroups)!=null&&x.some(function(g){return y.hasAudioGroup(g)})||E===d.SUBTITLE&&(_=z.subtitleGroups)!=null&&_.some(function(g){return y.hasSubtitleGroup(g)})||F&&z.audioCodec===y.audioCodec||!F&&z.audioCodec!==y.audioCodec||O&&z.codecSet===y.codecSet)return 0;return K=C,1}},S;for(var P=j.length;P--;){if(S=w(),S===0)continue;if(S===1)break}if(K>-1&&X.loadLevel!==K)return Y.levelRetry=!0,this.playlistError=0,{action:F0.SendAlternateToPenaltyBox,flags:y0.None,nextAutoLevel:K}}return{action:F0.SendAlternateToPenaltyBox,flags:y0.MoveAllAlternatesMatchingHost}},Z.onErrorOut=function Q(Y,J){var X;switch((X=J.errorAction)==null?void 0:X.action){case F0.DoNothing:break;case F0.SendAlternateToPenaltyBox:if(this.sendAlternateToPenaltyBox(J),!J.errorAction.resolved&&J.details!==D.FRAG_GAP)J.fatal=!0;else if(/MediaSource readyState: ended/.test(J.error.message))this.warn('MediaSource ended after "'+J.sourceBufferName+'" sourceBuffer append error. Attempting to recover from media error.'),this.hls.recoverMediaError();break}if(J.fatal){this.hls.stopLoad();return}},Z.sendAlternateToPenaltyBox=function Q(Y){var J=this.hls,X=Y.errorAction;if(!X)return;var{flags:z,hdcpLevel:N,nextAutoLevel:W}=X;switch(z){case y0.None:this.switchLevel(Y,W);break;case y0.MoveAllAlternatesMatchingHDCP:if(N)J.maxHdcpLevel=eY[eY.indexOf(N)-1],X.resolved=!0;this.warn('Restricting playback to HDCP-LEVEL of "'+J.maxHdcpLevel+'" or lower');break}if(!X.resolved)this.switchLevel(Y,W)},Z.switchLevel=function Q(Y,J){if(J!==void 0&&Y.errorAction){if(this.warn("switching to level "+J+" after "+Y.details),this.hls.nextAutoLevel=J,Y.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel,Y.details===D.BUFFER_ADD_CODEC_ERROR&&Y.mimeType&&Y.sourceBufferName!=="audiovideo"){var X=YQ(Y.mimeType),z=this.hls.levels;for(var N=z.length;N--;)if(z[N][Y.sourceBufferName+"Codec"]===X)this.hls.removeLevel(N)}}},H}(i0);function wY(q){var H={action:F0.DoNothing,flags:y0.None};if(q)H.resolved=!0;return H}var KQ={length:0,start:function q(){return 0},end:function q(){return 0}},i=function(){function q(){}return q.isBuffered=function H(Z,Q){if(Z){var Y=q.getBuffered(Z);for(var J=Y.length;J--;)if(Q>=Y.start(J)&&Q<=Y.end(J))return!0}return!1},q.bufferedRanges=function H(Z){if(Z){var Q=q.getBuffered(Z);return q.timeRangesToArray(Q)}return[]},q.timeRangesToArray=function H(Z){var Q=[];for(var Y=0;Y<Z.length;Y++)Q.push({start:Z.start(Y),end:Z.end(Y)});return Q},q.bufferInfo=function H(Z,Q,Y){if(Z){var J=q.bufferedRanges(Z);if(J.length)return q.bufferedInfo(J,Q,Y)}return{len:0,start:Q,end:Q,bufferedIndex:-1}},q.bufferedInfo=function H(Z,Q,Y){if(Q=Math.max(0,Q),Z.length>1)Z.sort(function(B,F){return B.start-F.start||F.end-B.end});var J=-1,X=[];if(Y)for(var z=0;z<Z.length;z++){if(Q>=Z[z].start&&Q<=Z[z].end)J=z;var N=X.length;if(N){var W=X[N-1].end;if(Z[z].start-W<Y){if(Z[z].end>W)X[N-1].end=Z[z].end}else X.push(Z[z])}else X.push(Z[z])}else X=Z;var G=0,K,j=Q,V=Q;for(var U=0;U<X.length;U++){var A=X[U].start,E=X[U].end;if(J===-1&&Q>=A&&Q<=E)J=U;if(Q+Y>=A&&Q<E)j=A,V=E,G=V-Q;else if(Q+Y<A){K=A;break}}return{len:G,start:j||0,end:V||0,nextStart:K,buffered:Z,bufferedIndex:J}},q.getBuffered=function H(Z){try{return Z.buffered||KQ}catch(Q){return s.log("failed to get media.buffered",Q),KQ}},q}(),jQ=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,UQ="HlsJsTrackRemovedError",v8=function(q){function H(Z){var Q=q.call(this,Z)||this;return Q.name=UQ,Q}return j0(H,q),H}(qY(Error)),g8=function(q){function H(Q,Y){var J=q.call(this,"buffer-controller",Q.logger)||this;return J.hls=void 0,J.fragmentTracker=void 0,J.details=null,J._objectUrl=null,J.operationQueue=null,J.bufferCodecEventsTotal=0,J.media=null,J.mediaSource=null,J.lastMpegAudioChunk=null,J.blockedAudioAppend=null,J.lastVideoAppendEnd=0,J.appendSource=void 0,J.transferData=void 0,J.overrides=void 0,J.appendErrors={audio:0,video:0,audiovideo:0},J.tracks={},J.sourceBuffers=[[null,null],[null,null]],J._onEndStreaming=function(X){var z;if(!J.hls)return;if(((z=J.mediaSource)==null?void 0:z.readyState)!=="open")return;J.hls.pauseBuffering()},J._onStartStreaming=function(X){if(!J.hls)return;J.hls.resumeBuffering()},J._onMediaSourceOpen=function(X){var z=J,N=z.media,W=z.mediaSource;if(X)J.log("Media source opened");if(!N||!W)return;if(W.removeEventListener("sourceopen",J._onMediaSourceOpen),N.removeEventListener("emptied",J._onMediaEmptied),J.updateDuration(),J.hls.trigger($.MEDIA_ATTACHED,{media:N,mediaSource:W}),J.mediaSource!==null)J.checkPendingTracks()},J._onMediaSourceClose=function(){J.log("Media source closed")},J._onMediaSourceEnded=function(){J.log("Media source ended")},J._onMediaEmptied=function(){var X=J,z=X.mediaSrc,N=X._objectUrl;if(z!==N)J.error("Media element src was set while attaching MediaSource ("+N+" > "+z+")")},J.hls=Q,J.fragmentTracker=Y,J.appendSource=A8(d0(Q.config.preferManagedMediaSource)),J.initTracks(),J.registerListeners(),J}j0(H,q);var Z=H.prototype;return Z.hasSourceTypes=function Q(){return Object.keys(this.tracks).length>0},Z.destroy=function Q(){if(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},Z.registerListeners=function Q(){var Y=this.hls;Y.on($.MEDIA_ATTACHING,this.onMediaAttaching,this),Y.on($.MEDIA_DETACHING,this.onMediaDetaching,this),Y.on($.MANIFEST_LOADING,this.onManifestLoading,this),Y.on($.MANIFEST_PARSED,this.onManifestParsed,this),Y.on($.BUFFER_RESET,this.onBufferReset,this),Y.on($.BUFFER_APPENDING,this.onBufferAppending,this),Y.on($.BUFFER_CODECS,this.onBufferCodecs,this),Y.on($.BUFFER_EOS,this.onBufferEos,this),Y.on($.BUFFER_FLUSHING,this.onBufferFlushing,this),Y.on($.LEVEL_UPDATED,this.onLevelUpdated,this),Y.on($.FRAG_PARSED,this.onFragParsed,this),Y.on($.FRAG_CHANGED,this.onFragChanged,this),Y.on($.ERROR,this.onError,this)},Z.unregisterListeners=function Q(){var Y=this.hls;Y.off($.MEDIA_ATTACHING,this.onMediaAttaching,this),Y.off($.MEDIA_DETACHING,this.onMediaDetaching,this),Y.off($.MANIFEST_LOADING,this.onManifestLoading,this),Y.off($.MANIFEST_PARSED,this.onManifestParsed,this),Y.off($.BUFFER_RESET,this.onBufferReset,this),Y.off($.BUFFER_APPENDING,this.onBufferAppending,this),Y.off($.BUFFER_CODECS,this.onBufferCodecs,this),Y.off($.BUFFER_EOS,this.onBufferEos,this),Y.off($.BUFFER_FLUSHING,this.onBufferFlushing,this),Y.off($.LEVEL_UPDATED,this.onLevelUpdated,this),Y.off($.FRAG_PARSED,this.onFragParsed,this),Y.off($.FRAG_CHANGED,this.onFragChanged,this),Y.off($.ERROR,this.onError,this)},Z.transferMedia=function Q(){var Y=this,J=this.media,X=this.mediaSource;if(!J)return null;var z={};if(this.operationQueue){var N=this.isUpdating();if(!N)this.operationQueue.removeBlockers();var W=this.isQueued();if(N||W)this.warn("Transfering MediaSource with"+(W?" operations in queue":"")+(N?" updating SourceBuffer(s)":"")+" "+this.operationQueue);this.operationQueue.destroy()}var G=this.transferData;if(!this.sourceBufferCount&&G&&G.mediaSource===X)K0(z,G.tracks);else this.sourceBuffers.forEach(function(K){var j=K[0];if(j)z[j]=K0({},Y.tracks[j]),Y.removeBuffer(j);K[0]=K[1]=null});return{media:J,mediaSource:X,tracks:z}},Z.initTracks=function Q(){var Y={};this.sourceBuffers=[[null,null],[null,null]],this.tracks=Y,this.resetQueue(),this.resetAppendErrors(),this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.lastVideoAppendEnd=0},Z.onManifestLoading=function Q(){this.bufferCodecEventsTotal=0,this.details=null},Z.onManifestParsed=function Q(Y,J){var X,z=2;if(J.audio&&!J.video||J.altAudio,z=1,this.bufferCodecEventsTotal=z,this.log(z+" bufferCodec event(s) expected."),(X=this.transferData)!=null&&X.mediaSource&&this.sourceBufferCount&&z)this.bufferCreated()},Z.onMediaAttaching=function Q(Y,J){var X=this.media=J.media,z=d0(this.appendSource);if(this.transferData=this.overrides=void 0,X&&z){var N=!!J.mediaSource;if(N||J.overrides)this.transferData=J,this.overrides=J.overrides;var W=this.mediaSource=J.mediaSource||new z;if(this.assignMediaSource(W),N)this._objectUrl=X.src,this.attachTransferred();else{var G=this._objectUrl=self.URL.createObjectURL(W);if(this.appendSource)try{X.removeAttribute("src");var K=self.ManagedMediaSource;X.disableRemotePlayback=X.disableRemotePlayback||K&&W instanceof K,VQ(X),m8(X,G),X.load()}catch(j){X.src=G}else X.src=G}X.addEventListener("emptied",this._onMediaEmptied)}},Z.assignMediaSource=function Q(Y){var J,X;if(this.log((((J=this.transferData)==null?void 0:J.mediaSource)===Y?"transferred":"created")+" media source: "+((X=Y.constructor)==null?void 0:X.name)),Y.addEventListener("sourceopen",this._onMediaSourceOpen),Y.addEventListener("sourceended",this._onMediaSourceEnded),Y.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource)Y.addEventListener("startstreaming",this._onStartStreaming),Y.addEventListener("endstreaming",this._onEndStreaming)},Z.attachTransferred=function Q(){var Y=this,J=this.media,X=this.transferData;if(!X||!J)return;var z=this.tracks,N=X.tracks,W=N?Object.keys(N):null,G=W?W.length:0,K=function A(){if(Y.media&&Y.mediaSourceOpenOrEnded)Y._onMediaSourceOpen()};if(N&&W&&G){if(!this.tracksReady){this.hls.config.startFragPrefetch=!0,this.log("attachTransferred: waiting for SourceBuffer track info");return}if(this.log("attachTransferred: (bufferCodecEventsTotal "+this.bufferCodecEventsTotal+`)
|
15
|
-
required tracks: `+
|
16
|
-
transfer tracks: `+M0(N,function(A,E){return A==="initSegment"?void 0:E})+"}"),!E8(N,z)){X.mediaSource=null,X.tracks=void 0;var j=J.currentTime,V=this.details,U=Math.max(j,(V==null?void 0:V.fragments[0].start)||0);if(U-j>1){this.log("attachTransferred: waiting for playback to reach new tracks start time "+j+" -> "+U);return}this.warn('attachTransferred: resetting MediaSource for incompatible tracks ("'+Object.keys(N)+'"->"'+Object.keys(z)+'") start time: '+U+" currentTime: "+j),this.onMediaDetaching($.MEDIA_DETACHING,{}),this.onMediaAttaching($.MEDIA_ATTACHING,X),J.currentTime=U;return}this.transferData=void 0,W.forEach(function(A){var E=A,B=N[E];if(B){var F=B.buffer;if(F){var R=Y.fragmentTracker,O=B.id;if(R.hasFragments(O)||R.hasParts(O)){var M=i.getBuffered(F);R.detectEvictedFragments(E,M,O,null,!0)}var L=J7(E),I=[E,F];if(Y.sourceBuffers[L]=I,F.updating&&Y.operationQueue)Y.operationQueue.prependBlocker(E);Y.trackSourceBuffer(E,B)}}}),K(),this.bufferCreated()}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),K()},Z.onMediaDetaching=function Q(Y,J){var X=this,z=!!J.transferMedia;this.transferData=this.overrides=void 0;var N=this.media,W=this.mediaSource,G=this._objectUrl;if(W){if(this.log("media source "+(z?"transferring":"detaching")),z)this.sourceBuffers.forEach(function(U){var A=U[0];if(A)X.removeBuffer(A)}),this.resetQueue();else{if(this.mediaSourceOpenOrEnded){var K=W.readyState==="open";try{var j=W.sourceBuffers;for(var V=j.length;V--;){if(K)j[V].abort();W.removeSourceBuffer(j[V])}if(K)W.endOfStream()}catch(U){this.warn("onMediaDetaching: "+U.message+" while calling endOfStream")}}if(this.sourceBufferCount)this.onBufferReset()}if(W.removeEventListener("sourceopen",this._onMediaSourceOpen),W.removeEventListener("sourceended",this._onMediaSourceEnded),W.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource)W.removeEventListener("startstreaming",this._onStartStreaming),W.removeEventListener("endstreaming",this._onEndStreaming);this.mediaSource=null,this._objectUrl=null}if(N){if(N.removeEventListener("emptied",this._onMediaEmptied),!z){if(G)self.URL.revokeObjectURL(G);if(this.mediaSrc===G){if(N.removeAttribute("src"),this.appendSource)VQ(N);N.load()}else this.warn("media|source.src was changed by a third party - skip cleanup")}this.media=null}this.hls.trigger($.MEDIA_DETACHED,J)},Z.onBufferReset=function Q(){var Y=this;this.sourceBuffers.forEach(function(J){var X=J[0];if(X)Y.resetBuffer(X)}),this.initTracks()},Z.resetBuffer=function Q(Y){var J,X=(J=this.tracks[Y])==null?void 0:J.buffer;if(this.removeBuffer(Y),X)try{var z;if((z=this.mediaSource)!=null&&z.sourceBuffers.length)this.mediaSource.removeSourceBuffer(X)}catch(N){this.warn("onBufferReset "+Y,N)}delete this.tracks[Y]},Z.removeBuffer=function Q(Y){this.removeBufferListeners(Y),this.sourceBuffers[J7(Y)]=[null,null];var J=this.tracks[Y];if(J)J.buffer=void 0},Z.resetQueue=function Q(){if(this.operationQueue)this.operationQueue.destroy();this.operationQueue=new S8(this.tracks)},Z.onBufferCodecs=function Q(Y,J){var X=this,z=this.tracks,N=Object.keys(J);this.log('BUFFER_CODECS: "'+N+'" (current SB count '+this.sourceBufferCount+")");var W="audiovideo"in J&&(z.audio||z.video)||z.audiovideo&&(("audio"in J)||("video"in J)),G=!W&&this.sourceBufferCount&&this.media&&N.some(function(K){return!z[K]});if(W||G){this.warn('Unsupported transition between "'+Object.keys(z)+'" and "'+N+'" SourceBuffers');return}if(N.forEach(function(K){var j,V,U,A=J[K],E=A.id,B=A.codec,F=A.levelCodec,R=A.container,O=A.metadata,M=A.supplemental,L=z[K],I=(j=X.transferData)==null?void 0:(V=j.tracks)==null?void 0:V[K],w=I!=null&&I.buffer?I:L,S=(w==null?void 0:w.pendingCodec)||(w==null?void 0:w.codec),P=w==null?void 0:w.levelCodec;if(!L)L=z[K]={buffer:void 0,listeners:[],codec:B,supplemental:M,container:R,levelCodec:F,metadata:O,id:E};var b=FY(S,P),C=b==null?void 0:b.replace(jQ,"$1"),x=FY(B,F),_=(U=x)==null?void 0:U.replace(jQ,"$1");if(x&&b&&C!==_){if(K.slice(0,5)==="audio")x=$Y(x,X.appendSource);if(X.log("switching codec "+S+" to "+x),x!==(L.pendingCodec||L.codec))L.pendingCodec=x;L.container=R,X.appendChangeType(K,R,x)}}),this.tracksReady||this.sourceBufferCount)J.tracks=this.sourceBufferTracks;if(this.sourceBufferCount)return;if(this.mediaSourceOpenOrEnded)this.checkPendingTracks()},Z.appendChangeType=function Q(Y,J,X){var z=this,N=J+";codecs="+X,W={label:"change-type="+N,execute:function G(){var K=z.tracks[Y];if(K){var j=K.buffer;if(j!=null&&j.changeType)z.log("changing "+Y+" sourceBuffer type to "+N),j.changeType(N),K.codec=X,K.container=J}z.shiftAndExecuteNext(Y)},onStart:function G(){},onComplete:function G(){},onError:function G(K){z.warn("Failed to change "+Y+" SourceBuffer type",K)}};this.append(W,Y,this.isPending(this.tracks[Y]))},Z.blockAudio=function Q(Y){var J,X=this,z=Y.start,N=z+Y.duration*0.05,W=((J=this.fragmentTracker.getAppendedFrag(z,d.MAIN))==null?void 0:J.gap)===!0;if(W)return;var G={label:"block-audio",execute:function K(){var j,V=X.tracks.video;if(X.lastVideoAppendEnd>N||V!=null&&V.buffer&&i.isBuffered(V.buffer,N)||((j=X.fragmentTracker.getAppendedFrag(N,d.MAIN))==null?void 0:j.gap)===!0)X.blockedAudioAppend=null,X.shiftAndExecuteNext("audio")},onStart:function K(){},onComplete:function K(){},onError:function K(j){X.warn("Error executing block-audio operation",j)}};this.blockedAudioAppend={op:G,frag:Y},this.append(G,"audio",!0)},Z.unblockAudio=function Q(){var Y=this.blockedAudioAppend,J=this.operationQueue;if(Y&&J)this.blockedAudioAppend=null,J.unblockAudio(Y.op)},Z.onBufferAppending=function Q(Y,J){var X=this,z=this.tracks,N=J.data,W=J.type,G=J.parent,K=J.frag,j=J.part,V=J.chunkMeta,U=V.buffering[W],A=K.sn,E=self.performance.now();U.start=E;var B=K.stats.buffering,F=j?j.stats.buffering:null;if(B.start===0)B.start=E;if(F&&F.start===0)F.start=E;var R=z.audio,O=!1;if(W==="audio"&&(R==null?void 0:R.container)==="audio/mpeg")O=!this.lastMpegAudioChunk||V.id===1||this.lastMpegAudioChunk.sn!==V.sn,this.lastMpegAudioChunk=V;var M=this.tracks.video,L=M==null?void 0:M.buffer;if(L&&A!=="initSegment"){var I=j||K,w=this.blockedAudioAppend;if(W==="audio"&&G!=="main"&&!this.blockedAudioAppend){var S=I.start,P=S+I.duration*0.05,b=L.buffered,C=this.currentOp("video");if(!b.length&&!C)this.blockAudio(I);else if(!C&&!i.isBuffered(L,P)&&this.lastVideoAppendEnd<P)this.blockAudio(I)}else if(W==="video"){var x=I.end;if(w){var _=w.frag.start;if(x>_||x<this.lastVideoAppendEnd||i.isBuffered(L,_))this.unblockAudio()}this.lastVideoAppendEnd=x}}var y=(j||K).start,T={label:"append-"+W,execute:function h(){if(U.executeStart=self.performance.now(),O){var g=X.tracks[W];if(g){var m=g.buffer;if(m){var p=y-m.timestampOffset;if(Math.abs(p)>=0.1)X.log("Updating audio SourceBuffer timestampOffset to "+y+" (delta: "+p+") sn: "+A+")"),m.timestampOffset=y}}}X.appendExecutor(N,W)},onStart:function h(){},onComplete:function h(){var g=self.performance.now();if(U.executeEnd=U.end=g,B.first===0)B.first=g;if(F&&F.first===0)F.first=g;var m={};if(X.sourceBuffers.forEach(function(p){var r=p[0],n=p[1];if(r)m[r]=i.getBuffered(n)}),X.appendErrors[W]=0,W==="audio"||W==="video")X.appendErrors.audiovideo=0;else X.appendErrors.audio=0,X.appendErrors.video=0;X.hls.trigger($.BUFFER_APPENDED,{type:W,frag:K,part:j,chunkMeta:V,parent:K.type,timeRanges:m})},onError:function h(g){var m,p={type:f.MEDIA_ERROR,parent:K.type,details:D.BUFFER_APPEND_ERROR,sourceBufferName:W,frag:K,part:j,chunkMeta:V,error:g,err:g,fatal:!1};if(g.code===DOMException.QUOTA_EXCEEDED_ERR)p.details=D.BUFFER_FULL_ERROR;else if(g.code===DOMException.INVALID_STATE_ERR&&X.mediaSourceOpenOrEnded&&!((m=X.media)!=null&&m.error))p.errorAction=wY(!0);else if(g.name===UQ)if(X.sourceBufferCount===0)p.errorAction=wY(!0);else++X.appendErrors[W];else{var r=++X.appendErrors[W];if(X.warn("Failed "+r+"/"+X.hls.config.appendErrorMaxRetry+' times to append segment in "'+W+'" sourceBuffer'),r>=X.hls.config.appendErrorMaxRetry)p.fatal=!0}X.hls.trigger($.ERROR,p)}};this.append(T,W,this.isPending(this.tracks[W]))},Z.getFlushOp=function Q(Y,J,X){var z=this;return this.log('queuing "'+Y+'" remove '+J+"-"+X),{label:"remove",execute:function N(){z.removeExecutor(Y,J,X)},onStart:function N(){},onComplete:function N(){z.hls.trigger($.BUFFER_FLUSHED,{type:Y})},onError:function N(W){z.warn("Failed to remove "+J+"-"+X+' from "'+Y+'" SourceBuffer',W)}}},Z.onBufferFlushing=function Q(Y,J){var X=this,z=J.type,N=J.startOffset,W=J.endOffset;if(z)this.append(this.getFlushOp(z,N,W),z);else this.sourceBuffers.forEach(function(G){var K=G[0];if(K)X.append(X.getFlushOp(K,N,W),K)})},Z.onFragParsed=function Q(Y,J){var X=this,z=J.frag,N=J.part,W=[],G=N?N.elementaryStreams:z.elementaryStreams;if(G[Q0.AUDIOVIDEO])W.push("audiovideo");else{if(G[Q0.AUDIO])W.push("audio");if(G[Q0.VIDEO])W.push("video")}var K=function j(){var V=self.performance.now();if(z.stats.buffering.end=V,N)N.stats.buffering.end=V;var U=N?N.stats:z.stats;X.hls.trigger($.FRAG_BUFFERED,{frag:z,part:N,stats:U,id:z.type})};if(W.length===0)this.warn("Fragments must have at least one ElementaryStreamType set. type: "+z.type+" level: "+z.level+" sn: "+z.sn);this.blockBuffers(K,W)},Z.onFragChanged=function Q(Y,J){this.trimBuffers()},Z.onBufferEos=function Q(Y,J){var X=this,z;this.sourceBuffers.forEach(function(G){var K=G[0];if(K){var j=X.tracks[K];if(!J.type||J.type===K){if(j.ending=!0,!j.ended)j.ended=!0,X.log(K+" buffer reached EOS")}}});var N=((z=this.overrides)==null?void 0:z.endOfStream)!==!1,W=this.sourceBufferCount>0&&!this.sourceBuffers.some(function(G){var K,j=G[0];return j&&!((K=X.tracks[j])!=null&&K.ended)});if(W)if(N)this.log("Queueing EOS"),this.blockUntilOpen(function(){X.tracksEnded();var G=X.mediaSource;if(!G||G.readyState!=="open"){if(G)X.log("Could not call mediaSource.endOfStream(). mediaSource.readyState: "+G.readyState);return}X.log("Calling mediaSource.endOfStream()"),G.endOfStream(),X.hls.trigger($.BUFFERED_TO_END,void 0)});else this.tracksEnded(),this.hls.trigger($.BUFFERED_TO_END,void 0)},Z.tracksEnded=function Q(){var Y=this;this.sourceBuffers.forEach(function(J){var X=J[0];if(X!==null){var z=Y.tracks[X];if(z)z.ending=!1}})},Z.onLevelUpdated=function Q(Y,J){var X=J.details;if(!X.fragments.length)return;this.details=X,this.updateDuration()},Z.updateDuration=function Q(){var Y=this,J=this.getDurationAndRange();if(!J)return;this.blockUntilOpen(function(){return Y.updateMediaSource(J)})},Z.onError=function Q(Y,J){if(J.details===D.BUFFER_APPEND_ERROR&&J.frag){var X,z=(X=J.errorAction)==null?void 0:X.nextAutoLevel;if(v(z)&&z!==J.frag.level)this.resetAppendErrors()}},Z.resetAppendErrors=function Q(){this.appendErrors={audio:0,video:0,audiovideo:0}},Z.trimBuffers=function Q(){var Y=this.hls,J=this.details,X=this.media;if(!X||J===null)return;if(!this.sourceBufferCount)return;var z=Y.config,N=X.currentTime,W=J.levelTargetDuration,G=J.live&&z.liveBackBufferLength!==null?z.liveBackBufferLength:z.backBufferLength;if(v(G)&&G>=0){var K=Math.max(G,W),j=Math.floor(N/W)*W-K;this.flushBackBuffer(N,W,j)}if(v(z.frontBufferFlushThreshold)&&z.frontBufferFlushThreshold>0){var V=Math.max(z.maxBufferLength,z.frontBufferFlushThreshold),U=Math.max(V,W),A=Math.floor(N/W)*W+U;this.flushFrontBuffer(N,W,A)}},Z.flushBackBuffer=function Q(Y,J,X){var z=this;this.sourceBuffers.forEach(function(N){var W=N[0],G=N[1];if(G){var K=i.getBuffered(G);if(K.length>0&&X>K.start(0)){var j;z.hls.trigger($.BACK_BUFFER_REACHED,{bufferEnd:X});var V=z.tracks[W];if((j=z.details)!=null&&j.live)z.hls.trigger($.LIVE_BACK_BUFFER_REACHED,{bufferEnd:X});else if(V!=null&&V.ended){z.log("Cannot flush "+W+" back buffer while SourceBuffer is in ended state");return}z.hls.trigger($.BUFFER_FLUSHING,{startOffset:0,endOffset:X,type:W})}}})},Z.flushFrontBuffer=function Q(Y,J,X){var z=this;this.sourceBuffers.forEach(function(N){var W=N[0],G=N[1];if(G){var K=i.getBuffered(G),j=K.length;if(j<2)return;var V=K.start(j-1),U=K.end(j-1);if(X>V||Y>=V&&Y<=U)return;z.hls.trigger($.BUFFER_FLUSHING,{startOffset:V,endOffset:1/0,type:W})}})},Z.getDurationAndRange=function Q(){var Y,J=this.details,X=this.mediaSource;if(!J||!this.media||(X==null?void 0:X.readyState)!=="open")return null;var z=J.edge;if(J.live&&this.hls.config.liveDurationInfinity){var N=J.fragments.length;if(N&&J.live&&!!X.setLiveSeekableRange){var W=Math.max(0,J.fragmentStart),G=Math.max(W,z);return{duration:1/0,start:W,end:G}}return{duration:1/0}}var K=(Y=this.overrides)==null?void 0:Y.duration;if(K){if(!v(K))return null;return{duration:K}}var j=this.media.duration,V=v(X.duration)?X.duration:0;if(z>V&&z>j||!v(j))return{duration:z};return null},Z.updateMediaSource=function Q(Y){var{duration:J,start:X,end:z}=Y,N=this.mediaSource;if(!this.media||!N||N.readyState!=="open")return;if(N.duration!==J){if(v(J))this.log("Updating MediaSource duration to "+J.toFixed(3));N.duration=J}if(X!==void 0&&z!==void 0)this.log("MediaSource duration is set to "+N.duration+". Setting seekable range to "+X+"-"+z+"."),N.setLiveSeekableRange(X,z)},Z.checkPendingTracks=function Q(){var Y=this.bufferCodecEventsTotal,J=this.pendingTrackCount,X=this.tracks;if(this.log("checkPendingTracks (pending: "+J+" codec events expected: "+Y+") "+M0(X)),this.tracksReady){var z,N=(z=this.transferData)==null?void 0:z.tracks;if(N&&Object.keys(N).length)this.attachTransferred();else this.createSourceBuffers()}},Z.bufferCreated=function Q(){var Y=this;if(this.sourceBufferCount){var J={};this.sourceBuffers.forEach(function(z){var N=z[0],W=z[1];if(N){var G=Y.tracks[N];J[N]={buffer:W,container:G.container,codec:G.codec,supplemental:G.supplemental,levelCodec:G.levelCodec,id:G.id,metadata:G.metadata}}}),this.hls.trigger($.BUFFER_CREATED,{tracks:J}),this.log("SourceBuffers created. Running queue: "+this.operationQueue),this.sourceBuffers.forEach(function(z){var N=z[0];Y.executeNext(N)})}else{var X=new Error("could not create source buffer for media codec(s)");this.hls.trigger($.ERROR,{type:f.MEDIA_ERROR,details:D.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:X,reason:X.message})}},Z.createSourceBuffers=function Q(){var Y=this.tracks,J=this.sourceBuffers,X=this.mediaSource;if(!X)throw new Error("createSourceBuffers called when mediaSource was null");for(var z in Y){var N=z,W=Y[N];if(this.isPending(W)){var G=this.getTrackCodec(W,N),K=W.container+";codecs="+G;W.codec=G,this.log("creating sourceBuffer("+K+")"+(this.currentOp(N)?" Queued":"")+" "+M0(W));try{var j=X.addSourceBuffer(K),V=J7(N),U=[N,j];J[V]=U,W.buffer=j}catch(E){var A;this.error("error while trying to add sourceBuffer: "+E.message),this.shiftAndExecuteNext(N),(A=this.operationQueue)==null||A.removeBlockers(),delete this.tracks[N],this.hls.trigger($.ERROR,{type:f.MEDIA_ERROR,details:D.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:E,sourceBufferName:N,mimeType:K,parent:W.id});return}this.trackSourceBuffer(N,W)}}this.bufferCreated()},Z.getTrackCodec=function Q(Y,J){var{supplemental:X,codec:z}=Y;if(X&&(J==="video"||J==="audiovideo")&&aY(X,"video"))z=F8(z,X);var N=FY(z,Y.levelCodec);if(N){if(J.slice(0,5)==="audio")return $Y(N,this.appendSource);return N}return""},Z.trackSourceBuffer=function Q(Y,J){var X=this,z=J.buffer;if(!z)return;var N=this.getTrackCodec(J,Y);if(this.tracks[Y]={buffer:z,codec:N,container:J.container,levelCodec:J.levelCodec,supplemental:J.supplemental,metadata:J.metadata,id:J.id,listeners:[]},this.removeBufferListeners(Y),this.addBufferListener(Y,"updatestart",this.onSBUpdateStart),this.addBufferListener(Y,"updateend",this.onSBUpdateEnd),this.addBufferListener(Y,"error",this.onSBUpdateError),this.appendSource)this.addBufferListener(Y,"bufferedchange",function(W,G){var K=G.removedRanges;if(K!=null&&K.length)X.hls.trigger($.BUFFER_FLUSHED,{type:W})})},Z.onSBUpdateStart=function Q(Y){var J=this.currentOp(Y);if(!J)return;J.onStart()},Z.onSBUpdateEnd=function Q(Y){var J;if(((J=this.mediaSource)==null?void 0:J.readyState)==="closed"){this.resetBuffer(Y);return}var X=this.currentOp(Y);if(!X)return;X.onComplete(),this.shiftAndExecuteNext(Y)},Z.onSBUpdateError=function Q(Y,J){var X,z=new Error(Y+" SourceBuffer error. MediaSource readyState: "+((X=this.mediaSource)==null?void 0:X.readyState));this.error(""+z,J),this.hls.trigger($.ERROR,{type:f.MEDIA_ERROR,details:D.BUFFER_APPENDING_ERROR,sourceBufferName:Y,error:z,fatal:!1});var N=this.currentOp(Y);if(N)N.onError(z)},Z.removeExecutor=function Q(Y,J,X){var z=this.media,N=this.mediaSource,W=this.tracks[Y],G=W==null?void 0:W.buffer;if(!z||!N||!G){this.warn("Attempting to remove from the "+Y+" SourceBuffer, but it does not exist"),this.shiftAndExecuteNext(Y);return}var K=v(z.duration)?z.duration:1/0,j=v(N.duration)?N.duration:1/0,V=Math.max(0,J),U=Math.min(X,K,j);if(U>V&&(!W.ending||W.ended))W.ended=!1,this.log("Removing ["+V+","+U+"] from the "+Y+" SourceBuffer"),G.remove(V,U);else this.shiftAndExecuteNext(Y)},Z.appendExecutor=function Q(Y,J){var X=this.tracks[J],z=X==null?void 0:X.buffer;if(!z)throw new v8("Attempting to append to the "+J+" SourceBuffer, but it does not exist");X.ending=!1,X.ended=!1,z.appendBuffer(Y)},Z.blockUntilOpen=function Q(Y){if(this.isUpdating()||this.isQueued())this.blockBuffers(Y);else Y()},Z.isUpdating=function Q(){return this.sourceBuffers.some(function(Y){var J=Y[0],X=Y[1];return J&&X.updating})},Z.isQueued=function Q(){var Y=this;return this.sourceBuffers.some(function(J){var X=J[0];return X&&!!Y.currentOp(X)})},Z.isPending=function Q(Y){return!!Y&&!Y.buffer},Z.blockBuffers=function Q(Y,J){var X=this;if(J===void 0)J=this.sourceBufferTypes;if(!J.length){this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(Y);return}var z=this.operationQueue,N=J.map(function(G){return X.appendBlocker(G)}),W=J.length>1&&!!this.blockedAudioAppend;if(W)this.unblockAudio();Promise.all(N).then(function(G){if(z!==X.operationQueue)return;Y(),X.stepOperationQueue(J)})},Z.stepOperationQueue=function Q(Y){var J=this;Y.forEach(function(X){var z,N=(z=J.tracks[X])==null?void 0:z.buffer;if(!N||N.updating)return;J.shiftAndExecuteNext(X)})},Z.append=function Q(Y,J,X){if(this.operationQueue)this.operationQueue.append(Y,J,X)},Z.appendBlocker=function Q(Y){if(this.operationQueue)return this.operationQueue.appendBlocker(Y)},Z.currentOp=function Q(Y){if(this.operationQueue)return this.operationQueue.current(Y);return null},Z.executeNext=function Q(Y){if(Y&&this.operationQueue)this.operationQueue.executeNext(Y)},Z.shiftAndExecuteNext=function Q(Y){if(this.operationQueue)this.operationQueue.shiftAndExecuteNext(Y)},Z.addBufferListener=function Q(Y,J,X){var z=this.tracks[Y];if(!z)return;var N=z.buffer;if(!N)return;var W=X.bind(this,Y);z.listeners.push({event:J,listener:W}),N.addEventListener(J,W)},Z.removeBufferListeners=function Q(Y){var J=this.tracks[Y];if(!J)return;var X=J.buffer;if(!X)return;J.listeners.forEach(function(z){X.removeEventListener(z.event,z.listener)}),J.listeners.length=0},q0(H,[{key:"mediaSourceOpenOrEnded",get:function Q(){var Y,J=(Y=this.mediaSource)==null?void 0:Y.readyState;return J==="open"||J==="ended"}},{key:"sourceBufferTracks",get:function Q(){var Y=this;return Object.keys(this.tracks).reduce(function(J,X){var z=Y.tracks[X];return J[X]={id:z.id,container:z.container,codec:z.codec,levelCodec:z.levelCodec},J},{})}},{key:"bufferedToEnd",get:function Q(){var Y=this;return this.sourceBufferCount>0&&!this.sourceBuffers.some(function(J){var X,z,N=J[0];return N&&(!((X=Y.tracks[N])!=null&&X.ended)||((z=Y.tracks[N])==null?void 0:z.ending))})}},{key:"tracksReady",get:function Q(){var Y=this.pendingTrackCount;return Y>0&&(Y>=this.bufferCodecEventsTotal||this.isPending(this.tracks.audiovideo))}},{key:"mediaSrc",get:function Q(){var Y,J,X=((Y=this.media)==null?void 0:(J=Y.querySelector)==null?void 0:J.call(Y,"source"))||this.media;return X==null?void 0:X.src}},{key:"pendingTrackCount",get:function Q(){var Y=this;return Object.keys(this.tracks).reduce(function(J,X){return J+(Y.isPending(Y.tracks[X])?1:0)},0)}},{key:"sourceBufferCount",get:function Q(){return this.sourceBuffers.reduce(function(Y,J){var X=J[0];return Y+(X?1:0)},0)}},{key:"sourceBufferTypes",get:function Q(){return this.sourceBuffers.map(function(Y){var J=Y[0];return J}).filter(function(Y){return!!Y})}}])}(i0);function VQ(q){var H=q.querySelectorAll("source");[].slice.call(H).forEach(function(Z){q.removeChild(Z)})}function m8(q,H){var Z=self.document.createElement("source");Z.type="video/mp4",Z.src=H,q.appendChild(Z)}function J7(q){return q==="audio"?1:0}var p8=function(){function q(Z){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=Z,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var H=q.prototype;return H.setStreamController=function Z(Q){this.streamController=Q},H.destroy=function Z(){if(this.hls)this.unregisterListener();if(this.timer)this.stopCapping();this.media=null,this.clientRect=null,this.hls=this.streamController=null},H.registerListeners=function Z(){var Q=this.hls;Q.on($.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),Q.on($.MEDIA_ATTACHING,this.onMediaAttaching,this),Q.on($.MANIFEST_PARSED,this.onManifestParsed,this),Q.on($.LEVELS_UPDATED,this.onLevelsUpdated,this),Q.on($.BUFFER_CODECS,this.onBufferCodecs,this),Q.on($.MEDIA_DETACHING,this.onMediaDetaching,this)},H.unregisterListener=function Z(){var Q=this.hls;Q.off($.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),Q.off($.MEDIA_ATTACHING,this.onMediaAttaching,this),Q.off($.MANIFEST_PARSED,this.onManifestParsed,this),Q.off($.LEVELS_UPDATED,this.onLevelsUpdated,this),Q.off($.BUFFER_CODECS,this.onBufferCodecs,this),Q.off($.MEDIA_DETACHING,this.onMediaDetaching,this)},H.onFpsDropLevelCapping=function Z(Q,Y){var J=this.hls.levels[Y.droppedLevel];if(this.isLevelAllowed(J))this.restrictedLevels.push({bitrate:J.bitrate,height:J.height,width:J.width})},H.onMediaAttaching=function Z(Q,Y){if(this.media=Y.media instanceof HTMLVideoElement?Y.media:null,this.clientRect=null,this.timer&&this.hls.levels.length)this.detectPlayerSize()},H.onManifestParsed=function Z(Q,Y){var J=this.hls;if(this.restrictedLevels=[],this.firstLevel=Y.firstLevel,J.config.capLevelToPlayerSize&&Y.video)this.startCapping()},H.onLevelsUpdated=function Z(Q,Y){if(this.timer&&v(this.autoLevelCapping))this.detectPlayerSize()},H.onBufferCodecs=function Z(Q,Y){var J=this.hls;if(J.config.capLevelToPlayerSize&&Y.video)this.startCapping()},H.onMediaDetaching=function Z(){this.stopCapping(),this.media=null},H.detectPlayerSize=function Z(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0){this.clientRect=null;return}var Q=this.hls.levels;if(Q.length){var Y=this.hls,J=this.getMaxLevel(Q.length-1);if(J!==this.autoLevelCapping)Y.logger.log("Setting autoLevelCapping to "+J+": "+Q[J].height+"p@"+Q[J].bitrate+" for media "+this.mediaWidth+"x"+this.mediaHeight);if(Y.autoLevelCapping=J,Y.autoLevelEnabled&&Y.autoLevelCapping>this.autoLevelCapping&&this.streamController)this.streamController.nextLevelSwitch();this.autoLevelCapping=Y.autoLevelCapping}}},H.getMaxLevel=function Z(Q){var Y=this,J=this.hls.levels;if(!J.length)return-1;var X=J.filter(function(z,N){return Y.isLevelAllowed(z)&&N<=Q});return this.clientRect=null,q.getMaxLevelByMediaSize(X,this.mediaWidth,this.mediaHeight)},H.startCapping=function Z(){if(this.timer)return;this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1000),this.detectPlayerSize()},H.stopCapping=function Z(){if(this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer)self.clearInterval(this.timer),this.timer=void 0},H.getDimensions=function Z(){if(this.clientRect)return this.clientRect;var Q=this.media,Y={width:0,height:0};if(Q){var J=Q.getBoundingClientRect();if(Y.width=J.width,Y.height=J.height,!Y.width&&!Y.height)Y.width=J.right-J.left||Q.width||0,Y.height=J.bottom-J.top||Q.height||0}return this.clientRect=Y,Y},H.isLevelAllowed=function Z(Q){var Y=this.restrictedLevels;return!Y.some(function(J){return Q.bitrate===J.bitrate&&Q.width===J.width&&Q.height===J.height})},q.getMaxLevelByMediaSize=function Z(Q,Y,J){if(!(Q!=null&&Q.length))return-1;var X=function K(j,V){if(!V)return!0;return j.width!==V.width||j.height!==V.height},z=Q.length-1,N=Math.max(Y,J);for(var W=0;W<Q.length;W+=1){var G=Q[W];if((G.width>=N||G.height>=N)&&X(G,Q[W+1])){z=W;break}}return z},q0(q,[{key:"mediaWidth",get:function Z(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function Z(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function Z(){var Q=1;if(!this.hls.config.ignoreDevicePixelRatio)try{Q=self.devicePixelRatio}catch(Y){}return Math.min(Q,this.hls.config.maxDevicePixelRatio)}}])}(),u8=/^(\d+)x(\d+)$/,AQ=/(.+?)=(".*?"|.*?)(?:,|$)/g,N0=function(){function q(Z,Q){if(typeof Z==="string")Z=q.parseAttrList(Z,Q);K0(this,Z)}var H=q.prototype;return H.decimalInteger=function Z(Q){var Y=parseInt(this[Q],10);if(Y>Number.MAX_SAFE_INTEGER)return 1/0;return Y},H.hexadecimalInteger=function Z(Q){if(this[Q]){var Y=(this[Q]||"0x").slice(2);Y=(Y.length&1?"0":"")+Y;var J=new Uint8Array(Y.length/2);for(var X=0;X<Y.length/2;X++)J[X]=parseInt(Y.slice(X*2,X*2+2),16);return J}return null},H.hexadecimalIntegerAsNumber=function Z(Q){var Y=parseInt(this[Q],16);if(Y>Number.MAX_SAFE_INTEGER)return 1/0;return Y},H.decimalFloatingPoint=function Z(Q){return parseFloat(this[Q])},H.optionalFloat=function Z(Q,Y){var J=this[Q];return J?parseFloat(J):Y},H.enumeratedString=function Z(Q){return this[Q]},H.enumeratedStringList=function Z(Q,Y){var J=this[Q];return(J?J.split(/[ ,]+/):[]).reduce(function(X,z){return X[z.toLowerCase()]=!0,X},Y)},H.bool=function Z(Q){return this[Q]==="YES"},H.decimalResolution=function Z(Q){var Y=u8.exec(this[Q]);if(Y===null)return;return{width:parseInt(Y[1],10),height:parseInt(Y[2],10)}},q.parseAttrList=function Z(Q,Y){var J,X={},z='"';AQ.lastIndex=0;while((J=AQ.exec(Q))!==null){var N=J[1].trim(),W=J[2],G=W.indexOf(z)===0&&W.lastIndexOf(z)===W.length-1,K=!1;if(G)W=W.slice(1,-1);else switch(N){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":K=!0}if(Y&&(G||K));else if(!K&&!G)switch(N){case"CLOSED-CAPTIONS":if(W==="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":s.warn(Q+": attribute "+N+" is missing quotes")}X[N]=W}return X},q0(q,[{key:"clientAttrs",get:function Z(){return Object.keys(this).filter(function(Q){return Q.substring(0,2)==="X-"})}}])}(),c8="com.apple.hls.interstitial";function f8(q){return q!=="ID"&&q!=="CLASS"&&q!=="CUE"&&q!=="START-DATE"&&q!=="DURATION"&&q!=="END-DATE"&&q!=="END-ON-NEXT"}function d8(q){return q==="SCTE35-OUT"||q==="SCTE35-IN"||q==="SCTE35-CMD"}var EQ=function(){function q(H,Z,Q){var Y;if(Q===void 0)Q=0;if(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=(Z==null?void 0:Z.tagAnchor)||null,this.tagOrder=(Y=Z==null?void 0:Z.tagOrder)!=null?Y:Q,Z){var J=Z.attr;for(var X in J)if(Object.prototype.hasOwnProperty.call(H,X)&&H[X]!==J[X]){s.warn('DATERANGE tag attribute: "'+X+'" does not match for tags with ID: "'+H.ID+'"'),this._badValueForSameId=X;break}H=K0(new N0({}),J,H)}if(this.attr=H,Z)this._startDate=Z._startDate,this._cue=Z._cue,this._endDate=Z._endDate,this._dateAtEnd=Z._dateAtEnd;else this._startDate=new Date(H["START-DATE"]);if("END-DATE"in this.attr){var z=(Z==null?void 0:Z.endDate)||new Date(this.attr["END-DATE"]);if(v(z.getTime()))this._endDate=z}}return q0(q,[{key:"id",get:function H(){return this.attr.ID}},{key:"class",get:function H(){return this.attr.CLASS}},{key:"cue",get:function H(){var Z=this._cue;if(Z===void 0)return this._cue=this.attr.enumeratedStringList(this.attr.CUE?"CUE":"X-CUE",{pre:!1,post:!1,once:!1});return Z}},{key:"startTime",get:function H(){var Z=this.tagAnchor;if(Z===null||Z.programDateTime===null)return s.warn('Expected tagAnchor Fragment with PDT set for DateRange "'+this.id+'": '+Z),NaN;return Z.start+(this.startDate.getTime()-Z.programDateTime)/1000}},{key:"startDate",get:function H(){return this._startDate}},{key:"endDate",get:function H(){var Z=this._endDate||this._dateAtEnd;if(Z)return Z;var Q=this.duration;if(Q!==null)return this._dateAtEnd=new Date(this._startDate.getTime()+Q*1000);return null}},{key:"duration",get:function H(){if("DURATION"in this.attr){var Z=this.attr.decimalFloatingPoint("DURATION");if(v(Z))return Z}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1000;return null}},{key:"plannedDuration",get:function H(){if("PLANNED-DURATION"in this.attr)return this.attr.decimalFloatingPoint("PLANNED-DURATION");return null}},{key:"endOnNext",get:function H(){return this.attr.bool("END-ON-NEXT")}},{key:"isInterstitial",get:function H(){return this.class===c8}},{key:"isValid",get:function H(){return!!this.id&&!this._badValueForSameId&&v(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))}}])}(),l8=10,n8=function(){function q(Z){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=Z}var H=q.prototype;return H.reloaded=function Z(Q){if(!Q){this.advanced=!0,this.updated=!0;return}var Y=this.lastPartSn-Q.lastPartSn,J=this.lastPartIndex-Q.lastPartIndex;if(this.updated=this.endSN!==Q.endSN||!!J||!!Y||!this.live,this.advanced=this.endSN>Q.endSN||Y>0||Y===0&&J>0,this.updated||this.advanced)this.misses=Math.floor(Q.misses*0.6);else this.misses=Q.misses+1},q0(q,[{key:"hasProgramDateTime",get:function Z(){if(this.fragments.length)return v(this.fragments[this.fragments.length-1].programDateTime);return!1}},{key:"levelTargetDuration",get:function Z(){return this.averagetargetduration||this.targetduration||l8}},{key:"drift",get:function Z(){var Q=this.driftEndTime-this.driftStartTime;if(Q>0){var Y=this.driftEnd-this.driftStart;return Y*1000/Q}return 1}},{key:"edge",get:function Z(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function Z(){var Q;if((Q=this.partList)!=null&&Q.length)return this.partList[this.partList.length-1].end;return this.fragmentEnd}},{key:"fragmentEnd",get:function Z(){var Q;if((Q=this.fragments)!=null&&Q.length)return this.fragments[this.fragments.length-1].end;return 0}},{key:"fragmentStart",get:function Z(){var Q;if((Q=this.fragments)!=null&&Q.length)return this.fragments[0].start;return 0}},{key:"age",get:function Z(){if(this.advancedDateTime)return Math.max(Date.now()-this.advancedDateTime,0)/1000;return 0}},{key:"lastPartIndex",get:function Z(){var Q;if((Q=this.partList)!=null&&Q.length)return this.partList[this.partList.length-1].index;return-1}},{key:"maxPartIndex",get:function Z(){var Q=this.partList;if(Q){var Y=this.lastPartIndex;if(Y!==-1){for(var J=Q.length;J--;)if(Q[J].index>Y)return Q[J].index;return Y}}return 0}},{key:"lastPartSn",get:function Z(){var Q;if((Q=this.partList)!=null&&Q.length)return this.partList[this.partList.length-1].fragment.sn;return this.endSN}},{key:"expired",get:function Z(){if(this.live&&this.age&&this.misses<3){var Q=this.partEnd-this.fragmentStart;return this.age>Math.max(Q,this.totalduration)+this.levelTargetDuration}return!1}}])}(),l0={cbc:0,ctr:1};function HY(q){return q==="AES-128"||q==="AES-256"||q==="AES-256-CTR"}function BQ(q){switch(q){case"AES-128":case"AES-256":return l0.cbc;case"AES-256-CTR":return l0.ctr;default:throw new Error("invalid full segment method "+q)}}var o8=function(){function q(Z,Q,Y,J,X){if(J===void 0)J=[1];if(X===void 0)X=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=Z,this.uri=Q,this.keyFormat=Y,this.keyFormatVersions=J,this.iv=X,this.encrypted=Z?Z!=="NONE":!1,this.isCommonEncryption=this.encrypted&&!HY(Z)}q.clearKeyUriToKeyIdMap=function Z(){};var H=q.prototype;return H.isSupported=function Z(){if(this.method){if(HY(this.method)||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES"}return!1},H.getDecryptData=function Z(Q){if(!this.encrypted||!this.uri)return null;if(HY(this.method)&&this.uri&&!this.iv){if(typeof Q!=="number")s.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),Q=0;var Y=s8(Q),J=new q(this.method,this.uri,"identity",this.keyFormatVersions,Y);return J}return this},q}();function s8(q){var H=new Uint8Array(16);for(var Z=12;Z<16;Z++)H[Z]=q>>8*(15-Z)&255;return H}var $Q=/#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,FQ=/#EXT-X-MEDIA:(.*)/g,i8=/^#EXT(?:INF|-X-TARGETDURATION):/m,Z7=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),r8=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("|")),zY=function(){function q(){}return q.findGroup=function H(Z,Q){for(var Y=0;Y<Z.length;Y++){var J=Z[Y];if(J.id===Q)return J}},q.resolve=function H(Z,Q){return cY.buildAbsoluteURL(Q,Z,{alwaysNormalize:!0})},q.isMediaPlaylist=function H(Z){return i8.test(Z)},q.parseMasterPlaylist=function H(Z,Q){var Y=!1,J={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:Y},X=[];$Q.lastIndex=0;var z;while((z=$Q.exec(Z))!=null)if(z[1]){var N,W=new N0(z[1],J),G=z[2],K={attrs:W,bitrate:W.decimalInteger("BANDWIDTH")||W.decimalInteger("AVERAGE-BANDWIDTH"),name:W.NAME,url:q.resolve(G,Q)},j=W.decimalResolution("RESOLUTION");if(j)K.width=j.width,K.height=j.height;IQ(W.CODECS,K);var V=W["SUPPLEMENTAL-CODECS"];if(V)K.supplemental={},IQ(V,K.supplemental);if(!((N=K.unknownCodecs)!=null&&N.length))X.push(K);J.levels.push(K)}else if(z[3]){var U=z[3],A=z[4];switch(U){case"SESSION-DATA":{var E=new N0(A,J),B=E["DATA-ID"];if(B){if(J.sessionData===null)J.sessionData={};J.sessionData[B]=E}break}case"SESSION-KEY":{var F=RQ(A,Q,J);if(F.encrypted&&F.isSupported()){if(J.sessionKeys===null)J.sessionKeys=[];J.sessionKeys.push(F)}else s.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+A+'"');break}case"DEFINE":break;case"CONTENT-STEERING":{var R=new N0(A,J);J.contentSteering={uri:q.resolve(R["SERVER-URI"],Q),pathwayId:R["PATHWAY-ID"]||"."};break}case"START":{J.startTimeOffset=MQ(A);break}}}var O=X.length>0&&X.length<J.levels.length;if(J.levels=O?X:J.levels,J.levels.length===0)J.playlistParsingError=new Error("no levels found in manifest");return J},q.parseMasterPlaylistMedia=function H(Z,Q,Y){var J,X={},z=Y.levels,N={AUDIO:z.map(function(M){return{id:M.attrs.AUDIO,audioCodec:M.audioCodec}}),SUBTITLES:z.map(function(M){return{id:M.attrs.SUBTITLES,textCodec:M.textCodec}}),"CLOSED-CAPTIONS":[]},W=0;FQ.lastIndex=0;while((J=FQ.exec(Z))!==null){var G=new N0(J[1],Y),K=G.TYPE;if(K){var j=N[K],V=X[K]||[];X[K]=V;var U=G.LANGUAGE,A=G["ASSOC-LANGUAGE"],E=G.CHANNELS,B=G.CHARACTERISTICS,F=G["INSTREAM-ID"],R={attrs:G,bitrate:0,id:W++,groupId:G["GROUP-ID"]||"",name:G.NAME||U||"",type:K,default:G.bool("DEFAULT"),autoselect:G.bool("AUTOSELECT"),forced:G.bool("FORCED"),lang:U,url:G.URI?q.resolve(G.URI,Q):""};if(A)R.assocLang=A;if(E)R.channels=E;if(B)R.characteristics=B;if(F)R.instreamId=F;if(j!=null&&j.length){var O=q.findGroup(j,R.groupId)||j[0];wQ(R,O,"audioCodec"),wQ(R,O,"textCodec")}V.push(R)}}return X},q.parseLevelPlaylist=function H(Z,Q,Y,J,X,z){var N,W={url:Q},G=new n8(Q),K=G.fragments,j=[],V=null,U=0,A=0,E=0,B=0,F=0,R=null,O=new oY(J,W),M,L,I,w=-1,S=!1,P=null,b;if(Z7.lastIndex=0,G.m3u8=Z,G.hasVariableRefs=!1,((N=Z7.exec(Z))==null?void 0:N[0])!=="#EXTM3U")return G.playlistParsingError=new Error("Missing format identifier #EXTM3U"),G;while((M=Z7.exec(Z))!==null){if(S){if(S=!1,O=new oY(J,W),O.playlistOffset=E,O.start=E,O.sn=U,O.cc=B,F)O.bitrate=F;if(O.level=Y,V){if(O.initSegment=V,V.rawProgramDateTime)O.rawProgramDateTime=V.rawProgramDateTime,V.rawProgramDateTime=null;if(P)O.setByteRange(P),P=null}}var C=M[1];if(C){O.duration=parseFloat(C);var x=(" "+M[2]).slice(1);O.title=x||null,O.tagList.push(x?["INF",C,x]:["INF",C])}else if(M[3]){if(v(O.duration)){if(O.playlistOffset=E,O.start=E,I)bQ(O,I,G);O.sn=U,O.level=Y,O.cc=B,K.push(O);var _=(" "+M[3]).slice(1);O.relurl=_,q7(O,R,j),R=O,E+=O.duration,U++,A=0,S=!0}}else{if(M=M[0].match(r8),!M){s.warn("No matches on slow regex match for level playlist!");continue}for(L=1;L<M.length;L++)if(M[L]!==void 0)break;var y=(" "+M[L]).slice(1),T=(" "+M[L+1]).slice(1),h=M[L+2]?(" "+M[L+2]).slice(1):null;switch(y){case"BYTERANGE":if(R)O.setByteRange(T,R);else O.setByteRange(T);break;case"PROGRAM-DATE-TIME":if(O.rawProgramDateTime=T,O.tagList.push(["PROGRAM-DATE-TIME",T]),w===-1)w=K.length;break;case"PLAYLIST-TYPE":if(G.type)p0(G,y,M);G.type=T.toUpperCase();break;case"MEDIA-SEQUENCE":if(G.startSN!==0)p0(G,y,M);else if(K.length>0)CQ(G,y,M);U=G.startSN=parseInt(T);break;case"SKIP":{if(G.skippedSegments)p0(G,y,M);var g=new N0(T,G),m=g.decimalInteger("SKIPPED-SEGMENTS");if(v(m)){G.skippedSegments+=m;for(var p=m;p--;)K.push(null);U+=m}var r=g.enumeratedString("RECENTLY-REMOVED-DATERANGES");if(r)G.recentlyRemovedDateranges=(G.recentlyRemovedDateranges||[]).concat(r.split("\t"));break}case"TARGETDURATION":if(G.targetduration!==0)p0(G,y,M);G.targetduration=Math.max(parseInt(T),1);break;case"VERSION":if(G.version!==null)p0(G,y,M);G.version=parseInt(T);break;case"INDEPENDENT-SEGMENTS":break;case"ENDLIST":if(!G.live)p0(G,y,M);G.live=!1;break;case"#":if(T||h)O.tagList.push(h?[T,h]:[T]);break;case"DISCONTINUITY":B++,O.tagList.push(["DIS"]);break;case"GAP":O.gap=!0,O.tagList.push([y]);break;case"BITRATE":if(O.tagList.push([y,T]),F=parseInt(T)*1000,v(F))O.bitrate=F;else F=0;break;case"DATERANGE":{var n=new N0(T,G),a=new EQ(n,G.dateRanges[n.ID],G.dateRangeTagCount);if(G.dateRangeTagCount++,a.isValid||G.skippedSegments)G.dateRanges[a.id]=a;else s.warn('Ignoring invalid DATERANGE tag: "'+T+'"');O.tagList.push(["EXT-X-DATERANGE",T]);break}case"DEFINE":break;case"DISCONTINUITY-SEQUENCE":if(G.startCC!==0)p0(G,y,M);else if(K.length>0)CQ(G,y,M);G.startCC=B=parseInt(T);break;case"KEY":{var l=RQ(T,Q,G);if(l.isSupported()){if(l.method==="NONE"){I=void 0;break}if(!I)I={};if(I[l.keyFormat])I=K0({},I);I[l.keyFormat]=l}else s.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+T+'"');break}case"START":G.startTimeOffset=MQ(T);break;case"MAP":{var z0=new N0(T,G);if(O.duration){var t=new oY(J,W);if(LQ(t,z0,Y,I),V=t,O.initSegment=V,V.rawProgramDateTime&&!O.rawProgramDateTime)O.rawProgramDateTime=V.rawProgramDateTime}else{var X0=O.byteRangeEndOffset;if(X0){var L0=O.byteRangeStartOffset;P=X0-L0+"@"+L0}else P=null;LQ(O,z0,Y,I),V=O,S=!0}V.cc=B;break}case"SERVER-CONTROL":{if(b)p0(G,y,M);b=new N0(T),G.canBlockReload=b.bool("CAN-BLOCK-RELOAD"),G.canSkipUntil=b.optionalFloat("CAN-SKIP-UNTIL",0),G.canSkipDateRanges=G.canSkipUntil>0&&b.bool("CAN-SKIP-DATERANGES"),G.partHoldBack=b.optionalFloat("PART-HOLD-BACK",0),G.holdBack=b.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{if(G.partTarget)p0(G,y,M);var A0=new N0(T);G.partTarget=A0.decimalFloatingPoint("PART-TARGET");break}case"PART":{var e=G.partList;if(!e)e=G.partList=[];var b0=A>0?e[e.length-1]:void 0,W0=A++,J0=new N0(T,G),C0=new Y8(J0,O,W,W0,b0);e.push(C0),O.duration+=C0.duration;break}case"PRELOAD-HINT":{var O0=new N0(T,G);G.preloadHint=O0;break}case"RENDITION-REPORT":{var S0=new N0(T,G);G.renditionReports=G.renditionReports||[],G.renditionReports.push(S0);break}default:s.warn("line parsed but not handled: "+M);break}}}if(R&&!R.relurl){if(K.pop(),E-=R.duration,G.partList)G.fragmentHint=R}else if(G.partList){if(q7(O,R,j),O.cc=B,G.fragmentHint=O,I)bQ(O,I,G)}if(!G.targetduration)G.playlistParsingError=new Error("#EXT-X-TARGETDURATION is required");var Y0=K.length,R0=K[0],G0=K[Y0-1];if(E+=G.skippedSegments*G.targetduration,E>0&&Y0&&G0){G.averagetargetduration=E/Y0;var P0=G0.sn;if(G.endSN=P0!=="initSegment"?P0:0,!G.live)G0.endList=!0;if(R0&&G.startCC===void 0)G.startCC=R0.cc;if(w>0){if(t8(K,w),R0)j.unshift(R0)}}else G.endSN=0,G.startCC=0;if(G.fragmentHint)E+=G.fragmentHint.duration;if(G.totalduration=E,j.length&&G.dateRangeTagCount&&R0)OQ(j,G);return G.endCC=B,G},q}();function OQ(q,H){var Z=q.length,Q=q[Z-1],Y=H.live?1/0:H.totalduration,J=Object.keys(H.dateRanges);for(var X=J.length;X--;){var z=H.dateRanges[J[X]],N=z.startDate.getTime();z.tagAnchor=Q.ref;for(var W=Z;W--;){var G=a8(H,N,q,W,Y);if(G!==-1){z.tagAnchor=H.fragments[G].ref;break}}}}function a8(q,H,Z,Q,Y){var J=Z[Q];if(J){var X=J.programDateTime;if(H>=X||Q===0){var z,N=(((z=Z[Q+1])==null?void 0:z.start)||Y)-J.start;if(H<=X+N*1000){var W=Z[Q].sn-q.startSN,G=q.fragments;if(G.length>Z.length){var K=Z[Q+1]||G[G.length-1],j=K.sn-q.startSN;for(var V=j;V>W;V--){var U=G[V].programDateTime;if(H>=U&&H<U+G[V].duration*1000)return V}}return W}}}return-1}function RQ(q,H,Z){var Q,Y,J=new N0(q,Z),X=(Q=J.METHOD)!=null?Q:"",z=J.URI,N=J.hexadecimalInteger("IV"),W=J.KEYFORMATVERSIONS,G=(Y=J.KEYFORMAT)!=null?Y:"identity";if(z&&J.IV&&!N)s.error("Invalid IV: "+J.IV);var K=z?zY.resolve(z,H):"",j=(W?W:"1").split("/").map(Number).filter(Number.isFinite);return new o8(X,K,G,j,N)}function MQ(q){var H=new N0(q),Z=H.decimalFloatingPoint("TIME-OFFSET");if(v(Z))return Z;return null}function IQ(q,H){var Z=(q||"").split(/[ ,]+/).filter(function(Q){return Q});["video","audio","text"].forEach(function(Q){var Y=Z.filter(function(J){return r7(J,Q)});if(Y.length)H[Q+"Codec"]=Y.map(function(J){return J.split("/")[0]}).join(","),Z=Z.filter(function(J){return Y.indexOf(J)===-1})}),H.unknownCodecs=Z}function wQ(q,H,Z){var Q=H[Z];if(Q)q[Z]=Q}function t8(q,H){var Z=q[H];for(var Q=H;Q--;){var Y=q[Q];if(!Y)return;Y.programDateTime=Z.programDateTime-Y.duration*1000,Z=Y}}function q7(q,H,Z){if(q.rawProgramDateTime)Z.push(q);else if(H!=null&&H.programDateTime)q.programDateTime=H.endProgramDateTime}function LQ(q,H,Z,Q){if(q.relurl=H.URI,H.BYTERANGE)q.setByteRange(H.BYTERANGE);if(q.level=Z,q.sn="initSegment",Q)q.levelkeys=Q;q.initSegment=null}function bQ(q,H,Z){q.levelkeys=H;var Q=Z.encryptedFragments;if((!Q.length||Q[Q.length-1].levelkeys!==H)&&Object.keys(H).some(function(Y){return H[Y].isCommonEncryption}))Q.push(q)}function p0(q,H,Z){q.playlistParsingError=new Error("#EXT-X-"+H+" must not appear more than once ("+Z[0]+")")}function CQ(q,H,Z){q.playlistParsingError=new Error("#EXT-X-"+H+" must appear before the first Media Segment ("+Z[0]+")")}function X7(q,H){var Z=H.startPTS;if(v(Z)){var Q=0,Y;if(H.sn>q.sn)Q=Z-q.start,Y=q;else Q=q.start-Z,Y=H;if(Y.duration!==Q)Y.setDuration(Q)}else if(H.sn>q.sn){var J=q.cc===H.cc;if(J&&q.minEndPTS)H.setStart(q.start+(q.minEndPTS-q.start));else H.setStart(q.start+q.duration)}else H.setStart(Math.max(q.start-H.duration,0))}function PQ(q,H,Z,Q,Y,J){var X=Q-Z;if(X<=0)s.warn("Fragment should have a positive duration",H),Q=Z+H.duration,J=Y+H.duration;var z=Z,N=Q,W=H.startPTS,G=H.endPTS;if(v(W)){var K=Math.abs(W-Z);if(!v(H.deltaPTS))H.deltaPTS=K;else H.deltaPTS=Math.max(K,H.deltaPTS);z=Math.max(Z,W),Z=Math.min(Z,W),Y=Math.min(Y,H.startDTS),N=Math.min(Q,G),Q=Math.max(Q,G),J=Math.max(J,H.endDTS)}var j=Z-H.start;if(H.start!==0)H.setStart(Z);H.setDuration(Q-H.start),H.startPTS=Z,H.maxStartPTS=z,H.startDTS=Y,H.endPTS=Q,H.minEndPTS=N,H.endDTS=J;var V=H.sn;if(!q||V<q.startSN||V>q.endSN)return 0;var U,A=V-q.startSN,E=q.fragments;E[A]=H;for(U=A;U>0;U--)X7(E[U],E[U-1]);for(U=A;U<E.length-1;U++)X7(E[U],E[U+1]);if(q.fragmentHint)X7(E[E.length-1],q.fragmentHint);return q.PTSKnown=q.alignedSliding=!0,j}function e8(q,H){if(q===H)return;var Z=null,Q=q.fragments;for(var Y=Q.length-1;Y>=0;Y--){var J=Q[Y].initSegment;if(J){Z=J;break}}if(q.fragmentHint)delete q.fragmentHint.endPTS;var X;JZ(q,H,function(U,A,E,B){if(H.skippedSegments){if(A.cc!==U.cc){var F=U.cc-A.cc;for(var R=E;R<B.length;R++)B[R].cc+=F}}if(v(U.startPTS)&&v(U.endPTS)){if(A.setStart(A.startPTS=U.startPTS),A.startDTS=U.startDTS,A.maxStartPTS=U.maxStartPTS,A.endPTS=U.endPTS,A.endDTS=U.endDTS,A.minEndPTS=U.minEndPTS,A.setDuration(U.endPTS-U.startPTS),A.duration)X=A;H.PTSKnown=H.alignedSliding=!0}if(U.hasStreams)A.elementaryStreams=U.elementaryStreams;if(A.loader=U.loader,U.hasStats)A.stats=U.stats;if(U.initSegment)A.initSegment=U.initSegment,Z=U.initSegment});var z=H.fragments,N=H.fragmentHint?z.concat(H.fragmentHint):z;if(Z)N.forEach(function(U){var A;if(U&&(!U.initSegment||U.initSegment.relurl===((A=Z)==null?void 0:A.relurl)))U.initSegment=Z});if(H.skippedSegments)if(H.deltaUpdateFailed=z.some(function(U){return!U}),H.deltaUpdateFailed){s.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var W=H.skippedSegments;W--;)z.shift();H.startSN=z[0].sn}else{if(H.endCC=z[z.length-1].cc,H.canSkipDateRanges)H.dateRanges=YZ(q.dateRanges,H);var G=q.fragments.filter(function(U){return U.rawProgramDateTime});if(q.hasProgramDateTime&&!H.hasProgramDateTime){for(var K=1;K<N.length;K++)if(N[K].programDateTime===null)q7(N[K],N[K-1],G)}OQ(G,H)}if(QZ(q.partList,H.partList,function(U,A){A.elementaryStreams=U.elementaryStreams,A.stats=U.stats}),X)PQ(H,X,X.startPTS,X.endPTS,X.startDTS,X.endDTS);else SQ(q,H);if(z.length)H.totalduration=H.edge-z[0].start;H.driftStartTime=q.driftStartTime,H.driftStart=q.driftStart;var j=H.advancedDateTime;if(H.advanced&&j){var V=H.edge;if(!H.driftStart)H.driftStartTime=j,H.driftStart=V;H.driftEndTime=j,H.driftEnd=V}else H.driftEndTime=q.driftEndTime,H.driftEnd=q.driftEnd,H.advancedDateTime=q.advancedDateTime;if(H.requestScheduled===-1)H.requestScheduled=q.requestScheduled}function YZ(q,H){var{dateRanges:Z,recentlyRemovedDateranges:Q}=H,Y=K0({},q);if(Q)Q.forEach(function(z){delete Y[z]});var J=Object.keys(Y),X=J.length;if(X)Object.keys(Z).forEach(function(z){var N=Y[z],W=new EQ(Z[z].attr,N);if(W.isValid){if(Y[z]=W,!N)W.tagOrder+=X}else s.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+M0(Z[z].attr)+'"')});return Y}function QZ(q,H,Z){if(q&&H){var Q=0;for(var Y=0,J=q.length;Y<=J;Y++){var X=q[Y],z=H[Y+Q];if(X&&z&&X.index===z.index&&X.fragment.sn===z.fragment.sn)Z(X,z);else Q--}}}function JZ(q,H,Z){var Q=H.skippedSegments,Y=Math.max(q.startSN,H.startSN)-H.startSN,J=(q.fragmentHint?1:0)+(Q?H.endSN:Math.min(q.endSN,H.endSN))-H.startSN,X=H.startSN-q.startSN,z=H.fragmentHint?H.fragments.concat(H.fragmentHint):H.fragments,N=q.fragmentHint?q.fragments.concat(q.fragmentHint):q.fragments;for(var W=Y;W<=J;W++){var G=N[X+W],K=z[W];if(Q&&!K&&G)K=H.fragments[W]=G;if(G&&K){if(Z(G,K,W,z),G.url&&G.url!==K.url){H.playlistParsingError=DQ("media sequence mismatch "+K.sn+":",q,H,G,K);return}else if(G.cc!==K.cc){H.playlistParsingError=DQ("discontinuity sequence mismatch ("+G.cc+"!="+K.cc+")",q,H,G,K);return}}}}function DQ(q,H,Z,Q,Y){return new Error(q+" "+Y.url+`
|
17
|
-
Playlist starting @`+
|
18
|
-
`+
|
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+`
|
19
20
|
|
20
|
-
Playlist starting @`+
|
21
|
-
`+Z.m3u8)}function SQ(q,H,Z){if(Z===void 0)Z=!0;var Q=H.startSN+H.skippedSegments-q.startSN,Y=q.fragments,J=Q>=0,X=0;if(J&&Q<Y.length)X=Y[Q].start;else if(J&&H.startSN===q.endSN+1)X=q.fragmentEnd;else if(J&&Z)X=q.fragmentStart+Q*H.levelTargetDuration;else if(!H.skippedSegments&&H.fragmentStart===0)X=q.fragmentStart;else return;ZZ(H,X)}function ZZ(q,H){if(H){var Z=q.fragments;for(var Q=q.skippedSegments;Q<Z.length;Q++)Z[Q].addStart(H);if(q.fragmentHint)q.fragmentHint.addStart(H)}}function xQ(q,H){if(H===void 0)H=1/0;var Z=1000*q.targetduration;if(q.updated){var Q=q.fragments,Y=4;if(Q.length&&Z*Y>H){var J=Q[Q.length-1].duration*1000;if(J<Z)Z=J}}else Z/=2;return Math.round(Z)}function qZ(q,H,Z){if(!q)return null;var Q=q.fragments[H-q.startSN];if(Q)return Q;if(Q=q.fragmentHint,Q&&Q.sn===H)return Q;if(H<q.startSN&&Z&&Z.sn===H)return Z;return null}function TQ(q,H,Z){if(!q)return null;return yQ(q.partList,H,Z)}function yQ(q,H,Z){if(q)for(var Q=q.length;Q--;){var Y=q[Q];if(Y.index===Z&&Y.fragment.sn===H)return Y}return null}function kQ(q){q.forEach(function(H,Z){var Q;(Q=H.details)==null||Q.fragments.forEach(function(Y){if(Y.level=Z,Y.initSegment)Y.initSegment.level=Z})})}var XZ=300000,HZ=function(q){function H(Q){var Y=q.call(this,"content-steering",Q.logger)||this;return Y.hls=void 0,Y.loader=null,Y.uri=null,Y.pathwayId=".",Y._pathwayPriority=null,Y.timeToLoad=300,Y.reloadTimer=-1,Y.updated=0,Y.started=!1,Y.enabled=!0,Y.levels=null,Y.audioTracks=null,Y.subtitleTracks=null,Y.penalizedPathways={},Y.hls=Q,Y.registerListeners(),Y}j0(H,q);var Z=H.prototype;return Z.registerListeners=function Q(){var Y=this.hls;Y.on($.MANIFEST_LOADING,this.onManifestLoading,this),Y.on($.MANIFEST_LOADED,this.onManifestLoaded,this),Y.on($.MANIFEST_PARSED,this.onManifestParsed,this),Y.on($.ERROR,this.onError,this)},Z.unregisterListeners=function Q(){var Y=this.hls;if(!Y)return;Y.off($.MANIFEST_LOADING,this.onManifestLoading,this),Y.off($.MANIFEST_LOADED,this.onManifestLoaded,this),Y.off($.MANIFEST_PARSED,this.onManifestParsed,this),Y.off($.ERROR,this.onError,this)},Z.pathways=function Q(){return(this.levels||[]).reduce(function(Y,J){if(Y.indexOf(J.pathwayId)===-1)Y.push(J.pathwayId);return Y},[])},Z.startLoad=function Q(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){var Y=this.timeToLoad*1000-(performance.now()-this.updated);if(Y>0){this.scheduleRefresh(this.uri,Y);return}}this.loadSteeringManifest(this.uri)}},Z.stopLoad=function Q(){if(this.started=!1,this.loader)this.loader.destroy(),this.loader=null;this.clearTimeout()},Z.clearTimeout=function Q(){if(this.reloadTimer!==-1)self.clearTimeout(this.reloadTimer),this.reloadTimer=-1},Z.destroy=function Q(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null},Z.removeLevel=function Q(Y){var J=this.levels;if(J)this.levels=J.filter(function(X){return X!==Y})},Z.onManifestLoading=function Q(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null},Z.onManifestLoaded=function Q(Y,J){var X=J.contentSteering;if(X===null)return;if(this.pathwayId=X.pathwayId,this.uri=X.uri,this.started)this.startLoad()},Z.onManifestParsed=function Q(Y,J){this.audioTracks=J.audioTracks,this.subtitleTracks=J.subtitleTracks},Z.onError=function Q(Y,J){var X=J.errorAction;if((X==null?void 0:X.action)===F0.SendAlternateToPenaltyBox&&X.flags===y0.MoveAllAlternatesMatchingHost){var z=this.levels,N=this._pathwayPriority,W=this.pathwayId;if(J.context){var G=J.context,K=G.groupId,j=G.pathwayId,V=G.type;if(K&&z)W=this.getPathwayForGroupId(K,V,W);else if(j)W=j}if(!(W in this.penalizedPathways))this.penalizedPathways[W]=performance.now();if(!N&&z)N=this.pathways();if(N&&N.length>1)this.updatePathwayPriority(N),X.resolved=this.pathwayId!==W;if(!X.resolved)this.warn("Could not resolve "+J.details+' ("'+J.error.message+'") with content-steering for Pathway: '+W+" levels: "+(z?z.length:z)+" priorities: "+M0(N)+" penalized: "+M0(this.penalizedPathways))}},Z.filterParsedLevels=function Q(Y){this.levels=Y;var J=this.getLevelsForPathway(this.pathwayId);if(J.length===0){var X=Y[0].pathwayId;this.log("No levels found in Pathway "+this.pathwayId+'. Setting initial Pathway to "'+X+'"'),J=this.getLevelsForPathway(X),this.pathwayId=X}if(J.length!==Y.length)this.log("Found "+J.length+"/"+Y.length+' levels in Pathway "'+this.pathwayId+'"');return J},Z.getLevelsForPathway=function Q(Y){if(this.levels===null)return[];return this.levels.filter(function(J){return Y===J.pathwayId})},Z.updatePathwayPriority=function Q(Y){this._pathwayPriority=Y;var J,X=this.penalizedPathways,z=performance.now();Object.keys(X).forEach(function(V){if(z-X[V]>XZ)delete X[V]});for(var N=0;N<Y.length;N++){var W=Y[N];if(W in X)continue;if(W===this.pathwayId)return;var G=this.hls.nextLoadLevel,K=this.hls.levels[G];if(J=this.getLevelsForPathway(W),J.length>0){this.log('Setting Pathway to "'+W+'"'),this.pathwayId=W,kQ(J),this.hls.trigger($.LEVELS_UPDATED,{levels:J});var j=this.hls.levels[G];if(K&&j&&this.levels){if(j.attrs["STABLE-VARIANT-ID"]!==K.attrs["STABLE-VARIANT-ID"]&&j.bitrate!==K.bitrate)this.log("Unstable Pathways change from bitrate "+K.bitrate+" to "+j.bitrate);this.hls.nextLoadLevel=G}break}}},Z.getPathwayForGroupId=function Q(Y,J,X){var z=this.getLevelsForPathway(X).concat(this.levels||[]);for(var N=0;N<z.length;N++)if(J===o.AUDIO_TRACK&&z[N].hasAudioGroup(Y)||J===o.SUBTITLE_TRACK&&z[N].hasSubtitleGroup(Y))return z[N].pathwayId;return X},Z.clonePathways=function Q(Y){var J=this,X=this.levels;if(!X)return;var z={},N={};Y.forEach(function(W){var G=W.ID,K=W["BASE-ID"],j=W["URI-REPLACEMENT"];if(X.some(function(U){return U.pathwayId===G}))return;var V=J.getLevelsForPathway(K).map(function(U){var A=new N0(U.attrs);A["PATHWAY-ID"]=G;var E=A.AUDIO&&A.AUDIO+"_clone_"+G,B=A.SUBTITLES&&A.SUBTITLES+"_clone_"+G;if(E)z[A.AUDIO]=E,A.AUDIO=E;if(B)N[A.SUBTITLES]=B,A.SUBTITLES=B;var F=hQ(U.uri,A["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",j),R=new ZQ({attrs:A,audioCodec:U.audioCodec,bitrate:U.bitrate,height:U.height,name:U.name,url:F,videoCodec:U.videoCodec,width:U.width});if(U.audioGroups)for(var O=1;O<U.audioGroups.length;O++)R.addGroupId("audio",U.audioGroups[O]+"_clone_"+G);if(U.subtitleGroups)for(var M=1;M<U.subtitleGroups.length;M++)R.addGroupId("text",U.subtitleGroups[M]+"_clone_"+G);return R});X.push.apply(X,V),_Q(J.audioTracks,z,j,G),_Q(J.subtitleTracks,N,j,G)})},Z.loadSteeringManifest=function Q(Y){var J=this,X=this.hls.config,z=X.loader;if(this.loader)this.loader.destroy();this.loader=new z(X);var N;try{N=new self.URL(Y)}catch(A){this.enabled=!1,this.log("Failed to parse Steering Manifest URI: "+Y);return}if(N.protocol!=="data:"){var W=(this.hls.bandwidthEstimate||X.abrEwmaDefaultEstimate)|0;N.searchParams.set("_HLS_pathway",this.pathwayId),N.searchParams.set("_HLS_throughput",""+W)}var G={responseType:"json",url:N.href},K=X.steeringManifestLoadPolicy.default,j=K.errorRetry||K.timeoutRetry||{},V={loadPolicy:K,timeout:K.maxLoadTimeMs,maxRetry:j.maxNumRetry||0,retryDelay:j.retryDelayMs||0,maxRetryDelay:j.maxRetryDelayMs||0},U={onSuccess:function A(E,B,F,R){J.log('Loaded steering manifest: "'+N+'"');var O=E.data;if((O==null?void 0:O.VERSION)!==1){J.log("Steering VERSION "+O.VERSION+" not supported!");return}J.updated=performance.now(),J.timeToLoad=O.TTL;var M=O["RELOAD-URI"],L=O["PATHWAY-CLONES"],I=O["PATHWAY-PRIORITY"];if(M)try{J.uri=new self.URL(M,N).href}catch(S){J.enabled=!1,J.log("Failed to parse Steering Manifest RELOAD-URI: "+M);return}if(J.scheduleRefresh(J.uri||F.url),L)J.clonePathways(L);var w={steeringManifest:O,url:N.toString()};if(J.hls.trigger($.STEERING_MANIFEST_LOADED,w),I)J.updatePathwayPriority(I)},onError:function A(E,B,F,R){if(J.log("Error loading steering manifest: "+E.code+" "+E.text+" ("+B.url+")"),J.stopLoad(),E.code===410){J.enabled=!1,J.log("Steering manifest "+B.url+" no longer available");return}var O=J.timeToLoad*1000;if(E.code===429){var M=J.loader;if(typeof(M==null?void 0:M.getResponseHeader)==="function"){var L=M.getResponseHeader("Retry-After");if(L)O=parseFloat(L)*1000}J.log("Steering manifest "+B.url+" rate limited");return}J.scheduleRefresh(J.uri||B.url,O)},onTimeout:function A(E,B,F){J.log("Timeout loading steering manifest ("+B.url+")"),J.scheduleRefresh(J.uri||B.url)}};this.log("Requesting steering manifest: "+N),this.loader.load(G,V,U)},Z.scheduleRefresh=function Q(Y,J){var X=this;if(J===void 0)J=this.timeToLoad*1000;this.clearTimeout(),this.reloadTimer=self.setTimeout(function(){var z,N=(z=X.hls)==null?void 0:z.media;if(N&&!N.ended){X.loadSteeringManifest(Y);return}X.scheduleRefresh(Y,X.timeToLoad*1000)},J)},q0(H,[{key:"pathwayPriority",get:function Q(){return this._pathwayPriority},set:function Q(Y){this.updatePathwayPriority(Y)}}])}(i0);function _Q(q,H,Z,Q){if(!q)return;Object.keys(H).forEach(function(Y){var J=q.filter(function(X){return X.groupId===Y}).map(function(X){var z=K0({},X);return z.details=void 0,z.attrs=new N0(z.attrs),z.url=z.attrs.URI=hQ(X.url,X.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",Z),z.groupId=z.attrs["GROUP-ID"]=H[Y],z.attrs["PATHWAY-ID"]=Q,z});q.push.apply(q,J)})}function hQ(q,H,Z,Q){var{HOST:Y,PARAMS:J}=Q,X=Q[Z],z;if(H){if(z=X==null?void 0:X[H],z)q=z}var N=new self.URL(q);if(Y&&!z)N.host=Y;if(J)Object.keys(J).sort().forEach(function(W){if(W)N.searchParams.set(W,J[W])});return N.href}var zZ=function(){function q(Z){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=Z,this.registerListeners()}var H=q.prototype;return H.setStreamController=function Z(Q){this.streamController=Q},H.registerListeners=function Z(){this.hls.on($.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on($.MEDIA_DETACHING,this.onMediaDetaching,this)},H.unregisterListeners=function Z(){this.hls.off($.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off($.MEDIA_DETACHING,this.onMediaDetaching,this)},H.destroy=function Z(){if(this.timer)clearInterval(this.timer);this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},H.onMediaAttaching=function Z(Q,Y){var J=this.hls.config;if(J.capLevelOnFPSDrop){var X=Y.media instanceof self.HTMLVideoElement?Y.media:null;if(this.media=X,X&&typeof X.getVideoPlaybackQuality==="function")this.isVideoPlaybackQualityAvailable=!0;self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),J.fpsDroppedMonitoringPeriod)}},H.onMediaDetaching=function Z(){this.media=null},H.checkFPS=function Z(Q,Y,J){var X=performance.now();if(Y){if(this.lastTime){var z=X-this.lastTime,N=J-this.lastDroppedFrames,W=Y-this.lastDecodedFrames,G=1000*N/z,K=this.hls;if(K.trigger($.FPS_DROP,{currentDropped:N,currentDecoded:W,totalDroppedFrames:J}),G>0){if(N>K.config.fpsDroppedMonitoringThreshold*W){var j=K.currentLevel;if(K.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+j),j>0&&(K.autoLevelCapping===-1||K.autoLevelCapping>=j))j=j-1,K.trigger($.FPS_DROP_LEVEL_CAPPING,{level:j,droppedLevel:K.currentLevel}),K.autoLevelCapping=j,this.streamController.nextLevelSwitch()}}}this.lastTime=X,this.lastDroppedFrames=J,this.lastDecodedFrames=Y}},H.checkFPSInterval=function Z(){var Q=this.media;if(Q)if(this.isVideoPlaybackQualityAvailable){var Y=Q.getVideoPlaybackQuality();this.checkFPS(Q,Y.totalVideoFrames,Y.droppedVideoFrames)}else this.checkFPS(Q,Q.webkitDecodedFrameCount,Q.webkitDroppedFrameCount)},q}(),NZ=function(){function q(){this.chunks=[],this.dataLength=0}var H=q.prototype;return H.push=function Z(Q){this.chunks.push(Q),this.dataLength+=Q.length},H.flush=function Z(){var Q=this.chunks,Y=this.dataLength,J;if(!Q.length)return new Uint8Array(0);else if(Q.length===1)J=Q[0];else J=WZ(Q,Y);return this.reset(),J},H.reset=function Z(){this.chunks.length=0,this.dataLength=0},q}();function WZ(q,H){var Z=new Uint8Array(H),Q=0;for(var Y=0;Y<q.length;Y++){var J=q[Y];Z.set(J,Q),Q+=J.length}return Z}function vQ(q,H){if(H+10<=q.length){if(q[H]===51&&q[H+1]===68&&q[H+2]===73){if(q[H+3]<255&&q[H+4]<255){if(q[H+6]<128&&q[H+7]<128&&q[H+8]<128&&q[H+9]<128)return!0}}}return!1}function H7(q,H){if(H+10<=q.length){if(q[H]===73&&q[H+1]===68&&q[H+2]===51){if(q[H+3]<255&&q[H+4]<255){if(q[H+6]<128&&q[H+7]<128&&q[H+8]<128&&q[H+9]<128)return!0}}}return!1}function LY(q,H){var Z=0;return Z=(q[H]&127)<<21,Z|=(q[H+1]&127)<<14,Z|=(q[H+2]&127)<<7,Z|=q[H+3]&127,Z}function bY(q,H){var Z=H,Q=0;while(H7(q,H)){Q+=10;var Y=LY(q,H+6);if(Q+=Y,vQ(q,H+10))Q+=10;H+=Q}if(Q>0)return q.subarray(Z,Z+Q);return}function GZ(q,H,Z,Q){var Y=[96000,88200,64000,48000,44100,32000,24000,22050,16000,12000,11025,8000,7350],J=H[Z+2],X=J>>2&15;if(X>12){var z=new Error("invalid ADTS sampling index:"+X);q.emit($.ERROR,$.ERROR,{type:f.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!0,error:z,reason:z.message});return}var N=(J>>6&3)+1,W=H[Z+3]>>6&3|(J&1)<<2,G="mp4a.40."+N,K=Y[X],j=X;if(N===5||N===29)j-=3;var V=[N<<3|(j&14)>>1,(j&1)<<7|W<<3];return s.log("manifest codec:"+Q+", parsed codec:"+G+", channels:"+W+", rate:"+K+" (ADTS object type:"+N+" sampling index:"+X+")"),{config:V,samplerate:K,channelCount:W,codec:G,parsedCodec:G,manifestCodec:Q}}function gQ(q,H){return q[H]===255&&(q[H+1]&246)===240}function mQ(q,H){return q[H+1]&1?7:9}function z7(q,H){return(q[H+3]&3)<<11|q[H+4]<<3|(q[H+5]&224)>>>5}function KZ(q,H){return H+5<q.length}function CY(q,H){return H+1<q.length&&gQ(q,H)}function jZ(q,H){return KZ(q,H)&&gQ(q,H)&&z7(q,H)<=q.length-H}function UZ(q,H){if(CY(q,H)){var Z=mQ(q,H);if(H+Z>=q.length)return!1;var Q=z7(q,H);if(Q<=Z)return!1;var Y=H+Q;return Y===q.length||CY(q,Y)}return!1}function pQ(q,H,Z,Q,Y){if(!q.samplerate){var J=GZ(H,Z,Q,Y);if(!J)return;K0(q,J)}}function uQ(q){return 92160000/q}function VZ(q,H){var Z=mQ(q,H);if(H+Z<=q.length){var Q=z7(q,H)-Z;if(Q>0)return{headerLength:Z,frameLength:Q}}}function cQ(q,H,Z,Q,Y){var J=uQ(q.samplerate),X=Q+Y*J,z=VZ(H,Z),N;if(z){var{frameLength:W,headerLength:G}=z,K=G+W,j=Math.max(0,Z+K-H.length);if(j)N=new Uint8Array(K-G),N.set(H.subarray(Z+G,H.length),0);else N=H.subarray(Z+G,Z+K);var V={unit:N,pts:X};if(!j)q.samples.push(V);return{sample:V,length:K,missing:j}}var U=H.length-Z;N=new Uint8Array(U),N.set(H.subarray(Z,H.length),0);var A={unit:N,pts:X};return{sample:A,length:U,missing:-1}}function AZ(q,H){return H7(q,H)&&LY(q,H+6)+10<=q.length-H}function EZ(q){if(q.size<2)return;var H=x0(q.data,!0),Z=new Uint8Array(q.data.subarray(H.length+1));return{key:q.type,info:H,data:Z.buffer}}function BZ(q){if(q.size<2)return;if(q.type==="TXXX"){var H=1,Z=x0(q.data.subarray(H),!0);H+=Z.length+1;var Q=x0(q.data.subarray(H));return{key:q.type,info:Z,data:Q}}var Y=x0(q.data.subarray(1));return{key:q.type,info:"",data:Y}}function $Z(q){if(q.type==="WXXX"){if(q.size<2)return;var H=1,Z=x0(q.data.subarray(H),!0);H+=Z.length+1;var Q=x0(q.data.subarray(H));return{key:q.type,info:Z,data:Q}}var Y=x0(q.data);return{key:q.type,info:"",data:Y}}function FZ(q){if(q instanceof ArrayBuffer)return q;else{if(q.byteOffset==0&&q.byteLength==q.buffer.byteLength)return q.buffer;return new Uint8Array(q).buffer}}function N7(q,H,Z){if(H===void 0)H=0;if(Z===void 0)Z=1/0;return OZ(q,H,Z,Uint8Array)}function OZ(q,H,Z,Q){var Y=RZ(q),J=1;if("BYTES_PER_ELEMENT"in Q)J=Q.BYTES_PER_ELEMENT;var X=MZ(q)?q.byteOffset:0,z=(X+q.byteLength)/J,N=(X+H)/J,W=Math.floor(Math.max(0,Math.min(N,z))),G=Math.floor(Math.min(W+Math.max(Z,0),z));return new Q(Y,W,G-W)}function RZ(q){if(q instanceof ArrayBuffer)return q;else return q.buffer}function MZ(q){return q&&q.buffer instanceof ArrayBuffer&&q.byteLength!==void 0&&q.byteOffset!==void 0}function IZ(q){var H={key:q.type,description:"",data:"",mimeType:null,pictureType:null},Z=3;if(q.size<2)return;if(q.data[0]!==Z){console.log("Ignore frame with unrecognized character encoding");return}var Q=q.data.subarray(1).indexOf(0);if(Q===-1)return;var Y=x0(N7(q.data,1,Q)),J=q.data[2+Q],X=q.data.subarray(3+Q).indexOf(0);if(X===-1)return;var z=x0(N7(q.data,3+Q,X)),N;if(Y==="-->")N=x0(N7(q.data,4+Q+X));else N=FZ(q.data.subarray(4+Q+X));return H.mimeType=Y,H.pictureType=J,H.description=z,H.data=N,H}function wZ(q){if(q.type==="PRIV")return EZ(q);else if(q.type[0]==="W")return $Z(q);else if(q.type==="APIC")return IZ(q);return BZ(q)}function LZ(q){var H=String.fromCharCode(q[0],q[1],q[2],q[3]),Z=LY(q,4),Q=10;return{type:H,size:Z,data:q.subarray(Q,Q+Z)}}var PY=10,bZ=10;function fQ(q){var H=0,Z=[];while(H7(q,H)){var Q=LY(q,H+6);if(q[H+5]>>6&1)H+=PY;H+=PY;var Y=H+Q;while(H+bZ<Y){var J=LZ(q.subarray(H)),X=wZ(J);if(X)Z.push(X);H+=J.size+PY}if(vQ(q,H))H+=PY}return Z}function dQ(q){return q&&q.key==="PRIV"&&q.info==="com.apple.streaming.transportStreamTimestamp"}function CZ(q){if(q.data.byteLength===8){var H=new Uint8Array(q.data),Z=H[3]&1,Q=(H[4]<<23)+(H[5]<<15)+(H[6]<<7)+H[7];if(Q/=45,Z)Q+=47721858.84;return Math.round(Q)}return}function lQ(q){var H=fQ(q);for(var Z=0;Z<H.length;Z++){var Q=H[Z];if(dQ(Q))return CZ(Q)}return}var D0=function(q){return q.audioId3="org.id3",q.dateRange="com.apple.quicktime.HLS",q.emsg="https://aomedia.org/emsg/ID3",q.misbklv="urn:misb:KLV:bin:1910.1",q}({});function m0(q,H){if(q===void 0)q="";if(H===void 0)H=90000;return{type:q,id:-1,pid:-1,inputTimeScale:H,sequenceNumber:-1,samples:[],dropped:0}}var nQ=function(){function q(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var H=q.prototype;return H.resetInitSegment=function Z(Q,Y,J,X){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:90000,sequenceNumber:0,samples:[],dropped:0}},H.resetTimeStamp=function Z(Q){this.initPTS=Q,this.resetContiguity()},H.resetContiguity=function Z(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},H.canParse=function Z(Q,Y){return!1},H.appendFrame=function Z(Q,Y,J){},H.demux=function Z(Q,Y){if(this.cachedData)Q=T0(this.cachedData,Q),this.cachedData=null;var J=bY(Q,0),X=J?J.length:0,z,N=this._audioTrack,W=this._id3Track,G=J?lQ(J):void 0,K=Q.length;if(this.basePTS===null||this.frameIndex===0&&v(G))this.basePTS=PZ(G,Y,this.initPTS),this.lastPTS=this.basePTS;if(this.lastPTS===null)this.lastPTS=this.basePTS;if(J&&J.length>0)W.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:J,type:D0.audioId3,duration:Number.POSITIVE_INFINITY});while(X<K){if(this.canParse(Q,X)){var j=this.appendFrame(N,Q,X);if(j)this.frameIndex++,this.lastPTS=j.sample.pts,X+=j.length,z=X;else X=K}else if(AZ(Q,X))J=bY(Q,X),W.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:J,type:D0.audioId3,duration:Number.POSITIVE_INFINITY}),X+=J.length,z=X;else X++;if(X===K&&z!==K){var V=Q.slice(z);if(this.cachedData)this.cachedData=T0(this.cachedData,V);else this.cachedData=V}}return{audioTrack:N,videoTrack:m0(),id3Track:W,textTrack:m0()}},H.demuxSampleAes=function Z(Q,Y,J){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},H.flush=function Z(Q){var Y=this.cachedData;if(Y)this.cachedData=null,this.demux(Y,0);return{audioTrack:this._audioTrack,videoTrack:m0(),id3Track:this._id3Track,textTrack:m0()}},H.destroy=function Z(){this.cachedData=null,this._audioTrack=this._id3Track=void 0},q}(),PZ=function q(H,Z,Q){if(v(H))return H*90;var Y=Q?Q.baseTime*90000/Q.timescale:0;return Z*90000+Y},DY=null,DZ=[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],SZ=[44100,48000,32000,22050,24000,16000,11025,12000,8000],xZ=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],TZ=[0,1,1,4];function oQ(q,H,Z,Q,Y){if(Z+24>H.length)return;var J=sQ(H,Z);if(J&&Z+J.frameLength<=H.length){var X=J.samplesPerFrame*90000/J.sampleRate,z=Q+Y*X,N={unit:H.subarray(Z,Z+J.frameLength),pts:z,dts:z};return q.config=[],q.channelCount=J.channelCount,q.samplerate=J.sampleRate,q.samples.push(N),{sample:N,length:J.frameLength,missing:0}}}function sQ(q,H){var Z=q[H+1]>>3&3,Q=q[H+1]>>1&3,Y=q[H+2]>>4&15,J=q[H+2]>>2&3;if(Z!==1&&Y!==0&&Y!==15&&J!==3){var X=q[H+2]>>1&1,z=q[H+3]>>6,N=Z===3?3-Q:Q===3?3:4,W=DZ[N*14+Y-1]*1000,G=Z===3?0:Z===2?1:2,K=SZ[G*3+J],j=z===3?1:2,V=xZ[Z][Q],U=TZ[Q],A=V*8*U,E=Math.floor(V*W/K+X)*U;if(DY===null){var B=navigator.userAgent||"",F=B.match(/Chrome\/(\d+)/i);DY=F?parseInt(F[1]):0}var R=!!DY&&DY<=87;if(R&&Q===2&&W>=224000&&z===0)q[H+3]=q[H+3]|128;return{sampleRate:K,channelCount:j,frameLength:E,samplesPerFrame:A}}}function W7(q,H){return q[H]===255&&(q[H+1]&224)===224&&(q[H+1]&6)!==0}function iQ(q,H){return H+1<q.length&&W7(q,H)}function yZ(q,H){var Z=4;return W7(q,H)&&Z<=q.length-H}function rQ(q,H){if(H+1<q.length&&W7(q,H)){var Z=4,Q=sQ(q,H),Y=Z;if(Q!=null&&Q.frameLength)Y=Q.frameLength;var J=H+Y;return J===q.length||iQ(q,J)}return!1}var kZ=function(q){function H(Q,Y){var J=q.call(this)||this;return J.observer=void 0,J.config=void 0,J.observer=Q,J.config=Y,J}j0(H,q);var Z=H.prototype;return Z.resetInitSegment=function Q(Y,J,X,z){q.prototype.resetInitSegment.call(this,Y,J,X,z),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:J,duration:z,inputTimeScale:90000,dropped:0}},H.probe=function Q(Y,J){if(!Y)return!1;var X=bY(Y,0),z=(X==null?void 0:X.length)||0;if(rQ(Y,z))return!1;for(var N=Y.length;z<N;z++)if(UZ(Y,z))return J.log("ADTS sync word found !"),!0;return!1},Z.canParse=function Q(Y,J){return jZ(Y,J)},Z.appendFrame=function Q(Y,J,X){pQ(Y,this.observer,J,X,Y.manifestCodec);var z=cQ(Y,J,X,this.basePTS,this.frameIndex);if(z&&z.missing===0)return z},H}(nQ),_Z=function q(H,Z){var Q=0,Y=5;Z+=Y;var J=new Uint32Array(1),X=new Uint32Array(1),z=new Uint8Array(1);while(Y>0){z[0]=H[Z];var N=Math.min(Y,8),W=8-N;X[0]=4278190080>>>24+W<<W,J[0]=(z[0]&X[0])>>W,Q=!Q?J[0]:Q<<N|J[0],Z+=1,Y-=N}return Q},hZ=function(q){function H(){return q.apply(this,arguments)||this}j0(H,q);var Z=H.prototype;return Z.resetInitSegment=function Q(Y,J,X,z){q.prototype.resetInitSegment.call(this,Y,J,X,z),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:J,duration:z,inputTimeScale:90000,dropped:0}},H.probe=function Q(Y){if(!Y)return!1;var J=bY(Y,0),X=(J==null?void 0:J.length)||0;if(J&&Y[X]===11&&Y[X+1]===119&&lQ(J)!==void 0&&_Z(Y,X)<=16)return!1;for(var z=Y.length;X<z;X++)if(rQ(Y,X))return s.log("MPEG Audio sync word found !"),!0;return!1},Z.canParse=function Q(Y,J){return yZ(Y,J)},Z.appendFrame=function Q(Y,J,X){if(this.basePTS===null)return;return oQ(Y,J,X,this.basePTS,this.frameIndex)},H}(nQ),vZ=function(){function q(Z,Q,Y){this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=Z,this.aesIV=Q,this.aesMode=Y}var H=q.prototype;return H.decrypt=function Z(Q,Y){switch(this.aesMode){case l0.cbc:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},Y,Q);case l0.ctr:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},Y,Q);default:throw new Error("[AESCrypto] invalid aes mode "+this.aesMode)}},q}();function gZ(q){var H=q.byteLength,Z=H&&new DataView(q.buffer).getUint8(H-1);if(Z)return q.slice(0,H-Z);return q}var mZ=function(){function q(){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 H=q.prototype;return H.uint8ArrayToUint32Array_=function Z(Q){var Y=new DataView(Q),J=new Uint32Array(4);for(var X=0;X<4;X++)J[X]=Y.getUint32(X*4);return J},H.initTable=function Z(){var Q=this.sBox,Y=this.invSBox,J=this.subMix,X=J[0],z=J[1],N=J[2],W=J[3],G=this.invSubMix,K=G[0],j=G[1],V=G[2],U=G[3],A=new Uint32Array(256),E=0,B=0,F=0;for(F=0;F<256;F++)if(F<128)A[F]=F<<1;else A[F]=F<<1^283;for(F=0;F<256;F++){var R=B^B<<1^B<<2^B<<3^B<<4;R=R>>>8^R&255^99,Q[E]=R,Y[R]=E;var O=A[E],M=A[O],L=A[M],I=A[R]*257^R*16843008;if(X[E]=I<<24|I>>>8,z[E]=I<<16|I>>>16,N[E]=I<<8|I>>>24,W[E]=I,I=L*16843009^M*65537^O*257^E*16843008,K[R]=I<<24|I>>>8,j[R]=I<<16|I>>>16,V[R]=I<<8|I>>>24,U[R]=I,!E)E=B=1;else E=O^A[A[A[L^O]]],B^=A[A[B]]}},H.expandKey=function Z(Q){var Y=this.uint8ArrayToUint32Array_(Q),J=!0,X=0;while(X<Y.length&&J)J=Y[X]===this.key[X],X++;if(J)return;this.key=Y;var z=this.keySize=Y.length;if(z!==4&&z!==6&&z!==8)throw new Error("Invalid aes key size="+z);var N=this.ksRows=(z+6+1)*4,W,G,K=this.keySchedule=new Uint32Array(N),j=this.invKeySchedule=new Uint32Array(N),V=this.sBox,U=this.rcon,A=this.invSubMix,E=A[0],B=A[1],F=A[2],R=A[3],O,M;for(W=0;W<N;W++){if(W<z){O=K[W]=Y[W];continue}if(M=O,W%z===0)M=M<<8|M>>>24,M=V[M>>>24]<<24|V[M>>>16&255]<<16|V[M>>>8&255]<<8|V[M&255],M^=U[W/z|0]<<24;else if(z>6&&W%z===4)M=V[M>>>24]<<24|V[M>>>16&255]<<16|V[M>>>8&255]<<8|V[M&255];K[W]=O=(K[W-z]^M)>>>0}for(G=0;G<N;G++){if(W=N-G,G&3)M=K[W];else M=K[W-4];if(G<4||W<=4)j[G]=M;else j[G]=E[V[M>>>24]]^B[V[M>>>16&255]]^F[V[M>>>8&255]]^R[V[M&255]];j[G]=j[G]>>>0}},H.networkToHostOrderSwap=function Z(Q){return Q<<24|(Q&65280)<<8|(Q&16711680)>>8|Q>>>24},H.decrypt=function Z(Q,Y,J){var X=this.keySize+6,z=this.invKeySchedule,N=this.invSBox,W=this.invSubMix,G=W[0],K=W[1],j=W[2],V=W[3],U=this.uint8ArrayToUint32Array_(J),A=U[0],E=U[1],B=U[2],F=U[3],R=new Int32Array(Q),O=new Int32Array(R.length),M,L,I,w,S,P,b,C,x,_,y,T,h,g,m=this.networkToHostOrderSwap;while(Y<R.length){x=m(R[Y]),_=m(R[Y+1]),y=m(R[Y+2]),T=m(R[Y+3]),S=x^z[0],P=T^z[1],b=y^z[2],C=_^z[3],h=4;for(g=1;g<X;g++)M=G[S>>>24]^K[P>>16&255]^j[b>>8&255]^V[C&255]^z[h],L=G[P>>>24]^K[b>>16&255]^j[C>>8&255]^V[S&255]^z[h+1],I=G[b>>>24]^K[C>>16&255]^j[S>>8&255]^V[P&255]^z[h+2],w=G[C>>>24]^K[S>>16&255]^j[P>>8&255]^V[b&255]^z[h+3],S=M,P=L,b=I,C=w,h=h+4;M=N[S>>>24]<<24^N[P>>16&255]<<16^N[b>>8&255]<<8^N[C&255]^z[h],L=N[P>>>24]<<24^N[b>>16&255]<<16^N[C>>8&255]<<8^N[S&255]^z[h+1],I=N[b>>>24]<<24^N[C>>16&255]<<16^N[S>>8&255]<<8^N[P&255]^z[h+2],w=N[C>>>24]<<24^N[S>>16&255]<<16^N[P>>8&255]<<8^N[b&255]^z[h+3],O[Y]=m(M^A),O[Y+1]=m(w^E),O[Y+2]=m(I^B),O[Y+3]=m(L^F),A=x,E=_,B=y,F=T,Y=Y+4}return O.buffer},q}(),pZ=function(){function q(Z,Q,Y){this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=Z,this.key=Q,this.aesMode=Y}var H=q.prototype;return H.expandKey=function Z(){var Q=uZ(this.aesMode);return this.subtle.importKey("raw",this.key,{name:Q},!1,["encrypt","decrypt"])},q}();function uZ(q){switch(q){case l0.cbc:return"AES-CBC";case l0.ctr:return"AES-CTR";default:throw new Error("[FastAESKey] invalid aes mode "+q)}}var cZ=16,G7=function(){function q(Z,Q){var Y=Q===void 0?{}:Q,J=Y.removePKCS7Padding,X=J===void 0?!0:J;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=Z.enableSoftwareAES,this.removePKCS7Padding=X,X)try{var z=self.crypto;if(z)this.subtle=z.subtle||z.webkitSubtle}catch(N){}this.useSoftware=!this.subtle}var H=q.prototype;return H.destroy=function Z(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},H.isSync=function Z(){return this.useSoftware},H.flush=function Z(){var Q=this.currentResult,Y=this.remainderData;if(!Q||Y)return this.reset(),null;var J=new Uint8Array(Q);if(this.reset(),this.removePKCS7Padding)return gZ(J);return J},H.reset=function Z(){if(this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter)this.softwareDecrypter=null},H.decrypt=function Z(Q,Y,J,X){var z=this;if(this.useSoftware)return new Promise(function(N,W){var G=ArrayBuffer.isView(Q)?Q:new Uint8Array(Q);z.softwareDecrypt(G,Y,J,X);var K=z.flush();if(K)N(K.buffer);else W(new Error("[softwareDecrypt] Failed to decrypt data"))});return this.webCryptoDecrypt(new Uint8Array(Q),Y,J,X)},H.softwareDecrypt=function Z(Q,Y,J,X){var z=this.currentIV,N=this.currentResult,W=this.remainderData;if(X!==l0.cbc||Y.byteLength!==16)return s.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;if(this.logOnce("JS AES decrypt"),W)Q=T0(W,Q),this.remainderData=null;var G=this.getValidChunk(Q);if(!G.length)return null;if(z)J=z;var K=this.softwareDecrypter;if(!K)K=this.softwareDecrypter=new mZ;K.expandKey(Y);var j=N;if(this.currentResult=K.decrypt(G.buffer,0,J),this.currentIV=G.slice(-16).buffer,!j)return null;return j},H.webCryptoDecrypt=function Z(Q,Y,J,X){var z=this;if(this.key!==Y||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(Q,Y,J,X));this.key=Y,this.fastAesKey=new pZ(this.subtle,Y,X)}return this.fastAesKey.expandKey().then(function(N){if(!z.subtle)return Promise.reject(new Error("web crypto not initialized"));z.logOnce("WebCrypto AES decrypt");var W=new vZ(z.subtle,new Uint8Array(J),X);return W.decrypt(Q.buffer,N)}).catch(function(N){return s.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+N.name+": "+N.message),z.onWebCryptoError(Q,Y,J,X)})},H.onWebCryptoError=function Z(Q,Y,J,X){var z=this.enableSoftwareAES;if(z){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(Q,Y,J,X);var N=this.flush();if(N)return N.buffer}throw new Error("WebCrypto"+(z?" and softwareDecrypt":"")+": failed to decrypt data")},H.getValidChunk=function Z(Q){var Y=Q,J=Q.length-Q.length%cZ;if(J!==Q.length)Y=Q.slice(0,J),this.remainderData=Q.slice(J);return Y},H.logOnce=function Z(Q){if(!this.logEnabled)return;s.log("[decrypter]: "+Q),this.logEnabled=!1},q}(),fZ=/\/emsg[-/]ID3/i,dZ=function(){function q(Z,Q){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=Q}var H=q.prototype;return H.resetTimeStamp=function Z(){},H.resetInitSegment=function Z(Q,Y,J,X){var z=this.videoTrack=m0("video",1),N=this.audioTrack=m0("audio",1),W=this.txtTrack=m0("text",1);if(this.id3Track=m0("id3",1),this.timeOffset=0,!(Q!=null&&Q.byteLength))return;var G=l7(Q);if(G.video){var K=G.video,j=K.id,V=K.timescale,U=K.codec,A=K.supplemental;z.id=j,z.timescale=W.timescale=V,z.codec=U,z.supplemental=A}if(G.audio){var E=G.audio,B=E.id,F=E.timescale,R=E.codec;N.id=B,N.timescale=F,N.codec=R}W.id=u7.text,z.sampleDuration=0,z.duration=N.duration=X},H.resetContiguity=function Z(){this.remainderData=null},q.probe=function Z(Q){return Z8(Q)},H.demux=function Z(Q,Y){this.timeOffset=Y;var J=Q,X=this.videoTrack,z=this.txtTrack;if(this.config.progressive){if(this.remainderData)J=T0(this.remainderData,Q);var N=j8(J);this.remainderData=N.remainder,X.samples=N.valid||new Uint8Array}else X.samples=J;var W=this.extractID3Track(X,Y);return z.samples=n7(Y,X),{videoTrack:X,audioTrack:this.audioTrack,id3Track:W,textTrack:this.txtTrack}},H.flush=function Z(){var Q=this.timeOffset,Y=this.videoTrack,J=this.txtTrack;Y.samples=this.remainderData||new Uint8Array,this.remainderData=null;var X=this.extractID3Track(Y,this.timeOffset);return J.samples=n7(Q,Y),{videoTrack:Y,audioTrack:m0(),id3Track:X,textTrack:m0()}},H.extractID3Track=function Z(Q,Y){var J=this,X=this.id3Track;if(Q.samples.length){var z=c(Q.samples,["emsg"]);if(z)z.forEach(function(N){var W=V8(N);if(fZ.test(W.schemeIdUri)){var G=aQ(W,Y),K=W.eventDuration===4294967295?Number.POSITIVE_INFINITY:W.eventDuration/W.timeScale;if(K<=0.001)K=Number.POSITIVE_INFINITY;var j=W.payload;X.samples.push({data:j,len:j.byteLength,dts:G,pts:G,type:D0.emsg,duration:K})}else if(J.config.enableEmsgKLVMetadata&&W.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){var V=aQ(W,Y);X.samples.push({data:W.payload,len:W.payload.byteLength,dts:V,pts:V,type:D0.misbklv,duration:Number.POSITIVE_INFINITY})}})}return X},H.demuxSampleAes=function Z(Q,Y,J){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},H.destroy=function Z(){this.config=null,this.remainderData=null,this.videoTrack=this.audioTrack=this.id3Track=this.txtTrack=void 0},q}();function aQ(q,H){return v(q.presentationTime)?q.presentationTime/q.timeScale:H+q.presentationTimeDelta/q.timeScale}var lZ=function(){function q(Z,Q,Y){this.keyData=void 0,this.decrypter=void 0,this.keyData=Y,this.decrypter=new G7(Q,{removePKCS7Padding:!1})}var H=q.prototype;return H.decryptBuffer=function Z(Q){return this.decrypter.decrypt(Q,this.keyData.key.buffer,this.keyData.iv.buffer,l0.cbc)},H.decryptAacSample=function Z(Q,Y,J){var X=this,z=Q[Y].unit;if(z.length<=16)return;var N=z.subarray(16,z.length-z.length%16),W=N.buffer.slice(N.byteOffset,N.byteOffset+N.length);this.decryptBuffer(W).then(function(G){var K=new Uint8Array(G);if(z.set(K,16),!X.decrypter.isSync())X.decryptAacSamples(Q,Y+1,J)})},H.decryptAacSamples=function Z(Q,Y,J){for(;;Y++){if(Y>=Q.length){J();return}if(Q[Y].unit.length<32)continue;if(this.decryptAacSample(Q,Y,J),!this.decrypter.isSync())return}},H.getAvcEncryptedData=function Z(Q){var Y=Math.floor((Q.length-48)/160)*16+16,J=new Int8Array(Y),X=0;for(var z=32;z<Q.length-16;z+=160,X+=16)J.set(Q.subarray(z,z+16),X);return J},H.getAvcDecryptedUnit=function Z(Q,Y){var J=new Uint8Array(Y),X=0;for(var z=32;z<Q.length-16;z+=160,X+=16)Q.set(J.subarray(X,X+16),z);return Q},H.decryptAvcSample=function Z(Q,Y,J,X,z){var N=this,W=s7(z.data),G=this.getAvcEncryptedData(W);this.decryptBuffer(G.buffer).then(function(K){if(z.data=N.getAvcDecryptedUnit(W,K),!N.decrypter.isSync())N.decryptAvcSamples(Q,Y,J+1,X)})},H.decryptAvcSamples=function Z(Q,Y,J,X){if(Q instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;Y++,J=0){if(Y>=Q.length){X();return}var z=Q[Y].units;for(;;J++){if(J>=z.length)break;var N=z[J];if(N.data.length<=48||N.type!==1&&N.type!==5)continue;if(this.decryptAvcSample(Q,Y,J,X,N),!this.decrypter.isSync())return}}},q}(),nZ=function(){function q(){this.VideoSample=null}var H=q.prototype;return H.createVideoSample=function Z(Q,Y,J){return{key:Q,frame:!1,pts:Y,dts:J,units:[],length:0}},H.getLastNalUnit=function Z(Q){var Y,J=this.VideoSample,X;if(!J||J.units.length===0)J=Q[Q.length-1];if((Y=J)!=null&&Y.units){var z=J.units;X=z[z.length-1]}return X},H.pushAccessUnit=function Z(Q,Y){if(Q.units.length&&Q.frame){if(Q.pts===void 0){var J=Y.samples,X=J.length;if(X){var z=J[X-1];Q.pts=z.pts,Q.dts=z.dts}else{Y.dropped++;return}}Y.samples.push(Q)}},H.parseNALu=function Z(Q,Y,J){var X=Y.byteLength,z=Q.naluState||0,N=z,W=[],G=0,K,j,V,U=-1,A=0;if(z===-1)U=0,A=this.getNALuType(Y,0),z=0,G=1;while(G<X){if(K=Y[G++],!z){z=K?0:1;continue}if(z===1){z=K?0:2;continue}if(!K)z=3;else if(K===1){if(j=G-z-1,U>=0){var E={data:Y.subarray(U,j),type:A};W.push(E)}else{var B=this.getLastNalUnit(Q.samples);if(B){if(N&&G<=4-N){if(B.state)B.data=B.data.subarray(0,B.data.byteLength-N)}if(j>0)B.data=T0(B.data,Y.subarray(0,j)),B.state=0}}if(G<X)V=this.getNALuType(Y,G),U=G,A=V,z=0;else z=-1}else z=0}if(U>=0&&z>=0){var F={data:Y.subarray(U,X),type:A,state:z};W.push(F)}if(W.length===0){var R=this.getLastNalUnit(Q.samples);if(R)R.data=T0(R.data,Y)}return Q.naluState=z,W},q}(),tQ=function(){function q(Z){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=Z,this.bytesAvailable=Z.byteLength,this.word=0,this.bitsAvailable=0}var H=q.prototype;return H.loadWord=function Z(){var Q=this.data,Y=this.bytesAvailable,J=Q.byteLength-Y,X=new Uint8Array(4),z=Math.min(4,Y);if(z===0)throw new Error("no bytes available");X.set(Q.subarray(J,J+z)),this.word=new DataView(X.buffer).getUint32(0),this.bitsAvailable=z*8,this.bytesAvailable-=z},H.skipBits=function Z(Q){var Y;if(Q=Math.min(Q,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>Q)this.word<<=Q,this.bitsAvailable-=Q;else Q-=this.bitsAvailable,Y=Q>>3,Q-=Y<<3,this.bytesAvailable-=Y,this.loadWord(),this.word<<=Q,this.bitsAvailable-=Q},H.readBits=function Z(Q){var Y=Math.min(this.bitsAvailable,Q),J=this.word>>>32-Y;if(Q>32)s.error("Cannot read more than 32 bits at a time");if(this.bitsAvailable-=Y,this.bitsAvailable>0)this.word<<=Y;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");if(Y=Q-Y,Y>0&&this.bitsAvailable)return J<<Y|this.readBits(Y);else return J},H.skipLZ=function Z(){var Q;for(Q=0;Q<this.bitsAvailable;++Q)if((this.word&2147483648>>>Q)!==0)return this.word<<=Q,this.bitsAvailable-=Q,Q;return this.loadWord(),Q+this.skipLZ()},H.skipUEG=function Z(){this.skipBits(1+this.skipLZ())},H.skipEG=function Z(){this.skipBits(1+this.skipLZ())},H.readUEG=function Z(){var Q=this.skipLZ();return this.readBits(Q+1)-1},H.readEG=function Z(){var Q=this.readUEG();if(1&Q)return 1+Q>>>1;else return-1*(Q>>>1)},H.readBoolean=function Z(){return this.readBits(1)===1},H.readUByte=function Z(){return this.readBits(8)},H.readUShort=function Z(){return this.readBits(16)},H.readUInt=function Z(){return this.readBits(32)},q}(),eQ=function(q){function H(){return q.apply(this,arguments)||this}j0(H,q);var Z=H.prototype;return Z.parsePES=function Q(Y,J,X,z){var N=this,W=this.parseNALu(Y,X.data,z),G=this.VideoSample,K,j=!1;if(X.data=null,G&&W.length&&!Y.audFound)this.pushAccessUnit(G,Y),G=this.VideoSample=this.createVideoSample(!1,X.pts,X.dts);if(W.forEach(function(V){var U,A;switch(V.type){case 1:{var E=!1;K=!0;var B=V.data;if(j&&B.length>4){var F=N.readSliceType(B);if(F===2||F===4||F===7||F===9)E=!0}if(E){var R;if((R=G)!=null&&R.frame&&!G.key)N.pushAccessUnit(G,Y),G=N.VideoSample=null}if(!G)G=N.VideoSample=N.createVideoSample(!0,X.pts,X.dts);G.frame=!0,G.key=E;break}case 5:if(K=!0,(U=G)!=null&&U.frame&&!G.key)N.pushAccessUnit(G,Y),G=N.VideoSample=null;if(!G)G=N.VideoSample=N.createVideoSample(!0,X.pts,X.dts);G.key=!0,G.frame=!0;break;case 6:{K=!0,o7(V.data,1,X.pts,J.samples);break}case 7:{var O,M;K=!0,j=!0;var L=V.data,I=N.readSPS(L);if(!Y.sps||Y.width!==I.width||Y.height!==I.height||((O=Y.pixelRatio)==null?void 0:O[0])!==I.pixelRatio[0]||((M=Y.pixelRatio)==null?void 0:M[1])!==I.pixelRatio[1]){Y.width=I.width,Y.height=I.height,Y.pixelRatio=I.pixelRatio,Y.sps=[L];var w=L.subarray(1,4),S="avc1.";for(var P=0;P<3;P++){var b=w[P].toString(16);if(b.length<2)b="0"+b;S+=b}Y.codec=S}break}case 8:K=!0,Y.pps=[V.data];break;case 9:if(K=!0,Y.audFound=!0,(A=G)!=null&&A.frame)N.pushAccessUnit(G,Y),G=null;if(!G)G=N.VideoSample=N.createVideoSample(!1,X.pts,X.dts);break;case 12:K=!0;break;default:K=!1;break}if(G&&K){var C=G.units;C.push(V)}}),z&&G)this.pushAccessUnit(G,Y),this.VideoSample=null},Z.getNALuType=function Q(Y,J){return Y[J]&31},Z.readSliceType=function Q(Y){var J=new tQ(Y);return J.readUByte(),J.readUEG(),J.readUEG()},Z.skipScalingList=function Q(Y,J){var X=8,z=8,N;for(var W=0;W<Y;W++){if(z!==0)N=J.readEG(),z=(X+N+256)%256;X=z===0?X:z}},Z.readSPS=function Q(Y){var J=new tQ(Y),X=0,z=0,N=0,W=0,G,K,j,V=J.readUByte.bind(J),U=J.readBits.bind(J),A=J.readUEG.bind(J),E=J.readBoolean.bind(J),B=J.skipBits.bind(J),F=J.skipEG.bind(J),R=J.skipUEG.bind(J),O=this.skipScalingList.bind(this);V();var M=V();if(U(5),B(3),V(),R(),M===100||M===110||M===122||M===244||M===44||M===83||M===86||M===118||M===128){var L=A();if(L===3)B(1);if(R(),R(),B(1),E()){K=L!==3?8:12;for(j=0;j<K;j++)if(E())if(j<6)O(16,J);else O(64,J)}}R();var I=A();if(I===0)A();else if(I===1){B(1),F(),F(),G=A();for(j=0;j<G;j++)F()}R(),B(1);var w=A(),S=A(),P=U(1);if(P===0)B(1);if(B(1),E())X=A(),z=A(),N=A(),W=A();var b=[1,1];if(E()){if(E()){var C=V();switch(C){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((w+1)*16-X*2-z*2),height:(2-P)*(S+1)*16-(P?2:4)*(N+W),pixelRatio:b}},H}(nZ),V0=188,oZ=function(){function q(Z,Q,Y,J){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=Z,this.config=Q,this.typeSupported=Y,this.logger=J,this.videoParser=null}q.probe=function Z(Q,Y){var J=q.syncOffset(Q);if(J>0)Y.warn("MPEG2-TS detected but first sync word found @ offset "+J);return J!==-1},q.syncOffset=function Z(Q){var Y=Q.length,J=Math.min(V0*5,Y-V0)+1,X=0;while(X<J){var z=!1,N=-1,W=0;for(var G=X;G<Y;G+=V0)if(Q[G]===71&&(Y-G===V0||Q[G+V0]===71)){if(W++,N===-1){if(N=G,N!==0)J=Math.min(N+V0*99,Q.length-V0)+1}if(!z)z=K7(Q,G)===0;if(z&&W>1&&(N===0&&W>2||G+V0>J))return N}else if(W)return-1;else break;X++}return-1},q.createTrack=function Z(Q,Y){return{container:Q==="video"||Q==="audio"?"video/mp2t":void 0,type:Q,id:u7[Q],pid:-1,inputTimeScale:90000,sequenceNumber:0,samples:[],dropped:0,duration:Q==="audio"?Y:void 0}};var H=q.prototype;return H.resetInitSegment=function Z(Q,Y,J,X){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=q.createTrack("video"),this._videoTrack.duration=X,this._audioTrack=q.createTrack("audio",X),this._id3Track=q.createTrack("id3"),this._txtTrack=q.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=Y,this.videoCodec=J},H.resetTimeStamp=function Z(){},H.resetContiguity=function Z(){var Q=this._audioTrack,Y=this._videoTrack,J=this._id3Track;if(Q)Q.pesData=null;if(Y)Y.pesData=null;if(J)J.pesData=null;this.aacOverFlow=null,this.remainderData=null},H.demux=function Z(Q,Y,J,X){if(J===void 0)J=!1;if(X===void 0)X=!1;if(!J)this.sampleAes=null;var z,N=this._videoTrack,W=this._audioTrack,G=this._id3Track,K=this._txtTrack,j=N.pid,V=N.pesData,U=W.pid,A=G.pid,E=W.pesData,B=G.pesData,F=null,R=this.pmtParsed,O=this._pmtId,M=Q.length;if(this.remainderData)Q=T0(this.remainderData,Q),M=Q.length,this.remainderData=null;if(M<V0&&!X)return this.remainderData=Q,{audioTrack:W,videoTrack:N,id3Track:G,textTrack:K};var L=Math.max(0,q.syncOffset(Q));if(M-=(M-L)%V0,M<Q.byteLength&&!X)this.remainderData=new Uint8Array(Q.buffer,M,Q.buffer.byteLength-M);var I=0;for(var w=L;w<M;w+=V0)if(Q[w]===71){var S=!!(Q[w+1]&64),P=K7(Q,w),b=(Q[w+3]&48)>>4,C=void 0;if(b>1){if(C=w+5+Q[w+4],C===w+V0)continue}else C=w+4;switch(P){case j:if(S){if(V&&(z=a0(V,this.logger))){if(this.videoParser===null)switch(N.segmentCodec){case"avc":this.videoParser=new eQ;break}if(this.videoParser!==null)this.videoParser.parsePES(N,K,z,!1)}V={data:[],size:0}}if(V)V.data.push(Q.subarray(C,w+V0)),V.size+=w+V0-C;break;case U:if(S){if(E&&(z=a0(E,this.logger)))switch(W.segmentCodec){case"aac":this.parseAACPES(W,z);break;case"mp3":this.parseMPEGPES(W,z);break}E={data:[],size:0}}if(E)E.data.push(Q.subarray(C,w+V0)),E.size+=w+V0-C;break;case A:if(S){if(B&&(z=a0(B,this.logger)))this.parseID3PES(G,z);B={data:[],size:0}}if(B)B.data.push(Q.subarray(C,w+V0)),B.size+=w+V0-C;break;case 0:if(S)C+=Q[C]+1;O=this._pmtId=sZ(Q,C);break;case O:{if(S)C+=Q[C]+1;var x=iZ(Q,C,this.typeSupported,J,this.observer,this.logger);if(j=x.videoPid,j>0)N.pid=j,N.segmentCodec=x.segmentVideoCodec;if(U=x.audioPid,U>0)W.pid=U,W.segmentCodec=x.segmentAudioCodec;if(A=x.id3Pid,A>0)G.pid=A;if(F!==null&&!R)this.logger.warn("MPEG-TS PMT found at "+w+" after unknown PID '"+F+"'. Backtracking to sync byte @"+L+" to parse all TS packets."),F=null,w=L-188;R=this.pmtParsed=!0;break}case 17:case 8191:break;default:F=P;break}}else I++;if(I>0)SY(this.observer,new Error("Found "+I+" TS packet/s that do not start with 0x47"),void 0,this.logger);N.pesData=V,W.pesData=E,G.pesData=B;var _={audioTrack:W,videoTrack:N,id3Track:G,textTrack:K};if(X)this.extractRemainingSamples(_);return _},H.flush=function Z(){var Q=this.remainderData;this.remainderData=null;var Y;if(Q)Y=this.demux(Q,-1,!1,!0);else Y={videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack};if(this.extractRemainingSamples(Y),this.sampleAes)return this.decrypt(Y,this.sampleAes);return Y},H.extractRemainingSamples=function Z(Q){var{audioTrack:Y,videoTrack:J,id3Track:X,textTrack:z}=Q,N=J.pesData,W=Y.pesData,G=X.pesData,K;if(N&&(K=a0(N,this.logger))){if(this.videoParser===null)switch(J.segmentCodec){case"avc":this.videoParser=new eQ;break}if(this.videoParser!==null)this.videoParser.parsePES(J,z,K,!0),J.pesData=null}else J.pesData=N;if(W&&(K=a0(W,this.logger))){switch(Y.segmentCodec){case"aac":this.parseAACPES(Y,K);break;case"mp3":this.parseMPEGPES(Y,K);break}Y.pesData=null}else{if(W!=null&&W.size)this.logger.log("last AAC PES packet truncated,might overlap between fragments");Y.pesData=W}if(G&&(K=a0(G,this.logger)))this.parseID3PES(X,K),X.pesData=null;else X.pesData=G},H.demuxSampleAes=function Z(Q,Y,J){var X=this.demux(Q,J,!0,!this.config.progressive),z=this.sampleAes=new lZ(this.observer,this.config,Y);return this.decrypt(X,z)},H.decrypt=function Z(Q,Y){return new Promise(function(J){var{audioTrack:X,videoTrack:z}=Q;if(X.samples&&X.segmentCodec==="aac")Y.decryptAacSamples(X.samples,0,function(){if(z.samples)Y.decryptAvcSamples(z.samples,0,0,function(){J(Q)});else J(Q)});else if(z.samples)Y.decryptAvcSamples(z.samples,0,0,function(){J(Q)})})},H.destroy=function Z(){if(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},H.parseAACPES=function Z(Q,Y){var J=0,X=this.aacOverFlow,z=Y.data;if(X){this.aacOverFlow=null;var N=X.missing,W=X.sample.unit.byteLength;if(N===-1)z=T0(X.sample.unit,z);else{var G=W-N;X.sample.unit.set(z.subarray(0,N),G),Q.samples.push(X.sample),J=X.missing}}var K,j;for(K=J,j=z.length;K<j-1;K++)if(CY(z,K))break;if(K!==J){var V,U=K<j-1;if(U)V="AAC PES did not start with ADTS header,offset:"+K;else V="No ADTS header found in AAC PES";if(SY(this.observer,new Error(V),U,this.logger),!U)return}pQ(Q,this.observer,z,K,this.audioCodec);var A;if(Y.pts!==void 0)A=Y.pts;else if(X){var E=uQ(Q.samplerate);A=X.sample.pts+E}else{this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}var B=0,F;while(K<j)if(F=cQ(Q,z,K,A,B),K+=F.length,!F.missing){B++;for(;K<j-1;K++)if(CY(z,K))break}else{this.aacOverFlow=F;break}},H.parseMPEGPES=function Z(Q,Y){var J=Y.data,X=J.length,z=0,N=0,W=Y.pts;if(W===void 0){this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}while(N<X)if(iQ(J,N)){var G=oQ(Q,J,N,W,z);if(G)N+=G.length,z++;else break}else N++},H.parseAC3PES=function Z(Q,Y){},H.parseID3PES=function Z(Q,Y){if(Y.pts===void 0){this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}var J=K0({},Y,{type:this._videoTrack?D0.emsg:D0.audioId3,duration:Number.POSITIVE_INFINITY});Q.samples.push(J)},q}();function K7(q,H){return((q[H+1]&31)<<8)+q[H+2]}function sZ(q,H){return(q[H+10]&31)<<8|q[H+11]}function iZ(q,H,Z,Q,Y,J){var X={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},z=(q[H+1]&15)<<8|q[H+2],N=H+3+z-4,W=(q[H+10]&15)<<8|q[H+11];H+=12+W;while(H<N){var G=K7(q,H),K=(q[H+3]&15)<<8|q[H+4];switch(q[H]){case 207:if(!Q){j7("ADTS AAC",J);break}case 15:if(X.audioPid===-1)X.audioPid=G;break;case 21:if(X.id3Pid===-1)X.id3Pid=G;break;case 219:if(!Q){j7("H.264",J);break}case 27:if(X.videoPid===-1)X.videoPid=G;break;case 3:case 4:if(!Z.mpeg&&!Z.mp3)J.log("MPEG audio found, not supported in this browser");else if(X.audioPid===-1)X.audioPid=G,X.segmentAudioCodec="mp3";break;case 193:if(!Q){j7("AC-3",J);break}case 129:J.warn("AC-3 in M2TS support not included in build");break;case 6:if(X.audioPid===-1&&K>0){var j=H+5,V=K;while(V>2){var U=q[j];switch(U){case 106:J.warn("AC-3 in M2TS support not included in build");break}var A=q[j+1]+2;j+=A,V-=A}}break;case 194:case 135:return SY(Y,new Error("Unsupported EC-3 in M2TS found"),void 0,J),X;case 36:return SY(Y,new Error("Unsupported HEVC in M2TS found"),void 0,J),X}H+=K+5}return X}function SY(q,H,Z,Q){Q.warn("parsing error: "+H.message),q.emit($.ERROR,$.ERROR,{type:f.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,levelRetry:Z,error:H,reason:H.message})}function j7(q,H){H.log(q+" with AES-128-CBC encryption found in unencrypted stream")}function a0(q,H){var Z=0,Q,Y,J,X,z,N=q.data;if(!q||q.size===0)return null;while(N[0].length<19&&N.length>1)N[0]=T0(N[0],N[1]),N.splice(1,1);Q=N[0];var W=(Q[0]<<16)+(Q[1]<<8)+Q[2];if(W===1){if(Y=(Q[4]<<8)+Q[5],Y&&Y>q.size-6)return null;var G=Q[7];if(G&192)if(X=(Q[9]&14)*536870912+(Q[10]&255)*4194304+(Q[11]&254)*16384+(Q[12]&255)*128+(Q[13]&254)/2,G&64){if(z=(Q[14]&14)*536870912+(Q[15]&255)*4194304+(Q[16]&254)*16384+(Q[17]&255)*128+(Q[18]&254)/2,X-z>5400000)H.warn(Math.round((X-z)/90000)+"s delta between PTS and DTS, align them"),X=z}else z=X;J=Q[8];var K=J+9;if(q.size<=K)return null;q.size-=K;var j=new Uint8Array(q.size);for(var V=0,U=N.length;V<U;V++){Q=N[V];var A=Q.byteLength;if(K)if(K>A){K-=A;continue}else Q=Q.subarray(K),A-=K,K=0;j.set(Q,Z),Z+=A}if(Y)Y-=J+3;return{data:j,pts:X,dts:z,len:Y}}return null}var rZ=function(){function q(){}return q.getSilentFrame=function H(Z,Q){switch(Z){case"mp4a.40.2":if(Q===1)return new Uint8Array([0,200,0,128,35,128]);else if(Q===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);else if(Q===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);else if(Q===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);else if(Q===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]);else if(Q===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(Q===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]);else if(Q===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]);else if(Q===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}return},q}(),n0=Math.pow(2,32)-1,B0=function(){function q(){}return q.init=function H(){q.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 Z;for(Z in q.types)if(q.types.hasOwnProperty(Z))q.types[Z]=[Z.charCodeAt(0),Z.charCodeAt(1),Z.charCodeAt(2),Z.charCodeAt(3)];var Q=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]),Y=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]);q.HDLR_TYPES={video:Q,audio:Y};var J=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),X=new Uint8Array([0,0,0,0,0,0,0,0]);q.STTS=q.STSC=q.STCO=X,q.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),q.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),q.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),q.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var z=new Uint8Array([105,115,111,109]),N=new Uint8Array([97,118,99,49]),W=new Uint8Array([0,0,0,1]);q.FTYP=q.box(q.types.ftyp,z,W,z,N),q.DINF=q.box(q.types.dinf,q.box(q.types.dref,J))},q.box=function H(Z){var Q=8;for(var Y=arguments.length,J=new Array(Y>1?Y-1:0),X=1;X<Y;X++)J[X-1]=arguments[X];var z=J.length,N=z;while(z--)Q+=J[z].byteLength;var W=new Uint8Array(Q);W[0]=Q>>24&255,W[1]=Q>>16&255,W[2]=Q>>8&255,W[3]=Q&255,W.set(Z,4);for(z=0,Q=8;z<N;z++)W.set(J[z],Q),Q+=J[z].byteLength;return W},q.hdlr=function H(Z){return q.box(q.types.hdlr,q.HDLR_TYPES[Z])},q.mdat=function H(Z){return q.box(q.types.mdat,Z)},q.mdhd=function H(Z,Q){Q*=Z;var Y=Math.floor(Q/(n0+1)),J=Math.floor(Q%(n0+1));return q.box(q.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,Z>>24&255,Z>>16&255,Z>>8&255,Z&255,Y>>24,Y>>16&255,Y>>8&255,Y&255,J>>24,J>>16&255,J>>8&255,J&255,85,196,0,0]))},q.mdia=function H(Z){return q.box(q.types.mdia,q.mdhd(Z.timescale||0,Z.duration||0),q.hdlr(Z.type),q.minf(Z))},q.mfhd=function H(Z){return q.box(q.types.mfhd,new Uint8Array([0,0,0,0,Z>>24,Z>>16&255,Z>>8&255,Z&255]))},q.minf=function H(Z){if(Z.type==="audio")return q.box(q.types.minf,q.box(q.types.smhd,q.SMHD),q.DINF,q.stbl(Z));else return q.box(q.types.minf,q.box(q.types.vmhd,q.VMHD),q.DINF,q.stbl(Z))},q.moof=function H(Z,Q,Y){return q.box(q.types.moof,q.mfhd(Z),q.traf(Y,Q))},q.moov=function H(Z){var Q=Z.length,Y=[];while(Q--)Y[Q]=q.trak(Z[Q]);return q.box.apply(null,[q.types.moov,q.mvhd(Z[0].timescale||0,Z[0].duration||0)].concat(Y).concat(q.mvex(Z)))},q.mvex=function H(Z){var Q=Z.length,Y=[];while(Q--)Y[Q]=q.trex(Z[Q]);return q.box.apply(null,[q.types.mvex].concat(Y))},q.mvhd=function H(Z,Q){Q*=Z;var Y=Math.floor(Q/(n0+1)),J=Math.floor(Q%(n0+1)),X=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,Z>>24&255,Z>>16&255,Z>>8&255,Z&255,Y>>24,Y>>16&255,Y>>8&255,Y&255,J>>24,J>>16&255,J>>8&255,J&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 q.box(q.types.mvhd,X)},q.sdtp=function H(Z){var Q=Z.samples||[],Y=new Uint8Array(4+Q.length),J,X;for(J=0;J<Q.length;J++)X=Q[J].flags,Y[J+4]=X.dependsOn<<4|X.isDependedOn<<2|X.hasRedundancy;return q.box(q.types.sdtp,Y)},q.stbl=function H(Z){return q.box(q.types.stbl,q.stsd(Z),q.box(q.types.stts,q.STTS),q.box(q.types.stsc,q.STSC),q.box(q.types.stsz,q.STSZ),q.box(q.types.stco,q.STCO))},q.avc1=function H(Z){var Q=[],Y=[],J,X,z;for(J=0;J<Z.sps.length;J++)X=Z.sps[J],z=X.byteLength,Q.push(z>>>8&255),Q.push(z&255),Q=Q.concat(Array.prototype.slice.call(X));for(J=0;J<Z.pps.length;J++)X=Z.pps[J],z=X.byteLength,Y.push(z>>>8&255),Y.push(z&255),Y=Y.concat(Array.prototype.slice.call(X));var N=q.box(q.types.avcC,new Uint8Array([1,Q[3],Q[4],Q[5],255,224|Z.sps.length].concat(Q).concat([Z.pps.length]).concat(Y))),W=Z.width,G=Z.height,K=Z.pixelRatio[0],j=Z.pixelRatio[1];return q.box(q.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,W>>8&255,W&255,G>>8&255,G&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]),N,q.box(q.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),q.box(q.types.pasp,new Uint8Array([K>>24,K>>16&255,K>>8&255,K&255,j>>24,j>>16&255,j>>8&255,j&255])))},q.esds=function H(Z){var Q=Z.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(Q,[6,1,2]))},q.audioStsd=function H(Z){var Q=Z.samplerate||0;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,Z.channelCount||0,0,16,0,0,0,0,Q>>8&255,Q&255,0,0])},q.mp4a=function H(Z){return q.box(q.types.mp4a,q.audioStsd(Z),q.box(q.types.esds,q.esds(Z)))},q.mp3=function H(Z){return q.box(q.types[".mp3"],q.audioStsd(Z))},q.ac3=function H(Z){return q.box(q.types["ac-3"],q.audioStsd(Z),q.box(q.types.dac3,Z.config))},q.stsd=function H(Z){var Q=Z.segmentCodec;if(Z.type==="audio"){if(Q==="aac")return q.box(q.types.stsd,q.STSD,q.mp4a(Z));if(Q==="mp3"&&Z.codec==="mp3")return q.box(q.types.stsd,q.STSD,q.mp3(Z))}else if(Z.pps&&Z.sps){if(Q==="avc")return q.box(q.types.stsd,q.STSD,q.avc1(Z))}else throw new Error("video track missing pps or sps");throw new Error("unsupported "+Z.type+" segment codec ("+Q+"/"+Z.codec+")")},q.tkhd=function H(Z){var Q=Z.id,Y=(Z.duration||0)*(Z.timescale||0),J=Z.width||0,X=Z.height||0,z=Math.floor(Y/(n0+1)),N=Math.floor(Y%(n0+1));return q.box(q.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,Q>>24&255,Q>>16&255,Q>>8&255,Q&255,0,0,0,0,z>>24,z>>16&255,z>>8&255,z&255,N>>24,N>>16&255,N>>8&255,N&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,J>>8&255,J&255,0,0,X>>8&255,X&255,0,0]))},q.traf=function H(Z,Q){var Y=q.sdtp(Z),J=Z.id,X=Math.floor(Q/(n0+1)),z=Math.floor(Q%(n0+1));return q.box(q.types.traf,q.box(q.types.tfhd,new Uint8Array([0,0,0,0,J>>24,J>>16&255,J>>8&255,J&255])),q.box(q.types.tfdt,new Uint8Array([1,0,0,0,X>>24,X>>16&255,X>>8&255,X&255,z>>24,z>>16&255,z>>8&255,z&255])),q.trun(Z,Y.length+16+20+8+16+8+8),Y)},q.trak=function H(Z){return Z.duration=Z.duration||4294967295,q.box(q.types.trak,q.tkhd(Z),q.mdia(Z))},q.trex=function H(Z){var Q=Z.id;return q.box(q.types.trex,new Uint8Array([0,0,0,0,Q>>24,Q>>16&255,Q>>8&255,Q&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},q.trun=function H(Z,Q){var Y=Z.samples||[],J=Y.length,X=12+16*J,z=new Uint8Array(X),N,W,G,K,j,V;Q+=8+X,z.set([Z.type==="video"?1:0,0,15,1,J>>>24&255,J>>>16&255,J>>>8&255,J&255,Q>>>24&255,Q>>>16&255,Q>>>8&255,Q&255],0);for(N=0;N<J;N++)W=Y[N],G=W.duration,K=W.size,j=W.flags,V=W.cts,z.set([G>>>24&255,G>>>16&255,G>>>8&255,G&255,K>>>24&255,K>>>16&255,K>>>8&255,K&255,j.isLeading<<2|j.dependsOn,j.isDependedOn<<6|j.hasRedundancy<<4|j.paddingValue<<1|j.isNonSync,j.degradPrio&61440,j.degradPrio&15,V>>>24&255,V>>>16&255,V>>>8&255,V&255],12+16*N);return q.box(q.types.trun,z)},q.initSegment=function H(Z){if(!q.types)q.init();var Q=q.moov(Z),Y=T0(q.FTYP,Q);return Y},q.hvc1=function H(Z){return new Uint8Array},q}();B0.types=void 0,B0.HDLR_TYPES=void 0,B0.STTS=void 0,B0.STSC=void 0,B0.STCO=void 0,B0.STSZ=void 0,B0.VMHD=void 0,B0.SMHD=void 0,B0.STSD=void 0,B0.FTYP=void 0,B0.DINF=void 0;var aZ=90000;function tZ(q,H,Z,Q){var Y=q*H*Z;return Math.round(Y)}function NY(q,H){return tZ(q,1000,1/aZ)}var eZ=1e4,Y9=1024,Q9=1152,J9=1536,t0=null,U7=null;function YJ(q,H,Z,Q){return{duration:H,size:Z,cts:Q,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:q?2:1,isNonSync:q?0:1}}}var V7=function(){function q(Z,Q,Y,J){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=Z,this.config=Q,this.typeSupported=Y,this.logger=J,this.ISGenerated=!1,t0===null){var X=navigator.userAgent||"",z=X.match(/Chrome\/(\d+)/i);t0=z?parseInt(z[1]):0}if(U7===null){var N=navigator.userAgent.match(/Safari\/(\d+)/i);U7=N?parseInt(N[1]):0}}var H=q.prototype;return H.destroy=function Z(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null},H.resetTimeStamp=function Z(Q){this.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=Q},H.resetNextTimestamp=function Z(){this.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},H.resetInitSegment=function Z(){this.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0},H.getVideoStartPts=function Z(Q){var Y=!1,J=Q[0].pts,X=Q.reduce(function(z,N){var W=N.pts,G=W-z;if(G<-4294967296)Y=!0,W=k0(W,J),G=W-z;if(G>0)return z;return W},J);if(Y)this.logger.debug("PTS rollover detected");return X},H.remux=function Z(Q,Y,J,X,z,N,W,G){var K,j,V,U,A,E,B=z,F=z,R=Q.pid>-1,O=Y.pid>-1,M=Y.samples.length,L=Q.samples.length>0,I=W&&M>0||M>1,w=(!R||L)&&(!O||I)||this.ISGenerated||W;if(w){if(this.ISGenerated){var S,P,b,C,x=this.videoTrackConfig;if(x&&(Y.width!==x.width||Y.height!==x.height||((S=Y.pixelRatio)==null?void 0:S[0])!==((P=x.pixelRatio)==null?void 0:P[0])||((b=Y.pixelRatio)==null?void 0:b[1])!==((C=x.pixelRatio)==null?void 0:C[1]))||!x&&I||this.nextAudioPts===null&&L)this.resetInitSegment()}if(!this.ISGenerated)V=this.generateIS(Q,Y,z,N);var _=this.isVideoContiguous,y=-1,T;if(I){if(y=Z9(Y.samples),!_&&this.config.forceKeyFrameOnDiscontinuity){if(E=!0,y>0){this.logger.warn("[mp4-remuxer]: Dropped "+y+" out of "+M+" video samples due to a missing keyframe");var h=this.getVideoStartPts(Y.samples);Y.samples=Y.samples.slice(y),Y.dropped+=y,F+=(Y.samples[0].pts-h)/Y.inputTimeScale,T=F}else if(y===-1)this.logger.warn("[mp4-remuxer]: No keyframe found out of "+M+" video samples"),E=!1}}if(this.ISGenerated){if(L&&I){var g=this.getVideoStartPts(Y.samples),m=k0(Q.samples[0].pts,g)-g,p=m/Y.inputTimeScale;B+=Math.max(0,p),F+=Math.max(0,-p)}if(L){if(!Q.samplerate)this.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),V=this.generateIS(Q,Y,z,N);if(j=this.remuxAudio(Q,B,this.isAudioContiguous,N,O||I||G===d.AUDIO?F:void 0),I){var r=j?j.endPTS-j.startPTS:0;if(!Y.inputTimeScale)this.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),V=this.generateIS(Q,Y,z,N);K=this.remuxVideo(Y,F,_,r)}}else if(I)K=this.remuxVideo(Y,F,_,0);if(K)K.firstKeyFrame=y,K.independent=y!==-1,K.firstKeyFramePTS=T}}if(this.ISGenerated&&this._initPTS&&this._initDTS){if(J.samples.length)A=QJ(J,z,this._initPTS,this._initDTS);if(X.samples.length)U=JJ(X,z,this._initPTS)}return{audio:j,video:K,initSegment:V,independent:E,text:U,id3:A}},H.generateIS=function Z(Q,Y,J,X){var z=Q.samples,N=Y.samples,W=this.typeSupported,G={},K=this._initPTS,j=!K||X,V="audio/mp4",U,A,E;if(j)U=A=1/0;if(Q.config&&z.length){switch(Q.timescale=Q.samplerate,Q.segmentCodec){case"mp3":if(W.mpeg)V="audio/mpeg",Q.codec="";else if(W.mp3)Q.codec="mp3";break;case"ac3":Q.codec="ac-3";break}if(G.audio={id:"audio",container:V,codec:Q.codec,initSegment:Q.segmentCodec==="mp3"&&W.mpeg?new Uint8Array(0):B0.initSegment([Q]),metadata:{channelCount:Q.channelCount}},j)if(E=Q.inputTimeScale,!K||E!==K.timescale)U=A=z[0].pts-Math.round(E*J);else j=!1}if(Y.sps&&Y.pps&&N.length){if(Y.timescale=Y.inputTimeScale,G.video={id:"main",container:"video/mp4",codec:Y.codec,initSegment:B0.initSegment([Y]),metadata:{width:Y.width,height:Y.height}},j)if(E=Y.inputTimeScale,!K||E!==K.timescale){var B=this.getVideoStartPts(N),F=Math.round(E*J);A=Math.min(A,k0(N[0].dts,B)-F),U=Math.min(U,B-F)}else j=!1;this.videoTrackConfig={width:Y.width,height:Y.height,pixelRatio:Y.pixelRatio}}if(Object.keys(G).length){if(this.ISGenerated=!0,j)this._initPTS={baseTime:U,timescale:E},this._initDTS={baseTime:A,timescale:E};else U=E=void 0;return{tracks:G,initPTS:U,timescale:E}}},H.remuxVideo=function Z(Q,Y,J,X){var{inputTimeScale:z,samples:N}=Q,W=[],G=N.length,K=this._initPTS,j=this.nextAvcDts,V=8,U=this.videoSampleDuration,A,E,B=Number.POSITIVE_INFINITY,F=Number.NEGATIVE_INFINITY,R=!1;if(!J||j===null){var O=Y*z,M=N[0].pts-k0(N[0].dts,N[0].pts);if(t0&&j!==null&&Math.abs(O-M-j)<15000)J=!0;else j=O-M}var L=K.baseTime*z/K.timescale;for(var I=0;I<G;I++){var w=N[I];if(w.pts=k0(w.pts-L,j),w.dts=k0(w.dts-L,j),w.dts<N[I>0?I-1:I].dts)R=!0}if(R)N.sort(function(vY,yJ){var $q=vY.dts-yJ.dts,Fq=vY.pts-yJ.pts;return $q||Fq});A=N[0].dts,E=N[N.length-1].dts;var S=E-A,P=S?Math.round(S/(G-1)):U||Q.inputTimeScale/30;if(J){var b=A-j,C=b>P,x=b<-1;if(C||x){if(C)this.logger.warn((Q.segmentCodec||"").toUpperCase()+": "+NY(b)+" ms ("+b+"dts) hole between fragments detected at "+Y.toFixed(3));else this.logger.warn((Q.segmentCodec||"").toUpperCase()+": "+NY(-b)+" ms ("+b+"dts) overlapping between fragments detected at "+Y.toFixed(3));if(!x||j>=N[0].pts||t0){A=j;var _=N[0].pts-b;if(C)N[0].dts=A,N[0].pts=_;else{var y=!0;for(var T=0;T<N.length;T++){if(N[T].dts>_&&y)break;var h=N[T].pts;if(N[T].dts-=b,N[T].pts-=b,T<N.length-1){var g=N[T+1].pts,m=N[T].pts,p=g<=m,r=g<=h;y=p==r}}}this.logger.log("Video: Initial PTS/DTS adjusted: "+NY(_)+"/"+NY(A)+", delta: "+NY(b)+" ms")}}}A=Math.max(0,A);var n=0,a=0,l=A;for(var z0=0;z0<G;z0++){var t=N[z0],X0=t.units,L0=X0.length,A0=0;for(var e=0;e<L0;e++)A0+=X0[e].data.length;if(a+=A0,n+=L0,t.length=A0,t.dts<l)t.dts=l,l+=P/4|0||1;else l=t.dts;B=Math.min(t.pts,B),F=Math.max(t.pts,F)}E=N[G-1].dts;var b0=a+4*n+8,W0;try{W0=new Uint8Array(b0)}catch(vY){this.observer.emit($.ERROR,$.ERROR,{type:f.MUX_ERROR,details:D.REMUX_ALLOC_ERROR,fatal:!1,error:vY,bytes:b0,reason:"fail allocating video mdat "+b0});return}var J0=new DataView(W0.buffer);J0.setUint32(0,b0),W0.set(B0.types.mdat,4);var C0=!1,O0=Number.POSITIVE_INFINITY,S0=Number.POSITIVE_INFINITY,Y0=Number.NEGATIVE_INFINITY,R0=Number.NEGATIVE_INFINITY;for(var G0=0;G0<G;G0++){var P0=N[G0],jY=P0.units,CJ=0;for(var I7=0,Wq=jY.length;I7<Wq;I7++){var PJ=jY[I7],Gq=PJ.data,w7=PJ.data.byteLength;J0.setUint32(V,w7),V+=4,W0.set(Gq,V),V+=w7,CJ+=4+w7}var _Y=void 0;if(G0<G-1)U=N[G0+1].dts-P0.dts,_Y=N[G0+1].pts-P0.pts;else{var DJ=this.config,hY=G0>0?P0.dts-N[G0-1].dts:P;if(_Y=G0>0?P0.pts-N[G0-1].pts:P,DJ.stretchShortVideoTrack&&this.nextAudioPts!==null){var Kq=Math.floor(DJ.maxBufferHole*z),L7=(X?B+X*z:this.nextAudioPts)-P0.pts;if(L7>Kq){if(U=L7-hY,U<0)U=hY;else C0=!0;this.logger.log("[mp4-remuxer]: It is approximately "+L7/90+" ms to the next segment; using duration "+U/90+" ms for the last video frame.")}else U=hY}else U=hY}var jq=Math.round(P0.pts-P0.dts);O0=Math.min(O0,U),Y0=Math.max(Y0,U),S0=Math.min(S0,_Y),R0=Math.max(R0,_Y),W.push(YJ(P0.key,U,CJ,jq))}if(W.length){if(t0){if(t0<70){var SJ=W[0].flags;SJ.dependsOn=2,SJ.isNonSync=0}}else if(U7){if(R0-S0<Y0-O0&&P/Y0<0.025&&W[0].cts===0){this.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");var b7=A;for(var _0=0,xJ=W.length;_0<xJ;_0++){var TJ=b7+W[_0].duration,Uq=b7+W[_0].cts;if(_0<xJ-1){var Vq=TJ+W[_0+1].cts;W[_0].duration=Vq-Uq}else W[_0].duration=_0?W[_0-1].duration:P;W[_0].cts=0,b7=TJ}}}}U=C0||!U?P:U,this.nextAvcDts=j=E+U,this.videoSampleDuration=U,this.isVideoContiguous=!0;var Aq=B0.moof(Q.sequenceNumber++,A,K0(Q,{samples:W})),Eq="video",Bq={data1:Aq,data2:W0,startPTS:B/z,endPTS:(F+U)/z,startDTS:A/z,endDTS:j/z,type:Eq,hasAudio:!1,hasVideo:!0,nb:W.length,dropped:Q.dropped};return Q.samples=[],Q.dropped=0,Bq},H.getSamplesPerFrame=function Z(Q){switch(Q.segmentCodec){case"mp3":return Q9;case"ac3":return J9;default:return Y9}},H.remuxAudio=function Z(Q,Y,J,X,z){var N=Q.inputTimeScale,W=Q.samplerate?Q.samplerate:N,G=N/W,K=this.getSamplesPerFrame(Q),j=K*G,V=this._initPTS,U=Q.segmentCodec==="mp3"&&this.typeSupported.mpeg,A=[],E=z!==void 0,B=Q.samples,F=U?0:8,R=this.nextAudioPts||-1,O=Y*N,M=V.baseTime*N/V.timescale;if(this.isAudioContiguous=J=J||B.length&&R>0&&(X&&Math.abs(O-R)<9000||Math.abs(k0(B[0].pts-M,O)-R)<20*j),B.forEach(function(Y0){Y0.pts=k0(Y0.pts-M,O)}),!J||R<0){if(B=B.filter(function(Y0){return Y0.pts>=0}),!B.length)return;if(z===0)R=0;else if(X&&!E)R=Math.max(0,O);else R=B[0].pts}if(Q.segmentCodec==="aac"){var L=this.config.maxAudioFramesDrift;for(var I=0,w=R;I<B.length;I++){var S=B[I],P=S.pts,b=P-w,C=Math.abs(1000*b/N);if(b<=-L*j&&E){if(I===0)this.logger.warn("Audio frame @ "+(P/N).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1000*b/N)+" ms."),this.nextAudioPts=R=w=P}else if(b>=L*j&&C<eZ&&E){var x=Math.round(b/j);if(w=P-x*j,w<0)x--,w+=j;if(I===0)this.nextAudioPts=R=w;this.logger.warn("[mp4-remuxer]: Injecting "+x+" audio frame @ "+(w/N).toFixed(3)+"s due to "+Math.round(1000*b/N)+" ms gap.");for(var _=0;_<x;_++){var y=Math.max(w,0),T=rZ.getSilentFrame(Q.parsedCodec||Q.manifestCodec||Q.codec,Q.channelCount);if(!T)this.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),T=S.unit.subarray();B.splice(I,0,{unit:T,pts:y}),w+=j,I++}}S.pts=w,w+=j}}var h=null,g=null,m,p=0,r=B.length;while(r--)p+=B[r].unit.byteLength;for(var n=0,a=B.length;n<a;n++){var l=B[n],z0=l.unit,t=l.pts;if(g!==null){var X0=A[n-1];X0.duration=Math.round((t-g)/G)}else{if(J&&Q.segmentCodec==="aac")t=R;if(h=t,p>0){p+=F;try{m=new Uint8Array(p)}catch(Y0){this.observer.emit($.ERROR,$.ERROR,{type:f.MUX_ERROR,details:D.REMUX_ALLOC_ERROR,fatal:!1,error:Y0,bytes:p,reason:"fail allocating audio mdat "+p});return}if(!U){var L0=new DataView(m.buffer);L0.setUint32(0,p),m.set(B0.types.mdat,4)}}else return}m.set(z0,F);var A0=z0.byteLength;F+=A0,A.push(YJ(!0,K,A0,0)),g=t}var e=A.length;if(!e)return;var b0=A[A.length-1];this.nextAudioPts=R=g+G*b0.duration;var W0=U?new Uint8Array(0):B0.moof(Q.sequenceNumber++,h/G,K0({},Q,{samples:A}));Q.samples=[];var J0=h/N,C0=R/N,O0="audio",S0={data1:W0,data2:m,startPTS:J0,endPTS:C0,startDTS:J0,endDTS:C0,type:O0,hasAudio:!0,hasVideo:!1,nb:e};return this.isAudioContiguous=!0,S0},q}();function k0(q,H){var Z;if(H===null)return q;if(H<q)Z=-8589934592;else Z=8589934592;while(Math.abs(q-H)>4294967296)q+=Z;return q}function Z9(q){for(var H=0;H<q.length;H++)if(q[H].key)return H;return-1}function QJ(q,H,Z,Q){var Y=q.samples.length;if(!Y)return;var J=q.inputTimeScale;for(var X=0;X<Y;X++){var z=q.samples[X];z.pts=k0(z.pts-Z.baseTime*J/Z.timescale,H*J)/J,z.dts=k0(z.dts-Q.baseTime*J/Q.timescale,H*J)/J}var N=q.samples;return q.samples=[],{samples:N}}function JJ(q,H,Z){var Q=q.samples.length;if(!Q)return;var Y=q.inputTimeScale;for(var J=0;J<Q;J++){var X=q.samples[J];X.pts=k0(X.pts-Z.baseTime*Y/Z.timescale,H*Y)/Y}q.samples.sort(function(N,W){return N.pts-W.pts});var z=q.samples;return q.samples=[],{samples:z}}var q9=function(){function q(Z,Q,Y,J){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=J}var H=q.prototype;return H.destroy=function Z(){},H.resetTimeStamp=function Z(Q){this.initPTS=Q,this.lastEndTime=null},H.resetNextTimestamp=function Z(){this.lastEndTime=null},H.resetInitSegment=function Z(Q,Y,J,X){this.audioCodec=Y,this.videoCodec=J,this.generateInitSegment(H8(Q,X)),this.emitInitSegment=!0},H.generateInitSegment=function Z(Q){var Y=this.audioCodec,J=this.videoCodec;if(!(Q!=null&&Q.byteLength)){this.initTracks=void 0,this.initData=void 0;return}var X=this.initData=l7(Q);if(X.audio)Y=ZJ(X.audio,Q0.AUDIO);if(X.video)J=ZJ(X.video,Q0.VIDEO);var z={};if(X.audio&&X.video)z.audiovideo={container:"video/mp4",codec:Y+","+J,supplemental:X.video.supplemental,initSegment:Q,id:"main"};else if(X.audio)z.audio={container:"audio/mp4",codec:Y,initSegment:Q,id:"audio"};else if(X.video)z.video={container:"video/mp4",codec:J,supplemental:X.video.supplemental,initSegment:Q,id:"main"};else this.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes.");this.initTracks=z},H.remux=function Z(Q,Y,J,X,z,N){var W,G,K=this.initPTS,j=this.lastEndTime,V={audio:void 0,video:void 0,text:X,id3:J,initSegment:void 0};if(!v(j))j=this.lastEndTime=z||0;var U=Y.samples;if(!(U!=null&&U.length))return V;var A={initPTS:void 0,timescale:1},E=this.initData;if(!((W=E)!=null&&W.length))this.generateInitSegment(U),E=this.initData;if(!((G=E)!=null&&G.length))return this.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),V;if(this.emitInitSegment)A.tracks=this.initTracks,this.emitInitSegment=!1;var B=W8(U,E),F=N8(E,U),R=F===null?z:F;if((N||!K)&&(X9(K,R,z,B)||A.timescale!==K.timescale)){if(A.initPTS=R-z,K&&K.timescale===1)this.logger.warn("Adjusting initPTS @"+z+" from "+K.baseTime/K.timescale+" to "+A.initPTS);this.initPTS=K={baseTime:A.initPTS,timescale:1}}var O=Q?R-K.baseTime/K.timescale:j,M=O+B;if(K8(E,U,K.baseTime/K.timescale),B>0)this.lastEndTime=M;else this.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp();var L=!!E.audio,I=!!E.video,w="";if(L)w+="audio";if(I)w+="video";var S={data1:U,startPTS:O,startDTS:O,endPTS:M,endDTS:M,type:w,hasAudio:L,hasVideo:I,nb:1,dropped:0};if(V.audio=S.type==="audio"?S:void 0,V.video=S.type!=="audio"?S:void 0,V.initSegment=A,V.id3=QJ(J,z,K,K),X.samples.length)V.text=JJ(X,z,K);return V},q}();function X9(q,H,Z,Q){if(q===null)return!0;var Y=Math.max(Q,1),J=H-q.baseTime/q.timescale;return Math.abs(J-Z)>Y}function ZJ(q,H){var Z=q==null?void 0:q.codec;if(Z&&Z.length>4)return Z;if(H===Q0.AUDIO){if(Z==="ec-3"||Z==="ac-3"||Z==="alac")return Z;if(Z==="fLaC"||Z==="Opus"){var Q=!1;return $Y(Z,Q)}return s.warn('Unhandled audio codec "'+Z+'" in mp4 MAP'),Z||"mp4a"}return s.warn('Unhandled video codec "'+Z+'" in mp4 MAP'),Z||"avc1"}var u0;try{u0=self.performance.now.bind(self.performance)}catch(q){u0=Date.now}var A7=[{demux:dZ,remux:q9},{demux:oZ,remux:V7},{demux:kZ,remux:V7},{demux:hZ,remux:V7}],E7=function(){function q(Z,Q,Y,J,X,z){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=Z,this.typeSupported=Q,this.config=Y,this.id=X,this.logger=z}var H=q.prototype;return H.configure=function Z(Q){if(this.transmuxConfig=Q,this.decrypter)this.decrypter.reset()},H.push=function Z(Q,Y,J,X){var z=this,N=J.transmuxing;N.executeStart=u0();var W=new Uint8Array(Q),G=this.currentTransmuxState,K=this.transmuxConfig;if(X)this.currentTransmuxState=X;var j=X||G,V=j.contiguous,U=j.discontinuity,A=j.trackSwitch,E=j.accurateTimeOffset,B=j.timeOffset,F=j.initSegmentChange,R=K.audioCodec,O=K.videoCodec,M=K.defaultInitPts,L=K.duration,I=K.initSegmentData,w=H9(W,Y);if(w&&HY(w.method)){var S=this.getDecrypter(),P=BQ(w.method);if(S.isSync()){var b=S.softwareDecrypt(W,w.key.buffer,w.iv.buffer,P),C=J.part>-1;if(C){var x=S.flush();b=x?x.buffer:x}if(!b)return N.executeEnd=u0(),B7(J);W=new Uint8Array(b)}else return this.asyncResult=!0,this.decryptionPromise=S.webCryptoDecrypt(W,w.key.buffer,w.iv.buffer,P).then(function(g){var m=z.push(g,null,J);return z.decryptionPromise=null,m}),this.decryptionPromise}var _=this.needsProbing(U,A);if(_){var y=this.configureTransmuxer(W);if(y)return this.logger.warn("[transmuxer] "+y.message),this.observer.emit($.ERROR,$.ERROR,{type:f.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,error:y,reason:y.message}),N.executeEnd=u0(),B7(J)}if(U||A||F||_)this.resetInitSegment(I,R,O,L,Y);if(U||F||_)this.resetInitialTimestamp(M);if(!V)this.resetContiguity();var T=this.transmux(W,w,B,E,J);this.asyncResult=o0(T);var h=this.currentTransmuxState;return h.contiguous=!0,h.discontinuity=!1,h.trackSwitch=!1,N.executeEnd=u0(),T},H.flush=function Z(Q){var Y=this,J=Q.transmuxing;J.executeStart=u0();var X=this.decrypter,z=this.currentTransmuxState,N=this.decryptionPromise;if(N)return this.asyncResult=!0,N.then(function(){return Y.flush(Q)});var W=[],G=z.timeOffset;if(X){var K=X.flush();if(K)W.push(this.push(K.buffer,null,Q))}var j=this.demuxer,V=this.remuxer;if(!j||!V){J.executeEnd=u0();var U=[B7(Q)];if(this.asyncResult)return Promise.resolve(U);return U}var A=j.flush(G);if(o0(A))return this.asyncResult=!0,A.then(function(E){return Y.flushRemux(W,E,Q),W});if(this.flushRemux(W,A,Q),this.asyncResult)return Promise.resolve(W);return W},H.flushRemux=function Z(Q,Y,J){var{audioTrack:X,videoTrack:z,id3Track:N,textTrack:W}=Y,G=this.currentTransmuxState,K=G.accurateTimeOffset,j=G.timeOffset;this.logger.log("[transmuxer.ts]: Flushed "+this.id+" sn: "+J.sn+(J.part>-1?" part: "+J.part:"")+" of "+(this.id===d.MAIN?"level":"track")+" "+J.level);var V=this.remuxer.remux(X,z,N,W,j,K,!0,this.id);Q.push({remuxResult:V,chunkMeta:J}),J.transmuxing.executeEnd=u0()},H.resetInitialTimestamp=function Z(Q){var Y=this.demuxer,J=this.remuxer;if(!Y||!J)return;Y.resetTimeStamp(Q),J.resetTimeStamp(Q)},H.resetContiguity=function Z(){var Q=this.demuxer,Y=this.remuxer;if(!Q||!Y)return;Q.resetContiguity(),Y.resetNextTimestamp()},H.resetInitSegment=function Z(Q,Y,J,X,z){var N=this.demuxer,W=this.remuxer;if(!N||!W)return;N.resetInitSegment(Q,Y,J,X),W.resetInitSegment(Q,Y,J,z)},H.destroy=function Z(){if(this.demuxer)this.demuxer.destroy(),this.demuxer=void 0;if(this.remuxer)this.remuxer.destroy(),this.remuxer=void 0},H.transmux=function Z(Q,Y,J,X,z){var N;if(Y&&Y.method==="SAMPLE-AES")N=this.transmuxSampleAes(Q,Y,J,X,z);else N=this.transmuxUnencrypted(Q,J,X,z);return N},H.transmuxUnencrypted=function Z(Q,Y,J,X){var z=this.demuxer.demux(Q,Y,!1,!this.config.progressive),N=z.audioTrack,W=z.videoTrack,G=z.id3Track,K=z.textTrack,j=this.remuxer.remux(N,W,G,K,Y,J,!1,this.id);return{remuxResult:j,chunkMeta:X}},H.transmuxSampleAes=function Z(Q,Y,J,X,z){var N=this;return this.demuxer.demuxSampleAes(Q,Y,J).then(function(W){var G=N.remuxer.remux(W.audioTrack,W.videoTrack,W.id3Track,W.textTrack,J,X,!1,N.id);return{remuxResult:G,chunkMeta:z}})},H.configureTransmuxer=function Z(Q){var Y=this.config,J=this.observer,X=this.typeSupported,z;for(var N=0,W=A7.length;N<W;N++){var G;if((G=A7[N].demux)!=null&&G.probe(Q,this.logger)){z=A7[N];break}}if(!z)return new Error("Failed to find demuxer by probing fragment data");var K=this.demuxer,j=this.remuxer,V=z.remux,U=z.demux;if(!j||!(j instanceof V))this.remuxer=new V(J,Y,X,this.logger);if(!K||!(K instanceof U))this.demuxer=new U(J,Y,X,this.logger),this.probe=U.probe},H.needsProbing=function Z(Q,Y){return!this.demuxer||!this.remuxer||Q||Y},H.getDecrypter=function Z(){var Q=this.decrypter;if(!Q)Q=this.decrypter=new G7(this.config);return Q},q}();function H9(q,H){var Z=null;if(q.byteLength>0&&(H==null?void 0:H.key)!=null&&H.iv!==null&&H.method!=null)Z=H;return Z}var B7=function q(H){return{remuxResult:{},chunkMeta:H}};function o0(q){return"then"in q&&q.then instanceof Function}var z9=function q(H,Z,Q,Y,J){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=H,this.videoCodec=Z,this.initSegmentData=Q,this.duration=Y,this.defaultInitPts=J||null},N9=function q(H,Z,Q,Y,J,X){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=H,this.contiguous=Z,this.accurateTimeOffset=Q,this.trackSwitch=Y,this.timeOffset=J,this.initSegmentChange=X};function W9(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(q){}return!1}var G9=/(\d+)-(\d+)\/(\d+)/,qJ=function(){function q(Z){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=Z.fetchSetup||V9,this.controller=new self.AbortController,this.stats=new nY}var H=q.prototype;return H.destroy=function Z(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null},H.abortInternal=function Z(){if(this.controller&&!this.stats.loading.end)this.stats.aborted=!0,this.controller.abort()},H.abort=function Z(){var Q;if(this.abortInternal(),(Q=this.callbacks)!=null&&Q.onAbort)this.callbacks.onAbort(this.stats,this.context,this.response)},H.load=function Z(Q,Y,J){var X=this,z=this.stats;if(z.loading.start)throw new Error("Loader can only be used once.");z.loading.start=self.performance.now();var N=K9(Q,this.controller.signal),W=Q.responseType==="arraybuffer",G=W?"byteLength":"length",K=Y.loadPolicy,j=K.maxTimeToFirstByteMs,V=K.maxLoadTimeMs;this.context=Q,this.config=Y,this.callbacks=J,this.request=this.fetchSetup(Q,N),self.clearTimeout(this.requestTimeout),Y.timeout=j&&v(j)?j:V,this.requestTimeout=self.setTimeout(function(){if(X.callbacks)X.abortInternal(),X.callbacks.onTimeout(z,Q,X.response)},Y.timeout);var U=o0(this.request)?this.request.then(self.fetch):self.fetch(this.request);U.then(function(A){var E;X.response=X.loader=A;var B=Math.max(self.performance.now(),z.loading.start);if(self.clearTimeout(X.requestTimeout),Y.timeout=V,X.requestTimeout=self.setTimeout(function(){if(X.callbacks)X.abortInternal(),X.callbacks.onTimeout(z,Q,X.response)},V-(B-z.loading.start)),!A.ok){var{status:F,statusText:R}=A;throw new A9(R||"fetch, bad network response",F,A)}z.loading.first=B,z.total=U9(A.headers)||z.total;var O=(E=X.callbacks)==null?void 0:E.onProgress;if(O&&v(Y.highWaterMark))return X.loadProgressively(A,z,Q,Y.highWaterMark,O);if(W)return A.arrayBuffer();if(Q.responseType==="json")return A.json();return A.text()}).then(function(A){var E,B,F=X.response;if(!F)throw new Error("loader destroyed");self.clearTimeout(X.requestTimeout),z.loading.end=Math.max(self.performance.now(),z.loading.first);var R=A[G];if(R)z.loaded=z.total=R;var O={url:F.url,data:A,code:F.status},M=(E=X.callbacks)==null?void 0:E.onProgress;if(M&&!v(Y.highWaterMark))M(z,Q,A,F);(B=X.callbacks)==null||B.onSuccess(O,z,Q,F)}).catch(function(A){var E;if(self.clearTimeout(X.requestTimeout),z.aborted)return;var B=!A?0:A.code||0,F=!A?null:A.message;(E=X.callbacks)==null||E.onError({code:B,text:F},Q,A?A.details:null,z)})},H.getCacheAge=function Z(){var Q=null;if(this.response){var Y=this.response.headers.get("age");Q=Y?parseFloat(Y):null}return Q},H.getResponseHeader=function Z(Q){return this.response?this.response.headers.get(Q):null},H.loadProgressively=function Z(Q,Y,J,X,z){if(X===void 0)X=0;var N=new NZ,W=Q.body.getReader(),G=function K(){return W.read().then(function(j){if(j.done){if(N.dataLength)z(Y,J,N.flush().buffer,Q);return Promise.resolve(new ArrayBuffer(0))}var V=j.value,U=V.length;if(Y.loaded+=U,U<X||N.dataLength){if(N.push(V),N.dataLength>=X)z(Y,J,N.flush().buffer,Q)}else z(Y,J,V.buffer,Q);return G()}).catch(function(){return Promise.reject()})};return G()},q}();function K9(q,H){var Z={method:"GET",mode:"cors",credentials:"same-origin",signal:H,headers:new self.Headers(K0({},q.headers))};if(q.rangeEnd)Z.headers.set("Range","bytes="+q.rangeStart+"-"+String(q.rangeEnd-1));return Z}function j9(q){var H=G9.exec(q);if(H)return parseInt(H[2])-parseInt(H[1])+1}function U9(q){var H=q.get("Content-Range");if(H){var Z=j9(H);if(v(Z))return Z}var Q=q.get("Content-Length");if(Q)return parseInt(Q)}function V9(q,H){return new self.Request(q.url,H)}var A9=function(q){function H(Z,Q,Y){var J=q.call(this,Z)||this;return J.code=void 0,J.details=void 0,J.code=Q,J.details=Y,J}return j0(H,q),H}(qY(Error)),E9=/^age:\s*[\d.]+\s*$/im,XJ=function(){function q(Z){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=Z?Z.xhrSetup||null:null,this.stats=new nY,this.retryDelay=0}var H=q.prototype;return H.destroy=function Z(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null},H.abortInternal=function Z(){var Q=this.loader;if(self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),Q){if(Q.onreadystatechange=null,Q.onprogress=null,Q.readyState!==4)this.stats.aborted=!0,Q.abort()}},H.abort=function Z(){var Q;if(this.abortInternal(),(Q=this.callbacks)!=null&&Q.onAbort)this.callbacks.onAbort(this.stats,this.context,this.loader)},H.load=function Z(Q,Y,J){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=Q,this.config=Y,this.callbacks=J,this.loadInternal()},H.loadInternal=function Z(){var Q=this,Y=this.config,J=this.context;if(!Y||!J)return;var X=this.loader=new self.XMLHttpRequest,z=this.stats;z.loading.first=0,z.loaded=0,z.aborted=!1;var N=this.xhrSetup;if(N)Promise.resolve().then(function(){if(Q.loader!==X||Q.stats.aborted)return;return N(X,J.url)}).catch(function(W){if(Q.loader!==X||Q.stats.aborted)return;return X.open("GET",J.url,!0),N(X,J.url)}).then(function(){if(Q.loader!==X||Q.stats.aborted)return;Q.openAndSendXhr(X,J,Y)}).catch(function(W){var G;(G=Q.callbacks)==null||G.onError({code:X.status,text:W.message},J,X,z);return});else this.openAndSendXhr(X,J,Y)},H.openAndSendXhr=function Z(Q,Y,J){if(!Q.readyState)Q.open("GET",Y.url,!0);var X=Y.headers,z=J.loadPolicy,N=z.maxTimeToFirstByteMs,W=z.maxLoadTimeMs;if(X)for(var G in X)Q.setRequestHeader(G,X[G]);if(Y.rangeEnd)Q.setRequestHeader("Range","bytes="+Y.rangeStart+"-"+(Y.rangeEnd-1));Q.onreadystatechange=this.readystatechange.bind(this),Q.onprogress=this.loadprogress.bind(this),Q.responseType=Y.responseType,self.clearTimeout(this.requestTimeout),J.timeout=N&&v(N)?N:W,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),J.timeout),Q.send()},H.readystatechange=function Z(){var Q=this.context,Y=this.loader,J=this.stats;if(!Q||!Y)return;var X=Y.readyState,z=this.config;if(J.aborted)return;if(X>=2){if(J.loading.first===0){if(J.loading.first=Math.max(self.performance.now(),J.loading.start),z.timeout!==z.loadPolicy.maxLoadTimeMs)self.clearTimeout(this.requestTimeout),z.timeout=z.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),z.loadPolicy.maxLoadTimeMs-(J.loading.first-J.loading.start))}if(X===4){self.clearTimeout(this.requestTimeout),Y.onreadystatechange=null,Y.onprogress=null;var N=Y.status,W=Y.responseType==="text"?Y.responseText:null;if(N>=200&&N<300){var G=W!=null?W:Y.response;if(G!=null){var K,j;J.loading.end=Math.max(self.performance.now(),J.loading.first);var V=Y.responseType==="arraybuffer"?G.byteLength:G.length;J.loaded=J.total=V,J.bwEstimate=J.total*8000/(J.loading.end-J.loading.first);var U=(K=this.callbacks)==null?void 0:K.onProgress;if(U)U(J,Q,G,Y);var A={url:Y.responseURL,data:G,code:N};(j=this.callbacks)==null||j.onSuccess(A,J,Q,Y);return}}var E=z.loadPolicy.errorRetry,B=J.retry,F={url:Q.url,data:void 0,code:N};if(IY(E,B,!1,F))this.retry(E);else{var R;s.error(N+" while loading "+Q.url),(R=this.callbacks)==null||R.onError({code:N,text:Y.statusText},Q,Y,J)}}}},H.loadtimeout=function Z(){if(!this.config)return;var Q=this.config.loadPolicy.timeoutRetry,Y=this.stats.retry;if(IY(Q,Y,!0))this.retry(Q);else{var J;s.warn("timeout while loading "+((J=this.context)==null?void 0:J.url));var X=this.callbacks;if(X)this.abortInternal(),X.onTimeout(this.stats,this.context,this.loader)}},H.retry=function Z(Q){var Y=this.context,J=this.stats;this.retryDelay=Q7(Q,J.retry),J.retry++,s.warn((status?"HTTP Status "+status:"Timeout")+" while loading "+(Y==null?void 0:Y.url)+", retrying "+J.retry+"/"+Q.maxNumRetry+" in "+this.retryDelay+"ms"),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)},H.loadprogress=function Z(Q){var Y=this.stats;if(Y.loaded=Q.loaded,Q.lengthComputable)Y.total=Q.total},H.getCacheAge=function Z(){var Q=null;if(this.loader&&E9.test(this.loader.getAllResponseHeaders())){var Y=this.loader.getResponseHeader("age");Q=Y?parseFloat(Y):null}return Q},H.getResponseHeader=function Z(Q){if(this.loader&&new RegExp("^"+Q+":\\s*[\\d.]+\\s*$","im").test(this.loader.getAllResponseHeaders()))return this.loader.getResponseHeader(Q);return null},q}(),HJ={maxTimeToFirstByteMs:8000,maxLoadTimeMs:20000,timeoutRetry:null,errorRetry:null},B9=I0(I0({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:60000000,maxFragLookUpTolerance:0.25,maxBufferHole:0.1,detectStallWithCurrentTimeMs:1250,highBufferWatchdogPeriod:2,nudgeOffset:0.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:5000,fpsDroppedMonitoringThreshold:0.2,appendErrorMaxRetry:3,ignorePlaylistParsingErrors:!1,loader:XJ,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:D8,bufferController:g8,capLevelController:p8,errorController:h8,fpsController:zZ,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:500000,abrEwmaDefaultEstimateMax:5000000,abrBandWidthFactor:0.95,abrBandWidthUpFactor:0.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:HJ},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8000,maxLoadTimeMs:20000,timeoutRetry:{maxNumRetry:1,retryDelayMs:1000,maxRetryDelayMs:20000,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1000,maxRetryDelayMs:20000,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:20000,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1000,maxRetryDelayMs:8000}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:20000,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1000,maxRetryDelayMs:8000}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:120000,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1000,maxRetryDelayMs:8000}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:20000,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1000,maxRetryDelayMs:8000}}},interstitialAssetListLoadPolicy:{default:HJ},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1000,manifestLoadingMaxRetryTimeout:64000,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1000,levelLoadingMaxRetryTimeout:64000,fragLoadingTimeOut:20000,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1000,fragLoadingMaxRetryTimeout:64000},$9()),{},{subtitleStreamController:void 0,subtitleTrackController:void 0,timelineController:void 0,audioStreamController:void 0,audioTrackController:void 0,emeController:void 0,cmcdController:void 0,contentSteeringController:HZ,interstitialsController:void 0});function $9(){return{cueHandler:eJ,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 F9(q,H,Z){if((H.liveSyncDurationCount||H.liveMaxLatencyDurationCount)&&(H.liveSyncDuration||H.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(H.liveMaxLatencyDurationCount!==void 0&&(H.liveSyncDurationCount===void 0||H.liveMaxLatencyDurationCount<=H.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(H.liveMaxLatencyDuration!==void 0&&(H.liveSyncDuration===void 0||H.liveMaxLatencyDuration<=H.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var Q=$7(q),Y=["manifest","level","frag"],J=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return Y.forEach(function(X){var z=(X==="level"?"playlist":X)+"LoadPolicy",N=H[z]===void 0,W=[];if(J.forEach(function(G){var K=X+"Loading"+G,j=H[K];if(j!==void 0&&N){W.push(K);var V=Q[z].default;switch(H[z]={default:V},G){case"TimeOut":V.maxLoadTimeMs=j,V.maxTimeToFirstByteMs=j;break;case"MaxRetry":V.errorRetry.maxNumRetry=j,V.timeoutRetry.maxNumRetry=j;break;case"RetryDelay":V.errorRetry.retryDelayMs=j,V.timeoutRetry.retryDelayMs=j;break;case"MaxRetryTimeout":V.errorRetry.maxRetryDelayMs=j,V.timeoutRetry.maxRetryDelayMs=j;break}}}),W.length)Z.warn('hls.js config: "'+W.join('", "')+'" setting(s) are deprecated, use "'+z+'": '+M0(H[z]))}),I0(I0({},Q),H)}function $7(q){if(q&&typeof q==="object"){if(Array.isArray(q))return q.map($7);return Object.keys(q).reduce(function(H,Z){return H[Z]=$7(q[Z]),H},{})}return q}function O9(q,H){var Z=q.loader;if(Z!==qJ&&Z!==XJ)H.log("[config]: Custom loader detected, cannot enable progressive streaming"),q.progressive=!1;else{var Q=W9();if(Q)q.loader=qJ,q.progressive=!0,q.enableSoftwareAES=!0,H.log("[config]: Progressive streaming enabled, using FetchLoader")}}var w0={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"},R9=function(){function q(Z){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=0.2,this.hls=void 0,this.hasGaps=!1,this.hls=Z,this._registerListeners()}var H=q.prototype;return H._registerListeners=function Z(){var Q=this.hls;Q.on($.MANIFEST_LOADING,this.onManifestLoading,this),Q.on($.BUFFER_APPENDED,this.onBufferAppended,this),Q.on($.FRAG_BUFFERED,this.onFragBuffered,this),Q.on($.FRAG_LOADED,this.onFragLoaded,this)},H._unregisterListeners=function Z(){var Q=this.hls;Q.off($.MANIFEST_LOADING,this.onManifestLoading,this),Q.off($.BUFFER_APPENDED,this.onBufferAppended,this),Q.off($.FRAG_BUFFERED,this.onFragBuffered,this),Q.off($.FRAG_LOADED,this.onFragLoaded,this)},H.destroy=function Z(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null},H.getAppendedFrag=function Z(Q,Y){var J=this.activePartLists[Y];if(J)for(var X=J.length;X--;){var z=J[X];if(!z)break;var N=z.end;if(z.start<=Q&&N!==null&&Q<=N)return z}return this.getBufferedFrag(Q,Y)},H.getBufferedFrag=function Z(Q,Y){return this.getFragAtPos(Q,Y,!0)},H.getFragAtPos=function Z(Q,Y,J){var X=this.fragments,z=Object.keys(X);for(var N=z.length;N--;){var W=X[z[N]];if((W==null?void 0:W.body.type)===Y&&(!J||W.buffered)){var G=W.body;if(G.start<=Q&&Q<=G.end)return G}}return null},H.detectEvictedFragments=function Z(Q,Y,J,X,z){var N=this;if(this.timeRanges)this.timeRanges[Q]=Y;var W=(X==null?void 0:X.fragment.sn)||-1;Object.keys(this.fragments).forEach(function(G){var K=N.fragments[G];if(!K)return;if(W>=K.body.sn)return;if(!K.buffered&&(!K.loaded||z)){if(K.body.type===J)N.removeFragment(K.body);return}var j=K.range[Q];if(!j)return;if(j.time.length===0){N.removeFragment(K.body);return}j.time.some(function(V){var U=!N.isTimeBuffered(V.startPTS,V.endPTS,Y);if(U)N.removeFragment(K.body);return U})})},H.detectPartialFragments=function Z(Q){var Y=this,J=this.timeRanges;if(!J||Q.frag.sn==="initSegment")return;var X=Q.frag,z=e0(X),N=this.fragments[z];if(!N||N.buffered&&X.gap)return;var W=!X.relurl;if(Object.keys(J).forEach(function(K){var j=X.elementaryStreams[K];if(!j)return;var V=J[K],U=W||j.partial===!0;N.range[K]=Y.getBufferedTimes(X,Q.part,U,V)}),N.loaded=null,Object.keys(N.range).length){N.buffered=!0;var G=N.body.endList=X.endList||N.body.endList;if(G)this.endListFragments[N.body.type]=N;if(!xY(N))this.removeParts(X.sn-1,X.type)}else this.removeFragment(N.body)},H.removeParts=function Z(Q,Y){var J=this.activePartLists[Y];if(!J)return;this.activePartLists[Y]=J.filter(function(X){return X.fragment.sn>=Q})},H.fragBuffered=function Z(Q,Y){var J=e0(Q),X=this.fragments[J];if(!X&&Y){if(X=this.fragments[J]={body:Q,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},Q.gap)this.hasGaps=!0}if(X)X.loaded=null,X.buffered=!0},H.getBufferedTimes=function Z(Q,Y,J,X){var z={time:[],partial:J},N=Q.start,W=Q.end,G=Q.minEndPTS||W,K=Q.maxStartPTS||N;for(var j=0;j<X.length;j++){var V=X.start(j)-this.bufferPadding,U=X.end(j)+this.bufferPadding;if(K>=V&&G<=U){z.time.push({startPTS:Math.max(N,X.start(j)),endPTS:Math.min(W,X.end(j))});break}else if(N<U&&W>V){var A=Math.max(N,X.start(j)),E=Math.min(W,X.end(j));if(E>A)z.partial=!0,z.time.push({startPTS:A,endPTS:E})}else if(W<=V)break}return z},H.getPartialFragment=function Z(Q){var Y=null,J,X,z,N=0,W=this.bufferPadding,G=this.fragments;return Object.keys(G).forEach(function(K){var j=G[K];if(!j)return;if(xY(j)){if(X=j.body.start-W,z=j.body.end+W,Q>=X&&Q<=z){if(J=Math.min(Q-X,z-Q),N<=J)Y=j.body,N=J}}}),Y},H.isEndListAppended=function Z(Q){var Y=this.endListFragments[Q];return Y!==void 0&&(Y.buffered||xY(Y))},H.getState=function Z(Q){var Y=e0(Q),J=this.fragments[Y];if(J)if(!J.buffered)return w0.APPENDING;else if(xY(J))return w0.PARTIAL;else return w0.OK;return w0.NOT_LOADED},H.isTimeBuffered=function Z(Q,Y,J){var X,z;for(var N=0;N<J.length;N++){if(X=J.start(N)-this.bufferPadding,z=J.end(N)+this.bufferPadding,Q>=X&&Y<=z)return!0;if(Y<=X)return!1}return!1},H.onManifestLoading=function Z(){this.removeAllFragments()},H.onFragLoaded=function Z(Q,Y){if(Y.frag.sn==="initSegment"||Y.frag.bitrateTest)return;var J=Y.frag,X=Y.part?null:Y,z=e0(J);this.fragments[z]={body:J,appendedPTS:null,loaded:X,buffered:!1,range:Object.create(null)}},H.onBufferAppended=function Z(Q,Y){var{frag:J,part:X,timeRanges:z,type:N}=Y;if(J.sn==="initSegment")return;var W=J.type;if(X){var G=this.activePartLists[W];if(!G)this.activePartLists[W]=G=[];G.push(X)}this.timeRanges=z;var K=z[N];this.detectEvictedFragments(N,K,W,X)},H.onFragBuffered=function Z(Q,Y){this.detectPartialFragments(Y)},H.hasFragment=function Z(Q){var Y=e0(Q);return!!this.fragments[Y]},H.hasFragments=function Z(Q){var Y=this.fragments,J=Object.keys(Y);if(!Q)return J.length>0;for(var X=J.length;X--;){var z=Y[J[X]];if((z==null?void 0:z.body.type)===Q)return!0}return!1},H.hasParts=function Z(Q){var Y;return!!((Y=this.activePartLists[Q])!=null&&Y.length)},H.removeFragmentsInRange=function Z(Q,Y,J,X,z){var N=this;if(X&&!this.hasGaps)return;Object.keys(this.fragments).forEach(function(W){var G=N.fragments[W];if(!G)return;var K=G.body;if(K.type!==J||X&&!K.gap)return;if(K.start<Y&&K.end>Q&&(G.buffered||z))N.removeFragment(K)})},H.removeFragment=function Z(Q){var Y=e0(Q);Q.clearElementaryStreamInfo();var J=this.activePartLists[Q.type];if(J){var X=Q.sn;this.activePartLists[Q.type]=J.filter(function(z){return z.fragment.sn!==X})}if(delete this.fragments[Y],Q.endList)delete this.endListFragments[Q.type]},H.removeAllFragments=function Z(){var Q,Y;this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1;var J=(Q=this.hls)==null?void 0:(Y=Q.latestLevelDetails)==null?void 0:Y.partList;if(J)J.forEach(function(X){return X.clearElementaryStreamInfo()})},q}();function xY(q){var H,Z,Q;return q.buffered&&(q.body.gap||((H=q.range.video)==null?void 0:H.partial)||((Z=q.range.audio)==null?void 0:Z.partial)||((Q=q.range.audiovideo)==null?void 0:Q.partial))}function e0(q){return q.type+"_"+q.level+"_"+q.sn}var zJ=Math.pow(2,17),M9=function(){function q(Z){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=Z}var H=q.prototype;return H.destroy=function Z(){if(this.loader)this.loader.destroy(),this.loader=null},H.abort=function Z(){if(this.loader)this.loader.abort()},H.load=function Z(Q,Y){var J=this,X=Q.url;if(!X)return Promise.reject(new c0({type:f.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:Q,error:new Error("Fragment does not have a "+(X?"part list":"url")),networkDetails:null}));this.abort();var z=this.config,N=z.fLoader,W=z.loader;return new Promise(function(G,K){if(J.loader)J.loader.destroy();if(Q.gap)if(Q.tagList.some(function(B){return B[0]==="GAP"})){K(WJ(Q));return}else Q.gap=!1;var j=J.loader=N?new N(z):new W(z),V=NJ(Q);Q.loader=j;var U=GQ(z.fragLoadPolicy.default),A={loadPolicy:U,timeout:U.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:Q.sn==="initSegment"?1/0:zJ};Q.stats=j.stats;var E={onSuccess:function B(F,R,O,M){J.resetLoader(Q,j);var L=F.data;if(O.resetIV&&Q.decryptdata)Q.decryptdata.iv=new Uint8Array(L.slice(0,16)),L=L.slice(16);G({frag:Q,part:null,payload:L,networkDetails:M})},onError:function B(F,R,O,M){J.resetLoader(Q,j),K(new c0({type:f.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:Q,response:I0({url:X,data:void 0},F),error:new Error("HTTP Error "+F.code+" "+F.text),networkDetails:O,stats:M}))},onAbort:function B(F,R,O){J.resetLoader(Q,j),K(new c0({type:f.NETWORK_ERROR,details:D.INTERNAL_ABORTED,fatal:!1,frag:Q,error:new Error("Aborted"),networkDetails:O,stats:F}))},onTimeout:function B(F,R,O){J.resetLoader(Q,j),K(new c0({type:f.NETWORK_ERROR,details:D.FRAG_LOAD_TIMEOUT,fatal:!1,frag:Q,error:new Error("Timeout after "+A.timeout+"ms"),networkDetails:O,stats:F}))}};if(Y)E.onProgress=function(B,F,R,O){return Y({frag:Q,part:null,payload:R,networkDetails:O})};j.load(V,A,E)})},H.loadPart=function Z(Q,Y,J){var X=this;this.abort();var z=this.config,N=z.fLoader,W=z.loader;return new Promise(function(G,K){if(X.loader)X.loader.destroy();if(Q.gap||Y.gap){K(WJ(Q,Y));return}var j=X.loader=N?new N(z):new W(z),V=NJ(Q,Y);Q.loader=j;var U=GQ(z.fragLoadPolicy.default),A={loadPolicy:U,timeout:U.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:zJ};Y.stats=j.stats,j.load(V,A,{onSuccess:function E(B,F,R,O){X.resetLoader(Q,j),X.updateStatsFromPart(Q,Y);var M={frag:Q,part:Y,payload:B.data,networkDetails:O};J(M),G(M)},onError:function E(B,F,R,O){X.resetLoader(Q,j),K(new c0({type:f.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:Q,part:Y,response:I0({url:V.url,data:void 0},B),error:new Error("HTTP Error "+B.code+" "+B.text),networkDetails:R,stats:O}))},onAbort:function E(B,F,R){Q.stats.aborted=Y.stats.aborted,X.resetLoader(Q,j),K(new c0({type:f.NETWORK_ERROR,details:D.INTERNAL_ABORTED,fatal:!1,frag:Q,part:Y,error:new Error("Aborted"),networkDetails:R,stats:B}))},onTimeout:function E(B,F,R){X.resetLoader(Q,j),K(new c0({type:f.NETWORK_ERROR,details:D.FRAG_LOAD_TIMEOUT,fatal:!1,frag:Q,part:Y,error:new Error("Timeout after "+A.timeout+"ms"),networkDetails:R,stats:B}))}})})},H.updateStatsFromPart=function Z(Q,Y){var J=Q.stats,X=Y.stats,z=X.total;if(J.loaded+=X.loaded,z){var N=Math.round(Q.duration/Y.duration),W=Math.min(Math.round(J.loaded/z),N),G=N-W,K=G*Math.round(J.loaded/W);J.total=J.loaded+K}else J.total=Math.max(J.loaded,J.total);var j=J.loading,V=X.loading;if(j.start)j.first+=V.first-V.start;else j.start=V.start,j.first=V.first;j.end=V.end},H.resetLoader=function Z(Q,Y){if(Q.loader=null,this.loader===Y)self.clearTimeout(this.partLoadTimeout),this.loader=null;Y.destroy()},q}();function NJ(q,H){if(H===void 0)H=null;var Z=H||q,Q={frag:q,part:H,responseType:"arraybuffer",url:Z.url,headers:{},rangeStart:0,rangeEnd:0},Y=Z.byteRangeStartOffset,J=Z.byteRangeEndOffset;if(v(Y)&&v(J)){var X,z=Y,N=J;if(q.sn==="initSegment"&&I9((X=q.decryptdata)==null?void 0:X.method)){var W=J-Y;if(W%16)N=J+(16-W%16);if(Y!==0)Q.resetIV=!0,z=Y-16}Q.rangeStart=z,Q.rangeEnd=N}return Q}function WJ(q,H){var Z=new Error("GAP "+(q.gap?"tag":"attribute")+" found"),Q={type:f.MEDIA_ERROR,details:D.FRAG_GAP,fatal:!1,frag:q,error:Z,networkDetails:null};if(H)Q.part=H;return(H?H:q).stats.aborted=!0,new c0(Q)}function I9(q){return q==="AES-128"||q==="AES-256"}var c0=function(q){function H(Z){var Q=q.call(this,Z.error.message)||this;return Q.data=void 0,Q.data=Z,Q}return j0(H,q),H}(qY(Error)),GJ=function(q){function H(Q,Y){var J=q.call(this,Q,Y)||this;return J._boundTick=void 0,J._tickTimer=null,J._tickInterval=null,J._tickCallCount=0,J._boundTick=J.tick.bind(J),J}j0(H,q);var Z=H.prototype;return Z.destroy=function Q(){this.onHandlerDestroying(),this.onHandlerDestroyed()},Z.onHandlerDestroying=function Q(){this.clearNextTick(),this.clearInterval()},Z.onHandlerDestroyed=function Q(){},Z.hasInterval=function Q(){return!!this._tickInterval},Z.hasNextTick=function Q(){return!!this._tickTimer},Z.setInterval=function Q(Y){if(!this._tickInterval)return this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,Y),!0;return!1},Z.clearInterval=function Q(){if(this._tickInterval)return self.clearInterval(this._tickInterval),this._tickInterval=null,!0;return!1},Z.clearNextTick=function Q(){if(this._tickTimer)return self.clearTimeout(this._tickTimer),this._tickTimer=null,!0;return!1},Z.tick=function Q(){if(this._tickCallCount++,this._tickCallCount===1){if(this.doTick(),this._tickCallCount>1)this.tickImmediate();this._tickCallCount=0}},Z.tickImmediate=function Q(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},Z.doTick=function Q(){},H}(i0),KJ=function q(H,Z,Q,Y,J,X){if(Y===void 0)Y=0;if(J===void 0)J=-1;if(X===void 0)X=!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=TY(),this.buffering={audio:TY(),video:TY(),audiovideo:TY()},this.level=H,this.sn=Z,this.id=Q,this.size=Y,this.part=J,this.partial=X};function TY(){return{start:0,executeStart:0,executeEnd:0,end:0}}function WY(q,H){for(var Z=0,Q=q.length;Z<Q;Z++){var Y;if(((Y=q[Z])==null?void 0:Y.cc)===H)return q[Z]}return null}function w9(q,H){if(q){if(H.startCC<q.endCC&&H.endCC>q.startCC)return!0}return!1}function jJ(q,H){if(q){var Z=q.start+H;q.start=q.startPTS=Z,q.endPTS=Z+q.duration}}function UJ(q,H){var Z=H.fragments;for(var Q=0,Y=Z.length;Q<Y;Q++)jJ(Z[Q],q);if(H.fragmentHint)jJ(H.fragmentHint,q);H.alignedSliding=!0}function L9(q,H){if(!q)return;if(b9(H,q),!H.alignedSliding&&q)C9(H,q);if(!H.alignedSliding&&q&&!H.skippedSegments)SQ(q,H,!1)}function b9(q,H){if(!w9(H,q))return;var Z=Math.min(H.endCC,q.endCC),Q=WY(H.fragments,Z),Y=WY(q.fragments,Z);if(!Q||!Y)return;s.log("Aligning playlist at start of dicontinuity sequence "+Z);var J=Q.start-Y.start;UJ(J,q)}function C9(q,H){if(!q.hasProgramDateTime||!H.hasProgramDateTime)return;var Z=q.fragments,Q=H.fragments;if(!Z.length||!Q.length)return;var Y,J,X=Math.min(H.endCC,q.endCC);if(H.startCC<X&&q.startCC<X)Y=WY(Q,X),J=WY(Z,X);if(!Y||!J)Y=Q[Math.floor(Q.length/2)],J=WY(Z,Y.cc)||Z[Math.floor(Z.length/2)];var z=Y.programDateTime,N=J.programDateTime;if(!z||!N)return;var W=(N-z)/1000-(J.start-Y.start);UJ(W,q)}var P9={toString:function q(H){var Z="",Q=H.length;for(var Y=0;Y<Q;Y++)Z+="["+H.start(Y).toFixed(3)+"-"+H.end(Y).toFixed(3)+"]";return Z}},k={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"},D9=function(q){function H(Q,Y,J,X,z){var N=q.call(this,X,Q.logger)||this;return N.hls=void 0,N.fragPrevious=null,N.fragCurrent=null,N.fragmentTracker=void 0,N.transmuxer=null,N._state=k.STOPPED,N.playlistType=void 0,N.media=null,N.mediaBuffer=null,N.config=void 0,N.bitrateTest=!1,N.lastCurrentTime=0,N.nextLoadPosition=0,N.startPosition=0,N.startTimeOffset=null,N.retryDate=0,N.levels=null,N.fragmentLoader=void 0,N.keyLoader=void 0,N.levelLastLoaded=null,N.startFragRequested=!1,N.decrypter=void 0,N.initPTS=[],N.buffering=!0,N.loadingParts=!1,N.loopSn=void 0,N.onMediaSeeking=function(){var W=N,G=W.config,K=W.fragCurrent,j=W.media,V=W.mediaBuffer,U=W.state,A=j?j.currentTime:0,E=i.bufferInfo(V?V:j,A,G.maxBufferHole);if(N.log("media seeking to "+(v(A)?A.toFixed(3):A)+", state: "+U),N.state===k.ENDED)N.resetLoadingState();else if(K){var B=G.maxFragLookUpTolerance,F=K.start-B,R=K.start+K.duration+B;if(!E.len||R<E.start||F>E.end){var O=A>R;if(A<F||O){if(O&&K.loader)N.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),K.abortRequests(),N.resetLoadingState();N.fragPrevious=null}}}if(j){N.fragmentTracker.removeFragmentsInRange(A,1/0,N.playlistType,!0);var M=N.lastCurrentTime;if(A>M)N.lastCurrentTime=A;if(!N.loadingParts){var L=Math.max(E.end,A),I=N.shouldLoadParts(N.getLevelDetails(),L);if(I)N.log("LL-Part loading ON after seeking to "+A.toFixed(2)+" with buffer @"+L.toFixed(2)),N.loadingParts=I}}if(!N.hls.hasEnoughToStart&&!E.len)N.log("setting startPosition to "+A+" because of seek before start"),N.nextLoadPosition=N.startPosition=A;N.tickImmediate()},N.onMediaEnded=function(){N.log("setting startPosition to 0 because media ended"),N.startPosition=N.lastCurrentTime=0},N.playlistType=z,N.hls=Q,N.fragmentLoader=new M9(Q.config),N.keyLoader=J,N.fragmentTracker=Y,N.config=Q.config,N.decrypter=new G7(Q.config),N}j0(H,q);var Z=H.prototype;return Z.registerListeners=function Q(){var Y=this.hls;Y.on($.MEDIA_ATTACHED,this.onMediaAttached,this),Y.on($.MEDIA_DETACHING,this.onMediaDetaching,this),Y.on($.MANIFEST_LOADING,this.onManifestLoading,this),Y.on($.MANIFEST_LOADED,this.onManifestLoaded,this),Y.on($.ERROR,this.onError,this)},Z.unregisterListeners=function Q(){var Y=this.hls;Y.off($.MEDIA_ATTACHED,this.onMediaAttached,this),Y.off($.MEDIA_DETACHING,this.onMediaDetaching,this),Y.off($.MANIFEST_LOADING,this.onManifestLoading,this),Y.off($.MANIFEST_LOADED,this.onManifestLoaded,this),Y.off($.ERROR,this.onError,this)},Z.doTick=function Q(){this.onTickEnd()},Z.onTickEnd=function Q(){},Z.startLoad=function Q(Y){},Z.stopLoad=function Q(){if(this.state===k.STOPPED)return;this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);var Y=this.fragCurrent;if(Y!=null&&Y.loader)Y.abortRequests(),this.fragmentTracker.removeFragment(Y);this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=k.STOPPED},Z.pauseBuffering=function Q(){this.buffering=!1},Z.resumeBuffering=function Q(){this.buffering=!0},Z._streamEnded=function Q(Y,J){if(J.live||!this.media)return!1;var X=Y.end||0,z=this.config.timelineOffset||0;if(X<=z)return!1;var N=Y.nextStart,W=N&&N>z&&N<J.edge;if(W)return!1;if(this.media.currentTime<Y.start)return!1;var G=J.partList;if(G!=null&&G.length){var K=G[G.length-1],j=i.isBuffered(this.media,K.start+K.duration/2);return j}var V=J.fragments[J.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(V)},Z.getLevelDetails=function Q(){if(this.levels&&this.levelLastLoaded!==null){var Y;return(Y=this.levelLastLoaded)==null?void 0:Y.details}},Z.onMediaAttached=function Q(Y,J){var X=this.media=this.mediaBuffer=J.media;X.removeEventListener("seeking",this.onMediaSeeking),X.removeEventListener("ended",this.onMediaEnded),X.addEventListener("seeking",this.onMediaSeeking),X.addEventListener("ended",this.onMediaEnded);var z=this.config;if(this.levels&&z.autoStartLoad&&this.state===k.STOPPED)this.startLoad(z.startPosition)},Z.onMediaDetaching=function Q(Y,J){var X=!!J.transferMedia,z=this.media;if(z===null)return;if(z.ended)this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0;if(z.removeEventListener("seeking",this.onMediaSeeking),z.removeEventListener("ended",this.onMediaEnded),this.keyLoader&&!X)this.keyLoader.detach();if(this.media=this.mediaBuffer=null,this.loopSn=void 0,X){this.resetLoadingState(),this.resetTransmuxer();return}this.loadingParts=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},Z.onManifestLoading=function Q(){this.initPTS=[],this.levels=this.levelLastLoaded=this.fragCurrent=null,this.lastCurrentTime=this.startPosition=0,this.startFragRequested=!1},Z.onError=function Q(Y,J){},Z.onManifestLoaded=function Q(Y,J){this.startTimeOffset=J.startTimeOffset},Z.onHandlerDestroying=function Q(){if(this.stopLoad(),this.transmuxer)this.transmuxer.destroy(),this.transmuxer=null;q.prototype.onHandlerDestroying.call(this),this.hls=this.onMediaSeeking=this.onMediaEnded=null},Z.onHandlerDestroyed=function Q(){if(this.state=k.STOPPED,this.fragmentLoader)this.fragmentLoader.destroy();if(this.keyLoader)this.keyLoader.destroy();if(this.decrypter)this.decrypter.destroy();this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,q.prototype.onHandlerDestroyed.call(this)},Z.loadFragment=function Q(Y,J,X){this.startFragRequested=!0,this._loadFragForPlayback(Y,J,X)},Z._loadFragForPlayback=function Q(Y,J,X){var z=this,N=function W(G){var K=G.frag;if(z.fragContextChanged(K)){z.warn(K.type+" sn: "+K.sn+(G.part?" part: "+G.part.index:"")+" of "+z.fragInfo(K,!1,G.part)+") was dropped during download."),z.fragmentTracker.removeFragment(K);return}K.stats.chunkCount++,z._handleFragmentLoadProgress(G)};this._doFragLoad(Y,J,X,N).then(function(W){if(!W)return;var G=z.state,K=W.frag;if(z.fragContextChanged(K)){if(G===k.FRAG_LOADING||!z.fragCurrent&&G===k.PARSING)z.fragmentTracker.removeFragment(K),z.state=k.IDLE;return}if("payload"in W)z.log("Loaded "+K.type+" sn: "+K.sn+" of "+z.playlistLabel()+" "+K.level),z.hls.trigger($.FRAG_LOADED,W);z._handleFragmentLoadComplete(W)}).catch(function(W){if(z.state===k.STOPPED||z.state===k.ERROR)return;z.warn("Frag error: "+((W==null?void 0:W.message)||W)),z.resetFragmentLoading(Y)})},Z.clearTrackerIfNeeded=function Q(Y){var J,X=this.fragmentTracker,z=X.getState(Y);if(z===w0.APPENDING){var N=Y.type,W=this.getFwdBufferInfo(this.mediaBuffer,N),G=Math.max(Y.duration,W?W.len:this.config.maxBufferLength),K=this.backtrackFragment,j=K?Y.sn-K.sn:0;if(j===1||this.reduceMaxBufferLength(G,Y.duration))X.removeFragment(Y)}else if(((J=this.mediaBuffer)==null?void 0:J.buffered.length)===0)X.removeAllFragments();else if(X.hasParts(Y.type)){if(X.detectPartialFragments({frag:Y,part:null,stats:Y.stats,id:Y.type}),X.getState(Y)===w0.PARTIAL)X.removeFragment(Y)}},Z.checkLiveUpdate=function Q(Y){if(Y.updated&&!Y.live){var J=Y.fragments[Y.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:J,part:null,stats:J.stats,id:J.type})}if(!Y.fragments[0])Y.deltaUpdateFailed=!0},Z.waitForLive=function Q(Y){var J=Y.details;return(J==null?void 0:J.live)&&J.type!=="EVENT"&&(this.levelLastLoaded!==Y||J.expired)},Z.flushMainBuffer=function Q(Y,J,X){if(X===void 0)X=null;if(!(Y-J))return;var z={startOffset:Y,endOffset:J,type:X};this.hls.trigger($.BUFFER_FLUSHING,z)},Z._loadInitSegment=function Q(Y,J){var X=this;this._doFragLoad(Y,J).then(function(z){var N=z==null?void 0:z.frag;if(!N||X.fragContextChanged(N)||!X.levels)throw new Error("init load aborted");return z}).then(function(z){var N=X.hls,W=z.frag,G=z.payload,K=W.decryptdata;if(G&&G.byteLength>0&&K!=null&&K.key&&K.iv&&HY(K.method)){var j=self.performance.now();return X.decrypter.decrypt(new Uint8Array(G),K.key.buffer,K.iv.buffer,BQ(K.method)).catch(function(V){throw N.trigger($.ERROR,{type:f.MEDIA_ERROR,details:D.FRAG_DECRYPT_ERROR,fatal:!1,error:V,reason:V.message,frag:W}),V}).then(function(V){var U=self.performance.now();return N.trigger($.FRAG_DECRYPTED,{frag:W,payload:V,stats:{tstart:j,tdecrypt:U}}),z.payload=V,X.completeInitSegmentLoad(z)})}return X.completeInitSegmentLoad(z)}).catch(function(z){if(X.state===k.STOPPED||X.state===k.ERROR)return;X.warn(z),X.resetFragmentLoading(Y)})},Z.completeInitSegmentLoad=function Q(Y){var J=this.levels;if(!J)throw new Error("init load aborted, missing levels");var X=Y.frag.stats;if(this.state!==k.STOPPED)this.state=k.IDLE;Y.frag.data=new Uint8Array(Y.payload),X.parsing.start=X.buffering.start=self.performance.now(),X.parsing.end=X.buffering.end=self.performance.now(),this.tick()},Z.fragContextChanged=function Q(Y){var J=this.fragCurrent;return!Y||!J||Y.sn!==J.sn||Y.level!==J.level},Z.fragBufferedComplete=function Q(Y,J){var X=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log("Buffered "+Y.type+" sn: "+Y.sn+(J?" part: "+J.index:"")+" of "+this.fragInfo(Y,!1,J)+" > buffer:"+(X?P9.toString(i.getBuffered(X)):"(detached)")+")"),h0(Y)){var z;if(Y.type!==d.SUBTITLE){var N=Y.elementaryStreams;if(!Object.keys(N).some(function(G){return!!N[G]})){this.state=k.IDLE;return}}var W=(z=this.levels)==null?void 0:z[Y.level];if(W!=null&&W.fragmentError)this.log("Resetting level fragment error count of "+W.fragmentError+" on frag buffered"),W.fragmentError=0}this.state=k.IDLE},Z._handleFragmentLoadComplete=function Q(Y){var J=this.transmuxer;if(!J)return;var{frag:X,part:z,partsLoaded:N}=Y,W=!N||N.length===0||N.some(function(K){return!K}),G=new KJ(X.level,X.sn,X.stats.chunkCount+1,0,z?z.index:-1,!W);J.flush(G)},Z._handleFragmentLoadProgress=function Q(Y){},Z._doFragLoad=function Q(Y,J,X,z){var N,W=this;if(X===void 0)X=null;this.fragCurrent=Y;var G=J==null?void 0:J.details;if(!this.levels||!G)throw new Error("frag load aborted, missing level"+(G?"":" detail")+"s");var K=null;if(Y.encrypted&&!((N=Y.decryptdata)!=null&&N.key)){if(this.log("Loading key for "+Y.sn+" of ["+G.startSN+"-"+G.endSN+"], "+this.playlistLabel()+" "+Y.level),this.state=k.KEY_LOADING,this.fragCurrent=Y,K=this.keyLoader.load(Y).then(function(O){if(!W.fragContextChanged(O.frag)){if(W.hls.trigger($.KEY_LOADED,O),W.state===k.KEY_LOADING)W.state=k.IDLE;return O}}),this.hls.trigger($.KEY_LOADING,{frag:Y}),this.fragCurrent===null)K=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING"))}else if(!Y.encrypted&&G.encryptedFragments.length)this.keyLoader.loadClear(Y,G.encryptedFragments);var j=this.fragPrevious;if(h0(Y)&&(!j||Y.sn!==j.sn)){var V=this.shouldLoadParts(J.details,Y.end);if(V!==this.loadingParts)this.log("LL-Part loading "+(V?"ON":"OFF")+" loading sn "+(j==null?void 0:j.sn)+"->"+Y.sn),this.loadingParts=V}if(X=Math.max(Y.start,X||0),this.loadingParts&&h0(Y)){var U=G.partList;if(U&&z){if(X>Y.end&&G.fragmentHint)Y=G.fragmentHint;var A=this.getNextPart(U,Y,X);if(A>-1){var E=U[A];Y=this.fragCurrent=E.fragment,this.log("Loading "+Y.type+" sn: "+Y.sn+" part: "+E.index+" ("+A+"/"+(U.length-1)+") of "+this.fragInfo(Y,!1,E)+") cc: "+Y.cc+" ["+G.startSN+"-"+G.endSN+"], target: "+parseFloat(X.toFixed(3))),this.nextLoadPosition=E.start+E.duration,this.state=k.FRAG_LOADING;var B;if(K)B=K.then(function(O){if(!O||W.fragContextChanged(O.frag))return null;return W.doFragPartsLoad(Y,E,J,z)}).catch(function(O){return W.handleFragLoadError(O)});else B=this.doFragPartsLoad(Y,E,J,z).catch(function(O){return W.handleFragLoadError(O)});if(this.hls.trigger($.FRAG_LOADING,{frag:Y,part:E,targetBufferTime:X}),this.fragCurrent===null)return Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts"));return B}else if(!Y.url||this.loadedEndOfParts(U,X))return Promise.resolve(null)}}if(h0(Y)&&this.loadingParts)this.log("LL-Part loading OFF after next part miss @"+X.toFixed(2)),this.loadingParts=!1;else if(!Y.url)return Promise.resolve(null);if(this.log("Loading "+Y.type+" sn: "+Y.sn+" of "+this.fragInfo(Y,!1)+") cc: "+Y.cc+" "+(G?"["+G.startSN+"-"+G.endSN+"]":"")+", target: "+parseFloat(X.toFixed(3))),v(Y.sn)&&!this.bitrateTest)this.nextLoadPosition=Y.start+Y.duration;this.state=k.FRAG_LOADING;var F=this.config.progressive,R;if(F&&K)R=K.then(function(O){if(!O||W.fragContextChanged(O==null?void 0:O.frag))return null;return W.fragmentLoader.load(Y,z)}).catch(function(O){return W.handleFragLoadError(O)});else R=Promise.all([this.fragmentLoader.load(Y,F?z:void 0),K]).then(function(O){var M=O[0];if(!F&&M&&z)z(M);return M}).catch(function(O){return W.handleFragLoadError(O)});if(this.hls.trigger($.FRAG_LOADING,{frag:Y,targetBufferTime:X}),this.fragCurrent===null)return Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING"));return R},Z.doFragPartsLoad=function Q(Y,J,X,z){var N=this;return new Promise(function(W,G){var K,j=[],V=(K=X.details)==null?void 0:K.partList,U=function A(E){N.fragmentLoader.loadPart(Y,E,z).then(function(B){j[E.index]=B;var F=B.part;N.hls.trigger($.FRAG_LOADED,B);var R=TQ(X.details,Y.sn,E.index+1)||yQ(V,Y.sn,E.index+1);if(R)U(R);else return W({frag:Y,part:F,partsLoaded:j})}).catch(G)};U(J)})},Z.handleFragLoadError=function Q(Y){if("data"in Y){var J=Y.data;if(Y.data&&J.details===D.INTERNAL_ABORTED)this.handleFragLoadAborted(J.frag,J.part);else this.hls.trigger($.ERROR,J)}else this.hls.trigger($.ERROR,{type:f.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,err:Y,error:Y,fatal:!0});return null},Z._handleTransmuxerFlush=function Q(Y){var J=this.getCurrentContext(Y);if(!J||this.state!==k.PARSING){if(!this.fragCurrent&&this.state!==k.STOPPED&&this.state!==k.ERROR)this.state=k.IDLE;return}var{frag:X,part:z,level:N}=J,W=self.performance.now();if(X.stats.parsing.end=W,z)z.stats.parsing.end=W;var G=this.getLevelDetails(),K=G&&X.sn>G.endSN,j=K||this.shouldLoadParts(G,X.end);if(j!==this.loadingParts)this.log("LL-Part loading "+(j?"ON":"OFF")+" after parsing segment ending @"+X.end.toFixed(2)),this.loadingParts=j;this.updateLevelTiming(X,z,N,Y.partial)},Z.shouldLoadParts=function Q(Y,J){if(this.config.lowLatencyMode){if(!Y)return this.loadingParts;if(Y!=null&&Y.partList){var X,z=Y.partList[0],N=z.end+(((X=Y.fragmentHint)==null?void 0:X.duration)||0);if(J>=N){var W,G=this.hls.hasEnoughToStart?((W=this.media)==null?void 0:W.currentTime)||this.lastCurrentTime:this.getLoadPosition();if(G>z.start-z.fragment.duration)return!0}}}return!1},Z.getCurrentContext=function Q(Y){var J=this.levels,X=this.fragCurrent,z=Y.level,N=Y.sn,W=Y.part;if(!(J!=null&&J[z]))return this.warn("Levels object was unset while buffering fragment "+N+" of "+this.playlistLabel()+" "+z+". The current chunk will not be buffered."),null;var G=J[z],K=G.details,j=W>-1?TQ(K,N,W):null,V=j?j.fragment:qZ(K,N,X);if(!V)return null;if(X&&X!==V)V.stats=X.stats;return{frag:V,part:j,level:G}},Z.bufferFragmentData=function Q(Y,J,X,z,N){var W;if(!Y||this.state!==k.PARSING)return;var{data1:G,data2:K}=Y,j=G;if(G&&K)j=T0(G,K);if(!((W=j)!=null&&W.length))return;var V={type:Y.type,frag:J,part:X,chunkMeta:z,parent:J.type,data:j};if(this.hls.trigger($.BUFFER_APPENDING,V),Y.dropped&&Y.independent&&!X){if(N)return;this.flushBufferGap(J)}},Z.flushBufferGap=function Q(Y){var J=this.media;if(!J)return;if(!i.isBuffered(J,J.currentTime)){this.flushMainBuffer(0,Y.start);return}var X=J.currentTime,z=i.bufferInfo(J,X,0),N=Y.duration,W=Math.min(this.config.maxFragLookUpTolerance*2,N*0.25),G=Math.max(Math.min(Y.start-W,z.end-W),X+W);if(Y.start-G>W)this.flushMainBuffer(G,Y.start)},Z.getFwdBufferInfo=function Q(Y,J){var X,z=this.getLoadPosition();if(!v(z))return null;var N=this.lastCurrentTime>z,W=N||(X=this.media)!=null&&X.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(Y,z,J,W)},Z.getFwdBufferInfoAtPos=function Q(Y,J,X,z){var N=i.bufferInfo(Y,J,z);if(N.len===0&&N.nextStart!==void 0){var W=this.fragmentTracker.getBufferedFrag(J,X);if(W&&(N.nextStart<=W.end||W.gap)){var G=Math.max(Math.min(N.nextStart,W.end)-J,z);return i.bufferInfo(Y,J,G)}}return N},Z.getMaxBufferLength=function Q(Y){var J=this.config,X;if(Y)X=Math.max(8*J.maxBufferSize/Y,J.maxBufferLength);else X=J.maxBufferLength;return Math.min(X,J.maxMaxBufferLength)},Z.reduceMaxBufferLength=function Q(Y,J){var X=this.config,z=Math.max(Math.min(Y-J,X.maxBufferLength),J),N=Math.max(Y-J*3,X.maxMaxBufferLength/2,z);if(N>=z)return X.maxMaxBufferLength=N,this.warn("Reduce max buffer length to "+N+"s"),!0;return!1},Z.getAppendedFrag=function Q(Y,J){var X;if(J===void 0)J=d.MAIN;var z=(X=this.fragmentTracker)==null?void 0:X.getAppendedFrag(Y,J);if(z&&"fragment"in z)return z.fragment;return z},Z.getNextFragment=function Q(Y,J){var X=J.fragments,z=X.length;if(!z)return null;var N=this.config,W=X[0].start,G=N.lowLatencyMode&&!!J.partList,K=null;if(J.live){var j=N.initialLiveManifestSize;if(z<j)return this.warn("Not enough fragments to start playback (have: "+z+", need: "+j+")"),null;if(!J.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||Y<W){var V;if(G&&!this.loadingParts)this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0;K=this.getInitialLiveFragment(J,X);var U=this.hls.startPosition,A=this.hls.liveSyncPosition,E=K?(U!==-1&&U>=W?U:A)||K.start:Y;this.log("Setting startPosition to "+E+" to match start frag at live edge. mainStart: "+U+" liveSyncPosition: "+A+" frag.start: "+((V=K)==null?void 0:V.start)),this.startPosition=this.nextLoadPosition=E}}else if(Y<=W)K=X[0];if(!K){var B=this.loadingParts?J.partEnd:J.fragmentEnd;K=this.getFragmentAtPosition(Y,B,J)}var F=this.filterReplacedPrimary(K,J);if(!F&&K){var R=K.sn-J.startSN;F=this.filterReplacedPrimary(X[R+1]||null,J)}return this.mapToInitFragWhenRequired(F)},Z.isLoopLoading=function Q(Y,J){var X=this.fragmentTracker.getState(Y);return(X===w0.OK||X===w0.PARTIAL&&!!Y.gap)&&this.nextLoadPosition>J},Z.getNextFragmentLoopLoading=function Q(Y,J,X,z,N){var W=null;if(Y.gap){if(W=this.getNextFragment(this.nextLoadPosition,J),W&&!W.gap&&X.nextStart){var G=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,X.nextStart,z,0);if(G!==null&&X.len+G.len>=N){var K=W.sn;if(this.loopSn!==K)this.log('buffer full after gaps in "'+z+'" playlist starting at sn: '+K),this.loopSn=K;return null}}}return this.loopSn=void 0,W},Z.filterReplacedPrimary=function Q(Y,J){if(!Y)return Y;if(VJ(this.hls.config));return Y},Z.mapToInitFragWhenRequired=function Q(Y){if(Y!=null&&Y.initSegment&&!(Y!=null&&Y.initSegment.data)&&!this.bitrateTest)return Y.initSegment;return Y},Z.getNextPart=function Q(Y,J,X){var z=-1,N=!1,W=!0;for(var G=0,K=Y.length;G<K;G++){var j=Y[G];if(W=W&&!j.independent,z>-1&&X<j.start)break;var V=j.loaded;if(V)z=-1;else if((N||j.independent||W)&&j.fragment===J)z=G;N=V}return z},Z.loadedEndOfParts=function Q(Y,J){var X=Y[Y.length-1];return X&&J>X.start&&X.loaded},Z.getInitialLiveFragment=function Q(Y,J){var X=this.fragPrevious,z=null;if(X){if(Y.hasProgramDateTime)this.log("Live playlist, switching playlist, load frag with same PDT: "+X.programDateTime),z=x8(J,X.endProgramDateTime,this.config.maxFragLookUpTolerance);if(!z){var N=X.sn+1;if(N>=Y.startSN&&N<=Y.endSN){var W=J[N-Y.startSN];if(X.cc===W.cc)z=W,this.log("Live playlist, switching playlist, load frag with next SN: "+z.sn)}if(!z){if(z=k8(J,X.cc),z)this.log("Live playlist, switching playlist, load frag with same CC: "+z.sn)}}}else{var G=this.hls.liveSyncPosition;if(G!==null)z=this.getFragmentAtPosition(G,this.bitrateTest?Y.fragmentEnd:Y.edge,Y)}return z},Z.getFragmentAtPosition=function Q(Y,J,X){var z=this.config,N=this.fragPrevious,W=X.fragments,G=X.endSN,K=X.fragmentHint,j=z.maxFragLookUpTolerance,V=X.partList,U=!!(this.loadingParts&&V!=null&&V.length&&K);if(U&&K&&!this.bitrateTest&&V[V.length-1].fragment.sn===K.sn)W=W.concat(K),G=K.sn;var A;if(Y<J){var E,B=Y<this.lastCurrentTime,F=B||Y>J-j||(E=this.media)!=null&&E.paused||!this.startFragRequested?0:j;A=Y7(N,W,Y,F)}else A=W[W.length-1];if(A){var R=A.sn-X.startSN,O=this.fragmentTracker.getState(A);if(O===w0.OK||O===w0.PARTIAL&&A.gap)N=A;if(N&&A.sn===N.sn&&(!U||V[0].fragment.sn>A.sn||!X.live&&!U)){var M=N&&A.level===N.level;if(M){var L=W[R+1];if(A.sn<G&&this.fragmentTracker.getState(L)!==w0.OK)A=L;else A=null}}}return A},Z.alignPlaylists=function Q(Y,J,X){var z=Y.fragments.length;if(!z)return this.warn("No fragments in live playlist"),0;var N=Y.fragmentStart,W=!J,G=Y.alignedSliding&&v(N);if(W||!G&&!N){L9(X,Y);var K=Y.fragmentStart;return this.log("Live playlist sliding: "+K.toFixed(2)+" start-sn: "+(J?J.startSN:"na")+"->"+Y.startSN+" fragments: "+z),K}return N},Z.waitForCdnTuneIn=function Q(Y){var J=3;return Y.live&&Y.canBlockReload&&Y.partTarget&&Y.tuneInGoal>Math.max(Y.partHoldBack,Y.partTarget*J)},Z.setStartPosition=function Q(Y,J){var X=this.startPosition;if(X<J)X=-1;var z=this.timelineOffset;if(X===-1){var N=this.startTimeOffset!==null,W=N?this.startTimeOffset:Y.startTimeOffset;if(W!==null&&v(W)){if(X=J+W,W<0)X+=Y.edge;X=Math.min(Math.max(J,X),J+Y.totalduration),this.log("Setting startPosition to "+X+" for start time offset "+W+" found in "+(N?"multivariant":"media")+" playlist"),this.startPosition=X}else if(Y.live)X=this.hls.liveSyncPosition||J,this.log("Setting startPosition to -1 to start at live edge "+X),this.startPosition=-1;else this.log("setting startPosition to 0 by default"),this.startPosition=X=0;this.lastCurrentTime=X+z}this.nextLoadPosition=X+z},Z.getLoadPosition=function Q(){var Y,J=this.media,X=0;if((Y=this.hls)!=null&&Y.hasEnoughToStart&&J)X=J.currentTime;else if(this.nextLoadPosition>=0)X=this.nextLoadPosition;return X},Z.handleFragLoadAborted=function Q(Y,J){if(this.transmuxer&&Y.type===this.playlistType&&h0(Y)&&Y.stats.aborted)this.warn("Fragment "+Y.sn+(J?" part "+J.index:"")+" of "+this.playlistLabel()+" "+Y.level+" was aborted"),this.resetFragmentLoading(Y)},Z.resetFragmentLoading=function Q(Y){if(!this.fragCurrent||!this.fragContextChanged(Y)&&this.state!==k.FRAG_LOADING_WAITING_RETRY)this.state=k.IDLE},Z.onFragmentOrKeyLoadError=function Q(Y,J){if(J.chunkMeta&&!J.frag){var X=this.getCurrentContext(J.chunkMeta);if(X)J.frag=X.frag}var z=J.frag;if(!z||z.type!==Y||!this.levels)return;if(this.fragContextChanged(z)){var N;this.warn("Frag load error must match current frag to retry "+z.url+" > "+((N=this.fragCurrent)==null?void 0:N.url));return}var W=J.details===D.FRAG_GAP;if(W)this.fragmentTracker.fragBuffered(z,!0);var G=J.errorAction,K=G||{},j=K.action,V=K.flags,U=K.retryCount,A=U===void 0?0:U,E=K.retryConfig,B=!!G&&!!E,F=B&&j===F0.RetryRequest,R=B&&!G.resolved&&V===y0.MoveAllAlternatesMatchingHost;if(!F&&R&&h0(z)&&!z.endList)this.resetFragmentErrors(Y),this.treatAsGap(z),G.resolved=!0;else if((F||R)&&A<E.maxNumRetry){this.resetStartWhenNotLoaded(this.levelLastLoaded);var O=Q7(E,A);this.warn("Fragment "+z.sn+" of "+Y+" "+z.level+" errored with "+J.details+", retrying loading "+(A+1)+"/"+E.maxNumRetry+" in "+O+"ms"),G.resolved=!0,this.retryDate=self.performance.now()+O,this.state=k.FRAG_LOADING_WAITING_RETRY}else if(E&&G)if(this.resetFragmentErrors(Y),A<E.maxNumRetry){if(!W&&j!==F0.RemoveAlternatePermanently)G.resolved=!0}else{this.warn(J.details+" reached or exceeded max retry ("+A+")");return}else if(j===F0.SendAlternateToPenaltyBox)this.state=k.WAITING_LEVEL;else this.state=k.ERROR;this.tickImmediate()},Z.reduceLengthAndFlushBuffer=function Q(Y){if(this.state===k.PARSING||this.state===k.PARSED){var{frag:J,parent:X}=Y,z=this.getFwdBufferInfo(this.mediaBuffer,X),N=z&&z.len>0.5;if(N)this.reduceMaxBufferLength(z.len,(J==null?void 0:J.duration)||10);var W=!N;if(W)this.warn("Buffer full error while media.currentTime is not buffered, flush "+X+" buffer");if(J)this.fragmentTracker.removeFragment(J),this.nextLoadPosition=J.start;return this.resetLoadingState(),W}return!1},Z.resetFragmentErrors=function Q(Y){if(Y===d.AUDIO)this.fragCurrent=null;if(!this.hls.hasEnoughToStart)this.startFragRequested=!1;if(this.state!==k.STOPPED)this.state=k.IDLE},Z.afterBufferFlushed=function Q(Y,J,X){if(!Y)return;var z=i.getBuffered(Y);if(this.fragmentTracker.detectEvictedFragments(J,z,X),this.state===k.ENDED)this.resetLoadingState()},Z.resetLoadingState=function Q(){if(this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==k.STOPPED)this.state=k.IDLE},Z.resetStartWhenNotLoaded=function Q(Y){if(!this.hls.hasEnoughToStart){this.startFragRequested=!1;var J=Y?Y.details:null;if(J!=null&&J.live)this.log("resetting startPosition for live start"),this.startPosition=-1,this.setStartPosition(J,J.fragmentStart),this.resetLoadingState();else this.nextLoadPosition=this.startPosition}},Z.resetWhenMissingContext=function Q(Y){this.warn("The loading context changed while buffering fragment "+Y.sn+" of "+this.playlistLabel()+" "+Y.level+". This chunk will not be buffered."),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()},Z.removeUnbufferedFrags=function Q(Y){if(Y===void 0)Y=0;this.fragmentTracker.removeFragmentsInRange(Y,1/0,this.playlistType,!1,!0)},Z.updateLevelTiming=function Q(Y,J,X,z){var N=this,W=X.details;if(!W){this.warn("level.details undefined");return}var G=Object.keys(Y.elementaryStreams).reduce(function(V,U){var A=Y.elementaryStreams[U];if(A){var E=A.endPTS-A.startPTS;if(E<=0)return N.warn("Could not parse fragment "+Y.sn+" "+U+" duration reliably ("+E+")"),V||!1;var B=z?0:PQ(W,Y,A.startPTS,A.endPTS,A.startDTS,A.endDTS);return N.hls.trigger($.LEVEL_PTS_UPDATED,{details:W,level:X,drift:B,type:U,frag:Y,start:A.startPTS,end:A.endPTS}),!0}return V},!1);if(!G){var K;if(X.fragmentError===0)this.treatAsGap(Y,X);if(((K=this.transmuxer)==null?void 0:K.error)===null){var j=new Error("Found no media in fragment "+Y.sn+" of "+this.playlistLabel()+" "+Y.level+" resetting transmuxer to fallback to playlist timing");if(this.warn(j.message),this.hls.trigger($.ERROR,{type:f.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,error:j,frag:Y,reason:"Found no media in msn "+Y.sn+" of "+this.playlistLabel()+' "'+X.url+'"'}),!this.hls)return;this.resetTransmuxer()}}this.state=k.PARSED,this.log("Parsed "+Y.type+" sn: "+Y.sn+(J?" part: "+J.index:"")+" of "+this.fragInfo(Y,!1,J)+")"),this.hls.trigger($.FRAG_PARSED,{frag:Y,part:J})},Z.playlistLabel=function Q(){return this.playlistType===d.MAIN?"level":"track"},Z.fragInfo=function Q(Y,J,X){var z,N;if(J===void 0)J=!0;return this.playlistLabel()+" "+Y.level+" ("+(X?"part":"frag")+":["+((z=J&&!X?Y.startPTS:(X||Y).start)!=null?z:NaN).toFixed(3)+"-"+((N=J&&!X?Y.endPTS:(X||Y).end)!=null?N:NaN).toFixed(3)+"]"+(X&&Y.type==="main"?"INDEPENDENT="+(X.independent?"YES":"NO"):"")},Z.treatAsGap=function Q(Y,J){if(J)J.fragmentError++;Y.gap=!0,this.fragmentTracker.removeFragment(Y),this.fragmentTracker.fragBuffered(Y,!0)},Z.resetTransmuxer=function Q(){var Y;(Y=this.transmuxer)==null||Y.reset()},Z.recoverWorkerError=function Q(Y){if(Y.event==="demuxerWorker"){if(this.fragmentTracker.removeAllFragments(),this.transmuxer)this.transmuxer.destroy(),this.transmuxer=null;this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()}},q0(H,[{key:"startPositionValue",get:function Q(){var Y=this.nextLoadPosition,J=this.startPosition;if(J===-1&&Y)return Y;return J}},{key:"bufferingEnabled",get:function Q(){return this.buffering}},{key:"inFlightFrag",get:function Q(){return{frag:this.fragCurrent,state:this.state}}},{key:"timelineOffset",get:function Q(){var Y=this.config.timelineOffset;if(Y){var J;return((J=this.getLevelDetails())==null?void 0:J.appliedTimelineOffset)||Y}return 0}},{key:"primaryPrefetch",get:function Q(){if(VJ(this.hls.config));return!1}},{key:"state",get:function Q(){return this._state},set:function Q(Y){var J=this._state;if(J!==Y)this._state=Y,this.log(J+"->"+Y)}}])}(GJ);function VJ(q){return!1}function GY(q,H,Z){YY(q,H,Z),q.addEventListener(H,Z)}function YY(q,H,Z){q.removeEventListener(H,Z)}var yY=2,S9=0.1,x9=0.05,T9=100,y9=function(q){function H(Q,Y){var J=q.call(this,"gap-controller",Q.logger)||this;return J.hls=null,J.fragmentTracker=null,J.media=null,J.mediaSource=void 0,J.nudgeRetry=0,J.stallReported=!1,J.stalled=null,J.moved=!1,J.seeking=!1,J.buffered={},J.lastCurrentTime=0,J.ended=0,J.waiting=0,J.onMediaPlaying=function(){J.ended=0,J.waiting=0},J.onMediaWaiting=function(){var X;if((X=J.media)!=null&&X.seeking)return;J.waiting=self.performance.now(),J.tick()},J.onMediaEnded=function(){if(J.hls){var X;J.ended=((X=J.media)==null?void 0:X.currentTime)||1,J.hls.trigger($.MEDIA_ENDED,{stalled:!1})}},J.hls=Q,J.fragmentTracker=Y,J.registerListeners(),J}j0(H,q);var Z=H.prototype;return Z.registerListeners=function Q(){var Y=this.hls;if(Y)Y.on($.MEDIA_ATTACHED,this.onMediaAttached,this),Y.on($.MEDIA_DETACHING,this.onMediaDetaching,this),Y.on($.BUFFER_APPENDED,this.onBufferAppended,this)},Z.unregisterListeners=function Q(){var Y=this.hls;if(Y)Y.off($.MEDIA_ATTACHED,this.onMediaAttached,this),Y.off($.MEDIA_DETACHING,this.onMediaDetaching,this),Y.off($.BUFFER_APPENDED,this.onBufferAppended,this)},Z.destroy=function Q(){q.prototype.destroy.call(this),this.unregisterListeners(),this.media=this.hls=this.fragmentTracker=null,this.mediaSource=void 0},Z.onMediaAttached=function Q(Y,J){this.setInterval(T9),this.mediaSource=J.mediaSource;var X=this.media=J.media;GY(X,"playing",this.onMediaPlaying),GY(X,"waiting",this.onMediaWaiting),GY(X,"ended",this.onMediaEnded)},Z.onMediaDetaching=function Q(Y,J){this.clearInterval();var X=this.media;if(X)YY(X,"playing",this.onMediaPlaying),YY(X,"waiting",this.onMediaWaiting),YY(X,"ended",this.onMediaEnded),this.media=null;this.mediaSource=void 0},Z.onBufferAppended=function Q(Y,J){this.buffered=J.timeRanges},Z.tick=function Q(){var Y;if(!((Y=this.media)!=null&&Y.readyState)||!this.hasBuffered)return;var J=this.media.currentTime;this.poll(J,this.lastCurrentTime),this.lastCurrentTime=J},Z.poll=function Q(Y,J){var X,z,N=(X=this.hls)==null?void 0:X.config;if(!N)return;var W=this.media,G=this.stalled;if(!W)return;var K=W.seeking,j=this.seeking&&!K,V=!this.seeking&&K,U=W.paused&&!K||W.ended||W.playbackRate===0;if(this.seeking=K,Y!==J){if(J)this.ended=0;if(this.moved=!0,!K){if(this.nudgeRetry=0,N.nudgeOnVideoHole&&!U&&Y>J)this.nudgeOnVideoHole(Y,J)}if(this.waiting===0)this.stallResolved(Y);return}if(V||j){if(j)this.stallResolved(Y);return}if(U){if(this.nudgeRetry=0,this.stallResolved(Y),!this.ended&&W.ended&&this.hls)this.ended=Y||1,this.hls.trigger($.MEDIA_ENDED,{stalled:!1});return}if(!i.getBuffered(W).length){this.nudgeRetry=0;return}var A=i.bufferInfo(W,Y,0),E=A.nextStart||0,B=this.fragmentTracker;if(K&&B&&this.hls){var F=AJ(this.hls.inFlightFragments,Y),R=A.len>yY,O=!E||F||E-Y>yY&&!B.getPartialFragment(Y);if(R||O)return;this.moved=!1}var M=(z=this.hls)==null?void 0:z.latestLevelDetails;if(!this.moved&&this.stalled!==null&&B){var L=A.len>0;if(!L&&!E)return;var I=Math.max(E,A.start||0)-Y,w=!!(M!=null&&M.live),S=w?M.targetduration*2:yY,P=B.getPartialFragment(Y);if(I>0&&(I<=S||P)){if(!W.paused)this._trySkipBufferHole(P);return}}var b=N.detectStallWithCurrentTimeMs,C=self.performance.now(),x=this.waiting;if(G===null){if(x>0&&C-x<b)this.stalled=x;else this.stalled=C;return}var _=C-G;if(!K&&(_>=b||x)&&this.hls){var y;if(((y=this.mediaSource)==null?void 0:y.readyState)==="ended"&&!(M!=null&&M.live)&&Math.abs(Y-((M==null?void 0:M.edge)||0))<1){if(this.ended)return;this.ended=Y||1,this.hls.trigger($.MEDIA_ENDED,{stalled:!0});return}if(this._reportStall(A),!this.media||!this.hls)return}var T=i.bufferInfo(W,Y,N.maxBufferHole);this._tryFixBufferStall(T,_)},Z.stallResolved=function Q(Y){var J=this.stalled;if(J&&this.hls){if(this.stalled=null,this.stallReported){var X=self.performance.now()-J;this.log("playback not stuck anymore @"+Y+", after "+Math.round(X)+"ms"),this.stallReported=!1,this.waiting=0,this.hls.trigger($.STALL_RESOLVED,{})}}},Z.nudgeOnVideoHole=function Q(Y,J){var X,z=this.buffered.video;if(this.hls&&this.media&&this.fragmentTracker&&(X=this.buffered.audio)!=null&&X.length&&z&&z.length>1&&Y>z.end(0)){var N=i.bufferedInfo(i.timeRangesToArray(this.buffered.audio),Y,0);if(N.len>1&&J>=N.start){var W=i.timeRangesToArray(z),G=i.bufferedInfo(W,J,0).bufferedIndex;if(G>-1&&G<W.length-1){var K=i.bufferedInfo(W,Y,0).bufferedIndex,j=W[G].end,V=W[G+1].start;if((K===-1||K>G)&&V-j<1&&Y-j<2){var U=new Error("nudging playhead to flush pipeline after video hole. currentTime: "+Y+" hole: "+j+" -> "+V+" buffered index: "+K);this.warn(U.message),this.media.currentTime+=0.000001;var A=this.fragmentTracker.getPartialFragment(Y)||void 0,E=i.bufferInfo(this.media,Y,0);this.hls.trigger($.ERROR,{type:f.MEDIA_ERROR,details:D.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:U,reason:U.message,frag:A,buffer:E.len,bufferInfo:E})}}}}},Z._tryFixBufferStall=function Q(Y,J){var X,z,N=this.fragmentTracker,W=this.media,G=(X=this.hls)==null?void 0:X.config;if(!W||!N||!G)return;var K=W.currentTime,j=(z=this.hls)==null?void 0:z.latestLevelDetails,V=N.getPartialFragment(K);if(V||j!=null&&j.live&&K<j.fragmentStart){var U=this._trySkipBufferHole(V);if(U||!this.media)return}var A=Y.buffered;if((A&&A.length>1&&Y.len>G.maxBufferHole||Y.nextStart&&Y.nextStart-K<G.maxBufferHole)&&(J>G.highBufferWatchdogPeriod*1000||this.waiting))this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(Y)},Z._reportStall=function Q(Y){var J=this.hls,X=this.media,z=this.stallReported,N=this.stalled;if(!z&&N!==null&&X&&J){this.stallReported=!0;var W=new Error("Playback stalling at @"+X.currentTime+" due to low buffer ("+M0(Y)+")");this.warn(W.message),J.trigger($.ERROR,{type:f.MEDIA_ERROR,details:D.BUFFER_STALLED_ERROR,fatal:!1,error:W,buffer:Y.len,bufferInfo:Y,stalled:{start:N}})}},Z._trySkipBufferHole=function Q(Y){var J,X=this.fragmentTracker,z=this.media,N=(J=this.hls)==null?void 0:J.config;if(!z||!X||!N)return 0;var W=z.currentTime,G=i.bufferInfo(z,W,0),K=W<G.start?G.start:G.nextStart;if(K&&this.hls){var j=G.len<=N.maxBufferHole,V=G.len>0&&G.len<1&&z.readyState<3,U=K-W;if(U>0&&(j||V)){if(U>N.maxBufferHole){var A=!1;if(W===0){var E=X.getAppendedFrag(0,d.MAIN);if(E&&K<E.end)A=!0}if(!A){var B=Y||X.getAppendedFrag(W,d.MAIN);if(B){var F;if(!((F=this.hls.loadLevelObj)!=null&&F.details))return 0;var R=AJ(this.hls.inFlightFragments,K);if(R)return 0;var O=!1,M=B.end;while(M<K){var L=X.getPartialFragment(M);if(L)M+=L.duration;else{O=!0;break}}if(O)return 0}}}var I=Math.max(K+x9,W+S9);if(this.warn("skipping hole, adjusting currentTime from "+W+" to "+I),this.moved=!0,z.currentTime=I,!(Y!=null&&Y.gap)){var w=new Error("fragment loaded with buffer holes, seeking from "+W+" to "+I);this.hls.trigger($.ERROR,{type:f.MEDIA_ERROR,details:D.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:w,reason:w.message,frag:Y||void 0,buffer:G.len,bufferInfo:G})}return I}}return 0},Z._tryNudgeBuffer=function Q(Y){var J=this.hls,X=this.media,z=this.nudgeRetry,N=J==null?void 0:J.config;if(!X||!N)return 0;var W=X.currentTime;if(this.nudgeRetry++,z<N.nudgeMaxRetry){var G=W+(z+1)*N.nudgeOffset,K=new Error("Nudging 'currentTime' from "+W+" to "+G);this.warn(K.message),X.currentTime=G,J.trigger($.ERROR,{type:f.MEDIA_ERROR,details:D.BUFFER_NUDGE_ON_STALL,error:K,fatal:!1,buffer:Y.len,bufferInfo:Y})}else{var j=new Error("Playhead still not moving while enough data buffered @"+W+" after "+N.nudgeMaxRetry+" nudges");this.error(j.message),J.trigger($.ERROR,{type:f.MEDIA_ERROR,details:D.BUFFER_STALLED_ERROR,error:j,fatal:!0,buffer:Y.len,bufferInfo:Y})}},q0(H,[{key:"hasBuffered",get:function Q(){return Object.keys(this.buffered).length>0}}])}(GJ);function AJ(q,H){var Z=EJ(q.main);if(Z&&Z.start<=H)return Z;var Q=EJ(q.audio);if(Q&&Q.start<=H)return Q;return null}function EJ(q){if(!q)return null;switch(q.state){case k.IDLE:case k.STOPPED:case k.ENDED:case k.ERROR:return null}return q.frag}function k9(q,H){var Z;try{Z=new Event("addtrack")}catch(Q){Z=document.createEvent("Event"),Z.initEvent("addtrack",!1,!1)}Z.track=q,H.dispatchEvent(Z)}function _9(q,H){var Z=q.mode;if(Z==="disabled")q.mode="hidden";if(q.cues)for(var Q=q.cues.length;Q--;){if(H)q.cues[Q].removeEventListener("enter",H);q.removeCue(q.cues[Q])}if(Z==="disabled")q.mode=Z}function h9(q,H,Z,Q){var Y=q.mode;if(Y==="disabled")q.mode="hidden";if(q.cues&&q.cues.length>0){var J=g9(q.cues,H,Z);for(var X=0;X<J.length;X++)if(!Q||Q(J[X]))q.removeCue(J[X])}if(Y==="disabled")q.mode=Y}function v9(q,H){if(H<=q[0].startTime)return 0;var Z=q.length-1;if(H>q[Z].endTime)return-1;var Q=0,Y=Z,J;while(Q<=Y)if(J=Math.floor((Y+Q)/2),H<q[J].startTime)Y=J-1;else if(H>q[J].startTime&&Q<Z)Q=J+1;else return J;return q[Q].startTime-H<H-q[Y].startTime?Q:Y}function g9(q,H,Z){var Q=[],Y=v9(q,H);if(Y>-1)for(var J=Y,X=q.length;J<X;J++){var z=q[J];if(z.startTime>=H&&z.endTime<=Z)Q.push(z);else if(z.startTime>Z)return Q}return Q}var m9=0.25;function F7(){if(typeof self==="undefined")return;return self.VTTCue||self.TextTrackCue}function BJ(q,H,Z,Q,Y){var J=new q(H,Z,"");try{if(J.value=Q,Y)J.type=Y}catch(X){J=new q(H,Z,M0(Y?I0({type:Y},Q):Q))}return J}var kY=function(){var q=F7();try{q&&new q(0,Number.POSITIVE_INFINITY,"")}catch(H){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function p9(q){return Uint8Array.from(q.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var u9=function(){function q(Z){var Q=this;this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=!0,this.onEventCueEnter=function(){if(!Q.hls)return;Q.hls.trigger($.EVENT_CUE_ENTER,{})},this.hls=Z,this._registerListeners()}var H=q.prototype;return H.destroy=function Z(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null},H._registerListeners=function Z(){var Q=this.hls;Q.on($.MEDIA_ATTACHING,this.onMediaAttaching,this),Q.on($.MEDIA_ATTACHED,this.onMediaAttached,this),Q.on($.MEDIA_DETACHING,this.onMediaDetaching,this),Q.on($.MANIFEST_LOADING,this.onManifestLoading,this),Q.on($.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),Q.on($.BUFFER_FLUSHING,this.onBufferFlushing,this),Q.on($.LEVEL_UPDATED,this.onLevelUpdated,this),Q.on($.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this)},H._unregisterListeners=function Z(){var Q=this.hls;Q.off($.MEDIA_ATTACHING,this.onMediaAttaching,this),Q.off($.MEDIA_ATTACHED,this.onMediaAttached,this),Q.off($.MEDIA_DETACHING,this.onMediaDetaching,this),Q.off($.MANIFEST_LOADING,this.onManifestLoading,this),Q.off($.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),Q.off($.BUFFER_FLUSHING,this.onBufferFlushing,this),Q.off($.LEVEL_UPDATED,this.onLevelUpdated,this),Q.off($.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this)},H.onMediaAttaching=function Z(Q,Y){var J;if(this.media=Y.media,((J=Y.overrides)==null?void 0:J.cueRemoval)===!1)this.removeCues=!1},H.onMediaAttached=function Z(){var Q=this.hls.latestLevelDetails;if(Q)this.updateDateRangeCues(Q)},H.onMediaDetaching=function Z(Q,Y){this.media=null;var J=!!Y.transferMedia;if(J)return;if(this.id3Track){if(this.removeCues)_9(this.id3Track,this.onEventCueEnter);this.id3Track=null}this.dateRangeCuesAppended={}},H.onManifestLoading=function Z(){this.dateRangeCuesAppended={}},H.createTrack=function Z(Q){var Y=this.getID3Track(Q.textTracks);return Y.mode="hidden",Y},H.getID3Track=function Z(Q){if(!this.media)return;for(var Y=0;Y<Q.length;Y++){var J=Q[Y];if(J.kind==="metadata"&&J.label==="id3")return k9(J,this.media),J}return this.media.addTextTrack("metadata","id3")},H.onFragParsingMetadata=function Z(Q,Y){if(!this.media)return;var J=this.hls.config,X=J.enableEmsgMetadataCues,z=J.enableID3MetadataCues;if(!X&&!z)return;var N=Y.samples;if(!this.id3Track)this.id3Track=this.createTrack(this.media);var W=F7();if(!W)return;for(var G=0;G<N.length;G++){var K=N[G].type;if(K===D0.emsg&&!X||!z)continue;var j=fQ(N[G].data);if(j){var V=N[G].pts,U=V+N[G].duration;if(U>kY)U=kY;var A=U-V;if(A<=0)U=V+m9;for(var E=0;E<j.length;E++){var B=j[E];if(!dQ(B)){this.updateId3CueEnds(V,K);var F=BJ(W,V,U,B,K);if(F)this.id3Track.addCue(F)}}}}},H.updateId3CueEnds=function Z(Q,Y){var J,X=(J=this.id3Track)==null?void 0:J.cues;if(X)for(var z=X.length;z--;){var N=X[z];if(N.type===Y&&N.startTime<Q&&N.endTime===kY)N.endTime=Q}},H.onBufferFlushing=function Z(Q,Y){var{startOffset:J,endOffset:X,type:z}=Y,N=this.id3Track,W=this.hls;if(!W)return;var G=W.config,K=G.enableEmsgMetadataCues,j=G.enableID3MetadataCues;if(N&&(K||j)){var V;if(z==="audio")V=function U(A){return A.type===D0.audioId3&&j};else if(z==="video")V=function U(A){return A.type===D0.emsg&&K};else V=function U(A){return A.type===D0.audioId3&&j||A.type===D0.emsg&&K};h9(N,J,X,V)}},H.onLevelUpdated=function Z(Q,Y){var J=Y.details;this.updateDateRangeCues(J,!0)},H.onLevelPtsUpdated=function Z(Q,Y){if(Math.abs(Y.drift)>0.01)this.updateDateRangeCues(Y.details)},H.updateDateRangeCues=function Z(Q,Y){var J=this;if(!this.media||!Q.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;var X=this.id3Track,z=Q.dateRanges,N=Object.keys(z),W=this.dateRangeCuesAppended;if(X&&Y){var G;if((G=X.cues)!=null&&G.length){var K=Object.keys(W).filter(function(F){return!N.includes(F)}),j=function F(){var R=K[V],O=W[R].cues;delete W[R],Object.keys(O).forEach(function(M){try{var L=O[M];L.removeEventListener("enter",J.onEventCueEnter),X.removeCue(L)}catch(I){}})};for(var V=K.length;V--;)j()}else W=this.dateRangeCuesAppended={}}var U=Q.fragments[Q.fragments.length-1];if(N.length===0||!v(U==null?void 0:U.programDateTime))return;if(!this.id3Track)this.id3Track=this.createTrack(this.media);var A=F7(),E=function F(){var R=N[B],O=z[R],M=O.startTime,L=W[R],I=(L==null?void 0:L.cues)||{},w=(L==null?void 0:L.durationKnown)||!1,S=kY,P=O.duration,b=O.endDate;if(b&&P!==null)S=M+P,w=!0;else if(O.endOnNext&&!w){var C=N.reduce(function(p,r){if(r!==O.id){var n=z[r];if(n.class===O.class&&n.startDate>O.startDate&&(!p||O.startDate<p.startDate))return n}return p},null);if(C)S=C.startTime,w=!0}var x=Object.keys(O.attr);for(var _=0;_<x.length;_++){var y=x[_];if(!f8(y))continue;var T=I[y];if(T){if(w&&!L.durationKnown)T.endTime=S;else if(Math.abs(T.startTime-M)>0.01)T.startTime=M,T.endTime=S}else if(A){var h=O.attr[y];if(d8(y))h=p9(h);var g={key:y,data:h},m=BJ(A,M,S,g,D0.dateRange);if(m)m.id=R,J.id3Track.addCue(m),I[y]=m}}W[R]={cues:I,dateRange:O,durationKnown:w}};for(var B=0;B<N.length;B++)E()},q}(),c9=function(){function q(Z){var Q=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{media:Y,levelDetails:J}=Q;if(!Y||!J)return;Q.currentTime=Y.currentTime;var X=Q.computeLatency();if(X===null)return;Q._latency=X;var z=Q.config,N=z.lowLatencyMode,W=z.maxLiveSyncPlaybackRate;if(!N||W===1||!J.live)return;var G=Q.targetLatency;if(G===null)return;var K=X-G,j=Math.min(Q.maxLatency,G+J.targetduration),V=K<j;if(V&&K>0.05&&Q.forwardBufferLength>1){var U=Math.min(2,Math.max(1,W)),A=Math.round(2/(1+Math.exp(-0.75*K-Q.edgeStalled))*20)/20,E=Math.min(U,Math.max(1,A));Q.changeMediaPlaybackRate(Y,E)}else if(Y.playbackRate!==1&&Y.playbackRate!==0)Q.changeMediaPlaybackRate(Y,1)},this.hls=Z,this.config=Z.config,this.registerListeners()}var H=q.prototype;return H.destroy=function Z(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null},H.registerListeners=function Z(){var Q=this.hls;if(!Q)return;Q.on($.MEDIA_ATTACHED,this.onMediaAttached,this),Q.on($.MEDIA_DETACHING,this.onMediaDetaching,this),Q.on($.MANIFEST_LOADING,this.onManifestLoading,this),Q.on($.LEVEL_UPDATED,this.onLevelUpdated,this),Q.on($.ERROR,this.onError,this)},H.unregisterListeners=function Z(){var Q=this.hls;if(!Q)return;Q.off($.MEDIA_ATTACHED,this.onMediaAttached,this),Q.off($.MEDIA_DETACHING,this.onMediaDetaching,this),Q.off($.MANIFEST_LOADING,this.onManifestLoading,this),Q.off($.LEVEL_UPDATED,this.onLevelUpdated,this),Q.off($.ERROR,this.onError,this)},H.onMediaAttached=function Z(Q,Y){this.media=Y.media,this.media.addEventListener("timeupdate",this.onTimeupdate)},H.onMediaDetaching=function Z(){if(this.media)this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null},H.onManifestLoading=function Z(){this._latency=null,this.stallCount=0},H.onLevelUpdated=function Z(Q,Y){var J=Y.details;if(J.advanced)this.onTimeupdate();if(!J.live&&this.media)this.media.removeEventListener("timeupdate",this.onTimeupdate)},H.onError=function Z(Q,Y){var J;if(Y.details!==D.BUFFER_STALLED_ERROR)return;if(this.stallCount++,this.hls&&(J=this.levelDetails)!=null&&J.live)this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency")},H.changeMediaPlaybackRate=function Z(Q,Y){var J,X;if(Q.playbackRate===Y)return;(J=this.hls)==null||J.logger.debug("[latency-controller]: latency="+this.latency.toFixed(3)+", targetLatency="+((X=this.targetLatency)==null?void 0:X.toFixed(3))+", forwardBufferLength="+this.forwardBufferLength.toFixed(3)+": adjusting playback rate from "+Q.playbackRate+" to "+Y),Q.playbackRate=Y},H.estimateLiveEdge=function Z(){var Q=this.levelDetails;if(Q===null)return null;return Q.edge+Q.age},H.computeLatency=function Z(){var Q=this.estimateLiveEdge();if(Q===null)return null;return Q-this.currentTime},q0(q,[{key:"levelDetails",get:function Z(){var Q;return((Q=this.hls)==null?void 0:Q.latestLevelDetails)||null}},{key:"latency",get:function Z(){return this._latency||0}},{key:"maxLatency",get:function Z(){var Q=this.config;if(Q.liveMaxLatencyDuration!==void 0)return Q.liveMaxLatencyDuration;var Y=this.levelDetails;return Y?Q.liveMaxLatencyDurationCount*Y.targetduration:0}},{key:"targetLatency",get:function Z(){var Q=this.levelDetails;if(Q===null||this.hls===null)return null;var{holdBack:Y,partHoldBack:J,targetduration:X}=Q,z=this.config,N=z.liveSyncDuration,W=z.liveSyncDurationCount,G=z.lowLatencyMode,K=this.hls.userConfig,j=G?J||Y:Y;if(this._targetLatencyUpdated||K.liveSyncDuration||K.liveSyncDurationCount||j===0)j=N!==void 0?N:W*X;var V=X;return j+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,V)},set:function Z(Q){this.stallCount=0,this.config.liveSyncDuration=Q,this._targetLatencyUpdated=!0}},{key:"liveSyncPosition",get:function Z(){var Q=this.estimateLiveEdge(),Y=this.targetLatency;if(Q===null||Y===null)return null;var J=this.levelDetails;if(J===null)return null;var X=J.edge,z=Q-Y-this.edgeStalled,N=X-J.totalduration,W=X-(this.config.lowLatencyMode&&J.partTarget||J.targetduration);return Math.min(Math.max(N,z),W)}},{key:"drift",get:function Z(){var Q=this.levelDetails;if(Q===null)return 1;return Q.drift}},{key:"edgeStalled",get:function Z(){var Q=this.levelDetails;if(Q===null)return 0;var Y=(this.config.lowLatencyMode&&Q.partTarget||Q.targetduration)*3;return Math.max(Q.age-Y,0)}},{key:"forwardBufferLength",get:function Z(){var Q=this.media,Y=this.levelDetails;if(!Q||!Y)return 0;var J=Q.buffered.length;return(J?Q.buffered.end(J-1):Y.edge)-this.currentTime}}])}(),f9=function(q){function H(Q,Y){var J=q.call(this,Y,Q.logger)||this;return J.hls=void 0,J.canLoad=!1,J.timer=-1,J.hls=Q,J}j0(H,q);var Z=H.prototype;return Z.destroy=function Q(){this.clearTimer(),this.hls=this.log=this.warn=null},Z.clearTimer=function Q(){if(this.timer!==-1)self.clearTimeout(this.timer),this.timer=-1},Z.startLoad=function Q(){this.canLoad=!0,this.loadPlaylist()},Z.stopLoad=function Q(){this.canLoad=!1,this.clearTimer()},Z.switchParams=function Q(Y,J,X){var z=J==null?void 0:J.renditionReports;if(z){var N=-1;for(var W=0;W<z.length;W++){var G=z[W],K=void 0;try{K=new self.URL(G.URI,J.url).href}catch(B){this.warn("Could not construct new URL for Rendition Report: "+B),K=G.URI||""}if(K===Y){N=W;break}else if(K===Y.substring(0,K.length))N=W}if(N!==-1){var j=z[N],V=parseInt(j["LAST-MSN"])||(J==null?void 0:J.lastPartSn),U=parseInt(j["LAST-PART"])||(J==null?void 0:J.lastPartIndex);if(this.hls.config.lowLatencyMode){var A=Math.min(J.age-J.partTarget,J.targetduration);if(U>=0&&A>J.partTarget)U+=1}var E=X&&QQ(X);return new JQ(V,U>=0?U:void 0,E)}}},Z.loadPlaylist=function Q(Y){this.clearTimer()},Z.loadingPlaylist=function Q(Y,J){this.clearTimer()},Z.shouldLoadPlaylist=function Q(Y){return this.canLoad&&!!Y&&!!Y.url&&(!Y.details||Y.details.live)},Z.getUrlWithDirectives=function Q(Y,J){if(J)try{return J.addDirectives(Y)}catch(X){this.warn("Could not construct new URL with HLS Delivery Directives: "+X)}return Y},Z.playlistLoaded=function Q(Y,J,X){var{details:z,stats:N}=J,W=self.performance.now(),G=N.loading.first?Math.max(0,W-N.loading.first):0;z.advancedDateTime=Date.now()-G;var K=this.hls.config.timelineOffset;if(K!==z.appliedTimelineOffset){var j=Math.max(K||0,0);z.appliedTimelineOffset=j,z.fragments.forEach(function(p){p.start=p.playlistOffset+j})}if(z.live||X!=null&&X.live){var V="levelInfo"in J?J.levelInfo:J.track;if(z.reloaded(X),X&&z.fragments.length>0){e8(X,z);var U=z.playlistParsingError;if(U){this.warn(U);var A=this.hls;if(!A.config.ignorePlaylistParsingErrors){var E,B=J.networkDetails;A.trigger($.ERROR,{type:f.NETWORK_ERROR,details:D.LEVEL_PARSING_ERROR,fatal:!1,url:z.url,error:U,reason:U.message,level:J.level||void 0,parent:(E=z.fragments[0])==null?void 0:E.type,networkDetails:B,stats:N});return}z.playlistParsingError=null}}if(z.requestScheduled===-1)z.requestScheduled=N.loading.start;var F=this.hls.mainForwardBufferInfo,R=F?F.end-F.len:0,O=(z.edge-R)*1000,M=xQ(z,O);if(z.requestScheduled+M<W)z.requestScheduled=W;else z.requestScheduled+=M;if(this.log("live playlist "+Y+" "+(z.advanced?"REFRESHED "+z.lastPartSn+"-"+z.lastPartIndex:z.updated?"UPDATED":"MISSED")),!this.canLoad||!z.live)return;var L,I=void 0,w=void 0;if(z.canBlockReload&&z.endSN&&z.advanced){var S=this.hls.config.lowLatencyMode,P=z.lastPartSn,b=z.endSN,C=z.lastPartIndex,x=C!==-1,_=P===b;if(x)if(_)I=b+1,w=S?0:C;else I=P,w=S?C+1:z.maxPartIndex;else I=b+1;var y=z.age,T=y+z.ageHeader,h=Math.min(T-z.partTarget,z.targetduration*1.5);if(h>0){if(T>z.targetduration*3)this.log("Playlist last advanced "+y.toFixed(2)+"s ago. Omitting segment and part directives."),I=void 0,w=void 0;else if(X!=null&&X.tuneInGoal&&T-z.partTarget>X.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+X.tuneInGoal+" to: "+h+" with playlist age: "+z.age),h=0;else{var g=Math.floor(h/z.targetduration);if(I+=g,w!==void 0){var m=Math.round(h%z.targetduration/z.partTarget);w+=m}this.log("CDN Tune-in age: "+z.ageHeader+"s last advanced "+y.toFixed(2)+"s goal: "+h+" skip sn "+g+" to part "+w)}z.tuneInGoal=h}if(L=this.getDeliveryDirectives(z,J.deliveryDirectives,I,w),S||!_){z.requestScheduled=W,this.loadingPlaylist(V,L);return}}else if(z.canBlockReload||z.canSkipUntil)L=this.getDeliveryDirectives(z,J.deliveryDirectives,I,w);if(L&&I!==void 0&&z.canBlockReload)z.requestScheduled=N.loading.first+Math.max(M-G*2,M/2);this.scheduleLoading(V,L,z)}else this.clearTimer()},Z.scheduleLoading=function Q(Y,J,X){var z=this,N=X||Y.details;if(!N){this.loadingPlaylist(Y,J);return}var W=self.performance.now(),G=N.requestScheduled;if(W>=G){this.loadingPlaylist(Y,J);return}var K=G-W;this.log("reload live playlist "+(Y.name||Y.bitrate+"bps")+" in "+Math.round(K)+" ms"),this.clearTimer(),this.timer=self.setTimeout(function(){return z.loadingPlaylist(Y,J)},K)},Z.getDeliveryDirectives=function Q(Y,J,X,z){var N=QQ(Y);if(J!=null&&J.skip&&Y.deltaUpdateFailed)X=J.msn,z=J.part,N=RY.No;return new JQ(X,z,N)},Z.checkRetry=function Q(Y){var J=this,X=Y.details,z=MY(Y),N=Y.errorAction,W=N||{},G=W.action,K=W.retryCount,j=K===void 0?0:K,V=W.retryConfig,U=!!N&&!!V&&(G===F0.RetryRequest||!N.resolved&&G===F0.SendAlternateToPenaltyBox);if(U){var A;if(j>=V.maxNumRetry)return!1;if(z&&(A=Y.context)!=null&&A.deliveryDirectives)this.warn("Retrying playlist loading "+(j+1)+"/"+V.maxNumRetry+' after "'+X+'" without delivery-directives'),this.loadPlaylist();else{var E=Q7(V,j);this.clearTimer(),this.timer=self.setTimeout(function(){return J.loadPlaylist()},E),this.warn("Retrying playlist loading "+(j+1)+"/"+V.maxNumRetry+' after "'+X+'" in '+E+"ms")}Y.levelRetry=!0,N.resolved=!0}return U},H}(i0),d9=function(q){function H(Q,Y){var J=q.call(this,Q,"level-controller")||this;return J._levels=[],J._firstLevel=-1,J._maxAutoLevel=-1,J._startLevel=void 0,J.currentLevel=null,J.currentLevelIndex=-1,J.manualLevelIndex=-1,J.steering=void 0,J.onParsedComplete=void 0,J.steering=Y,J._registerListeners(),J}j0(H,q);var Z=H.prototype;return Z._registerListeners=function Q(){var Y=this.hls;Y.on($.MANIFEST_LOADING,this.onManifestLoading,this),Y.on($.MANIFEST_LOADED,this.onManifestLoaded,this),Y.on($.LEVEL_LOADED,this.onLevelLoaded,this),Y.on($.LEVELS_UPDATED,this.onLevelsUpdated,this),Y.on($.FRAG_BUFFERED,this.onFragBuffered,this),Y.on($.ERROR,this.onError,this)},Z._unregisterListeners=function Q(){var Y=this.hls;Y.off($.MANIFEST_LOADING,this.onManifestLoading,this),Y.off($.MANIFEST_LOADED,this.onManifestLoaded,this),Y.off($.LEVEL_LOADED,this.onLevelLoaded,this),Y.off($.LEVELS_UPDATED,this.onLevelsUpdated,this),Y.off($.FRAG_BUFFERED,this.onFragBuffered,this),Y.off($.ERROR,this.onError,this)},Z.destroy=function Q(){this._unregisterListeners(),this.steering=null,this.resetLevels(),q.prototype.destroy.call(this)},Z.stopLoad=function Q(){var Y=this._levels;Y.forEach(function(J){J.loadError=0,J.fragmentError=0}),q.prototype.stopLoad.call(this)},Z.resetLevels=function Q(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1},Z.onManifestLoading=function Q(Y,J){this.resetLevels()},Z.onManifestLoaded=function Q(Y,J){var X=this,z=this.hls.config.preferManagedMediaSource,N=[],W={},G={},K=!1,j=!1,V=!1;J.levels.forEach(function(U){var A,E=U.attrs,B=U.audioCodec,F=U.videoCodec;if(B)U.audioCodec=B=$Y(B,z)||void 0;if(((A=F)==null?void 0:A.indexOf("avc1"))===0)F=U.videoCodec=O8(F);var{width:R,height:O,unknownCodecs:M}=U,L=M?M.length:0;if(M)for(var I=L;I--;){var w=M[I];if(X.isAudioSupported(w))U.audioCodec=B=B?B+","+w:w,L--,r0.audio[B.substring(0,4)]=2;else if(X.isVideoSupported(w))U.videoCodec=F=F?F+","+w:w,L--,r0.video[F.substring(0,4)]=2}if(K||(K=!!(R&&O)),j||(j=!!F),V||(V=!!B),L||B&&!X.isAudioSupported(B)||F&&!X.isVideoSupported(F)){X.log('Some or all CODECS not supported "'+E.CODECS+'"');return}var S=E.CODECS,P=E["FRAME-RATE"],b=E["HDCP-LEVEL"],C=E["PATHWAY-ID"],x=E.RESOLUTION,_=E["VIDEO-RANGE"],y=(C||".")+"-",T=""+y+U.bitrate+"-"+x+"-"+P+"-"+S+"-"+_+"-"+b;if(!W[T]){var h=X.createLevel(U);W[T]=h,G[T]=1,N.push(h)}else if(W[T].uri!==U.url&&!U.attrs["PATHWAY-ID"]){var g=G[T]+=1;U.attrs["PATHWAY-ID"]=new Array(g+1).join(".");var m=X.createLevel(U);W[T]=m,N.push(m)}else W[T].addGroupId("audio",E.AUDIO),W[T].addGroupId("text",E.SUBTITLES)}),this.filterAndSortMediaOptions(N,J,K,j,V)},Z.createLevel=function Q(Y){var J=new ZQ(Y),X=Y.supplemental;if(X!=null&&X.videoCodec&&!this.isVideoSupported(X.videoCodec)){var z=new Error('SUPPLEMENTAL-CODECS not supported "'+X.videoCodec+'"');this.log(z.message),J.supportedResult=v7.getUnsupportedResult(z,[])}return J},Z.isAudioSupported=function Q(Y){return aY(Y,"audio",this.hls.config.preferManagedMediaSource)},Z.isVideoSupported=function Q(Y){return aY(Y,"video",this.hls.config.preferManagedMediaSource)},Z.filterAndSortMediaOptions=function Q(Y,J,X,z,N){var W=this,G=[],K=[],j=Y;if((X||z)&&N)j=j.filter(function(I){var{videoCodec:w,videoRange:S,width:P,height:b}=I;return(!!w||!!(P&&b))&&I8(S)});if(j.length===0){Promise.resolve().then(function(){if(W.hls){var I="no level with compatible codecs found in manifest",w=I;if(J.levels.length)w="one or more CODECS in variant not supported: "+M0(J.levels.map(function(P){return P.attrs.CODECS}).filter(function(P,b,C){return C.indexOf(P)===b})),W.warn(w),I+=" ("+w+")";var S=new Error(I);W.hls.trigger($.ERROR,{type:f.MEDIA_ERROR,details:D.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:J.url,error:S,reason:w})}});return}if(J.audioTracks)G=J.audioTracks.filter(function(I){return!I.audioCodec||W.isAudioSupported(I.audioCodec)}),$J(G);if(J.subtitles)K=J.subtitles,$J(K);var V=j.slice(0);j.sort(function(I,w){if(I.attrs["HDCP-LEVEL"]!==w.attrs["HDCP-LEVEL"])return(I.attrs["HDCP-LEVEL"]||"")>(w.attrs["HDCP-LEVEL"]||"")?1:-1;if(X&&I.height!==w.height)return I.height-w.height;if(I.frameRate!==w.frameRate)return I.frameRate-w.frameRate;if(I.videoRange!==w.videoRange)return OY.indexOf(I.videoRange)-OY.indexOf(w.videoRange);if(I.videoCodec!==w.videoCodec){var S=t7(I.videoCodec),P=t7(w.videoCodec);if(S!==P)return P-S}if(I.uri===w.uri&&I.codecSet!==w.codecSet){var b=BY(I.codecSet),C=BY(w.codecSet);if(b!==C)return C-b}if(I.averageBitrate!==w.averageBitrate)return I.averageBitrate-w.averageBitrate;return 0});var U=V[0];if(this.steering){if(j=this.steering.filterParsedLevels(j),j.length!==V.length){for(var A=0;A<V.length;A++)if(V[A].pathwayId===j[0].pathwayId){U=V[A];break}}}this._levels=j;for(var E=0;E<j.length;E++)if(j[E]===U){var B;this._firstLevel=E;var F=U.bitrate,R=this.hls.bandwidthEstimate;if(this.log("manifest loaded, "+j.length+" level(s) found, first bitrate: "+F),((B=this.hls.userConfig)==null?void 0:B.abrEwmaDefaultEstimate)===void 0){var O=Math.min(F,this.hls.config.abrEwmaDefaultEstimateMax);if(O>R&&R===this.hls.abrEwmaDefaultEstimate)this.hls.bandwidthEstimate=O}break}var M=N&&!z,L={levels:j,audioTracks:G,subtitleTracks:K,sessionData:J.sessionData,sessionKeys:J.sessionKeys,firstLevel:this._firstLevel,stats:J.stats,audio:N,video:z,altAudio:!M&&G.some(function(I){return!!I.url})};this.hls.trigger($.MANIFEST_PARSED,L)},Z.onError=function Q(Y,J){if(J.fatal||!J.context)return;if(J.context.type===o.LEVEL&&J.context.level===this.level)this.checkRetry(J)},Z.onFragBuffered=function Q(Y,J){var X=J.frag;if(X!==void 0&&X.type===d.MAIN){var z=X.elementaryStreams;if(!Object.keys(z).some(function(W){return!!z[W]}))return;var N=this._levels[X.level];if(N!=null&&N.loadError)this.log("Resetting level error count of "+N.loadError+" on frag buffered"),N.loadError=0}},Z.onLevelLoaded=function Q(Y,J){var X,z=J.level,N=J.details,W=J.levelInfo;if(!W){var G;if(this.warn("Invalid level index "+z),(G=J.deliveryDirectives)!=null&&G.skip)N.deltaUpdateFailed=!0;return}if(W===this.currentLevel||J.withoutMultiVariant){if(W.fragmentError===0)W.loadError=0;var K=W.details;if(K===J.details&&K.advanced)K=void 0;this.playlistLoaded(z,J,K)}else if((X=J.deliveryDirectives)!=null&&X.skip)N.deltaUpdateFailed=!0},Z.loadPlaylist=function Q(Y){if(q.prototype.loadPlaylist.call(this),this.shouldLoadPlaylist(this.currentLevel))this.scheduleLoading(this.currentLevel,Y)},Z.loadingPlaylist=function Q(Y,J){q.prototype.loadingPlaylist.call(this,Y,J);var X=this.getUrlWithDirectives(Y.uri,J),z=this.currentLevelIndex,N=Y.attrs["PATHWAY-ID"],W=Y.details,G=W==null?void 0:W.age;this.log("Loading level index "+z+((J==null?void 0:J.msn)!==void 0?" at sn "+J.msn+" part "+J.part:"")+(N?" Pathway "+N:"")+(G&&W.live?" age "+G.toFixed(1)+(W.type?" "+W.type||"":""):"")+" "+X),this.hls.trigger($.LEVEL_LOADING,{url:X,level:z,levelInfo:Y,pathwayId:Y.attrs["PATHWAY-ID"],id:0,deliveryDirectives:J||null})},Z.removeLevel=function Q(Y){var J=this,X;if(this._levels.length===1)return;var z=this._levels.filter(function(W,G){if(G!==Y)return!0;if(J.steering)J.steering.removeLevel(W);if(W===J.currentLevel){if(J.currentLevel=null,J.currentLevelIndex=-1,W.details)W.details.fragments.forEach(function(K){return K.level=-1})}return!1});if(kQ(z),this._levels=z,this.currentLevelIndex>-1&&(X=this.currentLevel)!=null&&X.details)this.currentLevelIndex=this.currentLevel.details.fragments[0].level;if(this.manualLevelIndex>-1)this.manualLevelIndex=this.currentLevelIndex;var N=z.length-1;if(this._firstLevel=Math.min(this._firstLevel,N),this._startLevel)this._startLevel=Math.min(this._startLevel,N);this.hls.trigger($.LEVELS_UPDATED,{levels:z})},Z.onLevelsUpdated=function Q(Y,J){var X=J.levels;this._levels=X},Z.checkMaxAutoUpdated=function Q(){var Y=this.hls,J=Y.autoLevelCapping,X=Y.maxAutoLevel,z=Y.maxHdcpLevel;if(this._maxAutoLevel!==X)this._maxAutoLevel=X,this.hls.trigger($.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:J,levels:this.levels,maxAutoLevel:X,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:z})},q0(H,[{key:"levels",get:function Q(){if(this._levels.length===0)return null;return this._levels}},{key:"loadLevelObj",get:function Q(){return this.currentLevel}},{key:"level",get:function Q(){return this.currentLevelIndex},set:function Q(Y){var J=this._levels;if(J.length===0)return;if(Y<0||Y>=J.length){var X=new Error("invalid level idx"),z=Y<0;if(this.hls.trigger($.ERROR,{type:f.OTHER_ERROR,details:D.LEVEL_SWITCH_ERROR,level:Y,fatal:z,error:X,reason:X.message}),z)return;Y=Math.min(Y,J.length-1)}var N=this.currentLevelIndex,W=this.currentLevel,G=W?W.attrs["PATHWAY-ID"]:void 0,K=J[Y],j=K.attrs["PATHWAY-ID"];if(this.currentLevelIndex=Y,this.currentLevel=K,N===Y&&W&&G===j)return;this.log("Switching to level "+Y+" ("+(K.height?K.height+"p ":"")+(K.videoRange?K.videoRange+" ":"")+(K.codecSet?K.codecSet+" ":"")+"@"+K.bitrate+")"+(j?" with Pathway "+j:"")+" from level "+N+(G?" with Pathway "+G:""));var V={level:Y,attrs:K.attrs,details:K.details,bitrate:K.bitrate,averageBitrate:K.averageBitrate,maxBitrate:K.maxBitrate,realBitrate:K.realBitrate,width:K.width,height:K.height,codecSet:K.codecSet,audioCodec:K.audioCodec,videoCodec:K.videoCodec,audioGroups:K.audioGroups,subtitleGroups:K.subtitleGroups,loaded:K.loaded,loadError:K.loadError,fragmentError:K.fragmentError,name:K.name,id:K.id,uri:K.uri,url:K.url,urlId:0,audioGroupIds:K.audioGroupIds,textGroupIds:K.textGroupIds};this.hls.trigger($.LEVEL_SWITCHING,V);var U=K.details;if(!U||U.live){var A=this.switchParams(K.uri,W==null?void 0:W.details,U);this.loadPlaylist(A)}}},{key:"manualLevel",get:function Q(){return this.manualLevelIndex},set:function Q(Y){if(this.manualLevelIndex=Y,this._startLevel===void 0)this._startLevel=Y;if(Y!==-1)this.level=Y}},{key:"firstLevel",get:function Q(){return this._firstLevel},set:function Q(Y){this._firstLevel=Y}},{key:"startLevel",get:function Q(){if(this._startLevel===void 0){var Y=this.hls.config.startLevel;if(Y!==void 0)return Y;return this.hls.firstAutoLevel}return this._startLevel},set:function Q(Y){this._startLevel=Y}},{key:"pathways",get:function Q(){if(this.steering)return this.steering.pathways();return[]}},{key:"pathwayPriority",get:function Q(){if(this.steering)return this.steering.pathwayPriority;return null},set:function Q(Y){if(this.steering){var J=this.steering.pathways(),X=Y.filter(function(z){return J.indexOf(z)!==-1});if(Y.length<1){this.warn("pathwayPriority "+Y+" should contain at least one pathway from list: "+J);return}this.steering.pathwayPriority=X}}},{key:"nextLoadLevel",get:function Q(){if(this.manualLevelIndex!==-1)return this.manualLevelIndex;else return this.hls.nextAutoLevel},set:function Q(Y){if(this.level=Y,this.manualLevelIndex===-1)this.hls.nextAutoLevel=Y}}])}(f9);function $J(q){var H={};q.forEach(function(Z){var Q=Z.groupId||"";Z.id=H[Q]=H[Q]||0,H[Q]++})}var O7=[];if(typeof H0!=="undefined"&&H0)l9();function l9(){self.addEventListener("message",function(q){var H=q.data,Z=H.instanceNo;if(Z===void 0)return;var Q=O7[Z];if(H.cmd==="reset"){if(delete O7[H.resetNo],Q)Q.destroy();H.cmd="init"}if(H.cmd==="init"){var Y=JSON.parse(H.config),J=new pY;J.on($.FRAG_DECRYPTED,QY),J.on($.ERROR,QY);var X=_7(Y.debug,H.id);n9(X,Z),O7[Z]=new E7(J,H.typeSupported,Y,"",H.id,X),QY("init",null,Z);return}if(!Q)return;switch(H.cmd){case"configure":{Q.configure(H.config);break}case"demux":{var z=Q.push(H.data,H.decryptdata,H.chunkMeta,H.state);if(o0(z))z.then(function(G){R7(self,G,Z)}).catch(function(G){QY($.ERROR,{instanceNo:Z,type:f.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,chunkMeta:H.chunkMeta,fatal:!1,error:G,err:G,reason:"transmuxer-worker push error"},Z)});else R7(self,z,Z);break}case"flush":{var N=H.chunkMeta,W=Q.flush(N);if(o0(W))W.then(function(G){OJ(self,G,N,Z)}).catch(function(G){QY($.ERROR,{type:f.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,chunkMeta:H.chunkMeta,fatal:!1,error:G,err:G,reason:"transmuxer-worker flush error"},Z)});else OJ(self,W,N,Z);break}}})}function R7(q,H,Z){if(o9(H.remuxResult))return!1;var Q=[],Y=H.remuxResult,J=Y.audio,X=Y.video;if(J)FJ(Q,J);if(X)FJ(Q,X);return q.postMessage({event:"transmuxComplete",data:H,instanceNo:Z},Q),!0}function FJ(q,H){if(H.data1)q.push(H.data1.buffer);if(H.data2)q.push(H.data2.buffer)}function OJ(q,H,Z,Q){var Y=H.reduce(function(J,X){return R7(q,X,Q)||J},!1);if(!Y)q.postMessage({event:"transmuxComplete",data:H[0],instanceNo:Q});q.postMessage({event:"flush",data:Z,instanceNo:Q})}function QY(q,H,Z){self.postMessage({event:q,data:H,instanceNo:Z})}function n9(q,H){var Z=function Y(J){var X=function z(N){QY("workerLog",{logType:J,message:N},H)};q[J]=X};for(var Q in q)Z(Q)}function o9(q){return!q.audio&&!q.video&&!q.text&&!q.id3&&!q.initSegment}var KY="1.6.0",JY={};function s9(){return typeof Z0==="function"}function i9(){var q=JY[KY];if(q)return q.clientCount++,q;var H=new self.Blob(["var exports={};var module={exports:exports};function define(f){f()};define.amd=true;("+Z0.toString()+")(true);"],{type:"text/javascript"}),Z=self.URL.createObjectURL(H),Q=new self.Worker(Z),Y={worker:Q,objectURL:Z,clientCount:1};return JY[KY]=Y,Y}function r9(q){var H=JY[q];if(H)return H.clientCount++,H;var Z=new self.URL(q,self.location.href).href,Q=new self.Worker(Z),Y={worker:Q,scriptURL:Z,clientCount:1};return JY[q]=Y,Y}function a9(q){var H=JY[q||KY];if(H){var Z=H.clientCount--;if(Z===1){var{worker:Q,objectURL:Y}=H;if(delete JY[q||KY],Y)self.URL.revokeObjectURL(Y);Q.terminate()}}}var RJ=0,t9=function(){function q(Z,Q,Y,J){var X=this;this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=RJ++,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 U=V.data,A=X.hls;if(!A||!(U!=null&&U.event)||U.instanceNo!==X.instanceNo)return;switch(U.event){case"init":{var E,B=(E=X.workerContext)==null?void 0:E.objectURL;if(B)self.URL.revokeObjectURL(B);break}case"transmuxComplete":{X.handleTransmuxComplete(U.data);break}case"flush":{X.onFlush(U.data);break}case"workerLog":{if(A.logger[U.data.logType])A.logger[U.data.logType](U.data.message);break}default:{U.data=U.data||{},U.data.frag=X.frag,U.data.part=X.part,U.data.id=X.id,A.trigger(U.event,U.data);break}}},this.onWorkerError=function(V){if(!X.hls)return;var U=new Error(V.message+" ("+V.filename+":"+V.lineno+")");X.hls.config.enableWorker=!1,X.hls.logger.warn('Error in "'+X.id+'" Web Worker, fallback to inline'),X.hls.trigger($.ERROR,{type:f.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:U})};var z=Z.config;this.hls=Z,this.id=Q,this.useWorker=!!z.enableWorker,this.onTransmuxComplete=Y,this.onFlush=J;var N=function V(U,A){if(A=A||{},A.frag=X.frag||void 0,U===$.ERROR)A=A,A.parent=X.id,A.part=X.part,X.error=A.error;X.hls.trigger(U,A)};this.observer=new pY,this.observer.on($.FRAG_DECRYPTED,N),this.observer.on($.ERROR,N);var W=e7(z.preferManagedMediaSource);if(this.useWorker&&typeof Worker!=="undefined"){var G=this.hls.logger,K=z.workerPath||s9();if(K){try{if(z.workerPath)G.log("loading Web Worker "+z.workerPath+' for "'+Q+'"'),this.workerContext=r9(z.workerPath);else G.log('injecting Web Worker for "'+Q+'"'),this.workerContext=i9();var j=this.workerContext.worker;j.addEventListener("message",this.onWorkerMessage),j.addEventListener("error",this.onWorkerError),j.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:W,id:Q,config:M0(z)})}catch(V){G.warn('Error setting up "'+Q+'" Web Worker, fallback to inline',V),this.terminateWorker(),this.error=null,this.transmuxer=new E7(this.observer,W,z,"",Q,Z.logger)}return}}this.transmuxer=new E7(this.observer,W,z,"",Q,Z.logger)}var H=q.prototype;return H.reset=function Z(){if(this.frag=null,this.part=null,this.workerContext){var Q=this.instanceNo;this.instanceNo=RJ++;var Y=this.hls.config,J=e7(Y.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:Q,typeSupported:J,id:this.id,config:M0(Y)})}},H.terminateWorker=function Z(){if(this.workerContext){var Q=this.workerContext.worker;this.workerContext=null,Q.removeEventListener("message",this.onWorkerMessage),Q.removeEventListener("error",this.onWorkerError),a9(this.hls.config.workerPath)}},H.destroy=function Z(){if(this.workerContext)this.terminateWorker(),this.onWorkerMessage=this.onWorkerError=null;else{var Q=this.transmuxer;if(Q)Q.destroy(),this.transmuxer=null}var Y=this.observer;if(Y)Y.removeAllListeners();this.frag=null,this.part=null,this.observer=null,this.hls=null},H.push=function Z(Q,Y,J,X,z,N,W,G,K,j){var V,U,A=this;K.transmuxing.start=self.performance.now();var E=this.instanceNo,B=this.transmuxer,F=N?N.start:z.start,R=z.decryptdata,O=this.frag,M=!(O&&z.cc===O.cc),L=!(O&&K.level===O.level),I=O?K.sn-O.sn:-1,w=this.part?K.part-this.part.index:-1,S=I===0&&K.id>1&&K.id===(O==null?void 0:O.stats.chunkCount),P=!L&&(I===1||I===0&&(w===1||S&&w<=0)),b=self.performance.now();if(L||I||z.stats.parsing.start===0)z.stats.parsing.start=b;if(N&&(w||!P))N.stats.parsing.start=b;var C=!(O&&((V=z.initSegment)==null?void 0:V.url)===((U=O.initSegment)==null?void 0:U.url)),x=new N9(M,P,G,L,F,C);if(!P||M||C){this.hls.logger.log("[transmuxer-interface]: Starting new transmux session for "+z.type+" sn: "+K.sn+(K.part>-1?" part: "+K.part:"")+" "+(this.id===d.MAIN?"level":"track")+": "+K.level+" id: "+K.id+`
|
22
|
-
discontinuity: `+
|
23
|
-
trackSwitch: `+
|
24
|
-
contiguous: `+
|
25
|
-
accurateTimeOffset: `+
|
26
|
-
timeOffset: `+
|
27
|
-
initSegmentChange: `+C);var _=new z9(J,X,Y,W,j);this.configureTransmuxer(_)}if(this.frag=z,this.part=N,this.workerContext)this.workerContext.worker.postMessage({instanceNo:E,cmd:"demux",data:Q,decryptdata:R,chunkMeta:K,state:x},Q instanceof ArrayBuffer?[Q]:[]);else if(B){var y=B.push(Q,R,K,x);if(o0(y))y.then(function(T){A.handleTransmuxComplete(T)}).catch(function(T){A.transmuxerError(T,K,"transmuxer-interface push error")});else this.handleTransmuxComplete(y)}},H.flush=function Z(Q){var Y=this;Q.transmuxing.start=self.performance.now();var J=this.instanceNo,X=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:J,cmd:"flush",chunkMeta:Q});else if(X){var z=X.flush(Q);if(o0(z))z.then(function(N){Y.handleFlushResult(N,Q)}).catch(function(N){Y.transmuxerError(N,Q,"transmuxer-interface flush error")});else this.handleFlushResult(z,Q)}},H.transmuxerError=function Z(Q,Y,J){if(!this.hls)return;this.error=Q,this.hls.trigger($.ERROR,{type:f.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,chunkMeta:Y,frag:this.frag||void 0,part:this.part||void 0,fatal:!1,error:Q,err:Q,reason:J})},H.handleFlushResult=function Z(Q,Y){var J=this;Q.forEach(function(X){J.handleTransmuxComplete(X)}),this.onFlush(Y)},H.configureTransmuxer=function Z(Q){var Y=this.instanceNo,J=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:Y,cmd:"configure",config:Q});else if(J)J.configure(Q)},H.handleTransmuxComplete=function Z(Q){Q.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(Q)},q}();function MJ(){return self.SourceBuffer||self.WebKitSourceBuffer}function IJ(){var q=d0();if(!q)return!1;var H=MJ();return!H||H.prototype&&typeof H.prototype.appendBuffer==="function"&&typeof H.prototype.remove==="function"}function e9(){if(!IJ())return!1;var q=d0();return typeof(q==null?void 0:q.isTypeSupported)==="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(function(H){return q.isTypeSupported(XY(H,"video"))})||["mp4a.40.2","fLaC"].some(function(H){return q.isTypeSupported(XY(H,"audio"))}))}function Yq(){var q,H=MJ();return typeof(H==null?void 0:(q=H.prototype)==null?void 0:q.changeType)==="function"}var Qq=100,Jq=function(q){function H(Q,Y,J){var X=q.call(this,Q,Y,J,"stream-controller",d.MAIN)||this;return X.audioCodecSwap=!1,X.level=-1,X._forceStartLoad=!1,X._hasEnoughToStart=!1,X.altAudio=0,X.audioOnly=!1,X.fragPlaying=null,X.fragLastKbps=0,X.couldBacktrack=!1,X.backtrackFragment=null,X.audioCodecSwitch=!1,X.videoBuffer=null,X.onMediaPlaying=function(){X.tick()},X.onMediaSeeked=function(){var z=X.media,N=z?z.currentTime:null;if(N===null||!v(N))return;if(X.log("Media seeked to "+N.toFixed(3)),!X.getBufferedFrag(N))return;var W=X.getFwdBufferInfoAtPos(z,N,d.MAIN,0);if(W===null||W.len===0){X.warn("Main forward buffer length at "+N+' on "seeked" event '+(W?W.len:"empty")+")");return}X.tick()},X.registerListeners(),X}j0(H,q);var Z=H.prototype;return Z.registerListeners=function Q(){q.prototype.registerListeners.call(this);var Y=this.hls;Y.on($.MANIFEST_PARSED,this.onManifestParsed,this),Y.on($.LEVEL_LOADING,this.onLevelLoading,this),Y.on($.LEVEL_LOADED,this.onLevelLoaded,this),Y.on($.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),Y.on($.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),Y.on($.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),Y.on($.BUFFER_CREATED,this.onBufferCreated,this),Y.on($.BUFFER_FLUSHED,this.onBufferFlushed,this),Y.on($.LEVELS_UPDATED,this.onLevelsUpdated,this),Y.on($.FRAG_BUFFERED,this.onFragBuffered,this)},Z.unregisterListeners=function Q(){q.prototype.unregisterListeners.call(this);var Y=this.hls;Y.off($.MANIFEST_PARSED,this.onManifestParsed,this),Y.off($.LEVEL_LOADED,this.onLevelLoaded,this),Y.off($.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),Y.off($.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),Y.off($.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),Y.off($.BUFFER_CREATED,this.onBufferCreated,this),Y.off($.BUFFER_FLUSHED,this.onBufferFlushed,this),Y.off($.LEVELS_UPDATED,this.onLevelsUpdated,this),Y.off($.FRAG_BUFFERED,this.onFragBuffered,this)},Z.onHandlerDestroying=function Q(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),q.prototype.onHandlerDestroying.call(this)},Z.startLoad=function Q(Y,J){if(this.levels){var X=this.lastCurrentTime,z=this.hls;if(this.stopLoad(),this.setInterval(Qq),this.level=-1,!this.startFragRequested){var N=z.startLevel;if(N===-1)if(z.config.testBandwidth&&this.levels.length>1)N=0,this.bitrateTest=!0;else N=z.firstAutoLevel;z.nextLoadLevel=N,this.level=z.loadLevel,this._hasEnoughToStart=!!J}if(X>0&&Y===-1&&!J)this.log("Override startPosition with lastCurrentTime @"+X.toFixed(3)),Y=X;this.state=k.IDLE,this.nextLoadPosition=this.lastCurrentTime=Y+this.timelineOffset,this.startPosition=J?-1:Y,this.tick()}else this._forceStartLoad=!0,this.state=k.STOPPED},Z.stopLoad=function Q(){this._forceStartLoad=!1,q.prototype.stopLoad.call(this)},Z.doTick=function Q(){switch(this.state){case k.WAITING_LEVEL:{var Y=this.levels,J=this.level,X=Y==null?void 0:Y[J],z=X==null?void 0:X.details;if(z&&(!z.live||this.levelLastLoaded===X&&!this.waitForLive(X))){if(this.waitForCdnTuneIn(z))break;this.state=k.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=k.IDLE;break}break}case k.FRAG_LOADING_WAITING_RETRY:{var N,W=self.performance.now(),G=this.retryDate;if(!G||W>=G||(N=this.media)!=null&&N.seeking){var K=this.levels,j=this.level,V=K==null?void 0:K[j];this.resetStartWhenNotLoaded(V||null),this.state=k.IDLE}}break}if(this.state===k.IDLE)this.doTickIdle();this.onTickEnd()},Z.onTickEnd=function Q(){var Y;if(q.prototype.onTickEnd.call(this),(Y=this.media)!=null&&Y.readyState&&this.media.seeking===!1)this.lastCurrentTime=this.media.currentTime;this.checkFragmentChanged()},Z.doTickIdle=function Q(){var Y=this.hls,J=this.levelLastLoaded,X=this.levels,z=this.media;if(J===null||!z&&!this.primaryPrefetch&&(this.startFragRequested||!Y.config.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;var N=this.buffering?Y.nextLoadLevel:Y.loadLevel;if(!(X!=null&&X[N]))return;var W=X[N],G=this.getMainFwdBufferInfo();if(G===null)return;var K=this.getLevelDetails();if(K&&this._streamEnded(G,K)){var j={};if(this.altAudio===2)j.type="video";this.hls.trigger($.BUFFER_EOS,j),this.state=k.ENDED;return}if(!this.buffering)return;if(Y.loadLevel!==N&&Y.manualLevel===-1)this.log("Adapting to level "+N+" from level "+this.level);this.level=Y.nextLoadLevel=N;var V=W.details;if(!V||this.state===k.WAITING_LEVEL||this.waitForLive(W)){this.level=N,this.state=k.WAITING_LEVEL,this.startFragRequested=!1;return}var U=G.len,A=this.getMaxBufferLength(W.maxBitrate);if(U>=A)return;if(this.backtrackFragment&&this.backtrackFragment.start>G.end)this.backtrackFragment=null;var E=this.backtrackFragment?this.backtrackFragment.start:G.end,B=this.getNextFragment(E,V);if(this.couldBacktrack&&!this.fragPrevious&&B&&h0(B)&&this.fragmentTracker.getState(B)!==w0.OK){var F,R=((F=this.backtrackFragment)!=null?F:B).sn,O=R-V.startSN,M=V.fragments[O-1];if(M&&B.cc===M.cc)B=M,this.fragmentTracker.removeFragment(M)}else if(this.backtrackFragment&&G.len)this.backtrackFragment=null;if(B&&this.isLoopLoading(B,E)){var L=B.gap;if(!L){var I=this.audioOnly&&!this.altAudio?Q0.AUDIO:Q0.VIDEO,w=(I===Q0.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;if(w)this.afterBufferFlushed(w,I,d.MAIN)}B=this.getNextFragmentLoopLoading(B,V,G,d.MAIN,A)}if(!B)return;if(B.initSegment&&!B.initSegment.data&&!this.bitrateTest)B=B.initSegment;this.loadFragment(B,W,E)},Z.loadFragment=function Q(Y,J,X){var z=this.fragmentTracker.getState(Y);if(z===w0.NOT_LOADED||z===w0.PARTIAL)if(!h0(Y))this._loadInitSegment(Y,J);else if(this.bitrateTest)this.log("Fragment "+Y.sn+" of level "+Y.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(Y,J);else q.prototype.loadFragment.call(this,Y,J,X);else this.clearTrackerIfNeeded(Y)},Z.getBufferedFrag=function Q(Y){return this.fragmentTracker.getBufferedFrag(Y,d.MAIN)},Z.followingBufferedFrag=function Q(Y){if(Y)return this.getBufferedFrag(Y.end+0.5);return null},Z.immediateLevelSwitch=function Q(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},Z.nextLevelSwitch=function Q(){var Y=this.levels,J=this.media;if(J!=null&&J.readyState){var X,z=this.getAppendedFrag(J.currentTime);if(z&&z.start>1)this.flushMainBuffer(0,z.start-1);var N=this.getLevelDetails();if(N!=null&&N.live){var W=this.getMainFwdBufferInfo();if(!W||W.len<N.targetduration*2)return}if(!J.paused&&Y){var G=this.hls.nextLoadLevel,K=Y[G],j=this.fragLastKbps;if(j&&this.fragCurrent)X=this.fragCurrent.duration*K.maxBitrate/(1000*j)+1;else X=0}else X=0;var V=this.getBufferedFrag(J.currentTime+X);if(V){var U=this.followingBufferedFrag(V);if(U){this.abortCurrentFrag();var A=U.maxStartPTS?U.maxStartPTS:U.start,E=U.duration,B=Math.max(V.end,A+Math.min(Math.max(E-this.config.maxFragLookUpTolerance,E*(this.couldBacktrack?0.5:0.125)),E*(this.couldBacktrack?0.75:0.25)));this.flushMainBuffer(B,Number.POSITIVE_INFINITY)}}}},Z.abortCurrentFrag=function Q(){var Y=this.fragCurrent;if(this.fragCurrent=null,this.backtrackFragment=null,Y)Y.abortRequests(),this.fragmentTracker.removeFragment(Y);switch(this.state){case k.KEY_LOADING:case k.FRAG_LOADING:case k.FRAG_LOADING_WAITING_RETRY:case k.PARSING:case k.PARSED:this.state=k.IDLE;break}this.nextLoadPosition=this.getLoadPosition()},Z.flushMainBuffer=function Q(Y,J){q.prototype.flushMainBuffer.call(this,Y,J,this.altAudio===2?"video":null)},Z.onMediaAttached=function Q(Y,J){q.prototype.onMediaAttached.call(this,Y,J);var X=J.media;GY(X,"playing",this.onMediaPlaying),GY(X,"seeked",this.onMediaSeeked)},Z.onMediaDetaching=function Q(Y,J){var X=this.media;if(X)YY(X,"playing",this.onMediaPlaying),YY(X,"seeked",this.onMediaSeeked);this.videoBuffer=null,this.fragPlaying=null,q.prototype.onMediaDetaching.call(this,Y,J);var z=!!J.transferMedia;if(z)return;this._hasEnoughToStart=!1},Z.onManifestLoading=function Q(){q.prototype.onManifestLoading.call(this),this.log("Trigger BUFFER_RESET"),this.hls.trigger($.BUFFER_RESET,void 0),this.couldBacktrack=!1,this.fragLastKbps=0,this.fragPlaying=this.backtrackFragment=null,this.altAudio=0,this.audioOnly=!1},Z.onManifestParsed=function Q(Y,J){var X=!1,z=!1;if(J.levels.forEach(function(N){var W=N.audioCodec;if(W)X=X||W.indexOf("mp4a.40.2")!==-1,z=z||W.indexOf("mp4a.40.5")!==-1}),this.audioCodecSwitch=X&&z&&!Yq(),this.audioCodecSwitch)this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC");this.levels=J.levels,this.startFragRequested=!1},Z.onLevelLoading=function Q(Y,J){var X=this.levels;if(!X||this.state!==k.IDLE)return;var z=J.levelInfo;if(!z.details||z.details.live&&(this.levelLastLoaded!==z||z.details.expired)||this.waitForCdnTuneIn(z.details))this.state=k.WAITING_LEVEL},Z.onLevelLoaded=function Q(Y,J){var X,z=this.levels,N=this.startFragRequested,W=J.level,G=J.details,K=G.totalduration;if(!z){this.warn("Levels were reset while loading level "+W);return}this.log("Level "+W+" loaded ["+G.startSN+","+G.endSN+"]"+(G.lastPartSn?"[part-"+G.lastPartSn+"-"+G.lastPartIndex+"]":"")+", cc ["+G.startCC+", "+G.endCC+"] duration:"+K);var j=J.levelInfo,V=this.fragCurrent;if(V&&(this.state===k.FRAG_LOADING||this.state===k.FRAG_LOADING_WAITING_RETRY)){if(V.level!==J.level&&V.loader)this.abortCurrentFrag()}var U=0;if(G.live||(X=j.details)!=null&&X.live){var A;if(this.checkLiveUpdate(G),G.deltaUpdateFailed)return;U=this.alignPlaylists(G,j.details,(A=this.levelLastLoaded)==null?void 0:A.details)}if(j.details=G,this.levelLastLoaded=j,!N)this.setStartPosition(G,U);if(this.hls.trigger($.LEVEL_UPDATED,{details:G,level:W}),this.state===k.WAITING_LEVEL){if(this.waitForCdnTuneIn(G))return;this.state=k.IDLE}if(N&&G.live)this.synchronizeToLiveEdge(G);this.tick()},Z.synchronizeToLiveEdge=function Q(Y){var J=this.config,X=this.media;if(!X)return;var z=this.hls.liveSyncPosition,N=this.getLoadPosition(),W=Y.fragmentStart,G=Y.edge,K=N>=W-J.maxFragLookUpTolerance&&N<=G;if(z!==null&&X.duration>z&&(N<z||!K)){var j=J.liveMaxLatencyDuration!==void 0?J.liveMaxLatencyDuration:J.liveMaxLatencyDurationCount*Y.targetduration;if(!K&&X.readyState<4||N<G-j){if(!this._hasEnoughToStart)this.nextLoadPosition=z;if(X.readyState)this.warn("Playback: "+N.toFixed(3)+" is located too far from the end of live sliding playlist: "+G+", reset currentTime to : "+z.toFixed(3)),X.currentTime=z}}},Z._handleFragmentLoadProgress=function Q(Y){var J,X=Y.frag,z=Y.part,N=Y.payload,W=this.levels;if(!W){this.warn("Levels were reset while fragment load was in progress. Fragment "+X.sn+" of level "+X.level+" will not be buffered");return}var G=W[X.level];if(!G){this.warn("Level "+X.level+" not found on progress");return}var K=G.details;if(!K){this.warn("Dropping fragment "+X.sn+" of level "+X.level+" after level details were reset"),this.fragmentTracker.removeFragment(X);return}var j=G.videoCodec,V=K.PTSKnown||!K.live,U=(J=X.initSegment)==null?void 0:J.data,A=this._getAudioCodec(G),E=this.transmuxer=this.transmuxer||new t9(this.hls,d.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),B=z?z.index:-1,F=B!==-1,R=new KJ(X.level,X.sn,X.stats.chunkCount,N.byteLength,B,F),O=this.initPTS[X.cc];E.push(N,U,A,j,X,z,K.totalduration,V,R,O)},Z.onAudioTrackSwitching=function Q(Y,J){var X=this,z=this.hls,N=this.altAudio===2,W=HQ(J.url,z);if(!W){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var G=this.fragCurrent;if(G)this.log("Switching to main audio track, cancel main fragment load"),G.abortRequests(),this.fragmentTracker.removeFragment(G);this.resetTransmuxer(),this.resetLoadingState()}else if(this.audioOnly)this.resetTransmuxer();if(N){this.fragmentTracker.removeAllFragments(),z.once($.BUFFER_FLUSHED,function(){var K;(K=X.hls)==null||K.trigger($.AUDIO_TRACK_SWITCHED,J)}),z.trigger($.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});return}z.trigger($.AUDIO_TRACK_SWITCHED,J)}else this.altAudio=1},Z.onAudioTrackSwitched=function Q(Y,J){var X=HQ(J.url,this.hls);if(X){var z=this.videoBuffer;if(z&&this.mediaBuffer!==z)this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=z}this.altAudio=X?2:0,this.tick()},Z.onBufferCreated=function Q(Y,J){var X=J.tracks,z,N,W=!1;for(var G in X){var K=X[G];if(K.id==="main"){if(N=G,z=K,G==="video"){var j=X[G];if(j)this.videoBuffer=j.buffer}}else W=!0}if(W&&z)this.log("Alternate track found, use "+N+".buffered to schedule main fragment loading"),this.mediaBuffer=z.buffer;else this.mediaBuffer=this.media},Z.onFragBuffered=function Q(Y,J){var{frag:X,part:z}=J,N=X.type===d.MAIN;if(N){if(this.fragContextChanged(X)){if(this.warn("Fragment "+X.sn+(z?" p: "+z.index:"")+" of level "+X.level+" finished buffering, but was aborted. state: "+this.state),this.state===k.PARSED)this.state=k.IDLE;return}var W=z?z.stats:X.stats;if(this.fragLastKbps=Math.round(8*W.total/(W.buffering.end-W.loading.first)),h0(X))this.fragPrevious=X;this.fragBufferedComplete(X,z)}var G=this.media;if(!G)return;if(!this._hasEnoughToStart&&i.getBuffered(G).length)this._hasEnoughToStart=!0,this.seekToStartPos();if(N)this.tick()},Z.onError=function Q(Y,J){var X;if(J.fatal){this.state=k.ERROR;return}switch(J.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(d.MAIN,J);break;case D.LEVEL_LOAD_ERROR:case D.LEVEL_LOAD_TIMEOUT:case D.LEVEL_PARSING_ERROR:if(!J.levelRetry&&this.state===k.WAITING_LEVEL&&((X=J.context)==null?void 0:X.type)===o.LEVEL)this.state=k.IDLE;break;case D.BUFFER_ADD_CODEC_ERROR:case D.BUFFER_APPEND_ERROR:if(J.parent!=="main")return;this.resetLoadingState();break;case D.BUFFER_FULL_ERROR:if(J.parent!=="main")return;if(this.reduceLengthAndFlushBuffer(J))this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case D.INTERNAL_EXCEPTION:this.recoverWorkerError(J);break}},Z.onFragLoadEmergencyAborted=function Q(){if(this.state=k.IDLE,!this._hasEnoughToStart)this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime;this.tickImmediate()},Z.onBufferFlushed=function Q(Y,J){var X=J.type;if(X!==Q0.AUDIO||!this.altAudio){var z=(X===Q0.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;if(z)this.afterBufferFlushed(z,X,d.MAIN),this.tick()}},Z.onLevelsUpdated=function Q(Y,J){if(this.level>-1&&this.fragCurrent){if(this.level=this.fragCurrent.level,this.level===-1)this.resetWhenMissingContext(this.fragCurrent)}this.levels=J.levels},Z.swapAudioCodec=function Q(){this.audioCodecSwap=!this.audioCodecSwap},Z.seekToStartPos=function Q(){var Y=this.media;if(!Y)return;var J=Y.currentTime,X=this.startPosition;if(X>=0&&J<X){if(Y.seeking){this.log("could not seek to "+X+", already seeking at "+J);return}var z=this.timelineOffset;if(z&&X)X+=z;var N=this.getLevelDetails(),W=i.getBuffered(Y),G=W.length?W.start(0):0,K=G-X,j=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);if(K>0&&(K<j||this.loadingParts&&K<2*((N==null?void 0:N.partTarget)||0)))this.log("adjusting start position by "+K+" to match buffer start"),X+=K,this.startPosition=X;if(J<X)this.log("seek to target start position "+X+" from current time "+J+" buffer start "+G),Y.currentTime=X}},Z._getAudioCodec=function Q(Y){var J=this.config.defaultAudioCodec||Y.audioCodec;if(this.audioCodecSwap&&J)if(this.log("Swapping audio codec"),J.indexOf("mp4a.40.5")!==-1)J="mp4a.40.2";else J="mp4a.40.5";return J},Z._loadBitrateTestFrag=function Q(Y,J){var X=this;Y.bitrateTest=!0,this._doFragLoad(Y,J).then(function(z){var N=X.hls,W=z==null?void 0:z.frag;if(!W||X.fragContextChanged(W))return;J.fragmentError=0,X.state=k.IDLE,X.startFragRequested=!1,X.bitrateTest=!1;var G=W.stats;G.parsing.start=G.parsing.end=G.buffering.start=G.buffering.end=self.performance.now(),N.trigger($.FRAG_LOADED,z),W.bitrateTest=!1})},Z._handleTransmuxComplete=function Q(Y){var J,X=this.playlistType,z=this.hls,N=Y.remuxResult,W=Y.chunkMeta,G=this.getCurrentContext(W);if(!G){this.resetWhenMissingContext(W);return}var{frag:K,part:j,level:V}=G,U=N.video,A=N.text,E=N.id3,B=N.initSegment,F=V.details,R=this.altAudio?void 0:N.audio;if(this.fragContextChanged(K)){this.fragmentTracker.removeFragment(K);return}if(this.state=k.PARSING,B){if(B!=null&&B.tracks){var O=K.initSegment||K;this._bufferInitSegment(V,B.tracks,O,W),z.trigger($.FRAG_PARSING_INIT_SEGMENT,{frag:O,id:X,tracks:B.tracks})}var{initPTS:M,timescale:L}=B;if(v(M))this.initPTS[K.cc]={baseTime:M,timescale:L},z.trigger($.INIT_PTS_FOUND,{frag:K,id:X,initPTS:M,timescale:L})}if(U&&F){var I=F.fragments[K.sn-1-F.startSN],w=K.sn===F.startSN,S=!I||K.cc>I.cc;if(N.independent!==!1){var{startPTS:P,endPTS:b,startDTS:C,endDTS:x}=U;if(j)j.elementaryStreams[U.type]={startPTS:P,endPTS:b,startDTS:C,endDTS:x};else{if(U.firstKeyFrame&&U.independent&&W.id===1&&!S)this.couldBacktrack=!0;if(U.dropped&&U.independent){var _=this.getMainFwdBufferInfo(),y=(_?_.end:this.getLoadPosition())+this.config.maxBufferHole,T=U.firstKeyFramePTS?U.firstKeyFramePTS:P;if(!w&&y<T-this.config.maxBufferHole&&!S){this.backtrack(K);return}else if(S)K.gap=!0;K.setElementaryStreamInfo(U.type,K.start,b,K.start,x,!0)}else if(w&&P-(F.appliedTimelineOffset||0)>yY)K.gap=!0}if(K.setElementaryStreamInfo(U.type,P,b,C,x),this.backtrackFragment)this.backtrackFragment=K;this.bufferFragmentData(U,K,j,W,w||S)}else if(w||S)K.gap=!0;else{this.backtrack(K);return}}if(R){var{startPTS:h,endPTS:g,startDTS:m,endDTS:p}=R;if(j)j.elementaryStreams[Q0.AUDIO]={startPTS:h,endPTS:g,startDTS:m,endDTS:p};K.setElementaryStreamInfo(Q0.AUDIO,h,g,m,p),this.bufferFragmentData(R,K,j,W)}if(F&&E!=null&&(J=E.samples)!=null&&J.length){var r={id:X,frag:K,details:F,samples:E.samples};z.trigger($.FRAG_PARSING_METADATA,r)}if(F&&A){var n={id:X,frag:K,details:F,samples:A.samples};z.trigger($.FRAG_PARSING_USERDATA,n)}},Z._bufferInitSegment=function Q(Y,J,X,z){var N=this;if(this.state!==k.PARSING)return;if(this.audioOnly=!!J.audio&&!J.video,this.altAudio&&!this.audioOnly)delete J.audio;var{audio:W,video:G,audiovideo:K}=J;if(W){var j=FY(W.codec,Y.audioCodec);if(j==="mp4a")j="mp4a.40.5";var V=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){if(j)if(j.indexOf("mp4a.40.5")!==-1)j="mp4a.40.2";else j="mp4a.40.5";var U=W.metadata;if(U&&"channelCount"in U&&(U.channelCount||1)!==1&&V.indexOf("firefox")===-1)j="mp4a.40.5"}if(j&&j.indexOf("mp4a.40.5")!==-1&&V.indexOf("android")!==-1&&W.container!=="audio/mpeg")j="mp4a.40.2",this.log("Android: force audio codec to "+j);if(Y.audioCodec&&Y.audioCodec!==j)this.log('Swapping manifest audio codec "'+Y.audioCodec+'" for "'+j+'"');W.levelCodec=j,W.id=d.MAIN,this.log("Init audio buffer, container:"+W.container+", codecs[selected/level/parsed]=["+(j||"")+"/"+(Y.audioCodec||"")+"/"+W.codec+"]"),delete J.audiovideo}if(G){G.levelCodec=Y.videoCodec,G.id=d.MAIN;var A=G.codec;if((A==null?void 0:A.length)===4)switch(A){case"hvc1":case"hev1":G.codec="hvc1.1.6.L120.90";break;case"av01":G.codec="av01.0.04M.08";break;case"avc1":G.codec="avc1.42e01e";break}this.log("Init video buffer, container:"+G.container+", codecs[level/parsed]=["+(Y.videoCodec||"")+"/"+A+"]"+(G.codec!==A?" parsed-corrected="+G.codec:"")+(G.supplemental?" supplemental="+G.supplemental:"")),delete J.audiovideo}if(K)this.log("Init audiovideo buffer, container:"+K.container+", codecs[level/parsed]=["+Y.codecs+"/"+K.codec+"]"),delete J.video,delete J.audio;var E=Object.keys(J);if(E.length){if(this.hls.trigger($.BUFFER_CODECS,J),!this.hls)return;E.forEach(function(B){var F=J[B],R=F.initSegment;if(R!=null&&R.byteLength)N.hls.trigger($.BUFFER_APPENDING,{type:B,data:R,frag:X,part:null,chunkMeta:z,parent:X.type})})}this.tickImmediate()},Z.getMainFwdBufferInfo=function Q(){var Y=this.mediaBuffer&&this.altAudio===2?this.mediaBuffer:this.media;return this.getFwdBufferInfo(Y,d.MAIN)},Z.backtrack=function Q(Y){this.couldBacktrack=!0,this.backtrackFragment=Y,this.resetTransmuxer(),this.flushBufferGap(Y),this.fragmentTracker.removeFragment(Y),this.fragPrevious=null,this.nextLoadPosition=Y.start,this.state=k.IDLE},Z.checkFragmentChanged=function Q(){var Y=this.media,J=null;if(Y&&Y.readyState>1&&Y.seeking===!1){var X=Y.currentTime;if(i.isBuffered(Y,X))J=this.getAppendedFrag(X);else if(i.isBuffered(Y,X+0.1))J=this.getAppendedFrag(X+0.1);if(J){this.backtrackFragment=null;var z=this.fragPlaying,N=J.level;if(!z||J.sn!==z.sn||z.level!==N){if(this.fragPlaying=J,this.hls.trigger($.FRAG_CHANGED,{frag:J}),!z||z.level!==N)this.hls.trigger($.LEVEL_SWITCHED,{level:N})}}}},q0(H,[{key:"hasEnoughToStart",get:function Q(){return this._hasEnoughToStart}},{key:"maxBufferLength",get:function Q(){var Y=this.levels,J=this.level,X=Y==null?void 0:Y[J];if(!X)return this.config.maxBufferLength;return this.getMaxBufferLength(X.maxBitrate)}},{key:"nextLevel",get:function Q(){var Y=this.nextBufferedFrag;if(Y)return Y.level;return-1}},{key:"currentFrag",get:function Q(){var Y;if(this.fragPlaying)return this.fragPlaying;var J=((Y=this.media)==null?void 0:Y.currentTime)||this.lastCurrentTime;if(v(J))return this.getAppendedFrag(J);return null}},{key:"currentProgramDateTime",get:function Q(){var Y,J=((Y=this.media)==null?void 0:Y.currentTime)||this.lastCurrentTime;if(v(J)){var X=this.getLevelDetails(),z=this.currentFrag||(X?Y7(null,X.fragments,J):null);if(z){var N=z.programDateTime;if(N!==null){var W=N+(J-z.start)*1000;return new Date(W)}}}return null}},{key:"currentLevel",get:function Q(){var Y=this.currentFrag;if(Y)return Y.level;return-1}},{key:"nextBufferedFrag",get:function Q(){var Y=this.currentFrag;if(Y)return this.followingBufferedFrag(Y);return null}},{key:"forceStartLoad",get:function Q(){return this._forceStartLoad}}])}(D9),Zq=function(){function q(Z){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=Z}var H=q.prototype;return H.abort=function Z(Q){for(var Y in this.keyUriToKeyInfo){var J=this.keyUriToKeyInfo[Y].loader;if(J){var X;if(Q&&Q!==((X=J.context)==null?void 0:X.frag.type))return;J.abort()}}},H.detach=function Z(){for(var Q in this.keyUriToKeyInfo){var Y=this.keyUriToKeyInfo[Q];if(Y.mediaKeySessionContext||Y.decryptdata.isCommonEncryption)delete this.keyUriToKeyInfo[Q]}},H.destroy=function Z(){this.detach();for(var Q in this.keyUriToKeyInfo){var Y=this.keyUriToKeyInfo[Q].loader;if(Y)Y.destroy()}this.keyUriToKeyInfo={}},H.createKeyLoadError=function Z(Q,Y,J,X,z){if(Y===void 0)Y=D.KEY_LOAD_ERROR;return new c0({type:f.NETWORK_ERROR,details:Y,fatal:!1,frag:Q,response:z,error:J,networkDetails:X})},H.loadClear=function Z(Q,Y){var J=this;if(this.emeController&&this.config.emeEnabled){var{sn:X,cc:z}=Q,N=function G(){var K=Y[W];if(z<=K.cc&&(X==="initSegment"||K.sn==="initSegment"||X<K.sn))return J.emeController.selectKeySystemFormat(K).then(function(j){K.setKeyFormat(j)}),1};for(var W=0;W<Y.length;W++)if(N())break}},H.load=function Z(Q){var Y=this;if(!Q.decryptdata&&Q.encrypted&&this.emeController&&this.config.emeEnabled)return this.emeController.selectKeySystemFormat(Q).then(function(J){return Y.loadInternal(Q,J)});return this.loadInternal(Q)},H.loadInternal=function Z(Q,Y){var J,X;if(Y)Q.setKeyFormat(Y);var z=Q.decryptdata;if(!z){var N=new Error(Y?"Expected frag.decryptdata to be defined after setting format "+Y:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(Q,D.KEY_LOAD_ERROR,N))}var W=z.uri;if(!W)return Promise.reject(this.createKeyLoadError(Q,D.KEY_LOAD_ERROR,new Error('Invalid key URI: "'+W+'"')));var G=this.keyUriToKeyInfo[W];if((J=G)!=null&&J.decryptdata.key)return z.key=G.decryptdata.key,Promise.resolve({frag:Q,keyInfo:G});if((X=G)!=null&&X.keyLoadPromise){var K;switch((K=G.mediaKeySessionContext)==null?void 0:K.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return G.keyLoadPromise.then(function(j){return z.key=j.keyInfo.decryptdata.key,{frag:Q,keyInfo:G}})}}switch(G=this.keyUriToKeyInfo[W]={decryptdata:z,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},z.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":if(z.keyFormat==="identity")return this.loadKeyHTTP(G,Q);return this.loadKeyEME(G,Q);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(G,Q);default:return Promise.reject(this.createKeyLoadError(Q,D.KEY_LOAD_ERROR,new Error('Key supplied with unsupported METHOD: "'+z.method+'"')))}},H.loadKeyEME=function Z(Q,Y){var J={frag:Y,keyInfo:Q};if(this.emeController&&this.config.emeEnabled){var X=this.emeController.loadKey(J);if(X)return(Q.keyLoadPromise=X.then(function(z){return Q.mediaKeySessionContext=z,J})).catch(function(z){throw Q.keyLoadPromise=null,z})}return Promise.resolve(J)},H.loadKeyHTTP=function Z(Q,Y){var J=this,X=this.config,z=X.loader,N=new z(X);return Y.keyLoader=Q.loader=N,Q.keyLoadPromise=new Promise(function(W,G){var K={keyInfo:Q,frag:Y,responseType:"arraybuffer",url:Q.decryptdata.uri},j=X.keyLoadPolicy.default,V={loadPolicy:j,timeout:j.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},U={onSuccess:function A(E,B,F,R){var{frag:O,keyInfo:M,url:L}=F;if(!O.decryptdata||M!==J.keyUriToKeyInfo[L])return G(J.createKeyLoadError(O,D.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),R));M.decryptdata.key=O.decryptdata.key=new Uint8Array(E.data),O.keyLoader=null,M.loader=null,W({frag:O,keyInfo:M})},onError:function A(E,B,F,R){J.resetLoader(B),G(J.createKeyLoadError(Y,D.KEY_LOAD_ERROR,new Error("HTTP Error "+E.code+" loading key "+E.text),F,I0({url:K.url,data:void 0},E)))},onTimeout:function A(E,B,F){J.resetLoader(B),G(J.createKeyLoadError(Y,D.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),F))},onAbort:function A(E,B,F){J.resetLoader(B),G(J.createKeyLoadError(Y,D.INTERNAL_ABORTED,new Error("key loading aborted"),F))}};N.load(K,V,U)})},H.resetLoader=function Z(Q){var{frag:Y,keyInfo:J,url:X}=Q,z=J.loader;if(Y.keyLoader===z)Y.keyLoader=null,J.loader=null;if(delete this.keyUriToKeyInfo[X],z)z.destroy()},q}();function wJ(q){var H=q.type;switch(H){case o.AUDIO_TRACK:return d.AUDIO;case o.SUBTITLE_TRACK:return d.SUBTITLE;default:return d.MAIN}}function M7(q,H){var Z=q.url;if(Z===void 0||Z.indexOf("data:")===0)Z=H.url;return Z}var qq=function(){function q(Z){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=Z,this.registerListeners()}var H=q.prototype;return H.startLoad=function Z(Q){},H.stopLoad=function Z(){this.destroyInternalLoaders()},H.registerListeners=function Z(){var Q=this.hls;Q.on($.MANIFEST_LOADING,this.onManifestLoading,this),Q.on($.LEVEL_LOADING,this.onLevelLoading,this),Q.on($.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),Q.on($.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),Q.on($.LEVELS_UPDATED,this.onLevelsUpdated,this)},H.unregisterListeners=function Z(){var Q=this.hls;Q.off($.MANIFEST_LOADING,this.onManifestLoading,this),Q.off($.LEVEL_LOADING,this.onLevelLoading,this),Q.off($.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),Q.off($.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),Q.off($.LEVELS_UPDATED,this.onLevelsUpdated,this)},H.createInternalLoader=function Z(Q){var Y=this.hls.config,J=Y.pLoader,X=Y.loader,z=J||X,N=new z(Y);return this.loaders[Q.type]=N,N},H.getInternalLoader=function Z(Q){return this.loaders[Q.type]},H.resetInternalLoader=function Z(Q){if(this.loaders[Q])delete this.loaders[Q]},H.destroyInternalLoaders=function Z(){for(var Q in this.loaders){var Y=this.loaders[Q];if(Y)Y.destroy();this.resetInternalLoader(Q)}},H.destroy=function Z(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()},H.onManifestLoading=function Z(Q,Y){var J=Y.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:o.MANIFEST,url:J,deliveryDirectives:null,levelOrTrack:null})},H.onLevelLoading=function Z(Q,Y){var{id:J,level:X,pathwayId:z,url:N,deliveryDirectives:W,levelInfo:G}=Y;this.load({id:J,level:X,pathwayId:z,responseType:"text",type:o.LEVEL,url:N,deliveryDirectives:W,levelOrTrack:G})},H.onAudioTrackLoading=function Z(Q,Y){var{id:J,groupId:X,url:z,deliveryDirectives:N,track:W}=Y;this.load({id:J,groupId:X,level:null,responseType:"text",type:o.AUDIO_TRACK,url:z,deliveryDirectives:N,levelOrTrack:W})},H.onSubtitleTrackLoading=function Z(Q,Y){var{id:J,groupId:X,url:z,deliveryDirectives:N,track:W}=Y;this.load({id:J,groupId:X,level:null,responseType:"text",type:o.SUBTITLE_TRACK,url:z,deliveryDirectives:N,levelOrTrack:W})},H.onLevelsUpdated=function Z(Q,Y){var J=this.loaders[o.LEVEL];if(J){var X=J.context;if(X&&!Y.levels.some(function(z){return z===X.levelOrTrack}))J.abort(),delete this.loaders[o.LEVEL]}},H.load=function Z(Q){var Y,J=this,X=this.hls.config,z=this.getInternalLoader(Q);if(z){var N=this.hls.logger,W=z.context;if(W&&W.levelOrTrack===Q.levelOrTrack&&(W.url===Q.url||W.deliveryDirectives&&!Q.deliveryDirectives)){if(W.url===Q.url)N.log("[playlist-loader]: ignore "+Q.url+" ongoing request");else N.log("[playlist-loader]: ignore "+Q.url+" in favor of "+W.url);return}N.log("[playlist-loader]: aborting previous loader for type: "+Q.type),z.abort()}var G;if(Q.type===o.MANIFEST)G=X.manifestLoadPolicy.default;else G=K0({},X.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null});if(z=this.createInternalLoader(Q),v((Y=Q.deliveryDirectives)==null?void 0:Y.part)){var K;if(Q.type===o.LEVEL&&Q.level!==null)K=this.hls.levels[Q.level].details;else if(Q.type===o.AUDIO_TRACK&&Q.id!==null)K=this.hls.audioTracks[Q.id].details;else if(Q.type===o.SUBTITLE_TRACK&&Q.id!==null)K=this.hls.subtitleTracks[Q.id].details;if(K){var{partTarget:j,targetduration:V}=K;if(j&&V){var U=Math.max(j*3,V*0.8)*1000;G=K0({},G,{maxTimeToFirstByteMs:Math.min(U,G.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(U,G.maxTimeToFirstByteMs)})}}}var A=G.errorRetry||G.timeoutRetry||{},E={loadPolicy:G,timeout:G.maxLoadTimeMs,maxRetry:A.maxNumRetry||0,retryDelay:A.retryDelayMs||0,maxRetryDelay:A.maxRetryDelayMs||0},B={onSuccess:function F(R,O,M,L){var I=J.getInternalLoader(M);J.resetInternalLoader(M.type);var w=R.data;if(w.indexOf("#EXTM3U")!==0){J.handleManifestParsingError(R,M,new Error("no EXTM3U delimiter"),L||null,O);return}if(O.parsing.start=performance.now(),zY.isMediaPlaylist(w)||M.type!==o.MANIFEST)J.handleTrackOrLevelPlaylist(R,O,M,L||null,I);else J.handleMasterPlaylist(R,O,M,L)},onError:function F(R,O,M,L){J.handleNetworkError(O,M,!1,R,L)},onTimeout:function F(R,O,M){J.handleNetworkError(O,M,!0,void 0,R)}};z.load(Q,E,B)},H.checkAutostartLoad=function Z(){if(!this.hls)return;var Q=this.hls,Y=Q.config,J=Y.autoStartLoad,X=Y.startPosition,z=Q.forceStartLoad;if(J||z)this.hls.logger.log((J?"auto":"force")+" startLoad with configured startPosition "+X),this.hls.startLoad(X)},H.handleMasterPlaylist=function Z(Q,Y,J,X){var z=this.hls,N=Q.data,W=M7(Q,J),G=zY.parseMasterPlaylist(N,W);if(G.playlistParsingError){this.handleManifestParsingError(Q,J,G.playlistParsingError,X,Y);return}var{contentSteering:K,levels:j,sessionData:V,sessionKeys:U,startTimeOffset:A,variableList:E}=G;this.variableList=E;var B=zY.parseMasterPlaylistMedia(N,W,G),F=B.AUDIO,R=F===void 0?[]:F,O=B.SUBTITLES,M=B["CLOSED-CAPTIONS"];if(R.length){var L=R.some(function(I){return!I.url});if(!L&&j[0].audioCodec&&!j[0].attrs.AUDIO)this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),R.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new N0({}),bitrate:0,url:""})}z.trigger($.MANIFEST_LOADED,{levels:j,audioTracks:R,subtitles:O,captions:M,contentSteering:K,url:W,stats:Y,networkDetails:X,sessionData:V,sessionKeys:U,startTimeOffset:A,variableList:E})},H.handleTrackOrLevelPlaylist=function Z(Q,Y,J,X,z){var N=this.hls,W=J.id,G=J.level,K=J.type,j=M7(Q,J),V=v(G)?G:v(W)?W:0,U=wJ(J),A=zY.parseLevelPlaylist(Q.data,j,V,U,0,this.variableList);if(K===o.MANIFEST){var E={attrs:new N0({}),bitrate:0,details:A,name:"",url:j};A.requestScheduled=Y.loading.start+xQ(A,0),N.trigger($.MANIFEST_LOADED,{levels:[E],audioTracks:[],url:j,stats:Y,networkDetails:X,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}Y.parsing.end=performance.now(),J.levelDetails=A,this.handlePlaylistLoaded(A,Q,Y,J,X,z)},H.handleManifestParsingError=function Z(Q,Y,J,X,z){this.hls.trigger($.ERROR,{type:f.NETWORK_ERROR,details:D.MANIFEST_PARSING_ERROR,fatal:Y.type===o.MANIFEST,url:Q.url,err:J,error:J,reason:J.message,response:Q,context:Y,networkDetails:X,stats:z})},H.handleNetworkError=function Z(Q,Y,J,X,z){if(J===void 0)J=!1;var N="A network "+(J?"timeout":"error"+(X?" (status "+X.code+")":""))+" occurred while loading "+Q.type;if(Q.type===o.LEVEL)N+=": "+Q.level+" id: "+Q.id;else if(Q.type===o.AUDIO_TRACK||Q.type===o.SUBTITLE_TRACK)N+=" id: "+Q.id+' group-id: "'+Q.groupId+'"';var W=new Error(N);this.hls.logger.warn("[playlist-loader]: "+N);var G=D.UNKNOWN,K=!1,j=this.getInternalLoader(Q);switch(Q.type){case o.MANIFEST:G=J?D.MANIFEST_LOAD_TIMEOUT:D.MANIFEST_LOAD_ERROR,K=!0;break;case o.LEVEL:G=J?D.LEVEL_LOAD_TIMEOUT:D.LEVEL_LOAD_ERROR,K=!1;break;case o.AUDIO_TRACK:G=J?D.AUDIO_TRACK_LOAD_TIMEOUT:D.AUDIO_TRACK_LOAD_ERROR,K=!1;break;case o.SUBTITLE_TRACK:G=J?D.SUBTITLE_TRACK_LOAD_TIMEOUT:D.SUBTITLE_LOAD_ERROR,K=!1;break}if(j)this.resetInternalLoader(Q.type);var V={type:f.NETWORK_ERROR,details:G,fatal:K,url:Q.url,loader:j,context:Q,error:W,networkDetails:Y,stats:z};if(X){var U=(Y==null?void 0:Y.url)||Q.url;V.response=I0({url:U,data:void 0},X)}this.hls.trigger($.ERROR,V)},H.handlePlaylistLoaded=function Z(Q,Y,J,X,z,N){var W=this.hls,G=X.type,K=X.level,j=X.id,V=X.groupId,U=X.deliveryDirectives,A=M7(Y,X),E=wJ(X),B=typeof X.level==="number"&&E===d.MAIN?K:void 0;if(!Q.fragments.length){var F=Q.playlistParsingError=new Error("No Segments found in Playlist");W.trigger($.ERROR,{type:f.NETWORK_ERROR,details:D.LEVEL_EMPTY_ERROR,fatal:!1,url:A,error:F,reason:F.message,response:Y,context:X,level:B,parent:E,networkDetails:z,stats:J});return}if(!Q.targetduration)Q.playlistParsingError=new Error("Missing Target Duration");var R=Q.playlistParsingError;if(R){if(this.hls.logger.warn(R),!W.config.ignorePlaylistParsingErrors){W.trigger($.ERROR,{type:f.NETWORK_ERROR,details:D.LEVEL_PARSING_ERROR,fatal:!1,url:A,error:R,reason:R.message,response:Y,context:X,level:B,parent:E,networkDetails:z,stats:J});return}Q.playlistParsingError=null}if(Q.live&&N){if(N.getCacheAge)Q.ageHeader=N.getCacheAge()||0;if(!N.getCacheAge||isNaN(Q.ageHeader))Q.ageHeader=0}switch(G){case o.MANIFEST:case o.LEVEL:W.trigger($.LEVEL_LOADED,{details:Q,levelInfo:X.levelOrTrack||W.levels[0],level:B||0,id:j||0,stats:J,networkDetails:z,deliveryDirectives:U,withoutMultiVariant:G===o.MANIFEST});break;case o.AUDIO_TRACK:W.trigger($.AUDIO_TRACK_LOADED,{details:Q,track:X.levelOrTrack,id:j||0,groupId:V||"",stats:J,networkDetails:z,deliveryDirectives:U});break;case o.SUBTITLE_TRACK:W.trigger($.SUBTITLE_TRACK_LOADED,{details:Q,track:X.levelOrTrack,id:j||0,groupId:V||"",stats:J,networkDetails:z,deliveryDirectives:U});break}},q}(),Xq={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]};function Hq(q,H){return{supported:!1,configurations:H,decodingInfoResults:[{supported:!1,smooth:!1,powerEfficient:!1}],error:q}}var LJ={};function zq(q,H,Z){var{videoCodec:Q,audioCodec:Y}=q;if(!Q&&!Y||!Z)return Promise.resolve(Xq);var J=[];if(Q){var X={width:q.width,height:q.height,bitrate:Math.ceil(Math.max(q.bitrate*0.9,q.averageBitrate)),framerate:q.frameRate||30},z=q.videoRange;if(z!=="SDR")X.transferFunction=z.toLowerCase();var N=Q.split(","),W=navigator.userAgent;if(N.some(function(G){return rY(G)})&&i7())return Promise.resolve(Hq(new Error("Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent sting: ("+W+")"),J));J.push.apply(J,N.map(function(G){return{type:"media-source",video:I0(I0({},X),{},{contentType:XY(R8(G),"video")})}}))}if(Y&&q.audioGroups)q.audioGroups.forEach(function(G){var K;if(!G)return;(K=H.groups[G])==null||K.tracks.forEach(function(j){if(j.groupId===G){var V=j.channels||"",U=parseFloat(V);if(v(U)&&U>2)J.push.apply(J,Y.split(",").map(function(A){return{type:"media-source",audio:{contentType:XY(A,"audio"),channels:""+U}}}))}})});return Promise.all(J.map(function(G){var K=Nq(G);return LJ[K]||(LJ[K]=Z.decodingInfo(G))})).then(function(G){return{supported:!G.some(function(K){return!K.supported}),configurations:J,decodingInfoResults:G}}).catch(function(G){return{supported:!1,configurations:J,decodingInfoResults:[],error:G}})}function Nq(q){var{audio:H,video:Z}=q,Q=Z||H;if(Q){var Y=YQ(Q.contentType);if(Z)return"r"+Z.height+"x"+Z.width+"f"+Math.ceil(Z.framerate)+(Z.transferFunction||"sd")+"_"+Y+"_"+Math.ceil(Z.bitrate/1e5);if(H)return"c"+H.channels+(H.spatialRendering?"s":"n")+"_"+Y}return""}var bJ=function(){function q(Z){if(Z===void 0)Z={};this.config=void 0,this.userConfig=void 0,this.logger=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new pY,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 Q=this.logger=_7(Z.debug||!1,"Hls instance",Z.assetPlayerId),Y=this.config=F9(q.DefaultConfig,Z,Q);if(this.userConfig=Z,Y.progressive)O9(Y,Q);var{abrController:J,bufferController:X,capLevelController:z,errorController:N,fpsController:W}=Y,G=new N(this),K=this.abrController=new J(this),j=new R9(this),V=Y.interstitialsController,U=V?this.interstitialsController=new V(this,q):null,A=this.bufferController=new X(this,j),E=this.capLevelController=new z(this),B=new W(this),F=new qq(this),R=Y.contentSteeringController,O=R?new R(this):null,M=this.levelController=new d9(this,O),L=new u9(this),I=new Zq(this.config),w=this.streamController=new Jq(this,j,I),S=this.gapController=new y9(this,j);E.setStreamController(w),B.setStreamController(w);var P=[F,M,w];if(U)P.splice(1,0,U);if(O)P.splice(1,0,O);this.networkControllers=P;var b=[K,A,S,E,B,L,j];this.audioTrackController=this.createController(Y.audioTrackController,P);var C=Y.audioStreamController;if(C)P.push(this.audioStreamController=new C(this,j,I));this.subtitleTrackController=this.createController(Y.subtitleTrackController,P);var x=Y.subtitleStreamController;if(x)P.push(this.subtititleStreamController=new x(this,j,I));this.createController(Y.timelineController,b),I.emeController=this.emeController=this.createController(Y.emeController,b),this.cmcdController=this.createController(Y.cmcdController,b),this.latencyController=this.createController(c9,b),this.coreComponents=b,P.push(G);var _=G.onErrorOut;if(typeof _==="function")this.on($.ERROR,_,G);this.on($.MANIFEST_LOADED,F.onManifestLoaded,F)}q.isMSESupported=function Z(){return IJ()},q.isSupported=function Z(){return e9()},q.getMediaSource=function Z(){return d0()};var H=q.prototype;return H.createController=function Z(Q,Y){if(Q){var J=new Q(this);if(Y)Y.push(J);return J}return null},H.on=function Z(Q,Y,J){if(J===void 0)J=this;this._emitter.on(Q,Y,J)},H.once=function Z(Q,Y,J){if(J===void 0)J=this;this._emitter.once(Q,Y,J)},H.removeAllListeners=function Z(Q){this._emitter.removeAllListeners(Q)},H.off=function Z(Q,Y,J,X){if(J===void 0)J=this;this._emitter.off(Q,Y,J,X)},H.listeners=function Z(Q){return this._emitter.listeners(Q)},H.emit=function Z(Q,Y,J){return this._emitter.emit(Q,Y,J)},H.trigger=function Z(Q,Y){if(this.config.debug)return this.emit(Q,Q,Y);else try{return this.emit(Q,Q,Y)}catch(X){if(this.logger.error("An internal error happened while handling event "+Q+'. Error message: "'+X.message+'". Here is a stacktrace:',X),!this.triggeringException){this.triggeringException=!0;var J=Q===$.ERROR;this.trigger($.ERROR,{type:f.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,fatal:J,event:Q,error:X}),this.triggeringException=!1}}return!1},H.listenerCount=function Z(Q){return this._emitter.listenerCount(Q)},H.destroy=function Z(){this.logger.log("destroy"),this.trigger($.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this._url=null,this.networkControllers.forEach(function(Y){return Y.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(Y){return Y.destroy()}),this.coreComponents.length=0;var Q=this.config;Q.xhrSetup=Q.fetchSetup=void 0,this.userConfig=null},H.attachMedia=function Z(Q){if(!Q||"media"in Q&&!Q.media){var Y=new Error("attachMedia failed: invalid argument ("+Q+")");this.trigger($.ERROR,{type:f.OTHER_ERROR,details:D.ATTACH_MEDIA_ERROR,fatal:!0,error:Y});return}if(this.logger.log("attachMedia"),this._media)this.logger.warn("media must be detached before attaching"),this.detachMedia();var J="media"in Q,X=J?Q.media:Q,z=J?Q:{media:X};this._media=X,this.trigger($.MEDIA_ATTACHING,z)},H.detachMedia=function Z(){this.logger.log("detachMedia"),this.trigger($.MEDIA_DETACHING,{}),this._media=null},H.transferMedia=function Z(){this._media=null;var Q=this.bufferController.transferMedia();return this.trigger($.MEDIA_DETACHING,{transferMedia:Q}),Q},H.loadSource=function Z(Q){this.stopLoad();var Y=this.media,J=this._url,X=this._url=cY.buildAbsoluteURL(self.location.href,Q,{alwaysNormalize:!0});if(this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log("loadSource:"+X),Y&&J&&(J!==X||this.bufferController.hasSourceTypes()))this.detachMedia(),this.attachMedia(Y);this.trigger($.MANIFEST_LOADING,{url:Q})},H.startLoad=function Z(Q,Y){if(Q===void 0)Q=-1;this.logger.log("startLoad("+(Q+(Y?", <skip seek to start>":""))+")"),this.started=!0,this.resumeBuffering();for(var J=0;J<this.networkControllers.length;J++)if(this.networkControllers[J].startLoad(Q,Y),!this.started||!this.networkControllers)break},H.stopLoad=function Z(){this.logger.log("stopLoad"),this.started=!1;for(var Q=0;Q<this.networkControllers.length;Q++)if(this.networkControllers[Q].stopLoad(),this.started||!this.networkControllers)break},H.resumeBuffering=function Z(){if(!this.bufferingEnabled)this.logger.log("resume buffering"),this.networkControllers.forEach(function(Q){if(Q.resumeBuffering)Q.resumeBuffering()})},H.pauseBuffering=function Z(){if(this.bufferingEnabled)this.logger.log("pause buffering"),this.networkControllers.forEach(function(Q){if(Q.pauseBuffering)Q.pauseBuffering()})},H.swapAudioCodec=function Z(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},H.recoverMediaError=function Z(){this.logger.log("recoverMediaError");var Q=this._media,Y=Q==null?void 0:Q.currentTime;if(this.detachMedia(),Q){if(this.attachMedia(Q),Y)this.startLoad(Y)}},H.removeLevel=function Z(Q){this.levelController.removeLevel(Q)},H.setAudioOption=function Z(Q){var Y;return((Y=this.audioTrackController)==null?void 0:Y.setAudioOption(Q))||null},H.setSubtitleOption=function Z(Q){var Y;return((Y=this.subtitleTrackController)==null?void 0:Y.setSubtitleOption(Q))||null},H.getMediaDecodingInfo=function Z(Q,Y){if(Y===void 0)Y=this.allAudioTracks;var J=XQ(Y);return zq(Q,J,navigator.mediaCapabilities)},q0(q,[{key:"url",get:function Z(){return this._url}},{key:"hasEnoughToStart",get:function Z(){return this.streamController.hasEnoughToStart}},{key:"startPosition",get:function Z(){return this.streamController.startPositionValue}},{key:"loadingEnabled",get:function Z(){return this.started}},{key:"bufferingEnabled",get:function Z(){return this.streamController.bufferingEnabled}},{key:"inFlightFragments",get:function Z(){var Q,Y=(Q={},Q[d.MAIN]=this.streamController.inFlightFrag,Q);if(this.audioStreamController)Y[d.AUDIO]=this.audioStreamController.inFlightFrag;if(this.subtititleStreamController)Y[d.SUBTITLE]=this.subtititleStreamController.inFlightFrag;return Y}},{key:"sessionId",get:function Z(){var Q=this._sessionId;if(!Q)Q=this._sessionId=fJ();return Q}},{key:"levels",get:function Z(){var Q=this.levelController.levels;return Q?Q:[]}},{key:"latestLevelDetails",get:function Z(){return this.streamController.getLevelDetails()||null}},{key:"loadLevelObj",get:function Z(){return this.levelController.loadLevelObj}},{key:"currentLevel",get:function Z(){return this.streamController.currentLevel},set:function Z(Q){this.logger.log("set currentLevel:"+Q),this.levelController.manualLevel=Q,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function Z(){return this.streamController.nextLevel},set:function Z(Q){this.logger.log("set nextLevel:"+Q),this.levelController.manualLevel=Q,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function Z(){return this.levelController.level},set:function Z(Q){this.logger.log("set loadLevel:"+Q),this.levelController.manualLevel=Q}},{key:"nextLoadLevel",get:function Z(){return this.levelController.nextLoadLevel},set:function Z(Q){this.levelController.nextLoadLevel=Q}},{key:"firstLevel",get:function Z(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function Z(Q){this.logger.log("set firstLevel:"+Q),this.levelController.firstLevel=Q}},{key:"startLevel",get:function Z(){var Q=this.levelController.startLevel;if(Q===-1&&this.abrController.forcedAutoLevel>-1)return this.abrController.forcedAutoLevel;return Q},set:function Z(Q){if(this.logger.log("set startLevel:"+Q),Q!==-1)Q=Math.max(Q,this.minAutoLevel);this.levelController.startLevel=Q}},{key:"capLevelToPlayerSize",get:function Z(){return this.config.capLevelToPlayerSize},set:function Z(Q){var Y=!!Q;if(Y!==this.config.capLevelToPlayerSize){if(Y)this.capLevelController.startCapping();else this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch();this.config.capLevelToPlayerSize=Y}}},{key:"autoLevelCapping",get:function Z(){return this._autoLevelCapping},set:function Z(Q){if(this._autoLevelCapping!==Q)this.logger.log("set autoLevelCapping:"+Q),this._autoLevelCapping=Q,this.levelController.checkMaxAutoUpdated()}},{key:"bandwidthEstimate",get:function Z(){var Q=this.abrController.bwEstimator;if(!Q)return NaN;return Q.getEstimate()},set:function Z(Q){this.abrController.resetEstimator(Q)}},{key:"abrEwmaDefaultEstimate",get:function Z(){var Q=this.abrController.bwEstimator;if(!Q)return NaN;return Q.defaultEstimate}},{key:"ttfbEstimate",get:function Z(){var Q=this.abrController.bwEstimator;if(!Q)return NaN;return Q.getEstimateTTFB()}},{key:"maxHdcpLevel",get:function Z(){return this._maxHdcpLevel},set:function Z(Q){if(M8(Q)&&this._maxHdcpLevel!==Q)this._maxHdcpLevel=Q,this.levelController.checkMaxAutoUpdated()}},{key:"autoLevelEnabled",get:function Z(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function Z(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function Z(){var Q=this.levels,Y=this.config.minAutoBitrate;if(!Q)return 0;var J=Q.length;for(var X=0;X<J;X++)if(Q[X].maxBitrate>=Y)return X;return 0}},{key:"maxAutoLevel",get:function Z(){var Q=this.levels,Y=this.autoLevelCapping,J=this.maxHdcpLevel,X;if(Y===-1&&Q!=null&&Q.length)X=Q.length-1;else X=Y;if(J)for(var z=X;z--;){var N=Q[z].attrs["HDCP-LEVEL"];if(N&&N<=J)return z}return X}},{key:"firstAutoLevel",get:function Z(){return this.abrController.firstAutoLevel}},{key:"nextAutoLevel",get:function Z(){return this.abrController.nextAutoLevel},set:function Z(Q){this.abrController.nextAutoLevel=Q}},{key:"playingDate",get:function Z(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function Z(){return this.streamController.getMainFwdBufferInfo()}},{key:"maxBufferLength",get:function Z(){return this.streamController.maxBufferLength}},{key:"allAudioTracks",get:function Z(){var Q=this.audioTrackController;return Q?Q.allAudioTracks:[]}},{key:"audioTracks",get:function Z(){var Q=this.audioTrackController;return Q?Q.audioTracks:[]}},{key:"audioTrack",get:function Z(){var Q=this.audioTrackController;return Q?Q.audioTrack:-1},set:function Z(Q){var Y=this.audioTrackController;if(Y)Y.audioTrack=Q}},{key:"allSubtitleTracks",get:function Z(){var Q=this.subtitleTrackController;return Q?Q.allSubtitleTracks:[]}},{key:"subtitleTracks",get:function Z(){var Q=this.subtitleTrackController;return Q?Q.subtitleTracks:[]}},{key:"subtitleTrack",get:function Z(){var Q=this.subtitleTrackController;return Q?Q.subtitleTrack:-1},set:function Z(Q){var Y=this.subtitleTrackController;if(Y)Y.subtitleTrack=Q}},{key:"media",get:function Z(){return this._media}},{key:"subtitleDisplay",get:function Z(){var Q=this.subtitleTrackController;return Q?Q.subtitleDisplay:!1},set:function Z(Q){var Y=this.subtitleTrackController;if(Y)Y.subtitleDisplay=Q}},{key:"lowLatencyMode",get:function Z(){return this.config.lowLatencyMode},set:function Z(Q){this.config.lowLatencyMode=Q}},{key:"liveSyncPosition",get:function Z(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function Z(){return this.latencyController.latency}},{key:"maxLatency",get:function Z(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function Z(){return this.latencyController.targetLatency},set:function Z(Q){this.latencyController.targetLatency=Q}},{key:"drift",get:function Z(){return this.latencyController.drift}},{key:"forceStartLoad",get:function Z(){return this.streamController.forceStartLoad}},{key:"pathways",get:function Z(){return this.levelController.pathways}},{key:"pathwayPriority",get:function Z(){return this.levelController.pathwayPriority},set:function Z(Q){this.levelController.pathwayPriority=Q}},{key:"bufferedToEnd",get:function Z(){var Q;return!!((Q=this.bufferController)!=null&&Q.bufferedToEnd)}},{key:"interstitialsManager",get:function Z(){var Q;return((Q=this.interstitialsController)==null?void 0:Q.interstitialsManager)||null}}],[{key:"version",get:function Z(){return KY}},{key:"Events",get:function Z(){return $}},{key:"MetadataSchema",get:function Z(){return D0}},{key:"ErrorTypes",get:function Z(){return f}},{key:"ErrorDetails",get:function Z(){return D}},{key:"DefaultConfig",get:function Z(){if(!q.defaultConfig)return B9;return q.defaultConfig},set:function Z(Q){q.defaultConfig=Q}}])}();return bJ.defaultConfig=void 0,bJ})})(!1)});var Cq={};bq(Cq,{Hls:()=>mJ.default});var mJ=Iq(gJ());})();
|
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}));
|