lemon-mse 0.3.8 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,27 @@
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
+ Time to underbuffer: `+S.toFixed(3)+` s
4
+ Estimated load time for current fragment: `+m.toFixed(3)+` s
5
+ Estimated load time for down switch fragment: `+a.toFixed(3)+` s
6
+ TTFB estimate: `+(P|0)+` ms
7
+ Current BW estimate: `+(v(C)?C|0:"Unknown")+` bps
8
+ New BW estimate: `+(Y.getBwEstimate()|0)+` bps
9
+ Switching to level `+l+" @ "+(X0|0)+" bps"),G.nextLoadLevel=G.nextAutoLevel=l,Y.clearTimer();var A0=function e(){if(Y.clearTimer(),Y.fragCurrent===N&&Y.hls.loadLevel===l&&l>0){var b0=Y.getStarvationDelay();if(Y.warn("Aborting inflight request "+(l>0?"and switching down":"")+`
10
+ Fragment duration: `+N.duration.toFixed(3)+` s
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`
12
+ `+this.list("video")+`
13
+ `+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: `+M0(z,function(A,E){return A==="initSegment"?void 0:E})+`;
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 @`+H.startSN+`
18
+ `+H.m3u8+`
19
+
20
+ Playlist starting @`+Z.startSN+`
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: `+M+`
23
+ trackSwitch: `+L+`
24
+ contiguous: `+P+`
25
+ accurateTimeOffset: `+G+`
26
+ timeOffset: `+F+`
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());})();