lemon-mse 0.4.0 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,32 +1,35 @@
1
- (()=>{var $G=Object.create;var{getPrototypeOf:IG,defineProperty:fY,getOwnPropertyNames:dZ,getOwnPropertyDescriptor:LG}=Object,nZ=Object.prototype.hasOwnProperty;var LY=(j,F,K)=>{K=j!=null?$G(IG(j)):{};let U=F||!j||!j.__esModule?fY(K,"default",{value:j,enumerable:!0}):K;for(let N of dZ(j))if(!nZ.call(U,N))fY(U,N,{get:()=>j[N],enumerable:!0});return U},lZ=new WeakMap,EQ=(j)=>{var F=lZ.get(j),K;if(F)return F;if(F=fY({},"__esModule",{value:!0}),j&&typeof j==="object"||typeof j==="function")dZ(j).map((U)=>!nZ.call(F,U)&&fY(F,U,{get:()=>j[U],enumerable:!(K=LG(j,U))||K.enumerable}));return lZ.set(j,F),F},oZ=(j,F)=>()=>(F||j((F={exports:{}}).exports,F),F.exports);var BQ=(j,F)=>{for(var K in F)fY(j,K,{get:F[K],enumerable:!0,configurable:!0,set:(U)=>F[K]=()=>U})};var CY=oZ((UW,RQ)=>{var DG=Object.prototype.hasOwnProperty,F1="~";function cY(){}if(Object.create){if(cY.prototype=Object.create(null),!new cY().__proto__)F1=!1}function SG(j,F,K){this.fn=j,this.context=F,this.once=K||!1}function Y8(j,F,K,U,N){if(typeof K!=="function")throw new TypeError("The listener must be a function");var O=new SG(K,U||j,N),B=F1?F1+F:F;if(!j._events[B])j._events[B]=O,j._eventsCount++;else if(!j._events[B].fn)j._events[B].push(O);else j._events[B]=[j._events[B],O];return j}function bJ(j,F){if(--j._eventsCount===0)j._events=new cY;else delete j._events[F]}function j1(){this._events=new cY,this._eventsCount=0}j1.prototype.eventNames=function j(){var F=[],K,U;if(this._eventsCount===0)return F;for(U in K=this._events)if(DG.call(K,U))F.push(F1?U.slice(1):U);if(Object.getOwnPropertySymbols)return F.concat(Object.getOwnPropertySymbols(K));return F};j1.prototype.listeners=function j(F){var K=F1?F1+F:F,U=this._events[K];if(!U)return[];if(U.fn)return[U.fn];for(var N=0,O=U.length,B=new Array(O);N<O;N++)B[N]=U[N].fn;return B};j1.prototype.listenerCount=function j(F){var K=F1?F1+F:F,U=this._events[K];if(!U)return 0;if(U.fn)return 1;return U.length};j1.prototype.emit=function j(F,K,U,N,O,B){var w=F1?F1+F:F;if(!this._events[w])return!1;var R=this._events[w],P=arguments.length,x,k;if(R.fn){if(R.once)this.removeListener(F,R.fn,void 0,!0);switch(P){case 1:return R.fn.call(R.context),!0;case 2:return R.fn.call(R.context,K),!0;case 3:return R.fn.call(R.context,K,U),!0;case 4:return R.fn.call(R.context,K,U,N),!0;case 5:return R.fn.call(R.context,K,U,N,O),!0;case 6:return R.fn.call(R.context,K,U,N,O,B),!0}for(k=1,x=new Array(P-1);k<P;k++)x[k-1]=arguments[k];R.fn.apply(R.context,x)}else{var f=R.length,l;for(k=0;k<f;k++){if(R[k].once)this.removeListener(F,R[k].fn,void 0,!0);switch(P){case 1:R[k].fn.call(R[k].context);break;case 2:R[k].fn.call(R[k].context,K);break;case 3:R[k].fn.call(R[k].context,K,U);break;case 4:R[k].fn.call(R[k].context,K,U,N);break;default:if(!x)for(l=1,x=new Array(P-1);l<P;l++)x[l-1]=arguments[l];R[k].fn.apply(R[k].context,x)}}}return!0};j1.prototype.on=function j(F,K,U){return Y8(this,F,K,U,!1)};j1.prototype.once=function j(F,K,U){return Y8(this,F,K,U,!0)};j1.prototype.removeListener=function j(F,K,U,N){var O=F1?F1+F:F;if(!this._events[O])return this;if(!K)return bJ(this,O),this;var B=this._events[O];if(B.fn){if(B.fn===K&&(!N||B.once)&&(!U||B.context===U))bJ(this,O)}else{for(var w=0,R=[],P=B.length;w<P;w++)if(B[w].fn!==K||N&&!B[w].once||U&&B[w].context!==U)R.push(B[w]);if(R.length)this._events[O]=R.length===1?R[0]:R;else bJ(this,O)}return this};j1.prototype.removeAllListeners=function j(F){var K;if(F){if(K=F1?F1+F:F,this._events[K])bJ(this,K)}else this._events=new cY,this._eventsCount=0;return this};j1.prototype.off=j1.prototype.removeListener;j1.prototype.addListener=j1.prototype.on;j1.prefixed=F1;j1.EventEmitter=j1;if(typeof RQ!=="undefined")RQ.exports=j1});var e8=oZ((t8,dQ)=>{(function j(F){(function(K,U){typeof t8==="object"&&typeof dQ!=="undefined"?dQ.exports=U():typeof define==="function"&&define.amd?define(U):(K=typeof globalThis!=="undefined"?globalThis:K||self,K.Hls=U())})(this,function(){function K(X,W,Z){if(x())return Reflect.construct.apply(null,arguments);var J=[null];J.push.apply(J,W);var Y=new(X.bind.apply(X,J));return Z&&l(Y,Z.prototype),Y}function U(X,W){for(var Z=0;Z<W.length;Z++){var J=W[Z];J.enumerable=J.enumerable||!1,J.configurable=!0,"value"in J&&(J.writable=!0),Object.defineProperty(X,Y0(J.key),J)}}function N(X,W,Z){return W&&U(X.prototype,W),Z&&U(X,Z),Object.defineProperty(X,"prototype",{writable:!1}),X}function O(X,W,Z){return(W=Y0(W))in X?Object.defineProperty(X,W,{value:Z,enumerable:!0,configurable:!0,writable:!0}):X[W]=Z,X}function B(){return B=Object.assign?Object.assign.bind():function(X){for(var W=1;W<arguments.length;W++){var Z=arguments[W];for(var J in Z)({}).hasOwnProperty.call(Z,J)&&(X[J]=Z[J])}return X},B.apply(null,arguments)}function w(X){return w=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(W){return W.__proto__||Object.getPrototypeOf(W)},w(X)}function R(X,W){X.prototype=Object.create(W.prototype),X.prototype.constructor=X,l(X,W)}function P(X){try{return Function.toString.call(X).indexOf("[native code]")!==-1}catch(W){return typeof X=="function"}}function x(){try{var X=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(W){}return(x=function(){return!!X})()}function k(X,W){var Z=Object.keys(X);if(Object.getOwnPropertySymbols){var J=Object.getOwnPropertySymbols(X);W&&(J=J.filter(function(Y){return Object.getOwnPropertyDescriptor(X,Y).enumerable})),Z.push.apply(Z,J)}return Z}function f(X){for(var W=1;W<arguments.length;W++){var Z=arguments[W]!=null?arguments[W]:{};W%2?k(Object(Z),!0).forEach(function(J){O(X,J,Z[J])}):Object.getOwnPropertyDescriptors?Object.defineProperties(X,Object.getOwnPropertyDescriptors(Z)):k(Object(Z)).forEach(function(J){Object.defineProperty(X,J,Object.getOwnPropertyDescriptor(Z,J))})}return X}function l(X,W){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(Z,J){return Z.__proto__=J,Z},l(X,W)}function s(X,W){if(typeof X!="object"||!X)return X;var Z=X[Symbol.toPrimitive];if(Z!==void 0){var J=Z.call(X,W);if(typeof J!="object")return J;throw new TypeError("@@toPrimitive must return a primitive value.")}return(W==="string"?String:Number)(X)}function Y0(X){var W=s(X,"string");return typeof W=="symbol"?W:W+""}function t(X){var W=typeof Map=="function"?new Map:void 0;return t=function(Z){if(Z===null||!P(Z))return Z;if(typeof Z!="function")throw new TypeError("Super expression must either be null or a function");if(W!==void 0){if(W.has(Z))return W.get(Z);W.set(Z,J)}function J(){return K(Z,arguments,w(this).constructor)}return J.prototype=Object.create(Z.prototype,{constructor:{value:J,enumerable:!1,writable:!0,configurable:!0}}),l(J,Z)},t(X)}function K0(){try{return crypto.randomUUID()}catch(Y){try{var X=URL.createObjectURL(new Blob),W=X.toString();return URL.revokeObjectURL(X),W.slice(W.lastIndexOf("/")+1)}catch(Q){var Z=new Date().getTime(),J="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(G){var q=(Z+Math.random()*16)%16|0;return Z=Math.floor(Z/16),(G=="x"?q:q&3|8).toString(16)});return J}}}function q0(X){return X&&X.__esModule&&Object.prototype.hasOwnProperty.call(X,"default")?X.default:X}var R0={exports:{}},U0;function W0(){if(U0)return R0.exports;return U0=1,function(X){var W=Object.prototype.hasOwnProperty,Z="~";function J(){}if(Object.create){if(J.prototype=Object.create(null),!new J().__proto__)Z=!1}function Y(H,V,z){this.fn=H,this.context=V,this.once=z||!1}function Q(H,V,z,A,E){if(typeof z!=="function")throw new TypeError("The listener must be a function");var I=new Y(z,A||H,E),$=Z?Z+V:V;if(!H._events[$])H._events[$]=I,H._eventsCount++;else if(!H._events[$].fn)H._events[$].push(I);else H._events[$]=[H._events[$],I];return H}function G(H,V){if(--H._eventsCount===0)H._events=new J;else delete H._events[V]}function q(){this._events=new J,this._eventsCount=0}q.prototype.eventNames=function H(){var V=[],z,A;if(this._eventsCount===0)return V;for(A in z=this._events)if(W.call(z,A))V.push(Z?A.slice(1):A);if(Object.getOwnPropertySymbols)return V.concat(Object.getOwnPropertySymbols(z));return V},q.prototype.listeners=function H(V){var z=Z?Z+V:V,A=this._events[z];if(!A)return[];if(A.fn)return[A.fn];for(var E=0,I=A.length,$=new Array(I);E<I;E++)$[E]=A[E].fn;return $},q.prototype.listenerCount=function H(V){var z=Z?Z+V:V,A=this._events[z];if(!A)return 0;if(A.fn)return 1;return A.length},q.prototype.emit=function H(V,z,A,E,I,$){var L=Z?Z+V:V;if(!this._events[L])return!1;var b=this._events[L],C=arguments.length,D,y;if(b.fn){if(b.once)this.removeListener(V,b.fn,void 0,!0);switch(C){case 1:return b.fn.call(b.context),!0;case 2:return b.fn.call(b.context,z),!0;case 3:return b.fn.call(b.context,z,A),!0;case 4:return b.fn.call(b.context,z,A,E),!0;case 5:return b.fn.call(b.context,z,A,E,I),!0;case 6:return b.fn.call(b.context,z,A,E,I,$),!0}for(y=1,D=new Array(C-1);y<C;y++)D[y-1]=arguments[y];b.fn.apply(b.context,D)}else{var S=b.length,v;for(y=0;y<S;y++){if(b[y].once)this.removeListener(V,b[y].fn,void 0,!0);switch(C){case 1:b[y].fn.call(b[y].context);break;case 2:b[y].fn.call(b[y].context,z);break;case 3:b[y].fn.call(b[y].context,z,A);break;case 4:b[y].fn.call(b[y].context,z,A,E);break;default:if(!D)for(v=1,D=new Array(C-1);v<C;v++)D[v-1]=arguments[v];b[y].fn.apply(b[y].context,D)}}}return!0},q.prototype.on=function H(V,z,A){return Q(this,V,z,A,!1)},q.prototype.once=function H(V,z,A){return Q(this,V,z,A,!0)},q.prototype.removeListener=function H(V,z,A,E){var I=Z?Z+V:V;if(!this._events[I])return this;if(!z)return G(this,I),this;var $=this._events[I];if($.fn){if($.fn===z&&(!E||$.once)&&(!A||$.context===A))G(this,I)}else{for(var L=0,b=[],C=$.length;L<C;L++)if($[L].fn!==z||E&&!$[L].once||A&&$[L].context!==A)b.push($[L]);if(b.length)this._events[I]=b.length===1?b[0]:b;else G(this,I)}return this},q.prototype.removeAllListeners=function H(V){var z;if(V){if(z=Z?Z+V:V,this._events[z])G(this,z)}else this._events=new J,this._eventsCount=0;return this},q.prototype.off=q.prototype.removeListener,q.prototype.addListener=q.prototype.on,q.prefixed=Z,q.EventEmitter=q,X.exports=q}(R0),R0.exports}var z0=W0(),h0=q0(z0),l0={exports:{}},E0;function y0(){if(E0)return l0.exports;return E0=1,function(X,W){(function(Z){var J=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,Y=/^(?=([^\/?#]*))\1([^]*)$/,Q=/(?:\/|^)\.(?=\/)/g,G=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,q={buildAbsoluteURL:function(H,V,z){if(z=z||{},H=H.trim(),V=V.trim(),!V){if(!z.alwaysNormalize)return H;var A=q.parseURL(H);if(!A)throw new Error("Error trying to parse base URL.");return A.path=q.normalizePath(A.path),q.buildURLFromParts(A)}var E=q.parseURL(V);if(!E)throw new Error("Error trying to parse relative URL.");if(E.scheme){if(!z.alwaysNormalize)return V;return E.path=q.normalizePath(E.path),q.buildURLFromParts(E)}var I=q.parseURL(H);if(!I)throw new Error("Error trying to parse base URL.");if(!I.netLoc&&I.path&&I.path[0]!=="/"){var $=Y.exec(I.path);I.netLoc=$[1],I.path=$[2]}if(I.netLoc&&!I.path)I.path="/";var L={scheme:I.scheme,netLoc:E.netLoc,path:null,params:E.params,query:E.query,fragment:E.fragment};if(!E.netLoc){if(L.netLoc=I.netLoc,E.path[0]!=="/")if(!E.path){if(L.path=I.path,!E.params){if(L.params=I.params,!E.query)L.query=I.query}}else{var b=I.path,C=b.substring(0,b.lastIndexOf("/")+1)+E.path;L.path=q.normalizePath(C)}}if(L.path===null)L.path=z.alwaysNormalize?q.normalizePath(E.path):E.path;return q.buildURLFromParts(L)},parseURL:function(H){var V=J.exec(H);if(!V)return null;return{scheme:V[1]||"",netLoc:V[2]||"",path:V[3]||"",params:V[4]||"",query:V[5]||"",fragment:V[6]||""}},normalizePath:function(H){H=H.split("").reverse().join("").replace(Q,"");while(H.length!==(H=H.replace(G,"")).length);return H.split("").reverse().join("")},buildURLFromParts:function(H){return H.scheme+H.netLoc+H.path+H.params+H.query+H.fragment}};X.exports=q})()}(l0),l0.exports}var t0=y0(),T=Number.isFinite||function(X){return typeof X==="number"&&isFinite(X)},u=Number.isSafeInteger||function(X){return typeof X==="number"&&Math.abs(X)<=_},_=Number.MAX_SAFE_INTEGER||9007199254740991,n=function(X){return X.NETWORK_ERROR="networkError",X.MEDIA_ERROR="mediaError",X.KEY_SYSTEM_ERROR="keySystemError",X.MUX_ERROR="muxError",X.OTHER_ERROR="otherError",X}({}),h=function(X){return X.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",X.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",X.KEY_SYSTEM_NO_SESSION="keySystemNoSession",X.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",X.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",X.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",X.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",X.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",X.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",X.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",X.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",X.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",X.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",X.MANIFEST_LOAD_ERROR="manifestLoadError",X.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",X.MANIFEST_PARSING_ERROR="manifestParsingError",X.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",X.LEVEL_EMPTY_ERROR="levelEmptyError",X.LEVEL_LOAD_ERROR="levelLoadError",X.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",X.LEVEL_PARSING_ERROR="levelParsingError",X.LEVEL_SWITCH_ERROR="levelSwitchError",X.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",X.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",X.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",X.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",X.FRAG_LOAD_ERROR="fragLoadError",X.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",X.FRAG_DECRYPT_ERROR="fragDecryptError",X.FRAG_PARSING_ERROR="fragParsingError",X.FRAG_GAP="fragGap",X.REMUX_ALLOC_ERROR="remuxAllocError",X.KEY_LOAD_ERROR="keyLoadError",X.KEY_LOAD_TIMEOUT="keyLoadTimeOut",X.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",X.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",X.BUFFER_APPEND_ERROR="bufferAppendError",X.BUFFER_APPENDING_ERROR="bufferAppendingError",X.BUFFER_STALLED_ERROR="bufferStalledError",X.BUFFER_FULL_ERROR="bufferFullError",X.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",X.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",X.ASSET_LIST_LOAD_ERROR="assetListLoadError",X.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",X.ASSET_LIST_PARSING_ERROR="assetListParsingError",X.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",X.INTERNAL_EXCEPTION="internalException",X.INTERNAL_ABORTED="aborted",X.ATTACH_MEDIA_ERROR="attachMediaError",X.UNKNOWN="unknown",X}({}),M=function(X){return X.MEDIA_ATTACHING="hlsMediaAttaching",X.MEDIA_ATTACHED="hlsMediaAttached",X.MEDIA_DETACHING="hlsMediaDetaching",X.MEDIA_DETACHED="hlsMediaDetached",X.MEDIA_ENDED="hlsMediaEnded",X.STALL_RESOLVED="hlsStallResolved",X.BUFFER_RESET="hlsBufferReset",X.BUFFER_CODECS="hlsBufferCodecs",X.BUFFER_CREATED="hlsBufferCreated",X.BUFFER_APPENDING="hlsBufferAppending",X.BUFFER_APPENDED="hlsBufferAppended",X.BUFFER_EOS="hlsBufferEos",X.BUFFERED_TO_END="hlsBufferedToEnd",X.BUFFER_FLUSHING="hlsBufferFlushing",X.BUFFER_FLUSHED="hlsBufferFlushed",X.MANIFEST_LOADING="hlsManifestLoading",X.MANIFEST_LOADED="hlsManifestLoaded",X.MANIFEST_PARSED="hlsManifestParsed",X.LEVEL_SWITCHING="hlsLevelSwitching",X.LEVEL_SWITCHED="hlsLevelSwitched",X.LEVEL_LOADING="hlsLevelLoading",X.LEVEL_LOADED="hlsLevelLoaded",X.LEVEL_UPDATED="hlsLevelUpdated",X.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",X.LEVELS_UPDATED="hlsLevelsUpdated",X.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",X.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",X.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",X.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",X.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",X.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",X.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",X.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",X.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",X.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",X.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",X.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",X.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",X.CUES_PARSED="hlsCuesParsed",X.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",X.INIT_PTS_FOUND="hlsInitPtsFound",X.FRAG_LOADING="hlsFragLoading",X.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",X.FRAG_LOADED="hlsFragLoaded",X.FRAG_DECRYPTED="hlsFragDecrypted",X.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",X.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",X.FRAG_PARSING_METADATA="hlsFragParsingMetadata",X.FRAG_PARSED="hlsFragParsed",X.FRAG_BUFFERED="hlsFragBuffered",X.FRAG_CHANGED="hlsFragChanged",X.FPS_DROP="hlsFpsDrop",X.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",X.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",X.ERROR="hlsError",X.DESTROYING="hlsDestroying",X.KEY_LOADING="hlsKeyLoading",X.KEY_LOADED="hlsKeyLoaded",X.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",X.BACK_BUFFER_REACHED="hlsBackBufferReached",X.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",X.ASSET_LIST_LOADING="hlsAssetListLoading",X.ASSET_LIST_LOADED="hlsAssetListLoaded",X.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",X.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",X.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",X.INTERSTITIAL_STARTED="hlsInterstitialStarted",X.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",X.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",X.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",X.INTERSTITIAL_ENDED="hlsInterstitialEnded",X.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",X.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",X.EVENT_CUE_ENTER="hlsEventCueEnter",X}({}),Z0={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},G0={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"},C0=function(){function X(Z,J,Y){if(J===void 0)J=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_=J,this.totalWeight_=Y}var W=X.prototype;return W.sample=function Z(J,Y){var Q=Math.pow(this.alpha_,J);this.estimate_=Y*(1-Q)+Q*this.estimate_,this.totalWeight_+=J},W.getTotalWeight=function Z(){return this.totalWeight_},W.getEstimate=function Z(){if(this.alpha_){var J=1-Math.pow(this.alpha_,this.totalWeight_);if(J)return this.estimate_/J}return this.estimate_},X}(),u0=function(){function X(Z,J,Y,Q){if(Q===void 0)Q=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 C0(Z),this.fast_=new C0(J),this.defaultTTFB_=Q,this.ttfb_=new C0(Z)}var W=X.prototype;return W.update=function Z(J,Y){var Q=this.slow_,G=this.fast_,q=this.ttfb_;if(Q.halfLife!==J)this.slow_=new C0(J,Q.getEstimate(),Q.getTotalWeight());if(G.halfLife!==Y)this.fast_=new C0(Y,G.getEstimate(),G.getTotalWeight());if(q.halfLife!==J)this.ttfb_=new C0(J,q.getEstimate(),q.getTotalWeight())},W.sample=function Z(J,Y){J=Math.max(J,this.minDelayMs_);var Q=8*Y,G=J/1000,q=Q/G;this.fast_.sample(G,q),this.slow_.sample(G,q)},W.sampleTTFB=function Z(J){var Y=J/1000,Q=Math.sqrt(2)*Math.exp(-Math.pow(Y,2)/2);this.ttfb_.sample(Q,Math.max(J,5))},W.canEstimate=function Z(){return this.fast_.getTotalWeight()>=this.minWeight_},W.getEstimate=function Z(){if(this.canEstimate())return Math.min(this.fast_.getEstimate(),this.slow_.getEstimate());else return this.defaultEstimate_},W.getEstimateTTFB=function Z(){if(this.ttfb_.getTotalWeight()>=this.minWeight_)return this.ttfb_.getEstimate();else return this.defaultTTFB_},W.destroy=function Z(){},N(X,[{key:"defaultEstimate",get:function Z(){return this.defaultEstimate_}}])}(),d0=function X(W,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 J="["+W+"]:";this.trace=M0,this.debug=Z.debug.bind(null,J),this.log=Z.log.bind(null,J),this.warn=Z.warn.bind(null,J),this.info=Z.info.bind(null,J),this.error=Z.error.bind(null,J)},M0=function X(){},yY={trace:M0,debug:M0,log:M0,warn:M0,info:M0,error:M0};function P1(){return B({},yY)}function TY(X,W){var Z=self.console[X];return Z?Z.bind(self.console,(W?"["+W+"] ":"")+"["+X+"] >"):M0}function xY(X,W,Z){return W[X]?W[X].bind(W):TY(X,Z)}var eY=P1();function e0(X,W,Z){var J=P1();if(typeof console==="object"&&X===!0||typeof X==="object"){var Y=["debug","log","info","warn","error"];Y.forEach(function(Q){J[Q]=xY(Q,X,Z)});try{J.log('Debug logs enabled for "'+W+'" in hls.js version 1.6.0')}catch(Q){return P1()}Y.forEach(function(Q){eY[Q]=xY(Q,X)})}else B(eY,J);return J}var v0=eY,kJ,nQ;function YX(){if(nQ)return kJ;return nQ=1,kJ=void 0,kJ}var oQ=YX(),JX=q0(oQ);function x1(X,W){if(W===void 0)W=!1;if(typeof TextDecoder!=="undefined"){var Z=new TextDecoder("utf-8"),J=Z.decode(X);if(W){var Y=J.indexOf("\x00");return Y!==-1?J.substring(0,Y):J}return J.replace(/\0/g,"")}var Q=X.length,G,q,H,V="",z=0;while(z<Q){if(G=X[z++],G===0&&W)return V;else if(G===0||G===3)continue;switch(G>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:V+=String.fromCharCode(G);break;case 12:case 13:q=X[z++],V+=String.fromCharCode((G&31)<<6|q&63);break;case 14:q=X[z++],H=X[z++],V+=String.fromCharCode((G&15)<<12|(q&63)<<6|(H&63)<<0);break}}return V}var iQ={hexDump:function X(W){var Z="";for(var J=0;J<W.length;J++){var Y=W[J].toString(16);if(Y.length<2)Y="0"+Y;Z+=Y}return Z}},gJ=function X(){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}},i0={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"},sQ=function(){function X(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,ZX(this,"stats")}var W=X.prototype;return W.setByteRange=function Z(J,Y){var Q=J.split("@",2),G;if(Q.length===1)G=(Y==null?void 0:Y.byteRangeEndOffset)||0;else G=parseInt(Q[1]);this._byteRange=[G,parseInt(Q[0])+G]},W.clearElementaryStreamInfo=function Z(){var J=this.elementaryStreams;J[i0.AUDIO]=null,J[i0.VIDEO]=null,J[i0.AUDIOVIDEO]=null},N(X,[{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 J;this._streams=(J={},J[i0.AUDIO]=null,J[i0.VIDEO]=null,J[i0.AUDIOVIDEO]=null,J)}return this._streams},set:function Z(J){this._streams=J}},{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 gJ;return this._stats},set:function Z(J){this._stats=J}},{key:"url",get:function Z(){if(!this._url&&this.baseurl&&this.relurl)this._url=t0.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0});return this._url||""},set:function Z(J){this._url=J}}])}();function d1(X){return X.sn!=="initSegment"}var uJ=function(X){function W(J,Y){var Q=X.call(this,Y)||this;return Q._decryptdata=null,Q._programDateTime=null,Q._ref=null,Q._bitrate=void 0,Q.rawProgramDateTime=null,Q.tagList=[],Q.duration=0,Q.sn=0,Q.levelkeys=void 0,Q.type=void 0,Q.loader=null,Q.keyLoader=null,Q.level=-1,Q.cc=0,Q.startPTS=void 0,Q.endPTS=void 0,Q.startDTS=void 0,Q.endDTS=void 0,Q.start=0,Q.playlistOffset=0,Q.deltaPTS=void 0,Q.maxStartPTS=void 0,Q.minEndPTS=void 0,Q.data=void 0,Q.bitrateTest=!1,Q.title=null,Q.initSegment=null,Q.endList=void 0,Q.gap=void 0,Q.urlId=0,Q.type=J,Q}R(W,X);var Z=W.prototype;return Z.addStart=function J(Y){this.setStart(this.start+Y)},Z.setStart=function J(Y){if(this.start=Y,this._ref)this._ref.start=Y},Z.setDuration=function J(Y){if(this.duration=Y,this._ref)this._ref.duration=Y},Z.setKeyFormat=function J(Y){if(this.levelkeys){var Q=this.levelkeys[Y];if(Q&&!this._decryptdata)this._decryptdata=Q.getDecryptData(this.sn)}},Z.abortRequests=function J(){var Y,Q;(Y=this.loader)==null||Y.abort(),(Q=this.keyLoader)==null||Q.abort()},Z.setElementaryStreamInfo=function J(Y,Q,G,q,H,V){if(V===void 0)V=!1;var z=this.elementaryStreams,A=z[Y];if(!A){z[Y]={startPTS:Q,endPTS:G,startDTS:q,endDTS:H,partial:V};return}A.startPTS=Math.min(A.startPTS,Q),A.endPTS=Math.max(A.endPTS,G),A.startDTS=Math.min(A.startDTS,q),A.endDTS=Math.max(A.endDTS,H)},N(W,[{key:"byteLength",get:function J(){if(this.hasStats){var Y=this.stats.total;if(Y)return Y}if(this.byteRange){var Q=this.byteRange[0],G=this.byteRange[1];if(T(Q)&&T(G))return G-Q}return null}},{key:"bitrate",get:function J(){if(this.byteLength)return this.byteLength*8/this.duration;if(this._bitrate)return this._bitrate;return null},set:function J(Y){this._bitrate=Y}},{key:"decryptdata",get:function J(){var Y=this.levelkeys;if(!Y&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var Q=this.levelkeys.identity;if(Q)this._decryptdata=Q.getDecryptData(this.sn);else{var G=Object.keys(this.levelkeys);if(G.length===1)return this._decryptdata=this.levelkeys[G[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function J(){return this.start+this.duration}},{key:"endProgramDateTime",get:function J(){if(this.programDateTime===null)return null;var Y=!T(this.duration)?0:this.duration;return this.programDateTime+Y*1000}},{key:"encrypted",get:function J(){var Y;if((Y=this._decryptdata)!=null&&Y.encrypted)return!0;else if(this.levelkeys){var Q=Object.keys(this.levelkeys),G=Q.length;if(G>1||G===1&&this.levelkeys[Q[0]].encrypted)return!0}return!1}},{key:"programDateTime",get:function J(){if(this._programDateTime===null&&this.rawProgramDateTime)this.programDateTime=Date.parse(this.rawProgramDateTime);return this._programDateTime},set:function J(Y){if(!T(Y)){this._programDateTime=this.rawProgramDateTime=null;return}this._programDateTime=Y}},{key:"ref",get:function J(){if(!d1(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}}])}(sQ),QX=function(X){function W(Z,J,Y,Q,G){var q=X.call(this,Y)||this;q.fragOffset=0,q.duration=0,q.gap=!1,q.independent=!1,q.relurl=void 0,q.fragment=void 0,q.index=void 0,q.duration=Z.decimalFloatingPoint("DURATION"),q.gap=Z.bool("GAP"),q.independent=Z.bool("INDEPENDENT"),q.relurl=Z.enumeratedString("URI"),q.fragment=J,q.index=Q;var H=Z.enumeratedString("BYTERANGE");if(H)q.setByteRange(H,G);if(G)q.fragOffset=G.fragOffset+G.duration;return q}return R(W,X),N(W,[{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 J=this.elementaryStreams;return!!(J.audio||J.video||J.audiovideo)}}])}(sQ);function rQ(X,W){var Z=Object.getPrototypeOf(X);if(Z){var J=Object.getOwnPropertyDescriptor(Z,W);if(J)return J;return rQ(Z,W)}}function ZX(X,W){var Z=rQ(X,W);if(Z)Z.enumerable=!0,Object.defineProperty(X,W,Z)}var YJ=Math.pow(2,32)-1,XX=[].push,aQ={video:1,audio:2,id3:3,text:4};function W1(X){return String.fromCharCode.apply(null,X)}function tQ(X,W){var Z=X[W]<<8|X[W+1];return Z<0?65536+Z:Z}function B0(X,W){var Z=Y2(X,W);return Z<0?4294967296+Z:Z}function eQ(X,W){var Z=B0(X,W);return Z*=Math.pow(2,32),Z+=B0(X,W+4),Z}function Y2(X,W){return X[W]<<24|X[W+1]<<16|X[W+2]<<8|X[W+3]}function mJ(X,W,Z){X[W]=Z>>24,X[W+1]=Z>>16&255,X[W+2]=Z>>8&255,X[W+3]=Z&255}function GX(X){var W=X.byteLength;for(var Z=0;Z<W;){var J=B0(X,Z);if(J>8&&X[Z+4]===109&&X[Z+5]===111&&X[Z+6]===111&&X[Z+7]===102)return!0;Z=J>1?Z+J:W}return!1}function $0(X,W){var Z=[];if(!W.length)return Z;var J=X.byteLength;for(var Y=0;Y<J;){var Q=B0(X,Y),G=W1(X.subarray(Y+4,Y+8)),q=Q>1?Y+Q:J;if(G===W[0])if(W.length===1)Z.push(X.subarray(Y+8,q));else{var H=$0(X.subarray(Y+8,q),W.slice(1));if(H.length)XX.apply(Z,H)}Y=q}return Z}function WX(X){var W=[],Z=X[0],J=8,Y=B0(X,J);J+=4;var Q=0,G=0;if(Z===0)Q=B0(X,J),G=B0(X,J+4),J+=8;else Q=eQ(X,J),G=eQ(X,J+8),J+=16;J+=2;var q=X.length+G,H=tQ(X,J);J+=2;for(var V=0;V<H;V++){var z=J,A=B0(X,z);z+=4;var E=A&2147483647,I=(A&2147483648)>>>31;if(I===1)return v0.warn("SIDX has hierarchical references (not supported)"),null;var $=B0(X,z);z+=4,W.push({referenceSize:E,subsegmentDuration:$,info:{duration:$/Y,start:q,end:q+E-1}}),q+=E,z+=4,J=z}return{earliestPresentationTime:Q,timescale:Y,version:Z,referencesCount:H,references:W}}function J2(X){var W=[],Z=$0(X,["moov","trak"]);for(var J=0;J<Z.length;J++){var Y=Z[J],Q=$0(Y,["tkhd"])[0];if(Q){var G=Q[0],q=B0(Q,G===0?12:20),H=$0(Y,["mdia","mdhd"])[0];if(H){G=H[0];var V=B0(H,G===0?12:20),z=$0(Y,["mdia","hdlr"])[0];if(z){var A=W1(z.subarray(8,12)),E={soun:i0.AUDIO,vide:i0.VIDEO}[A],I=$0(Y,["mdia","minf","stbl","stsd"])[0],$=KX(I);if(E)W[q]={timescale:V,type:E,stsd:$},W[E]=f({timescale:V,id:q},$);else W[q]={timescale:V,type:A,stsd:$}}}}}var L=$0(X,["moov","mvex","trex"]);return L.forEach(function(b){var C=B0(b,4),D=W[C];if(D)D.default={duration:B0(b,12),flags:B0(b,20)}}),W}function KX(X){var W=X.subarray(8),Z=W.subarray(86),J=W1(W.subarray(4,8)),Y=J,Q,G=J==="enca"||J==="encv";if(G){var q=$0(W,[J])[0],H=q.subarray(J==="enca"?28:78),V=$0(H,["sinf"]);V.forEach(function(V1){var M1=$0(V1,["schm"])[0];if(M1){var n0=W1(M1.subarray(4,8));if(n0==="cbcs"||n0==="cenc"){var z1=$0(V1,["frma"])[0];if(z1)Y=W1(z1)}}})}var z=Y;switch(Y){case"avc1":case"avc2":case"avc3":case"avc4":{var A=$0(Z,["avcC"])[0];Y+="."+QJ(A[1])+QJ(A[2])+QJ(A[3]),Q=JJ(z==="avc1"?"dva1":"dvav",Z);break}case"mp4a":{var E=$0(W,[J])[0],I=$0(E.subarray(28),["esds"])[0];if(I&&I.length>7){var $=4;if(I[$++]!==3)break;$=_J(I,$),$+=2;var L=I[$++];if(L&128)$+=2;if(L&64)$+=I[$++];if(I[$++]!==4)break;$=_J(I,$);var b=I[$++];if(b===64)Y+="."+QJ(b);else break;if($+=12,I[$++]!==5)break;$=_J(I,$);var C=I[$++],D=(C&248)>>3;if(D===31)D+=1+((C&7)<<3)+((I[$]&224)>>5);Y+="."+D}break}case"hvc1":case"hev1":{var y=$0(Z,["hvcC"]);if(y){var S=y[0],v=S[1],p=["","A","B","C"][v>>6],g=v&31,m=B0(S,2),r=(v&32)>>5?"H":"L",o=S[12],c=S.subarray(6,12);Y+="."+p+g,Y+="."+m.toString(16).toUpperCase(),Y+="."+r+o;var d="";for(var e=c.length;e--;){var H0=c[e];if(H0||d){var Q0=H0.toString(16).toUpperCase();d="."+Q0+d}}Y+=d}Q=JJ(z=="hev1"?"dvhe":"dvh1",Z);break}case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":{Y=JJ(Y,Z)||Y;break}case"vp09":{var J0=$0(Z,["vpcC"])[0],N0=J0[4],V0=J0[5],j0=J0[6]>>4&15;Y+="."+n1(N0)+"."+n1(V0)+"."+n1(j0);break}case"av01":{var O0=$0(Z,["av1C"])[0],g0=O0[1]>>>5,T0=O0[1]&31,m0=O0[2]>>>7?"H":"M",D0=(O0[2]&64)>>6,Y1=(O0[2]&32)>>5,_0=g0===2&&D0?Y1?12:10:D0?10:8,a0=(O0[2]&16)>>4,w1=(O0[2]&8)>>3,q1=(O0[2]&4)>>2,p0=O0[2]&3,R1=1,Z1=1,s0=1,$1=0;Y+="."+g0+"."+n1(T0)+m0+"."+n1(_0)+"."+a0+"."+w1+q1+p0+"."+n1(R1)+"."+n1(Z1)+"."+n1(s0)+"."+$1,Q=JJ("dav1",Z);break}}return{codec:Y,encrypted:G,supplemental:Q}}function JJ(X,W){var Z=$0(W,["dvvC"]),J=Z.length?Z[0]:$0(W,["dvcC"])[0];if(J){var Y=J[2]>>1&127,Q=J[2]<<5&32|J[3]>>3&31;return X+"."+n1(Y)+"."+n1(Q)}}function _J(X,W){var Z=W+5;while(X[W++]&128&&W<Z);return W}function QJ(X){return("0"+X.toString(16).toUpperCase()).slice(-2)}function n1(X){return(X<10?"0":"")+X}function qX(X,W){if(!X||!W)return X;var Z=W.keyId;if(Z&&W.isCommonEncryption){var J=$0(X,["moov","trak"]);J.forEach(function(Y){var Q=$0(Y,["mdia","minf","stbl","stsd"])[0],G=Q.subarray(8),q=$0(G,["enca"]),H=q.length>0;if(!H)q=$0(G,["encv"]);q.forEach(function(V){var z=H?V.subarray(28):V.subarray(78),A=$0(z,["sinf"]);A.forEach(function(E){var I=HX(E);if(I){var $=I.subarray(8,24);if(!$.some(function(L){return L!==0}))v0.log("[eme] Patching keyId in 'enc"+(H?"a":"v")+">sinf>>tenc' box: "+iQ.hexDump($)+" -> "+iQ.hexDump(Z)),I.set(Z,8)}})})})}return X}function HX(X){var W=$0(X,["schm"])[0];if(W){var Z=W1(W.subarray(4,8));if(Z==="cbcs"||Z==="cenc")return $0(X,["schi","tenc"])[0]}return null}function NX(X,W){return $0(W,["moof","traf"]).reduce(function(Z,J){var Y=$0(J,["tfdt"])[0],Q=Y[0],G=$0(J,["tfhd"]).reduce(function(q,H){var V=B0(H,4),z=X[V];if(z){var A=B0(Y,4);if(Q===1){if(A===YJ)return v0.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),q;A*=YJ+1,A+=B0(Y,8)}var E=z.timescale||90000,I=A/E;if(T(I)&&(q===null||I<q))return I}return q},null);if(G!==null&&T(G)&&(Z===null||G<Z))return G;return Z},null)}function UX(X,W){var Z=0,J=0,Y=0,Q=$0(X,["moof","traf"]);for(var G=0;G<Q.length;G++){var q=Q[G],H=$0(q,["tfhd"])[0],V=B0(H,4),z=W[V];if(!z)continue;var A=z.default,E=B0(H,0)|(A==null?void 0:A.flags),I=A==null?void 0:A.duration;if(E&8)if(E&2)I=B0(H,12);else I=B0(H,8);var $=z.timescale||90000,L=$0(q,["trun"]);for(var b=0;b<L.length;b++){if(Z=VX(L[b]),!Z&&I){var C=B0(L[b],4);Z=I*C}if(z.type===i0.VIDEO)J+=Z/$;else if(z.type===i0.AUDIO)Y+=Z/$}}if(J===0&&Y===0){var D=1/0,y=0,S=0,v=$0(X,["sidx"]);for(var p=0;p<v.length;p++){var g=WX(v[p]);if(g!=null&&g.references){D=Math.min(D,g.earliestPresentationTime/g.timescale);var m=g.references.reduce(function(r,o){return r+o.info.duration||0},0);y=Math.max(y,m+g.earliestPresentationTime/g.timescale),S=y-D}}if(S&&T(S))return S}if(J)return J;return Y}function VX(X){var W=B0(X,0),Z=8;if(W&1)Z+=4;if(W&4)Z+=4;var J=0,Y=B0(X,4);for(var Q=0;Q<Y;Q++){if(W&256){var G=B0(X,Z);J+=G,Z+=4}if(W&512)Z+=4;if(W&1024)Z+=4;if(W&2048)Z+=4}return J}function zX(X,W,Z){$0(W,["moof","traf"]).forEach(function(J){$0(J,["tfhd"]).forEach(function(Y){var Q=B0(Y,4),G=X[Q];if(!G)return;var q=G.timescale||90000;$0(J,["tfdt"]).forEach(function(H){var V=H[0],z=Z*q;if(z){var A=B0(H,4);if(V===0)A-=z,A=Math.max(A,0),mJ(H,4,A);else{A*=Math.pow(2,32),A+=B0(H,8),A-=z,A=Math.max(A,0);var E=Math.floor(A/(YJ+1)),I=Math.floor(A%(YJ+1));mJ(H,4,E),mJ(H,8,I)}}})})})}function jX(X){var W={valid:null,remainder:null},Z=$0(X,["moof"]);if(Z.length<2)return W.remainder=X,W;var J=Z[Z.length-1];return W.valid=X.slice(0,J.byteOffset-8),W.remainder=X.slice(J.byteOffset-8),W}function v1(X,W){var Z=new Uint8Array(X.length+W.length);return Z.set(X),Z.set(W,X.length),Z}function Q2(X,W){var Z=[],J=W.samples,Y=W.timescale,Q=W.id,G=!1,q=$0(J,["moof"]);return q.map(function(H){var V=H.byteOffset-8,z=$0(H,["traf"]);z.map(function(A){var E=$0(A,["tfdt"]).map(function(I){var $=I[0],L=B0(I,4);if($===1)L*=Math.pow(2,32),L+=B0(I,8);return L/Y})[0];if(E!==void 0)X=E;return $0(A,["tfhd"]).map(function(I){var $=B0(I,4),L=B0(I,0)&16777215,b=(L&1)!==0,C=(L&2)!==0,D=(L&8)!==0,y=0,S=(L&16)!==0,v=0,p=(L&32)!==0,g=8;if($===Q){if(b)g+=8;if(C)g+=4;if(D)y=B0(I,g),g+=4;if(S)v=B0(I,g),g+=4;if(p)g+=4;if(W.type==="video")G=pJ(W.codec);$0(A,["trun"]).map(function(m){var r=m[0],o=B0(m,0)&16777215,c=(o&1)!==0,d=0,e=(o&4)!==0,H0=(o&256)!==0,Q0=0,J0=(o&512)!==0,N0=0,V0=(o&1024)!==0,j0=(o&2048)!==0,O0=0,g0=B0(m,4),T0=8;if(c)d=B0(m,T0),T0+=4;if(e)T0+=4;var m0=d+V;for(var D0=0;D0<g0;D0++){if(H0)Q0=B0(m,T0),T0+=4;else Q0=y;if(J0)N0=B0(m,T0),T0+=4;else N0=v;if(V0)T0+=4;if(j0){if(r===0)O0=B0(m,T0);else O0=Y2(m,T0);T0+=4}if(W.type===i0.VIDEO){var Y1=0;while(Y1<N0){var _0=B0(J,m0);if(m0+=4,AX(G,J[m0])){var a0=J.subarray(m0,m0+_0);Z2(a0,G?2:1,X+O0/Y,Z)}m0+=_0,Y1+=_0+4}}X+=Q0/Y}})}})})}),Z}function pJ(X){if(!X)return!1;var W=X.substring(0,4);return W==="hvc1"||W==="hev1"||W==="dvh1"||W==="dvhe"}function AX(X,W){if(X){var Z=W>>1&63;return Z===39||Z===40}else{var J=W&31;return J===6}}function Z2(X,W,Z,J){var Y=X2(X),Q=0;Q+=W;var G=0,q=0,H=0;while(Q<Y.length){G=0;do{if(Q>=Y.length)break;H=Y[Q++],G+=H}while(H===255);q=0;do{if(Q>=Y.length)break;H=Y[Q++],q+=H}while(H===255);var V=Y.length-Q,z=Q;if(q<V)Q+=q;else if(q>V){v0.error("Malformed SEI payload. "+q+" is too small, only "+V+" bytes left to parse.");break}if(G===4){var A=Y[z++];if(A===181){var E=tQ(Y,z);if(z+=2,E===49){var I=B0(Y,z);if(z+=4,I===1195456820){var $=Y[z++];if($===3){var L=Y[z++],b=31&L,C=64&L,D=C?2+b*3:0,y=new Uint8Array(D);if(C){y[0]=L;for(var S=1;S<D;S++)y[S]=Y[z++]}J.push({type:$,payloadType:G,pts:Z,bytes:y})}}}}}else if(G===5){if(q>16){var v=[];for(var p=0;p<16;p++){var g=Y[z++].toString(16);if(v.push(g.length==1?"0"+g:g),p===3||p===5||p===7||p===9)v.push("-")}var m=q-16,r=new Uint8Array(m);for(var o=0;o<m;o++)r[o]=Y[z++];J.push({payloadType:G,pts:Z,uuid:v.join(""),userData:x1(r),userDataBytes:r})}}}}function X2(X){var W=X.byteLength,Z=[],J=1;while(J<W-2)if(X[J]===0&&X[J+1]===0&&X[J+2]===3)Z.push(J+2),J+=2;else J++;if(Z.length===0)return X;var Y=W-Z.length,Q=new Uint8Array(Y),G=0;for(J=0;J<Y;G++,J++){if(G===Z[0])G++,Z.shift();Q[J]=X[G]}return Q}function OX(X){var W=X[0],Z="",J="",Y=0,Q=0,G=0,q=0,H=0,V=0;if(W===0){while(W1(X.subarray(V,V+1))!=="\x00")Z+=W1(X.subarray(V,V+1)),V+=1;Z+=W1(X.subarray(V,V+1)),V+=1;while(W1(X.subarray(V,V+1))!=="\x00")J+=W1(X.subarray(V,V+1)),V+=1;J+=W1(X.subarray(V,V+1)),V+=1,Y=B0(X,12),Q=B0(X,16),q=B0(X,20),H=B0(X,24),V=28}else if(W===1){V+=4,Y=B0(X,V),V+=4;var z=B0(X,V);V+=4;var A=B0(X,V);if(V+=4,G=Math.pow(2,32)*z+A,!u(G))G=Number.MAX_SAFE_INTEGER,v0.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box");q=B0(X,V),V+=4,H=B0(X,V),V+=4;while(W1(X.subarray(V,V+1))!=="\x00")Z+=W1(X.subarray(V,V+1)),V+=1;Z+=W1(X.subarray(V,V+1)),V+=1;while(W1(X.subarray(V,V+1))!=="\x00")J+=W1(X.subarray(V,V+1)),V+=1;J+=W1(X.subarray(V,V+1)),V+=1}var E=X.subarray(V,X.byteLength);return{schemeIdUri:Z,value:J,timeScale:Y,presentationTime:G,presentationTimeDelta:Q,eventDuration:q,id:H,payload:E}}function XY(X){if(X===void 0)X=!0;if(typeof self==="undefined")return;var W=(X||!self.MediaSource)&&self.ManagedMediaSource;return W||self.MediaSource||self.WebKitMediaSource}function FX(X){return typeof self!=="undefined"&&X===self.ManagedMediaSource}function EX(X,W){var Z=Object.keys(X),J=Object.keys(W),Y=Z.length,Q=J.length;return!Y||!Q||Y===Q&&!Z.some(function(G){return J.indexOf(G)===-1})}var G2=function X(){return/\(Windows.+Firefox\//i.test(navigator.userAgent)},FY={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 W2(X,W){var Z=FY[W];return!!Z&&!!Z[X.slice(0,4)]}function fJ(X,W,Z){if(Z===void 0)Z=!0;return!X.split(",").some(function(J){return!K2(J,W,Z)})}function K2(X,W,Z){var J;if(Z===void 0)Z=!0;var Y=XY(Z);return(J=Y==null?void 0:Y.isTypeSupported(vY(X,W)))!=null?J:!1}function vY(X,W){return W+"/mp4;codecs="+X}function q2(X){if(X){var W=X.substring(0,4);return FY.video[W]}return 2}function ZJ(X){var W=G2();return X.split(",").reduce(function(Z,J){var Y=W&&pJ(J),Q=Y?9:FY.video[J];if(Q)return(Q*2+Z)/(Z?3:2);return(FY.audio[J]+Z)/(Z?2:1)},0)}var cJ={};function BX(X,W){if(W===void 0)W=!0;if(cJ[X])return cJ[X];var Z={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[X];for(var J=0;J<Z.length;J++){var Y;if(K2(Z[J],"audio",W))return cJ[X]=Z[J],Z[J];else if(Z[J]==="mp3"&&(Y=XY(W))!=null&&Y.isTypeSupported("audio/mpeg"))return""}return X}var wX=/flac|opus|mp4a\.40\.34/i;function XJ(X,W){if(W===void 0)W=!0;return X.replace(wX,function(Z){return BX(Z.toLowerCase(),W)})}function RX(X,W){var Z=[];if(X){var J=X.split(",");for(var Y=0;Y<J.length;Y++)if(!W2(J[Y],"video"))Z.push(J[Y])}if(W)Z.push(W);return Z.join(",")}function GJ(X,W){if(X&&(X.length>4||["ac-3","ec-3","alac","fLaC","Opus"].indexOf(X)!==-1))return X;if(W){var Z=W.split(",");if(Z.length>1){if(X){for(var J=Z.length;J--;)if(Z[J].substring(0,4)===X.substring(0,4))return Z[J]}return Z[0]}}return W||X}function $X(X){var W=X.split(",");for(var Z=0;Z<W.length;Z++){var J=W[Z].split(".");if(J.length>2){var Y=J.shift()+".";Y+=parseInt(J.shift()).toString(16),Y+=("000"+parseInt(J.shift()).toString(16)).slice(-4),W[Z]=Y}}return W.join(",")}function IX(X){if(X.startsWith("av01.")){var W=X.split("."),Z=["0","111","01","01","01","0"];for(var J=W.length;J>4&&J<10;J++)W[J]=Z[J-4];return W.join(".")}return X}function H2(X){var W=XY(X)||{isTypeSupported:function Z(){return!1}};return{mpeg:W.isTypeSupported("audio/mpeg"),mp3:W.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:!1}}function N2(X){return X.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}var lJ=["NONE","TYPE-0","TYPE-1",null];function LX(X){return lJ.indexOf(X)>-1}var WJ=["SDR","PQ","HLG"];function bX(X){return!!X&&WJ.indexOf(X)>-1}var KJ={No:"",Yes:"YES",v2:"v2"};function U2(X){var{canSkipUntil:W,canSkipDateRanges:Z,age:J}=X,Y=J<W/2;if(W&&Y){if(Z)return KJ.v2;return KJ.Yes}return KJ.No}var V2=function(){function X(Z,J,Y){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=Z,this.part=J,this.skip=Y}var W=X.prototype;return W.addDirectives=function Z(J){var Y=new self.URL(J);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},X}(),z2=function(){function X(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(Q){return!!Q}).map(function(Q){return Q.substring(0,4)}).join(","),"supplemental"in Z){var J;this.supplemental=Z.supplemental;var Y=(J=Z.supplemental)==null?void 0:J.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 W=X.prototype;return W.hasAudioGroup=function Z(J){return j2(this._audioGroups,J)},W.hasSubtitleGroup=function Z(J){return j2(this._subtitleGroups,J)},W.addGroupId=function Z(J,Y){if(!Y)return;if(J==="audio"){var Q=this._audioGroups;if(!Q)Q=this._audioGroups=[];if(Q.indexOf(Y)===-1)Q.push(Y)}else if(J==="text"){var G=this._subtitleGroups;if(!G)G=this._subtitleGroups=[];if(G.indexOf(Y)===-1)G.push(Y)}},W.addFallback=function Z(){},N(X,[{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(J){}},{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 J;return(J=this.audioGroups)==null?void 0:J[0]}},{key:"textGroupId",get:function Z(){var J;return(J=this.subtitleGroups)==null?void 0:J[0]}}])}();function j2(X,W){if(!W||!X)return!1;return X.indexOf(W)!==-1}function MX(){if(typeof matchMedia==="function"){var X=matchMedia("(dynamic-range: high)"),W=matchMedia("bad query");if(X.media!==W.media)return X.matches===!0}return!1}function CX(X,W){var Z=!1,J=[];if(X)Z=X!=="SDR",J=[X];if(W){J=W.allowedVideoRanges||WJ.slice(0);var Y=J.join("")!=="SDR"&&!W.videoCodec;if(Z=W.preferHDR!==void 0?W.preferHDR:Y&&MX(),!Z)J=["SDR"]}return{preferHDR:Z,allowedVideoRanges:J}}var DX=function X(W){var Z=new WeakSet;return function(J,Y){if(W)Y=W(J,Y);if(typeof Y==="object"&&Y!==null){if(Z.has(Y))return;Z.add(Y)}return Y}},O1=function X(W,Z){return JSON.stringify(W,DX(Z))};function SX(X,W,Z,J,Y){var Q=Object.keys(X),G=J==null?void 0:J.channels,q=J==null?void 0:J.audioCodec,H=Y==null?void 0:Y.videoCodec,V=G&&parseInt(G)===2,z=!1,A=!1,E=1/0,I=1/0,$=1/0,L=1/0,b=0,C=[],D=CX(W,Y),y=D.preferHDR,S=D.allowedVideoRanges,v=function c(){var d=X[Q[p]];z||(z=d.channels[2]>0),E=Math.min(E,d.minHeight),I=Math.min(I,d.minFramerate),$=Math.min($,d.minBitrate);var e=S.filter(function(H0){return d.videoRanges[H0]>0});if(e.length>0)A=!0};for(var p=Q.length;p--;)v();E=T(E)?E:0,I=T(I)?I:0;var g=Math.max(1080,E),m=Math.max(30,I);if($=T($)?$:Z,Z=Math.max($,Z),!A)W=void 0;var r=Q.length>1,o=Q.reduce(function(c,d){var e=X[d];if(d===c)return c;if(C=A?S.filter(function(H0){return e.videoRanges[H0]>0}):[],r){if(e.minBitrate>Z)return o1(d,"min bitrate of "+e.minBitrate+" > current estimate of "+Z),c;if(!e.hasDefaultAudio)return o1(d,"no renditions with default or auto-select sound found"),c;if(q&&d.indexOf(q.substring(0,4))%5!==0)return o1(d,'audio codec preference "'+q+'" not found'),c;if(G&&!V){if(!e.channels[G])return o1(d,"no renditions with "+G+" channel sound found (channels options: "+Object.keys(e.channels)+")"),c}else if((!q||V)&&z&&e.channels["2"]===0)return o1(d,"no renditions with stereo sound found"),c;if(e.minHeight>g)return o1(d,"min resolution of "+e.minHeight+" > maximum of "+g),c;if(e.minFramerate>m)return o1(d,"min framerate of "+e.minFramerate+" > maximum of "+m),c;if(!C.some(function(H0){return e.videoRanges[H0]>0}))return o1(d,"no variants with VIDEO-RANGE of "+O1(C)+" found"),c;if(H&&d.indexOf(H.substring(0,4))%5!==0)return o1(d,'video codec preference "'+H+'" not found'),c;if(e.maxScore<b)return o1(d,"max score of "+e.maxScore+" < selected max of "+b),c}if(c&&(ZJ(d)>=ZJ(c)||e.fragmentError>X[c].fragmentError))return c;return L=e.minIndex,b=e.maxScore,d},void 0);return{codecSet:o,videoRanges:C,preferHDR:y,minFramerate:I,minBitrate:$,minIndex:L}}function o1(X,W){v0.log('[abr] start candidates with "'+X+'" ignored because '+W)}function A2(X){return X.reduce(function(W,Z){var J=W.groups[Z.groupId];if(!J)J=W.groups[Z.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1};J.tracks.push(Z);var Y=Z.channels||"2";if(J.channels[Y]=(J.channels[Y]||0)+1,J.hasDefault=J.hasDefault||Z.default,J.hasAutoSelect=J.hasAutoSelect||Z.autoselect,J.hasDefault)W.hasDefaultAudio=!0;if(J.hasAutoSelect)W.hasAutoSelectAudio=!0;return W},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function PX(X,W,Z,J){return X.slice(Z,J+1).reduce(function(Y,Q,G){if(!Q.codecSet)return Y;var q=Q.audioGroups,H=Y[Q.codecSet];if(!H)Y[Q.codecSet]=H={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:G,maxScore:0,videoRanges:{SDR:0},channels:{"2":0},hasDefaultAudio:!q,fragmentError:0};H.minBitrate=Math.min(H.minBitrate,Q.bitrate);var V=Math.min(Q.height,Q.width);return H.minHeight=Math.min(H.minHeight,V),H.minFramerate=Math.min(H.minFramerate,Q.frameRate),H.minIndex=Math.min(H.minIndex,G),H.maxScore=Math.max(H.maxScore,Q.score),H.fragmentError+=Q.fragmentError,H.videoRanges[Q.videoRange]=(H.videoRanges[Q.videoRange]||0)+1,Y},{})}function O2(X,W){var Z;return!!X&&X!==((Z=W.loadLevelObj)==null?void 0:Z.uri)}var yX=function(X){function W(J){var Y=X.call(this,"abr",J.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(Q){var G,q=Y,H=q.fragCurrent,V=q.partCurrent,z=q.hls,A=z.autoLevelEnabled,E=z.media;if(!H||!E)return;var I=performance.now(),$=V?V.stats:H.stats,L=V?V.duration:H.duration,b=I-$.loading.start,C=z.minAutoLevel,D=H.level,y=Y._nextAutoLevel;if($.aborted||$.loaded&&$.loaded===$.total||D<=C){Y.clearTimer(),Y._nextAutoLevel=-1;return}if(!A)return;var S=y>-1&&y!==D,v=!!Q||S;if(!v&&(E.paused||!E.playbackRate||!E.readyState))return;var p=z.mainForwardBufferInfo;if(!v&&p===null)return;var g=Y.bwEstimator.getEstimateTTFB(),m=Math.abs(E.playbackRate);if(b<=Math.max(g,1000*(L/(m*2))))return;var r=p?p.len/m:0,o=$.loading.first?$.loading.first-$.loading.start:-1,c=$.loaded&&o>-1,d=Y.getBwEstimate(),e=z.levels,H0=e[D],Q0=Math.max($.loaded,Math.round(L*(H.bitrate||H0.averageBitrate)/8)),J0=c?b-o:b;if(J0<1&&c)J0=Math.min(b,$.loaded*8/d);var N0=c?$.loaded*1000/J0:0,V0=g/1000,j0=N0?(Q0-$.loaded)/N0:Q0*8/d+V0;if(j0<=r)return;var O0=N0?N0*8:d,g0=((G=(Q==null?void 0:Q.details)||Y.hls.latestLevelDetails)==null?void 0:G.live)===!0,T0=Y.hls.config.abrBandWidthUpFactor,m0=Number.POSITIVE_INFINITY,D0;for(D0=D-1;D0>C;D0--){var Y1=e[D0].maxBitrate,_0=!e[D0].details||g0;if(m0=Y.getTimeToLoadFrag(V0,O0,L*Y1,_0),m0<Math.min(r,L+V0))break}if(m0>=j0)return;if(m0>L*10)return;if(c)Y.bwEstimator.sample(b-Math.min(g,o),$.loaded);else Y.bwEstimator.sampleTTFB(b);var a0=e[D0].maxBitrate;if(Y.getBwEstimate()*T0>a0)Y.resetEstimator(a0);var w1=Y.findBestLevel(a0,C,D0,0,r,1,1);if(w1>-1)D0=w1;Y.warn("Fragment "+H.sn+(V?" part "+V.index:"")+" of level "+D+` is loading too slowly;
2
- Fragment duration: `+H.duration.toFixed(3)+`
3
- Time to underbuffer: `+r.toFixed(3)+` s
4
- Estimated load time for current fragment: `+j0.toFixed(3)+` s
5
- Estimated load time for down switch fragment: `+m0.toFixed(3)+` s
6
- TTFB estimate: `+(o|0)+` ms
7
- Current BW estimate: `+(T(d)?d|0:"Unknown")+` bps
8
- New BW estimate: `+(Y.getBwEstimate()|0)+` bps
9
- Switching to level `+D0+" @ "+(a0|0)+" bps"),z.nextLoadLevel=z.nextAutoLevel=D0,Y.clearTimer();var q1=function p0(){if(Y.clearTimer(),Y.fragCurrent===H&&Y.hls.loadLevel===D0&&D0>0){var R1=Y.getStarvationDelay();if(Y.warn("Aborting inflight request "+(D0>0?"and switching down":"")+`
10
- Fragment duration: `+H.duration.toFixed(3)+` s
11
- Time to underbuffer: `+R1.toFixed(3)+" s"),H.abortRequests(),Y.fragCurrent=Y.partCurrent=null,D0>C){var Z1=Y.findBestLevel(Y.hls.levels[C].bitrate,C,D0,0,R1,1,1);if(Z1===-1)Z1=C;Y.hls.nextLoadLevel=Y.hls.nextAutoLevel=Z1,Y.resetEstimator(Y.hls.levels[Z1].bitrate)}}};if(S||j0>m0*2)q1();else Y.timer=self.setInterval(q1,m0*1000);z.trigger(M.FRAG_LOAD_EMERGENCY_ABORTED,{frag:H,part:V,stats:$})},Y.hls=J,Y.bwEstimator=Y.initEstimator(),Y.registerListeners(),Y}R(W,X);var Z=W.prototype;return Z.resetEstimator=function J(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 J(){var Y=this.hls.config;return new u0(Y.abrEwmaSlowVoD,Y.abrEwmaFastVoD,Y.abrEwmaDefaultEstimate)},Z.registerListeners=function J(){var Y=this.hls;Y.on(M.MANIFEST_LOADING,this.onManifestLoading,this),Y.on(M.FRAG_LOADING,this.onFragLoading,this),Y.on(M.FRAG_LOADED,this.onFragLoaded,this),Y.on(M.FRAG_BUFFERED,this.onFragBuffered,this),Y.on(M.LEVEL_SWITCHING,this.onLevelSwitching,this),Y.on(M.LEVEL_LOADED,this.onLevelLoaded,this),Y.on(M.LEVELS_UPDATED,this.onLevelsUpdated,this),Y.on(M.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),Y.on(M.ERROR,this.onError,this)},Z.unregisterListeners=function J(){var Y=this.hls;if(!Y)return;Y.off(M.MANIFEST_LOADING,this.onManifestLoading,this),Y.off(M.FRAG_LOADING,this.onFragLoading,this),Y.off(M.FRAG_LOADED,this.onFragLoaded,this),Y.off(M.FRAG_BUFFERED,this.onFragBuffered,this),Y.off(M.LEVEL_SWITCHING,this.onLevelSwitching,this),Y.off(M.LEVEL_LOADED,this.onLevelLoaded,this),Y.off(M.LEVELS_UPDATED,this.onLevelsUpdated,this),Y.off(M.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),Y.off(M.ERROR,this.onError,this)},Z.destroy=function J(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null},Z.onManifestLoading=function J(Y,Q){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()},Z.onLevelsUpdated=function J(){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 J(){this.firstSelection=-1,this.nextAutoLevelKey=""},Z.onFragLoading=function J(Y,Q){var G=Q.frag;if(this.ignoreFragment(G))return;if(!G.bitrateTest){var q;this.fragCurrent=G,this.partCurrent=(q=Q.part)!=null?q:null}this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)},Z.onLevelSwitching=function J(Y,Q){this.clearTimer()},Z.onError=function J(Y,Q){if(Q.fatal)return;switch(Q.details){case h.BUFFER_ADD_CODEC_ERROR:case h.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case h.FRAG_LOAD_TIMEOUT:{var G=Q.frag,q=this.fragCurrent,H=this.partCurrent;if(G&&q&&G.sn===q.sn&&G.level===q.level){var V=performance.now(),z=H?H.stats:G.stats,A=V-z.loading.start,E=z.loading.first?z.loading.first-z.loading.start:-1,I=z.loaded&&E>-1;if(I){var $=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(A-Math.min($,E),z.loaded)}else this.bwEstimator.sampleTTFB(A)}break}}},Z.getTimeToLoadFrag=function J(Y,Q,G,q){var H=Y+G/Q,V=q?Y+this.lastLevelLoadSec:0;return H+V},Z.onLevelLoaded=function J(Y,Q){var G=this.hls.config,q=Q.stats.loading,H=q.end-q.first;if(T(H))this.lastLevelLoadSec=H/1000;if(Q.details.live)this.bwEstimator.update(G.abrEwmaSlowLive,G.abrEwmaFastLive);else this.bwEstimator.update(G.abrEwmaSlowVoD,G.abrEwmaFastVoD);if(this.timer>-1)this._abandonRulesCheck(Q.levelInfo)},Z.onFragLoaded=function J(Y,Q){var{frag:G,part:q}=Q,H=q?q.stats:G.stats;if(G.type===G0.MAIN)this.bwEstimator.sampleTTFB(H.loading.first-H.loading.start);if(this.ignoreFragment(G))return;if(this.clearTimer(),G.level===this._nextAutoLevel)this._nextAutoLevel=-1;if(this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){var V=q?q.duration:G.duration,z=this.hls.levels[G.level],A=(z.loaded?z.loaded.bytes:0)+H.loaded,E=(z.loaded?z.loaded.duration:0)+V;z.loaded={bytes:A,duration:E},z.realBitrate=Math.round(8*A/E)}if(G.bitrateTest){var I={stats:H,frag:G,part:q,id:G.type};this.onFragBuffered(M.FRAG_BUFFERED,I),G.bitrateTest=!1}else this.lastLoadedFragLevel=G.level},Z.onFragBuffered=function J(Y,Q){var{frag:G,part:q}=Q,H=q!=null&&q.stats.loaded?q.stats:G.stats;if(H.aborted)return;if(this.ignoreFragment(G))return;var V=H.parsing.end-H.loading.start-Math.min(H.loading.first-H.loading.start,this.bwEstimator.getEstimateTTFB());if(this.bwEstimator.sample(V,H.loaded),H.bwEstimate=this.getBwEstimate(),G.bitrateTest)this.bitrateTestDelay=V/1000;else this.bitrateTestDelay=0},Z.ignoreFragment=function J(Y){return Y.type!==G0.MAIN||Y.sn==="initSegment"},Z.clearTimer=function J(){if(this.timer>-1)self.clearInterval(this.timer),this.timer=-1},Z.getAutoLevelKey=function J(){return this.getBwEstimate()+"_"+this.getStarvationDelay().toFixed(2)},Z.getNextABRAutoLevel=function J(){var Y=this.fragCurrent,Q=this.partCurrent,G=this.hls;if(G.levels.length<=1)return G.loadLevel;var{maxAutoLevel:q,config:H,minAutoLevel:V}=G,z=Q?Q.duration:Y?Y.duration:0,A=this.getBwEstimate(),E=this.getStarvationDelay(),I=H.abrBandWidthFactor,$=H.abrBandWidthUpFactor;if(E){var L=this.findBestLevel(A,V,q,E,0,I,$);if(L>=0)return this.rebufferNotice=-1,L}var b=z?Math.min(z,H.maxStarvationDelay):H.maxStarvationDelay;if(!E){var C=this.bitrateTestDelay;if(C){var D=z?Math.min(z,H.maxLoadingDelay):H.maxLoadingDelay;b=D-C,this.info("bitrate test took "+Math.round(1000*C)+"ms, set first fragment max fetchDuration to "+Math.round(1000*b)+" ms"),I=$=1}}var y=this.findBestLevel(A,V,q,E,b,I,$);if(this.rebufferNotice!==y)this.rebufferNotice=y,this.info((E?"rebuffering expected":"buffer is empty")+", optimal quality level "+y);if(y>-1)return y;var S=G.levels[V],v=G.loadLevelObj;if(v&&(S==null?void 0:S.bitrate)<v.bitrate)return V;return G.loadLevel},Z.getStarvationDelay=function J(){var Y=this.hls,Q=Y.media;if(!Q)return 1/0;var G=Q&&Q.playbackRate!==0?Math.abs(Q.playbackRate):1,q=Y.mainForwardBufferInfo;return(q?q.len:0)/G},Z.getBwEstimate=function J(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate},Z.findBestLevel=function J(Y,Q,G,q,H,V,z){var A,E=this,I=q+H,$=this.lastLoadedFragLevel,L=$===-1?this.hls.firstLevel:$,b=this.fragCurrent,C=this.partCurrent,D=this.hls,y=D.levels,S=D.allAudioTracks,v=D.loadLevel,p=D.config;if(y.length===1)return 0;var g=y[L],m=!!((A=this.hls.latestLevelDetails)!=null&&A.live),r=v===-1||$===-1,o,c="SDR",d=(g==null?void 0:g.frameRate)||0,e=p.audioPreference,H0=p.videoPreference,Q0=this.audioTracksByGroup||(this.audioTracksByGroup=A2(S)),J0=-1;if(r){if(this.firstSelection!==-1)return this.firstSelection;var N0=this.codecTiers||(this.codecTiers=PX(y,Q0,Q,G)),V0=SX(N0,c,Y,e,H0),j0=V0.codecSet,O0=V0.videoRanges,g0=V0.minFramerate,T0=V0.minBitrate,m0=V0.minIndex,D0=V0.preferHDR;J0=m0,o=j0,c=D0?O0[O0.length-1]:O0[0],d=g0,Y=Math.max(Y,T0),this.log("picked start tier "+O1(V0))}else o=g==null?void 0:g.codecSet,c=g==null?void 0:g.videoRange;var Y1=C?C.duration:b?b.duration:0,_0=this.bwEstimator.getEstimateTTFB()/1000,a0=[],w1=function R1(){var Z1,s0=y[p0],$1=p0>L;if(!s0)return 0;if(o&&s0.codecSet!==o||c&&s0.videoRange!==c||$1&&d>s0.frameRate||!$1&&d>0&&d<s0.frameRate||s0.supportedResult&&!((Z1=s0.supportedResult.decodingInfoResults)!=null&&Z1[0].smooth)){if(!r||p0!==J0)return a0.push(p0),0}var V1=s0.details,M1=(C?V1==null?void 0:V1.partTarget:V1==null?void 0:V1.averagetargetduration)||Y1,n0;if(!$1)n0=V*Y;else n0=z*Y;var z1=Y1&&q>=Y1*2&&H===0?s0.averageBitrate:s0.maxBitrate,X1=E.getTimeToLoadFrag(_0,n0,z1*M1,V1===void 0),I1=n0>=z1&&(p0===$||s0.loadError===0&&s0.fragmentError===0)&&(X1<=_0||!T(X1)||m&&!E.bitrateTestDelay||X1<I);if(I1){var pY=E.forcedAutoLevel;if(p0!==v&&(pY===-1||pY!==v)){if(a0.length)E.trace("Skipped level(s) "+a0.join(",")+" of "+G+' max with CODECS and VIDEO-RANGE:"'+y[a0[0]].codecs+'" '+y[a0[0]].videoRange+'; not compatible with "'+o+'" '+c);E.info("switch candidate:"+L+"->"+p0+" adjustedbw("+Math.round(n0)+")-bitrate="+Math.round(n0-z1)+" ttfb:"+_0.toFixed(1)+" avgDuration:"+M1.toFixed(1)+" maxFetchDuration:"+I.toFixed(1)+" fetchDuration:"+X1.toFixed(1)+" firstSelection:"+r+" codecSet:"+s0.codecSet+" videoRange:"+s0.videoRange+" hls.loadLevel:"+v)}if(r)E.firstSelection=p0;return{v:p0}}},q1;for(var p0=G;p0>=Q;p0--){if(q1=w1(),q1===0)continue;if(q1)return q1.v}return-1},Z.deriveNextAutoLevel=function J(Y){var Q=this.hls,G=Q.maxAutoLevel,q=Q.minAutoLevel;return Math.min(Math.max(Y,q),G)},N(W,[{key:"firstAutoLevel",get:function J(){var Y=this.hls,Q=Y.maxAutoLevel,G=Y.minAutoLevel,q=this.getBwEstimate(),H=this.hls.config.maxStarvationDelay,V=this.findBestLevel(q,G,Q,0,H,1,1);if(V>-1)return V;var z=this.hls.firstLevel,A=Math.min(Math.max(z,G),Q);return this.warn("Could not find best starting auto level. Defaulting to first in playlist "+z+" clamped to "+A),A}},{key:"forcedAutoLevel",get:function J(){if(this.nextAutoLevelKey)return-1;return this._nextAutoLevel}},{key:"nextAutoLevel",get:function J(){var Y=this.forcedAutoLevel,Q=this.bwEstimator,G=Q.canEstimate(),q=this.lastLoadedFragLevel>-1;if(Y!==-1&&(!G||!q||this.nextAutoLevelKey===this.getAutoLevelKey()))return Y;var H=G&&q?this.getNextABRAutoLevel():this.firstAutoLevel;if(Y!==-1){var V=this.hls.levels;if(V.length>Math.max(Y,H)&&V[Y].loadError<=V[H].loadError)return Y}return this._nextAutoLevel=H,this.nextAutoLevelKey=this.getAutoLevelKey(),H},set:function J(Y){var Q=this.deriveNextAutoLevel(Y);if(this._nextAutoLevel!==Q)this.nextAutoLevelKey="",this._nextAutoLevel=Q}}])}(d0),TX=function(){function X(Z){this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=Z}var W=X.prototype;return W.destroy=function Z(){this.tracks=this.queues=null},W.append=function Z(J,Y,Q){if(this.queues===null||this.tracks===null)return;var G=this.queues[Y];if(G.push(J),G.length===1&&!Q)this.executeNext(Y)},W.appendBlocker=function Z(J){var Y=this;return new Promise(function(Q){var G={label:"async-blocker",execute:Q,onStart:function q(){},onComplete:function q(){},onError:function q(){}};Y.append(G,J)})},W.prependBlocker=function Z(J){var Y=this;return new Promise(function(Q){if(Y.queues){var G={label:"async-blocker-prepend",execute:Q,onStart:function q(){},onComplete:function q(){},onError:function q(){}};Y.queues[J].unshift(G)}})},W.removeBlockers=function Z(){if(this.queues===null)return;[this.queues.video,this.queues.audio,this.queues.audiovideo].forEach(function(J){var Y,Q=(Y=J[0])==null?void 0:Y.label;if(Q==="async-blocker"||Q==="async-blocker-prepend")J[0].execute(),J.splice(0,1)})},W.unblockAudio=function Z(J){if(this.queues===null)return;var Y=this.queues.audio;if(Y[0]===J)this.shiftAndExecuteNext("audio")},W.executeNext=function Z(J){if(this.queues===null||this.tracks===null)return;var Y=this.queues[J];if(Y.length){var Q=Y[0];try{Q.execute()}catch(H){var G;if(Q.onError(H),this.queues===null||this.tracks===null)return;var q=(G=this.tracks[J])==null?void 0:G.buffer;if(!(q!=null&&q.updating))this.shiftAndExecuteNext(J)}}},W.shiftAndExecuteNext=function Z(J){if(this.queues===null)return;this.queues[J].shift(),this.executeNext(J)},W.current=function Z(J){var Y;return((Y=this.queues)==null?void 0:Y[J][0])||null},W.toString=function Z(){var J=this.queues,Y=this.tracks;if(J===null||Y===null)return"<destroyed>";return`
1
+ (function(g,f){if(typeof define=="function"&&define.amd){define(f)}else if(typeof exports=="object" && typeof module<"u"){module.exports=f()}else{var m=f();for(var i in m) g[i]=m[i]}}(typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : this,function(){var exports={};var __exports=exports;var module={exports};
2
+ "use strict";var Sh=Object.create;var Ai=Object.defineProperty;var Th=Object.getOwnPropertyDescriptor;var Ah=Object.getOwnPropertyNames;var bh=Object.getPrototypeOf,Lh=Object.prototype.hasOwnProperty;var Ks=(v,m)=>()=>(m||v((m={exports:{}}).exports,m),m.exports),xh=(v,m)=>{for(var o in m)Ai(v,o,{get:m[o],enumerable:!0})},Ws=(v,m,o,h)=>{if(m&&typeof m=="object"||typeof m=="function")for(let f of Ah(m))!Lh.call(v,f)&&f!==o&&Ai(v,f,{get:()=>m[f],enumerable:!(h=Th(m,f))||h.enumerable});return v};var Ar=(v,m,o)=>(o=v!=null?Sh(bh(v)):{},Ws(m||!v||!v.__esModule?Ai(o,"default",{value:v,enumerable:!0}):o,v)),Rh=v=>Ws(Ai({},"__esModule",{value:!0}),v);var xr=Ks((dd,En)=>{"use strict";var Ih=Object.prototype.hasOwnProperty,mt="~";function Hr(){}Object.create&&(Hr.prototype=Object.create(null),new Hr().__proto__||(mt=!1));function wh(v,m,o){this.fn=v,this.context=m,this.once=o||!1}function Qs(v,m,o,h,f){if(typeof o!="function")throw new TypeError("The listener must be a function");var g=new wh(o,h||v,f),E=mt?mt+m:m;return v._events[E]?v._events[E].fn?v._events[E]=[v._events[E],g]:v._events[E].push(g):(v._events[E]=g,v._eventsCount++),v}function Li(v,m){--v._eventsCount===0?v._events=new Hr:delete v._events[m]}function vt(){this._events=new Hr,this._eventsCount=0}vt.prototype.eventNames=function(){var m=[],o,h;if(this._eventsCount===0)return m;for(h in o=this._events)Ih.call(o,h)&&m.push(mt?h.slice(1):h);return Object.getOwnPropertySymbols?m.concat(Object.getOwnPropertySymbols(o)):m};vt.prototype.listeners=function(m){var o=mt?mt+m:m,h=this._events[o];if(!h)return[];if(h.fn)return[h.fn];for(var f=0,g=h.length,E=new Array(g);f<g;f++)E[f]=h[f].fn;return E};vt.prototype.listenerCount=function(m){var o=mt?mt+m:m,h=this._events[o];return h?h.fn?1:h.length:0};vt.prototype.emit=function(m,o,h,f,g,E){var _=mt?mt+m:m;if(!this._events[_])return!1;var S=this._events[_],D=arguments.length,P,F;if(S.fn){switch(S.once&&this.removeListener(m,S.fn,void 0,!0),D){case 1:return S.fn.call(S.context),!0;case 2:return S.fn.call(S.context,o),!0;case 3:return S.fn.call(S.context,o,h),!0;case 4:return S.fn.call(S.context,o,h,f),!0;case 5:return S.fn.call(S.context,o,h,f,g),!0;case 6:return S.fn.call(S.context,o,h,f,g,E),!0}for(F=1,P=new Array(D-1);F<D;F++)P[F-1]=arguments[F];S.fn.apply(S.context,P)}else{var H=S.length,W;for(F=0;F<H;F++)switch(S[F].once&&this.removeListener(m,S[F].fn,void 0,!0),D){case 1:S[F].fn.call(S[F].context);break;case 2:S[F].fn.call(S[F].context,o);break;case 3:S[F].fn.call(S[F].context,o,h);break;case 4:S[F].fn.call(S[F].context,o,h,f);break;default:if(!P)for(W=1,P=new Array(D-1);W<D;W++)P[W-1]=arguments[W];S[F].fn.apply(S[F].context,P)}}return!0};vt.prototype.on=function(m,o,h){return Qs(this,m,o,h,!1)};vt.prototype.once=function(m,o,h){return Qs(this,m,o,h,!0)};vt.prototype.removeListener=function(m,o,h,f){var g=mt?mt+m:m;if(!this._events[g])return this;if(!o)return Li(this,g),this;var E=this._events[g];if(E.fn)E.fn===o&&(!f||E.once)&&(!h||E.context===h)&&Li(this,g);else{for(var _=0,S=[],D=E.length;_<D;_++)(E[_].fn!==o||f&&!E[_].once||h&&E[_].context!==h)&&S.push(E[_]);S.length?this._events[g]=S.length===1?S[0]:S:Li(this,g)}return this};vt.prototype.removeAllListeners=function(m){var o;return m?(o=mt?mt+m:m,this._events[o]&&Li(this,o)):(this._events=new Hr,this._eventsCount=0),this};vt.prototype.off=vt.prototype.removeListener;vt.prototype.addListener=vt.prototype.on;vt.prefixed=mt;vt.EventEmitter=vt;typeof En<"u"&&(En.exports=vt)});var Qo=Ks((Xo,Kn)=>{(function v(m){(function(o,h){typeof Xo=="object"&&typeof Kn<"u"?Kn.exports=h():typeof define=="function"&&define.amd?define(h):(o=typeof globalThis<"u"?globalThis:o||self,o.Hls=h())})(this,function(){"use strict";function o(n,s,i){if(P())return Reflect.construct.apply(null,arguments);var t=[null];t.push.apply(t,s);var e=new(n.bind.apply(n,t));return i&&W(e,i.prototype),e}function h(n,s){for(var i=0;i<s.length;i++){var t=s[i];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(n,ee(t.key),t)}}function f(n,s,i){return s&&h(n.prototype,s),i&&h(n,i),Object.defineProperty(n,"prototype",{writable:!1}),n}function g(n,s,i){return(s=ee(s))in n?Object.defineProperty(n,s,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[s]=i,n}function E(){return E=Object.assign?Object.assign.bind():function(n){for(var s=1;s<arguments.length;s++){var i=arguments[s];for(var t in i)({}).hasOwnProperty.call(i,t)&&(n[t]=i[t])}return n},E.apply(null,arguments)}function _(n){return _=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(s){return s.__proto__||Object.getPrototypeOf(s)},_(n)}function S(n,s){n.prototype=Object.create(s.prototype),n.prototype.constructor=n,W(n,s)}function D(n){try{return Function.toString.call(n).indexOf("[native code]")!==-1}catch{return typeof n=="function"}}function P(){try{var n=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(P=function(){return!!n})()}function F(n,s){var i=Object.keys(n);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(n);s&&(t=t.filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})),i.push.apply(i,t)}return i}function H(n){for(var s=1;s<arguments.length;s++){var i=arguments[s]!=null?arguments[s]:{};s%2?F(Object(i),!0).forEach(function(t){g(n,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(i)):F(Object(i)).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(i,t))})}return n}function W(n,s){return W=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,t){return i.__proto__=t,i},W(n,s)}function $(n,s){if(typeof n!="object"||!n)return n;var i=n[Symbol.toPrimitive];if(i!==void 0){var t=i.call(n,s);if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(n)}function ee(n){var s=$(n,"string");return typeof s=="symbol"?s:s+""}function Z(n){var s=typeof Map=="function"?new Map:void 0;return Z=function(i){if(i===null||!D(i))return i;if(typeof i!="function")throw new TypeError("Super expression must either be null or a function");if(s!==void 0){if(s.has(i))return s.get(i);s.set(i,t)}function t(){return o(i,arguments,_(this).constructor)}return t.prototype=Object.create(i.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),W(t,i)},Z(n)}function oe(){try{return crypto.randomUUID()}catch{try{var n=URL.createObjectURL(new Blob),s=n.toString();return URL.revokeObjectURL(n),s.slice(s.lastIndexOf("/")+1)}catch{var i=new Date().getTime(),t="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var u=(i+Math.random()*16)%16|0;return i=Math.floor(i/16),(a=="x"?u:u&3|8).toString(16)});return t}}}function ue(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Se={exports:{}},he;function se(){return he||(he=1,function(n){var s=Object.prototype.hasOwnProperty,i="~";function t(){}Object.create&&(t.prototype=Object.create(null),new t().__proto__||(i=!1));function e(l,d,c){this.fn=l,this.context=d,this.once=c||!1}function r(l,d,c,p,y){if(typeof c!="function")throw new TypeError("The listener must be a function");var A=new e(c,p||l,y),T=i?i+d:d;return l._events[T]?l._events[T].fn?l._events[T]=[l._events[T],A]:l._events[T].push(A):(l._events[T]=A,l._eventsCount++),l}function a(l,d){--l._eventsCount===0?l._events=new t:delete l._events[d]}function u(){this._events=new t,this._eventsCount=0}u.prototype.eventNames=function(){var d=[],c,p;if(this._eventsCount===0)return d;for(p in c=this._events)s.call(c,p)&&d.push(i?p.slice(1):p);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(c)):d},u.prototype.listeners=function(d){var c=i?i+d:d,p=this._events[c];if(!p)return[];if(p.fn)return[p.fn];for(var y=0,A=p.length,T=new Array(A);y<A;y++)T[y]=p[y].fn;return T},u.prototype.listenerCount=function(d){var c=i?i+d:d,p=this._events[c];return p?p.fn?1:p.length:0},u.prototype.emit=function(d,c,p,y,A,T){var b=i?i+d:d;if(!this._events[b])return!1;var L=this._events[b],R=arguments.length,C,I;if(L.fn){switch(L.once&&this.removeListener(d,L.fn,void 0,!0),R){case 1:return L.fn.call(L.context),!0;case 2:return L.fn.call(L.context,c),!0;case 3:return L.fn.call(L.context,c,p),!0;case 4:return L.fn.call(L.context,c,p,y),!0;case 5:return L.fn.call(L.context,c,p,y,A),!0;case 6:return L.fn.call(L.context,c,p,y,A,T),!0}for(I=1,C=new Array(R-1);I<R;I++)C[I-1]=arguments[I];L.fn.apply(L.context,C)}else{var k=L.length,O;for(I=0;I<k;I++)switch(L[I].once&&this.removeListener(d,L[I].fn,void 0,!0),R){case 1:L[I].fn.call(L[I].context);break;case 2:L[I].fn.call(L[I].context,c);break;case 3:L[I].fn.call(L[I].context,c,p);break;case 4:L[I].fn.call(L[I].context,c,p,y);break;default:if(!C)for(O=1,C=new Array(R-1);O<R;O++)C[O-1]=arguments[O];L[I].fn.apply(L[I].context,C)}}return!0},u.prototype.on=function(d,c,p){return r(this,d,c,p,!1)},u.prototype.once=function(d,c,p){return r(this,d,c,p,!0)},u.prototype.removeListener=function(d,c,p,y){var A=i?i+d:d;if(!this._events[A])return this;if(!c)return a(this,A),this;var T=this._events[A];if(T.fn)T.fn===c&&(!y||T.once)&&(!p||T.context===p)&&a(this,A);else{for(var b=0,L=[],R=T.length;b<R;b++)(T[b].fn!==c||y&&!T[b].once||p&&T[b].context!==p)&&L.push(T[b]);L.length?this._events[A]=L.length===1?L[0]:L:a(this,A)}return this},u.prototype.removeAllListeners=function(d){var c;return d?(c=i?i+d:d,this._events[c]&&a(this,c)):(this._events=new t,this._eventsCount=0),this},u.prototype.off=u.prototype.removeListener,u.prototype.addListener=u.prototype.on,u.prefixed=i,u.EventEmitter=u,n.exports=u}(Se)),Se.exports}var ce=se(),Me=ue(ce),We={exports:{}},ye;function Ie(){return ye||(ye=1,function(n,s){(function(i){var t=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,e=/^(?=([^\/?#]*))\1([^]*)$/,r=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,u={buildAbsoluteURL:function(l,d,c){if(c=c||{},l=l.trim(),d=d.trim(),!d){if(!c.alwaysNormalize)return l;var p=u.parseURL(l);if(!p)throw new Error("Error trying to parse base URL.");return p.path=u.normalizePath(p.path),u.buildURLFromParts(p)}var y=u.parseURL(d);if(!y)throw new Error("Error trying to parse relative URL.");if(y.scheme)return c.alwaysNormalize?(y.path=u.normalizePath(y.path),u.buildURLFromParts(y)):d;var A=u.parseURL(l);if(!A)throw new Error("Error trying to parse base URL.");if(!A.netLoc&&A.path&&A.path[0]!=="/"){var T=e.exec(A.path);A.netLoc=T[1],A.path=T[2]}A.netLoc&&!A.path&&(A.path="/");var b={scheme:A.scheme,netLoc:y.netLoc,path:null,params:y.params,query:y.query,fragment:y.fragment};if(!y.netLoc&&(b.netLoc=A.netLoc,y.path[0]!=="/"))if(!y.path)b.path=A.path,y.params||(b.params=A.params,y.query||(b.query=A.query));else{var L=A.path,R=L.substring(0,L.lastIndexOf("/")+1)+y.path;b.path=u.normalizePath(R)}return b.path===null&&(b.path=c.alwaysNormalize?u.normalizePath(y.path):y.path),u.buildURLFromParts(b)},parseURL:function(l){var d=t.exec(l);return d?{scheme:d[1]||"",netLoc:d[2]||"",path:d[3]||"",params:d[4]||"",query:d[5]||"",fragment:d[6]||""}:null},normalizePath:function(l){for(l=l.split("").reverse().join("").replace(r,"");l.length!==(l=l.replace(a,"")).length;);return l.split("").reverse().join("")},buildURLFromParts:function(l){return l.scheme+l.netLoc+l.path+l.params+l.query+l.fragment}};n.exports=u})()}(We)),We.exports}var Ze=Ie(),w=Number.isFinite||function(n){return typeof n=="number"&&isFinite(n)},U=Number.isSafeInteger||function(n){return typeof n=="number"&&Math.abs(n)<=G},G=Number.MAX_SAFE_INTEGER||9007199254740991,Y=function(n){return n.NETWORK_ERROR="networkError",n.MEDIA_ERROR="mediaError",n.KEY_SYSTEM_ERROR="keySystemError",n.MUX_ERROR="muxError",n.OTHER_ERROR="otherError",n}({}),M=function(n){return n.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",n.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",n.KEY_SYSTEM_NO_SESSION="keySystemNoSession",n.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",n.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",n.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",n.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",n.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",n.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",n.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",n.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",n.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",n.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",n.MANIFEST_LOAD_ERROR="manifestLoadError",n.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",n.MANIFEST_PARSING_ERROR="manifestParsingError",n.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",n.LEVEL_EMPTY_ERROR="levelEmptyError",n.LEVEL_LOAD_ERROR="levelLoadError",n.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",n.LEVEL_PARSING_ERROR="levelParsingError",n.LEVEL_SWITCH_ERROR="levelSwitchError",n.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",n.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",n.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",n.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",n.FRAG_LOAD_ERROR="fragLoadError",n.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",n.FRAG_DECRYPT_ERROR="fragDecryptError",n.FRAG_PARSING_ERROR="fragParsingError",n.FRAG_GAP="fragGap",n.REMUX_ALLOC_ERROR="remuxAllocError",n.KEY_LOAD_ERROR="keyLoadError",n.KEY_LOAD_TIMEOUT="keyLoadTimeOut",n.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",n.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",n.BUFFER_APPEND_ERROR="bufferAppendError",n.BUFFER_APPENDING_ERROR="bufferAppendingError",n.BUFFER_STALLED_ERROR="bufferStalledError",n.BUFFER_FULL_ERROR="bufferFullError",n.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",n.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",n.ASSET_LIST_LOAD_ERROR="assetListLoadError",n.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",n.ASSET_LIST_PARSING_ERROR="assetListParsingError",n.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",n.INTERNAL_EXCEPTION="internalException",n.INTERNAL_ABORTED="aborted",n.ATTACH_MEDIA_ERROR="attachMediaError",n.UNKNOWN="unknown",n}({}),x=function(n){return n.MEDIA_ATTACHING="hlsMediaAttaching",n.MEDIA_ATTACHED="hlsMediaAttached",n.MEDIA_DETACHING="hlsMediaDetaching",n.MEDIA_DETACHED="hlsMediaDetached",n.MEDIA_ENDED="hlsMediaEnded",n.STALL_RESOLVED="hlsStallResolved",n.BUFFER_RESET="hlsBufferReset",n.BUFFER_CODECS="hlsBufferCodecs",n.BUFFER_CREATED="hlsBufferCreated",n.BUFFER_APPENDING="hlsBufferAppending",n.BUFFER_APPENDED="hlsBufferAppended",n.BUFFER_EOS="hlsBufferEos",n.BUFFERED_TO_END="hlsBufferedToEnd",n.BUFFER_FLUSHING="hlsBufferFlushing",n.BUFFER_FLUSHED="hlsBufferFlushed",n.MANIFEST_LOADING="hlsManifestLoading",n.MANIFEST_LOADED="hlsManifestLoaded",n.MANIFEST_PARSED="hlsManifestParsed",n.LEVEL_SWITCHING="hlsLevelSwitching",n.LEVEL_SWITCHED="hlsLevelSwitched",n.LEVEL_LOADING="hlsLevelLoading",n.LEVEL_LOADED="hlsLevelLoaded",n.LEVEL_UPDATED="hlsLevelUpdated",n.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",n.LEVELS_UPDATED="hlsLevelsUpdated",n.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",n.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",n.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",n.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",n.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",n.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",n.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",n.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",n.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",n.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",n.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",n.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",n.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",n.CUES_PARSED="hlsCuesParsed",n.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",n.INIT_PTS_FOUND="hlsInitPtsFound",n.FRAG_LOADING="hlsFragLoading",n.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",n.FRAG_LOADED="hlsFragLoaded",n.FRAG_DECRYPTED="hlsFragDecrypted",n.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",n.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",n.FRAG_PARSING_METADATA="hlsFragParsingMetadata",n.FRAG_PARSED="hlsFragParsed",n.FRAG_BUFFERED="hlsFragBuffered",n.FRAG_CHANGED="hlsFragChanged",n.FPS_DROP="hlsFpsDrop",n.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",n.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",n.ERROR="hlsError",n.DESTROYING="hlsDestroying",n.KEY_LOADING="hlsKeyLoading",n.KEY_LOADED="hlsKeyLoaded",n.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",n.BACK_BUFFER_REACHED="hlsBackBufferReached",n.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",n.ASSET_LIST_LOADING="hlsAssetListLoading",n.ASSET_LIST_LOADED="hlsAssetListLoaded",n.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",n.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",n.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",n.INTERSTITIAL_STARTED="hlsInterstitialStarted",n.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",n.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",n.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",n.INTERSTITIAL_ENDED="hlsInterstitialEnded",n.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",n.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",n.EVENT_CUE_ENTER="hlsEventCueEnter",n}({}),ie={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},ae={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"},Re=function(){function n(i,t,e){t===void 0&&(t=0),e===void 0&&(e=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=i,this.alpha_=i?Math.exp(Math.log(.5)/i):0,this.estimate_=t,this.totalWeight_=e}var s=n.prototype;return s.sample=function(t,e){var r=Math.pow(this.alpha_,t);this.estimate_=e*(1-r)+r*this.estimate_,this.totalWeight_+=t},s.getTotalWeight=function(){return this.totalWeight_},s.getEstimate=function(){if(this.alpha_){var t=1-Math.pow(this.alpha_,this.totalWeight_);if(t)return this.estimate_/t}return this.estimate_},n}(),Ue=function(){function n(i,t,e,r){r===void 0&&(r=100),this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=e,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new Re(i),this.fast_=new Re(t),this.defaultTTFB_=r,this.ttfb_=new Re(i)}var s=n.prototype;return s.update=function(t,e){var r=this.slow_,a=this.fast_,u=this.ttfb_;r.halfLife!==t&&(this.slow_=new Re(t,r.getEstimate(),r.getTotalWeight())),a.halfLife!==e&&(this.fast_=new Re(e,a.getEstimate(),a.getTotalWeight())),u.halfLife!==t&&(this.ttfb_=new Re(t,u.getEstimate(),u.getTotalWeight()))},s.sample=function(t,e){t=Math.max(t,this.minDelayMs_);var r=8*e,a=t/1e3,u=r/a;this.fast_.sample(a,u),this.slow_.sample(a,u)},s.sampleTTFB=function(t){var e=t/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(e,2)/2);this.ttfb_.sample(r,Math.max(t,5))},s.canEstimate=function(){return this.fast_.getTotalWeight()>=this.minWeight_},s.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},s.getEstimateTTFB=function(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_},s.destroy=function(){},f(n,[{key:"defaultEstimate",get:function(){return this.defaultEstimate_}}])}(),je=function(s,i){this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;var t="["+s+"]:";this.trace=xe,this.debug=i.debug.bind(null,t),this.log=i.log.bind(null,t),this.warn=i.warn.bind(null,t),this.info=i.info.bind(null,t),this.error=i.error.bind(null,t)},xe=function(){},Ir={trace:xe,debug:xe,log:xe,warn:xe,info:xe,error:xe};function Dt(){return E({},Ir)}function wr(n,s){var i=self.console[n];return i?i.bind(self.console,(s?"["+s+"] ":"")+"["+n+"] >"):xe}function Pr(n,s,i){return s[n]?s[n].bind(s):wr(n,i)}var Zr=Dt();function Je(n,s,i){var t=Dt();if(typeof console=="object"&&n===!0||typeof n=="object"){var e=["debug","log","info","warn","error"];e.forEach(function(r){t[r]=Pr(r,n,i)});try{t.log('Debug logs enabled for "'+s+'" in hls.js version 1.6.0')}catch{return Dt()}e.forEach(function(r){Zr[r]=Pr(r,n)})}else E(Zr,t);return t}var Oe=Zr,Mi,jn;function Zo(){return jn||(jn=1,Mi=void 0),Mi}var Yn=Zo(),Jo=ue(Yn);function Pt(n,s){if(s===void 0&&(s=!1),typeof TextDecoder<"u"){var i=new TextDecoder("utf-8"),t=i.decode(n);if(s){var e=t.indexOf("\0");return e!==-1?t.substring(0,e):t}return t.replace(/\0/g,"")}for(var r=n.length,a,u,l,d="",c=0;c<r;){if(a=n[c++],a===0&&s)return d;if(a===0||a===3)continue;switch(a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:d+=String.fromCharCode(a);break;case 12:case 13:u=n[c++],d+=String.fromCharCode((a&31)<<6|u&63);break;case 14:u=n[c++],l=n[c++],d+=String.fromCharCode((a&15)<<12|(u&63)<<6|(l&63)<<0);break}}return d}var zn={hexDump:function(s){for(var i="",t=0;t<s.length;t++){var e=s[t].toString(16);e.length<2&&(e="0"+e),i+=e}return i}},Fi=function(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}},qe={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"},qn=function(){function n(i){this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,typeof i=="string"&&(i={url:i}),this.base=i,tu(this,"stats")}var s=n.prototype;return s.setByteRange=function(t,e){var r=t.split("@",2),a;r.length===1?a=e?.byteRangeEndOffset||0:a=parseInt(r[1]),this._byteRange=[a,parseInt(r[0])+a]},s.clearElementaryStreamInfo=function(){var t=this.elementaryStreams;t[qe.AUDIO]=null,t[qe.VIDEO]=null,t[qe.AUDIOVIDEO]=null},f(n,[{key:"baseurl",get:function(){return this.base.url}},{key:"byteRange",get:function(){return this._byteRange===null?[]:this._byteRange}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"elementaryStreams",get:function(){if(this._streams===null){var t;this._streams=(t={},t[qe.AUDIO]=null,t[qe.VIDEO]=null,t[qe.AUDIOVIDEO]=null,t)}return this._streams},set:function(t){this._streams=t}},{key:"hasStats",get:function(){return this._stats!==null}},{key:"hasStreams",get:function(){return this._streams!==null}},{key:"stats",get:function(){return this._stats===null&&(this._stats=new Fi),this._stats},set:function(t){this._stats=t}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Ze.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(t){this._url=t}}])}();function jt(n){return n.sn!=="initSegment"}var Ni=function(n){function s(t,e){var r;return r=n.call(this,e)||this,r._decryptdata=null,r._programDateTime=null,r._ref=null,r._bitrate=void 0,r.rawProgramDateTime=null,r.tagList=[],r.duration=0,r.sn=0,r.levelkeys=void 0,r.type=void 0,r.loader=null,r.keyLoader=null,r.level=-1,r.cc=0,r.startPTS=void 0,r.endPTS=void 0,r.startDTS=void 0,r.endDTS=void 0,r.start=0,r.playlistOffset=0,r.deltaPTS=void 0,r.maxStartPTS=void 0,r.minEndPTS=void 0,r.data=void 0,r.bitrateTest=!1,r.title=null,r.initSegment=null,r.endList=void 0,r.gap=void 0,r.urlId=0,r.type=t,r}S(s,n);var i=s.prototype;return i.addStart=function(e){this.setStart(this.start+e)},i.setStart=function(e){this.start=e,this._ref&&(this._ref.start=e)},i.setDuration=function(e){this.duration=e,this._ref&&(this._ref.duration=e)},i.setKeyFormat=function(e){if(this.levelkeys){var r=this.levelkeys[e];r&&!this._decryptdata&&(this._decryptdata=r.getDecryptData(this.sn))}},i.abortRequests=function(){var e,r;(e=this.loader)==null||e.abort(),(r=this.keyLoader)==null||r.abort()},i.setElementaryStreamInfo=function(e,r,a,u,l,d){d===void 0&&(d=!1);var c=this.elementaryStreams,p=c[e];if(!p){c[e]={startPTS:r,endPTS:a,startDTS:u,endDTS:l,partial:d};return}p.startPTS=Math.min(p.startPTS,r),p.endPTS=Math.max(p.endPTS,a),p.startDTS=Math.min(p.startDTS,u),p.endDTS=Math.max(p.endDTS,l)},f(s,[{key:"byteLength",get:function(){if(this.hasStats){var e=this.stats.total;if(e)return e}if(this.byteRange){var r=this.byteRange[0],a=this.byteRange[1];if(w(r)&&w(a))return a-r}return null}},{key:"bitrate",get:function(){return this.byteLength?this.byteLength*8/this.duration:this._bitrate?this._bitrate:null},set:function(e){this._bitrate=e}},{key:"decryptdata",get:function(){var e=this.levelkeys;if(!e&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var r=this.levelkeys.identity;if(r)this._decryptdata=r.getDecryptData(this.sn);else{var a=Object.keys(this.levelkeys);if(a.length===1)return this._decryptdata=this.levelkeys[a[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null)return null;var e=w(this.duration)?this.duration:0;return this.programDateTime+e*1e3}},{key:"encrypted",get:function(){var e;if((e=this._decryptdata)!=null&&e.encrypted)return!0;if(this.levelkeys){var r=Object.keys(this.levelkeys),a=r.length;if(a>1||a===1&&this.levelkeys[r[0]].encrypted)return!0}return!1}},{key:"programDateTime",get:function(){return this._programDateTime===null&&this.rawProgramDateTime&&(this.programDateTime=Date.parse(this.rawProgramDateTime)),this._programDateTime},set:function(e){if(!w(e)){this._programDateTime=this.rawProgramDateTime=null;return}this._programDateTime=e}},{key:"ref",get:function(){return jt(this)?(this._ref||(this._ref={base:this.base,start:this.start,duration:this.duration,sn:this.sn,programDateTime:this.programDateTime}),this._ref):null}}])}(qn),eu=function(n){function s(i,t,e,r,a){var u;u=n.call(this,e)||this,u.fragOffset=0,u.duration=0,u.gap=!1,u.independent=!1,u.relurl=void 0,u.fragment=void 0,u.index=void 0,u.duration=i.decimalFloatingPoint("DURATION"),u.gap=i.bool("GAP"),u.independent=i.bool("INDEPENDENT"),u.relurl=i.enumeratedString("URI"),u.fragment=t,u.index=r;var l=i.enumeratedString("BYTERANGE");return l&&u.setByteRange(l,a),a&&(u.fragOffset=a.fragOffset+a.duration),u}return S(s,n),f(s,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var t=this.elementaryStreams;return!!(t.audio||t.video||t.audiovideo)}}])}(qn);function $n(n,s){var i=Object.getPrototypeOf(n);if(i){var t=Object.getOwnPropertyDescriptor(i,s);return t||$n(i,s)}}function tu(n,s){var i=$n(n,s);i&&(i.enumerable=!0,Object.defineProperty(n,s,i))}var Jr=Math.pow(2,32)-1,ru=[].push,Xn={video:1,audio:2,id3:3,text:4};function st(n){return String.fromCharCode.apply(null,n)}function Qn(n,s){var i=n[s]<<8|n[s+1];return i<0?65536+i:i}function Ee(n,s){var i=Jn(n,s);return i<0?4294967296+i:i}function Zn(n,s){var i=Ee(n,s);return i*=Math.pow(2,32),i+=Ee(n,s+4),i}function Jn(n,s){return n[s]<<24|n[s+1]<<16|n[s+2]<<8|n[s+3]}function Ui(n,s,i){n[s]=i>>24,n[s+1]=i>>16&255,n[s+2]=i>>8&255,n[s+3]=i&255}function iu(n){for(var s=n.byteLength,i=0;i<s;){var t=Ee(n,i);if(t>8&&n[i+4]===109&&n[i+5]===111&&n[i+6]===111&&n[i+7]===102)return!0;i=t>1?i+t:s}return!1}function Te(n,s){var i=[];if(!s.length)return i;for(var t=n.byteLength,e=0;e<t;){var r=Ee(n,e),a=st(n.subarray(e+4,e+8)),u=r>1?e+r:t;if(a===s[0])if(s.length===1)i.push(n.subarray(e+8,u));else{var l=Te(n.subarray(e+8,u),s.slice(1));l.length&&ru.apply(i,l)}e=u}return i}function nu(n){var s=[],i=n[0],t=8,e=Ee(n,t);t+=4;var r=0,a=0;i===0?(r=Ee(n,t),a=Ee(n,t+4),t+=8):(r=Zn(n,t),a=Zn(n,t+8),t+=16),t+=2;var u=n.length+a,l=Qn(n,t);t+=2;for(var d=0;d<l;d++){var c=t,p=Ee(n,c);c+=4;var y=p&2147483647,A=(p&2147483648)>>>31;if(A===1)return Oe.warn("SIDX has hierarchical references (not supported)"),null;var T=Ee(n,c);c+=4,s.push({referenceSize:y,subsegmentDuration:T,info:{duration:T/e,start:u,end:u+y-1}}),u+=y,c+=4,t=c}return{earliestPresentationTime:r,timescale:e,version:i,referencesCount:l,references:s}}function ea(n){for(var s=[],i=Te(n,["moov","trak"]),t=0;t<i.length;t++){var e=i[t],r=Te(e,["tkhd"])[0];if(r){var a=r[0],u=Ee(r,a===0?12:20),l=Te(e,["mdia","mdhd"])[0];if(l){a=l[0];var d=Ee(l,a===0?12:20),c=Te(e,["mdia","hdlr"])[0];if(c){var p=st(c.subarray(8,12)),y={soun:qe.AUDIO,vide:qe.VIDEO}[p],A=Te(e,["mdia","minf","stbl","stsd"])[0],T=au(A);y?(s[u]={timescale:d,type:y,stsd:T},s[y]=H({timescale:d,id:u},T)):s[u]={timescale:d,type:p,stsd:T}}}}}var b=Te(n,["moov","mvex","trex"]);return b.forEach(function(L){var R=Ee(L,4),C=s[R];C&&(C.default={duration:Ee(L,12),flags:Ee(L,20)})}),s}function au(n){var s=n.subarray(8),i=s.subarray(86),t=st(s.subarray(4,8)),e=t,r,a=t==="enca"||t==="encv";if(a){var u=Te(s,[t])[0],l=u.subarray(t==="enca"?28:78),d=Te(l,["sinf"]);d.forEach(function(dt){var xt=Te(dt,["schm"])[0];if(xt){var Ye=st(xt.subarray(4,8));if(Ye==="cbcs"||Ye==="cenc"){var ct=Te(dt,["frma"])[0];ct&&(e=st(ct))}}})}var c=e;switch(e){case"avc1":case"avc2":case"avc3":case"avc4":{var p=Te(i,["avcC"])[0];e+="."+ti(p[1])+ti(p[2])+ti(p[3]),r=ei(c==="avc1"?"dva1":"dvav",i);break}case"mp4a":{var y=Te(s,[t])[0],A=Te(y.subarray(28),["esds"])[0];if(A&&A.length>7){var T=4;if(A[T++]!==3)break;T=Bi(A,T),T+=2;var b=A[T++];if(b&128&&(T+=2),b&64&&(T+=A[T++]),A[T++]!==4)break;T=Bi(A,T);var L=A[T++];if(L===64)e+="."+ti(L);else break;if(T+=12,A[T++]!==5)break;T=Bi(A,T);var R=A[T++],C=(R&248)>>3;C===31&&(C+=1+((R&7)<<3)+((A[T]&224)>>5)),e+="."+C}break}case"hvc1":case"hev1":{var I=Te(i,["hvcC"]);if(I){var k=I[0],O=k[1],V=["","A","B","C"][O>>6],N=O&31,B=Ee(k,2),X=(O&32)>>5?"H":"L",z=k[12],K=k.subarray(6,12);e+="."+V+N,e+="."+B.toString(16).toUpperCase(),e+="."+X+z;for(var j="",J=K.length;J--;){var le=K[J];if(le||j){var re=le.toString(16).toUpperCase();j="."+re+j}}e+=j}r=ei(c=="hev1"?"dvhe":"dvh1",i);break}case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":{e=ei(e,i)||e;break}case"vp09":{var te=Te(i,["vpcC"])[0],fe=te[4],de=te[5],ve=te[6]>>4&15;e+="."+Yt(fe)+"."+Yt(de)+"."+Yt(ve);break}case"av01":{var ge=Te(i,["av1C"])[0],Ne=ge[1]>>>5,we=ge[1]&31,Be=ge[2]>>>7?"H":"M",Ce=(ge[2]&64)>>6,et=(ge[2]&32)>>5,Ge=Ne===2&&Ce?et?12:10:Ce?10:8,Qe=(ge[2]&16)>>4,_t=(ge[2]&8)>>3,ut=(ge[2]&4)>>2,Ve=ge[2]&3,St=1,it=1,$e=1,Tt=0;e+="."+Ne+"."+Yt(we)+Be+"."+Yt(Ge)+"."+Qe+"."+_t+ut+Ve+"."+Yt(St)+"."+Yt(it)+"."+Yt($e)+"."+Tt,r=ei("dav1",i);break}}return{codec:e,encrypted:a,supplemental:r}}function ei(n,s){var i=Te(s,["dvvC"]),t=i.length?i[0]:Te(s,["dvcC"])[0];if(t){var e=t[2]>>1&127,r=t[2]<<5&32|t[3]>>3&31;return n+"."+Yt(e)+"."+Yt(r)}}function Bi(n,s){for(var i=s+5;n[s++]&128&&s<i;);return s}function ti(n){return("0"+n.toString(16).toUpperCase()).slice(-2)}function Yt(n){return(n<10?"0":"")+n}function su(n,s){if(!n||!s)return n;var i=s.keyId;if(i&&s.isCommonEncryption){var t=Te(n,["moov","trak"]);t.forEach(function(e){var r=Te(e,["mdia","minf","stbl","stsd"])[0],a=r.subarray(8),u=Te(a,["enca"]),l=u.length>0;l||(u=Te(a,["encv"])),u.forEach(function(d){var c=l?d.subarray(28):d.subarray(78),p=Te(c,["sinf"]);p.forEach(function(y){var A=ou(y);if(A){var T=A.subarray(8,24);T.some(function(b){return b!==0})||(Oe.log("[eme] Patching keyId in 'enc"+(l?"a":"v")+">sinf>>tenc' box: "+zn.hexDump(T)+" -> "+zn.hexDump(i)),A.set(i,8))}})})})}return n}function ou(n){var s=Te(n,["schm"])[0];if(s){var i=st(s.subarray(4,8));if(i==="cbcs"||i==="cenc")return Te(n,["schi","tenc"])[0]}return null}function uu(n,s){return Te(s,["moof","traf"]).reduce(function(i,t){var e=Te(t,["tfdt"])[0],r=e[0],a=Te(t,["tfhd"]).reduce(function(u,l){var d=Ee(l,4),c=n[d];if(c){var p=Ee(e,4);if(r===1){if(p===Jr)return Oe.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),u;p*=Jr+1,p+=Ee(e,8)}var y=c.timescale||9e4,A=p/y;if(w(A)&&(u===null||A<u))return A}return u},null);return a!==null&&w(a)&&(i===null||a<i)?a:i},null)}function lu(n,s){for(var i=0,t=0,e=0,r=Te(n,["moof","traf"]),a=0;a<r.length;a++){var u=r[a],l=Te(u,["tfhd"])[0],d=Ee(l,4),c=s[d];if(c){var p=c.default,y=Ee(l,0)|p?.flags,A=p?.duration;y&8&&(y&2?A=Ee(l,12):A=Ee(l,8));for(var T=c.timescale||9e4,b=Te(u,["trun"]),L=0;L<b.length;L++){if(i=fu(b[L]),!i&&A){var R=Ee(b[L],4);i=A*R}c.type===qe.VIDEO?t+=i/T:c.type===qe.AUDIO&&(e+=i/T)}}}if(t===0&&e===0){for(var C=1/0,I=0,k=0,O=Te(n,["sidx"]),V=0;V<O.length;V++){var N=nu(O[V]);if(N!=null&&N.references){C=Math.min(C,N.earliestPresentationTime/N.timescale);var B=N.references.reduce(function(X,z){return X+z.info.duration||0},0);I=Math.max(I,B+N.earliestPresentationTime/N.timescale),k=I-C}}if(k&&w(k))return k}return t||e}function fu(n){var s=Ee(n,0),i=8;s&1&&(i+=4),s&4&&(i+=4);for(var t=0,e=Ee(n,4),r=0;r<e;r++){if(s&256){var a=Ee(n,i);t+=a,i+=4}s&512&&(i+=4),s&1024&&(i+=4),s&2048&&(i+=4)}return t}function hu(n,s,i){Te(s,["moof","traf"]).forEach(function(t){Te(t,["tfhd"]).forEach(function(e){var r=Ee(e,4),a=n[r];if(a){var u=a.timescale||9e4;Te(t,["tfdt"]).forEach(function(l){var d=l[0],c=i*u;if(c){var p=Ee(l,4);if(d===0)p-=c,p=Math.max(p,0),Ui(l,4,p);else{p*=Math.pow(2,32),p+=Ee(l,8),p-=c,p=Math.max(p,0);var y=Math.floor(p/(Jr+1)),A=Math.floor(p%(Jr+1));Ui(l,4,y),Ui(l,8,A)}}})}})})}function du(n){var s={valid:null,remainder:null},i=Te(n,["moof"]);if(i.length<2)return s.remainder=n,s;var t=i[i.length-1];return s.valid=n.slice(0,t.byteOffset-8),s.remainder=n.slice(t.byteOffset-8),s}function Ot(n,s){var i=new Uint8Array(n.length+s.length);return i.set(n),i.set(s,n.length),i}function ta(n,s){var i=[],t=s.samples,e=s.timescale,r=s.id,a=!1,u=Te(t,["moof"]);return u.map(function(l){var d=l.byteOffset-8,c=Te(l,["traf"]);c.map(function(p){var y=Te(p,["tfdt"]).map(function(A){var T=A[0],b=Ee(A,4);return T===1&&(b*=Math.pow(2,32),b+=Ee(A,8)),b/e})[0];return y!==void 0&&(n=y),Te(p,["tfhd"]).map(function(A){var T=Ee(A,4),b=Ee(A,0)&16777215,L=(b&1)!==0,R=(b&2)!==0,C=(b&8)!==0,I=0,k=(b&16)!==0,O=0,V=(b&32)!==0,N=8;T===r&&(L&&(N+=8),R&&(N+=4),C&&(I=Ee(A,N),N+=4),k&&(O=Ee(A,N),N+=4),V&&(N+=4),s.type==="video"&&(a=Gi(s.codec)),Te(p,["trun"]).map(function(B){var X=B[0],z=Ee(B,0)&16777215,K=(z&1)!==0,j=0,J=(z&4)!==0,le=(z&256)!==0,re=0,te=(z&512)!==0,fe=0,de=(z&1024)!==0,ve=(z&2048)!==0,ge=0,Ne=Ee(B,4),we=8;K&&(j=Ee(B,we),we+=4),J&&(we+=4);for(var Be=j+d,Ce=0;Ce<Ne;Ce++){if(le?(re=Ee(B,we),we+=4):re=I,te?(fe=Ee(B,we),we+=4):fe=O,de&&(we+=4),ve&&(X===0?ge=Ee(B,we):ge=Jn(B,we),we+=4),s.type===qe.VIDEO)for(var et=0;et<fe;){var Ge=Ee(t,Be);if(Be+=4,cu(a,t[Be])){var Qe=t.subarray(Be,Be+Ge);ra(Qe,a?2:1,n+ge/e,i)}Be+=Ge,et+=Ge+4}n+=re/e}}))})})}),i}function Gi(n){if(!n)return!1;var s=n.substring(0,4);return s==="hvc1"||s==="hev1"||s==="dvh1"||s==="dvhe"}function cu(n,s){if(n){var i=s>>1&63;return i===39||i===40}else{var t=s&31;return t===6}}function ra(n,s,i,t){var e=ia(n),r=0;r+=s;for(var a=0,u=0,l=0;r<e.length;){a=0;do{if(r>=e.length)break;l=e[r++],a+=l}while(l===255);u=0;do{if(r>=e.length)break;l=e[r++],u+=l}while(l===255);var d=e.length-r,c=r;if(u<d)r+=u;else if(u>d){Oe.error("Malformed SEI payload. "+u+" is too small, only "+d+" bytes left to parse.");break}if(a===4){var p=e[c++];if(p===181){var y=Qn(e,c);if(c+=2,y===49){var A=Ee(e,c);if(c+=4,A===1195456820){var T=e[c++];if(T===3){var b=e[c++],L=31&b,R=64&b,C=R?2+L*3:0,I=new Uint8Array(C);if(R){I[0]=b;for(var k=1;k<C;k++)I[k]=e[c++]}t.push({type:T,payloadType:a,pts:i,bytes:I})}}}}}else if(a===5&&u>16){for(var O=[],V=0;V<16;V++){var N=e[c++].toString(16);O.push(N.length==1?"0"+N:N),(V===3||V===5||V===7||V===9)&&O.push("-")}for(var B=u-16,X=new Uint8Array(B),z=0;z<B;z++)X[z]=e[c++];t.push({payloadType:a,pts:i,uuid:O.join(""),userData:Pt(X),userDataBytes:X})}}}function ia(n){for(var s=n.byteLength,i=[],t=1;t<s-2;)n[t]===0&&n[t+1]===0&&n[t+2]===3?(i.push(t+2),t+=2):t++;if(i.length===0)return n;var e=s-i.length,r=new Uint8Array(e),a=0;for(t=0;t<e;a++,t++)a===i[0]&&(a++,i.shift()),r[t]=n[a];return r}function vu(n){var s=n[0],i="",t="",e=0,r=0,a=0,u=0,l=0,d=0;if(s===0){for(;st(n.subarray(d,d+1))!=="\0";)i+=st(n.subarray(d,d+1)),d+=1;for(i+=st(n.subarray(d,d+1)),d+=1;st(n.subarray(d,d+1))!=="\0";)t+=st(n.subarray(d,d+1)),d+=1;t+=st(n.subarray(d,d+1)),d+=1,e=Ee(n,12),r=Ee(n,16),u=Ee(n,20),l=Ee(n,24),d=28}else if(s===1){d+=4,e=Ee(n,d),d+=4;var c=Ee(n,d);d+=4;var p=Ee(n,d);for(d+=4,a=Math.pow(2,32)*c+p,U(a)||(a=Number.MAX_SAFE_INTEGER,Oe.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),u=Ee(n,d),d+=4,l=Ee(n,d),d+=4;st(n.subarray(d,d+1))!=="\0";)i+=st(n.subarray(d,d+1)),d+=1;for(i+=st(n.subarray(d,d+1)),d+=1;st(n.subarray(d,d+1))!=="\0";)t+=st(n.subarray(d,d+1)),d+=1;t+=st(n.subarray(d,d+1)),d+=1}var y=n.subarray(d,n.byteLength);return{schemeIdUri:i,value:t,timeScale:e,presentationTime:a,presentationTimeDelta:r,eventDuration:u,id:l,payload:y}}function nr(n){if(n===void 0&&(n=!0),!(typeof self>"u")){var s=(n||!self.MediaSource)&&self.ManagedMediaSource;return s||self.MediaSource||self.WebKitMediaSource}}function pu(n){return typeof self<"u"&&n===self.ManagedMediaSource}function gu(n,s){var i=Object.keys(n),t=Object.keys(s),e=i.length,r=t.length;return!e||!r||e===r&&!i.some(function(a){return t.indexOf(a)===-1})}var na=function(){return/\(Windows.+Firefox\//i.test(navigator.userAgent)},gr={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,dav1:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function aa(n,s){var i=gr[s];return!!i&&!!i[n.slice(0,4)]}function Vi(n,s,i){return i===void 0&&(i=!0),!n.split(",").some(function(t){return!sa(t,s,i)})}function sa(n,s,i){var t;i===void 0&&(i=!0);var e=nr(i);return(t=e?.isTypeSupported(Or(n,s)))!=null?t:!1}function Or(n,s){return s+"/mp4;codecs="+n}function oa(n){if(n){var s=n.substring(0,4);return gr.video[s]}return 2}function ri(n){var s=na();return n.split(",").reduce(function(i,t){var e=s&&Gi(t),r=e?9:gr.video[t];return r?(r*2+i)/(i?3:2):(gr.audio[t]+i)/(i?2:1)},0)}var Hi={};function mu(n,s){if(s===void 0&&(s=!0),Hi[n])return Hi[n];for(var i={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[n],t=0;t<i.length;t++){var e;if(sa(i[t],"audio",s))return Hi[n]=i[t],i[t];if(i[t]==="mp3"&&(e=nr(s))!=null&&e.isTypeSupported("audio/mpeg"))return""}return n}var yu=/flac|opus|mp4a\.40\.34/i;function ii(n,s){return s===void 0&&(s=!0),n.replace(yu,function(i){return mu(i.toLowerCase(),s)})}function Eu(n,s){var i=[];if(n)for(var t=n.split(","),e=0;e<t.length;e++)aa(t[e],"video")||i.push(t[e]);return s&&i.push(s),i.join(",")}function ni(n,s){if(n&&(n.length>4||["ac-3","ec-3","alac","fLaC","Opus"].indexOf(n)!==-1))return n;if(s){var i=s.split(",");if(i.length>1){if(n){for(var t=i.length;t--;)if(i[t].substring(0,4)===n.substring(0,4))return i[t]}return i[0]}}return s||n}function _u(n){for(var s=n.split(","),i=0;i<s.length;i++){var t=s[i].split(".");if(t.length>2){var e=t.shift()+".";e+=parseInt(t.shift()).toString(16),e+=("000"+parseInt(t.shift()).toString(16)).slice(-4),s[i]=e}}return s.join(",")}function Su(n){if(n.startsWith("av01.")){for(var s=n.split("."),i=["0","111","01","01","01","0"],t=s.length;t>4&&t<10;t++)s[t]=i[t-4];return s.join(".")}return n}function ua(n){var s=nr(n)||{isTypeSupported:function(){return!1}};return{mpeg:s.isTypeSupported("audio/mpeg"),mp3:s.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:!1}}function la(n){return n.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}var Ki=["NONE","TYPE-0","TYPE-1",null];function Tu(n){return Ki.indexOf(n)>-1}var ai=["SDR","PQ","HLG"];function Au(n){return!!n&&ai.indexOf(n)>-1}var si={No:"",Yes:"YES",v2:"v2"};function fa(n){var s=n.canSkipUntil,i=n.canSkipDateRanges,t=n.age,e=t<s/2;return s&&e?i?si.v2:si.Yes:si.No}var ha=function(){function n(i,t,e){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=i,this.part=t,this.skip=e}var s=n.prototype;return s.addDirectives=function(t){var e=new self.URL(t);return this.msn!==void 0&&e.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&e.searchParams.set("_HLS_part",this.part.toString()),this.skip&&e.searchParams.set("_HLS_skip",this.skip),e.href},n}(),da=function(){function n(i){if(this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.supplemental=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[i.url],this._attrs=[i.attrs],this.bitrate=i.bitrate,i.details&&(this.details=i.details),this.id=i.id||0,this.name=i.name,this.width=i.width||0,this.height=i.height||0,this.frameRate=i.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=i.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=i.audioCodec,this.videoCodec=i.videoCodec,this.codecSet=[i.videoCodec,i.audioCodec].filter(function(r){return!!r}).map(function(r){return r.substring(0,4)}).join(","),"supplemental"in i){var t;this.supplemental=i.supplemental;var e=(t=i.supplemental)==null?void 0:t.videoCodec;e&&e!==i.videoCodec&&(this.codecSet+=","+e.substring(0,4))}this.addGroupId("audio",i.attrs.AUDIO),this.addGroupId("text",i.attrs.SUBTITLES)}var s=n.prototype;return s.hasAudioGroup=function(t){return ca(this._audioGroups,t)},s.hasSubtitleGroup=function(t){return ca(this._subtitleGroups,t)},s.addGroupId=function(t,e){if(e){if(t==="audio"){var r=this._audioGroups;r||(r=this._audioGroups=[]),r.indexOf(e)===-1&&r.push(e)}else if(t==="text"){var a=this._subtitleGroups;a||(a=this._subtitleGroups=[]),a.indexOf(e)===-1&&a.push(e)}}},s.addFallback=function(){},f(n,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"averageBitrate",get:function(){return this._avgBitrate||this.realBitrate||this.bitrate}},{key:"attrs",get:function(){return this._attrs[0]}},{key:"codecs",get:function(){return this.attrs.CODECS||""}},{key:"pathwayId",get:function(){return this.attrs["PATHWAY-ID"]||"."}},{key:"videoRange",get:function(){return this.attrs["VIDEO-RANGE"]||"SDR"}},{key:"score",get:function(){return this.attrs.optionalFloat("SCORE",0)}},{key:"uri",get:function(){return this.url[0]||""}},{key:"audioGroups",get:function(){return this._audioGroups}},{key:"subtitleGroups",get:function(){return this._subtitleGroups}},{key:"urlId",get:function(){return 0},set:function(t){}},{key:"audioGroupIds",get:function(){return this.audioGroups?[this.audioGroupId]:void 0}},{key:"textGroupIds",get:function(){return this.subtitleGroups?[this.textGroupId]:void 0}},{key:"audioGroupId",get:function(){var t;return(t=this.audioGroups)==null?void 0:t[0]}},{key:"textGroupId",get:function(){var t;return(t=this.subtitleGroups)==null?void 0:t[0]}}])}();function ca(n,s){return!s||!n?!1:n.indexOf(s)!==-1}function bu(){if(typeof matchMedia=="function"){var n=matchMedia("(dynamic-range: high)"),s=matchMedia("bad query");if(n.media!==s.media)return n.matches===!0}return!1}function Lu(n,s){var i=!1,t=[];if(n&&(i=n!=="SDR",t=[n]),s){t=s.allowedVideoRanges||ai.slice(0);var e=t.join("")!=="SDR"&&!s.videoCodec;i=s.preferHDR!==void 0?s.preferHDR:e&&bu(),i||(t=["SDR"])}return{preferHDR:i,allowedVideoRanges:t}}var xu=function(s){var i=new WeakSet;return function(t,e){if(s&&(e=s(t,e)),typeof e=="object"&&e!==null){if(i.has(e))return;i.add(e)}return e}},gt=function(s,i){return JSON.stringify(s,xu(i))};function Ru(n,s,i,t,e){for(var r=Object.keys(n),a=t?.channels,u=t?.audioCodec,l=e?.videoCodec,d=a&&parseInt(a)===2,c=!1,p=!1,y=1/0,A=1/0,T=1/0,b=1/0,L=0,R=[],C=Lu(s,e),I=C.preferHDR,k=C.allowedVideoRanges,O=function(){var j=n[r[V]];c||(c=j.channels[2]>0),y=Math.min(y,j.minHeight),A=Math.min(A,j.minFramerate),T=Math.min(T,j.minBitrate);var J=k.filter(function(le){return j.videoRanges[le]>0});J.length>0&&(p=!0)},V=r.length;V--;)O();y=w(y)?y:0,A=w(A)?A:0;var N=Math.max(1080,y),B=Math.max(30,A);T=w(T)?T:i,i=Math.max(T,i),p||(s=void 0);var X=r.length>1,z=r.reduce(function(K,j){var J=n[j];if(j===K)return K;if(R=p?k.filter(function(le){return J.videoRanges[le]>0}):[],X){if(J.minBitrate>i)return zt(j,"min bitrate of "+J.minBitrate+" > current estimate of "+i),K;if(!J.hasDefaultAudio)return zt(j,"no renditions with default or auto-select sound found"),K;if(u&&j.indexOf(u.substring(0,4))%5!==0)return zt(j,'audio codec preference "'+u+'" not found'),K;if(a&&!d){if(!J.channels[a])return zt(j,"no renditions with "+a+" channel sound found (channels options: "+Object.keys(J.channels)+")"),K}else if((!u||d)&&c&&J.channels[2]===0)return zt(j,"no renditions with stereo sound found"),K;if(J.minHeight>N)return zt(j,"min resolution of "+J.minHeight+" > maximum of "+N),K;if(J.minFramerate>B)return zt(j,"min framerate of "+J.minFramerate+" > maximum of "+B),K;if(!R.some(function(le){return J.videoRanges[le]>0}))return zt(j,"no variants with VIDEO-RANGE of "+gt(R)+" found"),K;if(l&&j.indexOf(l.substring(0,4))%5!==0)return zt(j,'video codec preference "'+l+'" not found'),K;if(J.maxScore<L)return zt(j,"max score of "+J.maxScore+" < selected max of "+L),K}return K&&(ri(j)>=ri(K)||J.fragmentError>n[K].fragmentError)?K:(b=J.minIndex,L=J.maxScore,j)},void 0);return{codecSet:z,videoRanges:R,preferHDR:I,minFramerate:A,minBitrate:T,minIndex:b}}function zt(n,s){Oe.log('[abr] start candidates with "'+n+'" ignored because '+s)}function va(n){return n.reduce(function(s,i){var t=s.groups[i.groupId];t||(t=s.groups[i.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),t.tracks.push(i);var e=i.channels||"2";return t.channels[e]=(t.channels[e]||0)+1,t.hasDefault=t.hasDefault||i.default,t.hasAutoSelect=t.hasAutoSelect||i.autoselect,t.hasDefault&&(s.hasDefaultAudio=!0),t.hasAutoSelect&&(s.hasAutoSelectAudio=!0),s},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function Cu(n,s,i,t){return n.slice(i,t+1).reduce(function(e,r,a){if(!r.codecSet)return e;var u=r.audioGroups,l=e[r.codecSet];l||(e[r.codecSet]=l={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:a,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!u,fragmentError:0}),l.minBitrate=Math.min(l.minBitrate,r.bitrate);var d=Math.min(r.height,r.width);return l.minHeight=Math.min(l.minHeight,d),l.minFramerate=Math.min(l.minFramerate,r.frameRate),l.minIndex=Math.min(l.minIndex,a),l.maxScore=Math.max(l.maxScore,r.score),l.fragmentError+=r.fragmentError,l.videoRanges[r.videoRange]=(l.videoRanges[r.videoRange]||0)+1,e},{})}function pa(n,s){var i;return!!n&&n!==((i=s.loadLevelObj)==null?void 0:i.uri)}var ku=function(n){function s(t){var e;return e=n.call(this,"abr",t.logger)||this,e.hls=void 0,e.lastLevelLoadSec=0,e.lastLoadedFragLevel=-1,e.firstSelection=-1,e._nextAutoLevel=-1,e.nextAutoLevelKey="",e.audioTracksByGroup=null,e.codecTiers=null,e.timer=-1,e.fragCurrent=null,e.partCurrent=null,e.bitrateTestDelay=0,e.rebufferNotice=-1,e.bwEstimator=void 0,e._abandonRulesCheck=function(r){var a,u=e,l=u.fragCurrent,d=u.partCurrent,c=u.hls,p=c.autoLevelEnabled,y=c.media;if(!(!l||!y)){var A=performance.now(),T=d?d.stats:l.stats,b=d?d.duration:l.duration,L=A-T.loading.start,R=c.minAutoLevel,C=l.level,I=e._nextAutoLevel;if(T.aborted||T.loaded&&T.loaded===T.total||C<=R){e.clearTimer(),e._nextAutoLevel=-1;return}if(p){var k=I>-1&&I!==C,O=!!r||k;if(!(!O&&(y.paused||!y.playbackRate||!y.readyState))){var V=c.mainForwardBufferInfo;if(!(!O&&V===null)){var N=e.bwEstimator.getEstimateTTFB(),B=Math.abs(y.playbackRate);if(!(L<=Math.max(N,1e3*(b/(B*2))))){var X=V?V.len/B:0,z=T.loading.first?T.loading.first-T.loading.start:-1,K=T.loaded&&z>-1,j=e.getBwEstimate(),J=c.levels,le=J[C],re=Math.max(T.loaded,Math.round(b*(l.bitrate||le.averageBitrate)/8)),te=K?L-z:L;te<1&&K&&(te=Math.min(L,T.loaded*8/j));var fe=K?T.loaded*1e3/te:0,de=N/1e3,ve=fe?(re-T.loaded)/fe:re*8/j+de;if(!(ve<=X)){var ge=fe?fe*8:j,Ne=((a=r?.details||e.hls.latestLevelDetails)==null?void 0:a.live)===!0,we=e.hls.config.abrBandWidthUpFactor,Be=Number.POSITIVE_INFINITY,Ce;for(Ce=C-1;Ce>R;Ce--){var et=J[Ce].maxBitrate,Ge=!J[Ce].details||Ne;if(Be=e.getTimeToLoadFrag(de,ge,b*et,Ge),Be<Math.min(X,b+de))break}if(!(Be>=ve)&&!(Be>b*10)){K?e.bwEstimator.sample(L-Math.min(N,z),T.loaded):e.bwEstimator.sampleTTFB(L);var Qe=J[Ce].maxBitrate;e.getBwEstimate()*we>Qe&&e.resetEstimator(Qe);var _t=e.findBestLevel(Qe,R,Ce,0,X,1,1);_t>-1&&(Ce=_t),e.warn("Fragment "+l.sn+(d?" part "+d.index:"")+" of level "+C+` is loading too slowly;
3
+ Fragment duration: `+l.duration.toFixed(3)+`
4
+ Time to underbuffer: `+X.toFixed(3)+` s
5
+ Estimated load time for current fragment: `+ve.toFixed(3)+` s
6
+ Estimated load time for down switch fragment: `+Be.toFixed(3)+` s
7
+ TTFB estimate: `+(z|0)+` ms
8
+ Current BW estimate: `+(w(j)?j|0:"Unknown")+` bps
9
+ New BW estimate: `+(e.getBwEstimate()|0)+` bps
10
+ Switching to level `+Ce+" @ "+(Qe|0)+" bps"),c.nextLoadLevel=c.nextAutoLevel=Ce,e.clearTimer();var ut=function(){if(e.clearTimer(),e.fragCurrent===l&&e.hls.loadLevel===Ce&&Ce>0){var St=e.getStarvationDelay();if(e.warn("Aborting inflight request "+(Ce>0?"and switching down":"")+`
11
+ Fragment duration: `+l.duration.toFixed(3)+` s
12
+ Time to underbuffer: `+St.toFixed(3)+" s"),l.abortRequests(),e.fragCurrent=e.partCurrent=null,Ce>R){var it=e.findBestLevel(e.hls.levels[R].bitrate,R,Ce,0,St,1,1);it===-1&&(it=R),e.hls.nextLoadLevel=e.hls.nextAutoLevel=it,e.resetEstimator(e.hls.levels[it].bitrate)}}};k||ve>Be*2?ut():e.timer=self.setInterval(ut,Be*1e3),c.trigger(x.FRAG_LOAD_EMERGENCY_ABORTED,{frag:l,part:d,stats:T})}}}}}}}},e.hls=t,e.bwEstimator=e.initEstimator(),e.registerListeners(),e}S(s,n);var i=s.prototype;return i.resetEstimator=function(e){e&&(this.log("setting initial bwe to "+e),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()},i.initEstimator=function(){var e=this.hls.config;return new Ue(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)},i.registerListeners=function(){var e=this.hls;e.on(x.MANIFEST_LOADING,this.onManifestLoading,this),e.on(x.FRAG_LOADING,this.onFragLoading,this),e.on(x.FRAG_LOADED,this.onFragLoaded,this),e.on(x.FRAG_BUFFERED,this.onFragBuffered,this),e.on(x.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(x.LEVEL_LOADED,this.onLevelLoaded,this),e.on(x.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(x.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(x.ERROR,this.onError,this)},i.unregisterListeners=function(){var e=this.hls;e&&(e.off(x.MANIFEST_LOADING,this.onManifestLoading,this),e.off(x.FRAG_LOADING,this.onFragLoading,this),e.off(x.FRAG_LOADED,this.onFragLoaded,this),e.off(x.FRAG_BUFFERED,this.onFragBuffered,this),e.off(x.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(x.LEVEL_LOADED,this.onLevelLoaded,this),e.off(x.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(x.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(x.ERROR,this.onError,this))},i.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null},i.onManifestLoading=function(e,r){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()},i.onLevelsUpdated=function(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null},i.onMaxAutoLevelUpdated=function(){this.firstSelection=-1,this.nextAutoLevelKey=""},i.onFragLoading=function(e,r){var a=r.frag;if(!this.ignoreFragment(a)){if(!a.bitrateTest){var u;this.fragCurrent=a,this.partCurrent=(u=r.part)!=null?u:null}this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}},i.onLevelSwitching=function(e,r){this.clearTimer()},i.onError=function(e,r){if(!r.fatal)switch(r.details){case M.BUFFER_ADD_CODEC_ERROR:case M.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case M.FRAG_LOAD_TIMEOUT:{var a=r.frag,u=this.fragCurrent,l=this.partCurrent;if(a&&u&&a.sn===u.sn&&a.level===u.level){var d=performance.now(),c=l?l.stats:a.stats,p=d-c.loading.start,y=c.loading.first?c.loading.first-c.loading.start:-1,A=c.loaded&&y>-1;if(A){var T=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(p-Math.min(T,y),c.loaded)}else this.bwEstimator.sampleTTFB(p)}break}}},i.getTimeToLoadFrag=function(e,r,a,u){var l=e+a/r,d=u?e+this.lastLevelLoadSec:0;return l+d},i.onLevelLoaded=function(e,r){var a=this.hls.config,u=r.stats.loading,l=u.end-u.first;w(l)&&(this.lastLevelLoadSec=l/1e3),r.details.live?this.bwEstimator.update(a.abrEwmaSlowLive,a.abrEwmaFastLive):this.bwEstimator.update(a.abrEwmaSlowVoD,a.abrEwmaFastVoD),this.timer>-1&&this._abandonRulesCheck(r.levelInfo)},i.onFragLoaded=function(e,r){var a=r.frag,u=r.part,l=u?u.stats:a.stats;if(a.type===ae.MAIN&&this.bwEstimator.sampleTTFB(l.loading.first-l.loading.start),!this.ignoreFragment(a)){if(this.clearTimer(),a.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){var d=u?u.duration:a.duration,c=this.hls.levels[a.level],p=(c.loaded?c.loaded.bytes:0)+l.loaded,y=(c.loaded?c.loaded.duration:0)+d;c.loaded={bytes:p,duration:y},c.realBitrate=Math.round(8*p/y)}if(a.bitrateTest){var A={stats:l,frag:a,part:u,id:a.type};this.onFragBuffered(x.FRAG_BUFFERED,A),a.bitrateTest=!1}else this.lastLoadedFragLevel=a.level}},i.onFragBuffered=function(e,r){var a=r.frag,u=r.part,l=u!=null&&u.stats.loaded?u.stats:a.stats;if(!l.aborted&&!this.ignoreFragment(a)){var d=l.parsing.end-l.loading.start-Math.min(l.loading.first-l.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(d,l.loaded),l.bwEstimate=this.getBwEstimate(),a.bitrateTest?this.bitrateTestDelay=d/1e3:this.bitrateTestDelay=0}},i.ignoreFragment=function(e){return e.type!==ae.MAIN||e.sn==="initSegment"},i.clearTimer=function(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)},i.getAutoLevelKey=function(){return this.getBwEstimate()+"_"+this.getStarvationDelay().toFixed(2)},i.getNextABRAutoLevel=function(){var e=this.fragCurrent,r=this.partCurrent,a=this.hls;if(a.levels.length<=1)return a.loadLevel;var u=a.maxAutoLevel,l=a.config,d=a.minAutoLevel,c=r?r.duration:e?e.duration:0,p=this.getBwEstimate(),y=this.getStarvationDelay(),A=l.abrBandWidthFactor,T=l.abrBandWidthUpFactor;if(y){var b=this.findBestLevel(p,d,u,y,0,A,T);if(b>=0)return this.rebufferNotice=-1,b}var L=c?Math.min(c,l.maxStarvationDelay):l.maxStarvationDelay;if(!y){var R=this.bitrateTestDelay;if(R){var C=c?Math.min(c,l.maxLoadingDelay):l.maxLoadingDelay;L=C-R,this.info("bitrate test took "+Math.round(1e3*R)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*L)+" ms"),A=T=1}}var I=this.findBestLevel(p,d,u,y,L,A,T);if(this.rebufferNotice!==I&&(this.rebufferNotice=I,this.info((y?"rebuffering expected":"buffer is empty")+", optimal quality level "+I)),I>-1)return I;var k=a.levels[d],O=a.loadLevelObj;return O&&k?.bitrate<O.bitrate?d:a.loadLevel},i.getStarvationDelay=function(){var e=this.hls,r=e.media;if(!r)return 1/0;var a=r&&r.playbackRate!==0?Math.abs(r.playbackRate):1,u=e.mainForwardBufferInfo;return(u?u.len:0)/a},i.getBwEstimate=function(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate},i.findBestLevel=function(e,r,a,u,l,d,c){var p,y=this,A=u+l,T=this.lastLoadedFragLevel,b=T===-1?this.hls.firstLevel:T,L=this.fragCurrent,R=this.partCurrent,C=this.hls,I=C.levels,k=C.allAudioTracks,O=C.loadLevel,V=C.config;if(I.length===1)return 0;var N=I[b],B=!!((p=this.hls.latestLevelDetails)!=null&&p.live),X=O===-1||T===-1,z,K="SDR",j=N?.frameRate||0,J=V.audioPreference,le=V.videoPreference,re=this.audioTracksByGroup||(this.audioTracksByGroup=va(k)),te=-1;if(X){if(this.firstSelection!==-1)return this.firstSelection;var fe=this.codecTiers||(this.codecTiers=Cu(I,re,r,a)),de=Ru(fe,K,e,J,le),ve=de.codecSet,ge=de.videoRanges,Ne=de.minFramerate,we=de.minBitrate,Be=de.minIndex,Ce=de.preferHDR;te=Be,z=ve,K=Ce?ge[ge.length-1]:ge[0],j=Ne,e=Math.max(e,we),this.log("picked start tier "+gt(de))}else z=N?.codecSet,K=N?.videoRange;for(var et=R?R.duration:L?L.duration:0,Ge=this.bwEstimator.getEstimateTTFB()/1e3,Qe=[],_t=function(){var it,$e=I[Ve],Tt=Ve>b;if(!$e)return 0;if((z&&$e.codecSet!==z||K&&$e.videoRange!==K||Tt&&j>$e.frameRate||!Tt&&j>0&&j<$e.frameRate||$e.supportedResult&&!((it=$e.supportedResult.decodingInfoResults)!=null&&it[0].smooth))&&(!X||Ve!==te))return Qe.push(Ve),0;var dt=$e.details,xt=(R?dt?.partTarget:dt?.averagetargetduration)||et,Ye;Tt?Ye=c*e:Ye=d*e;var ct=et&&u>=et*2&&l===0?$e.averageBitrate:$e.maxBitrate,nt=y.getTimeToLoadFrag(Ge,Ye,ct*xt,dt===void 0),At=Ye>=ct&&(Ve===T||$e.loadError===0&&$e.fragmentError===0)&&(nt<=Ge||!w(nt)||B&&!y.bitrateTestDelay||nt<A);if(At){var Vr=y.forcedAutoLevel;return Ve!==O&&(Vr===-1||Vr!==O)&&(Qe.length&&y.trace("Skipped level(s) "+Qe.join(",")+" of "+a+' max with CODECS and VIDEO-RANGE:"'+I[Qe[0]].codecs+'" '+I[Qe[0]].videoRange+'; not compatible with "'+z+'" '+K),y.info("switch candidate:"+b+"->"+Ve+" adjustedbw("+Math.round(Ye)+")-bitrate="+Math.round(Ye-ct)+" ttfb:"+Ge.toFixed(1)+" avgDuration:"+xt.toFixed(1)+" maxFetchDuration:"+A.toFixed(1)+" fetchDuration:"+nt.toFixed(1)+" firstSelection:"+X+" codecSet:"+$e.codecSet+" videoRange:"+$e.videoRange+" hls.loadLevel:"+O)),X&&(y.firstSelection=Ve),{v:Ve}}},ut,Ve=a;Ve>=r;Ve--)if(ut=_t(),ut!==0&&ut)return ut.v;return-1},i.deriveNextAutoLevel=function(e){var r=this.hls,a=r.maxAutoLevel,u=r.minAutoLevel;return Math.min(Math.max(e,u),a)},f(s,[{key:"firstAutoLevel",get:function(){var e=this.hls,r=e.maxAutoLevel,a=e.minAutoLevel,u=this.getBwEstimate(),l=this.hls.config.maxStarvationDelay,d=this.findBestLevel(u,a,r,0,l,1,1);if(d>-1)return d;var c=this.hls.firstLevel,p=Math.min(Math.max(c,a),r);return this.warn("Could not find best starting auto level. Defaulting to first in playlist "+c+" clamped to "+p),p}},{key:"forcedAutoLevel",get:function(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}},{key:"nextAutoLevel",get:function(){var e=this.forcedAutoLevel,r=this.bwEstimator,a=r.canEstimate(),u=this.lastLoadedFragLevel>-1;if(e!==-1&&(!a||!u||this.nextAutoLevelKey===this.getAutoLevelKey()))return e;var l=a&&u?this.getNextABRAutoLevel():this.firstAutoLevel;if(e!==-1){var d=this.hls.levels;if(d.length>Math.max(e,l)&&d[e].loadError<=d[l].loadError)return e}return this._nextAutoLevel=l,this.nextAutoLevelKey=this.getAutoLevelKey(),l},set:function(e){var r=this.deriveNextAutoLevel(e);this._nextAutoLevel!==r&&(this.nextAutoLevelKey="",this._nextAutoLevel=r)}}])}(je),Du=function(){function n(i){this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=i}var s=n.prototype;return s.destroy=function(){this.tracks=this.queues=null},s.append=function(t,e,r){if(!(this.queues===null||this.tracks===null)){var a=this.queues[e];a.push(t),a.length===1&&!r&&this.executeNext(e)}},s.appendBlocker=function(t){var e=this;return new Promise(function(r){var a={label:"async-blocker",execute:r,onStart:function(){},onComplete:function(){},onError:function(){}};e.append(a,t)})},s.prependBlocker=function(t){var e=this;return new Promise(function(r){if(e.queues){var a={label:"async-blocker-prepend",execute:r,onStart:function(){},onComplete:function(){},onError:function(){}};e.queues[t].unshift(a)}})},s.removeBlockers=function(){this.queues!==null&&[this.queues.video,this.queues.audio,this.queues.audiovideo].forEach(function(t){var e,r=(e=t[0])==null?void 0:e.label;(r==="async-blocker"||r==="async-blocker-prepend")&&(t[0].execute(),t.splice(0,1))})},s.unblockAudio=function(t){if(this.queues!==null){var e=this.queues.audio;e[0]===t&&this.shiftAndExecuteNext("audio")}},s.executeNext=function(t){if(!(this.queues===null||this.tracks===null)){var e=this.queues[t];if(e.length){var r=e[0];try{r.execute()}catch(l){var a;if(r.onError(l),this.queues===null||this.tracks===null)return;var u=(a=this.tracks[t])==null?void 0:a.buffer;u!=null&&u.updating||this.shiftAndExecuteNext(t)}}}},s.shiftAndExecuteNext=function(t){this.queues!==null&&(this.queues[t].shift(),this.executeNext(t))},s.current=function(t){var e;return((e=this.queues)==null?void 0:e[t][0])||null},s.toString=function(){var t=this.queues,e=this.tracks;return t===null||e===null?"<destroyed>":`
12
13
  `+this.list("video")+`
13
14
  `+this.list("audio")+`
14
- `+this.list("audiovideo")+"}"},W.list=function Z(J){var Y,Q;return(Y=this.queues)!=null&&Y[J]||(Q=this.tracks)!=null&&Q[J]?J+": ("+this.listSbInfo(J)+") "+this.listOps(J):""},W.listSbInfo=function Z(J){var Y,Q=(Y=this.tracks)==null?void 0:Y[J],G=Q==null?void 0:Q.buffer;if(!G)return"none";return"SourceBuffer"+(G.updating?" updating":"")+(Q.ended?" ended":"")+(Q.ending?" ending":"")},W.listOps=function Z(J){var Y;return((Y=this.queues)==null?void 0:Y[J].map(function(Q){return Q.label}).join(", "))||""},X}(),F2={search:function X(W,Z){var J=0,Y=W.length-1,Q=null,G=null;while(J<=Y){Q=(J+Y)/2|0,G=W[Q];var q=Z(G);if(q>0)J=Q+1;else if(q<0)Y=Q-1;else return G}return null}};function xX(X,W,Z){if(W===null||!Array.isArray(X)||!X.length||!T(W))return null;var J=X[0].programDateTime;if(W<(J||0))return null;var Y=X[X.length-1].endProgramDateTime;if(W>=(Y||0))return null;Z=Z||0;for(var Q=0;Q<X.length;++Q){var G=X[Q];if(hX(W,Z,G))return G}return null}function dJ(X,W,Z,J,Y){if(Z===void 0)Z=0;if(J===void 0)J=0;if(Y===void 0)Y=0.005;var Q=null;if(X){Q=W[1+X.sn-W[0].sn]||null;var G=X.endDTS-Z;if(G>0&&G<0.0000015)Z+=0.0000015;if(Q&&X.level!==Q.level&&Q.end<=X.end)Q=W[2+X.sn-W[0].sn]||null}else if(Z===0&&W[0].start===0)Q=W[0];if(Q&&((!X||X.level===Q.level)&&E2(Z,J,Q)===0||vX(Q,X,Math.min(Y,J))))return Q;var q=F2.search(W,E2.bind(null,Z,J));if(q&&(q!==X||!Q))return q;return Q}function vX(X,W,Z){if(W&&W.start===0&&W.level<X.level&&(W.endPTS||0)>0){var J=W.tagList.reduce(function(Y,Q){if(Q[0]==="INF")Y+=parseFloat(Q[1]);return Y},Z);return X.start<=J}return!1}function E2(X,W,Z){if(X===void 0)X=0;if(W===void 0)W=0;if(Z.start<=X&&Z.start+Z.duration>X)return 0;var J=Math.min(W,Z.duration+(Z.deltaPTS?Z.deltaPTS:0));if(Z.start+Z.duration-J<=X)return 1;else if(Z.start-J>X&&Z.start)return-1;return 0}function hX(X,W,Z){var J=Math.min(W,Z.duration+(Z.deltaPTS?Z.deltaPTS:0))*1000,Y=Z.endProgramDateTime||0;return Y-J>X}function kX(X,W){return F2.search(X,function(Z){if(Z.cc<W)return 1;else if(Z.cc>W)return-1;else return 0})}function qJ(X){switch(X.details){case h.FRAG_LOAD_TIMEOUT:case h.KEY_LOAD_TIMEOUT:case h.LEVEL_LOAD_TIMEOUT:case h.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function B2(X,W){var Z=qJ(W);return X.default[(Z?"timeout":"error")+"Retry"]}function nJ(X,W){var Z=X.backoff==="linear"?1:Math.pow(2,W);return Math.min(Z*X.retryDelayMs,X.maxRetryDelayMs)}function w2(X){return f(f({},X),{errorRetry:null,timeoutRetry:null})}function HJ(X,W,Z,J){if(!X)return!1;var Y=J==null?void 0:J.code,Q=W<X.maxNumRetry&&(gX(Y)||!!Z);return X.shouldRetry?X.shouldRetry(X,W,Z,J,Q):Q}function gX(X){return X===0&&navigator.onLine===!1||!!X&&(X<400||X>499)}var U1={DoNothing:0,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,RetryRequest:5},h1={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2},uX=function(X){function W(J){var Y=X.call(this,"error-controller",J.logger)||this;return Y.hls=void 0,Y.playlistError=0,Y.penalizedRenditions={},Y.hls=J,Y.registerListeners(),Y}R(W,X);var Z=W.prototype;return Z.registerListeners=function J(){var Y=this.hls;Y.on(M.ERROR,this.onError,this),Y.on(M.MANIFEST_LOADING,this.onManifestLoading,this),Y.on(M.LEVEL_UPDATED,this.onLevelUpdated,this)},Z.unregisterListeners=function J(){var Y=this.hls;if(!Y)return;Y.off(M.ERROR,this.onError,this),Y.off(M.ERROR,this.onErrorOut,this),Y.off(M.MANIFEST_LOADING,this.onManifestLoading,this),Y.off(M.LEVEL_UPDATED,this.onLevelUpdated,this)},Z.destroy=function J(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}},Z.startLoad=function J(Y){},Z.stopLoad=function J(){this.playlistError=0},Z.getVariantLevelIndex=function J(Y){return(Y==null?void 0:Y.type)===G0.MAIN?Y.level:this.hls.loadLevel},Z.onManifestLoading=function J(){this.playlistError=0,this.penalizedRenditions={}},Z.onLevelUpdated=function J(){this.playlistError=0},Z.onError=function J(Y,Q){var G;if(Q.fatal)return;var q=this.hls,H=Q.context;switch(Q.details){case h.FRAG_LOAD_ERROR:case h.FRAG_LOAD_TIMEOUT:case h.KEY_LOAD_ERROR:case h.KEY_LOAD_TIMEOUT:Q.errorAction=this.getFragRetryOrSwitchAction(Q);return;case h.FRAG_PARSING_ERROR:if((G=Q.frag)!=null&&G.gap){Q.errorAction=NJ();return}case h.FRAG_GAP:case h.FRAG_DECRYPT_ERROR:{Q.errorAction=this.getFragRetryOrSwitchAction(Q),Q.errorAction.action=U1.SendAlternateToPenaltyBox;return}case h.LEVEL_EMPTY_ERROR:case h.LEVEL_PARSING_ERROR:{var V,z,A=Q.parent===G0.MAIN?Q.level:q.loadLevel;if(Q.details===h.LEVEL_EMPTY_ERROR&&!!((V=Q.context)!=null&&(z=V.levelDetails)!=null&&z.live))Q.errorAction=this.getPlaylistRetryOrSwitchAction(Q,A);else Q.levelRetry=!1,Q.errorAction=this.getLevelSwitchAction(Q,A)}return;case h.LEVEL_LOAD_ERROR:case h.LEVEL_LOAD_TIMEOUT:if(typeof(H==null?void 0:H.level)==="number")Q.errorAction=this.getPlaylistRetryOrSwitchAction(Q,H.level);return;case h.AUDIO_TRACK_LOAD_ERROR:case h.AUDIO_TRACK_LOAD_TIMEOUT:case h.SUBTITLE_LOAD_ERROR:case h.SUBTITLE_TRACK_LOAD_TIMEOUT:if(H){var E=q.loadLevelObj;if(E&&(H.type===Z0.AUDIO_TRACK&&E.hasAudioGroup(H.groupId)||H.type===Z0.SUBTITLE_TRACK&&E.hasSubtitleGroup(H.groupId))){Q.errorAction=this.getPlaylistRetryOrSwitchAction(Q,q.loadLevel),Q.errorAction.action=U1.SendAlternateToPenaltyBox,Q.errorAction.flags=h1.MoveAllAlternatesMatchingHost;return}}return;case h.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{var I=q.loadLevelObj,$=I==null?void 0:I.attrs["HDCP-LEVEL"];if($)Q.errorAction={action:U1.SendAlternateToPenaltyBox,flags:h1.MoveAllAlternatesMatchingHDCP,hdcpLevel:$};else this.keySystemError(Q)}return;case h.BUFFER_ADD_CODEC_ERROR:case h.REMUX_ALLOC_ERROR:case h.BUFFER_APPEND_ERROR:if(!Q.errorAction){var L;Q.errorAction=this.getLevelSwitchAction(Q,(L=Q.level)!=null?L:q.loadLevel)}return;case h.INTERNAL_EXCEPTION:case h.BUFFER_APPENDING_ERROR:case h.BUFFER_FULL_ERROR:case h.LEVEL_SWITCH_ERROR:case h.BUFFER_STALLED_ERROR:case h.BUFFER_SEEK_OVER_HOLE:case h.BUFFER_NUDGE_ON_STALL:Q.errorAction=NJ();return}if(Q.type===n.KEY_SYSTEM_ERROR)this.keySystemError(Q)},Z.keySystemError=function J(Y){var Q=this.getVariantLevelIndex(Y.frag);Y.levelRetry=!1,Y.errorAction=this.getLevelSwitchAction(Y,Q)},Z.getPlaylistRetryOrSwitchAction=function J(Y,Q){var G=this.hls,q=B2(G.config.playlistLoadPolicy,Y),H=this.playlistError++,V=HJ(q,H,qJ(Y),Y.response);if(V)return{action:U1.RetryRequest,flags:h1.None,retryConfig:q,retryCount:H};var z=this.getLevelSwitchAction(Y,Q);if(q)z.retryConfig=q,z.retryCount=H;return z},Z.getFragRetryOrSwitchAction=function J(Y){var Q=this.hls,G=this.getVariantLevelIndex(Y.frag),q=Q.levels[G],H=Q.config,V=H.fragLoadPolicy,z=H.keyLoadPolicy,A=B2(Y.details.startsWith("key")?z:V,Y),E=Q.levels.reduce(function(L,b){return L+b.fragmentError},0);if(q){if(Y.details!==h.FRAG_GAP)q.fragmentError++;var I=HJ(A,E,qJ(Y),Y.response);if(I)return{action:U1.RetryRequest,flags:h1.None,retryConfig:A,retryCount:E}}var $=this.getLevelSwitchAction(Y,G);if(A)$.retryConfig=A,$.retryCount=E;return $},Z.getLevelSwitchAction=function J(Y,Q){var G=this.hls;if(Q===null||Q===void 0)Q=G.loadLevel;var q=this.hls.levels[Q];if(q){var H,V,z=Y.details;if(q.loadError++,z===h.BUFFER_APPEND_ERROR)q.fragmentError++;var A=-1,E=G.levels,I=G.loadLevel,$=G.minAutoLevel,L=G.maxAutoLevel;if(!G.autoLevelEnabled)G.loadLevel=-1;var b=(H=Y.frag)==null?void 0:H.type,C=b===G0.AUDIO&&z===h.FRAG_PARSING_ERROR||Y.sourceBufferName==="audio"&&(z===h.BUFFER_ADD_CODEC_ERROR||z===h.BUFFER_APPEND_ERROR),D=C&&E.some(function(c){var d=c.audioCodec;return q.audioCodec!==d}),y=Y.sourceBufferName==="video"&&(z===h.BUFFER_ADD_CODEC_ERROR||z===h.BUFFER_APPEND_ERROR),S=y&&E.some(function(c){var{codecSet:d,audioCodec:e}=c;return q.codecSet!==d&&q.audioCodec===e}),v=(V=Y.context)!=null?V:{},p=v.type,g=v.groupId,m=function c(){var d=(o+I)%E.length;if(d!==I&&d>=$&&d<=L&&E[d].loadError===0){var e,H0,Q0=E[d];if(z===h.FRAG_GAP&&b===G0.MAIN&&Y.frag){var J0=E[d].details;if(J0){var N0=dJ(Y.frag,J0.fragments,Y.frag.start);if(N0!=null&&N0.gap)return 0}}else if(p===Z0.AUDIO_TRACK&&Q0.hasAudioGroup(g)||p===Z0.SUBTITLE_TRACK&&Q0.hasSubtitleGroup(g))return 0;else if(b===G0.AUDIO&&(e=q.audioGroups)!=null&&e.some(function(V0){return Q0.hasAudioGroup(V0)})||b===G0.SUBTITLE&&(H0=q.subtitleGroups)!=null&&H0.some(function(V0){return Q0.hasSubtitleGroup(V0)})||D&&q.audioCodec===Q0.audioCodec||!D&&q.audioCodec!==Q0.audioCodec||S&&q.codecSet===Q0.codecSet)return 0;return A=d,1}},r;for(var o=E.length;o--;){if(r=m(),r===0)continue;if(r===1)break}if(A>-1&&G.loadLevel!==A)return Y.levelRetry=!0,this.playlistError=0,{action:U1.SendAlternateToPenaltyBox,flags:h1.None,nextAutoLevel:A}}return{action:U1.SendAlternateToPenaltyBox,flags:h1.MoveAllAlternatesMatchingHost}},Z.onErrorOut=function J(Y,Q){var G;switch((G=Q.errorAction)==null?void 0:G.action){case U1.DoNothing:break;case U1.SendAlternateToPenaltyBox:if(this.sendAlternateToPenaltyBox(Q),!Q.errorAction.resolved&&Q.details!==h.FRAG_GAP)Q.fatal=!0;else if(/MediaSource readyState: ended/.test(Q.error.message))this.warn('MediaSource ended after "'+Q.sourceBufferName+'" sourceBuffer append error. Attempting to recover from media error.'),this.hls.recoverMediaError();break}if(Q.fatal){this.hls.stopLoad();return}},Z.sendAlternateToPenaltyBox=function J(Y){var Q=this.hls,G=Y.errorAction;if(!G)return;var{flags:q,hdcpLevel:H,nextAutoLevel:V}=G;switch(q){case h1.None:this.switchLevel(Y,V);break;case h1.MoveAllAlternatesMatchingHDCP:if(H)Q.maxHdcpLevel=lJ[lJ.indexOf(H)-1],G.resolved=!0;this.warn('Restricting playback to HDCP-LEVEL of "'+Q.maxHdcpLevel+'" or lower');break}if(!G.resolved)this.switchLevel(Y,V)},Z.switchLevel=function J(Y,Q){if(Q!==void 0&&Y.errorAction){if(this.warn("switching to level "+Q+" after "+Y.details),this.hls.nextAutoLevel=Q,Y.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel,Y.details===h.BUFFER_ADD_CODEC_ERROR&&Y.mimeType&&Y.sourceBufferName!=="audiovideo"){var G=N2(Y.mimeType),q=this.hls.levels;for(var H=q.length;H--;)if(q[H][Y.sourceBufferName+"Codec"]===G)this.hls.removeLevel(H)}}},W}(d0);function NJ(X){var W={action:U1.DoNothing,flags:h1.None};if(X)W.resolved=!0;return W}var R2={length:0,start:function X(){return 0},end:function X(){return 0}},k0=function(){function X(){}return X.isBuffered=function W(Z,J){if(Z){var Y=X.getBuffered(Z);for(var Q=Y.length;Q--;)if(J>=Y.start(Q)&&J<=Y.end(Q))return!0}return!1},X.bufferedRanges=function W(Z){if(Z){var J=X.getBuffered(Z);return X.timeRangesToArray(J)}return[]},X.timeRangesToArray=function W(Z){var J=[];for(var Y=0;Y<Z.length;Y++)J.push({start:Z.start(Y),end:Z.end(Y)});return J},X.bufferInfo=function W(Z,J,Y){if(Z){var Q=X.bufferedRanges(Z);if(Q.length)return X.bufferedInfo(Q,J,Y)}return{len:0,start:J,end:J,bufferedIndex:-1}},X.bufferedInfo=function W(Z,J,Y){if(J=Math.max(0,J),Z.length>1)Z.sort(function(C,D){return C.start-D.start||D.end-C.end});var Q=-1,G=[];if(Y)for(var q=0;q<Z.length;q++){if(J>=Z[q].start&&J<=Z[q].end)Q=q;var H=G.length;if(H){var V=G[H-1].end;if(Z[q].start-V<Y){if(Z[q].end>V)G[H-1].end=Z[q].end}else G.push(Z[q])}else G.push(Z[q])}else G=Z;var z=0,A,E=J,I=J;for(var $=0;$<G.length;$++){var L=G[$].start,b=G[$].end;if(Q===-1&&J>=L&&J<=b)Q=$;if(J+Y>=L&&J<b)E=L,I=b,z=I-J;else if(J+Y<L){A=L;break}}return{len:z,start:E||0,end:I||0,nextStart:A,buffered:Z,bufferedIndex:Q}},X.getBuffered=function W(Z){try{return Z.buffered||R2}catch(J){return v0.log("failed to get media.buffered",J),R2}},X}(),$2=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,I2="HlsJsTrackRemovedError",mX=function(X){function W(Z){var J=X.call(this,Z)||this;return J.name=I2,J}return R(W,X),W}(t(Error)),_X=function(X){function W(J,Y){var Q=X.call(this,"buffer-controller",J.logger)||this;return Q.hls=void 0,Q.fragmentTracker=void 0,Q.details=null,Q._objectUrl=null,Q.operationQueue=null,Q.bufferCodecEventsTotal=0,Q.media=null,Q.mediaSource=null,Q.lastMpegAudioChunk=null,Q.blockedAudioAppend=null,Q.lastVideoAppendEnd=0,Q.appendSource=void 0,Q.transferData=void 0,Q.overrides=void 0,Q.appendErrors={audio:0,video:0,audiovideo:0},Q.tracks={},Q.sourceBuffers=[[null,null],[null,null]],Q._onEndStreaming=function(G){var q;if(!Q.hls)return;if(((q=Q.mediaSource)==null?void 0:q.readyState)!=="open")return;Q.hls.pauseBuffering()},Q._onStartStreaming=function(G){if(!Q.hls)return;Q.hls.resumeBuffering()},Q._onMediaSourceOpen=function(G){var q=Q,H=q.media,V=q.mediaSource;if(G)Q.log("Media source opened");if(!H||!V)return;if(V.removeEventListener("sourceopen",Q._onMediaSourceOpen),H.removeEventListener("emptied",Q._onMediaEmptied),Q.updateDuration(),Q.hls.trigger(M.MEDIA_ATTACHED,{media:H,mediaSource:V}),Q.mediaSource!==null)Q.checkPendingTracks()},Q._onMediaSourceClose=function(){Q.log("Media source closed")},Q._onMediaSourceEnded=function(){Q.log("Media source ended")},Q._onMediaEmptied=function(){var G=Q,q=G.mediaSrc,H=G._objectUrl;if(q!==H)Q.error("Media element src was set while attaching MediaSource ("+H+" > "+q+")")},Q.hls=J,Q.fragmentTracker=Y,Q.appendSource=FX(XY(J.config.preferManagedMediaSource)),Q.initTracks(),Q.registerListeners(),Q}R(W,X);var Z=W.prototype;return Z.hasSourceTypes=function J(){return Object.keys(this.tracks).length>0},Z.destroy=function J(){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 J(){var Y=this.hls;Y.on(M.MEDIA_ATTACHING,this.onMediaAttaching,this),Y.on(M.MEDIA_DETACHING,this.onMediaDetaching,this),Y.on(M.MANIFEST_LOADING,this.onManifestLoading,this),Y.on(M.MANIFEST_PARSED,this.onManifestParsed,this),Y.on(M.BUFFER_RESET,this.onBufferReset,this),Y.on(M.BUFFER_APPENDING,this.onBufferAppending,this),Y.on(M.BUFFER_CODECS,this.onBufferCodecs,this),Y.on(M.BUFFER_EOS,this.onBufferEos,this),Y.on(M.BUFFER_FLUSHING,this.onBufferFlushing,this),Y.on(M.LEVEL_UPDATED,this.onLevelUpdated,this),Y.on(M.FRAG_PARSED,this.onFragParsed,this),Y.on(M.FRAG_CHANGED,this.onFragChanged,this),Y.on(M.ERROR,this.onError,this)},Z.unregisterListeners=function J(){var Y=this.hls;Y.off(M.MEDIA_ATTACHING,this.onMediaAttaching,this),Y.off(M.MEDIA_DETACHING,this.onMediaDetaching,this),Y.off(M.MANIFEST_LOADING,this.onManifestLoading,this),Y.off(M.MANIFEST_PARSED,this.onManifestParsed,this),Y.off(M.BUFFER_RESET,this.onBufferReset,this),Y.off(M.BUFFER_APPENDING,this.onBufferAppending,this),Y.off(M.BUFFER_CODECS,this.onBufferCodecs,this),Y.off(M.BUFFER_EOS,this.onBufferEos,this),Y.off(M.BUFFER_FLUSHING,this.onBufferFlushing,this),Y.off(M.LEVEL_UPDATED,this.onLevelUpdated,this),Y.off(M.FRAG_PARSED,this.onFragParsed,this),Y.off(M.FRAG_CHANGED,this.onFragChanged,this),Y.off(M.ERROR,this.onError,this)},Z.transferMedia=function J(){var Y=this,Q=this.media,G=this.mediaSource;if(!Q)return null;var q={};if(this.operationQueue){var H=this.isUpdating();if(!H)this.operationQueue.removeBlockers();var V=this.isQueued();if(H||V)this.warn("Transfering MediaSource with"+(V?" operations in queue":"")+(H?" updating SourceBuffer(s)":"")+" "+this.operationQueue);this.operationQueue.destroy()}var z=this.transferData;if(!this.sourceBufferCount&&z&&z.mediaSource===G)B(q,z.tracks);else this.sourceBuffers.forEach(function(A){var E=A[0];if(E)q[E]=B({},Y.tracks[E]),Y.removeBuffer(E);A[0]=A[1]=null});return{media:Q,mediaSource:G,tracks:q}},Z.initTracks=function J(){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 J(){this.bufferCodecEventsTotal=0,this.details=null},Z.onManifestParsed=function J(Y,Q){var G,q=2;if(Q.audio&&!Q.video||Q.altAudio,q=1,this.bufferCodecEventsTotal=q,this.log(q+" bufferCodec event(s) expected."),(G=this.transferData)!=null&&G.mediaSource&&this.sourceBufferCount&&q)this.bufferCreated()},Z.onMediaAttaching=function J(Y,Q){var G=this.media=Q.media,q=XY(this.appendSource);if(this.transferData=this.overrides=void 0,G&&q){var H=!!Q.mediaSource;if(H||Q.overrides)this.transferData=Q,this.overrides=Q.overrides;var V=this.mediaSource=Q.mediaSource||new q;if(this.assignMediaSource(V),H)this._objectUrl=G.src,this.attachTransferred();else{var z=this._objectUrl=self.URL.createObjectURL(V);if(this.appendSource)try{G.removeAttribute("src");var A=self.ManagedMediaSource;G.disableRemotePlayback=G.disableRemotePlayback||A&&V instanceof A,L2(G),pX(G,z),G.load()}catch(E){G.src=z}else G.src=z}G.addEventListener("emptied",this._onMediaEmptied)}},Z.assignMediaSource=function J(Y){var Q,G;if(this.log((((Q=this.transferData)==null?void 0:Q.mediaSource)===Y?"transferred":"created")+" media source: "+((G=Y.constructor)==null?void 0:G.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 J(){var Y=this,Q=this.media,G=this.transferData;if(!G||!Q)return;var q=this.tracks,H=G.tracks,V=H?Object.keys(H):null,z=V?V.length:0,A=function L(){if(Y.media&&Y.mediaSourceOpenOrEnded)Y._onMediaSourceOpen()};if(H&&V&&z){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: `+O1(q,function(L,b){return L==="initSegment"?void 0:b})+`;
16
- transfer tracks: `+O1(H,function(L,b){return L==="initSegment"?void 0:b})+"}"),!EX(H,q)){G.mediaSource=null,G.tracks=void 0;var E=Q.currentTime,I=this.details,$=Math.max(E,(I==null?void 0:I.fragments[0].start)||0);if($-E>1){this.log("attachTransferred: waiting for playback to reach new tracks start time "+E+" -> "+$);return}this.warn('attachTransferred: resetting MediaSource for incompatible tracks ("'+Object.keys(H)+'"->"'+Object.keys(q)+'") start time: '+$+" currentTime: "+E),this.onMediaDetaching(M.MEDIA_DETACHING,{}),this.onMediaAttaching(M.MEDIA_ATTACHING,G),Q.currentTime=$;return}this.transferData=void 0,V.forEach(function(L){var b=L,C=H[b];if(C){var D=C.buffer;if(D){var y=Y.fragmentTracker,S=C.id;if(y.hasFragments(S)||y.hasParts(S)){var v=k0.getBuffered(D);y.detectEvictedFragments(b,v,S,null,!0)}var p=oJ(b),g=[b,D];if(Y.sourceBuffers[p]=g,D.updating&&Y.operationQueue)Y.operationQueue.prependBlocker(b);Y.trackSourceBuffer(b,C)}}}),A(),this.bufferCreated()}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),A()},Z.onMediaDetaching=function J(Y,Q){var G=this,q=!!Q.transferMedia;this.transferData=this.overrides=void 0;var H=this.media,V=this.mediaSource,z=this._objectUrl;if(V){if(this.log("media source "+(q?"transferring":"detaching")),q)this.sourceBuffers.forEach(function($){var L=$[0];if(L)G.removeBuffer(L)}),this.resetQueue();else{if(this.mediaSourceOpenOrEnded){var A=V.readyState==="open";try{var E=V.sourceBuffers;for(var I=E.length;I--;){if(A)E[I].abort();V.removeSourceBuffer(E[I])}if(A)V.endOfStream()}catch($){this.warn("onMediaDetaching: "+$.message+" while calling endOfStream")}}if(this.sourceBufferCount)this.onBufferReset()}if(V.removeEventListener("sourceopen",this._onMediaSourceOpen),V.removeEventListener("sourceended",this._onMediaSourceEnded),V.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource)V.removeEventListener("startstreaming",this._onStartStreaming),V.removeEventListener("endstreaming",this._onEndStreaming);this.mediaSource=null,this._objectUrl=null}if(H){if(H.removeEventListener("emptied",this._onMediaEmptied),!q){if(z)self.URL.revokeObjectURL(z);if(this.mediaSrc===z){if(H.removeAttribute("src"),this.appendSource)L2(H);H.load()}else this.warn("media|source.src was changed by a third party - skip cleanup")}this.media=null}this.hls.trigger(M.MEDIA_DETACHED,Q)},Z.onBufferReset=function J(){var Y=this;this.sourceBuffers.forEach(function(Q){var G=Q[0];if(G)Y.resetBuffer(G)}),this.initTracks()},Z.resetBuffer=function J(Y){var Q,G=(Q=this.tracks[Y])==null?void 0:Q.buffer;if(this.removeBuffer(Y),G)try{var q;if((q=this.mediaSource)!=null&&q.sourceBuffers.length)this.mediaSource.removeSourceBuffer(G)}catch(H){this.warn("onBufferReset "+Y,H)}delete this.tracks[Y]},Z.removeBuffer=function J(Y){this.removeBufferListeners(Y),this.sourceBuffers[oJ(Y)]=[null,null];var Q=this.tracks[Y];if(Q)Q.buffer=void 0},Z.resetQueue=function J(){if(this.operationQueue)this.operationQueue.destroy();this.operationQueue=new TX(this.tracks)},Z.onBufferCodecs=function J(Y,Q){var G=this,q=this.tracks,H=Object.keys(Q);this.log('BUFFER_CODECS: "'+H+'" (current SB count '+this.sourceBufferCount+")");var V="audiovideo"in Q&&(q.audio||q.video)||q.audiovideo&&(("audio"in Q)||("video"in Q)),z=!V&&this.sourceBufferCount&&this.media&&H.some(function(A){return!q[A]});if(V||z){this.warn('Unsupported transition between "'+Object.keys(q)+'" and "'+H+'" SourceBuffers');return}if(H.forEach(function(A){var E,I,$,L=Q[A],b=L.id,C=L.codec,D=L.levelCodec,y=L.container,S=L.metadata,v=L.supplemental,p=q[A],g=(E=G.transferData)==null?void 0:(I=E.tracks)==null?void 0:I[A],m=g!=null&&g.buffer?g:p,r=(m==null?void 0:m.pendingCodec)||(m==null?void 0:m.codec),o=m==null?void 0:m.levelCodec;if(!p)p=q[A]={buffer:void 0,listeners:[],codec:C,supplemental:v,container:y,levelCodec:D,metadata:S,id:b};var c=GJ(r,o),d=c==null?void 0:c.replace($2,"$1"),e=GJ(C,D),H0=($=e)==null?void 0:$.replace($2,"$1");if(e&&c&&d!==H0){if(A.slice(0,5)==="audio")e=XJ(e,G.appendSource);if(G.log("switching codec "+r+" to "+e),e!==(p.pendingCodec||p.codec))p.pendingCodec=e;p.container=y,G.appendChangeType(A,y,e)}}),this.tracksReady||this.sourceBufferCount)Q.tracks=this.sourceBufferTracks;if(this.sourceBufferCount)return;if(this.mediaSourceOpenOrEnded)this.checkPendingTracks()},Z.appendChangeType=function J(Y,Q,G){var q=this,H=Q+";codecs="+G,V={label:"change-type="+H,execute:function z(){var A=q.tracks[Y];if(A){var E=A.buffer;if(E!=null&&E.changeType)q.log("changing "+Y+" sourceBuffer type to "+H),E.changeType(H),A.codec=G,A.container=Q}q.shiftAndExecuteNext(Y)},onStart:function z(){},onComplete:function z(){},onError:function z(A){q.warn("Failed to change "+Y+" SourceBuffer type",A)}};this.append(V,Y,this.isPending(this.tracks[Y]))},Z.blockAudio=function J(Y){var Q,G=this,q=Y.start,H=q+Y.duration*0.05,V=((Q=this.fragmentTracker.getAppendedFrag(q,G0.MAIN))==null?void 0:Q.gap)===!0;if(V)return;var z={label:"block-audio",execute:function A(){var E,I=G.tracks.video;if(G.lastVideoAppendEnd>H||I!=null&&I.buffer&&k0.isBuffered(I.buffer,H)||((E=G.fragmentTracker.getAppendedFrag(H,G0.MAIN))==null?void 0:E.gap)===!0)G.blockedAudioAppend=null,G.shiftAndExecuteNext("audio")},onStart:function A(){},onComplete:function A(){},onError:function A(E){G.warn("Error executing block-audio operation",E)}};this.blockedAudioAppend={op:z,frag:Y},this.append(z,"audio",!0)},Z.unblockAudio=function J(){var Y=this.blockedAudioAppend,Q=this.operationQueue;if(Y&&Q)this.blockedAudioAppend=null,Q.unblockAudio(Y.op)},Z.onBufferAppending=function J(Y,Q){var G=this,q=this.tracks,H=Q.data,V=Q.type,z=Q.parent,A=Q.frag,E=Q.part,I=Q.chunkMeta,$=I.buffering[V],L=A.sn,b=self.performance.now();$.start=b;var C=A.stats.buffering,D=E?E.stats.buffering:null;if(C.start===0)C.start=b;if(D&&D.start===0)D.start=b;var y=q.audio,S=!1;if(V==="audio"&&(y==null?void 0:y.container)==="audio/mpeg")S=!this.lastMpegAudioChunk||I.id===1||this.lastMpegAudioChunk.sn!==I.sn,this.lastMpegAudioChunk=I;var v=this.tracks.video,p=v==null?void 0:v.buffer;if(p&&L!=="initSegment"){var g=E||A,m=this.blockedAudioAppend;if(V==="audio"&&z!=="main"&&!this.blockedAudioAppend){var r=g.start,o=r+g.duration*0.05,c=p.buffered,d=this.currentOp("video");if(!c.length&&!d)this.blockAudio(g);else if(!d&&!k0.isBuffered(p,o)&&this.lastVideoAppendEnd<o)this.blockAudio(g)}else if(V==="video"){var e=g.end;if(m){var H0=m.frag.start;if(e>H0||e<this.lastVideoAppendEnd||k0.isBuffered(p,H0))this.unblockAudio()}this.lastVideoAppendEnd=e}}var Q0=(E||A).start,J0={label:"append-"+V,execute:function N0(){if($.executeStart=self.performance.now(),S){var V0=G.tracks[V];if(V0){var j0=V0.buffer;if(j0){var O0=Q0-j0.timestampOffset;if(Math.abs(O0)>=0.1)G.log("Updating audio SourceBuffer timestampOffset to "+Q0+" (delta: "+O0+") sn: "+L+")"),j0.timestampOffset=Q0}}}G.appendExecutor(H,V)},onStart:function N0(){},onComplete:function N0(){var V0=self.performance.now();if($.executeEnd=$.end=V0,C.first===0)C.first=V0;if(D&&D.first===0)D.first=V0;var j0={};if(G.sourceBuffers.forEach(function(O0){var g0=O0[0],T0=O0[1];if(g0)j0[g0]=k0.getBuffered(T0)}),G.appendErrors[V]=0,V==="audio"||V==="video")G.appendErrors.audiovideo=0;else G.appendErrors.audio=0,G.appendErrors.video=0;G.hls.trigger(M.BUFFER_APPENDED,{type:V,frag:A,part:E,chunkMeta:I,parent:A.type,timeRanges:j0})},onError:function N0(V0){var j0,O0={type:n.MEDIA_ERROR,parent:A.type,details:h.BUFFER_APPEND_ERROR,sourceBufferName:V,frag:A,part:E,chunkMeta:I,error:V0,err:V0,fatal:!1};if(V0.code===DOMException.QUOTA_EXCEEDED_ERR)O0.details=h.BUFFER_FULL_ERROR;else if(V0.code===DOMException.INVALID_STATE_ERR&&G.mediaSourceOpenOrEnded&&!((j0=G.media)!=null&&j0.error))O0.errorAction=NJ(!0);else if(V0.name===I2)if(G.sourceBufferCount===0)O0.errorAction=NJ(!0);else++G.appendErrors[V];else{var g0=++G.appendErrors[V];if(G.warn("Failed "+g0+"/"+G.hls.config.appendErrorMaxRetry+' times to append segment in "'+V+'" sourceBuffer'),g0>=G.hls.config.appendErrorMaxRetry)O0.fatal=!0}G.hls.trigger(M.ERROR,O0)}};this.append(J0,V,this.isPending(this.tracks[V]))},Z.getFlushOp=function J(Y,Q,G){var q=this;return this.log('queuing "'+Y+'" remove '+Q+"-"+G),{label:"remove",execute:function H(){q.removeExecutor(Y,Q,G)},onStart:function H(){},onComplete:function H(){q.hls.trigger(M.BUFFER_FLUSHED,{type:Y})},onError:function H(V){q.warn("Failed to remove "+Q+"-"+G+' from "'+Y+'" SourceBuffer',V)}}},Z.onBufferFlushing=function J(Y,Q){var G=this,q=Q.type,H=Q.startOffset,V=Q.endOffset;if(q)this.append(this.getFlushOp(q,H,V),q);else this.sourceBuffers.forEach(function(z){var A=z[0];if(A)G.append(G.getFlushOp(A,H,V),A)})},Z.onFragParsed=function J(Y,Q){var G=this,q=Q.frag,H=Q.part,V=[],z=H?H.elementaryStreams:q.elementaryStreams;if(z[i0.AUDIOVIDEO])V.push("audiovideo");else{if(z[i0.AUDIO])V.push("audio");if(z[i0.VIDEO])V.push("video")}var A=function E(){var I=self.performance.now();if(q.stats.buffering.end=I,H)H.stats.buffering.end=I;var $=H?H.stats:q.stats;G.hls.trigger(M.FRAG_BUFFERED,{frag:q,part:H,stats:$,id:q.type})};if(V.length===0)this.warn("Fragments must have at least one ElementaryStreamType set. type: "+q.type+" level: "+q.level+" sn: "+q.sn);this.blockBuffers(A,V)},Z.onFragChanged=function J(Y,Q){this.trimBuffers()},Z.onBufferEos=function J(Y,Q){var G=this,q;this.sourceBuffers.forEach(function(z){var A=z[0];if(A){var E=G.tracks[A];if(!Q.type||Q.type===A){if(E.ending=!0,!E.ended)E.ended=!0,G.log(A+" buffer reached EOS")}}});var H=((q=this.overrides)==null?void 0:q.endOfStream)!==!1,V=this.sourceBufferCount>0&&!this.sourceBuffers.some(function(z){var A,E=z[0];return E&&!((A=G.tracks[E])!=null&&A.ended)});if(V)if(H)this.log("Queueing EOS"),this.blockUntilOpen(function(){G.tracksEnded();var z=G.mediaSource;if(!z||z.readyState!=="open"){if(z)G.log("Could not call mediaSource.endOfStream(). mediaSource.readyState: "+z.readyState);return}G.log("Calling mediaSource.endOfStream()"),z.endOfStream(),G.hls.trigger(M.BUFFERED_TO_END,void 0)});else this.tracksEnded(),this.hls.trigger(M.BUFFERED_TO_END,void 0)},Z.tracksEnded=function J(){var Y=this;this.sourceBuffers.forEach(function(Q){var G=Q[0];if(G!==null){var q=Y.tracks[G];if(q)q.ending=!1}})},Z.onLevelUpdated=function J(Y,Q){var G=Q.details;if(!G.fragments.length)return;this.details=G,this.updateDuration()},Z.updateDuration=function J(){var Y=this,Q=this.getDurationAndRange();if(!Q)return;this.blockUntilOpen(function(){return Y.updateMediaSource(Q)})},Z.onError=function J(Y,Q){if(Q.details===h.BUFFER_APPEND_ERROR&&Q.frag){var G,q=(G=Q.errorAction)==null?void 0:G.nextAutoLevel;if(T(q)&&q!==Q.frag.level)this.resetAppendErrors()}},Z.resetAppendErrors=function J(){this.appendErrors={audio:0,video:0,audiovideo:0}},Z.trimBuffers=function J(){var Y=this.hls,Q=this.details,G=this.media;if(!G||Q===null)return;if(!this.sourceBufferCount)return;var q=Y.config,H=G.currentTime,V=Q.levelTargetDuration,z=Q.live&&q.liveBackBufferLength!==null?q.liveBackBufferLength:q.backBufferLength;if(T(z)&&z>=0){var A=Math.max(z,V),E=Math.floor(H/V)*V-A;this.flushBackBuffer(H,V,E)}if(T(q.frontBufferFlushThreshold)&&q.frontBufferFlushThreshold>0){var I=Math.max(q.maxBufferLength,q.frontBufferFlushThreshold),$=Math.max(I,V),L=Math.floor(H/V)*V+$;this.flushFrontBuffer(H,V,L)}},Z.flushBackBuffer=function J(Y,Q,G){var q=this;this.sourceBuffers.forEach(function(H){var V=H[0],z=H[1];if(z){var A=k0.getBuffered(z);if(A.length>0&&G>A.start(0)){var E;q.hls.trigger(M.BACK_BUFFER_REACHED,{bufferEnd:G});var I=q.tracks[V];if((E=q.details)!=null&&E.live)q.hls.trigger(M.LIVE_BACK_BUFFER_REACHED,{bufferEnd:G});else if(I!=null&&I.ended){q.log("Cannot flush "+V+" back buffer while SourceBuffer is in ended state");return}q.hls.trigger(M.BUFFER_FLUSHING,{startOffset:0,endOffset:G,type:V})}}})},Z.flushFrontBuffer=function J(Y,Q,G){var q=this;this.sourceBuffers.forEach(function(H){var V=H[0],z=H[1];if(z){var A=k0.getBuffered(z),E=A.length;if(E<2)return;var I=A.start(E-1),$=A.end(E-1);if(G>I||Y>=I&&Y<=$)return;q.hls.trigger(M.BUFFER_FLUSHING,{startOffset:I,endOffset:1/0,type:V})}})},Z.getDurationAndRange=function J(){var Y,Q=this.details,G=this.mediaSource;if(!Q||!this.media||(G==null?void 0:G.readyState)!=="open")return null;var q=Q.edge;if(Q.live&&this.hls.config.liveDurationInfinity){var H=Q.fragments.length;if(H&&Q.live&&!!G.setLiveSeekableRange){var V=Math.max(0,Q.fragmentStart),z=Math.max(V,q);return{duration:1/0,start:V,end:z}}return{duration:1/0}}var A=(Y=this.overrides)==null?void 0:Y.duration;if(A){if(!T(A))return null;return{duration:A}}var E=this.media.duration,I=T(G.duration)?G.duration:0;if(q>I&&q>E||!T(E))return{duration:q};return null},Z.updateMediaSource=function J(Y){var{duration:Q,start:G,end:q}=Y,H=this.mediaSource;if(!this.media||!H||H.readyState!=="open")return;if(H.duration!==Q){if(T(Q))this.log("Updating MediaSource duration to "+Q.toFixed(3));H.duration=Q}if(G!==void 0&&q!==void 0)this.log("MediaSource duration is set to "+H.duration+". Setting seekable range to "+G+"-"+q+"."),H.setLiveSeekableRange(G,q)},Z.checkPendingTracks=function J(){var Y=this.bufferCodecEventsTotal,Q=this.pendingTrackCount,G=this.tracks;if(this.log("checkPendingTracks (pending: "+Q+" codec events expected: "+Y+") "+O1(G)),this.tracksReady){var q,H=(q=this.transferData)==null?void 0:q.tracks;if(H&&Object.keys(H).length)this.attachTransferred();else this.createSourceBuffers()}},Z.bufferCreated=function J(){var Y=this;if(this.sourceBufferCount){var Q={};this.sourceBuffers.forEach(function(q){var H=q[0],V=q[1];if(H){var z=Y.tracks[H];Q[H]={buffer:V,container:z.container,codec:z.codec,supplemental:z.supplemental,levelCodec:z.levelCodec,id:z.id,metadata:z.metadata}}}),this.hls.trigger(M.BUFFER_CREATED,{tracks:Q}),this.log("SourceBuffers created. Running queue: "+this.operationQueue),this.sourceBuffers.forEach(function(q){var H=q[0];Y.executeNext(H)})}else{var G=new Error("could not create source buffer for media codec(s)");this.hls.trigger(M.ERROR,{type:n.MEDIA_ERROR,details:h.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:G,reason:G.message})}},Z.createSourceBuffers=function J(){var Y=this.tracks,Q=this.sourceBuffers,G=this.mediaSource;if(!G)throw new Error("createSourceBuffers called when mediaSource was null");for(var q in Y){var H=q,V=Y[H];if(this.isPending(V)){var z=this.getTrackCodec(V,H),A=V.container+";codecs="+z;V.codec=z,this.log("creating sourceBuffer("+A+")"+(this.currentOp(H)?" Queued":"")+" "+O1(V));try{var E=G.addSourceBuffer(A),I=oJ(H),$=[H,E];Q[I]=$,V.buffer=E}catch(b){var L;this.error("error while trying to add sourceBuffer: "+b.message),this.shiftAndExecuteNext(H),(L=this.operationQueue)==null||L.removeBlockers(),delete this.tracks[H],this.hls.trigger(M.ERROR,{type:n.MEDIA_ERROR,details:h.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:b,sourceBufferName:H,mimeType:A,parent:V.id});return}this.trackSourceBuffer(H,V)}}this.bufferCreated()},Z.getTrackCodec=function J(Y,Q){var{supplemental:G,codec:q}=Y;if(G&&(Q==="video"||Q==="audiovideo")&&fJ(G,"video"))q=RX(q,G);var H=GJ(q,Y.levelCodec);if(H){if(Q.slice(0,5)==="audio")return XJ(H,this.appendSource);return H}return""},Z.trackSourceBuffer=function J(Y,Q){var G=this,q=Q.buffer;if(!q)return;var H=this.getTrackCodec(Q,Y);if(this.tracks[Y]={buffer:q,codec:H,container:Q.container,levelCodec:Q.levelCodec,supplemental:Q.supplemental,metadata:Q.metadata,id:Q.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(V,z){var A=z.removedRanges;if(A!=null&&A.length)G.hls.trigger(M.BUFFER_FLUSHED,{type:V})})},Z.onSBUpdateStart=function J(Y){var Q=this.currentOp(Y);if(!Q)return;Q.onStart()},Z.onSBUpdateEnd=function J(Y){var Q;if(((Q=this.mediaSource)==null?void 0:Q.readyState)==="closed"){this.resetBuffer(Y);return}var G=this.currentOp(Y);if(!G)return;G.onComplete(),this.shiftAndExecuteNext(Y)},Z.onSBUpdateError=function J(Y,Q){var G,q=new Error(Y+" SourceBuffer error. MediaSource readyState: "+((G=this.mediaSource)==null?void 0:G.readyState));this.error(""+q,Q),this.hls.trigger(M.ERROR,{type:n.MEDIA_ERROR,details:h.BUFFER_APPENDING_ERROR,sourceBufferName:Y,error:q,fatal:!1});var H=this.currentOp(Y);if(H)H.onError(q)},Z.removeExecutor=function J(Y,Q,G){var q=this.media,H=this.mediaSource,V=this.tracks[Y],z=V==null?void 0:V.buffer;if(!q||!H||!z){this.warn("Attempting to remove from the "+Y+" SourceBuffer, but it does not exist"),this.shiftAndExecuteNext(Y);return}var A=T(q.duration)?q.duration:1/0,E=T(H.duration)?H.duration:1/0,I=Math.max(0,Q),$=Math.min(G,A,E);if($>I&&(!V.ending||V.ended))V.ended=!1,this.log("Removing ["+I+","+$+"] from the "+Y+" SourceBuffer"),z.remove(I,$);else this.shiftAndExecuteNext(Y)},Z.appendExecutor=function J(Y,Q){var G=this.tracks[Q],q=G==null?void 0:G.buffer;if(!q)throw new mX("Attempting to append to the "+Q+" SourceBuffer, but it does not exist");G.ending=!1,G.ended=!1,q.appendBuffer(Y)},Z.blockUntilOpen=function J(Y){if(this.isUpdating()||this.isQueued())this.blockBuffers(Y);else Y()},Z.isUpdating=function J(){return this.sourceBuffers.some(function(Y){var Q=Y[0],G=Y[1];return Q&&G.updating})},Z.isQueued=function J(){var Y=this;return this.sourceBuffers.some(function(Q){var G=Q[0];return G&&!!Y.currentOp(G)})},Z.isPending=function J(Y){return!!Y&&!Y.buffer},Z.blockBuffers=function J(Y,Q){var G=this;if(Q===void 0)Q=this.sourceBufferTypes;if(!Q.length){this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(Y);return}var q=this.operationQueue,H=Q.map(function(z){return G.appendBlocker(z)}),V=Q.length>1&&!!this.blockedAudioAppend;if(V)this.unblockAudio();Promise.all(H).then(function(z){if(q!==G.operationQueue)return;Y(),G.stepOperationQueue(Q)})},Z.stepOperationQueue=function J(Y){var Q=this;Y.forEach(function(G){var q,H=(q=Q.tracks[G])==null?void 0:q.buffer;if(!H||H.updating)return;Q.shiftAndExecuteNext(G)})},Z.append=function J(Y,Q,G){if(this.operationQueue)this.operationQueue.append(Y,Q,G)},Z.appendBlocker=function J(Y){if(this.operationQueue)return this.operationQueue.appendBlocker(Y)},Z.currentOp=function J(Y){if(this.operationQueue)return this.operationQueue.current(Y);return null},Z.executeNext=function J(Y){if(Y&&this.operationQueue)this.operationQueue.executeNext(Y)},Z.shiftAndExecuteNext=function J(Y){if(this.operationQueue)this.operationQueue.shiftAndExecuteNext(Y)},Z.addBufferListener=function J(Y,Q,G){var q=this.tracks[Y];if(!q)return;var H=q.buffer;if(!H)return;var V=G.bind(this,Y);q.listeners.push({event:Q,listener:V}),H.addEventListener(Q,V)},Z.removeBufferListeners=function J(Y){var Q=this.tracks[Y];if(!Q)return;var G=Q.buffer;if(!G)return;Q.listeners.forEach(function(q){G.removeEventListener(q.event,q.listener)}),Q.listeners.length=0},N(W,[{key:"mediaSourceOpenOrEnded",get:function J(){var Y,Q=(Y=this.mediaSource)==null?void 0:Y.readyState;return Q==="open"||Q==="ended"}},{key:"sourceBufferTracks",get:function J(){var Y=this;return Object.keys(this.tracks).reduce(function(Q,G){var q=Y.tracks[G];return Q[G]={id:q.id,container:q.container,codec:q.codec,levelCodec:q.levelCodec},Q},{})}},{key:"bufferedToEnd",get:function J(){var Y=this;return this.sourceBufferCount>0&&!this.sourceBuffers.some(function(Q){var G,q,H=Q[0];return H&&(!((G=Y.tracks[H])!=null&&G.ended)||((q=Y.tracks[H])==null?void 0:q.ending))})}},{key:"tracksReady",get:function J(){var Y=this.pendingTrackCount;return Y>0&&(Y>=this.bufferCodecEventsTotal||this.isPending(this.tracks.audiovideo))}},{key:"mediaSrc",get:function J(){var Y,Q,G=((Y=this.media)==null?void 0:(Q=Y.querySelector)==null?void 0:Q.call(Y,"source"))||this.media;return G==null?void 0:G.src}},{key:"pendingTrackCount",get:function J(){var Y=this;return Object.keys(this.tracks).reduce(function(Q,G){return Q+(Y.isPending(Y.tracks[G])?1:0)},0)}},{key:"sourceBufferCount",get:function J(){return this.sourceBuffers.reduce(function(Y,Q){var G=Q[0];return Y+(G?1:0)},0)}},{key:"sourceBufferTypes",get:function J(){return this.sourceBuffers.map(function(Y){var Q=Y[0];return Q}).filter(function(Y){return!!Y})}}])}(d0);function L2(X){var W=X.querySelectorAll("source");[].slice.call(W).forEach(function(Z){X.removeChild(Z)})}function pX(X,W){var Z=self.document.createElement("source");Z.type="video/mp4",Z.src=W,X.appendChild(Z)}function oJ(X){return X==="audio"?1:0}var fX=function(){function X(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 W=X.prototype;return W.setStreamController=function Z(J){this.streamController=J},W.destroy=function Z(){if(this.hls)this.unregisterListener();if(this.timer)this.stopCapping();this.media=null,this.clientRect=null,this.hls=this.streamController=null},W.registerListeners=function Z(){var J=this.hls;J.on(M.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),J.on(M.MEDIA_ATTACHING,this.onMediaAttaching,this),J.on(M.MANIFEST_PARSED,this.onManifestParsed,this),J.on(M.LEVELS_UPDATED,this.onLevelsUpdated,this),J.on(M.BUFFER_CODECS,this.onBufferCodecs,this),J.on(M.MEDIA_DETACHING,this.onMediaDetaching,this)},W.unregisterListener=function Z(){var J=this.hls;J.off(M.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),J.off(M.MEDIA_ATTACHING,this.onMediaAttaching,this),J.off(M.MANIFEST_PARSED,this.onManifestParsed,this),J.off(M.LEVELS_UPDATED,this.onLevelsUpdated,this),J.off(M.BUFFER_CODECS,this.onBufferCodecs,this),J.off(M.MEDIA_DETACHING,this.onMediaDetaching,this)},W.onFpsDropLevelCapping=function Z(J,Y){var Q=this.hls.levels[Y.droppedLevel];if(this.isLevelAllowed(Q))this.restrictedLevels.push({bitrate:Q.bitrate,height:Q.height,width:Q.width})},W.onMediaAttaching=function Z(J,Y){if(this.media=Y.media instanceof HTMLVideoElement?Y.media:null,this.clientRect=null,this.timer&&this.hls.levels.length)this.detectPlayerSize()},W.onManifestParsed=function Z(J,Y){var Q=this.hls;if(this.restrictedLevels=[],this.firstLevel=Y.firstLevel,Q.config.capLevelToPlayerSize&&Y.video)this.startCapping()},W.onLevelsUpdated=function Z(J,Y){if(this.timer&&T(this.autoLevelCapping))this.detectPlayerSize()},W.onBufferCodecs=function Z(J,Y){var Q=this.hls;if(Q.config.capLevelToPlayerSize&&Y.video)this.startCapping()},W.onMediaDetaching=function Z(){this.stopCapping(),this.media=null},W.detectPlayerSize=function Z(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0){this.clientRect=null;return}var J=this.hls.levels;if(J.length){var Y=this.hls,Q=this.getMaxLevel(J.length-1);if(Q!==this.autoLevelCapping)Y.logger.log("Setting autoLevelCapping to "+Q+": "+J[Q].height+"p@"+J[Q].bitrate+" for media "+this.mediaWidth+"x"+this.mediaHeight);if(Y.autoLevelCapping=Q,Y.autoLevelEnabled&&Y.autoLevelCapping>this.autoLevelCapping&&this.streamController)this.streamController.nextLevelSwitch();this.autoLevelCapping=Y.autoLevelCapping}}},W.getMaxLevel=function Z(J){var Y=this,Q=this.hls.levels;if(!Q.length)return-1;var G=Q.filter(function(q,H){return Y.isLevelAllowed(q)&&H<=J});return this.clientRect=null,X.getMaxLevelByMediaSize(G,this.mediaWidth,this.mediaHeight)},W.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()},W.stopCapping=function Z(){if(this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer)self.clearInterval(this.timer),this.timer=void 0},W.getDimensions=function Z(){if(this.clientRect)return this.clientRect;var J=this.media,Y={width:0,height:0};if(J){var Q=J.getBoundingClientRect();if(Y.width=Q.width,Y.height=Q.height,!Y.width&&!Y.height)Y.width=Q.right-Q.left||J.width||0,Y.height=Q.bottom-Q.top||J.height||0}return this.clientRect=Y,Y},W.isLevelAllowed=function Z(J){var Y=this.restrictedLevels;return!Y.some(function(Q){return J.bitrate===Q.bitrate&&J.width===Q.width&&J.height===Q.height})},X.getMaxLevelByMediaSize=function Z(J,Y,Q){if(!(J!=null&&J.length))return-1;var G=function A(E,I){if(!I)return!0;return E.width!==I.width||E.height!==I.height},q=J.length-1,H=Math.max(Y,Q);for(var V=0;V<J.length;V+=1){var z=J[V];if((z.width>=H||z.height>=H)&&G(z,J[V+1])){q=V;break}}return q},N(X,[{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 J=1;if(!this.hls.config.ignoreDevicePixelRatio)try{J=self.devicePixelRatio}catch(Y){}return Math.min(J,this.hls.config.maxDevicePixelRatio)}}])}(),cX=/^(\d+)x(\d+)$/,b2=/(.+?)=(".*?"|.*?)(?:,|$)/g,Q1=function(){function X(Z,J){if(typeof Z==="string")Z=X.parseAttrList(Z,J);B(this,Z)}var W=X.prototype;return W.decimalInteger=function Z(J){var Y=parseInt(this[J],10);if(Y>Number.MAX_SAFE_INTEGER)return 1/0;return Y},W.hexadecimalInteger=function Z(J){if(this[J]){var Y=(this[J]||"0x").slice(2);Y=(Y.length&1?"0":"")+Y;var Q=new Uint8Array(Y.length/2);for(var G=0;G<Y.length/2;G++)Q[G]=parseInt(Y.slice(G*2,G*2+2),16);return Q}return null},W.hexadecimalIntegerAsNumber=function Z(J){var Y=parseInt(this[J],16);if(Y>Number.MAX_SAFE_INTEGER)return 1/0;return Y},W.decimalFloatingPoint=function Z(J){return parseFloat(this[J])},W.optionalFloat=function Z(J,Y){var Q=this[J];return Q?parseFloat(Q):Y},W.enumeratedString=function Z(J){return this[J]},W.enumeratedStringList=function Z(J,Y){var Q=this[J];return(Q?Q.split(/[ ,]+/):[]).reduce(function(G,q){return G[q.toLowerCase()]=!0,G},Y)},W.bool=function Z(J){return this[J]==="YES"},W.decimalResolution=function Z(J){var Y=cX.exec(this[J]);if(Y===null)return;return{width:parseInt(Y[1],10),height:parseInt(Y[2],10)}},X.parseAttrList=function Z(J,Y){var Q,G={},q='"';b2.lastIndex=0;while((Q=b2.exec(J))!==null){var H=Q[1].trim(),V=Q[2],z=V.indexOf(q)===0&&V.lastIndexOf(q)===V.length-1,A=!1;if(z)V=V.slice(1,-1);else switch(H){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":A=!0}if(Y&&(z||A));else if(!A&&!z)switch(H){case"CLOSED-CAPTIONS":if(V==="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":v0.warn(J+": attribute "+H+" is missing quotes")}G[H]=V}return G},N(X,[{key:"clientAttrs",get:function Z(){return Object.keys(this).filter(function(J){return J.substring(0,2)==="X-"})}}])}(),lX="com.apple.hls.interstitial";function dX(X){return X!=="ID"&&X!=="CLASS"&&X!=="CUE"&&X!=="START-DATE"&&X!=="DURATION"&&X!=="END-DATE"&&X!=="END-ON-NEXT"}function nX(X){return X==="SCTE35-OUT"||X==="SCTE35-IN"||X==="SCTE35-CMD"}var M2=function(){function X(W,Z,J){var Y;if(J===void 0)J=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:J,Z){var Q=Z.attr;for(var G in Q)if(Object.prototype.hasOwnProperty.call(W,G)&&W[G]!==Q[G]){v0.warn('DATERANGE tag attribute: "'+G+'" does not match for tags with ID: "'+W.ID+'"'),this._badValueForSameId=G;break}W=B(new Q1({}),Q,W)}if(this.attr=W,Z)this._startDate=Z._startDate,this._cue=Z._cue,this._endDate=Z._endDate,this._dateAtEnd=Z._dateAtEnd;else this._startDate=new Date(W["START-DATE"]);if("END-DATE"in this.attr){var q=(Z==null?void 0:Z.endDate)||new Date(this.attr["END-DATE"]);if(T(q.getTime()))this._endDate=q}}return N(X,[{key:"id",get:function W(){return this.attr.ID}},{key:"class",get:function W(){return this.attr.CLASS}},{key:"cue",get:function W(){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 W(){var Z=this.tagAnchor;if(Z===null||Z.programDateTime===null)return v0.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 W(){return this._startDate}},{key:"endDate",get:function W(){var Z=this._endDate||this._dateAtEnd;if(Z)return Z;var J=this.duration;if(J!==null)return this._dateAtEnd=new Date(this._startDate.getTime()+J*1000);return null}},{key:"duration",get:function W(){if("DURATION"in this.attr){var Z=this.attr.decimalFloatingPoint("DURATION");if(T(Z))return Z}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1000;return null}},{key:"plannedDuration",get:function W(){if("PLANNED-DURATION"in this.attr)return this.attr.decimalFloatingPoint("PLANNED-DURATION");return null}},{key:"endOnNext",get:function W(){return this.attr.bool("END-ON-NEXT")}},{key:"isInterstitial",get:function W(){return this.class===lX}},{key:"isValid",get:function W(){return!!this.id&&!this._badValueForSameId&&T(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))}}])}(),oX=10,iX=function(){function X(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 W=X.prototype;return W.reloaded=function Z(J){if(!J){this.advanced=!0,this.updated=!0;return}var Y=this.lastPartSn-J.lastPartSn,Q=this.lastPartIndex-J.lastPartIndex;if(this.updated=this.endSN!==J.endSN||!!Q||!!Y||!this.live,this.advanced=this.endSN>J.endSN||Y>0||Y===0&&Q>0,this.updated||this.advanced)this.misses=Math.floor(J.misses*0.6);else this.misses=J.misses+1},N(X,[{key:"hasProgramDateTime",get:function Z(){if(this.fragments.length)return T(this.fragments[this.fragments.length-1].programDateTime);return!1}},{key:"levelTargetDuration",get:function Z(){return this.averagetargetduration||this.targetduration||oX}},{key:"drift",get:function Z(){var J=this.driftEndTime-this.driftStartTime;if(J>0){var Y=this.driftEnd-this.driftStart;return Y*1000/J}return 1}},{key:"edge",get:function Z(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function Z(){var J;if((J=this.partList)!=null&&J.length)return this.partList[this.partList.length-1].end;return this.fragmentEnd}},{key:"fragmentEnd",get:function Z(){var J;if((J=this.fragments)!=null&&J.length)return this.fragments[this.fragments.length-1].end;return 0}},{key:"fragmentStart",get:function Z(){var J;if((J=this.fragments)!=null&&J.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 J;if((J=this.partList)!=null&&J.length)return this.partList[this.partList.length-1].index;return-1}},{key:"maxPartIndex",get:function Z(){var J=this.partList;if(J){var Y=this.lastPartIndex;if(Y!==-1){for(var Q=J.length;Q--;)if(J[Q].index>Y)return J[Q].index;return Y}}return 0}},{key:"lastPartSn",get:function Z(){var J;if((J=this.partList)!=null&&J.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 J=this.partEnd-this.fragmentStart;return this.age>Math.max(J,this.totalduration)+this.levelTargetDuration}return!1}}])}(),GY={cbc:0,ctr:1};function hY(X){return X==="AES-128"||X==="AES-256"||X==="AES-256-CTR"}function C2(X){switch(X){case"AES-128":case"AES-256":return GY.cbc;case"AES-256-CTR":return GY.ctr;default:throw new Error("invalid full segment method "+X)}}var sX=function(){function X(Z,J,Y,Q,G){if(Q===void 0)Q=[1];if(G===void 0)G=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=J,this.keyFormat=Y,this.keyFormatVersions=Q,this.iv=G,this.encrypted=Z?Z!=="NONE":!1,this.isCommonEncryption=this.encrypted&&!hY(Z)}X.clearKeyUriToKeyIdMap=function Z(){};var W=X.prototype;return W.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},W.getDecryptData=function Z(J){if(!this.encrypted||!this.uri)return null;if(hY(this.method)&&this.uri&&!this.iv){if(typeof J!=="number")v0.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),J=0;var Y=rX(J),Q=new X(this.method,this.uri,"identity",this.keyFormatVersions,Y);return Q}return this},X}();function rX(X){var W=new Uint8Array(16);for(var Z=12;Z<16;Z++)W[Z]=X>>8*(15-Z)&255;return W}var D2=/#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,S2=/#EXT-X-MEDIA:(.*)/g,aX=/^#EXT(?:INF|-X-TARGETDURATION):/m,iJ=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),tX=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("|")),kY=function(){function X(){}return X.findGroup=function W(Z,J){for(var Y=0;Y<Z.length;Y++){var Q=Z[Y];if(Q.id===J)return Q}},X.resolve=function W(Z,J){return t0.buildAbsoluteURL(J,Z,{alwaysNormalize:!0})},X.isMediaPlaylist=function W(Z){return aX.test(Z)},X.parseMasterPlaylist=function W(Z,J){var Y=!1,Q={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:Y},G=[];D2.lastIndex=0;var q;while((q=D2.exec(Z))!=null)if(q[1]){var H,V=new Q1(q[1],Q),z=q[2],A={attrs:V,bitrate:V.decimalInteger("BANDWIDTH")||V.decimalInteger("AVERAGE-BANDWIDTH"),name:V.NAME,url:X.resolve(z,J)},E=V.decimalResolution("RESOLUTION");if(E)A.width=E.width,A.height=E.height;x2(V.CODECS,A);var I=V["SUPPLEMENTAL-CODECS"];if(I)A.supplemental={},x2(I,A.supplemental);if(!((H=A.unknownCodecs)!=null&&H.length))G.push(A);Q.levels.push(A)}else if(q[3]){var $=q[3],L=q[4];switch($){case"SESSION-DATA":{var b=new Q1(L,Q),C=b["DATA-ID"];if(C){if(Q.sessionData===null)Q.sessionData={};Q.sessionData[C]=b}break}case"SESSION-KEY":{var D=y2(L,J,Q);if(D.encrypted&&D.isSupported()){if(Q.sessionKeys===null)Q.sessionKeys=[];Q.sessionKeys.push(D)}else v0.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+L+'"');break}case"DEFINE":break;case"CONTENT-STEERING":{var y=new Q1(L,Q);Q.contentSteering={uri:X.resolve(y["SERVER-URI"],J),pathwayId:y["PATHWAY-ID"]||"."};break}case"START":{Q.startTimeOffset=T2(L);break}}}var S=G.length>0&&G.length<Q.levels.length;if(Q.levels=S?G:Q.levels,Q.levels.length===0)Q.playlistParsingError=new Error("no levels found in manifest");return Q},X.parseMasterPlaylistMedia=function W(Z,J,Y){var Q,G={},q=Y.levels,H={AUDIO:q.map(function(v){return{id:v.attrs.AUDIO,audioCodec:v.audioCodec}}),SUBTITLES:q.map(function(v){return{id:v.attrs.SUBTITLES,textCodec:v.textCodec}}),"CLOSED-CAPTIONS":[]},V=0;S2.lastIndex=0;while((Q=S2.exec(Z))!==null){var z=new Q1(Q[1],Y),A=z.TYPE;if(A){var E=H[A],I=G[A]||[];G[A]=I;var $=z.LANGUAGE,L=z["ASSOC-LANGUAGE"],b=z.CHANNELS,C=z.CHARACTERISTICS,D=z["INSTREAM-ID"],y={attrs:z,bitrate:0,id:V++,groupId:z["GROUP-ID"]||"",name:z.NAME||$||"",type:A,default:z.bool("DEFAULT"),autoselect:z.bool("AUTOSELECT"),forced:z.bool("FORCED"),lang:$,url:z.URI?X.resolve(z.URI,J):""};if(L)y.assocLang=L;if(b)y.channels=b;if(C)y.characteristics=C;if(D)y.instreamId=D;if(E!=null&&E.length){var S=X.findGroup(E,y.groupId)||E[0];v2(y,S,"audioCodec"),v2(y,S,"textCodec")}I.push(y)}}return G},X.parseLevelPlaylist=function W(Z,J,Y,Q,G,q){var H,V={url:J},z=new iX(J),A=z.fragments,E=[],I=null,$=0,L=0,b=0,C=0,D=0,y=null,S=new uJ(Q,V),v,p,g,m=-1,r=!1,o=null,c;if(iJ.lastIndex=0,z.m3u8=Z,z.hasVariableRefs=!1,((H=iJ.exec(Z))==null?void 0:H[0])!=="#EXTM3U")return z.playlistParsingError=new Error("Missing format identifier #EXTM3U"),z;while((v=iJ.exec(Z))!==null){if(r){if(r=!1,S=new uJ(Q,V),S.playlistOffset=b,S.start=b,S.sn=$,S.cc=C,D)S.bitrate=D;if(S.level=Y,I){if(S.initSegment=I,I.rawProgramDateTime)S.rawProgramDateTime=I.rawProgramDateTime,I.rawProgramDateTime=null;if(o)S.setByteRange(o),o=null}}var d=v[1];if(d){S.duration=parseFloat(d);var e=(" "+v[2]).slice(1);S.title=e||null,S.tagList.push(e?["INF",d,e]:["INF",d])}else if(v[3]){if(T(S.duration)){if(S.playlistOffset=b,S.start=b,g)k2(S,g,z);S.sn=$,S.level=Y,S.cc=C,A.push(S);var H0=(" "+v[3]).slice(1);S.relurl=H0,sJ(S,y,E),y=S,b+=S.duration,$++,L=0,r=!0}}else{if(v=v[0].match(tX),!v){v0.warn("No matches on slow regex match for level playlist!");continue}for(p=1;p<v.length;p++)if(v[p]!==void 0)break;var Q0=(" "+v[p]).slice(1),J0=(" "+v[p+1]).slice(1),N0=v[p+2]?(" "+v[p+2]).slice(1):null;switch(Q0){case"BYTERANGE":if(y)S.setByteRange(J0,y);else S.setByteRange(J0);break;case"PROGRAM-DATE-TIME":if(S.rawProgramDateTime=J0,S.tagList.push(["PROGRAM-DATE-TIME",J0]),m===-1)m=A.length;break;case"PLAYLIST-TYPE":if(z.type)a1(z,Q0,v);z.type=J0.toUpperCase();break;case"MEDIA-SEQUENCE":if(z.startSN!==0)a1(z,Q0,v);else if(A.length>0)g2(z,Q0,v);$=z.startSN=parseInt(J0);break;case"SKIP":{if(z.skippedSegments)a1(z,Q0,v);var V0=new Q1(J0,z),j0=V0.decimalInteger("SKIPPED-SEGMENTS");if(T(j0)){z.skippedSegments+=j0;for(var O0=j0;O0--;)A.push(null);$+=j0}var g0=V0.enumeratedString("RECENTLY-REMOVED-DATERANGES");if(g0)z.recentlyRemovedDateranges=(z.recentlyRemovedDateranges||[]).concat(g0.split("\t"));break}case"TARGETDURATION":if(z.targetduration!==0)a1(z,Q0,v);z.targetduration=Math.max(parseInt(J0),1);break;case"VERSION":if(z.version!==null)a1(z,Q0,v);z.version=parseInt(J0);break;case"INDEPENDENT-SEGMENTS":break;case"ENDLIST":if(!z.live)a1(z,Q0,v);z.live=!1;break;case"#":if(J0||N0)S.tagList.push(N0?[J0,N0]:[J0]);break;case"DISCONTINUITY":C++,S.tagList.push(["DIS"]);break;case"GAP":S.gap=!0,S.tagList.push([Q0]);break;case"BITRATE":if(S.tagList.push([Q0,J0]),D=parseInt(J0)*1000,T(D))S.bitrate=D;else D=0;break;case"DATERANGE":{var T0=new Q1(J0,z),m0=new M2(T0,z.dateRanges[T0.ID],z.dateRangeTagCount);if(z.dateRangeTagCount++,m0.isValid||z.skippedSegments)z.dateRanges[m0.id]=m0;else v0.warn('Ignoring invalid DATERANGE tag: "'+J0+'"');S.tagList.push(["EXT-X-DATERANGE",J0]);break}case"DEFINE":break;case"DISCONTINUITY-SEQUENCE":if(z.startCC!==0)a1(z,Q0,v);else if(A.length>0)g2(z,Q0,v);z.startCC=C=parseInt(J0);break;case"KEY":{var D0=y2(J0,J,z);if(D0.isSupported()){if(D0.method==="NONE"){g=void 0;break}if(!g)g={};if(g[D0.keyFormat])g=B({},g);g[D0.keyFormat]=D0}else v0.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+J0+'"');break}case"START":z.startTimeOffset=T2(J0);break;case"MAP":{var Y1=new Q1(J0,z);if(S.duration){var _0=new uJ(Q,V);if(h2(_0,Y1,Y,g),I=_0,S.initSegment=I,I.rawProgramDateTime&&!S.rawProgramDateTime)S.rawProgramDateTime=I.rawProgramDateTime}else{var a0=S.byteRangeEndOffset;if(a0){var w1=S.byteRangeStartOffset;o=a0-w1+"@"+w1}else o=null;h2(S,Y1,Y,g),I=S,r=!0}I.cc=C;break}case"SERVER-CONTROL":{if(c)a1(z,Q0,v);c=new Q1(J0),z.canBlockReload=c.bool("CAN-BLOCK-RELOAD"),z.canSkipUntil=c.optionalFloat("CAN-SKIP-UNTIL",0),z.canSkipDateRanges=z.canSkipUntil>0&&c.bool("CAN-SKIP-DATERANGES"),z.partHoldBack=c.optionalFloat("PART-HOLD-BACK",0),z.holdBack=c.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{if(z.partTarget)a1(z,Q0,v);var q1=new Q1(J0);z.partTarget=q1.decimalFloatingPoint("PART-TARGET");break}case"PART":{var p0=z.partList;if(!p0)p0=z.partList=[];var R1=L>0?p0[p0.length-1]:void 0,Z1=L++,s0=new Q1(J0,z),$1=new QX(s0,S,V,Z1,R1);p0.push($1),S.duration+=$1.duration;break}case"PRELOAD-HINT":{var V1=new Q1(J0,z);z.preloadHint=V1;break}case"RENDITION-REPORT":{var M1=new Q1(J0,z);z.renditionReports=z.renditionReports||[],z.renditionReports.push(M1);break}default:v0.warn("line parsed but not handled: "+v);break}}}if(y&&!y.relurl){if(A.pop(),b-=y.duration,z.partList)z.fragmentHint=y}else if(z.partList){if(sJ(S,y,E),S.cc=C,z.fragmentHint=S,g)k2(S,g,z)}if(!z.targetduration)z.playlistParsingError=new Error("#EXT-X-TARGETDURATION is required");var n0=A.length,z1=A[0],X1=A[n0-1];if(b+=z.skippedSegments*z.targetduration,b>0&&n0&&X1){z.averagetargetduration=b/n0;var I1=X1.sn;if(z.endSN=I1!=="initSegment"?I1:0,!z.live)X1.endList=!0;if(z1&&z.startCC===void 0)z.startCC=z1.cc;if(m>0){if(Y7(A,m),z1)E.unshift(z1)}}else z.endSN=0,z.startCC=0;if(z.fragmentHint)b+=z.fragmentHint.duration;if(z.totalduration=b,E.length&&z.dateRangeTagCount&&z1)P2(E,z);return z.endCC=C,z},X}();function P2(X,W){var Z=X.length,J=X[Z-1],Y=W.live?1/0:W.totalduration,Q=Object.keys(W.dateRanges);for(var G=Q.length;G--;){var q=W.dateRanges[Q[G]],H=q.startDate.getTime();q.tagAnchor=J.ref;for(var V=Z;V--;){var z=eX(W,H,X,V,Y);if(z!==-1){q.tagAnchor=W.fragments[z].ref;break}}}}function eX(X,W,Z,J,Y){var Q=Z[J];if(Q){var G=Q.programDateTime;if(W>=G||J===0){var q,H=(((q=Z[J+1])==null?void 0:q.start)||Y)-Q.start;if(W<=G+H*1000){var V=Z[J].sn-X.startSN,z=X.fragments;if(z.length>Z.length){var A=Z[J+1]||z[z.length-1],E=A.sn-X.startSN;for(var I=E;I>V;I--){var $=z[I].programDateTime;if(W>=$&&W<$+z[I].duration*1000)return I}}return V}}}return-1}function y2(X,W,Z){var J,Y,Q=new Q1(X,Z),G=(J=Q.METHOD)!=null?J:"",q=Q.URI,H=Q.hexadecimalInteger("IV"),V=Q.KEYFORMATVERSIONS,z=(Y=Q.KEYFORMAT)!=null?Y:"identity";if(q&&Q.IV&&!H)v0.error("Invalid IV: "+Q.IV);var A=q?kY.resolve(q,W):"",E=(V?V:"1").split("/").map(Number).filter(Number.isFinite);return new sX(G,A,z,E,H)}function T2(X){var W=new Q1(X),Z=W.decimalFloatingPoint("TIME-OFFSET");if(T(Z))return Z;return null}function x2(X,W){var Z=(X||"").split(/[ ,]+/).filter(function(J){return J});["video","audio","text"].forEach(function(J){var Y=Z.filter(function(Q){return W2(Q,J)});if(Y.length)W[J+"Codec"]=Y.map(function(Q){return Q.split("/")[0]}).join(","),Z=Z.filter(function(Q){return Y.indexOf(Q)===-1})}),W.unknownCodecs=Z}function v2(X,W,Z){var J=W[Z];if(J)X[Z]=J}function Y7(X,W){var Z=X[W];for(var J=W;J--;){var Y=X[J];if(!Y)return;Y.programDateTime=Z.programDateTime-Y.duration*1000,Z=Y}}function sJ(X,W,Z){if(X.rawProgramDateTime)Z.push(X);else if(W!=null&&W.programDateTime)X.programDateTime=W.endProgramDateTime}function h2(X,W,Z,J){if(X.relurl=W.URI,W.BYTERANGE)X.setByteRange(W.BYTERANGE);if(X.level=Z,X.sn="initSegment",J)X.levelkeys=J;X.initSegment=null}function k2(X,W,Z){X.levelkeys=W;var J=Z.encryptedFragments;if((!J.length||J[J.length-1].levelkeys!==W)&&Object.keys(W).some(function(Y){return W[Y].isCommonEncryption}))J.push(X)}function a1(X,W,Z){X.playlistParsingError=new Error("#EXT-X-"+W+" must not appear more than once ("+Z[0]+")")}function g2(X,W,Z){X.playlistParsingError=new Error("#EXT-X-"+W+" must appear before the first Media Segment ("+Z[0]+")")}function rJ(X,W){var Z=W.startPTS;if(T(Z)){var J=0,Y;if(W.sn>X.sn)J=Z-X.start,Y=X;else J=X.start-Z,Y=W;if(Y.duration!==J)Y.setDuration(J)}else if(W.sn>X.sn){var Q=X.cc===W.cc;if(Q&&X.minEndPTS)W.setStart(X.start+(X.minEndPTS-X.start));else W.setStart(X.start+X.duration)}else W.setStart(Math.max(X.start-W.duration,0))}function u2(X,W,Z,J,Y,Q){var G=J-Z;if(G<=0)v0.warn("Fragment should have a positive duration",W),J=Z+W.duration,Q=Y+W.duration;var q=Z,H=J,V=W.startPTS,z=W.endPTS;if(T(V)){var A=Math.abs(V-Z);if(!T(W.deltaPTS))W.deltaPTS=A;else W.deltaPTS=Math.max(A,W.deltaPTS);q=Math.max(Z,V),Z=Math.min(Z,V),Y=Math.min(Y,W.startDTS),H=Math.min(J,z),J=Math.max(J,z),Q=Math.max(Q,W.endDTS)}var E=Z-W.start;if(W.start!==0)W.setStart(Z);W.setDuration(J-W.start),W.startPTS=Z,W.maxStartPTS=q,W.startDTS=Y,W.endPTS=J,W.minEndPTS=H,W.endDTS=Q;var I=W.sn;if(!X||I<X.startSN||I>X.endSN)return 0;var $,L=I-X.startSN,b=X.fragments;b[L]=W;for($=L;$>0;$--)rJ(b[$],b[$-1]);for($=L;$<b.length-1;$++)rJ(b[$],b[$+1]);if(X.fragmentHint)rJ(b[b.length-1],X.fragmentHint);return X.PTSKnown=X.alignedSliding=!0,E}function J7(X,W){if(X===W)return;var Z=null,J=X.fragments;for(var Y=J.length-1;Y>=0;Y--){var Q=J[Y].initSegment;if(Q){Z=Q;break}}if(X.fragmentHint)delete X.fragmentHint.endPTS;var G;X7(X,W,function($,L,b,C){if(W.skippedSegments){if(L.cc!==$.cc){var D=$.cc-L.cc;for(var y=b;y<C.length;y++)C[y].cc+=D}}if(T($.startPTS)&&T($.endPTS)){if(L.setStart(L.startPTS=$.startPTS),L.startDTS=$.startDTS,L.maxStartPTS=$.maxStartPTS,L.endPTS=$.endPTS,L.endDTS=$.endDTS,L.minEndPTS=$.minEndPTS,L.setDuration($.endPTS-$.startPTS),L.duration)G=L;W.PTSKnown=W.alignedSliding=!0}if($.hasStreams)L.elementaryStreams=$.elementaryStreams;if(L.loader=$.loader,$.hasStats)L.stats=$.stats;if($.initSegment)L.initSegment=$.initSegment,Z=$.initSegment});var q=W.fragments,H=W.fragmentHint?q.concat(W.fragmentHint):q;if(Z)H.forEach(function($){var L;if($&&(!$.initSegment||$.initSegment.relurl===((L=Z)==null?void 0:L.relurl)))$.initSegment=Z});if(W.skippedSegments)if(W.deltaUpdateFailed=q.some(function($){return!$}),W.deltaUpdateFailed){v0.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var V=W.skippedSegments;V--;)q.shift();W.startSN=q[0].sn}else{if(W.endCC=q[q.length-1].cc,W.canSkipDateRanges)W.dateRanges=Q7(X.dateRanges,W);var z=X.fragments.filter(function($){return $.rawProgramDateTime});if(X.hasProgramDateTime&&!W.hasProgramDateTime){for(var A=1;A<H.length;A++)if(H[A].programDateTime===null)sJ(H[A],H[A-1],z)}P2(z,W)}if(Z7(X.partList,W.partList,function($,L){L.elementaryStreams=$.elementaryStreams,L.stats=$.stats}),G)u2(W,G,G.startPTS,G.endPTS,G.startDTS,G.endDTS);else _2(X,W);if(q.length)W.totalduration=W.edge-q[0].start;W.driftStartTime=X.driftStartTime,W.driftStart=X.driftStart;var E=W.advancedDateTime;if(W.advanced&&E){var I=W.edge;if(!W.driftStart)W.driftStartTime=E,W.driftStart=I;W.driftEndTime=E,W.driftEnd=I}else W.driftEndTime=X.driftEndTime,W.driftEnd=X.driftEnd,W.advancedDateTime=X.advancedDateTime;if(W.requestScheduled===-1)W.requestScheduled=X.requestScheduled}function Q7(X,W){var{dateRanges:Z,recentlyRemovedDateranges:J}=W,Y=B({},X);if(J)J.forEach(function(q){delete Y[q]});var Q=Object.keys(Y),G=Q.length;if(G)Object.keys(Z).forEach(function(q){var H=Y[q],V=new M2(Z[q].attr,H);if(V.isValid){if(Y[q]=V,!H)V.tagOrder+=G}else v0.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+O1(Z[q].attr)+'"')});return Y}function Z7(X,W,Z){if(X&&W){var J=0;for(var Y=0,Q=X.length;Y<=Q;Y++){var G=X[Y],q=W[Y+J];if(G&&q&&G.index===q.index&&G.fragment.sn===q.fragment.sn)Z(G,q);else J--}}}function X7(X,W,Z){var J=W.skippedSegments,Y=Math.max(X.startSN,W.startSN)-W.startSN,Q=(X.fragmentHint?1:0)+(J?W.endSN:Math.min(X.endSN,W.endSN))-W.startSN,G=W.startSN-X.startSN,q=W.fragmentHint?W.fragments.concat(W.fragmentHint):W.fragments,H=X.fragmentHint?X.fragments.concat(X.fragmentHint):X.fragments;for(var V=Y;V<=Q;V++){var z=H[G+V],A=q[V];if(J&&!A&&z)A=W.fragments[V]=z;if(z&&A){if(Z(z,A,V,q),z.url&&z.url!==A.url){W.playlistParsingError=m2("media sequence mismatch "+A.sn+":",X,W,z,A);return}else if(z.cc!==A.cc){W.playlistParsingError=m2("discontinuity sequence mismatch ("+z.cc+"!="+A.cc+")",X,W,z,A);return}}}}function m2(X,W,Z,J,Y){return new Error(X+" "+Y.url+`
17
- Playlist starting @`+W.startSN+`
18
- `+W.m3u8+`
15
+ `+this.list("audiovideo")+"}"},s.list=function(t){var e,r;return(e=this.queues)!=null&&e[t]||(r=this.tracks)!=null&&r[t]?t+": ("+this.listSbInfo(t)+") "+this.listOps(t):""},s.listSbInfo=function(t){var e,r=(e=this.tracks)==null?void 0:e[t],a=r?.buffer;return a?"SourceBuffer"+(a.updating?" updating":"")+(r.ended?" ended":"")+(r.ending?" ending":""):"none"},s.listOps=function(t){var e;return((e=this.queues)==null?void 0:e[t].map(function(r){return r.label}).join(", "))||""},n}(),ga={search:function(s,i){for(var t=0,e=s.length-1,r=null,a=null;t<=e;){r=(t+e)/2|0,a=s[r];var u=i(a);if(u>0)t=r+1;else if(u<0)e=r-1;else return a}return null}};function Iu(n,s,i){if(s===null||!Array.isArray(n)||!n.length||!w(s))return null;var t=n[0].programDateTime;if(s<(t||0))return null;var e=n[n.length-1].endProgramDateTime;if(s>=(e||0))return null;i=i||0;for(var r=0;r<n.length;++r){var a=n[r];if(Pu(s,i,a))return a}return null}function Wi(n,s,i,t,e){i===void 0&&(i=0),t===void 0&&(t=0),e===void 0&&(e=.005);var r=null;if(n){r=s[1+n.sn-s[0].sn]||null;var a=n.endDTS-i;a>0&&a<15e-7&&(i+=15e-7),r&&n.level!==r.level&&r.end<=n.end&&(r=s[2+n.sn-s[0].sn]||null)}else i===0&&s[0].start===0&&(r=s[0]);if(r&&((!n||n.level===r.level)&&ma(i,t,r)===0||wu(r,n,Math.min(e,t))))return r;var u=ga.search(s,ma.bind(null,i,t));return u&&(u!==n||!r)?u:r}function wu(n,s,i){if(s&&s.start===0&&s.level<n.level&&(s.endPTS||0)>0){var t=s.tagList.reduce(function(e,r){return r[0]==="INF"&&(e+=parseFloat(r[1])),e},i);return n.start<=t}return!1}function ma(n,s,i){if(n===void 0&&(n=0),s===void 0&&(s=0),i.start<=n&&i.start+i.duration>n)return 0;var t=Math.min(s,i.duration+(i.deltaPTS?i.deltaPTS:0));return i.start+i.duration-t<=n?1:i.start-t>n&&i.start?-1:0}function Pu(n,s,i){var t=Math.min(s,i.duration+(i.deltaPTS?i.deltaPTS:0))*1e3,e=i.endProgramDateTime||0;return e-t>n}function Ou(n,s){return ga.search(n,function(i){return i.cc<s?1:i.cc>s?-1:0})}function oi(n){switch(n.details){case M.FRAG_LOAD_TIMEOUT:case M.KEY_LOAD_TIMEOUT:case M.LEVEL_LOAD_TIMEOUT:case M.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function ya(n,s){var i=oi(s);return n.default[(i?"timeout":"error")+"Retry"]}function ji(n,s){var i=n.backoff==="linear"?1:Math.pow(2,s);return Math.min(i*n.retryDelayMs,n.maxRetryDelayMs)}function Ea(n){return H(H({},n),{errorRetry:null,timeoutRetry:null})}function ui(n,s,i,t){if(!n)return!1;var e=t?.code,r=s<n.maxNumRetry&&(Mu(e)||!!i);return n.shouldRetry?n.shouldRetry(n,s,i,t,r):r}function Mu(n){return n===0&&navigator.onLine===!1||!!n&&(n<400||n>499)}var ht={DoNothing:0,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,RetryRequest:5},Mt={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2},Fu=function(n){function s(t){var e;return e=n.call(this,"error-controller",t.logger)||this,e.hls=void 0,e.playlistError=0,e.penalizedRenditions={},e.hls=t,e.registerListeners(),e}S(s,n);var i=s.prototype;return i.registerListeners=function(){var e=this.hls;e.on(x.ERROR,this.onError,this),e.on(x.MANIFEST_LOADING,this.onManifestLoading,this),e.on(x.LEVEL_UPDATED,this.onLevelUpdated,this)},i.unregisterListeners=function(){var e=this.hls;e&&(e.off(x.ERROR,this.onError,this),e.off(x.ERROR,this.onErrorOut,this),e.off(x.MANIFEST_LOADING,this.onManifestLoading,this),e.off(x.LEVEL_UPDATED,this.onLevelUpdated,this))},i.destroy=function(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}},i.startLoad=function(e){},i.stopLoad=function(){this.playlistError=0},i.getVariantLevelIndex=function(e){return e?.type===ae.MAIN?e.level:this.hls.loadLevel},i.onManifestLoading=function(){this.playlistError=0,this.penalizedRenditions={}},i.onLevelUpdated=function(){this.playlistError=0},i.onError=function(e,r){var a;if(!r.fatal){var u=this.hls,l=r.context;switch(r.details){case M.FRAG_LOAD_ERROR:case M.FRAG_LOAD_TIMEOUT:case M.KEY_LOAD_ERROR:case M.KEY_LOAD_TIMEOUT:r.errorAction=this.getFragRetryOrSwitchAction(r);return;case M.FRAG_PARSING_ERROR:if((a=r.frag)!=null&&a.gap){r.errorAction=li();return}case M.FRAG_GAP:case M.FRAG_DECRYPT_ERROR:{r.errorAction=this.getFragRetryOrSwitchAction(r),r.errorAction.action=ht.SendAlternateToPenaltyBox;return}case M.LEVEL_EMPTY_ERROR:case M.LEVEL_PARSING_ERROR:{var d,c,p=r.parent===ae.MAIN?r.level:u.loadLevel;r.details===M.LEVEL_EMPTY_ERROR&&((d=r.context)!=null&&(c=d.levelDetails)!=null&&c.live)?r.errorAction=this.getPlaylistRetryOrSwitchAction(r,p):(r.levelRetry=!1,r.errorAction=this.getLevelSwitchAction(r,p))}return;case M.LEVEL_LOAD_ERROR:case M.LEVEL_LOAD_TIMEOUT:typeof l?.level=="number"&&(r.errorAction=this.getPlaylistRetryOrSwitchAction(r,l.level));return;case M.AUDIO_TRACK_LOAD_ERROR:case M.AUDIO_TRACK_LOAD_TIMEOUT:case M.SUBTITLE_LOAD_ERROR:case M.SUBTITLE_TRACK_LOAD_TIMEOUT:if(l){var y=u.loadLevelObj;if(y&&(l.type===ie.AUDIO_TRACK&&y.hasAudioGroup(l.groupId)||l.type===ie.SUBTITLE_TRACK&&y.hasSubtitleGroup(l.groupId))){r.errorAction=this.getPlaylistRetryOrSwitchAction(r,u.loadLevel),r.errorAction.action=ht.SendAlternateToPenaltyBox,r.errorAction.flags=Mt.MoveAllAlternatesMatchingHost;return}}return;case M.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{var A=u.loadLevelObj,T=A?.attrs["HDCP-LEVEL"];T?r.errorAction={action:ht.SendAlternateToPenaltyBox,flags:Mt.MoveAllAlternatesMatchingHDCP,hdcpLevel:T}:this.keySystemError(r)}return;case M.BUFFER_ADD_CODEC_ERROR:case M.REMUX_ALLOC_ERROR:case M.BUFFER_APPEND_ERROR:if(!r.errorAction){var b;r.errorAction=this.getLevelSwitchAction(r,(b=r.level)!=null?b:u.loadLevel)}return;case M.INTERNAL_EXCEPTION:case M.BUFFER_APPENDING_ERROR:case M.BUFFER_FULL_ERROR:case M.LEVEL_SWITCH_ERROR:case M.BUFFER_STALLED_ERROR:case M.BUFFER_SEEK_OVER_HOLE:case M.BUFFER_NUDGE_ON_STALL:r.errorAction=li();return}r.type===Y.KEY_SYSTEM_ERROR&&this.keySystemError(r)}},i.keySystemError=function(e){var r=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,r)},i.getPlaylistRetryOrSwitchAction=function(e,r){var a=this.hls,u=ya(a.config.playlistLoadPolicy,e),l=this.playlistError++,d=ui(u,l,oi(e),e.response);if(d)return{action:ht.RetryRequest,flags:Mt.None,retryConfig:u,retryCount:l};var c=this.getLevelSwitchAction(e,r);return u&&(c.retryConfig=u,c.retryCount=l),c},i.getFragRetryOrSwitchAction=function(e){var r=this.hls,a=this.getVariantLevelIndex(e.frag),u=r.levels[a],l=r.config,d=l.fragLoadPolicy,c=l.keyLoadPolicy,p=ya(e.details.startsWith("key")?c:d,e),y=r.levels.reduce(function(b,L){return b+L.fragmentError},0);if(u){e.details!==M.FRAG_GAP&&u.fragmentError++;var A=ui(p,y,oi(e),e.response);if(A)return{action:ht.RetryRequest,flags:Mt.None,retryConfig:p,retryCount:y}}var T=this.getLevelSwitchAction(e,a);return p&&(T.retryConfig=p,T.retryCount=y),T},i.getLevelSwitchAction=function(e,r){var a=this.hls;r==null&&(r=a.loadLevel);var u=this.hls.levels[r];if(u){var l,d,c=e.details;u.loadError++,c===M.BUFFER_APPEND_ERROR&&u.fragmentError++;var p=-1,y=a.levels,A=a.loadLevel,T=a.minAutoLevel,b=a.maxAutoLevel;a.autoLevelEnabled||(a.loadLevel=-1);for(var L=(l=e.frag)==null?void 0:l.type,R=L===ae.AUDIO&&c===M.FRAG_PARSING_ERROR||e.sourceBufferName==="audio"&&(c===M.BUFFER_ADD_CODEC_ERROR||c===M.BUFFER_APPEND_ERROR),C=R&&y.some(function(K){var j=K.audioCodec;return u.audioCodec!==j}),I=e.sourceBufferName==="video"&&(c===M.BUFFER_ADD_CODEC_ERROR||c===M.BUFFER_APPEND_ERROR),k=I&&y.some(function(K){var j=K.codecSet,J=K.audioCodec;return u.codecSet!==j&&u.audioCodec===J}),O=(d=e.context)!=null?d:{},V=O.type,N=O.groupId,B=function(){var j=(z+A)%y.length;if(j!==A&&j>=T&&j<=b&&y[j].loadError===0){var J,le,re=y[j];if(c===M.FRAG_GAP&&L===ae.MAIN&&e.frag){var te=y[j].details;if(te){var fe=Wi(e.frag,te.fragments,e.frag.start);if(fe!=null&&fe.gap)return 0}}else{if(V===ie.AUDIO_TRACK&&re.hasAudioGroup(N)||V===ie.SUBTITLE_TRACK&&re.hasSubtitleGroup(N))return 0;if(L===ae.AUDIO&&(J=u.audioGroups)!=null&&J.some(function(de){return re.hasAudioGroup(de)})||L===ae.SUBTITLE&&(le=u.subtitleGroups)!=null&&le.some(function(de){return re.hasSubtitleGroup(de)})||C&&u.audioCodec===re.audioCodec||!C&&u.audioCodec!==re.audioCodec||k&&u.codecSet===re.codecSet)return 0}return p=j,1}},X,z=y.length;z--&&(X=B(),!(X!==0&&X===1)););if(p>-1&&a.loadLevel!==p)return e.levelRetry=!0,this.playlistError=0,{action:ht.SendAlternateToPenaltyBox,flags:Mt.None,nextAutoLevel:p}}return{action:ht.SendAlternateToPenaltyBox,flags:Mt.MoveAllAlternatesMatchingHost}},i.onErrorOut=function(e,r){var a;switch((a=r.errorAction)==null?void 0:a.action){case ht.DoNothing:break;case ht.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(r),!r.errorAction.resolved&&r.details!==M.FRAG_GAP?r.fatal=!0:/MediaSource readyState: ended/.test(r.error.message)&&(this.warn('MediaSource ended after "'+r.sourceBufferName+'" sourceBuffer append error. Attempting to recover from media error.'),this.hls.recoverMediaError());break}if(r.fatal){this.hls.stopLoad();return}},i.sendAlternateToPenaltyBox=function(e){var r=this.hls,a=e.errorAction;if(a){var u=a.flags,l=a.hdcpLevel,d=a.nextAutoLevel;switch(u){case Mt.None:this.switchLevel(e,d);break;case Mt.MoveAllAlternatesMatchingHDCP:l&&(r.maxHdcpLevel=Ki[Ki.indexOf(l)-1],a.resolved=!0),this.warn('Restricting playback to HDCP-LEVEL of "'+r.maxHdcpLevel+'" or lower');break}a.resolved||this.switchLevel(e,d)}},i.switchLevel=function(e,r){if(r!==void 0&&e.errorAction&&(this.warn("switching to level "+r+" after "+e.details),this.hls.nextAutoLevel=r,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel,e.details===M.BUFFER_ADD_CODEC_ERROR&&e.mimeType&&e.sourceBufferName!=="audiovideo"))for(var a=la(e.mimeType),u=this.hls.levels,l=u.length;l--;)u[l][e.sourceBufferName+"Codec"]===a&&this.hls.removeLevel(l)},s}(je);function li(n){var s={action:ht.DoNothing,flags:Mt.None};return n&&(s.resolved=!0),s}var _a={length:0,start:function(){return 0},end:function(){return 0}},Fe=function(){function n(){}return n.isBuffered=function(i,t){if(i){for(var e=n.getBuffered(i),r=e.length;r--;)if(t>=e.start(r)&&t<=e.end(r))return!0}return!1},n.bufferedRanges=function(i){if(i){var t=n.getBuffered(i);return n.timeRangesToArray(t)}return[]},n.timeRangesToArray=function(i){for(var t=[],e=0;e<i.length;e++)t.push({start:i.start(e),end:i.end(e)});return t},n.bufferInfo=function(i,t,e){if(i){var r=n.bufferedRanges(i);if(r.length)return n.bufferedInfo(r,t,e)}return{len:0,start:t,end:t,bufferedIndex:-1}},n.bufferedInfo=function(i,t,e){t=Math.max(0,t),i.length>1&&i.sort(function(R,C){return R.start-C.start||C.end-R.end});var r=-1,a=[];if(e)for(var u=0;u<i.length;u++){t>=i[u].start&&t<=i[u].end&&(r=u);var l=a.length;if(l){var d=a[l-1].end;i[u].start-d<e?i[u].end>d&&(a[l-1].end=i[u].end):a.push(i[u])}else a.push(i[u])}else a=i;for(var c=0,p,y=t,A=t,T=0;T<a.length;T++){var b=a[T].start,L=a[T].end;if(r===-1&&t>=b&&t<=L&&(r=T),t+e>=b&&t<L)y=b,A=L,c=A-t;else if(t+e<b){p=b;break}}return{len:c,start:y||0,end:A||0,nextStart:p,buffered:i,bufferedIndex:r}},n.getBuffered=function(i){try{return i.buffered||_a}catch(t){return Oe.log("failed to get media.buffered",t),_a}},n}(),Sa=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,Ta="HlsJsTrackRemovedError",Nu=function(n){function s(i){var t;return t=n.call(this,i)||this,t.name=Ta,t}return S(s,n),s}(Z(Error)),Uu=function(n){function s(t,e){var r;return r=n.call(this,"buffer-controller",t.logger)||this,r.hls=void 0,r.fragmentTracker=void 0,r.details=null,r._objectUrl=null,r.operationQueue=null,r.bufferCodecEventsTotal=0,r.media=null,r.mediaSource=null,r.lastMpegAudioChunk=null,r.blockedAudioAppend=null,r.lastVideoAppendEnd=0,r.appendSource=void 0,r.transferData=void 0,r.overrides=void 0,r.appendErrors={audio:0,video:0,audiovideo:0},r.tracks={},r.sourceBuffers=[[null,null],[null,null]],r._onEndStreaming=function(a){var u;r.hls&&((u=r.mediaSource)==null?void 0:u.readyState)==="open"&&r.hls.pauseBuffering()},r._onStartStreaming=function(a){r.hls&&r.hls.resumeBuffering()},r._onMediaSourceOpen=function(a){var u=r,l=u.media,d=u.mediaSource;a&&r.log("Media source opened"),!(!l||!d)&&(d.removeEventListener("sourceopen",r._onMediaSourceOpen),l.removeEventListener("emptied",r._onMediaEmptied),r.updateDuration(),r.hls.trigger(x.MEDIA_ATTACHED,{media:l,mediaSource:d}),r.mediaSource!==null&&r.checkPendingTracks())},r._onMediaSourceClose=function(){r.log("Media source closed")},r._onMediaSourceEnded=function(){r.log("Media source ended")},r._onMediaEmptied=function(){var a=r,u=a.mediaSrc,l=a._objectUrl;u!==l&&r.error("Media element src was set while attaching MediaSource ("+l+" > "+u+")")},r.hls=t,r.fragmentTracker=e,r.appendSource=pu(nr(t.config.preferManagedMediaSource)),r.initTracks(),r.registerListeners(),r}S(s,n);var i=s.prototype;return i.hasSourceTypes=function(){return Object.keys(this.tracks).length>0},i.destroy=function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.transferData=this.overrides=void 0,this.operationQueue&&(this.operationQueue.destroy(),this.operationQueue=null),this.hls=this.fragmentTracker=null,this._onMediaSourceOpen=this._onMediaSourceClose=null,this._onMediaSourceEnded=null,this._onStartStreaming=this._onEndStreaming=null},i.registerListeners=function(){var e=this.hls;e.on(x.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(x.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(x.MANIFEST_LOADING,this.onManifestLoading,this),e.on(x.MANIFEST_PARSED,this.onManifestParsed,this),e.on(x.BUFFER_RESET,this.onBufferReset,this),e.on(x.BUFFER_APPENDING,this.onBufferAppending,this),e.on(x.BUFFER_CODECS,this.onBufferCodecs,this),e.on(x.BUFFER_EOS,this.onBufferEos,this),e.on(x.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(x.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(x.FRAG_PARSED,this.onFragParsed,this),e.on(x.FRAG_CHANGED,this.onFragChanged,this),e.on(x.ERROR,this.onError,this)},i.unregisterListeners=function(){var e=this.hls;e.off(x.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(x.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(x.MANIFEST_LOADING,this.onManifestLoading,this),e.off(x.MANIFEST_PARSED,this.onManifestParsed,this),e.off(x.BUFFER_RESET,this.onBufferReset,this),e.off(x.BUFFER_APPENDING,this.onBufferAppending,this),e.off(x.BUFFER_CODECS,this.onBufferCodecs,this),e.off(x.BUFFER_EOS,this.onBufferEos,this),e.off(x.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(x.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(x.FRAG_PARSED,this.onFragParsed,this),e.off(x.FRAG_CHANGED,this.onFragChanged,this),e.off(x.ERROR,this.onError,this)},i.transferMedia=function(){var e=this,r=this.media,a=this.mediaSource;if(!r)return null;var u={};if(this.operationQueue){var l=this.isUpdating();l||this.operationQueue.removeBlockers();var d=this.isQueued();(l||d)&&this.warn("Transfering MediaSource with"+(d?" operations in queue":"")+(l?" updating SourceBuffer(s)":"")+" "+this.operationQueue),this.operationQueue.destroy()}var c=this.transferData;return!this.sourceBufferCount&&c&&c.mediaSource===a?E(u,c.tracks):this.sourceBuffers.forEach(function(p){var y=p[0];y&&(u[y]=E({},e.tracks[y]),e.removeBuffer(y)),p[0]=p[1]=null}),{media:r,mediaSource:a,tracks:u}},i.initTracks=function(){var e={};this.sourceBuffers=[[null,null],[null,null]],this.tracks=e,this.resetQueue(),this.resetAppendErrors(),this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.lastVideoAppendEnd=0},i.onManifestLoading=function(){this.bufferCodecEventsTotal=0,this.details=null},i.onManifestParsed=function(e,r){var a,u=2;r.audio&&!r.video||r.altAudio,u=1,this.bufferCodecEventsTotal=u,this.log(u+" bufferCodec event(s) expected."),(a=this.transferData)!=null&&a.mediaSource&&this.sourceBufferCount&&u&&this.bufferCreated()},i.onMediaAttaching=function(e,r){var a=this.media=r.media,u=nr(this.appendSource);if(this.transferData=this.overrides=void 0,a&&u){var l=!!r.mediaSource;(l||r.overrides)&&(this.transferData=r,this.overrides=r.overrides);var d=this.mediaSource=r.mediaSource||new u;if(this.assignMediaSource(d),l)this._objectUrl=a.src,this.attachTransferred();else{var c=this._objectUrl=self.URL.createObjectURL(d);if(this.appendSource)try{a.removeAttribute("src");var p=self.ManagedMediaSource;a.disableRemotePlayback=a.disableRemotePlayback||p&&d instanceof p,Aa(a),Bu(a,c),a.load()}catch{a.src=c}else a.src=c}a.addEventListener("emptied",this._onMediaEmptied)}},i.assignMediaSource=function(e){var r,a;this.log((((r=this.transferData)==null?void 0:r.mediaSource)===e?"transferred":"created")+" media source: "+((a=e.constructor)==null?void 0:a.name)),e.addEventListener("sourceopen",this._onMediaSourceOpen),e.addEventListener("sourceended",this._onMediaSourceEnded),e.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(e.addEventListener("startstreaming",this._onStartStreaming),e.addEventListener("endstreaming",this._onEndStreaming))},i.attachTransferred=function(){var e=this,r=this.media,a=this.transferData;if(!(!a||!r)){var u=this.tracks,l=a.tracks,d=l?Object.keys(l):null,c=d?d.length:0,p=function(){e.media&&e.mediaSourceOpenOrEnded&&e._onMediaSourceOpen()};if(l&&d&&c){if(!this.tracksReady){this.hls.config.startFragPrefetch=!0,this.log("attachTransferred: waiting for SourceBuffer track info");return}if(this.log("attachTransferred: (bufferCodecEventsTotal "+this.bufferCodecEventsTotal+`)
16
+ required tracks: `+gt(u,function(b,L){return b==="initSegment"?void 0:L})+`;
17
+ transfer tracks: `+gt(l,function(b,L){return b==="initSegment"?void 0:L})+"}"),!gu(l,u)){a.mediaSource=null,a.tracks=void 0;var y=r.currentTime,A=this.details,T=Math.max(y,A?.fragments[0].start||0);if(T-y>1){this.log("attachTransferred: waiting for playback to reach new tracks start time "+y+" -> "+T);return}this.warn('attachTransferred: resetting MediaSource for incompatible tracks ("'+Object.keys(l)+'"->"'+Object.keys(u)+'") start time: '+T+" currentTime: "+y),this.onMediaDetaching(x.MEDIA_DETACHING,{}),this.onMediaAttaching(x.MEDIA_ATTACHING,a),r.currentTime=T;return}this.transferData=void 0,d.forEach(function(b){var L=b,R=l[L];if(R){var C=R.buffer;if(C){var I=e.fragmentTracker,k=R.id;if(I.hasFragments(k)||I.hasParts(k)){var O=Fe.getBuffered(C);I.detectEvictedFragments(L,O,k,null,!0)}var V=Yi(L),N=[L,C];e.sourceBuffers[V]=N,C.updating&&e.operationQueue&&e.operationQueue.prependBlocker(L),e.trackSourceBuffer(L,R)}}}),p(),this.bufferCreated()}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),p()}},i.onMediaDetaching=function(e,r){var a=this,u=!!r.transferMedia;this.transferData=this.overrides=void 0;var l=this.media,d=this.mediaSource,c=this._objectUrl;if(d){if(this.log("media source "+(u?"transferring":"detaching")),u)this.sourceBuffers.forEach(function(T){var b=T[0];b&&a.removeBuffer(b)}),this.resetQueue();else{if(this.mediaSourceOpenOrEnded){var p=d.readyState==="open";try{for(var y=d.sourceBuffers,A=y.length;A--;)p&&y[A].abort(),d.removeSourceBuffer(y[A]);p&&d.endOfStream()}catch(T){this.warn("onMediaDetaching: "+T.message+" while calling endOfStream")}}this.sourceBufferCount&&this.onBufferReset()}d.removeEventListener("sourceopen",this._onMediaSourceOpen),d.removeEventListener("sourceended",this._onMediaSourceEnded),d.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(d.removeEventListener("startstreaming",this._onStartStreaming),d.removeEventListener("endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null}l&&(l.removeEventListener("emptied",this._onMediaEmptied),u||(c&&self.URL.revokeObjectURL(c),this.mediaSrc===c?(l.removeAttribute("src"),this.appendSource&&Aa(l),l.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger(x.MEDIA_DETACHED,r)},i.onBufferReset=function(){var e=this;this.sourceBuffers.forEach(function(r){var a=r[0];a&&e.resetBuffer(a)}),this.initTracks()},i.resetBuffer=function(e){var r,a=(r=this.tracks[e])==null?void 0:r.buffer;if(this.removeBuffer(e),a)try{var u;(u=this.mediaSource)!=null&&u.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(a)}catch(l){this.warn("onBufferReset "+e,l)}delete this.tracks[e]},i.removeBuffer=function(e){this.removeBufferListeners(e),this.sourceBuffers[Yi(e)]=[null,null];var r=this.tracks[e];r&&(r.buffer=void 0)},i.resetQueue=function(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new Du(this.tracks)},i.onBufferCodecs=function(e,r){var a=this,u=this.tracks,l=Object.keys(r);this.log('BUFFER_CODECS: "'+l+'" (current SB count '+this.sourceBufferCount+")");var d="audiovideo"in r&&(u.audio||u.video)||u.audiovideo&&("audio"in r||"video"in r),c=!d&&this.sourceBufferCount&&this.media&&l.some(function(p){return!u[p]});if(d||c){this.warn('Unsupported transition between "'+Object.keys(u)+'" and "'+l+'" SourceBuffers');return}l.forEach(function(p){var y,A,T,b=r[p],L=b.id,R=b.codec,C=b.levelCodec,I=b.container,k=b.metadata,O=b.supplemental,V=u[p],N=(y=a.transferData)==null||(A=y.tracks)==null?void 0:A[p],B=N!=null&&N.buffer?N:V,X=B?.pendingCodec||B?.codec,z=B?.levelCodec;V||(V=u[p]={buffer:void 0,listeners:[],codec:R,supplemental:O,container:I,levelCodec:C,metadata:k,id:L});var K=ni(X,z),j=K?.replace(Sa,"$1"),J=ni(R,C),le=(T=J)==null?void 0:T.replace(Sa,"$1");J&&K&&j!==le&&(p.slice(0,5)==="audio"&&(J=ii(J,a.appendSource)),a.log("switching codec "+X+" to "+J),J!==(V.pendingCodec||V.codec)&&(V.pendingCodec=J),V.container=I,a.appendChangeType(p,I,J))}),(this.tracksReady||this.sourceBufferCount)&&(r.tracks=this.sourceBufferTracks),!this.sourceBufferCount&&this.mediaSourceOpenOrEnded&&this.checkPendingTracks()},i.appendChangeType=function(e,r,a){var u=this,l=r+";codecs="+a,d={label:"change-type="+l,execute:function(){var p=u.tracks[e];if(p){var y=p.buffer;y!=null&&y.changeType&&(u.log("changing "+e+" sourceBuffer type to "+l),y.changeType(l),p.codec=a,p.container=r)}u.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(p){u.warn("Failed to change "+e+" SourceBuffer type",p)}};this.append(d,e,this.isPending(this.tracks[e]))},i.blockAudio=function(e){var r,a=this,u=e.start,l=u+e.duration*.05,d=((r=this.fragmentTracker.getAppendedFrag(u,ae.MAIN))==null?void 0:r.gap)===!0;if(!d){var c={label:"block-audio",execute:function(){var y,A=a.tracks.video;(a.lastVideoAppendEnd>l||A!=null&&A.buffer&&Fe.isBuffered(A.buffer,l)||((y=a.fragmentTracker.getAppendedFrag(l,ae.MAIN))==null?void 0:y.gap)===!0)&&(a.blockedAudioAppend=null,a.shiftAndExecuteNext("audio"))},onStart:function(){},onComplete:function(){},onError:function(y){a.warn("Error executing block-audio operation",y)}};this.blockedAudioAppend={op:c,frag:e},this.append(c,"audio",!0)}},i.unblockAudio=function(){var e=this.blockedAudioAppend,r=this.operationQueue;e&&r&&(this.blockedAudioAppend=null,r.unblockAudio(e.op))},i.onBufferAppending=function(e,r){var a=this,u=this.tracks,l=r.data,d=r.type,c=r.parent,p=r.frag,y=r.part,A=r.chunkMeta,T=A.buffering[d],b=p.sn,L=self.performance.now();T.start=L;var R=p.stats.buffering,C=y?y.stats.buffering:null;R.start===0&&(R.start=L),C&&C.start===0&&(C.start=L);var I=u.audio,k=!1;d==="audio"&&I?.container==="audio/mpeg"&&(k=!this.lastMpegAudioChunk||A.id===1||this.lastMpegAudioChunk.sn!==A.sn,this.lastMpegAudioChunk=A);var O=this.tracks.video,V=O?.buffer;if(V&&b!=="initSegment"){var N=y||p,B=this.blockedAudioAppend;if(d==="audio"&&c!=="main"&&!this.blockedAudioAppend){var X=N.start,z=X+N.duration*.05,K=V.buffered,j=this.currentOp("video");!K.length&&!j?this.blockAudio(N):!j&&!Fe.isBuffered(V,z)&&this.lastVideoAppendEnd<z&&this.blockAudio(N)}else if(d==="video"){var J=N.end;if(B){var le=B.frag.start;(J>le||J<this.lastVideoAppendEnd||Fe.isBuffered(V,le))&&this.unblockAudio()}this.lastVideoAppendEnd=J}}var re=(y||p).start,te={label:"append-"+d,execute:function(){if(T.executeStart=self.performance.now(),k){var de=a.tracks[d];if(de){var ve=de.buffer;if(ve){var ge=re-ve.timestampOffset;Math.abs(ge)>=.1&&(a.log("Updating audio SourceBuffer timestampOffset to "+re+" (delta: "+ge+") sn: "+b+")"),ve.timestampOffset=re)}}}a.appendExecutor(l,d)},onStart:function(){},onComplete:function(){var de=self.performance.now();T.executeEnd=T.end=de,R.first===0&&(R.first=de),C&&C.first===0&&(C.first=de);var ve={};a.sourceBuffers.forEach(function(ge){var Ne=ge[0],we=ge[1];Ne&&(ve[Ne]=Fe.getBuffered(we))}),a.appendErrors[d]=0,d==="audio"||d==="video"?a.appendErrors.audiovideo=0:(a.appendErrors.audio=0,a.appendErrors.video=0),a.hls.trigger(x.BUFFER_APPENDED,{type:d,frag:p,part:y,chunkMeta:A,parent:p.type,timeRanges:ve})},onError:function(de){var ve,ge={type:Y.MEDIA_ERROR,parent:p.type,details:M.BUFFER_APPEND_ERROR,sourceBufferName:d,frag:p,part:y,chunkMeta:A,error:de,err:de,fatal:!1};if(de.code===DOMException.QUOTA_EXCEEDED_ERR)ge.details=M.BUFFER_FULL_ERROR;else if(de.code===DOMException.INVALID_STATE_ERR&&a.mediaSourceOpenOrEnded&&!((ve=a.media)!=null&&ve.error))ge.errorAction=li(!0);else if(de.name===Ta)a.sourceBufferCount===0?ge.errorAction=li(!0):++a.appendErrors[d];else{var Ne=++a.appendErrors[d];a.warn("Failed "+Ne+"/"+a.hls.config.appendErrorMaxRetry+' times to append segment in "'+d+'" sourceBuffer'),Ne>=a.hls.config.appendErrorMaxRetry&&(ge.fatal=!0)}a.hls.trigger(x.ERROR,ge)}};this.append(te,d,this.isPending(this.tracks[d]))},i.getFlushOp=function(e,r,a){var u=this;return this.log('queuing "'+e+'" remove '+r+"-"+a),{label:"remove",execute:function(){u.removeExecutor(e,r,a)},onStart:function(){},onComplete:function(){u.hls.trigger(x.BUFFER_FLUSHED,{type:e})},onError:function(d){u.warn("Failed to remove "+r+"-"+a+' from "'+e+'" SourceBuffer',d)}}},i.onBufferFlushing=function(e,r){var a=this,u=r.type,l=r.startOffset,d=r.endOffset;u?this.append(this.getFlushOp(u,l,d),u):this.sourceBuffers.forEach(function(c){var p=c[0];p&&a.append(a.getFlushOp(p,l,d),p)})},i.onFragParsed=function(e,r){var a=this,u=r.frag,l=r.part,d=[],c=l?l.elementaryStreams:u.elementaryStreams;c[qe.AUDIOVIDEO]?d.push("audiovideo"):(c[qe.AUDIO]&&d.push("audio"),c[qe.VIDEO]&&d.push("video"));var p=function(){var A=self.performance.now();u.stats.buffering.end=A,l&&(l.stats.buffering.end=A);var T=l?l.stats:u.stats;a.hls.trigger(x.FRAG_BUFFERED,{frag:u,part:l,stats:T,id:u.type})};d.length===0&&this.warn("Fragments must have at least one ElementaryStreamType set. type: "+u.type+" level: "+u.level+" sn: "+u.sn),this.blockBuffers(p,d)},i.onFragChanged=function(e,r){this.trimBuffers()},i.onBufferEos=function(e,r){var a=this,u;this.sourceBuffers.forEach(function(c){var p=c[0];if(p){var y=a.tracks[p];(!r.type||r.type===p)&&(y.ending=!0,y.ended||(y.ended=!0,a.log(p+" buffer reached EOS")))}});var l=((u=this.overrides)==null?void 0:u.endOfStream)!==!1,d=this.sourceBufferCount>0&&!this.sourceBuffers.some(function(c){var p,y=c[0];return y&&!((p=a.tracks[y])!=null&&p.ended)});d&&(l?(this.log("Queueing EOS"),this.blockUntilOpen(function(){a.tracksEnded();var c=a.mediaSource;if(!c||c.readyState!=="open"){c&&a.log("Could not call mediaSource.endOfStream(). mediaSource.readyState: "+c.readyState);return}a.log("Calling mediaSource.endOfStream()"),c.endOfStream(),a.hls.trigger(x.BUFFERED_TO_END,void 0)})):(this.tracksEnded(),this.hls.trigger(x.BUFFERED_TO_END,void 0)))},i.tracksEnded=function(){var e=this;this.sourceBuffers.forEach(function(r){var a=r[0];if(a!==null){var u=e.tracks[a];u&&(u.ending=!1)}})},i.onLevelUpdated=function(e,r){var a=r.details;a.fragments.length&&(this.details=a,this.updateDuration())},i.updateDuration=function(){var e=this,r=this.getDurationAndRange();r&&this.blockUntilOpen(function(){return e.updateMediaSource(r)})},i.onError=function(e,r){if(r.details===M.BUFFER_APPEND_ERROR&&r.frag){var a,u=(a=r.errorAction)==null?void 0:a.nextAutoLevel;w(u)&&u!==r.frag.level&&this.resetAppendErrors()}},i.resetAppendErrors=function(){this.appendErrors={audio:0,video:0,audiovideo:0}},i.trimBuffers=function(){var e=this.hls,r=this.details,a=this.media;if(!(!a||r===null)&&this.sourceBufferCount){var u=e.config,l=a.currentTime,d=r.levelTargetDuration,c=r.live&&u.liveBackBufferLength!==null?u.liveBackBufferLength:u.backBufferLength;if(w(c)&&c>=0){var p=Math.max(c,d),y=Math.floor(l/d)*d-p;this.flushBackBuffer(l,d,y)}if(w(u.frontBufferFlushThreshold)&&u.frontBufferFlushThreshold>0){var A=Math.max(u.maxBufferLength,u.frontBufferFlushThreshold),T=Math.max(A,d),b=Math.floor(l/d)*d+T;this.flushFrontBuffer(l,d,b)}}},i.flushBackBuffer=function(e,r,a){var u=this;this.sourceBuffers.forEach(function(l){var d=l[0],c=l[1];if(c){var p=Fe.getBuffered(c);if(p.length>0&&a>p.start(0)){var y;u.hls.trigger(x.BACK_BUFFER_REACHED,{bufferEnd:a});var A=u.tracks[d];if((y=u.details)!=null&&y.live)u.hls.trigger(x.LIVE_BACK_BUFFER_REACHED,{bufferEnd:a});else if(A!=null&&A.ended){u.log("Cannot flush "+d+" back buffer while SourceBuffer is in ended state");return}u.hls.trigger(x.BUFFER_FLUSHING,{startOffset:0,endOffset:a,type:d})}}})},i.flushFrontBuffer=function(e,r,a){var u=this;this.sourceBuffers.forEach(function(l){var d=l[0],c=l[1];if(c){var p=Fe.getBuffered(c),y=p.length;if(y<2)return;var A=p.start(y-1),T=p.end(y-1);if(a>A||e>=A&&e<=T)return;u.hls.trigger(x.BUFFER_FLUSHING,{startOffset:A,endOffset:1/0,type:d})}})},i.getDurationAndRange=function(){var e,r=this.details,a=this.mediaSource;if(!r||!this.media||a?.readyState!=="open")return null;var u=r.edge;if(r.live&&this.hls.config.liveDurationInfinity){var l=r.fragments.length;if(l&&r.live&&a.setLiveSeekableRange){var d=Math.max(0,r.fragmentStart),c=Math.max(d,u);return{duration:1/0,start:d,end:c}}return{duration:1/0}}var p=(e=this.overrides)==null?void 0:e.duration;if(p)return w(p)?{duration:p}:null;var y=this.media.duration,A=w(a.duration)?a.duration:0;return u>A&&u>y||!w(y)?{duration:u}:null},i.updateMediaSource=function(e){var r=e.duration,a=e.start,u=e.end,l=this.mediaSource;!this.media||!l||l.readyState!=="open"||(l.duration!==r&&(w(r)&&this.log("Updating MediaSource duration to "+r.toFixed(3)),l.duration=r),a!==void 0&&u!==void 0&&(this.log("MediaSource duration is set to "+l.duration+". Setting seekable range to "+a+"-"+u+"."),l.setLiveSeekableRange(a,u)))},i.checkPendingTracks=function(){var e=this.bufferCodecEventsTotal,r=this.pendingTrackCount,a=this.tracks;if(this.log("checkPendingTracks (pending: "+r+" codec events expected: "+e+") "+gt(a)),this.tracksReady){var u,l=(u=this.transferData)==null?void 0:u.tracks;l&&Object.keys(l).length?this.attachTransferred():this.createSourceBuffers()}},i.bufferCreated=function(){var e=this;if(this.sourceBufferCount){var r={};this.sourceBuffers.forEach(function(u){var l=u[0],d=u[1];if(l){var c=e.tracks[l];r[l]={buffer:d,container:c.container,codec:c.codec,supplemental:c.supplemental,levelCodec:c.levelCodec,id:c.id,metadata:c.metadata}}}),this.hls.trigger(x.BUFFER_CREATED,{tracks:r}),this.log("SourceBuffers created. Running queue: "+this.operationQueue),this.sourceBuffers.forEach(function(u){var l=u[0];e.executeNext(l)})}else{var a=new Error("could not create source buffer for media codec(s)");this.hls.trigger(x.ERROR,{type:Y.MEDIA_ERROR,details:M.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:a,reason:a.message})}},i.createSourceBuffers=function(){var e=this.tracks,r=this.sourceBuffers,a=this.mediaSource;if(!a)throw new Error("createSourceBuffers called when mediaSource was null");for(var u in e){var l=u,d=e[l];if(this.isPending(d)){var c=this.getTrackCodec(d,l),p=d.container+";codecs="+c;d.codec=c,this.log("creating sourceBuffer("+p+")"+(this.currentOp(l)?" Queued":"")+" "+gt(d));try{var y=a.addSourceBuffer(p),A=Yi(l),T=[l,y];r[A]=T,d.buffer=y}catch(L){var b;this.error("error while trying to add sourceBuffer: "+L.message),this.shiftAndExecuteNext(l),(b=this.operationQueue)==null||b.removeBlockers(),delete this.tracks[l],this.hls.trigger(x.ERROR,{type:Y.MEDIA_ERROR,details:M.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:L,sourceBufferName:l,mimeType:p,parent:d.id});return}this.trackSourceBuffer(l,d)}}this.bufferCreated()},i.getTrackCodec=function(e,r){var a=e.supplemental,u=e.codec;a&&(r==="video"||r==="audiovideo")&&Vi(a,"video")&&(u=Eu(u,a));var l=ni(u,e.levelCodec);return l?r.slice(0,5)==="audio"?ii(l,this.appendSource):l:""},i.trackSourceBuffer=function(e,r){var a=this,u=r.buffer;if(u){var l=this.getTrackCodec(r,e);this.tracks[e]={buffer:u,codec:l,container:r.container,levelCodec:r.levelCodec,supplemental:r.supplemental,metadata:r.metadata,id:r.id,listeners:[]},this.removeBufferListeners(e),this.addBufferListener(e,"updatestart",this.onSBUpdateStart),this.addBufferListener(e,"updateend",this.onSBUpdateEnd),this.addBufferListener(e,"error",this.onSBUpdateError),this.appendSource&&this.addBufferListener(e,"bufferedchange",function(d,c){var p=c.removedRanges;p!=null&&p.length&&a.hls.trigger(x.BUFFER_FLUSHED,{type:d})})}},i.onSBUpdateStart=function(e){var r=this.currentOp(e);r&&r.onStart()},i.onSBUpdateEnd=function(e){var r;if(((r=this.mediaSource)==null?void 0:r.readyState)==="closed"){this.resetBuffer(e);return}var a=this.currentOp(e);a&&(a.onComplete(),this.shiftAndExecuteNext(e))},i.onSBUpdateError=function(e,r){var a,u=new Error(e+" SourceBuffer error. MediaSource readyState: "+((a=this.mediaSource)==null?void 0:a.readyState));this.error(""+u,r),this.hls.trigger(x.ERROR,{type:Y.MEDIA_ERROR,details:M.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:u,fatal:!1});var l=this.currentOp(e);l&&l.onError(u)},i.removeExecutor=function(e,r,a){var u=this.media,l=this.mediaSource,d=this.tracks[e],c=d?.buffer;if(!u||!l||!c){this.warn("Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),this.shiftAndExecuteNext(e);return}var p=w(u.duration)?u.duration:1/0,y=w(l.duration)?l.duration:1/0,A=Math.max(0,r),T=Math.min(a,p,y);T>A&&(!d.ending||d.ended)?(d.ended=!1,this.log("Removing ["+A+","+T+"] from the "+e+" SourceBuffer"),c.remove(A,T)):this.shiftAndExecuteNext(e)},i.appendExecutor=function(e,r){var a=this.tracks[r],u=a?.buffer;if(!u)throw new Nu("Attempting to append to the "+r+" SourceBuffer, but it does not exist");a.ending=!1,a.ended=!1,u.appendBuffer(e)},i.blockUntilOpen=function(e){this.isUpdating()||this.isQueued()?this.blockBuffers(e):e()},i.isUpdating=function(){return this.sourceBuffers.some(function(e){var r=e[0],a=e[1];return r&&a.updating})},i.isQueued=function(){var e=this;return this.sourceBuffers.some(function(r){var a=r[0];return a&&!!e.currentOp(a)})},i.isPending=function(e){return!!e&&!e.buffer},i.blockBuffers=function(e,r){var a=this;if(r===void 0&&(r=this.sourceBufferTypes),!r.length){this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}var u=this.operationQueue,l=r.map(function(c){return a.appendBlocker(c)}),d=r.length>1&&!!this.blockedAudioAppend;d&&this.unblockAudio(),Promise.all(l).then(function(c){u===a.operationQueue&&(e(),a.stepOperationQueue(r))})},i.stepOperationQueue=function(e){var r=this;e.forEach(function(a){var u,l=(u=r.tracks[a])==null?void 0:u.buffer;!l||l.updating||r.shiftAndExecuteNext(a)})},i.append=function(e,r,a){this.operationQueue&&this.operationQueue.append(e,r,a)},i.appendBlocker=function(e){if(this.operationQueue)return this.operationQueue.appendBlocker(e)},i.currentOp=function(e){return this.operationQueue?this.operationQueue.current(e):null},i.executeNext=function(e){e&&this.operationQueue&&this.operationQueue.executeNext(e)},i.shiftAndExecuteNext=function(e){this.operationQueue&&this.operationQueue.shiftAndExecuteNext(e)},i.addBufferListener=function(e,r,a){var u=this.tracks[e];if(u){var l=u.buffer;if(l){var d=a.bind(this,e);u.listeners.push({event:r,listener:d}),l.addEventListener(r,d)}}},i.removeBufferListeners=function(e){var r=this.tracks[e];if(r){var a=r.buffer;a&&(r.listeners.forEach(function(u){a.removeEventListener(u.event,u.listener)}),r.listeners.length=0)}},f(s,[{key:"mediaSourceOpenOrEnded",get:function(){var e,r=(e=this.mediaSource)==null?void 0:e.readyState;return r==="open"||r==="ended"}},{key:"sourceBufferTracks",get:function(){var e=this;return Object.keys(this.tracks).reduce(function(r,a){var u=e.tracks[a];return r[a]={id:u.id,container:u.container,codec:u.codec,levelCodec:u.levelCodec},r},{})}},{key:"bufferedToEnd",get:function(){var e=this;return this.sourceBufferCount>0&&!this.sourceBuffers.some(function(r){var a,u,l=r[0];return l&&(!((a=e.tracks[l])!=null&&a.ended)||((u=e.tracks[l])==null?void 0:u.ending))})}},{key:"tracksReady",get:function(){var e=this.pendingTrackCount;return e>0&&(e>=this.bufferCodecEventsTotal||this.isPending(this.tracks.audiovideo))}},{key:"mediaSrc",get:function(){var e,r,a=((e=this.media)==null||(r=e.querySelector)==null?void 0:r.call(e,"source"))||this.media;return a?.src}},{key:"pendingTrackCount",get:function(){var e=this;return Object.keys(this.tracks).reduce(function(r,a){return r+(e.isPending(e.tracks[a])?1:0)},0)}},{key:"sourceBufferCount",get:function(){return this.sourceBuffers.reduce(function(e,r){var a=r[0];return e+(a?1:0)},0)}},{key:"sourceBufferTypes",get:function(){return this.sourceBuffers.map(function(e){var r=e[0];return r}).filter(function(e){return!!e})}}])}(je);function Aa(n){var s=n.querySelectorAll("source");[].slice.call(s).forEach(function(i){n.removeChild(i)})}function Bu(n,s){var i=self.document.createElement("source");i.type="video/mp4",i.src=s,n.appendChild(i)}function Yi(n){return n==="audio"?1:0}var Gu=function(){function n(i){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=i,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var s=n.prototype;return s.setStreamController=function(t){this.streamController=t},s.destroy=function(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},s.registerListeners=function(){var t=this.hls;t.on(x.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.on(x.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(x.MANIFEST_PARSED,this.onManifestParsed,this),t.on(x.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(x.BUFFER_CODECS,this.onBufferCodecs,this),t.on(x.MEDIA_DETACHING,this.onMediaDetaching,this)},s.unregisterListener=function(){var t=this.hls;t.off(x.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.off(x.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(x.MANIFEST_PARSED,this.onManifestParsed,this),t.off(x.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(x.BUFFER_CODECS,this.onBufferCodecs,this),t.off(x.MEDIA_DETACHING,this.onMediaDetaching,this)},s.onFpsDropLevelCapping=function(t,e){var r=this.hls.levels[e.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})},s.onMediaAttaching=function(t,e){this.media=e.media instanceof HTMLVideoElement?e.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()},s.onManifestParsed=function(t,e){var r=this.hls;this.restrictedLevels=[],this.firstLevel=e.firstLevel,r.config.capLevelToPlayerSize&&e.video&&this.startCapping()},s.onLevelsUpdated=function(t,e){this.timer&&w(this.autoLevelCapping)&&this.detectPlayerSize()},s.onBufferCodecs=function(t,e){var r=this.hls;r.config.capLevelToPlayerSize&&e.video&&this.startCapping()},s.onMediaDetaching=function(){this.stopCapping(),this.media=null},s.detectPlayerSize=function(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0){this.clientRect=null;return}var t=this.hls.levels;if(t.length){var e=this.hls,r=this.getMaxLevel(t.length-1);r!==this.autoLevelCapping&&e.logger.log("Setting autoLevelCapping to "+r+": "+t[r].height+"p@"+t[r].bitrate+" for media "+this.mediaWidth+"x"+this.mediaHeight),e.autoLevelCapping=r,e.autoLevelEnabled&&e.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=e.autoLevelCapping}}},s.getMaxLevel=function(t){var e=this,r=this.hls.levels;if(!r.length)return-1;var a=r.filter(function(u,l){return e.isLevelAllowed(u)&&l<=t});return this.clientRect=null,n.getMaxLevelByMediaSize(a,this.mediaWidth,this.mediaHeight)},s.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},s.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},s.getDimensions=function(){if(this.clientRect)return this.clientRect;var t=this.media,e={width:0,height:0};if(t){var r=t.getBoundingClientRect();e.width=r.width,e.height=r.height,!e.width&&!e.height&&(e.width=r.right-r.left||t.width||0,e.height=r.bottom-r.top||t.height||0)}return this.clientRect=e,e},s.isLevelAllowed=function(t){var e=this.restrictedLevels;return!e.some(function(r){return t.bitrate===r.bitrate&&t.width===r.width&&t.height===r.height})},n.getMaxLevelByMediaSize=function(t,e,r){if(!(t!=null&&t.length))return-1;for(var a=function(y,A){return A?y.width!==A.width||y.height!==A.height:!0},u=t.length-1,l=Math.max(e,r),d=0;d<t.length;d+=1){var c=t[d];if((c.width>=l||c.height>=l)&&a(c,t[d+1])){u=d;break}}return u},f(n,[{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var t=1;if(!this.hls.config.ignoreDevicePixelRatio)try{t=self.devicePixelRatio}catch{}return Math.min(t,this.hls.config.maxDevicePixelRatio)}}])}(),Vu=/^(\d+)x(\d+)$/,ba=/(.+?)=(".*?"|.*?)(?:,|$)/g,rt=function(){function n(i,t){typeof i=="string"&&(i=n.parseAttrList(i,t)),E(this,i)}var s=n.prototype;return s.decimalInteger=function(t){var e=parseInt(this[t],10);return e>Number.MAX_SAFE_INTEGER?1/0:e},s.hexadecimalInteger=function(t){if(this[t]){var e=(this[t]||"0x").slice(2);e=(e.length&1?"0":"")+e;for(var r=new Uint8Array(e.length/2),a=0;a<e.length/2;a++)r[a]=parseInt(e.slice(a*2,a*2+2),16);return r}return null},s.hexadecimalIntegerAsNumber=function(t){var e=parseInt(this[t],16);return e>Number.MAX_SAFE_INTEGER?1/0:e},s.decimalFloatingPoint=function(t){return parseFloat(this[t])},s.optionalFloat=function(t,e){var r=this[t];return r?parseFloat(r):e},s.enumeratedString=function(t){return this[t]},s.enumeratedStringList=function(t,e){var r=this[t];return(r?r.split(/[ ,]+/):[]).reduce(function(a,u){return a[u.toLowerCase()]=!0,a},e)},s.bool=function(t){return this[t]==="YES"},s.decimalResolution=function(t){var e=Vu.exec(this[t]);if(e!==null)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}},n.parseAttrList=function(t,e){var r,a={},u='"';for(ba.lastIndex=0;(r=ba.exec(t))!==null;){var l=r[1].trim(),d=r[2],c=d.indexOf(u)===0&&d.lastIndexOf(u)===d.length-1,p=!1;if(c)d=d.slice(1,-1);else switch(l){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":p=!0}if(!(e&&(c||p))){if(!p&&!c)switch(l){case"CLOSED-CAPTIONS":if(d==="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":Oe.warn(t+": attribute "+l+" is missing quotes")}}a[l]=d}return a},f(n,[{key:"clientAttrs",get:function(){return Object.keys(this).filter(function(t){return t.substring(0,2)==="X-"})}}])}(),Hu="com.apple.hls.interstitial";function Ku(n){return n!=="ID"&&n!=="CLASS"&&n!=="CUE"&&n!=="START-DATE"&&n!=="DURATION"&&n!=="END-DATE"&&n!=="END-ON-NEXT"}function Wu(n){return n==="SCTE35-OUT"||n==="SCTE35-IN"||n==="SCTE35-CMD"}var La=function(){function n(s,i,t){var e;if(t===void 0&&(t=0),this.attr=void 0,this.tagAnchor=void 0,this.tagOrder=void 0,this._startDate=void 0,this._endDate=void 0,this._dateAtEnd=void 0,this._cue=void 0,this._badValueForSameId=void 0,this.tagAnchor=i?.tagAnchor||null,this.tagOrder=(e=i?.tagOrder)!=null?e:t,i){var r=i.attr;for(var a in r)if(Object.prototype.hasOwnProperty.call(s,a)&&s[a]!==r[a]){Oe.warn('DATERANGE tag attribute: "'+a+'" does not match for tags with ID: "'+s.ID+'"'),this._badValueForSameId=a;break}s=E(new rt({}),r,s)}if(this.attr=s,i?(this._startDate=i._startDate,this._cue=i._cue,this._endDate=i._endDate,this._dateAtEnd=i._dateAtEnd):this._startDate=new Date(s["START-DATE"]),"END-DATE"in this.attr){var u=i?.endDate||new Date(this.attr["END-DATE"]);w(u.getTime())&&(this._endDate=u)}}return f(n,[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"cue",get:function(){var i=this._cue;return i===void 0?this._cue=this.attr.enumeratedStringList(this.attr.CUE?"CUE":"X-CUE",{pre:!1,post:!1,once:!1}):i}},{key:"startTime",get:function(){var i=this.tagAnchor;return i===null||i.programDateTime===null?(Oe.warn('Expected tagAnchor Fragment with PDT set for DateRange "'+this.id+'": '+i),NaN):i.start+(this.startDate.getTime()-i.programDateTime)/1e3}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){var i=this._endDate||this._dateAtEnd;if(i)return i;var t=this.duration;return t!==null?this._dateAtEnd=new Date(this._startDate.getTime()+t*1e3):null}},{key:"duration",get:function(){if("DURATION"in this.attr){var i=this.attr.decimalFloatingPoint("DURATION");if(w(i))return i}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}},{key:"endOnNext",get:function(){return this.attr.bool("END-ON-NEXT")}},{key:"isInterstitial",get:function(){return this.class===Hu}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&w(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)}}])}(),ju=10,Yu=function(){function n(i){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.dateRangeTagCount=0,this.live=!0,this.requestScheduled=-1,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.appliedTimelineOffset=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=i}var s=n.prototype;return s.reloaded=function(t){if(!t){this.advanced=!0,this.updated=!0;return}var e=this.lastPartSn-t.lastPartSn,r=this.lastPartIndex-t.lastPartIndex;this.updated=this.endSN!==t.endSN||!!r||!!e||!this.live,this.advanced=this.endSN>t.endSN||e>0||e===0&&r>0,this.updated||this.advanced?this.misses=Math.floor(t.misses*.6):this.misses=t.misses+1},f(n,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?w(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||ju}},{key:"drift",get:function(){var t=this.driftEndTime-this.driftStartTime;if(t>0){var e=this.driftEnd-this.driftStart;return e*1e3/t}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var t;return(t=this.partList)!=null&&t.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var t;return(t=this.fragments)!=null&&t.length?this.fragments[this.fragments.length-1].end:0}},{key:"fragmentStart",get:function(){var t;return(t=this.fragments)!=null&&t.length?this.fragments[0].start:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var t;return(t=this.partList)!=null&&t.length?this.partList[this.partList.length-1].index:-1}},{key:"maxPartIndex",get:function(){var t=this.partList;if(t){var e=this.lastPartIndex;if(e!==-1){for(var r=t.length;r--;)if(t[r].index>e)return t[r].index;return e}}return 0}},{key:"lastPartSn",get:function(){var t;return(t=this.partList)!=null&&t.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}},{key:"expired",get:function(){if(this.live&&this.age&&this.misses<3){var t=this.partEnd-this.fragmentStart;return this.age>Math.max(t,this.totalduration)+this.levelTargetDuration}return!1}}])}(),ar={cbc:0,ctr:1};function Mr(n){return n==="AES-128"||n==="AES-256"||n==="AES-256-CTR"}function xa(n){switch(n){case"AES-128":case"AES-256":return ar.cbc;case"AES-256-CTR":return ar.ctr;default:throw new Error("invalid full segment method "+n)}}var zu=function(){function n(i,t,e,r,a){r===void 0&&(r=[1]),a===void 0&&(a=null),this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=i,this.uri=t,this.keyFormat=e,this.keyFormatVersions=r,this.iv=a,this.encrypted=i?i!=="NONE":!1,this.isCommonEncryption=this.encrypted&&!Mr(i)}n.clearKeyUriToKeyIdMap=function(){};var s=n.prototype;return s.isSupported=function(){if(this.method){if(Mr(this.method)||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES"}return!1},s.getDecryptData=function(t){if(!this.encrypted||!this.uri)return null;if(Mr(this.method)&&this.uri&&!this.iv){typeof t!="number"&&(Oe.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),t=0);var e=qu(t),r=new n(this.method,this.uri,"identity",this.keyFormatVersions,e);return r}return this},n}();function qu(n){for(var s=new Uint8Array(16),i=12;i<16;i++)s[i]=n>>8*(15-i)&255;return s}var Ra=/#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,Ca=/#EXT-X-MEDIA:(.*)/g,$u=/^#EXT(?:INF|-X-TARGETDURATION):/m,zi=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),Xu=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("|")),Fr=function(){function n(){}return n.findGroup=function(i,t){for(var e=0;e<i.length;e++){var r=i[e];if(r.id===t)return r}},n.resolve=function(i,t){return Ze.buildAbsoluteURL(t,i,{alwaysNormalize:!0})},n.isMediaPlaylist=function(i){return $u.test(i)},n.parseMasterPlaylist=function(i,t){var e=!1,r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:e},a=[];Ra.lastIndex=0;for(var u;(u=Ra.exec(i))!=null;)if(u[1]){var l,d=new rt(u[1],r),c=u[2],p={attrs:d,bitrate:d.decimalInteger("BANDWIDTH")||d.decimalInteger("AVERAGE-BANDWIDTH"),name:d.NAME,url:n.resolve(c,t)},y=d.decimalResolution("RESOLUTION");y&&(p.width=y.width,p.height=y.height),wa(d.CODECS,p);var A=d["SUPPLEMENTAL-CODECS"];A&&(p.supplemental={},wa(A,p.supplemental)),(l=p.unknownCodecs)!=null&&l.length||a.push(p),r.levels.push(p)}else if(u[3]){var T=u[3],b=u[4];switch(T){case"SESSION-DATA":{var L=new rt(b,r),R=L["DATA-ID"];R&&(r.sessionData===null&&(r.sessionData={}),r.sessionData[R]=L);break}case"SESSION-KEY":{var C=Da(b,t,r);C.encrypted&&C.isSupported()?(r.sessionKeys===null&&(r.sessionKeys=[]),r.sessionKeys.push(C)):Oe.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+b+'"');break}case"DEFINE":break;case"CONTENT-STEERING":{var I=new rt(b,r);r.contentSteering={uri:n.resolve(I["SERVER-URI"],t),pathwayId:I["PATHWAY-ID"]||"."};break}case"START":{r.startTimeOffset=Ia(b);break}}}var k=a.length>0&&a.length<r.levels.length;return r.levels=k?a:r.levels,r.levels.length===0&&(r.playlistParsingError=new Error("no levels found in manifest")),r},n.parseMasterPlaylistMedia=function(i,t,e){var r,a={},u=e.levels,l={AUDIO:u.map(function(O){return{id:O.attrs.AUDIO,audioCodec:O.audioCodec}}),SUBTITLES:u.map(function(O){return{id:O.attrs.SUBTITLES,textCodec:O.textCodec}}),"CLOSED-CAPTIONS":[]},d=0;for(Ca.lastIndex=0;(r=Ca.exec(i))!==null;){var c=new rt(r[1],e),p=c.TYPE;if(p){var y=l[p],A=a[p]||[];a[p]=A;var T=c.LANGUAGE,b=c["ASSOC-LANGUAGE"],L=c.CHANNELS,R=c.CHARACTERISTICS,C=c["INSTREAM-ID"],I={attrs:c,bitrate:0,id:d++,groupId:c["GROUP-ID"]||"",name:c.NAME||T||"",type:p,default:c.bool("DEFAULT"),autoselect:c.bool("AUTOSELECT"),forced:c.bool("FORCED"),lang:T,url:c.URI?n.resolve(c.URI,t):""};if(b&&(I.assocLang=b),L&&(I.channels=L),R&&(I.characteristics=R),C&&(I.instreamId=C),y!=null&&y.length){var k=n.findGroup(y,I.groupId)||y[0];Pa(I,k,"audioCodec"),Pa(I,k,"textCodec")}A.push(I)}}return a},n.parseLevelPlaylist=function(i,t,e,r,a,u){var l,d={url:t},c=new Yu(t),p=c.fragments,y=[],A=null,T=0,b=0,L=0,R=0,C=0,I=null,k=new Ni(r,d),O,V,N,B=-1,X=!1,z=null,K;if(zi.lastIndex=0,c.m3u8=i,c.hasVariableRefs=!1,((l=zi.exec(i))==null?void 0:l[0])!=="#EXTM3U")return c.playlistParsingError=new Error("Missing format identifier #EXTM3U"),c;for(;(O=zi.exec(i))!==null;){X&&(X=!1,k=new Ni(r,d),k.playlistOffset=L,k.start=L,k.sn=T,k.cc=R,C&&(k.bitrate=C),k.level=e,A&&(k.initSegment=A,A.rawProgramDateTime&&(k.rawProgramDateTime=A.rawProgramDateTime,A.rawProgramDateTime=null),z&&(k.setByteRange(z),z=null)));var j=O[1];if(j){k.duration=parseFloat(j);var J=(" "+O[2]).slice(1);k.title=J||null,k.tagList.push(J?["INF",j,J]:["INF",j])}else if(O[3]){if(w(k.duration)){k.playlistOffset=L,k.start=L,N&&Ma(k,N,c),k.sn=T,k.level=e,k.cc=R,p.push(k);var le=(" "+O[3]).slice(1);k.relurl=le,qi(k,I,y),I=k,L+=k.duration,T++,b=0,X=!0}}else{if(O=O[0].match(Xu),!O){Oe.warn("No matches on slow regex match for level playlist!");continue}for(V=1;V<O.length&&O[V]===void 0;V++);var re=(" "+O[V]).slice(1),te=(" "+O[V+1]).slice(1),fe=O[V+2]?(" "+O[V+2]).slice(1):null;switch(re){case"BYTERANGE":I?k.setByteRange(te,I):k.setByteRange(te);break;case"PROGRAM-DATE-TIME":k.rawProgramDateTime=te,k.tagList.push(["PROGRAM-DATE-TIME",te]),B===-1&&(B=p.length);break;case"PLAYLIST-TYPE":c.type&&Qt(c,re,O),c.type=te.toUpperCase();break;case"MEDIA-SEQUENCE":c.startSN!==0?Qt(c,re,O):p.length>0&&Fa(c,re,O),T=c.startSN=parseInt(te);break;case"SKIP":{c.skippedSegments&&Qt(c,re,O);var de=new rt(te,c),ve=de.decimalInteger("SKIPPED-SEGMENTS");if(w(ve)){c.skippedSegments+=ve;for(var ge=ve;ge--;)p.push(null);T+=ve}var Ne=de.enumeratedString("RECENTLY-REMOVED-DATERANGES");Ne&&(c.recentlyRemovedDateranges=(c.recentlyRemovedDateranges||[]).concat(Ne.split(" ")));break}case"TARGETDURATION":c.targetduration!==0&&Qt(c,re,O),c.targetduration=Math.max(parseInt(te),1);break;case"VERSION":c.version!==null&&Qt(c,re,O),c.version=parseInt(te);break;case"INDEPENDENT-SEGMENTS":break;case"ENDLIST":c.live||Qt(c,re,O),c.live=!1;break;case"#":(te||fe)&&k.tagList.push(fe?[te,fe]:[te]);break;case"DISCONTINUITY":R++,k.tagList.push(["DIS"]);break;case"GAP":k.gap=!0,k.tagList.push([re]);break;case"BITRATE":k.tagList.push([re,te]),C=parseInt(te)*1e3,w(C)?k.bitrate=C:C=0;break;case"DATERANGE":{var we=new rt(te,c),Be=new La(we,c.dateRanges[we.ID],c.dateRangeTagCount);c.dateRangeTagCount++,Be.isValid||c.skippedSegments?c.dateRanges[Be.id]=Be:Oe.warn('Ignoring invalid DATERANGE tag: "'+te+'"'),k.tagList.push(["EXT-X-DATERANGE",te]);break}case"DEFINE":break;case"DISCONTINUITY-SEQUENCE":c.startCC!==0?Qt(c,re,O):p.length>0&&Fa(c,re,O),c.startCC=R=parseInt(te);break;case"KEY":{var Ce=Da(te,t,c);if(Ce.isSupported()){if(Ce.method==="NONE"){N=void 0;break}N||(N={}),N[Ce.keyFormat]&&(N=E({},N)),N[Ce.keyFormat]=Ce}else Oe.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+te+'"');break}case"START":c.startTimeOffset=Ia(te);break;case"MAP":{var et=new rt(te,c);if(k.duration){var Ge=new Ni(r,d);Oa(Ge,et,e,N),A=Ge,k.initSegment=A,A.rawProgramDateTime&&!k.rawProgramDateTime&&(k.rawProgramDateTime=A.rawProgramDateTime)}else{var Qe=k.byteRangeEndOffset;if(Qe){var _t=k.byteRangeStartOffset;z=Qe-_t+"@"+_t}else z=null;Oa(k,et,e,N),A=k,X=!0}A.cc=R;break}case"SERVER-CONTROL":{K&&Qt(c,re,O),K=new rt(te),c.canBlockReload=K.bool("CAN-BLOCK-RELOAD"),c.canSkipUntil=K.optionalFloat("CAN-SKIP-UNTIL",0),c.canSkipDateRanges=c.canSkipUntil>0&&K.bool("CAN-SKIP-DATERANGES"),c.partHoldBack=K.optionalFloat("PART-HOLD-BACK",0),c.holdBack=K.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{c.partTarget&&Qt(c,re,O);var ut=new rt(te);c.partTarget=ut.decimalFloatingPoint("PART-TARGET");break}case"PART":{var Ve=c.partList;Ve||(Ve=c.partList=[]);var St=b>0?Ve[Ve.length-1]:void 0,it=b++,$e=new rt(te,c),Tt=new eu($e,k,d,it,St);Ve.push(Tt),k.duration+=Tt.duration;break}case"PRELOAD-HINT":{var dt=new rt(te,c);c.preloadHint=dt;break}case"RENDITION-REPORT":{var xt=new rt(te,c);c.renditionReports=c.renditionReports||[],c.renditionReports.push(xt);break}default:Oe.warn("line parsed but not handled: "+O);break}}}I&&!I.relurl?(p.pop(),L-=I.duration,c.partList&&(c.fragmentHint=I)):c.partList&&(qi(k,I,y),k.cc=R,c.fragmentHint=k,N&&Ma(k,N,c)),c.targetduration||(c.playlistParsingError=new Error("#EXT-X-TARGETDURATION is required"));var Ye=p.length,ct=p[0],nt=p[Ye-1];if(L+=c.skippedSegments*c.targetduration,L>0&&Ye&&nt){c.averagetargetduration=L/Ye;var At=nt.sn;c.endSN=At!=="initSegment"?At:0,c.live||(nt.endList=!0),ct&&c.startCC===void 0&&(c.startCC=ct.cc),B>0&&(Zu(p,B),ct&&y.unshift(ct))}else c.endSN=0,c.startCC=0;return c.fragmentHint&&(L+=c.fragmentHint.duration),c.totalduration=L,y.length&&c.dateRangeTagCount&&ct&&ka(y,c),c.endCC=R,c},n}();function ka(n,s){for(var i=n.length,t=n[i-1],e=s.live?1/0:s.totalduration,r=Object.keys(s.dateRanges),a=r.length;a--;){var u=s.dateRanges[r[a]],l=u.startDate.getTime();u.tagAnchor=t.ref;for(var d=i;d--;){var c=Qu(s,l,n,d,e);if(c!==-1){u.tagAnchor=s.fragments[c].ref;break}}}}function Qu(n,s,i,t,e){var r=i[t];if(r){var a=r.programDateTime;if(s>=a||t===0){var u,l=(((u=i[t+1])==null?void 0:u.start)||e)-r.start;if(s<=a+l*1e3){var d=i[t].sn-n.startSN,c=n.fragments;if(c.length>i.length)for(var p=i[t+1]||c[c.length-1],y=p.sn-n.startSN,A=y;A>d;A--){var T=c[A].programDateTime;if(s>=T&&s<T+c[A].duration*1e3)return A}return d}}}return-1}function Da(n,s,i){var t,e,r=new rt(n,i),a=(t=r.METHOD)!=null?t:"",u=r.URI,l=r.hexadecimalInteger("IV"),d=r.KEYFORMATVERSIONS,c=(e=r.KEYFORMAT)!=null?e:"identity";u&&r.IV&&!l&&Oe.error("Invalid IV: "+r.IV);var p=u?Fr.resolve(u,s):"",y=(d||"1").split("/").map(Number).filter(Number.isFinite);return new zu(a,p,c,y,l)}function Ia(n){var s=new rt(n),i=s.decimalFloatingPoint("TIME-OFFSET");return w(i)?i:null}function wa(n,s){var i=(n||"").split(/[ ,]+/).filter(function(t){return t});["video","audio","text"].forEach(function(t){var e=i.filter(function(r){return aa(r,t)});e.length&&(s[t+"Codec"]=e.map(function(r){return r.split("/")[0]}).join(","),i=i.filter(function(r){return e.indexOf(r)===-1}))}),s.unknownCodecs=i}function Pa(n,s,i){var t=s[i];t&&(n[i]=t)}function Zu(n,s){for(var i=n[s],t=s;t--;){var e=n[t];if(!e)return;e.programDateTime=i.programDateTime-e.duration*1e3,i=e}}function qi(n,s,i){n.rawProgramDateTime?i.push(n):s!=null&&s.programDateTime&&(n.programDateTime=s.endProgramDateTime)}function Oa(n,s,i,t){n.relurl=s.URI,s.BYTERANGE&&n.setByteRange(s.BYTERANGE),n.level=i,n.sn="initSegment",t&&(n.levelkeys=t),n.initSegment=null}function Ma(n,s,i){n.levelkeys=s;var t=i.encryptedFragments;(!t.length||t[t.length-1].levelkeys!==s)&&Object.keys(s).some(function(e){return s[e].isCommonEncryption})&&t.push(n)}function Qt(n,s,i){n.playlistParsingError=new Error("#EXT-X-"+s+" must not appear more than once ("+i[0]+")")}function Fa(n,s,i){n.playlistParsingError=new Error("#EXT-X-"+s+" must appear before the first Media Segment ("+i[0]+")")}function $i(n,s){var i=s.startPTS;if(w(i)){var t=0,e;s.sn>n.sn?(t=i-n.start,e=n):(t=n.start-i,e=s),e.duration!==t&&e.setDuration(t)}else if(s.sn>n.sn){var r=n.cc===s.cc;r&&n.minEndPTS?s.setStart(n.start+(n.minEndPTS-n.start)):s.setStart(n.start+n.duration)}else s.setStart(Math.max(n.start-s.duration,0))}function Na(n,s,i,t,e,r){var a=t-i;a<=0&&(Oe.warn("Fragment should have a positive duration",s),t=i+s.duration,r=e+s.duration);var u=i,l=t,d=s.startPTS,c=s.endPTS;if(w(d)){var p=Math.abs(d-i);w(s.deltaPTS)?s.deltaPTS=Math.max(p,s.deltaPTS):s.deltaPTS=p,u=Math.max(i,d),i=Math.min(i,d),e=Math.min(e,s.startDTS),l=Math.min(t,c),t=Math.max(t,c),r=Math.max(r,s.endDTS)}var y=i-s.start;s.start!==0&&s.setStart(i),s.setDuration(t-s.start),s.startPTS=i,s.maxStartPTS=u,s.startDTS=e,s.endPTS=t,s.minEndPTS=l,s.endDTS=r;var A=s.sn;if(!n||A<n.startSN||A>n.endSN)return 0;var T,b=A-n.startSN,L=n.fragments;for(L[b]=s,T=b;T>0;T--)$i(L[T],L[T-1]);for(T=b;T<L.length-1;T++)$i(L[T],L[T+1]);return n.fragmentHint&&$i(L[L.length-1],n.fragmentHint),n.PTSKnown=n.alignedSliding=!0,y}function Ju(n,s){if(n!==s){for(var i=null,t=n.fragments,e=t.length-1;e>=0;e--){var r=t[e].initSegment;if(r){i=r;break}}n.fragmentHint&&delete n.fragmentHint.endPTS;var a;rl(n,s,function(T,b,L,R){if(s.skippedSegments&&b.cc!==T.cc)for(var C=T.cc-b.cc,I=L;I<R.length;I++)R[I].cc+=C;w(T.startPTS)&&w(T.endPTS)&&(b.setStart(b.startPTS=T.startPTS),b.startDTS=T.startDTS,b.maxStartPTS=T.maxStartPTS,b.endPTS=T.endPTS,b.endDTS=T.endDTS,b.minEndPTS=T.minEndPTS,b.setDuration(T.endPTS-T.startPTS),b.duration&&(a=b),s.PTSKnown=s.alignedSliding=!0),T.hasStreams&&(b.elementaryStreams=T.elementaryStreams),b.loader=T.loader,T.hasStats&&(b.stats=T.stats),T.initSegment&&(b.initSegment=T.initSegment,i=T.initSegment)});var u=s.fragments,l=s.fragmentHint?u.concat(s.fragmentHint):u;if(i&&l.forEach(function(T){var b;T&&(!T.initSegment||T.initSegment.relurl===((b=i)==null?void 0:b.relurl))&&(T.initSegment=i)}),s.skippedSegments)if(s.deltaUpdateFailed=u.some(function(T){return!T}),s.deltaUpdateFailed){Oe.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var d=s.skippedSegments;d--;)u.shift();s.startSN=u[0].sn}else{s.endCC=u[u.length-1].cc,s.canSkipDateRanges&&(s.dateRanges=el(n.dateRanges,s));var c=n.fragments.filter(function(T){return T.rawProgramDateTime});if(n.hasProgramDateTime&&!s.hasProgramDateTime)for(var p=1;p<l.length;p++)l[p].programDateTime===null&&qi(l[p],l[p-1],c);ka(c,s)}tl(n.partList,s.partList,function(T,b){b.elementaryStreams=T.elementaryStreams,b.stats=T.stats}),a?Na(s,a,a.startPTS,a.endPTS,a.startDTS,a.endDTS):Ba(n,s),u.length&&(s.totalduration=s.edge-u[0].start),s.driftStartTime=n.driftStartTime,s.driftStart=n.driftStart;var y=s.advancedDateTime;if(s.advanced&&y){var A=s.edge;s.driftStart||(s.driftStartTime=y,s.driftStart=A),s.driftEndTime=y,s.driftEnd=A}else s.driftEndTime=n.driftEndTime,s.driftEnd=n.driftEnd,s.advancedDateTime=n.advancedDateTime;s.requestScheduled===-1&&(s.requestScheduled=n.requestScheduled)}}function el(n,s){var i=s.dateRanges,t=s.recentlyRemovedDateranges,e=E({},n);t&&t.forEach(function(u){delete e[u]});var r=Object.keys(e),a=r.length;return a&&Object.keys(i).forEach(function(u){var l=e[u],d=new La(i[u].attr,l);d.isValid?(e[u]=d,l||(d.tagOrder+=a)):Oe.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+gt(i[u].attr)+'"')}),e}function tl(n,s,i){if(n&&s)for(var t=0,e=0,r=n.length;e<=r;e++){var a=n[e],u=s[e+t];a&&u&&a.index===u.index&&a.fragment.sn===u.fragment.sn?i(a,u):t--}}function rl(n,s,i){for(var t=s.skippedSegments,e=Math.max(n.startSN,s.startSN)-s.startSN,r=(n.fragmentHint?1:0)+(t?s.endSN:Math.min(n.endSN,s.endSN))-s.startSN,a=s.startSN-n.startSN,u=s.fragmentHint?s.fragments.concat(s.fragmentHint):s.fragments,l=n.fragmentHint?n.fragments.concat(n.fragmentHint):n.fragments,d=e;d<=r;d++){var c=l[a+d],p=u[d];if(t&&!p&&c&&(p=s.fragments[d]=c),c&&p){if(i(c,p,d,u),c.url&&c.url!==p.url){s.playlistParsingError=Ua("media sequence mismatch "+p.sn+":",n,s,c,p);return}else if(c.cc!==p.cc){s.playlistParsingError=Ua("discontinuity sequence mismatch ("+c.cc+"!="+p.cc+")",n,s,c,p);return}}}}function Ua(n,s,i,t,e){return new Error(n+" "+e.url+`
18
+ Playlist starting @`+s.startSN+`
19
+ `+s.m3u8+`
19
20
 
20
- Playlist starting @`+Z.startSN+`
21
- `+Z.m3u8)}function _2(X,W,Z){if(Z===void 0)Z=!0;var J=W.startSN+W.skippedSegments-X.startSN,Y=X.fragments,Q=J>=0,G=0;if(Q&&J<Y.length)G=Y[J].start;else if(Q&&W.startSN===X.endSN+1)G=X.fragmentEnd;else if(Q&&Z)G=X.fragmentStart+J*W.levelTargetDuration;else if(!W.skippedSegments&&W.fragmentStart===0)G=X.fragmentStart;else return;G7(W,G)}function G7(X,W){if(W){var Z=X.fragments;for(var J=X.skippedSegments;J<Z.length;J++)Z[J].addStart(W);if(X.fragmentHint)X.fragmentHint.addStart(W)}}function p2(X,W){if(W===void 0)W=1/0;var Z=1000*X.targetduration;if(X.updated){var J=X.fragments,Y=4;if(J.length&&Z*Y>W){var Q=J[J.length-1].duration*1000;if(Q<Z)Z=Q}}else Z/=2;return Math.round(Z)}function W7(X,W,Z){if(!X)return null;var J=X.fragments[W-X.startSN];if(J)return J;if(J=X.fragmentHint,J&&J.sn===W)return J;if(W<X.startSN&&Z&&Z.sn===W)return Z;return null}function f2(X,W,Z){if(!X)return null;return c2(X.partList,W,Z)}function c2(X,W,Z){if(X)for(var J=X.length;J--;){var Y=X[J];if(Y.index===Z&&Y.fragment.sn===W)return Y}return null}function l2(X){X.forEach(function(W,Z){var J;(J=W.details)==null||J.fragments.forEach(function(Y){if(Y.level=Z,Y.initSegment)Y.initSegment.level=Z})})}var K7=300000,q7=function(X){function W(J){var Y=X.call(this,"content-steering",J.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=J,Y.registerListeners(),Y}R(W,X);var Z=W.prototype;return Z.registerListeners=function J(){var Y=this.hls;Y.on(M.MANIFEST_LOADING,this.onManifestLoading,this),Y.on(M.MANIFEST_LOADED,this.onManifestLoaded,this),Y.on(M.MANIFEST_PARSED,this.onManifestParsed,this),Y.on(M.ERROR,this.onError,this)},Z.unregisterListeners=function J(){var Y=this.hls;if(!Y)return;Y.off(M.MANIFEST_LOADING,this.onManifestLoading,this),Y.off(M.MANIFEST_LOADED,this.onManifestLoaded,this),Y.off(M.MANIFEST_PARSED,this.onManifestParsed,this),Y.off(M.ERROR,this.onError,this)},Z.pathways=function J(){return(this.levels||[]).reduce(function(Y,Q){if(Y.indexOf(Q.pathwayId)===-1)Y.push(Q.pathwayId);return Y},[])},Z.startLoad=function J(){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 J(){if(this.started=!1,this.loader)this.loader.destroy(),this.loader=null;this.clearTimeout()},Z.clearTimeout=function J(){if(this.reloadTimer!==-1)self.clearTimeout(this.reloadTimer),this.reloadTimer=-1},Z.destroy=function J(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null},Z.removeLevel=function J(Y){var Q=this.levels;if(Q)this.levels=Q.filter(function(G){return G!==Y})},Z.onManifestLoading=function J(){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 J(Y,Q){var G=Q.contentSteering;if(G===null)return;if(this.pathwayId=G.pathwayId,this.uri=G.uri,this.started)this.startLoad()},Z.onManifestParsed=function J(Y,Q){this.audioTracks=Q.audioTracks,this.subtitleTracks=Q.subtitleTracks},Z.onError=function J(Y,Q){var G=Q.errorAction;if((G==null?void 0:G.action)===U1.SendAlternateToPenaltyBox&&G.flags===h1.MoveAllAlternatesMatchingHost){var q=this.levels,H=this._pathwayPriority,V=this.pathwayId;if(Q.context){var z=Q.context,A=z.groupId,E=z.pathwayId,I=z.type;if(A&&q)V=this.getPathwayForGroupId(A,I,V);else if(E)V=E}if(!(V in this.penalizedPathways))this.penalizedPathways[V]=performance.now();if(!H&&q)H=this.pathways();if(H&&H.length>1)this.updatePathwayPriority(H),G.resolved=this.pathwayId!==V;if(!G.resolved)this.warn("Could not resolve "+Q.details+' ("'+Q.error.message+'") with content-steering for Pathway: '+V+" levels: "+(q?q.length:q)+" priorities: "+O1(H)+" penalized: "+O1(this.penalizedPathways))}},Z.filterParsedLevels=function J(Y){this.levels=Y;var Q=this.getLevelsForPathway(this.pathwayId);if(Q.length===0){var G=Y[0].pathwayId;this.log("No levels found in Pathway "+this.pathwayId+'. Setting initial Pathway to "'+G+'"'),Q=this.getLevelsForPathway(G),this.pathwayId=G}if(Q.length!==Y.length)this.log("Found "+Q.length+"/"+Y.length+' levels in Pathway "'+this.pathwayId+'"');return Q},Z.getLevelsForPathway=function J(Y){if(this.levels===null)return[];return this.levels.filter(function(Q){return Y===Q.pathwayId})},Z.updatePathwayPriority=function J(Y){this._pathwayPriority=Y;var Q,G=this.penalizedPathways,q=performance.now();Object.keys(G).forEach(function(I){if(q-G[I]>K7)delete G[I]});for(var H=0;H<Y.length;H++){var V=Y[H];if(V in G)continue;if(V===this.pathwayId)return;var z=this.hls.nextLoadLevel,A=this.hls.levels[z];if(Q=this.getLevelsForPathway(V),Q.length>0){this.log('Setting Pathway to "'+V+'"'),this.pathwayId=V,l2(Q),this.hls.trigger(M.LEVELS_UPDATED,{levels:Q});var E=this.hls.levels[z];if(A&&E&&this.levels){if(E.attrs["STABLE-VARIANT-ID"]!==A.attrs["STABLE-VARIANT-ID"]&&E.bitrate!==A.bitrate)this.log("Unstable Pathways change from bitrate "+A.bitrate+" to "+E.bitrate);this.hls.nextLoadLevel=z}break}}},Z.getPathwayForGroupId=function J(Y,Q,G){var q=this.getLevelsForPathway(G).concat(this.levels||[]);for(var H=0;H<q.length;H++)if(Q===Z0.AUDIO_TRACK&&q[H].hasAudioGroup(Y)||Q===Z0.SUBTITLE_TRACK&&q[H].hasSubtitleGroup(Y))return q[H].pathwayId;return G},Z.clonePathways=function J(Y){var Q=this,G=this.levels;if(!G)return;var q={},H={};Y.forEach(function(V){var z=V.ID,A=V["BASE-ID"],E=V["URI-REPLACEMENT"];if(G.some(function($){return $.pathwayId===z}))return;var I=Q.getLevelsForPathway(A).map(function($){var L=new Q1($.attrs);L["PATHWAY-ID"]=z;var b=L.AUDIO&&L.AUDIO+"_clone_"+z,C=L.SUBTITLES&&L.SUBTITLES+"_clone_"+z;if(b)q[L.AUDIO]=b,L.AUDIO=b;if(C)H[L.SUBTITLES]=C,L.SUBTITLES=C;var D=n2($.uri,L["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",E),y=new z2({attrs:L,audioCodec:$.audioCodec,bitrate:$.bitrate,height:$.height,name:$.name,url:D,videoCodec:$.videoCodec,width:$.width});if($.audioGroups)for(var S=1;S<$.audioGroups.length;S++)y.addGroupId("audio",$.audioGroups[S]+"_clone_"+z);if($.subtitleGroups)for(var v=1;v<$.subtitleGroups.length;v++)y.addGroupId("text",$.subtitleGroups[v]+"_clone_"+z);return y});G.push.apply(G,I),d2(Q.audioTracks,q,E,z),d2(Q.subtitleTracks,H,E,z)})},Z.loadSteeringManifest=function J(Y){var Q=this,G=this.hls.config,q=G.loader;if(this.loader)this.loader.destroy();this.loader=new q(G);var H;try{H=new self.URL(Y)}catch(L){this.enabled=!1,this.log("Failed to parse Steering Manifest URI: "+Y);return}if(H.protocol!=="data:"){var V=(this.hls.bandwidthEstimate||G.abrEwmaDefaultEstimate)|0;H.searchParams.set("_HLS_pathway",this.pathwayId),H.searchParams.set("_HLS_throughput",""+V)}var z={responseType:"json",url:H.href},A=G.steeringManifestLoadPolicy.default,E=A.errorRetry||A.timeoutRetry||{},I={loadPolicy:A,timeout:A.maxLoadTimeMs,maxRetry:E.maxNumRetry||0,retryDelay:E.retryDelayMs||0,maxRetryDelay:E.maxRetryDelayMs||0},$={onSuccess:function L(b,C,D,y){Q.log('Loaded steering manifest: "'+H+'"');var S=b.data;if((S==null?void 0:S.VERSION)!==1){Q.log("Steering VERSION "+S.VERSION+" not supported!");return}Q.updated=performance.now(),Q.timeToLoad=S.TTL;var v=S["RELOAD-URI"],p=S["PATHWAY-CLONES"],g=S["PATHWAY-PRIORITY"];if(v)try{Q.uri=new self.URL(v,H).href}catch(r){Q.enabled=!1,Q.log("Failed to parse Steering Manifest RELOAD-URI: "+v);return}if(Q.scheduleRefresh(Q.uri||D.url),p)Q.clonePathways(p);var m={steeringManifest:S,url:H.toString()};if(Q.hls.trigger(M.STEERING_MANIFEST_LOADED,m),g)Q.updatePathwayPriority(g)},onError:function L(b,C,D,y){if(Q.log("Error loading steering manifest: "+b.code+" "+b.text+" ("+C.url+")"),Q.stopLoad(),b.code===410){Q.enabled=!1,Q.log("Steering manifest "+C.url+" no longer available");return}var S=Q.timeToLoad*1000;if(b.code===429){var v=Q.loader;if(typeof(v==null?void 0:v.getResponseHeader)==="function"){var p=v.getResponseHeader("Retry-After");if(p)S=parseFloat(p)*1000}Q.log("Steering manifest "+C.url+" rate limited");return}Q.scheduleRefresh(Q.uri||C.url,S)},onTimeout:function L(b,C,D){Q.log("Timeout loading steering manifest ("+C.url+")"),Q.scheduleRefresh(Q.uri||C.url)}};this.log("Requesting steering manifest: "+H),this.loader.load(z,I,$)},Z.scheduleRefresh=function J(Y,Q){var G=this;if(Q===void 0)Q=this.timeToLoad*1000;this.clearTimeout(),this.reloadTimer=self.setTimeout(function(){var q,H=(q=G.hls)==null?void 0:q.media;if(H&&!H.ended){G.loadSteeringManifest(Y);return}G.scheduleRefresh(Y,G.timeToLoad*1000)},Q)},N(W,[{key:"pathwayPriority",get:function J(){return this._pathwayPriority},set:function J(Y){this.updatePathwayPriority(Y)}}])}(d0);function d2(X,W,Z,J){if(!X)return;Object.keys(W).forEach(function(Y){var Q=X.filter(function(G){return G.groupId===Y}).map(function(G){var q=B({},G);return q.details=void 0,q.attrs=new Q1(q.attrs),q.url=q.attrs.URI=n2(G.url,G.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",Z),q.groupId=q.attrs["GROUP-ID"]=W[Y],q.attrs["PATHWAY-ID"]=J,q});X.push.apply(X,Q)})}function n2(X,W,Z,J){var{HOST:Y,PARAMS:Q}=J,G=J[Z],q;if(W){if(q=G==null?void 0:G[W],q)X=q}var H=new self.URL(X);if(Y&&!q)H.host=Y;if(Q)Object.keys(Q).sort().forEach(function(V){if(V)H.searchParams.set(V,Q[V])});return H.href}var H7=function(){function X(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 W=X.prototype;return W.setStreamController=function Z(J){this.streamController=J},W.registerListeners=function Z(){this.hls.on(M.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(M.MEDIA_DETACHING,this.onMediaDetaching,this)},W.unregisterListeners=function Z(){this.hls.off(M.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(M.MEDIA_DETACHING,this.onMediaDetaching,this)},W.destroy=function Z(){if(this.timer)clearInterval(this.timer);this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},W.onMediaAttaching=function Z(J,Y){var Q=this.hls.config;if(Q.capLevelOnFPSDrop){var G=Y.media instanceof self.HTMLVideoElement?Y.media:null;if(this.media=G,G&&typeof G.getVideoPlaybackQuality==="function")this.isVideoPlaybackQualityAvailable=!0;self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),Q.fpsDroppedMonitoringPeriod)}},W.onMediaDetaching=function Z(){this.media=null},W.checkFPS=function Z(J,Y,Q){var G=performance.now();if(Y){if(this.lastTime){var q=G-this.lastTime,H=Q-this.lastDroppedFrames,V=Y-this.lastDecodedFrames,z=1000*H/q,A=this.hls;if(A.trigger(M.FPS_DROP,{currentDropped:H,currentDecoded:V,totalDroppedFrames:Q}),z>0){if(H>A.config.fpsDroppedMonitoringThreshold*V){var E=A.currentLevel;if(A.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+E),E>0&&(A.autoLevelCapping===-1||A.autoLevelCapping>=E))E=E-1,A.trigger(M.FPS_DROP_LEVEL_CAPPING,{level:E,droppedLevel:A.currentLevel}),A.autoLevelCapping=E,this.streamController.nextLevelSwitch()}}}this.lastTime=G,this.lastDroppedFrames=Q,this.lastDecodedFrames=Y}},W.checkFPSInterval=function Z(){var J=this.media;if(J)if(this.isVideoPlaybackQualityAvailable){var Y=J.getVideoPlaybackQuality();this.checkFPS(J,Y.totalVideoFrames,Y.droppedVideoFrames)}else this.checkFPS(J,J.webkitDecodedFrameCount,J.webkitDroppedFrameCount)},X}(),N7=function(){function X(){this.chunks=[],this.dataLength=0}var W=X.prototype;return W.push=function Z(J){this.chunks.push(J),this.dataLength+=J.length},W.flush=function Z(){var J=this.chunks,Y=this.dataLength,Q;if(!J.length)return new Uint8Array(0);else if(J.length===1)Q=J[0];else Q=U7(J,Y);return this.reset(),Q},W.reset=function Z(){this.chunks.length=0,this.dataLength=0},X}();function U7(X,W){var Z=new Uint8Array(W),J=0;for(var Y=0;Y<X.length;Y++){var Q=X[Y];Z.set(Q,J),J+=Q.length}return Z}function o2(X,W){if(W+10<=X.length){if(X[W]===51&&X[W+1]===68&&X[W+2]===73){if(X[W+3]<255&&X[W+4]<255){if(X[W+6]<128&&X[W+7]<128&&X[W+8]<128&&X[W+9]<128)return!0}}}return!1}function aJ(X,W){if(W+10<=X.length){if(X[W]===73&&X[W+1]===68&&X[W+2]===51){if(X[W+3]<255&&X[W+4]<255){if(X[W+6]<128&&X[W+7]<128&&X[W+8]<128&&X[W+9]<128)return!0}}}return!1}function UJ(X,W){var Z=0;return Z=(X[W]&127)<<21,Z|=(X[W+1]&127)<<14,Z|=(X[W+2]&127)<<7,Z|=X[W+3]&127,Z}function VJ(X,W){var Z=W,J=0;while(aJ(X,W)){J+=10;var Y=UJ(X,W+6);if(J+=Y,o2(X,W+10))J+=10;W+=J}if(J>0)return X.subarray(Z,Z+J);return}function V7(X,W,Z,J){var Y=[96000,88200,64000,48000,44100,32000,24000,22050,16000,12000,11025,8000,7350],Q=W[Z+2],G=Q>>2&15;if(G>12){var q=new Error("invalid ADTS sampling index:"+G);X.emit(M.ERROR,M.ERROR,{type:n.MEDIA_ERROR,details:h.FRAG_PARSING_ERROR,fatal:!0,error:q,reason:q.message});return}var H=(Q>>6&3)+1,V=W[Z+3]>>6&3|(Q&1)<<2,z="mp4a.40."+H,A=Y[G],E=G;if(H===5||H===29)E-=3;var I=[H<<3|(E&14)>>1,(E&1)<<7|V<<3];return v0.log("manifest codec:"+J+", parsed codec:"+z+", channels:"+V+", rate:"+A+" (ADTS object type:"+H+" sampling index:"+G+")"),{config:I,samplerate:A,channelCount:V,codec:z,parsedCodec:z,manifestCodec:J}}function i2(X,W){return X[W]===255&&(X[W+1]&246)===240}function s2(X,W){return X[W+1]&1?7:9}function tJ(X,W){return(X[W+3]&3)<<11|X[W+4]<<3|(X[W+5]&224)>>>5}function z7(X,W){return W+5<X.length}function zJ(X,W){return W+1<X.length&&i2(X,W)}function j7(X,W){return z7(X,W)&&i2(X,W)&&tJ(X,W)<=X.length-W}function A7(X,W){if(zJ(X,W)){var Z=s2(X,W);if(W+Z>=X.length)return!1;var J=tJ(X,W);if(J<=Z)return!1;var Y=W+J;return Y===X.length||zJ(X,Y)}return!1}function r2(X,W,Z,J,Y){if(!X.samplerate){var Q=V7(W,Z,J,Y);if(!Q)return;B(X,Q)}}function a2(X){return 92160000/X}function O7(X,W){var Z=s2(X,W);if(W+Z<=X.length){var J=tJ(X,W)-Z;if(J>0)return{headerLength:Z,frameLength:J}}}function t2(X,W,Z,J,Y){var Q=a2(X.samplerate),G=J+Y*Q,q=O7(W,Z),H;if(q){var{frameLength:V,headerLength:z}=q,A=z+V,E=Math.max(0,Z+A-W.length);if(E)H=new Uint8Array(A-z),H.set(W.subarray(Z+z,W.length),0);else H=W.subarray(Z+z,Z+A);var I={unit:H,pts:G};if(!E)X.samples.push(I);return{sample:I,length:A,missing:E}}var $=W.length-Z;H=new Uint8Array($),H.set(W.subarray(Z,W.length),0);var L={unit:H,pts:G};return{sample:L,length:$,missing:-1}}function F7(X,W){return aJ(X,W)&&UJ(X,W+6)+10<=X.length-W}function E7(X){if(X.size<2)return;var W=x1(X.data,!0),Z=new Uint8Array(X.data.subarray(W.length+1));return{key:X.type,info:W,data:Z.buffer}}function B7(X){if(X.size<2)return;if(X.type==="TXXX"){var W=1,Z=x1(X.data.subarray(W),!0);W+=Z.length+1;var J=x1(X.data.subarray(W));return{key:X.type,info:Z,data:J}}var Y=x1(X.data.subarray(1));return{key:X.type,info:"",data:Y}}function w7(X){if(X.type==="WXXX"){if(X.size<2)return;var W=1,Z=x1(X.data.subarray(W),!0);W+=Z.length+1;var J=x1(X.data.subarray(W));return{key:X.type,info:Z,data:J}}var Y=x1(X.data);return{key:X.type,info:"",data:Y}}function R7(X){if(X instanceof ArrayBuffer)return X;else{if(X.byteOffset==0&&X.byteLength==X.buffer.byteLength)return X.buffer;return new Uint8Array(X).buffer}}function eJ(X,W,Z){if(W===void 0)W=0;if(Z===void 0)Z=1/0;return $7(X,W,Z,Uint8Array)}function $7(X,W,Z,J){var Y=I7(X),Q=1;if("BYTES_PER_ELEMENT"in J)Q=J.BYTES_PER_ELEMENT;var G=L7(X)?X.byteOffset:0,q=(G+X.byteLength)/Q,H=(G+W)/Q,V=Math.floor(Math.max(0,Math.min(H,q))),z=Math.floor(Math.min(V+Math.max(Z,0),q));return new J(Y,V,z-V)}function I7(X){if(X instanceof ArrayBuffer)return X;else return X.buffer}function L7(X){return X&&X.buffer instanceof ArrayBuffer&&X.byteLength!==void 0&&X.byteOffset!==void 0}function b7(X){var W={key:X.type,description:"",data:"",mimeType:null,pictureType:null},Z=3;if(X.size<2)return;if(X.data[0]!==Z){console.log("Ignore frame with unrecognized character encoding");return}var J=X.data.subarray(1).indexOf(0);if(J===-1)return;var Y=x1(eJ(X.data,1,J)),Q=X.data[2+J],G=X.data.subarray(3+J).indexOf(0);if(G===-1)return;var q=x1(eJ(X.data,3+J,G)),H;if(Y==="-->")H=x1(eJ(X.data,4+J+G));else H=R7(X.data.subarray(4+J+G));return W.mimeType=Y,W.pictureType=Q,W.description=q,W.data=H,W}function M7(X){if(X.type==="PRIV")return E7(X);else if(X.type[0]==="W")return w7(X);else if(X.type==="APIC")return b7(X);return B7(X)}function C7(X){var W=String.fromCharCode(X[0],X[1],X[2],X[3]),Z=UJ(X,4),J=10;return{type:W,size:Z,data:X.subarray(J,J+Z)}}var jJ=10,D7=10;function e2(X){var W=0,Z=[];while(aJ(X,W)){var J=UJ(X,W+6);if(X[W+5]>>6&1)W+=jJ;W+=jJ;var Y=W+J;while(W+D7<Y){var Q=C7(X.subarray(W)),G=M7(Q);if(G)Z.push(G);W+=Q.size+jJ}if(o2(X,W))W+=jJ}return Z}function YZ(X){return X&&X.key==="PRIV"&&X.info==="com.apple.streaming.transportStreamTimestamp"}function S7(X){if(X.data.byteLength===8){var W=new Uint8Array(X.data),Z=W[3]&1,J=(W[4]<<23)+(W[5]<<15)+(W[6]<<7)+W[7];if(J/=45,Z)J+=47721858.84;return Math.round(J)}return}function JZ(X){var W=e2(X);for(var Z=0;Z<W.length;Z++){var J=W[Z];if(YZ(J))return S7(J)}return}var b1=function(X){return X.audioId3="org.id3",X.dateRange="com.apple.quicktime.HLS",X.emsg="https://aomedia.org/emsg/ID3",X.misbklv="urn:misb:KLV:bin:1910.1",X}({});function i1(X,W){if(X===void 0)X="";if(W===void 0)W=90000;return{type:X,id:-1,pid:-1,inputTimeScale:W,sequenceNumber:-1,samples:[],dropped:0}}var QZ=function(){function X(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var W=X.prototype;return W.resetInitSegment=function Z(J,Y,Q,G){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:90000,sequenceNumber:0,samples:[],dropped:0}},W.resetTimeStamp=function Z(J){this.initPTS=J,this.resetContiguity()},W.resetContiguity=function Z(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},W.canParse=function Z(J,Y){return!1},W.appendFrame=function Z(J,Y,Q){},W.demux=function Z(J,Y){if(this.cachedData)J=v1(this.cachedData,J),this.cachedData=null;var Q=VJ(J,0),G=Q?Q.length:0,q,H=this._audioTrack,V=this._id3Track,z=Q?JZ(Q):void 0,A=J.length;if(this.basePTS===null||this.frameIndex===0&&T(z))this.basePTS=P7(z,Y,this.initPTS),this.lastPTS=this.basePTS;if(this.lastPTS===null)this.lastPTS=this.basePTS;if(Q&&Q.length>0)V.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:Q,type:b1.audioId3,duration:Number.POSITIVE_INFINITY});while(G<A){if(this.canParse(J,G)){var E=this.appendFrame(H,J,G);if(E)this.frameIndex++,this.lastPTS=E.sample.pts,G+=E.length,q=G;else G=A}else if(F7(J,G))Q=VJ(J,G),V.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:Q,type:b1.audioId3,duration:Number.POSITIVE_INFINITY}),G+=Q.length,q=G;else G++;if(G===A&&q!==A){var I=J.slice(q);if(this.cachedData)this.cachedData=v1(this.cachedData,I);else this.cachedData=I}}return{audioTrack:H,videoTrack:i1(),id3Track:V,textTrack:i1()}},W.demuxSampleAes=function Z(J,Y,Q){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},W.flush=function Z(J){var Y=this.cachedData;if(Y)this.cachedData=null,this.demux(Y,0);return{audioTrack:this._audioTrack,videoTrack:i1(),id3Track:this._id3Track,textTrack:i1()}},W.destroy=function Z(){this.cachedData=null,this._audioTrack=this._id3Track=void 0},X}(),P7=function X(W,Z,J){if(T(W))return W*90;var Y=J?J.baseTime*90000/J.timescale:0;return Z*90000+Y},AJ=null,y7=[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],T7=[44100,48000,32000,22050,24000,16000,11025,12000,8000],x7=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],v7=[0,1,1,4];function ZZ(X,W,Z,J,Y){if(Z+24>W.length)return;var Q=XZ(W,Z);if(Q&&Z+Q.frameLength<=W.length){var G=Q.samplesPerFrame*90000/Q.sampleRate,q=J+Y*G,H={unit:W.subarray(Z,Z+Q.frameLength),pts:q,dts:q};return X.config=[],X.channelCount=Q.channelCount,X.samplerate=Q.sampleRate,X.samples.push(H),{sample:H,length:Q.frameLength,missing:0}}}function XZ(X,W){var Z=X[W+1]>>3&3,J=X[W+1]>>1&3,Y=X[W+2]>>4&15,Q=X[W+2]>>2&3;if(Z!==1&&Y!==0&&Y!==15&&Q!==3){var G=X[W+2]>>1&1,q=X[W+3]>>6,H=Z===3?3-J:J===3?3:4,V=y7[H*14+Y-1]*1000,z=Z===3?0:Z===2?1:2,A=T7[z*3+Q],E=q===3?1:2,I=x7[Z][J],$=v7[J],L=I*8*$,b=Math.floor(I*V/A+G)*$;if(AJ===null){var C=navigator.userAgent||"",D=C.match(/Chrome\/(\d+)/i);AJ=D?parseInt(D[1]):0}var y=!!AJ&&AJ<=87;if(y&&J===2&&V>=224000&&q===0)X[W+3]=X[W+3]|128;return{sampleRate:A,channelCount:E,frameLength:b,samplesPerFrame:L}}}function YQ(X,W){return X[W]===255&&(X[W+1]&224)===224&&(X[W+1]&6)!==0}function GZ(X,W){return W+1<X.length&&YQ(X,W)}function h7(X,W){var Z=4;return YQ(X,W)&&Z<=X.length-W}function WZ(X,W){if(W+1<X.length&&YQ(X,W)){var Z=4,J=XZ(X,W),Y=Z;if(J!=null&&J.frameLength)Y=J.frameLength;var Q=W+Y;return Q===X.length||GZ(X,Q)}return!1}var k7=function(X){function W(J,Y){var Q=X.call(this)||this;return Q.observer=void 0,Q.config=void 0,Q.observer=J,Q.config=Y,Q}R(W,X);var Z=W.prototype;return Z.resetInitSegment=function J(Y,Q,G,q){X.prototype.resetInitSegment.call(this,Y,Q,G,q),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:Q,duration:q,inputTimeScale:90000,dropped:0}},W.probe=function J(Y,Q){if(!Y)return!1;var G=VJ(Y,0),q=(G==null?void 0:G.length)||0;if(WZ(Y,q))return!1;for(var H=Y.length;q<H;q++)if(A7(Y,q))return Q.log("ADTS sync word found !"),!0;return!1},Z.canParse=function J(Y,Q){return j7(Y,Q)},Z.appendFrame=function J(Y,Q,G){r2(Y,this.observer,Q,G,Y.manifestCodec);var q=t2(Y,Q,G,this.basePTS,this.frameIndex);if(q&&q.missing===0)return q},W}(QZ),g7=function X(W,Z){var J=0,Y=5;Z+=Y;var Q=new Uint32Array(1),G=new Uint32Array(1),q=new Uint8Array(1);while(Y>0){q[0]=W[Z];var H=Math.min(Y,8),V=8-H;G[0]=4278190080>>>24+V<<V,Q[0]=(q[0]&G[0])>>V,J=!J?Q[0]:J<<H|Q[0],Z+=1,Y-=H}return J},u7=function(X){function W(){return X.apply(this,arguments)||this}R(W,X);var Z=W.prototype;return Z.resetInitSegment=function J(Y,Q,G,q){X.prototype.resetInitSegment.call(this,Y,Q,G,q),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:Q,duration:q,inputTimeScale:90000,dropped:0}},W.probe=function J(Y){if(!Y)return!1;var Q=VJ(Y,0),G=(Q==null?void 0:Q.length)||0;if(Q&&Y[G]===11&&Y[G+1]===119&&JZ(Q)!==void 0&&g7(Y,G)<=16)return!1;for(var q=Y.length;G<q;G++)if(WZ(Y,G))return v0.log("MPEG Audio sync word found !"),!0;return!1},Z.canParse=function J(Y,Q){return h7(Y,Q)},Z.appendFrame=function J(Y,Q,G){if(this.basePTS===null)return;return ZZ(Y,Q,G,this.basePTS,this.frameIndex)},W}(QZ),m7=function(){function X(Z,J,Y){this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=Z,this.aesIV=J,this.aesMode=Y}var W=X.prototype;return W.decrypt=function Z(J,Y){switch(this.aesMode){case GY.cbc:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},Y,J);case GY.ctr:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},Y,J);default:throw new Error("[AESCrypto] invalid aes mode "+this.aesMode)}},X}();function _7(X){var W=X.byteLength,Z=W&&new DataView(X.buffer).getUint8(W-1);if(Z)return X.slice(0,W-Z);return X}var p7=function(){function X(){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 W=X.prototype;return W.uint8ArrayToUint32Array_=function Z(J){var Y=new DataView(J),Q=new Uint32Array(4);for(var G=0;G<4;G++)Q[G]=Y.getUint32(G*4);return Q},W.initTable=function Z(){var J=this.sBox,Y=this.invSBox,Q=this.subMix,G=Q[0],q=Q[1],H=Q[2],V=Q[3],z=this.invSubMix,A=z[0],E=z[1],I=z[2],$=z[3],L=new Uint32Array(256),b=0,C=0,D=0;for(D=0;D<256;D++)if(D<128)L[D]=D<<1;else L[D]=D<<1^283;for(D=0;D<256;D++){var y=C^C<<1^C<<2^C<<3^C<<4;y=y>>>8^y&255^99,J[b]=y,Y[y]=b;var S=L[b],v=L[S],p=L[v],g=L[y]*257^y*16843008;if(G[b]=g<<24|g>>>8,q[b]=g<<16|g>>>16,H[b]=g<<8|g>>>24,V[b]=g,g=p*16843009^v*65537^S*257^b*16843008,A[y]=g<<24|g>>>8,E[y]=g<<16|g>>>16,I[y]=g<<8|g>>>24,$[y]=g,!b)b=C=1;else b=S^L[L[L[p^S]]],C^=L[L[C]]}},W.expandKey=function Z(J){var Y=this.uint8ArrayToUint32Array_(J),Q=!0,G=0;while(G<Y.length&&Q)Q=Y[G]===this.key[G],G++;if(Q)return;this.key=Y;var q=this.keySize=Y.length;if(q!==4&&q!==6&&q!==8)throw new Error("Invalid aes key size="+q);var H=this.ksRows=(q+6+1)*4,V,z,A=this.keySchedule=new Uint32Array(H),E=this.invKeySchedule=new Uint32Array(H),I=this.sBox,$=this.rcon,L=this.invSubMix,b=L[0],C=L[1],D=L[2],y=L[3],S,v;for(V=0;V<H;V++){if(V<q){S=A[V]=Y[V];continue}if(v=S,V%q===0)v=v<<8|v>>>24,v=I[v>>>24]<<24|I[v>>>16&255]<<16|I[v>>>8&255]<<8|I[v&255],v^=$[V/q|0]<<24;else if(q>6&&V%q===4)v=I[v>>>24]<<24|I[v>>>16&255]<<16|I[v>>>8&255]<<8|I[v&255];A[V]=S=(A[V-q]^v)>>>0}for(z=0;z<H;z++){if(V=H-z,z&3)v=A[V];else v=A[V-4];if(z<4||V<=4)E[z]=v;else E[z]=b[I[v>>>24]]^C[I[v>>>16&255]]^D[I[v>>>8&255]]^y[I[v&255]];E[z]=E[z]>>>0}},W.networkToHostOrderSwap=function Z(J){return J<<24|(J&65280)<<8|(J&16711680)>>8|J>>>24},W.decrypt=function Z(J,Y,Q){var G=this.keySize+6,q=this.invKeySchedule,H=this.invSBox,V=this.invSubMix,z=V[0],A=V[1],E=V[2],I=V[3],$=this.uint8ArrayToUint32Array_(Q),L=$[0],b=$[1],C=$[2],D=$[3],y=new Int32Array(J),S=new Int32Array(y.length),v,p,g,m,r,o,c,d,e,H0,Q0,J0,N0,V0,j0=this.networkToHostOrderSwap;while(Y<y.length){e=j0(y[Y]),H0=j0(y[Y+1]),Q0=j0(y[Y+2]),J0=j0(y[Y+3]),r=e^q[0],o=J0^q[1],c=Q0^q[2],d=H0^q[3],N0=4;for(V0=1;V0<G;V0++)v=z[r>>>24]^A[o>>16&255]^E[c>>8&255]^I[d&255]^q[N0],p=z[o>>>24]^A[c>>16&255]^E[d>>8&255]^I[r&255]^q[N0+1],g=z[c>>>24]^A[d>>16&255]^E[r>>8&255]^I[o&255]^q[N0+2],m=z[d>>>24]^A[r>>16&255]^E[o>>8&255]^I[c&255]^q[N0+3],r=v,o=p,c=g,d=m,N0=N0+4;v=H[r>>>24]<<24^H[o>>16&255]<<16^H[c>>8&255]<<8^H[d&255]^q[N0],p=H[o>>>24]<<24^H[c>>16&255]<<16^H[d>>8&255]<<8^H[r&255]^q[N0+1],g=H[c>>>24]<<24^H[d>>16&255]<<16^H[r>>8&255]<<8^H[o&255]^q[N0+2],m=H[d>>>24]<<24^H[r>>16&255]<<16^H[o>>8&255]<<8^H[c&255]^q[N0+3],S[Y]=j0(v^L),S[Y+1]=j0(m^b),S[Y+2]=j0(g^C),S[Y+3]=j0(p^D),L=e,b=H0,C=Q0,D=J0,Y=Y+4}return S.buffer},X}(),f7=function(){function X(Z,J,Y){this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=Z,this.key=J,this.aesMode=Y}var W=X.prototype;return W.expandKey=function Z(){var J=c7(this.aesMode);return this.subtle.importKey("raw",this.key,{name:J},!1,["encrypt","decrypt"])},X}();function c7(X){switch(X){case GY.cbc:return"AES-CBC";case GY.ctr:return"AES-CTR";default:throw new Error("[FastAESKey] invalid aes mode "+X)}}var l7=16,JQ=function(){function X(Z,J){var Y=J===void 0?{}:J,Q=Y.removePKCS7Padding,G=Q===void 0?!0:Q;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=G,G)try{var q=self.crypto;if(q)this.subtle=q.subtle||q.webkitSubtle}catch(H){}this.useSoftware=!this.subtle}var W=X.prototype;return W.destroy=function Z(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},W.isSync=function Z(){return this.useSoftware},W.flush=function Z(){var J=this.currentResult,Y=this.remainderData;if(!J||Y)return this.reset(),null;var Q=new Uint8Array(J);if(this.reset(),this.removePKCS7Padding)return _7(Q);return Q},W.reset=function Z(){if(this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter)this.softwareDecrypter=null},W.decrypt=function Z(J,Y,Q,G){var q=this;if(this.useSoftware)return new Promise(function(H,V){var z=ArrayBuffer.isView(J)?J:new Uint8Array(J);q.softwareDecrypt(z,Y,Q,G);var A=q.flush();if(A)H(A.buffer);else V(new Error("[softwareDecrypt] Failed to decrypt data"))});return this.webCryptoDecrypt(new Uint8Array(J),Y,Q,G)},W.softwareDecrypt=function Z(J,Y,Q,G){var q=this.currentIV,H=this.currentResult,V=this.remainderData;if(G!==GY.cbc||Y.byteLength!==16)return v0.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;if(this.logOnce("JS AES decrypt"),V)J=v1(V,J),this.remainderData=null;var z=this.getValidChunk(J);if(!z.length)return null;if(q)Q=q;var A=this.softwareDecrypter;if(!A)A=this.softwareDecrypter=new p7;A.expandKey(Y);var E=H;if(this.currentResult=A.decrypt(z.buffer,0,Q),this.currentIV=z.slice(-16).buffer,!E)return null;return E},W.webCryptoDecrypt=function Z(J,Y,Q,G){var q=this;if(this.key!==Y||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(J,Y,Q,G));this.key=Y,this.fastAesKey=new f7(this.subtle,Y,G)}return this.fastAesKey.expandKey().then(function(H){if(!q.subtle)return Promise.reject(new Error("web crypto not initialized"));q.logOnce("WebCrypto AES decrypt");var V=new m7(q.subtle,new Uint8Array(Q),G);return V.decrypt(J.buffer,H)}).catch(function(H){return v0.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+H.name+": "+H.message),q.onWebCryptoError(J,Y,Q,G)})},W.onWebCryptoError=function Z(J,Y,Q,G){var q=this.enableSoftwareAES;if(q){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(J,Y,Q,G);var H=this.flush();if(H)return H.buffer}throw new Error("WebCrypto"+(q?" and softwareDecrypt":"")+": failed to decrypt data")},W.getValidChunk=function Z(J){var Y=J,Q=J.length-J.length%l7;if(Q!==J.length)Y=J.slice(0,Q),this.remainderData=J.slice(Q);return Y},W.logOnce=function Z(J){if(!this.logEnabled)return;v0.log("[decrypter]: "+J),this.logEnabled=!1},X}(),d7=/\/emsg[-/]ID3/i,n7=function(){function X(Z,J){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=J}var W=X.prototype;return W.resetTimeStamp=function Z(){},W.resetInitSegment=function Z(J,Y,Q,G){var q=this.videoTrack=i1("video",1),H=this.audioTrack=i1("audio",1),V=this.txtTrack=i1("text",1);if(this.id3Track=i1("id3",1),this.timeOffset=0,!(J!=null&&J.byteLength))return;var z=J2(J);if(z.video){var A=z.video,E=A.id,I=A.timescale,$=A.codec,L=A.supplemental;q.id=E,q.timescale=V.timescale=I,q.codec=$,q.supplemental=L}if(z.audio){var b=z.audio,C=b.id,D=b.timescale,y=b.codec;H.id=C,H.timescale=D,H.codec=y}V.id=aQ.text,q.sampleDuration=0,q.duration=H.duration=G},W.resetContiguity=function Z(){this.remainderData=null},X.probe=function Z(J){return GX(J)},W.demux=function Z(J,Y){this.timeOffset=Y;var Q=J,G=this.videoTrack,q=this.txtTrack;if(this.config.progressive){if(this.remainderData)Q=v1(this.remainderData,J);var H=jX(Q);this.remainderData=H.remainder,G.samples=H.valid||new Uint8Array}else G.samples=Q;var V=this.extractID3Track(G,Y);return q.samples=Q2(Y,G),{videoTrack:G,audioTrack:this.audioTrack,id3Track:V,textTrack:this.txtTrack}},W.flush=function Z(){var J=this.timeOffset,Y=this.videoTrack,Q=this.txtTrack;Y.samples=this.remainderData||new Uint8Array,this.remainderData=null;var G=this.extractID3Track(Y,this.timeOffset);return Q.samples=Q2(J,Y),{videoTrack:Y,audioTrack:i1(),id3Track:G,textTrack:i1()}},W.extractID3Track=function Z(J,Y){var Q=this,G=this.id3Track;if(J.samples.length){var q=$0(J.samples,["emsg"]);if(q)q.forEach(function(H){var V=OX(H);if(d7.test(V.schemeIdUri)){var z=KZ(V,Y),A=V.eventDuration===4294967295?Number.POSITIVE_INFINITY:V.eventDuration/V.timeScale;if(A<=0.001)A=Number.POSITIVE_INFINITY;var E=V.payload;G.samples.push({data:E,len:E.byteLength,dts:z,pts:z,type:b1.emsg,duration:A})}else if(Q.config.enableEmsgKLVMetadata&&V.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){var I=KZ(V,Y);G.samples.push({data:V.payload,len:V.payload.byteLength,dts:I,pts:I,type:b1.misbklv,duration:Number.POSITIVE_INFINITY})}})}return G},W.demuxSampleAes=function Z(J,Y,Q){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},W.destroy=function Z(){this.config=null,this.remainderData=null,this.videoTrack=this.audioTrack=this.id3Track=this.txtTrack=void 0},X}();function KZ(X,W){return T(X.presentationTime)?X.presentationTime/X.timeScale:W+X.presentationTimeDelta/X.timeScale}var o7=function(){function X(Z,J,Y){this.keyData=void 0,this.decrypter=void 0,this.keyData=Y,this.decrypter=new JQ(J,{removePKCS7Padding:!1})}var W=X.prototype;return W.decryptBuffer=function Z(J){return this.decrypter.decrypt(J,this.keyData.key.buffer,this.keyData.iv.buffer,GY.cbc)},W.decryptAacSample=function Z(J,Y,Q){var G=this,q=J[Y].unit;if(q.length<=16)return;var H=q.subarray(16,q.length-q.length%16),V=H.buffer.slice(H.byteOffset,H.byteOffset+H.length);this.decryptBuffer(V).then(function(z){var A=new Uint8Array(z);if(q.set(A,16),!G.decrypter.isSync())G.decryptAacSamples(J,Y+1,Q)})},W.decryptAacSamples=function Z(J,Y,Q){for(;;Y++){if(Y>=J.length){Q();return}if(J[Y].unit.length<32)continue;if(this.decryptAacSample(J,Y,Q),!this.decrypter.isSync())return}},W.getAvcEncryptedData=function Z(J){var Y=Math.floor((J.length-48)/160)*16+16,Q=new Int8Array(Y),G=0;for(var q=32;q<J.length-16;q+=160,G+=16)Q.set(J.subarray(q,q+16),G);return Q},W.getAvcDecryptedUnit=function Z(J,Y){var Q=new Uint8Array(Y),G=0;for(var q=32;q<J.length-16;q+=160,G+=16)J.set(Q.subarray(G,G+16),q);return J},W.decryptAvcSample=function Z(J,Y,Q,G,q){var H=this,V=X2(q.data),z=this.getAvcEncryptedData(V);this.decryptBuffer(z.buffer).then(function(A){if(q.data=H.getAvcDecryptedUnit(V,A),!H.decrypter.isSync())H.decryptAvcSamples(J,Y,Q+1,G)})},W.decryptAvcSamples=function Z(J,Y,Q,G){if(J instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;Y++,Q=0){if(Y>=J.length){G();return}var q=J[Y].units;for(;;Q++){if(Q>=q.length)break;var H=q[Q];if(H.data.length<=48||H.type!==1&&H.type!==5)continue;if(this.decryptAvcSample(J,Y,Q,G,H),!this.decrypter.isSync())return}}},X}(),i7=function(){function X(){this.VideoSample=null}var W=X.prototype;return W.createVideoSample=function Z(J,Y,Q){return{key:J,frame:!1,pts:Y,dts:Q,units:[],length:0}},W.getLastNalUnit=function Z(J){var Y,Q=this.VideoSample,G;if(!Q||Q.units.length===0)Q=J[J.length-1];if((Y=Q)!=null&&Y.units){var q=Q.units;G=q[q.length-1]}return G},W.pushAccessUnit=function Z(J,Y){if(J.units.length&&J.frame){if(J.pts===void 0){var Q=Y.samples,G=Q.length;if(G){var q=Q[G-1];J.pts=q.pts,J.dts=q.dts}else{Y.dropped++;return}}Y.samples.push(J)}},W.parseNALu=function Z(J,Y,Q){var G=Y.byteLength,q=J.naluState||0,H=q,V=[],z=0,A,E,I,$=-1,L=0;if(q===-1)$=0,L=this.getNALuType(Y,0),q=0,z=1;while(z<G){if(A=Y[z++],!q){q=A?0:1;continue}if(q===1){q=A?0:2;continue}if(!A)q=3;else if(A===1){if(E=z-q-1,$>=0){var b={data:Y.subarray($,E),type:L};V.push(b)}else{var C=this.getLastNalUnit(J.samples);if(C){if(H&&z<=4-H){if(C.state)C.data=C.data.subarray(0,C.data.byteLength-H)}if(E>0)C.data=v1(C.data,Y.subarray(0,E)),C.state=0}}if(z<G)I=this.getNALuType(Y,z),$=z,L=I,q=0;else q=-1}else q=0}if($>=0&&q>=0){var D={data:Y.subarray($,G),type:L,state:q};V.push(D)}if(V.length===0){var y=this.getLastNalUnit(J.samples);if(y)y.data=v1(y.data,Y)}return J.naluState=q,V},X}(),qZ=function(){function X(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 W=X.prototype;return W.loadWord=function Z(){var J=this.data,Y=this.bytesAvailable,Q=J.byteLength-Y,G=new Uint8Array(4),q=Math.min(4,Y);if(q===0)throw new Error("no bytes available");G.set(J.subarray(Q,Q+q)),this.word=new DataView(G.buffer).getUint32(0),this.bitsAvailable=q*8,this.bytesAvailable-=q},W.skipBits=function Z(J){var Y;if(J=Math.min(J,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>J)this.word<<=J,this.bitsAvailable-=J;else J-=this.bitsAvailable,Y=J>>3,J-=Y<<3,this.bytesAvailable-=Y,this.loadWord(),this.word<<=J,this.bitsAvailable-=J},W.readBits=function Z(J){var Y=Math.min(this.bitsAvailable,J),Q=this.word>>>32-Y;if(J>32)v0.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=J-Y,Y>0&&this.bitsAvailable)return Q<<Y|this.readBits(Y);else return Q},W.skipLZ=function Z(){var J;for(J=0;J<this.bitsAvailable;++J)if((this.word&2147483648>>>J)!==0)return this.word<<=J,this.bitsAvailable-=J,J;return this.loadWord(),J+this.skipLZ()},W.skipUEG=function Z(){this.skipBits(1+this.skipLZ())},W.skipEG=function Z(){this.skipBits(1+this.skipLZ())},W.readUEG=function Z(){var J=this.skipLZ();return this.readBits(J+1)-1},W.readEG=function Z(){var J=this.readUEG();if(1&J)return 1+J>>>1;else return-1*(J>>>1)},W.readBoolean=function Z(){return this.readBits(1)===1},W.readUByte=function Z(){return this.readBits(8)},W.readUShort=function Z(){return this.readBits(16)},W.readUInt=function Z(){return this.readBits(32)},X}(),HZ=function(X){function W(){return X.apply(this,arguments)||this}R(W,X);var Z=W.prototype;return Z.parsePES=function J(Y,Q,G,q){var H=this,V=this.parseNALu(Y,G.data,q),z=this.VideoSample,A,E=!1;if(G.data=null,z&&V.length&&!Y.audFound)this.pushAccessUnit(z,Y),z=this.VideoSample=this.createVideoSample(!1,G.pts,G.dts);if(V.forEach(function(I){var $,L;switch(I.type){case 1:{var b=!1;A=!0;var C=I.data;if(E&&C.length>4){var D=H.readSliceType(C);if(D===2||D===4||D===7||D===9)b=!0}if(b){var y;if((y=z)!=null&&y.frame&&!z.key)H.pushAccessUnit(z,Y),z=H.VideoSample=null}if(!z)z=H.VideoSample=H.createVideoSample(!0,G.pts,G.dts);z.frame=!0,z.key=b;break}case 5:if(A=!0,($=z)!=null&&$.frame&&!z.key)H.pushAccessUnit(z,Y),z=H.VideoSample=null;if(!z)z=H.VideoSample=H.createVideoSample(!0,G.pts,G.dts);z.key=!0,z.frame=!0;break;case 6:{A=!0,Z2(I.data,1,G.pts,Q.samples);break}case 7:{var S,v;A=!0,E=!0;var p=I.data,g=H.readSPS(p);if(!Y.sps||Y.width!==g.width||Y.height!==g.height||((S=Y.pixelRatio)==null?void 0:S[0])!==g.pixelRatio[0]||((v=Y.pixelRatio)==null?void 0:v[1])!==g.pixelRatio[1]){Y.width=g.width,Y.height=g.height,Y.pixelRatio=g.pixelRatio,Y.sps=[p];var m=p.subarray(1,4),r="avc1.";for(var o=0;o<3;o++){var c=m[o].toString(16);if(c.length<2)c="0"+c;r+=c}Y.codec=r}break}case 8:A=!0,Y.pps=[I.data];break;case 9:if(A=!0,Y.audFound=!0,(L=z)!=null&&L.frame)H.pushAccessUnit(z,Y),z=null;if(!z)z=H.VideoSample=H.createVideoSample(!1,G.pts,G.dts);break;case 12:A=!0;break;default:A=!1;break}if(z&&A){var d=z.units;d.push(I)}}),q&&z)this.pushAccessUnit(z,Y),this.VideoSample=null},Z.getNALuType=function J(Y,Q){return Y[Q]&31},Z.readSliceType=function J(Y){var Q=new qZ(Y);return Q.readUByte(),Q.readUEG(),Q.readUEG()},Z.skipScalingList=function J(Y,Q){var G=8,q=8,H;for(var V=0;V<Y;V++){if(q!==0)H=Q.readEG(),q=(G+H+256)%256;G=q===0?G:q}},Z.readSPS=function J(Y){var Q=new qZ(Y),G=0,q=0,H=0,V=0,z,A,E,I=Q.readUByte.bind(Q),$=Q.readBits.bind(Q),L=Q.readUEG.bind(Q),b=Q.readBoolean.bind(Q),C=Q.skipBits.bind(Q),D=Q.skipEG.bind(Q),y=Q.skipUEG.bind(Q),S=this.skipScalingList.bind(this);I();var v=I();if($(5),C(3),I(),y(),v===100||v===110||v===122||v===244||v===44||v===83||v===86||v===118||v===128){var p=L();if(p===3)C(1);if(y(),y(),C(1),b()){A=p!==3?8:12;for(E=0;E<A;E++)if(b())if(E<6)S(16,Q);else S(64,Q)}}y();var g=L();if(g===0)L();else if(g===1){C(1),D(),D(),z=L();for(E=0;E<z;E++)D()}y(),C(1);var m=L(),r=L(),o=$(1);if(o===0)C(1);if(C(1),b())G=L(),q=L(),H=L(),V=L();var c=[1,1];if(b()){if(b()){var d=I();switch(d){case 1:c=[1,1];break;case 2:c=[12,11];break;case 3:c=[10,11];break;case 4:c=[16,11];break;case 5:c=[40,33];break;case 6:c=[24,11];break;case 7:c=[20,11];break;case 8:c=[32,11];break;case 9:c=[80,33];break;case 10:c=[18,11];break;case 11:c=[15,11];break;case 12:c=[64,33];break;case 13:c=[160,99];break;case 14:c=[4,3];break;case 15:c=[3,2];break;case 16:c=[2,1];break;case 255:{c=[I()<<8|I(),I()<<8|I()];break}}}}return{width:Math.ceil((m+1)*16-G*2-q*2),height:(2-o)*(r+1)*16-(o?2:4)*(H+V),pixelRatio:c}},W}(i7),K1=188,s7=function(){function X(Z,J,Y,Q){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=J,this.typeSupported=Y,this.logger=Q,this.videoParser=null}X.probe=function Z(J,Y){var Q=X.syncOffset(J);if(Q>0)Y.warn("MPEG2-TS detected but first sync word found @ offset "+Q);return Q!==-1},X.syncOffset=function Z(J){var Y=J.length,Q=Math.min(K1*5,Y-K1)+1,G=0;while(G<Q){var q=!1,H=-1,V=0;for(var z=G;z<Y;z+=K1)if(J[z]===71&&(Y-z===K1||J[z+K1]===71)){if(V++,H===-1){if(H=z,H!==0)Q=Math.min(H+K1*99,J.length-K1)+1}if(!q)q=QQ(J,z)===0;if(q&&V>1&&(H===0&&V>2||z+K1>Q))return H}else if(V)return-1;else break;G++}return-1},X.createTrack=function Z(J,Y){return{container:J==="video"||J==="audio"?"video/mp2t":void 0,type:J,id:aQ[J],pid:-1,inputTimeScale:90000,sequenceNumber:0,samples:[],dropped:0,duration:J==="audio"?Y:void 0}};var W=X.prototype;return W.resetInitSegment=function Z(J,Y,Q,G){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=X.createTrack("video"),this._videoTrack.duration=G,this._audioTrack=X.createTrack("audio",G),this._id3Track=X.createTrack("id3"),this._txtTrack=X.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=Y,this.videoCodec=Q},W.resetTimeStamp=function Z(){},W.resetContiguity=function Z(){var J=this._audioTrack,Y=this._videoTrack,Q=this._id3Track;if(J)J.pesData=null;if(Y)Y.pesData=null;if(Q)Q.pesData=null;this.aacOverFlow=null,this.remainderData=null},W.demux=function Z(J,Y,Q,G){if(Q===void 0)Q=!1;if(G===void 0)G=!1;if(!Q)this.sampleAes=null;var q,H=this._videoTrack,V=this._audioTrack,z=this._id3Track,A=this._txtTrack,E=H.pid,I=H.pesData,$=V.pid,L=z.pid,b=V.pesData,C=z.pesData,D=null,y=this.pmtParsed,S=this._pmtId,v=J.length;if(this.remainderData)J=v1(this.remainderData,J),v=J.length,this.remainderData=null;if(v<K1&&!G)return this.remainderData=J,{audioTrack:V,videoTrack:H,id3Track:z,textTrack:A};var p=Math.max(0,X.syncOffset(J));if(v-=(v-p)%K1,v<J.byteLength&&!G)this.remainderData=new Uint8Array(J.buffer,v,J.buffer.byteLength-v);var g=0;for(var m=p;m<v;m+=K1)if(J[m]===71){var r=!!(J[m+1]&64),o=QQ(J,m),c=(J[m+3]&48)>>4,d=void 0;if(c>1){if(d=m+5+J[m+4],d===m+K1)continue}else d=m+4;switch(o){case E:if(r){if(I&&(q=EY(I,this.logger))){if(this.videoParser===null)switch(H.segmentCodec){case"avc":this.videoParser=new HZ;break}if(this.videoParser!==null)this.videoParser.parsePES(H,A,q,!1)}I={data:[],size:0}}if(I)I.data.push(J.subarray(d,m+K1)),I.size+=m+K1-d;break;case $:if(r){if(b&&(q=EY(b,this.logger)))switch(V.segmentCodec){case"aac":this.parseAACPES(V,q);break;case"mp3":this.parseMPEGPES(V,q);break}b={data:[],size:0}}if(b)b.data.push(J.subarray(d,m+K1)),b.size+=m+K1-d;break;case L:if(r){if(C&&(q=EY(C,this.logger)))this.parseID3PES(z,q);C={data:[],size:0}}if(C)C.data.push(J.subarray(d,m+K1)),C.size+=m+K1-d;break;case 0:if(r)d+=J[d]+1;S=this._pmtId=r7(J,d);break;case S:{if(r)d+=J[d]+1;var e=a7(J,d,this.typeSupported,Q,this.observer,this.logger);if(E=e.videoPid,E>0)H.pid=E,H.segmentCodec=e.segmentVideoCodec;if($=e.audioPid,$>0)V.pid=$,V.segmentCodec=e.segmentAudioCodec;if(L=e.id3Pid,L>0)z.pid=L;if(D!==null&&!y)this.logger.warn("MPEG-TS PMT found at "+m+" after unknown PID '"+D+"'. Backtracking to sync byte @"+p+" to parse all TS packets."),D=null,m=p-188;y=this.pmtParsed=!0;break}case 17:case 8191:break;default:D=o;break}}else g++;if(g>0)OJ(this.observer,new Error("Found "+g+" TS packet/s that do not start with 0x47"),void 0,this.logger);H.pesData=I,V.pesData=b,z.pesData=C;var H0={audioTrack:V,videoTrack:H,id3Track:z,textTrack:A};if(G)this.extractRemainingSamples(H0);return H0},W.flush=function Z(){var J=this.remainderData;this.remainderData=null;var Y;if(J)Y=this.demux(J,-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},W.extractRemainingSamples=function Z(J){var{audioTrack:Y,videoTrack:Q,id3Track:G,textTrack:q}=J,H=Q.pesData,V=Y.pesData,z=G.pesData,A;if(H&&(A=EY(H,this.logger))){if(this.videoParser===null)switch(Q.segmentCodec){case"avc":this.videoParser=new HZ;break}if(this.videoParser!==null)this.videoParser.parsePES(Q,q,A,!0),Q.pesData=null}else Q.pesData=H;if(V&&(A=EY(V,this.logger))){switch(Y.segmentCodec){case"aac":this.parseAACPES(Y,A);break;case"mp3":this.parseMPEGPES(Y,A);break}Y.pesData=null}else{if(V!=null&&V.size)this.logger.log("last AAC PES packet truncated,might overlap between fragments");Y.pesData=V}if(z&&(A=EY(z,this.logger)))this.parseID3PES(G,A),G.pesData=null;else G.pesData=z},W.demuxSampleAes=function Z(J,Y,Q){var G=this.demux(J,Q,!0,!this.config.progressive),q=this.sampleAes=new o7(this.observer,this.config,Y);return this.decrypt(G,q)},W.decrypt=function Z(J,Y){return new Promise(function(Q){var{audioTrack:G,videoTrack:q}=J;if(G.samples&&G.segmentCodec==="aac")Y.decryptAacSamples(G.samples,0,function(){if(q.samples)Y.decryptAvcSamples(q.samples,0,0,function(){Q(J)});else Q(J)});else if(q.samples)Y.decryptAvcSamples(q.samples,0,0,function(){Q(J)})})},W.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},W.parseAACPES=function Z(J,Y){var Q=0,G=this.aacOverFlow,q=Y.data;if(G){this.aacOverFlow=null;var H=G.missing,V=G.sample.unit.byteLength;if(H===-1)q=v1(G.sample.unit,q);else{var z=V-H;G.sample.unit.set(q.subarray(0,H),z),J.samples.push(G.sample),Q=G.missing}}var A,E;for(A=Q,E=q.length;A<E-1;A++)if(zJ(q,A))break;if(A!==Q){var I,$=A<E-1;if($)I="AAC PES did not start with ADTS header,offset:"+A;else I="No ADTS header found in AAC PES";if(OJ(this.observer,new Error(I),$,this.logger),!$)return}r2(J,this.observer,q,A,this.audioCodec);var L;if(Y.pts!==void 0)L=Y.pts;else if(G){var b=a2(J.samplerate);L=G.sample.pts+b}else{this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}var C=0,D;while(A<E)if(D=t2(J,q,A,L,C),A+=D.length,!D.missing){C++;for(;A<E-1;A++)if(zJ(q,A))break}else{this.aacOverFlow=D;break}},W.parseMPEGPES=function Z(J,Y){var Q=Y.data,G=Q.length,q=0,H=0,V=Y.pts;if(V===void 0){this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}while(H<G)if(GZ(Q,H)){var z=ZZ(J,Q,H,V,q);if(z)H+=z.length,q++;else break}else H++},W.parseAC3PES=function Z(J,Y){},W.parseID3PES=function Z(J,Y){if(Y.pts===void 0){this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}var Q=B({},Y,{type:this._videoTrack?b1.emsg:b1.audioId3,duration:Number.POSITIVE_INFINITY});J.samples.push(Q)},X}();function QQ(X,W){return((X[W+1]&31)<<8)+X[W+2]}function r7(X,W){return(X[W+10]&31)<<8|X[W+11]}function a7(X,W,Z,J,Y,Q){var G={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},q=(X[W+1]&15)<<8|X[W+2],H=W+3+q-4,V=(X[W+10]&15)<<8|X[W+11];W+=12+V;while(W<H){var z=QQ(X,W),A=(X[W+3]&15)<<8|X[W+4];switch(X[W]){case 207:if(!J){ZQ("ADTS AAC",Q);break}case 15:if(G.audioPid===-1)G.audioPid=z;break;case 21:if(G.id3Pid===-1)G.id3Pid=z;break;case 219:if(!J){ZQ("H.264",Q);break}case 27:if(G.videoPid===-1)G.videoPid=z;break;case 3:case 4:if(!Z.mpeg&&!Z.mp3)Q.log("MPEG audio found, not supported in this browser");else if(G.audioPid===-1)G.audioPid=z,G.segmentAudioCodec="mp3";break;case 193:if(!J){ZQ("AC-3",Q);break}case 129:Q.warn("AC-3 in M2TS support not included in build");break;case 6:if(G.audioPid===-1&&A>0){var E=W+5,I=A;while(I>2){var $=X[E];switch($){case 106:Q.warn("AC-3 in M2TS support not included in build");break}var L=X[E+1]+2;E+=L,I-=L}}break;case 194:case 135:return OJ(Y,new Error("Unsupported EC-3 in M2TS found"),void 0,Q),G;case 36:return OJ(Y,new Error("Unsupported HEVC in M2TS found"),void 0,Q),G}W+=A+5}return G}function OJ(X,W,Z,J){J.warn("parsing error: "+W.message),X.emit(M.ERROR,M.ERROR,{type:n.MEDIA_ERROR,details:h.FRAG_PARSING_ERROR,fatal:!1,levelRetry:Z,error:W,reason:W.message})}function ZQ(X,W){W.log(X+" with AES-128-CBC encryption found in unencrypted stream")}function EY(X,W){var Z=0,J,Y,Q,G,q,H=X.data;if(!X||X.size===0)return null;while(H[0].length<19&&H.length>1)H[0]=v1(H[0],H[1]),H.splice(1,1);J=H[0];var V=(J[0]<<16)+(J[1]<<8)+J[2];if(V===1){if(Y=(J[4]<<8)+J[5],Y&&Y>X.size-6)return null;var z=J[7];if(z&192)if(G=(J[9]&14)*536870912+(J[10]&255)*4194304+(J[11]&254)*16384+(J[12]&255)*128+(J[13]&254)/2,z&64){if(q=(J[14]&14)*536870912+(J[15]&255)*4194304+(J[16]&254)*16384+(J[17]&255)*128+(J[18]&254)/2,G-q>5400000)W.warn(Math.round((G-q)/90000)+"s delta between PTS and DTS, align them"),G=q}else q=G;Q=J[8];var A=Q+9;if(X.size<=A)return null;X.size-=A;var E=new Uint8Array(X.size);for(var I=0,$=H.length;I<$;I++){J=H[I];var L=J.byteLength;if(A)if(A>L){A-=L;continue}else J=J.subarray(A),L-=A,A=0;E.set(J,Z),Z+=L}if(Y)Y-=Q+3;return{data:E,pts:G,dts:q,len:Y}}return null}var t7=function(){function X(){}return X.getSilentFrame=function W(Z,J){switch(Z){case"mp4a.40.2":if(J===1)return new Uint8Array([0,200,0,128,35,128]);else if(J===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);else if(J===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);else if(J===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);else if(J===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(J===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(J===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(J===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(J===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},X}(),WY=Math.pow(2,32)-1,H1=function(){function X(){}return X.init=function W(){X.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 X.types)if(X.types.hasOwnProperty(Z))X.types[Z]=[Z.charCodeAt(0),Z.charCodeAt(1),Z.charCodeAt(2),Z.charCodeAt(3)];var J=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]);X.HDLR_TYPES={video:J,audio:Y};var Q=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),G=new Uint8Array([0,0,0,0,0,0,0,0]);X.STTS=X.STSC=X.STCO=G,X.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),X.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),X.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),X.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var q=new Uint8Array([105,115,111,109]),H=new Uint8Array([97,118,99,49]),V=new Uint8Array([0,0,0,1]);X.FTYP=X.box(X.types.ftyp,q,V,q,H),X.DINF=X.box(X.types.dinf,X.box(X.types.dref,Q))},X.box=function W(Z){var J=8;for(var Y=arguments.length,Q=new Array(Y>1?Y-1:0),G=1;G<Y;G++)Q[G-1]=arguments[G];var q=Q.length,H=q;while(q--)J+=Q[q].byteLength;var V=new Uint8Array(J);V[0]=J>>24&255,V[1]=J>>16&255,V[2]=J>>8&255,V[3]=J&255,V.set(Z,4);for(q=0,J=8;q<H;q++)V.set(Q[q],J),J+=Q[q].byteLength;return V},X.hdlr=function W(Z){return X.box(X.types.hdlr,X.HDLR_TYPES[Z])},X.mdat=function W(Z){return X.box(X.types.mdat,Z)},X.mdhd=function W(Z,J){J*=Z;var Y=Math.floor(J/(WY+1)),Q=Math.floor(J%(WY+1));return X.box(X.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,Q>>24,Q>>16&255,Q>>8&255,Q&255,85,196,0,0]))},X.mdia=function W(Z){return X.box(X.types.mdia,X.mdhd(Z.timescale||0,Z.duration||0),X.hdlr(Z.type),X.minf(Z))},X.mfhd=function W(Z){return X.box(X.types.mfhd,new Uint8Array([0,0,0,0,Z>>24,Z>>16&255,Z>>8&255,Z&255]))},X.minf=function W(Z){if(Z.type==="audio")return X.box(X.types.minf,X.box(X.types.smhd,X.SMHD),X.DINF,X.stbl(Z));else return X.box(X.types.minf,X.box(X.types.vmhd,X.VMHD),X.DINF,X.stbl(Z))},X.moof=function W(Z,J,Y){return X.box(X.types.moof,X.mfhd(Z),X.traf(Y,J))},X.moov=function W(Z){var J=Z.length,Y=[];while(J--)Y[J]=X.trak(Z[J]);return X.box.apply(null,[X.types.moov,X.mvhd(Z[0].timescale||0,Z[0].duration||0)].concat(Y).concat(X.mvex(Z)))},X.mvex=function W(Z){var J=Z.length,Y=[];while(J--)Y[J]=X.trex(Z[J]);return X.box.apply(null,[X.types.mvex].concat(Y))},X.mvhd=function W(Z,J){J*=Z;var Y=Math.floor(J/(WY+1)),Q=Math.floor(J%(WY+1)),G=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,Q>>24,Q>>16&255,Q>>8&255,Q&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 X.box(X.types.mvhd,G)},X.sdtp=function W(Z){var J=Z.samples||[],Y=new Uint8Array(4+J.length),Q,G;for(Q=0;Q<J.length;Q++)G=J[Q].flags,Y[Q+4]=G.dependsOn<<4|G.isDependedOn<<2|G.hasRedundancy;return X.box(X.types.sdtp,Y)},X.stbl=function W(Z){return X.box(X.types.stbl,X.stsd(Z),X.box(X.types.stts,X.STTS),X.box(X.types.stsc,X.STSC),X.box(X.types.stsz,X.STSZ),X.box(X.types.stco,X.STCO))},X.avc1=function W(Z){var J=[],Y=[],Q,G,q;for(Q=0;Q<Z.sps.length;Q++)G=Z.sps[Q],q=G.byteLength,J.push(q>>>8&255),J.push(q&255),J=J.concat(Array.prototype.slice.call(G));for(Q=0;Q<Z.pps.length;Q++)G=Z.pps[Q],q=G.byteLength,Y.push(q>>>8&255),Y.push(q&255),Y=Y.concat(Array.prototype.slice.call(G));var H=X.box(X.types.avcC,new Uint8Array([1,J[3],J[4],J[5],255,224|Z.sps.length].concat(J).concat([Z.pps.length]).concat(Y))),V=Z.width,z=Z.height,A=Z.pixelRatio[0],E=Z.pixelRatio[1];return X.box(X.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,V>>8&255,V&255,z>>8&255,z&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]),H,X.box(X.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),X.box(X.types.pasp,new Uint8Array([A>>24,A>>16&255,A>>8&255,A&255,E>>24,E>>16&255,E>>8&255,E&255])))},X.esds=function W(Z){var J=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(J,[6,1,2]))},X.audioStsd=function W(Z){var J=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,J>>8&255,J&255,0,0])},X.mp4a=function W(Z){return X.box(X.types.mp4a,X.audioStsd(Z),X.box(X.types.esds,X.esds(Z)))},X.mp3=function W(Z){return X.box(X.types[".mp3"],X.audioStsd(Z))},X.ac3=function W(Z){return X.box(X.types["ac-3"],X.audioStsd(Z),X.box(X.types.dac3,Z.config))},X.stsd=function W(Z){var J=Z.segmentCodec;if(Z.type==="audio"){if(J==="aac")return X.box(X.types.stsd,X.STSD,X.mp4a(Z));if(J==="mp3"&&Z.codec==="mp3")return X.box(X.types.stsd,X.STSD,X.mp3(Z))}else if(Z.pps&&Z.sps){if(J==="avc")return X.box(X.types.stsd,X.STSD,X.avc1(Z))}else throw new Error("video track missing pps or sps");throw new Error("unsupported "+Z.type+" segment codec ("+J+"/"+Z.codec+")")},X.tkhd=function W(Z){var J=Z.id,Y=(Z.duration||0)*(Z.timescale||0),Q=Z.width||0,G=Z.height||0,q=Math.floor(Y/(WY+1)),H=Math.floor(Y%(WY+1));return X.box(X.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,J>>24&255,J>>16&255,J>>8&255,J&255,0,0,0,0,q>>24,q>>16&255,q>>8&255,q&255,H>>24,H>>16&255,H>>8&255,H&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,Q>>8&255,Q&255,0,0,G>>8&255,G&255,0,0]))},X.traf=function W(Z,J){var Y=X.sdtp(Z),Q=Z.id,G=Math.floor(J/(WY+1)),q=Math.floor(J%(WY+1));return X.box(X.types.traf,X.box(X.types.tfhd,new Uint8Array([0,0,0,0,Q>>24,Q>>16&255,Q>>8&255,Q&255])),X.box(X.types.tfdt,new Uint8Array([1,0,0,0,G>>24,G>>16&255,G>>8&255,G&255,q>>24,q>>16&255,q>>8&255,q&255])),X.trun(Z,Y.length+16+20+8+16+8+8),Y)},X.trak=function W(Z){return Z.duration=Z.duration||4294967295,X.box(X.types.trak,X.tkhd(Z),X.mdia(Z))},X.trex=function W(Z){var J=Z.id;return X.box(X.types.trex,new Uint8Array([0,0,0,0,J>>24,J>>16&255,J>>8&255,J&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},X.trun=function W(Z,J){var Y=Z.samples||[],Q=Y.length,G=12+16*Q,q=new Uint8Array(G),H,V,z,A,E,I;J+=8+G,q.set([Z.type==="video"?1:0,0,15,1,Q>>>24&255,Q>>>16&255,Q>>>8&255,Q&255,J>>>24&255,J>>>16&255,J>>>8&255,J&255],0);for(H=0;H<Q;H++)V=Y[H],z=V.duration,A=V.size,E=V.flags,I=V.cts,q.set([z>>>24&255,z>>>16&255,z>>>8&255,z&255,A>>>24&255,A>>>16&255,A>>>8&255,A&255,E.isLeading<<2|E.dependsOn,E.isDependedOn<<6|E.hasRedundancy<<4|E.paddingValue<<1|E.isNonSync,E.degradPrio&61440,E.degradPrio&15,I>>>24&255,I>>>16&255,I>>>8&255,I&255],12+16*H);return X.box(X.types.trun,q)},X.initSegment=function W(Z){if(!X.types)X.init();var J=X.moov(Z),Y=v1(X.FTYP,J);return Y},X.hvc1=function W(Z){return new Uint8Array},X}();H1.types=void 0,H1.HDLR_TYPES=void 0,H1.STTS=void 0,H1.STSC=void 0,H1.STCO=void 0,H1.STSZ=void 0,H1.VMHD=void 0,H1.SMHD=void 0,H1.STSD=void 0,H1.FTYP=void 0,H1.DINF=void 0;var e7=90000;function Y9(X,W,Z,J){var Y=X*W*Z;return Math.round(Y)}function gY(X,W){return Y9(X,1000,1/e7)}var J9=1e4,Q9=1024,Z9=1152,X9=1536,BY=null,XQ=null;function NZ(X,W,Z,J){return{duration:W,size:Z,cts:J,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:X?2:1,isNonSync:X?0:1}}}var GQ=function(){function X(Z,J,Y,Q){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=J,this.typeSupported=Y,this.logger=Q,this.ISGenerated=!1,BY===null){var G=navigator.userAgent||"",q=G.match(/Chrome\/(\d+)/i);BY=q?parseInt(q[1]):0}if(XQ===null){var H=navigator.userAgent.match(/Safari\/(\d+)/i);XQ=H?parseInt(H[1]):0}}var W=X.prototype;return W.destroy=function Z(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null},W.resetTimeStamp=function Z(J){this.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=J},W.resetNextTimestamp=function Z(){this.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},W.resetInitSegment=function Z(){this.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0},W.getVideoStartPts=function Z(J){var Y=!1,Q=J[0].pts,G=J.reduce(function(q,H){var V=H.pts,z=V-q;if(z<-4294967296)Y=!0,V=k1(V,Q),z=V-q;if(z>0)return q;return V},Q);if(Y)this.logger.debug("PTS rollover detected");return G},W.remux=function Z(J,Y,Q,G,q,H,V,z){var A,E,I,$,L,b,C=q,D=q,y=J.pid>-1,S=Y.pid>-1,v=Y.samples.length,p=J.samples.length>0,g=V&&v>0||v>1,m=(!y||p)&&(!S||g)||this.ISGenerated||V;if(m){if(this.ISGenerated){var r,o,c,d,e=this.videoTrackConfig;if(e&&(Y.width!==e.width||Y.height!==e.height||((r=Y.pixelRatio)==null?void 0:r[0])!==((o=e.pixelRatio)==null?void 0:o[0])||((c=Y.pixelRatio)==null?void 0:c[1])!==((d=e.pixelRatio)==null?void 0:d[1]))||!e&&g||this.nextAudioPts===null&&p)this.resetInitSegment()}if(!this.ISGenerated)I=this.generateIS(J,Y,q,H);var H0=this.isVideoContiguous,Q0=-1,J0;if(g){if(Q0=G9(Y.samples),!H0&&this.config.forceKeyFrameOnDiscontinuity){if(b=!0,Q0>0){this.logger.warn("[mp4-remuxer]: Dropped "+Q0+" out of "+v+" video samples due to a missing keyframe");var N0=this.getVideoStartPts(Y.samples);Y.samples=Y.samples.slice(Q0),Y.dropped+=Q0,D+=(Y.samples[0].pts-N0)/Y.inputTimeScale,J0=D}else if(Q0===-1)this.logger.warn("[mp4-remuxer]: No keyframe found out of "+v+" video samples"),b=!1}}if(this.ISGenerated){if(p&&g){var V0=this.getVideoStartPts(Y.samples),j0=k1(J.samples[0].pts,V0)-V0,O0=j0/Y.inputTimeScale;C+=Math.max(0,O0),D+=Math.max(0,-O0)}if(p){if(!J.samplerate)this.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),I=this.generateIS(J,Y,q,H);if(E=this.remuxAudio(J,C,this.isAudioContiguous,H,S||g||z===G0.AUDIO?D:void 0),g){var g0=E?E.endPTS-E.startPTS:0;if(!Y.inputTimeScale)this.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),I=this.generateIS(J,Y,q,H);A=this.remuxVideo(Y,D,H0,g0)}}else if(g)A=this.remuxVideo(Y,D,H0,0);if(A)A.firstKeyFrame=Q0,A.independent=Q0!==-1,A.firstKeyFramePTS=J0}}if(this.ISGenerated&&this._initPTS&&this._initDTS){if(Q.samples.length)L=UZ(Q,q,this._initPTS,this._initDTS);if(G.samples.length)$=VZ(G,q,this._initPTS)}return{audio:E,video:A,initSegment:I,independent:b,text:$,id3:L}},W.generateIS=function Z(J,Y,Q,G){var q=J.samples,H=Y.samples,V=this.typeSupported,z={},A=this._initPTS,E=!A||G,I="audio/mp4",$,L,b;if(E)$=L=1/0;if(J.config&&q.length){switch(J.timescale=J.samplerate,J.segmentCodec){case"mp3":if(V.mpeg)I="audio/mpeg",J.codec="";else if(V.mp3)J.codec="mp3";break;case"ac3":J.codec="ac-3";break}if(z.audio={id:"audio",container:I,codec:J.codec,initSegment:J.segmentCodec==="mp3"&&V.mpeg?new Uint8Array(0):H1.initSegment([J]),metadata:{channelCount:J.channelCount}},E)if(b=J.inputTimeScale,!A||b!==A.timescale)$=L=q[0].pts-Math.round(b*Q);else E=!1}if(Y.sps&&Y.pps&&H.length){if(Y.timescale=Y.inputTimeScale,z.video={id:"main",container:"video/mp4",codec:Y.codec,initSegment:H1.initSegment([Y]),metadata:{width:Y.width,height:Y.height}},E)if(b=Y.inputTimeScale,!A||b!==A.timescale){var C=this.getVideoStartPts(H),D=Math.round(b*Q);L=Math.min(L,k1(H[0].dts,C)-D),$=Math.min($,C-D)}else E=!1;this.videoTrackConfig={width:Y.width,height:Y.height,pixelRatio:Y.pixelRatio}}if(Object.keys(z).length){if(this.ISGenerated=!0,E)this._initPTS={baseTime:$,timescale:b},this._initDTS={baseTime:L,timescale:b};else $=b=void 0;return{tracks:z,initPTS:$,timescale:b}}},W.remuxVideo=function Z(J,Y,Q,G){var{inputTimeScale:q,samples:H}=J,V=[],z=H.length,A=this._initPTS,E=this.nextAvcDts,I=8,$=this.videoSampleDuration,L,b,C=Number.POSITIVE_INFINITY,D=Number.NEGATIVE_INFINITY,y=!1;if(!Q||E===null){var S=Y*q,v=H[0].pts-k1(H[0].dts,H[0].pts);if(BY&&E!==null&&Math.abs(S-v-E)<15000)Q=!0;else E=S-v}var p=A.baseTime*q/A.timescale;for(var g=0;g<z;g++){var m=H[g];if(m.pts=k1(m.pts-p,E),m.dts=k1(m.dts-p,E),m.dts<H[g>0?g-1:g].dts)y=!0}if(y)H.sort(function(IJ,cZ){var wG=IJ.dts-cZ.dts,RG=IJ.pts-cZ.pts;return wG||RG});L=H[0].dts,b=H[H.length-1].dts;var r=b-L,o=r?Math.round(r/(z-1)):$||J.inputTimeScale/30;if(Q){var c=L-E,d=c>o,e=c<-1;if(d||e){if(d)this.logger.warn((J.segmentCodec||"").toUpperCase()+": "+gY(c)+" ms ("+c+"dts) hole between fragments detected at "+Y.toFixed(3));else this.logger.warn((J.segmentCodec||"").toUpperCase()+": "+gY(-c)+" ms ("+c+"dts) overlapping between fragments detected at "+Y.toFixed(3));if(!e||E>=H[0].pts||BY){L=E;var H0=H[0].pts-c;if(d)H[0].dts=L,H[0].pts=H0;else{var Q0=!0;for(var J0=0;J0<H.length;J0++){if(H[J0].dts>H0&&Q0)break;var N0=H[J0].pts;if(H[J0].dts-=c,H[J0].pts-=c,J0<H.length-1){var V0=H[J0+1].pts,j0=H[J0].pts,O0=V0<=j0,g0=V0<=N0;Q0=O0==g0}}}this.logger.log("Video: Initial PTS/DTS adjusted: "+gY(H0)+"/"+gY(L)+", delta: "+gY(c)+" ms")}}}L=Math.max(0,L);var T0=0,m0=0,D0=L;for(var Y1=0;Y1<z;Y1++){var _0=H[Y1],a0=_0.units,w1=a0.length,q1=0;for(var p0=0;p0<w1;p0++)q1+=a0[p0].data.length;if(m0+=q1,T0+=w1,_0.length=q1,_0.dts<D0)_0.dts=D0,D0+=o/4|0||1;else D0=_0.dts;C=Math.min(_0.pts,C),D=Math.max(_0.pts,D)}b=H[z-1].dts;var R1=m0+4*T0+8,Z1;try{Z1=new Uint8Array(R1)}catch(IJ){this.observer.emit(M.ERROR,M.ERROR,{type:n.MUX_ERROR,details:h.REMUX_ALLOC_ERROR,fatal:!1,error:IJ,bytes:R1,reason:"fail allocating video mdat "+R1});return}var s0=new DataView(Z1.buffer);s0.setUint32(0,R1),Z1.set(H1.types.mdat,4);var $1=!1,V1=Number.POSITIVE_INFINITY,M1=Number.POSITIVE_INFINITY,n0=Number.NEGATIVE_INFINITY,z1=Number.NEGATIVE_INFINITY;for(var X1=0;X1<z;X1++){var I1=H[X1],pY=I1.units,gZ=0;for(var jQ=0,UG=pY.length;jQ<UG;jQ++){var uZ=pY[jQ],VG=uZ.data,AQ=uZ.data.byteLength;s0.setUint32(I,AQ),I+=4,Z1.set(VG,I),I+=AQ,gZ+=4+AQ}var RJ=void 0;if(X1<z-1)$=H[X1+1].dts-I1.dts,RJ=H[X1+1].pts-I1.pts;else{var mZ=this.config,$J=X1>0?I1.dts-H[X1-1].dts:o;if(RJ=X1>0?I1.pts-H[X1-1].pts:o,mZ.stretchShortVideoTrack&&this.nextAudioPts!==null){var zG=Math.floor(mZ.maxBufferHole*q),OQ=(G?C+G*q:this.nextAudioPts)-I1.pts;if(OQ>zG){if($=OQ-$J,$<0)$=$J;else $1=!0;this.logger.log("[mp4-remuxer]: It is approximately "+OQ/90+" ms to the next segment; using duration "+$/90+" ms for the last video frame.")}else $=$J}else $=$J}var jG=Math.round(I1.pts-I1.dts);V1=Math.min(V1,$),n0=Math.max(n0,$),M1=Math.min(M1,RJ),z1=Math.max(z1,RJ),V.push(NZ(I1.key,$,gZ,jG))}if(V.length){if(BY){if(BY<70){var _Z=V[0].flags;_Z.dependsOn=2,_Z.isNonSync=0}}else if(XQ){if(z1-M1<n0-V1&&o/n0<0.025&&V[0].cts===0){this.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");var FQ=L;for(var g1=0,pZ=V.length;g1<pZ;g1++){var fZ=FQ+V[g1].duration,AG=FQ+V[g1].cts;if(g1<pZ-1){var OG=fZ+V[g1+1].cts;V[g1].duration=OG-AG}else V[g1].duration=g1?V[g1-1].duration:o;V[g1].cts=0,FQ=fZ}}}}$=$1||!$?o:$,this.nextAvcDts=E=b+$,this.videoSampleDuration=$,this.isVideoContiguous=!0;var FG=H1.moof(J.sequenceNumber++,L,B(J,{samples:V})),EG="video",BG={data1:FG,data2:Z1,startPTS:C/q,endPTS:(D+$)/q,startDTS:L/q,endDTS:E/q,type:EG,hasAudio:!1,hasVideo:!0,nb:V.length,dropped:J.dropped};return J.samples=[],J.dropped=0,BG},W.getSamplesPerFrame=function Z(J){switch(J.segmentCodec){case"mp3":return Z9;case"ac3":return X9;default:return Q9}},W.remuxAudio=function Z(J,Y,Q,G,q){var H=J.inputTimeScale,V=J.samplerate?J.samplerate:H,z=H/V,A=this.getSamplesPerFrame(J),E=A*z,I=this._initPTS,$=J.segmentCodec==="mp3"&&this.typeSupported.mpeg,L=[],b=q!==void 0,C=J.samples,D=$?0:8,y=this.nextAudioPts||-1,S=Y*H,v=I.baseTime*H/I.timescale;if(this.isAudioContiguous=Q=Q||C.length&&y>0&&(G&&Math.abs(S-y)<9000||Math.abs(k1(C[0].pts-v,S)-y)<20*E),C.forEach(function(n0){n0.pts=k1(n0.pts-v,S)}),!Q||y<0){if(C=C.filter(function(n0){return n0.pts>=0}),!C.length)return;if(q===0)y=0;else if(G&&!b)y=Math.max(0,S);else y=C[0].pts}if(J.segmentCodec==="aac"){var p=this.config.maxAudioFramesDrift;for(var g=0,m=y;g<C.length;g++){var r=C[g],o=r.pts,c=o-m,d=Math.abs(1000*c/H);if(c<=-p*E&&b){if(g===0)this.logger.warn("Audio frame @ "+(o/H).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1000*c/H)+" ms."),this.nextAudioPts=y=m=o}else if(c>=p*E&&d<J9&&b){var e=Math.round(c/E);if(m=o-e*E,m<0)e--,m+=E;if(g===0)this.nextAudioPts=y=m;this.logger.warn("[mp4-remuxer]: Injecting "+e+" audio frame @ "+(m/H).toFixed(3)+"s due to "+Math.round(1000*c/H)+" ms gap.");for(var H0=0;H0<e;H0++){var Q0=Math.max(m,0),J0=t7.getSilentFrame(J.parsedCodec||J.manifestCodec||J.codec,J.channelCount);if(!J0)this.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),J0=r.unit.subarray();C.splice(g,0,{unit:J0,pts:Q0}),m+=E,g++}}r.pts=m,m+=E}}var N0=null,V0=null,j0,O0=0,g0=C.length;while(g0--)O0+=C[g0].unit.byteLength;for(var T0=0,m0=C.length;T0<m0;T0++){var D0=C[T0],Y1=D0.unit,_0=D0.pts;if(V0!==null){var a0=L[T0-1];a0.duration=Math.round((_0-V0)/z)}else{if(Q&&J.segmentCodec==="aac")_0=y;if(N0=_0,O0>0){O0+=D;try{j0=new Uint8Array(O0)}catch(n0){this.observer.emit(M.ERROR,M.ERROR,{type:n.MUX_ERROR,details:h.REMUX_ALLOC_ERROR,fatal:!1,error:n0,bytes:O0,reason:"fail allocating audio mdat "+O0});return}if(!$){var w1=new DataView(j0.buffer);w1.setUint32(0,O0),j0.set(H1.types.mdat,4)}}else return}j0.set(Y1,D);var q1=Y1.byteLength;D+=q1,L.push(NZ(!0,A,q1,0)),V0=_0}var p0=L.length;if(!p0)return;var R1=L[L.length-1];this.nextAudioPts=y=V0+z*R1.duration;var Z1=$?new Uint8Array(0):H1.moof(J.sequenceNumber++,N0/z,B({},J,{samples:L}));J.samples=[];var s0=N0/H,$1=y/H,V1="audio",M1={data1:Z1,data2:j0,startPTS:s0,endPTS:$1,startDTS:s0,endDTS:$1,type:V1,hasAudio:!0,hasVideo:!1,nb:p0};return this.isAudioContiguous=!0,M1},X}();function k1(X,W){var Z;if(W===null)return X;if(W<X)Z=-8589934592;else Z=8589934592;while(Math.abs(X-W)>4294967296)X+=Z;return X}function G9(X){for(var W=0;W<X.length;W++)if(X[W].key)return W;return-1}function UZ(X,W,Z,J){var Y=X.samples.length;if(!Y)return;var Q=X.inputTimeScale;for(var G=0;G<Y;G++){var q=X.samples[G];q.pts=k1(q.pts-Z.baseTime*Q/Z.timescale,W*Q)/Q,q.dts=k1(q.dts-J.baseTime*Q/J.timescale,W*Q)/Q}var H=X.samples;return X.samples=[],{samples:H}}function VZ(X,W,Z){var J=X.samples.length;if(!J)return;var Y=X.inputTimeScale;for(var Q=0;Q<J;Q++){var G=X.samples[Q];G.pts=k1(G.pts-Z.baseTime*Y/Z.timescale,W*Y)/Y}X.samples.sort(function(H,V){return H.pts-V.pts});var q=X.samples;return X.samples=[],{samples:q}}var W9=function(){function X(Z,J,Y,Q){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=Q}var W=X.prototype;return W.destroy=function Z(){},W.resetTimeStamp=function Z(J){this.initPTS=J,this.lastEndTime=null},W.resetNextTimestamp=function Z(){this.lastEndTime=null},W.resetInitSegment=function Z(J,Y,Q,G){this.audioCodec=Y,this.videoCodec=Q,this.generateInitSegment(qX(J,G)),this.emitInitSegment=!0},W.generateInitSegment=function Z(J){var Y=this.audioCodec,Q=this.videoCodec;if(!(J!=null&&J.byteLength)){this.initTracks=void 0,this.initData=void 0;return}var G=this.initData=J2(J);if(G.audio)Y=zZ(G.audio,i0.AUDIO);if(G.video)Q=zZ(G.video,i0.VIDEO);var q={};if(G.audio&&G.video)q.audiovideo={container:"video/mp4",codec:Y+","+Q,supplemental:G.video.supplemental,initSegment:J,id:"main"};else if(G.audio)q.audio={container:"audio/mp4",codec:Y,initSegment:J,id:"audio"};else if(G.video)q.video={container:"video/mp4",codec:Q,supplemental:G.video.supplemental,initSegment:J,id:"main"};else this.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes.");this.initTracks=q},W.remux=function Z(J,Y,Q,G,q,H){var V,z,A=this.initPTS,E=this.lastEndTime,I={audio:void 0,video:void 0,text:G,id3:Q,initSegment:void 0};if(!T(E))E=this.lastEndTime=q||0;var $=Y.samples;if(!($!=null&&$.length))return I;var L={initPTS:void 0,timescale:1},b=this.initData;if(!((V=b)!=null&&V.length))this.generateInitSegment($),b=this.initData;if(!((z=b)!=null&&z.length))return this.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),I;if(this.emitInitSegment)L.tracks=this.initTracks,this.emitInitSegment=!1;var C=UX($,b),D=NX(b,$),y=D===null?q:D;if((H||!A)&&(K9(A,y,q,C)||L.timescale!==A.timescale)){if(L.initPTS=y-q,A&&A.timescale===1)this.logger.warn("Adjusting initPTS @"+q+" from "+A.baseTime/A.timescale+" to "+L.initPTS);this.initPTS=A={baseTime:L.initPTS,timescale:1}}var S=J?y-A.baseTime/A.timescale:E,v=S+C;if(zX(b,$,A.baseTime/A.timescale),C>0)this.lastEndTime=v;else this.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp();var p=!!b.audio,g=!!b.video,m="";if(p)m+="audio";if(g)m+="video";var r={data1:$,startPTS:S,startDTS:S,endPTS:v,endDTS:v,type:m,hasAudio:p,hasVideo:g,nb:1,dropped:0};if(I.audio=r.type==="audio"?r:void 0,I.video=r.type!=="audio"?r:void 0,I.initSegment=L,I.id3=UZ(Q,q,A,A),G.samples.length)I.text=VZ(G,q,A);return I},X}();function K9(X,W,Z,J){if(X===null)return!0;var Y=Math.max(J,1),Q=W-X.baseTime/X.timescale;return Math.abs(Q-Z)>Y}function zZ(X,W){var Z=X==null?void 0:X.codec;if(Z&&Z.length>4)return Z;if(W===i0.AUDIO){if(Z==="ec-3"||Z==="ac-3"||Z==="alac")return Z;if(Z==="fLaC"||Z==="Opus"){var J=!1;return XJ(Z,J)}return v0.warn('Unhandled audio codec "'+Z+'" in mp4 MAP'),Z||"mp4a"}return v0.warn('Unhandled video codec "'+Z+'" in mp4 MAP'),Z||"avc1"}var t1;try{t1=self.performance.now.bind(self.performance)}catch(X){t1=Date.now}var WQ=[{demux:n7,remux:W9},{demux:s7,remux:GQ},{demux:k7,remux:GQ},{demux:u7,remux:GQ}],KQ=function(){function X(Z,J,Y,Q,G,q){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=J,this.config=Y,this.id=G,this.logger=q}var W=X.prototype;return W.configure=function Z(J){if(this.transmuxConfig=J,this.decrypter)this.decrypter.reset()},W.push=function Z(J,Y,Q,G){var q=this,H=Q.transmuxing;H.executeStart=t1();var V=new Uint8Array(J),z=this.currentTransmuxState,A=this.transmuxConfig;if(G)this.currentTransmuxState=G;var E=G||z,I=E.contiguous,$=E.discontinuity,L=E.trackSwitch,b=E.accurateTimeOffset,C=E.timeOffset,D=E.initSegmentChange,y=A.audioCodec,S=A.videoCodec,v=A.defaultInitPts,p=A.duration,g=A.initSegmentData,m=q9(V,Y);if(m&&hY(m.method)){var r=this.getDecrypter(),o=C2(m.method);if(r.isSync()){var c=r.softwareDecrypt(V,m.key.buffer,m.iv.buffer,o),d=Q.part>-1;if(d){var e=r.flush();c=e?e.buffer:e}if(!c)return H.executeEnd=t1(),qQ(Q);V=new Uint8Array(c)}else return this.asyncResult=!0,this.decryptionPromise=r.webCryptoDecrypt(V,m.key.buffer,m.iv.buffer,o).then(function(V0){var j0=q.push(V0,null,Q);return q.decryptionPromise=null,j0}),this.decryptionPromise}var H0=this.needsProbing($,L);if(H0){var Q0=this.configureTransmuxer(V);if(Q0)return this.logger.warn("[transmuxer] "+Q0.message),this.observer.emit(M.ERROR,M.ERROR,{type:n.MEDIA_ERROR,details:h.FRAG_PARSING_ERROR,fatal:!1,error:Q0,reason:Q0.message}),H.executeEnd=t1(),qQ(Q)}if($||L||D||H0)this.resetInitSegment(g,y,S,p,Y);if($||D||H0)this.resetInitialTimestamp(v);if(!I)this.resetContiguity();var J0=this.transmux(V,m,C,b,Q);this.asyncResult=VY(J0);var N0=this.currentTransmuxState;return N0.contiguous=!0,N0.discontinuity=!1,N0.trackSwitch=!1,H.executeEnd=t1(),J0},W.flush=function Z(J){var Y=this,Q=J.transmuxing;Q.executeStart=t1();var G=this.decrypter,q=this.currentTransmuxState,H=this.decryptionPromise;if(H)return this.asyncResult=!0,H.then(function(){return Y.flush(J)});var V=[],z=q.timeOffset;if(G){var A=G.flush();if(A)V.push(this.push(A.buffer,null,J))}var E=this.demuxer,I=this.remuxer;if(!E||!I){Q.executeEnd=t1();var $=[qQ(J)];if(this.asyncResult)return Promise.resolve($);return $}var L=E.flush(z);if(VY(L))return this.asyncResult=!0,L.then(function(b){return Y.flushRemux(V,b,J),V});if(this.flushRemux(V,L,J),this.asyncResult)return Promise.resolve(V);return V},W.flushRemux=function Z(J,Y,Q){var{audioTrack:G,videoTrack:q,id3Track:H,textTrack:V}=Y,z=this.currentTransmuxState,A=z.accurateTimeOffset,E=z.timeOffset;this.logger.log("[transmuxer.ts]: Flushed "+this.id+" sn: "+Q.sn+(Q.part>-1?" part: "+Q.part:"")+" of "+(this.id===G0.MAIN?"level":"track")+" "+Q.level);var I=this.remuxer.remux(G,q,H,V,E,A,!0,this.id);J.push({remuxResult:I,chunkMeta:Q}),Q.transmuxing.executeEnd=t1()},W.resetInitialTimestamp=function Z(J){var Y=this.demuxer,Q=this.remuxer;if(!Y||!Q)return;Y.resetTimeStamp(J),Q.resetTimeStamp(J)},W.resetContiguity=function Z(){var J=this.demuxer,Y=this.remuxer;if(!J||!Y)return;J.resetContiguity(),Y.resetNextTimestamp()},W.resetInitSegment=function Z(J,Y,Q,G,q){var H=this.demuxer,V=this.remuxer;if(!H||!V)return;H.resetInitSegment(J,Y,Q,G),V.resetInitSegment(J,Y,Q,q)},W.destroy=function Z(){if(this.demuxer)this.demuxer.destroy(),this.demuxer=void 0;if(this.remuxer)this.remuxer.destroy(),this.remuxer=void 0},W.transmux=function Z(J,Y,Q,G,q){var H;if(Y&&Y.method==="SAMPLE-AES")H=this.transmuxSampleAes(J,Y,Q,G,q);else H=this.transmuxUnencrypted(J,Q,G,q);return H},W.transmuxUnencrypted=function Z(J,Y,Q,G){var q=this.demuxer.demux(J,Y,!1,!this.config.progressive),H=q.audioTrack,V=q.videoTrack,z=q.id3Track,A=q.textTrack,E=this.remuxer.remux(H,V,z,A,Y,Q,!1,this.id);return{remuxResult:E,chunkMeta:G}},W.transmuxSampleAes=function Z(J,Y,Q,G,q){var H=this;return this.demuxer.demuxSampleAes(J,Y,Q).then(function(V){var z=H.remuxer.remux(V.audioTrack,V.videoTrack,V.id3Track,V.textTrack,Q,G,!1,H.id);return{remuxResult:z,chunkMeta:q}})},W.configureTransmuxer=function Z(J){var Y=this.config,Q=this.observer,G=this.typeSupported,q;for(var H=0,V=WQ.length;H<V;H++){var z;if((z=WQ[H].demux)!=null&&z.probe(J,this.logger)){q=WQ[H];break}}if(!q)return new Error("Failed to find demuxer by probing fragment data");var A=this.demuxer,E=this.remuxer,I=q.remux,$=q.demux;if(!E||!(E instanceof I))this.remuxer=new I(Q,Y,G,this.logger);if(!A||!(A instanceof $))this.demuxer=new $(Q,Y,G,this.logger),this.probe=$.probe},W.needsProbing=function Z(J,Y){return!this.demuxer||!this.remuxer||J||Y},W.getDecrypter=function Z(){var J=this.decrypter;if(!J)J=this.decrypter=new JQ(this.config);return J},X}();function q9(X,W){var Z=null;if(X.byteLength>0&&(W==null?void 0:W.key)!=null&&W.iv!==null&&W.method!=null)Z=W;return Z}var qQ=function X(W){return{remuxResult:{},chunkMeta:W}};function VY(X){return"then"in X&&X.then instanceof Function}var H9=function X(W,Z,J,Y,Q){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=W,this.videoCodec=Z,this.initSegmentData=J,this.duration=Y,this.defaultInitPts=Q||null},N9=function X(W,Z,J,Y,Q,G){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=W,this.contiguous=Z,this.accurateTimeOffset=J,this.trackSwitch=Y,this.timeOffset=Q,this.initSegmentChange=G};function U9(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(X){}return!1}var V9=/(\d+)-(\d+)\/(\d+)/,jZ=function(){function X(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||O9,this.controller=new self.AbortController,this.stats=new gJ}var W=X.prototype;return W.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},W.abortInternal=function Z(){if(this.controller&&!this.stats.loading.end)this.stats.aborted=!0,this.controller.abort()},W.abort=function Z(){var J;if(this.abortInternal(),(J=this.callbacks)!=null&&J.onAbort)this.callbacks.onAbort(this.stats,this.context,this.response)},W.load=function Z(J,Y,Q){var G=this,q=this.stats;if(q.loading.start)throw new Error("Loader can only be used once.");q.loading.start=self.performance.now();var H=z9(J,this.controller.signal),V=J.responseType==="arraybuffer",z=V?"byteLength":"length",A=Y.loadPolicy,E=A.maxTimeToFirstByteMs,I=A.maxLoadTimeMs;this.context=J,this.config=Y,this.callbacks=Q,this.request=this.fetchSetup(J,H),self.clearTimeout(this.requestTimeout),Y.timeout=E&&T(E)?E:I,this.requestTimeout=self.setTimeout(function(){if(G.callbacks)G.abortInternal(),G.callbacks.onTimeout(q,J,G.response)},Y.timeout);var $=VY(this.request)?this.request.then(self.fetch):self.fetch(this.request);$.then(function(L){var b;G.response=G.loader=L;var C=Math.max(self.performance.now(),q.loading.start);if(self.clearTimeout(G.requestTimeout),Y.timeout=I,G.requestTimeout=self.setTimeout(function(){if(G.callbacks)G.abortInternal(),G.callbacks.onTimeout(q,J,G.response)},I-(C-q.loading.start)),!L.ok){var{status:D,statusText:y}=L;throw new F9(y||"fetch, bad network response",D,L)}q.loading.first=C,q.total=A9(L.headers)||q.total;var S=(b=G.callbacks)==null?void 0:b.onProgress;if(S&&T(Y.highWaterMark))return G.loadProgressively(L,q,J,Y.highWaterMark,S);if(V)return L.arrayBuffer();if(J.responseType==="json")return L.json();return L.text()}).then(function(L){var b,C,D=G.response;if(!D)throw new Error("loader destroyed");self.clearTimeout(G.requestTimeout),q.loading.end=Math.max(self.performance.now(),q.loading.first);var y=L[z];if(y)q.loaded=q.total=y;var S={url:D.url,data:L,code:D.status},v=(b=G.callbacks)==null?void 0:b.onProgress;if(v&&!T(Y.highWaterMark))v(q,J,L,D);(C=G.callbacks)==null||C.onSuccess(S,q,J,D)}).catch(function(L){var b;if(self.clearTimeout(G.requestTimeout),q.aborted)return;var C=!L?0:L.code||0,D=!L?null:L.message;(b=G.callbacks)==null||b.onError({code:C,text:D},J,L?L.details:null,q)})},W.getCacheAge=function Z(){var J=null;if(this.response){var Y=this.response.headers.get("age");J=Y?parseFloat(Y):null}return J},W.getResponseHeader=function Z(J){return this.response?this.response.headers.get(J):null},W.loadProgressively=function Z(J,Y,Q,G,q){if(G===void 0)G=0;var H=new N7,V=J.body.getReader(),z=function A(){return V.read().then(function(E){if(E.done){if(H.dataLength)q(Y,Q,H.flush().buffer,J);return Promise.resolve(new ArrayBuffer(0))}var I=E.value,$=I.length;if(Y.loaded+=$,$<G||H.dataLength){if(H.push(I),H.dataLength>=G)q(Y,Q,H.flush().buffer,J)}else q(Y,Q,I.buffer,J);return z()}).catch(function(){return Promise.reject()})};return z()},X}();function z9(X,W){var Z={method:"GET",mode:"cors",credentials:"same-origin",signal:W,headers:new self.Headers(B({},X.headers))};if(X.rangeEnd)Z.headers.set("Range","bytes="+X.rangeStart+"-"+String(X.rangeEnd-1));return Z}function j9(X){var W=V9.exec(X);if(W)return parseInt(W[2])-parseInt(W[1])+1}function A9(X){var W=X.get("Content-Range");if(W){var Z=j9(W);if(T(Z))return Z}var J=X.get("Content-Length");if(J)return parseInt(J)}function O9(X,W){return new self.Request(X.url,W)}var F9=function(X){function W(Z,J,Y){var Q=X.call(this,Z)||this;return Q.code=void 0,Q.details=void 0,Q.code=J,Q.details=Y,Q}return R(W,X),W}(t(Error)),E9=/^age:\s*[\d.]+\s*$/im,AZ=function(){function X(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 gJ,this.retryDelay=0}var W=X.prototype;return W.destroy=function Z(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null},W.abortInternal=function Z(){var J=this.loader;if(self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),J){if(J.onreadystatechange=null,J.onprogress=null,J.readyState!==4)this.stats.aborted=!0,J.abort()}},W.abort=function Z(){var J;if(this.abortInternal(),(J=this.callbacks)!=null&&J.onAbort)this.callbacks.onAbort(this.stats,this.context,this.loader)},W.load=function Z(J,Y,Q){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=J,this.config=Y,this.callbacks=Q,this.loadInternal()},W.loadInternal=function Z(){var J=this,Y=this.config,Q=this.context;if(!Y||!Q)return;var G=this.loader=new self.XMLHttpRequest,q=this.stats;q.loading.first=0,q.loaded=0,q.aborted=!1;var H=this.xhrSetup;if(H)Promise.resolve().then(function(){if(J.loader!==G||J.stats.aborted)return;return H(G,Q.url)}).catch(function(V){if(J.loader!==G||J.stats.aborted)return;return G.open("GET",Q.url,!0),H(G,Q.url)}).then(function(){if(J.loader!==G||J.stats.aborted)return;J.openAndSendXhr(G,Q,Y)}).catch(function(V){var z;(z=J.callbacks)==null||z.onError({code:G.status,text:V.message},Q,G,q);return});else this.openAndSendXhr(G,Q,Y)},W.openAndSendXhr=function Z(J,Y,Q){if(!J.readyState)J.open("GET",Y.url,!0);var G=Y.headers,q=Q.loadPolicy,H=q.maxTimeToFirstByteMs,V=q.maxLoadTimeMs;if(G)for(var z in G)J.setRequestHeader(z,G[z]);if(Y.rangeEnd)J.setRequestHeader("Range","bytes="+Y.rangeStart+"-"+(Y.rangeEnd-1));J.onreadystatechange=this.readystatechange.bind(this),J.onprogress=this.loadprogress.bind(this),J.responseType=Y.responseType,self.clearTimeout(this.requestTimeout),Q.timeout=H&&T(H)?H:V,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),Q.timeout),J.send()},W.readystatechange=function Z(){var J=this.context,Y=this.loader,Q=this.stats;if(!J||!Y)return;var G=Y.readyState,q=this.config;if(Q.aborted)return;if(G>=2){if(Q.loading.first===0){if(Q.loading.first=Math.max(self.performance.now(),Q.loading.start),q.timeout!==q.loadPolicy.maxLoadTimeMs)self.clearTimeout(this.requestTimeout),q.timeout=q.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),q.loadPolicy.maxLoadTimeMs-(Q.loading.first-Q.loading.start))}if(G===4){self.clearTimeout(this.requestTimeout),Y.onreadystatechange=null,Y.onprogress=null;var H=Y.status,V=Y.responseType==="text"?Y.responseText:null;if(H>=200&&H<300){var z=V!=null?V:Y.response;if(z!=null){var A,E;Q.loading.end=Math.max(self.performance.now(),Q.loading.first);var I=Y.responseType==="arraybuffer"?z.byteLength:z.length;Q.loaded=Q.total=I,Q.bwEstimate=Q.total*8000/(Q.loading.end-Q.loading.first);var $=(A=this.callbacks)==null?void 0:A.onProgress;if($)$(Q,J,z,Y);var L={url:Y.responseURL,data:z,code:H};(E=this.callbacks)==null||E.onSuccess(L,Q,J,Y);return}}var b=q.loadPolicy.errorRetry,C=Q.retry,D={url:J.url,data:void 0,code:H};if(HJ(b,C,!1,D))this.retry(b);else{var y;v0.error(H+" while loading "+J.url),(y=this.callbacks)==null||y.onError({code:H,text:Y.statusText},J,Y,Q)}}}},W.loadtimeout=function Z(){if(!this.config)return;var J=this.config.loadPolicy.timeoutRetry,Y=this.stats.retry;if(HJ(J,Y,!0))this.retry(J);else{var Q;v0.warn("timeout while loading "+((Q=this.context)==null?void 0:Q.url));var G=this.callbacks;if(G)this.abortInternal(),G.onTimeout(this.stats,this.context,this.loader)}},W.retry=function Z(J){var Y=this.context,Q=this.stats;this.retryDelay=nJ(J,Q.retry),Q.retry++,v0.warn((status?"HTTP Status "+status:"Timeout")+" while loading "+(Y==null?void 0:Y.url)+", retrying "+Q.retry+"/"+J.maxNumRetry+" in "+this.retryDelay+"ms"),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)},W.loadprogress=function Z(J){var Y=this.stats;if(Y.loaded=J.loaded,J.lengthComputable)Y.total=J.total},W.getCacheAge=function Z(){var J=null;if(this.loader&&E9.test(this.loader.getAllResponseHeaders())){var Y=this.loader.getResponseHeader("age");J=Y?parseFloat(Y):null}return J},W.getResponseHeader=function Z(J){if(this.loader&&new RegExp("^"+J+":\\s*[\\d.]+\\s*$","im").test(this.loader.getAllResponseHeaders()))return this.loader.getResponseHeader(J);return null},X}(),OZ={maxTimeToFirstByteMs:8000,maxLoadTimeMs:20000,timeoutRetry:null,errorRetry:null},B9=f(f({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:AZ,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:yX,bufferController:_X,capLevelController:fX,errorController:uX,fpsController:H7,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:OZ},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:OZ},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1000,manifestLoadingMaxRetryTimeout:64000,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1000,levelLoadingMaxRetryTimeout:64000,fragLoadingTimeOut:20000,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1000,fragLoadingMaxRetryTimeout:64000},w9()),{},{subtitleStreamController:void 0,subtitleTrackController:void 0,timelineController:void 0,audioStreamController:void 0,audioTrackController:void 0,emeController:void 0,cmcdController:void 0,contentSteeringController:q7,interstitialsController:void 0});function w9(){return{cueHandler:JX,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 R9(X,W,Z){if((W.liveSyncDurationCount||W.liveMaxLatencyDurationCount)&&(W.liveSyncDuration||W.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(W.liveMaxLatencyDurationCount!==void 0&&(W.liveSyncDurationCount===void 0||W.liveMaxLatencyDurationCount<=W.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(W.liveMaxLatencyDuration!==void 0&&(W.liveSyncDuration===void 0||W.liveMaxLatencyDuration<=W.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var J=HQ(X),Y=["manifest","level","frag"],Q=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return Y.forEach(function(G){var q=(G==="level"?"playlist":G)+"LoadPolicy",H=W[q]===void 0,V=[];if(Q.forEach(function(z){var A=G+"Loading"+z,E=W[A];if(E!==void 0&&H){V.push(A);var I=J[q].default;switch(W[q]={default:I},z){case"TimeOut":I.maxLoadTimeMs=E,I.maxTimeToFirstByteMs=E;break;case"MaxRetry":I.errorRetry.maxNumRetry=E,I.timeoutRetry.maxNumRetry=E;break;case"RetryDelay":I.errorRetry.retryDelayMs=E,I.timeoutRetry.retryDelayMs=E;break;case"MaxRetryTimeout":I.errorRetry.maxRetryDelayMs=E,I.timeoutRetry.maxRetryDelayMs=E;break}}}),V.length)Z.warn('hls.js config: "'+V.join('", "')+'" setting(s) are deprecated, use "'+q+'": '+O1(W[q]))}),f(f({},J),W)}function HQ(X){if(X&&typeof X==="object"){if(Array.isArray(X))return X.map(HQ);return Object.keys(X).reduce(function(W,Z){return W[Z]=HQ(X[Z]),W},{})}return X}function $9(X,W){var Z=X.loader;if(Z!==jZ&&Z!==AZ)W.log("[config]: Custom loader detected, cannot enable progressive streaming"),X.progressive=!1;else{var J=U9();if(J)X.loader=jZ,X.progressive=!0,X.enableSoftwareAES=!0,W.log("[config]: Progressive streaming enabled, using FetchLoader")}}var B1={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"},I9=function(){function X(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 W=X.prototype;return W._registerListeners=function Z(){var J=this.hls;J.on(M.MANIFEST_LOADING,this.onManifestLoading,this),J.on(M.BUFFER_APPENDED,this.onBufferAppended,this),J.on(M.FRAG_BUFFERED,this.onFragBuffered,this),J.on(M.FRAG_LOADED,this.onFragLoaded,this)},W._unregisterListeners=function Z(){var J=this.hls;J.off(M.MANIFEST_LOADING,this.onManifestLoading,this),J.off(M.BUFFER_APPENDED,this.onBufferAppended,this),J.off(M.FRAG_BUFFERED,this.onFragBuffered,this),J.off(M.FRAG_LOADED,this.onFragLoaded,this)},W.destroy=function Z(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null},W.getAppendedFrag=function Z(J,Y){var Q=this.activePartLists[Y];if(Q)for(var G=Q.length;G--;){var q=Q[G];if(!q)break;var H=q.end;if(q.start<=J&&H!==null&&J<=H)return q}return this.getBufferedFrag(J,Y)},W.getBufferedFrag=function Z(J,Y){return this.getFragAtPos(J,Y,!0)},W.getFragAtPos=function Z(J,Y,Q){var G=this.fragments,q=Object.keys(G);for(var H=q.length;H--;){var V=G[q[H]];if((V==null?void 0:V.body.type)===Y&&(!Q||V.buffered)){var z=V.body;if(z.start<=J&&J<=z.end)return z}}return null},W.detectEvictedFragments=function Z(J,Y,Q,G,q){var H=this;if(this.timeRanges)this.timeRanges[J]=Y;var V=(G==null?void 0:G.fragment.sn)||-1;Object.keys(this.fragments).forEach(function(z){var A=H.fragments[z];if(!A)return;if(V>=A.body.sn)return;if(!A.buffered&&(!A.loaded||q)){if(A.body.type===Q)H.removeFragment(A.body);return}var E=A.range[J];if(!E)return;if(E.time.length===0){H.removeFragment(A.body);return}E.time.some(function(I){var $=!H.isTimeBuffered(I.startPTS,I.endPTS,Y);if($)H.removeFragment(A.body);return $})})},W.detectPartialFragments=function Z(J){var Y=this,Q=this.timeRanges;if(!Q||J.frag.sn==="initSegment")return;var G=J.frag,q=wY(G),H=this.fragments[q];if(!H||H.buffered&&G.gap)return;var V=!G.relurl;if(Object.keys(Q).forEach(function(A){var E=G.elementaryStreams[A];if(!E)return;var I=Q[A],$=V||E.partial===!0;H.range[A]=Y.getBufferedTimes(G,J.part,$,I)}),H.loaded=null,Object.keys(H.range).length){H.buffered=!0;var z=H.body.endList=G.endList||H.body.endList;if(z)this.endListFragments[H.body.type]=H;if(!FJ(H))this.removeParts(G.sn-1,G.type)}else this.removeFragment(H.body)},W.removeParts=function Z(J,Y){var Q=this.activePartLists[Y];if(!Q)return;this.activePartLists[Y]=Q.filter(function(G){return G.fragment.sn>=J})},W.fragBuffered=function Z(J,Y){var Q=wY(J),G=this.fragments[Q];if(!G&&Y){if(G=this.fragments[Q]={body:J,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},J.gap)this.hasGaps=!0}if(G)G.loaded=null,G.buffered=!0},W.getBufferedTimes=function Z(J,Y,Q,G){var q={time:[],partial:Q},H=J.start,V=J.end,z=J.minEndPTS||V,A=J.maxStartPTS||H;for(var E=0;E<G.length;E++){var I=G.start(E)-this.bufferPadding,$=G.end(E)+this.bufferPadding;if(A>=I&&z<=$){q.time.push({startPTS:Math.max(H,G.start(E)),endPTS:Math.min(V,G.end(E))});break}else if(H<$&&V>I){var L=Math.max(H,G.start(E)),b=Math.min(V,G.end(E));if(b>L)q.partial=!0,q.time.push({startPTS:L,endPTS:b})}else if(V<=I)break}return q},W.getPartialFragment=function Z(J){var Y=null,Q,G,q,H=0,V=this.bufferPadding,z=this.fragments;return Object.keys(z).forEach(function(A){var E=z[A];if(!E)return;if(FJ(E)){if(G=E.body.start-V,q=E.body.end+V,J>=G&&J<=q){if(Q=Math.min(J-G,q-J),H<=Q)Y=E.body,H=Q}}}),Y},W.isEndListAppended=function Z(J){var Y=this.endListFragments[J];return Y!==void 0&&(Y.buffered||FJ(Y))},W.getState=function Z(J){var Y=wY(J),Q=this.fragments[Y];if(Q)if(!Q.buffered)return B1.APPENDING;else if(FJ(Q))return B1.PARTIAL;else return B1.OK;return B1.NOT_LOADED},W.isTimeBuffered=function Z(J,Y,Q){var G,q;for(var H=0;H<Q.length;H++){if(G=Q.start(H)-this.bufferPadding,q=Q.end(H)+this.bufferPadding,J>=G&&Y<=q)return!0;if(Y<=G)return!1}return!1},W.onManifestLoading=function Z(){this.removeAllFragments()},W.onFragLoaded=function Z(J,Y){if(Y.frag.sn==="initSegment"||Y.frag.bitrateTest)return;var Q=Y.frag,G=Y.part?null:Y,q=wY(Q);this.fragments[q]={body:Q,appendedPTS:null,loaded:G,buffered:!1,range:Object.create(null)}},W.onBufferAppended=function Z(J,Y){var{frag:Q,part:G,timeRanges:q,type:H}=Y;if(Q.sn==="initSegment")return;var V=Q.type;if(G){var z=this.activePartLists[V];if(!z)this.activePartLists[V]=z=[];z.push(G)}this.timeRanges=q;var A=q[H];this.detectEvictedFragments(H,A,V,G)},W.onFragBuffered=function Z(J,Y){this.detectPartialFragments(Y)},W.hasFragment=function Z(J){var Y=wY(J);return!!this.fragments[Y]},W.hasFragments=function Z(J){var Y=this.fragments,Q=Object.keys(Y);if(!J)return Q.length>0;for(var G=Q.length;G--;){var q=Y[Q[G]];if((q==null?void 0:q.body.type)===J)return!0}return!1},W.hasParts=function Z(J){var Y;return!!((Y=this.activePartLists[J])!=null&&Y.length)},W.removeFragmentsInRange=function Z(J,Y,Q,G,q){var H=this;if(G&&!this.hasGaps)return;Object.keys(this.fragments).forEach(function(V){var z=H.fragments[V];if(!z)return;var A=z.body;if(A.type!==Q||G&&!A.gap)return;if(A.start<Y&&A.end>J&&(z.buffered||q))H.removeFragment(A)})},W.removeFragment=function Z(J){var Y=wY(J);J.clearElementaryStreamInfo();var Q=this.activePartLists[J.type];if(Q){var G=J.sn;this.activePartLists[J.type]=Q.filter(function(q){return q.fragment.sn!==G})}if(delete this.fragments[Y],J.endList)delete this.endListFragments[J.type]},W.removeAllFragments=function Z(){var J,Y;this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1;var Q=(J=this.hls)==null?void 0:(Y=J.latestLevelDetails)==null?void 0:Y.partList;if(Q)Q.forEach(function(G){return G.clearElementaryStreamInfo()})},X}();function FJ(X){var W,Z,J;return X.buffered&&(X.body.gap||((W=X.range.video)==null?void 0:W.partial)||((Z=X.range.audio)==null?void 0:Z.partial)||((J=X.range.audiovideo)==null?void 0:J.partial))}function wY(X){return X.type+"_"+X.level+"_"+X.sn}var FZ=Math.pow(2,17),L9=function(){function X(Z){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=Z}var W=X.prototype;return W.destroy=function Z(){if(this.loader)this.loader.destroy(),this.loader=null},W.abort=function Z(){if(this.loader)this.loader.abort()},W.load=function Z(J,Y){var Q=this,G=J.url;if(!G)return Promise.reject(new e1({type:n.NETWORK_ERROR,details:h.FRAG_LOAD_ERROR,fatal:!1,frag:J,error:new Error("Fragment does not have a "+(G?"part list":"url")),networkDetails:null}));this.abort();var q=this.config,H=q.fLoader,V=q.loader;return new Promise(function(z,A){if(Q.loader)Q.loader.destroy();if(J.gap)if(J.tagList.some(function(C){return C[0]==="GAP"})){A(BZ(J));return}else J.gap=!1;var E=Q.loader=H?new H(q):new V(q),I=EZ(J);J.loader=E;var $=w2(q.fragLoadPolicy.default),L={loadPolicy:$,timeout:$.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:J.sn==="initSegment"?1/0:FZ};J.stats=E.stats;var b={onSuccess:function C(D,y,S,v){Q.resetLoader(J,E);var p=D.data;if(S.resetIV&&J.decryptdata)J.decryptdata.iv=new Uint8Array(p.slice(0,16)),p=p.slice(16);z({frag:J,part:null,payload:p,networkDetails:v})},onError:function C(D,y,S,v){Q.resetLoader(J,E),A(new e1({type:n.NETWORK_ERROR,details:h.FRAG_LOAD_ERROR,fatal:!1,frag:J,response:f({url:G,data:void 0},D),error:new Error("HTTP Error "+D.code+" "+D.text),networkDetails:S,stats:v}))},onAbort:function C(D,y,S){Q.resetLoader(J,E),A(new e1({type:n.NETWORK_ERROR,details:h.INTERNAL_ABORTED,fatal:!1,frag:J,error:new Error("Aborted"),networkDetails:S,stats:D}))},onTimeout:function C(D,y,S){Q.resetLoader(J,E),A(new e1({type:n.NETWORK_ERROR,details:h.FRAG_LOAD_TIMEOUT,fatal:!1,frag:J,error:new Error("Timeout after "+L.timeout+"ms"),networkDetails:S,stats:D}))}};if(Y)b.onProgress=function(C,D,y,S){return Y({frag:J,part:null,payload:y,networkDetails:S})};E.load(I,L,b)})},W.loadPart=function Z(J,Y,Q){var G=this;this.abort();var q=this.config,H=q.fLoader,V=q.loader;return new Promise(function(z,A){if(G.loader)G.loader.destroy();if(J.gap||Y.gap){A(BZ(J,Y));return}var E=G.loader=H?new H(q):new V(q),I=EZ(J,Y);J.loader=E;var $=w2(q.fragLoadPolicy.default),L={loadPolicy:$,timeout:$.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:FZ};Y.stats=E.stats,E.load(I,L,{onSuccess:function b(C,D,y,S){G.resetLoader(J,E),G.updateStatsFromPart(J,Y);var v={frag:J,part:Y,payload:C.data,networkDetails:S};Q(v),z(v)},onError:function b(C,D,y,S){G.resetLoader(J,E),A(new e1({type:n.NETWORK_ERROR,details:h.FRAG_LOAD_ERROR,fatal:!1,frag:J,part:Y,response:f({url:I.url,data:void 0},C),error:new Error("HTTP Error "+C.code+" "+C.text),networkDetails:y,stats:S}))},onAbort:function b(C,D,y){J.stats.aborted=Y.stats.aborted,G.resetLoader(J,E),A(new e1({type:n.NETWORK_ERROR,details:h.INTERNAL_ABORTED,fatal:!1,frag:J,part:Y,error:new Error("Aborted"),networkDetails:y,stats:C}))},onTimeout:function b(C,D,y){G.resetLoader(J,E),A(new e1({type:n.NETWORK_ERROR,details:h.FRAG_LOAD_TIMEOUT,fatal:!1,frag:J,part:Y,error:new Error("Timeout after "+L.timeout+"ms"),networkDetails:y,stats:C}))}})})},W.updateStatsFromPart=function Z(J,Y){var Q=J.stats,G=Y.stats,q=G.total;if(Q.loaded+=G.loaded,q){var H=Math.round(J.duration/Y.duration),V=Math.min(Math.round(Q.loaded/q),H),z=H-V,A=z*Math.round(Q.loaded/V);Q.total=Q.loaded+A}else Q.total=Math.max(Q.loaded,Q.total);var E=Q.loading,I=G.loading;if(E.start)E.first+=I.first-I.start;else E.start=I.start,E.first=I.first;E.end=I.end},W.resetLoader=function Z(J,Y){if(J.loader=null,this.loader===Y)self.clearTimeout(this.partLoadTimeout),this.loader=null;Y.destroy()},X}();function EZ(X,W){if(W===void 0)W=null;var Z=W||X,J={frag:X,part:W,responseType:"arraybuffer",url:Z.url,headers:{},rangeStart:0,rangeEnd:0},Y=Z.byteRangeStartOffset,Q=Z.byteRangeEndOffset;if(T(Y)&&T(Q)){var G,q=Y,H=Q;if(X.sn==="initSegment"&&b9((G=X.decryptdata)==null?void 0:G.method)){var V=Q-Y;if(V%16)H=Q+(16-V%16);if(Y!==0)J.resetIV=!0,q=Y-16}J.rangeStart=q,J.rangeEnd=H}return J}function BZ(X,W){var Z=new Error("GAP "+(X.gap?"tag":"attribute")+" found"),J={type:n.MEDIA_ERROR,details:h.FRAG_GAP,fatal:!1,frag:X,error:Z,networkDetails:null};if(W)J.part=W;return(W?W:X).stats.aborted=!0,new e1(J)}function b9(X){return X==="AES-128"||X==="AES-256"}var e1=function(X){function W(Z){var J=X.call(this,Z.error.message)||this;return J.data=void 0,J.data=Z,J}return R(W,X),W}(t(Error)),wZ=function(X){function W(J,Y){var Q=X.call(this,J,Y)||this;return Q._boundTick=void 0,Q._tickTimer=null,Q._tickInterval=null,Q._tickCallCount=0,Q._boundTick=Q.tick.bind(Q),Q}R(W,X);var Z=W.prototype;return Z.destroy=function J(){this.onHandlerDestroying(),this.onHandlerDestroyed()},Z.onHandlerDestroying=function J(){this.clearNextTick(),this.clearInterval()},Z.onHandlerDestroyed=function J(){},Z.hasInterval=function J(){return!!this._tickInterval},Z.hasNextTick=function J(){return!!this._tickTimer},Z.setInterval=function J(Y){if(!this._tickInterval)return this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,Y),!0;return!1},Z.clearInterval=function J(){if(this._tickInterval)return self.clearInterval(this._tickInterval),this._tickInterval=null,!0;return!1},Z.clearNextTick=function J(){if(this._tickTimer)return self.clearTimeout(this._tickTimer),this._tickTimer=null,!0;return!1},Z.tick=function J(){if(this._tickCallCount++,this._tickCallCount===1){if(this.doTick(),this._tickCallCount>1)this.tickImmediate();this._tickCallCount=0}},Z.tickImmediate=function J(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},Z.doTick=function J(){},W}(d0),RZ=function X(W,Z,J,Y,Q,G){if(Y===void 0)Y=0;if(Q===void 0)Q=-1;if(G===void 0)G=!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=EJ(),this.buffering={audio:EJ(),video:EJ(),audiovideo:EJ()},this.level=W,this.sn=Z,this.id=J,this.size=Y,this.part=Q,this.partial=G};function EJ(){return{start:0,executeStart:0,executeEnd:0,end:0}}function uY(X,W){for(var Z=0,J=X.length;Z<J;Z++){var Y;if(((Y=X[Z])==null?void 0:Y.cc)===W)return X[Z]}return null}function M9(X,W){if(X){if(W.startCC<X.endCC&&W.endCC>X.startCC)return!0}return!1}function $Z(X,W){if(X){var Z=X.start+W;X.start=X.startPTS=Z,X.endPTS=Z+X.duration}}function IZ(X,W){var Z=W.fragments;for(var J=0,Y=Z.length;J<Y;J++)$Z(Z[J],X);if(W.fragmentHint)$Z(W.fragmentHint,X);W.alignedSliding=!0}function C9(X,W){if(!X)return;if(D9(W,X),!W.alignedSliding&&X)S9(W,X);if(!W.alignedSliding&&X&&!W.skippedSegments)_2(X,W,!1)}function D9(X,W){if(!M9(W,X))return;var Z=Math.min(W.endCC,X.endCC),J=uY(W.fragments,Z),Y=uY(X.fragments,Z);if(!J||!Y)return;v0.log("Aligning playlist at start of dicontinuity sequence "+Z);var Q=J.start-Y.start;IZ(Q,X)}function S9(X,W){if(!X.hasProgramDateTime||!W.hasProgramDateTime)return;var Z=X.fragments,J=W.fragments;if(!Z.length||!J.length)return;var Y,Q,G=Math.min(W.endCC,X.endCC);if(W.startCC<G&&X.startCC<G)Y=uY(J,G),Q=uY(Z,G);if(!Y||!Q)Y=J[Math.floor(J.length/2)],Q=uY(Z,Y.cc)||Z[Math.floor(Z.length/2)];var q=Y.programDateTime,H=Q.programDateTime;if(!q||!H)return;var V=(H-q)/1000-(Q.start-Y.start);IZ(V,X)}var P9={toString:function X(W){var Z="",J=W.length;for(var Y=0;Y<J;Y++)Z+="["+W.start(Y).toFixed(3)+"-"+W.end(Y).toFixed(3)+"]";return Z}},X0={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"},y9=function(X){function W(J,Y,Q,G,q){var H=X.call(this,G,J.logger)||this;return H.hls=void 0,H.fragPrevious=null,H.fragCurrent=null,H.fragmentTracker=void 0,H.transmuxer=null,H._state=X0.STOPPED,H.playlistType=void 0,H.media=null,H.mediaBuffer=null,H.config=void 0,H.bitrateTest=!1,H.lastCurrentTime=0,H.nextLoadPosition=0,H.startPosition=0,H.startTimeOffset=null,H.retryDate=0,H.levels=null,H.fragmentLoader=void 0,H.keyLoader=void 0,H.levelLastLoaded=null,H.startFragRequested=!1,H.decrypter=void 0,H.initPTS=[],H.buffering=!0,H.loadingParts=!1,H.loopSn=void 0,H.onMediaSeeking=function(){var V=H,z=V.config,A=V.fragCurrent,E=V.media,I=V.mediaBuffer,$=V.state,L=E?E.currentTime:0,b=k0.bufferInfo(I?I:E,L,z.maxBufferHole);if(H.log("media seeking to "+(T(L)?L.toFixed(3):L)+", state: "+$),H.state===X0.ENDED)H.resetLoadingState();else if(A){var C=z.maxFragLookUpTolerance,D=A.start-C,y=A.start+A.duration+C;if(!b.len||y<b.start||D>b.end){var S=L>y;if(L<D||S){if(S&&A.loader)H.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),A.abortRequests(),H.resetLoadingState();H.fragPrevious=null}}}if(E){H.fragmentTracker.removeFragmentsInRange(L,1/0,H.playlistType,!0);var v=H.lastCurrentTime;if(L>v)H.lastCurrentTime=L;if(!H.loadingParts){var p=Math.max(b.end,L),g=H.shouldLoadParts(H.getLevelDetails(),p);if(g)H.log("LL-Part loading ON after seeking to "+L.toFixed(2)+" with buffer @"+p.toFixed(2)),H.loadingParts=g}}if(!H.hls.hasEnoughToStart&&!b.len)H.log("setting startPosition to "+L+" because of seek before start"),H.nextLoadPosition=H.startPosition=L;H.tickImmediate()},H.onMediaEnded=function(){H.log("setting startPosition to 0 because media ended"),H.startPosition=H.lastCurrentTime=0},H.playlistType=q,H.hls=J,H.fragmentLoader=new L9(J.config),H.keyLoader=Q,H.fragmentTracker=Y,H.config=J.config,H.decrypter=new JQ(J.config),H}R(W,X);var Z=W.prototype;return Z.registerListeners=function J(){var Y=this.hls;Y.on(M.MEDIA_ATTACHED,this.onMediaAttached,this),Y.on(M.MEDIA_DETACHING,this.onMediaDetaching,this),Y.on(M.MANIFEST_LOADING,this.onManifestLoading,this),Y.on(M.MANIFEST_LOADED,this.onManifestLoaded,this),Y.on(M.ERROR,this.onError,this)},Z.unregisterListeners=function J(){var Y=this.hls;Y.off(M.MEDIA_ATTACHED,this.onMediaAttached,this),Y.off(M.MEDIA_DETACHING,this.onMediaDetaching,this),Y.off(M.MANIFEST_LOADING,this.onManifestLoading,this),Y.off(M.MANIFEST_LOADED,this.onManifestLoaded,this),Y.off(M.ERROR,this.onError,this)},Z.doTick=function J(){this.onTickEnd()},Z.onTickEnd=function J(){},Z.startLoad=function J(Y){},Z.stopLoad=function J(){if(this.state===X0.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=X0.STOPPED},Z.pauseBuffering=function J(){this.buffering=!1},Z.resumeBuffering=function J(){this.buffering=!0},Z._streamEnded=function J(Y,Q){if(Q.live||!this.media)return!1;var G=Y.end||0,q=this.config.timelineOffset||0;if(G<=q)return!1;var H=Y.nextStart,V=H&&H>q&&H<Q.edge;if(V)return!1;if(this.media.currentTime<Y.start)return!1;var z=Q.partList;if(z!=null&&z.length){var A=z[z.length-1],E=k0.isBuffered(this.media,A.start+A.duration/2);return E}var I=Q.fragments[Q.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(I)},Z.getLevelDetails=function J(){if(this.levels&&this.levelLastLoaded!==null){var Y;return(Y=this.levelLastLoaded)==null?void 0:Y.details}},Z.onMediaAttached=function J(Y,Q){var G=this.media=this.mediaBuffer=Q.media;G.removeEventListener("seeking",this.onMediaSeeking),G.removeEventListener("ended",this.onMediaEnded),G.addEventListener("seeking",this.onMediaSeeking),G.addEventListener("ended",this.onMediaEnded);var q=this.config;if(this.levels&&q.autoStartLoad&&this.state===X0.STOPPED)this.startLoad(q.startPosition)},Z.onMediaDetaching=function J(Y,Q){var G=!!Q.transferMedia,q=this.media;if(q===null)return;if(q.ended)this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0;if(q.removeEventListener("seeking",this.onMediaSeeking),q.removeEventListener("ended",this.onMediaEnded),this.keyLoader&&!G)this.keyLoader.detach();if(this.media=this.mediaBuffer=null,this.loopSn=void 0,G){this.resetLoadingState(),this.resetTransmuxer();return}this.loadingParts=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},Z.onManifestLoading=function J(){this.initPTS=[],this.levels=this.levelLastLoaded=this.fragCurrent=null,this.lastCurrentTime=this.startPosition=0,this.startFragRequested=!1},Z.onError=function J(Y,Q){},Z.onManifestLoaded=function J(Y,Q){this.startTimeOffset=Q.startTimeOffset},Z.onHandlerDestroying=function J(){if(this.stopLoad(),this.transmuxer)this.transmuxer.destroy(),this.transmuxer=null;X.prototype.onHandlerDestroying.call(this),this.hls=this.onMediaSeeking=this.onMediaEnded=null},Z.onHandlerDestroyed=function J(){if(this.state=X0.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,X.prototype.onHandlerDestroyed.call(this)},Z.loadFragment=function J(Y,Q,G){this.startFragRequested=!0,this._loadFragForPlayback(Y,Q,G)},Z._loadFragForPlayback=function J(Y,Q,G){var q=this,H=function V(z){var A=z.frag;if(q.fragContextChanged(A)){q.warn(A.type+" sn: "+A.sn+(z.part?" part: "+z.part.index:"")+" of "+q.fragInfo(A,!1,z.part)+") was dropped during download."),q.fragmentTracker.removeFragment(A);return}A.stats.chunkCount++,q._handleFragmentLoadProgress(z)};this._doFragLoad(Y,Q,G,H).then(function(V){if(!V)return;var z=q.state,A=V.frag;if(q.fragContextChanged(A)){if(z===X0.FRAG_LOADING||!q.fragCurrent&&z===X0.PARSING)q.fragmentTracker.removeFragment(A),q.state=X0.IDLE;return}if("payload"in V)q.log("Loaded "+A.type+" sn: "+A.sn+" of "+q.playlistLabel()+" "+A.level),q.hls.trigger(M.FRAG_LOADED,V);q._handleFragmentLoadComplete(V)}).catch(function(V){if(q.state===X0.STOPPED||q.state===X0.ERROR)return;q.warn("Frag error: "+((V==null?void 0:V.message)||V)),q.resetFragmentLoading(Y)})},Z.clearTrackerIfNeeded=function J(Y){var Q,G=this.fragmentTracker,q=G.getState(Y);if(q===B1.APPENDING){var H=Y.type,V=this.getFwdBufferInfo(this.mediaBuffer,H),z=Math.max(Y.duration,V?V.len:this.config.maxBufferLength),A=this.backtrackFragment,E=A?Y.sn-A.sn:0;if(E===1||this.reduceMaxBufferLength(z,Y.duration))G.removeFragment(Y)}else if(((Q=this.mediaBuffer)==null?void 0:Q.buffered.length)===0)G.removeAllFragments();else if(G.hasParts(Y.type)){if(G.detectPartialFragments({frag:Y,part:null,stats:Y.stats,id:Y.type}),G.getState(Y)===B1.PARTIAL)G.removeFragment(Y)}},Z.checkLiveUpdate=function J(Y){if(Y.updated&&!Y.live){var Q=Y.fragments[Y.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:Q,part:null,stats:Q.stats,id:Q.type})}if(!Y.fragments[0])Y.deltaUpdateFailed=!0},Z.waitForLive=function J(Y){var Q=Y.details;return(Q==null?void 0:Q.live)&&Q.type!=="EVENT"&&(this.levelLastLoaded!==Y||Q.expired)},Z.flushMainBuffer=function J(Y,Q,G){if(G===void 0)G=null;if(!(Y-Q))return;var q={startOffset:Y,endOffset:Q,type:G};this.hls.trigger(M.BUFFER_FLUSHING,q)},Z._loadInitSegment=function J(Y,Q){var G=this;this._doFragLoad(Y,Q).then(function(q){var H=q==null?void 0:q.frag;if(!H||G.fragContextChanged(H)||!G.levels)throw new Error("init load aborted");return q}).then(function(q){var H=G.hls,V=q.frag,z=q.payload,A=V.decryptdata;if(z&&z.byteLength>0&&A!=null&&A.key&&A.iv&&hY(A.method)){var E=self.performance.now();return G.decrypter.decrypt(new Uint8Array(z),A.key.buffer,A.iv.buffer,C2(A.method)).catch(function(I){throw H.trigger(M.ERROR,{type:n.MEDIA_ERROR,details:h.FRAG_DECRYPT_ERROR,fatal:!1,error:I,reason:I.message,frag:V}),I}).then(function(I){var $=self.performance.now();return H.trigger(M.FRAG_DECRYPTED,{frag:V,payload:I,stats:{tstart:E,tdecrypt:$}}),q.payload=I,G.completeInitSegmentLoad(q)})}return G.completeInitSegmentLoad(q)}).catch(function(q){if(G.state===X0.STOPPED||G.state===X0.ERROR)return;G.warn(q),G.resetFragmentLoading(Y)})},Z.completeInitSegmentLoad=function J(Y){var Q=this.levels;if(!Q)throw new Error("init load aborted, missing levels");var G=Y.frag.stats;if(this.state!==X0.STOPPED)this.state=X0.IDLE;Y.frag.data=new Uint8Array(Y.payload),G.parsing.start=G.buffering.start=self.performance.now(),G.parsing.end=G.buffering.end=self.performance.now(),this.tick()},Z.fragContextChanged=function J(Y){var Q=this.fragCurrent;return!Y||!Q||Y.sn!==Q.sn||Y.level!==Q.level},Z.fragBufferedComplete=function J(Y,Q){var G=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log("Buffered "+Y.type+" sn: "+Y.sn+(Q?" part: "+Q.index:"")+" of "+this.fragInfo(Y,!1,Q)+" > buffer:"+(G?P9.toString(k0.getBuffered(G)):"(detached)")+")"),d1(Y)){var q;if(Y.type!==G0.SUBTITLE){var H=Y.elementaryStreams;if(!Object.keys(H).some(function(z){return!!H[z]})){this.state=X0.IDLE;return}}var V=(q=this.levels)==null?void 0:q[Y.level];if(V!=null&&V.fragmentError)this.log("Resetting level fragment error count of "+V.fragmentError+" on frag buffered"),V.fragmentError=0}this.state=X0.IDLE},Z._handleFragmentLoadComplete=function J(Y){var Q=this.transmuxer;if(!Q)return;var{frag:G,part:q,partsLoaded:H}=Y,V=!H||H.length===0||H.some(function(A){return!A}),z=new RZ(G.level,G.sn,G.stats.chunkCount+1,0,q?q.index:-1,!V);Q.flush(z)},Z._handleFragmentLoadProgress=function J(Y){},Z._doFragLoad=function J(Y,Q,G,q){var H,V=this;if(G===void 0)G=null;this.fragCurrent=Y;var z=Q==null?void 0:Q.details;if(!this.levels||!z)throw new Error("frag load aborted, missing level"+(z?"":" detail")+"s");var A=null;if(Y.encrypted&&!((H=Y.decryptdata)!=null&&H.key)){if(this.log("Loading key for "+Y.sn+" of ["+z.startSN+"-"+z.endSN+"], "+this.playlistLabel()+" "+Y.level),this.state=X0.KEY_LOADING,this.fragCurrent=Y,A=this.keyLoader.load(Y).then(function(S){if(!V.fragContextChanged(S.frag)){if(V.hls.trigger(M.KEY_LOADED,S),V.state===X0.KEY_LOADING)V.state=X0.IDLE;return S}}),this.hls.trigger(M.KEY_LOADING,{frag:Y}),this.fragCurrent===null)A=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING"))}else if(!Y.encrypted&&z.encryptedFragments.length)this.keyLoader.loadClear(Y,z.encryptedFragments);var E=this.fragPrevious;if(d1(Y)&&(!E||Y.sn!==E.sn)){var I=this.shouldLoadParts(Q.details,Y.end);if(I!==this.loadingParts)this.log("LL-Part loading "+(I?"ON":"OFF")+" loading sn "+(E==null?void 0:E.sn)+"->"+Y.sn),this.loadingParts=I}if(G=Math.max(Y.start,G||0),this.loadingParts&&d1(Y)){var $=z.partList;if($&&q){if(G>Y.end&&z.fragmentHint)Y=z.fragmentHint;var L=this.getNextPart($,Y,G);if(L>-1){var b=$[L];Y=this.fragCurrent=b.fragment,this.log("Loading "+Y.type+" sn: "+Y.sn+" part: "+b.index+" ("+L+"/"+($.length-1)+") of "+this.fragInfo(Y,!1,b)+") cc: "+Y.cc+" ["+z.startSN+"-"+z.endSN+"], target: "+parseFloat(G.toFixed(3))),this.nextLoadPosition=b.start+b.duration,this.state=X0.FRAG_LOADING;var C;if(A)C=A.then(function(S){if(!S||V.fragContextChanged(S.frag))return null;return V.doFragPartsLoad(Y,b,Q,q)}).catch(function(S){return V.handleFragLoadError(S)});else C=this.doFragPartsLoad(Y,b,Q,q).catch(function(S){return V.handleFragLoadError(S)});if(this.hls.trigger(M.FRAG_LOADING,{frag:Y,part:b,targetBufferTime:G}),this.fragCurrent===null)return Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts"));return C}else if(!Y.url||this.loadedEndOfParts($,G))return Promise.resolve(null)}}if(d1(Y)&&this.loadingParts)this.log("LL-Part loading OFF after next part miss @"+G.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+" "+(z?"["+z.startSN+"-"+z.endSN+"]":"")+", target: "+parseFloat(G.toFixed(3))),T(Y.sn)&&!this.bitrateTest)this.nextLoadPosition=Y.start+Y.duration;this.state=X0.FRAG_LOADING;var D=this.config.progressive,y;if(D&&A)y=A.then(function(S){if(!S||V.fragContextChanged(S==null?void 0:S.frag))return null;return V.fragmentLoader.load(Y,q)}).catch(function(S){return V.handleFragLoadError(S)});else y=Promise.all([this.fragmentLoader.load(Y,D?q:void 0),A]).then(function(S){var v=S[0];if(!D&&v&&q)q(v);return v}).catch(function(S){return V.handleFragLoadError(S)});if(this.hls.trigger(M.FRAG_LOADING,{frag:Y,targetBufferTime:G}),this.fragCurrent===null)return Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING"));return y},Z.doFragPartsLoad=function J(Y,Q,G,q){var H=this;return new Promise(function(V,z){var A,E=[],I=(A=G.details)==null?void 0:A.partList,$=function L(b){H.fragmentLoader.loadPart(Y,b,q).then(function(C){E[b.index]=C;var D=C.part;H.hls.trigger(M.FRAG_LOADED,C);var y=f2(G.details,Y.sn,b.index+1)||c2(I,Y.sn,b.index+1);if(y)$(y);else return V({frag:Y,part:D,partsLoaded:E})}).catch(z)};$(Q)})},Z.handleFragLoadError=function J(Y){if("data"in Y){var Q=Y.data;if(Y.data&&Q.details===h.INTERNAL_ABORTED)this.handleFragLoadAborted(Q.frag,Q.part);else this.hls.trigger(M.ERROR,Q)}else this.hls.trigger(M.ERROR,{type:n.OTHER_ERROR,details:h.INTERNAL_EXCEPTION,err:Y,error:Y,fatal:!0});return null},Z._handleTransmuxerFlush=function J(Y){var Q=this.getCurrentContext(Y);if(!Q||this.state!==X0.PARSING){if(!this.fragCurrent&&this.state!==X0.STOPPED&&this.state!==X0.ERROR)this.state=X0.IDLE;return}var{frag:G,part:q,level:H}=Q,V=self.performance.now();if(G.stats.parsing.end=V,q)q.stats.parsing.end=V;var z=this.getLevelDetails(),A=z&&G.sn>z.endSN,E=A||this.shouldLoadParts(z,G.end);if(E!==this.loadingParts)this.log("LL-Part loading "+(E?"ON":"OFF")+" after parsing segment ending @"+G.end.toFixed(2)),this.loadingParts=E;this.updateLevelTiming(G,q,H,Y.partial)},Z.shouldLoadParts=function J(Y,Q){if(this.config.lowLatencyMode){if(!Y)return this.loadingParts;if(Y!=null&&Y.partList){var G,q=Y.partList[0],H=q.end+(((G=Y.fragmentHint)==null?void 0:G.duration)||0);if(Q>=H){var V,z=this.hls.hasEnoughToStart?((V=this.media)==null?void 0:V.currentTime)||this.lastCurrentTime:this.getLoadPosition();if(z>q.start-q.fragment.duration)return!0}}}return!1},Z.getCurrentContext=function J(Y){var Q=this.levels,G=this.fragCurrent,q=Y.level,H=Y.sn,V=Y.part;if(!(Q!=null&&Q[q]))return this.warn("Levels object was unset while buffering fragment "+H+" of "+this.playlistLabel()+" "+q+". The current chunk will not be buffered."),null;var z=Q[q],A=z.details,E=V>-1?f2(A,H,V):null,I=E?E.fragment:W7(A,H,G);if(!I)return null;if(G&&G!==I)I.stats=G.stats;return{frag:I,part:E,level:z}},Z.bufferFragmentData=function J(Y,Q,G,q,H){var V;if(!Y||this.state!==X0.PARSING)return;var{data1:z,data2:A}=Y,E=z;if(z&&A)E=v1(z,A);if(!((V=E)!=null&&V.length))return;var I={type:Y.type,frag:Q,part:G,chunkMeta:q,parent:Q.type,data:E};if(this.hls.trigger(M.BUFFER_APPENDING,I),Y.dropped&&Y.independent&&!G){if(H)return;this.flushBufferGap(Q)}},Z.flushBufferGap=function J(Y){var Q=this.media;if(!Q)return;if(!k0.isBuffered(Q,Q.currentTime)){this.flushMainBuffer(0,Y.start);return}var G=Q.currentTime,q=k0.bufferInfo(Q,G,0),H=Y.duration,V=Math.min(this.config.maxFragLookUpTolerance*2,H*0.25),z=Math.max(Math.min(Y.start-V,q.end-V),G+V);if(Y.start-z>V)this.flushMainBuffer(z,Y.start)},Z.getFwdBufferInfo=function J(Y,Q){var G,q=this.getLoadPosition();if(!T(q))return null;var H=this.lastCurrentTime>q,V=H||(G=this.media)!=null&&G.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(Y,q,Q,V)},Z.getFwdBufferInfoAtPos=function J(Y,Q,G,q){var H=k0.bufferInfo(Y,Q,q);if(H.len===0&&H.nextStart!==void 0){var V=this.fragmentTracker.getBufferedFrag(Q,G);if(V&&(H.nextStart<=V.end||V.gap)){var z=Math.max(Math.min(H.nextStart,V.end)-Q,q);return k0.bufferInfo(Y,Q,z)}}return H},Z.getMaxBufferLength=function J(Y){var Q=this.config,G;if(Y)G=Math.max(8*Q.maxBufferSize/Y,Q.maxBufferLength);else G=Q.maxBufferLength;return Math.min(G,Q.maxMaxBufferLength)},Z.reduceMaxBufferLength=function J(Y,Q){var G=this.config,q=Math.max(Math.min(Y-Q,G.maxBufferLength),Q),H=Math.max(Y-Q*3,G.maxMaxBufferLength/2,q);if(H>=q)return G.maxMaxBufferLength=H,this.warn("Reduce max buffer length to "+H+"s"),!0;return!1},Z.getAppendedFrag=function J(Y,Q){var G;if(Q===void 0)Q=G0.MAIN;var q=(G=this.fragmentTracker)==null?void 0:G.getAppendedFrag(Y,Q);if(q&&"fragment"in q)return q.fragment;return q},Z.getNextFragment=function J(Y,Q){var G=Q.fragments,q=G.length;if(!q)return null;var H=this.config,V=G[0].start,z=H.lowLatencyMode&&!!Q.partList,A=null;if(Q.live){var E=H.initialLiveManifestSize;if(q<E)return this.warn("Not enough fragments to start playback (have: "+q+", need: "+E+")"),null;if(!Q.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||Y<V){var I;if(z&&!this.loadingParts)this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0;A=this.getInitialLiveFragment(Q,G);var $=this.hls.startPosition,L=this.hls.liveSyncPosition,b=A?($!==-1&&$>=V?$:L)||A.start:Y;this.log("Setting startPosition to "+b+" to match start frag at live edge. mainStart: "+$+" liveSyncPosition: "+L+" frag.start: "+((I=A)==null?void 0:I.start)),this.startPosition=this.nextLoadPosition=b}}else if(Y<=V)A=G[0];if(!A){var C=this.loadingParts?Q.partEnd:Q.fragmentEnd;A=this.getFragmentAtPosition(Y,C,Q)}var D=this.filterReplacedPrimary(A,Q);if(!D&&A){var y=A.sn-Q.startSN;D=this.filterReplacedPrimary(G[y+1]||null,Q)}return this.mapToInitFragWhenRequired(D)},Z.isLoopLoading=function J(Y,Q){var G=this.fragmentTracker.getState(Y);return(G===B1.OK||G===B1.PARTIAL&&!!Y.gap)&&this.nextLoadPosition>Q},Z.getNextFragmentLoopLoading=function J(Y,Q,G,q,H){var V=null;if(Y.gap){if(V=this.getNextFragment(this.nextLoadPosition,Q),V&&!V.gap&&G.nextStart){var z=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,G.nextStart,q,0);if(z!==null&&G.len+z.len>=H){var A=V.sn;if(this.loopSn!==A)this.log('buffer full after gaps in "'+q+'" playlist starting at sn: '+A),this.loopSn=A;return null}}}return this.loopSn=void 0,V},Z.filterReplacedPrimary=function J(Y,Q){if(!Y)return Y;if(LZ(this.hls.config));return Y},Z.mapToInitFragWhenRequired=function J(Y){if(Y!=null&&Y.initSegment&&!(Y!=null&&Y.initSegment.data)&&!this.bitrateTest)return Y.initSegment;return Y},Z.getNextPart=function J(Y,Q,G){var q=-1,H=!1,V=!0;for(var z=0,A=Y.length;z<A;z++){var E=Y[z];if(V=V&&!E.independent,q>-1&&G<E.start)break;var I=E.loaded;if(I)q=-1;else if((H||E.independent||V)&&E.fragment===Q)q=z;H=I}return q},Z.loadedEndOfParts=function J(Y,Q){var G=Y[Y.length-1];return G&&Q>G.start&&G.loaded},Z.getInitialLiveFragment=function J(Y,Q){var G=this.fragPrevious,q=null;if(G){if(Y.hasProgramDateTime)this.log("Live playlist, switching playlist, load frag with same PDT: "+G.programDateTime),q=xX(Q,G.endProgramDateTime,this.config.maxFragLookUpTolerance);if(!q){var H=G.sn+1;if(H>=Y.startSN&&H<=Y.endSN){var V=Q[H-Y.startSN];if(G.cc===V.cc)q=V,this.log("Live playlist, switching playlist, load frag with next SN: "+q.sn)}if(!q){if(q=kX(Q,G.cc),q)this.log("Live playlist, switching playlist, load frag with same CC: "+q.sn)}}}else{var z=this.hls.liveSyncPosition;if(z!==null)q=this.getFragmentAtPosition(z,this.bitrateTest?Y.fragmentEnd:Y.edge,Y)}return q},Z.getFragmentAtPosition=function J(Y,Q,G){var q=this.config,H=this.fragPrevious,V=G.fragments,z=G.endSN,A=G.fragmentHint,E=q.maxFragLookUpTolerance,I=G.partList,$=!!(this.loadingParts&&I!=null&&I.length&&A);if($&&A&&!this.bitrateTest&&I[I.length-1].fragment.sn===A.sn)V=V.concat(A),z=A.sn;var L;if(Y<Q){var b,C=Y<this.lastCurrentTime,D=C||Y>Q-E||(b=this.media)!=null&&b.paused||!this.startFragRequested?0:E;L=dJ(H,V,Y,D)}else L=V[V.length-1];if(L){var y=L.sn-G.startSN,S=this.fragmentTracker.getState(L);if(S===B1.OK||S===B1.PARTIAL&&L.gap)H=L;if(H&&L.sn===H.sn&&(!$||I[0].fragment.sn>L.sn||!G.live&&!$)){var v=H&&L.level===H.level;if(v){var p=V[y+1];if(L.sn<z&&this.fragmentTracker.getState(p)!==B1.OK)L=p;else L=null}}}return L},Z.alignPlaylists=function J(Y,Q,G){var q=Y.fragments.length;if(!q)return this.warn("No fragments in live playlist"),0;var H=Y.fragmentStart,V=!Q,z=Y.alignedSliding&&T(H);if(V||!z&&!H){C9(G,Y);var A=Y.fragmentStart;return this.log("Live playlist sliding: "+A.toFixed(2)+" start-sn: "+(Q?Q.startSN:"na")+"->"+Y.startSN+" fragments: "+q),A}return H},Z.waitForCdnTuneIn=function J(Y){var Q=3;return Y.live&&Y.canBlockReload&&Y.partTarget&&Y.tuneInGoal>Math.max(Y.partHoldBack,Y.partTarget*Q)},Z.setStartPosition=function J(Y,Q){var G=this.startPosition;if(G<Q)G=-1;var q=this.timelineOffset;if(G===-1){var H=this.startTimeOffset!==null,V=H?this.startTimeOffset:Y.startTimeOffset;if(V!==null&&T(V)){if(G=Q+V,V<0)G+=Y.edge;G=Math.min(Math.max(Q,G),Q+Y.totalduration),this.log("Setting startPosition to "+G+" for start time offset "+V+" found in "+(H?"multivariant":"media")+" playlist"),this.startPosition=G}else if(Y.live)G=this.hls.liveSyncPosition||Q,this.log("Setting startPosition to -1 to start at live edge "+G),this.startPosition=-1;else this.log("setting startPosition to 0 by default"),this.startPosition=G=0;this.lastCurrentTime=G+q}this.nextLoadPosition=G+q},Z.getLoadPosition=function J(){var Y,Q=this.media,G=0;if((Y=this.hls)!=null&&Y.hasEnoughToStart&&Q)G=Q.currentTime;else if(this.nextLoadPosition>=0)G=this.nextLoadPosition;return G},Z.handleFragLoadAborted=function J(Y,Q){if(this.transmuxer&&Y.type===this.playlistType&&d1(Y)&&Y.stats.aborted)this.warn("Fragment "+Y.sn+(Q?" part "+Q.index:"")+" of "+this.playlistLabel()+" "+Y.level+" was aborted"),this.resetFragmentLoading(Y)},Z.resetFragmentLoading=function J(Y){if(!this.fragCurrent||!this.fragContextChanged(Y)&&this.state!==X0.FRAG_LOADING_WAITING_RETRY)this.state=X0.IDLE},Z.onFragmentOrKeyLoadError=function J(Y,Q){if(Q.chunkMeta&&!Q.frag){var G=this.getCurrentContext(Q.chunkMeta);if(G)Q.frag=G.frag}var q=Q.frag;if(!q||q.type!==Y||!this.levels)return;if(this.fragContextChanged(q)){var H;this.warn("Frag load error must match current frag to retry "+q.url+" > "+((H=this.fragCurrent)==null?void 0:H.url));return}var V=Q.details===h.FRAG_GAP;if(V)this.fragmentTracker.fragBuffered(q,!0);var z=Q.errorAction,A=z||{},E=A.action,I=A.flags,$=A.retryCount,L=$===void 0?0:$,b=A.retryConfig,C=!!z&&!!b,D=C&&E===U1.RetryRequest,y=C&&!z.resolved&&I===h1.MoveAllAlternatesMatchingHost;if(!D&&y&&d1(q)&&!q.endList)this.resetFragmentErrors(Y),this.treatAsGap(q),z.resolved=!0;else if((D||y)&&L<b.maxNumRetry){this.resetStartWhenNotLoaded(this.levelLastLoaded);var S=nJ(b,L);this.warn("Fragment "+q.sn+" of "+Y+" "+q.level+" errored with "+Q.details+", retrying loading "+(L+1)+"/"+b.maxNumRetry+" in "+S+"ms"),z.resolved=!0,this.retryDate=self.performance.now()+S,this.state=X0.FRAG_LOADING_WAITING_RETRY}else if(b&&z)if(this.resetFragmentErrors(Y),L<b.maxNumRetry){if(!V&&E!==U1.RemoveAlternatePermanently)z.resolved=!0}else{this.warn(Q.details+" reached or exceeded max retry ("+L+")");return}else if(E===U1.SendAlternateToPenaltyBox)this.state=X0.WAITING_LEVEL;else this.state=X0.ERROR;this.tickImmediate()},Z.reduceLengthAndFlushBuffer=function J(Y){if(this.state===X0.PARSING||this.state===X0.PARSED){var{frag:Q,parent:G}=Y,q=this.getFwdBufferInfo(this.mediaBuffer,G),H=q&&q.len>0.5;if(H)this.reduceMaxBufferLength(q.len,(Q==null?void 0:Q.duration)||10);var V=!H;if(V)this.warn("Buffer full error while media.currentTime is not buffered, flush "+G+" buffer");if(Q)this.fragmentTracker.removeFragment(Q),this.nextLoadPosition=Q.start;return this.resetLoadingState(),V}return!1},Z.resetFragmentErrors=function J(Y){if(Y===G0.AUDIO)this.fragCurrent=null;if(!this.hls.hasEnoughToStart)this.startFragRequested=!1;if(this.state!==X0.STOPPED)this.state=X0.IDLE},Z.afterBufferFlushed=function J(Y,Q,G){if(!Y)return;var q=k0.getBuffered(Y);if(this.fragmentTracker.detectEvictedFragments(Q,q,G),this.state===X0.ENDED)this.resetLoadingState()},Z.resetLoadingState=function J(){if(this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==X0.STOPPED)this.state=X0.IDLE},Z.resetStartWhenNotLoaded=function J(Y){if(!this.hls.hasEnoughToStart){this.startFragRequested=!1;var Q=Y?Y.details:null;if(Q!=null&&Q.live)this.log("resetting startPosition for live start"),this.startPosition=-1,this.setStartPosition(Q,Q.fragmentStart),this.resetLoadingState();else this.nextLoadPosition=this.startPosition}},Z.resetWhenMissingContext=function J(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 J(Y){if(Y===void 0)Y=0;this.fragmentTracker.removeFragmentsInRange(Y,1/0,this.playlistType,!1,!0)},Z.updateLevelTiming=function J(Y,Q,G,q){var H=this,V=G.details;if(!V){this.warn("level.details undefined");return}var z=Object.keys(Y.elementaryStreams).reduce(function(I,$){var L=Y.elementaryStreams[$];if(L){var b=L.endPTS-L.startPTS;if(b<=0)return H.warn("Could not parse fragment "+Y.sn+" "+$+" duration reliably ("+b+")"),I||!1;var C=q?0:u2(V,Y,L.startPTS,L.endPTS,L.startDTS,L.endDTS);return H.hls.trigger(M.LEVEL_PTS_UPDATED,{details:V,level:G,drift:C,type:$,frag:Y,start:L.startPTS,end:L.endPTS}),!0}return I},!1);if(!z){var A;if(G.fragmentError===0)this.treatAsGap(Y,G);if(((A=this.transmuxer)==null?void 0:A.error)===null){var E=new Error("Found no media in fragment "+Y.sn+" of "+this.playlistLabel()+" "+Y.level+" resetting transmuxer to fallback to playlist timing");if(this.warn(E.message),this.hls.trigger(M.ERROR,{type:n.MEDIA_ERROR,details:h.FRAG_PARSING_ERROR,fatal:!1,error:E,frag:Y,reason:"Found no media in msn "+Y.sn+" of "+this.playlistLabel()+' "'+G.url+'"'}),!this.hls)return;this.resetTransmuxer()}}this.state=X0.PARSED,this.log("Parsed "+Y.type+" sn: "+Y.sn+(Q?" part: "+Q.index:"")+" of "+this.fragInfo(Y,!1,Q)+")"),this.hls.trigger(M.FRAG_PARSED,{frag:Y,part:Q})},Z.playlistLabel=function J(){return this.playlistType===G0.MAIN?"level":"track"},Z.fragInfo=function J(Y,Q,G){var q,H;if(Q===void 0)Q=!0;return this.playlistLabel()+" "+Y.level+" ("+(G?"part":"frag")+":["+((q=Q&&!G?Y.startPTS:(G||Y).start)!=null?q:NaN).toFixed(3)+"-"+((H=Q&&!G?Y.endPTS:(G||Y).end)!=null?H:NaN).toFixed(3)+"]"+(G&&Y.type==="main"?"INDEPENDENT="+(G.independent?"YES":"NO"):"")},Z.treatAsGap=function J(Y,Q){if(Q)Q.fragmentError++;Y.gap=!0,this.fragmentTracker.removeFragment(Y),this.fragmentTracker.fragBuffered(Y,!0)},Z.resetTransmuxer=function J(){var Y;(Y=this.transmuxer)==null||Y.reset()},Z.recoverWorkerError=function J(Y){if(Y.event==="demuxerWorker"){if(this.fragmentTracker.removeAllFragments(),this.transmuxer)this.transmuxer.destroy(),this.transmuxer=null;this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()}},N(W,[{key:"startPositionValue",get:function J(){var Y=this.nextLoadPosition,Q=this.startPosition;if(Q===-1&&Y)return Y;return Q}},{key:"bufferingEnabled",get:function J(){return this.buffering}},{key:"inFlightFrag",get:function J(){return{frag:this.fragCurrent,state:this.state}}},{key:"timelineOffset",get:function J(){var Y=this.config.timelineOffset;if(Y){var Q;return((Q=this.getLevelDetails())==null?void 0:Q.appliedTimelineOffset)||Y}return 0}},{key:"primaryPrefetch",get:function J(){if(LZ(this.hls.config));return!1}},{key:"state",get:function J(){return this._state},set:function J(Y){var Q=this._state;if(Q!==Y)this._state=Y,this.log(Q+"->"+Y)}}])}(wZ);function LZ(X){return!1}function mY(X,W,Z){RY(X,W,Z),X.addEventListener(W,Z)}function RY(X,W,Z){X.removeEventListener(W,Z)}var BJ=2,T9=0.1,x9=0.05,v9=100,h9=function(X){function W(J,Y){var Q=X.call(this,"gap-controller",J.logger)||this;return Q.hls=null,Q.fragmentTracker=null,Q.media=null,Q.mediaSource=void 0,Q.nudgeRetry=0,Q.stallReported=!1,Q.stalled=null,Q.moved=!1,Q.seeking=!1,Q.buffered={},Q.lastCurrentTime=0,Q.ended=0,Q.waiting=0,Q.onMediaPlaying=function(){Q.ended=0,Q.waiting=0},Q.onMediaWaiting=function(){var G;if((G=Q.media)!=null&&G.seeking)return;Q.waiting=self.performance.now(),Q.tick()},Q.onMediaEnded=function(){if(Q.hls){var G;Q.ended=((G=Q.media)==null?void 0:G.currentTime)||1,Q.hls.trigger(M.MEDIA_ENDED,{stalled:!1})}},Q.hls=J,Q.fragmentTracker=Y,Q.registerListeners(),Q}R(W,X);var Z=W.prototype;return Z.registerListeners=function J(){var Y=this.hls;if(Y)Y.on(M.MEDIA_ATTACHED,this.onMediaAttached,this),Y.on(M.MEDIA_DETACHING,this.onMediaDetaching,this),Y.on(M.BUFFER_APPENDED,this.onBufferAppended,this)},Z.unregisterListeners=function J(){var Y=this.hls;if(Y)Y.off(M.MEDIA_ATTACHED,this.onMediaAttached,this),Y.off(M.MEDIA_DETACHING,this.onMediaDetaching,this),Y.off(M.BUFFER_APPENDED,this.onBufferAppended,this)},Z.destroy=function J(){X.prototype.destroy.call(this),this.unregisterListeners(),this.media=this.hls=this.fragmentTracker=null,this.mediaSource=void 0},Z.onMediaAttached=function J(Y,Q){this.setInterval(v9),this.mediaSource=Q.mediaSource;var G=this.media=Q.media;mY(G,"playing",this.onMediaPlaying),mY(G,"waiting",this.onMediaWaiting),mY(G,"ended",this.onMediaEnded)},Z.onMediaDetaching=function J(Y,Q){this.clearInterval();var G=this.media;if(G)RY(G,"playing",this.onMediaPlaying),RY(G,"waiting",this.onMediaWaiting),RY(G,"ended",this.onMediaEnded),this.media=null;this.mediaSource=void 0},Z.onBufferAppended=function J(Y,Q){this.buffered=Q.timeRanges},Z.tick=function J(){var Y;if(!((Y=this.media)!=null&&Y.readyState)||!this.hasBuffered)return;var Q=this.media.currentTime;this.poll(Q,this.lastCurrentTime),this.lastCurrentTime=Q},Z.poll=function J(Y,Q){var G,q,H=(G=this.hls)==null?void 0:G.config;if(!H)return;var V=this.media,z=this.stalled;if(!V)return;var A=V.seeking,E=this.seeking&&!A,I=!this.seeking&&A,$=V.paused&&!A||V.ended||V.playbackRate===0;if(this.seeking=A,Y!==Q){if(Q)this.ended=0;if(this.moved=!0,!A){if(this.nudgeRetry=0,H.nudgeOnVideoHole&&!$&&Y>Q)this.nudgeOnVideoHole(Y,Q)}if(this.waiting===0)this.stallResolved(Y);return}if(I||E){if(E)this.stallResolved(Y);return}if($){if(this.nudgeRetry=0,this.stallResolved(Y),!this.ended&&V.ended&&this.hls)this.ended=Y||1,this.hls.trigger(M.MEDIA_ENDED,{stalled:!1});return}if(!k0.getBuffered(V).length){this.nudgeRetry=0;return}var L=k0.bufferInfo(V,Y,0),b=L.nextStart||0,C=this.fragmentTracker;if(A&&C&&this.hls){var D=bZ(this.hls.inFlightFragments,Y),y=L.len>BJ,S=!b||D||b-Y>BJ&&!C.getPartialFragment(Y);if(y||S)return;this.moved=!1}var v=(q=this.hls)==null?void 0:q.latestLevelDetails;if(!this.moved&&this.stalled!==null&&C){var p=L.len>0;if(!p&&!b)return;var g=Math.max(b,L.start||0)-Y,m=!!(v!=null&&v.live),r=m?v.targetduration*2:BJ,o=C.getPartialFragment(Y);if(g>0&&(g<=r||o)){if(!V.paused)this._trySkipBufferHole(o);return}}var c=H.detectStallWithCurrentTimeMs,d=self.performance.now(),e=this.waiting;if(z===null){if(e>0&&d-e<c)this.stalled=e;else this.stalled=d;return}var H0=d-z;if(!A&&(H0>=c||e)&&this.hls){var Q0;if(((Q0=this.mediaSource)==null?void 0:Q0.readyState)==="ended"&&!(v!=null&&v.live)&&Math.abs(Y-((v==null?void 0:v.edge)||0))<1){if(this.ended)return;this.ended=Y||1,this.hls.trigger(M.MEDIA_ENDED,{stalled:!0});return}if(this._reportStall(L),!this.media||!this.hls)return}var J0=k0.bufferInfo(V,Y,H.maxBufferHole);this._tryFixBufferStall(J0,H0)},Z.stallResolved=function J(Y){var Q=this.stalled;if(Q&&this.hls){if(this.stalled=null,this.stallReported){var G=self.performance.now()-Q;this.log("playback not stuck anymore @"+Y+", after "+Math.round(G)+"ms"),this.stallReported=!1,this.waiting=0,this.hls.trigger(M.STALL_RESOLVED,{})}}},Z.nudgeOnVideoHole=function J(Y,Q){var G,q=this.buffered.video;if(this.hls&&this.media&&this.fragmentTracker&&(G=this.buffered.audio)!=null&&G.length&&q&&q.length>1&&Y>q.end(0)){var H=k0.bufferedInfo(k0.timeRangesToArray(this.buffered.audio),Y,0);if(H.len>1&&Q>=H.start){var V=k0.timeRangesToArray(q),z=k0.bufferedInfo(V,Q,0).bufferedIndex;if(z>-1&&z<V.length-1){var A=k0.bufferedInfo(V,Y,0).bufferedIndex,E=V[z].end,I=V[z+1].start;if((A===-1||A>z)&&I-E<1&&Y-E<2){var $=new Error("nudging playhead to flush pipeline after video hole. currentTime: "+Y+" hole: "+E+" -> "+I+" buffered index: "+A);this.warn($.message),this.media.currentTime+=0.000001;var L=this.fragmentTracker.getPartialFragment(Y)||void 0,b=k0.bufferInfo(this.media,Y,0);this.hls.trigger(M.ERROR,{type:n.MEDIA_ERROR,details:h.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:$,reason:$.message,frag:L,buffer:b.len,bufferInfo:b})}}}}},Z._tryFixBufferStall=function J(Y,Q){var G,q,H=this.fragmentTracker,V=this.media,z=(G=this.hls)==null?void 0:G.config;if(!V||!H||!z)return;var A=V.currentTime,E=(q=this.hls)==null?void 0:q.latestLevelDetails,I=H.getPartialFragment(A);if(I||E!=null&&E.live&&A<E.fragmentStart){var $=this._trySkipBufferHole(I);if($||!this.media)return}var L=Y.buffered;if((L&&L.length>1&&Y.len>z.maxBufferHole||Y.nextStart&&Y.nextStart-A<z.maxBufferHole)&&(Q>z.highBufferWatchdogPeriod*1000||this.waiting))this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(Y)},Z._reportStall=function J(Y){var Q=this.hls,G=this.media,q=this.stallReported,H=this.stalled;if(!q&&H!==null&&G&&Q){this.stallReported=!0;var V=new Error("Playback stalling at @"+G.currentTime+" due to low buffer ("+O1(Y)+")");this.warn(V.message),Q.trigger(M.ERROR,{type:n.MEDIA_ERROR,details:h.BUFFER_STALLED_ERROR,fatal:!1,error:V,buffer:Y.len,bufferInfo:Y,stalled:{start:H}})}},Z._trySkipBufferHole=function J(Y){var Q,G=this.fragmentTracker,q=this.media,H=(Q=this.hls)==null?void 0:Q.config;if(!q||!G||!H)return 0;var V=q.currentTime,z=k0.bufferInfo(q,V,0),A=V<z.start?z.start:z.nextStart;if(A&&this.hls){var E=z.len<=H.maxBufferHole,I=z.len>0&&z.len<1&&q.readyState<3,$=A-V;if($>0&&(E||I)){if($>H.maxBufferHole){var L=!1;if(V===0){var b=G.getAppendedFrag(0,G0.MAIN);if(b&&A<b.end)L=!0}if(!L){var C=Y||G.getAppendedFrag(V,G0.MAIN);if(C){var D;if(!((D=this.hls.loadLevelObj)!=null&&D.details))return 0;var y=bZ(this.hls.inFlightFragments,A);if(y)return 0;var S=!1,v=C.end;while(v<A){var p=G.getPartialFragment(v);if(p)v+=p.duration;else{S=!0;break}}if(S)return 0}}}var g=Math.max(A+x9,V+T9);if(this.warn("skipping hole, adjusting currentTime from "+V+" to "+g),this.moved=!0,q.currentTime=g,!(Y!=null&&Y.gap)){var m=new Error("fragment loaded with buffer holes, seeking from "+V+" to "+g);this.hls.trigger(M.ERROR,{type:n.MEDIA_ERROR,details:h.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:m,reason:m.message,frag:Y||void 0,buffer:z.len,bufferInfo:z})}return g}}return 0},Z._tryNudgeBuffer=function J(Y){var Q=this.hls,G=this.media,q=this.nudgeRetry,H=Q==null?void 0:Q.config;if(!G||!H)return 0;var V=G.currentTime;if(this.nudgeRetry++,q<H.nudgeMaxRetry){var z=V+(q+1)*H.nudgeOffset,A=new Error("Nudging 'currentTime' from "+V+" to "+z);this.warn(A.message),G.currentTime=z,Q.trigger(M.ERROR,{type:n.MEDIA_ERROR,details:h.BUFFER_NUDGE_ON_STALL,error:A,fatal:!1,buffer:Y.len,bufferInfo:Y})}else{var E=new Error("Playhead still not moving while enough data buffered @"+V+" after "+H.nudgeMaxRetry+" nudges");this.error(E.message),Q.trigger(M.ERROR,{type:n.MEDIA_ERROR,details:h.BUFFER_STALLED_ERROR,error:E,fatal:!0,buffer:Y.len,bufferInfo:Y})}},N(W,[{key:"hasBuffered",get:function J(){return Object.keys(this.buffered).length>0}}])}(wZ);function bZ(X,W){var Z=MZ(X.main);if(Z&&Z.start<=W)return Z;var J=MZ(X.audio);if(J&&J.start<=W)return J;return null}function MZ(X){if(!X)return null;switch(X.state){case X0.IDLE:case X0.STOPPED:case X0.ENDED:case X0.ERROR:return null}return X.frag}function k9(X,W){var Z;try{Z=new Event("addtrack")}catch(J){Z=document.createEvent("Event"),Z.initEvent("addtrack",!1,!1)}Z.track=X,W.dispatchEvent(Z)}function g9(X,W){var Z=X.mode;if(Z==="disabled")X.mode="hidden";if(X.cues)for(var J=X.cues.length;J--;){if(W)X.cues[J].removeEventListener("enter",W);X.removeCue(X.cues[J])}if(Z==="disabled")X.mode=Z}function u9(X,W,Z,J){var Y=X.mode;if(Y==="disabled")X.mode="hidden";if(X.cues&&X.cues.length>0){var Q=_9(X.cues,W,Z);for(var G=0;G<Q.length;G++)if(!J||J(Q[G]))X.removeCue(Q[G])}if(Y==="disabled")X.mode=Y}function m9(X,W){if(W<=X[0].startTime)return 0;var Z=X.length-1;if(W>X[Z].endTime)return-1;var J=0,Y=Z,Q;while(J<=Y)if(Q=Math.floor((Y+J)/2),W<X[Q].startTime)Y=Q-1;else if(W>X[Q].startTime&&J<Z)J=Q+1;else return Q;return X[J].startTime-W<W-X[Y].startTime?J:Y}function _9(X,W,Z){var J=[],Y=m9(X,W);if(Y>-1)for(var Q=Y,G=X.length;Q<G;Q++){var q=X[Q];if(q.startTime>=W&&q.endTime<=Z)J.push(q);else if(q.startTime>Z)return J}return J}var p9=0.25;function NQ(){if(typeof self==="undefined")return;return self.VTTCue||self.TextTrackCue}function CZ(X,W,Z,J,Y){var Q=new X(W,Z,"");try{if(Q.value=J,Y)Q.type=Y}catch(G){Q=new X(W,Z,O1(Y?f({type:Y},J):J))}return Q}var wJ=function(){var X=NQ();try{X&&new X(0,Number.POSITIVE_INFINITY,"")}catch(W){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function f9(X){return Uint8Array.from(X.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var c9=function(){function X(Z){var J=this;this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=!0,this.onEventCueEnter=function(){if(!J.hls)return;J.hls.trigger(M.EVENT_CUE_ENTER,{})},this.hls=Z,this._registerListeners()}var W=X.prototype;return W.destroy=function Z(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null},W._registerListeners=function Z(){var J=this.hls;J.on(M.MEDIA_ATTACHING,this.onMediaAttaching,this),J.on(M.MEDIA_ATTACHED,this.onMediaAttached,this),J.on(M.MEDIA_DETACHING,this.onMediaDetaching,this),J.on(M.MANIFEST_LOADING,this.onManifestLoading,this),J.on(M.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),J.on(M.BUFFER_FLUSHING,this.onBufferFlushing,this),J.on(M.LEVEL_UPDATED,this.onLevelUpdated,this),J.on(M.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this)},W._unregisterListeners=function Z(){var J=this.hls;J.off(M.MEDIA_ATTACHING,this.onMediaAttaching,this),J.off(M.MEDIA_ATTACHED,this.onMediaAttached,this),J.off(M.MEDIA_DETACHING,this.onMediaDetaching,this),J.off(M.MANIFEST_LOADING,this.onManifestLoading,this),J.off(M.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),J.off(M.BUFFER_FLUSHING,this.onBufferFlushing,this),J.off(M.LEVEL_UPDATED,this.onLevelUpdated,this),J.off(M.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this)},W.onMediaAttaching=function Z(J,Y){var Q;if(this.media=Y.media,((Q=Y.overrides)==null?void 0:Q.cueRemoval)===!1)this.removeCues=!1},W.onMediaAttached=function Z(){var J=this.hls.latestLevelDetails;if(J)this.updateDateRangeCues(J)},W.onMediaDetaching=function Z(J,Y){this.media=null;var Q=!!Y.transferMedia;if(Q)return;if(this.id3Track){if(this.removeCues)g9(this.id3Track,this.onEventCueEnter);this.id3Track=null}this.dateRangeCuesAppended={}},W.onManifestLoading=function Z(){this.dateRangeCuesAppended={}},W.createTrack=function Z(J){var Y=this.getID3Track(J.textTracks);return Y.mode="hidden",Y},W.getID3Track=function Z(J){if(!this.media)return;for(var Y=0;Y<J.length;Y++){var Q=J[Y];if(Q.kind==="metadata"&&Q.label==="id3")return k9(Q,this.media),Q}return this.media.addTextTrack("metadata","id3")},W.onFragParsingMetadata=function Z(J,Y){if(!this.media)return;var Q=this.hls.config,G=Q.enableEmsgMetadataCues,q=Q.enableID3MetadataCues;if(!G&&!q)return;var H=Y.samples;if(!this.id3Track)this.id3Track=this.createTrack(this.media);var V=NQ();if(!V)return;for(var z=0;z<H.length;z++){var A=H[z].type;if(A===b1.emsg&&!G||!q)continue;var E=e2(H[z].data);if(E){var I=H[z].pts,$=I+H[z].duration;if($>wJ)$=wJ;var L=$-I;if(L<=0)$=I+p9;for(var b=0;b<E.length;b++){var C=E[b];if(!YZ(C)){this.updateId3CueEnds(I,A);var D=CZ(V,I,$,C,A);if(D)this.id3Track.addCue(D)}}}}},W.updateId3CueEnds=function Z(J,Y){var Q,G=(Q=this.id3Track)==null?void 0:Q.cues;if(G)for(var q=G.length;q--;){var H=G[q];if(H.type===Y&&H.startTime<J&&H.endTime===wJ)H.endTime=J}},W.onBufferFlushing=function Z(J,Y){var{startOffset:Q,endOffset:G,type:q}=Y,H=this.id3Track,V=this.hls;if(!V)return;var z=V.config,A=z.enableEmsgMetadataCues,E=z.enableID3MetadataCues;if(H&&(A||E)){var I;if(q==="audio")I=function $(L){return L.type===b1.audioId3&&E};else if(q==="video")I=function $(L){return L.type===b1.emsg&&A};else I=function $(L){return L.type===b1.audioId3&&E||L.type===b1.emsg&&A};u9(H,Q,G,I)}},W.onLevelUpdated=function Z(J,Y){var Q=Y.details;this.updateDateRangeCues(Q,!0)},W.onLevelPtsUpdated=function Z(J,Y){if(Math.abs(Y.drift)>0.01)this.updateDateRangeCues(Y.details)},W.updateDateRangeCues=function Z(J,Y){var Q=this;if(!this.media||!J.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;var G=this.id3Track,q=J.dateRanges,H=Object.keys(q),V=this.dateRangeCuesAppended;if(G&&Y){var z;if((z=G.cues)!=null&&z.length){var A=Object.keys(V).filter(function(D){return!H.includes(D)}),E=function D(){var y=A[I],S=V[y].cues;delete V[y],Object.keys(S).forEach(function(v){try{var p=S[v];p.removeEventListener("enter",Q.onEventCueEnter),G.removeCue(p)}catch(g){}})};for(var I=A.length;I--;)E()}else V=this.dateRangeCuesAppended={}}var $=J.fragments[J.fragments.length-1];if(H.length===0||!T($==null?void 0:$.programDateTime))return;if(!this.id3Track)this.id3Track=this.createTrack(this.media);var L=NQ(),b=function D(){var y=H[C],S=q[y],v=S.startTime,p=V[y],g=(p==null?void 0:p.cues)||{},m=(p==null?void 0:p.durationKnown)||!1,r=wJ,o=S.duration,c=S.endDate;if(c&&o!==null)r=v+o,m=!0;else if(S.endOnNext&&!m){var d=H.reduce(function(O0,g0){if(g0!==S.id){var T0=q[g0];if(T0.class===S.class&&T0.startDate>S.startDate&&(!O0||S.startDate<O0.startDate))return T0}return O0},null);if(d)r=d.startTime,m=!0}var e=Object.keys(S.attr);for(var H0=0;H0<e.length;H0++){var Q0=e[H0];if(!dX(Q0))continue;var J0=g[Q0];if(J0){if(m&&!p.durationKnown)J0.endTime=r;else if(Math.abs(J0.startTime-v)>0.01)J0.startTime=v,J0.endTime=r}else if(L){var N0=S.attr[Q0];if(nX(Q0))N0=f9(N0);var V0={key:Q0,data:N0},j0=CZ(L,v,r,V0,b1.dateRange);if(j0)j0.id=y,Q.id3Track.addCue(j0),g[Q0]=j0}}V[y]={cues:g,dateRange:S,durationKnown:m}};for(var C=0;C<H.length;C++)b()},X}(),l9=function(){function X(Z){var J=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:Q}=J;if(!Y||!Q)return;J.currentTime=Y.currentTime;var G=J.computeLatency();if(G===null)return;J._latency=G;var q=J.config,H=q.lowLatencyMode,V=q.maxLiveSyncPlaybackRate;if(!H||V===1||!Q.live)return;var z=J.targetLatency;if(z===null)return;var A=G-z,E=Math.min(J.maxLatency,z+Q.targetduration),I=A<E;if(I&&A>0.05&&J.forwardBufferLength>1){var $=Math.min(2,Math.max(1,V)),L=Math.round(2/(1+Math.exp(-0.75*A-J.edgeStalled))*20)/20,b=Math.min($,Math.max(1,L));J.changeMediaPlaybackRate(Y,b)}else if(Y.playbackRate!==1&&Y.playbackRate!==0)J.changeMediaPlaybackRate(Y,1)},this.hls=Z,this.config=Z.config,this.registerListeners()}var W=X.prototype;return W.destroy=function Z(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null},W.registerListeners=function Z(){var J=this.hls;if(!J)return;J.on(M.MEDIA_ATTACHED,this.onMediaAttached,this),J.on(M.MEDIA_DETACHING,this.onMediaDetaching,this),J.on(M.MANIFEST_LOADING,this.onManifestLoading,this),J.on(M.LEVEL_UPDATED,this.onLevelUpdated,this),J.on(M.ERROR,this.onError,this)},W.unregisterListeners=function Z(){var J=this.hls;if(!J)return;J.off(M.MEDIA_ATTACHED,this.onMediaAttached,this),J.off(M.MEDIA_DETACHING,this.onMediaDetaching,this),J.off(M.MANIFEST_LOADING,this.onManifestLoading,this),J.off(M.LEVEL_UPDATED,this.onLevelUpdated,this),J.off(M.ERROR,this.onError,this)},W.onMediaAttached=function Z(J,Y){this.media=Y.media,this.media.addEventListener("timeupdate",this.onTimeupdate)},W.onMediaDetaching=function Z(){if(this.media)this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null},W.onManifestLoading=function Z(){this._latency=null,this.stallCount=0},W.onLevelUpdated=function Z(J,Y){var Q=Y.details;if(Q.advanced)this.onTimeupdate();if(!Q.live&&this.media)this.media.removeEventListener("timeupdate",this.onTimeupdate)},W.onError=function Z(J,Y){var Q;if(Y.details!==h.BUFFER_STALLED_ERROR)return;if(this.stallCount++,this.hls&&(Q=this.levelDetails)!=null&&Q.live)this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency")},W.changeMediaPlaybackRate=function Z(J,Y){var Q,G;if(J.playbackRate===Y)return;(Q=this.hls)==null||Q.logger.debug("[latency-controller]: latency="+this.latency.toFixed(3)+", targetLatency="+((G=this.targetLatency)==null?void 0:G.toFixed(3))+", forwardBufferLength="+this.forwardBufferLength.toFixed(3)+": adjusting playback rate from "+J.playbackRate+" to "+Y),J.playbackRate=Y},W.estimateLiveEdge=function Z(){var J=this.levelDetails;if(J===null)return null;return J.edge+J.age},W.computeLatency=function Z(){var J=this.estimateLiveEdge();if(J===null)return null;return J-this.currentTime},N(X,[{key:"levelDetails",get:function Z(){var J;return((J=this.hls)==null?void 0:J.latestLevelDetails)||null}},{key:"latency",get:function Z(){return this._latency||0}},{key:"maxLatency",get:function Z(){var J=this.config;if(J.liveMaxLatencyDuration!==void 0)return J.liveMaxLatencyDuration;var Y=this.levelDetails;return Y?J.liveMaxLatencyDurationCount*Y.targetduration:0}},{key:"targetLatency",get:function Z(){var J=this.levelDetails;if(J===null||this.hls===null)return null;var{holdBack:Y,partHoldBack:Q,targetduration:G}=J,q=this.config,H=q.liveSyncDuration,V=q.liveSyncDurationCount,z=q.lowLatencyMode,A=this.hls.userConfig,E=z?Q||Y:Y;if(this._targetLatencyUpdated||A.liveSyncDuration||A.liveSyncDurationCount||E===0)E=H!==void 0?H:V*G;var I=G;return E+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,I)},set:function Z(J){this.stallCount=0,this.config.liveSyncDuration=J,this._targetLatencyUpdated=!0}},{key:"liveSyncPosition",get:function Z(){var J=this.estimateLiveEdge(),Y=this.targetLatency;if(J===null||Y===null)return null;var Q=this.levelDetails;if(Q===null)return null;var G=Q.edge,q=J-Y-this.edgeStalled,H=G-Q.totalduration,V=G-(this.config.lowLatencyMode&&Q.partTarget||Q.targetduration);return Math.min(Math.max(H,q),V)}},{key:"drift",get:function Z(){var J=this.levelDetails;if(J===null)return 1;return J.drift}},{key:"edgeStalled",get:function Z(){var J=this.levelDetails;if(J===null)return 0;var Y=(this.config.lowLatencyMode&&J.partTarget||J.targetduration)*3;return Math.max(J.age-Y,0)}},{key:"forwardBufferLength",get:function Z(){var J=this.media,Y=this.levelDetails;if(!J||!Y)return 0;var Q=J.buffered.length;return(Q?J.buffered.end(Q-1):Y.edge)-this.currentTime}}])}(),d9=function(X){function W(J,Y){var Q=X.call(this,Y,J.logger)||this;return Q.hls=void 0,Q.canLoad=!1,Q.timer=-1,Q.hls=J,Q}R(W,X);var Z=W.prototype;return Z.destroy=function J(){this.clearTimer(),this.hls=this.log=this.warn=null},Z.clearTimer=function J(){if(this.timer!==-1)self.clearTimeout(this.timer),this.timer=-1},Z.startLoad=function J(){this.canLoad=!0,this.loadPlaylist()},Z.stopLoad=function J(){this.canLoad=!1,this.clearTimer()},Z.switchParams=function J(Y,Q,G){var q=Q==null?void 0:Q.renditionReports;if(q){var H=-1;for(var V=0;V<q.length;V++){var z=q[V],A=void 0;try{A=new self.URL(z.URI,Q.url).href}catch(C){this.warn("Could not construct new URL for Rendition Report: "+C),A=z.URI||""}if(A===Y){H=V;break}else if(A===Y.substring(0,A.length))H=V}if(H!==-1){var E=q[H],I=parseInt(E["LAST-MSN"])||(Q==null?void 0:Q.lastPartSn),$=parseInt(E["LAST-PART"])||(Q==null?void 0:Q.lastPartIndex);if(this.hls.config.lowLatencyMode){var L=Math.min(Q.age-Q.partTarget,Q.targetduration);if($>=0&&L>Q.partTarget)$+=1}var b=G&&U2(G);return new V2(I,$>=0?$:void 0,b)}}},Z.loadPlaylist=function J(Y){this.clearTimer()},Z.loadingPlaylist=function J(Y,Q){this.clearTimer()},Z.shouldLoadPlaylist=function J(Y){return this.canLoad&&!!Y&&!!Y.url&&(!Y.details||Y.details.live)},Z.getUrlWithDirectives=function J(Y,Q){if(Q)try{return Q.addDirectives(Y)}catch(G){this.warn("Could not construct new URL with HLS Delivery Directives: "+G)}return Y},Z.playlistLoaded=function J(Y,Q,G){var{details:q,stats:H}=Q,V=self.performance.now(),z=H.loading.first?Math.max(0,V-H.loading.first):0;q.advancedDateTime=Date.now()-z;var A=this.hls.config.timelineOffset;if(A!==q.appliedTimelineOffset){var E=Math.max(A||0,0);q.appliedTimelineOffset=E,q.fragments.forEach(function(O0){O0.start=O0.playlistOffset+E})}if(q.live||G!=null&&G.live){var I="levelInfo"in Q?Q.levelInfo:Q.track;if(q.reloaded(G),G&&q.fragments.length>0){J7(G,q);var $=q.playlistParsingError;if($){this.warn($);var L=this.hls;if(!L.config.ignorePlaylistParsingErrors){var b,C=Q.networkDetails;L.trigger(M.ERROR,{type:n.NETWORK_ERROR,details:h.LEVEL_PARSING_ERROR,fatal:!1,url:q.url,error:$,reason:$.message,level:Q.level||void 0,parent:(b=q.fragments[0])==null?void 0:b.type,networkDetails:C,stats:H});return}q.playlistParsingError=null}}if(q.requestScheduled===-1)q.requestScheduled=H.loading.start;var D=this.hls.mainForwardBufferInfo,y=D?D.end-D.len:0,S=(q.edge-y)*1000,v=p2(q,S);if(q.requestScheduled+v<V)q.requestScheduled=V;else q.requestScheduled+=v;if(this.log("live playlist "+Y+" "+(q.advanced?"REFRESHED "+q.lastPartSn+"-"+q.lastPartIndex:q.updated?"UPDATED":"MISSED")),!this.canLoad||!q.live)return;var p,g=void 0,m=void 0;if(q.canBlockReload&&q.endSN&&q.advanced){var r=this.hls.config.lowLatencyMode,o=q.lastPartSn,c=q.endSN,d=q.lastPartIndex,e=d!==-1,H0=o===c;if(e)if(H0)g=c+1,m=r?0:d;else g=o,m=r?d+1:q.maxPartIndex;else g=c+1;var Q0=q.age,J0=Q0+q.ageHeader,N0=Math.min(J0-q.partTarget,q.targetduration*1.5);if(N0>0){if(J0>q.targetduration*3)this.log("Playlist last advanced "+Q0.toFixed(2)+"s ago. Omitting segment and part directives."),g=void 0,m=void 0;else if(G!=null&&G.tuneInGoal&&J0-q.partTarget>G.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+G.tuneInGoal+" to: "+N0+" with playlist age: "+q.age),N0=0;else{var V0=Math.floor(N0/q.targetduration);if(g+=V0,m!==void 0){var j0=Math.round(N0%q.targetduration/q.partTarget);m+=j0}this.log("CDN Tune-in age: "+q.ageHeader+"s last advanced "+Q0.toFixed(2)+"s goal: "+N0+" skip sn "+V0+" to part "+m)}q.tuneInGoal=N0}if(p=this.getDeliveryDirectives(q,Q.deliveryDirectives,g,m),r||!H0){q.requestScheduled=V,this.loadingPlaylist(I,p);return}}else if(q.canBlockReload||q.canSkipUntil)p=this.getDeliveryDirectives(q,Q.deliveryDirectives,g,m);if(p&&g!==void 0&&q.canBlockReload)q.requestScheduled=H.loading.first+Math.max(v-z*2,v/2);this.scheduleLoading(I,p,q)}else this.clearTimer()},Z.scheduleLoading=function J(Y,Q,G){var q=this,H=G||Y.details;if(!H){this.loadingPlaylist(Y,Q);return}var V=self.performance.now(),z=H.requestScheduled;if(V>=z){this.loadingPlaylist(Y,Q);return}var A=z-V;this.log("reload live playlist "+(Y.name||Y.bitrate+"bps")+" in "+Math.round(A)+" ms"),this.clearTimer(),this.timer=self.setTimeout(function(){return q.loadingPlaylist(Y,Q)},A)},Z.getDeliveryDirectives=function J(Y,Q,G,q){var H=U2(Y);if(Q!=null&&Q.skip&&Y.deltaUpdateFailed)G=Q.msn,q=Q.part,H=KJ.No;return new V2(G,q,H)},Z.checkRetry=function J(Y){var Q=this,G=Y.details,q=qJ(Y),H=Y.errorAction,V=H||{},z=V.action,A=V.retryCount,E=A===void 0?0:A,I=V.retryConfig,$=!!H&&!!I&&(z===U1.RetryRequest||!H.resolved&&z===U1.SendAlternateToPenaltyBox);if($){var L;if(E>=I.maxNumRetry)return!1;if(q&&(L=Y.context)!=null&&L.deliveryDirectives)this.warn("Retrying playlist loading "+(E+1)+"/"+I.maxNumRetry+' after "'+G+'" without delivery-directives'),this.loadPlaylist();else{var b=nJ(I,E);this.clearTimer(),this.timer=self.setTimeout(function(){return Q.loadPlaylist()},b),this.warn("Retrying playlist loading "+(E+1)+"/"+I.maxNumRetry+' after "'+G+'" in '+b+"ms")}Y.levelRetry=!0,H.resolved=!0}return $},W}(d0),n9=function(X){function W(J,Y){var Q=X.call(this,J,"level-controller")||this;return Q._levels=[],Q._firstLevel=-1,Q._maxAutoLevel=-1,Q._startLevel=void 0,Q.currentLevel=null,Q.currentLevelIndex=-1,Q.manualLevelIndex=-1,Q.steering=void 0,Q.onParsedComplete=void 0,Q.steering=Y,Q._registerListeners(),Q}R(W,X);var Z=W.prototype;return Z._registerListeners=function J(){var Y=this.hls;Y.on(M.MANIFEST_LOADING,this.onManifestLoading,this),Y.on(M.MANIFEST_LOADED,this.onManifestLoaded,this),Y.on(M.LEVEL_LOADED,this.onLevelLoaded,this),Y.on(M.LEVELS_UPDATED,this.onLevelsUpdated,this),Y.on(M.FRAG_BUFFERED,this.onFragBuffered,this),Y.on(M.ERROR,this.onError,this)},Z._unregisterListeners=function J(){var Y=this.hls;Y.off(M.MANIFEST_LOADING,this.onManifestLoading,this),Y.off(M.MANIFEST_LOADED,this.onManifestLoaded,this),Y.off(M.LEVEL_LOADED,this.onLevelLoaded,this),Y.off(M.LEVELS_UPDATED,this.onLevelsUpdated,this),Y.off(M.FRAG_BUFFERED,this.onFragBuffered,this),Y.off(M.ERROR,this.onError,this)},Z.destroy=function J(){this._unregisterListeners(),this.steering=null,this.resetLevels(),X.prototype.destroy.call(this)},Z.stopLoad=function J(){var Y=this._levels;Y.forEach(function(Q){Q.loadError=0,Q.fragmentError=0}),X.prototype.stopLoad.call(this)},Z.resetLevels=function J(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1},Z.onManifestLoading=function J(Y,Q){this.resetLevels()},Z.onManifestLoaded=function J(Y,Q){var G=this,q=this.hls.config.preferManagedMediaSource,H=[],V={},z={},A=!1,E=!1,I=!1;Q.levels.forEach(function($){var L,b=$.attrs,C=$.audioCodec,D=$.videoCodec;if(C)$.audioCodec=C=XJ(C,q)||void 0;if(((L=D)==null?void 0:L.indexOf("avc1"))===0)D=$.videoCodec=$X(D);var{width:y,height:S,unknownCodecs:v}=$,p=v?v.length:0;if(v)for(var g=p;g--;){var m=v[g];if(G.isAudioSupported(m))$.audioCodec=C=C?C+","+m:m,p--,FY.audio[C.substring(0,4)]=2;else if(G.isVideoSupported(m))$.videoCodec=D=D?D+","+m:m,p--,FY.video[D.substring(0,4)]=2}if(A||(A=!!(y&&S)),E||(E=!!D),I||(I=!!C),p||C&&!G.isAudioSupported(C)||D&&!G.isVideoSupported(D)){G.log('Some or all CODECS not supported "'+b.CODECS+'"');return}var r=b.CODECS,o=b["FRAME-RATE"],c=b["HDCP-LEVEL"],d=b["PATHWAY-ID"],e=b.RESOLUTION,H0=b["VIDEO-RANGE"],Q0=(d||".")+"-",J0=""+Q0+$.bitrate+"-"+e+"-"+o+"-"+r+"-"+H0+"-"+c;if(!V[J0]){var N0=G.createLevel($);V[J0]=N0,z[J0]=1,H.push(N0)}else if(V[J0].uri!==$.url&&!$.attrs["PATHWAY-ID"]){var V0=z[J0]+=1;$.attrs["PATHWAY-ID"]=new Array(V0+1).join(".");var j0=G.createLevel($);V[J0]=j0,H.push(j0)}else V[J0].addGroupId("audio",b.AUDIO),V[J0].addGroupId("text",b.SUBTITLES)}),this.filterAndSortMediaOptions(H,Q,A,E,I)},Z.createLevel=function J(Y){var Q=new z2(Y),G=Y.supplemental;if(G!=null&&G.videoCodec&&!this.isVideoSupported(G.videoCodec)){var q=new Error('SUPPLEMENTAL-CODECS not supported "'+G.videoCodec+'"');this.log(q.message),Q.supportedResult=oQ.getUnsupportedResult(q,[])}return Q},Z.isAudioSupported=function J(Y){return fJ(Y,"audio",this.hls.config.preferManagedMediaSource)},Z.isVideoSupported=function J(Y){return fJ(Y,"video",this.hls.config.preferManagedMediaSource)},Z.filterAndSortMediaOptions=function J(Y,Q,G,q,H){var V=this,z=[],A=[],E=Y;if((G||q)&&H)E=E.filter(function(g){var{videoCodec:m,videoRange:r,width:o,height:c}=g;return(!!m||!!(o&&c))&&bX(r)});if(E.length===0){Promise.resolve().then(function(){if(V.hls){var g="no level with compatible codecs found in manifest",m=g;if(Q.levels.length)m="one or more CODECS in variant not supported: "+O1(Q.levels.map(function(o){return o.attrs.CODECS}).filter(function(o,c,d){return d.indexOf(o)===c})),V.warn(m),g+=" ("+m+")";var r=new Error(g);V.hls.trigger(M.ERROR,{type:n.MEDIA_ERROR,details:h.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:Q.url,error:r,reason:m})}});return}if(Q.audioTracks)z=Q.audioTracks.filter(function(g){return!g.audioCodec||V.isAudioSupported(g.audioCodec)}),DZ(z);if(Q.subtitles)A=Q.subtitles,DZ(A);var I=E.slice(0);E.sort(function(g,m){if(g.attrs["HDCP-LEVEL"]!==m.attrs["HDCP-LEVEL"])return(g.attrs["HDCP-LEVEL"]||"")>(m.attrs["HDCP-LEVEL"]||"")?1:-1;if(G&&g.height!==m.height)return g.height-m.height;if(g.frameRate!==m.frameRate)return g.frameRate-m.frameRate;if(g.videoRange!==m.videoRange)return WJ.indexOf(g.videoRange)-WJ.indexOf(m.videoRange);if(g.videoCodec!==m.videoCodec){var r=q2(g.videoCodec),o=q2(m.videoCodec);if(r!==o)return o-r}if(g.uri===m.uri&&g.codecSet!==m.codecSet){var c=ZJ(g.codecSet),d=ZJ(m.codecSet);if(c!==d)return d-c}if(g.averageBitrate!==m.averageBitrate)return g.averageBitrate-m.averageBitrate;return 0});var $=I[0];if(this.steering){if(E=this.steering.filterParsedLevels(E),E.length!==I.length){for(var L=0;L<I.length;L++)if(I[L].pathwayId===E[0].pathwayId){$=I[L];break}}}this._levels=E;for(var b=0;b<E.length;b++)if(E[b]===$){var C;this._firstLevel=b;var D=$.bitrate,y=this.hls.bandwidthEstimate;if(this.log("manifest loaded, "+E.length+" level(s) found, first bitrate: "+D),((C=this.hls.userConfig)==null?void 0:C.abrEwmaDefaultEstimate)===void 0){var S=Math.min(D,this.hls.config.abrEwmaDefaultEstimateMax);if(S>y&&y===this.hls.abrEwmaDefaultEstimate)this.hls.bandwidthEstimate=S}break}var v=H&&!q,p={levels:E,audioTracks:z,subtitleTracks:A,sessionData:Q.sessionData,sessionKeys:Q.sessionKeys,firstLevel:this._firstLevel,stats:Q.stats,audio:H,video:q,altAudio:!v&&z.some(function(g){return!!g.url})};this.hls.trigger(M.MANIFEST_PARSED,p)},Z.onError=function J(Y,Q){if(Q.fatal||!Q.context)return;if(Q.context.type===Z0.LEVEL&&Q.context.level===this.level)this.checkRetry(Q)},Z.onFragBuffered=function J(Y,Q){var G=Q.frag;if(G!==void 0&&G.type===G0.MAIN){var q=G.elementaryStreams;if(!Object.keys(q).some(function(V){return!!q[V]}))return;var H=this._levels[G.level];if(H!=null&&H.loadError)this.log("Resetting level error count of "+H.loadError+" on frag buffered"),H.loadError=0}},Z.onLevelLoaded=function J(Y,Q){var G,q=Q.level,H=Q.details,V=Q.levelInfo;if(!V){var z;if(this.warn("Invalid level index "+q),(z=Q.deliveryDirectives)!=null&&z.skip)H.deltaUpdateFailed=!0;return}if(V===this.currentLevel||Q.withoutMultiVariant){if(V.fragmentError===0)V.loadError=0;var A=V.details;if(A===Q.details&&A.advanced)A=void 0;this.playlistLoaded(q,Q,A)}else if((G=Q.deliveryDirectives)!=null&&G.skip)H.deltaUpdateFailed=!0},Z.loadPlaylist=function J(Y){if(X.prototype.loadPlaylist.call(this),this.shouldLoadPlaylist(this.currentLevel))this.scheduleLoading(this.currentLevel,Y)},Z.loadingPlaylist=function J(Y,Q){X.prototype.loadingPlaylist.call(this,Y,Q);var G=this.getUrlWithDirectives(Y.uri,Q),q=this.currentLevelIndex,H=Y.attrs["PATHWAY-ID"],V=Y.details,z=V==null?void 0:V.age;this.log("Loading level index "+q+((Q==null?void 0:Q.msn)!==void 0?" at sn "+Q.msn+" part "+Q.part:"")+(H?" Pathway "+H:"")+(z&&V.live?" age "+z.toFixed(1)+(V.type?" "+V.type||"":""):"")+" "+G),this.hls.trigger(M.LEVEL_LOADING,{url:G,level:q,levelInfo:Y,pathwayId:Y.attrs["PATHWAY-ID"],id:0,deliveryDirectives:Q||null})},Z.removeLevel=function J(Y){var Q=this,G;if(this._levels.length===1)return;var q=this._levels.filter(function(V,z){if(z!==Y)return!0;if(Q.steering)Q.steering.removeLevel(V);if(V===Q.currentLevel){if(Q.currentLevel=null,Q.currentLevelIndex=-1,V.details)V.details.fragments.forEach(function(A){return A.level=-1})}return!1});if(l2(q),this._levels=q,this.currentLevelIndex>-1&&(G=this.currentLevel)!=null&&G.details)this.currentLevelIndex=this.currentLevel.details.fragments[0].level;if(this.manualLevelIndex>-1)this.manualLevelIndex=this.currentLevelIndex;var H=q.length-1;if(this._firstLevel=Math.min(this._firstLevel,H),this._startLevel)this._startLevel=Math.min(this._startLevel,H);this.hls.trigger(M.LEVELS_UPDATED,{levels:q})},Z.onLevelsUpdated=function J(Y,Q){var G=Q.levels;this._levels=G},Z.checkMaxAutoUpdated=function J(){var Y=this.hls,Q=Y.autoLevelCapping,G=Y.maxAutoLevel,q=Y.maxHdcpLevel;if(this._maxAutoLevel!==G)this._maxAutoLevel=G,this.hls.trigger(M.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:Q,levels:this.levels,maxAutoLevel:G,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:q})},N(W,[{key:"levels",get:function J(){if(this._levels.length===0)return null;return this._levels}},{key:"loadLevelObj",get:function J(){return this.currentLevel}},{key:"level",get:function J(){return this.currentLevelIndex},set:function J(Y){var Q=this._levels;if(Q.length===0)return;if(Y<0||Y>=Q.length){var G=new Error("invalid level idx"),q=Y<0;if(this.hls.trigger(M.ERROR,{type:n.OTHER_ERROR,details:h.LEVEL_SWITCH_ERROR,level:Y,fatal:q,error:G,reason:G.message}),q)return;Y=Math.min(Y,Q.length-1)}var H=this.currentLevelIndex,V=this.currentLevel,z=V?V.attrs["PATHWAY-ID"]:void 0,A=Q[Y],E=A.attrs["PATHWAY-ID"];if(this.currentLevelIndex=Y,this.currentLevel=A,H===Y&&V&&z===E)return;this.log("Switching to level "+Y+" ("+(A.height?A.height+"p ":"")+(A.videoRange?A.videoRange+" ":"")+(A.codecSet?A.codecSet+" ":"")+"@"+A.bitrate+")"+(E?" with Pathway "+E:"")+" from level "+H+(z?" with Pathway "+z:""));var I={level:Y,attrs:A.attrs,details:A.details,bitrate:A.bitrate,averageBitrate:A.averageBitrate,maxBitrate:A.maxBitrate,realBitrate:A.realBitrate,width:A.width,height:A.height,codecSet:A.codecSet,audioCodec:A.audioCodec,videoCodec:A.videoCodec,audioGroups:A.audioGroups,subtitleGroups:A.subtitleGroups,loaded:A.loaded,loadError:A.loadError,fragmentError:A.fragmentError,name:A.name,id:A.id,uri:A.uri,url:A.url,urlId:0,audioGroupIds:A.audioGroupIds,textGroupIds:A.textGroupIds};this.hls.trigger(M.LEVEL_SWITCHING,I);var $=A.details;if(!$||$.live){var L=this.switchParams(A.uri,V==null?void 0:V.details,$);this.loadPlaylist(L)}}},{key:"manualLevel",get:function J(){return this.manualLevelIndex},set:function J(Y){if(this.manualLevelIndex=Y,this._startLevel===void 0)this._startLevel=Y;if(Y!==-1)this.level=Y}},{key:"firstLevel",get:function J(){return this._firstLevel},set:function J(Y){this._firstLevel=Y}},{key:"startLevel",get:function J(){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 J(Y){this._startLevel=Y}},{key:"pathways",get:function J(){if(this.steering)return this.steering.pathways();return[]}},{key:"pathwayPriority",get:function J(){if(this.steering)return this.steering.pathwayPriority;return null},set:function J(Y){if(this.steering){var Q=this.steering.pathways(),G=Y.filter(function(q){return Q.indexOf(q)!==-1});if(Y.length<1){this.warn("pathwayPriority "+Y+" should contain at least one pathway from list: "+Q);return}this.steering.pathwayPriority=G}}},{key:"nextLoadLevel",get:function J(){if(this.manualLevelIndex!==-1)return this.manualLevelIndex;else return this.hls.nextAutoLevel},set:function J(Y){if(this.level=Y,this.manualLevelIndex===-1)this.hls.nextAutoLevel=Y}}])}(d9);function DZ(X){var W={};X.forEach(function(Z){var J=Z.groupId||"";Z.id=W[J]=W[J]||0,W[J]++})}var UQ=[];if(typeof F!=="undefined"&&F)o9();function o9(){self.addEventListener("message",function(X){var W=X.data,Z=W.instanceNo;if(Z===void 0)return;var J=UQ[Z];if(W.cmd==="reset"){if(delete UQ[W.resetNo],J)J.destroy();W.cmd="init"}if(W.cmd==="init"){var Y=JSON.parse(W.config),Q=new h0;Q.on(M.FRAG_DECRYPTED,$Y),Q.on(M.ERROR,$Y);var G=e0(Y.debug,W.id);i9(G,Z),UQ[Z]=new KQ(Q,W.typeSupported,Y,"",W.id,G),$Y("init",null,Z);return}if(!J)return;switch(W.cmd){case"configure":{J.configure(W.config);break}case"demux":{var q=J.push(W.data,W.decryptdata,W.chunkMeta,W.state);if(VY(q))q.then(function(z){VQ(self,z,Z)}).catch(function(z){$Y(M.ERROR,{instanceNo:Z,type:n.MEDIA_ERROR,details:h.FRAG_PARSING_ERROR,chunkMeta:W.chunkMeta,fatal:!1,error:z,err:z,reason:"transmuxer-worker push error"},Z)});else VQ(self,q,Z);break}case"flush":{var H=W.chunkMeta,V=J.flush(H);if(VY(V))V.then(function(z){PZ(self,z,H,Z)}).catch(function(z){$Y(M.ERROR,{type:n.MEDIA_ERROR,details:h.FRAG_PARSING_ERROR,chunkMeta:W.chunkMeta,fatal:!1,error:z,err:z,reason:"transmuxer-worker flush error"},Z)});else PZ(self,V,H,Z);break}}})}function VQ(X,W,Z){if(s9(W.remuxResult))return!1;var J=[],Y=W.remuxResult,Q=Y.audio,G=Y.video;if(Q)SZ(J,Q);if(G)SZ(J,G);return X.postMessage({event:"transmuxComplete",data:W,instanceNo:Z},J),!0}function SZ(X,W){if(W.data1)X.push(W.data1.buffer);if(W.data2)X.push(W.data2.buffer)}function PZ(X,W,Z,J){var Y=W.reduce(function(Q,G){return VQ(X,G,J)||Q},!1);if(!Y)X.postMessage({event:"transmuxComplete",data:W[0],instanceNo:J});X.postMessage({event:"flush",data:Z,instanceNo:J})}function $Y(X,W,Z){self.postMessage({event:X,data:W,instanceNo:Z})}function i9(X,W){var Z=function Y(Q){var G=function q(H){$Y("workerLog",{logType:Q,message:H},W)};X[Q]=G};for(var J in X)Z(J)}function s9(X){return!X.audio&&!X.video&&!X.text&&!X.id3&&!X.initSegment}var _Y="1.6.0",IY={};function r9(){return typeof j==="function"}function a9(){var X=IY[_Y];if(X)return X.clientCount++,X;var W=new self.Blob(["var exports={};var module={exports:exports};function define(f){f()};define.amd=true;("+j.toString()+")(true);"],{type:"text/javascript"}),Z=self.URL.createObjectURL(W),J=new self.Worker(Z),Y={worker:J,objectURL:Z,clientCount:1};return IY[_Y]=Y,Y}function t9(X){var W=IY[X];if(W)return W.clientCount++,W;var Z=new self.URL(X,self.location.href).href,J=new self.Worker(Z),Y={worker:J,scriptURL:Z,clientCount:1};return IY[X]=Y,Y}function e9(X){var W=IY[X||_Y];if(W){var Z=W.clientCount--;if(Z===1){var{worker:J,objectURL:Y}=W;if(delete IY[X||_Y],Y)self.URL.revokeObjectURL(Y);J.terminate()}}}var yZ=0,YG=function(){function X(Z,J,Y,Q){var G=this;this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=yZ++,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(I){var $=I.data,L=G.hls;if(!L||!($!=null&&$.event)||$.instanceNo!==G.instanceNo)return;switch($.event){case"init":{var b,C=(b=G.workerContext)==null?void 0:b.objectURL;if(C)self.URL.revokeObjectURL(C);break}case"transmuxComplete":{G.handleTransmuxComplete($.data);break}case"flush":{G.onFlush($.data);break}case"workerLog":{if(L.logger[$.data.logType])L.logger[$.data.logType]($.data.message);break}default:{$.data=$.data||{},$.data.frag=G.frag,$.data.part=G.part,$.data.id=G.id,L.trigger($.event,$.data);break}}},this.onWorkerError=function(I){if(!G.hls)return;var $=new Error(I.message+" ("+I.filename+":"+I.lineno+")");G.hls.config.enableWorker=!1,G.hls.logger.warn('Error in "'+G.id+'" Web Worker, fallback to inline'),G.hls.trigger(M.ERROR,{type:n.OTHER_ERROR,details:h.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:$})};var q=Z.config;this.hls=Z,this.id=J,this.useWorker=!!q.enableWorker,this.onTransmuxComplete=Y,this.onFlush=Q;var H=function I($,L){if(L=L||{},L.frag=G.frag||void 0,$===M.ERROR)L=L,L.parent=G.id,L.part=G.part,G.error=L.error;G.hls.trigger($,L)};this.observer=new h0,this.observer.on(M.FRAG_DECRYPTED,H),this.observer.on(M.ERROR,H);var V=H2(q.preferManagedMediaSource);if(this.useWorker&&typeof Worker!=="undefined"){var z=this.hls.logger,A=q.workerPath||r9();if(A){try{if(q.workerPath)z.log("loading Web Worker "+q.workerPath+' for "'+J+'"'),this.workerContext=t9(q.workerPath);else z.log('injecting Web Worker for "'+J+'"'),this.workerContext=a9();var E=this.workerContext.worker;E.addEventListener("message",this.onWorkerMessage),E.addEventListener("error",this.onWorkerError),E.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:V,id:J,config:O1(q)})}catch(I){z.warn('Error setting up "'+J+'" Web Worker, fallback to inline',I),this.terminateWorker(),this.error=null,this.transmuxer=new KQ(this.observer,V,q,"",J,Z.logger)}return}}this.transmuxer=new KQ(this.observer,V,q,"",J,Z.logger)}var W=X.prototype;return W.reset=function Z(){if(this.frag=null,this.part=null,this.workerContext){var J=this.instanceNo;this.instanceNo=yZ++;var Y=this.hls.config,Q=H2(Y.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:J,typeSupported:Q,id:this.id,config:O1(Y)})}},W.terminateWorker=function Z(){if(this.workerContext){var J=this.workerContext.worker;this.workerContext=null,J.removeEventListener("message",this.onWorkerMessage),J.removeEventListener("error",this.onWorkerError),e9(this.hls.config.workerPath)}},W.destroy=function Z(){if(this.workerContext)this.terminateWorker(),this.onWorkerMessage=this.onWorkerError=null;else{var J=this.transmuxer;if(J)J.destroy(),this.transmuxer=null}var Y=this.observer;if(Y)Y.removeAllListeners();this.frag=null,this.part=null,this.observer=null,this.hls=null},W.push=function Z(J,Y,Q,G,q,H,V,z,A,E){var I,$,L=this;A.transmuxing.start=self.performance.now();var b=this.instanceNo,C=this.transmuxer,D=H?H.start:q.start,y=q.decryptdata,S=this.frag,v=!(S&&q.cc===S.cc),p=!(S&&A.level===S.level),g=S?A.sn-S.sn:-1,m=this.part?A.part-this.part.index:-1,r=g===0&&A.id>1&&A.id===(S==null?void 0:S.stats.chunkCount),o=!p&&(g===1||g===0&&(m===1||r&&m<=0)),c=self.performance.now();if(p||g||q.stats.parsing.start===0)q.stats.parsing.start=c;if(H&&(m||!o))H.stats.parsing.start=c;var d=!(S&&((I=q.initSegment)==null?void 0:I.url)===(($=S.initSegment)==null?void 0:$.url)),e=new N9(v,o,z,p,D,d);if(!o||v||d){this.hls.logger.log("[transmuxer-interface]: Starting new transmux session for "+q.type+" sn: "+A.sn+(A.part>-1?" part: "+A.part:"")+" "+(this.id===G0.MAIN?"level":"track")+": "+A.level+" id: "+A.id+`
22
- discontinuity: `+v+`
23
- trackSwitch: `+p+`
24
- contiguous: `+o+`
25
- accurateTimeOffset: `+z+`
26
- timeOffset: `+D+`
27
- initSegmentChange: `+d);var H0=new H9(Q,G,Y,V,E);this.configureTransmuxer(H0)}if(this.frag=q,this.part=H,this.workerContext)this.workerContext.worker.postMessage({instanceNo:b,cmd:"demux",data:J,decryptdata:y,chunkMeta:A,state:e},J instanceof ArrayBuffer?[J]:[]);else if(C){var Q0=C.push(J,y,A,e);if(VY(Q0))Q0.then(function(J0){L.handleTransmuxComplete(J0)}).catch(function(J0){L.transmuxerError(J0,A,"transmuxer-interface push error")});else this.handleTransmuxComplete(Q0)}},W.flush=function Z(J){var Y=this;J.transmuxing.start=self.performance.now();var Q=this.instanceNo,G=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:Q,cmd:"flush",chunkMeta:J});else if(G){var q=G.flush(J);if(VY(q))q.then(function(H){Y.handleFlushResult(H,J)}).catch(function(H){Y.transmuxerError(H,J,"transmuxer-interface flush error")});else this.handleFlushResult(q,J)}},W.transmuxerError=function Z(J,Y,Q){if(!this.hls)return;this.error=J,this.hls.trigger(M.ERROR,{type:n.MEDIA_ERROR,details:h.FRAG_PARSING_ERROR,chunkMeta:Y,frag:this.frag||void 0,part:this.part||void 0,fatal:!1,error:J,err:J,reason:Q})},W.handleFlushResult=function Z(J,Y){var Q=this;J.forEach(function(G){Q.handleTransmuxComplete(G)}),this.onFlush(Y)},W.configureTransmuxer=function Z(J){var Y=this.instanceNo,Q=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:Y,cmd:"configure",config:J});else if(Q)Q.configure(J)},W.handleTransmuxComplete=function Z(J){J.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(J)},X}();function TZ(){return self.SourceBuffer||self.WebKitSourceBuffer}function xZ(){var X=XY();if(!X)return!1;var W=TZ();return!W||W.prototype&&typeof W.prototype.appendBuffer==="function"&&typeof W.prototype.remove==="function"}function JG(){if(!xZ())return!1;var X=XY();return typeof(X==null?void 0:X.isTypeSupported)==="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(function(W){return X.isTypeSupported(vY(W,"video"))})||["mp4a.40.2","fLaC"].some(function(W){return X.isTypeSupported(vY(W,"audio"))}))}function QG(){var X,W=TZ();return typeof(W==null?void 0:(X=W.prototype)==null?void 0:X.changeType)==="function"}var ZG=100,XG=function(X){function W(J,Y,Q){var G=X.call(this,J,Y,Q,"stream-controller",G0.MAIN)||this;return G.audioCodecSwap=!1,G.level=-1,G._forceStartLoad=!1,G._hasEnoughToStart=!1,G.altAudio=0,G.audioOnly=!1,G.fragPlaying=null,G.fragLastKbps=0,G.couldBacktrack=!1,G.backtrackFragment=null,G.audioCodecSwitch=!1,G.videoBuffer=null,G.onMediaPlaying=function(){G.tick()},G.onMediaSeeked=function(){var q=G.media,H=q?q.currentTime:null;if(H===null||!T(H))return;if(G.log("Media seeked to "+H.toFixed(3)),!G.getBufferedFrag(H))return;var V=G.getFwdBufferInfoAtPos(q,H,G0.MAIN,0);if(V===null||V.len===0){G.warn("Main forward buffer length at "+H+' on "seeked" event '+(V?V.len:"empty")+")");return}G.tick()},G.registerListeners(),G}R(W,X);var Z=W.prototype;return Z.registerListeners=function J(){X.prototype.registerListeners.call(this);var Y=this.hls;Y.on(M.MANIFEST_PARSED,this.onManifestParsed,this),Y.on(M.LEVEL_LOADING,this.onLevelLoading,this),Y.on(M.LEVEL_LOADED,this.onLevelLoaded,this),Y.on(M.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),Y.on(M.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),Y.on(M.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),Y.on(M.BUFFER_CREATED,this.onBufferCreated,this),Y.on(M.BUFFER_FLUSHED,this.onBufferFlushed,this),Y.on(M.LEVELS_UPDATED,this.onLevelsUpdated,this),Y.on(M.FRAG_BUFFERED,this.onFragBuffered,this)},Z.unregisterListeners=function J(){X.prototype.unregisterListeners.call(this);var Y=this.hls;Y.off(M.MANIFEST_PARSED,this.onManifestParsed,this),Y.off(M.LEVEL_LOADED,this.onLevelLoaded,this),Y.off(M.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),Y.off(M.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),Y.off(M.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),Y.off(M.BUFFER_CREATED,this.onBufferCreated,this),Y.off(M.BUFFER_FLUSHED,this.onBufferFlushed,this),Y.off(M.LEVELS_UPDATED,this.onLevelsUpdated,this),Y.off(M.FRAG_BUFFERED,this.onFragBuffered,this)},Z.onHandlerDestroying=function J(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),X.prototype.onHandlerDestroying.call(this)},Z.startLoad=function J(Y,Q){if(this.levels){var G=this.lastCurrentTime,q=this.hls;if(this.stopLoad(),this.setInterval(ZG),this.level=-1,!this.startFragRequested){var H=q.startLevel;if(H===-1)if(q.config.testBandwidth&&this.levels.length>1)H=0,this.bitrateTest=!0;else H=q.firstAutoLevel;q.nextLoadLevel=H,this.level=q.loadLevel,this._hasEnoughToStart=!!Q}if(G>0&&Y===-1&&!Q)this.log("Override startPosition with lastCurrentTime @"+G.toFixed(3)),Y=G;this.state=X0.IDLE,this.nextLoadPosition=this.lastCurrentTime=Y+this.timelineOffset,this.startPosition=Q?-1:Y,this.tick()}else this._forceStartLoad=!0,this.state=X0.STOPPED},Z.stopLoad=function J(){this._forceStartLoad=!1,X.prototype.stopLoad.call(this)},Z.doTick=function J(){switch(this.state){case X0.WAITING_LEVEL:{var Y=this.levels,Q=this.level,G=Y==null?void 0:Y[Q],q=G==null?void 0:G.details;if(q&&(!q.live||this.levelLastLoaded===G&&!this.waitForLive(G))){if(this.waitForCdnTuneIn(q))break;this.state=X0.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=X0.IDLE;break}break}case X0.FRAG_LOADING_WAITING_RETRY:{var H,V=self.performance.now(),z=this.retryDate;if(!z||V>=z||(H=this.media)!=null&&H.seeking){var A=this.levels,E=this.level,I=A==null?void 0:A[E];this.resetStartWhenNotLoaded(I||null),this.state=X0.IDLE}}break}if(this.state===X0.IDLE)this.doTickIdle();this.onTickEnd()},Z.onTickEnd=function J(){var Y;if(X.prototype.onTickEnd.call(this),(Y=this.media)!=null&&Y.readyState&&this.media.seeking===!1)this.lastCurrentTime=this.media.currentTime;this.checkFragmentChanged()},Z.doTickIdle=function J(){var Y=this.hls,Q=this.levelLastLoaded,G=this.levels,q=this.media;if(Q===null||!q&&!this.primaryPrefetch&&(this.startFragRequested||!Y.config.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;var H=this.buffering?Y.nextLoadLevel:Y.loadLevel;if(!(G!=null&&G[H]))return;var V=G[H],z=this.getMainFwdBufferInfo();if(z===null)return;var A=this.getLevelDetails();if(A&&this._streamEnded(z,A)){var E={};if(this.altAudio===2)E.type="video";this.hls.trigger(M.BUFFER_EOS,E),this.state=X0.ENDED;return}if(!this.buffering)return;if(Y.loadLevel!==H&&Y.manualLevel===-1)this.log("Adapting to level "+H+" from level "+this.level);this.level=Y.nextLoadLevel=H;var I=V.details;if(!I||this.state===X0.WAITING_LEVEL||this.waitForLive(V)){this.level=H,this.state=X0.WAITING_LEVEL,this.startFragRequested=!1;return}var $=z.len,L=this.getMaxBufferLength(V.maxBitrate);if($>=L)return;if(this.backtrackFragment&&this.backtrackFragment.start>z.end)this.backtrackFragment=null;var b=this.backtrackFragment?this.backtrackFragment.start:z.end,C=this.getNextFragment(b,I);if(this.couldBacktrack&&!this.fragPrevious&&C&&d1(C)&&this.fragmentTracker.getState(C)!==B1.OK){var D,y=((D=this.backtrackFragment)!=null?D:C).sn,S=y-I.startSN,v=I.fragments[S-1];if(v&&C.cc===v.cc)C=v,this.fragmentTracker.removeFragment(v)}else if(this.backtrackFragment&&z.len)this.backtrackFragment=null;if(C&&this.isLoopLoading(C,b)){var p=C.gap;if(!p){var g=this.audioOnly&&!this.altAudio?i0.AUDIO:i0.VIDEO,m=(g===i0.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;if(m)this.afterBufferFlushed(m,g,G0.MAIN)}C=this.getNextFragmentLoopLoading(C,I,z,G0.MAIN,L)}if(!C)return;if(C.initSegment&&!C.initSegment.data&&!this.bitrateTest)C=C.initSegment;this.loadFragment(C,V,b)},Z.loadFragment=function J(Y,Q,G){var q=this.fragmentTracker.getState(Y);if(q===B1.NOT_LOADED||q===B1.PARTIAL)if(!d1(Y))this._loadInitSegment(Y,Q);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,Q);else X.prototype.loadFragment.call(this,Y,Q,G);else this.clearTrackerIfNeeded(Y)},Z.getBufferedFrag=function J(Y){return this.fragmentTracker.getBufferedFrag(Y,G0.MAIN)},Z.followingBufferedFrag=function J(Y){if(Y)return this.getBufferedFrag(Y.end+0.5);return null},Z.immediateLevelSwitch=function J(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},Z.nextLevelSwitch=function J(){var Y=this.levels,Q=this.media;if(Q!=null&&Q.readyState){var G,q=this.getAppendedFrag(Q.currentTime);if(q&&q.start>1)this.flushMainBuffer(0,q.start-1);var H=this.getLevelDetails();if(H!=null&&H.live){var V=this.getMainFwdBufferInfo();if(!V||V.len<H.targetduration*2)return}if(!Q.paused&&Y){var z=this.hls.nextLoadLevel,A=Y[z],E=this.fragLastKbps;if(E&&this.fragCurrent)G=this.fragCurrent.duration*A.maxBitrate/(1000*E)+1;else G=0}else G=0;var I=this.getBufferedFrag(Q.currentTime+G);if(I){var $=this.followingBufferedFrag(I);if($){this.abortCurrentFrag();var L=$.maxStartPTS?$.maxStartPTS:$.start,b=$.duration,C=Math.max(I.end,L+Math.min(Math.max(b-this.config.maxFragLookUpTolerance,b*(this.couldBacktrack?0.5:0.125)),b*(this.couldBacktrack?0.75:0.25)));this.flushMainBuffer(C,Number.POSITIVE_INFINITY)}}}},Z.abortCurrentFrag=function J(){var Y=this.fragCurrent;if(this.fragCurrent=null,this.backtrackFragment=null,Y)Y.abortRequests(),this.fragmentTracker.removeFragment(Y);switch(this.state){case X0.KEY_LOADING:case X0.FRAG_LOADING:case X0.FRAG_LOADING_WAITING_RETRY:case X0.PARSING:case X0.PARSED:this.state=X0.IDLE;break}this.nextLoadPosition=this.getLoadPosition()},Z.flushMainBuffer=function J(Y,Q){X.prototype.flushMainBuffer.call(this,Y,Q,this.altAudio===2?"video":null)},Z.onMediaAttached=function J(Y,Q){X.prototype.onMediaAttached.call(this,Y,Q);var G=Q.media;mY(G,"playing",this.onMediaPlaying),mY(G,"seeked",this.onMediaSeeked)},Z.onMediaDetaching=function J(Y,Q){var G=this.media;if(G)RY(G,"playing",this.onMediaPlaying),RY(G,"seeked",this.onMediaSeeked);this.videoBuffer=null,this.fragPlaying=null,X.prototype.onMediaDetaching.call(this,Y,Q);var q=!!Q.transferMedia;if(q)return;this._hasEnoughToStart=!1},Z.onManifestLoading=function J(){X.prototype.onManifestLoading.call(this),this.log("Trigger BUFFER_RESET"),this.hls.trigger(M.BUFFER_RESET,void 0),this.couldBacktrack=!1,this.fragLastKbps=0,this.fragPlaying=this.backtrackFragment=null,this.altAudio=0,this.audioOnly=!1},Z.onManifestParsed=function J(Y,Q){var G=!1,q=!1;if(Q.levels.forEach(function(H){var V=H.audioCodec;if(V)G=G||V.indexOf("mp4a.40.2")!==-1,q=q||V.indexOf("mp4a.40.5")!==-1}),this.audioCodecSwitch=G&&q&&!QG(),this.audioCodecSwitch)this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC");this.levels=Q.levels,this.startFragRequested=!1},Z.onLevelLoading=function J(Y,Q){var G=this.levels;if(!G||this.state!==X0.IDLE)return;var q=Q.levelInfo;if(!q.details||q.details.live&&(this.levelLastLoaded!==q||q.details.expired)||this.waitForCdnTuneIn(q.details))this.state=X0.WAITING_LEVEL},Z.onLevelLoaded=function J(Y,Q){var G,q=this.levels,H=this.startFragRequested,V=Q.level,z=Q.details,A=z.totalduration;if(!q){this.warn("Levels were reset while loading level "+V);return}this.log("Level "+V+" loaded ["+z.startSN+","+z.endSN+"]"+(z.lastPartSn?"[part-"+z.lastPartSn+"-"+z.lastPartIndex+"]":"")+", cc ["+z.startCC+", "+z.endCC+"] duration:"+A);var E=Q.levelInfo,I=this.fragCurrent;if(I&&(this.state===X0.FRAG_LOADING||this.state===X0.FRAG_LOADING_WAITING_RETRY)){if(I.level!==Q.level&&I.loader)this.abortCurrentFrag()}var $=0;if(z.live||(G=E.details)!=null&&G.live){var L;if(this.checkLiveUpdate(z),z.deltaUpdateFailed)return;$=this.alignPlaylists(z,E.details,(L=this.levelLastLoaded)==null?void 0:L.details)}if(E.details=z,this.levelLastLoaded=E,!H)this.setStartPosition(z,$);if(this.hls.trigger(M.LEVEL_UPDATED,{details:z,level:V}),this.state===X0.WAITING_LEVEL){if(this.waitForCdnTuneIn(z))return;this.state=X0.IDLE}if(H&&z.live)this.synchronizeToLiveEdge(z);this.tick()},Z.synchronizeToLiveEdge=function J(Y){var Q=this.config,G=this.media;if(!G)return;var q=this.hls.liveSyncPosition,H=this.getLoadPosition(),V=Y.fragmentStart,z=Y.edge,A=H>=V-Q.maxFragLookUpTolerance&&H<=z;if(q!==null&&G.duration>q&&(H<q||!A)){var E=Q.liveMaxLatencyDuration!==void 0?Q.liveMaxLatencyDuration:Q.liveMaxLatencyDurationCount*Y.targetduration;if(!A&&G.readyState<4||H<z-E){if(!this._hasEnoughToStart)this.nextLoadPosition=q;if(G.readyState)this.warn("Playback: "+H.toFixed(3)+" is located too far from the end of live sliding playlist: "+z+", reset currentTime to : "+q.toFixed(3)),G.currentTime=q}}},Z._handleFragmentLoadProgress=function J(Y){var Q,G=Y.frag,q=Y.part,H=Y.payload,V=this.levels;if(!V){this.warn("Levels were reset while fragment load was in progress. Fragment "+G.sn+" of level "+G.level+" will not be buffered");return}var z=V[G.level];if(!z){this.warn("Level "+G.level+" not found on progress");return}var A=z.details;if(!A){this.warn("Dropping fragment "+G.sn+" of level "+G.level+" after level details were reset"),this.fragmentTracker.removeFragment(G);return}var E=z.videoCodec,I=A.PTSKnown||!A.live,$=(Q=G.initSegment)==null?void 0:Q.data,L=this._getAudioCodec(z),b=this.transmuxer=this.transmuxer||new YG(this.hls,G0.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),C=q?q.index:-1,D=C!==-1,y=new RZ(G.level,G.sn,G.stats.chunkCount,H.byteLength,C,D),S=this.initPTS[G.cc];b.push(H,$,L,E,G,q,A.totalduration,I,y,S)},Z.onAudioTrackSwitching=function J(Y,Q){var G=this,q=this.hls,H=this.altAudio===2,V=O2(Q.url,q);if(!V){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var z=this.fragCurrent;if(z)this.log("Switching to main audio track, cancel main fragment load"),z.abortRequests(),this.fragmentTracker.removeFragment(z);this.resetTransmuxer(),this.resetLoadingState()}else if(this.audioOnly)this.resetTransmuxer();if(H){this.fragmentTracker.removeAllFragments(),q.once(M.BUFFER_FLUSHED,function(){var A;(A=G.hls)==null||A.trigger(M.AUDIO_TRACK_SWITCHED,Q)}),q.trigger(M.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});return}q.trigger(M.AUDIO_TRACK_SWITCHED,Q)}else this.altAudio=1},Z.onAudioTrackSwitched=function J(Y,Q){var G=O2(Q.url,this.hls);if(G){var q=this.videoBuffer;if(q&&this.mediaBuffer!==q)this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=q}this.altAudio=G?2:0,this.tick()},Z.onBufferCreated=function J(Y,Q){var G=Q.tracks,q,H,V=!1;for(var z in G){var A=G[z];if(A.id==="main"){if(H=z,q=A,z==="video"){var E=G[z];if(E)this.videoBuffer=E.buffer}}else V=!0}if(V&&q)this.log("Alternate track found, use "+H+".buffered to schedule main fragment loading"),this.mediaBuffer=q.buffer;else this.mediaBuffer=this.media},Z.onFragBuffered=function J(Y,Q){var{frag:G,part:q}=Q,H=G.type===G0.MAIN;if(H){if(this.fragContextChanged(G)){if(this.warn("Fragment "+G.sn+(q?" p: "+q.index:"")+" of level "+G.level+" finished buffering, but was aborted. state: "+this.state),this.state===X0.PARSED)this.state=X0.IDLE;return}var V=q?q.stats:G.stats;if(this.fragLastKbps=Math.round(8*V.total/(V.buffering.end-V.loading.first)),d1(G))this.fragPrevious=G;this.fragBufferedComplete(G,q)}var z=this.media;if(!z)return;if(!this._hasEnoughToStart&&k0.getBuffered(z).length)this._hasEnoughToStart=!0,this.seekToStartPos();if(H)this.tick()},Z.onError=function J(Y,Q){var G;if(Q.fatal){this.state=X0.ERROR;return}switch(Q.details){case h.FRAG_GAP:case h.FRAG_PARSING_ERROR:case h.FRAG_DECRYPT_ERROR:case h.FRAG_LOAD_ERROR:case h.FRAG_LOAD_TIMEOUT:case h.KEY_LOAD_ERROR:case h.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(G0.MAIN,Q);break;case h.LEVEL_LOAD_ERROR:case h.LEVEL_LOAD_TIMEOUT:case h.LEVEL_PARSING_ERROR:if(!Q.levelRetry&&this.state===X0.WAITING_LEVEL&&((G=Q.context)==null?void 0:G.type)===Z0.LEVEL)this.state=X0.IDLE;break;case h.BUFFER_ADD_CODEC_ERROR:case h.BUFFER_APPEND_ERROR:if(Q.parent!=="main")return;this.resetLoadingState();break;case h.BUFFER_FULL_ERROR:if(Q.parent!=="main")return;if(this.reduceLengthAndFlushBuffer(Q))this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case h.INTERNAL_EXCEPTION:this.recoverWorkerError(Q);break}},Z.onFragLoadEmergencyAborted=function J(){if(this.state=X0.IDLE,!this._hasEnoughToStart)this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime;this.tickImmediate()},Z.onBufferFlushed=function J(Y,Q){var G=Q.type;if(G!==i0.AUDIO||!this.altAudio){var q=(G===i0.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;if(q)this.afterBufferFlushed(q,G,G0.MAIN),this.tick()}},Z.onLevelsUpdated=function J(Y,Q){if(this.level>-1&&this.fragCurrent){if(this.level=this.fragCurrent.level,this.level===-1)this.resetWhenMissingContext(this.fragCurrent)}this.levels=Q.levels},Z.swapAudioCodec=function J(){this.audioCodecSwap=!this.audioCodecSwap},Z.seekToStartPos=function J(){var Y=this.media;if(!Y)return;var Q=Y.currentTime,G=this.startPosition;if(G>=0&&Q<G){if(Y.seeking){this.log("could not seek to "+G+", already seeking at "+Q);return}var q=this.timelineOffset;if(q&&G)G+=q;var H=this.getLevelDetails(),V=k0.getBuffered(Y),z=V.length?V.start(0):0,A=z-G,E=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);if(A>0&&(A<E||this.loadingParts&&A<2*((H==null?void 0:H.partTarget)||0)))this.log("adjusting start position by "+A+" to match buffer start"),G+=A,this.startPosition=G;if(Q<G)this.log("seek to target start position "+G+" from current time "+Q+" buffer start "+z),Y.currentTime=G}},Z._getAudioCodec=function J(Y){var Q=this.config.defaultAudioCodec||Y.audioCodec;if(this.audioCodecSwap&&Q)if(this.log("Swapping audio codec"),Q.indexOf("mp4a.40.5")!==-1)Q="mp4a.40.2";else Q="mp4a.40.5";return Q},Z._loadBitrateTestFrag=function J(Y,Q){var G=this;Y.bitrateTest=!0,this._doFragLoad(Y,Q).then(function(q){var H=G.hls,V=q==null?void 0:q.frag;if(!V||G.fragContextChanged(V))return;Q.fragmentError=0,G.state=X0.IDLE,G.startFragRequested=!1,G.bitrateTest=!1;var z=V.stats;z.parsing.start=z.parsing.end=z.buffering.start=z.buffering.end=self.performance.now(),H.trigger(M.FRAG_LOADED,q),V.bitrateTest=!1})},Z._handleTransmuxComplete=function J(Y){var Q,G=this.playlistType,q=this.hls,H=Y.remuxResult,V=Y.chunkMeta,z=this.getCurrentContext(V);if(!z){this.resetWhenMissingContext(V);return}var{frag:A,part:E,level:I}=z,$=H.video,L=H.text,b=H.id3,C=H.initSegment,D=I.details,y=this.altAudio?void 0:H.audio;if(this.fragContextChanged(A)){this.fragmentTracker.removeFragment(A);return}if(this.state=X0.PARSING,C){if(C!=null&&C.tracks){var S=A.initSegment||A;this._bufferInitSegment(I,C.tracks,S,V),q.trigger(M.FRAG_PARSING_INIT_SEGMENT,{frag:S,id:G,tracks:C.tracks})}var{initPTS:v,timescale:p}=C;if(T(v))this.initPTS[A.cc]={baseTime:v,timescale:p},q.trigger(M.INIT_PTS_FOUND,{frag:A,id:G,initPTS:v,timescale:p})}if($&&D){var g=D.fragments[A.sn-1-D.startSN],m=A.sn===D.startSN,r=!g||A.cc>g.cc;if(H.independent!==!1){var{startPTS:o,endPTS:c,startDTS:d,endDTS:e}=$;if(E)E.elementaryStreams[$.type]={startPTS:o,endPTS:c,startDTS:d,endDTS:e};else{if($.firstKeyFrame&&$.independent&&V.id===1&&!r)this.couldBacktrack=!0;if($.dropped&&$.independent){var H0=this.getMainFwdBufferInfo(),Q0=(H0?H0.end:this.getLoadPosition())+this.config.maxBufferHole,J0=$.firstKeyFramePTS?$.firstKeyFramePTS:o;if(!m&&Q0<J0-this.config.maxBufferHole&&!r){this.backtrack(A);return}else if(r)A.gap=!0;A.setElementaryStreamInfo($.type,A.start,c,A.start,e,!0)}else if(m&&o-(D.appliedTimelineOffset||0)>BJ)A.gap=!0}if(A.setElementaryStreamInfo($.type,o,c,d,e),this.backtrackFragment)this.backtrackFragment=A;this.bufferFragmentData($,A,E,V,m||r)}else if(m||r)A.gap=!0;else{this.backtrack(A);return}}if(y){var{startPTS:N0,endPTS:V0,startDTS:j0,endDTS:O0}=y;if(E)E.elementaryStreams[i0.AUDIO]={startPTS:N0,endPTS:V0,startDTS:j0,endDTS:O0};A.setElementaryStreamInfo(i0.AUDIO,N0,V0,j0,O0),this.bufferFragmentData(y,A,E,V)}if(D&&b!=null&&(Q=b.samples)!=null&&Q.length){var g0={id:G,frag:A,details:D,samples:b.samples};q.trigger(M.FRAG_PARSING_METADATA,g0)}if(D&&L){var T0={id:G,frag:A,details:D,samples:L.samples};q.trigger(M.FRAG_PARSING_USERDATA,T0)}},Z._bufferInitSegment=function J(Y,Q,G,q){var H=this;if(this.state!==X0.PARSING)return;if(this.audioOnly=!!Q.audio&&!Q.video,this.altAudio&&!this.audioOnly)delete Q.audio;var{audio:V,video:z,audiovideo:A}=Q;if(V){var E=GJ(V.codec,Y.audioCodec);if(E==="mp4a")E="mp4a.40.5";var I=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){if(E)if(E.indexOf("mp4a.40.5")!==-1)E="mp4a.40.2";else E="mp4a.40.5";var $=V.metadata;if($&&"channelCount"in $&&($.channelCount||1)!==1&&I.indexOf("firefox")===-1)E="mp4a.40.5"}if(E&&E.indexOf("mp4a.40.5")!==-1&&I.indexOf("android")!==-1&&V.container!=="audio/mpeg")E="mp4a.40.2",this.log("Android: force audio codec to "+E);if(Y.audioCodec&&Y.audioCodec!==E)this.log('Swapping manifest audio codec "'+Y.audioCodec+'" for "'+E+'"');V.levelCodec=E,V.id=G0.MAIN,this.log("Init audio buffer, container:"+V.container+", codecs[selected/level/parsed]=["+(E||"")+"/"+(Y.audioCodec||"")+"/"+V.codec+"]"),delete Q.audiovideo}if(z){z.levelCodec=Y.videoCodec,z.id=G0.MAIN;var L=z.codec;if((L==null?void 0:L.length)===4)switch(L){case"hvc1":case"hev1":z.codec="hvc1.1.6.L120.90";break;case"av01":z.codec="av01.0.04M.08";break;case"avc1":z.codec="avc1.42e01e";break}this.log("Init video buffer, container:"+z.container+", codecs[level/parsed]=["+(Y.videoCodec||"")+"/"+L+"]"+(z.codec!==L?" parsed-corrected="+z.codec:"")+(z.supplemental?" supplemental="+z.supplemental:"")),delete Q.audiovideo}if(A)this.log("Init audiovideo buffer, container:"+A.container+", codecs[level/parsed]=["+Y.codecs+"/"+A.codec+"]"),delete Q.video,delete Q.audio;var b=Object.keys(Q);if(b.length){if(this.hls.trigger(M.BUFFER_CODECS,Q),!this.hls)return;b.forEach(function(C){var D=Q[C],y=D.initSegment;if(y!=null&&y.byteLength)H.hls.trigger(M.BUFFER_APPENDING,{type:C,data:y,frag:G,part:null,chunkMeta:q,parent:G.type})})}this.tickImmediate()},Z.getMainFwdBufferInfo=function J(){var Y=this.mediaBuffer&&this.altAudio===2?this.mediaBuffer:this.media;return this.getFwdBufferInfo(Y,G0.MAIN)},Z.backtrack=function J(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=X0.IDLE},Z.checkFragmentChanged=function J(){var Y=this.media,Q=null;if(Y&&Y.readyState>1&&Y.seeking===!1){var G=Y.currentTime;if(k0.isBuffered(Y,G))Q=this.getAppendedFrag(G);else if(k0.isBuffered(Y,G+0.1))Q=this.getAppendedFrag(G+0.1);if(Q){this.backtrackFragment=null;var q=this.fragPlaying,H=Q.level;if(!q||Q.sn!==q.sn||q.level!==H){if(this.fragPlaying=Q,this.hls.trigger(M.FRAG_CHANGED,{frag:Q}),!q||q.level!==H)this.hls.trigger(M.LEVEL_SWITCHED,{level:H})}}}},N(W,[{key:"hasEnoughToStart",get:function J(){return this._hasEnoughToStart}},{key:"maxBufferLength",get:function J(){var Y=this.levels,Q=this.level,G=Y==null?void 0:Y[Q];if(!G)return this.config.maxBufferLength;return this.getMaxBufferLength(G.maxBitrate)}},{key:"nextLevel",get:function J(){var Y=this.nextBufferedFrag;if(Y)return Y.level;return-1}},{key:"currentFrag",get:function J(){var Y;if(this.fragPlaying)return this.fragPlaying;var Q=((Y=this.media)==null?void 0:Y.currentTime)||this.lastCurrentTime;if(T(Q))return this.getAppendedFrag(Q);return null}},{key:"currentProgramDateTime",get:function J(){var Y,Q=((Y=this.media)==null?void 0:Y.currentTime)||this.lastCurrentTime;if(T(Q)){var G=this.getLevelDetails(),q=this.currentFrag||(G?dJ(null,G.fragments,Q):null);if(q){var H=q.programDateTime;if(H!==null){var V=H+(Q-q.start)*1000;return new Date(V)}}}return null}},{key:"currentLevel",get:function J(){var Y=this.currentFrag;if(Y)return Y.level;return-1}},{key:"nextBufferedFrag",get:function J(){var Y=this.currentFrag;if(Y)return this.followingBufferedFrag(Y);return null}},{key:"forceStartLoad",get:function J(){return this._forceStartLoad}}])}(y9),GG=function(){function X(Z){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=Z}var W=X.prototype;return W.abort=function Z(J){for(var Y in this.keyUriToKeyInfo){var Q=this.keyUriToKeyInfo[Y].loader;if(Q){var G;if(J&&J!==((G=Q.context)==null?void 0:G.frag.type))return;Q.abort()}}},W.detach=function Z(){for(var J in this.keyUriToKeyInfo){var Y=this.keyUriToKeyInfo[J];if(Y.mediaKeySessionContext||Y.decryptdata.isCommonEncryption)delete this.keyUriToKeyInfo[J]}},W.destroy=function Z(){this.detach();for(var J in this.keyUriToKeyInfo){var Y=this.keyUriToKeyInfo[J].loader;if(Y)Y.destroy()}this.keyUriToKeyInfo={}},W.createKeyLoadError=function Z(J,Y,Q,G,q){if(Y===void 0)Y=h.KEY_LOAD_ERROR;return new e1({type:n.NETWORK_ERROR,details:Y,fatal:!1,frag:J,response:q,error:Q,networkDetails:G})},W.loadClear=function Z(J,Y){var Q=this;if(this.emeController&&this.config.emeEnabled){var{sn:G,cc:q}=J,H=function z(){var A=Y[V];if(q<=A.cc&&(G==="initSegment"||A.sn==="initSegment"||G<A.sn))return Q.emeController.selectKeySystemFormat(A).then(function(E){A.setKeyFormat(E)}),1};for(var V=0;V<Y.length;V++)if(H())break}},W.load=function Z(J){var Y=this;if(!J.decryptdata&&J.encrypted&&this.emeController&&this.config.emeEnabled)return this.emeController.selectKeySystemFormat(J).then(function(Q){return Y.loadInternal(J,Q)});return this.loadInternal(J)},W.loadInternal=function Z(J,Y){var Q,G;if(Y)J.setKeyFormat(Y);var q=J.decryptdata;if(!q){var H=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(J,h.KEY_LOAD_ERROR,H))}var V=q.uri;if(!V)return Promise.reject(this.createKeyLoadError(J,h.KEY_LOAD_ERROR,new Error('Invalid key URI: "'+V+'"')));var z=this.keyUriToKeyInfo[V];if((Q=z)!=null&&Q.decryptdata.key)return q.key=z.decryptdata.key,Promise.resolve({frag:J,keyInfo:z});if((G=z)!=null&&G.keyLoadPromise){var A;switch((A=z.mediaKeySessionContext)==null?void 0:A.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return z.keyLoadPromise.then(function(E){return q.key=E.keyInfo.decryptdata.key,{frag:J,keyInfo:z}})}}switch(z=this.keyUriToKeyInfo[V]={decryptdata:q,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},q.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":if(q.keyFormat==="identity")return this.loadKeyHTTP(z,J);return this.loadKeyEME(z,J);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(z,J);default:return Promise.reject(this.createKeyLoadError(J,h.KEY_LOAD_ERROR,new Error('Key supplied with unsupported METHOD: "'+q.method+'"')))}},W.loadKeyEME=function Z(J,Y){var Q={frag:Y,keyInfo:J};if(this.emeController&&this.config.emeEnabled){var G=this.emeController.loadKey(Q);if(G)return(J.keyLoadPromise=G.then(function(q){return J.mediaKeySessionContext=q,Q})).catch(function(q){throw J.keyLoadPromise=null,q})}return Promise.resolve(Q)},W.loadKeyHTTP=function Z(J,Y){var Q=this,G=this.config,q=G.loader,H=new q(G);return Y.keyLoader=J.loader=H,J.keyLoadPromise=new Promise(function(V,z){var A={keyInfo:J,frag:Y,responseType:"arraybuffer",url:J.decryptdata.uri},E=G.keyLoadPolicy.default,I={loadPolicy:E,timeout:E.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},$={onSuccess:function L(b,C,D,y){var{frag:S,keyInfo:v,url:p}=D;if(!S.decryptdata||v!==Q.keyUriToKeyInfo[p])return z(Q.createKeyLoadError(S,h.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),y));v.decryptdata.key=S.decryptdata.key=new Uint8Array(b.data),S.keyLoader=null,v.loader=null,V({frag:S,keyInfo:v})},onError:function L(b,C,D,y){Q.resetLoader(C),z(Q.createKeyLoadError(Y,h.KEY_LOAD_ERROR,new Error("HTTP Error "+b.code+" loading key "+b.text),D,f({url:A.url,data:void 0},b)))},onTimeout:function L(b,C,D){Q.resetLoader(C),z(Q.createKeyLoadError(Y,h.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),D))},onAbort:function L(b,C,D){Q.resetLoader(C),z(Q.createKeyLoadError(Y,h.INTERNAL_ABORTED,new Error("key loading aborted"),D))}};H.load(A,I,$)})},W.resetLoader=function Z(J){var{frag:Y,keyInfo:Q,url:G}=J,q=Q.loader;if(Y.keyLoader===q)Y.keyLoader=null,Q.loader=null;if(delete this.keyUriToKeyInfo[G],q)q.destroy()},X}();function vZ(X){var W=X.type;switch(W){case Z0.AUDIO_TRACK:return G0.AUDIO;case Z0.SUBTITLE_TRACK:return G0.SUBTITLE;default:return G0.MAIN}}function zQ(X,W){var Z=X.url;if(Z===void 0||Z.indexOf("data:")===0)Z=W.url;return Z}var WG=function(){function X(Z){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=Z,this.registerListeners()}var W=X.prototype;return W.startLoad=function Z(J){},W.stopLoad=function Z(){this.destroyInternalLoaders()},W.registerListeners=function Z(){var J=this.hls;J.on(M.MANIFEST_LOADING,this.onManifestLoading,this),J.on(M.LEVEL_LOADING,this.onLevelLoading,this),J.on(M.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),J.on(M.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),J.on(M.LEVELS_UPDATED,this.onLevelsUpdated,this)},W.unregisterListeners=function Z(){var J=this.hls;J.off(M.MANIFEST_LOADING,this.onManifestLoading,this),J.off(M.LEVEL_LOADING,this.onLevelLoading,this),J.off(M.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),J.off(M.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),J.off(M.LEVELS_UPDATED,this.onLevelsUpdated,this)},W.createInternalLoader=function Z(J){var Y=this.hls.config,Q=Y.pLoader,G=Y.loader,q=Q||G,H=new q(Y);return this.loaders[J.type]=H,H},W.getInternalLoader=function Z(J){return this.loaders[J.type]},W.resetInternalLoader=function Z(J){if(this.loaders[J])delete this.loaders[J]},W.destroyInternalLoaders=function Z(){for(var J in this.loaders){var Y=this.loaders[J];if(Y)Y.destroy();this.resetInternalLoader(J)}},W.destroy=function Z(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()},W.onManifestLoading=function Z(J,Y){var Q=Y.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Z0.MANIFEST,url:Q,deliveryDirectives:null,levelOrTrack:null})},W.onLevelLoading=function Z(J,Y){var{id:Q,level:G,pathwayId:q,url:H,deliveryDirectives:V,levelInfo:z}=Y;this.load({id:Q,level:G,pathwayId:q,responseType:"text",type:Z0.LEVEL,url:H,deliveryDirectives:V,levelOrTrack:z})},W.onAudioTrackLoading=function Z(J,Y){var{id:Q,groupId:G,url:q,deliveryDirectives:H,track:V}=Y;this.load({id:Q,groupId:G,level:null,responseType:"text",type:Z0.AUDIO_TRACK,url:q,deliveryDirectives:H,levelOrTrack:V})},W.onSubtitleTrackLoading=function Z(J,Y){var{id:Q,groupId:G,url:q,deliveryDirectives:H,track:V}=Y;this.load({id:Q,groupId:G,level:null,responseType:"text",type:Z0.SUBTITLE_TRACK,url:q,deliveryDirectives:H,levelOrTrack:V})},W.onLevelsUpdated=function Z(J,Y){var Q=this.loaders[Z0.LEVEL];if(Q){var G=Q.context;if(G&&!Y.levels.some(function(q){return q===G.levelOrTrack}))Q.abort(),delete this.loaders[Z0.LEVEL]}},W.load=function Z(J){var Y,Q=this,G=this.hls.config,q=this.getInternalLoader(J);if(q){var H=this.hls.logger,V=q.context;if(V&&V.levelOrTrack===J.levelOrTrack&&(V.url===J.url||V.deliveryDirectives&&!J.deliveryDirectives)){if(V.url===J.url)H.log("[playlist-loader]: ignore "+J.url+" ongoing request");else H.log("[playlist-loader]: ignore "+J.url+" in favor of "+V.url);return}H.log("[playlist-loader]: aborting previous loader for type: "+J.type),q.abort()}var z;if(J.type===Z0.MANIFEST)z=G.manifestLoadPolicy.default;else z=B({},G.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null});if(q=this.createInternalLoader(J),T((Y=J.deliveryDirectives)==null?void 0:Y.part)){var A;if(J.type===Z0.LEVEL&&J.level!==null)A=this.hls.levels[J.level].details;else if(J.type===Z0.AUDIO_TRACK&&J.id!==null)A=this.hls.audioTracks[J.id].details;else if(J.type===Z0.SUBTITLE_TRACK&&J.id!==null)A=this.hls.subtitleTracks[J.id].details;if(A){var{partTarget:E,targetduration:I}=A;if(E&&I){var $=Math.max(E*3,I*0.8)*1000;z=B({},z,{maxTimeToFirstByteMs:Math.min($,z.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min($,z.maxTimeToFirstByteMs)})}}}var L=z.errorRetry||z.timeoutRetry||{},b={loadPolicy:z,timeout:z.maxLoadTimeMs,maxRetry:L.maxNumRetry||0,retryDelay:L.retryDelayMs||0,maxRetryDelay:L.maxRetryDelayMs||0},C={onSuccess:function D(y,S,v,p){var g=Q.getInternalLoader(v);Q.resetInternalLoader(v.type);var m=y.data;if(m.indexOf("#EXTM3U")!==0){Q.handleManifestParsingError(y,v,new Error("no EXTM3U delimiter"),p||null,S);return}if(S.parsing.start=performance.now(),kY.isMediaPlaylist(m)||v.type!==Z0.MANIFEST)Q.handleTrackOrLevelPlaylist(y,S,v,p||null,g);else Q.handleMasterPlaylist(y,S,v,p)},onError:function D(y,S,v,p){Q.handleNetworkError(S,v,!1,y,p)},onTimeout:function D(y,S,v){Q.handleNetworkError(S,v,!0,void 0,y)}};q.load(J,b,C)},W.checkAutostartLoad=function Z(){if(!this.hls)return;var J=this.hls,Y=J.config,Q=Y.autoStartLoad,G=Y.startPosition,q=J.forceStartLoad;if(Q||q)this.hls.logger.log((Q?"auto":"force")+" startLoad with configured startPosition "+G),this.hls.startLoad(G)},W.handleMasterPlaylist=function Z(J,Y,Q,G){var q=this.hls,H=J.data,V=zQ(J,Q),z=kY.parseMasterPlaylist(H,V);if(z.playlistParsingError){this.handleManifestParsingError(J,Q,z.playlistParsingError,G,Y);return}var{contentSteering:A,levels:E,sessionData:I,sessionKeys:$,startTimeOffset:L,variableList:b}=z;this.variableList=b;var C=kY.parseMasterPlaylistMedia(H,V,z),D=C.AUDIO,y=D===void 0?[]:D,S=C.SUBTITLES,v=C["CLOSED-CAPTIONS"];if(y.length){var p=y.some(function(g){return!g.url});if(!p&&E[0].audioCodec&&!E[0].attrs.AUDIO)this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),y.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new Q1({}),bitrate:0,url:""})}q.trigger(M.MANIFEST_LOADED,{levels:E,audioTracks:y,subtitles:S,captions:v,contentSteering:A,url:V,stats:Y,networkDetails:G,sessionData:I,sessionKeys:$,startTimeOffset:L,variableList:b})},W.handleTrackOrLevelPlaylist=function Z(J,Y,Q,G,q){var H=this.hls,V=Q.id,z=Q.level,A=Q.type,E=zQ(J,Q),I=T(z)?z:T(V)?V:0,$=vZ(Q),L=kY.parseLevelPlaylist(J.data,E,I,$,0,this.variableList);if(A===Z0.MANIFEST){var b={attrs:new Q1({}),bitrate:0,details:L,name:"",url:E};L.requestScheduled=Y.loading.start+p2(L,0),H.trigger(M.MANIFEST_LOADED,{levels:[b],audioTracks:[],url:E,stats:Y,networkDetails:G,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}Y.parsing.end=performance.now(),Q.levelDetails=L,this.handlePlaylistLoaded(L,J,Y,Q,G,q)},W.handleManifestParsingError=function Z(J,Y,Q,G,q){this.hls.trigger(M.ERROR,{type:n.NETWORK_ERROR,details:h.MANIFEST_PARSING_ERROR,fatal:Y.type===Z0.MANIFEST,url:J.url,err:Q,error:Q,reason:Q.message,response:J,context:Y,networkDetails:G,stats:q})},W.handleNetworkError=function Z(J,Y,Q,G,q){if(Q===void 0)Q=!1;var H="A network "+(Q?"timeout":"error"+(G?" (status "+G.code+")":""))+" occurred while loading "+J.type;if(J.type===Z0.LEVEL)H+=": "+J.level+" id: "+J.id;else if(J.type===Z0.AUDIO_TRACK||J.type===Z0.SUBTITLE_TRACK)H+=" id: "+J.id+' group-id: "'+J.groupId+'"';var V=new Error(H);this.hls.logger.warn("[playlist-loader]: "+H);var z=h.UNKNOWN,A=!1,E=this.getInternalLoader(J);switch(J.type){case Z0.MANIFEST:z=Q?h.MANIFEST_LOAD_TIMEOUT:h.MANIFEST_LOAD_ERROR,A=!0;break;case Z0.LEVEL:z=Q?h.LEVEL_LOAD_TIMEOUT:h.LEVEL_LOAD_ERROR,A=!1;break;case Z0.AUDIO_TRACK:z=Q?h.AUDIO_TRACK_LOAD_TIMEOUT:h.AUDIO_TRACK_LOAD_ERROR,A=!1;break;case Z0.SUBTITLE_TRACK:z=Q?h.SUBTITLE_TRACK_LOAD_TIMEOUT:h.SUBTITLE_LOAD_ERROR,A=!1;break}if(E)this.resetInternalLoader(J.type);var I={type:n.NETWORK_ERROR,details:z,fatal:A,url:J.url,loader:E,context:J,error:V,networkDetails:Y,stats:q};if(G){var $=(Y==null?void 0:Y.url)||J.url;I.response=f({url:$,data:void 0},G)}this.hls.trigger(M.ERROR,I)},W.handlePlaylistLoaded=function Z(J,Y,Q,G,q,H){var V=this.hls,z=G.type,A=G.level,E=G.id,I=G.groupId,$=G.deliveryDirectives,L=zQ(Y,G),b=vZ(G),C=typeof G.level==="number"&&b===G0.MAIN?A:void 0;if(!J.fragments.length){var D=J.playlistParsingError=new Error("No Segments found in Playlist");V.trigger(M.ERROR,{type:n.NETWORK_ERROR,details:h.LEVEL_EMPTY_ERROR,fatal:!1,url:L,error:D,reason:D.message,response:Y,context:G,level:C,parent:b,networkDetails:q,stats:Q});return}if(!J.targetduration)J.playlistParsingError=new Error("Missing Target Duration");var y=J.playlistParsingError;if(y){if(this.hls.logger.warn(y),!V.config.ignorePlaylistParsingErrors){V.trigger(M.ERROR,{type:n.NETWORK_ERROR,details:h.LEVEL_PARSING_ERROR,fatal:!1,url:L,error:y,reason:y.message,response:Y,context:G,level:C,parent:b,networkDetails:q,stats:Q});return}J.playlistParsingError=null}if(J.live&&H){if(H.getCacheAge)J.ageHeader=H.getCacheAge()||0;if(!H.getCacheAge||isNaN(J.ageHeader))J.ageHeader=0}switch(z){case Z0.MANIFEST:case Z0.LEVEL:V.trigger(M.LEVEL_LOADED,{details:J,levelInfo:G.levelOrTrack||V.levels[0],level:C||0,id:E||0,stats:Q,networkDetails:q,deliveryDirectives:$,withoutMultiVariant:z===Z0.MANIFEST});break;case Z0.AUDIO_TRACK:V.trigger(M.AUDIO_TRACK_LOADED,{details:J,track:G.levelOrTrack,id:E||0,groupId:I||"",stats:Q,networkDetails:q,deliveryDirectives:$});break;case Z0.SUBTITLE_TRACK:V.trigger(M.SUBTITLE_TRACK_LOADED,{details:J,track:G.levelOrTrack,id:E||0,groupId:I||"",stats:Q,networkDetails:q,deliveryDirectives:$});break}},X}(),KG={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]};function qG(X,W){return{supported:!1,configurations:W,decodingInfoResults:[{supported:!1,smooth:!1,powerEfficient:!1}],error:X}}var hZ={};function HG(X,W,Z){var{videoCodec:J,audioCodec:Y}=X;if(!J&&!Y||!Z)return Promise.resolve(KG);var Q=[];if(J){var G={width:X.width,height:X.height,bitrate:Math.ceil(Math.max(X.bitrate*0.9,X.averageBitrate)),framerate:X.frameRate||30},q=X.videoRange;if(q!=="SDR")G.transferFunction=q.toLowerCase();var H=J.split(","),V=navigator.userAgent;if(H.some(function(z){return pJ(z)})&&G2())return Promise.resolve(qG(new Error("Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent sting: ("+V+")"),Q));Q.push.apply(Q,H.map(function(z){return{type:"media-source",video:f(f({},G),{},{contentType:vY(IX(z),"video")})}}))}if(Y&&X.audioGroups)X.audioGroups.forEach(function(z){var A;if(!z)return;(A=W.groups[z])==null||A.tracks.forEach(function(E){if(E.groupId===z){var I=E.channels||"",$=parseFloat(I);if(T($)&&$>2)Q.push.apply(Q,Y.split(",").map(function(L){return{type:"media-source",audio:{contentType:vY(L,"audio"),channels:""+$}}}))}})});return Promise.all(Q.map(function(z){var A=NG(z);return hZ[A]||(hZ[A]=Z.decodingInfo(z))})).then(function(z){return{supported:!z.some(function(A){return!A.supported}),configurations:Q,decodingInfoResults:z}}).catch(function(z){return{supported:!1,configurations:Q,decodingInfoResults:[],error:z}})}function NG(X){var{audio:W,video:Z}=X,J=Z||W;if(J){var Y=N2(J.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(W)return"c"+W.channels+(W.spatialRendering?"s":"n")+"_"+Y}return""}var kZ=function(){function X(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 h0,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 J=this.logger=e0(Z.debug||!1,"Hls instance",Z.assetPlayerId),Y=this.config=R9(X.DefaultConfig,Z,J);if(this.userConfig=Z,Y.progressive)$9(Y,J);var{abrController:Q,bufferController:G,capLevelController:q,errorController:H,fpsController:V}=Y,z=new H(this),A=this.abrController=new Q(this),E=new I9(this),I=Y.interstitialsController,$=I?this.interstitialsController=new I(this,X):null,L=this.bufferController=new G(this,E),b=this.capLevelController=new q(this),C=new V(this),D=new WG(this),y=Y.contentSteeringController,S=y?new y(this):null,v=this.levelController=new n9(this,S),p=new c9(this),g=new GG(this.config),m=this.streamController=new XG(this,E,g),r=this.gapController=new h9(this,E);b.setStreamController(m),C.setStreamController(m);var o=[D,v,m];if($)o.splice(1,0,$);if(S)o.splice(1,0,S);this.networkControllers=o;var c=[A,L,r,b,C,p,E];this.audioTrackController=this.createController(Y.audioTrackController,o);var d=Y.audioStreamController;if(d)o.push(this.audioStreamController=new d(this,E,g));this.subtitleTrackController=this.createController(Y.subtitleTrackController,o);var e=Y.subtitleStreamController;if(e)o.push(this.subtititleStreamController=new e(this,E,g));this.createController(Y.timelineController,c),g.emeController=this.emeController=this.createController(Y.emeController,c),this.cmcdController=this.createController(Y.cmcdController,c),this.latencyController=this.createController(l9,c),this.coreComponents=c,o.push(z);var H0=z.onErrorOut;if(typeof H0==="function")this.on(M.ERROR,H0,z);this.on(M.MANIFEST_LOADED,D.onManifestLoaded,D)}X.isMSESupported=function Z(){return xZ()},X.isSupported=function Z(){return JG()},X.getMediaSource=function Z(){return XY()};var W=X.prototype;return W.createController=function Z(J,Y){if(J){var Q=new J(this);if(Y)Y.push(Q);return Q}return null},W.on=function Z(J,Y,Q){if(Q===void 0)Q=this;this._emitter.on(J,Y,Q)},W.once=function Z(J,Y,Q){if(Q===void 0)Q=this;this._emitter.once(J,Y,Q)},W.removeAllListeners=function Z(J){this._emitter.removeAllListeners(J)},W.off=function Z(J,Y,Q,G){if(Q===void 0)Q=this;this._emitter.off(J,Y,Q,G)},W.listeners=function Z(J){return this._emitter.listeners(J)},W.emit=function Z(J,Y,Q){return this._emitter.emit(J,Y,Q)},W.trigger=function Z(J,Y){if(this.config.debug)return this.emit(J,J,Y);else try{return this.emit(J,J,Y)}catch(G){if(this.logger.error("An internal error happened while handling event "+J+'. Error message: "'+G.message+'". Here is a stacktrace:',G),!this.triggeringException){this.triggeringException=!0;var Q=J===M.ERROR;this.trigger(M.ERROR,{type:n.OTHER_ERROR,details:h.INTERNAL_EXCEPTION,fatal:Q,event:J,error:G}),this.triggeringException=!1}}return!1},W.listenerCount=function Z(J){return this._emitter.listenerCount(J)},W.destroy=function Z(){this.logger.log("destroy"),this.trigger(M.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 J=this.config;J.xhrSetup=J.fetchSetup=void 0,this.userConfig=null},W.attachMedia=function Z(J){if(!J||"media"in J&&!J.media){var Y=new Error("attachMedia failed: invalid argument ("+J+")");this.trigger(M.ERROR,{type:n.OTHER_ERROR,details:h.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 Q="media"in J,G=Q?J.media:J,q=Q?J:{media:G};this._media=G,this.trigger(M.MEDIA_ATTACHING,q)},W.detachMedia=function Z(){this.logger.log("detachMedia"),this.trigger(M.MEDIA_DETACHING,{}),this._media=null},W.transferMedia=function Z(){this._media=null;var J=this.bufferController.transferMedia();return this.trigger(M.MEDIA_DETACHING,{transferMedia:J}),J},W.loadSource=function Z(J){this.stopLoad();var Y=this.media,Q=this._url,G=this._url=t0.buildAbsoluteURL(self.location.href,J,{alwaysNormalize:!0});if(this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log("loadSource:"+G),Y&&Q&&(Q!==G||this.bufferController.hasSourceTypes()))this.detachMedia(),this.attachMedia(Y);this.trigger(M.MANIFEST_LOADING,{url:J})},W.startLoad=function Z(J,Y){if(J===void 0)J=-1;this.logger.log("startLoad("+(J+(Y?", <skip seek to start>":""))+")"),this.started=!0,this.resumeBuffering();for(var Q=0;Q<this.networkControllers.length;Q++)if(this.networkControllers[Q].startLoad(J,Y),!this.started||!this.networkControllers)break},W.stopLoad=function Z(){this.logger.log("stopLoad"),this.started=!1;for(var J=0;J<this.networkControllers.length;J++)if(this.networkControllers[J].stopLoad(),this.started||!this.networkControllers)break},W.resumeBuffering=function Z(){if(!this.bufferingEnabled)this.logger.log("resume buffering"),this.networkControllers.forEach(function(J){if(J.resumeBuffering)J.resumeBuffering()})},W.pauseBuffering=function Z(){if(this.bufferingEnabled)this.logger.log("pause buffering"),this.networkControllers.forEach(function(J){if(J.pauseBuffering)J.pauseBuffering()})},W.swapAudioCodec=function Z(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},W.recoverMediaError=function Z(){this.logger.log("recoverMediaError");var J=this._media,Y=J==null?void 0:J.currentTime;if(this.detachMedia(),J){if(this.attachMedia(J),Y)this.startLoad(Y)}},W.removeLevel=function Z(J){this.levelController.removeLevel(J)},W.setAudioOption=function Z(J){var Y;return((Y=this.audioTrackController)==null?void 0:Y.setAudioOption(J))||null},W.setSubtitleOption=function Z(J){var Y;return((Y=this.subtitleTrackController)==null?void 0:Y.setSubtitleOption(J))||null},W.getMediaDecodingInfo=function Z(J,Y){if(Y===void 0)Y=this.allAudioTracks;var Q=A2(Y);return HG(J,Q,navigator.mediaCapabilities)},N(X,[{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 J,Y=(J={},J[G0.MAIN]=this.streamController.inFlightFrag,J);if(this.audioStreamController)Y[G0.AUDIO]=this.audioStreamController.inFlightFrag;if(this.subtititleStreamController)Y[G0.SUBTITLE]=this.subtititleStreamController.inFlightFrag;return Y}},{key:"sessionId",get:function Z(){var J=this._sessionId;if(!J)J=this._sessionId=K0();return J}},{key:"levels",get:function Z(){var J=this.levelController.levels;return J?J:[]}},{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(J){this.logger.log("set currentLevel:"+J),this.levelController.manualLevel=J,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function Z(){return this.streamController.nextLevel},set:function Z(J){this.logger.log("set nextLevel:"+J),this.levelController.manualLevel=J,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function Z(){return this.levelController.level},set:function Z(J){this.logger.log("set loadLevel:"+J),this.levelController.manualLevel=J}},{key:"nextLoadLevel",get:function Z(){return this.levelController.nextLoadLevel},set:function Z(J){this.levelController.nextLoadLevel=J}},{key:"firstLevel",get:function Z(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function Z(J){this.logger.log("set firstLevel:"+J),this.levelController.firstLevel=J}},{key:"startLevel",get:function Z(){var J=this.levelController.startLevel;if(J===-1&&this.abrController.forcedAutoLevel>-1)return this.abrController.forcedAutoLevel;return J},set:function Z(J){if(this.logger.log("set startLevel:"+J),J!==-1)J=Math.max(J,this.minAutoLevel);this.levelController.startLevel=J}},{key:"capLevelToPlayerSize",get:function Z(){return this.config.capLevelToPlayerSize},set:function Z(J){var Y=!!J;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(J){if(this._autoLevelCapping!==J)this.logger.log("set autoLevelCapping:"+J),this._autoLevelCapping=J,this.levelController.checkMaxAutoUpdated()}},{key:"bandwidthEstimate",get:function Z(){var J=this.abrController.bwEstimator;if(!J)return NaN;return J.getEstimate()},set:function Z(J){this.abrController.resetEstimator(J)}},{key:"abrEwmaDefaultEstimate",get:function Z(){var J=this.abrController.bwEstimator;if(!J)return NaN;return J.defaultEstimate}},{key:"ttfbEstimate",get:function Z(){var J=this.abrController.bwEstimator;if(!J)return NaN;return J.getEstimateTTFB()}},{key:"maxHdcpLevel",get:function Z(){return this._maxHdcpLevel},set:function Z(J){if(LX(J)&&this._maxHdcpLevel!==J)this._maxHdcpLevel=J,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 J=this.levels,Y=this.config.minAutoBitrate;if(!J)return 0;var Q=J.length;for(var G=0;G<Q;G++)if(J[G].maxBitrate>=Y)return G;return 0}},{key:"maxAutoLevel",get:function Z(){var J=this.levels,Y=this.autoLevelCapping,Q=this.maxHdcpLevel,G;if(Y===-1&&J!=null&&J.length)G=J.length-1;else G=Y;if(Q)for(var q=G;q--;){var H=J[q].attrs["HDCP-LEVEL"];if(H&&H<=Q)return q}return G}},{key:"firstAutoLevel",get:function Z(){return this.abrController.firstAutoLevel}},{key:"nextAutoLevel",get:function Z(){return this.abrController.nextAutoLevel},set:function Z(J){this.abrController.nextAutoLevel=J}},{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 J=this.audioTrackController;return J?J.allAudioTracks:[]}},{key:"audioTracks",get:function Z(){var J=this.audioTrackController;return J?J.audioTracks:[]}},{key:"audioTrack",get:function Z(){var J=this.audioTrackController;return J?J.audioTrack:-1},set:function Z(J){var Y=this.audioTrackController;if(Y)Y.audioTrack=J}},{key:"allSubtitleTracks",get:function Z(){var J=this.subtitleTrackController;return J?J.allSubtitleTracks:[]}},{key:"subtitleTracks",get:function Z(){var J=this.subtitleTrackController;return J?J.subtitleTracks:[]}},{key:"subtitleTrack",get:function Z(){var J=this.subtitleTrackController;return J?J.subtitleTrack:-1},set:function Z(J){var Y=this.subtitleTrackController;if(Y)Y.subtitleTrack=J}},{key:"media",get:function Z(){return this._media}},{key:"subtitleDisplay",get:function Z(){var J=this.subtitleTrackController;return J?J.subtitleDisplay:!1},set:function Z(J){var Y=this.subtitleTrackController;if(Y)Y.subtitleDisplay=J}},{key:"lowLatencyMode",get:function Z(){return this.config.lowLatencyMode},set:function Z(J){this.config.lowLatencyMode=J}},{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(J){this.latencyController.targetLatency=J}},{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(J){this.levelController.pathwayPriority=J}},{key:"bufferedToEnd",get:function Z(){var J;return!!((J=this.bufferController)!=null&&J.bufferedToEnd)}},{key:"interstitialsManager",get:function Z(){var J;return((J=this.interstitialsController)==null?void 0:J.interstitialsManager)||null}}],[{key:"version",get:function Z(){return _Y}},{key:"Events",get:function Z(){return M}},{key:"MetadataSchema",get:function Z(){return b1}},{key:"ErrorTypes",get:function Z(){return n}},{key:"ErrorDetails",get:function Z(){return h}},{key:"DefaultConfig",get:function Z(){if(!X.defaultConfig)return B9;return X.defaultConfig},set:function Z(J){X.defaultConfig=J}}])}();return kZ.defaultConfig=void 0,kZ})})(!1)});var WW={};BQ(WW,{Flv:()=>OY});function iZ(j,F){var K=Object.keys(j);if(Object.getOwnPropertySymbols){var U=Object.getOwnPropertySymbols(j);F&&(U=U.filter(function(N){return Object.getOwnPropertyDescriptor(j,N).enumerable})),K.push.apply(K,U)}return K}function y1(j){for(var F=1;F<arguments.length;F++){var K=arguments[F]!=null?arguments[F]:{};F%2?iZ(Object(K),!0).forEach(function(U){F0(j,U,K[U])}):Object.getOwnPropertyDescriptors?Object.defineProperties(j,Object.getOwnPropertyDescriptors(K)):iZ(Object(K)).forEach(function(U){Object.defineProperty(j,U,Object.getOwnPropertyDescriptor(K,U))})}return j}function S0(){S0=function(){return j};var j={},F=Object.prototype,K=F.hasOwnProperty,U=Object.defineProperty||function(T,u,_){T[u]=_.value},N=typeof Symbol=="function"?Symbol:{},O=N.iterator||"@@iterator",B=N.asyncIterator||"@@asyncIterator",w=N.toStringTag||"@@toStringTag";function R(T,u,_){return Object.defineProperty(T,u,{value:_,enumerable:!0,configurable:!0,writable:!0}),T[u]}try{R({},"")}catch(T){R=function(u,_,n){return u[_]=n}}function P(T,u,_,n){var h=u&&u.prototype instanceof f?u:f,M=Object.create(h.prototype),Z0=new E0(n||[]);return U(M,"_invoke",{value:W0(T,_,Z0)}),M}function x(T,u,_){try{return{type:"normal",arg:T.call(u,_)}}catch(n){return{type:"throw",arg:n}}}j.wrap=P;var k={};function f(){}function l(){}function s(){}var Y0={};R(Y0,O,function(){return this});var t=Object.getPrototypeOf,K0=t&&t(t(y0([])));K0&&K0!==F&&K.call(K0,O)&&(Y0=K0);var q0=s.prototype=f.prototype=Object.create(Y0);function R0(T){["next","throw","return"].forEach(function(u){R(T,u,function(_){return this._invoke(u,_)})})}function U0(T,u){function _(h,M,Z0,G0){var C0=x(T[h],T,M);if(C0.type!=="throw"){var u0=C0.arg,d0=u0.value;return d0&&typeof d0=="object"&&K.call(d0,"__await")?u.resolve(d0.__await).then(function(M0){_("next",M0,Z0,G0)},function(M0){_("throw",M0,Z0,G0)}):u.resolve(d0).then(function(M0){u0.value=M0,Z0(u0)},function(M0){return _("throw",M0,Z0,G0)})}G0(C0.arg)}var n;U(this,"_invoke",{value:function(h,M){function Z0(){return new u(function(G0,C0){_(h,M,G0,C0)})}return n=n?n.then(Z0,Z0):Z0()}})}function W0(T,u,_){var n="suspendedStart";return function(h,M){if(n==="executing")throw new Error("Generator is already running");if(n==="completed"){if(h==="throw")throw M;return t0()}for(_.method=h,_.arg=M;;){var Z0=_.delegate;if(Z0){var G0=z0(Z0,_);if(G0){if(G0===k)continue;return G0}}if(_.method==="next")_.sent=_._sent=_.arg;else if(_.method==="throw"){if(n==="suspendedStart")throw n="completed",_.arg;_.dispatchException(_.arg)}else _.method==="return"&&_.abrupt("return",_.arg);n="executing";var C0=x(T,u,_);if(C0.type==="normal"){if(n=_.done?"completed":"suspendedYield",C0.arg===k)continue;return{value:C0.arg,done:_.done}}C0.type==="throw"&&(n="completed",_.method="throw",_.arg=C0.arg)}}}function z0(T,u){var _=u.method,n=T.iterator[_];if(n===void 0)return u.delegate=null,_==="throw"&&T.iterator.return&&(u.method="return",u.arg=void 0,z0(T,u),u.method==="throw")||_!=="return"&&(u.method="throw",u.arg=new TypeError("The iterator does not provide a '"+_+"' method")),k;var h=x(n,T.iterator,u.arg);if(h.type==="throw")return u.method="throw",u.arg=h.arg,u.delegate=null,k;var M=h.arg;return M?M.done?(u[T.resultName]=M.value,u.next=T.nextLoc,u.method!=="return"&&(u.method="next",u.arg=void 0),u.delegate=null,k):M:(u.method="throw",u.arg=new TypeError("iterator result is not an object"),u.delegate=null,k)}function h0(T){var u={tryLoc:T[0]};1 in T&&(u.catchLoc=T[1]),2 in T&&(u.finallyLoc=T[2],u.afterLoc=T[3]),this.tryEntries.push(u)}function l0(T){var u=T.completion||{};u.type="normal",delete u.arg,T.completion=u}function E0(T){this.tryEntries=[{tryLoc:"root"}],T.forEach(h0,this),this.reset(!0)}function y0(T){if(T){var u=T[O];if(u)return u.call(T);if(typeof T.next=="function")return T;if(!isNaN(T.length)){var _=-1,n=function h(){for(;++_<T.length;)if(K.call(T,_))return h.value=T[_],h.done=!1,h;return h.value=void 0,h.done=!0,h};return n.next=n}}return{next:t0}}function t0(){return{value:void 0,done:!0}}return l.prototype=s,U(q0,"constructor",{value:s,configurable:!0}),U(s,"constructor",{value:l,configurable:!0}),l.displayName=R(s,w,"GeneratorFunction"),j.isGeneratorFunction=function(T){var u=typeof T=="function"&&T.constructor;return!!u&&(u===l||(u.displayName||u.name)==="GeneratorFunction")},j.mark=function(T){return Object.setPrototypeOf?Object.setPrototypeOf(T,s):(T.__proto__=s,R(T,w,"GeneratorFunction")),T.prototype=Object.create(q0),T},j.awrap=function(T){return{__await:T}},R0(U0.prototype),R(U0.prototype,B,function(){return this}),j.AsyncIterator=U0,j.async=function(T,u,_,n,h){h===void 0&&(h=Promise);var M=new U0(P(T,u,_,n),h);return j.isGeneratorFunction(u)?M:M.next().then(function(Z0){return Z0.done?Z0.value:M.next()})},R0(q0),R(q0,w,"Generator"),R(q0,O,function(){return this}),R(q0,"toString",function(){return"[object Generator]"}),j.keys=function(T){var u=Object(T),_=[];for(var n in u)_.push(n);return _.reverse(),function h(){for(;_.length;){var M=_.pop();if(M in u)return h.value=M,h.done=!1,h}return h.done=!0,h}},j.values=y0,E0.prototype={constructor:E0,reset:function(T){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(l0),!T)for(var u in this)u.charAt(0)==="t"&&K.call(this,u)&&!isNaN(+u.slice(1))&&(this[u]=void 0)},stop:function(){this.done=!0;var T=this.tryEntries[0].completion;if(T.type==="throw")throw T.arg;return this.rval},dispatchException:function(T){if(this.done)throw T;var u=this;function _(C0,u0){return M.type="throw",M.arg=T,u.next=C0,u0&&(u.method="next",u.arg=void 0),!!u0}for(var n=this.tryEntries.length-1;n>=0;--n){var h=this.tryEntries[n],M=h.completion;if(h.tryLoc==="root")return _("end");if(h.tryLoc<=this.prev){var Z0=K.call(h,"catchLoc"),G0=K.call(h,"finallyLoc");if(Z0&&G0){if(this.prev<h.catchLoc)return _(h.catchLoc,!0);if(this.prev<h.finallyLoc)return _(h.finallyLoc)}else if(Z0){if(this.prev<h.catchLoc)return _(h.catchLoc,!0)}else{if(!G0)throw new Error("try statement without catch or finally");if(this.prev<h.finallyLoc)return _(h.finallyLoc)}}}},abrupt:function(T,u){for(var _=this.tryEntries.length-1;_>=0;--_){var n=this.tryEntries[_];if(n.tryLoc<=this.prev&&K.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var h=n;break}}h&&(T==="break"||T==="continue")&&h.tryLoc<=u&&u<=h.finallyLoc&&(h=null);var M=h?h.completion:{};return M.type=T,M.arg=u,h?(this.method="next",this.next=h.finallyLoc,k):this.complete(M)},complete:function(T,u){if(T.type==="throw")throw T.arg;return T.type==="break"||T.type==="continue"?this.next=T.arg:T.type==="return"?(this.rval=this.arg=T.arg,this.method="return",this.next="end"):T.type==="normal"&&u&&(this.next=u),k},finish:function(T){for(var u=this.tryEntries.length-1;u>=0;--u){var _=this.tryEntries[u];if(_.finallyLoc===T)return this.complete(_.completion,_.afterLoc),l0(_),k}},catch:function(T){for(var u=this.tryEntries.length-1;u>=0;--u){var _=this.tryEntries[u];if(_.tryLoc===T){var n=_.completion;if(n.type==="throw"){var h=n.arg;l0(_)}return h}}throw new Error("illegal catch attempt")},delegateYield:function(T,u,_){return this.delegate={iterator:y0(T),resultName:u,nextLoc:_},this.method==="next"&&(this.arg=void 0),k}},j}function sZ(j,F,K,U,N,O,B){try{var w=j[O](B),R=w.value}catch(P){K(P);return}if(w.done)F(R);else Promise.resolve(R).then(U,N)}function G1(j){return function(){var F=this,K=arguments;return new Promise(function(U,N){var O=j.apply(F,K);function B(R){sZ(O,U,N,B,w,"next",R)}function w(R){sZ(O,U,N,B,w,"throw",R)}B(void 0)})}}function bY(j,F){if(!(j instanceof F))throw new TypeError("Cannot call a class as a function")}function rZ(j,F){for(var K=0;K<F.length;K++){var U=F[K];if(U.enumerable=U.enumerable||!1,U.configurable=!0,"value"in U)U.writable=!0;Object.defineProperty(j,eZ(U.key),U)}}function MY(j,F,K){if(F)rZ(j.prototype,F);if(K)rZ(j,K);return Object.defineProperty(j,"prototype",{writable:!1}),j}function F0(j,F,K){if(F=eZ(F),F in j)Object.defineProperty(j,F,{value:K,enumerable:!0,configurable:!0,writable:!0});else j[F]=K;return j}function aZ(j,F){if(typeof F!=="function"&&F!==null)throw new TypeError("Super expression must either be null or a function");if(j.prototype=Object.create(F&&F.prototype,{constructor:{value:j,writable:!0,configurable:!0}}),Object.defineProperty(j,"prototype",{writable:!1}),F)wQ(j,F)}function LJ(j){return LJ=Object.setPrototypeOf?Object.getPrototypeOf.bind():function F(K){return K.__proto__||Object.getPrototypeOf(K)},LJ(j)}function wQ(j,F){return wQ=Object.setPrototypeOf?Object.setPrototypeOf.bind():function K(U,N){return U.__proto__=N,U},wQ(j,F)}function bG(){if(typeof Reflect==="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy==="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(j){return!1}}function x0(j){if(j===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return j}function MG(j,F){if(F&&(typeof F==="object"||typeof F==="function"))return F;else if(F!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return x0(j)}function tZ(j){var F=bG();return function K(){var U=LJ(j),N;if(F){var O=LJ(this).constructor;N=Reflect.construct(U,arguments,O)}else N=U.apply(this,arguments);return MG(this,N)}}function CG(j,F){if(typeof j!=="object"||j===null)return j;var K=j[Symbol.toPrimitive];if(K!==void 0){var U=K.call(j,F||"default");if(typeof U!=="object")return U;throw new TypeError("@@toPrimitive must return a primitive value.")}return(F==="string"?String:Number)(j)}function eZ(j){var F=CG(j,"string");return typeof F==="symbol"?F:String(F)}function J8(j,F){var K=Object.keys(j);if(Object.getOwnPropertySymbols){var U=Object.getOwnPropertySymbols(j);F&&(U=U.filter(function(N){return Object.getOwnPropertyDescriptor(j,N).enumerable})),K.push.apply(K,U)}return K}function qY(j){for(var F=1;F<arguments.length;F++){var K=arguments[F]!=null?arguments[F]:{};F%2?J8(Object(K),!0).forEach(function(U){i(j,U,K[U])}):Object.getOwnPropertyDescriptors?Object.defineProperties(j,Object.getOwnPropertyDescriptors(K)):J8(Object(K)).forEach(function(U){Object.defineProperty(j,U,Object.getOwnPropertyDescriptor(K,U))})}return j}function r0(){r0=function(){return j};var j={},F=Object.prototype,K=F.hasOwnProperty,U=Object.defineProperty||function(T,u,_){T[u]=_.value},N=typeof Symbol=="function"?Symbol:{},O=N.iterator||"@@iterator",B=N.asyncIterator||"@@asyncIterator",w=N.toStringTag||"@@toStringTag";function R(T,u,_){return Object.defineProperty(T,u,{value:_,enumerable:!0,configurable:!0,writable:!0}),T[u]}try{R({},"")}catch(T){R=function(u,_,n){return u[_]=n}}function P(T,u,_,n){var h=u&&u.prototype instanceof f?u:f,M=Object.create(h.prototype),Z0=new E0(n||[]);return U(M,"_invoke",{value:W0(T,_,Z0)}),M}function x(T,u,_){try{return{type:"normal",arg:T.call(u,_)}}catch(n){return{type:"throw",arg:n}}}j.wrap=P;var k={};function f(){}function l(){}function s(){}var Y0={};R(Y0,O,function(){return this});var t=Object.getPrototypeOf,K0=t&&t(t(y0([])));K0&&K0!==F&&K.call(K0,O)&&(Y0=K0);var q0=s.prototype=f.prototype=Object.create(Y0);function R0(T){["next","throw","return"].forEach(function(u){R(T,u,function(_){return this._invoke(u,_)})})}function U0(T,u){function _(h,M,Z0,G0){var C0=x(T[h],T,M);if(C0.type!=="throw"){var u0=C0.arg,d0=u0.value;return d0&&typeof d0=="object"&&K.call(d0,"__await")?u.resolve(d0.__await).then(function(M0){_("next",M0,Z0,G0)},function(M0){_("throw",M0,Z0,G0)}):u.resolve(d0).then(function(M0){u0.value=M0,Z0(u0)},function(M0){return _("throw",M0,Z0,G0)})}G0(C0.arg)}var n;U(this,"_invoke",{value:function(h,M){function Z0(){return new u(function(G0,C0){_(h,M,G0,C0)})}return n=n?n.then(Z0,Z0):Z0()}})}function W0(T,u,_){var n="suspendedStart";return function(h,M){if(n==="executing")throw new Error("Generator is already running");if(n==="completed"){if(h==="throw")throw M;return t0()}for(_.method=h,_.arg=M;;){var Z0=_.delegate;if(Z0){var G0=z0(Z0,_);if(G0){if(G0===k)continue;return G0}}if(_.method==="next")_.sent=_._sent=_.arg;else if(_.method==="throw"){if(n==="suspendedStart")throw n="completed",_.arg;_.dispatchException(_.arg)}else _.method==="return"&&_.abrupt("return",_.arg);n="executing";var C0=x(T,u,_);if(C0.type==="normal"){if(n=_.done?"completed":"suspendedYield",C0.arg===k)continue;return{value:C0.arg,done:_.done}}C0.type==="throw"&&(n="completed",_.method="throw",_.arg=C0.arg)}}}function z0(T,u){var _=u.method,n=T.iterator[_];if(n===void 0)return u.delegate=null,_==="throw"&&T.iterator.return&&(u.method="return",u.arg=void 0,z0(T,u),u.method==="throw")||_!=="return"&&(u.method="throw",u.arg=new TypeError("The iterator does not provide a '"+_+"' method")),k;var h=x(n,T.iterator,u.arg);if(h.type==="throw")return u.method="throw",u.arg=h.arg,u.delegate=null,k;var M=h.arg;return M?M.done?(u[T.resultName]=M.value,u.next=T.nextLoc,u.method!=="return"&&(u.method="next",u.arg=void 0),u.delegate=null,k):M:(u.method="throw",u.arg=new TypeError("iterator result is not an object"),u.delegate=null,k)}function h0(T){var u={tryLoc:T[0]};1 in T&&(u.catchLoc=T[1]),2 in T&&(u.finallyLoc=T[2],u.afterLoc=T[3]),this.tryEntries.push(u)}function l0(T){var u=T.completion||{};u.type="normal",delete u.arg,T.completion=u}function E0(T){this.tryEntries=[{tryLoc:"root"}],T.forEach(h0,this),this.reset(!0)}function y0(T){if(T){var u=T[O];if(u)return u.call(T);if(typeof T.next=="function")return T;if(!isNaN(T.length)){var _=-1,n=function h(){for(;++_<T.length;)if(K.call(T,_))return h.value=T[_],h.done=!1,h;return h.value=void 0,h.done=!0,h};return n.next=n}}return{next:t0}}function t0(){return{value:void 0,done:!0}}return l.prototype=s,U(q0,"constructor",{value:s,configurable:!0}),U(s,"constructor",{value:l,configurable:!0}),l.displayName=R(s,w,"GeneratorFunction"),j.isGeneratorFunction=function(T){var u=typeof T=="function"&&T.constructor;return!!u&&(u===l||(u.displayName||u.name)==="GeneratorFunction")},j.mark=function(T){return Object.setPrototypeOf?Object.setPrototypeOf(T,s):(T.__proto__=s,R(T,w,"GeneratorFunction")),T.prototype=Object.create(q0),T},j.awrap=function(T){return{__await:T}},R0(U0.prototype),R(U0.prototype,B,function(){return this}),j.AsyncIterator=U0,j.async=function(T,u,_,n,h){h===void 0&&(h=Promise);var M=new U0(P(T,u,_,n),h);return j.isGeneratorFunction(u)?M:M.next().then(function(Z0){return Z0.done?Z0.value:M.next()})},R0(q0),R(q0,w,"Generator"),R(q0,O,function(){return this}),R(q0,"toString",function(){return"[object Generator]"}),j.keys=function(T){var u=Object(T),_=[];for(var n in u)_.push(n);return _.reverse(),function h(){for(;_.length;){var M=_.pop();if(M in u)return h.value=M,h.done=!1,h}return h.done=!0,h}},j.values=y0,E0.prototype={constructor:E0,reset:function(T){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(l0),!T)for(var u in this)u.charAt(0)==="t"&&K.call(this,u)&&!isNaN(+u.slice(1))&&(this[u]=void 0)},stop:function(){this.done=!0;var T=this.tryEntries[0].completion;if(T.type==="throw")throw T.arg;return this.rval},dispatchException:function(T){if(this.done)throw T;var u=this;function _(C0,u0){return M.type="throw",M.arg=T,u.next=C0,u0&&(u.method="next",u.arg=void 0),!!u0}for(var n=this.tryEntries.length-1;n>=0;--n){var h=this.tryEntries[n],M=h.completion;if(h.tryLoc==="root")return _("end");if(h.tryLoc<=this.prev){var Z0=K.call(h,"catchLoc"),G0=K.call(h,"finallyLoc");if(Z0&&G0){if(this.prev<h.catchLoc)return _(h.catchLoc,!0);if(this.prev<h.finallyLoc)return _(h.finallyLoc)}else if(Z0){if(this.prev<h.catchLoc)return _(h.catchLoc,!0)}else{if(!G0)throw new Error("try statement without catch or finally");if(this.prev<h.finallyLoc)return _(h.finallyLoc)}}}},abrupt:function(T,u){for(var _=this.tryEntries.length-1;_>=0;--_){var n=this.tryEntries[_];if(n.tryLoc<=this.prev&&K.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var h=n;break}}h&&(T==="break"||T==="continue")&&h.tryLoc<=u&&u<=h.finallyLoc&&(h=null);var M=h?h.completion:{};return M.type=T,M.arg=u,h?(this.method="next",this.next=h.finallyLoc,k):this.complete(M)},complete:function(T,u){if(T.type==="throw")throw T.arg;return T.type==="break"||T.type==="continue"?this.next=T.arg:T.type==="return"?(this.rval=this.arg=T.arg,this.method="return",this.next="end"):T.type==="normal"&&u&&(this.next=u),k},finish:function(T){for(var u=this.tryEntries.length-1;u>=0;--u){var _=this.tryEntries[u];if(_.finallyLoc===T)return this.complete(_.completion,_.afterLoc),l0(_),k}},catch:function(T){for(var u=this.tryEntries.length-1;u>=0;--u){var _=this.tryEntries[u];if(_.tryLoc===T){var n=_.completion;if(n.type==="throw"){var h=n.arg;l0(_)}return h}}throw new Error("illegal catch attempt")},delegateYield:function(T,u,_){return this.delegate={iterator:y0(T),resultName:u,nextLoc:_},this.method==="next"&&(this.arg=void 0),k}},j}function s1(j){return s1=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(F){return typeof F}:function(F){return F&&typeof Symbol=="function"&&F.constructor===Symbol&&F!==Symbol.prototype?"symbol":typeof F},s1(j)}function Q8(j,F,K,U,N,O,B){try{var w=j[O](B),R=w.value}catch(P){K(P);return}if(w.done)F(R);else Promise.resolve(R).then(U,N)}function C1(j){return function(){var F=this,K=arguments;return new Promise(function(U,N){var O=j.apply(F,K);function B(R){Q8(O,U,N,B,w,"next",R)}function w(R){Q8(O,U,N,B,w,"throw",R)}B(void 0)})}}function f0(j,F){if(!(j instanceof F))throw new TypeError("Cannot call a class as a function")}function Z8(j,F){for(var K=0;K<F.length;K++){var U=F[K];if(U.enumerable=U.enumerable||!1,U.configurable=!0,"value"in U)U.writable=!0;Object.defineProperty(j,q8(U.key),U)}}function c0(j,F,K){if(F)Z8(j.prototype,F);if(K)Z8(j,K);return Object.defineProperty(j,"prototype",{writable:!1}),j}function i(j,F,K){if(F=q8(F),F in j)Object.defineProperty(j,F,{value:K,enumerable:!0,configurable:!0,writable:!0});else j[F]=K;return j}function u1(j,F){if(typeof F!=="function"&&F!==null)throw new TypeError("Super expression must either be null or a function");if(j.prototype=Object.create(F&&F.prototype,{constructor:{value:j,writable:!0,configurable:!0}}),Object.defineProperty(j,"prototype",{writable:!1}),F)dY(j,F)}function KY(j){return KY=Object.setPrototypeOf?Object.getPrototypeOf.bind():function F(K){return K.__proto__||Object.getPrototypeOf(K)},KY(j)}function dY(j,F){return dY=Object.setPrototypeOf?Object.setPrototypeOf.bind():function K(U,N){return U.__proto__=N,U},dY(j,F)}function G8(){if(typeof Reflect==="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy==="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(j){return!1}}function MJ(j,F,K){if(G8())MJ=Reflect.construct.bind();else MJ=function U(N,O,B){var w=[null];w.push.apply(w,O);var R=Function.bind.apply(N,w),P=new R;if(B)dY(P,B.prototype);return P};return MJ.apply(null,arguments)}function PG(j){return Function.toString.call(j).indexOf("[native code]")!==-1}function zY(j){var F=typeof Map==="function"?new Map:void 0;return zY=function K(U){if(U===null||!PG(U))return U;if(typeof U!=="function")throw new TypeError("Super expression must either be null or a function");if(typeof F!=="undefined"){if(F.has(U))return F.get(U);F.set(U,N)}function N(){return MJ(U,arguments,KY(this).constructor)}return N.prototype=Object.create(U.prototype,{constructor:{value:N,enumerable:!1,writable:!0,configurable:!0}}),dY(N,U)},zY(j)}function yG(j,F){if(j==null)return{};var K={},U=Object.keys(j),N,O;for(O=0;O<U.length;O++){if(N=U[O],F.indexOf(N)>=0)continue;K[N]=j[N]}return K}function W8(j,F){if(j==null)return{};var K=yG(j,F),U,N;if(Object.getOwnPropertySymbols){var O=Object.getOwnPropertySymbols(j);for(N=0;N<O.length;N++){if(U=O[N],F.indexOf(U)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(j,U))continue;K[U]=j[U]}}return K}function A0(j){if(j===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return j}function TG(j,F){if(F&&(typeof F==="object"||typeof F==="function"))return F;else if(F!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return A0(j)}function m1(j){var F=G8();return function K(){var U=KY(j),N;if(F){var O=KY(this).constructor;N=Reflect.construct(U,arguments,O)}else N=U.apply(this,arguments);return TG(this,N)}}function xG(j,F){while(!Object.prototype.hasOwnProperty.call(j,F))if(j=KY(j),j===null)break;return j}function lY(){if(typeof Reflect!=="undefined"&&Reflect.get)lY=Reflect.get.bind();else lY=function j(F,K,U){var N=xG(F,K);if(!N)return;var O=Object.getOwnPropertyDescriptor(N,K);if(O.get)return O.get.call(arguments.length<3?F:U);return O.value};return lY.apply(this,arguments)}function vG(j,F){if(!j)return;if(typeof j==="string")return X8(j,F);var K=Object.prototype.toString.call(j).slice(8,-1);if(K==="Object"&&j.constructor)K=j.constructor.name;if(K==="Map"||K==="Set")return Array.from(j);if(K==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(K))return X8(j,F)}function X8(j,F){if(F==null||F>j.length)F=j.length;for(var K=0,U=new Array(F);K<F;K++)U[K]=j[K];return U}function K8(j,F){var K=typeof Symbol!=="undefined"&&j[Symbol.iterator]||j["@@iterator"];if(!K){if(Array.isArray(j)||(K=vG(j))||F&&j&&typeof j.length==="number"){if(K)j=K;var U=0,N=function(){};return{s:N,n:function(){if(U>=j.length)return{done:!0};return{done:!1,value:j[U++]}},e:function(R){throw R},f:N}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
28
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var O=!0,B=!1,w;return{s:function(){K=K.call(j)},n:function(){var R=K.next();return O=R.done,R},e:function(R){B=!0,w=R},f:function(){try{if(!O&&K.return!=null)K.return()}finally{if(B)throw w}}}}function hG(j,F){if(typeof j!=="object"||j===null)return j;var K=j[Symbol.toPrimitive];if(K!==void 0){var U=K.call(j,F||"default");if(typeof U!=="object")return U;throw new TypeError("@@toPrimitive must return a primitive value.")}return(F==="string"?String:Number)(j)}function q8(j){var F=hG(j,"string");return typeof F==="symbol"?F:String(F)}var J1=function(){function j(){f0(this,j)}return c0(j,null,[{key:"start",value:function F(K){if(!K||!K.length)return 0;if(K.length===1&&K.end(0)-K.start(0)<0.000001)return 0;if(K.length===1&&K.start(0)<0)return 0;return K.start(0)}},{key:"end",value:function F(K){if(!K||!K.length)return 0;if(K.length===1&&K.end(0)-K.start(0)<0.000001)return 0;return K.end(K.length-1)}},{key:"get",value:function F(K){if(!K)return;try{return K.buffered}catch(U){}}},{key:"buffers",value:function F(K,U){if(!K||!K.length)return[];var N=[];for(var O=0,B=K.length;O<B;O++){var w=N.length;if(!w||!U)N.push([K.start(O),K.end(O)]);else{var R=N[w-1],P=R[1],x=K.start(O);if(x-P<=U){var k=K.end(O);if(k>P)R[1]=k}else N.push([K.start(O),K.end(O)])}}return N}},{key:"totalLength",value:function F(K){if(!K||!K.length)return 0;return K.reduce(function(U,N){return U+=N[1]-N[0]},0)}},{key:"info",value:function F(K){var U=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,N=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;if(!K||!K.length)return{start:0,end:0,buffers:[]};var O=0,B=0,w=0,R=0,P=0,x=0,k=0,f=j.buffers(K,N);for(var l=0,s=f.length;l<s;l++){var Y0=f[l];if(U+N>=Y0[0]&&U<=Y0[1])O=Y0[0],B=Y0[1],w=l;else if(U+N<Y0[0]){R=Y0[0],P=Y0[1];break}else if(U+N>Y0[1])x=Y0[0],k=Y0[1]}return{start:O,end:B,index:w,buffers:f,nextStart:R,nextEnd:P,prevStart:x,prevEnd:k,currentTime:U,behind:U-O,remaining:B?B-U:0,length:j.totalLength&&j.totalLength(f)}}},{key:"isBuffered",value:function F(K,U){if(K){var N=j.get(K);if(N!==null&&N!==void 0&&N.length){for(var O=0;O<N.length;O++)if(U>=N.start(O)&&U<=N.end(O))return!0}}return!1}}]),j}();var H8=typeof window!=="undefined";var L1,P0={MANIFEST:"manifest",NETWORK:"network",NETWORK_TIMEOUT:"network_timeout",NETWORK_FORBIDDEN:"network_forbidden",NETWORK_NOTFOUND:"network_notfound",NETWROK_RANGE_NOT_SATISFIABLE:"network_range_not_satisfiable",DEMUX:"demux",REMUX:"remux",MEDIA:"media",DRM:"drm",OTHER:"other",RUNTIME:"runtime",SUB_TYPES:{FLV:"FLV",HLS:"HLS",MP4:"MP4",FMP4:"FMP4",MSE_ADD_SB:"MSE_ADD_SB",MSE_APPEND_BUFFER:"MSE_APPEND_BUFFER",MSE_OTHER:"MSE_OTHER",MSE_FULL:"MSE_FULL",MSE_CHANGE_TYPE:"MSE_CHANGE_TYPE",OPTION:"OPTION",DASH:"DASH",LICENSE:"LICENSE",CUSTOM_LICENSE:"CUSTOM_LICENSE",MSE_HIJACK:"MSE_HIJACK",EME_HIJACK:"EME_HIJACK",SIDX:"SIDX",NO_CANPLAY_ERROR:"NO_CANPLAY_ERROR",BUFFERBREAK_ERROR:"BUFFERBREAK_ERROR",WAITING_TIMEOUT_ERROR:"WAITING_TIMEOUT_ERROR",MEDIA_ERR_ABORTED:"MEDIA_ERR_ABORTED",MEDIA_ERR_NETWORK:"MEDIA_ERR_NETWORK",MEDIA_ERR_DECODE:"MEDIA_ERR_DECODE",MEDIA_ERR_SRC_NOT_SUPPORTED:"MEDIA_ERR_SRC_NOT_SUPPORTED",MEDIA_ERR_CODEC_NOT_SUPPORTED:"MEDIA_ERR_CODEC_NOT_SUPPORTED",MEDIA_ERR_URL_EMPTY:"MEDIA_ERR_URL_EMPTY"}},CJ=(L1={},i(L1,P0.MANIFEST,{HLS:1100,DASH:1200}),i(L1,P0.NETWORK,2100),i(L1,P0.NETWORK_TIMEOUT,2101),i(L1,P0.NETWORK_FORBIDDEN,2103),i(L1,P0.NETWORK_NOTFOUND,2104),i(L1,P0.NETWROK_RANGE_NOT_SATISFIABLE,2116),i(L1,P0.DEMUX,{FLV:3100,HLS:3200,MP4:3300,FMP4:3400,SIDX:3410}),i(L1,P0.REMUX,{FMP4:4100,MP4:4200}),i(L1,P0.MEDIA,{MEDIA_ERR_ABORTED:5101,MEDIA_ERR_NETWORK:5102,MEDIA_ERR_DECODE:5103,MEDIA_ERR_SRC_NOT_SUPPORTED:5104,MEDIA_ERR_CODEC_NOT_SUPPORTED:5105,MEDIA_ERR_URL_EMPTY:5106,MSE_ADD_SB:5200,MSE_APPEND_BUFFER:5201,MSE_OTHER:5202,MSE_FULL:5203,MSE_HIJACK:5204,MSE_CHANGE_TYPE:5205,EME_HIJACK:5301}),i(L1,P0.DRM,{LICENSE:7100,CUSTOM_LICENSE:7200}),i(L1,P0.OTHER,8000),i(L1,P0.RUNTIME,{NO_CANPLAY_ERROR:9001,BUFFERBREAK_ERROR:9002,WAITING_TIMEOUT_ERROR:9003}),L1),A1=function(j){u1(K,j);var F=m1(K);function K(U,N,O,B,w){var R;if(f0(this,K),R=F.call(this,w||(O===null||O===void 0?void 0:O.message)),R.errorType=U===P0.NETWORK_TIMEOUT?P0.NETWORK:U,R.originError=O,R.ext=B,R.errorCode=CJ[U][N]||CJ[U],R.errorMessage=R.message,!R.errorCode)R.errorType=P0.OTHER,R.errorCode=CJ[R.errorType];return R}return c0(K,null,[{key:"create",value:function U(N,O,B,w,R){if(N instanceof K)return N;else if(N instanceof Error)B=N,N="";if(!N)N=P0.OTHER;return new K(N,O,B,w,R)}},{key:"network",value:function U(N){var O;return new K(N!==null&&N!==void 0&&N.isTimeout?P0.NETWORK_TIMEOUT:P0.NETWORK,null,N instanceof Error?N:null,{url:N===null||N===void 0?void 0:N.url,response:N===null||N===void 0?void 0:N.response,httpCode:N===null||N===void 0?void 0:(O=N.response)===null||O===void 0?void 0:O.status})}}]),K}(zY(Error));var oY={DEBUG:1,LOG:2,WARN:3,ERROR:4},kG=204800,gG=["Boolean","Number","String","Undefined","Null","Date","Object"],D1=function(){function j(F,K){f0(this,j),this.name=F||"",this._prefix="[".concat(this.name,"]"),this.logCacheLevel=(K===null||K===void 0?void 0:K.logCacheLevel)||3,this.logMaxSize=(K===null||K===void 0?void 0:K.logMaxSize)||kG,this.logSize=0,this.logTextArray=[]}return c0(j,[{key:"debug",value:function F(){var K;for(var U=arguments.length,N=new Array(U),O=0;O<U;O++)N[O]=arguments[O];if(this.logCache.apply(this,[oY.DEBUG].concat(N)),j.disabled)return;(K=console).debug.apply(K,["[".concat(nY(),"]"),this._prefix].concat(N))}},{key:"log",value:function F(){var K;for(var U=arguments.length,N=new Array(U),O=0;O<U;O++)N[O]=arguments[O];if(this.logCache.apply(this,[oY.LOG].concat(N)),j.disabled)return;(K=console).log.apply(K,["[".concat(nY(),"]"),this._prefix].concat(N))}},{key:"warn",value:function F(){var K;for(var U=arguments.length,N=new Array(U),O=0;O<U;O++)N[O]=arguments[O];if(this.logCache.apply(this,[oY.WARN].concat(N)),j.disabled)return;(K=console).warn.apply(K,["[".concat(nY(),"]"),this._prefix].concat(N))}},{key:"error",value:function F(){var K;for(var U=arguments.length,N=new Array(U),O=0;O<U;O++)N[O]=arguments[O];if(this.logCache.apply(this,[oY.ERROR].concat(N)),j.disabled)return;(K=console).error.apply(K,["[".concat(nY(),"]"),this._prefix].concat(N))}},{key:"logCache",value:function F(K){if(K<this.logCacheLevel)return;var U="";try{for(var N=arguments.length,O=new Array(N>1?N-1:0),B=1;B<N;B++)O[B-1]=arguments[B];var w=O.map(function(P){return N8(P)});U="[".concat(nY(),"]")+this._prefix+JSON.stringify(w)}catch(P){return}if(K>=this.logCacheLevel)this.logSize+=U.length,this.logTextArray.push(U);if(this.logSize>this.logMaxSize){var R=this.logTextArray.shift();this.logSize-=R.length}}},{key:"getLogCache",value:function F(){var K=this.logTextArray.join(`
29
- `);return this.reset(),K}},{key:"reset",value:function F(){this.logTextArray=[],this.logSize=0}},{key:"table",value:function F(){var K;if(j.disabled)return;console.group(this._prefix),(K=console).table.apply(K,arguments),console.groupEnd()}},{key:"setLogLevel",value:function F(K){this.logCacheLevel=K}}],[{key:"enable",value:function F(){j.disabled=!1}},{key:"disable",value:function F(){j.disabled=!0}}]),j}();i(D1,"disabled",!0);function nY(){return new Date().toLocaleString()}function uG(j){if(s1(j)!=="object")return j;var F=Object.prototype.toString.call(j).slice(8,-1);switch(F){case"Array":case"Uint8Array":case"ArrayBuffer":return F+"["+j.length+"]";case"Object":return"{}";default:return F}}function N8(j,F,K){if(!K)K=1;if(!F)F=2;var U={};if(!j||s1(j)!=="object")return j;var N=Object.prototype.toString.call(j).slice(8,-1);if(!gG.includes(N))return N;if(K>F)return;for(var O in j)if(Object.prototype.hasOwnProperty.call(j,O))if(K===F)U[O]=uG(j[O]);else if(s1(j[O])==="object")U[O]=N8(j[O],F,K+1);else U[O]=j[O];return U}function HY(){var j,F,K=new Promise(function(U,N){j=U,F=N});return K.used=!1,K.resolve=function(){return K.used=!0,j.apply(void 0,arguments)},K.reject=function(){return K.used=!0,F.apply(void 0,arguments)},K}function jY(){try{return parseInt(performance.now(),10)}catch(j){return new Date().getTime()}}var U8={stringify:function j(F){try{return JSON.stringify(F)}catch(K){return""}},parse:function j(F){try{return JSON.parse(F)}catch(K){return}}};function V8(){var j=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;try{if(!H8)return null;if(j&&typeof ManagedMediaSource!=="undefined")return ManagedMediaSource;return window.MediaSource}catch(F){}}function $Q(j){return/ManagedMediaSource/gi.test(Object.prototype.toString.call(j))}function mG(j){var F=[];if(j instanceof TimeRanges)for(var K=0;K<j.length;K++)F.push({start:j.start(K),end:j.end(K)});return F}var DJ={APPEND:"appendBuffer",REMOVE:"removeBuffer",UPDATE_DURATION:"updateDuration"};var NY=function(){function j(F,K){var U=this;if(f0(this,j),i(this,"media",null),i(this,"mediaSource",null),i(this,"_openPromise",HY()),i(this,"_queue",Object.create(null)),i(this,"_sourceBuffer",Object.create(null)),i(this,"_mseFullFlag",{}),i(this,"_st",0),i(this,"_opst",0),i(this,"_logger",null),i(this,"_config",null),i(this,"_url",null),i(this,"_onStartStreaming",function(){U._logger.debug("startstreaming")}),i(this,"_onEndStreaming",function(){U._logger.debug("endstreaming")}),i(this,"_onSBUpdateEnd",function(N){var O=U._queue[N];if(O){var B=O[0];if((B===null||B===void 0?void 0:B.opName)!==DJ.UPDATE_DURATION)O.shift();if(B){var w,R,P=jY()-U._opst;U._logger.debug("UpdateEnd(".concat(N,"/").concat(B.opName,")"),U8.stringify(mG((w=U._sourceBuffer[N])===null||w===void 0?void 0:w.buffered)),P,B.context),B.promise.resolve({name:B.opName,context:B.context,costtime:P});var x=(R=B.context)===null||R===void 0?void 0:R.callback;if(x&&typeof x==="function")x(B.context);U._startQueue(N)}}}),i(this,"_onSBUpdateError",function(N,O){var B=U._queue[N];if(B){var w=B[0];if(w)U._logger.error("UpdateError",N,w.opName,w.context),w.promise.reject(new A1(P0.MEDIA,P0.SUB_TYPES.MSE_APPEND_BUFFER,O))}}),this._config=Object.assign(j.getDefaultConfig(),K),F)this.bindMedia(F);if(this._logger=new D1("MSE"),this._config.openLog)D1.enable()}return c0(j,[{key:"isOpened",get:function F(){var K;return((K=this.mediaSource)===null||K===void 0?void 0:K.readyState)==="open"}},{key:"hasOpTasks",get:function F(){var K=this,U=!1;return Object.keys(this._queue).forEach(function(N){var O=K._queue[N];if(Array.isArray(O))U||(U=O.length>0)}),U}},{key:"url",get:function F(){return this._url}},{key:"duration",get:function F(){var K;return((K=this.mediaSource)===null||K===void 0?void 0:K.duration)||-1}},{key:"isEnded",get:function F(){return this.mediaSource?this.mediaSource.readyState==="ended":!1}},{key:"streaming",get:function F(){return $Q(this.mediaSource)?this.mediaSource.streaming:!0}},{key:"isFull",value:function F(K){return K?this._mseFullFlag[K]:this._mseFullFlag[j.VIDEO]}},{key:"updateDuration",value:function F(K){var U=this,N=this.mediaSource&&this.mediaSource.duration>K;if(this.mediaSource&&this.mediaSource.duration>K){var O=0;if(Object.keys(this._sourceBuffer).forEach(function(B){try{O=Math.max(U.bufferEnd(B)||0,O)}catch(w){}}),K<O)return Promise.resolve()}return this._enqueueBlockingOp(function(){if(U.isEnded){U._logger.debug("setDuration but ended");return}if(U.mediaSource)U.mediaSource.duration=K,U._logger.debug("setDuration",K)},DJ.UPDATE_DURATION,{isReduceDuration:N})}},{key:"open",value:function F(){var K=this;if(this._openPromise.used&&!this.isOpened&&this.mediaSource){var U=this.mediaSource,N=function O(){var B=jY()-K._st;K._logger.debug("sourceopen",B),U.removeEventListener("sourceopen",O),K._openPromise.resolve({costtime:B})};U.addEventListener("sourceopen",N),this._openPromise=HY()}return this._openPromise}},{key:"bindMedia",value:function(){var F=C1(r0().mark(function U(N){var O=this,B,w,R,P;return r0().wrap(function x(k){while(!0)switch(k.prev=k.next){case 0:if(!(this.mediaSource||this.media)){k.next=3;break}return k.next=3,this.unbindMedia();case 3:if(B=V8(this._config.preferMMS),!(!N||!B)){k.next=6;break}throw new Error("Param media or MediaSource does not exist");case 6:if(this.media=N,w=this.mediaSource=new B,R=$Q(w),this._st=jY(),P=function f(){var l=jY()-O._st;O._logger.debug("sourceopen"),w.removeEventListener("sourceopen",f),URL.revokeObjectURL(N.src),O._openPromise.resolve({costtime:l})},w.addEventListener("sourceopen",P),R)w.addEventListener("startstreaming",this._onStartStreaming),w.addEventListener("endstreaming",this._onEndStreaming);return this._url=URL.createObjectURL(w),N.src=this._url,N.disableRemotePlayback=R,k.abrupt("return",this._openPromise);case 17:case"end":return k.stop()}},U,this)}));function K(U){return F.apply(this,arguments)}return K}()},{key:"unbindMedia",value:function(){var F=C1(r0().mark(function U(){var N=this,O,B,w;return r0().wrap(function R(P){while(!0)switch(P.prev=P.next){case 0:if(!this._openPromise.used)this._openPromise.resolve();if(O=this.mediaSource,O){if(Object.keys(this._queue).forEach(function(x){var k=N._queue[x];if(k)k.forEach(function(f){var l,s;return(l=f.promise)===null||l===void 0?void 0:(s=l.resolve)===null||s===void 0?void 0:s.call(l)})}),B=!!this.media&&this.media.readyState>=1,w=O.readyState==="open",B&&w)try{O.endOfStream()}catch(x){}if(Object.keys(this._sourceBuffer).forEach(function(x){try{O.removeSourceBuffer(N._sourceBuffer[x])}catch(k){}}),$Q(O))O.removeEventListener("startstreaming",this._onStartStreaming),O.removeEventListener("endstreaming",this._onEndStreaming)}if(this.media){this.media.disableRemotePlayback=!1,this.media.removeAttribute("src");try{this.media.load()}catch(x){}this.media=null}this.mediaSource=null,this._openPromise=HY(),this._queue=Object.create(null),this._sourceBuffer=Object.create(null);case 8:case"end":return P.stop()}},U,this)}));function K(){return F.apply(this,arguments)}return K}()},{key:"createSource",value:function F(K,U){if(this._sourceBuffer[K]||!this.mediaSource)return;var N;try{N=this._sourceBuffer[K]=this.mediaSource.addSourceBuffer(U)}catch(O){throw new A1(P0.MEDIA,P0.SUB_TYPES.MSE_ADD_SB,O)}N.mimeType=U,N.addEventListener("updateend",this._onSBUpdateEnd.bind(this,K)),N.addEventListener("error",this._onSBUpdateError.bind(this,K))}},{key:"changeType",value:function F(K,U){var N=this,O=this._sourceBuffer[K];if(!this.mediaSource||!O||O.mimeType===U)return Promise.resolve();if(typeof O.changeType!=="function")return Promise.reject(new A1(P0.MEDIA,P0.SUB_TYPES.MSE_CHANGE_TYPE,new Error("changeType is not a function")));return this._enqueueOp(K,function(){try{O.changeType(U)}catch(B){throw new A1(P0.MEDIA,P0.SUB_TYPES.MSE_CHANGE_TYPE,B)}O.mimeType=U,N._onSBUpdateEnd(K)},"changeType",{mimeType:U})}},{key:"createOrChangeSource",value:function F(K,U){return this.createSource(K,U),this.changeType(K,U)}},{key:"append",value:function F(K,U,N){var O=this;if(!U||!U.byteLength)return Promise.resolve();if(!this._sourceBuffer[K])return Promise.resolve();return this._enqueueOp(K,function(){var B;if(!O.mediaSource||O.media.error)return;O._logger.debug("MSE APPEND START",N),O._opst=jY(),(B=O._sourceBuffer[K])===null||B===void 0||B.appendBuffer(U)},DJ.APPEND,N)}},{key:"remove",value:function F(K,U,N,O){var B=this,w=!1;if(this._mseFullFlag[K])w=!0;return this._enqueueOp(K,function(){if(!B.mediaSource||B.media.error)return;var R=B._sourceBuffer[K];if(U>=N||!R){B._onSBUpdateEnd(K);return}B._opst=jY(),B._logger.debug("MSE REMOVE START",K,U,N,O),R.remove(U,N)},DJ.REMOVE,O,w)}},{key:"clearBuffer",value:function F(K,U){var N=this,O;return Object.keys(this._sourceBuffer).forEach(function(B){O=N.remove(B,K,U)}),O||Promise.resolve()}},{key:"clearAllBuffer",value:function F(){var K=this,U;return Object.keys(this._sourceBuffer).forEach(function(N){var O=K._sourceBuffer[N];U=K.remove(N,0,J1.end(J1.get(O)))}),U}},{key:"clearOpQueues",value:function F(K,U){var N;this._logger.debug("MSE clearOpQueue START");var O=this._queue[K];if(U&&O){this._queue[K]=[];return}if(!O||!O[K]||O.length<5)return;var B=[];O.forEach(function(w){if(w.context&&w.context.isinit)B.push(w)}),this._queue[K]=O.slice(0,2),B.length>0&&(N=this._queue[K]).push.apply(N,B)}},{key:"endOfStream",value:function F(K){var U=this;if(!this.mediaSource||this.mediaSource.readyState!=="open")return Promise.resolve();return this._enqueueBlockingOp(function(){var N=U.mediaSource;if(!N||N.readyState!=="open")return;if(U._logger.debug("MSE endOfStream START"),K)N.endOfStream(K);else N.endOfStream()},"endOfStream")}},{key:"setLiveSeekableRange",value:function F(K,U){var N=this.mediaSource;if(K<0||U<K||!(N!==null&&N!==void 0&&N.setLiveSeekableRange)||N.readyState!=="open")return;N.setLiveSeekableRange(K,U)}},{key:"getSourceBuffer",value:function F(K){return this._sourceBuffer[K]}},{key:"buffered",value:function F(K){return J1.get(this._sourceBuffer[K])}},{key:"bufferStart",value:function F(K){return J1.start(this.buffered(K))}},{key:"bufferEnd",value:function F(K){return J1.end(this.buffered(K))}},{key:"_enqueueOp",value:function F(K,U,N,O,B){var w=this;if(!this.mediaSource)return Promise.resolve();var R=this._queue[K]=this._queue[K]||[],P={exec:U,promise:HY(),opName:N,context:O};if(B)R.splice(0,0,P),this._mseFullFlag[K]=!1,this._startQueue(K);else R.push(P);if(this.isOpened||this.isEnded){if(R.length===1)this._startQueue(K)}else this._openPromise.then(function(){if(R.length===1)w._startQueue(K)});return P.promise}},{key:"_enqueueBlockingOp",value:function(){var F=C1(r0().mark(function U(N,O,B){var w=this,R,P;return r0().wrap(function x(k){while(!0)switch(k.prev=k.next){case 0:if(this.mediaSource){k.next=2;break}return k.abrupt("return",Promise.resolve());case 2:if(R=Object.keys(this._sourceBuffer),R.length){k.next=5;break}return k.abrupt("return",N());case 5:return P=[],R.forEach(function(f){var l=w._queue[f],s=HY();if(P.push(s),l.push({exec:function Y0(){s.resolve()},promise:s,opName:O,context:B}),l.length===1)w._startQueue(f)}),k.abrupt("return",Promise.all(P).then(function(){try{return N()}finally{R.forEach(function(f){var l=w._queue[f],s=w._sourceBuffer[f];if(l===null||l===void 0||l.shift(),!s||!s.updating)w._startQueue(f)})}}));case 8:case"end":return k.stop()}},U,this)}));function K(U,N,O){return F.apply(this,arguments)}return K}()},{key:"_startQueue",value:function F(K){var U=this._queue[K];if(U){var N=U[0];if(N&&!this._mseFullFlag[K])try{N.exec()}catch(w){if(w&&w.message&&w.message.indexOf("SourceBuffer is full")>=0){var O;if(this._mseFullFlag[K]=!0,N.context&&s1(N.context)==="object")N.context.isFull=!0;this._logger.error("[MSE error], context,",N.context," ,name,",N.opName,",err,SourceBuffer is full"),N===null||N===void 0||(O=N.promise)===null||O===void 0||O.reject(new A1(P0.MEDIA,P0.SUB_TYPES.MSE_FULL,w))}else{var B;this._logger.error(w),N===null||N===void 0||(B=N.promise)===null||B===void 0||B.reject(w.constructor===A1?w:new A1(P0.MEDIA,P0.SUB_TYPES.MSE_OTHER,w)),U.shift(),this._startQueue(K)}}}}},{key:"setTimeoffset",value:function F(K,U,N){var O=this;return this._enqueueOp(K,function(){if(U<0)U+=0.001;O._sourceBuffer[K].timestampOffset=U,O._onSBUpdateEnd(K)},"setTimeoffset",N)}},{key:"abort",value:function F(K,U){var N=this;if(!this.isOpened)return Promise.resolve();return this._enqueueOp(K,function(){N._sourceBuffer[K].abort(),N._onSBUpdateEnd(K)},"abort",U)}}],[{key:"isSupported",value:function F(){var K=arguments.length>0&&arguments[0]!==void 0?arguments[0]:'video/mp4; codecs="avc1.42E01E,mp4a.40.2"',U=V8();if(!U)return!1;try{return U.isTypeSupported(K)}catch(N){return this._logger.error(K,N),!1}}},{key:"isMMSOnly",value:function F(){return typeof ManagedMediaSource!=="undefined"&&typeof MediaSource==="undefined"}},{key:"getDefaultConfig",value:function F(){return{openLog:!1,preferMMS:!1}}}]),j}();i(NY,"VIDEO","video");i(NY,"AUDIO","audio");var _1={FETCH:"fetch",XHR:"xhr"},UY={ARRAY_BUFFER:"arraybuffer",TEXT:"text",JSON:"json"};var T1=function(j){u1(K,j);var F=m1(K);function K(U,N,O,B){var w;return f0(this,K),w=F.call(this,B),i(A0(w),"retryCount",0),i(A0(w),"isTimeout",!1),i(A0(w),"loaderType",_1.FETCH),i(A0(w),"startTime",0),i(A0(w),"endTime",0),i(A0(w),"options",{}),w.url=U,w.request=N,w.response=O,w}return c0(K)}(zY(Error));var z8=Object.prototype.toString;function j8(j){return j!==null&&s1(j)==="object"}function IQ(j){if(z8.call(j)!=="[object Object]")return!1;var F=Object.getPrototypeOf(j);return F===null||F===Object.prototype}function A8(j){return z8.call(j)==="[object Date]"}function SJ(j){if(!j||j[0]===null||j[0]===void 0||j[0]===0&&(j[1]===null||j[1]===void 0))return;var F="bytes="+j[0]+"-";if(j[1])F+=j[1];return F}function O8(j){return encodeURIComponent(j).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function PJ(j,F){if(!j)return;if(!F)return j;var K,U=Object.keys(F).map(function(O){if(K=F[O],K===null||K===void 0)return;if(Array.isArray(K))O=O+"[]";else K=[K];return K.map(function(B){if(A8(B))B=B.toISOString();else if(j8(B))B=JSON.stringify(B);return"".concat(O8(O),"=").concat(O8(B))}).join("&")}).filter(Boolean).join("&");if(U){var N=j.indexOf("#");if(N!==-1)j=j.slice(0,N);j+=(j.indexOf("?")===-1?"?":"&")+U}return j}function iY(j,F,K,U,N,O,B,w,R,P,x){if(N=N!==null&&N!==void 0?parseFloat(N):null,U=parseInt(U||"0",10),Number.isNaN(U))U=0;var k={range:R,vid:P,index:w,contentLength:U,age:N,startTime:O,firstByteTime:B,endTime:Date.now(),priOptions:x};return{data:j,done:F,options:k,response:K}}function sY(j,F){return Math.round(j*8*1000/F/1024)}var w0={ERROR:"error",TTFB:"core.ttfb",LOAD_START:"core.loadstart",LOAD_RESPONSE_HEADERS:"core.loadresponseheaders",LOAD_COMPLETE:"core.loadcomplete",LOAD_RETRY:"core.loadretry",SOURCEBUFFER_CREATED:"core.sourcebuffercreated",MEDIASOURCE_OPENED:"core.mediasourceopened",ANALYZE_DURATION_EXCEEDED:"core.analyzedurationexceeded",APPEND_BUFFER:"core.appendbuffer",REMOVE_BUFFER:"core.removebuffer",BUFFEREOS:"core.buffereos",KEYFRAME:"core.keyframe",CHASEFRAME:"core.chaseframe",METADATA_PARSED:"core.metadataparsed",SEI:"core.sei",SEI_IN_TIME:"core.seiintime",FLV_SCRIPT_DATA:"core.flvscriptdata",LOWDECODE:"core.lowdecode",SWITCH_URL_SUCCESS:"core.switchurlsuccess",SWITCH_URL_FAILED:"core.switchurlfailed",SPEED:"core.speed",HLS_MANIFEST_LOADED:"core.hlsmanifestloaded",HLS_LEVEL_LOADED:"core.hlslevelloaded",DEMUXED_TRACK:"core.demuxedtrack",STREAM_EXCEPTION:"core.streamexception",LARGE_AV_FIRST_FRAME_GAP_DETECT:"LARGE_AV_FIRST_FRAME_GAP_DETECT",LARGE_VIDEO_DTS_GAP_DETECT:"LARGE_VIDEO_DTS_GAP_DETECT",LARGE_AUDIO_DTS_GAP_DETECT:"LARGE_AUDIO_DTS_GAP_DETECT",AUDIO_GAP_DETECT:"AUDIO_GAP_DETECT",AUDIO_OVERLAP_DETECT:"AUDIO_OVERLAP_DETECT",MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT:"MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT",REAL_TIME_SPEED:"real_time_speed"};var E8=LY(CY()),F8=2097152,rY=function(j){u1(K,j);var F=m1(K);function K(){var U;return f0(this,K),U=F.call(this),i(A0(U),"_abortController",null),i(A0(U),"_timeoutTimer",null),i(A0(U),"_reader",null),i(A0(U),"_response",null),i(A0(U),"_aborted",!1),i(A0(U),"_index",-1),i(A0(U),"_range",null),i(A0(U),"_receivedLength",0),i(A0(U),"_running",!1),i(A0(U),"_logger",null),i(A0(U),"_vid",""),i(A0(U),"_onProcessMinLen",0),i(A0(U),"_onCancel",null),i(A0(U),"_priOptions",null),U}return c0(K,[{key:"load",value:function U(N){var O,B=this,w=N.url,R=N.vid,P=N.timeout,x=N.responseType,k=N.onProgress,f=N.index,l=N.onTimeout,s=N.onCancel,Y0=N.range,t=N.transformResponse,K0=N.request,q0=N.params,R0=N.logger,U0=N.method,W0=N.headers,z0=N.body,h0=N.mode,l0=N.credentials,E0=N.cache,y0=N.redirect,t0=N.referrer,T=N.referrerPolicy,u=N.onProcessMinLen,_=N.priOptions;this._logger=R0,this._aborted=!1,this._onProcessMinLen=u,this._onCancel=s,this._abortController=typeof AbortController!=="undefined"&&new AbortController,this._running=!0,this._index=f,this._range=Y0||[0,0],this._vid=R||w,this._priOptions=_||{};var n={method:U0,headers:W0,body:z0,mode:h0,credentials:l0,cache:E0,redirect:y0,referrer:t0,referrerPolicy:T,signal:(O=this._abortController)===null||O===void 0?void 0:O.signal},h=!1;clearTimeout(this._timeoutTimer),w=PJ(w,q0);var M=SJ(Y0);if(M){if(K0)W0=K0.headers;else W0=n.headers=n.headers||(Headers?new Headers:{});if(Headers&&W0 instanceof Headers)W0.append("Range",M);else W0.Range=M}if(P)this._timeoutTimer=setTimeout(function(){if(h=!0,B.cancel(),l){var G0=new T1(w,n,null,"timeout");G0.isTimeout=!0,l(G0,{index:B._index,range:B._range,vid:B._vid,priOptions:B._priOptions})}},P);var Z0=Date.now();return this._logger.debug("[fetch load start], index,",f,",range,",Y0),new Promise(function(G0,C0){fetch(K0||w,K0?void 0:n).then(function(){var u0=C1(r0().mark(function d0(M0){var yY,P1,TY,xY;return r0().wrap(function eY(e0){while(!0)switch(e0.prev=e0.next){case 0:if(clearTimeout(B._timeoutTimer),B._response=M0,!(B._aborted||!B._running)){e0.next=4;break}return e0.abrupt("return");case 4:if(t)M0=t(M0,w)||M0;if(M0.ok){e0.next=7;break}throw new T1(w,n,M0,"bad network response");case 7:if(yY=Date.now(),x!==UY.TEXT){e0.next=15;break}return e0.next=11,M0.text();case 11:P1=e0.sent,B._running=!1,e0.next=37;break;case 15:if(x!==UY.JSON){e0.next=22;break}return e0.next=18,M0.json();case 18:P1=e0.sent,B._running=!1,e0.next=37;break;case 22:if(!k){e0.next=29;break}return B.resolve=G0,B.reject=C0,B._loadChunk(M0,k,Z0,yY),e0.abrupt("return");case 29:return e0.next=31,M0.arrayBuffer();case 31:P1=e0.sent,P1=new Uint8Array(P1),B._running=!1,TY=Date.now()-Z0,xY=sY(P1.byteLength,TY),B.emit(w0.REAL_TIME_SPEED,{speed:xY,len:P1.byteLength,time:TY,vid:B._vid,index:B._index,range:B._range,priOptions:B._priOptions});case 37:B._logger.debug("[fetch load end], index,",f,",range,",Y0),G0(iY(P1,!0,M0,M0.headers.get("Content-Length"),M0.headers.get("age"),Z0,yY,f,Y0,B._vid,B._priOptions));case 39:case"end":return e0.stop()}},d0)}));return function(d0){return u0.apply(this,arguments)}}()).catch(function(u0){var d0;if(clearTimeout(B._timeoutTimer),B._running=!1,B._aborted&&!h)return;u0=u0 instanceof T1?u0:new T1(w,n,null,(d0=u0)===null||d0===void 0?void 0:d0.message),u0.startTime=Z0,u0.endTime=Date.now(),u0.isTimeout=h,u0.options={index:B._index,range:B._range,vid:B._vid,priOptions:B._priOptions},C0(u0)})})}},{key:"cancel",value:function(){var U=C1(r0().mark(function O(){return r0().wrap(function B(w){while(!0)switch(w.prev=w.next){case 0:if(!this._aborted){w.next=2;break}return w.abrupt("return");case 2:if(this._aborted=!0,this._running=!1,!this._response){w.next=14;break}if(w.prev=5,!this._reader){w.next=9;break}return w.next=9,this._reader.cancel();case 9:w.next=13;break;case 11:w.prev=11,w.t0=w.catch(5);case 13:this._response=this._reader=null;case 14:if(this._abortController){try{this._abortController.abort()}catch(R){}this._abortController=null}if(this._onCancel)this._onCancel({index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions});case 16:case"end":return w.stop()}},O,this,[[5,11]])}));function N(){return U.apply(this,arguments)}return N}()},{key:"_loadChunk",value:function U(N,O,B,w){var R=this;if(!N.body||!N.body.getReader){this._running=!1;var P=new T1(N.url,"",N,"onProgress of bad response.body.getReader");P.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this.reject(P);return}if(this._onProcessMinLen>0)this._cache=new Uint8Array(F8),this._writeIdx=0;var x=this._reader=N.body.getReader(),k,f,l,s=function(){var Y0=C1(r0().mark(function t(){var K0,q0,R0,U0,W0,z0,h0,l0;return r0().wrap(function E0(y0){while(!0)switch(y0.prev=y0.next){case 0:return f=Date.now(),y0.prev=1,y0.next=4,x.read();case 4:k=y0.sent,l=Date.now(),y0.next=13;break;case 8:if(y0.prev=8,y0.t0=y0.catch(1),l=Date.now(),!R._aborted)R._running=!1,y0.t0.options={index:R._index,range:R._range,vid:R._vid,priOptions:R._priOptions},R.reject(y0.t0);return y0.abrupt("return");case 13:if(q0=((K0=R._range)===null||K0===void 0?void 0:K0.length)>0?R._range[0]:0,R0=q0+R._receivedLength,!R._aborted){y0.next=19;break}return R._running=!1,O(void 0,!1,{range:[R0,R0],vid:R._vid,index:R._index,startTime:f,endTime:l,st:B,firstByteTime:w,priOptions:R._priOptions},N),y0.abrupt("return");case 19:if(U0=k.value?k.value.byteLength:0,R._receivedLength+=U0,R._logger.debug("【fetchLoader,onProgress call】,task,",R._range,", start,",R0,", end,",q0+R._receivedLength,", done,",k.done),R._onProcessMinLen>0){if(R._writeIdx+U0>=R._onProcessMinLen||k.done)W0=new Uint8Array(R._writeIdx+U0),W0.set(R._cache.slice(0,R._writeIdx),0),U0>0&&W0.set(k.value,R._writeIdx),R._writeIdx=0,R._logger.debug("【fetchLoader,onProgress enough】,done,",k.done,",len,",W0.byteLength,", writeIdx,",R._writeIdx);else if(U0>0&&R._writeIdx+U0<F8)R._cache.set(k.value,R._writeIdx),R._writeIdx+=U0,R._logger.debug("【fetchLoader,onProgress cache】,len,",U0,", writeIdx,",R._writeIdx);else if(U0>0)z0=new Uint8Array(R._writeIdx+U0+2048),R._logger.debug("【fetchLoader,onProgress extra start】,size,",R._writeIdx+U0+2048,", datalen,",U0,", writeIdx,",R._writeIdx),z0.set(R._cache.slice(0,R._writeIdx),0),U0>0&&z0.set(k.value,R._writeIdx),R._writeIdx+=U0,delete R._cache,R._cache=z0,R._logger.debug("【fetchLoader,onProgress extra end】,len,",U0,", writeIdx,",R._writeIdx)}else W0=k.value;if(W0&&W0.byteLength>0||k.done)O(W0,k.done,{range:[R._range[0]+R._receivedLength-(W0?W0.byteLength:0),R._range[0]+R._receivedLength],vid:R._vid,index:R._index,startTime:f,endTime:l,st:B,firstByteTime:w,priOptions:R._priOptions},N);if(!k.done)s();else h0=Date.now()-B,l0=sY(R._receivedLength,h0),R.emit(w0.REAL_TIME_SPEED,{speed:l0,len:R._receivedLength,time:h0,vid:R._vid,index:R._index,range:R._range,priOptions:R._priOptions}),R._running=!1,R._logger.debug("[fetchLoader onProgress end],task,",R._range,",done,",k.done),R.resolve(iY(k,!0,N,N.headers.get("Content-Length"),N.headers.get("age"),B,w,R._index,R._range,R._vid,R._priOptions));case 25:case"end":return y0.stop()}},t,null,[[1,8]])}));return function t(){return Y0.apply(this,arguments)}}();s()}},{key:"receiveLen",get:function U(){return this._receivedLength}},{key:"running",get:function U(){return this._running},set:function U(N){this._running=N}}],[{key:"isSupported",value:function U(){return typeof fetch!=="undefined"}}]),K}(E8.default);function B8(j){return qY({loaderType:_1.FETCH,retry:0,retryDelay:0,timeout:0,request:null,onTimeout:void 0,onProgress:void 0,onRetryError:void 0,transformRequest:void 0,transformResponse:void 0,transformError:void 0,responseType:UY.TEXT,range:void 0,url:"",params:void 0,method:"GET",headers:{},body:void 0,mode:void 0,credentials:void 0,cache:void 0,redirect:void 0,referrer:void 0,referrerPolicy:void 0,integrity:void 0,onProcessMinLen:0},j)}var w8=LY(CY()),R8=function(j){u1(K,j);var F=m1(K);function K(){var U;return f0(this,K),U=F.call(this),i(A0(U),"_xhr",null),i(A0(U),"_aborted",!1),i(A0(U),"_timeoutTimer",null),i(A0(U),"_range",null),i(A0(U),"_receivedLength",0),i(A0(U),"_url",null),i(A0(U),"_onProgress",null),i(A0(U),"_index",-1),i(A0(U),"_headers",null),i(A0(U),"_currentChunkSizeKB",384),i(A0(U),"_timeout",null),i(A0(U),"_xhr",null),i(A0(U),"_withCredentials",null),i(A0(U),"_startTime",-1),i(A0(U),"_loadCompleteResolve",null),i(A0(U),"_loadCompleteReject",null),i(A0(U),"_runing",!1),i(A0(U),"_logger",!1),i(A0(U),"_vid",""),i(A0(U),"_responseType",void 0),i(A0(U),"_credentials",void 0),i(A0(U),"_method",void 0),i(A0(U),"_transformResponse",void 0),i(A0(U),"_firstRtt",void 0),i(A0(U),"_onCancel",null),i(A0(U),"_priOptions",null),U}return c0(K,[{key:"load",value:function U(N){var O=this;clearTimeout(this._timeoutTimer),this._logger=N.logger,this._range=N.range,this._onProgress=N.onProgress,this._index=N.index,this._headers=N.headers,this._withCredentials=N.credentials==="include"||N.credentials==="same-origin",this._body=N.body||null,N.method&&(this._method=N.method),this._timeout=N.timeout||null,this._runing=!0,this._vid=N.vid||N.url,this._responseType=N.responseType,this._firstRtt=-1,this._onTimeout=N.onTimeout,this._onCancel=N.onCancel,this._request=N.request,this._priOptions=N.priOptions||{},this._logger.debug("【xhrLoader task】, range",this._range),this._url=PJ(N.url,N.params);var B=Date.now();return new Promise(function(w,R){O._loadCompleteResolve=w,O._loadCompleteReject=R,O._startLoad()}).catch(function(w){if(clearTimeout(O._timeoutTimer),O._runing=!1,O._aborted)return;throw w=w instanceof T1?w:new T1(O._url,O._request),w.startTime=B,w.endTime=Date.now(),w.options={index:O._index,vid:O._vid,priOptions:O._priOptions},w})}},{key:"_startLoad",value:function U(){var N=null;if(this._responseType===UY.ARRAY_BUFFER&&this._range&&this._range.length>1)if(this._onProgress){this._firstRtt=-1;var O=this._currentChunkSizeKB*1024,B=this._range[0]+this._receivedLength,w=this._range[1];if(O<this._range[1]-B)w=B+O;N=[B,w],this._logger.debug("[xhr_loader->],tast :",this._range,", SubRange, ",N)}else N=this._range,this._logger.debug("[xhr_loader->],tast :",this._range,", allRange, ",N);this._internalOpen(N)}},{key:"_internalOpen",value:function U(N){var O=this;try{this._startTime=Date.now();var B=this._xhr=new XMLHttpRequest;B.open(this._method||"GET",this._url,!0),B.responseType=this._responseType,this._timeout&&(B.timeout=this._timeout),B.withCredentials=this._withCredentials,B.onload=this._onLoad.bind(this),B.onreadystatechange=this._onReadyStatechange.bind(this),B.onerror=function(P){var x,k,f;O._running=!1;var l=new T1(O._url,O._request,P===null||P===void 0?void 0:(x=P.currentTarget)===null||x===void 0?void 0:x.response,"xhr.onerror.status:"+(P===null||P===void 0?void 0:(k=P.currentTarget)===null||k===void 0?void 0:k.status)+",statusText,"+(P===null||P===void 0?void 0:(f=P.currentTarget)===null||f===void 0?void 0:f.statusText));l.options={index:O._index,range:O._range,vid:O._vid,priOptions:O._priOptions},O._loadCompleteReject(l)},B.ontimeout=function(P){O.cancel();var x=new T1(O._url,O._request,{status:408},"timeout");if(O._onTimeout)x.isTimeout=!0,O._onTimeout(x,{index:O._index,range:O._range,vid:O._vid,priOptions:O._priOptions});x.options={index:O._index,range:O._range,vid:O._vid,priOptions:O._priOptions},O._loadCompleteReject(x)};var w=this._headers||{},R=SJ(N);if(R)w.Range=R;if(w)Object.keys(w).forEach(function(P){B.setRequestHeader(P,w[P])});this._logger.debug("[xhr.send->] tast,",this._range,",load sub range, ",N),B.send(this._body)}catch(P){P.options={index:this._index,range:N,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(P)}}},{key:"_onReadyStatechange",value:function U(N){var O=N.target;if(O.readyState===2)this._firstRtt<0&&(this._firstRtt=Date.now())}},{key:"_onLoad",value:function U(N){var O,B=N.target.status;if(B<200||B>299){var w=new T1(this._url,null,qY(qY({},N.target.response),{},{status:B}),"bad response,status:"+B);return w.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(w)}var R=null,P=!1,x,k=((O=this._range)===null||O===void 0?void 0:O.length)>0?this._range[0]:0;if(this._responseType===UY.ARRAY_BUFFER){var f,l=new Uint8Array(N.target.response);if(x=k+this._receivedLength,l&&l.byteLength>0){this._receivedLength+=l.byteLength;var s=Date.now()-this._startTime,Y0=sY(this._receivedLength,s);this.emit(w0.REAL_TIME_SPEED,{speed:Y0,len:this._receivedLength,time:s,vid:this._vid,index:this._index,range:[x,k+this._receivedLength],priOptions:this._priOptions})}if(R=l,((f=this._range)===null||f===void 0?void 0:f.length)>1&&this._range[1]&&this._receivedLength<this._range[1]-this._range[0])P=!1;else P=!0;this._logger.debug("[xhr load done->], tast :",this._range,", start",x,"end ",k+this._receivedLength,",dataLen,",l?l.byteLength:0,",receivedLength",this._receivedLength,",index,",this._index,", done,",P)}else P=!0,R=N.target.response;var t={ok:B>=200&&B<300,status:B,statusText:this._xhr.statusText,url:this._xhr.responseURL,headers:this._getHeaders(this._xhr),body:this._xhr.response};if(this._transformResponse)t=this._transformResponse(t,this._url)||t;if(this._onProgress)this._onProgress(R,P,{index:this._index,vid:this._vid,range:[x,k+this._receivedLength],startTime:this._startTime,endTime:Date.now(),priOptions:this._priOptions},t);if(!P)this._startLoad();else this._runing=!1,this._loadCompleteResolve&&this._loadCompleteResolve(iY(this._onProgress?null:R,P,t,t.headers["content-length"],t.headers.age,this._startTime,this._firstRtt,this._index,this._range,this._vid,this._priOptions))}},{key:"cancel",value:function U(){if(this._aborted)return;if(this._aborted=!0,this._runing=!1,lY(KY(K.prototype),"removeAllListeners",this).call(this),this._onCancel)this._onCancel({index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions});if(this._xhr)return this._xhr.abort()}},{key:"receiveLen",get:function U(){return this._receivedLength}},{key:"running",get:function U(){return this._running},set:function U(N){this._running=N}},{key:"_getHeaders",value:function U(N){var O=N.getAllResponseHeaders().trim().split(`\r
30
- `),B={},w=K8(O),R;try{for(w.s();!(R=w.n()).done;){var P=R.value,x=P.split(": ");B[x[0].toLowerCase()]=x.slice(1).join(": ")}}catch(k){w.e(k)}finally{w.f()}return B}}],[{key:"isSupported",value:function U(){return typeof XMLHttpRequest!=="undefined"}}]),K}(w8.default);var _G=["retry","retryDelay","onRetryError","transformError"],$8=function(){function j(F,K){f0(this,j),this.promise=HY(),this.alive=!!K.onProgress,!K.logger&&(K.logger=new D1("Loader")),this._loaderType=F,this._loader=F===_1.FETCH&&typeof fetch!=="undefined"?new rY:new R8,this._config=K,this._retryCount=0,this._retryTimer=null,this._canceled=!1,this._retryCheckFunc=K.retryCheckFunc,this._logger=K.logger}return c0(j,[{key:"exec",value:function F(){var K=this,U=this._config,N=U.retry,O=U.retryDelay,B=U.onRetryError,w=U.transformError,R=W8(U,_G),P=function(){var x=C1(r0().mark(function k(){var f,l,s;return r0().wrap(function Y0(t){while(!0)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,K._loader.load(R);case 3:f=t.sent,K.promise.resolve(f),t.next=27;break;case 7:if(t.prev=7,t.t0=t.catch(0),K._loader.running=!1,K._logger.debug("[task request catch err]",t.t0),!K._canceled){t.next=13;break}return t.abrupt("return");case 13:if(t.t0.loaderType=K._loaderType,t.t0.retryCount=K._retryCount,l=t.t0,w)l=w(l)||l;if(B&&K._retryCount>0)B(l,K._retryCount,{index:R.index,vid:R.vid,range:R.range,priOptions:R.priOptions});if(K._retryCount++,s=!0,K._retryCheckFunc)s=K._retryCheckFunc(t.t0);if(!(s&&K._retryCount<=N)){t.next=26;break}return clearTimeout(K._retryTimer),K._logger.debug("[task request setTimeout],retry",K._retryCount,",retry range,",R.range),K._retryTimer=setTimeout(P,O),t.abrupt("return");case 26:K.promise.reject(l);case 27:case"end":return t.stop()}},k,null,[[0,7]])}));return function k(){return x.apply(this,arguments)}}();return P(),this.promise}},{key:"cancel",value:function(){var F=C1(r0().mark(function U(){return r0().wrap(function N(O){while(!0)switch(O.prev=O.next){case 0:return clearTimeout(this._retryTimer),this._canceled=!0,this._loader.running=!1,O.abrupt("return",this._loader.cancel());case 4:case"end":return O.stop()}},U,this)}));function K(){return F.apply(this,arguments)}return K}()},{key:"running",get:function F(){return this._loader&&this._loader.running}},{key:"loader",get:function F(){return this._loader}}]),j}();function LQ(j){return j&&!j.paused&&!j.ended&&j.playbackRate!==0&&j.readyState!==0}function bQ(j){if(!j)return{};if(typeof j.getVideoPlaybackQuality==="function"){var F=j.getVideoPlaybackQuality();return{droppedVideoFrames:F.droppedVideoFrames||F.corruptedVideoFrames,totalVideoFrames:F.totalVideoFrames,creationTime:F.creationTime}}return{droppedVideoFrames:j.webkitDroppedFrameCount,totalVideoFrames:j.webkitDecodedFrameCount,creationTime:performance.now()}}function MQ(){for(var j=arguments.length,F=new Array(j),K=0;K<j;K++)F[K]=arguments[K];if(F=F.filter(Boolean),F.length<2)return F[0];var U=new Uint8Array(F.reduce(function(O,B){return O+B.byteLength},0)),N=0;return F.forEach(function(O){U.set(O,N),N+=O.byteLength}),U}function CQ(){var j=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return new Promise(function(F){return setTimeout(F,j)})}var I8=LY(CY()),DQ=function(j){u1(K,j);var F=m1(K);function K(U){var N;if(f0(this,K),N=F.call(this,U),i(A0(N),"type",_1.FETCH),i(A0(N),"_queue",[]),i(A0(N),"_alive",[]),i(A0(N),"_currentTask",null),i(A0(N),"_finnalUrl",""),i(A0(N),"_config",void 0),N._config=B8(U),N._config.loaderType===_1.XHR||!rY.isSupported())N.type=_1.XHR;return N.log=U.logger,N}return c0(K,[{key:"isFetch",value:function U(){return this.type===_1.FETCH}},{key:"load",value:function U(N){var O=this,B=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(typeof N==="string"||!N)B.url=N||B.url||this._config.url;else B=N;if(B=Object.assign({},this._config,B),B.params)B.params=Object.assign({},B.params);if(B.headers&&IQ(B.headers))B.headers=Object.assign({},B.headers);if(B.body&&IQ(B.body))B.body=Object.assign({},B.body);if(B.transformRequest)B=B.transformRequest(B)||B;B.logger=this.log;var w=new $8(this.type,B);if(w.loader.on(w0.REAL_TIME_SPEED,function(R){O.emit(w0.REAL_TIME_SPEED,R)}),this._queue.push(w),this._queue.length===1&&(!this._currentTask||!this._currentTask.running))this._processTask();return w.promise}},{key:"cancel",value:function(){var U=C1(r0().mark(function O(){var B;return r0().wrap(function w(R){while(!0)switch(R.prev=R.next){case 0:if(B=this._queue.map(function(P){return P.cancel()}).concat(this._alive.map(function(P){return P.cancel()})),this._currentTask)B.push(this._currentTask.cancel());return this._queue=[],this._alive=[],R.next=6,Promise.all(B);case 6:return R.next=8,CQ();case 8:case"end":return R.stop()}},O,this)}));function N(){return U.apply(this,arguments)}return N}()},{key:"_processTask",value:function U(){var N=this;if(this._currentTask=this._queue.shift(),!this._currentTask)return;if(this._currentTask.alive)this._alive.push(this._currentTask);var O=this._currentTask.exec().catch(function(B){});if(!(O&&typeof O.finally==="function"))return;O.finally(function(){var B,w;if((B=N._currentTask)!==null&&B!==void 0&&B.alive&&((w=N._alive)===null||w===void 0?void 0:w.length)>0)N._alive=N._alive.filter(function(R){return R&&R!==N._currentTask});N._processTask()})}}],[{key:"isFetchSupport",value:function U(){return rY.isSupported()}}]),K}(I8.default);var SQ=function(){function j(){f0(this,j),i(this,"_prevCurrentTime",0)}return c0(j,[{key:"do",value:function F(K){var U=arguments.length>1&&arguments[1]!==void 0?arguments[1]:3,N=arguments.length>2?arguments[2]:void 0,O=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1;if(!K)return;var B=K.currentTime,w=0;if(this._prevCurrentTime===B){var R=J1.info(J1.get(K),B);if(!R.buffers.length)return;if(N&&R.nextStart||R.nextStart&&R.nextStart-B<U)w=R.nextStart+0.1;else if(R.end&&R.end-B>O&&!K.seeking)w=B+0.1}if(this._prevCurrentTime=B,w&&B!==w)K.currentTime=w}}]),j}();var PQ=function(){function j(F){var K=this;f0(this,j),i(this,"_seiSet",new Set),this.emitter=F,F.on(w0.SEI,function(U){if(U)K._seiSet.add(U)})}return c0(j,[{key:"throw",value:function F(K,U){var N=this;if(K===null||K===void 0||!this._seiSet.size)return;var O=K-0.2,B=K+0.2,w=[];if(this._seiSet.forEach(function(R){if(R.time>=O&&R.time<=B)w.push(R)}),w.forEach(function(R){N._seiSet.delete(R),N.emitter.emit(w0.SEI_IN_TIME,R)}),!U)return;this._seiSet.forEach(function(R){if(R.time<K-5)N._seiSet.delete(R)})}},{key:"reset",value:function F(){this._seiSet.clear()}}]),j}();var pG=1000,fG=50,cG=3,lG=3000,yQ=function(){function j(F){f0(this,j),i(this,"_chunkSpeed",0),i(this,"_chunkCache",[]),i(this,"_speeds",[]),i(this,"_totalSize",0),i(this,"_totalCost",0),this._opts=F||{}}return c0(j,[{key:"addRecord",value:function F(K,U){if(!K||!U)return;this._speeds.push(8000*K/U),this._speeds=this._speeds.slice(-cG)}},{key:"addChunkRecord",value:function F(K,U){var N,O;if(!K||!U||K<(((N=this._opts)===null||N===void 0?void 0:N.skipChunkSize)||pG))return;this._totalSize+=K,this._totalCost+=U,this._chunkSpeed=8000*K/U,this._chunkCache.push({size:K,duration:U,timestamp:performance.now()});var B=((O=this._opts)===null||O===void 0?void 0:O.chunkCountForSpeed)||fG;if(this._chunkCache.length>B)this._chunkCache=this._chunkCache.slice(-B)}},{key:"getAvgSpeed",value:function F(){var K;if(!this._chunkCache.length&&!this._speeds.length)return 0;if(this._speeds.length)return this._speeds.reduce(function(w,R){return w+=R})/this._speeds.length;var U=this._chunkCache[this._chunkCache.length-1],N=performance.now()-U.timestamp;if(N>(((K=this._opts)===null||K===void 0?void 0:K.longtimeNoReceived)||lG))this._chunkCache.push({size:0,duration:N,timestamp:performance.now()});var O=this._chunkCache.reduce(function(w,R){return w+=R.size},0),B=this._chunkCache.reduce(function(w,R){return w+=R.duration},0);return 8000*O/B}},{key:"getLatestSpeed",value:function F(){if(!this._chunkCache.length&&!this._speeds.length)return 0;if(this._speeds.length)return this._speeds[this._speeds.length-1];return this._chunkSpeed}},{key:"getTotalSize",value:function F(){return this._totalSize}},{key:"getTotalCost",value:function F(){return this._totalCost}},{key:"reset",value:function F(){this._chunkCache=[],this._speeds=[],this._totalSize=0,this._totalCost=0}}]),j}();var bK=LY(CY());var L8=function(){function j(F){f0(this,j),i(this,"encodeType",""),i(this,"audioCodec",""),i(this,"videoCodec",""),i(this,"domain",""),i(this,"fps",0),i(this,"bitrate",0),i(this,"width",0),i(this,"height",0),i(this,"samplerate",0),i(this,"channelCount",0),i(this,"gop",0),i(this,"_bitsAccumulateSize",0),i(this,"_bitsAccumulateDuration",0),i(this,"_startGopId",-1),this._timescale=F}return c0(j,[{key:"getStats",value:function F(){return{encodeType:this.encodeType,audioCodec:this.audioCodec,videoCodec:this.videoCodec,domain:this.domain,fps:this.fps,bitrate:this.bitrate,width:this.width,height:this.height,samplerate:this.samplerate,channelCount:this.channelCount,gop:this.gop}}},{key:"setEncodeType",value:function F(K){this.encodeType=K}},{key:"setFpsFromScriptData",value:function F(K){var U,N=K.data,O=N===null||N===void 0?void 0:(U=N.onMetaData)===null||U===void 0?void 0:U.framerate;if(O&&O>0&&O<100)this.fps=O}},{key:"setVideoMeta",value:function F(K){if(this.width=K.width,this.height=K.height,this.videoCodec=K.codec,this.encodeType=K.codecType,K.fpsNum&&K.fpsDen){var U=K.fpsNum/K.fpsDen;if(U>0&&U<100)this.fps=U}}},{key:"setAudioMeta",value:function F(K){this.audioCodec=K.codec,this.samplerate=K.sampleRate,this.channelCount=K.channelCount}},{key:"setDomain",value:function F(K){this.domain=K.split("/").slice(2,3)[0]}},{key:"updateBitrate",value:function F(K){var U=this;if(!this.fps||this.fps>=100){if(K.length){var N=K.reduce(function(O,B){return O+=B.duration},0)/K.length;this.fps=Math.round(this._timescale/N)}}K.forEach(function(O){if(U._startGopId===-1)U._startGopId=O.gopId;if(O.gopId===U._startGopId)U.gop++;if(U._bitsAccumulateDuration+=O.duration/(U._timescale/1000),U._bitsAccumulateSize+=O.units.reduce(function(B,w){return B+=w.length},0),U._bitsAccumulateDuration>=1000)U.bitrate=U._bitsAccumulateSize*8,U._bitsAccumulateDuration=0,U._bitsAccumulateSize=0})}}]),j}(),TQ=function(){function j(F){var K=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1000;f0(this,j),i(this,"_core",null),i(this,"_samples",[]),this._core=F,this._timescale=K,this._stats=new L8(K),this._bindEvents()}return c0(j,[{key:"getStats",value:function F(){var K,U,N,O,B,w,R,P,x,k,f,l=((K=this._core)===null||K===void 0?void 0:K.media)||{},s=l.currentTime,Y0=s===void 0?0:s,t=l.decodeFps,K0=t===void 0?0:t;return qY(qY({},this._stats.getStats()),{},{downloadSpeed:((U=this._core)===null||U===void 0?void 0:(N=U.speedInfo)===null||N===void 0?void 0:N.call(U).speed)||0,avgSpeed:((O=this._core)===null||O===void 0?void 0:(B=O.speedInfo)===null||B===void 0?void 0:B.call(O).avgSpeed)||0,totalReceivedByte:((w=this._core)===null||w===void 0?void 0:(R=w.speedInfo)===null||R===void 0?void 0:R.call(w).totalSize)||0,totalReceivedCost:((P=this._core)===null||P===void 0?void 0:(x=P.speedInfo)===null||x===void 0?void 0:x.call(P).totalCost)||0,currentTime:Y0,bufferEnd:((k=this._core)===null||k===void 0?void 0:(f=k.bufferInfo())===null||f===void 0?void 0:f.remaining)||0,decodeFps:K0})}},{key:"_bindEvents",value:function F(){var K=this;this._core.on(w0.DEMUXED_TRACK,function(U){var N=U.videoTrack;return K._stats.updateBitrate(N.samples)}),this._core.on(w0.FLV_SCRIPT_DATA,function(U){K._stats.setFpsFromScriptData(U)}),this._core.on(w0.METADATA_PARSED,function(U){if(U.type==="video")K._stats.setVideoMeta(U.track);else K._stats.setAudioMeta(U.track)}),this._core.on(w0.TTFB,function(U){K._stats.setDomain(U.responseUrl)})}},{key:"reset",value:function F(){this._samples=[],this._stats=new L8(this._timescale)}}]),j}();var a8=LY(CY());function dG(j,F){var K=j==null?null:typeof Symbol!="undefined"&&j[Symbol.iterator]||j["@@iterator"];if(K!=null){var U,N,O,B,w=[],R=!0,P=!1;try{if(O=(K=K.call(j)).next,F===0){if(Object(K)!==K)return;R=!1}else for(;!(R=(U=O.call(K)).done)&&(w.push(U.value),w.length!==F);R=!0);}catch(x){P=!0,N=x}finally{try{if(!R&&K.return!=null&&(B=K.return(),Object(B)!==B))return}finally{if(P)throw N}}return w}}function I0(j,F){if(!(j instanceof F))throw new TypeError("Cannot call a class as a function")}function b8(j,F){for(var K=0;K<F.length;K++){var U=F[K];if(U.enumerable=U.enumerable||!1,U.configurable=!0,"value"in U)U.writable=!0;Object.defineProperty(j,D8(U.key),U)}}function L0(j,F,K){if(F)b8(j.prototype,F);if(K)b8(j,K);return Object.defineProperty(j,"prototype",{writable:!1}),j}function a(j,F,K){if(F=D8(F),F in j)Object.defineProperty(j,F,{value:K,enumerable:!0,configurable:!0,writable:!0});else j[F]=K;return j}function hQ(j,F){if(typeof F!=="function"&&F!==null)throw new TypeError("Super expression must either be null or a function");if(j.prototype=Object.create(F&&F.prototype,{constructor:{value:j,writable:!0,configurable:!0}}),Object.defineProperty(j,"prototype",{writable:!1}),F)xQ(j,F)}function yJ(j){return yJ=Object.setPrototypeOf?Object.getPrototypeOf.bind():function F(K){return K.__proto__||Object.getPrototypeOf(K)},yJ(j)}function xQ(j,F){return xQ=Object.setPrototypeOf?Object.setPrototypeOf.bind():function K(U,N){return U.__proto__=N,U},xQ(j,F)}function nG(){if(typeof Reflect==="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy==="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(j){return!1}}function oG(j){if(j===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return j}function iG(j,F){if(F&&(typeof F==="object"||typeof F==="function"))return F;else if(F!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return oG(j)}function kQ(j){var F=nG();return function K(){var U=yJ(j),N;if(F){var O=yJ(this).constructor;N=Reflect.construct(U,arguments,O)}else N=U.apply(this,arguments);return iG(this,N)}}function M8(j,F){return rG(j)||dG(j,F)||C8(j,F)||eG()}function p1(j){return sG(j)||aG(j)||C8(j)||tG()}function sG(j){if(Array.isArray(j))return vQ(j)}function rG(j){if(Array.isArray(j))return j}function aG(j){if(typeof Symbol!=="undefined"&&j[Symbol.iterator]!=null||j["@@iterator"]!=null)return Array.from(j)}function C8(j,F){if(!j)return;if(typeof j==="string")return vQ(j,F);var K=Object.prototype.toString.call(j).slice(8,-1);if(K==="Object"&&j.constructor)K=j.constructor.name;if(K==="Map"||K==="Set")return Array.from(j);if(K==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(K))return vQ(j,F)}function vQ(j,F){if(F==null||F>j.length)F=j.length;for(var K=0,U=new Array(F);K<F;K++)U[K]=j[K];return U}function tG(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
31
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function eG(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
32
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function YW(j,F){if(typeof j!=="object"||j===null)return j;var K=j[Symbol.toPrimitive];if(K!==void 0){var U=K.call(j,F||"default");if(typeof U!=="object")return U;throw new TypeError("@@toPrimitive must return a primitive value.")}return(F==="string"?String:Number)(j)}function D8(j){var F=YW(j,"string");return typeof F==="symbol"?F:String(F)}var f1={VIDEO:"video",AUDIO:"audio",METADATA:"metadata"},YY={AV1:"av1",AVC:"avc",HEVC:"hevc"},o0={AAC:"aac",G711PCMA:"g7110a",G711PCMU:"g7110m",OPUS:"opus",MP3:"mp3"},E1={LARGE_AV_SHIFT:"LARGE_AV_SHIFT",LARGE_VIDEO_GAP:"LARGE_VIDEO_GAP",LARGE_VIDEO_GAP_BETWEEN_CHUNK:"LARGE_VIDEO_GAP_BETWEEN_CHUNK",LARGE_AUDIO_GAP:"LARGE_AUDIO_GAP",AUDIO_FILLED:"AUDIO_FILLED",AUDIO_DROPPED:"AUDIO_DROPPED"};var S8=function(){function j(){I0(this,j),a(this,"id",1),a(this,"type",f1.VIDEO),a(this,"codecType",YY.AVC),a(this,"pid",-1),a(this,"hvcC",void 0),a(this,"codec",""),a(this,"timescale",0),a(this,"formatTimescale",0),a(this,"sequenceNumber",0),a(this,"baseMediaDecodeTime",0),a(this,"baseDts",0),a(this,"duration",0),a(this,"warnings",[]),a(this,"samples",[]),a(this,"pps",[]),a(this,"sps",[]),a(this,"vps",[]),a(this,"fpsNum",0),a(this,"fpsDen",0),a(this,"sarRatio",[]),a(this,"width",0),a(this,"height",0),a(this,"nalUnitSize",4),a(this,"present",!1),a(this,"isVideoEncryption",!1),a(this,"isAudioEncryption",!1),a(this,"isVideo",!0),a(this,"lastKeyFrameDts",0),a(this,"kid",null),a(this,"pssh",null),a(this,"ext",void 0)}return L0(j,[{key:"reset",value:function F(){this.sequenceNumber=this.width=this.height=this.fpsDen=this.fpsNum=this.duration=this.baseMediaDecodeTime=this.timescale=0,this.codec="",this.present=!1,this.pid=-1,this.pps=[],this.sps=[],this.vps=[],this.sarRatio=[],this.samples=[],this.warnings=[],this.hvcC=null}},{key:"firstDts",get:function F(){return this.samples.length?this.samples[0].dts:null}},{key:"firstPts",get:function F(){return this.samples.length?this.samples[0].pts:null}},{key:"samplesDuration",get:function F(){if(this.samples.length>0){var K=this.samples[0],U=this.samples[this.samples.length-1];return U.dts-K.dts+U.duration}return 0}},{key:"exist",value:function F(){if(/av01/.test(this.codec))return!0;return!!(this.pps.length&&this.sps.length&&this.codec)}},{key:"hasSample",value:function F(){return!!this.samples.length}},{key:"isEncryption",get:function F(){return this.isVideoEncryption}}]),j}();var P8=function(){function j(){I0(this,j),a(this,"id",2),a(this,"type",f1.AUDIO),a(this,"codecType",o0.AAC),a(this,"pid",-1),a(this,"codec",""),a(this,"container",""),a(this,"sequenceNumber",0),a(this,"sampleDuration",0),a(this,"timescale",0),a(this,"formatTimescale",0),a(this,"baseMediaDecodeTime",0),a(this,"duration",0),a(this,"warnings",[]),a(this,"samples",[]),a(this,"baseDts",0),a(this,"sampleSize",16),a(this,"sampleRate",0),a(this,"channelCount",0),a(this,"objectType",0),a(this,"sampleRateIndex",0),a(this,"config",[]),a(this,"present",!1),a(this,"isVideoEncryption",!1),a(this,"isAudioEncryption",!1),a(this,"kid",null),a(this,"ext",void 0)}return L0(j,[{key:"reset",value:function F(){this.sequenceNumber=0,this.timescale=0,this.sampleDuration=0,this.sampleRate=0,this.channelCount=0,this.baseMediaDecodeTime=0,this.present=!1,this.pid=-1,this.codec="",this.samples=[],this.config=[],this.warnings=[]}},{key:"exist",value:function F(){return!!(this.sampleRate&&this.channelCount&&(this.codec||this.container)&&(this.codecType===o0.AAC||this.codecType===o0.G711PCMA||this.codecType===o0.G711PCMU||this.codecType===o0.OPUS||this.codecType===o0.MP3))}},{key:"hasSample",value:function F(){return!!this.samples.length}},{key:"isEncryption",get:function F(){return this.isAudioEncryption}},{key:"firstDts",get:function F(){return this.samples.length?this.samples[0].dts:null}},{key:"firstPts",get:function F(){return this.samples.length?this.samples[0].pts:null}},{key:"samplesDuration",get:function F(){if(this.samples.length>0){var K=this.samples[0],U=this.samples[this.samples.length-1];return U.dts-K.dts+U.duration}return 0}}]),j}();var y8=function(){function j(F,K,U){if(I0(this,j),a(this,"flag",{}),a(this,"keyframe",!1),a(this,"gopId",0),a(this,"duration",0),a(this,"size",0),a(this,"units",[]),a(this,"chromaFormat",420),this.originPts=this.pts=F,this.originDts=this.dts=K,U)this.units=U}return L0(j,[{key:"cts",get:function F(){return this.pts-this.dts}},{key:"setToKeyframe",value:function F(){this.keyframe=!0,this.flag.dependsOn=2,this.flag.isNonSyncSample=0}}]),j}();var DY=L0(function j(F,K,U,N){if(I0(this,j),a(this,"duration",1024),a(this,"flag",{dependsOn:2,isNonSyncSample:0}),a(this,"keyframe",!0),this.originPts=this.pts=this.dts=F,this.data=K,this.size=K.byteLength,this.sampleOffset=N,U)this.duration=U});var T8=L0(function j(F,K){I0(this,j),a(this,"time",0),this.data=F,this.originPts=this.pts=K}),x8=function(j){hQ(K,j);var F=kQ(K);function K(){return I0(this,K),F.apply(this,arguments)}return L0(K)}(T8),v8=function(j){hQ(K,j);var F=kQ(K);function K(){return I0(this,K),F.apply(this,arguments)}return L0(K)}(T8),h8=function(){function j(){I0(this,j),a(this,"id",3),a(this,"type",f1.METADATA),a(this,"timescale",0),a(this,"flvScriptSamples",[]),a(this,"seiSamples",[])}return L0(j,[{key:"exist",value:function F(){return!!((this.flvScriptSamples.length||this.seiSamples.length)&&this.timescale)}},{key:"reset",value:function F(){this.timescale=0,this.flvScriptSamples=[],this.seiSamples=[]}},{key:"hasSample",value:function F(){return!!(this.flvScriptSamples.length||this.seiSamples.length)}}]),j}();var AY=function(){function j(F){I0(this,j),this.name=F||"",this._prefix="[".concat(this.name,"]")}return L0(j,[{key:"warn",value:function F(){var K;if(j.disabled)return;for(var U=arguments.length,N=new Array(U),O=0;O<U;O++)N[O]=arguments[O];(K=console).warn.apply(K,[this._prefix].concat(N))}}],[{key:"enable",value:function F(){j.disabled=!1}},{key:"disable",value:function F(){j.disabled=!0}}]),j}();a(AY,"disabled",!0);var TJ=typeof window!=="undefined",gQ=TJ&&navigator.userAgent.toLocaleLowerCase(),k8=TJ&&/^((?!chrome|android).)*safari/.test(gQ),g8=TJ&&gQ.includes("firefox"),u8=TJ&&gQ.includes("android");var SY=function(){function j(){I0(this,j)}return L0(j,null,[{key:"getRateIndexByRate",value:function F(K){return j.FREQ.indexOf(K)}},{key:"parseADTS",value:function F(K,U){var N=K.length,O=0;while(O+2<N){if(K[O]===255&&(K[O+1]&246)===240)break;O++}if(O>=N)return;var B=O,w=[],R=(K[O+2]&60)>>>2,P=j.FREQ[R];if(!P)throw new Error("Invalid sampling index: ".concat(R));var x=((K[O+2]&192)>>>6)+1,k=(K[O+2]&1)<<2|(K[O+3]&192)>>>6,f=j._getConfig(R,k,x),l=f.config,s=f.codec,Y0,t,K0=0,q0=j.getFrameDuration(P);while(O+7<N){if(K[O]!==255||(K[O+1]&246)!==240){O++;continue}if(t=(K[O+3]&3)<<11|K[O+4]<<3|(K[O+5]&224)>>5,!t||N-O<t)break;Y0=(~K[O+1]&1)*2,w.push({pts:U+K0*q0,data:K.subarray(O+7+Y0,O+t)}),K0++,O+=t}return{skip:B,remaining:O>=N?void 0:K.subarray(O),frames:w,samplingFrequencyIndex:R,sampleRate:P,objectType:x,channelCount:k,codec:s,config:l,originCodec:"mp4a.40.".concat(x)}}},{key:"parseAudioSpecificConfig",value:function F(K){if(!K.length)return;var U=K[0]>>>3,N=(K[0]&7)<<1|K[1]>>>7,O=(K[1]&120)>>>3,B=j.FREQ[N];if(!B)return;var w=j._getConfig(N,O,U),R=w.config,P=w.codec;return{samplingFrequencyIndex:N,sampleRate:B,objectType:U,channelCount:O,config:R,codec:P,originCodec:"mp4a.40.".concat(U)}}},{key:"getFrameDuration",value:function F(K){var U=arguments.length>1&&arguments[1]!==void 0?arguments[1]:90000;return 1024*U/K}},{key:"_getConfig",value:function F(K,U,N){var O=[],B,w;if(g8)if(K>=6)B=5,w=K-3;else B=2,w=K;else if(u8)B=2,w=K;else if(B=5,w=K,K>=6)w=K-3;else if(U===1)B=2,w=K;if(O[0]=B<<3,O[0]|=(K&14)>>1,O[1]=(K&1)<<7,O[1]|=U<<3,B===5)O[1]|=(w&14)>>1,O[2]=(w&1)<<7,O[2]|=8,O[3]=0;return{config:O,codec:"mp4a.40.".concat(B)}}},{key:"getSilentFrame",value:function F(K,U){switch(K){case"mp4a.40.2":if(U===1)return new Uint8Array([0,200,0,128,35,128]);if(U===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(U===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(U===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(U===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(U===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(U===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(U===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(U===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}}}]),j}();a(SY,"FREQ",[96000,88200,64000,48000,44100,32000,24000,22050,16000,12000,11025,8000,7350]);var aY=function(){function j(){I0(this,j)}return L0(j,null,[{key:"getFrameDuration",value:function F(K){return 20}},{key:"parseHeaderPackets",value:function F(K){if(!K.length)return;var U=new DataView(K.buffer,K.byteOffset,K.byteLength),N="";for(var O=0;O<8;O++)N+=String.fromCodePoint(K[O]);if(N!=="OpusHead")throw new Error("Invalid Opus MagicSignature");var B=K[9];console.log("Pre-skip",K[10],K[11]);var w=U.getUint32(12,!0),R=U.getInt16(16,!0);if(!w)return;var P="opus",x="opus",k=new Uint8Array(K.buffer,K.byteOffset+8,K.byteLength-8);return{outputGain:R,sampleRate:w,channelCount:B,config:k,codec:P,originCodec:x}}}]),j}();var JW=500,m8=3,uQ=1000,mQ=5000,QW=1000,ZW=200,_8=5000,p8=5,f8=function(){function j(F,K,U){I0(this,j),this.videoTrack=F,this.audioTrack=K,this.metadataTrack=U,this._baseDts=-1,this._baseDtsInited=!1,this._audioNextPts=void 0,this._videoNextDts=void 0,this._audioTimestampBreak=0,this._videoTimestampBreak=0,this._lastVideoDuration=0,this._keyFrameInNextChunk=!1,this._lastAudioExceptionGapDot=-1/0,this._lastAudioExceptionOverlapDot=-1/0,this._lastAudioExceptionLargeGapDot=-1/0,this._lastVideoExceptionLargeGapDot=-1/0,this._lastVideoExceptionChunkFirstDtsDot=-1/0}return L0(j,[{key:"fix",value:function F(){var K=this,U=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,N=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,O=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;U=Math.round(U*1000);var B=this.videoTrack,w=this.audioTrack;if(N||!O)this._videoLastSample=null,this._audioNextPts=void 0,this._videoNextDts=void 0,this._audioTimestampBreak=0,this._videoTimestampBreak=0,this._lastAudioExceptionGapDot=-1/0,this._lastAudioExceptionOverlapDot=-1/0,this._lastAudioExceptionLargeGapDot=-1/0,this._lastVideoExceptionLargeGapDot=-1/0,this._lastVideoExceptionChunkFirstDtsDot=-1/0;if(N&&!O)this._baseDtsInited=!1;if(!this._baseDtsInited)this._calculateBaseDts(w,B);if(!O&&U)this._audioNextPts=this._videoNextDts=U;var R=this._baseDtsInited&&(this._videoTimestampBreak||!this.videoTrack.exist())&&(this._audioTimestampBreak||!this.audioTrack.exist());if(R)this._resetBaseDtsWhenStreamBreaked();if(this._fixAudio(w),this._keyFrameInNextChunk=!1,this._fixVideo(B),this.metadataTrack.exist()){var P=this.metadataTrack.timescale;this.metadataTrack.seiSamples.forEach(function(x){x.pts=x.originPts-K._baseDts,x.time=Math.max(0,x.pts)/P}),this.metadataTrack.flvScriptSamples.forEach(function(x){x.pts=x.originPts-K._baseDts,x.time=Math.max(0,x.pts)/P})}if(B.samples.length)B.baseMediaDecodeTime=B.samples[0].dts;if(w.samples.length)w.baseMediaDecodeTime=w.samples[0].pts*w.timescale/1000}},{key:"_fixVideo",value:function F(K){var U=this,N=K.samples;if(!N.length)return;N.forEach(function(q0){if(q0.dts-=U._baseDts,q0.pts-=U._baseDts,q0.keyframe)U._keyFrameInNextChunk=!0});var O;if(K.fpsNum&&K.fpsDen)O=K.timescale*(K.fpsDen/K.fpsNum);else if(K.length>1){var B=K.samples[0],w=K.samples[N.length-1];O=Math.floor((w.dts-B.dts)/(N.length-1))}else O=this._lastVideoDuration||40;var R=N.pop();if(this._videoLastSample)N.unshift(this._videoLastSample);if(this._videoLastSample=R,!N.length)return;if(this._videoNextDts===void 0){var P=N[0];this._videoNextDts=P.dts}var x=N.length,k=0,f=N[0],l=this._videoNextDts-f.dts;if(Math.abs(l)>ZW){if(Math.abs(f.dts-this._lastVideoExceptionChunkFirstDtsDot)>_8){var s;this._lastVideoExceptionChunkFirstDtsDot=f.dts,K.warnings.push({type:E1.LARGE_VIDEO_GAP_BETWEEN_CHUNK,nextDts:this._videoNextDts,firstSampleDts:f.dts,nextSampleDts:(s=N[1])===null||s===void 0?void 0:s.dts,sampleDuration:l})}if(this._videoTimestampBreak>=p8)this._videoNextDts=f.dts,this._videoTimestampBreak=0;else if(f.dts+=l,f.pts+=l,!this.audioTrack.exist())this._videoTimestampBreak=1}for(var Y0=0;Y0<x;Y0++){var t=N[Y0].dts,K0=N[Y0+1];if(Y0<x-1)k=K0.dts-t;else if(R)k=R.dts-t;else k=O;if(k>QW||k<0){if(this._videoTimestampBreak++,Math.abs(t-this._lastVideoExceptionLargeGapDot)>_8)this._lastVideoExceptionLargeGapDot=t,K.warnings.push({type:E1.LARGE_VIDEO_GAP,time:t/K.timescale,dts:t,originDts:N[Y0].originDts,nextDts:this._videoNextDts,sampleDuration:k,refSampleDuration:O});k=O}N[Y0].duration=k,this._videoNextDts+=k,this._lastVideoDuration=k}}},{key:"_fixAudio",value:function F(K){var U=this,N=K.samples;if(!N.length)return;N.forEach(function(O){O.dts=O.pts-=U._baseDts}),this._doFixAudioInternal(K,N,1000)}},{key:"_calculateBaseDts",value:function F(K,U){var N=K.samples,O=U.samples;if(!N.length&&!O.length)return!1;var B=1/0,w=1/0;if(N.length)K.baseDts=B=N[0].pts;if(O.length)U.baseDts=w=O[0].dts;this._baseDts=Math.min(B,w);var R=w-B;if(Number.isFinite(R)&&Math.abs(R)>JW)U.warnings.push({type:E1.LARGE_AV_SHIFT,videoBaseDts:w,audioBasePts:B,baseDts:this._baseDts,delta:R});return this._baseDtsInited=!0,!0}},{key:"_resetBaseDtsWhenStreamBreaked",value:function F(){var K=this._calculateBaseDts(this.audioTrack,this.videoTrack);if(!K)return;if(!this.audioTrack.exist())this._baseDts-=this._videoNextDts;else if(!this.videoTrack.exist())this._baseDts-=this._audioNextPts;else this._baseDts-=Math.min(this._audioNextPts,this._videoNextDts);this._videoTimestampBreak=0,this._audioTimestampBreak=0}},{key:"_doFixAudioInternal",value:function F(K,U,N){if(!K.sampleDuration)switch(K.codecType){case o0.AAC:{K.sampleDuration=SY.getFrameDuration(K.timescale,N);break}case o0.OPUS:{K.sampleDuration=aY.getFrameDuration(K.samples,N);break}case o0.G711PCMA:case o0.G711PCMU:{K.sampleDuration=this._getG711Duration(K);break}default:console.error("can't fix audio codecType:",K.codecType);break}var O=K.sampleDuration,B=K.codecType===o0.OPUS?20:K.codecType===o0.AAC?1024:O*K.timescale/1000;if(this._audioNextPts===void 0){var w=U[0];this._audioNextPts=w.pts}for(var R=0;R<U.length;R++){var P=this._audioNextPts,x=U[R],k=x.pts-P;if(R===0&&this._audioTimestampBreak>=p8&&this._keyFrameInNextChunk)P=this._audioNextPts=x.dts,k=0,this._audioTimestampBreak=0;if(!this._audioTimestampBreak&&k>=m8*O&&k<=uQ&&!k8){var f=this._getSilentFrame(K)||U[0].data.subarray(),l=Math.floor(k/O);if(Math.abs(x.pts-this._lastAudioExceptionGapDot)>mQ)this._lastAudioExceptionGapDot=x.pts,K.warnings.push({type:E1.AUDIO_FILLED,pts:x.pts,originPts:x.originPts,count:l,nextPts:P,refSampleDuration:O});for(var s=0;s<l;s++){var Y0=new DY(Math.floor(this._audioNextPts+O)-Math.floor(this._audioNextPts),f,B);Y0.originPts=Math.floor(this._baseDts+P),U.splice(R,0,Y0),this._audioNextPts+=O,R++}R--}else if(k<=-m8*O&&k>=-1*uQ){if(Math.abs(x.pts-this._lastAudioExceptionOverlapDot)>mQ)this._lastAudioExceptionOverlapDot=x.pts,K.warnings.push({type:E1.AUDIO_DROPPED,pts:x.pts,originPts:x.originPts,nextPts:P,refSampleDuration:O});U.splice(R,1),R--}else{if(Math.abs(k)>uQ){if(this._audioTimestampBreak++,Math.abs(x.pts-this._lastAudioExceptionLargeGapDot)>mQ)this._lastAudioExceptionLargeGapDot=x.pts,K.warnings.push({type:E1.LARGE_AUDIO_GAP,time:x.pts/1000,pts:x.pts,originPts:x.originPts,nextPts:P,sampleDuration:k,refSampleDuration:O})}if(K.codecType===o0.OPUS){var t=U[U.length-1];if(t)t.duration=x.pts-t.pts}else x.dts=x.pts=P,x.duration=B;this._audioNextPts+=O}}}},{key:"_getG711Duration",value:function F(K){var{sampleSize:U,channelCount:N,sampleRate:O}=K,B=K.samples[0];if(!B)return;return B.data.byteLength*2/N/(U/8)/O*1000}},{key:"_getSilentFrame",value:function F(K){if(K.codecType===o0.AAC)return SY.getSilentFrame(K.codec,K.channelCount);return new Uint8Array(8*K.sampleDuration*K.channelCount)}}]),j}();function S1(){for(var j=arguments.length,F=new Array(j),K=0;K<j;K++)F[K]=arguments[K];F=F.filter(Boolean);var U=new Uint8Array(F.reduce(function(O,B){return O+B.byteLength},0)),N=0;return F.forEach(function(O){U.set(O,N),N+=O.byteLength}),U}var Fq=Math.pow(2,32);function PY(j){var F=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(j[F]<<24>>>0)+(j[F+1]<<16)+(j[F+2]<<8)+(j[F+3]||0)}function c8(j){var F="avc1.",K;for(var U=0;U<3;U++){if(K=j[U].toString(16),K.length<2)K="0".concat(K);F+=K}return F}function _Q(j){if(!Array.isArray(j)){var F=[],K="";for(var U=0;U<j.length;U++)if(U%2)K=j[U-1]+j[U],F.push(parseInt(K,16)),K="";return F}return j.map(function(N){return parseInt(N,16)})}var JY=function(){function j(){I0(this,j)}return L0(j,null,[{key:"parseAnnexB",value:function F(K){var U=K.byteLength-1,N=0;do{if(K[U]===0)N++;else break;U--}while(U>0);if(N>=3)K=K.subarray(0,U+1);var O=K.length,B=2,w=0;while(K[B]!==null&&K[B]!==void 0&&K[B]!==1)B++;if(B++,w=B+2,w>=O)return[];var R=[];while(w<O)switch(K[w]){case 0:if(K[w-1]!==0){w+=2;break}else if(K[w-2]!==0){w++;break}else if(w<O-1&&K[w+1]!==1){w++;break}if(B!==w-2)R.push(K.subarray(B,w-2));do w++;while(K[w]!==1&&w<O);B=w+1,w=B+2;break;case 1:if(K[w-1]!==0||K[w-2]!==0){w+=3;break}if(B!==w-2)R.push(K.subarray(B,w-2));B=w+1,w=B+2;break;default:w+=3;break}if(B<O)R.push(K.subarray(B));return R}},{key:"parseAvcC",value:function F(K){var U=arguments.length>1&&arguments[1]!==void 0?arguments[1]:4;if(K.length<4)return;var N=K.length,O=[],B=0,w;while(B+U<N){if(w=PY(K,B),U===3)w>>>=8;if(B+=U,!w)continue;if(B+w>N)break;O.push(K.subarray(B,B+w)),B+=w}return O}},{key:"parseSEI",value:function F(K,U){var N=K.length,O=U?2:1,B=0,w=0,R="";while(K[O]===255)B+=255,O++;B+=K[O++];while(K[O]===255)w+=255,O++;if(w+=K[O++],B===5&&N>O+16)for(var P=0;P<16;P++)R+=K[O].toString(16),O++;return{payload:K.subarray(O,O+w),type:B,size:w,uuid:R}}},{key:"removeEPB",value:function F(K){var U=K.byteLength,N=[],O=1;while(O<U-2)if(K[O]===0&&K[O+1]===0&&K[O+2]===3)N.push(O+2),O+=2;else O++;if(!N.length)return K;var B=U-N.length,w=new Uint8Array(B),R=0;for(O=0;O<B;R++,O++){if(R===N[0])R++,N.shift();w[O]=K[R]}return w}}]),j}();var tY=function(){function j(F){if(I0(this,j),a(this,"_bytesAvailable",void 0),a(this,"_bitsAvailable",0),a(this,"_word",0),!F)throw new Error("ExpGolomb data params is required");if(this._data=F,this._bytesAvailable=F.byteLength,this._bytesAvailable)this._loadWord()}return L0(j,[{key:"bitsAvailable",get:function F(){return this._bitsAvailable}},{key:"_loadWord",value:function F(){var K=this._data.byteLength-this._bytesAvailable,U=Math.min(4,this._bytesAvailable);if(U===0)throw new Error("No bytes available");var N=new Uint8Array(4);N.set(this._data.subarray(K,K+U)),this._word=new DataView(N.buffer).getUint32(0),this._bitsAvailable=U*8,this._bytesAvailable-=U}},{key:"skipBits",value:function F(K){if(this._bitsAvailable>K)this._word<<=K,this._bitsAvailable-=K;else{K-=this._bitsAvailable;var U=Math.floor(K/8);K-=U*8,this._bytesAvailable-=U,this._loadWord(),this._word<<=K,this._bitsAvailable-=K}}},{key:"readBits",value:function F(K){if(K>32)throw new Error("Cannot read more than 32 bits");var U=Math.min(this._bitsAvailable,K),N=this._word>>>32-U;if(this._bitsAvailable-=U,this._bitsAvailable>0)this._word<<=U;else if(this._bytesAvailable>0)this._loadWord();if(U=K-U,U>0&&this._bitsAvailable)return N<<U|this.readBits(U);return N}},{key:"skipLZ",value:function F(){var K;for(K=0;K<this._bitsAvailable;++K)if((this._word&2147483648>>>K)!==0)return this._word<<=K,this._bitsAvailable-=K,K;return this._loadWord(),K+this.skipLZ()}},{key:"skipUEG",value:function F(){this.skipBits(1+this.skipLZ())}},{key:"readUEG",value:function F(){var K=this.skipLZ();return this.readBits(K+1)-1}},{key:"readEG",value:function F(){var K=this.readUEG();if(1&K)return 1+K>>>1;return-1*(K>>>1)}},{key:"readBool",value:function F(){return this.readBits(1)===1}},{key:"readUByte",value:function F(){return this.readBits(8)}},{key:"skipScalingList",value:function F(K){var U=8,N=8,O;for(var B=0;B<K;B++){if(N!==0)O=this.readEG(),N=(U+O+256)%256;U=N===0?U:N}}}]),j}();var l8=function(){function j(){I0(this,j)}return L0(j,null,[{key:"parseAVCDecoderConfigurationRecord",value:function F(K){if(K.length<7)return;var U=(K[4]&3)+1,N,O=[],B=[],w=6,R=K[5]&31,P;for(var x=0;x<R;x++){if(P=K[w]<<8|K[w+1],w+=2,!P)continue;var k=K.subarray(w,w+P);if(w+=P,O.push(k),!N)N=j.parseSPS(JY.removeEPB(k))}var f=K[w];w++;var l;for(var s=0;s<f;s++){if(l=K[w]<<8|K[w+1],w+=2,!l)continue;B.push(K.subarray(w,w+l)),w+=l}return{sps:N,spsArr:O,ppsArr:B,nalUnitSize:U}}},{key:"parseSPS",value:function F(K){var U=new tY(K);U.readUByte();var N=U.readUByte(),O=U.readUByte(),B=U.readUByte();U.skipUEG();var w=420;if(N===100||N===110||N===122||N===244||N===44||N===83||N===86||N===118||N===128||N===138||N===144){var R=U.readUEG();if(R<=3)w=[0,420,422,444][R];if(R===3)U.skipBits(1);if(U.skipUEG(),U.skipUEG(),U.skipBits(1),U.readBool()){var P=R!==3?8:12;for(var x=0;x<P;x++)if(U.readBool())if(x<6)U.skipScalingList(16);else U.skipScalingList(64)}}U.skipUEG();var k=U.readUEG();if(k===0)U.readUEG();else if(k===1){U.skipBits(1),U.skipUEG(),U.skipUEG();var f=U.readUEG();for(var l=0;l<f;l++)U.skipUEG()}U.skipUEG(),U.skipBits(1);var s=U.readUEG(),Y0=U.readUEG(),t=U.readBits(1);if(t===0)U.skipBits(1);U.skipBits(1);var K0=0,q0=0,R0=0,U0=0;if(U.readBool())K0=U.readUEG(),q0=U.readUEG(),R0=U.readUEG(),U0=U.readUEG();var W0,z0,h0,l0,E0;if(U.readBool()){if(U.readBool()){var y0=U.readUByte();switch(y0){case 1:W0=[1,1];break;case 2:W0=[12,11];break;case 3:W0=[10,11];break;case 4:W0=[16,11];break;case 5:W0=[40,33];break;case 6:W0=[24,11];break;case 7:W0=[20,11];break;case 8:W0=[32,11];break;case 9:W0=[80,33];break;case 10:W0=[18,11];break;case 11:W0=[15,11];break;case 12:W0=[64,33];break;case 13:W0=[160,99];break;case 14:W0=[4,3];break;case 15:W0=[3,2];break;case 16:W0=[2,1];break;case 255:{W0=[U.readUByte()<<8|U.readUByte(),U.readUByte()<<8|U.readUByte()];break}}}if(U.readBool())U.readBool();if(U.readBool()){if(U.readBits(4),U.readBool())U.readBits(24)}if(U.readBool())U.readUEG(),U.readUEG();if(U.readBool()){var t0=U.readBits(32),T=U.readBits(32);z0=U.readBool(),h0=T,l0=t0*2,E0=h0/l0}}return{codec:c8(K.subarray(1,4)),profileIdc:N,profileCompatibility:O,levelIdc:B,chromaFormat:w,width:Math.ceil((s+1)*16-2*(K0+q0)),height:(2-t)*(Y0+1)*16-(t?2:4)*(R0+U0),sarRatio:W0,fpsNum:h0,fpsDen:l0,fps:E0,fixedFrame:z0}}}]),j}();var d8=function(){function j(){I0(this,j)}return L0(j,null,[{key:"parseHEVCDecoderConfigurationRecord",value:function F(K){var U=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(K.length<23)return;U=U||{};var N=(K[21]&3)+1,O,B,w=[],R=[],P=[],x=23,k=K[22],f,l,s;for(var Y0=0;Y0<k;Y0++){f=K[x]&63,l=K[x+1]<<8|K[x+2],x+=3;for(var t=0;t<l;t++){if(s=K[x]<<8|K[x+1],x+=2,!s)continue;switch(f){case 32:{var K0=K.subarray(x,x+s);if(!O)O=j.parseVPS(JY.removeEPB(K0),U);P.push(K0)}break;case 33:{var q0=K.subarray(x,x+s);if(!B)B=j.parseSPS(JY.removeEPB(q0),U);w.push(q0)}break;case 34:R.push(K.subarray(x,x+s));break}x+=s}}return{hvcC:U,sps:B,spsArr:w,ppsArr:R,vpsArr:P,nalUnitSize:N}}},{key:"parseVPS",value:function F(K,U){U=U||{};var N=new tY(K);N.readUByte(),N.readUByte(),N.readBits(12);var O=N.readBits(3);return U.numTemporalLayers=Math.max(U.numTemporalLayers||0,O+1),N.readBits(17),j._parseProfileTierLevel(N,O,U),U}},{key:"parseSPS",value:function F(K){var U=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};U=U||{};var N=new tY(K);N.readUByte(),N.readUByte(),N.readBits(4);var O=N.readBits(3);U.numTemporalLayers=Math.max(O+1,U.numTemporalLayers||0),U.temporalIdNested=N.readBits(1),j._parseProfileTierLevel(N,O,U),N.readUEG();var B=U.chromaFormatIdc=N.readUEG(),w=420;if(B<=3)w=[0,420,422,444][B];var R=0;if(B===3)R=N.readBits(1);var P=N.readUEG(),x=N.readUEG(),k=N.readBits(1),f,l,s,Y0;if(k===1)f=N.readUEG(),l=N.readUEG(),s=N.readUEG(),Y0=N.readUEG();if(U.bitDepthLumaMinus8=N.readUEG(),U.bitDepthChromaMinus8=N.readUEG(),k===1){var t=(B===1||B===2)&&R===0?2:1,K0=B===1&&R===0?2:1;P-=t*(l+f),x-=K0*(Y0+s)}return{codec:"hev1.1.6.L93.B0",width:P,height:x,chromaFormat:w,hvcC:U}}},{key:"_parseProfileTierLevel",value:function F(K,U,N){var O=N.generalTierFlag||0;N.generalProfileSpace=K.readBits(2),N.generalTierFlag=Math.max(K.readBits(1),O),N.generalProfileIdc=Math.max(K.readBits(5),N.generalProfileIdc||0),N.generalProfileCompatibilityFlags=K.readBits(32),N.generalConstraintIndicatorFlags=[K.readBits(8),K.readBits(8),K.readBits(8),K.readBits(8),K.readBits(8),K.readBits(8)];var B=K.readBits(8);if(O<N.generalTierFlag)N.generalLevelIdc=B;else N.generalLevelIdc=Math.max(B,N.generalLevelIdc||0);var w=[],R=[];if(U>K.bitsAvailable)throw new Error("maxSubLayersMinus inavlid size ".concat(U));for(var P=0;P<U;P++)w[P]=K.readBits(1),R[P]=K.readBits(1);if(U>0)K.readBits((8-U)*2);for(var x=0;x<U;x++){if(w[x]!==0)K.readBits(2),K.readBits(1),K.readBits(5),K.readBits(16),K.readBits(16),K.readBits(4),K.readBits(16),K.readBits(16),K.readBits(12);if(R[x]!==0)K.readBits(8)}}}]),j}();var pQ=function(){function j(){I0(this,j)}return L0(j,null,[{key:"decode",value:function F(K){var U=[],N=K,O=0,B=K.length;while(O<B){if(N[O]<128){U.push(String.fromCharCode(N[O])),++O;continue}else if(N[O]<192);else if(N[O]<224){if(j._checkContinuation(N,O,1)){var w=(N[O]&31)<<6|N[O+1]&63;if(w>=128){U.push(String.fromCharCode(w&65535)),O+=2;continue}}}else if(N[O]<240){if(j._checkContinuation(N,O,2)){var R=(N[O]&15)<<12|(N[O+1]&63)<<6|N[O+2]&63;if(R>=2048&&(R&63488)!==55296){U.push(String.fromCharCode(R&65535)),O+=3;continue}}}else if(N[O]<248){if(j._checkContinuation(N,O,3)){var P=(N[O]&7)<<18|(N[O+1]&63)<<12|(N[O+2]&63)<<6|N[O+3]&63;if(P>65536&&P<1114112){P-=65536,U.push(String.fromCharCode(P>>>10|55296)),U.push(String.fromCharCode(P&1023|56320)),O+=4;continue}}}U.push(String.fromCharCode(65533)),++O}return U.join("")}},{key:"_checkContinuation",value:function F(K,U,N){var O=K;if(U+N<O.length){while(N--)if((O[++U]&192)!==128)return!1;return!0}else return!1}}]),j}();var n8=function(){function j(){I0(this,j)}return L0(j,null,[{key:"parse",value:function F(K){if(K.length<3)return;var U={},N=j._parseValue(new DataView(K.buffer,K.byteOffset,K.byteLength)),O=j._parseValue(new DataView(K.buffer,K.byteOffset+N.size,K.byteLength-N.size));return U[N.data]=O.data,U}},{key:"_parseValue",value:function F(K){var U=K.byteLength,N=K.getUint8(0),O=1,B=!1,w;switch(N){case 0:w=K.getFloat64(1),O+=8;break;case 1:{w=!!K.getUint8(1),O+=1;break}case 2:{var R=j._parseString(new DataView(K.buffer,K.byteOffset+O,K.byteLength-O)),P=R.data,x=R.size;w=P,O+=x}break;case 3:{w={};var k=0;if((K.getUint32(U-4)&16777215)===9)k=3;while(O<U-4){var f=j._parseObject(new DataView(K.buffer,K.byteOffset+O,K.byteLength-O-k)),l=f.size,s=f.data,Y0=f.isEnd;if(Y0)break;w[s.name]=s.value,O+=l}if(O<=U-3){var t=K.getUint32(O-1)&16777215;if(t===9)O+=3}}break;case 8:{w={},O+=4;var K0=0;if((K.getUint32(U-4)&16777215)===9)K0=3;while(O<U-8){var q0=j._parseObject(new DataView(K.buffer,K.byteOffset+O,K.byteLength-O-K0)),R0=q0.size,U0=q0.data,W0=q0.isEnd;if(W0)break;w[U0.name]=U0.value,O+=R0}if(O<=U-3){var z0=K.getUint32(O-1)&16777215;if(z0===9)O+=3}}break;case 9:w=void 0,O=1,B=!0;break;case 10:{w=[];var h0=K.getUint32(1);O+=4;for(var l0=0;l0<h0;l0++){var E0=j._parseValue(new DataView(K.buffer,K.byteOffset+O,K.byteLength-O)),y0=E0.data,t0=E0.size;w.push(y0),O+=t0}}break;case 11:{var T=K.getFloat64(O)+K.getInt16(O+8)*60000;w=new Date(T),O+=10}break;case 12:{var u=K.getUint32(1);if(O+=4,w="",u>0)w=pQ.decode(new Uint8Array(K.buffer,K.byteOffset+O,u));O+=u}break;default:O=U;break}return{data:w,size:O,isEnd:B}}},{key:"_parseString",value:function F(K){var U=K.getUint16(0),N="";if(U>0)N=pQ.decode(new Uint8Array(K.buffer,K.byteOffset+2,U));return{data:N,size:2+U}}},{key:"_parseObject",value:function F(K){if(K.byteLength<3)return;var U=j._parseString(K),N=j._parseValue(new DataView(K.buffer,K.byteOffset+U.size,K.byteLength-U.size));return{data:{name:U.data,value:N.data},size:U.size+N.size,isEnd:N.isEnd}}}]),j}();var c1={MP3:2,G711A:7,G711M:8,AAC:10,OPUS:13};var l1=new AY("FlvDemuxer"),xJ=function(){function j(F,K,U){I0(this,j),a(this,"_headerParsed",!1),a(this,"_remainingData",null),a(this,"_gopId",0),a(this,"_needAddMetaBeforeKeyFrameNal",!0),this.videoTrack=F||new S8,this.audioTrack=K||new P8,this.metadataTrack=U||new h8,this._fixer=new f8(this.videoTrack,this.audioTrack,this.metadataTrack)}return L0(j,[{key:"demux",value:function F(K){var U,N=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,O=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,B=arguments.length>3?arguments[3]:void 0,w=this.audioTrack,R=this.videoTrack,P=this.metadataTrack;if(N||!O)this._remainingData=null;if(N)this._headerParsed=!1;if(N)R.reset(),w.reset(),P.reset();else if(R.samples=[],w.samples=[],P.seiSamples=[],P.flvScriptSamples=[],R.warnings=[],w.warnings=[],this._remainingData)K=S1(this._remainingData,K),this._remainingData=null;if(!K.length)return{videoTrack:R,audioTrack:w,metadataTrack:P};var x=0;if(!this._headerParsed){if(!j.probe(K))throw new Error("Invalid flv file");w.present=(K[4]&4)>>>2!==0,R.present=(K[4]&1)!==0,this._headerParsed=!0,x=PY(K,5)+4}var k=K.length,f,l,s,Y0,t;while(x+15<k){if(f=K[x],l=K[x+1]<<16|K[x+2]<<8|K[x+3],x+15+l>k)break;if(s=(K[x+7]<<24>>>0)+(K[x+4]<<16)+(K[x+5]<<8)+K[x+6],x+=11,Y0=K.subarray(x,x+l),f===8)this._parseAudio(Y0,s);else if(f===9){if(B)this.seamlessLoadingSwitching=!0;this._parseVideo(Y0,s)}else if(f===18)this._parseScript(Y0,s);else l1.warn("Invalid tag type: ".concat(f));if(x+=l,t=PY(K,x),t!==11+l)l1.warn("Invalid PrevTagSize ".concat(t," (").concat(11+l,")"));x+=4}if(x<k)this._remainingData=K.subarray(x);if(w.formatTimescale=R.formatTimescale=R.timescale=P.timescale=1000,w.timescale=w.codecType===o0.OPUS?1000:w.sampleRate||0,!w.exist()&&w.hasSample())w.reset();if(!R.exist()&&R.hasSample())R.reset();var K0=P.flvScriptSamples[P.flvScriptSamples.length-1],q0=K0===null||K0===void 0?void 0:(U=K0.data)===null||U===void 0?void 0:U.onMetaData;if(q0){if(R!==null&&R!==void 0&&R.exist()){if(q0.hasOwnProperty("duration"))R.duration=q0.duration*1000;if(q0.hasOwnProperty("width")&&q0.hasOwnProperty("height"))R.width=q0.width,R.height=q0.height}if(w!==null&&w!==void 0&&w.exist()){if(q0.hasOwnProperty("duration"))w.duration=q0.duration*1000}}return{videoTrack:R,audioTrack:w,metadataTrack:P}}},{key:"fix",value:function F(K,U,N){return this._fixer.fix(K,U,N),{videoTrack:this.videoTrack,audioTrack:this.audioTrack,metadataTrack:this.metadataTrack}}},{key:"demuxAndFix",value:function F(K,U,N,O,B){return this.demux(K,U,N,B),this.fix(O,U,N)}},{key:"_parseAudio",value:function F(K,U){if(!K.length)return;var N=(K[0]&240)>>>4,O=this.audioTrack;if(N!==c1.AAC&&N!==c1.G711A&&N!==c1.G711M&&N!==c1.OPUS){l1.warn("Unsupported sound format: ".concat(N)),O.reset();return}if(N!==c1.AAC&&N!==c1.OPUS){var B=(K[0]&12)>>2,w=(K[0]&2)>>1,R=K[0]&1;O.sampleRate=j.AUDIO_RATE[B],O.sampleSize=w?16:8,O.channelCount=R+1}switch(N){case c1.G711A:case c1.G711M:this._parseG711(K,U,N);break;case c1.AAC:this._parseAac(K,U);break;case c1.OPUS:this._parseOpus(K,U);break}}},{key:"_parseOpus",value:function F(K,U){var N=this.audioTrack,O=K[1];switch(N.codecType=o0.OPUS,O){case 0:{var B=aY.parseHeaderPackets(K.subarray(2));if(B)N.codec=B.codec,N.channelCount=B.channelCount,N.sampleRate=B.sampleRate,N.config=B.config,N.sampleDuration=aY.getFrameDuration([],N.timescale);else N.reset(),l1.warn("Cannot parse AudioSpecificConfig",K);break}case 1:{if(U===void 0||U===null)return;var w=new DY(U,K.subarray(2),N.sampleDuration);N.samples.push(w);break}default:l1.warn("Unknown OpusPacketType: ".concat(O))}}},{key:"_parseG711",value:function F(K,U,N){var O=this.audioTrack,B=K.subarray(1);if(B.byteLength<1)return;var w=new DY(U,B);O.codecType=N===7?o0.G711PCMA:o0.G711PCMU,O.sampleRate=8000,O.codec=O.codecType,O.samples.push(w)}},{key:"_parseAac",value:function F(K,U){var N=this.audioTrack;if(N.codecType=o0.AAC,K[1]===0){var O=SY.parseAudioSpecificConfig(K.subarray(2));if(O)N.codec=O.codec,N.channelCount=O.channelCount,N.sampleRate=O.sampleRate,N.config=O.config,N.objectType=O.objectType,N.sampleRateIndex=O.samplingFrequencyIndex;else N.reset(),l1.warn("Cannot parse AudioSpecificConfig",K)}else if(K[1]===1){if(U===void 0||U===null)return;N.samples.push(new DY(U,K.subarray(2)))}else l1.warn("Unknown AACPacketType: ".concat(K[1]))}},{key:"_parseVideo",value:function F(K,U){var N=this;if(K.length<6)return;var O=(K[0]&240)>>>4,B=K[0]&15,w=this.videoTrack;if(B!==7&&B!==12){w.reset(),l1.warn("Unsupported codecId: ".concat(B));return}var R=B===12;w.codecType=R?YY.HEVC:YY.AVC;var P=K[1],x=(K[2]<<16|K[3]<<8|K[4])<<8>>8;if(P===0){var k=K.subarray(5),f=R?d8.parseHEVCDecoderConfigurationRecord(k):l8.parseAVCDecoderConfigurationRecord(k);if(f){var{hvcC:l,sps:s,ppsArr:Y0,spsArr:t,vpsArr:K0,nalUnitSize:q0}=f;if(l)w.hvcC=w.hvcC||l;if(s)w.codec=s.codec,w.width=s.width,w.height=s.height,w.sarRatio=s.sarRatio,w.fpsNum=s.fpsNum,w.fpsDen=s.fpsDen;if(t.length)w.sps=t;if(Y0.length)w.pps=Y0;if(K0&&K0.length)w.vps=K0;if(q0)w.nalUnitSize=q0}else l1.warn("Cannot parse ".concat(R?"HEVC":"AVC","DecoderConfigurationRecord"),K)}else if(P===1){var R0=JY.parseAvcC(K.subarray(5),w.nalUnitSize);if(R0=this._checkAddMetaNalToUnits(R,R0,w),R0&&R0.length){var U0=new y8(U+x,U,R0);if(this.seamlessLoadingSwitching&&U<w.lastKeyFrameDts)return;if(this.seamlessLoadingSwitching=!1,O===1)U0.setToKeyframe(),w.lastKeyFrameDts=U;if(w.samples.push(U0),R0.forEach(function(W0){var z0=R?W0[0]>>>1&63:W0[0]&31;switch(z0){case 5:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:if(!R&&z0!==5||R&&z0===5)break;U0.setToKeyframe();break;case 6:case 39:case 40:if(!R&&z0!==6||R&&z0===6)break;N.metadataTrack.seiSamples.push(new v8(JY.parseSEI(JY.removeEPB(W0),R),U+x));break}}),U0.keyframe)this._gopId++;U0.gopId=this._gopId}else l1.warn("Cannot parse NALUs",K)}else if(P===2);else l1.warn("Unknown AVCPacketType: ".concat(P))}},{key:"_checkAddMetaNalToUnits",value:function F(K,U,N){if(!K||!this._needAddMetaBeforeKeyFrameNal)return this._needAddMetaBeforeKeyFrameNal=!1,U;var O=U.map(function(B){return B[0]>>>1&63});if(O.includes(32))return this._needAddMetaBeforeKeyFrameNal=!1,U;return U.unshift(N.pps[0]),U.unshift(N.sps[0]),U.unshift(N.vps[0]),U.filter(Boolean)}},{key:"_parseScript",value:function F(K,U){this.metadataTrack.flvScriptSamples.push(new x8(n8.parse(K),U))}}],[{key:"probe",value:function F(K){if(K[0]!==70||K[1]!==76||K[2]!==86||K[3]!==1)return!1;return PY(K,5)>=9}}]),j}();a(xJ,"AUDIO_RATE",[5500,11000,22000,44000]);function XW(j){var F=0;for(var K=arguments.length,U=new Array(K>1?K-1:0),N=1;N<K;N++)U[N-1]=arguments[N];U.forEach(function(w){F+=w.length});var O=new j(F),B=0;return U.forEach(function(w){O.set(w,B),B+=w.length}),O}var N1=function(){function j(){I0(this,j),this.buffer=new Uint8Array(0)}return L0(j,[{key:"write",value:function F(){var K=this;for(var U=arguments.length,N=new Array(U),O=0;O<U;O++)N[O]=arguments[O];N.forEach(function(B){if(B)K.buffer=XW(Uint8Array,K.buffer,B);else window.console.warn(B)})}}],[{key:"writeUint16",value:function F(K){return new Uint8Array([K>>8&255,K&255])}},{key:"writeUint32",value:function F(K){return new Uint8Array([K>>24,K>>16&255,K>>8&255,K&255])}}]),j}();var o8=Math.pow(2,32)-1,b0=function(){function j(){I0(this,j)}return L0(j,null,[{key:"box",value:function F(K){for(var U=arguments.length,N=new Array(U>1?U-1:0),O=1;O<U;O++)N[O-1]=arguments[O];N=N.filter(Boolean);var B=8+N.reduce(function(P,x){return P+x.byteLength},0),w=new Uint8Array(B);w[0]=B>>24&255,w[1]=B>>16&255,w[2]=B>>8&255,w[3]=B&255,w.set(K,4);var R=8;return N.forEach(function(P){w.set(P,R),R+=P.byteLength}),w}},{key:"ftyp",value:function F(K){var U=K.find(function(N){return N.type===f1.VIDEO&&N.codecType===YY.HEVC});return U?j.FTYPHEV1:j.FTYPAVC1}},{key:"initSegment",value:function F(K){var U=j.ftyp(K),N=S1(U,j.moov(K));return N}},{key:"pssh",value:function F(K){var U=new Uint8Array([1,0,0,0].concat([16,119,239,236,192,178,77,2,172,227,60,30,82,226,251,75],[0,0,0,1],_Q(K.kid),[0,0,0,0]));return j.box(j.types.pssh,U)}},{key:"moov",value:function F(K){if(K[0].useEME&&(K[0].encv||K[0].enca)){if(!K[0].pssh)K[0].pssh={kid:K[0].kid};var U=this.pssh(K[0].pssh);return j.box.apply(j,[j.types.moov,j.mvhd(K[0].mvhdDurtion||K[0].duration,K[0].mvhdTimecale||K[0].timescale),j.mvex(K)].concat(p1(K.map(function(N){return j.trak(N)})),[U]))}else return j.box.apply(j,[j.types.moov,j.mvhd(K[0].mvhdDurtion||K[0].duration,K[0].mvhdTimecale||K[0].timescale)].concat(p1(K.map(function(N){return j.trak(N)})),[j.mvex(K)]))}},{key:"mvhd",value:function F(K){var U=arguments.length>1&&arguments[1]!==void 0?arguments[1]:90000,N=j.box(j.types.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,U>>24&255,U>>16&255,U>>8&255,U&255,K>>24&255,K>>16&255,K>>8&255,K&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]));return N}},{key:"trak",value:function F(K){var U=j.box(j.types.trak,j.tkhd(K.id,K.tkhdDuration||0,K.width,K.height),j.mdia(K));return U}},{key:"tkhd",value:function F(K,U){var N=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,O=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,B=j.box(j.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,K>>24&255,K>>16&255,K>>8&255,K&255,0,0,0,0,U>>24&255,U>>16&255,U>>8&255,U&255,0,0,0,0,0,0,0,0,0,0,0,0,1,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,N>>8&255,N&255,0,0,O>>8&255,O&255,0,0]));return B}},{key:"mdia",value:function F(K){var U=j.box(j.types.mdia,j.mdhd(K.duration,K.timescale),j.hdlr(K.type),j.minf(K));return U}},{key:"mdhd",value:function F(K){var U=arguments.length>1&&arguments[1]!==void 0?arguments[1]:90000,N=j.box(j.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,U>>24&255,U>>16&255,U>>8&255,U&255,K>>24&255,K>>16&255,K>>8&255,K&255,85,196,0,0]));return N}},{key:"hdlr",value:function F(K){var U=j.box(j.types.hdlr,j.HDLR_TYPES[K]);return U}},{key:"minf",value:function F(K){var U=j.box(j.types.minf,K.type===f1.VIDEO?j.VMHD:j.SMHD,j.DINF,j.stbl(K));return U}},{key:"stbl",value:function F(K){var U=[];if(K&&K.ext)K.ext.stss&&U.push(j.stss(K.ext.stss.entries));var N=j.box(j.types.stbl,j.stsd(K),j.STTS,U[0],j.STSC,j.STSZ,j.STCO);return N}},{key:"stsd",value:function F(K){var U;if(K.type==="audio")if(K.useEME&&K.enca)U=j.enca(K);else if(K.codecType===o0.OPUS)U=j.opus(K);else U=j.mp4a(K);else if(K.useEME&&K.encv)U=j.encv(K);else if(K.av1C)U=j.av01(K);else U=j.avc1hev1(K);var N=j.box(j.types.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),U);return N}},{key:"enca",value:function F(K){var U=K.enca.channelCount,N=K.enca.sampleRate,O=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,U,0,16,0,0,0,0,N>>8&255,N&255,0,0]),B=j.esds(K.config),w=j.sinf(K.enca);return j.box(j.types.enca,O,B,w)}},{key:"encv",value:function F(K){var U,N,O=K.sps.length>0?K.sps[0]:[],B=K.pps.length>0?K.pps[0]:[],w=K.width,R=K.height,P=K.sarRatio[0],x=K.sarRatio[1],k=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,R>>8&255,R&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]),f=new Uint8Array((U=(N=[1,O[1],O[2],O[3],255,225,O.length>>>8&255,O.length&255]).concat.apply(N,p1(O)).concat([1,B.length>>>8&255,B.length&255])).concat.apply(U,p1(B))),l=new Uint8Array([0,0,88,57,0,15,200,192,0,4,86,72]),s=j.sinf(K.encv),Y0=new Uint8Array([P>>24,P>>16&255,P>>8&255,P&255,x>>24,x>>16&255,x>>8&255,x&255]);return j.box(j.types.encv,k,j.box(j.types.avcC,f),j.box(j.types.btrt,l),s,j.box(j.types.pasp,Y0))}},{key:"schi",value:function F(K){var U=new Uint8Array([]),N=j.tenc(K);return j.box(j.types.schi,U,N)}},{key:"tenc",value:function F(K){var U=new Uint8Array([0,0,0,0,0,0,K.default_IsEncrypted&255,K.default_IV_size&255].concat(_Q(K.default_KID)));return j.box(j.types.tenc,U)}},{key:"sinf",value:function F(K){var U=new Uint8Array([]),N=new Uint8Array([K.data_format.charCodeAt(0),K.data_format.charCodeAt(1),K.data_format.charCodeAt(2),K.data_format.charCodeAt(3)]),O=new Uint8Array([0,0,0,0,99,101,110,99,0,1,0,0]),B=j.schi(K);return j.box(j.types.sinf,U,j.box(j.types.frma,N),j.box(j.types.schm,O),B)}},{key:"av01",value:function F(K){return j.box(j.types.av01,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,K.width>>8&255,K.width&255,K.height>>8&255,K.height&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,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,0,0,0,0,0,0,24,17,17]),K.av1C,K.colr)}},{key:"avc1hev1",value:function F(K){var U=K.codecType===YY.HEVC,N=U?j.types.hvc1:j.types.avc1,O=U?j.hvcC(K):j.avcC(K),B=[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,K.width>>8&255,K.width&255,K.height>>8&255,K.height&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,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,0,0,0,0,0,0,24,17,17]),O];if(U)B.push(j.box(j.types.fiel,new Uint8Array([1,0])));else if(K.sarRatio&&K.sarRatio.length>1)B.push(j.pasp(K.sarRatio));return j.box.apply(j,[N].concat(B))}},{key:"avcC",value:function F(K){var U,N,O=[],B=[],w;return K.sps.forEach(function(R){w=R.byteLength,O.push(w>>>8&255),O.push(w&255),O.push.apply(O,p1(R))}),K.pps.forEach(function(R){w=R.byteLength,B.push(w>>>8&255),B.push(w&255),B.push.apply(B,p1(R))}),j.box(j.types.avcC,new Uint8Array((U=(N=[1,O[3],O[4],O[5],255,224|K.sps.length]).concat.apply(N,O).concat([K.pps.length])).concat.apply(U,B)))}},{key:"hvcC",value:function F(K){var U=K.hvcC;if(U instanceof ArrayBuffer||U instanceof Uint8Array)return U;var{vps:N,sps:O,pps:B}=K,w;if(U){var{generalProfileCompatibilityFlags:R,generalConstraintIndicatorFlags:P}=U,x=(N.length&&1)+(O.length&&1)+(B.length&&1);w=[1,U.generalProfileSpace<<6|U.generalTierFlag<<5|U.generalProfileIdc,R>>>24,R>>>16,R>>>8,R,P[0],P[1],P[2],P[3],P[4],P[5],U.generalLevelIdc,240,0,252,U.chromaFormatIdc|252,U.bitDepthLumaMinus8|248,U.bitDepthChromaMinus8|248,0,0,U.numTemporalLayers<<3|U.temporalIdNested<<2|3,x];var k=function f(l){var s;w.push(l.length>>8,l.length),(s=w).push.apply(s,p1(l))};if(N.length)w.push(160,0,N.length),N.forEach(k);if(O.length)w.push(161,0,O.length),O.forEach(k);if(B.length)w.push(162,0,B.length),B.forEach(k)}else w=[1,1,96,0,0,0,144,0,0,0,0,0,93,240,0,252,253,248,248,0,0,15,3,160,0,1,0,24,64,1,12,1,255,255,1,96,0,0,3,0,144,0,0,3,0,0,3,0,93,153,152,9,161,0,1,0,45,66,1,1,1,96,0,0,3,0,144,0,0,3,0,0,3,0,93,160,2,128,128,45,22,89,153,164,147,43,154,128,128,128,130,0,0,3,0,2,0,0,3,0,50,16,162,0,1,0,7,68,1,193,114,180,98,64];return j.box(j.types.hvcC,new Uint8Array(w))}},{key:"pasp",value:function F(K){var U=M8(K,2),N=U[0],O=U[1];return j.box(j.types.pasp,new Uint8Array([N>>24,N>>16&255,N>>8&255,N&255,O>>24,O>>16&255,O>>8&255,O&255]))}},{key:"mp4a",value:function F(K){return j.box(j.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,K.channelCount,0,16,0,0,0,0,K.sampleRate>>8&255,K.sampleRate&255,0,0]),K.config.length?j.esds(K.config):void 0)}},{key:"esds",value:function F(K){var U=K.length,N=j.box(j.types.esds,new Uint8Array([0,0,0,0,3,23+U,0,0,0,4,15+U,64,21,0,6,0,0,0,218,192,0,0,218,192,5].concat([U]).concat(K).concat([6,1,2])));return N}},{key:"opus",value:function F(K){var U=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,K.channelCount,0,16,0,0,0,0,K.sampleRate>>8&255,K.sampleRate&255,0,0]),N=K.config.length?j.dOps(K):[];return j.box(j.types.Opus,U,N)}},{key:"dOps",value:function F(K){if(K.config)return K.config[4]=K.sampleRate>>>24&255,K.config[5]=K.sampleRate>>>16&255,K.config[6]=K.sampleRate>>>8&255,K.config[7]=K.sampleRate&255,j.box(j.types.dOps,K.config)}},{key:"mvex",value:function F(K){var U=j.box.apply(j,[j.types.mvex].concat(p1(K.map(function(N){return j.trex(N.id)}))));return U}},{key:"trex",value:function F(K){var U=j.box(j.types.trex,new Uint8Array([0,0,0,0,K>>24,K>>16&255,K>>8&255,K&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]));return U}},{key:"trex1",value:function F(K){var U=j.box(j.types.trex,new Uint8Array([0,0,0,0,K>>24,K>>16&255,K>>8&255,K&255,0,0,0,1,0,0,2,0,0,0,0,0,0,1,0,0]));return U}},{key:"trex2",value:function F(K){var U=j.box(j.types.trex,new Uint8Array([0,0,0,0,K>>24,K>>16&255,K>>8&255,K&255,0,0,0,1,0,0,4,0,0,0,0,0,2,0,0,0]));return U}},{key:"moof",value:function F(K){var U=j.box.apply(j,[j.types.moof,j.mfhd(K[0].samples?K[0].samples[0].gopId:0)].concat(p1(K.map(function(N){return j.traf(N)}))));return U}},{key:"mfhd",value:function F(K){var U=j.box(j.types.mfhd,new Uint8Array([0,0,0,0,K>>24,K>>16&255,K>>8&255,K&255]));return U}},{key:"traf",value:function F(K){var U=j.tfhd(K.id),N=j.tfdt(K,K.baseMediaDecodeTime),O=0,B;if(K.isVideo&&K.videoSenc)B=K.videoSenc,B.forEach(function(u){if(O=O+8,u.subsamples&&u.subsamples.length)O=O+2,O=O+u.subsamples.length*6});if(K.videoSencLength=O,!K.useEME||!K.isVideoEncryption&&!K.isAudioEncryption){var w=j.sdtp(K),R=76;return j.box(j.types.traf,U,N,w,j.trun(K.samples,w.byteLength+R))}else if(K.isVideoEncryption)if(K.isVideo){var P=j.saiz(K),x=j.saio(K),k=j.trun1(K),f=j.senc(K),l=j.box(j.types.traf,U,N,P,x,k,f);return l}else if(!K.isAudioEncryption){var s=j.sbgp(),Y0=j.trun1(K);return j.box(j.types.traf,U,N,s,Y0)}else{var t=j.sbgp(),K0=j.saiz(K),q0=j.saio(K),R0=j.senc(K),U0=j.trun1(K),W0=j.box(j.types.traf,U,N,t,K0,q0,R0,U0);return W0}else if(K.isVideo){var z0=j.trun1(K);return j.box(j.types.traf,U,N,z0)}else{var h0=j.sbgp(),l0=j.saiz(K),E0=j.saio(K),y0=j.senc(K),t0=j.trun1(K),T=j.box(j.types.traf,U,N,h0,l0,E0,y0,t0);return T}}},{key:"sdtp",value:function F(K){var U=new N1;return K.samples.forEach(function(N){U.write(new Uint8Array(K.isVideo?[N.keyframe?32:16]:[16]))}),j.box(j.types.sdtp,this.extension(0,0),U.buffer)}},{key:"trun1",value:function F(K){var U=new N1,N=N1.writeUint32(K.samples.length),O=null;if(K.isVideo){var B=K.videoSencLength;if(O=N1.writeUint32(K.samples.length*16+B+149),!K.isVideoEncryption&&K.isAudioEncryption)O=N1.writeUint32(K.samples.length*16+92)}else{var w=K.samples.length*12+124;if(K.isAudioEncryption)w=K.samples.length*12+8*K.audioSenc.length+177;O=N1.writeUint32(w)}return K.samples.forEach(function(R){if(U.write(N1.writeUint32(R.duration)),U.write(N1.writeUint32(R.size)),U.write(N1.writeUint32(R.keyframe?33554432:65536)),K.isVideo)U.write(N1.writeUint32(R.cts?R.cts:0))}),j.box(j.types.trun,this.extension(0,K.flags),N,O,U.buffer)}},{key:"senc",value:function F(K){var U=new N1,N=K.samples.length,O=K.isVideo?16:8,B=K.isVideo?2:0,w=[],R=0;if(K.isVideo)w=K.videoSenc,R=K.videoSencLength;else w=K.audioSenc;return R=R||O*N,U.write(N1.writeUint32(16+R),j.types.senc,this.extension(0,B)),U.write(N1.writeUint32(N)),w.forEach(function(P){for(var x=0;x<P.InitializationVector.length;x++)U.write(new Uint8Array([P.InitializationVector[x]]));if(P.subsamples&&P.subsamples.length)U.write(N1.writeUint16(P.subsamples.length)),P.subsamples.forEach(function(k){U.write(N1.writeUint16(k.BytesOfClearData)),U.write(N1.writeUint32(k.BytesOfProtectedData))})}),U.buffer}},{key:"saio",value:function F(K){var U=K.samples.length*12+141;if(!K.isVideo&&K.isAudioEncryption)U=149;var N=new Uint8Array([1,0,0,0,0,0,0,1,0,0,0,0,U>>24&255,U>>16&255,U>>8&255,U&255]);return j.box(j.types.saio,N)}},{key:"saiz",value:function F(K){var U=K.samples.length,N=new Uint8Array([0,0,0,0,16,U>>24&255,U>>16&255,U>>8&255,U&255]);return j.box(j.types.saiz,N)}},{key:"sbgp",value:function F(){var K=new Uint8Array([114,111,108,108,0,0,0,1,0,0,1,25,0,0,0,1]);return j.box(j.types.sbgp,this.extension(0,0),K)}},{key:"extension",value:function F(K,U){return new Uint8Array([K,U>>16&255,U>>8&255,U&255])}},{key:"tfhd",value:function F(K){return j.box(j.types.tfhd,new Uint8Array([0,0,0,0,K>>24,K>>16&255,K>>8&255,K&255]))}},{key:"tfdt",value:function F(K,U){var N=Math.floor(U/(o8+1)),O=Math.floor(U%(o8+1));if(K.useEME&&(K.isVideoEncryption||K.isAudioEncryption))return j.box(j.types.tfdt,new Uint8Array([0,0,0,0,O>>24,O>>16&255,O>>8&255,O&255]));else return j.box(j.types.tfdt,new Uint8Array([1,0,0,0,N>>24,N>>16&255,N>>8&255,N&255,O>>24,O>>16&255,O>>8&255,O&255]))}},{key:"trun",value:function F(K,U){var N=K.length,O=12+16*N;U+=8+O;var B=new Uint8Array(O);B.set([0,0,15,1,N>>>24&255,N>>>16&255,N>>>8&255,N&255,U>>>24&255,U>>>16&255,U>>>8&255,U&255],0);for(var w=0;w<N;w++){var R=K[w],P=R.duration,x=R.size,k=R.flag,f=k===void 0?{}:k,l=R.cts,s=l===void 0?0:l;B.set([P>>>24&255,P>>>16&255,P>>>8&255,P&255,x>>>24&255,x>>>16&255,x>>>8&255,x&255,f.isLeading<<2|(f.dependsOn===null||f.dependsOn===void 0?1:f.dependsOn),f.isDependedOn<<6|f.hasRedundancy<<4|f.paddingValue<<1|(f.isNonSyncSample===null||f.isNonSyncSample===void 0?1:f.isNonSyncSample),f.degradationPriority&61440,f.degradationPriority&15,s>>>24&255,s>>>16&255,s>>>8&255,s&255],12+16*w)}return j.box(j.types.trun,B)}},{key:"moovMP4",value:function F(K){return j.box.apply(j,[j.types.moov,j.mvhd(K[0].duration,K[0].timescale)].concat(p1(K.map(function(U){return j.trackMP4(U)}))))}},{key:"trackMP4",value:function F(K){return j.box(j.types.trak,j.tkhd(K.id,K.duration,K.width,K.height),j.mdiaMP4(K))}},{key:"mdiaMP4",value:function F(K){return j.box(j.types.mdia,j.mdhd(K.duration,K.timescale),j.hdlr(K.type),j.minfMP4(K))}},{key:"minfMP4",value:function F(K){return j.box(j.types.minf,K.type===f1.VIDEO?j.VMHD:j.SMHD,j.DINF,j.stblMP4(K))}},{key:"stblMP4",value:function F(K){var U=K.ext,N=[j.stsd(K),j.stts(U.stts),j.stsc(U.stsc),j.stsz(U.stsz),j.stco(U.stco)];if(U.stss.length)N.push(j.stss(U.stss));if(U.ctts.length)N.push(j.ctts(U.ctts));return j.box.apply(j,[j.types.stbl].concat(N))}},{key:"stts",value:function F(K){var U=K.length,N=new Uint8Array(8*U),O=0;return K.forEach(function(B){var{value:w,count:R}=B;N.set([R>>24,R>>16&255,R>>8&255,R&255,w>>24,w>>16&255,w>>8&255,w&255],O),O+=8}),j.box(j.types.stts,S1(new Uint8Array([0,0,0,0,U>>24,U>>16&255,U>>8&255,U&255]),N))}},{key:"stsc",value:function F(K){var U=K.length,N=new Uint8Array(12*U),O=0;return K.forEach(function(B){var{firstChunk:w,samplesPerChunk:R,sampleDescIndex:P}=B;N.set([w>>24,w>>16&255,w>>8&255,w&255,R>>24,R>>16&255,R>>8&255,R&255,P>>24,P>>16&255,P>>8&255,P&255],O),O+=12}),j.box(j.types.stsc,S1(new Uint8Array([0,0,0,0,U>>24,U>>16&255,U>>8&255,U&255]),N))}},{key:"stsz",value:function F(K){var U=K.length,N=new Uint8Array(4*U),O=0;return K.forEach(function(B){N.set([B>>24,B>>16&255,B>>8&255,B&255],O),O+=4}),j.box(j.types.stsz,S1(new Uint8Array([0,0,0,0,0,0,0,0,U>>24,U>>16&255,U>>8&255,U&255]),N))}},{key:"stco",value:function F(K){var U=K.length,N=new Uint8Array(4*U),O=0;return K.forEach(function(B){N.set([B>>24,B>>16&255,B>>8&255,B&255],O),O+=4}),j.box(j.types.stco,S1(new Uint8Array([0,0,0,0,U>>24,U>>16&255,U>>8&255,U&255]),N))}},{key:"stss",value:function F(K){var U=K.length,N=new Uint8Array(4*U),O=0;return K.forEach(function(B){N.set([B>>24,B>>16&255,B>>8&255,B&255],O),O+=4}),j.box(j.types.stss,S1(new Uint8Array([0,0,0,0,U>>24,U>>16&255,U>>8&255,U&255]),N))}},{key:"ctts",value:function F(K){var U=K.length,N=new Uint8Array(8*U),O=0;return K.forEach(function(B){var{value:w,count:R}=B;N.set([R>>24,R>>16&255,R>>8&255,R&255,w>>24,w>>16&255,w>>8&255,w&255],O),O+=8}),j.box(j.types.ctts,S1(new Uint8Array([0,0,0,0,U>>24,U>>16&255,U>>8&255,U&255]),N))}},{key:"styp",value:function F(){return j.box(j.types.styp,new Uint8Array([109,115,100,104,0,0,0,0,109,115,100,104,109,115,105,120]))}},{key:"sidx",value:function F(K){var U=K.timescale,N=K.samples[0].duration,O=N*K.samples.length,B=K.samples[0].sampleOffset*N,w=8;K.samples.forEach(function(f){w+=f.size});var R=0;if(K.isVideo){var P=0,x;if(K.videoSenc)x=K.videoSenc;if(K.isVideo)x.forEach(function(f){if(P=P+8,f.subsamples&&f.subsamples.length)P=P+2,P=P+f.subsamples.length*6});if(K.videoSencLength=P,R=w+141+K.samples.length*16+P,K.useEME&&K.isAudioEncryption&&!K.isVideoEncryption)R=w+K.samples.length*16+84}else if(R=w+116+K.samples.length*12,K.useEME&&K.isAudioEncryption)R=w+169+K.samples.length*12+8*K.audioSenc.length;var k=new Uint8Array([0,0,0,0,0,0,0,K.id&255,U>>24&255,U>>16&255,U>>8&255,U&255,B>>24&255,B>>16&255,B>>8&255,B&255,0,0,0,0,0,0,0,1,0,R>>16&255,R>>8&255,R&255,O>>24&255,O>>16&255,O>>8&255,O&255,144,0,0,0]);return j.box(j.types.sidx,k)}},{key:"mdat",value:function F(K){var U=j.box(j.types.mdat,K);return U}}]),j}();a(b0,"types",["Opus","dOps","av01","av1C","avc1","avcC","hvc1","hvcC","dinf","dref","esds","ftyp","hdlr","mdat","mdhd","mdia","mfhd","minf","moof","moov","mp4a","mvex","mvhd","pasp","stbl","stco","stsc","stsd","stsz","stts","tfdt","tfhd","traf","trak","trex","tkhd","vmhd","smhd","ctts","stss","styp","pssh","sidx","sbgp","saiz","saio","senc","trun","encv","enca","sinf","btrt","frma","tenc","schm","schi","mehd","fiel","sdtp"].reduce(function(j,F){return j[F]=[F.charCodeAt(0),F.charCodeAt(1),F.charCodeAt(2),F.charCodeAt(3)],j},Object.create(null)));a(b0,"HDLR_TYPES",{video: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]),audio: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])});a(b0,"FTYPAVC1",b0.box(b0.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49])));a(b0,"FTYPHEV1",b0.box(b0.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,104,101,118,49])));a(b0,"DINF",b0.box(b0.types.dinf,b0.box(b0.types.dref,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]))));a(b0,"VMHD",b0.box(b0.types.vmhd,new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])));a(b0,"SMHD",b0.box(b0.types.smhd,new Uint8Array([0,0,0,0,0,0,0,0])));a(b0,"StblTable",new Uint8Array([0,0,0,0,0,0,0,0]));a(b0,"STTS",b0.box(b0.types.stts,b0.StblTable));a(b0,"STSC",b0.box(b0.types.stsc,b0.StblTable));a(b0,"STSZ",b0.box(b0.types.stsz,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0])));a(b0,"STCO",b0.box(b0.types.stco,b0.StblTable));var fQ=function(){function j(F,K){I0(this,j),this.name=F||"",this._prefix="[".concat(this.name,"]"),j.disabled=K}return L0(j,[{key:"debug",value:function F(){var K;if(j.disabled)return;for(var U=arguments.length,N=new Array(U),O=0;O<U;O++)N[O]=arguments[O];(K=console).debug.apply(K,[this._prefix].concat(N))}},{key:"log",value:function F(){var K;if(j.disabled)return;for(var U=arguments.length,N=new Array(U),O=0;O<U;O++)N[O]=arguments[O];(K=console).log.apply(K,[this._prefix].concat(N))}},{key:"warn",value:function F(){var K;if(j.disabled)return;for(var U=arguments.length,N=new Array(U),O=0;O<U;O++)N[O]=arguments[O];(K=console).warn.apply(K,[this._prefix].concat(N))}},{key:"error",value:function F(){var K;if(j.disabled)return;for(var U=arguments.length,N=new Array(U),O=0;O<U;O++)N[O]=arguments[O];(K=console).error.apply(K,[this._prefix].concat(N))}},{key:"table",value:function F(){var K;if(j.disabled)return;console.group(this._prefix),(K=console).table.apply(K,arguments),console.groupEnd()}}],[{key:"enable",value:function F(){j.disabled=!1}},{key:"disable",value:function F(){j.disabled=!0}}]),j}();a(fQ,"disabled",!0);var cQ=function(){function j(F,K,U){I0(this,j),this.videoTrack=F,this.audioTrack=K;var N=/Chrome\/([^.]+)/.exec(navigator.userAgent);this.forceFirstIDR=N&&Number(N[1])<50,this.log=new fQ("FMP4Remuxer",U&&U.openLog?!U.openLog:!0)}return L0(j,[{key:"remux",value:function F(){var K=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,U=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},N=this.videoTrack,O=this.audioTrack,B=N.exist(),w=O.exist(),R,P,x,k=[];if(K)if(U&&U.initMerge){if(B)k.push(this.videoTrack);if(w)k.push(this.audioTrack);x=b0.initSegment(k)}else{if(B)R=b0.initSegment([this.videoTrack]);if(w)P=b0.initSegment([this.audioTrack])}var f,l;if(B&&N.hasSample())f=this._remuxVideo();if(w&&O.hasSample())l=this._remuxAudio();return N.samples=[],O.samples=[],{initSegment:x,videoInitSegment:R,audioInitSegment:P,videoSegment:f,audioSegment:l}}},{key:"_remuxVideo",value:function F(){var K=this.videoTrack;if(this.forceFirstIDR)K.samples[0].flag={dependsOn:2,isNonSyncSample:0};var U=K.samples,N=/av01/.test(K.codec),O=0;if(N)U.forEach(function(R0){O+=R0.data.byteLength});else U.forEach(function(R0){O+=R0.units.reduce(function(U0,W0){return U0+W0.byteLength},0),O+=R0.units.length*4});var B=new Uint8Array(O);if(N)for(var w=0,R=U.length,P=0,x;w<R;w++)x=U[w],B.set(x.data,P),x.size=x.data.byteLength,P+=x.size;else{var k=new DataView(B.buffer),f=function R0(U0,W0){W0=U[l];var z0=0;W0.units.forEach(function(h0){k.setUint32(U0,h0.byteLength),U0+=4,B.set(h0,U0),U0+=h0.byteLength,z0+=4+h0.byteLength}),W0.size=z0,Y0=U0,t=W0};for(var l=0,s=U.length,Y0=0,t;l<s;l++)f(Y0,t)}var K0=b0.mdat(B),q0=b0.moof([K]);return S1(q0,K0)}},{key:"_remuxAudio",value:function F(){var K=this.audioTrack,U=new Uint8Array(K.samples.reduce(function(B,w){return B+w.size},0));K.samples.reduce(function(B,w){return U.set(w.data,B),B+w.size},0);var N=b0.mdat(U),O=b0.moof([K]);return S1(O,N)}},{key:"reset",value:function F(){this.videoTrack.reset(),this.audioTrack.reset()}}]),j}();var i8=function(){function j(){bY(this,j),F0(this,"_ttfb",0),F0(this,"_demuxStart",0),F0(this,"_demuxEnd",0),F0(this,"_demuxCost",0),F0(this,"_remuxStart",0),F0(this,"_remuxEnd",0),F0(this,"_remuxCost",0),F0(this,"_appendStart",0),F0(this,"_appendEnd",0),F0(this,"_appendCost",0)}return MY(j,[{key:"set",value:function F(K,U){this["_".concat(K)]=U}},{key:"start",value:function F(K){this["_".concat(K,"Start")]=Date.now()}},{key:"end",value:function F(K){this["_".concat(K,"End")]=Date.now(),this["_".concat(K,"Cost")]=this["_".concat(K,"Cost")]+(this["_".concat(K,"End")]-this["_".concat(K,"Start")])}},{key:"transferCost",get:function F(){return{ttfbCost:this._ttfb,demuxCost:this._demuxCost,remuxCost:this._remuxCost,appendCost:this._appendCost}}}]),j}(),QY={TTFB:"ttfb",DEMUX:"demux",REMUX:"remux",APPEND:"append"};var ZY=new D1("BufferService"),s8=function(){function j(F,K){var U=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(bY(this,j),F0(this,"flv",null),F0(this,"_demuxer",new xJ),F0(this,"_remuxer",null),F0(this,"_mse",null),F0(this,"_softVideo",null),F0(this,"_sourceCreated",!1),F0(this,"_needInitSegment",!0),F0(this,"_discontinuity",!0),F0(this,"_contiguous",!1),F0(this,"_initSegmentId",""),F0(this,"_cachedBuffer",null),F0(this,"_demuxStartTime",0),F0(this,"_opts",null),this.flv=F,this._opts=U,K)this._softVideo=K;else this._remuxer=new cQ(this._demuxer.videoTrack,this._demuxer.audioTrack),this._mse=new NY(null,{preferMMS:typeof U.preferMMS==="boolean"?U.preferMMS:!!U.perferMMS}),this._mse.bindMedia(F.media)}return MY(j,[{key:"baseDts",get:function F(){var K,U;return(K=this._demuxer)===null||K===void 0?void 0:(U=K._fixer)===null||U===void 0?void 0:U._baseDts}},{key:"blobUrl",get:function F(){var K;return(K=this._mse)===null||K===void 0?void 0:K.url}},{key:"isFull",value:function F(){var K=arguments.length>0&&arguments[0]!==void 0?arguments[0]:NY.VIDEO;return this._mse.isFull(K)}},{key:"seamlessSwitch",value:function F(){this._needInitSegment=!0,this._discontinuity=!0,this._contiguous=!0,this._initSegmentId=""}},{key:"unContiguous",value:function F(K){this._contiguous=!1,this._demuxStartTime=K}},{key:"reset",value:function(){var F=G1(S0().mark(function U(){var N,O=arguments;return S0().wrap(function B(w){while(!0)switch(w.prev=w.next){case 0:if(N=O.length>0&&O[0]!==void 0?O[0]:!1,!(this._mse&&!N)){w.next=6;break}return w.next=4,this._mse.unbindMedia();case 4:return w.next=6,this._mse.bindMedia(this.flv.media);case 6:this._needInitSegment=!0,this._discontinuity=!0,this._contiguous=!1,this._sourceCreated=!1,this._initSegmentId="",this.resetSeamlessSwitchStats();case 12:case"end":return w.stop()}},U,this)}));function K(){return F.apply(this,arguments)}return K}()},{key:"resetSeamlessSwitchStats",value:function F(){if(this.seamlessLoadingSwitch=null,this.seamlessLoadingSwitching=!1,this._demuxer)this._demuxer.seamlessLoadingSwitching=!1}},{key:"endOfStream",value:function(){var F=G1(S0().mark(function U(){return S0().wrap(function N(O){while(!0)switch(O.prev=O.next){case 0:if(!this._mse){O.next=7;break}if(!this._sourceCreated){O.next=5;break}return O.next=4,this._mse.endOfStream();case 4:this.flv.emit(w0.BUFFEREOS);case 5:O.next=8;break;case 7:if(this._softVideo)this._softVideo.endOfStream();case 8:case"end":return O.stop()}},U,this)}));function K(){return F.apply(this,arguments)}return K}()},{key:"updateDuration",value:function(){var F=G1(S0().mark(function U(N){return S0().wrap(function O(B){while(!0)switch(B.prev=B.next){case 0:if(!this._mse){B.next=7;break}if(this._mse.isOpened){B.next=4;break}return B.next=4,this._mse.open();case 4:return ZY.debug("update duration",N),B.next=7,this._mse.updateDuration(N);case 7:case"end":return B.stop()}},U,this)}));function K(U){return F.apply(this,arguments)}return K}()},{key:"destroy",value:function(){var F=G1(S0().mark(function U(){return S0().wrap(function N(O){while(!0)switch(O.prev=O.next){case 0:if(!this._mse){O.next=3;break}return O.next=3,this._mse.unbindMedia();case 3:this._mse=null,this._softVideo=null,this._demuxer=null,this._remuxer=null;case 7:case"end":return O.stop()}},U,this)}));function K(){return F.apply(this,arguments)}return K}()},{key:"appendBuffer",value:function(){var F=G1(S0().mark(function U(N){var O=this,B,w,R,P,x,k,f,l,s,Y0,t,K0,q0,R0,U0,W0,z0,h0;return S0().wrap(function l0(E0){while(!0)switch(E0.prev=E0.next){case 0:if(B=!1,this._cachedBuffer)N=MQ(this._cachedBuffer,N),this._cachedBuffer=null;if(w=this._demuxer,!(!N||!N.length||!w)){E0.next=5;break}return E0.abrupt("return");case 5:E0.prev=5,this.flv._transferCost.start(QY.DEMUX),w.demuxAndFix(N,this.seamlessLoadingSwitching||this._discontinuity,this._contiguous,this._demuxStartTime,this.seamlessLoadingSwitching),this.seamlessLoadingSwitching=!1,this.flv._transferCost.end(QY.DEMUX),E0.next=15;break;case 12:throw E0.prev=12,E0.t0=E0.catch(5),new A1(P0.DEMUX,P0.SUB_TYPES.FLV,E0.t0);case 15:if(R=w.videoTrack,P=w.audioTrack,x=w.metadataTrack,!this.seamlessLoadingSwitch){E0.next=25;break}if(k=R.samples.findIndex(function(y0){return y0.originDts===R.lastKeyFrameDts}),!(k>=0)){E0.next=25;break}return R.samples.splice(k),E0.next=22,this.seamlessLoadingSwitch();case 22:this.seamlessLoadingSwitch=null,N=null,B=!0;case 25:if(f=R.exist(),l=P.exist(),this._opts.onlyAudio)f=!1,R.present=!1;if(this._opts.onlyVideo)l=!1,P.present=!1;if(!(!f&&R.present||!l&&P.present)){E0.next=42;break}if(s=0,Y0=f?R:l?P:void 0,Y0&&Y0.samples.length)s=(Y0.samples[Y0.samples.length-1].originPts-Y0.samples[0].originPts)/Y0.timescale*1000;if(!(s>this._opts.analyzeDuration)){E0.next=40;break}ZY.warn("analyze duration exceeded, ".concat(s,"ms"),Y0),R.present=f,P.present=l,this.flv.emit(w0.ANALYZE_DURATION_EXCEEDED,{duration:s}),E0.next=42;break;case 40:return this._cachedBuffer=N,E0.abrupt("return");case 42:if(t=R.type,K0=P.type,this._fireEvents(R,P,x),!B)this._discontinuity=!1,this._contiguous=!0,this._demuxStartTime=0;if(q0=this._mse,R0=function y0(){var t0;if((t0=O.flv)!==null&&t0!==void 0&&t0.emit){var T;(T=O.flv)===null||T===void 0||T.emit(w0.APPEND_BUFFER,{})}},this.flv.emit(w0.DEMUXED_TRACK,{videoTrack:R}),U0="".concat(R.codec,"/").concat(R.width,"/").concat(R.height,"/").concat(P.codec,"/").concat(P.config),U0!==this._initSegmentId)this._needInitSegment=!0,this._initSegmentId=U0,this._emitMetaParsedEvent(R,P);if(!q0){E0.next=83;break}if(this._sourceCreated){E0.next=59;break}return E0.next=55,q0.open();case 55:if(f)ZY.log("codec: video/mp4;codecs=".concat(R.codec)),q0.createSource(t,"video/mp4;codecs=".concat(R.codec));if(l)ZY.log("codec: audio/mp4;codecs=".concat(P.codec)),q0.createSource(K0,"audio/mp4;codecs=".concat(P.codec));this._sourceCreated=!0,this.flv.emit(w0.SOURCEBUFFER_CREATED);case 59:if(E0.prev=59,this._needInitSegment&&!this._opts.mseLowLatency)R.duration=this._opts.durationForMSELowLatencyOff*R.timescale,P.duration=this._opts.durationForMSELowLatencyOff*l.timescale;this.flv._transferCost.start(QY.REMUX),W0=this._remuxer.remux(this._needInitSegment),this.flv._transferCost.end(QY.REMUX),E0.next=69;break;case 66:throw E0.prev=66,E0.t1=E0.catch(59),new A1(P0.REMUX,P0.SUB_TYPES.FMP4,E0.t1);case 69:if(!(this._needInitSegment&&!W0.videoInitSegment&&!W0.audioInitSegment)){E0.next=71;break}return E0.abrupt("return");case 71:if(this._needInitSegment=!1,z0=[],W0.videoInitSegment)z0.push(q0.append(t,W0.videoInitSegment));if(W0.audioInitSegment)z0.push(q0.append(K0,W0.audioInitSegment));if(W0.videoSegment)z0.push(q0.append(t,W0.videoSegment));if(W0.audioSegment)z0.push(q0.append(K0,W0.audioSegment));return this.flv._transferCost.start(QY.APPEND),h0=Promise.all(z0),h0.then(R0).then(function(){O.flv._transferCost.end(QY.APPEND),R0()}),E0.abrupt("return",h0);case 83:if(this._softVideo)this._softVideo.appendBuffer(R,P),R0();case 84:case"end":return E0.stop()}},U,this,[[5,12],[59,66]])}));function K(U){return F.apply(this,arguments)}return K}()},{key:"evictBuffer",value:function(){var F=G1(S0().mark(function U(N){var O=this,B,w,R,P;return S0().wrap(function x(k){while(!0)switch(k.prev=k.next){case 0:if(B=this.flv.media,!(!this._mse||!this._demuxer||!B||!N||N<0)){k.next=3;break}return k.abrupt("return");case 3:if(w=B.currentTime,R=w-N,!(R<=0)){k.next=7;break}return k.abrupt("return");case 7:if(P=J1.start(J1.get(B)),!(P+1>=R)){k.next=10;break}return k.abrupt("return");case 10:return k.abrupt("return",this._mse.clearBuffer(0,R).then(function(){return O.flv.emit(w0.REMOVE_BUFFER,{removeEnd:R})}));case 11:case"end":return k.stop()}},U,this)}));function K(U){return F.apply(this,arguments)}return K}()},{key:"_emitMetaParsedEvent",value:function F(K,U){if(K.exist())this.flv.emit(w0.METADATA_PARSED,{type:"video",track:K,meta:{codec:K.codec,timescale:K.timescale,width:K.width,height:K.height,sarRatio:K.sarRatio,baseDts:K.baseDts}});if(U.exist())this.flv.emit(w0.METADATA_PARSED,{type:"audio",track:U,meta:{codec:U.codec,channelCount:U.channelCount,sampleRate:U.sampleRate,timescale:U.timescale,baseDts:U.baseDts}});ZY.debug("track parsed",K,U)}},{key:"_fireEvents",value:function F(K,U,N){var O=this;ZY.debug("videoTrack samples count: ".concat(K.samples.length,", audioTrack samples count: ").concat(U.samples.length)),N.flvScriptSamples.forEach(function(B){O.flv.emit(w0.FLV_SCRIPT_DATA,B),ZY.debug("flvScriptData",B)}),K.samples.forEach(function(B){if(B.keyframe)O.flv.emit(w0.KEYFRAME,{pts:B.originPts})}),K.warnings.forEach(function(B){var w;switch(B.type){case E1.LARGE_AV_SHIFT:w=w0.LARGE_AV_FIRST_FRAME_GAP_DETECT;break;case E1.LARGE_VIDEO_GAP:w=w0.LARGE_VIDEO_DTS_GAP_DETECT;break;case E1.LARGE_VIDEO_GAP_BETWEEN_CHUNK:w=w0.MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT;break}if(w)O.flv.emit(w0.STREAM_EXCEPTION,y1(y1({},B),{},{type:w}));ZY.warn("video exception",B)}),U.warnings.forEach(function(B){var w;switch(B.type){case E1.LARGE_AUDIO_GAP:w=w0.LARGE_AUDIO_DTS_GAP_DETECT;break;case E1.AUDIO_FILLED:w=w0.AUDIO_GAP_DETECT;break;case E1.AUDIO_DROPPED:w=w0.AUDIO_OVERLAP_DETECT;break}if(w)O.flv.emit(w0.STREAM_EXCEPTION,y1(y1({},B),{},{type:w}));ZY.warn("audio exception",B)}),N.seiSamples.forEach(function(B){O.flv.emit(w0.SEI,y1(y1({},B),{},{sei:{code:B.data.type,content:B.data.payload,dts:B.pts}}))})}}]),j}();function r8(j){var F=y1({retryCount:3,retryDelay:1000,disconnectRetryCount:0,loadTimeout:1e4,maxReaderInterval:5000,preloadTime:5,defaultVodLoadSize:1e7,isLive:!1,softDecode:!1,bufferBehind:10,maxJumpDistance:3,analyzeDuration:20000,seamlesslyReload:!1,keepStatusAfterSwitch:!0,onlyVideo:!1,onlyAudio:!1,preferMMS:!1,mseLowLatency:!0,durationForMSELowLatencyOff:6,chunkCountForSpeed:50,skipChunkSize:1000,longtimeNoReceived:3000,enableStartGapJump:!0},j);if(F.isLive){if(F.preloadTime){if(!F.maxLatency)F.maxLatency=F.preloadTime*2;if(!F.targetLatency)F.targetLatency=F.preloadTime;if(F.disconnectTime===null||F.disconnectTime===void 0)F.disconnectTime=F.maxLatency}}return F}function lQ(j,F){var K=0,U=j.length-1,N=0,O=0,B=U;if(F<j[0])K=0,O=B+1;while(O<=B)if(N=O+Math.floor((B-O)/2),N===U||F>=j[N]&&F<j[N+1]){K=N;break}else if(j[N]<F)O=N+1;else B=N-1;return K}var r1=new D1("flv"),vJ=0.1,GW=0.3,OY=function(j){aZ(K,j);var F=tZ(K);function K(U){var N;if(bY(this,K),N=F.call(this),F0(x0(N),"media",null),F0(x0(N),"_loading",!1),F0(x0(N),"_opts",null),F0(x0(N),"_bufferService",null),F0(x0(N),"_gapService",null),F0(x0(N),"_stats",null),F0(x0(N),"_mediaLoader",null),F0(x0(N),"_maxChunkWaitTimer",null),F0(x0(N),"_tickTimer",null),F0(x0(N),"_tickInterval",500),F0(x0(N),"_urlSwitching",!1),F0(x0(N),"_seamlessSwitching",!1),F0(x0(N),"_disconnectRetryCount",0),F0(x0(N),"_preLoadEndPoint",0),F0(x0(N),"_keyframes",null),F0(x0(N),"_acceptRanges",!0),F0(x0(N),"_onProgress",function(){var O=G1(S0().mark(function B(w,R,P,x){var k,f,l,s,Y0,t,K0,q0,R0,U0;return S0().wrap(function W0(z0){while(!0)switch(z0.prev=z0.next){case 0:if(k=P.startTime,f=P.endTime,l=P.st,s=P.firstByteTime,N._loading=!R,N._firstProgressEmit){z0.next=13;break}if(N.media){z0.next=6;break}return(Y0=N._mediaLoader)===null||Y0===void 0||Y0.cancel(),z0.abrupt("return");case 6:t=x.headers,K0=l?s-l:f-k,N.emit(w0.TTFB,{url:N._opts.url,responseUrl:x.url,elapsed:K0}),N.emit(w0.LOAD_RESPONSE_HEADERS,{headers:t}),N._transferCost.set(QY.TTFB,K0),N._acceptRanges=!!(t!==null&&t!==void 0&&t.get("Accept-Ranges"))||!!(t!==null&&t!==void 0&&t.get("Content-Range")),N._firstProgressEmit=!0;case 13:if(N._bufferService){z0.next=15;break}return z0.abrupt("return");case 15:return clearTimeout(N._maxChunkWaitTimer),N._bandwidthService.addChunkRecord(w===null||w===void 0?void 0:w.byteLength,f-k),z0.prev=17,z0.next=20,N._bufferService.appendBuffer(w);case 20:(q0=N._bufferService)===null||q0===void 0||q0.evictBuffer(N._opts.bufferBehind),z0.next=33;break;case 23:if(z0.prev=23,z0.t0=z0.catch(17),!(!N.isLive&&N._bufferService.isFull())){z0.next=32;break}return z0.next=28,N._mediaLoader.cancel();case 28:return N._loading=!1,R0=N.bufferInfo().remaining,N._opts.preloadTime=parseInt(R0)/2,z0.abrupt("return");case 32:return z0.abrupt("return",N._emitError(A1.create(z0.t0)));case 33:if(N._urlSwitching)N._urlSwitching=!1,N.emit(w0.SWITCH_URL_SUCCESS,{url:N._opts.url});if(N._seamlessSwitching)N._seamlessSwitching=!1,N._tick();if(!(R&&!N.media.seeking)){z0.next=40;break}if(N.emit(w0.LOAD_COMPLETE),r1.debug("load done"),N.isLive&&N._disconnectRetryCount<=0)N._end();return z0.abrupt("return");case 40:if(N.isLive){z0.next=42;break}return z0.abrupt("return");case 42:if(U0=N._opts.maxReaderInterval,U0&&N._firstProgressEmit)clearTimeout(N._maxChunkWaitTimer),N._maxChunkWaitTimer=setTimeout(function(){if(N._disconnectRetryCount){N._disconnectRetryCount--,N.load();return}r1.debug("onMaxChunkWait",U0),N._end()},U0);case 44:case"end":return z0.stop()}},B,null,[[17,23]])}));return function(B,w,R,P){return O.apply(this,arguments)}}()),F0(x0(N),"_onRetryError",function(O,B){r1.debug("load retry",O,B),N.emit(w0.LOAD_RETRY,{error:A1.network(O),retryTime:B})}),F0(x0(N),"_end",function(){if(N._clear(),N._bufferService)N._bufferService.endOfStream();r1.debug("end stream")}),F0(x0(N),"_resetDisconnectCount",function(){N._disconnectRetryCount=N._opts.disconnectRetryCount}),F0(x0(N),"_tick",function(){clearTimeout(N._tickTimer);var O=x0(N),B=O.media;if(!B)return;N._tickTimer=setTimeout(N._tick,N._tickInterval);var w=J1.end(J1.get(B));if(w<vJ||!B.readyState)return;var R=N._opts;if(LQ(B)&&B.currentTime){if(N._gapService)N._gapService.do(B,R.maxJumpDistance,N.isLive,3)}else{if(!B.currentTime&&N._gapService&&R.enableStartGapJump){var P=N._opts.mseLowLatency||N._opts.mseLowLatency===!1&&N.bufferInfo(GW).nextStart;if(P)N._gapService.do(B,R.maxJumpDistance,N.isLive,3);return}if(R.isLive&&B.readyState===4&&w-B.currentTime>R.disconnectTime)N.disconnect()}}),F0(x0(N),"_onPlay",function(){var O,B,w=N._opts.softDecode||((O=N.media)===null||O===void 0?void 0:(B=O.buffered)===null||B===void 0?void 0:B.length);if(N.isLive){if(!N._loading&&w)N.replay(void 0,!0);return}var R=N.bufferInfo();if((R.start||R.nextStart)>vJ)N._tick()}),F0(x0(N),"_onLoadeddata",function(){if(N.isLive&&!N._opts.mseLowLatency){if(N.media.duration!==1/0)N._bufferService.updateDuration(1/0).catch(function(O){})}}),F0(x0(N),"_onSeeking",G1(S0().mark(function O(){return S0().wrap(function B(w){while(!0)switch(w.prev=w.next){case 0:if(!N.isLive&&N.seekable)N._preLoadEndPoint=-1,N._checkPreload();case 1:case"end":return w.stop()}},O)}))),F0(x0(N),"_onTimeupdate",function(){if(!N.media)return;var O=N._opts,B=N.media.currentTime;if(O.isLive&&O.maxLatency&&O.targetLatency){var w=J1.end(J1.get(N.media)),R=w-B;if(R>=O.maxLatency)N.media.currentTime=w-O.targetLatency,N.emit(w0.CHASEFRAME,{currentTime:N.media.currentTime,latency:O.targetLatency})}if(N._seiService.throw(B,!0),O.isLive||!N.seekable||N._loading)return;N._checkPreload()}),F0(x0(N),"_onWaiting",function(){if(N.isLive&&!N._loading&&N._disconnectRetryCount)N._disconnectRetryCount--,N.load()}),F0(x0(N),"_onBufferUpdate",function(){if(N._opts.isLive)return;var O=N.bufferInfo(),B=O.end,w=O.nextEnd;if(Math.abs((B||w)-N.media.duration)<1){if(N._end(),N.media.readyState<=2)N._tick()}}),F0(x0(N),"_checkPreload",G1(S0().mark(function O(){var B,w,R,P,x,k,f,l,s,Y0;return S0().wrap(function t(K0){while(!0)switch(K0.prev=K0.next){case 0:if(B=N.bufferInfo(),w=B.remaining,R=w===void 0?0:w,P=N._opts,x=N._keyframes.filepositions,k=N._keyframes.times,f=N.media.currentTime,!(R<P.preloadTime)){K0.next=19;break}if(l=lQ(N._keyframes.times,f+R+vJ),s=lQ(N._keyframes.times,f+R+N._opts.preloadTime),s===l)s=l+1;if(N._preLoadEndPoint!==s){K0.next=11;break}return K0.abrupt("return");case 11:if(Y0=x[l],!(Y0===null||Y0===void 0)){K0.next=14;break}return K0.abrupt("return");case 14:return K0.next=16,N._mediaLoader.cancel();case 16:N._loadData(null,[Y0,x[s]]),N._preLoadEndPoint=s,N._bufferService.unContiguous(k[l]);case 19:case"end":return K0.stop()}},O)}))),F0(x0(N),"_onFlvScriptData",function(O){var B,w,R,P,x=(B=O.data)===null||B===void 0?void 0:(w=B.onMetaData)===null||w===void 0?void 0:w.keyframes,k=(R=O.data)===null||R===void 0?void 0:(P=R.onMetaData)===null||P===void 0?void 0:P.duration;if(x)N._keyframes=x;if(!N._opts.isLive&&k)N._bufferService.updateDuration(k)}),N._opts=r8(U),N.media=N._opts.media||document.createElement("video"),N._opts.media=null,N._firstProgressEmit=!1,N._mediaLoader=new DQ(y1(y1({},N._opts.fetchOptions),{},{retry:N._opts.retryCount,retryDelay:N._opts.retryDelay,timeout:N._opts.loadTimeout,onRetryError:N._onRetryError,onProgress:N._onProgress,responseType:"arraybuffer"})),N._disconnectRetryCount=N._opts.disconnectRetryCount,N._transferCost=new i8,N._bufferService=new s8(x0(N),N._opts.softDecode?N.media:void 0,N._opts),N._seiService=new PQ(x0(N)),N._bandwidthService=new yQ({chunkCountForSpeed:N._opts.chunkCountForSpeed,skipChunkSize:N._opts.skipChunkSize,longtimeNoReceived:N._opts.longtimeNoReceived}),N._stats=new TQ(x0(N)),!N._opts.softDecode)N._gapService=new SQ;return N.media.addEventListener("play",N._onPlay),N.media.addEventListener("loadeddata",N._onLoadeddata),N.media.addEventListener("seeking",N._onSeeking),N.media.addEventListener("timeupdate",N._onTimeupdate),N.media.addEventListener("progress",N._onBufferUpdate),N.media.addEventListener("waiting",N._onWaiting),N.on(w0.FLV_SCRIPT_DATA,N._onFlvScriptData),N}return MY(K,[{key:"version",get:function U(){return"3.0.21"}},{key:"isLive",get:function U(){return this._opts.isLive}},{key:"baseDts",get:function U(){var N;return(N=this._bufferService)===null||N===void 0?void 0:N.baseDts}},{key:"seekable",get:function U(){return!!this._keyframes&&this._acceptRanges}},{key:"loader",get:function U(){return this._mediaLoader}},{key:"blobUrl",get:function U(){var N;return(N=this._bufferService)===null||N===void 0?void 0:N.blobUrl}},{key:"speedInfo",value:function U(){return{speed:this._bandwidthService.getLatestSpeed(),avgSpeed:this._bandwidthService.getAvgSpeed(),totalSize:this._bandwidthService.getTotalSize(),totalCost:this._bandwidthService.getTotalCost()}}},{key:"getStats",value:function U(){return this._stats.getStats()}},{key:"bufferInfo",value:function U(){var N,O=arguments.length>0&&arguments[0]!==void 0?arguments[0]:vJ;return J1.info(J1.get(this.media),(N=this.media)===null||N===void 0?void 0:N.currentTime,O)}},{key:"playbackQuality",value:function U(){return bQ(this.media)}},{key:"load",value:function(){var U=G1(S0().mark(function O(B){var w,R=arguments;return S0().wrap(function P(x){while(!0)switch(x.prev=x.next){case 0:if(w=R.length>1&&R[1]!==void 0?R[1]:!1,this._bufferService){x.next=3;break}return x.abrupt("return");case 3:return x.next=5,this._reset(w);case 5:this._loadData(B,this._opts.isLive?[]:[0,this._opts.defaultVodLoadSize]),clearTimeout(this._tickTimer),this._tickTimer=setTimeout(this._tick,this._tickInterval);case 8:case"end":return x.stop()}},O,this)}));function N(O){return U.apply(this,arguments)}return N}()},{key:"replay",value:function(){var U=G1(S0().mark(function O(){var B=this,w,R,P=arguments;return S0().wrap(function x(k){while(!0)switch(k.prev=k.next){case 0:if(w=P.length>0&&P[0]!==void 0?P[0]:this._opts.seamlesslyReload,R=P.length>1?P[1]:void 0,this.media){k.next=4;break}return k.abrupt("return");case 4:if(this._resetDisconnectCount(),!w){k.next=11;break}return k.next=8,this._clear();case 8:setTimeout(function(){B._seamlessSwitching=!0,B._loadData(B._opts.url),B._bufferService.seamlessSwitch()}),k.next=13;break;case 11:return k.next=13,this.load();case 13:return k.abrupt("return",this.media.play(!R).catch(function(){}));case 14:case"end":return k.stop()}},O,this)}));function N(){return U.apply(this,arguments)}return N}()},{key:"disconnect",value:function U(){var N;return r1.debug("disconnect!"),(N=this._bufferService)===null||N===void 0||N.resetSeamlessSwitchStats(),this._clear()}},{key:"switchURL",value:function(){var U=G1(S0().mark(function O(B,w){var R=this;return S0().wrap(function P(x){while(!0)switch(x.prev=x.next){case 0:if(this._bufferService){x.next=2;break}return x.abrupt("return");case 2:if(this._resetDisconnectCount(),!(this._loading&&w)){x.next=6;break}return this._bufferService.seamlessLoadingSwitch=function(){var k=G1(S0().mark(function f(l){return S0().wrap(function s(Y0){while(!0)switch(Y0.prev=Y0.next){case 0:return Y0.next=2,R._clear();case 2:R._bufferService.seamlessLoadingSwitching=!0,R._urlSwitching=!0,R._seamlessSwitching=!0,R._bufferService.seamlessSwitch(),R._loadData(B);case 7:case"end":return Y0.stop()}},f)}));return function(f){return k.apply(this,arguments)}}(),x.abrupt("return");case 6:if(!(!w||!this._opts.isLive)){x.next=11;break}return x.next=9,this.load(B);case 9:return this._urlSwitching=!0,x.abrupt("return",this.media.play(!0).catch(function(){}));case 11:return x.next=13,this._clear();case 13:setTimeout(function(){R._urlSwitching=!0,R._seamlessSwitching=!0,R._loadData(B),R._bufferService.seamlessSwitch()});case 14:case"end":return x.stop()}},O,this)}));function N(O,B){return U.apply(this,arguments)}return N}()},{key:"destroy",value:function(){var U=G1(S0().mark(function O(){return S0().wrap(function B(w){while(!0)switch(w.prev=w.next){case 0:if(this.media){w.next=2;break}return w.abrupt("return");case 2:return this.removeAllListeners(),this._seiService.reset(),this.media.removeEventListener("play",this._onPlay),this.media.removeEventListener("loadeddata",this._onLoadeddata),this.media.removeEventListener("seeking",this._onSeeking),this.media.removeEventListener("timeupdate",this._onTimeupdate),this.media.removeEventListener("waiting",this._onWaiting),this.media.removeEventListener("progress",this._onBufferUpdate),w.next=12,Promise.all([this._clear(),this._bufferService.destroy()]);case 12:this.media=null,this._bufferService=null;case 14:case"end":return w.stop()}},O,this)}));function N(){return U.apply(this,arguments)}return N}()},{key:"_emitError",value:function U(N){var O,B=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;if(r1.table(N),r1.error(N),r1.error((O=this.media)===null||O===void 0?void 0:O.error),this._urlSwitching)this._urlSwitching=!1,this._seamlessSwitching=!1,this.emit(w0.SWITCH_URL_FAILED,N);if(this.emit(w0.ERROR,N),B)this._seiService.reset(),this._end()}},{key:"_reset",value:function(){var U=G1(S0().mark(function O(){var B,w=arguments;return S0().wrap(function R(P){while(!0)switch(P.prev=P.next){case 0:return B=w.length>0&&w[0]!==void 0?w[0]:!1,this._seiService.reset(),this._bandwidthService.reset(),this._stats.reset(),P.next=6,this._clear();case 6:return P.next=8,this._bufferService.reset(B);case 8:case"end":return P.stop()}},O,this)}));function N(){return U.apply(this,arguments)}return N}()},{key:"_loadData",value:function(){var U=G1(S0().mark(function O(B,w){var R;return S0().wrap(function P(x){while(!0)switch(x.prev=x.next){case 0:if(B)this._opts.url=B;if(R=B=this._opts.url,B){x.next=4;break}throw new Error("Source url is missing");case 4:if(this._opts.preProcessUrl)R=this._opts.preProcessUrl(B).url;if(this._mediaLoader.finnalUrl=R,this.emit(w0.LOAD_START,{url:R,seamlessSwitching:this._seamlessSwitching}),r1.debug("load data, loading:",this._loading,R),!this._loading){x.next=11;break}return x.next=11,this._mediaLoader.cancel();case 11:return this._loading=!0,x.prev=12,x.next=15,this._mediaLoader.load({url:R,range:w});case 15:x.next=21;break;case 17:return x.prev=17,x.t0=x.catch(12),this._loading=!1,x.abrupt("return",this._emitError(A1.network(x.t0),!1));case 21:case"end":return x.stop()}},O,this,[[12,17]])}));function N(O,B){return U.apply(this,arguments)}return N}()},{key:"_clear",value:function(){var U=G1(S0().mark(function O(){return S0().wrap(function B(w){while(!0)switch(w.prev=w.next){case 0:if(!this._mediaLoader){w.next=3;break}return w.next=3,this._mediaLoader.cancel();case 3:clearTimeout(this._maxChunkWaitTimer),clearTimeout(this._tickTimer),this._loading=!1,this._firstProgressEmit=!1;case 7:case"end":return w.stop()}},O,this)}));function N(){return U.apply(this,arguments)}return N}()}],[{key:"isSupported",value:function U(N){if(!N||N==="video"||N==="audio")return NY.isSupported();return typeof WebAssembly!=="undefined"}},{key:"enableLogger",value:function U(){D1.enable(),AY.enable()}},{key:"disableLogger",value:function U(){D1.disable(),AY.disable()}}]),K}(a8.default);try{if(localStorage.getItem("xgd"))OY.enableLogger();else OY.disableLogger()}catch(j){}var KW={};BQ(KW,{Hls:()=>hJ.default});var hJ=LY(e8());var qW={};BQ(qW,{Hls:()=>hJ.default,Flv:()=>OY});})();
21
+ Playlist starting @`+i.startSN+`
22
+ `+i.m3u8)}function Ba(n,s,i){i===void 0&&(i=!0);var t=s.startSN+s.skippedSegments-n.startSN,e=n.fragments,r=t>=0,a=0;if(r&&t<e.length)a=e[t].start;else if(r&&s.startSN===n.endSN+1)a=n.fragmentEnd;else if(r&&i)a=n.fragmentStart+t*s.levelTargetDuration;else if(!s.skippedSegments&&s.fragmentStart===0)a=n.fragmentStart;else return;il(s,a)}function il(n,s){if(s){for(var i=n.fragments,t=n.skippedSegments;t<i.length;t++)i[t].addStart(s);n.fragmentHint&&n.fragmentHint.addStart(s)}}function Ga(n,s){s===void 0&&(s=1/0);var i=1e3*n.targetduration;if(n.updated){var t=n.fragments,e=4;if(t.length&&i*e>s){var r=t[t.length-1].duration*1e3;r<i&&(i=r)}}else i/=2;return Math.round(i)}function nl(n,s,i){if(!n)return null;var t=n.fragments[s-n.startSN];return t||(t=n.fragmentHint,t&&t.sn===s)?t:s<n.startSN&&i&&i.sn===s?i:null}function Va(n,s,i){return n?Ha(n.partList,s,i):null}function Ha(n,s,i){if(n)for(var t=n.length;t--;){var e=n[t];if(e.index===i&&e.fragment.sn===s)return e}return null}function Ka(n){n.forEach(function(s,i){var t;(t=s.details)==null||t.fragments.forEach(function(e){e.level=i,e.initSegment&&(e.initSegment.level=i)})})}var al=3e5,sl=function(n){function s(t){var e;return e=n.call(this,"content-steering",t.logger)||this,e.hls=void 0,e.loader=null,e.uri=null,e.pathwayId=".",e._pathwayPriority=null,e.timeToLoad=300,e.reloadTimer=-1,e.updated=0,e.started=!1,e.enabled=!0,e.levels=null,e.audioTracks=null,e.subtitleTracks=null,e.penalizedPathways={},e.hls=t,e.registerListeners(),e}S(s,n);var i=s.prototype;return i.registerListeners=function(){var e=this.hls;e.on(x.MANIFEST_LOADING,this.onManifestLoading,this),e.on(x.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(x.MANIFEST_PARSED,this.onManifestParsed,this),e.on(x.ERROR,this.onError,this)},i.unregisterListeners=function(){var e=this.hls;e&&(e.off(x.MANIFEST_LOADING,this.onManifestLoading,this),e.off(x.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(x.MANIFEST_PARSED,this.onManifestParsed,this),e.off(x.ERROR,this.onError,this))},i.pathways=function(){return(this.levels||[]).reduce(function(e,r){return e.indexOf(r.pathwayId)===-1&&e.push(r.pathwayId),e},[])},i.startLoad=function(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){var e=this.timeToLoad*1e3-(performance.now()-this.updated);if(e>0){this.scheduleRefresh(this.uri,e);return}}this.loadSteeringManifest(this.uri)}},i.stopLoad=function(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()},i.clearTimeout=function(){this.reloadTimer!==-1&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)},i.destroy=function(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null},i.removeLevel=function(e){var r=this.levels;r&&(this.levels=r.filter(function(a){return a!==e}))},i.onManifestLoading=function(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null},i.onManifestLoaded=function(e,r){var a=r.contentSteering;a!==null&&(this.pathwayId=a.pathwayId,this.uri=a.uri,this.started&&this.startLoad())},i.onManifestParsed=function(e,r){this.audioTracks=r.audioTracks,this.subtitleTracks=r.subtitleTracks},i.onError=function(e,r){var a=r.errorAction;if(a?.action===ht.SendAlternateToPenaltyBox&&a.flags===Mt.MoveAllAlternatesMatchingHost){var u=this.levels,l=this._pathwayPriority,d=this.pathwayId;if(r.context){var c=r.context,p=c.groupId,y=c.pathwayId,A=c.type;p&&u?d=this.getPathwayForGroupId(p,A,d):y&&(d=y)}d in this.penalizedPathways||(this.penalizedPathways[d]=performance.now()),!l&&u&&(l=this.pathways()),l&&l.length>1&&(this.updatePathwayPriority(l),a.resolved=this.pathwayId!==d),a.resolved||this.warn("Could not resolve "+r.details+' ("'+r.error.message+'") with content-steering for Pathway: '+d+" levels: "+(u&&u.length)+" priorities: "+gt(l)+" penalized: "+gt(this.penalizedPathways))}},i.filterParsedLevels=function(e){this.levels=e;var r=this.getLevelsForPathway(this.pathwayId);if(r.length===0){var a=e[0].pathwayId;this.log("No levels found in Pathway "+this.pathwayId+'. Setting initial Pathway to "'+a+'"'),r=this.getLevelsForPathway(a),this.pathwayId=a}return r.length!==e.length&&this.log("Found "+r.length+"/"+e.length+' levels in Pathway "'+this.pathwayId+'"'),r},i.getLevelsForPathway=function(e){return this.levels===null?[]:this.levels.filter(function(r){return e===r.pathwayId})},i.updatePathwayPriority=function(e){this._pathwayPriority=e;var r,a=this.penalizedPathways,u=performance.now();Object.keys(a).forEach(function(A){u-a[A]>al&&delete a[A]});for(var l=0;l<e.length;l++){var d=e[l];if(!(d in a)){if(d===this.pathwayId)return;var c=this.hls.nextLoadLevel,p=this.hls.levels[c];if(r=this.getLevelsForPathway(d),r.length>0){this.log('Setting Pathway to "'+d+'"'),this.pathwayId=d,Ka(r),this.hls.trigger(x.LEVELS_UPDATED,{levels:r});var y=this.hls.levels[c];p&&y&&this.levels&&(y.attrs["STABLE-VARIANT-ID"]!==p.attrs["STABLE-VARIANT-ID"]&&y.bitrate!==p.bitrate&&this.log("Unstable Pathways change from bitrate "+p.bitrate+" to "+y.bitrate),this.hls.nextLoadLevel=c);break}}}},i.getPathwayForGroupId=function(e,r,a){for(var u=this.getLevelsForPathway(a).concat(this.levels||[]),l=0;l<u.length;l++)if(r===ie.AUDIO_TRACK&&u[l].hasAudioGroup(e)||r===ie.SUBTITLE_TRACK&&u[l].hasSubtitleGroup(e))return u[l].pathwayId;return a},i.clonePathways=function(e){var r=this,a=this.levels;if(a){var u={},l={};e.forEach(function(d){var c=d.ID,p=d["BASE-ID"],y=d["URI-REPLACEMENT"];if(!a.some(function(T){return T.pathwayId===c})){var A=r.getLevelsForPathway(p).map(function(T){var b=new rt(T.attrs);b["PATHWAY-ID"]=c;var L=b.AUDIO&&b.AUDIO+"_clone_"+c,R=b.SUBTITLES&&b.SUBTITLES+"_clone_"+c;L&&(u[b.AUDIO]=L,b.AUDIO=L),R&&(l[b.SUBTITLES]=R,b.SUBTITLES=R);var C=ja(T.uri,b["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",y),I=new da({attrs:b,audioCodec:T.audioCodec,bitrate:T.bitrate,height:T.height,name:T.name,url:C,videoCodec:T.videoCodec,width:T.width});if(T.audioGroups)for(var k=1;k<T.audioGroups.length;k++)I.addGroupId("audio",T.audioGroups[k]+"_clone_"+c);if(T.subtitleGroups)for(var O=1;O<T.subtitleGroups.length;O++)I.addGroupId("text",T.subtitleGroups[O]+"_clone_"+c);return I});a.push.apply(a,A),Wa(r.audioTracks,u,y,c),Wa(r.subtitleTracks,l,y,c)}})}},i.loadSteeringManifest=function(e){var r=this,a=this.hls.config,u=a.loader;this.loader&&this.loader.destroy(),this.loader=new u(a);var l;try{l=new self.URL(e)}catch{this.enabled=!1,this.log("Failed to parse Steering Manifest URI: "+e);return}if(l.protocol!=="data:"){var d=(this.hls.bandwidthEstimate||a.abrEwmaDefaultEstimate)|0;l.searchParams.set("_HLS_pathway",this.pathwayId),l.searchParams.set("_HLS_throughput",""+d)}var c={responseType:"json",url:l.href},p=a.steeringManifestLoadPolicy.default,y=p.errorRetry||p.timeoutRetry||{},A={loadPolicy:p,timeout:p.maxLoadTimeMs,maxRetry:y.maxNumRetry||0,retryDelay:y.retryDelayMs||0,maxRetryDelay:y.maxRetryDelayMs||0},T={onSuccess:function(L,R,C,I){r.log('Loaded steering manifest: "'+l+'"');var k=L.data;if(k?.VERSION!==1){r.log("Steering VERSION "+k.VERSION+" not supported!");return}r.updated=performance.now(),r.timeToLoad=k.TTL;var O=k["RELOAD-URI"],V=k["PATHWAY-CLONES"],N=k["PATHWAY-PRIORITY"];if(O)try{r.uri=new self.URL(O,l).href}catch{r.enabled=!1,r.log("Failed to parse Steering Manifest RELOAD-URI: "+O);return}r.scheduleRefresh(r.uri||C.url),V&&r.clonePathways(V);var B={steeringManifest:k,url:l.toString()};r.hls.trigger(x.STEERING_MANIFEST_LOADED,B),N&&r.updatePathwayPriority(N)},onError:function(L,R,C,I){if(r.log("Error loading steering manifest: "+L.code+" "+L.text+" ("+R.url+")"),r.stopLoad(),L.code===410){r.enabled=!1,r.log("Steering manifest "+R.url+" no longer available");return}var k=r.timeToLoad*1e3;if(L.code===429){var O=r.loader;if(typeof O?.getResponseHeader=="function"){var V=O.getResponseHeader("Retry-After");V&&(k=parseFloat(V)*1e3)}r.log("Steering manifest "+R.url+" rate limited");return}r.scheduleRefresh(r.uri||R.url,k)},onTimeout:function(L,R,C){r.log("Timeout loading steering manifest ("+R.url+")"),r.scheduleRefresh(r.uri||R.url)}};this.log("Requesting steering manifest: "+l),this.loader.load(c,A,T)},i.scheduleRefresh=function(e,r){var a=this;r===void 0&&(r=this.timeToLoad*1e3),this.clearTimeout(),this.reloadTimer=self.setTimeout(function(){var u,l=(u=a.hls)==null?void 0:u.media;if(l&&!l.ended){a.loadSteeringManifest(e);return}a.scheduleRefresh(e,a.timeToLoad*1e3)},r)},f(s,[{key:"pathwayPriority",get:function(){return this._pathwayPriority},set:function(e){this.updatePathwayPriority(e)}}])}(je);function Wa(n,s,i,t){n&&Object.keys(s).forEach(function(e){var r=n.filter(function(a){return a.groupId===e}).map(function(a){var u=E({},a);return u.details=void 0,u.attrs=new rt(u.attrs),u.url=u.attrs.URI=ja(a.url,a.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",i),u.groupId=u.attrs["GROUP-ID"]=s[e],u.attrs["PATHWAY-ID"]=t,u});n.push.apply(n,r)})}function ja(n,s,i,t){var e=t.HOST,r=t.PARAMS,a=t[i],u;s&&(u=a?.[s],u&&(n=u));var l=new self.URL(n);return e&&!u&&(l.host=e),r&&Object.keys(r).sort().forEach(function(d){d&&l.searchParams.set(d,r[d])}),l.href}var ol=function(){function n(i){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=i,this.registerListeners()}var s=n.prototype;return s.setStreamController=function(t){this.streamController=t},s.registerListeners=function(){this.hls.on(x.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(x.MEDIA_DETACHING,this.onMediaDetaching,this)},s.unregisterListeners=function(){this.hls.off(x.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(x.MEDIA_DETACHING,this.onMediaDetaching,this)},s.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},s.onMediaAttaching=function(t,e){var r=this.hls.config;if(r.capLevelOnFPSDrop){var a=e.media instanceof self.HTMLVideoElement?e.media:null;this.media=a,a&&typeof a.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}},s.onMediaDetaching=function(){this.media=null},s.checkFPS=function(t,e,r){var a=performance.now();if(e){if(this.lastTime){var u=a-this.lastTime,l=r-this.lastDroppedFrames,d=e-this.lastDecodedFrames,c=1e3*l/u,p=this.hls;if(p.trigger(x.FPS_DROP,{currentDropped:l,currentDecoded:d,totalDroppedFrames:r}),c>0&&l>p.config.fpsDroppedMonitoringThreshold*d){var y=p.currentLevel;p.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+y),y>0&&(p.autoLevelCapping===-1||p.autoLevelCapping>=y)&&(y=y-1,p.trigger(x.FPS_DROP_LEVEL_CAPPING,{level:y,droppedLevel:p.currentLevel}),p.autoLevelCapping=y,this.streamController.nextLevelSwitch())}}this.lastTime=a,this.lastDroppedFrames=r,this.lastDecodedFrames=e}},s.checkFPSInterval=function(){var t=this.media;if(t)if(this.isVideoPlaybackQualityAvailable){var e=t.getVideoPlaybackQuality();this.checkFPS(t,e.totalVideoFrames,e.droppedVideoFrames)}else this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount)},n}(),ul=function(){function n(){this.chunks=[],this.dataLength=0}var s=n.prototype;return s.push=function(t){this.chunks.push(t),this.dataLength+=t.length},s.flush=function(){var t=this.chunks,e=this.dataLength,r;if(t.length)t.length===1?r=t[0]:r=ll(t,e);else return new Uint8Array(0);return this.reset(),r},s.reset=function(){this.chunks.length=0,this.dataLength=0},n}();function ll(n,s){for(var i=new Uint8Array(s),t=0,e=0;e<n.length;e++){var r=n[e];i.set(r,t),t+=r.length}return i}function Ya(n,s){return s+10<=n.length&&n[s]===51&&n[s+1]===68&&n[s+2]===73&&n[s+3]<255&&n[s+4]<255&&n[s+6]<128&&n[s+7]<128&&n[s+8]<128&&n[s+9]<128}function Xi(n,s){return s+10<=n.length&&n[s]===73&&n[s+1]===68&&n[s+2]===51&&n[s+3]<255&&n[s+4]<255&&n[s+6]<128&&n[s+7]<128&&n[s+8]<128&&n[s+9]<128}function fi(n,s){var i=0;return i=(n[s]&127)<<21,i|=(n[s+1]&127)<<14,i|=(n[s+2]&127)<<7,i|=n[s+3]&127,i}function hi(n,s){for(var i=s,t=0;Xi(n,s);){t+=10;var e=fi(n,s+6);t+=e,Ya(n,s+10)&&(t+=10),s+=t}if(t>0)return n.subarray(i,i+t)}function fl(n,s,i,t){var e=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],r=s[i+2],a=r>>2&15;if(a>12){var u=new Error("invalid ADTS sampling index:"+a);n.emit(x.ERROR,x.ERROR,{type:Y.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,fatal:!0,error:u,reason:u.message});return}var l=(r>>6&3)+1,d=s[i+3]>>6&3|(r&1)<<2,c="mp4a.40."+l,p=e[a],y=a;(l===5||l===29)&&(y-=3);var A=[l<<3|(y&14)>>1,(y&1)<<7|d<<3];return Oe.log("manifest codec:"+t+", parsed codec:"+c+", channels:"+d+", rate:"+p+" (ADTS object type:"+l+" sampling index:"+a+")"),{config:A,samplerate:p,channelCount:d,codec:c,parsedCodec:c,manifestCodec:t}}function za(n,s){return n[s]===255&&(n[s+1]&246)===240}function qa(n,s){return n[s+1]&1?7:9}function Qi(n,s){return(n[s+3]&3)<<11|n[s+4]<<3|(n[s+5]&224)>>>5}function hl(n,s){return s+5<n.length}function di(n,s){return s+1<n.length&&za(n,s)}function dl(n,s){return hl(n,s)&&za(n,s)&&Qi(n,s)<=n.length-s}function cl(n,s){if(di(n,s)){var i=qa(n,s);if(s+i>=n.length)return!1;var t=Qi(n,s);if(t<=i)return!1;var e=s+t;return e===n.length||di(n,e)}return!1}function $a(n,s,i,t,e){if(!n.samplerate){var r=fl(s,i,t,e);if(!r)return;E(n,r)}}function Xa(n){return 1024*9e4/n}function vl(n,s){var i=qa(n,s);if(s+i<=n.length){var t=Qi(n,s)-i;if(t>0)return{headerLength:i,frameLength:t}}}function Qa(n,s,i,t,e){var r=Xa(n.samplerate),a=t+e*r,u=vl(s,i),l;if(u){var d=u.frameLength,c=u.headerLength,p=c+d,y=Math.max(0,i+p-s.length);y?(l=new Uint8Array(p-c),l.set(s.subarray(i+c,s.length),0)):l=s.subarray(i+c,i+p);var A={unit:l,pts:a};return y||n.samples.push(A),{sample:A,length:p,missing:y}}var T=s.length-i;l=new Uint8Array(T),l.set(s.subarray(i,s.length),0);var b={unit:l,pts:a};return{sample:b,length:T,missing:-1}}function pl(n,s){return Xi(n,s)&&fi(n,s+6)+10<=n.length-s}function gl(n){if(!(n.size<2)){var s=Pt(n.data,!0),i=new Uint8Array(n.data.subarray(s.length+1));return{key:n.type,info:s,data:i.buffer}}}function ml(n){if(!(n.size<2)){if(n.type==="TXXX"){var s=1,i=Pt(n.data.subarray(s),!0);s+=i.length+1;var t=Pt(n.data.subarray(s));return{key:n.type,info:i,data:t}}var e=Pt(n.data.subarray(1));return{key:n.type,info:"",data:e}}}function yl(n){if(n.type==="WXXX"){if(n.size<2)return;var s=1,i=Pt(n.data.subarray(s),!0);s+=i.length+1;var t=Pt(n.data.subarray(s));return{key:n.type,info:i,data:t}}var e=Pt(n.data);return{key:n.type,info:"",data:e}}function El(n){return n instanceof ArrayBuffer?n:n.byteOffset==0&&n.byteLength==n.buffer.byteLength?n.buffer:new Uint8Array(n).buffer}function Zi(n,s,i){return s===void 0&&(s=0),i===void 0&&(i=1/0),_l(n,s,i,Uint8Array)}function _l(n,s,i,t){var e=Sl(n),r=1;"BYTES_PER_ELEMENT"in t&&(r=t.BYTES_PER_ELEMENT);var a=Tl(n)?n.byteOffset:0,u=(a+n.byteLength)/r,l=(a+s)/r,d=Math.floor(Math.max(0,Math.min(l,u))),c=Math.floor(Math.min(d+Math.max(i,0),u));return new t(e,d,c-d)}function Sl(n){return n instanceof ArrayBuffer?n:n.buffer}function Tl(n){return n&&n.buffer instanceof ArrayBuffer&&n.byteLength!==void 0&&n.byteOffset!==void 0}function Al(n){var s={key:n.type,description:"",data:"",mimeType:null,pictureType:null},i=3;if(!(n.size<2)){if(n.data[0]!==i){console.log("Ignore frame with unrecognized character encoding");return}var t=n.data.subarray(1).indexOf(0);if(t!==-1){var e=Pt(Zi(n.data,1,t)),r=n.data[2+t],a=n.data.subarray(3+t).indexOf(0);if(a!==-1){var u=Pt(Zi(n.data,3+t,a)),l;return e==="-->"?l=Pt(Zi(n.data,4+t+a)):l=El(n.data.subarray(4+t+a)),s.mimeType=e,s.pictureType=r,s.description=u,s.data=l,s}}}}function bl(n){return n.type==="PRIV"?gl(n):n.type[0]==="W"?yl(n):n.type==="APIC"?Al(n):ml(n)}function Ll(n){var s=String.fromCharCode(n[0],n[1],n[2],n[3]),i=fi(n,4),t=10;return{type:s,size:i,data:n.subarray(t,t+i)}}var ci=10,xl=10;function Za(n){for(var s=0,i=[];Xi(n,s);){var t=fi(n,s+6);n[s+5]>>6&1&&(s+=ci),s+=ci;for(var e=s+t;s+xl<e;){var r=Ll(n.subarray(s)),a=bl(r);a&&i.push(a),s+=r.size+ci}Ya(n,s)&&(s+=ci)}return i}function Ja(n){return n&&n.key==="PRIV"&&n.info==="com.apple.streaming.transportStreamTimestamp"}function Rl(n){if(n.data.byteLength===8){var s=new Uint8Array(n.data),i=s[3]&1,t=(s[4]<<23)+(s[5]<<15)+(s[6]<<7)+s[7];return t/=45,i&&(t+=4772185884e-2),Math.round(t)}}function es(n){for(var s=Za(n),i=0;i<s.length;i++){var t=s[i];if(Ja(t))return Rl(t)}}var Lt=function(n){return n.audioId3="org.id3",n.dateRange="com.apple.quicktime.HLS",n.emsg="https://aomedia.org/emsg/ID3",n.misbklv="urn:misb:KLV:bin:1910.1",n}({});function qt(n,s){return n===void 0&&(n=""),s===void 0&&(s=9e4),{type:n,id:-1,pid:-1,inputTimeScale:s,sequenceNumber:-1,samples:[],dropped:0}}var ts=function(){function n(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var s=n.prototype;return s.resetInitSegment=function(t,e,r,a){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},s.resetTimeStamp=function(t){this.initPTS=t,this.resetContiguity()},s.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},s.canParse=function(t,e){return!1},s.appendFrame=function(t,e,r){},s.demux=function(t,e){this.cachedData&&(t=Ot(this.cachedData,t),this.cachedData=null);var r=hi(t,0),a=r?r.length:0,u,l=this._audioTrack,d=this._id3Track,c=r?es(r):void 0,p=t.length;for((this.basePTS===null||this.frameIndex===0&&w(c))&&(this.basePTS=Cl(c,e,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),r&&r.length>0&&d.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:Lt.audioId3,duration:Number.POSITIVE_INFINITY});a<p;){if(this.canParse(t,a)){var y=this.appendFrame(l,t,a);y?(this.frameIndex++,this.lastPTS=y.sample.pts,a+=y.length,u=a):a=p}else pl(t,a)?(r=hi(t,a),d.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:Lt.audioId3,duration:Number.POSITIVE_INFINITY}),a+=r.length,u=a):a++;if(a===p&&u!==p){var A=t.slice(u);this.cachedData?this.cachedData=Ot(this.cachedData,A):this.cachedData=A}}return{audioTrack:l,videoTrack:qt(),id3Track:d,textTrack:qt()}},s.demuxSampleAes=function(t,e,r){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},s.flush=function(t){var e=this.cachedData;return e&&(this.cachedData=null,this.demux(e,0)),{audioTrack:this._audioTrack,videoTrack:qt(),id3Track:this._id3Track,textTrack:qt()}},s.destroy=function(){this.cachedData=null,this._audioTrack=this._id3Track=void 0},n}(),Cl=function(s,i,t){if(w(s))return s*90;var e=t?t.baseTime*9e4/t.timescale:0;return i*9e4+e},vi=null,kl=[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],Dl=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Il=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],wl=[0,1,1,4];function rs(n,s,i,t,e){if(!(i+24>s.length)){var r=is(s,i);if(r&&i+r.frameLength<=s.length){var a=r.samplesPerFrame*9e4/r.sampleRate,u=t+e*a,l={unit:s.subarray(i,i+r.frameLength),pts:u,dts:u};return n.config=[],n.channelCount=r.channelCount,n.samplerate=r.sampleRate,n.samples.push(l),{sample:l,length:r.frameLength,missing:0}}}}function is(n,s){var i=n[s+1]>>3&3,t=n[s+1]>>1&3,e=n[s+2]>>4&15,r=n[s+2]>>2&3;if(i!==1&&e!==0&&e!==15&&r!==3){var a=n[s+2]>>1&1,u=n[s+3]>>6,l=i===3?3-t:t===3?3:4,d=kl[l*14+e-1]*1e3,c=i===3?0:i===2?1:2,p=Dl[c*3+r],y=u===3?1:2,A=Il[i][t],T=wl[t],b=A*8*T,L=Math.floor(A*d/p+a)*T;if(vi===null){var R=navigator.userAgent||"",C=R.match(/Chrome\/(\d+)/i);vi=C?parseInt(C[1]):0}var I=!!vi&&vi<=87;return I&&t===2&&d>=224e3&&u===0&&(n[s+3]=n[s+3]|128),{sampleRate:p,channelCount:y,frameLength:L,samplesPerFrame:b}}}function Ji(n,s){return n[s]===255&&(n[s+1]&224)===224&&(n[s+1]&6)!==0}function ns(n,s){return s+1<n.length&&Ji(n,s)}function Pl(n,s){var i=4;return Ji(n,s)&&i<=n.length-s}function as(n,s){if(s+1<n.length&&Ji(n,s)){var i=4,t=is(n,s),e=i;t!=null&&t.frameLength&&(e=t.frameLength);var r=s+e;return r===n.length||ns(n,r)}return!1}var Ol=function(n){function s(t,e){var r;return r=n.call(this)||this,r.observer=void 0,r.config=void 0,r.observer=t,r.config=e,r}S(s,n);var i=s.prototype;return i.resetInitSegment=function(e,r,a,u){n.prototype.resetInitSegment.call(this,e,r,a,u),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:r,duration:u,inputTimeScale:9e4,dropped:0}},s.probe=function(e,r){if(!e)return!1;var a=hi(e,0),u=a?.length||0;if(as(e,u))return!1;for(var l=e.length;u<l;u++)if(cl(e,u))return r.log("ADTS sync word found !"),!0;return!1},i.canParse=function(e,r){return dl(e,r)},i.appendFrame=function(e,r,a){$a(e,this.observer,r,a,e.manifestCodec);var u=Qa(e,r,a,this.basePTS,this.frameIndex);if(u&&u.missing===0)return u},s}(ts),Ml=function(s,i){var t=0,e=5;i+=e;for(var r=new Uint32Array(1),a=new Uint32Array(1),u=new Uint8Array(1);e>0;){u[0]=s[i];var l=Math.min(e,8),d=8-l;a[0]=4278190080>>>24+d<<d,r[0]=(u[0]&a[0])>>d,t=t?t<<l|r[0]:r[0],i+=1,e-=l}return t},Fl=function(n){function s(){return n.apply(this,arguments)||this}S(s,n);var i=s.prototype;return i.resetInitSegment=function(e,r,a,u){n.prototype.resetInitSegment.call(this,e,r,a,u),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:r,duration:u,inputTimeScale:9e4,dropped:0}},s.probe=function(e){if(!e)return!1;var r=hi(e,0),a=r?.length||0;if(r&&e[a]===11&&e[a+1]===119&&es(r)!==void 0&&Ml(e,a)<=16)return!1;for(var u=e.length;a<u;a++)if(as(e,a))return Oe.log("MPEG Audio sync word found !"),!0;return!1},i.canParse=function(e,r){return Pl(e,r)},i.appendFrame=function(e,r,a){if(this.basePTS!==null)return rs(e,r,a,this.basePTS,this.frameIndex)},s}(ts),Nl=function(){function n(i,t,e){this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=i,this.aesIV=t,this.aesMode=e}var s=n.prototype;return s.decrypt=function(t,e){switch(this.aesMode){case ar.cbc:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},e,t);case ar.ctr:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},e,t);default:throw new Error("[AESCrypto] invalid aes mode "+this.aesMode)}},n}();function Ul(n){var s=n.byteLength,i=s&&new DataView(n.buffer).getUint8(s-1);return i?n.slice(0,s-i):n}var Bl=function(){function n(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var s=n.prototype;return s.uint8ArrayToUint32Array_=function(t){for(var e=new DataView(t),r=new Uint32Array(4),a=0;a<4;a++)r[a]=e.getUint32(a*4);return r},s.initTable=function(){var t=this.sBox,e=this.invSBox,r=this.subMix,a=r[0],u=r[1],l=r[2],d=r[3],c=this.invSubMix,p=c[0],y=c[1],A=c[2],T=c[3],b=new Uint32Array(256),L=0,R=0,C=0;for(C=0;C<256;C++)C<128?b[C]=C<<1:b[C]=C<<1^283;for(C=0;C<256;C++){var I=R^R<<1^R<<2^R<<3^R<<4;I=I>>>8^I&255^99,t[L]=I,e[I]=L;var k=b[L],O=b[k],V=b[O],N=b[I]*257^I*16843008;a[L]=N<<24|N>>>8,u[L]=N<<16|N>>>16,l[L]=N<<8|N>>>24,d[L]=N,N=V*16843009^O*65537^k*257^L*16843008,p[I]=N<<24|N>>>8,y[I]=N<<16|N>>>16,A[I]=N<<8|N>>>24,T[I]=N,L?(L=k^b[b[b[V^k]]],R^=b[b[R]]):L=R=1}},s.expandKey=function(t){for(var e=this.uint8ArrayToUint32Array_(t),r=!0,a=0;a<e.length&&r;)r=e[a]===this.key[a],a++;if(!r){this.key=e;var u=this.keySize=e.length;if(u!==4&&u!==6&&u!==8)throw new Error("Invalid aes key size="+u);var l=this.ksRows=(u+6+1)*4,d,c,p=this.keySchedule=new Uint32Array(l),y=this.invKeySchedule=new Uint32Array(l),A=this.sBox,T=this.rcon,b=this.invSubMix,L=b[0],R=b[1],C=b[2],I=b[3],k,O;for(d=0;d<l;d++){if(d<u){k=p[d]=e[d];continue}O=k,d%u===0?(O=O<<8|O>>>24,O=A[O>>>24]<<24|A[O>>>16&255]<<16|A[O>>>8&255]<<8|A[O&255],O^=T[d/u|0]<<24):u>6&&d%u===4&&(O=A[O>>>24]<<24|A[O>>>16&255]<<16|A[O>>>8&255]<<8|A[O&255]),p[d]=k=(p[d-u]^O)>>>0}for(c=0;c<l;c++)d=l-c,c&3?O=p[d]:O=p[d-4],c<4||d<=4?y[c]=O:y[c]=L[A[O>>>24]]^R[A[O>>>16&255]]^C[A[O>>>8&255]]^I[A[O&255]],y[c]=y[c]>>>0}},s.networkToHostOrderSwap=function(t){return t<<24|(t&65280)<<8|(t&16711680)>>8|t>>>24},s.decrypt=function(t,e,r){for(var a=this.keySize+6,u=this.invKeySchedule,l=this.invSBox,d=this.invSubMix,c=d[0],p=d[1],y=d[2],A=d[3],T=this.uint8ArrayToUint32Array_(r),b=T[0],L=T[1],R=T[2],C=T[3],I=new Int32Array(t),k=new Int32Array(I.length),O,V,N,B,X,z,K,j,J,le,re,te,fe,de,ve=this.networkToHostOrderSwap;e<I.length;){for(J=ve(I[e]),le=ve(I[e+1]),re=ve(I[e+2]),te=ve(I[e+3]),X=J^u[0],z=te^u[1],K=re^u[2],j=le^u[3],fe=4,de=1;de<a;de++)O=c[X>>>24]^p[z>>16&255]^y[K>>8&255]^A[j&255]^u[fe],V=c[z>>>24]^p[K>>16&255]^y[j>>8&255]^A[X&255]^u[fe+1],N=c[K>>>24]^p[j>>16&255]^y[X>>8&255]^A[z&255]^u[fe+2],B=c[j>>>24]^p[X>>16&255]^y[z>>8&255]^A[K&255]^u[fe+3],X=O,z=V,K=N,j=B,fe=fe+4;O=l[X>>>24]<<24^l[z>>16&255]<<16^l[K>>8&255]<<8^l[j&255]^u[fe],V=l[z>>>24]<<24^l[K>>16&255]<<16^l[j>>8&255]<<8^l[X&255]^u[fe+1],N=l[K>>>24]<<24^l[j>>16&255]<<16^l[X>>8&255]<<8^l[z&255]^u[fe+2],B=l[j>>>24]<<24^l[X>>16&255]<<16^l[z>>8&255]<<8^l[K&255]^u[fe+3],k[e]=ve(O^b),k[e+1]=ve(B^L),k[e+2]=ve(N^R),k[e+3]=ve(V^C),b=J,L=le,R=re,C=te,e=e+4}return k.buffer},n}(),Gl=function(){function n(i,t,e){this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=i,this.key=t,this.aesMode=e}var s=n.prototype;return s.expandKey=function(){var t=Vl(this.aesMode);return this.subtle.importKey("raw",this.key,{name:t},!1,["encrypt","decrypt"])},n}();function Vl(n){switch(n){case ar.cbc:return"AES-CBC";case ar.ctr:return"AES-CTR";default:throw new Error("[FastAESKey] invalid aes mode "+n)}}var Hl=16,en=function(){function n(i,t){var e=t===void 0?{}:t,r=e.removePKCS7Padding,a=r===void 0?!0:r;if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.enableSoftwareAES=void 0,this.enableSoftwareAES=i.enableSoftwareAES,this.removePKCS7Padding=a,a)try{var u=self.crypto;u&&(this.subtle=u.subtle||u.webkitSubtle)}catch{}this.useSoftware=!this.subtle}var s=n.prototype;return s.destroy=function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},s.isSync=function(){return this.useSoftware},s.flush=function(){var t=this.currentResult,e=this.remainderData;if(!t||e)return this.reset(),null;var r=new Uint8Array(t);return this.reset(),this.removePKCS7Padding?Ul(r):r},s.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},s.decrypt=function(t,e,r,a){var u=this;return this.useSoftware?new Promise(function(l,d){var c=ArrayBuffer.isView(t)?t:new Uint8Array(t);u.softwareDecrypt(c,e,r,a);var p=u.flush();p?l(p.buffer):d(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(t),e,r,a)},s.softwareDecrypt=function(t,e,r,a){var u=this.currentIV,l=this.currentResult,d=this.remainderData;if(a!==ar.cbc||e.byteLength!==16)return Oe.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),d&&(t=Ot(d,t),this.remainderData=null);var c=this.getValidChunk(t);if(!c.length)return null;u&&(r=u);var p=this.softwareDecrypter;p||(p=this.softwareDecrypter=new Bl),p.expandKey(e);var y=l;return this.currentResult=p.decrypt(c.buffer,0,r),this.currentIV=c.slice(-16).buffer,y||null},s.webCryptoDecrypt=function(t,e,r,a){var u=this;if(this.key!==e||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(t,e,r,a));this.key=e,this.fastAesKey=new Gl(this.subtle,e,a)}return this.fastAesKey.expandKey().then(function(l){if(!u.subtle)return Promise.reject(new Error("web crypto not initialized"));u.logOnce("WebCrypto AES decrypt");var d=new Nl(u.subtle,new Uint8Array(r),a);return d.decrypt(t.buffer,l)}).catch(function(l){return Oe.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+l.name+": "+l.message),u.onWebCryptoError(t,e,r,a)})},s.onWebCryptoError=function(t,e,r,a){var u=this.enableSoftwareAES;if(u){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(t,e,r,a);var l=this.flush();if(l)return l.buffer}throw new Error("WebCrypto"+(u?" and softwareDecrypt":"")+": failed to decrypt data")},s.getValidChunk=function(t){var e=t,r=t.length-t.length%Hl;return r!==t.length&&(e=t.slice(0,r),this.remainderData=t.slice(r)),e},s.logOnce=function(t){this.logEnabled&&(Oe.log("[decrypter]: "+t),this.logEnabled=!1)},n}(),Kl=/\/emsg[-/]ID3/i,Wl=function(){function n(i,t){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=t}var s=n.prototype;return s.resetTimeStamp=function(){},s.resetInitSegment=function(t,e,r,a){var u=this.videoTrack=qt("video",1),l=this.audioTrack=qt("audio",1),d=this.txtTrack=qt("text",1);if(this.id3Track=qt("id3",1),this.timeOffset=0,!!(t!=null&&t.byteLength)){var c=ea(t);if(c.video){var p=c.video,y=p.id,A=p.timescale,T=p.codec,b=p.supplemental;u.id=y,u.timescale=d.timescale=A,u.codec=T,u.supplemental=b}if(c.audio){var L=c.audio,R=L.id,C=L.timescale,I=L.codec;l.id=R,l.timescale=C,l.codec=I}d.id=Xn.text,u.sampleDuration=0,u.duration=l.duration=a}},s.resetContiguity=function(){this.remainderData=null},n.probe=function(t){return iu(t)},s.demux=function(t,e){this.timeOffset=e;var r=t,a=this.videoTrack,u=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=Ot(this.remainderData,t));var l=du(r);this.remainderData=l.remainder,a.samples=l.valid||new Uint8Array}else a.samples=r;var d=this.extractID3Track(a,e);return u.samples=ta(e,a),{videoTrack:a,audioTrack:this.audioTrack,id3Track:d,textTrack:this.txtTrack}},s.flush=function(){var t=this.timeOffset,e=this.videoTrack,r=this.txtTrack;e.samples=this.remainderData||new Uint8Array,this.remainderData=null;var a=this.extractID3Track(e,this.timeOffset);return r.samples=ta(t,e),{videoTrack:e,audioTrack:qt(),id3Track:a,textTrack:qt()}},s.extractID3Track=function(t,e){var r=this,a=this.id3Track;if(t.samples.length){var u=Te(t.samples,["emsg"]);u&&u.forEach(function(l){var d=vu(l);if(Kl.test(d.schemeIdUri)){var c=ss(d,e),p=d.eventDuration===4294967295?Number.POSITIVE_INFINITY:d.eventDuration/d.timeScale;p<=.001&&(p=Number.POSITIVE_INFINITY);var y=d.payload;a.samples.push({data:y,len:y.byteLength,dts:c,pts:c,type:Lt.emsg,duration:p})}else if(r.config.enableEmsgKLVMetadata&&d.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){var A=ss(d,e);a.samples.push({data:d.payload,len:d.payload.byteLength,dts:A,pts:A,type:Lt.misbklv,duration:Number.POSITIVE_INFINITY})}})}return a},s.demuxSampleAes=function(t,e,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},s.destroy=function(){this.config=null,this.remainderData=null,this.videoTrack=this.audioTrack=this.id3Track=this.txtTrack=void 0},n}();function ss(n,s){return w(n.presentationTime)?n.presentationTime/n.timeScale:s+n.presentationTimeDelta/n.timeScale}var jl=function(){function n(i,t,e){this.keyData=void 0,this.decrypter=void 0,this.keyData=e,this.decrypter=new en(t,{removePKCS7Padding:!1})}var s=n.prototype;return s.decryptBuffer=function(t){return this.decrypter.decrypt(t,this.keyData.key.buffer,this.keyData.iv.buffer,ar.cbc)},s.decryptAacSample=function(t,e,r){var a=this,u=t[e].unit;if(!(u.length<=16)){var l=u.subarray(16,u.length-u.length%16),d=l.buffer.slice(l.byteOffset,l.byteOffset+l.length);this.decryptBuffer(d).then(function(c){var p=new Uint8Array(c);u.set(p,16),a.decrypter.isSync()||a.decryptAacSamples(t,e+1,r)})}},s.decryptAacSamples=function(t,e,r){for(;;e++){if(e>=t.length){r();return}if(!(t[e].unit.length<32)&&(this.decryptAacSample(t,e,r),!this.decrypter.isSync()))return}},s.getAvcEncryptedData=function(t){for(var e=Math.floor((t.length-48)/160)*16+16,r=new Int8Array(e),a=0,u=32;u<t.length-16;u+=160,a+=16)r.set(t.subarray(u,u+16),a);return r},s.getAvcDecryptedUnit=function(t,e){for(var r=new Uint8Array(e),a=0,u=32;u<t.length-16;u+=160,a+=16)t.set(r.subarray(a,a+16),u);return t},s.decryptAvcSample=function(t,e,r,a,u){var l=this,d=ia(u.data),c=this.getAvcEncryptedData(d);this.decryptBuffer(c.buffer).then(function(p){u.data=l.getAvcDecryptedUnit(d,p),l.decrypter.isSync()||l.decryptAvcSamples(t,e,r+1,a)})},s.decryptAvcSamples=function(t,e,r,a){if(t instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;e++,r=0){if(e>=t.length){a();return}for(var u=t[e].units;!(r>=u.length);r++){var l=u[r];if(!(l.data.length<=48||l.type!==1&&l.type!==5)&&(this.decryptAvcSample(t,e,r,a,l),!this.decrypter.isSync()))return}}},n}(),Yl=function(){function n(){this.VideoSample=null}var s=n.prototype;return s.createVideoSample=function(t,e,r){return{key:t,frame:!1,pts:e,dts:r,units:[],length:0}},s.getLastNalUnit=function(t){var e,r=this.VideoSample,a;if((!r||r.units.length===0)&&(r=t[t.length-1]),(e=r)!=null&&e.units){var u=r.units;a=u[u.length-1]}return a},s.pushAccessUnit=function(t,e){if(t.units.length&&t.frame){if(t.pts===void 0){var r=e.samples,a=r.length;if(a){var u=r[a-1];t.pts=u.pts,t.dts=u.dts}else{e.dropped++;return}}e.samples.push(t)}},s.parseNALu=function(t,e,r){var a=e.byteLength,u=t.naluState||0,l=u,d=[],c=0,p,y,A,T=-1,b=0;for(u===-1&&(T=0,b=this.getNALuType(e,0),u=0,c=1);c<a;){if(p=e[c++],!u){u=p?0:1;continue}if(u===1){u=p?0:2;continue}if(!p)u=3;else if(p===1){if(y=c-u-1,T>=0){var L={data:e.subarray(T,y),type:b};d.push(L)}else{var R=this.getLastNalUnit(t.samples);R&&(l&&c<=4-l&&R.state&&(R.data=R.data.subarray(0,R.data.byteLength-l)),y>0&&(R.data=Ot(R.data,e.subarray(0,y)),R.state=0))}c<a?(A=this.getNALuType(e,c),T=c,b=A,u=0):u=-1}else u=0}if(T>=0&&u>=0){var C={data:e.subarray(T,a),type:b,state:u};d.push(C)}if(d.length===0){var I=this.getLastNalUnit(t.samples);I&&(I.data=Ot(I.data,e))}return t.naluState=u,d},n}(),os=function(){function n(i){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=i,this.bytesAvailable=i.byteLength,this.word=0,this.bitsAvailable=0}var s=n.prototype;return s.loadWord=function(){var t=this.data,e=this.bytesAvailable,r=t.byteLength-e,a=new Uint8Array(4),u=Math.min(4,e);if(u===0)throw new Error("no bytes available");a.set(t.subarray(r,r+u)),this.word=new DataView(a.buffer).getUint32(0),this.bitsAvailable=u*8,this.bytesAvailable-=u},s.skipBits=function(t){var e;t=Math.min(t,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>t?(this.word<<=t,this.bitsAvailable-=t):(t-=this.bitsAvailable,e=t>>3,t-=e<<3,this.bytesAvailable-=e,this.loadWord(),this.word<<=t,this.bitsAvailable-=t)},s.readBits=function(t){var e=Math.min(this.bitsAvailable,t),r=this.word>>>32-e;if(t>32&&Oe.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=e,this.bitsAvailable>0)this.word<<=e;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return e=t-e,e>0&&this.bitsAvailable?r<<e|this.readBits(e):r},s.skipLZ=function(){var t;for(t=0;t<this.bitsAvailable;++t)if((this.word&2147483648>>>t)!==0)return this.word<<=t,this.bitsAvailable-=t,t;return this.loadWord(),t+this.skipLZ()},s.skipUEG=function(){this.skipBits(1+this.skipLZ())},s.skipEG=function(){this.skipBits(1+this.skipLZ())},s.readUEG=function(){var t=this.skipLZ();return this.readBits(t+1)-1},s.readEG=function(){var t=this.readUEG();return 1&t?1+t>>>1:-1*(t>>>1)},s.readBoolean=function(){return this.readBits(1)===1},s.readUByte=function(){return this.readBits(8)},s.readUShort=function(){return this.readBits(16)},s.readUInt=function(){return this.readBits(32)},n}(),us=function(n){function s(){return n.apply(this,arguments)||this}S(s,n);var i=s.prototype;return i.parsePES=function(e,r,a,u){var l=this,d=this.parseNALu(e,a.data,u),c=this.VideoSample,p,y=!1;a.data=null,c&&d.length&&!e.audFound&&(this.pushAccessUnit(c,e),c=this.VideoSample=this.createVideoSample(!1,a.pts,a.dts)),d.forEach(function(A){var T,b;switch(A.type){case 1:{var L=!1;p=!0;var R=A.data;if(y&&R.length>4){var C=l.readSliceType(R);(C===2||C===4||C===7||C===9)&&(L=!0)}if(L){var I;(I=c)!=null&&I.frame&&!c.key&&(l.pushAccessUnit(c,e),c=l.VideoSample=null)}c||(c=l.VideoSample=l.createVideoSample(!0,a.pts,a.dts)),c.frame=!0,c.key=L;break}case 5:p=!0,(T=c)!=null&&T.frame&&!c.key&&(l.pushAccessUnit(c,e),c=l.VideoSample=null),c||(c=l.VideoSample=l.createVideoSample(!0,a.pts,a.dts)),c.key=!0,c.frame=!0;break;case 6:{p=!0,ra(A.data,1,a.pts,r.samples);break}case 7:{var k,O;p=!0,y=!0;var V=A.data,N=l.readSPS(V);if(!e.sps||e.width!==N.width||e.height!==N.height||((k=e.pixelRatio)==null?void 0:k[0])!==N.pixelRatio[0]||((O=e.pixelRatio)==null?void 0:O[1])!==N.pixelRatio[1]){e.width=N.width,e.height=N.height,e.pixelRatio=N.pixelRatio,e.sps=[V];for(var B=V.subarray(1,4),X="avc1.",z=0;z<3;z++){var K=B[z].toString(16);K.length<2&&(K="0"+K),X+=K}e.codec=X}break}case 8:p=!0,e.pps=[A.data];break;case 9:p=!0,e.audFound=!0,(b=c)!=null&&b.frame&&(l.pushAccessUnit(c,e),c=null),c||(c=l.VideoSample=l.createVideoSample(!1,a.pts,a.dts));break;case 12:p=!0;break;default:p=!1;break}if(c&&p){var j=c.units;j.push(A)}}),u&&c&&(this.pushAccessUnit(c,e),this.VideoSample=null)},i.getNALuType=function(e,r){return e[r]&31},i.readSliceType=function(e){var r=new os(e);return r.readUByte(),r.readUEG(),r.readUEG()},i.skipScalingList=function(e,r){for(var a=8,u=8,l,d=0;d<e;d++)u!==0&&(l=r.readEG(),u=(a+l+256)%256),a=u===0?a:u},i.readSPS=function(e){var r=new os(e),a=0,u=0,l=0,d=0,c,p,y,A=r.readUByte.bind(r),T=r.readBits.bind(r),b=r.readUEG.bind(r),L=r.readBoolean.bind(r),R=r.skipBits.bind(r),C=r.skipEG.bind(r),I=r.skipUEG.bind(r),k=this.skipScalingList.bind(this);A();var O=A();if(T(5),R(3),A(),I(),O===100||O===110||O===122||O===244||O===44||O===83||O===86||O===118||O===128){var V=b();if(V===3&&R(1),I(),I(),R(1),L())for(p=V!==3?8:12,y=0;y<p;y++)L()&&(y<6?k(16,r):k(64,r))}I();var N=b();if(N===0)b();else if(N===1)for(R(1),C(),C(),c=b(),y=0;y<c;y++)C();I(),R(1);var B=b(),X=b(),z=T(1);z===0&&R(1),R(1),L()&&(a=b(),u=b(),l=b(),d=b());var K=[1,1];if(L()&&L()){var j=A();switch(j){case 1:K=[1,1];break;case 2:K=[12,11];break;case 3:K=[10,11];break;case 4:K=[16,11];break;case 5:K=[40,33];break;case 6:K=[24,11];break;case 7:K=[20,11];break;case 8:K=[32,11];break;case 9:K=[80,33];break;case 10:K=[18,11];break;case 11:K=[15,11];break;case 12:K=[64,33];break;case 13:K=[160,99];break;case 14:K=[4,3];break;case 15:K=[3,2];break;case 16:K=[2,1];break;case 255:{K=[A()<<8|A(),A()<<8|A()];break}}}return{width:Math.ceil((B+1)*16-a*2-u*2),height:(2-z)*(X+1)*16-(z?2:4)*(l+d),pixelRatio:K}},s}(Yl),ot=188,zl=function(){function n(i,t,e,r){this.logger=void 0,this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=i,this.config=t,this.typeSupported=e,this.logger=r,this.videoParser=null}n.probe=function(t,e){var r=n.syncOffset(t);return r>0&&e.warn("MPEG2-TS detected but first sync word found @ offset "+r),r!==-1},n.syncOffset=function(t){for(var e=t.length,r=Math.min(ot*5,e-ot)+1,a=0;a<r;){for(var u=!1,l=-1,d=0,c=a;c<e;c+=ot)if(t[c]===71&&(e-c===ot||t[c+ot]===71)){if(d++,l===-1&&(l=c,l!==0&&(r=Math.min(l+ot*99,t.length-ot)+1)),u||(u=tn(t,c)===0),u&&d>1&&(l===0&&d>2||c+ot>r))return l}else{if(d)return-1;break}a++}return-1},n.createTrack=function(t,e){return{container:t==="video"||t==="audio"?"video/mp2t":void 0,type:t,id:Xn[t],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:t==="audio"?e:void 0}};var s=n.prototype;return s.resetInitSegment=function(t,e,r,a){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=n.createTrack("video"),this._videoTrack.duration=a,this._audioTrack=n.createTrack("audio",a),this._id3Track=n.createTrack("id3"),this._txtTrack=n.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=e,this.videoCodec=r},s.resetTimeStamp=function(){},s.resetContiguity=function(){var t=this._audioTrack,e=this._videoTrack,r=this._id3Track;t&&(t.pesData=null),e&&(e.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.remainderData=null},s.demux=function(t,e,r,a){r===void 0&&(r=!1),a===void 0&&(a=!1),r||(this.sampleAes=null);var u,l=this._videoTrack,d=this._audioTrack,c=this._id3Track,p=this._txtTrack,y=l.pid,A=l.pesData,T=d.pid,b=c.pid,L=d.pesData,R=c.pesData,C=null,I=this.pmtParsed,k=this._pmtId,O=t.length;if(this.remainderData&&(t=Ot(this.remainderData,t),O=t.length,this.remainderData=null),O<ot&&!a)return this.remainderData=t,{audioTrack:d,videoTrack:l,id3Track:c,textTrack:p};var V=Math.max(0,n.syncOffset(t));O-=(O-V)%ot,O<t.byteLength&&!a&&(this.remainderData=new Uint8Array(t.buffer,O,t.buffer.byteLength-O));for(var N=0,B=V;B<O;B+=ot)if(t[B]===71){var X=!!(t[B+1]&64),z=tn(t,B),K=(t[B+3]&48)>>4,j=void 0;if(K>1){if(j=B+5+t[B+4],j===B+ot)continue}else j=B+4;switch(z){case y:if(X){if(A&&(u=mr(A,this.logger))){if(this.videoParser===null)switch(l.segmentCodec){case"avc":this.videoParser=new us;break}this.videoParser!==null&&this.videoParser.parsePES(l,p,u,!1)}A={data:[],size:0}}A&&(A.data.push(t.subarray(j,B+ot)),A.size+=B+ot-j);break;case T:if(X){if(L&&(u=mr(L,this.logger)))switch(d.segmentCodec){case"aac":this.parseAACPES(d,u);break;case"mp3":this.parseMPEGPES(d,u);break}L={data:[],size:0}}L&&(L.data.push(t.subarray(j,B+ot)),L.size+=B+ot-j);break;case b:X&&(R&&(u=mr(R,this.logger))&&this.parseID3PES(c,u),R={data:[],size:0}),R&&(R.data.push(t.subarray(j,B+ot)),R.size+=B+ot-j);break;case 0:X&&(j+=t[j]+1),k=this._pmtId=ql(t,j);break;case k:{X&&(j+=t[j]+1);var J=$l(t,j,this.typeSupported,r,this.observer,this.logger);y=J.videoPid,y>0&&(l.pid=y,l.segmentCodec=J.segmentVideoCodec),T=J.audioPid,T>0&&(d.pid=T,d.segmentCodec=J.segmentAudioCodec),b=J.id3Pid,b>0&&(c.pid=b),C!==null&&!I&&(this.logger.warn("MPEG-TS PMT found at "+B+" after unknown PID '"+C+"'. Backtracking to sync byte @"+V+" to parse all TS packets."),C=null,B=V-188),I=this.pmtParsed=!0;break}case 17:case 8191:break;default:C=z;break}}else N++;N>0&&pi(this.observer,new Error("Found "+N+" TS packet/s that do not start with 0x47"),void 0,this.logger),l.pesData=A,d.pesData=L,c.pesData=R;var le={audioTrack:d,videoTrack:l,id3Track:c,textTrack:p};return a&&this.extractRemainingSamples(le),le},s.flush=function(){var t=this.remainderData;this.remainderData=null;var e;return t?e=this.demux(t,-1,!1,!0):e={videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e},s.extractRemainingSamples=function(t){var e=t.audioTrack,r=t.videoTrack,a=t.id3Track,u=t.textTrack,l=r.pesData,d=e.pesData,c=a.pesData,p;if(l&&(p=mr(l,this.logger))){if(this.videoParser===null)switch(r.segmentCodec){case"avc":this.videoParser=new us;break}this.videoParser!==null&&(this.videoParser.parsePES(r,u,p,!0),r.pesData=null)}else r.pesData=l;if(d&&(p=mr(d,this.logger))){switch(e.segmentCodec){case"aac":this.parseAACPES(e,p);break;case"mp3":this.parseMPEGPES(e,p);break}e.pesData=null}else d!=null&&d.size&&this.logger.log("last AAC PES packet truncated,might overlap between fragments"),e.pesData=d;c&&(p=mr(c,this.logger))?(this.parseID3PES(a,p),a.pesData=null):a.pesData=c},s.demuxSampleAes=function(t,e,r){var a=this.demux(t,r,!0,!this.config.progressive),u=this.sampleAes=new jl(this.observer,this.config,e);return this.decrypt(a,u)},s.decrypt=function(t,e){return new Promise(function(r){var a=t.audioTrack,u=t.videoTrack;a.samples&&a.segmentCodec==="aac"?e.decryptAacSamples(a.samples,0,function(){u.samples?e.decryptAvcSamples(u.samples,0,0,function(){r(t)}):r(t)}):u.samples&&e.decryptAvcSamples(u.samples,0,0,function(){r(t)})})},s.destroy=function(){this.observer&&this.observer.removeAllListeners(),this.config=this.logger=this.observer=null,this.aacOverFlow=this.videoParser=this.remainderData=this.sampleAes=null,this._videoTrack=this._audioTrack=this._id3Track=this._txtTrack=void 0},s.parseAACPES=function(t,e){var r=0,a=this.aacOverFlow,u=e.data;if(a){this.aacOverFlow=null;var l=a.missing,d=a.sample.unit.byteLength;if(l===-1)u=Ot(a.sample.unit,u);else{var c=d-l;a.sample.unit.set(u.subarray(0,l),c),t.samples.push(a.sample),r=a.missing}}var p,y;for(p=r,y=u.length;p<y-1&&!di(u,p);p++);if(p!==r){var A,T=p<y-1;if(T?A="AAC PES did not start with ADTS header,offset:"+p:A="No ADTS header found in AAC PES",pi(this.observer,new Error(A),T,this.logger),!T)return}$a(t,this.observer,u,p,this.audioCodec);var b;if(e.pts!==void 0)b=e.pts;else if(a){var L=Xa(t.samplerate);b=a.sample.pts+L}else{this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var R=0,C;p<y;)if(C=Qa(t,u,p,b,R),p+=C.length,C.missing){this.aacOverFlow=C;break}else for(R++;p<y-1&&!di(u,p);p++);},s.parseMPEGPES=function(t,e){var r=e.data,a=r.length,u=0,l=0,d=e.pts;if(d===void 0){this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;l<a;)if(ns(r,l)){var c=rs(t,r,l,d,u);if(c)l+=c.length,u++;else break}else l++},s.parseAC3PES=function(t,e){},s.parseID3PES=function(t,e){if(e.pts===void 0){this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}var r=E({},e,{type:this._videoTrack?Lt.emsg:Lt.audioId3,duration:Number.POSITIVE_INFINITY});t.samples.push(r)},n}();function tn(n,s){return((n[s+1]&31)<<8)+n[s+2]}function ql(n,s){return(n[s+10]&31)<<8|n[s+11]}function $l(n,s,i,t,e,r){var a={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},u=(n[s+1]&15)<<8|n[s+2],l=s+3+u-4,d=(n[s+10]&15)<<8|n[s+11];for(s+=12+d;s<l;){var c=tn(n,s),p=(n[s+3]&15)<<8|n[s+4];switch(n[s]){case 207:if(!t){rn("ADTS AAC",r);break}case 15:a.audioPid===-1&&(a.audioPid=c);break;case 21:a.id3Pid===-1&&(a.id3Pid=c);break;case 219:if(!t){rn("H.264",r);break}case 27:a.videoPid===-1&&(a.videoPid=c);break;case 3:case 4:!i.mpeg&&!i.mp3?r.log("MPEG audio found, not supported in this browser"):a.audioPid===-1&&(a.audioPid=c,a.segmentAudioCodec="mp3");break;case 193:if(!t){rn("AC-3",r);break}case 129:r.warn("AC-3 in M2TS support not included in build");break;case 6:if(a.audioPid===-1&&p>0)for(var y=s+5,A=p;A>2;){var T=n[y];switch(T){case 106:r.warn("AC-3 in M2TS support not included in build");break}var b=n[y+1]+2;y+=b,A-=b}break;case 194:case 135:return pi(e,new Error("Unsupported EC-3 in M2TS found"),void 0,r),a;case 36:return pi(e,new Error("Unsupported HEVC in M2TS found"),void 0,r),a}s+=p+5}return a}function pi(n,s,i,t){t.warn("parsing error: "+s.message),n.emit(x.ERROR,x.ERROR,{type:Y.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,fatal:!1,levelRetry:i,error:s,reason:s.message})}function rn(n,s){s.log(n+" with AES-128-CBC encryption found in unencrypted stream")}function mr(n,s){var i=0,t,e,r,a,u,l=n.data;if(!n||n.size===0)return null;for(;l[0].length<19&&l.length>1;)l[0]=Ot(l[0],l[1]),l.splice(1,1);t=l[0];var d=(t[0]<<16)+(t[1]<<8)+t[2];if(d===1){if(e=(t[4]<<8)+t[5],e&&e>n.size-6)return null;var c=t[7];c&192&&(a=(t[9]&14)*536870912+(t[10]&255)*4194304+(t[11]&254)*16384+(t[12]&255)*128+(t[13]&254)/2,c&64?(u=(t[14]&14)*536870912+(t[15]&255)*4194304+(t[16]&254)*16384+(t[17]&255)*128+(t[18]&254)/2,a-u>60*9e4&&(s.warn(Math.round((a-u)/9e4)+"s delta between PTS and DTS, align them"),a=u)):u=a),r=t[8];var p=r+9;if(n.size<=p)return null;n.size-=p;for(var y=new Uint8Array(n.size),A=0,T=l.length;A<T;A++){t=l[A];var b=t.byteLength;if(p)if(p>b){p-=b;continue}else t=t.subarray(p),b-=p,p=0;y.set(t,i),i+=b}return e&&(e-=r+3),{data:y,pts:a,dts:u,len:e}}return null}var Xl=function(){function n(){}return n.getSilentFrame=function(i,t){switch(i){case"mp4a.40.2":if(t===1)return new Uint8Array([0,200,0,128,35,128]);if(t===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(t===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(t===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(t===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(t===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(t===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}},n}(),sr=Math.pow(2,32)-1,lt=function(){function n(){}return n.init=function(){n.types={avc1:[],avcC:[],hvc1:[],hvcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var i;for(i in n.types)n.types.hasOwnProperty(i)&&(n.types[i]=[i.charCodeAt(0),i.charCodeAt(1),i.charCodeAt(2),i.charCodeAt(3)]);var t=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),e=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);n.HDLR_TYPES={video:t,audio:e};var r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),a=new Uint8Array([0,0,0,0,0,0,0,0]);n.STTS=n.STSC=n.STCO=a,n.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),n.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),n.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),n.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var u=new Uint8Array([105,115,111,109]),l=new Uint8Array([97,118,99,49]),d=new Uint8Array([0,0,0,1]);n.FTYP=n.box(n.types.ftyp,u,d,u,l),n.DINF=n.box(n.types.dinf,n.box(n.types.dref,r))},n.box=function(i){for(var t=8,e=arguments.length,r=new Array(e>1?e-1:0),a=1;a<e;a++)r[a-1]=arguments[a];for(var u=r.length,l=u;u--;)t+=r[u].byteLength;var d=new Uint8Array(t);for(d[0]=t>>24&255,d[1]=t>>16&255,d[2]=t>>8&255,d[3]=t&255,d.set(i,4),u=0,t=8;u<l;u++)d.set(r[u],t),t+=r[u].byteLength;return d},n.hdlr=function(i){return n.box(n.types.hdlr,n.HDLR_TYPES[i])},n.mdat=function(i){return n.box(n.types.mdat,i)},n.mdhd=function(i,t){t*=i;var e=Math.floor(t/(sr+1)),r=Math.floor(t%(sr+1));return n.box(n.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,i>>24&255,i>>16&255,i>>8&255,i&255,e>>24,e>>16&255,e>>8&255,e&255,r>>24,r>>16&255,r>>8&255,r&255,85,196,0,0]))},n.mdia=function(i){return n.box(n.types.mdia,n.mdhd(i.timescale||0,i.duration||0),n.hdlr(i.type),n.minf(i))},n.mfhd=function(i){return n.box(n.types.mfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,i&255]))},n.minf=function(i){return i.type==="audio"?n.box(n.types.minf,n.box(n.types.smhd,n.SMHD),n.DINF,n.stbl(i)):n.box(n.types.minf,n.box(n.types.vmhd,n.VMHD),n.DINF,n.stbl(i))},n.moof=function(i,t,e){return n.box(n.types.moof,n.mfhd(i),n.traf(e,t))},n.moov=function(i){for(var t=i.length,e=[];t--;)e[t]=n.trak(i[t]);return n.box.apply(null,[n.types.moov,n.mvhd(i[0].timescale||0,i[0].duration||0)].concat(e).concat(n.mvex(i)))},n.mvex=function(i){for(var t=i.length,e=[];t--;)e[t]=n.trex(i[t]);return n.box.apply(null,[n.types.mvex].concat(e))},n.mvhd=function(i,t){t*=i;var e=Math.floor(t/(sr+1)),r=Math.floor(t%(sr+1)),a=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,i>>24&255,i>>16&255,i>>8&255,i&255,e>>24,e>>16&255,e>>8&255,e&255,r>>24,r>>16&255,r>>8&255,r&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return n.box(n.types.mvhd,a)},n.sdtp=function(i){var t=i.samples||[],e=new Uint8Array(4+t.length),r,a;for(r=0;r<t.length;r++)a=t[r].flags,e[r+4]=a.dependsOn<<4|a.isDependedOn<<2|a.hasRedundancy;return n.box(n.types.sdtp,e)},n.stbl=function(i){return n.box(n.types.stbl,n.stsd(i),n.box(n.types.stts,n.STTS),n.box(n.types.stsc,n.STSC),n.box(n.types.stsz,n.STSZ),n.box(n.types.stco,n.STCO))},n.avc1=function(i){var t=[],e=[],r,a,u;for(r=0;r<i.sps.length;r++)a=i.sps[r],u=a.byteLength,t.push(u>>>8&255),t.push(u&255),t=t.concat(Array.prototype.slice.call(a));for(r=0;r<i.pps.length;r++)a=i.pps[r],u=a.byteLength,e.push(u>>>8&255),e.push(u&255),e=e.concat(Array.prototype.slice.call(a));var l=n.box(n.types.avcC,new Uint8Array([1,t[3],t[4],t[5],255,224|i.sps.length].concat(t).concat([i.pps.length]).concat(e))),d=i.width,c=i.height,p=i.pixelRatio[0],y=i.pixelRatio[1];return n.box(n.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,d>>8&255,d&255,c>>8&255,c&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),l,n.box(n.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),n.box(n.types.pasp,new Uint8Array([p>>24,p>>16&255,p>>8&255,p&255,y>>24,y>>16&255,y>>8&255,y&255])))},n.esds=function(i){var t=i.config;return new Uint8Array([0,0,0,0,3,25,0,1,0,4,17,64,21,0,0,0,0,0,0,0,0,0,0,0,5,2].concat(t,[6,1,2]))},n.audioStsd=function(i){var t=i.samplerate||0;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,i.channelCount||0,0,16,0,0,0,0,t>>8&255,t&255,0,0])},n.mp4a=function(i){return n.box(n.types.mp4a,n.audioStsd(i),n.box(n.types.esds,n.esds(i)))},n.mp3=function(i){return n.box(n.types[".mp3"],n.audioStsd(i))},n.ac3=function(i){return n.box(n.types["ac-3"],n.audioStsd(i),n.box(n.types.dac3,i.config))},n.stsd=function(i){var t=i.segmentCodec;if(i.type==="audio"){if(t==="aac")return n.box(n.types.stsd,n.STSD,n.mp4a(i));if(t==="mp3"&&i.codec==="mp3")return n.box(n.types.stsd,n.STSD,n.mp3(i))}else if(i.pps&&i.sps){if(t==="avc")return n.box(n.types.stsd,n.STSD,n.avc1(i))}else throw new Error("video track missing pps or sps");throw new Error("unsupported "+i.type+" segment codec ("+t+"/"+i.codec+")")},n.tkhd=function(i){var t=i.id,e=(i.duration||0)*(i.timescale||0),r=i.width||0,a=i.height||0,u=Math.floor(e/(sr+1)),l=Math.floor(e%(sr+1));return n.box(n.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,t&255,0,0,0,0,u>>24,u>>16&255,u>>8&255,u&255,l>>24,l>>16&255,l>>8&255,l&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,r>>8&255,r&255,0,0,a>>8&255,a&255,0,0]))},n.traf=function(i,t){var e=n.sdtp(i),r=i.id,a=Math.floor(t/(sr+1)),u=Math.floor(t%(sr+1));return n.box(n.types.traf,n.box(n.types.tfhd,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,r&255])),n.box(n.types.tfdt,new Uint8Array([1,0,0,0,a>>24,a>>16&255,a>>8&255,a&255,u>>24,u>>16&255,u>>8&255,u&255])),n.trun(i,e.length+16+20+8+16+8+8),e)},n.trak=function(i){return i.duration=i.duration||4294967295,n.box(n.types.trak,n.tkhd(i),n.mdia(i))},n.trex=function(i){var t=i.id;return n.box(n.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},n.trun=function(i,t){var e=i.samples||[],r=e.length,a=12+16*r,u=new Uint8Array(a),l,d,c,p,y,A;for(t+=8+a,u.set([i.type==="video"?1:0,0,15,1,r>>>24&255,r>>>16&255,r>>>8&255,r&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255],0),l=0;l<r;l++)d=e[l],c=d.duration,p=d.size,y=d.flags,A=d.cts,u.set([c>>>24&255,c>>>16&255,c>>>8&255,c&255,p>>>24&255,p>>>16&255,p>>>8&255,p&255,y.isLeading<<2|y.dependsOn,y.isDependedOn<<6|y.hasRedundancy<<4|y.paddingValue<<1|y.isNonSync,y.degradPrio&61440,y.degradPrio&15,A>>>24&255,A>>>16&255,A>>>8&255,A&255],12+16*l);return n.box(n.types.trun,u)},n.initSegment=function(i){n.types||n.init();var t=n.moov(i),e=Ot(n.FTYP,t);return e},n.hvc1=function(i){return new Uint8Array},n}();lt.types=void 0,lt.HDLR_TYPES=void 0,lt.STTS=void 0,lt.STSC=void 0,lt.STCO=void 0,lt.STSZ=void 0,lt.VMHD=void 0,lt.SMHD=void 0,lt.STSD=void 0,lt.FTYP=void 0,lt.DINF=void 0;var Ql=9e4;function Zl(n,s,i,t){var e=n*s*i;return Math.round(e)}function Nr(n,s){return Zl(n,1e3,1/Ql)}var Jl=10*1e3,ef=1024,tf=1152,rf=1536,yr=null,nn=null;function ls(n,s,i,t){return{duration:s,size:i,cts:t,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:n?2:1,isNonSync:n?0:1}}}var an=function(){function n(i,t,e,r){if(this.logger=void 0,this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=i,this.config=t,this.typeSupported=e,this.logger=r,this.ISGenerated=!1,yr===null){var a=navigator.userAgent||"",u=a.match(/Chrome\/(\d+)/i);yr=u?parseInt(u[1]):0}if(nn===null){var l=navigator.userAgent.match(/Safari\/(\d+)/i);nn=l?parseInt(l[1]):0}}var s=n.prototype;return s.destroy=function(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null},s.resetTimeStamp=function(t){this.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=t},s.resetNextTimestamp=function(){this.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},s.resetInitSegment=function(){this.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0},s.getVideoStartPts=function(t){var e=!1,r=t[0].pts,a=t.reduce(function(u,l){var d=l.pts,c=d-u;return c<-4294967296&&(e=!0,d=Ft(d,r),c=d-u),c>0?u:d},r);return e&&this.logger.debug("PTS rollover detected"),a},s.remux=function(t,e,r,a,u,l,d,c){var p,y,A,T,b,L,R=u,C=u,I=t.pid>-1,k=e.pid>-1,O=e.samples.length,V=t.samples.length>0,N=d&&O>0||O>1,B=(!I||V)&&(!k||N)||this.ISGenerated||d;if(B){if(this.ISGenerated){var X,z,K,j,J=this.videoTrackConfig;(J&&(e.width!==J.width||e.height!==J.height||((X=e.pixelRatio)==null?void 0:X[0])!==((z=J.pixelRatio)==null?void 0:z[0])||((K=e.pixelRatio)==null?void 0:K[1])!==((j=J.pixelRatio)==null?void 0:j[1]))||!J&&N||this.nextAudioPts===null&&V)&&this.resetInitSegment()}this.ISGenerated||(A=this.generateIS(t,e,u,l));var le=this.isVideoContiguous,re=-1,te;if(N&&(re=nf(e.samples),!le&&this.config.forceKeyFrameOnDiscontinuity))if(L=!0,re>0){this.logger.warn("[mp4-remuxer]: Dropped "+re+" out of "+O+" video samples due to a missing keyframe");var fe=this.getVideoStartPts(e.samples);e.samples=e.samples.slice(re),e.dropped+=re,C+=(e.samples[0].pts-fe)/e.inputTimeScale,te=C}else re===-1&&(this.logger.warn("[mp4-remuxer]: No keyframe found out of "+O+" video samples"),L=!1);if(this.ISGenerated){if(V&&N){var de=this.getVideoStartPts(e.samples),ve=Ft(t.samples[0].pts,de)-de,ge=ve/e.inputTimeScale;R+=Math.max(0,ge),C+=Math.max(0,-ge)}if(V){if(t.samplerate||(this.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),A=this.generateIS(t,e,u,l)),y=this.remuxAudio(t,R,this.isAudioContiguous,l,k||N||c===ae.AUDIO?C:void 0),N){var Ne=y?y.endPTS-y.startPTS:0;e.inputTimeScale||(this.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),A=this.generateIS(t,e,u,l)),p=this.remuxVideo(e,C,le,Ne)}}else N&&(p=this.remuxVideo(e,C,le,0));p&&(p.firstKeyFrame=re,p.independent=re!==-1,p.firstKeyFramePTS=te)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(b=fs(r,u,this._initPTS,this._initDTS)),a.samples.length&&(T=hs(a,u,this._initPTS))),{audio:y,video:p,initSegment:A,independent:L,text:T,id3:b}},s.generateIS=function(t,e,r,a){var u=t.samples,l=e.samples,d=this.typeSupported,c={},p=this._initPTS,y=!p||a,A="audio/mp4",T,b,L;if(y&&(T=b=1/0),t.config&&u.length){switch(t.timescale=t.samplerate,t.segmentCodec){case"mp3":d.mpeg?(A="audio/mpeg",t.codec=""):d.mp3&&(t.codec="mp3");break;case"ac3":t.codec="ac-3";break}c.audio={id:"audio",container:A,codec:t.codec,initSegment:t.segmentCodec==="mp3"&&d.mpeg?new Uint8Array(0):lt.initSegment([t]),metadata:{channelCount:t.channelCount}},y&&(L=t.inputTimeScale,!p||L!==p.timescale?T=b=u[0].pts-Math.round(L*r):y=!1)}if(e.sps&&e.pps&&l.length){if(e.timescale=e.inputTimeScale,c.video={id:"main",container:"video/mp4",codec:e.codec,initSegment:lt.initSegment([e]),metadata:{width:e.width,height:e.height}},y)if(L=e.inputTimeScale,!p||L!==p.timescale){var R=this.getVideoStartPts(l),C=Math.round(L*r);b=Math.min(b,Ft(l[0].dts,R)-C),T=Math.min(T,R-C)}else y=!1;this.videoTrackConfig={width:e.width,height:e.height,pixelRatio:e.pixelRatio}}if(Object.keys(c).length)return this.ISGenerated=!0,y?(this._initPTS={baseTime:T,timescale:L},this._initDTS={baseTime:b,timescale:L}):T=L=void 0,{tracks:c,initPTS:T,timescale:L}},s.remuxVideo=function(t,e,r,a){var u=t.inputTimeScale,l=t.samples,d=[],c=l.length,p=this._initPTS,y=this.nextAvcDts,A=8,T=this.videoSampleDuration,b,L,R=Number.POSITIVE_INFINITY,C=Number.NEGATIVE_INFINITY,I=!1;if(!r||y===null){var k=e*u,O=l[0].pts-Ft(l[0].dts,l[0].pts);yr&&y!==null&&Math.abs(k-O-y)<15e3?r=!0:y=k-O}for(var V=p.baseTime*u/p.timescale,N=0;N<c;N++){var B=l[N];B.pts=Ft(B.pts-V,y),B.dts=Ft(B.dts-V,y),B.dts<l[N>0?N-1:N].dts&&(I=!0)}I&&l.sort(function(Ti,Hs){var Eh=Ti.dts-Hs.dts,_h=Ti.pts-Hs.pts;return Eh||_h}),b=l[0].dts,L=l[l.length-1].dts;var X=L-b,z=X?Math.round(X/(c-1)):T||t.inputTimeScale/30;if(r){var K=b-y,j=K>z,J=K<-1;if((j||J)&&(j?this.logger.warn((t.segmentCodec||"").toUpperCase()+": "+Nr(K)+" ms ("+K+"dts) hole between fragments detected at "+e.toFixed(3)):this.logger.warn((t.segmentCodec||"").toUpperCase()+": "+Nr(-K)+" ms ("+K+"dts) overlapping between fragments detected at "+e.toFixed(3)),!J||y>=l[0].pts||yr)){b=y;var le=l[0].pts-K;if(j)l[0].dts=b,l[0].pts=le;else for(var re=!0,te=0;te<l.length&&!(l[te].dts>le&&re);te++){var fe=l[te].pts;if(l[te].dts-=K,l[te].pts-=K,te<l.length-1){var de=l[te+1].pts,ve=l[te].pts,ge=de<=ve,Ne=de<=fe;re=ge==Ne}}this.logger.log("Video: Initial PTS/DTS adjusted: "+Nr(le)+"/"+Nr(b)+", delta: "+Nr(K)+" ms")}}b=Math.max(0,b);for(var we=0,Be=0,Ce=b,et=0;et<c;et++){for(var Ge=l[et],Qe=Ge.units,_t=Qe.length,ut=0,Ve=0;Ve<_t;Ve++)ut+=Qe[Ve].data.length;Be+=ut,we+=_t,Ge.length=ut,Ge.dts<Ce?(Ge.dts=Ce,Ce+=z/4|0||1):Ce=Ge.dts,R=Math.min(Ge.pts,R),C=Math.max(Ge.pts,C)}L=l[c-1].dts;var St=Be+4*we+8,it;try{it=new Uint8Array(St)}catch(Ti){this.observer.emit(x.ERROR,x.ERROR,{type:Y.MUX_ERROR,details:M.REMUX_ALLOC_ERROR,fatal:!1,error:Ti,bytes:St,reason:"fail allocating video mdat "+St});return}var $e=new DataView(it.buffer);$e.setUint32(0,St),it.set(lt.types.mdat,4);for(var Tt=!1,dt=Number.POSITIVE_INFINITY,xt=Number.POSITIVE_INFINITY,Ye=Number.NEGATIVE_INFINITY,ct=Number.NEGATIVE_INFINITY,nt=0;nt<c;nt++){for(var At=l[nt],Vr=At.units,Fs=0,vn=0,fh=Vr.length;vn<fh;vn++){var Ns=Vr[vn],hh=Ns.data,pn=Ns.data.byteLength;$e.setUint32(A,pn),A+=4,it.set(hh,A),A+=pn,Fs+=4+pn}var _i=void 0;if(nt<c-1)T=l[nt+1].dts-At.dts,_i=l[nt+1].pts-At.pts;else{var Us=this.config,Si=nt>0?At.dts-l[nt-1].dts:z;if(_i=nt>0?At.pts-l[nt-1].pts:z,Us.stretchShortVideoTrack&&this.nextAudioPts!==null){var dh=Math.floor(Us.maxBufferHole*u),gn=(a?R+a*u:this.nextAudioPts)-At.pts;gn>dh?(T=gn-Si,T<0?T=Si:Tt=!0,this.logger.log("[mp4-remuxer]: It is approximately "+gn/90+" ms to the next segment; using duration "+T/90+" ms for the last video frame.")):T=Si}else T=Si}var ch=Math.round(At.pts-At.dts);dt=Math.min(dt,T),Ye=Math.max(Ye,T),xt=Math.min(xt,_i),ct=Math.max(ct,_i),d.push(ls(At.key,T,Fs,ch))}if(d.length){if(yr){if(yr<70){var Bs=d[0].flags;Bs.dependsOn=2,Bs.isNonSync=0}}else if(nn&&ct-xt<Ye-dt&&z/Ye<.025&&d[0].cts===0){this.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var mn=b,Nt=0,Gs=d.length;Nt<Gs;Nt++){var Vs=mn+d[Nt].duration,vh=mn+d[Nt].cts;if(Nt<Gs-1){var ph=Vs+d[Nt+1].cts;d[Nt].duration=ph-vh}else d[Nt].duration=Nt?d[Nt-1].duration:z;d[Nt].cts=0,mn=Vs}}}T=Tt||!T?z:T,this.nextAvcDts=y=L+T,this.videoSampleDuration=T,this.isVideoContiguous=!0;var gh=lt.moof(t.sequenceNumber++,b,E(t,{samples:d})),mh="video",yh={data1:gh,data2:it,startPTS:R/u,endPTS:(C+T)/u,startDTS:b/u,endDTS:y/u,type:mh,hasAudio:!1,hasVideo:!0,nb:d.length,dropped:t.dropped};return t.samples=[],t.dropped=0,yh},s.getSamplesPerFrame=function(t){switch(t.segmentCodec){case"mp3":return tf;case"ac3":return rf;default:return ef}},s.remuxAudio=function(t,e,r,a,u){var l=t.inputTimeScale,d=t.samplerate?t.samplerate:l,c=l/d,p=this.getSamplesPerFrame(t),y=p*c,A=this._initPTS,T=t.segmentCodec==="mp3"&&this.typeSupported.mpeg,b=[],L=u!==void 0,R=t.samples,C=T?0:8,I=this.nextAudioPts||-1,k=e*l,O=A.baseTime*l/A.timescale;if(this.isAudioContiguous=r=r||R.length&&I>0&&(a&&Math.abs(k-I)<9e3||Math.abs(Ft(R[0].pts-O,k)-I)<20*y),R.forEach(function(Ye){Ye.pts=Ft(Ye.pts-O,k)}),!r||I<0){if(R=R.filter(function(Ye){return Ye.pts>=0}),!R.length)return;u===0?I=0:a&&!L?I=Math.max(0,k):I=R[0].pts}if(t.segmentCodec==="aac")for(var V=this.config.maxAudioFramesDrift,N=0,B=I;N<R.length;N++){var X=R[N],z=X.pts,K=z-B,j=Math.abs(1e3*K/l);if(K<=-V*y&&L)N===0&&(this.logger.warn("Audio frame @ "+(z/l).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*K/l)+" ms."),this.nextAudioPts=I=B=z);else if(K>=V*y&&j<Jl&&L){var J=Math.round(K/y);B=z-J*y,B<0&&(J--,B+=y),N===0&&(this.nextAudioPts=I=B),this.logger.warn("[mp4-remuxer]: Injecting "+J+" audio frame @ "+(B/l).toFixed(3)+"s due to "+Math.round(1e3*K/l)+" ms gap.");for(var le=0;le<J;le++){var re=Math.max(B,0),te=Xl.getSilentFrame(t.parsedCodec||t.manifestCodec||t.codec,t.channelCount);te||(this.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),te=X.unit.subarray()),R.splice(N,0,{unit:te,pts:re}),B+=y,N++}}X.pts=B,B+=y}for(var fe=null,de=null,ve,ge=0,Ne=R.length;Ne--;)ge+=R[Ne].unit.byteLength;for(var we=0,Be=R.length;we<Be;we++){var Ce=R[we],et=Ce.unit,Ge=Ce.pts;if(de!==null){var Qe=b[we-1];Qe.duration=Math.round((Ge-de)/c)}else if(r&&t.segmentCodec==="aac"&&(Ge=I),fe=Ge,ge>0){ge+=C;try{ve=new Uint8Array(ge)}catch(Ye){this.observer.emit(x.ERROR,x.ERROR,{type:Y.MUX_ERROR,details:M.REMUX_ALLOC_ERROR,fatal:!1,error:Ye,bytes:ge,reason:"fail allocating audio mdat "+ge});return}if(!T){var _t=new DataView(ve.buffer);_t.setUint32(0,ge),ve.set(lt.types.mdat,4)}}else return;ve.set(et,C);var ut=et.byteLength;C+=ut,b.push(ls(!0,p,ut,0)),de=Ge}var Ve=b.length;if(Ve){var St=b[b.length-1];this.nextAudioPts=I=de+c*St.duration;var it=T?new Uint8Array(0):lt.moof(t.sequenceNumber++,fe/c,E({},t,{samples:b}));t.samples=[];var $e=fe/l,Tt=I/l,dt="audio",xt={data1:it,data2:ve,startPTS:$e,endPTS:Tt,startDTS:$e,endDTS:Tt,type:dt,hasAudio:!0,hasVideo:!1,nb:Ve};return this.isAudioContiguous=!0,xt}},n}();function Ft(n,s){var i;if(s===null)return n;for(s<n?i=-8589934592:i=8589934592;Math.abs(n-s)>4294967296;)n+=i;return n}function nf(n){for(var s=0;s<n.length;s++)if(n[s].key)return s;return-1}function fs(n,s,i,t){var e=n.samples.length;if(e){for(var r=n.inputTimeScale,a=0;a<e;a++){var u=n.samples[a];u.pts=Ft(u.pts-i.baseTime*r/i.timescale,s*r)/r,u.dts=Ft(u.dts-t.baseTime*r/t.timescale,s*r)/r}var l=n.samples;return n.samples=[],{samples:l}}}function hs(n,s,i){var t=n.samples.length;if(t){for(var e=n.inputTimeScale,r=0;r<t;r++){var a=n.samples[r];a.pts=Ft(a.pts-i.baseTime*e/i.timescale,s*e)/e}n.samples.sort(function(l,d){return l.pts-d.pts});var u=n.samples;return n.samples=[],{samples:u}}}var af=function(){function n(i,t,e,r){this.logger=void 0,this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null,this.logger=r}var s=n.prototype;return s.destroy=function(){},s.resetTimeStamp=function(t){this.initPTS=t,this.lastEndTime=null},s.resetNextTimestamp=function(){this.lastEndTime=null},s.resetInitSegment=function(t,e,r,a){this.audioCodec=e,this.videoCodec=r,this.generateInitSegment(su(t,a)),this.emitInitSegment=!0},s.generateInitSegment=function(t){var e=this.audioCodec,r=this.videoCodec;if(!(t!=null&&t.byteLength)){this.initTracks=void 0,this.initData=void 0;return}var a=this.initData=ea(t);a.audio&&(e=ds(a.audio,qe.AUDIO)),a.video&&(r=ds(a.video,qe.VIDEO));var u={};a.audio&&a.video?u.audiovideo={container:"video/mp4",codec:e+","+r,supplemental:a.video.supplemental,initSegment:t,id:"main"}:a.audio?u.audio={container:"audio/mp4",codec:e,initSegment:t,id:"audio"}:a.video?u.video={container:"video/mp4",codec:r,supplemental:a.video.supplemental,initSegment:t,id:"main"}:this.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=u},s.remux=function(t,e,r,a,u,l){var d,c,p=this.initPTS,y=this.lastEndTime,A={audio:void 0,video:void 0,text:a,id3:r,initSegment:void 0};w(y)||(y=this.lastEndTime=u||0);var T=e.samples;if(!(T!=null&&T.length))return A;var b={initPTS:void 0,timescale:1},L=this.initData;if((d=L)!=null&&d.length||(this.generateInitSegment(T),L=this.initData),!((c=L)!=null&&c.length))return this.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),A;this.emitInitSegment&&(b.tracks=this.initTracks,this.emitInitSegment=!1);var R=lu(T,L),C=uu(L,T),I=C===null?u:C;(l||!p)&&(sf(p,I,u,R)||b.timescale!==p.timescale)&&(b.initPTS=I-u,p&&p.timescale===1&&this.logger.warn("Adjusting initPTS @"+u+" from "+p.baseTime/p.timescale+" to "+b.initPTS),this.initPTS=p={baseTime:b.initPTS,timescale:1});var k=t?I-p.baseTime/p.timescale:y,O=k+R;hu(L,T,p.baseTime/p.timescale),R>0?this.lastEndTime=O:(this.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var V=!!L.audio,N=!!L.video,B="";V&&(B+="audio"),N&&(B+="video");var X={data1:T,startPTS:k,startDTS:k,endPTS:O,endDTS:O,type:B,hasAudio:V,hasVideo:N,nb:1,dropped:0};return A.audio=X.type==="audio"?X:void 0,A.video=X.type!=="audio"?X:void 0,A.initSegment=b,A.id3=fs(r,u,p,p),a.samples.length&&(A.text=hs(a,u,p)),A},n}();function sf(n,s,i,t){if(n===null)return!0;var e=Math.max(t,1),r=s-n.baseTime/n.timescale;return Math.abs(r-i)>e}function ds(n,s){var i=n?.codec;if(i&&i.length>4)return i;if(s===qe.AUDIO){if(i==="ec-3"||i==="ac-3"||i==="alac")return i;if(i==="fLaC"||i==="Opus"){var t=!1;return ii(i,t)}return Oe.warn('Unhandled audio codec "'+i+'" in mp4 MAP'),i||"mp4a"}return Oe.warn('Unhandled video codec "'+i+'" in mp4 MAP'),i||"avc1"}var Zt;try{Zt=self.performance.now.bind(self.performance)}catch{Zt=Date.now}var sn=[{demux:Wl,remux:af},{demux:zl,remux:an},{demux:Ol,remux:an},{demux:Fl,remux:an}],on=function(){function n(i,t,e,r,a,u){this.asyncResult=!1,this.logger=void 0,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=i,this.typeSupported=t,this.config=e,this.id=a,this.logger=u}var s=n.prototype;return s.configure=function(t){this.transmuxConfig=t,this.decrypter&&this.decrypter.reset()},s.push=function(t,e,r,a){var u=this,l=r.transmuxing;l.executeStart=Zt();var d=new Uint8Array(t),c=this.currentTransmuxState,p=this.transmuxConfig;a&&(this.currentTransmuxState=a);var y=a||c,A=y.contiguous,T=y.discontinuity,b=y.trackSwitch,L=y.accurateTimeOffset,R=y.timeOffset,C=y.initSegmentChange,I=p.audioCodec,k=p.videoCodec,O=p.defaultInitPts,V=p.duration,N=p.initSegmentData,B=of(d,e);if(B&&Mr(B.method)){var X=this.getDecrypter(),z=xa(B.method);if(X.isSync()){var K=X.softwareDecrypt(d,B.key.buffer,B.iv.buffer,z),j=r.part>-1;if(j){var J=X.flush();K=J&&J.buffer}if(!K)return l.executeEnd=Zt(),un(r);d=new Uint8Array(K)}else return this.asyncResult=!0,this.decryptionPromise=X.webCryptoDecrypt(d,B.key.buffer,B.iv.buffer,z).then(function(de){var ve=u.push(de,null,r);return u.decryptionPromise=null,ve}),this.decryptionPromise}var le=this.needsProbing(T,b);if(le){var re=this.configureTransmuxer(d);if(re)return this.logger.warn("[transmuxer] "+re.message),this.observer.emit(x.ERROR,x.ERROR,{type:Y.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,fatal:!1,error:re,reason:re.message}),l.executeEnd=Zt(),un(r)}(T||b||C||le)&&this.resetInitSegment(N,I,k,V,e),(T||C||le)&&this.resetInitialTimestamp(O),A||this.resetContiguity();var te=this.transmux(d,B,R,L,r);this.asyncResult=dr(te);var fe=this.currentTransmuxState;return fe.contiguous=!0,fe.discontinuity=!1,fe.trackSwitch=!1,l.executeEnd=Zt(),te},s.flush=function(t){var e=this,r=t.transmuxing;r.executeStart=Zt();var a=this.decrypter,u=this.currentTransmuxState,l=this.decryptionPromise;if(l)return this.asyncResult=!0,l.then(function(){return e.flush(t)});var d=[],c=u.timeOffset;if(a){var p=a.flush();p&&d.push(this.push(p.buffer,null,t))}var y=this.demuxer,A=this.remuxer;if(!y||!A){r.executeEnd=Zt();var T=[un(t)];return this.asyncResult?Promise.resolve(T):T}var b=y.flush(c);return dr(b)?(this.asyncResult=!0,b.then(function(L){return e.flushRemux(d,L,t),d})):(this.flushRemux(d,b,t),this.asyncResult?Promise.resolve(d):d)},s.flushRemux=function(t,e,r){var a=e.audioTrack,u=e.videoTrack,l=e.id3Track,d=e.textTrack,c=this.currentTransmuxState,p=c.accurateTimeOffset,y=c.timeOffset;this.logger.log("[transmuxer.ts]: Flushed "+this.id+" sn: "+r.sn+(r.part>-1?" part: "+r.part:"")+" of "+(this.id===ae.MAIN?"level":"track")+" "+r.level);var A=this.remuxer.remux(a,u,l,d,y,p,!0,this.id);t.push({remuxResult:A,chunkMeta:r}),r.transmuxing.executeEnd=Zt()},s.resetInitialTimestamp=function(t){var e=this.demuxer,r=this.remuxer;!e||!r||(e.resetTimeStamp(t),r.resetTimeStamp(t))},s.resetContiguity=function(){var t=this.demuxer,e=this.remuxer;!t||!e||(t.resetContiguity(),e.resetNextTimestamp())},s.resetInitSegment=function(t,e,r,a,u){var l=this.demuxer,d=this.remuxer;!l||!d||(l.resetInitSegment(t,e,r,a),d.resetInitSegment(t,e,r,u))},s.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},s.transmux=function(t,e,r,a,u){var l;return e&&e.method==="SAMPLE-AES"?l=this.transmuxSampleAes(t,e,r,a,u):l=this.transmuxUnencrypted(t,r,a,u),l},s.transmuxUnencrypted=function(t,e,r,a){var u=this.demuxer.demux(t,e,!1,!this.config.progressive),l=u.audioTrack,d=u.videoTrack,c=u.id3Track,p=u.textTrack,y=this.remuxer.remux(l,d,c,p,e,r,!1,this.id);return{remuxResult:y,chunkMeta:a}},s.transmuxSampleAes=function(t,e,r,a,u){var l=this;return this.demuxer.demuxSampleAes(t,e,r).then(function(d){var c=l.remuxer.remux(d.audioTrack,d.videoTrack,d.id3Track,d.textTrack,r,a,!1,l.id);return{remuxResult:c,chunkMeta:u}})},s.configureTransmuxer=function(t){for(var e=this.config,r=this.observer,a=this.typeSupported,u,l=0,d=sn.length;l<d;l++){var c;if((c=sn[l].demux)!=null&&c.probe(t,this.logger)){u=sn[l];break}}if(!u)return new Error("Failed to find demuxer by probing fragment data");var p=this.demuxer,y=this.remuxer,A=u.remux,T=u.demux;(!y||!(y instanceof A))&&(this.remuxer=new A(r,e,a,this.logger)),(!p||!(p instanceof T))&&(this.demuxer=new T(r,e,a,this.logger),this.probe=T.probe)},s.needsProbing=function(t,e){return!this.demuxer||!this.remuxer||t||e},s.getDecrypter=function(){var t=this.decrypter;return t||(t=this.decrypter=new en(this.config)),t},n}();function of(n,s){var i=null;return n.byteLength>0&&s?.key!=null&&s.iv!==null&&s.method!=null&&(i=s),i}var un=function(s){return{remuxResult:{},chunkMeta:s}};function dr(n){return"then"in n&&n.then instanceof Function}var uf=function(s,i,t,e,r){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=s,this.videoCodec=i,this.initSegmentData=t,this.duration=e,this.defaultInitPts=r||null},lf=function(s,i,t,e,r,a){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=s,this.contiguous=i,this.accurateTimeOffset=t,this.trackSwitch=e,this.timeOffset=r,this.initSegmentChange=a};function ff(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var hf=/(\d+)-(\d+)\/(\d+)/,cs=function(){function n(i){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=i.fetchSetup||pf,this.controller=new self.AbortController,this.stats=new Fi}var s=n.prototype;return s.destroy=function(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null},s.abortInternal=function(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())},s.abort=function(){var t;this.abortInternal(),(t=this.callbacks)!=null&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},s.load=function(t,e,r){var a=this,u=this.stats;if(u.loading.start)throw new Error("Loader can only be used once.");u.loading.start=self.performance.now();var l=df(t,this.controller.signal),d=t.responseType==="arraybuffer",c=d?"byteLength":"length",p=e.loadPolicy,y=p.maxTimeToFirstByteMs,A=p.maxLoadTimeMs;this.context=t,this.config=e,this.callbacks=r,this.request=this.fetchSetup(t,l),self.clearTimeout(this.requestTimeout),e.timeout=y&&w(y)?y:A,this.requestTimeout=self.setTimeout(function(){a.callbacks&&(a.abortInternal(),a.callbacks.onTimeout(u,t,a.response))},e.timeout);var T=dr(this.request)?this.request.then(self.fetch):self.fetch(this.request);T.then(function(b){var L;a.response=a.loader=b;var R=Math.max(self.performance.now(),u.loading.start);if(self.clearTimeout(a.requestTimeout),e.timeout=A,a.requestTimeout=self.setTimeout(function(){a.callbacks&&(a.abortInternal(),a.callbacks.onTimeout(u,t,a.response))},A-(R-u.loading.start)),!b.ok){var C=b.status,I=b.statusText;throw new gf(I||"fetch, bad network response",C,b)}u.loading.first=R,u.total=vf(b.headers)||u.total;var k=(L=a.callbacks)==null?void 0:L.onProgress;return k&&w(e.highWaterMark)?a.loadProgressively(b,u,t,e.highWaterMark,k):d?b.arrayBuffer():t.responseType==="json"?b.json():b.text()}).then(function(b){var L,R,C=a.response;if(!C)throw new Error("loader destroyed");self.clearTimeout(a.requestTimeout),u.loading.end=Math.max(self.performance.now(),u.loading.first);var I=b[c];I&&(u.loaded=u.total=I);var k={url:C.url,data:b,code:C.status},O=(L=a.callbacks)==null?void 0:L.onProgress;O&&!w(e.highWaterMark)&&O(u,t,b,C),(R=a.callbacks)==null||R.onSuccess(k,u,t,C)}).catch(function(b){var L;if(self.clearTimeout(a.requestTimeout),!u.aborted){var R=b&&b.code||0,C=b?b.message:null;(L=a.callbacks)==null||L.onError({code:R,text:C},t,b?b.details:null,u)}})},s.getCacheAge=function(){var t=null;if(this.response){var e=this.response.headers.get("age");t=e?parseFloat(e):null}return t},s.getResponseHeader=function(t){return this.response?this.response.headers.get(t):null},s.loadProgressively=function(t,e,r,a,u){a===void 0&&(a=0);var l=new ul,d=t.body.getReader(),c=function(){return d.read().then(function(y){if(y.done)return l.dataLength&&u(e,r,l.flush().buffer,t),Promise.resolve(new ArrayBuffer(0));var A=y.value,T=A.length;return e.loaded+=T,T<a||l.dataLength?(l.push(A),l.dataLength>=a&&u(e,r,l.flush().buffer,t)):u(e,r,A.buffer,t),c()}).catch(function(){return Promise.reject()})};return c()},n}();function df(n,s){var i={method:"GET",mode:"cors",credentials:"same-origin",signal:s,headers:new self.Headers(E({},n.headers))};return n.rangeEnd&&i.headers.set("Range","bytes="+n.rangeStart+"-"+String(n.rangeEnd-1)),i}function cf(n){var s=hf.exec(n);if(s)return parseInt(s[2])-parseInt(s[1])+1}function vf(n){var s=n.get("Content-Range");if(s){var i=cf(s);if(w(i))return i}var t=n.get("Content-Length");if(t)return parseInt(t)}function pf(n,s){return new self.Request(n.url,s)}var gf=function(n){function s(i,t,e){var r;return r=n.call(this,i)||this,r.code=void 0,r.details=void 0,r.code=t,r.details=e,r}return S(s,n),s}(Z(Error)),mf=/^age:\s*[\d.]+\s*$/im,vs=function(){function n(i){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=i&&i.xhrSetup||null,this.stats=new Fi,this.retryDelay=0}var s=n.prototype;return s.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null},s.abortInternal=function(){var t=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),t&&(t.onreadystatechange=null,t.onprogress=null,t.readyState!==4&&(this.stats.aborted=!0,t.abort()))},s.abort=function(){var t;this.abortInternal(),(t=this.callbacks)!=null&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},s.load=function(t,e,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=t,this.config=e,this.callbacks=r,this.loadInternal()},s.loadInternal=function(){var t=this,e=this.config,r=this.context;if(!(!e||!r)){var a=this.loader=new self.XMLHttpRequest,u=this.stats;u.loading.first=0,u.loaded=0,u.aborted=!1;var l=this.xhrSetup;l?Promise.resolve().then(function(){if(!(t.loader!==a||t.stats.aborted))return l(a,r.url)}).catch(function(d){if(!(t.loader!==a||t.stats.aborted))return a.open("GET",r.url,!0),l(a,r.url)}).then(function(){t.loader!==a||t.stats.aborted||t.openAndSendXhr(a,r,e)}).catch(function(d){var c;(c=t.callbacks)==null||c.onError({code:a.status,text:d.message},r,a,u)}):this.openAndSendXhr(a,r,e)}},s.openAndSendXhr=function(t,e,r){t.readyState||t.open("GET",e.url,!0);var a=e.headers,u=r.loadPolicy,l=u.maxTimeToFirstByteMs,d=u.maxLoadTimeMs;if(a)for(var c in a)t.setRequestHeader(c,a[c]);e.rangeEnd&&t.setRequestHeader("Range","bytes="+e.rangeStart+"-"+(e.rangeEnd-1)),t.onreadystatechange=this.readystatechange.bind(this),t.onprogress=this.loadprogress.bind(this),t.responseType=e.responseType,self.clearTimeout(this.requestTimeout),r.timeout=l&&w(l)?l:d,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),t.send()},s.readystatechange=function(){var t=this.context,e=this.loader,r=this.stats;if(!(!t||!e)){var a=e.readyState,u=this.config;if(!r.aborted&&a>=2&&(r.loading.first===0&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),u.timeout!==u.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),u.timeout=u.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),u.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),a===4)){self.clearTimeout(this.requestTimeout),e.onreadystatechange=null,e.onprogress=null;var l=e.status,d=e.responseType==="text"?e.responseText:null;if(l>=200&&l<300){var c=d??e.response;if(c!=null){var p,y;r.loading.end=Math.max(self.performance.now(),r.loading.first);var A=e.responseType==="arraybuffer"?c.byteLength:c.length;r.loaded=r.total=A,r.bwEstimate=r.total*8e3/(r.loading.end-r.loading.first);var T=(p=this.callbacks)==null?void 0:p.onProgress;T&&T(r,t,c,e);var b={url:e.responseURL,data:c,code:l};(y=this.callbacks)==null||y.onSuccess(b,r,t,e);return}}var L=u.loadPolicy.errorRetry,R=r.retry,C={url:t.url,data:void 0,code:l};if(ui(L,R,!1,C))this.retry(L);else{var I;Oe.error(l+" while loading "+t.url),(I=this.callbacks)==null||I.onError({code:l,text:e.statusText},t,e,r)}}}},s.loadtimeout=function(){if(this.config){var t=this.config.loadPolicy.timeoutRetry,e=this.stats.retry;if(ui(t,e,!0))this.retry(t);else{var r;Oe.warn("timeout while loading "+((r=this.context)==null?void 0:r.url));var a=this.callbacks;a&&(this.abortInternal(),a.onTimeout(this.stats,this.context,this.loader))}}},s.retry=function(t){var e=this.context,r=this.stats;this.retryDelay=ji(t,r.retry),r.retry++,Oe.warn((status?"HTTP Status "+status:"Timeout")+" while loading "+e?.url+", retrying "+r.retry+"/"+t.maxNumRetry+" in "+this.retryDelay+"ms"),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)},s.loadprogress=function(t){var e=this.stats;e.loaded=t.loaded,t.lengthComputable&&(e.total=t.total)},s.getCacheAge=function(){var t=null;if(this.loader&&mf.test(this.loader.getAllResponseHeaders())){var e=this.loader.getResponseHeader("age");t=e?parseFloat(e):null}return t},s.getResponseHeader=function(t){return this.loader&&new RegExp("^"+t+":\\s*[\\d.]+\\s*$","im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(t):null},n}(),ps={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},yf=H(H({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,maxDevicePixelRatio:Number.POSITIVE_INFINITY,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,maxBufferSize:60*1e3*1e3,maxFragLookUpTolerance:.25,maxBufferHole:.1,detectStallWithCurrentTimeMs:1250,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,nudgeOnVideoHole:!0,liveSyncDurationCount:3,liveSyncOnStallIncrease:1,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,ignorePlaylistParsingErrors:!1,loader:vs,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:ku,bufferController:Uu,capLevelController:Gu,errorController:Fu,fpsController:ol,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:null,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableEmsgKLVMetadata:!1,enableID3MetadataCues:!0,enableInterstitialPlayback:!1,interstitialAppendInPlace:!0,interstitialLiveLookAhead:10,useMediaCapabilities:!1,certLoadPolicy:{default:ps},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},interstitialAssetListLoadPolicy:{default:ps},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},Ef()),{},{subtitleStreamController:void 0,subtitleTrackController:void 0,timelineController:void 0,audioStreamController:void 0,audioTrackController:void 0,emeController:void 0,cmcdController:void 0,contentSteeringController:sl,interstitialsController:void 0});function Ef(){return{cueHandler:Jo,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 _f(n,s,i){if((s.liveSyncDurationCount||s.liveMaxLatencyDurationCount)&&(s.liveSyncDuration||s.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(s.liveMaxLatencyDurationCount!==void 0&&(s.liveSyncDurationCount===void 0||s.liveMaxLatencyDurationCount<=s.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(s.liveMaxLatencyDuration!==void 0&&(s.liveSyncDuration===void 0||s.liveMaxLatencyDuration<=s.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var t=ln(n),e=["manifest","level","frag"],r=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return e.forEach(function(a){var u=(a==="level"?"playlist":a)+"LoadPolicy",l=s[u]===void 0,d=[];r.forEach(function(c){var p=a+"Loading"+c,y=s[p];if(y!==void 0&&l){d.push(p);var A=t[u].default;switch(s[u]={default:A},c){case"TimeOut":A.maxLoadTimeMs=y,A.maxTimeToFirstByteMs=y;break;case"MaxRetry":A.errorRetry.maxNumRetry=y,A.timeoutRetry.maxNumRetry=y;break;case"RetryDelay":A.errorRetry.retryDelayMs=y,A.timeoutRetry.retryDelayMs=y;break;case"MaxRetryTimeout":A.errorRetry.maxRetryDelayMs=y,A.timeoutRetry.maxRetryDelayMs=y;break}}}),d.length&&i.warn('hls.js config: "'+d.join('", "')+'" setting(s) are deprecated, use "'+u+'": '+gt(s[u]))}),H(H({},t),s)}function ln(n){return n&&typeof n=="object"?Array.isArray(n)?n.map(ln):Object.keys(n).reduce(function(s,i){return s[i]=ln(n[i]),s},{}):n}function Sf(n,s){var i=n.loader;if(i!==cs&&i!==vs)s.log("[config]: Custom loader detected, cannot enable progressive streaming"),n.progressive=!1;else{var t=ff();t&&(n.loader=cs,n.progressive=!0,n.enableSoftwareAES=!0,s.log("[config]: Progressive streaming enabled, using FetchLoader"))}}var Et={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"},Tf=function(){function n(i){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=i,this._registerListeners()}var s=n.prototype;return s._registerListeners=function(){var t=this.hls;t.on(x.MANIFEST_LOADING,this.onManifestLoading,this),t.on(x.BUFFER_APPENDED,this.onBufferAppended,this),t.on(x.FRAG_BUFFERED,this.onFragBuffered,this),t.on(x.FRAG_LOADED,this.onFragLoaded,this)},s._unregisterListeners=function(){var t=this.hls;t.off(x.MANIFEST_LOADING,this.onManifestLoading,this),t.off(x.BUFFER_APPENDED,this.onBufferAppended,this),t.off(x.FRAG_BUFFERED,this.onFragBuffered,this),t.off(x.FRAG_LOADED,this.onFragLoaded,this)},s.destroy=function(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null},s.getAppendedFrag=function(t,e){var r=this.activePartLists[e];if(r)for(var a=r.length;a--;){var u=r[a];if(!u)break;var l=u.end;if(u.start<=t&&l!==null&&t<=l)return u}return this.getBufferedFrag(t,e)},s.getBufferedFrag=function(t,e){return this.getFragAtPos(t,e,!0)},s.getFragAtPos=function(t,e,r){for(var a=this.fragments,u=Object.keys(a),l=u.length;l--;){var d=a[u[l]];if(d?.body.type===e&&(!r||d.buffered)){var c=d.body;if(c.start<=t&&t<=c.end)return c}}return null},s.detectEvictedFragments=function(t,e,r,a,u){var l=this;this.timeRanges&&(this.timeRanges[t]=e);var d=a?.fragment.sn||-1;Object.keys(this.fragments).forEach(function(c){var p=l.fragments[c];if(p&&!(d>=p.body.sn)){if(!p.buffered&&(!p.loaded||u)){p.body.type===r&&l.removeFragment(p.body);return}var y=p.range[t];if(y){if(y.time.length===0){l.removeFragment(p.body);return}y.time.some(function(A){var T=!l.isTimeBuffered(A.startPTS,A.endPTS,e);return T&&l.removeFragment(p.body),T})}}})},s.detectPartialFragments=function(t){var e=this,r=this.timeRanges;if(!(!r||t.frag.sn==="initSegment")){var a=t.frag,u=Er(a),l=this.fragments[u];if(!(!l||l.buffered&&a.gap)){var d=!a.relurl;if(Object.keys(r).forEach(function(p){var y=a.elementaryStreams[p];if(y){var A=r[p],T=d||y.partial===!0;l.range[p]=e.getBufferedTimes(a,t.part,T,A)}}),l.loaded=null,Object.keys(l.range).length){l.buffered=!0;var c=l.body.endList=a.endList||l.body.endList;c&&(this.endListFragments[l.body.type]=l),gi(l)||this.removeParts(a.sn-1,a.type)}else this.removeFragment(l.body)}}},s.removeParts=function(t,e){var r=this.activePartLists[e];r&&(this.activePartLists[e]=r.filter(function(a){return a.fragment.sn>=t}))},s.fragBuffered=function(t,e){var r=Er(t),a=this.fragments[r];!a&&e&&(a=this.fragments[r]={body:t,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},t.gap&&(this.hasGaps=!0)),a&&(a.loaded=null,a.buffered=!0)},s.getBufferedTimes=function(t,e,r,a){for(var u={time:[],partial:r},l=t.start,d=t.end,c=t.minEndPTS||d,p=t.maxStartPTS||l,y=0;y<a.length;y++){var A=a.start(y)-this.bufferPadding,T=a.end(y)+this.bufferPadding;if(p>=A&&c<=T){u.time.push({startPTS:Math.max(l,a.start(y)),endPTS:Math.min(d,a.end(y))});break}else if(l<T&&d>A){var b=Math.max(l,a.start(y)),L=Math.min(d,a.end(y));L>b&&(u.partial=!0,u.time.push({startPTS:b,endPTS:L}))}else if(d<=A)break}return u},s.getPartialFragment=function(t){var e=null,r,a,u,l=0,d=this.bufferPadding,c=this.fragments;return Object.keys(c).forEach(function(p){var y=c[p];y&&gi(y)&&(a=y.body.start-d,u=y.body.end+d,t>=a&&t<=u&&(r=Math.min(t-a,u-t),l<=r&&(e=y.body,l=r)))}),e},s.isEndListAppended=function(t){var e=this.endListFragments[t];return e!==void 0&&(e.buffered||gi(e))},s.getState=function(t){var e=Er(t),r=this.fragments[e];return r?r.buffered?gi(r)?Et.PARTIAL:Et.OK:Et.APPENDING:Et.NOT_LOADED},s.isTimeBuffered=function(t,e,r){for(var a,u,l=0;l<r.length;l++){if(a=r.start(l)-this.bufferPadding,u=r.end(l)+this.bufferPadding,t>=a&&e<=u)return!0;if(e<=a)return!1}return!1},s.onManifestLoading=function(){this.removeAllFragments()},s.onFragLoaded=function(t,e){if(!(e.frag.sn==="initSegment"||e.frag.bitrateTest)){var r=e.frag,a=e.part?null:e,u=Er(r);this.fragments[u]={body:r,appendedPTS:null,loaded:a,buffered:!1,range:Object.create(null)}}},s.onBufferAppended=function(t,e){var r=e.frag,a=e.part,u=e.timeRanges,l=e.type;if(r.sn!=="initSegment"){var d=r.type;if(a){var c=this.activePartLists[d];c||(this.activePartLists[d]=c=[]),c.push(a)}this.timeRanges=u;var p=u[l];this.detectEvictedFragments(l,p,d,a)}},s.onFragBuffered=function(t,e){this.detectPartialFragments(e)},s.hasFragment=function(t){var e=Er(t);return!!this.fragments[e]},s.hasFragments=function(t){var e=this.fragments,r=Object.keys(e);if(!t)return r.length>0;for(var a=r.length;a--;){var u=e[r[a]];if(u?.body.type===t)return!0}return!1},s.hasParts=function(t){var e;return!!((e=this.activePartLists[t])!=null&&e.length)},s.removeFragmentsInRange=function(t,e,r,a,u){var l=this;a&&!this.hasGaps||Object.keys(this.fragments).forEach(function(d){var c=l.fragments[d];if(c){var p=c.body;p.type!==r||a&&!p.gap||p.start<e&&p.end>t&&(c.buffered||u)&&l.removeFragment(p)}})},s.removeFragment=function(t){var e=Er(t);t.clearElementaryStreamInfo();var r=this.activePartLists[t.type];if(r){var a=t.sn;this.activePartLists[t.type]=r.filter(function(u){return u.fragment.sn!==a})}delete this.fragments[e],t.endList&&delete this.endListFragments[t.type]},s.removeAllFragments=function(){var t,e;this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1;var r=(t=this.hls)==null||(e=t.latestLevelDetails)==null?void 0:e.partList;r&&r.forEach(function(a){return a.clearElementaryStreamInfo()})},n}();function gi(n){var s,i,t;return n.buffered&&(n.body.gap||((s=n.range.video)==null?void 0:s.partial)||((i=n.range.audio)==null?void 0:i.partial)||((t=n.range.audiovideo)==null?void 0:t.partial))}function Er(n){return n.type+"_"+n.level+"_"+n.sn}var gs=Math.pow(2,17),Af=function(){function n(i){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=i}var s=n.prototype;return s.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},s.abort=function(){this.loader&&this.loader.abort()},s.load=function(t,e){var r=this,a=t.url;if(!a)return Promise.reject(new Jt({type:Y.NETWORK_ERROR,details:M.FRAG_LOAD_ERROR,fatal:!1,frag:t,error:new Error("Fragment does not have a "+(a?"part list":"url")),networkDetails:null}));this.abort();var u=this.config,l=u.fLoader,d=u.loader;return new Promise(function(c,p){if(r.loader&&r.loader.destroy(),t.gap)if(t.tagList.some(function(R){return R[0]==="GAP"})){p(ys(t));return}else t.gap=!1;var y=r.loader=l?new l(u):new d(u),A=ms(t);t.loader=y;var T=Ea(u.fragLoadPolicy.default),b={loadPolicy:T,timeout:T.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:t.sn==="initSegment"?1/0:gs};t.stats=y.stats;var L={onSuccess:function(C,I,k,O){r.resetLoader(t,y);var V=C.data;k.resetIV&&t.decryptdata&&(t.decryptdata.iv=new Uint8Array(V.slice(0,16)),V=V.slice(16)),c({frag:t,part:null,payload:V,networkDetails:O})},onError:function(C,I,k,O){r.resetLoader(t,y),p(new Jt({type:Y.NETWORK_ERROR,details:M.FRAG_LOAD_ERROR,fatal:!1,frag:t,response:H({url:a,data:void 0},C),error:new Error("HTTP Error "+C.code+" "+C.text),networkDetails:k,stats:O}))},onAbort:function(C,I,k){r.resetLoader(t,y),p(new Jt({type:Y.NETWORK_ERROR,details:M.INTERNAL_ABORTED,fatal:!1,frag:t,error:new Error("Aborted"),networkDetails:k,stats:C}))},onTimeout:function(C,I,k){r.resetLoader(t,y),p(new Jt({type:Y.NETWORK_ERROR,details:M.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,error:new Error("Timeout after "+b.timeout+"ms"),networkDetails:k,stats:C}))}};e&&(L.onProgress=function(R,C,I,k){return e({frag:t,part:null,payload:I,networkDetails:k})}),y.load(A,b,L)})},s.loadPart=function(t,e,r){var a=this;this.abort();var u=this.config,l=u.fLoader,d=u.loader;return new Promise(function(c,p){if(a.loader&&a.loader.destroy(),t.gap||e.gap){p(ys(t,e));return}var y=a.loader=l?new l(u):new d(u),A=ms(t,e);t.loader=y;var T=Ea(u.fragLoadPolicy.default),b={loadPolicy:T,timeout:T.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:gs};e.stats=y.stats,y.load(A,b,{onSuccess:function(R,C,I,k){a.resetLoader(t,y),a.updateStatsFromPart(t,e);var O={frag:t,part:e,payload:R.data,networkDetails:k};r(O),c(O)},onError:function(R,C,I,k){a.resetLoader(t,y),p(new Jt({type:Y.NETWORK_ERROR,details:M.FRAG_LOAD_ERROR,fatal:!1,frag:t,part:e,response:H({url:A.url,data:void 0},R),error:new Error("HTTP Error "+R.code+" "+R.text),networkDetails:I,stats:k}))},onAbort:function(R,C,I){t.stats.aborted=e.stats.aborted,a.resetLoader(t,y),p(new Jt({type:Y.NETWORK_ERROR,details:M.INTERNAL_ABORTED,fatal:!1,frag:t,part:e,error:new Error("Aborted"),networkDetails:I,stats:R}))},onTimeout:function(R,C,I){a.resetLoader(t,y),p(new Jt({type:Y.NETWORK_ERROR,details:M.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,part:e,error:new Error("Timeout after "+b.timeout+"ms"),networkDetails:I,stats:R}))}})})},s.updateStatsFromPart=function(t,e){var r=t.stats,a=e.stats,u=a.total;if(r.loaded+=a.loaded,u){var l=Math.round(t.duration/e.duration),d=Math.min(Math.round(r.loaded/u),l),c=l-d,p=c*Math.round(r.loaded/d);r.total=r.loaded+p}else r.total=Math.max(r.loaded,r.total);var y=r.loading,A=a.loading;y.start?y.first+=A.first-A.start:(y.start=A.start,y.first=A.first),y.end=A.end},s.resetLoader=function(t,e){t.loader=null,this.loader===e&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),e.destroy()},n}();function ms(n,s){s===void 0&&(s=null);var i=s||n,t={frag:n,part:s,responseType:"arraybuffer",url:i.url,headers:{},rangeStart:0,rangeEnd:0},e=i.byteRangeStartOffset,r=i.byteRangeEndOffset;if(w(e)&&w(r)){var a,u=e,l=r;if(n.sn==="initSegment"&&bf((a=n.decryptdata)==null?void 0:a.method)){var d=r-e;d%16&&(l=r+(16-d%16)),e!==0&&(t.resetIV=!0,u=e-16)}t.rangeStart=u,t.rangeEnd=l}return t}function ys(n,s){var i=new Error("GAP "+(n.gap?"tag":"attribute")+" found"),t={type:Y.MEDIA_ERROR,details:M.FRAG_GAP,fatal:!1,frag:n,error:i,networkDetails:null};return s&&(t.part=s),(s||n).stats.aborted=!0,new Jt(t)}function bf(n){return n==="AES-128"||n==="AES-256"}var Jt=function(n){function s(i){var t;return t=n.call(this,i.error.message)||this,t.data=void 0,t.data=i,t}return S(s,n),s}(Z(Error)),Es=function(n){function s(t,e){var r;return r=n.call(this,t,e)||this,r._boundTick=void 0,r._tickTimer=null,r._tickInterval=null,r._tickCallCount=0,r._boundTick=r.tick.bind(r),r}S(s,n);var i=s.prototype;return i.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},i.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},i.onHandlerDestroyed=function(){},i.hasInterval=function(){return!!this._tickInterval},i.hasNextTick=function(){return!!this._tickTimer},i.setInterval=function(e){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)},i.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},i.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},i.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},i.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},i.doTick=function(){},s}(je),_s=function(s,i,t,e,r,a){e===void 0&&(e=0),r===void 0&&(r=-1),a===void 0&&(a=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=mi(),this.buffering={audio:mi(),video:mi(),audiovideo:mi()},this.level=s,this.sn=i,this.id=t,this.size=e,this.part=r,this.partial=a};function mi(){return{start:0,executeStart:0,executeEnd:0,end:0}}function Ur(n,s){for(var i=0,t=n.length;i<t;i++){var e;if(((e=n[i])==null?void 0:e.cc)===s)return n[i]}return null}function Lf(n,s){return!!(n&&s.startCC<n.endCC&&s.endCC>n.startCC)}function Ss(n,s){if(n){var i=n.start+s;n.start=n.startPTS=i,n.endPTS=i+n.duration}}function Ts(n,s){for(var i=s.fragments,t=0,e=i.length;t<e;t++)Ss(i[t],n);s.fragmentHint&&Ss(s.fragmentHint,n),s.alignedSliding=!0}function xf(n,s){n&&(Rf(s,n),!s.alignedSliding&&n&&Cf(s,n),!s.alignedSliding&&n&&!s.skippedSegments&&Ba(n,s,!1))}function Rf(n,s){if(Lf(s,n)){var i=Math.min(s.endCC,n.endCC),t=Ur(s.fragments,i),e=Ur(n.fragments,i);if(!(!t||!e)){Oe.log("Aligning playlist at start of dicontinuity sequence "+i);var r=t.start-e.start;Ts(r,n)}}}function Cf(n,s){if(!(!n.hasProgramDateTime||!s.hasProgramDateTime)){var i=n.fragments,t=s.fragments;if(!(!i.length||!t.length)){var e,r,a=Math.min(s.endCC,n.endCC);s.startCC<a&&n.startCC<a&&(e=Ur(t,a),r=Ur(i,a)),(!e||!r)&&(e=t[Math.floor(t.length/2)],r=Ur(i,e.cc)||i[Math.floor(i.length/2)]);var u=e.programDateTime,l=r.programDateTime;if(!(!u||!l)){var d=(l-u)/1e3-(r.start-e.start);Ts(d,n)}}}}var kf={toString:function(s){for(var i="",t=s.length,e=0;e<t;e++)i+="["+s.start(e).toFixed(3)+"-"+s.end(e).toFixed(3)+"]";return i}},ne={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"},Df=function(n){function s(t,e,r,a,u){var l;return l=n.call(this,a,t.logger)||this,l.hls=void 0,l.fragPrevious=null,l.fragCurrent=null,l.fragmentTracker=void 0,l.transmuxer=null,l._state=ne.STOPPED,l.playlistType=void 0,l.media=null,l.mediaBuffer=null,l.config=void 0,l.bitrateTest=!1,l.lastCurrentTime=0,l.nextLoadPosition=0,l.startPosition=0,l.startTimeOffset=null,l.retryDate=0,l.levels=null,l.fragmentLoader=void 0,l.keyLoader=void 0,l.levelLastLoaded=null,l.startFragRequested=!1,l.decrypter=void 0,l.initPTS=[],l.buffering=!0,l.loadingParts=!1,l.loopSn=void 0,l.onMediaSeeking=function(){var d=l,c=d.config,p=d.fragCurrent,y=d.media,A=d.mediaBuffer,T=d.state,b=y?y.currentTime:0,L=Fe.bufferInfo(A||y,b,c.maxBufferHole);if(l.log("media seeking to "+(w(b)?b.toFixed(3):b)+", state: "+T),l.state===ne.ENDED)l.resetLoadingState();else if(p){var R=c.maxFragLookUpTolerance,C=p.start-R,I=p.start+p.duration+R;if(!L.len||I<L.start||C>L.end){var k=b>I;(b<C||k)&&(k&&p.loader&&(l.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),p.abortRequests(),l.resetLoadingState()),l.fragPrevious=null)}}if(y){l.fragmentTracker.removeFragmentsInRange(b,1/0,l.playlistType,!0);var O=l.lastCurrentTime;if(b>O&&(l.lastCurrentTime=b),!l.loadingParts){var V=Math.max(L.end,b),N=l.shouldLoadParts(l.getLevelDetails(),V);N&&(l.log("LL-Part loading ON after seeking to "+b.toFixed(2)+" with buffer @"+V.toFixed(2)),l.loadingParts=N)}}!l.hls.hasEnoughToStart&&!L.len&&(l.log("setting startPosition to "+b+" because of seek before start"),l.nextLoadPosition=l.startPosition=b),l.tickImmediate()},l.onMediaEnded=function(){l.log("setting startPosition to 0 because media ended"),l.startPosition=l.lastCurrentTime=0},l.playlistType=u,l.hls=t,l.fragmentLoader=new Af(t.config),l.keyLoader=r,l.fragmentTracker=e,l.config=t.config,l.decrypter=new en(t.config),l}S(s,n);var i=s.prototype;return i.registerListeners=function(){var e=this.hls;e.on(x.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(x.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(x.MANIFEST_LOADING,this.onManifestLoading,this),e.on(x.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(x.ERROR,this.onError,this)},i.unregisterListeners=function(){var e=this.hls;e.off(x.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(x.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(x.MANIFEST_LOADING,this.onManifestLoading,this),e.off(x.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(x.ERROR,this.onError,this)},i.doTick=function(){this.onTickEnd()},i.onTickEnd=function(){},i.startLoad=function(e){},i.stopLoad=function(){if(this.state!==ne.STOPPED){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);var e=this.fragCurrent;e!=null&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=ne.STOPPED}},i.pauseBuffering=function(){this.buffering=!1},i.resumeBuffering=function(){this.buffering=!0},i._streamEnded=function(e,r){if(r.live||!this.media)return!1;var a=e.end||0,u=this.config.timelineOffset||0;if(a<=u)return!1;var l=e.nextStart,d=l&&l>u&&l<r.edge;if(d||this.media.currentTime<e.start)return!1;var c=r.partList;if(c!=null&&c.length){var p=c[c.length-1],y=Fe.isBuffered(this.media,p.start+p.duration/2);return y}var A=r.fragments[r.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(A)},i.getLevelDetails=function(){if(this.levels&&this.levelLastLoaded!==null){var e;return(e=this.levelLastLoaded)==null?void 0:e.details}},i.onMediaAttached=function(e,r){var a=this.media=this.mediaBuffer=r.media;a.removeEventListener("seeking",this.onMediaSeeking),a.removeEventListener("ended",this.onMediaEnded),a.addEventListener("seeking",this.onMediaSeeking),a.addEventListener("ended",this.onMediaEnded);var u=this.config;this.levels&&u.autoStartLoad&&this.state===ne.STOPPED&&this.startLoad(u.startPosition)},i.onMediaDetaching=function(e,r){var a=!!r.transferMedia,u=this.media;if(u!==null){if(u.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),u.removeEventListener("seeking",this.onMediaSeeking),u.removeEventListener("ended",this.onMediaEnded),this.keyLoader&&!a&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loopSn=void 0,a){this.resetLoadingState(),this.resetTransmuxer();return}this.loadingParts=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}},i.onManifestLoading=function(){this.initPTS=[],this.levels=this.levelLastLoaded=this.fragCurrent=null,this.lastCurrentTime=this.startPosition=0,this.startFragRequested=!1},i.onError=function(e,r){},i.onManifestLoaded=function(e,r){this.startTimeOffset=r.startTimeOffset},i.onHandlerDestroying=function(){this.stopLoad(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),n.prototype.onHandlerDestroying.call(this),this.hls=this.onMediaSeeking=this.onMediaEnded=null},i.onHandlerDestroyed=function(){this.state=ne.STOPPED,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,n.prototype.onHandlerDestroyed.call(this)},i.loadFragment=function(e,r,a){this.startFragRequested=!0,this._loadFragForPlayback(e,r,a)},i._loadFragForPlayback=function(e,r,a){var u=this,l=function(c){var p=c.frag;if(u.fragContextChanged(p)){u.warn(p.type+" sn: "+p.sn+(c.part?" part: "+c.part.index:"")+" of "+u.fragInfo(p,!1,c.part)+") was dropped during download."),u.fragmentTracker.removeFragment(p);return}p.stats.chunkCount++,u._handleFragmentLoadProgress(c)};this._doFragLoad(e,r,a,l).then(function(d){if(d){var c=u.state,p=d.frag;if(u.fragContextChanged(p)){(c===ne.FRAG_LOADING||!u.fragCurrent&&c===ne.PARSING)&&(u.fragmentTracker.removeFragment(p),u.state=ne.IDLE);return}"payload"in d&&(u.log("Loaded "+p.type+" sn: "+p.sn+" of "+u.playlistLabel()+" "+p.level),u.hls.trigger(x.FRAG_LOADED,d)),u._handleFragmentLoadComplete(d)}}).catch(function(d){u.state===ne.STOPPED||u.state===ne.ERROR||(u.warn("Frag error: "+(d?.message||d)),u.resetFragmentLoading(e))})},i.clearTrackerIfNeeded=function(e){var r,a=this.fragmentTracker,u=a.getState(e);if(u===Et.APPENDING){var l=e.type,d=this.getFwdBufferInfo(this.mediaBuffer,l),c=Math.max(e.duration,d?d.len:this.config.maxBufferLength),p=this.backtrackFragment,y=p?e.sn-p.sn:0;(y===1||this.reduceMaxBufferLength(c,e.duration))&&a.removeFragment(e)}else((r=this.mediaBuffer)==null?void 0:r.buffered.length)===0?a.removeAllFragments():a.hasParts(e.type)&&(a.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),a.getState(e)===Et.PARTIAL&&a.removeFragment(e))},i.checkLiveUpdate=function(e){if(e.updated&&!e.live){var r=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:r,part:null,stats:r.stats,id:r.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)},i.waitForLive=function(e){var r=e.details;return r?.live&&r.type!=="EVENT"&&(this.levelLastLoaded!==e||r.expired)},i.flushMainBuffer=function(e,r,a){if(a===void 0&&(a=null),!!(e-r)){var u={startOffset:e,endOffset:r,type:a};this.hls.trigger(x.BUFFER_FLUSHING,u)}},i._loadInitSegment=function(e,r){var a=this;this._doFragLoad(e,r).then(function(u){var l=u?.frag;if(!l||a.fragContextChanged(l)||!a.levels)throw new Error("init load aborted");return u}).then(function(u){var l=a.hls,d=u.frag,c=u.payload,p=d.decryptdata;if(c&&c.byteLength>0&&p!=null&&p.key&&p.iv&&Mr(p.method)){var y=self.performance.now();return a.decrypter.decrypt(new Uint8Array(c),p.key.buffer,p.iv.buffer,xa(p.method)).catch(function(A){throw l.trigger(x.ERROR,{type:Y.MEDIA_ERROR,details:M.FRAG_DECRYPT_ERROR,fatal:!1,error:A,reason:A.message,frag:d}),A}).then(function(A){var T=self.performance.now();return l.trigger(x.FRAG_DECRYPTED,{frag:d,payload:A,stats:{tstart:y,tdecrypt:T}}),u.payload=A,a.completeInitSegmentLoad(u)})}return a.completeInitSegmentLoad(u)}).catch(function(u){a.state===ne.STOPPED||a.state===ne.ERROR||(a.warn(u),a.resetFragmentLoading(e))})},i.completeInitSegmentLoad=function(e){var r=this.levels;if(!r)throw new Error("init load aborted, missing levels");var a=e.frag.stats;this.state!==ne.STOPPED&&(this.state=ne.IDLE),e.frag.data=new Uint8Array(e.payload),a.parsing.start=a.buffering.start=self.performance.now(),a.parsing.end=a.buffering.end=self.performance.now(),this.tick()},i.fragContextChanged=function(e){var r=this.fragCurrent;return!e||!r||e.sn!==r.sn||e.level!==r.level},i.fragBufferedComplete=function(e,r){var a=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log("Buffered "+e.type+" sn: "+e.sn+(r?" part: "+r.index:"")+" of "+this.fragInfo(e,!1,r)+" > buffer:"+(a?kf.toString(Fe.getBuffered(a)):"(detached)")+")"),jt(e)){var u;if(e.type!==ae.SUBTITLE){var l=e.elementaryStreams;if(!Object.keys(l).some(function(c){return!!l[c]})){this.state=ne.IDLE;return}}var d=(u=this.levels)==null?void 0:u[e.level];d!=null&&d.fragmentError&&(this.log("Resetting level fragment error count of "+d.fragmentError+" on frag buffered"),d.fragmentError=0)}this.state=ne.IDLE},i._handleFragmentLoadComplete=function(e){var r=this.transmuxer;if(r){var a=e.frag,u=e.part,l=e.partsLoaded,d=!l||l.length===0||l.some(function(p){return!p}),c=new _s(a.level,a.sn,a.stats.chunkCount+1,0,u?u.index:-1,!d);r.flush(c)}},i._handleFragmentLoadProgress=function(e){},i._doFragLoad=function(e,r,a,u){var l,d=this;a===void 0&&(a=null),this.fragCurrent=e;var c=r?.details;if(!this.levels||!c)throw new Error("frag load aborted, missing level"+(c?"":" detail")+"s");var p=null;e.encrypted&&!((l=e.decryptdata)!=null&&l.key)?(this.log("Loading key for "+e.sn+" of ["+c.startSN+"-"+c.endSN+"], "+this.playlistLabel()+" "+e.level),this.state=ne.KEY_LOADING,this.fragCurrent=e,p=this.keyLoader.load(e).then(function(k){if(!d.fragContextChanged(k.frag))return d.hls.trigger(x.KEY_LOADED,k),d.state===ne.KEY_LOADING&&(d.state=ne.IDLE),k}),this.hls.trigger(x.KEY_LOADING,{frag:e}),this.fragCurrent===null&&(p=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!e.encrypted&&c.encryptedFragments.length&&this.keyLoader.loadClear(e,c.encryptedFragments);var y=this.fragPrevious;if(jt(e)&&(!y||e.sn!==y.sn)){var A=this.shouldLoadParts(r.details,e.end);A!==this.loadingParts&&(this.log("LL-Part loading "+(A?"ON":"OFF")+" loading sn "+y?.sn+"->"+e.sn),this.loadingParts=A)}if(a=Math.max(e.start,a||0),this.loadingParts&&jt(e)){var T=c.partList;if(T&&u){a>e.end&&c.fragmentHint&&(e=c.fragmentHint);var b=this.getNextPart(T,e,a);if(b>-1){var L=T[b];e=this.fragCurrent=L.fragment,this.log("Loading "+e.type+" sn: "+e.sn+" part: "+L.index+" ("+b+"/"+(T.length-1)+") of "+this.fragInfo(e,!1,L)+") cc: "+e.cc+" ["+c.startSN+"-"+c.endSN+"], target: "+parseFloat(a.toFixed(3))),this.nextLoadPosition=L.start+L.duration,this.state=ne.FRAG_LOADING;var R;return p?R=p.then(function(k){return!k||d.fragContextChanged(k.frag)?null:d.doFragPartsLoad(e,L,r,u)}).catch(function(k){return d.handleFragLoadError(k)}):R=this.doFragPartsLoad(e,L,r,u).catch(function(k){return d.handleFragLoadError(k)}),this.hls.trigger(x.FRAG_LOADING,{frag:e,part:L,targetBufferTime:a}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):R}else if(!e.url||this.loadedEndOfParts(T,a))return Promise.resolve(null)}}if(jt(e)&&this.loadingParts)this.log("LL-Part loading OFF after next part miss @"+a.toFixed(2)),this.loadingParts=!1;else if(!e.url)return Promise.resolve(null);this.log("Loading "+e.type+" sn: "+e.sn+" of "+this.fragInfo(e,!1)+") cc: "+e.cc+" "+(c?"["+c.startSN+"-"+c.endSN+"]":"")+", target: "+parseFloat(a.toFixed(3))),w(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=ne.FRAG_LOADING;var C=this.config.progressive,I;return C&&p?I=p.then(function(k){return!k||d.fragContextChanged(k?.frag)?null:d.fragmentLoader.load(e,u)}).catch(function(k){return d.handleFragLoadError(k)}):I=Promise.all([this.fragmentLoader.load(e,C?u:void 0),p]).then(function(k){var O=k[0];return!C&&O&&u&&u(O),O}).catch(function(k){return d.handleFragLoadError(k)}),this.hls.trigger(x.FRAG_LOADING,{frag:e,targetBufferTime:a}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):I},i.doFragPartsLoad=function(e,r,a,u){var l=this;return new Promise(function(d,c){var p,y=[],A=(p=a.details)==null?void 0:p.partList,T=function(L){l.fragmentLoader.loadPart(e,L,u).then(function(R){y[L.index]=R;var C=R.part;l.hls.trigger(x.FRAG_LOADED,R);var I=Va(a.details,e.sn,L.index+1)||Ha(A,e.sn,L.index+1);if(I)T(I);else return d({frag:e,part:C,partsLoaded:y})}).catch(c)};T(r)})},i.handleFragLoadError=function(e){if("data"in e){var r=e.data;e.data&&r.details===M.INTERNAL_ABORTED?this.handleFragLoadAborted(r.frag,r.part):this.hls.trigger(x.ERROR,r)}else this.hls.trigger(x.ERROR,{type:Y.OTHER_ERROR,details:M.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null},i._handleTransmuxerFlush=function(e){var r=this.getCurrentContext(e);if(!r||this.state!==ne.PARSING){!this.fragCurrent&&this.state!==ne.STOPPED&&this.state!==ne.ERROR&&(this.state=ne.IDLE);return}var a=r.frag,u=r.part,l=r.level,d=self.performance.now();a.stats.parsing.end=d,u&&(u.stats.parsing.end=d);var c=this.getLevelDetails(),p=c&&a.sn>c.endSN,y=p||this.shouldLoadParts(c,a.end);y!==this.loadingParts&&(this.log("LL-Part loading "+(y?"ON":"OFF")+" after parsing segment ending @"+a.end.toFixed(2)),this.loadingParts=y),this.updateLevelTiming(a,u,l,e.partial)},i.shouldLoadParts=function(e,r){if(this.config.lowLatencyMode){if(!e)return this.loadingParts;if(e!=null&&e.partList){var a,u=e.partList[0],l=u.end+(((a=e.fragmentHint)==null?void 0:a.duration)||0);if(r>=l){var d,c=this.hls.hasEnoughToStart?((d=this.media)==null?void 0:d.currentTime)||this.lastCurrentTime:this.getLoadPosition();if(c>u.start-u.fragment.duration)return!0}}}return!1},i.getCurrentContext=function(e){var r=this.levels,a=this.fragCurrent,u=e.level,l=e.sn,d=e.part;if(!(r!=null&&r[u]))return this.warn("Levels object was unset while buffering fragment "+l+" of "+this.playlistLabel()+" "+u+". The current chunk will not be buffered."),null;var c=r[u],p=c.details,y=d>-1?Va(p,l,d):null,A=y?y.fragment:nl(p,l,a);return A?(a&&a!==A&&(A.stats=a.stats),{frag:A,part:y,level:c}):null},i.bufferFragmentData=function(e,r,a,u,l){var d;if(!(!e||this.state!==ne.PARSING)){var c=e.data1,p=e.data2,y=c;if(c&&p&&(y=Ot(c,p)),!!((d=y)!=null&&d.length)){var A={type:e.type,frag:r,part:a,chunkMeta:u,parent:r.type,data:y};if(this.hls.trigger(x.BUFFER_APPENDING,A),e.dropped&&e.independent&&!a){if(l)return;this.flushBufferGap(r)}}}},i.flushBufferGap=function(e){var r=this.media;if(r){if(!Fe.isBuffered(r,r.currentTime)){this.flushMainBuffer(0,e.start);return}var a=r.currentTime,u=Fe.bufferInfo(r,a,0),l=e.duration,d=Math.min(this.config.maxFragLookUpTolerance*2,l*.25),c=Math.max(Math.min(e.start-d,u.end-d),a+d);e.start-c>d&&this.flushMainBuffer(c,e.start)}},i.getFwdBufferInfo=function(e,r){var a,u=this.getLoadPosition();if(!w(u))return null;var l=this.lastCurrentTime>u,d=l||(a=this.media)!=null&&a.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(e,u,r,d)},i.getFwdBufferInfoAtPos=function(e,r,a,u){var l=Fe.bufferInfo(e,r,u);if(l.len===0&&l.nextStart!==void 0){var d=this.fragmentTracker.getBufferedFrag(r,a);if(d&&(l.nextStart<=d.end||d.gap)){var c=Math.max(Math.min(l.nextStart,d.end)-r,u);return Fe.bufferInfo(e,r,c)}}return l},i.getMaxBufferLength=function(e){var r=this.config,a;return e?a=Math.max(8*r.maxBufferSize/e,r.maxBufferLength):a=r.maxBufferLength,Math.min(a,r.maxMaxBufferLength)},i.reduceMaxBufferLength=function(e,r){var a=this.config,u=Math.max(Math.min(e-r,a.maxBufferLength),r),l=Math.max(e-r*3,a.maxMaxBufferLength/2,u);return l>=u?(a.maxMaxBufferLength=l,this.warn("Reduce max buffer length to "+l+"s"),!0):!1},i.getAppendedFrag=function(e,r){var a;r===void 0&&(r=ae.MAIN);var u=(a=this.fragmentTracker)==null?void 0:a.getAppendedFrag(e,r);return u&&"fragment"in u?u.fragment:u},i.getNextFragment=function(e,r){var a=r.fragments,u=a.length;if(!u)return null;var l=this.config,d=a[0].start,c=l.lowLatencyMode&&!!r.partList,p=null;if(r.live){var y=l.initialLiveManifestSize;if(u<y)return this.warn("Not enough fragments to start playback (have: "+u+", need: "+y+")"),null;if(!r.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||e<d){var A;c&&!this.loadingParts&&(this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0),p=this.getInitialLiveFragment(r,a);var T=this.hls.startPosition,b=this.hls.liveSyncPosition,L=p?(T!==-1&&T>=d?T:b)||p.start:e;this.log("Setting startPosition to "+L+" to match start frag at live edge. mainStart: "+T+" liveSyncPosition: "+b+" frag.start: "+((A=p)==null?void 0:A.start)),this.startPosition=this.nextLoadPosition=L}}else e<=d&&(p=a[0]);if(!p){var R=this.loadingParts?r.partEnd:r.fragmentEnd;p=this.getFragmentAtPosition(e,R,r)}var C=this.filterReplacedPrimary(p,r);if(!C&&p){var I=p.sn-r.startSN;C=this.filterReplacedPrimary(a[I+1]||null,r)}return this.mapToInitFragWhenRequired(C)},i.isLoopLoading=function(e,r){var a=this.fragmentTracker.getState(e);return(a===Et.OK||a===Et.PARTIAL&&!!e.gap)&&this.nextLoadPosition>r},i.getNextFragmentLoopLoading=function(e,r,a,u,l){var d=null;if(e.gap&&(d=this.getNextFragment(this.nextLoadPosition,r),d&&!d.gap&&a.nextStart)){var c=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,a.nextStart,u,0);if(c!==null&&a.len+c.len>=l){var p=d.sn;return this.loopSn!==p&&(this.log('buffer full after gaps in "'+u+'" playlist starting at sn: '+p),this.loopSn=p),null}}return this.loopSn=void 0,d},i.filterReplacedPrimary=function(e,r){return e&&(As(this.hls.config),e)},i.mapToInitFragWhenRequired=function(e){return e!=null&&e.initSegment&&!(e!=null&&e.initSegment.data)&&!this.bitrateTest?e.initSegment:e},i.getNextPart=function(e,r,a){for(var u=-1,l=!1,d=!0,c=0,p=e.length;c<p;c++){var y=e[c];if(d=d&&!y.independent,u>-1&&a<y.start)break;var A=y.loaded;A?u=-1:(l||y.independent||d)&&y.fragment===r&&(u=c),l=A}return u},i.loadedEndOfParts=function(e,r){var a=e[e.length-1];return a&&r>a.start&&a.loaded},i.getInitialLiveFragment=function(e,r){var a=this.fragPrevious,u=null;if(a){if(e.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+a.programDateTime),u=Iu(r,a.endProgramDateTime,this.config.maxFragLookUpTolerance)),!u){var l=a.sn+1;if(l>=e.startSN&&l<=e.endSN){var d=r[l-e.startSN];a.cc===d.cc&&(u=d,this.log("Live playlist, switching playlist, load frag with next SN: "+u.sn))}u||(u=Ou(r,a.cc),u&&this.log("Live playlist, switching playlist, load frag with same CC: "+u.sn))}}else{var c=this.hls.liveSyncPosition;c!==null&&(u=this.getFragmentAtPosition(c,this.bitrateTest?e.fragmentEnd:e.edge,e))}return u},i.getFragmentAtPosition=function(e,r,a){var u=this.config,l=this.fragPrevious,d=a.fragments,c=a.endSN,p=a.fragmentHint,y=u.maxFragLookUpTolerance,A=a.partList,T=!!(this.loadingParts&&A!=null&&A.length&&p);T&&p&&!this.bitrateTest&&A[A.length-1].fragment.sn===p.sn&&(d=d.concat(p),c=p.sn);var b;if(e<r){var L,R=e<this.lastCurrentTime,C=R||e>r-y||(L=this.media)!=null&&L.paused||!this.startFragRequested?0:y;b=Wi(l,d,e,C)}else b=d[d.length-1];if(b){var I=b.sn-a.startSN,k=this.fragmentTracker.getState(b);if((k===Et.OK||k===Et.PARTIAL&&b.gap)&&(l=b),l&&b.sn===l.sn&&(!T||A[0].fragment.sn>b.sn||!a.live&&!T)){var O=l&&b.level===l.level;if(O){var V=d[I+1];b.sn<c&&this.fragmentTracker.getState(V)!==Et.OK?b=V:b=null}}}return b},i.alignPlaylists=function(e,r,a){var u=e.fragments.length;if(!u)return this.warn("No fragments in live playlist"),0;var l=e.fragmentStart,d=!r,c=e.alignedSliding&&w(l);if(d||!c&&!l){xf(a,e);var p=e.fragmentStart;return this.log("Live playlist sliding: "+p.toFixed(2)+" start-sn: "+(r?r.startSN:"na")+"->"+e.startSN+" fragments: "+u),p}return l},i.waitForCdnTuneIn=function(e){var r=3;return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,e.partTarget*r)},i.setStartPosition=function(e,r){var a=this.startPosition;a<r&&(a=-1);var u=this.timelineOffset;if(a===-1){var l=this.startTimeOffset!==null,d=l?this.startTimeOffset:e.startTimeOffset;d!==null&&w(d)?(a=r+d,d<0&&(a+=e.edge),a=Math.min(Math.max(r,a),r+e.totalduration),this.log("Setting startPosition to "+a+" for start time offset "+d+" found in "+(l?"multivariant":"media")+" playlist"),this.startPosition=a):e.live?(a=this.hls.liveSyncPosition||r,this.log("Setting startPosition to -1 to start at live edge "+a),this.startPosition=-1):(this.log("setting startPosition to 0 by default"),this.startPosition=a=0),this.lastCurrentTime=a+u}this.nextLoadPosition=a+u},i.getLoadPosition=function(){var e,r=this.media,a=0;return(e=this.hls)!=null&&e.hasEnoughToStart&&r?a=r.currentTime:this.nextLoadPosition>=0&&(a=this.nextLoadPosition),a},i.handleFragLoadAborted=function(e,r){this.transmuxer&&e.type===this.playlistType&&jt(e)&&e.stats.aborted&&(this.warn("Fragment "+e.sn+(r?" part "+r.index:"")+" of "+this.playlistLabel()+" "+e.level+" was aborted"),this.resetFragmentLoading(e))},i.resetFragmentLoading=function(e){(!this.fragCurrent||!this.fragContextChanged(e)&&this.state!==ne.FRAG_LOADING_WAITING_RETRY)&&(this.state=ne.IDLE)},i.onFragmentOrKeyLoadError=function(e,r){if(r.chunkMeta&&!r.frag){var a=this.getCurrentContext(r.chunkMeta);a&&(r.frag=a.frag)}var u=r.frag;if(!(!u||u.type!==e||!this.levels)){if(this.fragContextChanged(u)){var l;this.warn("Frag load error must match current frag to retry "+u.url+" > "+((l=this.fragCurrent)==null?void 0:l.url));return}var d=r.details===M.FRAG_GAP;d&&this.fragmentTracker.fragBuffered(u,!0);var c=r.errorAction,p=c||{},y=p.action,A=p.flags,T=p.retryCount,b=T===void 0?0:T,L=p.retryConfig,R=!!c&&!!L,C=R&&y===ht.RetryRequest,I=R&&!c.resolved&&A===Mt.MoveAllAlternatesMatchingHost;if(!C&&I&&jt(u)&&!u.endList)this.resetFragmentErrors(e),this.treatAsGap(u),c.resolved=!0;else if((C||I)&&b<L.maxNumRetry){this.resetStartWhenNotLoaded(this.levelLastLoaded);var k=ji(L,b);this.warn("Fragment "+u.sn+" of "+e+" "+u.level+" errored with "+r.details+", retrying loading "+(b+1)+"/"+L.maxNumRetry+" in "+k+"ms"),c.resolved=!0,this.retryDate=self.performance.now()+k,this.state=ne.FRAG_LOADING_WAITING_RETRY}else if(L&&c)if(this.resetFragmentErrors(e),b<L.maxNumRetry)!d&&y!==ht.RemoveAlternatePermanently&&(c.resolved=!0);else{this.warn(r.details+" reached or exceeded max retry ("+b+")");return}else y===ht.SendAlternateToPenaltyBox?this.state=ne.WAITING_LEVEL:this.state=ne.ERROR;this.tickImmediate()}},i.reduceLengthAndFlushBuffer=function(e){if(this.state===ne.PARSING||this.state===ne.PARSED){var r=e.frag,a=e.parent,u=this.getFwdBufferInfo(this.mediaBuffer,a),l=u&&u.len>.5;l&&this.reduceMaxBufferLength(u.len,r?.duration||10);var d=!l;return d&&this.warn("Buffer full error while media.currentTime is not buffered, flush "+a+" buffer"),r&&(this.fragmentTracker.removeFragment(r),this.nextLoadPosition=r.start),this.resetLoadingState(),d}return!1},i.resetFragmentErrors=function(e){e===ae.AUDIO&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==ne.STOPPED&&(this.state=ne.IDLE)},i.afterBufferFlushed=function(e,r,a){if(e){var u=Fe.getBuffered(e);this.fragmentTracker.detectEvictedFragments(r,u,a),this.state===ne.ENDED&&this.resetLoadingState()}},i.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==ne.STOPPED&&(this.state=ne.IDLE)},i.resetStartWhenNotLoaded=function(e){if(!this.hls.hasEnoughToStart){this.startFragRequested=!1;var r=e?e.details:null;r!=null&&r.live?(this.log("resetting startPosition for live start"),this.startPosition=-1,this.setStartPosition(r,r.fragmentStart),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},i.resetWhenMissingContext=function(e){this.warn("The loading context changed while buffering fragment "+e.sn+" of "+this.playlistLabel()+" "+e.level+". This chunk will not be buffered."),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()},i.removeUnbufferedFrags=function(e){e===void 0&&(e=0),this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)},i.updateLevelTiming=function(e,r,a,u){var l=this,d=a.details;if(!d){this.warn("level.details undefined");return}var c=Object.keys(e.elementaryStreams).reduce(function(A,T){var b=e.elementaryStreams[T];if(b){var L=b.endPTS-b.startPTS;if(L<=0)return l.warn("Could not parse fragment "+e.sn+" "+T+" duration reliably ("+L+")"),A||!1;var R=u?0:Na(d,e,b.startPTS,b.endPTS,b.startDTS,b.endDTS);return l.hls.trigger(x.LEVEL_PTS_UPDATED,{details:d,level:a,drift:R,type:T,frag:e,start:b.startPTS,end:b.endPTS}),!0}return A},!1);if(!c){var p;if(a.fragmentError===0&&this.treatAsGap(e,a),((p=this.transmuxer)==null?void 0:p.error)===null){var y=new Error("Found no media in fragment "+e.sn+" of "+this.playlistLabel()+" "+e.level+" resetting transmuxer to fallback to playlist timing");if(this.warn(y.message),this.hls.trigger(x.ERROR,{type:Y.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,fatal:!1,error:y,frag:e,reason:"Found no media in msn "+e.sn+" of "+this.playlistLabel()+' "'+a.url+'"'}),!this.hls)return;this.resetTransmuxer()}}this.state=ne.PARSED,this.log("Parsed "+e.type+" sn: "+e.sn+(r?" part: "+r.index:"")+" of "+this.fragInfo(e,!1,r)+")"),this.hls.trigger(x.FRAG_PARSED,{frag:e,part:r})},i.playlistLabel=function(){return this.playlistType===ae.MAIN?"level":"track"},i.fragInfo=function(e,r,a){var u,l;return r===void 0&&(r=!0),this.playlistLabel()+" "+e.level+" ("+(a?"part":"frag")+":["+((u=r&&!a?e.startPTS:(a||e).start)!=null?u:NaN).toFixed(3)+"-"+((l=r&&!a?e.endPTS:(a||e).end)!=null?l:NaN).toFixed(3)+"]"+(a&&e.type==="main"?"INDEPENDENT="+(a.independent?"YES":"NO"):"")},i.treatAsGap=function(e,r){r&&r.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)},i.resetTransmuxer=function(){var e;(e=this.transmuxer)==null||e.reset()},i.recoverWorkerError=function(e){e.event==="demuxerWorker"&&(this.fragmentTracker.removeAllFragments(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())},f(s,[{key:"startPositionValue",get:function(){var e=this.nextLoadPosition,r=this.startPosition;return r===-1&&e?e:r}},{key:"bufferingEnabled",get:function(){return this.buffering}},{key:"inFlightFrag",get:function(){return{frag:this.fragCurrent,state:this.state}}},{key:"timelineOffset",get:function(){var e=this.config.timelineOffset;if(e){var r;return((r=this.getLevelDetails())==null?void 0:r.appliedTimelineOffset)||e}return 0}},{key:"primaryPrefetch",get:function(){return As(this.hls.config),!1}},{key:"state",get:function(){return this._state},set:function(e){var r=this._state;r!==e&&(this._state=e,this.log(r+"->"+e))}}])}(Es);function As(n){return!1}function Br(n,s,i){_r(n,s,i),n.addEventListener(s,i)}function _r(n,s,i){n.removeEventListener(s,i)}var yi=2,If=.1,wf=.05,Pf=100,Of=function(n){function s(t,e){var r;return r=n.call(this,"gap-controller",t.logger)||this,r.hls=null,r.fragmentTracker=null,r.media=null,r.mediaSource=void 0,r.nudgeRetry=0,r.stallReported=!1,r.stalled=null,r.moved=!1,r.seeking=!1,r.buffered={},r.lastCurrentTime=0,r.ended=0,r.waiting=0,r.onMediaPlaying=function(){r.ended=0,r.waiting=0},r.onMediaWaiting=function(){var a;(a=r.media)!=null&&a.seeking||(r.waiting=self.performance.now(),r.tick())},r.onMediaEnded=function(){if(r.hls){var a;r.ended=((a=r.media)==null?void 0:a.currentTime)||1,r.hls.trigger(x.MEDIA_ENDED,{stalled:!1})}},r.hls=t,r.fragmentTracker=e,r.registerListeners(),r}S(s,n);var i=s.prototype;return i.registerListeners=function(){var e=this.hls;e&&(e.on(x.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(x.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(x.BUFFER_APPENDED,this.onBufferAppended,this))},i.unregisterListeners=function(){var e=this.hls;e&&(e.off(x.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(x.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(x.BUFFER_APPENDED,this.onBufferAppended,this))},i.destroy=function(){n.prototype.destroy.call(this),this.unregisterListeners(),this.media=this.hls=this.fragmentTracker=null,this.mediaSource=void 0},i.onMediaAttached=function(e,r){this.setInterval(Pf),this.mediaSource=r.mediaSource;var a=this.media=r.media;Br(a,"playing",this.onMediaPlaying),Br(a,"waiting",this.onMediaWaiting),Br(a,"ended",this.onMediaEnded)},i.onMediaDetaching=function(e,r){this.clearInterval();var a=this.media;a&&(_r(a,"playing",this.onMediaPlaying),_r(a,"waiting",this.onMediaWaiting),_r(a,"ended",this.onMediaEnded),this.media=null),this.mediaSource=void 0},i.onBufferAppended=function(e,r){this.buffered=r.timeRanges},i.tick=function(){var e;if(!(!((e=this.media)!=null&&e.readyState)||!this.hasBuffered)){var r=this.media.currentTime;this.poll(r,this.lastCurrentTime),this.lastCurrentTime=r}},i.poll=function(e,r){var a,u,l=(a=this.hls)==null?void 0:a.config;if(l){var d=this.media,c=this.stalled;if(d){var p=d.seeking,y=this.seeking&&!p,A=!this.seeking&&p,T=d.paused&&!p||d.ended||d.playbackRate===0;if(this.seeking=p,e!==r){r&&(this.ended=0),this.moved=!0,p||(this.nudgeRetry=0,l.nudgeOnVideoHole&&!T&&e>r&&this.nudgeOnVideoHole(e,r)),this.waiting===0&&this.stallResolved(e);return}if(A||y){y&&this.stallResolved(e);return}if(T){this.nudgeRetry=0,this.stallResolved(e),!this.ended&&d.ended&&this.hls&&(this.ended=e||1,this.hls.trigger(x.MEDIA_ENDED,{stalled:!1}));return}if(!Fe.getBuffered(d).length){this.nudgeRetry=0;return}var b=Fe.bufferInfo(d,e,0),L=b.nextStart||0,R=this.fragmentTracker;if(p&&R&&this.hls){var C=bs(this.hls.inFlightFragments,e),I=b.len>yi,k=!L||C||L-e>yi&&!R.getPartialFragment(e);if(I||k)return;this.moved=!1}var O=(u=this.hls)==null?void 0:u.latestLevelDetails;if(!this.moved&&this.stalled!==null&&R){var V=b.len>0;if(!V&&!L)return;var N=Math.max(L,b.start||0)-e,B=!!(O!=null&&O.live),X=B?O.targetduration*2:yi,z=R.getPartialFragment(e);if(N>0&&(N<=X||z)){d.paused||this._trySkipBufferHole(z);return}}var K=l.detectStallWithCurrentTimeMs,j=self.performance.now(),J=this.waiting;if(c===null){J>0&&j-J<K?this.stalled=J:this.stalled=j;return}var le=j-c;if(!p&&(le>=K||J)&&this.hls){var re;if(((re=this.mediaSource)==null?void 0:re.readyState)==="ended"&&!(O!=null&&O.live)&&Math.abs(e-(O?.edge||0))<1){if(this.ended)return;this.ended=e||1,this.hls.trigger(x.MEDIA_ENDED,{stalled:!0});return}if(this._reportStall(b),!this.media||!this.hls)return}var te=Fe.bufferInfo(d,e,l.maxBufferHole);this._tryFixBufferStall(te,le)}}},i.stallResolved=function(e){var r=this.stalled;if(r&&this.hls&&(this.stalled=null,this.stallReported)){var a=self.performance.now()-r;this.log("playback not stuck anymore @"+e+", after "+Math.round(a)+"ms"),this.stallReported=!1,this.waiting=0,this.hls.trigger(x.STALL_RESOLVED,{})}},i.nudgeOnVideoHole=function(e,r){var a,u=this.buffered.video;if(this.hls&&this.media&&this.fragmentTracker&&(a=this.buffered.audio)!=null&&a.length&&u&&u.length>1&&e>u.end(0)){var l=Fe.bufferedInfo(Fe.timeRangesToArray(this.buffered.audio),e,0);if(l.len>1&&r>=l.start){var d=Fe.timeRangesToArray(u),c=Fe.bufferedInfo(d,r,0).bufferedIndex;if(c>-1&&c<d.length-1){var p=Fe.bufferedInfo(d,e,0).bufferedIndex,y=d[c].end,A=d[c+1].start;if((p===-1||p>c)&&A-y<1&&e-y<2){var T=new Error("nudging playhead to flush pipeline after video hole. currentTime: "+e+" hole: "+y+" -> "+A+" buffered index: "+p);this.warn(T.message),this.media.currentTime+=1e-6;var b=this.fragmentTracker.getPartialFragment(e)||void 0,L=Fe.bufferInfo(this.media,e,0);this.hls.trigger(x.ERROR,{type:Y.MEDIA_ERROR,details:M.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:T,reason:T.message,frag:b,buffer:L.len,bufferInfo:L})}}}}},i._tryFixBufferStall=function(e,r){var a,u,l=this.fragmentTracker,d=this.media,c=(a=this.hls)==null?void 0:a.config;if(!(!d||!l||!c)){var p=d.currentTime,y=(u=this.hls)==null?void 0:u.latestLevelDetails,A=l.getPartialFragment(p);if(A||y!=null&&y.live&&p<y.fragmentStart){var T=this._trySkipBufferHole(A);if(T||!this.media)return}var b=e.buffered;(b&&b.length>1&&e.len>c.maxBufferHole||e.nextStart&&e.nextStart-p<c.maxBufferHole)&&(r>c.highBufferWatchdogPeriod*1e3||this.waiting)&&(this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(e))}},i._reportStall=function(e){var r=this.hls,a=this.media,u=this.stallReported,l=this.stalled;if(!u&&l!==null&&a&&r){this.stallReported=!0;var d=new Error("Playback stalling at @"+a.currentTime+" due to low buffer ("+gt(e)+")");this.warn(d.message),r.trigger(x.ERROR,{type:Y.MEDIA_ERROR,details:M.BUFFER_STALLED_ERROR,fatal:!1,error:d,buffer:e.len,bufferInfo:e,stalled:{start:l}})}},i._trySkipBufferHole=function(e){var r,a=this.fragmentTracker,u=this.media,l=(r=this.hls)==null?void 0:r.config;if(!u||!a||!l)return 0;var d=u.currentTime,c=Fe.bufferInfo(u,d,0),p=d<c.start?c.start:c.nextStart;if(p&&this.hls){var y=c.len<=l.maxBufferHole,A=c.len>0&&c.len<1&&u.readyState<3,T=p-d;if(T>0&&(y||A)){if(T>l.maxBufferHole){var b=!1;if(d===0){var L=a.getAppendedFrag(0,ae.MAIN);L&&p<L.end&&(b=!0)}if(!b){var R=e||a.getAppendedFrag(d,ae.MAIN);if(R){var C;if(!((C=this.hls.loadLevelObj)!=null&&C.details))return 0;var I=bs(this.hls.inFlightFragments,p);if(I)return 0;for(var k=!1,O=R.end;O<p;){var V=a.getPartialFragment(O);if(V)O+=V.duration;else{k=!0;break}}if(k)return 0}}}var N=Math.max(p+wf,d+If);if(this.warn("skipping hole, adjusting currentTime from "+d+" to "+N),this.moved=!0,u.currentTime=N,!(e!=null&&e.gap)){var B=new Error("fragment loaded with buffer holes, seeking from "+d+" to "+N);this.hls.trigger(x.ERROR,{type:Y.MEDIA_ERROR,details:M.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:B,reason:B.message,frag:e||void 0,buffer:c.len,bufferInfo:c})}return N}}return 0},i._tryNudgeBuffer=function(e){var r=this.hls,a=this.media,u=this.nudgeRetry,l=r?.config;if(!a||!l)return 0;var d=a.currentTime;if(this.nudgeRetry++,u<l.nudgeMaxRetry){var c=d+(u+1)*l.nudgeOffset,p=new Error("Nudging 'currentTime' from "+d+" to "+c);this.warn(p.message),a.currentTime=c,r.trigger(x.ERROR,{type:Y.MEDIA_ERROR,details:M.BUFFER_NUDGE_ON_STALL,error:p,fatal:!1,buffer:e.len,bufferInfo:e})}else{var y=new Error("Playhead still not moving while enough data buffered @"+d+" after "+l.nudgeMaxRetry+" nudges");this.error(y.message),r.trigger(x.ERROR,{type:Y.MEDIA_ERROR,details:M.BUFFER_STALLED_ERROR,error:y,fatal:!0,buffer:e.len,bufferInfo:e})}},f(s,[{key:"hasBuffered",get:function(){return Object.keys(this.buffered).length>0}}])}(Es);function bs(n,s){var i=Ls(n.main);if(i&&i.start<=s)return i;var t=Ls(n.audio);return t&&t.start<=s?t:null}function Ls(n){if(!n)return null;switch(n.state){case ne.IDLE:case ne.STOPPED:case ne.ENDED:case ne.ERROR:return null}return n.frag}function Mf(n,s){var i;try{i=new Event("addtrack")}catch{i=document.createEvent("Event"),i.initEvent("addtrack",!1,!1)}i.track=n,s.dispatchEvent(i)}function Ff(n,s){var i=n.mode;if(i==="disabled"&&(n.mode="hidden"),n.cues)for(var t=n.cues.length;t--;)s&&n.cues[t].removeEventListener("enter",s),n.removeCue(n.cues[t]);i==="disabled"&&(n.mode=i)}function Nf(n,s,i,t){var e=n.mode;if(e==="disabled"&&(n.mode="hidden"),n.cues&&n.cues.length>0)for(var r=Bf(n.cues,s,i),a=0;a<r.length;a++)(!t||t(r[a]))&&n.removeCue(r[a]);e==="disabled"&&(n.mode=e)}function Uf(n,s){if(s<=n[0].startTime)return 0;var i=n.length-1;if(s>n[i].endTime)return-1;for(var t=0,e=i,r;t<=e;)if(r=Math.floor((e+t)/2),s<n[r].startTime)e=r-1;else if(s>n[r].startTime&&t<i)t=r+1;else return r;return n[t].startTime-s<s-n[e].startTime?t:e}function Bf(n,s,i){var t=[],e=Uf(n,s);if(e>-1)for(var r=e,a=n.length;r<a;r++){var u=n[r];if(u.startTime>=s&&u.endTime<=i)t.push(u);else if(u.startTime>i)return t}return t}var Gf=.25;function fn(){if(!(typeof self>"u"))return self.VTTCue||self.TextTrackCue}function xs(n,s,i,t,e){var r=new n(s,i,"");try{r.value=t,e&&(r.type=e)}catch{r=new n(s,i,gt(e?H({type:e},t):t))}return r}var Ei=function(){var n=fn();try{n&&new n(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function Vf(n){return Uint8Array.from(n.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var Hf=function(){function n(i){var t=this;this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=!0,this.onEventCueEnter=function(){t.hls&&t.hls.trigger(x.EVENT_CUE_ENTER,{})},this.hls=i,this._registerListeners()}var s=n.prototype;return s.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null},s._registerListeners=function(){var t=this.hls;t.on(x.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(x.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(x.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(x.MANIFEST_LOADING,this.onManifestLoading,this),t.on(x.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.on(x.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(x.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(x.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this)},s._unregisterListeners=function(){var t=this.hls;t.off(x.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(x.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(x.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(x.MANIFEST_LOADING,this.onManifestLoading,this),t.off(x.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.off(x.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(x.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(x.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this)},s.onMediaAttaching=function(t,e){var r;this.media=e.media,((r=e.overrides)==null?void 0:r.cueRemoval)===!1&&(this.removeCues=!1)},s.onMediaAttached=function(){var t=this.hls.latestLevelDetails;t&&this.updateDateRangeCues(t)},s.onMediaDetaching=function(t,e){this.media=null;var r=!!e.transferMedia;r||(this.id3Track&&(this.removeCues&&Ff(this.id3Track,this.onEventCueEnter),this.id3Track=null),this.dateRangeCuesAppended={})},s.onManifestLoading=function(){this.dateRangeCuesAppended={}},s.createTrack=function(t){var e=this.getID3Track(t.textTracks);return e.mode="hidden",e},s.getID3Track=function(t){if(this.media){for(var e=0;e<t.length;e++){var r=t[e];if(r.kind==="metadata"&&r.label==="id3")return Mf(r,this.media),r}return this.media.addTextTrack("metadata","id3")}},s.onFragParsingMetadata=function(t,e){if(this.media){var r=this.hls.config,a=r.enableEmsgMetadataCues,u=r.enableID3MetadataCues;if(!(!a&&!u)){var l=e.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));var d=fn();if(d)for(var c=0;c<l.length;c++){var p=l[c].type;if(!(p===Lt.emsg&&!a||!u)){var y=Za(l[c].data);if(y){var A=l[c].pts,T=A+l[c].duration;T>Ei&&(T=Ei);var b=T-A;b<=0&&(T=A+Gf);for(var L=0;L<y.length;L++){var R=y[L];if(!Ja(R)){this.updateId3CueEnds(A,p);var C=xs(d,A,T,R,p);C&&this.id3Track.addCue(C)}}}}}}}},s.updateId3CueEnds=function(t,e){var r,a=(r=this.id3Track)==null?void 0:r.cues;if(a)for(var u=a.length;u--;){var l=a[u];l.type===e&&l.startTime<t&&l.endTime===Ei&&(l.endTime=t)}},s.onBufferFlushing=function(t,e){var r=e.startOffset,a=e.endOffset,u=e.type,l=this.id3Track,d=this.hls;if(d){var c=d.config,p=c.enableEmsgMetadataCues,y=c.enableID3MetadataCues;if(l&&(p||y)){var A;u==="audio"?A=function(b){return b.type===Lt.audioId3&&y}:u==="video"?A=function(b){return b.type===Lt.emsg&&p}:A=function(b){return b.type===Lt.audioId3&&y||b.type===Lt.emsg&&p},Nf(l,r,a,A)}}},s.onLevelUpdated=function(t,e){var r=e.details;this.updateDateRangeCues(r,!0)},s.onLevelPtsUpdated=function(t,e){Math.abs(e.drift)>.01&&this.updateDateRangeCues(e.details)},s.updateDateRangeCues=function(t,e){var r=this;if(!(!this.media||!t.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)){var a=this.id3Track,u=t.dateRanges,l=Object.keys(u),d=this.dateRangeCuesAppended;if(a&&e){var c;if((c=a.cues)!=null&&c.length)for(var p=Object.keys(d).filter(function(C){return!l.includes(C)}),y=function(){var I=p[A],k=d[I].cues;delete d[I],Object.keys(k).forEach(function(O){try{var V=k[O];V.removeEventListener("enter",r.onEventCueEnter),a.removeCue(V)}catch{}})},A=p.length;A--;)y();else d=this.dateRangeCuesAppended={}}var T=t.fragments[t.fragments.length-1];if(!(l.length===0||!w(T?.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var b=fn(),L=function(){var I=l[R],k=u[I],O=k.startTime,V=d[I],N=V?.cues||{},B=V?.durationKnown||!1,X=Ei,z=k.duration,K=k.endDate;if(K&&z!==null)X=O+z,B=!0;else if(k.endOnNext&&!B){var j=l.reduce(function(ge,Ne){if(Ne!==k.id){var we=u[Ne];if(we.class===k.class&&we.startDate>k.startDate&&(!ge||k.startDate<ge.startDate))return we}return ge},null);j&&(X=j.startTime,B=!0)}for(var J=Object.keys(k.attr),le=0;le<J.length;le++){var re=J[le];if(Ku(re)){var te=N[re];if(te)B&&!V.durationKnown?te.endTime=X:Math.abs(te.startTime-O)>.01&&(te.startTime=O,te.endTime=X);else if(b){var fe=k.attr[re];Wu(re)&&(fe=Vf(fe));var de={key:re,data:fe},ve=xs(b,O,X,de,Lt.dateRange);ve&&(ve.id=I,r.id3Track.addCue(ve),N[re]=ve)}}}d[I]={cues:N,dateRange:k,durationKnown:B}},R=0;R<l.length;R++)L()}}},n}(),Kf=function(){function n(i){var t=this;this.hls=void 0,this.config=void 0,this.media=null,this.currentTime=0,this.stallCount=0,this._latency=null,this._targetLatencyUpdated=!1,this.onTimeupdate=function(){var e=t.media,r=t.levelDetails;if(!(!e||!r)){t.currentTime=e.currentTime;var a=t.computeLatency();if(a!==null){t._latency=a;var u=t.config,l=u.lowLatencyMode,d=u.maxLiveSyncPlaybackRate;if(!(!l||d===1||!r.live)){var c=t.targetLatency;if(c!==null){var p=a-c,y=Math.min(t.maxLatency,c+r.targetduration),A=p<y;if(A&&p>.05&&t.forwardBufferLength>1){var T=Math.min(2,Math.max(1,d)),b=Math.round(2/(1+Math.exp(-.75*p-t.edgeStalled))*20)/20,L=Math.min(T,Math.max(1,b));t.changeMediaPlaybackRate(e,L)}else e.playbackRate!==1&&e.playbackRate!==0&&t.changeMediaPlaybackRate(e,1)}}}}},this.hls=i,this.config=i.config,this.registerListeners()}var s=n.prototype;return s.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null},s.registerListeners=function(){var t=this.hls;t&&(t.on(x.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(x.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(x.MANIFEST_LOADING,this.onManifestLoading,this),t.on(x.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(x.ERROR,this.onError,this))},s.unregisterListeners=function(){var t=this.hls;t&&(t.off(x.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(x.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(x.MANIFEST_LOADING,this.onManifestLoading,this),t.off(x.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(x.ERROR,this.onError,this))},s.onMediaAttached=function(t,e){this.media=e.media,this.media.addEventListener("timeupdate",this.onTimeupdate)},s.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null)},s.onManifestLoading=function(){this._latency=null,this.stallCount=0},s.onLevelUpdated=function(t,e){var r=e.details;r.advanced&&this.onTimeupdate(),!r.live&&this.media&&this.media.removeEventListener("timeupdate",this.onTimeupdate)},s.onError=function(t,e){var r;e.details===M.BUFFER_STALLED_ERROR&&(this.stallCount++,this.hls&&(r=this.levelDetails)!=null&&r.live&&this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency"))},s.changeMediaPlaybackRate=function(t,e){var r,a;t.playbackRate!==e&&((r=this.hls)==null||r.logger.debug("[latency-controller]: latency="+this.latency.toFixed(3)+", targetLatency="+((a=this.targetLatency)==null?void 0:a.toFixed(3))+", forwardBufferLength="+this.forwardBufferLength.toFixed(3)+": adjusting playback rate from "+t.playbackRate+" to "+e),t.playbackRate=e)},s.estimateLiveEdge=function(){var t=this.levelDetails;return t===null?null:t.edge+t.age},s.computeLatency=function(){var t=this.estimateLiveEdge();return t===null?null:t-this.currentTime},f(n,[{key:"levelDetails",get:function(){var t;return((t=this.hls)==null?void 0:t.latestLevelDetails)||null}},{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var t=this.config;if(t.liveMaxLatencyDuration!==void 0)return t.liveMaxLatencyDuration;var e=this.levelDetails;return e?t.liveMaxLatencyDurationCount*e.targetduration:0}},{key:"targetLatency",get:function(){var t=this.levelDetails;if(t===null||this.hls===null)return null;var e=t.holdBack,r=t.partHoldBack,a=t.targetduration,u=this.config,l=u.liveSyncDuration,d=u.liveSyncDurationCount,c=u.lowLatencyMode,p=this.hls.userConfig,y=c&&r||e;(this._targetLatencyUpdated||p.liveSyncDuration||p.liveSyncDurationCount||y===0)&&(y=l!==void 0?l:d*a);var A=a;return y+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,A)},set:function(t){this.stallCount=0,this.config.liveSyncDuration=t,this._targetLatencyUpdated=!0}},{key:"liveSyncPosition",get:function(){var t=this.estimateLiveEdge(),e=this.targetLatency;if(t===null||e===null)return null;var r=this.levelDetails;if(r===null)return null;var a=r.edge,u=t-e-this.edgeStalled,l=a-r.totalduration,d=a-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(l,u),d)}},{key:"drift",get:function(){var t=this.levelDetails;return t===null?1:t.drift}},{key:"edgeStalled",get:function(){var t=this.levelDetails;if(t===null)return 0;var e=(this.config.lowLatencyMode&&t.partTarget||t.targetduration)*3;return Math.max(t.age-e,0)}},{key:"forwardBufferLength",get:function(){var t=this.media,e=this.levelDetails;if(!t||!e)return 0;var r=t.buffered.length;return(r?t.buffered.end(r-1):e.edge)-this.currentTime}}])}(),Wf=function(n){function s(t,e){var r;return r=n.call(this,e,t.logger)||this,r.hls=void 0,r.canLoad=!1,r.timer=-1,r.hls=t,r}S(s,n);var i=s.prototype;return i.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},i.clearTimer=function(){this.timer!==-1&&(self.clearTimeout(this.timer),this.timer=-1)},i.startLoad=function(){this.canLoad=!0,this.loadPlaylist()},i.stopLoad=function(){this.canLoad=!1,this.clearTimer()},i.switchParams=function(e,r,a){var u=r?.renditionReports;if(u){for(var l=-1,d=0;d<u.length;d++){var c=u[d],p=void 0;try{p=new self.URL(c.URI,r.url).href}catch(R){this.warn("Could not construct new URL for Rendition Report: "+R),p=c.URI||""}if(p===e){l=d;break}else p===e.substring(0,p.length)&&(l=d)}if(l!==-1){var y=u[l],A=parseInt(y["LAST-MSN"])||r?.lastPartSn,T=parseInt(y["LAST-PART"])||r?.lastPartIndex;if(this.hls.config.lowLatencyMode){var b=Math.min(r.age-r.partTarget,r.targetduration);T>=0&&b>r.partTarget&&(T+=1)}var L=a&&fa(a);return new ha(A,T>=0?T:void 0,L)}}},i.loadPlaylist=function(e){this.clearTimer()},i.loadingPlaylist=function(e,r){this.clearTimer()},i.shouldLoadPlaylist=function(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)},i.getUrlWithDirectives=function(e,r){if(r)try{return r.addDirectives(e)}catch(a){this.warn("Could not construct new URL with HLS Delivery Directives: "+a)}return e},i.playlistLoaded=function(e,r,a){var u=r.details,l=r.stats,d=self.performance.now(),c=l.loading.first?Math.max(0,d-l.loading.first):0;u.advancedDateTime=Date.now()-c;var p=this.hls.config.timelineOffset;if(p!==u.appliedTimelineOffset){var y=Math.max(p||0,0);u.appliedTimelineOffset=y,u.fragments.forEach(function(ge){ge.start=ge.playlistOffset+y})}if(u.live||a!=null&&a.live){var A="levelInfo"in r?r.levelInfo:r.track;if(u.reloaded(a),a&&u.fragments.length>0){Ju(a,u);var T=u.playlistParsingError;if(T){this.warn(T);var b=this.hls;if(!b.config.ignorePlaylistParsingErrors){var L,R=r.networkDetails;b.trigger(x.ERROR,{type:Y.NETWORK_ERROR,details:M.LEVEL_PARSING_ERROR,fatal:!1,url:u.url,error:T,reason:T.message,level:r.level||void 0,parent:(L=u.fragments[0])==null?void 0:L.type,networkDetails:R,stats:l});return}u.playlistParsingError=null}}u.requestScheduled===-1&&(u.requestScheduled=l.loading.start);var C=this.hls.mainForwardBufferInfo,I=C?C.end-C.len:0,k=(u.edge-I)*1e3,O=Ga(u,k);if(u.requestScheduled+O<d?u.requestScheduled=d:u.requestScheduled+=O,this.log("live playlist "+e+" "+(u.advanced?"REFRESHED "+u.lastPartSn+"-"+u.lastPartIndex:u.updated?"UPDATED":"MISSED")),!this.canLoad||!u.live)return;var V,N=void 0,B=void 0;if(u.canBlockReload&&u.endSN&&u.advanced){var X=this.hls.config.lowLatencyMode,z=u.lastPartSn,K=u.endSN,j=u.lastPartIndex,J=j!==-1,le=z===K;J?le?(N=K+1,B=X?0:j):(N=z,B=X?j+1:u.maxPartIndex):N=K+1;var re=u.age,te=re+u.ageHeader,fe=Math.min(te-u.partTarget,u.targetduration*1.5);if(fe>0){if(te>u.targetduration*3)this.log("Playlist last advanced "+re.toFixed(2)+"s ago. Omitting segment and part directives."),N=void 0,B=void 0;else if(a!=null&&a.tuneInGoal&&te-u.partTarget>a.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+a.tuneInGoal+" to: "+fe+" with playlist age: "+u.age),fe=0;else{var de=Math.floor(fe/u.targetduration);if(N+=de,B!==void 0){var ve=Math.round(fe%u.targetduration/u.partTarget);B+=ve}this.log("CDN Tune-in age: "+u.ageHeader+"s last advanced "+re.toFixed(2)+"s goal: "+fe+" skip sn "+de+" to part "+B)}u.tuneInGoal=fe}if(V=this.getDeliveryDirectives(u,r.deliveryDirectives,N,B),X||!le){u.requestScheduled=d,this.loadingPlaylist(A,V);return}}else(u.canBlockReload||u.canSkipUntil)&&(V=this.getDeliveryDirectives(u,r.deliveryDirectives,N,B));V&&N!==void 0&&u.canBlockReload&&(u.requestScheduled=l.loading.first+Math.max(O-c*2,O/2)),this.scheduleLoading(A,V,u)}else this.clearTimer()},i.scheduleLoading=function(e,r,a){var u=this,l=a||e.details;if(!l){this.loadingPlaylist(e,r);return}var d=self.performance.now(),c=l.requestScheduled;if(d>=c){this.loadingPlaylist(e,r);return}var p=c-d;this.log("reload live playlist "+(e.name||e.bitrate+"bps")+" in "+Math.round(p)+" ms"),this.clearTimer(),this.timer=self.setTimeout(function(){return u.loadingPlaylist(e,r)},p)},i.getDeliveryDirectives=function(e,r,a,u){var l=fa(e);return r!=null&&r.skip&&e.deltaUpdateFailed&&(a=r.msn,u=r.part,l=si.No),new ha(a,u,l)},i.checkRetry=function(e){var r=this,a=e.details,u=oi(e),l=e.errorAction,d=l||{},c=d.action,p=d.retryCount,y=p===void 0?0:p,A=d.retryConfig,T=!!l&&!!A&&(c===ht.RetryRequest||!l.resolved&&c===ht.SendAlternateToPenaltyBox);if(T){var b;if(y>=A.maxNumRetry)return!1;if(u&&(b=e.context)!=null&&b.deliveryDirectives)this.warn("Retrying playlist loading "+(y+1)+"/"+A.maxNumRetry+' after "'+a+'" without delivery-directives'),this.loadPlaylist();else{var L=ji(A,y);this.clearTimer(),this.timer=self.setTimeout(function(){return r.loadPlaylist()},L),this.warn("Retrying playlist loading "+(y+1)+"/"+A.maxNumRetry+' after "'+a+'" in '+L+"ms")}e.levelRetry=!0,l.resolved=!0}return T},s}(je),jf=function(n){function s(t,e){var r;return r=n.call(this,t,"level-controller")||this,r._levels=[],r._firstLevel=-1,r._maxAutoLevel=-1,r._startLevel=void 0,r.currentLevel=null,r.currentLevelIndex=-1,r.manualLevelIndex=-1,r.steering=void 0,r.onParsedComplete=void 0,r.steering=e,r._registerListeners(),r}S(s,n);var i=s.prototype;return i._registerListeners=function(){var e=this.hls;e.on(x.MANIFEST_LOADING,this.onManifestLoading,this),e.on(x.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(x.LEVEL_LOADED,this.onLevelLoaded,this),e.on(x.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(x.FRAG_BUFFERED,this.onFragBuffered,this),e.on(x.ERROR,this.onError,this)},i._unregisterListeners=function(){var e=this.hls;e.off(x.MANIFEST_LOADING,this.onManifestLoading,this),e.off(x.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(x.LEVEL_LOADED,this.onLevelLoaded,this),e.off(x.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(x.FRAG_BUFFERED,this.onFragBuffered,this),e.off(x.ERROR,this.onError,this)},i.destroy=function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),n.prototype.destroy.call(this)},i.stopLoad=function(){var e=this._levels;e.forEach(function(r){r.loadError=0,r.fragmentError=0}),n.prototype.stopLoad.call(this)},i.resetLevels=function(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1},i.onManifestLoading=function(e,r){this.resetLevels()},i.onManifestLoaded=function(e,r){var a=this,u=this.hls.config.preferManagedMediaSource,l=[],d={},c={},p=!1,y=!1,A=!1;r.levels.forEach(function(T){var b,L=T.attrs,R=T.audioCodec,C=T.videoCodec;R&&(T.audioCodec=R=ii(R,u)||void 0),((b=C)==null?void 0:b.indexOf("avc1"))===0&&(C=T.videoCodec=_u(C));var I=T.width,k=T.height,O=T.unknownCodecs,V=O?O.length:0;if(O)for(var N=V;N--;){var B=O[N];a.isAudioSupported(B)?(T.audioCodec=R=R?R+","+B:B,V--,gr.audio[R.substring(0,4)]=2):a.isVideoSupported(B)&&(T.videoCodec=C=C?C+","+B:B,V--,gr.video[C.substring(0,4)]=2)}if(p||(p=!!(I&&k)),y||(y=!!C),A||(A=!!R),V||R&&!a.isAudioSupported(R)||C&&!a.isVideoSupported(C)){a.log('Some or all CODECS not supported "'+L.CODECS+'"');return}var X=L.CODECS,z=L["FRAME-RATE"],K=L["HDCP-LEVEL"],j=L["PATHWAY-ID"],J=L.RESOLUTION,le=L["VIDEO-RANGE"],re=(j||".")+"-",te=""+re+T.bitrate+"-"+J+"-"+z+"-"+X+"-"+le+"-"+K;if(d[te])if(d[te].uri!==T.url&&!T.attrs["PATHWAY-ID"]){var de=c[te]+=1;T.attrs["PATHWAY-ID"]=new Array(de+1).join(".");var ve=a.createLevel(T);d[te]=ve,l.push(ve)}else d[te].addGroupId("audio",L.AUDIO),d[te].addGroupId("text",L.SUBTITLES);else{var fe=a.createLevel(T);d[te]=fe,c[te]=1,l.push(fe)}}),this.filterAndSortMediaOptions(l,r,p,y,A)},i.createLevel=function(e){var r=new da(e),a=e.supplemental;if(a!=null&&a.videoCodec&&!this.isVideoSupported(a.videoCodec)){var u=new Error('SUPPLEMENTAL-CODECS not supported "'+a.videoCodec+'"');this.log(u.message),r.supportedResult=Yn.getUnsupportedResult(u,[])}return r},i.isAudioSupported=function(e){return Vi(e,"audio",this.hls.config.preferManagedMediaSource)},i.isVideoSupported=function(e){return Vi(e,"video",this.hls.config.preferManagedMediaSource)},i.filterAndSortMediaOptions=function(e,r,a,u,l){var d=this,c=[],p=[],y=e;if((a||u)&&l&&(y=y.filter(function(N){var B=N.videoCodec,X=N.videoRange,z=N.width,K=N.height;return(!!B||!!(z&&K))&&Au(X)})),y.length===0){Promise.resolve().then(function(){if(d.hls){var N="no level with compatible codecs found in manifest",B=N;r.levels.length&&(B="one or more CODECS in variant not supported: "+gt(r.levels.map(function(z){return z.attrs.CODECS}).filter(function(z,K,j){return j.indexOf(z)===K})),d.warn(B),N+=" ("+B+")");var X=new Error(N);d.hls.trigger(x.ERROR,{type:Y.MEDIA_ERROR,details:M.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:r.url,error:X,reason:B})}});return}r.audioTracks&&(c=r.audioTracks.filter(function(N){return!N.audioCodec||d.isAudioSupported(N.audioCodec)}),Rs(c)),r.subtitles&&(p=r.subtitles,Rs(p));var A=y.slice(0);y.sort(function(N,B){if(N.attrs["HDCP-LEVEL"]!==B.attrs["HDCP-LEVEL"])return(N.attrs["HDCP-LEVEL"]||"")>(B.attrs["HDCP-LEVEL"]||"")?1:-1;if(a&&N.height!==B.height)return N.height-B.height;if(N.frameRate!==B.frameRate)return N.frameRate-B.frameRate;if(N.videoRange!==B.videoRange)return ai.indexOf(N.videoRange)-ai.indexOf(B.videoRange);if(N.videoCodec!==B.videoCodec){var X=oa(N.videoCodec),z=oa(B.videoCodec);if(X!==z)return z-X}if(N.uri===B.uri&&N.codecSet!==B.codecSet){var K=ri(N.codecSet),j=ri(B.codecSet);if(K!==j)return j-K}return N.averageBitrate!==B.averageBitrate?N.averageBitrate-B.averageBitrate:0});var T=A[0];if(this.steering&&(y=this.steering.filterParsedLevels(y),y.length!==A.length)){for(var b=0;b<A.length;b++)if(A[b].pathwayId===y[0].pathwayId){T=A[b];break}}this._levels=y;for(var L=0;L<y.length;L++)if(y[L]===T){var R;this._firstLevel=L;var C=T.bitrate,I=this.hls.bandwidthEstimate;if(this.log("manifest loaded, "+y.length+" level(s) found, first bitrate: "+C),((R=this.hls.userConfig)==null?void 0:R.abrEwmaDefaultEstimate)===void 0){var k=Math.min(C,this.hls.config.abrEwmaDefaultEstimateMax);k>I&&I===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=k)}break}var O=l&&!u,V={levels:y,audioTracks:c,subtitleTracks:p,sessionData:r.sessionData,sessionKeys:r.sessionKeys,firstLevel:this._firstLevel,stats:r.stats,audio:l,video:u,altAudio:!O&&c.some(function(N){return!!N.url})};this.hls.trigger(x.MANIFEST_PARSED,V)},i.onError=function(e,r){r.fatal||!r.context||r.context.type===ie.LEVEL&&r.context.level===this.level&&this.checkRetry(r)},i.onFragBuffered=function(e,r){var a=r.frag;if(a!==void 0&&a.type===ae.MAIN){var u=a.elementaryStreams;if(!Object.keys(u).some(function(d){return!!u[d]}))return;var l=this._levels[a.level];l!=null&&l.loadError&&(this.log("Resetting level error count of "+l.loadError+" on frag buffered"),l.loadError=0)}},i.onLevelLoaded=function(e,r){var a,u=r.level,l=r.details,d=r.levelInfo;if(!d){var c;this.warn("Invalid level index "+u),(c=r.deliveryDirectives)!=null&&c.skip&&(l.deltaUpdateFailed=!0);return}if(d===this.currentLevel||r.withoutMultiVariant){d.fragmentError===0&&(d.loadError=0);var p=d.details;p===r.details&&p.advanced&&(p=void 0),this.playlistLoaded(u,r,p)}else(a=r.deliveryDirectives)!=null&&a.skip&&(l.deltaUpdateFailed=!0)},i.loadPlaylist=function(e){n.prototype.loadPlaylist.call(this),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,e)},i.loadingPlaylist=function(e,r){n.prototype.loadingPlaylist.call(this,e,r);var a=this.getUrlWithDirectives(e.uri,r),u=this.currentLevelIndex,l=e.attrs["PATHWAY-ID"],d=e.details,c=d?.age;this.log("Loading level index "+u+(r?.msn!==void 0?" at sn "+r.msn+" part "+r.part:"")+(l?" Pathway "+l:"")+(c&&d.live?" age "+c.toFixed(1)+(d.type&&" "+d.type||""):"")+" "+a),this.hls.trigger(x.LEVEL_LOADING,{url:a,level:u,levelInfo:e,pathwayId:e.attrs["PATHWAY-ID"],id:0,deliveryDirectives:r||null})},i.removeLevel=function(e){var r=this,a;if(this._levels.length!==1){var u=this._levels.filter(function(d,c){return c!==e?!0:(r.steering&&r.steering.removeLevel(d),d===r.currentLevel&&(r.currentLevel=null,r.currentLevelIndex=-1,d.details&&d.details.fragments.forEach(function(p){return p.level=-1})),!1)});Ka(u),this._levels=u,this.currentLevelIndex>-1&&(a=this.currentLevel)!=null&&a.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.manualLevelIndex>-1&&(this.manualLevelIndex=this.currentLevelIndex);var l=u.length-1;this._firstLevel=Math.min(this._firstLevel,l),this._startLevel&&(this._startLevel=Math.min(this._startLevel,l)),this.hls.trigger(x.LEVELS_UPDATED,{levels:u})}},i.onLevelsUpdated=function(e,r){var a=r.levels;this._levels=a},i.checkMaxAutoUpdated=function(){var e=this.hls,r=e.autoLevelCapping,a=e.maxAutoLevel,u=e.maxHdcpLevel;this._maxAutoLevel!==a&&(this._maxAutoLevel=a,this.hls.trigger(x.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:r,levels:this.levels,maxAutoLevel:a,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:u}))},f(s,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"loadLevelObj",get:function(){return this.currentLevel}},{key:"level",get:function(){return this.currentLevelIndex},set:function(e){var r=this._levels;if(r.length!==0){if(e<0||e>=r.length){var a=new Error("invalid level idx"),u=e<0;if(this.hls.trigger(x.ERROR,{type:Y.OTHER_ERROR,details:M.LEVEL_SWITCH_ERROR,level:e,fatal:u,error:a,reason:a.message}),u)return;e=Math.min(e,r.length-1)}var l=this.currentLevelIndex,d=this.currentLevel,c=d?d.attrs["PATHWAY-ID"]:void 0,p=r[e],y=p.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=p,!(l===e&&d&&c===y)){this.log("Switching to level "+e+" ("+(p.height?p.height+"p ":"")+(p.videoRange?p.videoRange+" ":"")+(p.codecSet?p.codecSet+" ":"")+"@"+p.bitrate+")"+(y?" with Pathway "+y:"")+" from level "+l+(c?" with Pathway "+c:""));var A={level:e,attrs:p.attrs,details:p.details,bitrate:p.bitrate,averageBitrate:p.averageBitrate,maxBitrate:p.maxBitrate,realBitrate:p.realBitrate,width:p.width,height:p.height,codecSet:p.codecSet,audioCodec:p.audioCodec,videoCodec:p.videoCodec,audioGroups:p.audioGroups,subtitleGroups:p.subtitleGroups,loaded:p.loaded,loadError:p.loadError,fragmentError:p.fragmentError,name:p.name,id:p.id,uri:p.uri,url:p.url,urlId:0,audioGroupIds:p.audioGroupIds,textGroupIds:p.textGroupIds};this.hls.trigger(x.LEVEL_SWITCHING,A);var T=p.details;if(!T||T.live){var b=this.switchParams(p.uri,d?.details,T);this.loadPlaylist(b)}}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(e){this.manualLevelIndex=e,this._startLevel===void 0&&(this._startLevel=e),e!==-1&&(this.level=e)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(e){this._firstLevel=e}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var e=this.hls.config.startLevel;return e!==void 0?e:this.hls.firstAutoLevel}return this._startLevel},set:function(e){this._startLevel=e}},{key:"pathways",get:function(){return this.steering?this.steering.pathways():[]}},{key:"pathwayPriority",get:function(){return this.steering?this.steering.pathwayPriority:null},set:function(e){if(this.steering){var r=this.steering.pathways(),a=e.filter(function(u){return r.indexOf(u)!==-1});if(e.length<1){this.warn("pathwayPriority "+e+" should contain at least one pathway from list: "+r);return}this.steering.pathwayPriority=a}}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(e){this.level=e,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=e)}}])}(Wf);function Rs(n){var s={};n.forEach(function(i){var t=i.groupId||"";i.id=s[t]=s[t]||0,s[t]++})}var hn=[];typeof m<"u"&&m&&Yf();function Yf(){self.addEventListener("message",function(n){var s=n.data,i=s.instanceNo;if(i!==void 0){var t=hn[i];if(s.cmd==="reset"&&(delete hn[s.resetNo],t&&t.destroy(),s.cmd="init"),s.cmd==="init"){var e=JSON.parse(s.config),r=new Me;r.on(x.FRAG_DECRYPTED,Sr),r.on(x.ERROR,Sr);var a=Je(e.debug,s.id);zf(a,i),hn[i]=new on(r,s.typeSupported,e,"",s.id,a),Sr("init",null,i);return}if(t)switch(s.cmd){case"configure":{t.configure(s.config);break}case"demux":{var u=t.push(s.data,s.decryptdata,s.chunkMeta,s.state);dr(u)?u.then(function(c){dn(self,c,i)}).catch(function(c){Sr(x.ERROR,{instanceNo:i,type:Y.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,chunkMeta:s.chunkMeta,fatal:!1,error:c,err:c,reason:"transmuxer-worker push error"},i)}):dn(self,u,i);break}case"flush":{var l=s.chunkMeta,d=t.flush(l);dr(d)?d.then(function(c){ks(self,c,l,i)}).catch(function(c){Sr(x.ERROR,{type:Y.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,chunkMeta:s.chunkMeta,fatal:!1,error:c,err:c,reason:"transmuxer-worker flush error"},i)}):ks(self,d,l,i);break}}}})}function dn(n,s,i){if(qf(s.remuxResult))return!1;var t=[],e=s.remuxResult,r=e.audio,a=e.video;return r&&Cs(t,r),a&&Cs(t,a),n.postMessage({event:"transmuxComplete",data:s,instanceNo:i},t),!0}function Cs(n,s){s.data1&&n.push(s.data1.buffer),s.data2&&n.push(s.data2.buffer)}function ks(n,s,i,t){var e=s.reduce(function(r,a){return dn(n,a,t)||r},!1);e||n.postMessage({event:"transmuxComplete",data:s[0],instanceNo:t}),n.postMessage({event:"flush",data:i,instanceNo:t})}function Sr(n,s,i){self.postMessage({event:n,data:s,instanceNo:i})}function zf(n,s){var i=function(r){var a=function(l){Sr("workerLog",{logType:r,message:l},s)};n[r]=a};for(var t in n)i(t)}function qf(n){return!n.audio&&!n.video&&!n.text&&!n.id3&&!n.initSegment}var Gr="1.6.0",Tr={};function $f(){return typeof v=="function"}function Xf(){var n=Tr[Gr];if(n)return n.clientCount++,n;var s=new self.Blob(["var exports={};var module={exports:exports};function define(f){f()};define.amd=true;("+v.toString()+")(true);"],{type:"text/javascript"}),i=self.URL.createObjectURL(s),t=new self.Worker(i),e={worker:t,objectURL:i,clientCount:1};return Tr[Gr]=e,e}function Qf(n){var s=Tr[n];if(s)return s.clientCount++,s;var i=new self.URL(n,self.location.href).href,t=new self.Worker(i),e={worker:t,scriptURL:i,clientCount:1};return Tr[n]=e,e}function Zf(n){var s=Tr[n||Gr];if(s){var i=s.clientCount--;if(i===1){var t=s.worker,e=s.objectURL;delete Tr[n||Gr],e&&self.URL.revokeObjectURL(e),t.terminate()}}}var Ds=0,Jf=function(){function n(i,t,e,r){var a=this;this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=Ds++,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(A){var T=A.data,b=a.hls;if(!(!b||!(T!=null&&T.event)||T.instanceNo!==a.instanceNo))switch(T.event){case"init":{var L,R=(L=a.workerContext)==null?void 0:L.objectURL;R&&self.URL.revokeObjectURL(R);break}case"transmuxComplete":{a.handleTransmuxComplete(T.data);break}case"flush":{a.onFlush(T.data);break}case"workerLog":{b.logger[T.data.logType]&&b.logger[T.data.logType](T.data.message);break}default:{T.data=T.data||{},T.data.frag=a.frag,T.data.part=a.part,T.data.id=a.id,b.trigger(T.event,T.data);break}}},this.onWorkerError=function(A){if(a.hls){var T=new Error(A.message+" ("+A.filename+":"+A.lineno+")");a.hls.config.enableWorker=!1,a.hls.logger.warn('Error in "'+a.id+'" Web Worker, fallback to inline'),a.hls.trigger(x.ERROR,{type:Y.OTHER_ERROR,details:M.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:T})}};var u=i.config;this.hls=i,this.id=t,this.useWorker=!!u.enableWorker,this.onTransmuxComplete=e,this.onFlush=r;var l=function(T,b){b=b||{},b.frag=a.frag||void 0,T===x.ERROR&&(b=b,b.parent=a.id,b.part=a.part,a.error=b.error),a.hls.trigger(T,b)};this.observer=new Me,this.observer.on(x.FRAG_DECRYPTED,l),this.observer.on(x.ERROR,l);var d=ua(u.preferManagedMediaSource);if(this.useWorker&&typeof Worker<"u"){var c=this.hls.logger,p=u.workerPath||$f();if(p){try{u.workerPath?(c.log("loading Web Worker "+u.workerPath+' for "'+t+'"'),this.workerContext=Qf(u.workerPath)):(c.log('injecting Web Worker for "'+t+'"'),this.workerContext=Xf());var y=this.workerContext.worker;y.addEventListener("message",this.onWorkerMessage),y.addEventListener("error",this.onWorkerError),y.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:d,id:t,config:gt(u)})}catch(A){c.warn('Error setting up "'+t+'" Web Worker, fallback to inline',A),this.terminateWorker(),this.error=null,this.transmuxer=new on(this.observer,d,u,"",t,i.logger)}return}}this.transmuxer=new on(this.observer,d,u,"",t,i.logger)}var s=n.prototype;return s.reset=function(){if(this.frag=null,this.part=null,this.workerContext){var t=this.instanceNo;this.instanceNo=Ds++;var e=this.hls.config,r=ua(e.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:t,typeSupported:r,id:this.id,config:gt(e)})}},s.terminateWorker=function(){if(this.workerContext){var t=this.workerContext.worker;this.workerContext=null,t.removeEventListener("message",this.onWorkerMessage),t.removeEventListener("error",this.onWorkerError),Zf(this.hls.config.workerPath)}},s.destroy=function(){if(this.workerContext)this.terminateWorker(),this.onWorkerMessage=this.onWorkerError=null;else{var t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}var e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.part=null,this.observer=null,this.hls=null},s.push=function(t,e,r,a,u,l,d,c,p,y){var A,T,b=this;p.transmuxing.start=self.performance.now();var L=this.instanceNo,R=this.transmuxer,C=l?l.start:u.start,I=u.decryptdata,k=this.frag,O=!(k&&u.cc===k.cc),V=!(k&&p.level===k.level),N=k?p.sn-k.sn:-1,B=this.part?p.part-this.part.index:-1,X=N===0&&p.id>1&&p.id===k?.stats.chunkCount,z=!V&&(N===1||N===0&&(B===1||X&&B<=0)),K=self.performance.now();(V||N||u.stats.parsing.start===0)&&(u.stats.parsing.start=K),l&&(B||!z)&&(l.stats.parsing.start=K);var j=!(k&&((A=u.initSegment)==null?void 0:A.url)===((T=k.initSegment)==null?void 0:T.url)),J=new lf(O,z,c,V,C,j);if(!z||O||j){this.hls.logger.log("[transmuxer-interface]: Starting new transmux session for "+u.type+" sn: "+p.sn+(p.part>-1?" part: "+p.part:"")+" "+(this.id===ae.MAIN?"level":"track")+": "+p.level+" id: "+p.id+`
23
+ discontinuity: `+O+`
24
+ trackSwitch: `+V+`
25
+ contiguous: `+z+`
26
+ accurateTimeOffset: `+c+`
27
+ timeOffset: `+C+`
28
+ initSegmentChange: `+j);var le=new uf(r,a,e,d,y);this.configureTransmuxer(le)}if(this.frag=u,this.part=l,this.workerContext)this.workerContext.worker.postMessage({instanceNo:L,cmd:"demux",data:t,decryptdata:I,chunkMeta:p,state:J},t instanceof ArrayBuffer?[t]:[]);else if(R){var re=R.push(t,I,p,J);dr(re)?re.then(function(te){b.handleTransmuxComplete(te)}).catch(function(te){b.transmuxerError(te,p,"transmuxer-interface push error")}):this.handleTransmuxComplete(re)}},s.flush=function(t){var e=this;t.transmuxing.start=self.performance.now();var r=this.instanceNo,a=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:r,cmd:"flush",chunkMeta:t});else if(a){var u=a.flush(t);dr(u)?u.then(function(l){e.handleFlushResult(l,t)}).catch(function(l){e.transmuxerError(l,t,"transmuxer-interface flush error")}):this.handleFlushResult(u,t)}},s.transmuxerError=function(t,e,r){this.hls&&(this.error=t,this.hls.trigger(x.ERROR,{type:Y.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,chunkMeta:e,frag:this.frag||void 0,part:this.part||void 0,fatal:!1,error:t,err:t,reason:r}))},s.handleFlushResult=function(t,e){var r=this;t.forEach(function(a){r.handleTransmuxComplete(a)}),this.onFlush(e)},s.configureTransmuxer=function(t){var e=this.instanceNo,r=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({instanceNo:e,cmd:"configure",config:t}):r&&r.configure(t)},s.handleTransmuxComplete=function(t){t.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(t)},n}();function Is(){return self.SourceBuffer||self.WebKitSourceBuffer}function ws(){var n=nr();if(!n)return!1;var s=Is();return!s||s.prototype&&typeof s.prototype.appendBuffer=="function"&&typeof s.prototype.remove=="function"}function eh(){if(!ws())return!1;var n=nr();return typeof n?.isTypeSupported=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(function(s){return n.isTypeSupported(Or(s,"video"))})||["mp4a.40.2","fLaC"].some(function(s){return n.isTypeSupported(Or(s,"audio"))}))}function th(){var n,s=Is();return typeof(s==null||(n=s.prototype)==null?void 0:n.changeType)=="function"}var rh=100,ih=function(n){function s(t,e,r){var a;return a=n.call(this,t,e,r,"stream-controller",ae.MAIN)||this,a.audioCodecSwap=!1,a.level=-1,a._forceStartLoad=!1,a._hasEnoughToStart=!1,a.altAudio=0,a.audioOnly=!1,a.fragPlaying=null,a.fragLastKbps=0,a.couldBacktrack=!1,a.backtrackFragment=null,a.audioCodecSwitch=!1,a.videoBuffer=null,a.onMediaPlaying=function(){a.tick()},a.onMediaSeeked=function(){var u=a.media,l=u?u.currentTime:null;if(!(l===null||!w(l))&&(a.log("Media seeked to "+l.toFixed(3)),!!a.getBufferedFrag(l))){var d=a.getFwdBufferInfoAtPos(u,l,ae.MAIN,0);if(d===null||d.len===0){a.warn("Main forward buffer length at "+l+' on "seeked" event '+(d?d.len:"empty")+")");return}a.tick()}},a.registerListeners(),a}S(s,n);var i=s.prototype;return i.registerListeners=function(){n.prototype.registerListeners.call(this);var e=this.hls;e.on(x.MANIFEST_PARSED,this.onManifestParsed,this),e.on(x.LEVEL_LOADING,this.onLevelLoading,this),e.on(x.LEVEL_LOADED,this.onLevelLoaded,this),e.on(x.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(x.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(x.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(x.BUFFER_CREATED,this.onBufferCreated,this),e.on(x.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(x.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(x.FRAG_BUFFERED,this.onFragBuffered,this)},i.unregisterListeners=function(){n.prototype.unregisterListeners.call(this);var e=this.hls;e.off(x.MANIFEST_PARSED,this.onManifestParsed,this),e.off(x.LEVEL_LOADED,this.onLevelLoaded,this),e.off(x.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(x.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(x.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(x.BUFFER_CREATED,this.onBufferCreated,this),e.off(x.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(x.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(x.FRAG_BUFFERED,this.onFragBuffered,this)},i.onHandlerDestroying=function(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),n.prototype.onHandlerDestroying.call(this)},i.startLoad=function(e,r){if(this.levels){var a=this.lastCurrentTime,u=this.hls;if(this.stopLoad(),this.setInterval(rh),this.level=-1,!this.startFragRequested){var l=u.startLevel;l===-1&&(u.config.testBandwidth&&this.levels.length>1?(l=0,this.bitrateTest=!0):l=u.firstAutoLevel),u.nextLoadLevel=l,this.level=u.loadLevel,this._hasEnoughToStart=!!r}a>0&&e===-1&&!r&&(this.log("Override startPosition with lastCurrentTime @"+a.toFixed(3)),e=a),this.state=ne.IDLE,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=r?-1:e,this.tick()}else this._forceStartLoad=!0,this.state=ne.STOPPED},i.stopLoad=function(){this._forceStartLoad=!1,n.prototype.stopLoad.call(this)},i.doTick=function(){switch(this.state){case ne.WAITING_LEVEL:{var e=this.levels,r=this.level,a=e?.[r],u=a?.details;if(u&&(!u.live||this.levelLastLoaded===a&&!this.waitForLive(a))){if(this.waitForCdnTuneIn(u))break;this.state=ne.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=ne.IDLE;break}break}case ne.FRAG_LOADING_WAITING_RETRY:{var l,d=self.performance.now(),c=this.retryDate;if(!c||d>=c||(l=this.media)!=null&&l.seeking){var p=this.levels,y=this.level,A=p?.[y];this.resetStartWhenNotLoaded(A||null),this.state=ne.IDLE}}break}this.state===ne.IDLE&&this.doTickIdle(),this.onTickEnd()},i.onTickEnd=function(){var e;n.prototype.onTickEnd.call(this),(e=this.media)!=null&&e.readyState&&this.media.seeking===!1&&(this.lastCurrentTime=this.media.currentTime),this.checkFragmentChanged()},i.doTickIdle=function(){var e=this.hls,r=this.levelLastLoaded,a=this.levels,u=this.media;if(!(r===null||!u&&!this.primaryPrefetch&&(this.startFragRequested||!e.config.startFragPrefetch))&&!(this.altAudio&&this.audioOnly)){var l=this.buffering?e.nextLoadLevel:e.loadLevel;if(a!=null&&a[l]){var d=a[l],c=this.getMainFwdBufferInfo();if(c!==null){var p=this.getLevelDetails();if(p&&this._streamEnded(c,p)){var y={};this.altAudio===2&&(y.type="video"),this.hls.trigger(x.BUFFER_EOS,y),this.state=ne.ENDED;return}if(this.buffering){e.loadLevel!==l&&e.manualLevel===-1&&this.log("Adapting to level "+l+" from level "+this.level),this.level=e.nextLoadLevel=l;var A=d.details;if(!A||this.state===ne.WAITING_LEVEL||this.waitForLive(d)){this.level=l,this.state=ne.WAITING_LEVEL,this.startFragRequested=!1;return}var T=c.len,b=this.getMaxBufferLength(d.maxBitrate);if(!(T>=b)){this.backtrackFragment&&this.backtrackFragment.start>c.end&&(this.backtrackFragment=null);var L=this.backtrackFragment?this.backtrackFragment.start:c.end,R=this.getNextFragment(L,A);if(this.couldBacktrack&&!this.fragPrevious&&R&&jt(R)&&this.fragmentTracker.getState(R)!==Et.OK){var C,I=((C=this.backtrackFragment)!=null?C:R).sn,k=I-A.startSN,O=A.fragments[k-1];O&&R.cc===O.cc&&(R=O,this.fragmentTracker.removeFragment(O))}else this.backtrackFragment&&c.len&&(this.backtrackFragment=null);if(R&&this.isLoopLoading(R,L)){var V=R.gap;if(!V){var N=this.audioOnly&&!this.altAudio?qe.AUDIO:qe.VIDEO,B=(N===qe.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;B&&this.afterBufferFlushed(B,N,ae.MAIN)}R=this.getNextFragmentLoopLoading(R,A,c,ae.MAIN,b)}R&&(R.initSegment&&!R.initSegment.data&&!this.bitrateTest&&(R=R.initSegment),this.loadFragment(R,d,L))}}}}}},i.loadFragment=function(e,r,a){var u=this.fragmentTracker.getState(e);u===Et.NOT_LOADED||u===Et.PARTIAL?jt(e)?this.bitrateTest?(this.log("Fragment "+e.sn+" of level "+e.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(e,r)):n.prototype.loadFragment.call(this,e,r,a):this._loadInitSegment(e,r):this.clearTrackerIfNeeded(e)},i.getBufferedFrag=function(e){return this.fragmentTracker.getBufferedFrag(e,ae.MAIN)},i.followingBufferedFrag=function(e){return e?this.getBufferedFrag(e.end+.5):null},i.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},i.nextLevelSwitch=function(){var e=this.levels,r=this.media;if(r!=null&&r.readyState){var a,u=this.getAppendedFrag(r.currentTime);u&&u.start>1&&this.flushMainBuffer(0,u.start-1);var l=this.getLevelDetails();if(l!=null&&l.live){var d=this.getMainFwdBufferInfo();if(!d||d.len<l.targetduration*2)return}if(!r.paused&&e){var c=this.hls.nextLoadLevel,p=e[c],y=this.fragLastKbps;y&&this.fragCurrent?a=this.fragCurrent.duration*p.maxBitrate/(1e3*y)+1:a=0}else a=0;var A=this.getBufferedFrag(r.currentTime+a);if(A){var T=this.followingBufferedFrag(A);if(T){this.abortCurrentFrag();var b=T.maxStartPTS?T.maxStartPTS:T.start,L=T.duration,R=Math.max(A.end,b+Math.min(Math.max(L-this.config.maxFragLookUpTolerance,L*(this.couldBacktrack?.5:.125)),L*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(R,Number.POSITIVE_INFINITY)}}}},i.abortCurrentFrag=function(){var e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case ne.KEY_LOADING:case ne.FRAG_LOADING:case ne.FRAG_LOADING_WAITING_RETRY:case ne.PARSING:case ne.PARSED:this.state=ne.IDLE;break}this.nextLoadPosition=this.getLoadPosition()},i.flushMainBuffer=function(e,r){n.prototype.flushMainBuffer.call(this,e,r,this.altAudio===2?"video":null)},i.onMediaAttached=function(e,r){n.prototype.onMediaAttached.call(this,e,r);var a=r.media;Br(a,"playing",this.onMediaPlaying),Br(a,"seeked",this.onMediaSeeked)},i.onMediaDetaching=function(e,r){var a=this.media;a&&(_r(a,"playing",this.onMediaPlaying),_r(a,"seeked",this.onMediaSeeked)),this.videoBuffer=null,this.fragPlaying=null,n.prototype.onMediaDetaching.call(this,e,r);var u=!!r.transferMedia;u||(this._hasEnoughToStart=!1)},i.onManifestLoading=function(){n.prototype.onManifestLoading.call(this),this.log("Trigger BUFFER_RESET"),this.hls.trigger(x.BUFFER_RESET,void 0),this.couldBacktrack=!1,this.fragLastKbps=0,this.fragPlaying=this.backtrackFragment=null,this.altAudio=0,this.audioOnly=!1},i.onManifestParsed=function(e,r){var a=!1,u=!1;r.levels.forEach(function(l){var d=l.audioCodec;d&&(a=a||d.indexOf("mp4a.40.2")!==-1,u=u||d.indexOf("mp4a.40.5")!==-1)}),this.audioCodecSwitch=a&&u&&!th(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=r.levels,this.startFragRequested=!1},i.onLevelLoading=function(e,r){var a=this.levels;if(!(!a||this.state!==ne.IDLE)){var u=r.levelInfo;(!u.details||u.details.live&&(this.levelLastLoaded!==u||u.details.expired)||this.waitForCdnTuneIn(u.details))&&(this.state=ne.WAITING_LEVEL)}},i.onLevelLoaded=function(e,r){var a,u=this.levels,l=this.startFragRequested,d=r.level,c=r.details,p=c.totalduration;if(!u){this.warn("Levels were reset while loading level "+d);return}this.log("Level "+d+" loaded ["+c.startSN+","+c.endSN+"]"+(c.lastPartSn?"[part-"+c.lastPartSn+"-"+c.lastPartIndex+"]":"")+", cc ["+c.startCC+", "+c.endCC+"] duration:"+p);var y=r.levelInfo,A=this.fragCurrent;A&&(this.state===ne.FRAG_LOADING||this.state===ne.FRAG_LOADING_WAITING_RETRY)&&A.level!==r.level&&A.loader&&this.abortCurrentFrag();var T=0;if(c.live||(a=y.details)!=null&&a.live){var b;if(this.checkLiveUpdate(c),c.deltaUpdateFailed)return;T=this.alignPlaylists(c,y.details,(b=this.levelLastLoaded)==null?void 0:b.details)}if(y.details=c,this.levelLastLoaded=y,l||this.setStartPosition(c,T),this.hls.trigger(x.LEVEL_UPDATED,{details:c,level:d}),this.state===ne.WAITING_LEVEL){if(this.waitForCdnTuneIn(c))return;this.state=ne.IDLE}l&&c.live&&this.synchronizeToLiveEdge(c),this.tick()},i.synchronizeToLiveEdge=function(e){var r=this.config,a=this.media;if(a){var u=this.hls.liveSyncPosition,l=this.getLoadPosition(),d=e.fragmentStart,c=e.edge,p=l>=d-r.maxFragLookUpTolerance&&l<=c;if(u!==null&&a.duration>u&&(l<u||!p)){var y=r.liveMaxLatencyDuration!==void 0?r.liveMaxLatencyDuration:r.liveMaxLatencyDurationCount*e.targetduration;(!p&&a.readyState<4||l<c-y)&&(this._hasEnoughToStart||(this.nextLoadPosition=u),a.readyState&&(this.warn("Playback: "+l.toFixed(3)+" is located too far from the end of live sliding playlist: "+c+", reset currentTime to : "+u.toFixed(3)),a.currentTime=u))}}},i._handleFragmentLoadProgress=function(e){var r,a=e.frag,u=e.part,l=e.payload,d=this.levels;if(!d){this.warn("Levels were reset while fragment load was in progress. Fragment "+a.sn+" of level "+a.level+" will not be buffered");return}var c=d[a.level];if(!c){this.warn("Level "+a.level+" not found on progress");return}var p=c.details;if(!p){this.warn("Dropping fragment "+a.sn+" of level "+a.level+" after level details were reset"),this.fragmentTracker.removeFragment(a);return}var y=c.videoCodec,A=p.PTSKnown||!p.live,T=(r=a.initSegment)==null?void 0:r.data,b=this._getAudioCodec(c),L=this.transmuxer=this.transmuxer||new Jf(this.hls,ae.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),R=u?u.index:-1,C=R!==-1,I=new _s(a.level,a.sn,a.stats.chunkCount,l.byteLength,R,C),k=this.initPTS[a.cc];L.push(l,T,b,y,a,u,p.totalduration,A,I,k)},i.onAudioTrackSwitching=function(e,r){var a=this,u=this.hls,l=this.altAudio===2,d=pa(r.url,u);if(d)this.altAudio=1;else{if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var c=this.fragCurrent;c&&(this.log("Switching to main audio track, cancel main fragment load"),c.abortRequests(),this.fragmentTracker.removeFragment(c)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();if(l){this.fragmentTracker.removeAllFragments(),u.once(x.BUFFER_FLUSHED,function(){var p;(p=a.hls)==null||p.trigger(x.AUDIO_TRACK_SWITCHED,r)}),u.trigger(x.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});return}u.trigger(x.AUDIO_TRACK_SWITCHED,r)}},i.onAudioTrackSwitched=function(e,r){var a=pa(r.url,this.hls);if(a){var u=this.videoBuffer;u&&this.mediaBuffer!==u&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=u)}this.altAudio=a?2:0,this.tick()},i.onBufferCreated=function(e,r){var a=r.tracks,u,l,d=!1;for(var c in a){var p=a[c];if(p.id==="main"){if(l=c,u=p,c==="video"){var y=a[c];y&&(this.videoBuffer=y.buffer)}}else d=!0}d&&u?(this.log("Alternate track found, use "+l+".buffered to schedule main fragment loading"),this.mediaBuffer=u.buffer):this.mediaBuffer=this.media},i.onFragBuffered=function(e,r){var a=r.frag,u=r.part,l=a.type===ae.MAIN;if(l){if(this.fragContextChanged(a)){this.warn("Fragment "+a.sn+(u?" p: "+u.index:"")+" of level "+a.level+" finished buffering, but was aborted. state: "+this.state),this.state===ne.PARSED&&(this.state=ne.IDLE);return}var d=u?u.stats:a.stats;this.fragLastKbps=Math.round(8*d.total/(d.buffering.end-d.loading.first)),jt(a)&&(this.fragPrevious=a),this.fragBufferedComplete(a,u)}var c=this.media;c&&(!this._hasEnoughToStart&&Fe.getBuffered(c).length&&(this._hasEnoughToStart=!0,this.seekToStartPos()),l&&this.tick())},i.onError=function(e,r){var a;if(r.fatal){this.state=ne.ERROR;return}switch(r.details){case M.FRAG_GAP:case M.FRAG_PARSING_ERROR:case M.FRAG_DECRYPT_ERROR:case M.FRAG_LOAD_ERROR:case M.FRAG_LOAD_TIMEOUT:case M.KEY_LOAD_ERROR:case M.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(ae.MAIN,r);break;case M.LEVEL_LOAD_ERROR:case M.LEVEL_LOAD_TIMEOUT:case M.LEVEL_PARSING_ERROR:!r.levelRetry&&this.state===ne.WAITING_LEVEL&&((a=r.context)==null?void 0:a.type)===ie.LEVEL&&(this.state=ne.IDLE);break;case M.BUFFER_ADD_CODEC_ERROR:case M.BUFFER_APPEND_ERROR:if(r.parent!=="main")return;this.resetLoadingState();break;case M.BUFFER_FULL_ERROR:if(r.parent!=="main")return;this.reduceLengthAndFlushBuffer(r)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case M.INTERNAL_EXCEPTION:this.recoverWorkerError(r);break}},i.onFragLoadEmergencyAborted=function(){this.state=ne.IDLE,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()},i.onBufferFlushed=function(e,r){var a=r.type;if(a!==qe.AUDIO||!this.altAudio){var u=(a===qe.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;u&&(this.afterBufferFlushed(u,a,ae.MAIN),this.tick())}},i.onLevelsUpdated=function(e,r){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level,this.level===-1&&this.resetWhenMissingContext(this.fragCurrent)),this.levels=r.levels},i.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},i.seekToStartPos=function(){var e=this.media;if(e){var r=e.currentTime,a=this.startPosition;if(a>=0&&r<a){if(e.seeking){this.log("could not seek to "+a+", already seeking at "+r);return}var u=this.timelineOffset;u&&a&&(a+=u);var l=this.getLevelDetails(),d=Fe.getBuffered(e),c=d.length?d.start(0):0,p=c-a,y=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);p>0&&(p<y||this.loadingParts&&p<2*(l?.partTarget||0))&&(this.log("adjusting start position by "+p+" to match buffer start"),a+=p,this.startPosition=a),r<a&&(this.log("seek to target start position "+a+" from current time "+r+" buffer start "+c),e.currentTime=a)}}},i._getAudioCodec=function(e){var r=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&r&&(this.log("Swapping audio codec"),r.indexOf("mp4a.40.5")!==-1?r="mp4a.40.2":r="mp4a.40.5"),r},i._loadBitrateTestFrag=function(e,r){var a=this;e.bitrateTest=!0,this._doFragLoad(e,r).then(function(u){var l=a.hls,d=u?.frag;if(!(!d||a.fragContextChanged(d))){r.fragmentError=0,a.state=ne.IDLE,a.startFragRequested=!1,a.bitrateTest=!1;var c=d.stats;c.parsing.start=c.parsing.end=c.buffering.start=c.buffering.end=self.performance.now(),l.trigger(x.FRAG_LOADED,u),d.bitrateTest=!1}})},i._handleTransmuxComplete=function(e){var r,a=this.playlistType,u=this.hls,l=e.remuxResult,d=e.chunkMeta,c=this.getCurrentContext(d);if(!c){this.resetWhenMissingContext(d);return}var p=c.frag,y=c.part,A=c.level,T=l.video,b=l.text,L=l.id3,R=l.initSegment,C=A.details,I=this.altAudio?void 0:l.audio;if(this.fragContextChanged(p)){this.fragmentTracker.removeFragment(p);return}if(this.state=ne.PARSING,R){if(R!=null&&R.tracks){var k=p.initSegment||p;this._bufferInitSegment(A,R.tracks,k,d),u.trigger(x.FRAG_PARSING_INIT_SEGMENT,{frag:k,id:a,tracks:R.tracks})}var O=R.initPTS,V=R.timescale;w(O)&&(this.initPTS[p.cc]={baseTime:O,timescale:V},u.trigger(x.INIT_PTS_FOUND,{frag:p,id:a,initPTS:O,timescale:V}))}if(T&&C){var N=C.fragments[p.sn-1-C.startSN],B=p.sn===C.startSN,X=!N||p.cc>N.cc;if(l.independent!==!1){var z=T.startPTS,K=T.endPTS,j=T.startDTS,J=T.endDTS;if(y)y.elementaryStreams[T.type]={startPTS:z,endPTS:K,startDTS:j,endDTS:J};else if(T.firstKeyFrame&&T.independent&&d.id===1&&!X&&(this.couldBacktrack=!0),T.dropped&&T.independent){var le=this.getMainFwdBufferInfo(),re=(le?le.end:this.getLoadPosition())+this.config.maxBufferHole,te=T.firstKeyFramePTS?T.firstKeyFramePTS:z;if(!B&&re<te-this.config.maxBufferHole&&!X){this.backtrack(p);return}else X&&(p.gap=!0);p.setElementaryStreamInfo(T.type,p.start,K,p.start,J,!0)}else B&&z-(C.appliedTimelineOffset||0)>yi&&(p.gap=!0);p.setElementaryStreamInfo(T.type,z,K,j,J),this.backtrackFragment&&(this.backtrackFragment=p),this.bufferFragmentData(T,p,y,d,B||X)}else if(B||X)p.gap=!0;else{this.backtrack(p);return}}if(I){var fe=I.startPTS,de=I.endPTS,ve=I.startDTS,ge=I.endDTS;y&&(y.elementaryStreams[qe.AUDIO]={startPTS:fe,endPTS:de,startDTS:ve,endDTS:ge}),p.setElementaryStreamInfo(qe.AUDIO,fe,de,ve,ge),this.bufferFragmentData(I,p,y,d)}if(C&&L!=null&&(r=L.samples)!=null&&r.length){var Ne={id:a,frag:p,details:C,samples:L.samples};u.trigger(x.FRAG_PARSING_METADATA,Ne)}if(C&&b){var we={id:a,frag:p,details:C,samples:b.samples};u.trigger(x.FRAG_PARSING_USERDATA,we)}},i._bufferInitSegment=function(e,r,a,u){var l=this;if(this.state===ne.PARSING){this.audioOnly=!!r.audio&&!r.video,this.altAudio&&!this.audioOnly&&delete r.audio;var d=r.audio,c=r.video,p=r.audiovideo;if(d){var y=ni(d.codec,e.audioCodec);y==="mp4a"&&(y="mp4a.40.5");var A=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){y&&(y.indexOf("mp4a.40.5")!==-1?y="mp4a.40.2":y="mp4a.40.5");var T=d.metadata;T&&"channelCount"in T&&(T.channelCount||1)!==1&&A.indexOf("firefox")===-1&&(y="mp4a.40.5")}y&&y.indexOf("mp4a.40.5")!==-1&&A.indexOf("android")!==-1&&d.container!=="audio/mpeg"&&(y="mp4a.40.2",this.log("Android: force audio codec to "+y)),e.audioCodec&&e.audioCodec!==y&&this.log('Swapping manifest audio codec "'+e.audioCodec+'" for "'+y+'"'),d.levelCodec=y,d.id=ae.MAIN,this.log("Init audio buffer, container:"+d.container+", codecs[selected/level/parsed]=["+(y||"")+"/"+(e.audioCodec||"")+"/"+d.codec+"]"),delete r.audiovideo}if(c){c.levelCodec=e.videoCodec,c.id=ae.MAIN;var b=c.codec;if(b?.length===4)switch(b){case"hvc1":case"hev1":c.codec="hvc1.1.6.L120.90";break;case"av01":c.codec="av01.0.04M.08";break;case"avc1":c.codec="avc1.42e01e";break}this.log("Init video buffer, container:"+c.container+", codecs[level/parsed]=["+(e.videoCodec||"")+"/"+b+"]"+(c.codec!==b?" parsed-corrected="+c.codec:"")+(c.supplemental?" supplemental="+c.supplemental:"")),delete r.audiovideo}p&&(this.log("Init audiovideo buffer, container:"+p.container+", codecs[level/parsed]=["+e.codecs+"/"+p.codec+"]"),delete r.video,delete r.audio);var L=Object.keys(r);if(L.length){if(this.hls.trigger(x.BUFFER_CODECS,r),!this.hls)return;L.forEach(function(R){var C=r[R],I=C.initSegment;I!=null&&I.byteLength&&l.hls.trigger(x.BUFFER_APPENDING,{type:R,data:I,frag:a,part:null,chunkMeta:u,parent:a.type})})}this.tickImmediate()}},i.getMainFwdBufferInfo=function(){var e=this.mediaBuffer&&this.altAudio===2?this.mediaBuffer:this.media;return this.getFwdBufferInfo(e,ae.MAIN)},i.backtrack=function(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=ne.IDLE},i.checkFragmentChanged=function(){var e=this.media,r=null;if(e&&e.readyState>1&&e.seeking===!1){var a=e.currentTime;if(Fe.isBuffered(e,a)?r=this.getAppendedFrag(a):Fe.isBuffered(e,a+.1)&&(r=this.getAppendedFrag(a+.1)),r){this.backtrackFragment=null;var u=this.fragPlaying,l=r.level;(!u||r.sn!==u.sn||u.level!==l)&&(this.fragPlaying=r,this.hls.trigger(x.FRAG_CHANGED,{frag:r}),(!u||u.level!==l)&&this.hls.trigger(x.LEVEL_SWITCHED,{level:l}))}}},f(s,[{key:"hasEnoughToStart",get:function(){return this._hasEnoughToStart}},{key:"maxBufferLength",get:function(){var e=this.levels,r=this.level,a=e?.[r];return a?this.getMaxBufferLength(a.maxBitrate):this.config.maxBufferLength}},{key:"nextLevel",get:function(){var e=this.nextBufferedFrag;return e?e.level:-1}},{key:"currentFrag",get:function(){var e;if(this.fragPlaying)return this.fragPlaying;var r=((e=this.media)==null?void 0:e.currentTime)||this.lastCurrentTime;return w(r)?this.getAppendedFrag(r):null}},{key:"currentProgramDateTime",get:function(){var e,r=((e=this.media)==null?void 0:e.currentTime)||this.lastCurrentTime;if(w(r)){var a=this.getLevelDetails(),u=this.currentFrag||(a?Wi(null,a.fragments,r):null);if(u){var l=u.programDateTime;if(l!==null){var d=l+(r-u.start)*1e3;return new Date(d)}}}return null}},{key:"currentLevel",get:function(){var e=this.currentFrag;return e?e.level:-1}},{key:"nextBufferedFrag",get:function(){var e=this.currentFrag;return e?this.followingBufferedFrag(e):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}])}(Df),nh=function(){function n(i){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=i}var s=n.prototype;return s.abort=function(t){for(var e in this.keyUriToKeyInfo){var r=this.keyUriToKeyInfo[e].loader;if(r){var a;if(t&&t!==((a=r.context)==null?void 0:a.frag.type))return;r.abort()}}},s.detach=function(){for(var t in this.keyUriToKeyInfo){var e=this.keyUriToKeyInfo[t];(e.mediaKeySessionContext||e.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[t]}},s.destroy=function(){this.detach();for(var t in this.keyUriToKeyInfo){var e=this.keyUriToKeyInfo[t].loader;e&&e.destroy()}this.keyUriToKeyInfo={}},s.createKeyLoadError=function(t,e,r,a,u){return e===void 0&&(e=M.KEY_LOAD_ERROR),new Jt({type:Y.NETWORK_ERROR,details:e,fatal:!1,frag:t,response:u,error:r,networkDetails:a})},s.loadClear=function(t,e){var r=this;if(this.emeController&&this.config.emeEnabled)for(var a=t.sn,u=t.cc,l=function(){var p=e[d];if(u<=p.cc&&(a==="initSegment"||p.sn==="initSegment"||a<p.sn))return r.emeController.selectKeySystemFormat(p).then(function(y){p.setKeyFormat(y)}),1},d=0;d<e.length&&!l();d++);},s.load=function(t){var e=this;return!t.decryptdata&&t.encrypted&&this.emeController&&this.config.emeEnabled?this.emeController.selectKeySystemFormat(t).then(function(r){return e.loadInternal(t,r)}):this.loadInternal(t)},s.loadInternal=function(t,e){var r,a;e&&t.setKeyFormat(e);var u=t.decryptdata;if(!u){var l=new Error(e?"Expected frag.decryptdata to be defined after setting format "+e:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(t,M.KEY_LOAD_ERROR,l))}var d=u.uri;if(!d)return Promise.reject(this.createKeyLoadError(t,M.KEY_LOAD_ERROR,new Error('Invalid key URI: "'+d+'"')));var c=this.keyUriToKeyInfo[d];if((r=c)!=null&&r.decryptdata.key)return u.key=c.decryptdata.key,Promise.resolve({frag:t,keyInfo:c});if((a=c)!=null&&a.keyLoadPromise){var p;switch((p=c.mediaKeySessionContext)==null?void 0:p.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return c.keyLoadPromise.then(function(y){return u.key=y.keyInfo.decryptdata.key,{frag:t,keyInfo:c}})}}switch(c=this.keyUriToKeyInfo[d]={decryptdata:u,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},u.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return u.keyFormat==="identity"?this.loadKeyHTTP(c,t):this.loadKeyEME(c,t);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(c,t);default:return Promise.reject(this.createKeyLoadError(t,M.KEY_LOAD_ERROR,new Error('Key supplied with unsupported METHOD: "'+u.method+'"')))}},s.loadKeyEME=function(t,e){var r={frag:e,keyInfo:t};if(this.emeController&&this.config.emeEnabled){var a=this.emeController.loadKey(r);if(a)return(t.keyLoadPromise=a.then(function(u){return t.mediaKeySessionContext=u,r})).catch(function(u){throw t.keyLoadPromise=null,u})}return Promise.resolve(r)},s.loadKeyHTTP=function(t,e){var r=this,a=this.config,u=a.loader,l=new u(a);return e.keyLoader=t.loader=l,t.keyLoadPromise=new Promise(function(d,c){var p={keyInfo:t,frag:e,responseType:"arraybuffer",url:t.decryptdata.uri},y=a.keyLoadPolicy.default,A={loadPolicy:y,timeout:y.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},T={onSuccess:function(L,R,C,I){var k=C.frag,O=C.keyInfo,V=C.url;if(!k.decryptdata||O!==r.keyUriToKeyInfo[V])return c(r.createKeyLoadError(k,M.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),I));O.decryptdata.key=k.decryptdata.key=new Uint8Array(L.data),k.keyLoader=null,O.loader=null,d({frag:k,keyInfo:O})},onError:function(L,R,C,I){r.resetLoader(R),c(r.createKeyLoadError(e,M.KEY_LOAD_ERROR,new Error("HTTP Error "+L.code+" loading key "+L.text),C,H({url:p.url,data:void 0},L)))},onTimeout:function(L,R,C){r.resetLoader(R),c(r.createKeyLoadError(e,M.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),C))},onAbort:function(L,R,C){r.resetLoader(R),c(r.createKeyLoadError(e,M.INTERNAL_ABORTED,new Error("key loading aborted"),C))}};l.load(p,A,T)})},s.resetLoader=function(t){var e=t.frag,r=t.keyInfo,a=t.url,u=r.loader;e.keyLoader===u&&(e.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[a],u&&u.destroy()},n}();function Ps(n){var s=n.type;switch(s){case ie.AUDIO_TRACK:return ae.AUDIO;case ie.SUBTITLE_TRACK:return ae.SUBTITLE;default:return ae.MAIN}}function cn(n,s){var i=n.url;return(i===void 0||i.indexOf("data:")===0)&&(i=s.url),i}var ah=function(){function n(i){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=i,this.registerListeners()}var s=n.prototype;return s.startLoad=function(t){},s.stopLoad=function(){this.destroyInternalLoaders()},s.registerListeners=function(){var t=this.hls;t.on(x.MANIFEST_LOADING,this.onManifestLoading,this),t.on(x.LEVEL_LOADING,this.onLevelLoading,this),t.on(x.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.on(x.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),t.on(x.LEVELS_UPDATED,this.onLevelsUpdated,this)},s.unregisterListeners=function(){var t=this.hls;t.off(x.MANIFEST_LOADING,this.onManifestLoading,this),t.off(x.LEVEL_LOADING,this.onLevelLoading,this),t.off(x.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.off(x.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),t.off(x.LEVELS_UPDATED,this.onLevelsUpdated,this)},s.createInternalLoader=function(t){var e=this.hls.config,r=e.pLoader,a=e.loader,u=r||a,l=new u(e);return this.loaders[t.type]=l,l},s.getInternalLoader=function(t){return this.loaders[t.type]},s.resetInternalLoader=function(t){this.loaders[t]&&delete this.loaders[t]},s.destroyInternalLoaders=function(){for(var t in this.loaders){var e=this.loaders[t];e&&e.destroy(),this.resetInternalLoader(t)}},s.destroy=function(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()},s.onManifestLoading=function(t,e){var r=e.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:ie.MANIFEST,url:r,deliveryDirectives:null,levelOrTrack:null})},s.onLevelLoading=function(t,e){var r=e.id,a=e.level,u=e.pathwayId,l=e.url,d=e.deliveryDirectives,c=e.levelInfo;this.load({id:r,level:a,pathwayId:u,responseType:"text",type:ie.LEVEL,url:l,deliveryDirectives:d,levelOrTrack:c})},s.onAudioTrackLoading=function(t,e){var r=e.id,a=e.groupId,u=e.url,l=e.deliveryDirectives,d=e.track;this.load({id:r,groupId:a,level:null,responseType:"text",type:ie.AUDIO_TRACK,url:u,deliveryDirectives:l,levelOrTrack:d})},s.onSubtitleTrackLoading=function(t,e){var r=e.id,a=e.groupId,u=e.url,l=e.deliveryDirectives,d=e.track;this.load({id:r,groupId:a,level:null,responseType:"text",type:ie.SUBTITLE_TRACK,url:u,deliveryDirectives:l,levelOrTrack:d})},s.onLevelsUpdated=function(t,e){var r=this.loaders[ie.LEVEL];if(r){var a=r.context;a&&!e.levels.some(function(u){return u===a.levelOrTrack})&&(r.abort(),delete this.loaders[ie.LEVEL])}},s.load=function(t){var e,r=this,a=this.hls.config,u=this.getInternalLoader(t);if(u){var l=this.hls.logger,d=u.context;if(d&&d.levelOrTrack===t.levelOrTrack&&(d.url===t.url||d.deliveryDirectives&&!t.deliveryDirectives)){d.url===t.url?l.log("[playlist-loader]: ignore "+t.url+" ongoing request"):l.log("[playlist-loader]: ignore "+t.url+" in favor of "+d.url);return}l.log("[playlist-loader]: aborting previous loader for type: "+t.type),u.abort()}var c;if(t.type===ie.MANIFEST?c=a.manifestLoadPolicy.default:c=E({},a.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),u=this.createInternalLoader(t),w((e=t.deliveryDirectives)==null?void 0:e.part)){var p;if(t.type===ie.LEVEL&&t.level!==null?p=this.hls.levels[t.level].details:t.type===ie.AUDIO_TRACK&&t.id!==null?p=this.hls.audioTracks[t.id].details:t.type===ie.SUBTITLE_TRACK&&t.id!==null&&(p=this.hls.subtitleTracks[t.id].details),p){var y=p.partTarget,A=p.targetduration;if(y&&A){var T=Math.max(y*3,A*.8)*1e3;c=E({},c,{maxTimeToFirstByteMs:Math.min(T,c.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(T,c.maxTimeToFirstByteMs)})}}}var b=c.errorRetry||c.timeoutRetry||{},L={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:b.maxNumRetry||0,retryDelay:b.retryDelayMs||0,maxRetryDelay:b.maxRetryDelayMs||0},R={onSuccess:function(I,k,O,V){var N=r.getInternalLoader(O);r.resetInternalLoader(O.type);var B=I.data;if(B.indexOf("#EXTM3U")!==0){r.handleManifestParsingError(I,O,new Error("no EXTM3U delimiter"),V||null,k);return}k.parsing.start=performance.now(),Fr.isMediaPlaylist(B)||O.type!==ie.MANIFEST?r.handleTrackOrLevelPlaylist(I,k,O,V||null,N):r.handleMasterPlaylist(I,k,O,V)},onError:function(I,k,O,V){r.handleNetworkError(k,O,!1,I,V)},onTimeout:function(I,k,O){r.handleNetworkError(k,O,!0,void 0,I)}};u.load(t,L,R)},s.checkAutostartLoad=function(){if(this.hls){var t=this.hls,e=t.config,r=e.autoStartLoad,a=e.startPosition,u=t.forceStartLoad;(r||u)&&(this.hls.logger.log((r?"auto":"force")+" startLoad with configured startPosition "+a),this.hls.startLoad(a))}},s.handleMasterPlaylist=function(t,e,r,a){var u=this.hls,l=t.data,d=cn(t,r),c=Fr.parseMasterPlaylist(l,d);if(c.playlistParsingError){this.handleManifestParsingError(t,r,c.playlistParsingError,a,e);return}var p=c.contentSteering,y=c.levels,A=c.sessionData,T=c.sessionKeys,b=c.startTimeOffset,L=c.variableList;this.variableList=L;var R=Fr.parseMasterPlaylistMedia(l,d,c),C=R.AUDIO,I=C===void 0?[]:C,k=R.SUBTITLES,O=R["CLOSED-CAPTIONS"];if(I.length){var V=I.some(function(N){return!N.url});!V&&y[0].audioCodec&&!y[0].attrs.AUDIO&&(this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),I.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new rt({}),bitrate:0,url:""}))}u.trigger(x.MANIFEST_LOADED,{levels:y,audioTracks:I,subtitles:k,captions:O,contentSteering:p,url:d,stats:e,networkDetails:a,sessionData:A,sessionKeys:T,startTimeOffset:b,variableList:L})},s.handleTrackOrLevelPlaylist=function(t,e,r,a,u){var l=this.hls,d=r.id,c=r.level,p=r.type,y=cn(t,r),A=w(c)?c:w(d)?d:0,T=Ps(r),b=Fr.parseLevelPlaylist(t.data,y,A,T,0,this.variableList);if(p===ie.MANIFEST){var L={attrs:new rt({}),bitrate:0,details:b,name:"",url:y};b.requestScheduled=e.loading.start+Ga(b,0),l.trigger(x.MANIFEST_LOADED,{levels:[L],audioTracks:[],url:y,stats:e,networkDetails:a,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}e.parsing.end=performance.now(),r.levelDetails=b,this.handlePlaylistLoaded(b,t,e,r,a,u)},s.handleManifestParsingError=function(t,e,r,a,u){this.hls.trigger(x.ERROR,{type:Y.NETWORK_ERROR,details:M.MANIFEST_PARSING_ERROR,fatal:e.type===ie.MANIFEST,url:t.url,err:r,error:r,reason:r.message,response:t,context:e,networkDetails:a,stats:u})},s.handleNetworkError=function(t,e,r,a,u){r===void 0&&(r=!1);var l="A network "+(r?"timeout":"error"+(a?" (status "+a.code+")":""))+" occurred while loading "+t.type;t.type===ie.LEVEL?l+=": "+t.level+" id: "+t.id:(t.type===ie.AUDIO_TRACK||t.type===ie.SUBTITLE_TRACK)&&(l+=" id: "+t.id+' group-id: "'+t.groupId+'"');var d=new Error(l);this.hls.logger.warn("[playlist-loader]: "+l);var c=M.UNKNOWN,p=!1,y=this.getInternalLoader(t);switch(t.type){case ie.MANIFEST:c=r?M.MANIFEST_LOAD_TIMEOUT:M.MANIFEST_LOAD_ERROR,p=!0;break;case ie.LEVEL:c=r?M.LEVEL_LOAD_TIMEOUT:M.LEVEL_LOAD_ERROR,p=!1;break;case ie.AUDIO_TRACK:c=r?M.AUDIO_TRACK_LOAD_TIMEOUT:M.AUDIO_TRACK_LOAD_ERROR,p=!1;break;case ie.SUBTITLE_TRACK:c=r?M.SUBTITLE_TRACK_LOAD_TIMEOUT:M.SUBTITLE_LOAD_ERROR,p=!1;break}y&&this.resetInternalLoader(t.type);var A={type:Y.NETWORK_ERROR,details:c,fatal:p,url:t.url,loader:y,context:t,error:d,networkDetails:e,stats:u};if(a){var T=e?.url||t.url;A.response=H({url:T,data:void 0},a)}this.hls.trigger(x.ERROR,A)},s.handlePlaylistLoaded=function(t,e,r,a,u,l){var d=this.hls,c=a.type,p=a.level,y=a.id,A=a.groupId,T=a.deliveryDirectives,b=cn(e,a),L=Ps(a),R=typeof a.level=="number"&&L===ae.MAIN?p:void 0;if(!t.fragments.length){var C=t.playlistParsingError=new Error("No Segments found in Playlist");d.trigger(x.ERROR,{type:Y.NETWORK_ERROR,details:M.LEVEL_EMPTY_ERROR,fatal:!1,url:b,error:C,reason:C.message,response:e,context:a,level:R,parent:L,networkDetails:u,stats:r});return}t.targetduration||(t.playlistParsingError=new Error("Missing Target Duration"));var I=t.playlistParsingError;if(I){if(this.hls.logger.warn(I),!d.config.ignorePlaylistParsingErrors){d.trigger(x.ERROR,{type:Y.NETWORK_ERROR,details:M.LEVEL_PARSING_ERROR,fatal:!1,url:b,error:I,reason:I.message,response:e,context:a,level:R,parent:L,networkDetails:u,stats:r});return}t.playlistParsingError=null}switch(t.live&&l&&(l.getCacheAge&&(t.ageHeader=l.getCacheAge()||0),(!l.getCacheAge||isNaN(t.ageHeader))&&(t.ageHeader=0)),c){case ie.MANIFEST:case ie.LEVEL:d.trigger(x.LEVEL_LOADED,{details:t,levelInfo:a.levelOrTrack||d.levels[0],level:R||0,id:y||0,stats:r,networkDetails:u,deliveryDirectives:T,withoutMultiVariant:c===ie.MANIFEST});break;case ie.AUDIO_TRACK:d.trigger(x.AUDIO_TRACK_LOADED,{details:t,track:a.levelOrTrack,id:y||0,groupId:A||"",stats:r,networkDetails:u,deliveryDirectives:T});break;case ie.SUBTITLE_TRACK:d.trigger(x.SUBTITLE_TRACK_LOADED,{details:t,track:a.levelOrTrack,id:y||0,groupId:A||"",stats:r,networkDetails:u,deliveryDirectives:T});break}},n}(),sh={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]};function oh(n,s){return{supported:!1,configurations:s,decodingInfoResults:[{supported:!1,smooth:!1,powerEfficient:!1}],error:n}}var Os={};function uh(n,s,i){var t=n.videoCodec,e=n.audioCodec;if(!t&&!e||!i)return Promise.resolve(sh);var r=[];if(t){var a={width:n.width,height:n.height,bitrate:Math.ceil(Math.max(n.bitrate*.9,n.averageBitrate)),framerate:n.frameRate||30},u=n.videoRange;u!=="SDR"&&(a.transferFunction=u.toLowerCase());var l=t.split(","),d=navigator.userAgent;if(l.some(function(c){return Gi(c)})&&na())return Promise.resolve(oh(new Error("Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent sting: ("+d+")"),r));r.push.apply(r,l.map(function(c){return{type:"media-source",video:H(H({},a),{},{contentType:Or(Su(c),"video")})}}))}return e&&n.audioGroups&&n.audioGroups.forEach(function(c){var p;c&&((p=s.groups[c])==null||p.tracks.forEach(function(y){if(y.groupId===c){var A=y.channels||"",T=parseFloat(A);w(T)&&T>2&&r.push.apply(r,e.split(",").map(function(b){return{type:"media-source",audio:{contentType:Or(b,"audio"),channels:""+T}}}))}}))}),Promise.all(r.map(function(c){var p=lh(c);return Os[p]||(Os[p]=i.decodingInfo(c))})).then(function(c){return{supported:!c.some(function(p){return!p.supported}),configurations:r,decodingInfoResults:c}}).catch(function(c){return{supported:!1,configurations:r,decodingInfoResults:[],error:c}})}function lh(n){var s=n.audio,i=n.video,t=i||s;if(t){var e=la(t.contentType);if(i)return"r"+i.height+"x"+i.width+"f"+Math.ceil(i.framerate)+(i.transferFunction||"sd")+"_"+e+"_"+Math.ceil(i.bitrate/1e5);if(s)return"c"+s.channels+(s.spatialRendering?"s":"n")+"_"+e}return""}var Ms=function(){function n(i){i===void 0&&(i={}),this.config=void 0,this.userConfig=void 0,this.logger=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new Me,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioStreamController=void 0,this.subtititleStreamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.interstitialsController=void 0,this.gapController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this._url=null,this._sessionId=void 0,this.triggeringException=void 0,this.started=!1;var t=this.logger=Je(i.debug||!1,"Hls instance",i.assetPlayerId),e=this.config=_f(n.DefaultConfig,i,t);this.userConfig=i,e.progressive&&Sf(e,t);var r=e.abrController,a=e.bufferController,u=e.capLevelController,l=e.errorController,d=e.fpsController,c=new l(this),p=this.abrController=new r(this),y=new Tf(this),A=e.interstitialsController,T=A?this.interstitialsController=new A(this,n):null,b=this.bufferController=new a(this,y),L=this.capLevelController=new u(this),R=new d(this),C=new ah(this),I=e.contentSteeringController,k=I?new I(this):null,O=this.levelController=new jf(this,k),V=new Hf(this),N=new nh(this.config),B=this.streamController=new ih(this,y,N),X=this.gapController=new Of(this,y);L.setStreamController(B),R.setStreamController(B);var z=[C,O,B];T&&z.splice(1,0,T),k&&z.splice(1,0,k),this.networkControllers=z;var K=[p,b,X,L,R,V,y];this.audioTrackController=this.createController(e.audioTrackController,z);var j=e.audioStreamController;j&&z.push(this.audioStreamController=new j(this,y,N)),this.subtitleTrackController=this.createController(e.subtitleTrackController,z);var J=e.subtitleStreamController;J&&z.push(this.subtititleStreamController=new J(this,y,N)),this.createController(e.timelineController,K),N.emeController=this.emeController=this.createController(e.emeController,K),this.cmcdController=this.createController(e.cmcdController,K),this.latencyController=this.createController(Kf,K),this.coreComponents=K,z.push(c);var le=c.onErrorOut;typeof le=="function"&&this.on(x.ERROR,le,c),this.on(x.MANIFEST_LOADED,C.onManifestLoaded,C)}n.isMSESupported=function(){return ws()},n.isSupported=function(){return eh()},n.getMediaSource=function(){return nr()};var s=n.prototype;return s.createController=function(t,e){if(t){var r=new t(this);return e&&e.push(r),r}return null},s.on=function(t,e,r){r===void 0&&(r=this),this._emitter.on(t,e,r)},s.once=function(t,e,r){r===void 0&&(r=this),this._emitter.once(t,e,r)},s.removeAllListeners=function(t){this._emitter.removeAllListeners(t)},s.off=function(t,e,r,a){r===void 0&&(r=this),this._emitter.off(t,e,r,a)},s.listeners=function(t){return this._emitter.listeners(t)},s.emit=function(t,e,r){return this._emitter.emit(t,e,r)},s.trigger=function(t,e){if(this.config.debug)return this.emit(t,t,e);try{return this.emit(t,t,e)}catch(a){if(this.logger.error("An internal error happened while handling event "+t+'. Error message: "'+a.message+'". Here is a stacktrace:',a),!this.triggeringException){this.triggeringException=!0;var r=t===x.ERROR;this.trigger(x.ERROR,{type:Y.OTHER_ERROR,details:M.INTERNAL_EXCEPTION,fatal:r,event:t,error:a}),this.triggeringException=!1}}return!1},s.listenerCount=function(t){return this._emitter.listenerCount(t)},s.destroy=function(){this.logger.log("destroy"),this.trigger(x.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this._url=null,this.networkControllers.forEach(function(e){return e.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(e){return e.destroy()}),this.coreComponents.length=0;var t=this.config;t.xhrSetup=t.fetchSetup=void 0,this.userConfig=null},s.attachMedia=function(t){if(!t||"media"in t&&!t.media){var e=new Error("attachMedia failed: invalid argument ("+t+")");this.trigger(x.ERROR,{type:Y.OTHER_ERROR,details:M.ATTACH_MEDIA_ERROR,fatal:!0,error:e});return}this.logger.log("attachMedia"),this._media&&(this.logger.warn("media must be detached before attaching"),this.detachMedia());var r="media"in t,a=r?t.media:t,u=r?t:{media:a};this._media=a,this.trigger(x.MEDIA_ATTACHING,u)},s.detachMedia=function(){this.logger.log("detachMedia"),this.trigger(x.MEDIA_DETACHING,{}),this._media=null},s.transferMedia=function(){this._media=null;var t=this.bufferController.transferMedia();return this.trigger(x.MEDIA_DETACHING,{transferMedia:t}),t},s.loadSource=function(t){this.stopLoad();var e=this.media,r=this._url,a=this._url=Ze.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log("loadSource:"+a),e&&r&&(r!==a||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(e)),this.trigger(x.MANIFEST_LOADING,{url:t})},s.startLoad=function(t,e){t===void 0&&(t=-1),this.logger.log("startLoad("+(t+(e?", <skip seek to start>":""))+")"),this.started=!0,this.resumeBuffering();for(var r=0;r<this.networkControllers.length&&(this.networkControllers[r].startLoad(t,e),!(!this.started||!this.networkControllers));r++);},s.stopLoad=function(){this.logger.log("stopLoad"),this.started=!1;for(var t=0;t<this.networkControllers.length&&(this.networkControllers[t].stopLoad(),!(this.started||!this.networkControllers));t++);},s.resumeBuffering=function(){this.bufferingEnabled||(this.logger.log("resume buffering"),this.networkControllers.forEach(function(t){t.resumeBuffering&&t.resumeBuffering()}))},s.pauseBuffering=function(){this.bufferingEnabled&&(this.logger.log("pause buffering"),this.networkControllers.forEach(function(t){t.pauseBuffering&&t.pauseBuffering()}))},s.swapAudioCodec=function(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},s.recoverMediaError=function(){this.logger.log("recoverMediaError");var t=this._media,e=t?.currentTime;this.detachMedia(),t&&(this.attachMedia(t),e&&this.startLoad(e))},s.removeLevel=function(t){this.levelController.removeLevel(t)},s.setAudioOption=function(t){var e;return((e=this.audioTrackController)==null?void 0:e.setAudioOption(t))||null},s.setSubtitleOption=function(t){var e;return((e=this.subtitleTrackController)==null?void 0:e.setSubtitleOption(t))||null},s.getMediaDecodingInfo=function(t,e){e===void 0&&(e=this.allAudioTracks);var r=va(e);return uh(t,r,navigator.mediaCapabilities)},f(n,[{key:"url",get:function(){return this._url}},{key:"hasEnoughToStart",get:function(){return this.streamController.hasEnoughToStart}},{key:"startPosition",get:function(){return this.streamController.startPositionValue}},{key:"loadingEnabled",get:function(){return this.started}},{key:"bufferingEnabled",get:function(){return this.streamController.bufferingEnabled}},{key:"inFlightFragments",get:function(){var t,e=(t={},t[ae.MAIN]=this.streamController.inFlightFrag,t);return this.audioStreamController&&(e[ae.AUDIO]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(e[ae.SUBTITLE]=this.subtititleStreamController.inFlightFrag),e}},{key:"sessionId",get:function(){var t=this._sessionId;return t||(t=this._sessionId=oe()),t}},{key:"levels",get:function(){var t=this.levelController.levels;return t||[]}},{key:"latestLevelDetails",get:function(){return this.streamController.getLevelDetails()||null}},{key:"loadLevelObj",get:function(){return this.levelController.loadLevelObj}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(t){this.logger.log("set currentLevel:"+t),this.levelController.manualLevel=t,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(t){this.logger.log("set nextLevel:"+t),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(t){this.logger.log("set loadLevel:"+t),this.levelController.manualLevel=t}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(t){this.levelController.nextLoadLevel=t}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(t){this.logger.log("set firstLevel:"+t),this.levelController.firstLevel=t}},{key:"startLevel",get:function(){var t=this.levelController.startLevel;return t===-1&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:t},set:function(t){this.logger.log("set startLevel:"+t),t!==-1&&(t=Math.max(t,this.minAutoLevel)),this.levelController.startLevel=t}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(t){var e=!!t;e!==this.config.capLevelToPlayerSize&&(e?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=e)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(t){this._autoLevelCapping!==t&&(this.logger.log("set autoLevelCapping:"+t),this._autoLevelCapping=t,this.levelController.checkMaxAutoUpdated())}},{key:"bandwidthEstimate",get:function(){var t=this.abrController.bwEstimator;return t?t.getEstimate():NaN},set:function(t){this.abrController.resetEstimator(t)}},{key:"abrEwmaDefaultEstimate",get:function(){var t=this.abrController.bwEstimator;return t?t.defaultEstimate:NaN}},{key:"ttfbEstimate",get:function(){var t=this.abrController.bwEstimator;return t?t.getEstimateTTFB():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(t){Tu(t)&&this._maxHdcpLevel!==t&&(this._maxHdcpLevel=t,this.levelController.checkMaxAutoUpdated())}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var t=this.levels,e=this.config.minAutoBitrate;if(!t)return 0;for(var r=t.length,a=0;a<r;a++)if(t[a].maxBitrate>=e)return a;return 0}},{key:"maxAutoLevel",get:function(){var t=this.levels,e=this.autoLevelCapping,r=this.maxHdcpLevel,a;if(e===-1&&t!=null&&t.length?a=t.length-1:a=e,r)for(var u=a;u--;){var l=t[u].attrs["HDCP-LEVEL"];if(l&&l<=r)return u}return a}},{key:"firstAutoLevel",get:function(){return this.abrController.firstAutoLevel}},{key:"nextAutoLevel",get:function(){return this.abrController.nextAutoLevel},set:function(t){this.abrController.nextAutoLevel=t}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"maxBufferLength",get:function(){return this.streamController.maxBufferLength}},{key:"allAudioTracks",get:function(){var t=this.audioTrackController;return t?t.allAudioTracks:[]}},{key:"audioTracks",get:function(){var t=this.audioTrackController;return t?t.audioTracks:[]}},{key:"audioTrack",get:function(){var t=this.audioTrackController;return t?t.audioTrack:-1},set:function(t){var e=this.audioTrackController;e&&(e.audioTrack=t)}},{key:"allSubtitleTracks",get:function(){var t=this.subtitleTrackController;return t?t.allSubtitleTracks:[]}},{key:"subtitleTracks",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTrack:-1},set:function(t){var e=this.subtitleTrackController;e&&(e.subtitleTrack=t)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var t=this.subtitleTrackController;return t?t.subtitleDisplay:!1},set:function(t){var e=this.subtitleTrackController;e&&(e.subtitleDisplay=t)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(t){this.config.lowLatencyMode=t}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency},set:function(t){this.latencyController.targetLatency=t}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}},{key:"pathways",get:function(){return this.levelController.pathways}},{key:"pathwayPriority",get:function(){return this.levelController.pathwayPriority},set:function(t){this.levelController.pathwayPriority=t}},{key:"bufferedToEnd",get:function(){var t;return!!((t=this.bufferController)!=null&&t.bufferedToEnd)}},{key:"interstitialsManager",get:function(){var t;return((t=this.interstitialsController)==null?void 0:t.interstitialsManager)||null}}],[{key:"version",get:function(){return Gr}},{key:"Events",get:function(){return x}},{key:"MetadataSchema",get:function(){return Lt}},{key:"ErrorTypes",get:function(){return Y}},{key:"ErrorDetails",get:function(){return M}},{key:"DefaultConfig",get:function(){return n.defaultConfig?n.defaultConfig:yf},set:function(t){n.defaultConfig=t}}])}();return Ms.defaultConfig=void 0,Ms})})(!1)});var ld={};xh(ld,{Flv:()=>Dr,Hls:()=>Wn.default});module.exports=Rh(ld);function js(v,m){var o=Object.keys(v);if(Object.getOwnPropertySymbols){var h=Object.getOwnPropertySymbols(v);m&&(h=h.filter(function(f){return Object.getOwnPropertyDescriptor(v,f).enumerable})),o.push.apply(o,h)}return o}function It(v){for(var m=1;m<arguments.length;m++){var o=arguments[m]!=null?arguments[m]:{};m%2?js(Object(o),!0).forEach(function(h){me(v,h,o[h])}):Object.getOwnPropertyDescriptors?Object.defineProperties(v,Object.getOwnPropertyDescriptors(o)):js(Object(o)).forEach(function(h){Object.defineProperty(v,h,Object.getOwnPropertyDescriptor(o,h))})}return v}function ke(){ke=function(){return v};var v={},m=Object.prototype,o=m.hasOwnProperty,h=Object.defineProperty||function(w,U,G){w[U]=G.value},f=typeof Symbol=="function"?Symbol:{},g=f.iterator||"@@iterator",E=f.asyncIterator||"@@asyncIterator",_=f.toStringTag||"@@toStringTag";function S(w,U,G){return Object.defineProperty(w,U,{value:G,enumerable:!0,configurable:!0,writable:!0}),w[U]}try{S({},"")}catch{S=function(U,G,Y){return U[G]=Y}}function D(w,U,G,Y){var M=U&&U.prototype instanceof H?U:H,x=Object.create(M.prototype),ie=new ye(Y||[]);return h(x,"_invoke",{value:se(w,G,ie)}),x}function P(w,U,G){try{return{type:"normal",arg:w.call(U,G)}}catch(Y){return{type:"throw",arg:Y}}}v.wrap=D;var F={};function H(){}function W(){}function $(){}var ee={};S(ee,g,function(){return this});var Z=Object.getPrototypeOf,oe=Z&&Z(Z(Ie([])));oe&&oe!==m&&o.call(oe,g)&&(ee=oe);var ue=$.prototype=H.prototype=Object.create(ee);function Se(w){["next","throw","return"].forEach(function(U){S(w,U,function(G){return this._invoke(U,G)})})}function he(w,U){function G(M,x,ie,ae){var Re=P(w[M],w,x);if(Re.type!=="throw"){var Ue=Re.arg,je=Ue.value;return je&&typeof je=="object"&&o.call(je,"__await")?U.resolve(je.__await).then(function(xe){G("next",xe,ie,ae)},function(xe){G("throw",xe,ie,ae)}):U.resolve(je).then(function(xe){Ue.value=xe,ie(Ue)},function(xe){return G("throw",xe,ie,ae)})}ae(Re.arg)}var Y;h(this,"_invoke",{value:function(M,x){function ie(){return new U(function(ae,Re){G(M,x,ae,Re)})}return Y=Y?Y.then(ie,ie):ie()}})}function se(w,U,G){var Y="suspendedStart";return function(M,x){if(Y==="executing")throw new Error("Generator is already running");if(Y==="completed"){if(M==="throw")throw x;return Ze()}for(G.method=M,G.arg=x;;){var ie=G.delegate;if(ie){var ae=ce(ie,G);if(ae){if(ae===F)continue;return ae}}if(G.method==="next")G.sent=G._sent=G.arg;else if(G.method==="throw"){if(Y==="suspendedStart")throw Y="completed",G.arg;G.dispatchException(G.arg)}else G.method==="return"&&G.abrupt("return",G.arg);Y="executing";var Re=P(w,U,G);if(Re.type==="normal"){if(Y=G.done?"completed":"suspendedYield",Re.arg===F)continue;return{value:Re.arg,done:G.done}}Re.type==="throw"&&(Y="completed",G.method="throw",G.arg=Re.arg)}}}function ce(w,U){var G=U.method,Y=w.iterator[G];if(Y===void 0)return U.delegate=null,G==="throw"&&w.iterator.return&&(U.method="return",U.arg=void 0,ce(w,U),U.method==="throw")||G!=="return"&&(U.method="throw",U.arg=new TypeError("The iterator does not provide a '"+G+"' method")),F;var M=P(Y,w.iterator,U.arg);if(M.type==="throw")return U.method="throw",U.arg=M.arg,U.delegate=null,F;var x=M.arg;return x?x.done?(U[w.resultName]=x.value,U.next=w.nextLoc,U.method!=="return"&&(U.method="next",U.arg=void 0),U.delegate=null,F):x:(U.method="throw",U.arg=new TypeError("iterator result is not an object"),U.delegate=null,F)}function Me(w){var U={tryLoc:w[0]};1 in w&&(U.catchLoc=w[1]),2 in w&&(U.finallyLoc=w[2],U.afterLoc=w[3]),this.tryEntries.push(U)}function We(w){var U=w.completion||{};U.type="normal",delete U.arg,w.completion=U}function ye(w){this.tryEntries=[{tryLoc:"root"}],w.forEach(Me,this),this.reset(!0)}function Ie(w){if(w){var U=w[g];if(U)return U.call(w);if(typeof w.next=="function")return w;if(!isNaN(w.length)){var G=-1,Y=function M(){for(;++G<w.length;)if(o.call(w,G))return M.value=w[G],M.done=!1,M;return M.value=void 0,M.done=!0,M};return Y.next=Y}}return{next:Ze}}function Ze(){return{value:void 0,done:!0}}return W.prototype=$,h(ue,"constructor",{value:$,configurable:!0}),h($,"constructor",{value:W,configurable:!0}),W.displayName=S($,_,"GeneratorFunction"),v.isGeneratorFunction=function(w){var U=typeof w=="function"&&w.constructor;return!!U&&(U===W||(U.displayName||U.name)==="GeneratorFunction")},v.mark=function(w){return Object.setPrototypeOf?Object.setPrototypeOf(w,$):(w.__proto__=$,S(w,_,"GeneratorFunction")),w.prototype=Object.create(ue),w},v.awrap=function(w){return{__await:w}},Se(he.prototype),S(he.prototype,E,function(){return this}),v.AsyncIterator=he,v.async=function(w,U,G,Y,M){M===void 0&&(M=Promise);var x=new he(D(w,U,G,Y),M);return v.isGeneratorFunction(U)?x:x.next().then(function(ie){return ie.done?ie.value:x.next()})},Se(ue),S(ue,_,"Generator"),S(ue,g,function(){return this}),S(ue,"toString",function(){return"[object Generator]"}),v.keys=function(w){var U=Object(w),G=[];for(var Y in U)G.push(Y);return G.reverse(),function M(){for(;G.length;){var x=G.pop();if(x in U)return M.value=x,M.done=!1,M}return M.done=!0,M}},v.values=Ie,ye.prototype={constructor:ye,reset:function(w){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(We),!w)for(var U in this)U.charAt(0)==="t"&&o.call(this,U)&&!isNaN(+U.slice(1))&&(this[U]=void 0)},stop:function(){this.done=!0;var w=this.tryEntries[0].completion;if(w.type==="throw")throw w.arg;return this.rval},dispatchException:function(w){if(this.done)throw w;var U=this;function G(Re,Ue){return x.type="throw",x.arg=w,U.next=Re,Ue&&(U.method="next",U.arg=void 0),!!Ue}for(var Y=this.tryEntries.length-1;Y>=0;--Y){var M=this.tryEntries[Y],x=M.completion;if(M.tryLoc==="root")return G("end");if(M.tryLoc<=this.prev){var ie=o.call(M,"catchLoc"),ae=o.call(M,"finallyLoc");if(ie&&ae){if(this.prev<M.catchLoc)return G(M.catchLoc,!0);if(this.prev<M.finallyLoc)return G(M.finallyLoc)}else if(ie){if(this.prev<M.catchLoc)return G(M.catchLoc,!0)}else{if(!ae)throw new Error("try statement without catch or finally");if(this.prev<M.finallyLoc)return G(M.finallyLoc)}}}},abrupt:function(w,U){for(var G=this.tryEntries.length-1;G>=0;--G){var Y=this.tryEntries[G];if(Y.tryLoc<=this.prev&&o.call(Y,"finallyLoc")&&this.prev<Y.finallyLoc){var M=Y;break}}M&&(w==="break"||w==="continue")&&M.tryLoc<=U&&U<=M.finallyLoc&&(M=null);var x=M?M.completion:{};return x.type=w,x.arg=U,M?(this.method="next",this.next=M.finallyLoc,F):this.complete(x)},complete:function(w,U){if(w.type==="throw")throw w.arg;return w.type==="break"||w.type==="continue"?this.next=w.arg:w.type==="return"?(this.rval=this.arg=w.arg,this.method="return",this.next="end"):w.type==="normal"&&U&&(this.next=U),F},finish:function(w){for(var U=this.tryEntries.length-1;U>=0;--U){var G=this.tryEntries[U];if(G.finallyLoc===w)return this.complete(G.completion,G.afterLoc),We(G),F}},catch:function(w){for(var U=this.tryEntries.length-1;U>=0;--U){var G=this.tryEntries[U];if(G.tryLoc===w){var Y=G.completion;if(Y.type==="throw"){var M=Y.arg;We(G)}return M}}throw new Error("illegal catch attempt")},delegateYield:function(w,U,G){return this.delegate={iterator:Ie(w),resultName:U,nextLoc:G},this.method==="next"&&(this.arg=void 0),F}},v}function Ys(v,m,o,h,f,g,E){try{var _=v[g](E),S=_.value}catch(D){o(D);return}_.done?m(S):Promise.resolve(S).then(h,f)}function at(v){return function(){var m=this,o=arguments;return new Promise(function(h,f){var g=v.apply(m,o);function E(S){Ys(g,h,f,E,_,"next",S)}function _(S){Ys(g,h,f,E,_,"throw",S)}E(void 0)})}}function br(v,m){if(!(v instanceof m))throw new TypeError("Cannot call a class as a function")}function zs(v,m){for(var o=0;o<m.length;o++){var h=m[o];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(v,Xs(h.key),h)}}function Lr(v,m,o){return m&&zs(v.prototype,m),o&&zs(v,o),Object.defineProperty(v,"prototype",{writable:!1}),v}function me(v,m,o){return m=Xs(m),m in v?Object.defineProperty(v,m,{value:o,enumerable:!0,configurable:!0,writable:!0}):v[m]=o,v}function qs(v,m){if(typeof m!="function"&&m!==null)throw new TypeError("Super expression must either be null or a function");v.prototype=Object.create(m&&m.prototype,{constructor:{value:v,writable:!0,configurable:!0}}),Object.defineProperty(v,"prototype",{writable:!1}),m&&yn(v,m)}function bi(v){return bi=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(o){return o.__proto__||Object.getPrototypeOf(o)},bi(v)}function yn(v,m){return yn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(h,f){return h.__proto__=f,h},yn(v,m)}function Ch(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Pe(v){if(v===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v}function kh(v,m){if(m&&(typeof m=="object"||typeof m=="function"))return m;if(m!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Pe(v)}function $s(v){var m=Ch();return function(){var h=bi(v),f;if(m){var g=bi(this).constructor;f=Reflect.construct(h,arguments,g)}else f=h.apply(this,arguments);return kh(this,f)}}function Dh(v,m){if(typeof v!="object"||v===null)return v;var o=v[Symbol.toPrimitive];if(o!==void 0){var h=o.call(v,m||"default");if(typeof h!="object")return h;throw new TypeError("@@toPrimitive must return a primitive value.")}return(m==="string"?String:Number)(v)}function Xs(v){var m=Dh(v,"string");return typeof m=="symbol"?m:String(m)}function Zs(v,m){var o=Object.keys(v);if(Object.getOwnPropertySymbols){var h=Object.getOwnPropertySymbols(v);m&&(h=h.filter(function(f){return Object.getOwnPropertyDescriptor(v,f).enumerable})),o.push.apply(o,h)}return o}function ur(v){for(var m=1;m<arguments.length;m++){var o=arguments[m]!=null?arguments[m]:{};m%2?Zs(Object(o),!0).forEach(function(h){q(v,h,o[h])}):Object.getOwnPropertyDescriptors?Object.defineProperties(v,Object.getOwnPropertyDescriptors(o)):Zs(Object(o)).forEach(function(h){Object.defineProperty(v,h,Object.getOwnPropertyDescriptor(o,h))})}return v}function Xe(){Xe=function(){return v};var v={},m=Object.prototype,o=m.hasOwnProperty,h=Object.defineProperty||function(w,U,G){w[U]=G.value},f=typeof Symbol=="function"?Symbol:{},g=f.iterator||"@@iterator",E=f.asyncIterator||"@@asyncIterator",_=f.toStringTag||"@@toStringTag";function S(w,U,G){return Object.defineProperty(w,U,{value:G,enumerable:!0,configurable:!0,writable:!0}),w[U]}try{S({},"")}catch{S=function(U,G,Y){return U[G]=Y}}function D(w,U,G,Y){var M=U&&U.prototype instanceof H?U:H,x=Object.create(M.prototype),ie=new ye(Y||[]);return h(x,"_invoke",{value:se(w,G,ie)}),x}function P(w,U,G){try{return{type:"normal",arg:w.call(U,G)}}catch(Y){return{type:"throw",arg:Y}}}v.wrap=D;var F={};function H(){}function W(){}function $(){}var ee={};S(ee,g,function(){return this});var Z=Object.getPrototypeOf,oe=Z&&Z(Z(Ie([])));oe&&oe!==m&&o.call(oe,g)&&(ee=oe);var ue=$.prototype=H.prototype=Object.create(ee);function Se(w){["next","throw","return"].forEach(function(U){S(w,U,function(G){return this._invoke(U,G)})})}function he(w,U){function G(M,x,ie,ae){var Re=P(w[M],w,x);if(Re.type!=="throw"){var Ue=Re.arg,je=Ue.value;return je&&typeof je=="object"&&o.call(je,"__await")?U.resolve(je.__await).then(function(xe){G("next",xe,ie,ae)},function(xe){G("throw",xe,ie,ae)}):U.resolve(je).then(function(xe){Ue.value=xe,ie(Ue)},function(xe){return G("throw",xe,ie,ae)})}ae(Re.arg)}var Y;h(this,"_invoke",{value:function(M,x){function ie(){return new U(function(ae,Re){G(M,x,ae,Re)})}return Y=Y?Y.then(ie,ie):ie()}})}function se(w,U,G){var Y="suspendedStart";return function(M,x){if(Y==="executing")throw new Error("Generator is already running");if(Y==="completed"){if(M==="throw")throw x;return Ze()}for(G.method=M,G.arg=x;;){var ie=G.delegate;if(ie){var ae=ce(ie,G);if(ae){if(ae===F)continue;return ae}}if(G.method==="next")G.sent=G._sent=G.arg;else if(G.method==="throw"){if(Y==="suspendedStart")throw Y="completed",G.arg;G.dispatchException(G.arg)}else G.method==="return"&&G.abrupt("return",G.arg);Y="executing";var Re=P(w,U,G);if(Re.type==="normal"){if(Y=G.done?"completed":"suspendedYield",Re.arg===F)continue;return{value:Re.arg,done:G.done}}Re.type==="throw"&&(Y="completed",G.method="throw",G.arg=Re.arg)}}}function ce(w,U){var G=U.method,Y=w.iterator[G];if(Y===void 0)return U.delegate=null,G==="throw"&&w.iterator.return&&(U.method="return",U.arg=void 0,ce(w,U),U.method==="throw")||G!=="return"&&(U.method="throw",U.arg=new TypeError("The iterator does not provide a '"+G+"' method")),F;var M=P(Y,w.iterator,U.arg);if(M.type==="throw")return U.method="throw",U.arg=M.arg,U.delegate=null,F;var x=M.arg;return x?x.done?(U[w.resultName]=x.value,U.next=w.nextLoc,U.method!=="return"&&(U.method="next",U.arg=void 0),U.delegate=null,F):x:(U.method="throw",U.arg=new TypeError("iterator result is not an object"),U.delegate=null,F)}function Me(w){var U={tryLoc:w[0]};1 in w&&(U.catchLoc=w[1]),2 in w&&(U.finallyLoc=w[2],U.afterLoc=w[3]),this.tryEntries.push(U)}function We(w){var U=w.completion||{};U.type="normal",delete U.arg,w.completion=U}function ye(w){this.tryEntries=[{tryLoc:"root"}],w.forEach(Me,this),this.reset(!0)}function Ie(w){if(w){var U=w[g];if(U)return U.call(w);if(typeof w.next=="function")return w;if(!isNaN(w.length)){var G=-1,Y=function M(){for(;++G<w.length;)if(o.call(w,G))return M.value=w[G],M.done=!1,M;return M.value=void 0,M.done=!0,M};return Y.next=Y}}return{next:Ze}}function Ze(){return{value:void 0,done:!0}}return W.prototype=$,h(ue,"constructor",{value:$,configurable:!0}),h($,"constructor",{value:W,configurable:!0}),W.displayName=S($,_,"GeneratorFunction"),v.isGeneratorFunction=function(w){var U=typeof w=="function"&&w.constructor;return!!U&&(U===W||(U.displayName||U.name)==="GeneratorFunction")},v.mark=function(w){return Object.setPrototypeOf?Object.setPrototypeOf(w,$):(w.__proto__=$,S(w,_,"GeneratorFunction")),w.prototype=Object.create(ue),w},v.awrap=function(w){return{__await:w}},Se(he.prototype),S(he.prototype,E,function(){return this}),v.AsyncIterator=he,v.async=function(w,U,G,Y,M){M===void 0&&(M=Promise);var x=new he(D(w,U,G,Y),M);return v.isGeneratorFunction(U)?x:x.next().then(function(ie){return ie.done?ie.value:x.next()})},Se(ue),S(ue,_,"Generator"),S(ue,g,function(){return this}),S(ue,"toString",function(){return"[object Generator]"}),v.keys=function(w){var U=Object(w),G=[];for(var Y in U)G.push(Y);return G.reverse(),function M(){for(;G.length;){var x=G.pop();if(x in U)return M.value=x,M.done=!1,M}return M.done=!0,M}},v.values=Ie,ye.prototype={constructor:ye,reset:function(w){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(We),!w)for(var U in this)U.charAt(0)==="t"&&o.call(this,U)&&!isNaN(+U.slice(1))&&(this[U]=void 0)},stop:function(){this.done=!0;var w=this.tryEntries[0].completion;if(w.type==="throw")throw w.arg;return this.rval},dispatchException:function(w){if(this.done)throw w;var U=this;function G(Re,Ue){return x.type="throw",x.arg=w,U.next=Re,Ue&&(U.method="next",U.arg=void 0),!!Ue}for(var Y=this.tryEntries.length-1;Y>=0;--Y){var M=this.tryEntries[Y],x=M.completion;if(M.tryLoc==="root")return G("end");if(M.tryLoc<=this.prev){var ie=o.call(M,"catchLoc"),ae=o.call(M,"finallyLoc");if(ie&&ae){if(this.prev<M.catchLoc)return G(M.catchLoc,!0);if(this.prev<M.finallyLoc)return G(M.finallyLoc)}else if(ie){if(this.prev<M.catchLoc)return G(M.catchLoc,!0)}else{if(!ae)throw new Error("try statement without catch or finally");if(this.prev<M.finallyLoc)return G(M.finallyLoc)}}}},abrupt:function(w,U){for(var G=this.tryEntries.length-1;G>=0;--G){var Y=this.tryEntries[G];if(Y.tryLoc<=this.prev&&o.call(Y,"finallyLoc")&&this.prev<Y.finallyLoc){var M=Y;break}}M&&(w==="break"||w==="continue")&&M.tryLoc<=U&&U<=M.finallyLoc&&(M=null);var x=M?M.completion:{};return x.type=w,x.arg=U,M?(this.method="next",this.next=M.finallyLoc,F):this.complete(x)},complete:function(w,U){if(w.type==="throw")throw w.arg;return w.type==="break"||w.type==="continue"?this.next=w.arg:w.type==="return"?(this.rval=this.arg=w.arg,this.method="return",this.next="end"):w.type==="normal"&&U&&(this.next=U),F},finish:function(w){for(var U=this.tryEntries.length-1;U>=0;--U){var G=this.tryEntries[U];if(G.finallyLoc===w)return this.complete(G.completion,G.afterLoc),We(G),F}},catch:function(w){for(var U=this.tryEntries.length-1;U>=0;--U){var G=this.tryEntries[U];if(G.tryLoc===w){var Y=G.completion;if(Y.type==="throw"){var M=Y.arg;We(G)}return M}}throw new Error("illegal catch attempt")},delegateYield:function(w,U,G){return this.delegate={iterator:Ie(w),resultName:U,nextLoc:G},this.method==="next"&&(this.arg=void 0),F}},v}function $t(v){"@babel/helpers - typeof";return $t=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(m){return typeof m}:function(m){return m&&typeof Symbol=="function"&&m.constructor===Symbol&&m!==Symbol.prototype?"symbol":typeof m},$t(v)}function Js(v,m,o,h,f,g,E){try{var _=v[g](E),S=_.value}catch(D){o(D);return}_.done?m(S):Promise.resolve(S).then(h,f)}function Rt(v){return function(){var m=this,o=arguments;return new Promise(function(h,f){var g=v.apply(m,o);function E(S){Js(g,h,f,E,_,"next",S)}function _(S){Js(g,h,f,E,_,"throw",S)}E(void 0)})}}function He(v,m){if(!(v instanceof m))throw new TypeError("Cannot call a class as a function")}function eo(v,m){for(var o=0;o<m.length;o++){var h=m[o];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(v,ao(h.key),h)}}function Ke(v,m,o){return m&&eo(v.prototype,m),o&&eo(v,o),Object.defineProperty(v,"prototype",{writable:!1}),v}function q(v,m,o){return m=ao(m),m in v?Object.defineProperty(v,m,{value:o,enumerable:!0,configurable:!0,writable:!0}):v[m]=o,v}function Ut(v,m){if(typeof m!="function"&&m!==null)throw new TypeError("Super expression must either be null or a function");v.prototype=Object.create(m&&m.prototype,{constructor:{value:v,writable:!0,configurable:!0}}),Object.defineProperty(v,"prototype",{writable:!1}),m&&Wr(v,m)}function or(v){return or=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(o){return o.__proto__||Object.getPrototypeOf(o)},or(v)}function Wr(v,m){return Wr=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(h,f){return h.__proto__=f,h},Wr(v,m)}function ro(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function xi(v,m,o){return ro()?xi=Reflect.construct.bind():xi=function(f,g,E){var _=[null];_.push.apply(_,g);var S=Function.bind.apply(f,_),D=new S;return E&&Wr(D,E.prototype),D},xi.apply(null,arguments)}function Ph(v){return Function.toString.call(v).indexOf("[native code]")!==-1}function cr(v){var m=typeof Map=="function"?new Map:void 0;return cr=function(h){if(h===null||!Ph(h))return h;if(typeof h!="function")throw new TypeError("Super expression must either be null or a function");if(typeof m<"u"){if(m.has(h))return m.get(h);m.set(h,f)}function f(){return xi(h,arguments,or(this).constructor)}return f.prototype=Object.create(h.prototype,{constructor:{value:f,enumerable:!1,writable:!0,configurable:!0}}),Wr(f,h)},cr(v)}function Oh(v,m){if(v==null)return{};var o={},h=Object.keys(v),f,g;for(g=0;g<h.length;g++)f=h[g],!(m.indexOf(f)>=0)&&(o[f]=v[f]);return o}function io(v,m){if(v==null)return{};var o=Oh(v,m),h,f;if(Object.getOwnPropertySymbols){var g=Object.getOwnPropertySymbols(v);for(f=0;f<g.length;f++)h=g[f],!(m.indexOf(h)>=0)&&Object.prototype.propertyIsEnumerable.call(v,h)&&(o[h]=v[h])}return o}function pe(v){if(v===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v}function Mh(v,m){if(m&&(typeof m=="object"||typeof m=="function"))return m;if(m!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return pe(v)}function Bt(v){var m=ro();return function(){var h=or(v),f;if(m){var g=or(this).constructor;f=Reflect.construct(h,arguments,g)}else f=h.apply(this,arguments);return Mh(this,f)}}function Fh(v,m){for(;!Object.prototype.hasOwnProperty.call(v,m)&&(v=or(v),v!==null););return v}function Kr(){return typeof Reflect<"u"&&Reflect.get?Kr=Reflect.get.bind():Kr=function(m,o,h){var f=Fh(m,o);if(f){var g=Object.getOwnPropertyDescriptor(f,o);return g.get?g.get.call(arguments.length<3?m:h):g.value}},Kr.apply(this,arguments)}function Nh(v,m){if(v){if(typeof v=="string")return to(v,m);var o=Object.prototype.toString.call(v).slice(8,-1);if(o==="Object"&&v.constructor&&(o=v.constructor.name),o==="Map"||o==="Set")return Array.from(v);if(o==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o))return to(v,m)}}function to(v,m){(m==null||m>v.length)&&(m=v.length);for(var o=0,h=new Array(m);o<m;o++)h[o]=v[o];return h}function no(v,m){var o=typeof Symbol<"u"&&v[Symbol.iterator]||v["@@iterator"];if(!o){if(Array.isArray(v)||(o=Nh(v))||m&&v&&typeof v.length=="number"){o&&(v=o);var h=0,f=function(){};return{s:f,n:function(){return h>=v.length?{done:!0}:{done:!1,value:v[h++]}},e:function(S){throw S},f}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
29
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var g=!0,E=!1,_;return{s:function(){o=o.call(v)},n:function(){var S=o.next();return g=S.done,S},e:function(S){E=!0,_=S},f:function(){try{!g&&o.return!=null&&o.return()}finally{if(E)throw _}}}}function Uh(v,m){if(typeof v!="object"||v===null)return v;var o=v[Symbol.toPrimitive];if(o!==void 0){var h=o.call(v,m||"default");if(typeof h!="object")return h;throw new TypeError("@@toPrimitive must return a primitive value.")}return(m==="string"?String:Number)(v)}function ao(v){var m=Uh(v,"string");return typeof m=="symbol"?m:String(m)}var tt=function(){function v(){He(this,v)}return Ke(v,null,[{key:"start",value:function(o){return!o||!o.length||o.length===1&&o.end(0)-o.start(0)<1e-6||o.length===1&&o.start(0)<0?0:o.start(0)}},{key:"end",value:function(o){return!o||!o.length||o.length===1&&o.end(0)-o.start(0)<1e-6?0:o.end(o.length-1)}},{key:"get",value:function(o){if(o)try{return o.buffered}catch{}}},{key:"buffers",value:function(o,h){if(!o||!o.length)return[];for(var f=[],g=0,E=o.length;g<E;g++){var _=f.length;if(!_||!h)f.push([o.start(g),o.end(g)]);else{var S=f[_-1],D=S[1],P=o.start(g);if(P-D<=h){var F=o.end(g);F>D&&(S[1]=F)}else f.push([o.start(g),o.end(g)])}}return f}},{key:"totalLength",value:function(o){return!o||!o.length?0:o.reduce(function(h,f){return h+=f[1]-f[0]},0)}},{key:"info",value:function(o){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,f=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;if(!o||!o.length)return{start:0,end:0,buffers:[]};for(var g=0,E=0,_=0,S=0,D=0,P=0,F=0,H=v.buffers(o,f),W=0,$=H.length;W<$;W++){var ee=H[W];if(h+f>=ee[0]&&h<=ee[1])g=ee[0],E=ee[1],_=W;else if(h+f<ee[0]){S=ee[0],D=ee[1];break}else h+f>ee[1]&&(P=ee[0],F=ee[1])}return{start:g,end:E,index:_,buffers:H,nextStart:S,nextEnd:D,prevStart:P,prevEnd:F,currentTime:h,behind:h-g,remaining:E?E-h:0,length:v.totalLength&&v.totalLength(H)}}},{key:"isBuffered",value:function(o,h){if(o){var f=v.get(o);if(f!=null&&f.length){for(var g=0;g<f.length;g++)if(h>=f.start(g)&&h<=f.end(g))return!0}}return!1}}]),v}();var so=typeof window<"u";var bt,De={MANIFEST:"manifest",NETWORK:"network",NETWORK_TIMEOUT:"network_timeout",NETWORK_FORBIDDEN:"network_forbidden",NETWORK_NOTFOUND:"network_notfound",NETWROK_RANGE_NOT_SATISFIABLE:"network_range_not_satisfiable",DEMUX:"demux",REMUX:"remux",MEDIA:"media",DRM:"drm",OTHER:"other",RUNTIME:"runtime",SUB_TYPES:{FLV:"FLV",HLS:"HLS",MP4:"MP4",FMP4:"FMP4",MSE_ADD_SB:"MSE_ADD_SB",MSE_APPEND_BUFFER:"MSE_APPEND_BUFFER",MSE_OTHER:"MSE_OTHER",MSE_FULL:"MSE_FULL",MSE_CHANGE_TYPE:"MSE_CHANGE_TYPE",OPTION:"OPTION",DASH:"DASH",LICENSE:"LICENSE",CUSTOM_LICENSE:"CUSTOM_LICENSE",MSE_HIJACK:"MSE_HIJACK",EME_HIJACK:"EME_HIJACK",SIDX:"SIDX",NO_CANPLAY_ERROR:"NO_CANPLAY_ERROR",BUFFERBREAK_ERROR:"BUFFERBREAK_ERROR",WAITING_TIMEOUT_ERROR:"WAITING_TIMEOUT_ERROR",MEDIA_ERR_ABORTED:"MEDIA_ERR_ABORTED",MEDIA_ERR_NETWORK:"MEDIA_ERR_NETWORK",MEDIA_ERR_DECODE:"MEDIA_ERR_DECODE",MEDIA_ERR_SRC_NOT_SUPPORTED:"MEDIA_ERR_SRC_NOT_SUPPORTED",MEDIA_ERR_CODEC_NOT_SUPPORTED:"MEDIA_ERR_CODEC_NOT_SUPPORTED",MEDIA_ERR_URL_EMPTY:"MEDIA_ERR_URL_EMPTY"}},Ri=(bt={},q(bt,De.MANIFEST,{HLS:1100,DASH:1200}),q(bt,De.NETWORK,2100),q(bt,De.NETWORK_TIMEOUT,2101),q(bt,De.NETWORK_FORBIDDEN,2103),q(bt,De.NETWORK_NOTFOUND,2104),q(bt,De.NETWROK_RANGE_NOT_SATISFIABLE,2116),q(bt,De.DEMUX,{FLV:3100,HLS:3200,MP4:3300,FMP4:3400,SIDX:3410}),q(bt,De.REMUX,{FMP4:4100,MP4:4200}),q(bt,De.MEDIA,{MEDIA_ERR_ABORTED:5101,MEDIA_ERR_NETWORK:5102,MEDIA_ERR_DECODE:5103,MEDIA_ERR_SRC_NOT_SUPPORTED:5104,MEDIA_ERR_CODEC_NOT_SUPPORTED:5105,MEDIA_ERR_URL_EMPTY:5106,MSE_ADD_SB:5200,MSE_APPEND_BUFFER:5201,MSE_OTHER:5202,MSE_FULL:5203,MSE_HIJACK:5204,MSE_CHANGE_TYPE:5205,EME_HIJACK:5301}),q(bt,De.DRM,{LICENSE:7100,CUSTOM_LICENSE:7200}),q(bt,De.OTHER,8e3),q(bt,De.RUNTIME,{NO_CANPLAY_ERROR:9001,BUFFERBREAK_ERROR:9002,WAITING_TIMEOUT_ERROR:9003}),bt),pt=function(v){Ut(o,v);var m=Bt(o);function o(h,f,g,E,_){var S;return He(this,o),S=m.call(this,_||g?.message),S.errorType=h===De.NETWORK_TIMEOUT?De.NETWORK:h,S.originError=g,S.ext=E,S.errorCode=Ri[h][f]||Ri[h],S.errorMessage=S.message,S.errorCode||(S.errorType=De.OTHER,S.errorCode=Ri[S.errorType]),S}return Ke(o,null,[{key:"create",value:function(f,g,E,_,S){return f instanceof o?f:(f instanceof Error&&(E=f,f=""),f||(f=De.OTHER),new o(f,g,E,_,S))}},{key:"network",value:function(f){var g;return new o(f!=null&&f.isTimeout?De.NETWORK_TIMEOUT:De.NETWORK,null,f instanceof Error?f:null,{url:f?.url,response:f?.response,httpCode:f==null||(g=f.response)===null||g===void 0?void 0:g.status})}}]),o}(cr(Error));var Yr={DEBUG:1,LOG:2,WARN:3,ERROR:4},Bh=200*1024,Gh=["Boolean","Number","String","Undefined","Null","Date","Object"],Ct=function(){function v(m,o){He(this,v),this.name=m||"",this._prefix="[".concat(this.name,"]"),this.logCacheLevel=o?.logCacheLevel||3,this.logMaxSize=o?.logMaxSize||Bh,this.logSize=0,this.logTextArray=[]}return Ke(v,[{key:"debug",value:function(){for(var o,h=arguments.length,f=new Array(h),g=0;g<h;g++)f[g]=arguments[g];this.logCache.apply(this,[Yr.DEBUG].concat(f)),!v.disabled&&(o=console).debug.apply(o,["[".concat(jr(),"]"),this._prefix].concat(f))}},{key:"log",value:function(){for(var o,h=arguments.length,f=new Array(h),g=0;g<h;g++)f[g]=arguments[g];this.logCache.apply(this,[Yr.LOG].concat(f)),!v.disabled&&(o=console).log.apply(o,["[".concat(jr(),"]"),this._prefix].concat(f))}},{key:"warn",value:function(){for(var o,h=arguments.length,f=new Array(h),g=0;g<h;g++)f[g]=arguments[g];this.logCache.apply(this,[Yr.WARN].concat(f)),!v.disabled&&(o=console).warn.apply(o,["[".concat(jr(),"]"),this._prefix].concat(f))}},{key:"error",value:function(){for(var o,h=arguments.length,f=new Array(h),g=0;g<h;g++)f[g]=arguments[g];this.logCache.apply(this,[Yr.ERROR].concat(f)),!v.disabled&&(o=console).error.apply(o,["[".concat(jr(),"]"),this._prefix].concat(f))}},{key:"logCache",value:function(o){if(!(o<this.logCacheLevel)){var h="";try{for(var f=arguments.length,g=new Array(f>1?f-1:0),E=1;E<f;E++)g[E-1]=arguments[E];var _=g.map(function(D){return oo(D)});h="[".concat(jr(),"]")+this._prefix+JSON.stringify(_)}catch{return}if(o>=this.logCacheLevel&&(this.logSize+=h.length,this.logTextArray.push(h)),this.logSize>this.logMaxSize){var S=this.logTextArray.shift();this.logSize-=S.length}}}},{key:"getLogCache",value:function(){var o=this.logTextArray.join(`
30
+ `);return this.reset(),o}},{key:"reset",value:function(){this.logTextArray=[],this.logSize=0}},{key:"table",value:function(){var o;v.disabled||(console.group(this._prefix),(o=console).table.apply(o,arguments),console.groupEnd())}},{key:"setLogLevel",value:function(o){this.logCacheLevel=o}}],[{key:"enable",value:function(){v.disabled=!1}},{key:"disable",value:function(){v.disabled=!0}}]),v}();q(Ct,"disabled",!0);function jr(){return new Date().toLocaleString()}function Vh(v){if($t(v)!=="object")return v;var m=Object.prototype.toString.call(v).slice(8,-1);switch(m){case"Array":case"Uint8Array":case"ArrayBuffer":return m+"["+v.length+"]";case"Object":return"{}";default:return m}}function oo(v,m,o){o||(o=1),m||(m=2);var h={};if(!v||$t(v)!=="object")return v;var f=Object.prototype.toString.call(v).slice(8,-1);if(!Gh.includes(f))return f;if(!(o>m)){for(var g in v)Object.prototype.hasOwnProperty.call(v,g)&&(o===m?h[g]=Vh(v[g]):$t(v[g])==="object"?h[g]=oo(v[g],m,o+1):h[g]=v[g]);return h}}function lr(){var v,m,o=new Promise(function(h,f){v=h,m=f});return o.used=!1,o.resolve=function(){return o.used=!0,v.apply(void 0,arguments)},o.reject=function(){return o.used=!0,m.apply(void 0,arguments)},o}function vr(){try{return parseInt(performance.now(),10)}catch{return new Date().getTime()}}var uo={stringify:function(m){try{return JSON.stringify(m)}catch{return""}},parse:function(m){try{return JSON.parse(m)}catch{return}}};function lo(){var v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;try{return so?v&&typeof ManagedMediaSource<"u"?ManagedMediaSource:window.MediaSource:null}catch{}}function _n(v){return/ManagedMediaSource/gi.test(Object.prototype.toString.call(v))}function Hh(v){var m=[];if(v instanceof TimeRanges)for(var o=0;o<v.length;o++)m.push({start:v.start(o),end:v.end(o)});return m}var Ci={APPEND:"appendBuffer",REMOVE:"removeBuffer",UPDATE_DURATION:"updateDuration"};var fr=function(){function v(m,o){var h=this;He(this,v),q(this,"media",null),q(this,"mediaSource",null),q(this,"_openPromise",lr()),q(this,"_queue",Object.create(null)),q(this,"_sourceBuffer",Object.create(null)),q(this,"_mseFullFlag",{}),q(this,"_st",0),q(this,"_opst",0),q(this,"_logger",null),q(this,"_config",null),q(this,"_url",null),q(this,"_onStartStreaming",function(){h._logger.debug("startstreaming")}),q(this,"_onEndStreaming",function(){h._logger.debug("endstreaming")}),q(this,"_onSBUpdateEnd",function(f){var g=h._queue[f];if(g){var E=g[0];if(E?.opName!==Ci.UPDATE_DURATION&&g.shift(),E){var _,S,D=vr()-h._opst;h._logger.debug("UpdateEnd(".concat(f,"/").concat(E.opName,")"),uo.stringify(Hh((_=h._sourceBuffer[f])===null||_===void 0?void 0:_.buffered)),D,E.context),E.promise.resolve({name:E.opName,context:E.context,costtime:D});var P=(S=E.context)===null||S===void 0?void 0:S.callback;P&&typeof P=="function"&&P(E.context),h._startQueue(f)}}}),q(this,"_onSBUpdateError",function(f,g){var E=h._queue[f];if(E){var _=E[0];_&&(h._logger.error("UpdateError",f,_.opName,_.context),_.promise.reject(new pt(De.MEDIA,De.SUB_TYPES.MSE_APPEND_BUFFER,g)))}}),this._config=Object.assign(v.getDefaultConfig(),o),m&&this.bindMedia(m),this._logger=new Ct("MSE"),this._config.openLog&&Ct.enable()}return Ke(v,[{key:"isOpened",get:function(){var o;return((o=this.mediaSource)===null||o===void 0?void 0:o.readyState)==="open"}},{key:"hasOpTasks",get:function(){var o=this,h=!1;return Object.keys(this._queue).forEach(function(f){var g=o._queue[f];Array.isArray(g)&&(h||(h=g.length>0))}),h}},{key:"url",get:function(){return this._url}},{key:"duration",get:function(){var o;return((o=this.mediaSource)===null||o===void 0?void 0:o.duration)||-1}},{key:"isEnded",get:function(){return this.mediaSource?this.mediaSource.readyState==="ended":!1}},{key:"streaming",get:function(){return _n(this.mediaSource)?this.mediaSource.streaming:!0}},{key:"isFull",value:function(o){return o?this._mseFullFlag[o]:this._mseFullFlag[v.VIDEO]}},{key:"updateDuration",value:function(o){var h=this,f=this.mediaSource&&this.mediaSource.duration>o;if(this.mediaSource&&this.mediaSource.duration>o){var g=0;if(Object.keys(this._sourceBuffer).forEach(function(E){try{g=Math.max(h.bufferEnd(E)||0,g)}catch{}}),o<g)return Promise.resolve()}return this._enqueueBlockingOp(function(){if(h.isEnded){h._logger.debug("setDuration but ended");return}h.mediaSource&&(h.mediaSource.duration=o,h._logger.debug("setDuration",o))},Ci.UPDATE_DURATION,{isReduceDuration:f})}},{key:"open",value:function(){var o=this;if(this._openPromise.used&&!this.isOpened&&this.mediaSource){var h=this.mediaSource,f=function g(){var E=vr()-o._st;o._logger.debug("sourceopen",E),h.removeEventListener("sourceopen",g),o._openPromise.resolve({costtime:E})};h.addEventListener("sourceopen",f),this._openPromise=lr()}return this._openPromise}},{key:"bindMedia",value:function(){var m=Rt(Xe().mark(function h(f){var g=this,E,_,S,D;return Xe().wrap(function(F){for(;;)switch(F.prev=F.next){case 0:if(!(this.mediaSource||this.media)){F.next=3;break}return F.next=3,this.unbindMedia();case 3:if(E=lo(this._config.preferMMS),!(!f||!E)){F.next=6;break}throw new Error("Param media or MediaSource does not exist");case 6:return this.media=f,_=this.mediaSource=new E,S=_n(_),this._st=vr(),D=function H(){var W=vr()-g._st;g._logger.debug("sourceopen"),_.removeEventListener("sourceopen",H),URL.revokeObjectURL(f.src),g._openPromise.resolve({costtime:W})},_.addEventListener("sourceopen",D),S&&(_.addEventListener("startstreaming",this._onStartStreaming),_.addEventListener("endstreaming",this._onEndStreaming)),this._url=URL.createObjectURL(_),f.src=this._url,f.disableRemotePlayback=S,F.abrupt("return",this._openPromise);case 17:case"end":return F.stop()}},h,this)}));function o(h){return m.apply(this,arguments)}return o}()},{key:"unbindMedia",value:function(){var m=Rt(Xe().mark(function h(){var f=this,g,E,_;return Xe().wrap(function(D){for(;;)switch(D.prev=D.next){case 0:if(this._openPromise.used||this._openPromise.resolve(),g=this.mediaSource,g){if(Object.keys(this._queue).forEach(function(P){var F=f._queue[P];F&&F.forEach(function(H){var W,$;return(W=H.promise)===null||W===void 0||($=W.resolve)===null||$===void 0?void 0:$.call(W)})}),E=!!this.media&&this.media.readyState>=1,_=g.readyState==="open",E&&_)try{g.endOfStream()}catch{}Object.keys(this._sourceBuffer).forEach(function(P){try{g.removeSourceBuffer(f._sourceBuffer[P])}catch{}}),_n(g)&&(g.removeEventListener("startstreaming",this._onStartStreaming),g.removeEventListener("endstreaming",this._onEndStreaming))}if(this.media){this.media.disableRemotePlayback=!1,this.media.removeAttribute("src");try{this.media.load()}catch{}this.media=null}this.mediaSource=null,this._openPromise=lr(),this._queue=Object.create(null),this._sourceBuffer=Object.create(null);case 8:case"end":return D.stop()}},h,this)}));function o(){return m.apply(this,arguments)}return o}()},{key:"createSource",value:function(o,h){if(!(this._sourceBuffer[o]||!this.mediaSource)){var f;try{f=this._sourceBuffer[o]=this.mediaSource.addSourceBuffer(h)}catch(g){throw new pt(De.MEDIA,De.SUB_TYPES.MSE_ADD_SB,g)}f.mimeType=h,f.addEventListener("updateend",this._onSBUpdateEnd.bind(this,o)),f.addEventListener("error",this._onSBUpdateError.bind(this,o))}}},{key:"changeType",value:function(o,h){var f=this,g=this._sourceBuffer[o];return!this.mediaSource||!g||g.mimeType===h?Promise.resolve():typeof g.changeType!="function"?Promise.reject(new pt(De.MEDIA,De.SUB_TYPES.MSE_CHANGE_TYPE,new Error("changeType is not a function"))):this._enqueueOp(o,function(){try{g.changeType(h)}catch(E){throw new pt(De.MEDIA,De.SUB_TYPES.MSE_CHANGE_TYPE,E)}g.mimeType=h,f._onSBUpdateEnd(o)},"changeType",{mimeType:h})}},{key:"createOrChangeSource",value:function(o,h){return this.createSource(o,h),this.changeType(o,h)}},{key:"append",value:function(o,h,f){var g=this;return!h||!h.byteLength||!this._sourceBuffer[o]?Promise.resolve():this._enqueueOp(o,function(){var E;!g.mediaSource||g.media.error||(g._logger.debug("MSE APPEND START",f),g._opst=vr(),(E=g._sourceBuffer[o])===null||E===void 0||E.appendBuffer(h))},Ci.APPEND,f)}},{key:"remove",value:function(o,h,f,g){var E=this,_=!1;return this._mseFullFlag[o]&&(_=!0),this._enqueueOp(o,function(){if(!(!E.mediaSource||E.media.error)){var S=E._sourceBuffer[o];if(h>=f||!S){E._onSBUpdateEnd(o);return}E._opst=vr(),E._logger.debug("MSE REMOVE START",o,h,f,g),S.remove(h,f)}},Ci.REMOVE,g,_)}},{key:"clearBuffer",value:function(o,h){var f=this,g;return Object.keys(this._sourceBuffer).forEach(function(E){g=f.remove(E,o,h)}),g||Promise.resolve()}},{key:"clearAllBuffer",value:function(){var o=this,h;return Object.keys(this._sourceBuffer).forEach(function(f){var g=o._sourceBuffer[f];h=o.remove(f,0,tt.end(tt.get(g)))}),h}},{key:"clearOpQueues",value:function(o,h){var f;this._logger.debug("MSE clearOpQueue START");var g=this._queue[o];if(h&&g){this._queue[o]=[];return}if(!(!g||!g[o]||g.length<5)){var E=[];g.forEach(function(_){_.context&&_.context.isinit&&E.push(_)}),this._queue[o]=g.slice(0,2),E.length>0&&(f=this._queue[o]).push.apply(f,E)}}},{key:"endOfStream",value:function(o){var h=this;return!this.mediaSource||this.mediaSource.readyState!=="open"?Promise.resolve():this._enqueueBlockingOp(function(){var f=h.mediaSource;!f||f.readyState!=="open"||(h._logger.debug("MSE endOfStream START"),o?f.endOfStream(o):f.endOfStream())},"endOfStream")}},{key:"setLiveSeekableRange",value:function(o,h){var f=this.mediaSource;o<0||h<o||!(f!=null&&f.setLiveSeekableRange)||f.readyState!=="open"||f.setLiveSeekableRange(o,h)}},{key:"getSourceBuffer",value:function(o){return this._sourceBuffer[o]}},{key:"buffered",value:function(o){return tt.get(this._sourceBuffer[o])}},{key:"bufferStart",value:function(o){return tt.start(this.buffered(o))}},{key:"bufferEnd",value:function(o){return tt.end(this.buffered(o))}},{key:"_enqueueOp",value:function(o,h,f,g,E){var _=this;if(!this.mediaSource)return Promise.resolve();var S=this._queue[o]=this._queue[o]||[],D={exec:h,promise:lr(),opName:f,context:g};return E?(S.splice(0,0,D),this._mseFullFlag[o]=!1,this._startQueue(o)):S.push(D),this.isOpened||this.isEnded?S.length===1&&this._startQueue(o):this._openPromise.then(function(){S.length===1&&_._startQueue(o)}),D.promise}},{key:"_enqueueBlockingOp",value:function(){var m=Rt(Xe().mark(function h(f,g,E){var _=this,S,D;return Xe().wrap(function(F){for(;;)switch(F.prev=F.next){case 0:if(this.mediaSource){F.next=2;break}return F.abrupt("return",Promise.resolve());case 2:if(S=Object.keys(this._sourceBuffer),S.length){F.next=5;break}return F.abrupt("return",f());case 5:return D=[],S.forEach(function(H){var W=_._queue[H],$=lr();D.push($),W.push({exec:function(){$.resolve()},promise:$,opName:g,context:E}),W.length===1&&_._startQueue(H)}),F.abrupt("return",Promise.all(D).then(function(){try{return f()}finally{S.forEach(function(H){var W=_._queue[H],$=_._sourceBuffer[H];W?.shift(),(!$||!$.updating)&&_._startQueue(H)})}}));case 8:case"end":return F.stop()}},h,this)}));function o(h,f,g){return m.apply(this,arguments)}return o}()},{key:"_startQueue",value:function(o){var h=this._queue[o];if(h){var f=h[0];if(f&&!this._mseFullFlag[o])try{f.exec()}catch(_){if(_&&_.message&&_.message.indexOf("SourceBuffer is full")>=0){var g;this._mseFullFlag[o]=!0,f.context&&$t(f.context)==="object"&&(f.context.isFull=!0),this._logger.error("[MSE error], context,",f.context," ,name,",f.opName,",err,SourceBuffer is full"),f==null||(g=f.promise)===null||g===void 0||g.reject(new pt(De.MEDIA,De.SUB_TYPES.MSE_FULL,_))}else{var E;this._logger.error(_),f==null||(E=f.promise)===null||E===void 0||E.reject(_.constructor===pt?_:new pt(De.MEDIA,De.SUB_TYPES.MSE_OTHER,_)),h.shift(),this._startQueue(o)}}}}},{key:"setTimeoffset",value:function(o,h,f){var g=this;return this._enqueueOp(o,function(){h<0&&(h+=.001),g._sourceBuffer[o].timestampOffset=h,g._onSBUpdateEnd(o)},"setTimeoffset",f)}},{key:"abort",value:function(o,h){var f=this;return this.isOpened?this._enqueueOp(o,function(){f._sourceBuffer[o].abort(),f._onSBUpdateEnd(o)},"abort",h):Promise.resolve()}}],[{key:"isSupported",value:function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:'video/mp4; codecs="avc1.42E01E,mp4a.40.2"',h=lo();if(!h)return!1;try{return h.isTypeSupported(o)}catch(f){return this._logger.error(o,f),!1}}},{key:"isMMSOnly",value:function(){return typeof ManagedMediaSource<"u"&&typeof MediaSource>"u"}},{key:"getDefaultConfig",value:function(){return{openLog:!1,preferMMS:!1}}}]),v}();q(fr,"VIDEO","video");q(fr,"AUDIO","audio");var Gt={FETCH:"fetch",XHR:"xhr"},hr={ARRAY_BUFFER:"arraybuffer",TEXT:"text",JSON:"json"};var wt=function(v){Ut(o,v);var m=Bt(o);function o(h,f,g,E){var _;return He(this,o),_=m.call(this,E),q(pe(_),"retryCount",0),q(pe(_),"isTimeout",!1),q(pe(_),"loaderType",Gt.FETCH),q(pe(_),"startTime",0),q(pe(_),"endTime",0),q(pe(_),"options",{}),_.url=h,_.request=f,_.response=g,_}return Ke(o)}(cr(Error));var fo=Object.prototype.toString;function ho(v){return v!==null&&$t(v)==="object"}function Sn(v){if(fo.call(v)!=="[object Object]")return!1;var m=Object.getPrototypeOf(v);return m===null||m===Object.prototype}function co(v){return fo.call(v)==="[object Date]"}function ki(v){if(!(!v||v[0]===null||v[0]===void 0||v[0]===0&&(v[1]===null||v[1]===void 0))){var m="bytes="+v[0]+"-";return v[1]&&(m+=v[1]),m}}function vo(v){return encodeURIComponent(v).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Di(v,m){if(v){if(!m)return v;var o,h=Object.keys(m).map(function(g){if(o=m[g],o!=null)return Array.isArray(o)?g=g+"[]":o=[o],o.map(function(E){return co(E)?E=E.toISOString():ho(E)&&(E=JSON.stringify(E)),"".concat(vo(g),"=").concat(vo(E))}).join("&")}).filter(Boolean).join("&");if(h){var f=v.indexOf("#");f!==-1&&(v=v.slice(0,f)),v+=(v.indexOf("?")===-1?"?":"&")+h}return v}}function zr(v,m,o,h,f,g,E,_,S,D,P){f=f!=null?parseFloat(f):null,h=parseInt(h||"0",10),Number.isNaN(h)&&(h=0);var F={range:S,vid:D,index:_,contentLength:h,age:f,startTime:g,firstByteTime:E,endTime:Date.now(),priOptions:P};return{data:v,done:m,options:F,response:o}}function qr(v,m){return Math.round(v*8*1e3/m/1024)}var _e={ERROR:"error",TTFB:"core.ttfb",LOAD_START:"core.loadstart",LOAD_RESPONSE_HEADERS:"core.loadresponseheaders",LOAD_COMPLETE:"core.loadcomplete",LOAD_RETRY:"core.loadretry",SOURCEBUFFER_CREATED:"core.sourcebuffercreated",MEDIASOURCE_OPENED:"core.mediasourceopened",ANALYZE_DURATION_EXCEEDED:"core.analyzedurationexceeded",APPEND_BUFFER:"core.appendbuffer",REMOVE_BUFFER:"core.removebuffer",BUFFEREOS:"core.buffereos",KEYFRAME:"core.keyframe",CHASEFRAME:"core.chaseframe",METADATA_PARSED:"core.metadataparsed",SEI:"core.sei",SEI_IN_TIME:"core.seiintime",FLV_SCRIPT_DATA:"core.flvscriptdata",LOWDECODE:"core.lowdecode",SWITCH_URL_SUCCESS:"core.switchurlsuccess",SWITCH_URL_FAILED:"core.switchurlfailed",SPEED:"core.speed",HLS_MANIFEST_LOADED:"core.hlsmanifestloaded",HLS_LEVEL_LOADED:"core.hlslevelloaded",DEMUXED_TRACK:"core.demuxedtrack",STREAM_EXCEPTION:"core.streamexception",LARGE_AV_FIRST_FRAME_GAP_DETECT:"LARGE_AV_FIRST_FRAME_GAP_DETECT",LARGE_VIDEO_DTS_GAP_DETECT:"LARGE_VIDEO_DTS_GAP_DETECT",LARGE_AUDIO_DTS_GAP_DETECT:"LARGE_AUDIO_DTS_GAP_DETECT",AUDIO_GAP_DETECT:"AUDIO_GAP_DETECT",AUDIO_OVERLAP_DETECT:"AUDIO_OVERLAP_DETECT",MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT:"MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT",REAL_TIME_SPEED:"real_time_speed"};var go=Ar(xr()),po=2*1024*1024,$r=function(v){Ut(o,v);var m=Bt(o);function o(){var h;return He(this,o),h=m.call(this),q(pe(h),"_abortController",null),q(pe(h),"_timeoutTimer",null),q(pe(h),"_reader",null),q(pe(h),"_response",null),q(pe(h),"_aborted",!1),q(pe(h),"_index",-1),q(pe(h),"_range",null),q(pe(h),"_receivedLength",0),q(pe(h),"_running",!1),q(pe(h),"_logger",null),q(pe(h),"_vid",""),q(pe(h),"_onProcessMinLen",0),q(pe(h),"_onCancel",null),q(pe(h),"_priOptions",null),h}return Ke(o,[{key:"load",value:function(f){var g,E=this,_=f.url,S=f.vid,D=f.timeout,P=f.responseType,F=f.onProgress,H=f.index,W=f.onTimeout,$=f.onCancel,ee=f.range,Z=f.transformResponse,oe=f.request,ue=f.params,Se=f.logger,he=f.method,se=f.headers,ce=f.body,Me=f.mode,We=f.credentials,ye=f.cache,Ie=f.redirect,Ze=f.referrer,w=f.referrerPolicy,U=f.onProcessMinLen,G=f.priOptions;this._logger=Se,this._aborted=!1,this._onProcessMinLen=U,this._onCancel=$,this._abortController=typeof AbortController<"u"&&new AbortController,this._running=!0,this._index=H,this._range=ee||[0,0],this._vid=S||_,this._priOptions=G||{};var Y={method:he,headers:se,body:ce,mode:Me,credentials:We,cache:ye,redirect:Ie,referrer:Ze,referrerPolicy:w,signal:(g=this._abortController)===null||g===void 0?void 0:g.signal},M=!1;clearTimeout(this._timeoutTimer),_=Di(_,ue);var x=ki(ee);x&&(oe?se=oe.headers:se=Y.headers=Y.headers||(Headers?new Headers:{}),Headers&&se instanceof Headers?se.append("Range",x):se.Range=x),D&&(this._timeoutTimer=setTimeout(function(){if(M=!0,E.cancel(),W){var ae=new wt(_,Y,null,"timeout");ae.isTimeout=!0,W(ae,{index:E._index,range:E._range,vid:E._vid,priOptions:E._priOptions})}},D));var ie=Date.now();return this._logger.debug("[fetch load start], index,",H,",range,",ee),new Promise(function(ae,Re){fetch(oe||_,oe?void 0:Y).then(function(){var Ue=Rt(Xe().mark(function je(xe){var Ir,Dt,wr,Pr;return Xe().wrap(function(Je){for(;;)switch(Je.prev=Je.next){case 0:if(clearTimeout(E._timeoutTimer),E._response=xe,!(E._aborted||!E._running)){Je.next=4;break}return Je.abrupt("return");case 4:if(Z&&(xe=Z(xe,_)||xe),xe.ok){Je.next=7;break}throw new wt(_,Y,xe,"bad network response");case 7:if(Ir=Date.now(),P!==hr.TEXT){Je.next=15;break}return Je.next=11,xe.text();case 11:Dt=Je.sent,E._running=!1,Je.next=37;break;case 15:if(P!==hr.JSON){Je.next=22;break}return Je.next=18,xe.json();case 18:Dt=Je.sent,E._running=!1,Je.next=37;break;case 22:if(!F){Je.next=29;break}return E.resolve=ae,E.reject=Re,E._loadChunk(xe,F,ie,Ir),Je.abrupt("return");case 29:return Je.next=31,xe.arrayBuffer();case 31:Dt=Je.sent,Dt=new Uint8Array(Dt),E._running=!1,wr=Date.now()-ie,Pr=qr(Dt.byteLength,wr),E.emit(_e.REAL_TIME_SPEED,{speed:Pr,len:Dt.byteLength,time:wr,vid:E._vid,index:E._index,range:E._range,priOptions:E._priOptions});case 37:E._logger.debug("[fetch load end], index,",H,",range,",ee),ae(zr(Dt,!0,xe,xe.headers.get("Content-Length"),xe.headers.get("age"),ie,Ir,H,ee,E._vid,E._priOptions));case 39:case"end":return Je.stop()}},je)}));return function(je){return Ue.apply(this,arguments)}}()).catch(function(Ue){var je;clearTimeout(E._timeoutTimer),E._running=!1,!(E._aborted&&!M)&&(Ue=Ue instanceof wt?Ue:new wt(_,Y,null,(je=Ue)===null||je===void 0?void 0:je.message),Ue.startTime=ie,Ue.endTime=Date.now(),Ue.isTimeout=M,Ue.options={index:E._index,range:E._range,vid:E._vid,priOptions:E._priOptions},Re(Ue))})})}},{key:"cancel",value:function(){var h=Rt(Xe().mark(function g(){return Xe().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:if(!this._aborted){_.next=2;break}return _.abrupt("return");case 2:if(this._aborted=!0,this._running=!1,!this._response){_.next=14;break}if(_.prev=5,!this._reader){_.next=9;break}return _.next=9,this._reader.cancel();case 9:_.next=13;break;case 11:_.prev=11,_.t0=_.catch(5);case 13:this._response=this._reader=null;case 14:if(this._abortController){try{this._abortController.abort()}catch{}this._abortController=null}this._onCancel&&this._onCancel({index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions});case 16:case"end":return _.stop()}},g,this,[[5,11]])}));function f(){return h.apply(this,arguments)}return f}()},{key:"_loadChunk",value:function(f,g,E,_){var S=this;if(!f.body||!f.body.getReader){this._running=!1;var D=new wt(f.url,"",f,"onProgress of bad response.body.getReader");D.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this.reject(D);return}this._onProcessMinLen>0&&(this._cache=new Uint8Array(po),this._writeIdx=0);var P=this._reader=f.body.getReader(),F,H,W,$=function(){var ee=Rt(Xe().mark(function Z(){var oe,ue,Se,he,se,ce,Me,We;return Xe().wrap(function(Ie){for(;;)switch(Ie.prev=Ie.next){case 0:return H=Date.now(),Ie.prev=1,Ie.next=4,P.read();case 4:F=Ie.sent,W=Date.now(),Ie.next=13;break;case 8:return Ie.prev=8,Ie.t0=Ie.catch(1),W=Date.now(),S._aborted||(S._running=!1,Ie.t0.options={index:S._index,range:S._range,vid:S._vid,priOptions:S._priOptions},S.reject(Ie.t0)),Ie.abrupt("return");case 13:if(ue=((oe=S._range)===null||oe===void 0?void 0:oe.length)>0?S._range[0]:0,Se=ue+S._receivedLength,!S._aborted){Ie.next=19;break}return S._running=!1,g(void 0,!1,{range:[Se,Se],vid:S._vid,index:S._index,startTime:H,endTime:W,st:E,firstByteTime:_,priOptions:S._priOptions},f),Ie.abrupt("return");case 19:he=F.value?F.value.byteLength:0,S._receivedLength+=he,S._logger.debug("\u3010fetchLoader,onProgress call\u3011,task,",S._range,", start,",Se,", end,",ue+S._receivedLength,", done,",F.done),S._onProcessMinLen>0?S._writeIdx+he>=S._onProcessMinLen||F.done?(se=new Uint8Array(S._writeIdx+he),se.set(S._cache.slice(0,S._writeIdx),0),he>0&&se.set(F.value,S._writeIdx),S._writeIdx=0,S._logger.debug("\u3010fetchLoader,onProgress enough\u3011,done,",F.done,",len,",se.byteLength,", writeIdx,",S._writeIdx)):he>0&&S._writeIdx+he<po?(S._cache.set(F.value,S._writeIdx),S._writeIdx+=he,S._logger.debug("\u3010fetchLoader,onProgress cache\u3011,len,",he,", writeIdx,",S._writeIdx)):he>0&&(ce=new Uint8Array(S._writeIdx+he+2048),S._logger.debug("\u3010fetchLoader,onProgress extra start\u3011,size,",S._writeIdx+he+2048,", datalen,",he,", writeIdx,",S._writeIdx),ce.set(S._cache.slice(0,S._writeIdx),0),he>0&&ce.set(F.value,S._writeIdx),S._writeIdx+=he,delete S._cache,S._cache=ce,S._logger.debug("\u3010fetchLoader,onProgress extra end\u3011,len,",he,", writeIdx,",S._writeIdx)):se=F.value,(se&&se.byteLength>0||F.done)&&g(se,F.done,{range:[S._range[0]+S._receivedLength-(se?se.byteLength:0),S._range[0]+S._receivedLength],vid:S._vid,index:S._index,startTime:H,endTime:W,st:E,firstByteTime:_,priOptions:S._priOptions},f),F.done?(Me=Date.now()-E,We=qr(S._receivedLength,Me),S.emit(_e.REAL_TIME_SPEED,{speed:We,len:S._receivedLength,time:Me,vid:S._vid,index:S._index,range:S._range,priOptions:S._priOptions}),S._running=!1,S._logger.debug("[fetchLoader onProgress end],task,",S._range,",done,",F.done),S.resolve(zr(F,!0,f,f.headers.get("Content-Length"),f.headers.get("age"),E,_,S._index,S._range,S._vid,S._priOptions))):$();case 25:case"end":return Ie.stop()}},Z,null,[[1,8]])}));return function(){return ee.apply(this,arguments)}}();$()}},{key:"receiveLen",get:function(){return this._receivedLength}},{key:"running",get:function(){return this._running},set:function(f){this._running=f}}],[{key:"isSupported",value:function(){return typeof fetch<"u"}}]),o}(go.default);function mo(v){return ur({loaderType:Gt.FETCH,retry:0,retryDelay:0,timeout:0,request:null,onTimeout:void 0,onProgress:void 0,onRetryError:void 0,transformRequest:void 0,transformResponse:void 0,transformError:void 0,responseType:hr.TEXT,range:void 0,url:"",params:void 0,method:"GET",headers:{},body:void 0,mode:void 0,credentials:void 0,cache:void 0,redirect:void 0,referrer:void 0,referrerPolicy:void 0,integrity:void 0,onProcessMinLen:0},v)}var yo=Ar(xr()),Eo=function(v){Ut(o,v);var m=Bt(o);function o(){var h;return He(this,o),h=m.call(this),q(pe(h),"_xhr",null),q(pe(h),"_aborted",!1),q(pe(h),"_timeoutTimer",null),q(pe(h),"_range",null),q(pe(h),"_receivedLength",0),q(pe(h),"_url",null),q(pe(h),"_onProgress",null),q(pe(h),"_index",-1),q(pe(h),"_headers",null),q(pe(h),"_currentChunkSizeKB",384),q(pe(h),"_timeout",null),q(pe(h),"_xhr",null),q(pe(h),"_withCredentials",null),q(pe(h),"_startTime",-1),q(pe(h),"_loadCompleteResolve",null),q(pe(h),"_loadCompleteReject",null),q(pe(h),"_runing",!1),q(pe(h),"_logger",!1),q(pe(h),"_vid",""),q(pe(h),"_responseType",void 0),q(pe(h),"_credentials",void 0),q(pe(h),"_method",void 0),q(pe(h),"_transformResponse",void 0),q(pe(h),"_firstRtt",void 0),q(pe(h),"_onCancel",null),q(pe(h),"_priOptions",null),h}return Ke(o,[{key:"load",value:function(f){var g=this;clearTimeout(this._timeoutTimer),this._logger=f.logger,this._range=f.range,this._onProgress=f.onProgress,this._index=f.index,this._headers=f.headers,this._withCredentials=f.credentials==="include"||f.credentials==="same-origin",this._body=f.body||null,f.method&&(this._method=f.method),this._timeout=f.timeout||null,this._runing=!0,this._vid=f.vid||f.url,this._responseType=f.responseType,this._firstRtt=-1,this._onTimeout=f.onTimeout,this._onCancel=f.onCancel,this._request=f.request,this._priOptions=f.priOptions||{},this._logger.debug("\u3010xhrLoader task\u3011, range",this._range),this._url=Di(f.url,f.params);var E=Date.now();return new Promise(function(_,S){g._loadCompleteResolve=_,g._loadCompleteReject=S,g._startLoad()}).catch(function(_){if(clearTimeout(g._timeoutTimer),g._runing=!1,!g._aborted)throw _=_ instanceof wt?_:new wt(g._url,g._request),_.startTime=E,_.endTime=Date.now(),_.options={index:g._index,vid:g._vid,priOptions:g._priOptions},_})}},{key:"_startLoad",value:function(){var f=null;if(this._responseType===hr.ARRAY_BUFFER&&this._range&&this._range.length>1)if(this._onProgress){this._firstRtt=-1;var g=this._currentChunkSizeKB*1024,E=this._range[0]+this._receivedLength,_=this._range[1];g<this._range[1]-E&&(_=E+g),f=[E,_],this._logger.debug("[xhr_loader->],tast :",this._range,", SubRange, ",f)}else f=this._range,this._logger.debug("[xhr_loader->],tast :",this._range,", allRange, ",f);this._internalOpen(f)}},{key:"_internalOpen",value:function(f){var g=this;try{this._startTime=Date.now();var E=this._xhr=new XMLHttpRequest;E.open(this._method||"GET",this._url,!0),E.responseType=this._responseType,this._timeout&&(E.timeout=this._timeout),E.withCredentials=this._withCredentials,E.onload=this._onLoad.bind(this),E.onreadystatechange=this._onReadyStatechange.bind(this),E.onerror=function(D){var P,F,H;g._running=!1;var W=new wt(g._url,g._request,D==null||(P=D.currentTarget)===null||P===void 0?void 0:P.response,"xhr.onerror.status:"+(D==null||(F=D.currentTarget)===null||F===void 0?void 0:F.status)+",statusText,"+(D==null||(H=D.currentTarget)===null||H===void 0?void 0:H.statusText));W.options={index:g._index,range:g._range,vid:g._vid,priOptions:g._priOptions},g._loadCompleteReject(W)},E.ontimeout=function(D){g.cancel();var P=new wt(g._url,g._request,{status:408},"timeout");g._onTimeout&&(P.isTimeout=!0,g._onTimeout(P,{index:g._index,range:g._range,vid:g._vid,priOptions:g._priOptions})),P.options={index:g._index,range:g._range,vid:g._vid,priOptions:g._priOptions},g._loadCompleteReject(P)};var _=this._headers||{},S=ki(f);S&&(_.Range=S),_&&Object.keys(_).forEach(function(D){E.setRequestHeader(D,_[D])}),this._logger.debug("[xhr.send->] tast,",this._range,",load sub range, ",f),E.send(this._body)}catch(D){D.options={index:this._index,range:f,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(D)}}},{key:"_onReadyStatechange",value:function(f){var g=f.target;g.readyState===2&&this._firstRtt<0&&(this._firstRtt=Date.now())}},{key:"_onLoad",value:function(f){var g,E=f.target.status;if(E<200||E>299){var _=new wt(this._url,null,ur(ur({},f.target.response),{},{status:E}),"bad response,status:"+E);return _.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(_)}var S=null,D=!1,P,F=((g=this._range)===null||g===void 0?void 0:g.length)>0?this._range[0]:0;if(this._responseType===hr.ARRAY_BUFFER){var H,W=new Uint8Array(f.target.response);if(P=F+this._receivedLength,W&&W.byteLength>0){this._receivedLength+=W.byteLength;var $=Date.now()-this._startTime,ee=qr(this._receivedLength,$);this.emit(_e.REAL_TIME_SPEED,{speed:ee,len:this._receivedLength,time:$,vid:this._vid,index:this._index,range:[P,F+this._receivedLength],priOptions:this._priOptions})}S=W,((H=this._range)===null||H===void 0?void 0:H.length)>1&&this._range[1]&&this._receivedLength<this._range[1]-this._range[0]?D=!1:D=!0,this._logger.debug("[xhr load done->], tast :",this._range,", start",P,"end ",F+this._receivedLength,",dataLen,",W?W.byteLength:0,",receivedLength",this._receivedLength,",index,",this._index,", done,",D)}else D=!0,S=f.target.response;var Z={ok:E>=200&&E<300,status:E,statusText:this._xhr.statusText,url:this._xhr.responseURL,headers:this._getHeaders(this._xhr),body:this._xhr.response};this._transformResponse&&(Z=this._transformResponse(Z,this._url)||Z),this._onProgress&&this._onProgress(S,D,{index:this._index,vid:this._vid,range:[P,F+this._receivedLength],startTime:this._startTime,endTime:Date.now(),priOptions:this._priOptions},Z),D?(this._runing=!1,this._loadCompleteResolve&&this._loadCompleteResolve(zr(this._onProgress?null:S,D,Z,Z.headers["content-length"],Z.headers.age,this._startTime,this._firstRtt,this._index,this._range,this._vid,this._priOptions))):this._startLoad()}},{key:"cancel",value:function(){if(!this._aborted&&(this._aborted=!0,this._runing=!1,Kr(or(o.prototype),"removeAllListeners",this).call(this),this._onCancel&&this._onCancel({index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions}),this._xhr))return this._xhr.abort()}},{key:"receiveLen",get:function(){return this._receivedLength}},{key:"running",get:function(){return this._running},set:function(f){this._running=f}},{key:"_getHeaders",value:function(f){var g=f.getAllResponseHeaders().trim().split(`\r
31
+ `),E={},_=no(g),S;try{for(_.s();!(S=_.n()).done;){var D=S.value,P=D.split(": ");E[P[0].toLowerCase()]=P.slice(1).join(": ")}}catch(F){_.e(F)}finally{_.f()}return E}}],[{key:"isSupported",value:function(){return typeof XMLHttpRequest<"u"}}]),o}(yo.default);var Kh=["retry","retryDelay","onRetryError","transformError"],_o=function(){function v(m,o){He(this,v),this.promise=lr(),this.alive=!!o.onProgress,!o.logger&&(o.logger=new Ct("Loader")),this._loaderType=m,this._loader=m===Gt.FETCH&&typeof fetch<"u"?new $r:new Eo,this._config=o,this._retryCount=0,this._retryTimer=null,this._canceled=!1,this._retryCheckFunc=o.retryCheckFunc,this._logger=o.logger}return Ke(v,[{key:"exec",value:function(){var o=this,h=this._config,f=h.retry,g=h.retryDelay,E=h.onRetryError,_=h.transformError,S=io(h,Kh),D=function(){var P=Rt(Xe().mark(function F(){var H,W,$;return Xe().wrap(function(Z){for(;;)switch(Z.prev=Z.next){case 0:return Z.prev=0,Z.next=3,o._loader.load(S);case 3:H=Z.sent,o.promise.resolve(H),Z.next=27;break;case 7:if(Z.prev=7,Z.t0=Z.catch(0),o._loader.running=!1,o._logger.debug("[task request catch err]",Z.t0),!o._canceled){Z.next=13;break}return Z.abrupt("return");case 13:if(Z.t0.loaderType=o._loaderType,Z.t0.retryCount=o._retryCount,W=Z.t0,_&&(W=_(W)||W),E&&o._retryCount>0&&E(W,o._retryCount,{index:S.index,vid:S.vid,range:S.range,priOptions:S.priOptions}),o._retryCount++,$=!0,o._retryCheckFunc&&($=o._retryCheckFunc(Z.t0)),!($&&o._retryCount<=f)){Z.next=26;break}return clearTimeout(o._retryTimer),o._logger.debug("[task request setTimeout],retry",o._retryCount,",retry range,",S.range),o._retryTimer=setTimeout(D,g),Z.abrupt("return");case 26:o.promise.reject(W);case 27:case"end":return Z.stop()}},F,null,[[0,7]])}));return function(){return P.apply(this,arguments)}}();return D(),this.promise}},{key:"cancel",value:function(){var m=Rt(Xe().mark(function h(){return Xe().wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return clearTimeout(this._retryTimer),this._canceled=!0,this._loader.running=!1,g.abrupt("return",this._loader.cancel());case 4:case"end":return g.stop()}},h,this)}));function o(){return m.apply(this,arguments)}return o}()},{key:"running",get:function(){return this._loader&&this._loader.running}},{key:"loader",get:function(){return this._loader}}]),v}();function Tn(v){return v&&!v.paused&&!v.ended&&v.playbackRate!==0&&v.readyState!==0}function An(v){if(!v)return{};if(typeof v.getVideoPlaybackQuality=="function"){var m=v.getVideoPlaybackQuality();return{droppedVideoFrames:m.droppedVideoFrames||m.corruptedVideoFrames,totalVideoFrames:m.totalVideoFrames,creationTime:m.creationTime}}return{droppedVideoFrames:v.webkitDroppedFrameCount,totalVideoFrames:v.webkitDecodedFrameCount,creationTime:performance.now()}}function bn(){for(var v=arguments.length,m=new Array(v),o=0;o<v;o++)m[o]=arguments[o];if(m=m.filter(Boolean),m.length<2)return m[0];var h=new Uint8Array(m.reduce(function(g,E){return g+E.byteLength},0)),f=0;return m.forEach(function(g){h.set(g,f),f+=g.byteLength}),h}function Ln(){var v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return new Promise(function(m){return setTimeout(m,v)})}var So=Ar(xr()),xn=function(v){Ut(o,v);var m=Bt(o);function o(h){var f;return He(this,o),f=m.call(this,h),q(pe(f),"type",Gt.FETCH),q(pe(f),"_queue",[]),q(pe(f),"_alive",[]),q(pe(f),"_currentTask",null),q(pe(f),"_finnalUrl",""),q(pe(f),"_config",void 0),f._config=mo(h),(f._config.loaderType===Gt.XHR||!$r.isSupported())&&(f.type=Gt.XHR),f.log=h.logger,f}return Ke(o,[{key:"isFetch",value:function(){return this.type===Gt.FETCH}},{key:"load",value:function(f){var g=this,E=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};typeof f=="string"||!f?E.url=f||E.url||this._config.url:E=f,E=Object.assign({},this._config,E),E.params&&(E.params=Object.assign({},E.params)),E.headers&&Sn(E.headers)&&(E.headers=Object.assign({},E.headers)),E.body&&Sn(E.body)&&(E.body=Object.assign({},E.body)),E.transformRequest&&(E=E.transformRequest(E)||E),E.logger=this.log;var _=new _o(this.type,E);return _.loader.on(_e.REAL_TIME_SPEED,function(S){g.emit(_e.REAL_TIME_SPEED,S)}),this._queue.push(_),this._queue.length===1&&(!this._currentTask||!this._currentTask.running)&&this._processTask(),_.promise}},{key:"cancel",value:function(){var h=Rt(Xe().mark(function g(){var E;return Xe().wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return E=this._queue.map(function(D){return D.cancel()}).concat(this._alive.map(function(D){return D.cancel()})),this._currentTask&&E.push(this._currentTask.cancel()),this._queue=[],this._alive=[],S.next=6,Promise.all(E);case 6:return S.next=8,Ln();case 8:case"end":return S.stop()}},g,this)}));function f(){return h.apply(this,arguments)}return f}()},{key:"_processTask",value:function(){var f=this;if(this._currentTask=this._queue.shift(),!!this._currentTask){this._currentTask.alive&&this._alive.push(this._currentTask);var g=this._currentTask.exec().catch(function(E){});g&&typeof g.finally=="function"&&g.finally(function(){var E,_;(E=f._currentTask)!==null&&E!==void 0&&E.alive&&((_=f._alive)===null||_===void 0?void 0:_.length)>0&&(f._alive=f._alive.filter(function(S){return S&&S!==f._currentTask})),f._processTask()})}}}],[{key:"isFetchSupport",value:function(){return $r.isSupported()}}]),o}(So.default);var Rn=function(){function v(){He(this,v),q(this,"_prevCurrentTime",0)}return Ke(v,[{key:"do",value:function(o){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:3,f=arguments.length>2?arguments[2]:void 0,g=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1;if(o){var E=o.currentTime,_=0;if(this._prevCurrentTime===E){var S=tt.info(tt.get(o),E);if(!S.buffers.length)return;f&&S.nextStart||S.nextStart&&S.nextStart-E<h?_=S.nextStart+.1:S.end&&S.end-E>g&&!o.seeking&&(_=E+.1)}this._prevCurrentTime=E,_&&E!==_&&(o.currentTime=_)}}}]),v}();var Cn=function(){function v(m){var o=this;He(this,v),q(this,"_seiSet",new Set),this.emitter=m,m.on(_e.SEI,function(h){h&&o._seiSet.add(h)})}return Ke(v,[{key:"throw",value:function(o,h){var f=this;if(!(o==null||!this._seiSet.size)){var g=o-.2,E=o+.2,_=[];this._seiSet.forEach(function(S){S.time>=g&&S.time<=E&&_.push(S)}),_.forEach(function(S){f._seiSet.delete(S),f.emitter.emit(_e.SEI_IN_TIME,S)}),h&&this._seiSet.forEach(function(S){S.time<o-5&&f._seiSet.delete(S)})}}},{key:"reset",value:function(){this._seiSet.clear()}}]),v}();var Wh=1e3,jh=50,Yh=3,zh=3e3,kn=function(){function v(m){He(this,v),q(this,"_chunkSpeed",0),q(this,"_chunkCache",[]),q(this,"_speeds",[]),q(this,"_totalSize",0),q(this,"_totalCost",0),this._opts=m||{}}return Ke(v,[{key:"addRecord",value:function(o,h){!o||!h||(this._speeds.push(8e3*o/h),this._speeds=this._speeds.slice(-Yh))}},{key:"addChunkRecord",value:function(o,h){var f,g;if(!(!o||!h||o<(((f=this._opts)===null||f===void 0?void 0:f.skipChunkSize)||Wh))){this._totalSize+=o,this._totalCost+=h,this._chunkSpeed=8e3*o/h,this._chunkCache.push({size:o,duration:h,timestamp:performance.now()});var E=((g=this._opts)===null||g===void 0?void 0:g.chunkCountForSpeed)||jh;this._chunkCache.length>E&&(this._chunkCache=this._chunkCache.slice(-E))}}},{key:"getAvgSpeed",value:function(){var o;if(!this._chunkCache.length&&!this._speeds.length)return 0;if(this._speeds.length)return this._speeds.reduce(function(_,S){return _+=S})/this._speeds.length;var h=this._chunkCache[this._chunkCache.length-1],f=performance.now()-h.timestamp;f>(((o=this._opts)===null||o===void 0?void 0:o.longtimeNoReceived)||zh)&&this._chunkCache.push({size:0,duration:f,timestamp:performance.now()});var g=this._chunkCache.reduce(function(_,S){return _+=S.size},0),E=this._chunkCache.reduce(function(_,S){return _+=S.duration},0);return 8e3*g/E}},{key:"getLatestSpeed",value:function(){return!this._chunkCache.length&&!this._speeds.length?0:this._speeds.length?this._speeds[this._speeds.length-1]:this._chunkSpeed}},{key:"getTotalSize",value:function(){return this._totalSize}},{key:"getTotalCost",value:function(){return this._totalCost}},{key:"reset",value:function(){this._chunkCache=[],this._speeds=[],this._totalSize=0,this._totalCost=0}}]),v}();var xc=Ar(xr());var To=function(){function v(m){He(this,v),q(this,"encodeType",""),q(this,"audioCodec",""),q(this,"videoCodec",""),q(this,"domain",""),q(this,"fps",0),q(this,"bitrate",0),q(this,"width",0),q(this,"height",0),q(this,"samplerate",0),q(this,"channelCount",0),q(this,"gop",0),q(this,"_bitsAccumulateSize",0),q(this,"_bitsAccumulateDuration",0),q(this,"_startGopId",-1),this._timescale=m}return Ke(v,[{key:"getStats",value:function(){return{encodeType:this.encodeType,audioCodec:this.audioCodec,videoCodec:this.videoCodec,domain:this.domain,fps:this.fps,bitrate:this.bitrate,width:this.width,height:this.height,samplerate:this.samplerate,channelCount:this.channelCount,gop:this.gop}}},{key:"setEncodeType",value:function(o){this.encodeType=o}},{key:"setFpsFromScriptData",value:function(o){var h,f=o.data,g=f==null||(h=f.onMetaData)===null||h===void 0?void 0:h.framerate;g&&g>0&&g<100&&(this.fps=g)}},{key:"setVideoMeta",value:function(o){if(this.width=o.width,this.height=o.height,this.videoCodec=o.codec,this.encodeType=o.codecType,o.fpsNum&&o.fpsDen){var h=o.fpsNum/o.fpsDen;h>0&&h<100&&(this.fps=h)}}},{key:"setAudioMeta",value:function(o){this.audioCodec=o.codec,this.samplerate=o.sampleRate,this.channelCount=o.channelCount}},{key:"setDomain",value:function(o){this.domain=o.split("/").slice(2,3)[0]}},{key:"updateBitrate",value:function(o){var h=this;if((!this.fps||this.fps>=100)&&o.length){var f=o.reduce(function(g,E){return g+=E.duration},0)/o.length;this.fps=Math.round(this._timescale/f)}o.forEach(function(g){h._startGopId===-1&&(h._startGopId=g.gopId),g.gopId===h._startGopId&&h.gop++,h._bitsAccumulateDuration+=g.duration/(h._timescale/1e3),h._bitsAccumulateSize+=g.units.reduce(function(E,_){return E+=_.length},0),h._bitsAccumulateDuration>=1e3&&(h.bitrate=h._bitsAccumulateSize*8,h._bitsAccumulateDuration=0,h._bitsAccumulateSize=0)})}}]),v}(),Dn=function(){function v(m){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1e3;He(this,v),q(this,"_core",null),q(this,"_samples",[]),this._core=m,this._timescale=o,this._stats=new To(o),this._bindEvents()}return Ke(v,[{key:"getStats",value:function(){var o,h,f,g,E,_,S,D,P,F,H,W=((o=this._core)===null||o===void 0?void 0:o.media)||{},$=W.currentTime,ee=$===void 0?0:$,Z=W.decodeFps,oe=Z===void 0?0:Z;return ur(ur({},this._stats.getStats()),{},{downloadSpeed:((h=this._core)===null||h===void 0||(f=h.speedInfo)===null||f===void 0?void 0:f.call(h).speed)||0,avgSpeed:((g=this._core)===null||g===void 0||(E=g.speedInfo)===null||E===void 0?void 0:E.call(g).avgSpeed)||0,totalReceivedByte:((_=this._core)===null||_===void 0||(S=_.speedInfo)===null||S===void 0?void 0:S.call(_).totalSize)||0,totalReceivedCost:((D=this._core)===null||D===void 0||(P=D.speedInfo)===null||P===void 0?void 0:P.call(D).totalCost)||0,currentTime:ee,bufferEnd:((F=this._core)===null||F===void 0||(H=F.bufferInfo())===null||H===void 0?void 0:H.remaining)||0,decodeFps:oe})}},{key:"_bindEvents",value:function(){var o=this;this._core.on(_e.DEMUXED_TRACK,function(h){var f=h.videoTrack;return o._stats.updateBitrate(f.samples)}),this._core.on(_e.FLV_SCRIPT_DATA,function(h){o._stats.setFpsFromScriptData(h)}),this._core.on(_e.METADATA_PARSED,function(h){h.type==="video"?o._stats.setVideoMeta(h.track):o._stats.setAudioMeta(h.track)}),this._core.on(_e.TTFB,function(h){o._stats.setDomain(h.responseUrl)})}},{key:"reset",value:function(){this._samples=[],this._stats=new To(this._timescale)}}]),v}();var $o=Ar(xr());function qh(v,m){var o=v==null?null:typeof Symbol<"u"&&v[Symbol.iterator]||v["@@iterator"];if(o!=null){var h,f,g,E,_=[],S=!0,D=!1;try{if(g=(o=o.call(v)).next,m===0){if(Object(o)!==o)return;S=!1}else for(;!(S=(h=g.call(o)).done)&&(_.push(h.value),_.length!==m);S=!0);}catch(P){D=!0,f=P}finally{try{if(!S&&o.return!=null&&(E=o.return(),Object(E)!==E))return}finally{if(D)throw f}}return _}}function Ae(v,m){if(!(v instanceof m))throw new TypeError("Cannot call a class as a function")}function Ao(v,m){for(var o=0;o<m.length;o++){var h=m[o];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(v,xo(h.key),h)}}function be(v,m,o){return m&&Ao(v.prototype,m),o&&Ao(v,o),Object.defineProperty(v,"prototype",{writable:!1}),v}function Q(v,m,o){return m=xo(m),m in v?Object.defineProperty(v,m,{value:o,enumerable:!0,configurable:!0,writable:!0}):v[m]=o,v}function Pn(v,m){if(typeof m!="function"&&m!==null)throw new TypeError("Super expression must either be null or a function");v.prototype=Object.create(m&&m.prototype,{constructor:{value:v,writable:!0,configurable:!0}}),Object.defineProperty(v,"prototype",{writable:!1}),m&&In(v,m)}function Ii(v){return Ii=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(o){return o.__proto__||Object.getPrototypeOf(o)},Ii(v)}function In(v,m){return In=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(h,f){return h.__proto__=f,h},In(v,m)}function $h(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Xh(v){if(v===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v}function Qh(v,m){if(m&&(typeof m=="object"||typeof m=="function"))return m;if(m!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Xh(v)}function On(v){var m=$h();return function(){var h=Ii(v),f;if(m){var g=Ii(this).constructor;f=Reflect.construct(h,arguments,g)}else f=h.apply(this,arguments);return Qh(this,f)}}function bo(v,m){return Jh(v)||qh(v,m)||Lo(v,m)||rd()}function Vt(v){return Zh(v)||ed(v)||Lo(v)||td()}function Zh(v){if(Array.isArray(v))return wn(v)}function Jh(v){if(Array.isArray(v))return v}function ed(v){if(typeof Symbol<"u"&&v[Symbol.iterator]!=null||v["@@iterator"]!=null)return Array.from(v)}function Lo(v,m){if(v){if(typeof v=="string")return wn(v,m);var o=Object.prototype.toString.call(v).slice(8,-1);if(o==="Object"&&v.constructor&&(o=v.constructor.name),o==="Map"||o==="Set")return Array.from(v);if(o==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o))return wn(v,m)}}function wn(v,m){(m==null||m>v.length)&&(m=v.length);for(var o=0,h=new Array(m);o<m;o++)h[o]=v[o];return h}function td(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
32
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function rd(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
33
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function id(v,m){if(typeof v!="object"||v===null)return v;var o=v[Symbol.toPrimitive];if(o!==void 0){var h=o.call(v,m||"default");if(typeof h!="object")return h;throw new TypeError("@@toPrimitive must return a primitive value.")}return(m==="string"?String:Number)(v)}function xo(v){var m=id(v,"string");return typeof m=="symbol"?m:String(m)}var Ht={VIDEO:"video",AUDIO:"audio",METADATA:"metadata"},er={AV1:"av1",AVC:"avc",HEVC:"hevc"},ze={AAC:"aac",G711PCMA:"g7110a",G711PCMU:"g7110m",OPUS:"opus",MP3:"mp3"},yt={LARGE_AV_SHIFT:"LARGE_AV_SHIFT",LARGE_VIDEO_GAP:"LARGE_VIDEO_GAP",LARGE_VIDEO_GAP_BETWEEN_CHUNK:"LARGE_VIDEO_GAP_BETWEEN_CHUNK",LARGE_AUDIO_GAP:"LARGE_AUDIO_GAP",AUDIO_FILLED:"AUDIO_FILLED",AUDIO_DROPPED:"AUDIO_DROPPED"};var Ro=function(){function v(){Ae(this,v),Q(this,"id",1),Q(this,"type",Ht.VIDEO),Q(this,"codecType",er.AVC),Q(this,"pid",-1),Q(this,"hvcC",void 0),Q(this,"codec",""),Q(this,"timescale",0),Q(this,"formatTimescale",0),Q(this,"sequenceNumber",0),Q(this,"baseMediaDecodeTime",0),Q(this,"baseDts",0),Q(this,"duration",0),Q(this,"warnings",[]),Q(this,"samples",[]),Q(this,"pps",[]),Q(this,"sps",[]),Q(this,"vps",[]),Q(this,"fpsNum",0),Q(this,"fpsDen",0),Q(this,"sarRatio",[]),Q(this,"width",0),Q(this,"height",0),Q(this,"nalUnitSize",4),Q(this,"present",!1),Q(this,"isVideoEncryption",!1),Q(this,"isAudioEncryption",!1),Q(this,"isVideo",!0),Q(this,"lastKeyFrameDts",0),Q(this,"kid",null),Q(this,"pssh",null),Q(this,"ext",void 0)}return be(v,[{key:"reset",value:function(){this.sequenceNumber=this.width=this.height=this.fpsDen=this.fpsNum=this.duration=this.baseMediaDecodeTime=this.timescale=0,this.codec="",this.present=!1,this.pid=-1,this.pps=[],this.sps=[],this.vps=[],this.sarRatio=[],this.samples=[],this.warnings=[],this.hvcC=null}},{key:"firstDts",get:function(){return this.samples.length?this.samples[0].dts:null}},{key:"firstPts",get:function(){return this.samples.length?this.samples[0].pts:null}},{key:"samplesDuration",get:function(){if(this.samples.length>0){var o=this.samples[0],h=this.samples[this.samples.length-1];return h.dts-o.dts+h.duration}return 0}},{key:"exist",value:function(){return/av01/.test(this.codec)?!0:!!(this.pps.length&&this.sps.length&&this.codec)}},{key:"hasSample",value:function(){return!!this.samples.length}},{key:"isEncryption",get:function(){return this.isVideoEncryption}}]),v}();var Co=function(){function v(){Ae(this,v),Q(this,"id",2),Q(this,"type",Ht.AUDIO),Q(this,"codecType",ze.AAC),Q(this,"pid",-1),Q(this,"codec",""),Q(this,"container",""),Q(this,"sequenceNumber",0),Q(this,"sampleDuration",0),Q(this,"timescale",0),Q(this,"formatTimescale",0),Q(this,"baseMediaDecodeTime",0),Q(this,"duration",0),Q(this,"warnings",[]),Q(this,"samples",[]),Q(this,"baseDts",0),Q(this,"sampleSize",16),Q(this,"sampleRate",0),Q(this,"channelCount",0),Q(this,"objectType",0),Q(this,"sampleRateIndex",0),Q(this,"config",[]),Q(this,"present",!1),Q(this,"isVideoEncryption",!1),Q(this,"isAudioEncryption",!1),Q(this,"kid",null),Q(this,"ext",void 0)}return be(v,[{key:"reset",value:function(){this.sequenceNumber=0,this.timescale=0,this.sampleDuration=0,this.sampleRate=0,this.channelCount=0,this.baseMediaDecodeTime=0,this.present=!1,this.pid=-1,this.codec="",this.samples=[],this.config=[],this.warnings=[]}},{key:"exist",value:function(){return!!(this.sampleRate&&this.channelCount&&(this.codec||this.container)&&(this.codecType===ze.AAC||this.codecType===ze.G711PCMA||this.codecType===ze.G711PCMU||this.codecType===ze.OPUS||this.codecType===ze.MP3))}},{key:"hasSample",value:function(){return!!this.samples.length}},{key:"isEncryption",get:function(){return this.isAudioEncryption}},{key:"firstDts",get:function(){return this.samples.length?this.samples[0].dts:null}},{key:"firstPts",get:function(){return this.samples.length?this.samples[0].pts:null}},{key:"samplesDuration",get:function(){if(this.samples.length>0){var o=this.samples[0],h=this.samples[this.samples.length-1];return h.dts-o.dts+h.duration}return 0}}]),v}();var ko=function(){function v(m,o,h){Ae(this,v),Q(this,"flag",{}),Q(this,"keyframe",!1),Q(this,"gopId",0),Q(this,"duration",0),Q(this,"size",0),Q(this,"units",[]),Q(this,"chromaFormat",420),this.originPts=this.pts=m,this.originDts=this.dts=o,h&&(this.units=h)}return be(v,[{key:"cts",get:function(){return this.pts-this.dts}},{key:"setToKeyframe",value:function(){this.keyframe=!0,this.flag.dependsOn=2,this.flag.isNonSyncSample=0}}]),v}();var Rr=be(function v(m,o,h,f){Ae(this,v),Q(this,"duration",1024),Q(this,"flag",{dependsOn:2,isNonSyncSample:0}),Q(this,"keyframe",!0),this.originPts=this.pts=this.dts=m,this.data=o,this.size=o.byteLength,this.sampleOffset=f,h&&(this.duration=h)});var Do=be(function v(m,o){Ae(this,v),Q(this,"time",0),this.data=m,this.originPts=this.pts=o}),Io=function(v){Pn(o,v);var m=On(o);function o(){return Ae(this,o),m.apply(this,arguments)}return be(o)}(Do),wo=function(v){Pn(o,v);var m=On(o);function o(){return Ae(this,o),m.apply(this,arguments)}return be(o)}(Do),Po=function(){function v(){Ae(this,v),Q(this,"id",3),Q(this,"type",Ht.METADATA),Q(this,"timescale",0),Q(this,"flvScriptSamples",[]),Q(this,"seiSamples",[])}return be(v,[{key:"exist",value:function(){return!!((this.flvScriptSamples.length||this.seiSamples.length)&&this.timescale)}},{key:"reset",value:function(){this.timescale=0,this.flvScriptSamples=[],this.seiSamples=[]}},{key:"hasSample",value:function(){return!!(this.flvScriptSamples.length||this.seiSamples.length)}}]),v}();var pr=function(){function v(m){Ae(this,v),this.name=m||"",this._prefix="[".concat(this.name,"]")}return be(v,[{key:"warn",value:function(){var o;if(!v.disabled){for(var h=arguments.length,f=new Array(h),g=0;g<h;g++)f[g]=arguments[g];(o=console).warn.apply(o,[this._prefix].concat(f))}}}],[{key:"enable",value:function(){v.disabled=!1}},{key:"disable",value:function(){v.disabled=!0}}]),v}();Q(pr,"disabled",!0);var wi=typeof window<"u",Mn=wi&&navigator.userAgent.toLocaleLowerCase(),Oo=wi&&/^((?!chrome|android).)*safari/.test(Mn),Mo=wi&&Mn.includes("firefox"),Fo=wi&&Mn.includes("android");var Cr=function(){function v(){Ae(this,v)}return be(v,null,[{key:"getRateIndexByRate",value:function(o){return v.FREQ.indexOf(o)}},{key:"parseADTS",value:function(o,h){for(var f=o.length,g=0;g+2<f&&!(o[g]===255&&(o[g+1]&246)===240);)g++;if(!(g>=f)){var E=g,_=[],S=(o[g+2]&60)>>>2,D=v.FREQ[S];if(!D)throw new Error("Invalid sampling index: ".concat(S));for(var P=((o[g+2]&192)>>>6)+1,F=(o[g+2]&1)<<2|(o[g+3]&192)>>>6,H=v._getConfig(S,F,P),W=H.config,$=H.codec,ee,Z,oe=0,ue=v.getFrameDuration(D);g+7<f;){if(o[g]!==255||(o[g+1]&246)!==240){g++;continue}if(Z=(o[g+3]&3)<<11|o[g+4]<<3|(o[g+5]&224)>>5,!Z||f-g<Z)break;ee=(~o[g+1]&1)*2,_.push({pts:h+oe*ue,data:o.subarray(g+7+ee,g+Z)}),oe++,g+=Z}return{skip:E,remaining:g>=f?void 0:o.subarray(g),frames:_,samplingFrequencyIndex:S,sampleRate:D,objectType:P,channelCount:F,codec:$,config:W,originCodec:"mp4a.40.".concat(P)}}}},{key:"parseAudioSpecificConfig",value:function(o){if(o.length){var h=o[0]>>>3,f=(o[0]&7)<<1|o[1]>>>7,g=(o[1]&120)>>>3,E=v.FREQ[f];if(E){var _=v._getConfig(f,g,h),S=_.config,D=_.codec;return{samplingFrequencyIndex:f,sampleRate:E,objectType:h,channelCount:g,config:S,codec:D,originCodec:"mp4a.40.".concat(h)}}}}},{key:"getFrameDuration",value:function(o){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:9e4;return 1024*h/o}},{key:"_getConfig",value:function(o,h,f){var g=[],E,_;return Mo?o>=6?(E=5,_=o-3):(E=2,_=o):Fo?(E=2,_=o):(E=5,_=o,o>=6?_=o-3:h===1&&(E=2,_=o)),g[0]=E<<3,g[0]|=(o&14)>>1,g[1]=(o&1)<<7,g[1]|=h<<3,E===5&&(g[1]|=(_&14)>>1,g[2]=(_&1)<<7,g[2]|=8,g[3]=0),{config:g,codec:"mp4a.40.".concat(E)}}},{key:"getSilentFrame",value:function(o,h){switch(o){case"mp4a.40.2":if(h===1)return new Uint8Array([0,200,0,128,35,128]);if(h===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(h===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(h===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(h===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(h===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(h===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(h===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(h===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}}}]),v}();Q(Cr,"FREQ",[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350]);var Xr=function(){function v(){Ae(this,v)}return be(v,null,[{key:"getFrameDuration",value:function(o){return 20}},{key:"parseHeaderPackets",value:function(o){if(o.length){for(var h=new DataView(o.buffer,o.byteOffset,o.byteLength),f="",g=0;g<8;g++)f+=String.fromCodePoint(o[g]);if(f!=="OpusHead")throw new Error("Invalid Opus MagicSignature");var E=o[9];console.log("Pre-skip",o[10],o[11]);var _=h.getUint32(12,!0),S=h.getInt16(16,!0);if(_){var D="opus",P="opus",F=new Uint8Array(o.buffer,o.byteOffset+8,o.byteLength-8);return{outputGain:S,sampleRate:_,channelCount:E,config:F,codec:D,originCodec:P}}}}}]),v}();var nd=500,No=3,Fn=1e3,Nn=5e3,ad=1e3,sd=200,Uo=5e3,Bo=5,Go=function(){function v(m,o,h){Ae(this,v),this.videoTrack=m,this.audioTrack=o,this.metadataTrack=h,this._baseDts=-1,this._baseDtsInited=!1,this._audioNextPts=void 0,this._videoNextDts=void 0,this._audioTimestampBreak=0,this._videoTimestampBreak=0,this._lastVideoDuration=0,this._keyFrameInNextChunk=!1,this._lastAudioExceptionGapDot=-1/0,this._lastAudioExceptionOverlapDot=-1/0,this._lastAudioExceptionLargeGapDot=-1/0,this._lastVideoExceptionLargeGapDot=-1/0,this._lastVideoExceptionChunkFirstDtsDot=-1/0}return be(v,[{key:"fix",value:function(){var o=this,h=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,g=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;h=Math.round(h*1e3);var E=this.videoTrack,_=this.audioTrack;(f||!g)&&(this._videoLastSample=null,this._audioNextPts=void 0,this._videoNextDts=void 0,this._audioTimestampBreak=0,this._videoTimestampBreak=0,this._lastAudioExceptionGapDot=-1/0,this._lastAudioExceptionOverlapDot=-1/0,this._lastAudioExceptionLargeGapDot=-1/0,this._lastVideoExceptionLargeGapDot=-1/0,this._lastVideoExceptionChunkFirstDtsDot=-1/0),f&&!g&&(this._baseDtsInited=!1),this._baseDtsInited||this._calculateBaseDts(_,E),!g&&h&&(this._audioNextPts=this._videoNextDts=h);var S=this._baseDtsInited&&(this._videoTimestampBreak||!this.videoTrack.exist())&&(this._audioTimestampBreak||!this.audioTrack.exist());if(S&&this._resetBaseDtsWhenStreamBreaked(),this._fixAudio(_),this._keyFrameInNextChunk=!1,this._fixVideo(E),this.metadataTrack.exist()){var D=this.metadataTrack.timescale;this.metadataTrack.seiSamples.forEach(function(P){P.pts=P.originPts-o._baseDts,P.time=Math.max(0,P.pts)/D}),this.metadataTrack.flvScriptSamples.forEach(function(P){P.pts=P.originPts-o._baseDts,P.time=Math.max(0,P.pts)/D})}E.samples.length&&(E.baseMediaDecodeTime=E.samples[0].dts),_.samples.length&&(_.baseMediaDecodeTime=_.samples[0].pts*_.timescale/1e3)}},{key:"_fixVideo",value:function(o){var h=this,f=o.samples;if(f.length){f.forEach(function(ue){ue.dts-=h._baseDts,ue.pts-=h._baseDts,ue.keyframe&&(h._keyFrameInNextChunk=!0)});var g;if(o.fpsNum&&o.fpsDen)g=o.timescale*(o.fpsDen/o.fpsNum);else if(o.length>1){var E=o.samples[0],_=o.samples[f.length-1];g=Math.floor((_.dts-E.dts)/(f.length-1))}else g=this._lastVideoDuration||40;var S=f.pop();if(this._videoLastSample&&f.unshift(this._videoLastSample),this._videoLastSample=S,!!f.length){if(this._videoNextDts===void 0){var D=f[0];this._videoNextDts=D.dts}var P=f.length,F=0,H=f[0],W=this._videoNextDts-H.dts;if(Math.abs(W)>sd){if(Math.abs(H.dts-this._lastVideoExceptionChunkFirstDtsDot)>Uo){var $;this._lastVideoExceptionChunkFirstDtsDot=H.dts,o.warnings.push({type:yt.LARGE_VIDEO_GAP_BETWEEN_CHUNK,nextDts:this._videoNextDts,firstSampleDts:H.dts,nextSampleDts:($=f[1])===null||$===void 0?void 0:$.dts,sampleDuration:W})}this._videoTimestampBreak>=Bo?(this._videoNextDts=H.dts,this._videoTimestampBreak=0):(H.dts+=W,H.pts+=W,this.audioTrack.exist()||(this._videoTimestampBreak=1))}for(var ee=0;ee<P;ee++){var Z=f[ee].dts,oe=f[ee+1];ee<P-1?F=oe.dts-Z:S?F=S.dts-Z:F=g,(F>ad||F<0)&&(this._videoTimestampBreak++,Math.abs(Z-this._lastVideoExceptionLargeGapDot)>Uo&&(this._lastVideoExceptionLargeGapDot=Z,o.warnings.push({type:yt.LARGE_VIDEO_GAP,time:Z/o.timescale,dts:Z,originDts:f[ee].originDts,nextDts:this._videoNextDts,sampleDuration:F,refSampleDuration:g})),F=g),f[ee].duration=F,this._videoNextDts+=F,this._lastVideoDuration=F}}}}},{key:"_fixAudio",value:function(o){var h=this,f=o.samples;f.length&&(f.forEach(function(g){g.dts=g.pts-=h._baseDts}),this._doFixAudioInternal(o,f,1e3))}},{key:"_calculateBaseDts",value:function(o,h){var f=o.samples,g=h.samples;if(!f.length&&!g.length)return!1;var E=1/0,_=1/0;f.length&&(o.baseDts=E=f[0].pts),g.length&&(h.baseDts=_=g[0].dts),this._baseDts=Math.min(E,_);var S=_-E;return Number.isFinite(S)&&Math.abs(S)>nd&&h.warnings.push({type:yt.LARGE_AV_SHIFT,videoBaseDts:_,audioBasePts:E,baseDts:this._baseDts,delta:S}),this._baseDtsInited=!0,!0}},{key:"_resetBaseDtsWhenStreamBreaked",value:function(){var o=this._calculateBaseDts(this.audioTrack,this.videoTrack);o&&(this.audioTrack.exist()?this.videoTrack.exist()?this._baseDts-=Math.min(this._audioNextPts,this._videoNextDts):this._baseDts-=this._audioNextPts:this._baseDts-=this._videoNextDts,this._videoTimestampBreak=0,this._audioTimestampBreak=0)}},{key:"_doFixAudioInternal",value:function(o,h,f){if(!o.sampleDuration)switch(o.codecType){case ze.AAC:{o.sampleDuration=Cr.getFrameDuration(o.timescale,f);break}case ze.OPUS:{o.sampleDuration=Xr.getFrameDuration(o.samples,f);break}case ze.G711PCMA:case ze.G711PCMU:{o.sampleDuration=this._getG711Duration(o);break}default:console.error("can't fix audio codecType:",o.codecType);break}var g=o.sampleDuration,E=o.codecType===ze.OPUS?20:o.codecType===ze.AAC?1024:g*o.timescale/1e3;if(this._audioNextPts===void 0){var _=h[0];this._audioNextPts=_.pts}for(var S=0;S<h.length;S++){var D=this._audioNextPts,P=h[S],F=P.pts-D;if(S===0&&this._audioTimestampBreak>=Bo&&this._keyFrameInNextChunk&&(D=this._audioNextPts=P.dts,F=0,this._audioTimestampBreak=0),!this._audioTimestampBreak&&F>=No*g&&F<=Fn&&!Oo){var H=this._getSilentFrame(o)||h[0].data.subarray(),W=Math.floor(F/g);Math.abs(P.pts-this._lastAudioExceptionGapDot)>Nn&&(this._lastAudioExceptionGapDot=P.pts,o.warnings.push({type:yt.AUDIO_FILLED,pts:P.pts,originPts:P.originPts,count:W,nextPts:D,refSampleDuration:g}));for(var $=0;$<W;$++){var ee=new Rr(Math.floor(this._audioNextPts+g)-Math.floor(this._audioNextPts),H,E);ee.originPts=Math.floor(this._baseDts+D),h.splice(S,0,ee),this._audioNextPts+=g,S++}S--}else if(F<=-No*g&&F>=-1*Fn)Math.abs(P.pts-this._lastAudioExceptionOverlapDot)>Nn&&(this._lastAudioExceptionOverlapDot=P.pts,o.warnings.push({type:yt.AUDIO_DROPPED,pts:P.pts,originPts:P.originPts,nextPts:D,refSampleDuration:g})),h.splice(S,1),S--;else{if(Math.abs(F)>Fn&&(this._audioTimestampBreak++,Math.abs(P.pts-this._lastAudioExceptionLargeGapDot)>Nn&&(this._lastAudioExceptionLargeGapDot=P.pts,o.warnings.push({type:yt.LARGE_AUDIO_GAP,time:P.pts/1e3,pts:P.pts,originPts:P.originPts,nextPts:D,sampleDuration:F,refSampleDuration:g}))),o.codecType===ze.OPUS){var Z=h[h.length-1];Z&&(Z.duration=P.pts-Z.pts)}else P.dts=P.pts=D,P.duration=E;this._audioNextPts+=g}}}},{key:"_getG711Duration",value:function(o){var h=o.sampleSize,f=o.channelCount,g=o.sampleRate,E=o.samples[0];if(E)return E.data.byteLength*2/f/(h/8)/g*1e3}},{key:"_getSilentFrame",value:function(o){return o.codecType===ze.AAC?Cr.getSilentFrame(o.codec,o.channelCount):new Uint8Array(8*o.sampleDuration*o.channelCount)}}]),v}();function kt(){for(var v=arguments.length,m=new Array(v),o=0;o<v;o++)m[o]=arguments[o];m=m.filter(Boolean);var h=new Uint8Array(m.reduce(function(g,E){return g+E.byteLength},0)),f=0;return m.forEach(function(g){h.set(g,f),f+=g.byteLength}),h}var yv=Math.pow(2,32);function kr(v){var m=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(v[m]<<24>>>0)+(v[m+1]<<16)+(v[m+2]<<8)+(v[m+3]||0)}function Vo(v){for(var m="avc1.",o,h=0;h<3;h++)o=v[h].toString(16),o.length<2&&(o="0".concat(o)),m+=o;return m}function Un(v){if(!Array.isArray(v)){for(var m=[],o="",h=0;h<v.length;h++)h%2&&(o=v[h-1]+v[h],m.push(parseInt(o,16)),o="");return m}return v.map(function(f){return parseInt(f,16)})}var tr=function(){function v(){Ae(this,v)}return be(v,null,[{key:"parseAnnexB",value:function(o){var h=o.byteLength-1,f=0;do{if(o[h]===0)f++;else break;h--}while(h>0);f>=3&&(o=o.subarray(0,h+1));for(var g=o.length,E=2,_=0;o[E]!==null&&o[E]!==void 0&&o[E]!==1;)E++;if(E++,_=E+2,_>=g)return[];for(var S=[];_<g;)switch(o[_]){case 0:if(o[_-1]!==0){_+=2;break}else if(o[_-2]!==0){_++;break}else if(_<g-1&&o[_+1]!==1){_++;break}E!==_-2&&S.push(o.subarray(E,_-2));do _++;while(o[_]!==1&&_<g);E=_+1,_=E+2;break;case 1:if(o[_-1]!==0||o[_-2]!==0){_+=3;break}E!==_-2&&S.push(o.subarray(E,_-2)),E=_+1,_=E+2;break;default:_+=3;break}return E<g&&S.push(o.subarray(E)),S}},{key:"parseAvcC",value:function(o){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:4;if(!(o.length<4)){for(var f=o.length,g=[],E=0,_;E+h<f;)if(_=kr(o,E),h===3&&(_>>>=8),E+=h,!!_){if(E+_>f)break;g.push(o.subarray(E,E+_)),E+=_}return g}}},{key:"parseSEI",value:function(o,h){for(var f=o.length,g=h?2:1,E=0,_=0,S="";o[g]===255;)E+=255,g++;for(E+=o[g++];o[g]===255;)_+=255,g++;if(_+=o[g++],E===5&&f>g+16)for(var D=0;D<16;D++)S+=o[g].toString(16),g++;return{payload:o.subarray(g,g+_),type:E,size:_,uuid:S}}},{key:"removeEPB",value:function(o){for(var h=o.byteLength,f=[],g=1;g<h-2;)o[g]===0&&o[g+1]===0&&o[g+2]===3?(f.push(g+2),g+=2):g++;if(!f.length)return o;var E=h-f.length,_=new Uint8Array(E),S=0;for(g=0;g<E;S++,g++)S===f[0]&&(S++,f.shift()),_[g]=o[S];return _}}]),v}();var Qr=function(){function v(m){if(Ae(this,v),Q(this,"_bytesAvailable",void 0),Q(this,"_bitsAvailable",0),Q(this,"_word",0),!m)throw new Error("ExpGolomb data params is required");this._data=m,this._bytesAvailable=m.byteLength,this._bytesAvailable&&this._loadWord()}return be(v,[{key:"bitsAvailable",get:function(){return this._bitsAvailable}},{key:"_loadWord",value:function(){var o=this._data.byteLength-this._bytesAvailable,h=Math.min(4,this._bytesAvailable);if(h===0)throw new Error("No bytes available");var f=new Uint8Array(4);f.set(this._data.subarray(o,o+h)),this._word=new DataView(f.buffer).getUint32(0),this._bitsAvailable=h*8,this._bytesAvailable-=h}},{key:"skipBits",value:function(o){if(this._bitsAvailable>o)this._word<<=o,this._bitsAvailable-=o;else{o-=this._bitsAvailable;var h=Math.floor(o/8);o-=h*8,this._bytesAvailable-=h,this._loadWord(),this._word<<=o,this._bitsAvailable-=o}}},{key:"readBits",value:function(o){if(o>32)throw new Error("Cannot read more than 32 bits");var h=Math.min(this._bitsAvailable,o),f=this._word>>>32-h;return this._bitsAvailable-=h,this._bitsAvailable>0?this._word<<=h:this._bytesAvailable>0&&this._loadWord(),h=o-h,h>0&&this._bitsAvailable?f<<h|this.readBits(h):f}},{key:"skipLZ",value:function(){var o;for(o=0;o<this._bitsAvailable;++o)if((this._word&2147483648>>>o)!==0)return this._word<<=o,this._bitsAvailable-=o,o;return this._loadWord(),o+this.skipLZ()}},{key:"skipUEG",value:function(){this.skipBits(1+this.skipLZ())}},{key:"readUEG",value:function(){var o=this.skipLZ();return this.readBits(o+1)-1}},{key:"readEG",value:function(){var o=this.readUEG();return 1&o?1+o>>>1:-1*(o>>>1)}},{key:"readBool",value:function(){return this.readBits(1)===1}},{key:"readUByte",value:function(){return this.readBits(8)}},{key:"skipScalingList",value:function(o){for(var h=8,f=8,g,E=0;E<o;E++)f!==0&&(g=this.readEG(),f=(h+g+256)%256),h=f===0?h:f}}]),v}();var Ho=function(){function v(){Ae(this,v)}return be(v,null,[{key:"parseAVCDecoderConfigurationRecord",value:function(o){if(!(o.length<7)){for(var h=(o[4]&3)+1,f,g=[],E=[],_=6,S=o[5]&31,D,P=0;P<S;P++)if(D=o[_]<<8|o[_+1],_+=2,!!D){var F=o.subarray(_,_+D);_+=D,g.push(F),f||(f=v.parseSPS(tr.removeEPB(F)))}var H=o[_];_++;for(var W,$=0;$<H;$++)W=o[_]<<8|o[_+1],_+=2,W&&(E.push(o.subarray(_,_+W)),_+=W);return{sps:f,spsArr:g,ppsArr:E,nalUnitSize:h}}}},{key:"parseSPS",value:function(o){var h=new Qr(o);h.readUByte();var f=h.readUByte(),g=h.readUByte(),E=h.readUByte();h.skipUEG();var _=420;if(f===100||f===110||f===122||f===244||f===44||f===83||f===86||f===118||f===128||f===138||f===144){var S=h.readUEG();if(S<=3&&(_=[0,420,422,444][S]),S===3&&h.skipBits(1),h.skipUEG(),h.skipUEG(),h.skipBits(1),h.readBool())for(var D=S!==3?8:12,P=0;P<D;P++)h.readBool()&&(P<6?h.skipScalingList(16):h.skipScalingList(64))}h.skipUEG();var F=h.readUEG();if(F===0)h.readUEG();else if(F===1){h.skipBits(1),h.skipUEG(),h.skipUEG();for(var H=h.readUEG(),W=0;W<H;W++)h.skipUEG()}h.skipUEG(),h.skipBits(1);var $=h.readUEG(),ee=h.readUEG(),Z=h.readBits(1);Z===0&&h.skipBits(1),h.skipBits(1);var oe=0,ue=0,Se=0,he=0;h.readBool()&&(oe=h.readUEG(),ue=h.readUEG(),Se=h.readUEG(),he=h.readUEG());var se,ce,Me,We,ye;if(h.readBool()){if(h.readBool()){var Ie=h.readUByte();switch(Ie){case 1:se=[1,1];break;case 2:se=[12,11];break;case 3:se=[10,11];break;case 4:se=[16,11];break;case 5:se=[40,33];break;case 6:se=[24,11];break;case 7:se=[20,11];break;case 8:se=[32,11];break;case 9:se=[80,33];break;case 10:se=[18,11];break;case 11:se=[15,11];break;case 12:se=[64,33];break;case 13:se=[160,99];break;case 14:se=[4,3];break;case 15:se=[3,2];break;case 16:se=[2,1];break;case 255:{se=[h.readUByte()<<8|h.readUByte(),h.readUByte()<<8|h.readUByte()];break}}}if(h.readBool()&&h.readBool(),h.readBool()&&(h.readBits(4),h.readBool()&&h.readBits(24)),h.readBool()&&(h.readUEG(),h.readUEG()),h.readBool()){var Ze=h.readBits(32),w=h.readBits(32);ce=h.readBool(),Me=w,We=Ze*2,ye=Me/We}}return{codec:Vo(o.subarray(1,4)),profileIdc:f,profileCompatibility:g,levelIdc:E,chromaFormat:_,width:Math.ceil(($+1)*16-2*(oe+ue)),height:(2-Z)*(ee+1)*16-(Z?2:4)*(Se+he),sarRatio:se,fpsNum:Me,fpsDen:We,fps:ye,fixedFrame:ce}}}]),v}();var Ko=function(){function v(){Ae(this,v)}return be(v,null,[{key:"parseHEVCDecoderConfigurationRecord",value:function(o){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!(o.length<23)){h=h||{};for(var f=(o[21]&3)+1,g,E,_=[],S=[],D=[],P=23,F=o[22],H,W,$,ee=0;ee<F;ee++){H=o[P]&63,W=o[P+1]<<8|o[P+2],P+=3;for(var Z=0;Z<W;Z++)if($=o[P]<<8|o[P+1],P+=2,!!$){switch(H){case 32:{var oe=o.subarray(P,P+$);g||(g=v.parseVPS(tr.removeEPB(oe),h)),D.push(oe)}break;case 33:{var ue=o.subarray(P,P+$);E||(E=v.parseSPS(tr.removeEPB(ue),h)),_.push(ue)}break;case 34:S.push(o.subarray(P,P+$));break}P+=$}}return{hvcC:h,sps:E,spsArr:_,ppsArr:S,vpsArr:D,nalUnitSize:f}}}},{key:"parseVPS",value:function(o,h){h=h||{};var f=new Qr(o);f.readUByte(),f.readUByte(),f.readBits(12);var g=f.readBits(3);return h.numTemporalLayers=Math.max(h.numTemporalLayers||0,g+1),f.readBits(17),v._parseProfileTierLevel(f,g,h),h}},{key:"parseSPS",value:function(o){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};h=h||{};var f=new Qr(o);f.readUByte(),f.readUByte(),f.readBits(4);var g=f.readBits(3);h.numTemporalLayers=Math.max(g+1,h.numTemporalLayers||0),h.temporalIdNested=f.readBits(1),v._parseProfileTierLevel(f,g,h),f.readUEG();var E=h.chromaFormatIdc=f.readUEG(),_=420;E<=3&&(_=[0,420,422,444][E]);var S=0;E===3&&(S=f.readBits(1));var D=f.readUEG(),P=f.readUEG(),F=f.readBits(1),H,W,$,ee;if(F===1&&(H=f.readUEG(),W=f.readUEG(),$=f.readUEG(),ee=f.readUEG()),h.bitDepthLumaMinus8=f.readUEG(),h.bitDepthChromaMinus8=f.readUEG(),F===1){var Z=(E===1||E===2)&&S===0?2:1,oe=E===1&&S===0?2:1;D-=Z*(W+H),P-=oe*(ee+$)}return{codec:"hev1.1.6.L93.B0",width:D,height:P,chromaFormat:_,hvcC:h}}},{key:"_parseProfileTierLevel",value:function(o,h,f){var g=f.generalTierFlag||0;f.generalProfileSpace=o.readBits(2),f.generalTierFlag=Math.max(o.readBits(1),g),f.generalProfileIdc=Math.max(o.readBits(5),f.generalProfileIdc||0),f.generalProfileCompatibilityFlags=o.readBits(32),f.generalConstraintIndicatorFlags=[o.readBits(8),o.readBits(8),o.readBits(8),o.readBits(8),o.readBits(8),o.readBits(8)];var E=o.readBits(8);g<f.generalTierFlag?f.generalLevelIdc=E:f.generalLevelIdc=Math.max(E,f.generalLevelIdc||0);var _=[],S=[];if(h>o.bitsAvailable)throw new Error("maxSubLayersMinus inavlid size ".concat(h));for(var D=0;D<h;D++)_[D]=o.readBits(1),S[D]=o.readBits(1);h>0&&o.readBits((8-h)*2);for(var P=0;P<h;P++)_[P]!==0&&(o.readBits(2),o.readBits(1),o.readBits(5),o.readBits(16),o.readBits(16),o.readBits(4),o.readBits(16),o.readBits(16),o.readBits(12)),S[P]!==0&&o.readBits(8)}}]),v}();var Bn=function(){function v(){Ae(this,v)}return be(v,null,[{key:"decode",value:function(o){for(var h=[],f=o,g=0,E=o.length;g<E;){if(f[g]<128){h.push(String.fromCharCode(f[g])),++g;continue}else if(!(f[g]<192)){if(f[g]<224){if(v._checkContinuation(f,g,1)){var _=(f[g]&31)<<6|f[g+1]&63;if(_>=128){h.push(String.fromCharCode(_&65535)),g+=2;continue}}}else if(f[g]<240){if(v._checkContinuation(f,g,2)){var S=(f[g]&15)<<12|(f[g+1]&63)<<6|f[g+2]&63;if(S>=2048&&(S&63488)!==55296){h.push(String.fromCharCode(S&65535)),g+=3;continue}}}else if(f[g]<248&&v._checkContinuation(f,g,3)){var D=(f[g]&7)<<18|(f[g+1]&63)<<12|(f[g+2]&63)<<6|f[g+3]&63;if(D>65536&&D<1114112){D-=65536,h.push(String.fromCharCode(D>>>10|55296)),h.push(String.fromCharCode(D&1023|56320)),g+=4;continue}}}h.push("\uFFFD"),++g}return h.join("")}},{key:"_checkContinuation",value:function(o,h,f){var g=o;if(h+f<g.length){for(;f--;)if((g[++h]&192)!==128)return!1;return!0}else return!1}}]),v}();var Wo=function(){function v(){Ae(this,v)}return be(v,null,[{key:"parse",value:function(o){if(!(o.length<3)){var h={},f=v._parseValue(new DataView(o.buffer,o.byteOffset,o.byteLength)),g=v._parseValue(new DataView(o.buffer,o.byteOffset+f.size,o.byteLength-f.size));return h[f.data]=g.data,h}}},{key:"_parseValue",value:function(o){var h=o.byteLength,f=o.getUint8(0),g=1,E=!1,_;switch(f){case 0:_=o.getFloat64(1),g+=8;break;case 1:{_=!!o.getUint8(1),g+=1;break}case 2:{var S=v._parseString(new DataView(o.buffer,o.byteOffset+g,o.byteLength-g)),D=S.data,P=S.size;_=D,g+=P}break;case 3:{_={};var F=0;for((o.getUint32(h-4)&16777215)===9&&(F=3);g<h-4;){var H=v._parseObject(new DataView(o.buffer,o.byteOffset+g,o.byteLength-g-F)),W=H.size,$=H.data,ee=H.isEnd;if(ee)break;_[$.name]=$.value,g+=W}if(g<=h-3){var Z=o.getUint32(g-1)&16777215;Z===9&&(g+=3)}}break;case 8:{_={},g+=4;var oe=0;for((o.getUint32(h-4)&16777215)===9&&(oe=3);g<h-8;){var ue=v._parseObject(new DataView(o.buffer,o.byteOffset+g,o.byteLength-g-oe)),Se=ue.size,he=ue.data,se=ue.isEnd;if(se)break;_[he.name]=he.value,g+=Se}if(g<=h-3){var ce=o.getUint32(g-1)&16777215;ce===9&&(g+=3)}}break;case 9:_=void 0,g=1,E=!0;break;case 10:{_=[];var Me=o.getUint32(1);g+=4;for(var We=0;We<Me;We++){var ye=v._parseValue(new DataView(o.buffer,o.byteOffset+g,o.byteLength-g)),Ie=ye.data,Ze=ye.size;_.push(Ie),g+=Ze}}break;case 11:{var w=o.getFloat64(g)+o.getInt16(g+8)*6e4;_=new Date(w),g+=10}break;case 12:{var U=o.getUint32(1);g+=4,_="",U>0&&(_=Bn.decode(new Uint8Array(o.buffer,o.byteOffset+g,U))),g+=U}break;default:g=h;break}return{data:_,size:g,isEnd:E}}},{key:"_parseString",value:function(o){var h=o.getUint16(0),f="";return h>0&&(f=Bn.decode(new Uint8Array(o.buffer,o.byteOffset+2,h))),{data:f,size:2+h}}},{key:"_parseObject",value:function(o){if(!(o.byteLength<3)){var h=v._parseString(o),f=v._parseValue(new DataView(o.buffer,o.byteOffset+h.size,o.byteLength-h.size));return{data:{name:h.data,value:f.data},size:h.size+f.size,isEnd:f.isEnd}}}}]),v}();var Kt={MP3:2,G711A:7,G711M:8,AAC:10,OPUS:13};var Wt=new pr("FlvDemuxer"),Pi=function(){function v(m,o,h){Ae(this,v),Q(this,"_headerParsed",!1),Q(this,"_remainingData",null),Q(this,"_gopId",0),Q(this,"_needAddMetaBeforeKeyFrameNal",!0),this.videoTrack=m||new Ro,this.audioTrack=o||new Co,this.metadataTrack=h||new Po,this._fixer=new Go(this.videoTrack,this.audioTrack,this.metadataTrack)}return be(v,[{key:"demux",value:function(o){var h,f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,g=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,E=arguments.length>3?arguments[3]:void 0,_=this.audioTrack,S=this.videoTrack,D=this.metadataTrack;if((f||!g)&&(this._remainingData=null),f&&(this._headerParsed=!1),f?(S.reset(),_.reset(),D.reset()):(S.samples=[],_.samples=[],D.seiSamples=[],D.flvScriptSamples=[],S.warnings=[],_.warnings=[],this._remainingData&&(o=kt(this._remainingData,o),this._remainingData=null)),!o.length)return{videoTrack:S,audioTrack:_,metadataTrack:D};var P=0;if(!this._headerParsed){if(!v.probe(o))throw new Error("Invalid flv file");_.present=(o[4]&4)>>>2!==0,S.present=(o[4]&1)!==0,this._headerParsed=!0,P=kr(o,5)+4}for(var F=o.length,H,W,$,ee,Z;P+15<F&&(H=o[P],W=o[P+1]<<16|o[P+2]<<8|o[P+3],!(P+15+W>F));)$=(o[P+7]<<24>>>0)+(o[P+4]<<16)+(o[P+5]<<8)+o[P+6],P+=11,ee=o.subarray(P,P+W),H===8?this._parseAudio(ee,$):H===9?(E&&(this.seamlessLoadingSwitching=!0),this._parseVideo(ee,$)):H===18?this._parseScript(ee,$):Wt.warn("Invalid tag type: ".concat(H)),P+=W,Z=kr(o,P),Z!==11+W&&Wt.warn("Invalid PrevTagSize ".concat(Z," (").concat(11+W,")")),P+=4;P<F&&(this._remainingData=o.subarray(P)),_.formatTimescale=S.formatTimescale=S.timescale=D.timescale=1e3,_.timescale=_.codecType===ze.OPUS?1e3:_.sampleRate||0,!_.exist()&&_.hasSample()&&_.reset(),!S.exist()&&S.hasSample()&&S.reset();var oe=D.flvScriptSamples[D.flvScriptSamples.length-1],ue=oe==null||(h=oe.data)===null||h===void 0?void 0:h.onMetaData;return ue&&(S!=null&&S.exist()&&(ue.hasOwnProperty("duration")&&(S.duration=ue.duration*1e3),ue.hasOwnProperty("width")&&ue.hasOwnProperty("height")&&(S.width=ue.width,S.height=ue.height)),_!=null&&_.exist()&&ue.hasOwnProperty("duration")&&(_.duration=ue.duration*1e3)),{videoTrack:S,audioTrack:_,metadataTrack:D}}},{key:"fix",value:function(o,h,f){return this._fixer.fix(o,h,f),{videoTrack:this.videoTrack,audioTrack:this.audioTrack,metadataTrack:this.metadataTrack}}},{key:"demuxAndFix",value:function(o,h,f,g,E){return this.demux(o,h,f,E),this.fix(g,h,f)}},{key:"_parseAudio",value:function(o,h){if(o.length){var f=(o[0]&240)>>>4,g=this.audioTrack;if(f!==Kt.AAC&&f!==Kt.G711A&&f!==Kt.G711M&&f!==Kt.OPUS){Wt.warn("Unsupported sound format: ".concat(f)),g.reset();return}if(f!==Kt.AAC&&f!==Kt.OPUS){var E=(o[0]&12)>>2,_=(o[0]&2)>>1,S=o[0]&1;g.sampleRate=v.AUDIO_RATE[E],g.sampleSize=_?16:8,g.channelCount=S+1}switch(f){case Kt.G711A:case Kt.G711M:this._parseG711(o,h,f);break;case Kt.AAC:this._parseAac(o,h);break;case Kt.OPUS:this._parseOpus(o,h);break}}}},{key:"_parseOpus",value:function(o,h){var f=this.audioTrack,g=o[1];switch(f.codecType=ze.OPUS,g){case 0:{var E=Xr.parseHeaderPackets(o.subarray(2));E?(f.codec=E.codec,f.channelCount=E.channelCount,f.sampleRate=E.sampleRate,f.config=E.config,f.sampleDuration=Xr.getFrameDuration([],f.timescale)):(f.reset(),Wt.warn("Cannot parse AudioSpecificConfig",o));break}case 1:{if(h==null)return;var _=new Rr(h,o.subarray(2),f.sampleDuration);f.samples.push(_);break}default:Wt.warn("Unknown OpusPacketType: ".concat(g))}}},{key:"_parseG711",value:function(o,h,f){var g=this.audioTrack,E=o.subarray(1);if(!(E.byteLength<1)){var _=new Rr(h,E);g.codecType=f===7?ze.G711PCMA:ze.G711PCMU,g.sampleRate=8e3,g.codec=g.codecType,g.samples.push(_)}}},{key:"_parseAac",value:function(o,h){var f=this.audioTrack;if(f.codecType=ze.AAC,o[1]===0){var g=Cr.parseAudioSpecificConfig(o.subarray(2));g?(f.codec=g.codec,f.channelCount=g.channelCount,f.sampleRate=g.sampleRate,f.config=g.config,f.objectType=g.objectType,f.sampleRateIndex=g.samplingFrequencyIndex):(f.reset(),Wt.warn("Cannot parse AudioSpecificConfig",o))}else if(o[1]===1){if(h==null)return;f.samples.push(new Rr(h,o.subarray(2)))}else Wt.warn("Unknown AACPacketType: ".concat(o[1]))}},{key:"_parseVideo",value:function(o,h){var f=this;if(!(o.length<6)){var g=(o[0]&240)>>>4,E=o[0]&15,_=this.videoTrack;if(E!==7&&E!==12){_.reset(),Wt.warn("Unsupported codecId: ".concat(E));return}var S=E===12;_.codecType=S?er.HEVC:er.AVC;var D=o[1],P=(o[2]<<16|o[3]<<8|o[4])<<8>>8;if(D===0){var F=o.subarray(5),H=S?Ko.parseHEVCDecoderConfigurationRecord(F):Ho.parseAVCDecoderConfigurationRecord(F);if(H){var W=H.hvcC,$=H.sps,ee=H.ppsArr,Z=H.spsArr,oe=H.vpsArr,ue=H.nalUnitSize;W&&(_.hvcC=_.hvcC||W),$&&(_.codec=$.codec,_.width=$.width,_.height=$.height,_.sarRatio=$.sarRatio,_.fpsNum=$.fpsNum,_.fpsDen=$.fpsDen),Z.length&&(_.sps=Z),ee.length&&(_.pps=ee),oe&&oe.length&&(_.vps=oe),ue&&(_.nalUnitSize=ue)}else Wt.warn("Cannot parse ".concat(S?"HEVC":"AVC","DecoderConfigurationRecord"),o)}else if(D===1){var Se=tr.parseAvcC(o.subarray(5),_.nalUnitSize);if(Se=this._checkAddMetaNalToUnits(S,Se,_),Se&&Se.length){var he=new ko(h+P,h,Se);if(this.seamlessLoadingSwitching&&h<_.lastKeyFrameDts)return;this.seamlessLoadingSwitching=!1,g===1&&(he.setToKeyframe(),_.lastKeyFrameDts=h),_.samples.push(he),Se.forEach(function(se){var ce=S?se[0]>>>1&63:se[0]&31;switch(ce){case 5:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:if(!S&&ce!==5||S&&ce===5)break;he.setToKeyframe();break;case 6:case 39:case 40:if(!S&&ce!==6||S&&ce===6)break;f.metadataTrack.seiSamples.push(new wo(tr.parseSEI(tr.removeEPB(se),S),h+P));break}}),he.keyframe&&this._gopId++,he.gopId=this._gopId}else Wt.warn("Cannot parse NALUs",o)}else D===2||Wt.warn("Unknown AVCPacketType: ".concat(D))}}},{key:"_checkAddMetaNalToUnits",value:function(o,h,f){if(!o||!this._needAddMetaBeforeKeyFrameNal)return this._needAddMetaBeforeKeyFrameNal=!1,h;var g=h.map(function(E){return E[0]>>>1&63});return g.includes(32)?(this._needAddMetaBeforeKeyFrameNal=!1,h):(h.unshift(f.pps[0]),h.unshift(f.sps[0]),h.unshift(f.vps[0]),h.filter(Boolean))}},{key:"_parseScript",value:function(o,h){this.metadataTrack.flvScriptSamples.push(new Io(Wo.parse(o),h))}}],[{key:"probe",value:function(o){return o[0]!==70||o[1]!==76||o[2]!==86||o[3]!==1?!1:kr(o,5)>=9}}]),v}();Q(Pi,"AUDIO_RATE",[5500,11e3,22e3,44e3]);function od(v){for(var m=0,o=arguments.length,h=new Array(o>1?o-1:0),f=1;f<o;f++)h[f-1]=arguments[f];h.forEach(function(_){m+=_.length});var g=new v(m),E=0;return h.forEach(function(_){g.set(_,E),E+=_.length}),g}var ft=function(){function v(){Ae(this,v),this.buffer=new Uint8Array(0)}return be(v,[{key:"write",value:function(){for(var o=this,h=arguments.length,f=new Array(h),g=0;g<h;g++)f[g]=arguments[g];f.forEach(function(E){E?o.buffer=od(Uint8Array,o.buffer,E):window.console.warn(E)})}}],[{key:"writeUint16",value:function(o){return new Uint8Array([o>>8&255,o&255])}},{key:"writeUint32",value:function(o){return new Uint8Array([o>>24,o>>16&255,o>>8&255,o&255])}}]),v}();var jo=Math.pow(2,32)-1,Le=function(){function v(){Ae(this,v)}return be(v,null,[{key:"box",value:function(o){for(var h=arguments.length,f=new Array(h>1?h-1:0),g=1;g<h;g++)f[g-1]=arguments[g];f=f.filter(Boolean);var E=8+f.reduce(function(D,P){return D+P.byteLength},0),_=new Uint8Array(E);_[0]=E>>24&255,_[1]=E>>16&255,_[2]=E>>8&255,_[3]=E&255,_.set(o,4);var S=8;return f.forEach(function(D){_.set(D,S),S+=D.byteLength}),_}},{key:"ftyp",value:function(o){var h=o.find(function(f){return f.type===Ht.VIDEO&&f.codecType===er.HEVC});return h?v.FTYPHEV1:v.FTYPAVC1}},{key:"initSegment",value:function(o){var h=v.ftyp(o),f=kt(h,v.moov(o));return f}},{key:"pssh",value:function(o){var h=new Uint8Array([1,0,0,0].concat([16,119,239,236,192,178,77,2,172,227,60,30,82,226,251,75],[0,0,0,1],Un(o.kid),[0,0,0,0]));return v.box(v.types.pssh,h)}},{key:"moov",value:function(o){if(o[0].useEME&&(o[0].encv||o[0].enca)){o[0].pssh||(o[0].pssh={kid:o[0].kid});var h=this.pssh(o[0].pssh);return v.box.apply(v,[v.types.moov,v.mvhd(o[0].mvhdDurtion||o[0].duration,o[0].mvhdTimecale||o[0].timescale),v.mvex(o)].concat(Vt(o.map(function(f){return v.trak(f)})),[h]))}else return v.box.apply(v,[v.types.moov,v.mvhd(o[0].mvhdDurtion||o[0].duration,o[0].mvhdTimecale||o[0].timescale)].concat(Vt(o.map(function(f){return v.trak(f)})),[v.mvex(o)]))}},{key:"mvhd",value:function(o){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:9e4,f=v.box(v.types.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,h>>24&255,h>>16&255,h>>8&255,h&255,o>>24&255,o>>16&255,o>>8&255,o&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 f}},{key:"trak",value:function(o){var h=v.box(v.types.trak,v.tkhd(o.id,o.tkhdDuration||0,o.width,o.height),v.mdia(o));return h}},{key:"tkhd",value:function(o,h){var f=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,g=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,E=v.box(v.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,o>>24&255,o>>16&255,o>>8&255,o&255,0,0,0,0,h>>24&255,h>>16&255,h>>8&255,h&255,0,0,0,0,0,0,0,0,0,0,0,0,1,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,f>>8&255,f&255,0,0,g>>8&255,g&255,0,0]));return E}},{key:"mdia",value:function(o){var h=v.box(v.types.mdia,v.mdhd(o.duration,o.timescale),v.hdlr(o.type),v.minf(o));return h}},{key:"mdhd",value:function(o){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:9e4,f=v.box(v.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,h>>24&255,h>>16&255,h>>8&255,h&255,o>>24&255,o>>16&255,o>>8&255,o&255,85,196,0,0]));return f}},{key:"hdlr",value:function(o){var h=v.box(v.types.hdlr,v.HDLR_TYPES[o]);return h}},{key:"minf",value:function(o){var h=v.box(v.types.minf,o.type===Ht.VIDEO?v.VMHD:v.SMHD,v.DINF,v.stbl(o));return h}},{key:"stbl",value:function(o){var h=[];o&&o.ext&&o.ext.stss&&h.push(v.stss(o.ext.stss.entries));var f=v.box(v.types.stbl,v.stsd(o),v.STTS,h[0],v.STSC,v.STSZ,v.STCO);return f}},{key:"stsd",value:function(o){var h;o.type==="audio"?o.useEME&&o.enca?h=v.enca(o):o.codecType===ze.OPUS?h=v.opus(o):h=v.mp4a(o):o.useEME&&o.encv?h=v.encv(o):o.av1C?h=v.av01(o):h=v.avc1hev1(o);var f=v.box(v.types.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),h);return f}},{key:"enca",value:function(o){var h=o.enca.channelCount,f=o.enca.sampleRate,g=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,h,0,16,0,0,0,0,f>>8&255,f&255,0,0]),E=v.esds(o.config),_=v.sinf(o.enca);return v.box(v.types.enca,g,E,_)}},{key:"encv",value:function(o){var h,f,g=o.sps.length>0?o.sps[0]:[],E=o.pps.length>0?o.pps[0]:[],_=o.width,S=o.height,D=o.sarRatio[0],P=o.sarRatio[1],F=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,_>>8&255,_&255,S>>8&255,S&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]),H=new Uint8Array((h=(f=[1,g[1],g[2],g[3],255,225,g.length>>>8&255,g.length&255]).concat.apply(f,Vt(g)).concat([1,E.length>>>8&255,E.length&255])).concat.apply(h,Vt(E))),W=new Uint8Array([0,0,88,57,0,15,200,192,0,4,86,72]),$=v.sinf(o.encv),ee=new Uint8Array([D>>24,D>>16&255,D>>8&255,D&255,P>>24,P>>16&255,P>>8&255,P&255]);return v.box(v.types.encv,F,v.box(v.types.avcC,H),v.box(v.types.btrt,W),$,v.box(v.types.pasp,ee))}},{key:"schi",value:function(o){var h=new Uint8Array([]),f=v.tenc(o);return v.box(v.types.schi,h,f)}},{key:"tenc",value:function(o){var h=new Uint8Array([0,0,0,0,0,0,o.default_IsEncrypted&255,o.default_IV_size&255].concat(Un(o.default_KID)));return v.box(v.types.tenc,h)}},{key:"sinf",value:function(o){var h=new Uint8Array([]),f=new Uint8Array([o.data_format.charCodeAt(0),o.data_format.charCodeAt(1),o.data_format.charCodeAt(2),o.data_format.charCodeAt(3)]),g=new Uint8Array([0,0,0,0,99,101,110,99,0,1,0,0]),E=v.schi(o);return v.box(v.types.sinf,h,v.box(v.types.frma,f),v.box(v.types.schm,g),E)}},{key:"av01",value:function(o){return v.box(v.types.av01,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,o.width>>8&255,o.width&255,o.height>>8&255,o.height&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,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,0,0,0,0,0,0,24,17,17]),o.av1C,o.colr)}},{key:"avc1hev1",value:function(o){var h=o.codecType===er.HEVC,f=h?v.types.hvc1:v.types.avc1,g=h?v.hvcC(o):v.avcC(o),E=[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,o.width>>8&255,o.width&255,o.height>>8&255,o.height&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,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,0,0,0,0,0,0,24,17,17]),g];return h?E.push(v.box(v.types.fiel,new Uint8Array([1,0]))):o.sarRatio&&o.sarRatio.length>1&&E.push(v.pasp(o.sarRatio)),v.box.apply(v,[f].concat(E))}},{key:"avcC",value:function(o){var h,f,g=[],E=[],_;return o.sps.forEach(function(S){_=S.byteLength,g.push(_>>>8&255),g.push(_&255),g.push.apply(g,Vt(S))}),o.pps.forEach(function(S){_=S.byteLength,E.push(_>>>8&255),E.push(_&255),E.push.apply(E,Vt(S))}),v.box(v.types.avcC,new Uint8Array((h=(f=[1,g[3],g[4],g[5],255,224|o.sps.length]).concat.apply(f,g).concat([o.pps.length])).concat.apply(h,E)))}},{key:"hvcC",value:function(o){var h=o.hvcC;if(h instanceof ArrayBuffer||h instanceof Uint8Array)return h;var f=o.vps,g=o.sps,E=o.pps,_;if(h){var S=h.generalProfileCompatibilityFlags,D=h.generalConstraintIndicatorFlags,P=(f.length&&1)+(g.length&&1)+(E.length&&1);_=[1,h.generalProfileSpace<<6|h.generalTierFlag<<5|h.generalProfileIdc,S>>>24,S>>>16,S>>>8,S,D[0],D[1],D[2],D[3],D[4],D[5],h.generalLevelIdc,240,0,252,h.chromaFormatIdc|252,h.bitDepthLumaMinus8|248,h.bitDepthChromaMinus8|248,0,0,h.numTemporalLayers<<3|h.temporalIdNested<<2|3,P];var F=function(W){var $;_.push(W.length>>8,W.length),($=_).push.apply($,Vt(W))};f.length&&(_.push(160,0,f.length),f.forEach(F)),g.length&&(_.push(161,0,g.length),g.forEach(F)),E.length&&(_.push(162,0,E.length),E.forEach(F))}else _=[1,1,96,0,0,0,144,0,0,0,0,0,93,240,0,252,253,248,248,0,0,15,3,160,0,1,0,24,64,1,12,1,255,255,1,96,0,0,3,0,144,0,0,3,0,0,3,0,93,153,152,9,161,0,1,0,45,66,1,1,1,96,0,0,3,0,144,0,0,3,0,0,3,0,93,160,2,128,128,45,22,89,153,164,147,43,154,128,128,128,130,0,0,3,0,2,0,0,3,0,50,16,162,0,1,0,7,68,1,193,114,180,98,64];return v.box(v.types.hvcC,new Uint8Array(_))}},{key:"pasp",value:function(o){var h=bo(o,2),f=h[0],g=h[1];return v.box(v.types.pasp,new Uint8Array([f>>24,f>>16&255,f>>8&255,f&255,g>>24,g>>16&255,g>>8&255,g&255]))}},{key:"mp4a",value:function(o){return v.box(v.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,o.channelCount,0,16,0,0,0,0,o.sampleRate>>8&255,o.sampleRate&255,0,0]),o.config.length?v.esds(o.config):void 0)}},{key:"esds",value:function(o){var h=o.length,f=v.box(v.types.esds,new Uint8Array([0,0,0,0,3,23+h,0,0,0,4,15+h,64,21,0,6,0,0,0,218,192,0,0,218,192,5].concat([h]).concat(o).concat([6,1,2])));return f}},{key:"opus",value:function(o){var h=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,o.channelCount,0,16,0,0,0,0,o.sampleRate>>8&255,o.sampleRate&255,0,0]),f=o.config.length?v.dOps(o):[];return v.box(v.types.Opus,h,f)}},{key:"dOps",value:function(o){if(o.config)return o.config[4]=o.sampleRate>>>24&255,o.config[5]=o.sampleRate>>>16&255,o.config[6]=o.sampleRate>>>8&255,o.config[7]=o.sampleRate&255,v.box(v.types.dOps,o.config)}},{key:"mvex",value:function(o){var h=v.box.apply(v,[v.types.mvex].concat(Vt(o.map(function(f){return v.trex(f.id)}))));return h}},{key:"trex",value:function(o){var h=v.box(v.types.trex,new Uint8Array([0,0,0,0,o>>24,o>>16&255,o>>8&255,o&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]));return h}},{key:"trex1",value:function(o){var h=v.box(v.types.trex,new Uint8Array([0,0,0,0,o>>24,o>>16&255,o>>8&255,o&255,0,0,0,1,0,0,2,0,0,0,0,0,0,1,0,0]));return h}},{key:"trex2",value:function(o){var h=v.box(v.types.trex,new Uint8Array([0,0,0,0,o>>24,o>>16&255,o>>8&255,o&255,0,0,0,1,0,0,4,0,0,0,0,0,2,0,0,0]));return h}},{key:"moof",value:function(o){var h=v.box.apply(v,[v.types.moof,v.mfhd(o[0].samples?o[0].samples[0].gopId:0)].concat(Vt(o.map(function(f){return v.traf(f)}))));return h}},{key:"mfhd",value:function(o){var h=v.box(v.types.mfhd,new Uint8Array([0,0,0,0,o>>24,o>>16&255,o>>8&255,o&255]));return h}},{key:"traf",value:function(o){var h=v.tfhd(o.id),f=v.tfdt(o,o.baseMediaDecodeTime),g=0,E;if(o.isVideo&&o.videoSenc&&(E=o.videoSenc,E.forEach(function(U){g=g+8,U.subsamples&&U.subsamples.length&&(g=g+2,g=g+U.subsamples.length*6)})),o.videoSencLength=g,!o.useEME||!o.isVideoEncryption&&!o.isAudioEncryption){var _=v.sdtp(o),S=76;return v.box(v.types.traf,h,f,_,v.trun(o.samples,_.byteLength+S))}else if(o.isVideoEncryption)if(o.isVideo){var D=v.saiz(o),P=v.saio(o),F=v.trun1(o),H=v.senc(o),W=v.box(v.types.traf,h,f,D,P,F,H);return W}else if(o.isAudioEncryption){var Z=v.sbgp(),oe=v.saiz(o),ue=v.saio(o),Se=v.senc(o),he=v.trun1(o),se=v.box(v.types.traf,h,f,Z,oe,ue,Se,he);return se}else{var $=v.sbgp(),ee=v.trun1(o);return v.box(v.types.traf,h,f,$,ee)}else if(o.isVideo){var ce=v.trun1(o);return v.box(v.types.traf,h,f,ce)}else{var Me=v.sbgp(),We=v.saiz(o),ye=v.saio(o),Ie=v.senc(o),Ze=v.trun1(o),w=v.box(v.types.traf,h,f,Me,We,ye,Ie,Ze);return w}}},{key:"sdtp",value:function(o){var h=new ft;return o.samples.forEach(function(f){h.write(new Uint8Array(o.isVideo?[f.keyframe?32:16]:[16]))}),v.box(v.types.sdtp,this.extension(0,0),h.buffer)}},{key:"trun1",value:function(o){var h=new ft,f=ft.writeUint32(o.samples.length),g=null;if(o.isVideo){var E=o.videoSencLength;g=ft.writeUint32(o.samples.length*16+E+149),!o.isVideoEncryption&&o.isAudioEncryption&&(g=ft.writeUint32(o.samples.length*16+92))}else{var _=o.samples.length*12+124;o.isAudioEncryption&&(_=o.samples.length*12+8*o.audioSenc.length+177),g=ft.writeUint32(_)}return o.samples.forEach(function(S){h.write(ft.writeUint32(S.duration)),h.write(ft.writeUint32(S.size)),h.write(ft.writeUint32(S.keyframe?33554432:65536)),o.isVideo&&h.write(ft.writeUint32(S.cts?S.cts:0))}),v.box(v.types.trun,this.extension(0,o.flags),f,g,h.buffer)}},{key:"senc",value:function(o){var h=new ft,f=o.samples.length,g=o.isVideo?16:8,E=o.isVideo?2:0,_=[],S=0;return o.isVideo?(_=o.videoSenc,S=o.videoSencLength):_=o.audioSenc,S=S||g*f,h.write(ft.writeUint32(16+S),v.types.senc,this.extension(0,E)),h.write(ft.writeUint32(f)),_.forEach(function(D){for(var P=0;P<D.InitializationVector.length;P++)h.write(new Uint8Array([D.InitializationVector[P]]));D.subsamples&&D.subsamples.length&&(h.write(ft.writeUint16(D.subsamples.length)),D.subsamples.forEach(function(F){h.write(ft.writeUint16(F.BytesOfClearData)),h.write(ft.writeUint32(F.BytesOfProtectedData))}))}),h.buffer}},{key:"saio",value:function(o){var h=o.samples.length*12+141;!o.isVideo&&o.isAudioEncryption&&(h=149);var f=new Uint8Array([1,0,0,0,0,0,0,1,0,0,0,0,h>>24&255,h>>16&255,h>>8&255,h&255]);return v.box(v.types.saio,f)}},{key:"saiz",value:function(o){var h=o.samples.length,f=new Uint8Array([0,0,0,0,16,h>>24&255,h>>16&255,h>>8&255,h&255]);return v.box(v.types.saiz,f)}},{key:"sbgp",value:function(){var o=new Uint8Array([114,111,108,108,0,0,0,1,0,0,1,25,0,0,0,1]);return v.box(v.types.sbgp,this.extension(0,0),o)}},{key:"extension",value:function(o,h){return new Uint8Array([o,h>>16&255,h>>8&255,h&255])}},{key:"tfhd",value:function(o){return v.box(v.types.tfhd,new Uint8Array([0,0,0,0,o>>24,o>>16&255,o>>8&255,o&255]))}},{key:"tfdt",value:function(o,h){var f=Math.floor(h/(jo+1)),g=Math.floor(h%(jo+1));return o.useEME&&(o.isVideoEncryption||o.isAudioEncryption)?v.box(v.types.tfdt,new Uint8Array([0,0,0,0,g>>24,g>>16&255,g>>8&255,g&255])):v.box(v.types.tfdt,new Uint8Array([1,0,0,0,f>>24,f>>16&255,f>>8&255,f&255,g>>24,g>>16&255,g>>8&255,g&255]))}},{key:"trun",value:function(o,h){var f=o.length,g=12+16*f;h+=8+g;var E=new Uint8Array(g);E.set([0,0,15,1,f>>>24&255,f>>>16&255,f>>>8&255,f&255,h>>>24&255,h>>>16&255,h>>>8&255,h&255],0);for(var _=0;_<f;_++){var S=o[_],D=S.duration,P=S.size,F=S.flag,H=F===void 0?{}:F,W=S.cts,$=W===void 0?0:W;E.set([D>>>24&255,D>>>16&255,D>>>8&255,D&255,P>>>24&255,P>>>16&255,P>>>8&255,P&255,H.isLeading<<2|(H.dependsOn===null||H.dependsOn===void 0?1:H.dependsOn),H.isDependedOn<<6|H.hasRedundancy<<4|H.paddingValue<<1|(H.isNonSyncSample===null||H.isNonSyncSample===void 0?1:H.isNonSyncSample),H.degradationPriority&61440,H.degradationPriority&15,$>>>24&255,$>>>16&255,$>>>8&255,$&255],12+16*_)}return v.box(v.types.trun,E)}},{key:"moovMP4",value:function(o){return v.box.apply(v,[v.types.moov,v.mvhd(o[0].duration,o[0].timescale)].concat(Vt(o.map(function(h){return v.trackMP4(h)}))))}},{key:"trackMP4",value:function(o){return v.box(v.types.trak,v.tkhd(o.id,o.duration,o.width,o.height),v.mdiaMP4(o))}},{key:"mdiaMP4",value:function(o){return v.box(v.types.mdia,v.mdhd(o.duration,o.timescale),v.hdlr(o.type),v.minfMP4(o))}},{key:"minfMP4",value:function(o){return v.box(v.types.minf,o.type===Ht.VIDEO?v.VMHD:v.SMHD,v.DINF,v.stblMP4(o))}},{key:"stblMP4",value:function(o){var h=o.ext,f=[v.stsd(o),v.stts(h.stts),v.stsc(h.stsc),v.stsz(h.stsz),v.stco(h.stco)];return h.stss.length&&f.push(v.stss(h.stss)),h.ctts.length&&f.push(v.ctts(h.ctts)),v.box.apply(v,[v.types.stbl].concat(f))}},{key:"stts",value:function(o){var h=o.length,f=new Uint8Array(8*h),g=0;return o.forEach(function(E){var _=E.value,S=E.count;f.set([S>>24,S>>16&255,S>>8&255,S&255,_>>24,_>>16&255,_>>8&255,_&255],g),g+=8}),v.box(v.types.stts,kt(new Uint8Array([0,0,0,0,h>>24,h>>16&255,h>>8&255,h&255]),f))}},{key:"stsc",value:function(o){var h=o.length,f=new Uint8Array(12*h),g=0;return o.forEach(function(E){var _=E.firstChunk,S=E.samplesPerChunk,D=E.sampleDescIndex;f.set([_>>24,_>>16&255,_>>8&255,_&255,S>>24,S>>16&255,S>>8&255,S&255,D>>24,D>>16&255,D>>8&255,D&255],g),g+=12}),v.box(v.types.stsc,kt(new Uint8Array([0,0,0,0,h>>24,h>>16&255,h>>8&255,h&255]),f))}},{key:"stsz",value:function(o){var h=o.length,f=new Uint8Array(4*h),g=0;return o.forEach(function(E){f.set([E>>24,E>>16&255,E>>8&255,E&255],g),g+=4}),v.box(v.types.stsz,kt(new Uint8Array([0,0,0,0,0,0,0,0,h>>24,h>>16&255,h>>8&255,h&255]),f))}},{key:"stco",value:function(o){var h=o.length,f=new Uint8Array(4*h),g=0;return o.forEach(function(E){f.set([E>>24,E>>16&255,E>>8&255,E&255],g),g+=4}),v.box(v.types.stco,kt(new Uint8Array([0,0,0,0,h>>24,h>>16&255,h>>8&255,h&255]),f))}},{key:"stss",value:function(o){var h=o.length,f=new Uint8Array(4*h),g=0;return o.forEach(function(E){f.set([E>>24,E>>16&255,E>>8&255,E&255],g),g+=4}),v.box(v.types.stss,kt(new Uint8Array([0,0,0,0,h>>24,h>>16&255,h>>8&255,h&255]),f))}},{key:"ctts",value:function(o){var h=o.length,f=new Uint8Array(8*h),g=0;return o.forEach(function(E){var _=E.value,S=E.count;f.set([S>>24,S>>16&255,S>>8&255,S&255,_>>24,_>>16&255,_>>8&255,_&255],g),g+=8}),v.box(v.types.ctts,kt(new Uint8Array([0,0,0,0,h>>24,h>>16&255,h>>8&255,h&255]),f))}},{key:"styp",value:function(){return v.box(v.types.styp,new Uint8Array([109,115,100,104,0,0,0,0,109,115,100,104,109,115,105,120]))}},{key:"sidx",value:function(o){var h=o.timescale,f=o.samples[0].duration,g=f*o.samples.length,E=o.samples[0].sampleOffset*f,_=8;o.samples.forEach(function(H){_+=H.size});var S=0;if(o.isVideo){var D=0,P;o.videoSenc&&(P=o.videoSenc),o.isVideo&&P.forEach(function(H){D=D+8,H.subsamples&&H.subsamples.length&&(D=D+2,D=D+H.subsamples.length*6)}),o.videoSencLength=D,S=_+141+o.samples.length*16+D,o.useEME&&o.isAudioEncryption&&!o.isVideoEncryption&&(S=_+o.samples.length*16+84)}else S=_+116+o.samples.length*12,o.useEME&&o.isAudioEncryption&&(S=_+169+o.samples.length*12+8*o.audioSenc.length);var F=new Uint8Array([0,0,0,0,0,0,0,o.id&255,h>>24&255,h>>16&255,h>>8&255,h&255,E>>24&255,E>>16&255,E>>8&255,E&255,0,0,0,0,0,0,0,1,0,S>>16&255,S>>8&255,S&255,g>>24&255,g>>16&255,g>>8&255,g&255,144,0,0,0]);return v.box(v.types.sidx,F)}},{key:"mdat",value:function(o){var h=v.box(v.types.mdat,o);return h}}]),v}();Q(Le,"types",["Opus","dOps","av01","av1C","avc1","avcC","hvc1","hvcC","dinf","dref","esds","ftyp","hdlr","mdat","mdhd","mdia","mfhd","minf","moof","moov","mp4a","mvex","mvhd","pasp","stbl","stco","stsc","stsd","stsz","stts","tfdt","tfhd","traf","trak","trex","tkhd","vmhd","smhd","ctts","stss","styp","pssh","sidx","sbgp","saiz","saio","senc","trun","encv","enca","sinf","btrt","frma","tenc","schm","schi","mehd","fiel","sdtp"].reduce(function(v,m){return v[m]=[m.charCodeAt(0),m.charCodeAt(1),m.charCodeAt(2),m.charCodeAt(3)],v},Object.create(null)));Q(Le,"HDLR_TYPES",{video: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]),audio: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(Le,"FTYPAVC1",Le.box(Le.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49])));Q(Le,"FTYPHEV1",Le.box(Le.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,104,101,118,49])));Q(Le,"DINF",Le.box(Le.types.dinf,Le.box(Le.types.dref,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]))));Q(Le,"VMHD",Le.box(Le.types.vmhd,new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])));Q(Le,"SMHD",Le.box(Le.types.smhd,new Uint8Array([0,0,0,0,0,0,0,0])));Q(Le,"StblTable",new Uint8Array([0,0,0,0,0,0,0,0]));Q(Le,"STTS",Le.box(Le.types.stts,Le.StblTable));Q(Le,"STSC",Le.box(Le.types.stsc,Le.StblTable));Q(Le,"STSZ",Le.box(Le.types.stsz,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0])));Q(Le,"STCO",Le.box(Le.types.stco,Le.StblTable));var Gn=function(){function v(m,o){Ae(this,v),this.name=m||"",this._prefix="[".concat(this.name,"]"),v.disabled=o}return be(v,[{key:"debug",value:function(){var o;if(!v.disabled){for(var h=arguments.length,f=new Array(h),g=0;g<h;g++)f[g]=arguments[g];(o=console).debug.apply(o,[this._prefix].concat(f))}}},{key:"log",value:function(){var o;if(!v.disabled){for(var h=arguments.length,f=new Array(h),g=0;g<h;g++)f[g]=arguments[g];(o=console).log.apply(o,[this._prefix].concat(f))}}},{key:"warn",value:function(){var o;if(!v.disabled){for(var h=arguments.length,f=new Array(h),g=0;g<h;g++)f[g]=arguments[g];(o=console).warn.apply(o,[this._prefix].concat(f))}}},{key:"error",value:function(){var o;if(!v.disabled){for(var h=arguments.length,f=new Array(h),g=0;g<h;g++)f[g]=arguments[g];(o=console).error.apply(o,[this._prefix].concat(f))}}},{key:"table",value:function(){var o;v.disabled||(console.group(this._prefix),(o=console).table.apply(o,arguments),console.groupEnd())}}],[{key:"enable",value:function(){v.disabled=!1}},{key:"disable",value:function(){v.disabled=!0}}]),v}();Q(Gn,"disabled",!0);var Vn=function(){function v(m,o,h){Ae(this,v),this.videoTrack=m,this.audioTrack=o;var f=/Chrome\/([^.]+)/.exec(navigator.userAgent);this.forceFirstIDR=f&&Number(f[1])<50,this.log=new Gn("FMP4Remuxer",h&&h.openLog?!h.openLog:!0)}return be(v,[{key:"remux",value:function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},f=this.videoTrack,g=this.audioTrack,E=f.exist(),_=g.exist(),S,D,P,F=[];o&&(h&&h.initMerge?(E&&F.push(this.videoTrack),_&&F.push(this.audioTrack),P=Le.initSegment(F)):(E&&(S=Le.initSegment([this.videoTrack])),_&&(D=Le.initSegment([this.audioTrack]))));var H,W;return E&&f.hasSample()&&(H=this._remuxVideo()),_&&g.hasSample()&&(W=this._remuxAudio()),f.samples=[],g.samples=[],{initSegment:P,videoInitSegment:S,audioInitSegment:D,videoSegment:H,audioSegment:W}}},{key:"_remuxVideo",value:function(){var o=this.videoTrack;this.forceFirstIDR&&(o.samples[0].flag={dependsOn:2,isNonSyncSample:0});var h=o.samples,f=/av01/.test(o.codec),g=0;f?h.forEach(function(Se){g+=Se.data.byteLength}):h.forEach(function(Se){g+=Se.units.reduce(function(he,se){return he+se.byteLength},0),g+=Se.units.length*4});var E=new Uint8Array(g);if(f)for(var _=0,S=h.length,D=0,P;_<S;_++)P=h[_],E.set(P.data,D),P.size=P.data.byteLength,D+=P.size;else for(var F=new DataView(E.buffer),H=function(he,se){se=h[W];var ce=0;se.units.forEach(function(Me){F.setUint32(he,Me.byteLength),he+=4,E.set(Me,he),he+=Me.byteLength,ce+=4+Me.byteLength}),se.size=ce,ee=he,Z=se},W=0,$=h.length,ee=0,Z;W<$;W++)H(ee,Z);var oe=Le.mdat(E),ue=Le.moof([o]);return kt(ue,oe)}},{key:"_remuxAudio",value:function(){var o=this.audioTrack,h=new Uint8Array(o.samples.reduce(function(E,_){return E+_.size},0));o.samples.reduce(function(E,_){return h.set(_.data,E),E+_.size},0);var f=Le.mdat(h),g=Le.moof([o]);return kt(g,f)}},{key:"reset",value:function(){this.videoTrack.reset(),this.audioTrack.reset()}}]),v}();var Yo=function(){function v(){br(this,v),me(this,"_ttfb",0),me(this,"_demuxStart",0),me(this,"_demuxEnd",0),me(this,"_demuxCost",0),me(this,"_remuxStart",0),me(this,"_remuxEnd",0),me(this,"_remuxCost",0),me(this,"_appendStart",0),me(this,"_appendEnd",0),me(this,"_appendCost",0)}return Lr(v,[{key:"set",value:function(o,h){this["_".concat(o)]=h}},{key:"start",value:function(o){this["_".concat(o,"Start")]=Date.now()}},{key:"end",value:function(o){this["_".concat(o,"End")]=Date.now(),this["_".concat(o,"Cost")]=this["_".concat(o,"Cost")]+(this["_".concat(o,"End")]-this["_".concat(o,"Start")])}},{key:"transferCost",get:function(){return{ttfbCost:this._ttfb,demuxCost:this._demuxCost,remuxCost:this._remuxCost,appendCost:this._appendCost}}}]),v}(),rr={TTFB:"ttfb",DEMUX:"demux",REMUX:"remux",APPEND:"append"};var ir=new Ct("BufferService"),zo=function(){function v(m,o){var h=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};br(this,v),me(this,"flv",null),me(this,"_demuxer",new Pi),me(this,"_remuxer",null),me(this,"_mse",null),me(this,"_softVideo",null),me(this,"_sourceCreated",!1),me(this,"_needInitSegment",!0),me(this,"_discontinuity",!0),me(this,"_contiguous",!1),me(this,"_initSegmentId",""),me(this,"_cachedBuffer",null),me(this,"_demuxStartTime",0),me(this,"_opts",null),this.flv=m,this._opts=h,o?this._softVideo=o:(this._remuxer=new Vn(this._demuxer.videoTrack,this._demuxer.audioTrack),this._mse=new fr(null,{preferMMS:typeof h.preferMMS=="boolean"?h.preferMMS:!!h.perferMMS}),this._mse.bindMedia(m.media))}return Lr(v,[{key:"baseDts",get:function(){var o,h;return(o=this._demuxer)===null||o===void 0||(h=o._fixer)===null||h===void 0?void 0:h._baseDts}},{key:"blobUrl",get:function(){var o;return(o=this._mse)===null||o===void 0?void 0:o.url}},{key:"isFull",value:function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:fr.VIDEO;return this._mse.isFull(o)}},{key:"seamlessSwitch",value:function(){this._needInitSegment=!0,this._discontinuity=!0,this._contiguous=!0,this._initSegmentId=""}},{key:"unContiguous",value:function(o){this._contiguous=!1,this._demuxStartTime=o}},{key:"reset",value:function(){var m=at(ke().mark(function h(){var f,g=arguments;return ke().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:if(f=g.length>0&&g[0]!==void 0?g[0]:!1,!(this._mse&&!f)){_.next=6;break}return _.next=4,this._mse.unbindMedia();case 4:return _.next=6,this._mse.bindMedia(this.flv.media);case 6:this._needInitSegment=!0,this._discontinuity=!0,this._contiguous=!1,this._sourceCreated=!1,this._initSegmentId="",this.resetSeamlessSwitchStats();case 12:case"end":return _.stop()}},h,this)}));function o(){return m.apply(this,arguments)}return o}()},{key:"resetSeamlessSwitchStats",value:function(){this.seamlessLoadingSwitch=null,this.seamlessLoadingSwitching=!1,this._demuxer&&(this._demuxer.seamlessLoadingSwitching=!1)}},{key:"endOfStream",value:function(){var m=at(ke().mark(function h(){return ke().wrap(function(g){for(;;)switch(g.prev=g.next){case 0:if(!this._mse){g.next=7;break}if(!this._sourceCreated){g.next=5;break}return g.next=4,this._mse.endOfStream();case 4:this.flv.emit(_e.BUFFEREOS);case 5:g.next=8;break;case 7:this._softVideo&&this._softVideo.endOfStream();case 8:case"end":return g.stop()}},h,this)}));function o(){return m.apply(this,arguments)}return o}()},{key:"updateDuration",value:function(){var m=at(ke().mark(function h(f){return ke().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:if(!this._mse){E.next=7;break}if(this._mse.isOpened){E.next=4;break}return E.next=4,this._mse.open();case 4:return ir.debug("update duration",f),E.next=7,this._mse.updateDuration(f);case 7:case"end":return E.stop()}},h,this)}));function o(h){return m.apply(this,arguments)}return o}()},{key:"destroy",value:function(){var m=at(ke().mark(function h(){return ke().wrap(function(g){for(;;)switch(g.prev=g.next){case 0:if(!this._mse){g.next=3;break}return g.next=3,this._mse.unbindMedia();case 3:this._mse=null,this._softVideo=null,this._demuxer=null,this._remuxer=null;case 7:case"end":return g.stop()}},h,this)}));function o(){return m.apply(this,arguments)}return o}()},{key:"appendBuffer",value:function(){var m=at(ke().mark(function h(f){var g=this,E,_,S,D,P,F,H,W,$,ee,Z,oe,ue,Se,he,se,ce,Me;return ke().wrap(function(ye){for(;;)switch(ye.prev=ye.next){case 0:if(E=!1,this._cachedBuffer&&(f=bn(this._cachedBuffer,f),this._cachedBuffer=null),_=this._demuxer,!(!f||!f.length||!_)){ye.next=5;break}return ye.abrupt("return");case 5:ye.prev=5,this.flv._transferCost.start(rr.DEMUX),_.demuxAndFix(f,this.seamlessLoadingSwitching||this._discontinuity,this._contiguous,this._demuxStartTime,this.seamlessLoadingSwitching),this.seamlessLoadingSwitching=!1,this.flv._transferCost.end(rr.DEMUX),ye.next=15;break;case 12:throw ye.prev=12,ye.t0=ye.catch(5),new pt(De.DEMUX,De.SUB_TYPES.FLV,ye.t0);case 15:if(S=_.videoTrack,D=_.audioTrack,P=_.metadataTrack,!this.seamlessLoadingSwitch){ye.next=25;break}if(F=S.samples.findIndex(function(Ie){return Ie.originDts===S.lastKeyFrameDts}),!(F>=0)){ye.next=25;break}return S.samples.splice(F),ye.next=22,this.seamlessLoadingSwitch();case 22:this.seamlessLoadingSwitch=null,f=null,E=!0;case 25:if(H=S.exist(),W=D.exist(),this._opts.onlyAudio&&(H=!1,S.present=!1),this._opts.onlyVideo&&(W=!1,D.present=!1),!(!H&&S.present||!W&&D.present)){ye.next=42;break}if($=0,ee=H?S:W?D:void 0,ee&&ee.samples.length&&($=(ee.samples[ee.samples.length-1].originPts-ee.samples[0].originPts)/ee.timescale*1e3),!($>this._opts.analyzeDuration)){ye.next=40;break}ir.warn("analyze duration exceeded, ".concat($,"ms"),ee),S.present=H,D.present=W,this.flv.emit(_e.ANALYZE_DURATION_EXCEEDED,{duration:$}),ye.next=42;break;case 40:return this._cachedBuffer=f,ye.abrupt("return");case 42:if(Z=S.type,oe=D.type,this._fireEvents(S,D,P),E||(this._discontinuity=!1,this._contiguous=!0,this._demuxStartTime=0),ue=this._mse,Se=function(){var Ze;if((Ze=g.flv)!==null&&Ze!==void 0&&Ze.emit){var w;(w=g.flv)===null||w===void 0||w.emit(_e.APPEND_BUFFER,{})}},this.flv.emit(_e.DEMUXED_TRACK,{videoTrack:S}),he="".concat(S.codec,"/").concat(S.width,"/").concat(S.height,"/").concat(D.codec,"/").concat(D.config),he!==this._initSegmentId&&(this._needInitSegment=!0,this._initSegmentId=he,this._emitMetaParsedEvent(S,D)),!ue){ye.next=83;break}if(this._sourceCreated){ye.next=59;break}return ye.next=55,ue.open();case 55:H&&(ir.log("codec: video/mp4;codecs=".concat(S.codec)),ue.createSource(Z,"video/mp4;codecs=".concat(S.codec))),W&&(ir.log("codec: audio/mp4;codecs=".concat(D.codec)),ue.createSource(oe,"audio/mp4;codecs=".concat(D.codec))),this._sourceCreated=!0,this.flv.emit(_e.SOURCEBUFFER_CREATED);case 59:ye.prev=59,this._needInitSegment&&!this._opts.mseLowLatency&&(S.duration=this._opts.durationForMSELowLatencyOff*S.timescale,D.duration=this._opts.durationForMSELowLatencyOff*W.timescale),this.flv._transferCost.start(rr.REMUX),se=this._remuxer.remux(this._needInitSegment),this.flv._transferCost.end(rr.REMUX),ye.next=69;break;case 66:throw ye.prev=66,ye.t1=ye.catch(59),new pt(De.REMUX,De.SUB_TYPES.FMP4,ye.t1);case 69:if(!(this._needInitSegment&&!se.videoInitSegment&&!se.audioInitSegment)){ye.next=71;break}return ye.abrupt("return");case 71:return this._needInitSegment=!1,ce=[],se.videoInitSegment&&ce.push(ue.append(Z,se.videoInitSegment)),se.audioInitSegment&&ce.push(ue.append(oe,se.audioInitSegment)),se.videoSegment&&ce.push(ue.append(Z,se.videoSegment)),se.audioSegment&&ce.push(ue.append(oe,se.audioSegment)),this.flv._transferCost.start(rr.APPEND),Me=Promise.all(ce),Me.then(Se).then(function(){g.flv._transferCost.end(rr.APPEND),Se()}),ye.abrupt("return",Me);case 83:this._softVideo&&(this._softVideo.appendBuffer(S,D),Se());case 84:case"end":return ye.stop()}},h,this,[[5,12],[59,66]])}));function o(h){return m.apply(this,arguments)}return o}()},{key:"evictBuffer",value:function(){var m=at(ke().mark(function h(f){var g=this,E,_,S,D;return ke().wrap(function(F){for(;;)switch(F.prev=F.next){case 0:if(E=this.flv.media,!(!this._mse||!this._demuxer||!E||!f||f<0)){F.next=3;break}return F.abrupt("return");case 3:if(_=E.currentTime,S=_-f,!(S<=0)){F.next=7;break}return F.abrupt("return");case 7:if(D=tt.start(tt.get(E)),!(D+1>=S)){F.next=10;break}return F.abrupt("return");case 10:return F.abrupt("return",this._mse.clearBuffer(0,S).then(function(){return g.flv.emit(_e.REMOVE_BUFFER,{removeEnd:S})}));case 11:case"end":return F.stop()}},h,this)}));function o(h){return m.apply(this,arguments)}return o}()},{key:"_emitMetaParsedEvent",value:function(o,h){o.exist()&&this.flv.emit(_e.METADATA_PARSED,{type:"video",track:o,meta:{codec:o.codec,timescale:o.timescale,width:o.width,height:o.height,sarRatio:o.sarRatio,baseDts:o.baseDts}}),h.exist()&&this.flv.emit(_e.METADATA_PARSED,{type:"audio",track:h,meta:{codec:h.codec,channelCount:h.channelCount,sampleRate:h.sampleRate,timescale:h.timescale,baseDts:h.baseDts}}),ir.debug("track parsed",o,h)}},{key:"_fireEvents",value:function(o,h,f){var g=this;ir.debug("videoTrack samples count: ".concat(o.samples.length,", audioTrack samples count: ").concat(h.samples.length)),f.flvScriptSamples.forEach(function(E){g.flv.emit(_e.FLV_SCRIPT_DATA,E),ir.debug("flvScriptData",E)}),o.samples.forEach(function(E){E.keyframe&&g.flv.emit(_e.KEYFRAME,{pts:E.originPts})}),o.warnings.forEach(function(E){var _;switch(E.type){case yt.LARGE_AV_SHIFT:_=_e.LARGE_AV_FIRST_FRAME_GAP_DETECT;break;case yt.LARGE_VIDEO_GAP:_=_e.LARGE_VIDEO_DTS_GAP_DETECT;break;case yt.LARGE_VIDEO_GAP_BETWEEN_CHUNK:_=_e.MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT;break}_&&g.flv.emit(_e.STREAM_EXCEPTION,It(It({},E),{},{type:_})),ir.warn("video exception",E)}),h.warnings.forEach(function(E){var _;switch(E.type){case yt.LARGE_AUDIO_GAP:_=_e.LARGE_AUDIO_DTS_GAP_DETECT;break;case yt.AUDIO_FILLED:_=_e.AUDIO_GAP_DETECT;break;case yt.AUDIO_DROPPED:_=_e.AUDIO_OVERLAP_DETECT;break}_&&g.flv.emit(_e.STREAM_EXCEPTION,It(It({},E),{},{type:_})),ir.warn("audio exception",E)}),f.seiSamples.forEach(function(E){g.flv.emit(_e.SEI,It(It({},E),{},{sei:{code:E.data.type,content:E.data.payload,dts:E.pts}}))})}}]),v}();function qo(v){var m=It({retryCount:3,retryDelay:1e3,disconnectRetryCount:0,loadTimeout:1e4,maxReaderInterval:5e3,preloadTime:5,defaultVodLoadSize:1e7,isLive:!1,softDecode:!1,bufferBehind:10,maxJumpDistance:3,analyzeDuration:2e4,seamlesslyReload:!1,keepStatusAfterSwitch:!0,onlyVideo:!1,onlyAudio:!1,preferMMS:!1,mseLowLatency:!0,durationForMSELowLatencyOff:6,chunkCountForSpeed:50,skipChunkSize:1e3,longtimeNoReceived:3e3,enableStartGapJump:!0},v);return m.isLive&&m.preloadTime&&(m.maxLatency||(m.maxLatency=m.preloadTime*2),m.targetLatency||(m.targetLatency=m.preloadTime),(m.disconnectTime===null||m.disconnectTime===void 0)&&(m.disconnectTime=m.maxLatency)),m}function Hn(v,m){var o=0,h=v.length-1,f=0,g=0,E=h;for(m<v[0]&&(o=0,g=E+1);g<=E;)if(f=g+Math.floor((E-g)/2),f===h||m>=v[f]&&m<v[f+1]){o=f;break}else v[f]<m?g=f+1:E=f-1;return o}var Xt=new Ct("flv"),Oi=.1,ud=.3,Dr=function(v){qs(o,v);var m=$s(o);function o(h){var f;return br(this,o),f=m.call(this),me(Pe(f),"media",null),me(Pe(f),"_loading",!1),me(Pe(f),"_opts",null),me(Pe(f),"_bufferService",null),me(Pe(f),"_gapService",null),me(Pe(f),"_stats",null),me(Pe(f),"_mediaLoader",null),me(Pe(f),"_maxChunkWaitTimer",null),me(Pe(f),"_tickTimer",null),me(Pe(f),"_tickInterval",500),me(Pe(f),"_urlSwitching",!1),me(Pe(f),"_seamlessSwitching",!1),me(Pe(f),"_disconnectRetryCount",0),me(Pe(f),"_preLoadEndPoint",0),me(Pe(f),"_keyframes",null),me(Pe(f),"_acceptRanges",!0),me(Pe(f),"_onProgress",function(){var g=at(ke().mark(function E(_,S,D,P){var F,H,W,$,ee,Z,oe,ue,Se,he;return ke().wrap(function(ce){for(;;)switch(ce.prev=ce.next){case 0:if(F=D.startTime,H=D.endTime,W=D.st,$=D.firstByteTime,f._loading=!S,f._firstProgressEmit){ce.next=13;break}if(f.media){ce.next=6;break}return(ee=f._mediaLoader)===null||ee===void 0||ee.cancel(),ce.abrupt("return");case 6:Z=P.headers,oe=W?$-W:H-F,f.emit(_e.TTFB,{url:f._opts.url,responseUrl:P.url,elapsed:oe}),f.emit(_e.LOAD_RESPONSE_HEADERS,{headers:Z}),f._transferCost.set(rr.TTFB,oe),f._acceptRanges=!!(Z!=null&&Z.get("Accept-Ranges"))||!!(Z!=null&&Z.get("Content-Range")),f._firstProgressEmit=!0;case 13:if(f._bufferService){ce.next=15;break}return ce.abrupt("return");case 15:return clearTimeout(f._maxChunkWaitTimer),f._bandwidthService.addChunkRecord(_?.byteLength,H-F),ce.prev=17,ce.next=20,f._bufferService.appendBuffer(_);case 20:(ue=f._bufferService)===null||ue===void 0||ue.evictBuffer(f._opts.bufferBehind),ce.next=33;break;case 23:if(ce.prev=23,ce.t0=ce.catch(17),!(!f.isLive&&f._bufferService.isFull())){ce.next=32;break}return ce.next=28,f._mediaLoader.cancel();case 28:return f._loading=!1,Se=f.bufferInfo().remaining,f._opts.preloadTime=parseInt(Se)/2,ce.abrupt("return");case 32:return ce.abrupt("return",f._emitError(pt.create(ce.t0)));case 33:if(f._urlSwitching&&(f._urlSwitching=!1,f.emit(_e.SWITCH_URL_SUCCESS,{url:f._opts.url})),f._seamlessSwitching&&(f._seamlessSwitching=!1,f._tick()),!(S&&!f.media.seeking)){ce.next=40;break}return f.emit(_e.LOAD_COMPLETE),Xt.debug("load done"),f.isLive&&f._disconnectRetryCount<=0&&f._end(),ce.abrupt("return");case 40:if(f.isLive){ce.next=42;break}return ce.abrupt("return");case 42:he=f._opts.maxReaderInterval,he&&f._firstProgressEmit&&(clearTimeout(f._maxChunkWaitTimer),f._maxChunkWaitTimer=setTimeout(function(){if(f._disconnectRetryCount){f._disconnectRetryCount--,f.load();return}Xt.debug("onMaxChunkWait",he),f._end()},he));case 44:case"end":return ce.stop()}},E,null,[[17,23]])}));return function(E,_,S,D){return g.apply(this,arguments)}}()),me(Pe(f),"_onRetryError",function(g,E){Xt.debug("load retry",g,E),f.emit(_e.LOAD_RETRY,{error:pt.network(g),retryTime:E})}),me(Pe(f),"_end",function(){f._clear(),f._bufferService&&f._bufferService.endOfStream(),Xt.debug("end stream")}),me(Pe(f),"_resetDisconnectCount",function(){f._disconnectRetryCount=f._opts.disconnectRetryCount}),me(Pe(f),"_tick",function(){clearTimeout(f._tickTimer);var g=Pe(f),E=g.media;if(E){f._tickTimer=setTimeout(f._tick,f._tickInterval);var _=tt.end(tt.get(E));if(!(_<Oi||!E.readyState)){var S=f._opts;if(Tn(E)&&E.currentTime)f._gapService&&f._gapService.do(E,S.maxJumpDistance,f.isLive,3);else{if(!E.currentTime&&f._gapService&&S.enableStartGapJump){var D=f._opts.mseLowLatency||f._opts.mseLowLatency===!1&&f.bufferInfo(ud).nextStart;D&&f._gapService.do(E,S.maxJumpDistance,f.isLive,3);return}S.isLive&&E.readyState===4&&_-E.currentTime>S.disconnectTime&&f.disconnect()}}}}),me(Pe(f),"_onPlay",function(){var g,E,_=f._opts.softDecode||((g=f.media)===null||g===void 0||(E=g.buffered)===null||E===void 0?void 0:E.length);if(f.isLive){!f._loading&&_&&f.replay(void 0,!0);return}var S=f.bufferInfo();(S.start||S.nextStart)>Oi&&f._tick()}),me(Pe(f),"_onLoadeddata",function(){f.isLive&&!f._opts.mseLowLatency&&f.media.duration!==1/0&&f._bufferService.updateDuration(1/0).catch(function(g){})}),me(Pe(f),"_onSeeking",at(ke().mark(function g(){return ke().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:!f.isLive&&f.seekable&&(f._preLoadEndPoint=-1,f._checkPreload());case 1:case"end":return _.stop()}},g)}))),me(Pe(f),"_onTimeupdate",function(){if(f.media){var g=f._opts,E=f.media.currentTime;if(g.isLive&&g.maxLatency&&g.targetLatency){var _=tt.end(tt.get(f.media)),S=_-E;S>=g.maxLatency&&(f.media.currentTime=_-g.targetLatency,f.emit(_e.CHASEFRAME,{currentTime:f.media.currentTime,latency:g.targetLatency}))}f._seiService.throw(E,!0),!(g.isLive||!f.seekable||f._loading)&&f._checkPreload()}}),me(Pe(f),"_onWaiting",function(){f.isLive&&!f._loading&&f._disconnectRetryCount&&(f._disconnectRetryCount--,f.load())}),me(Pe(f),"_onBufferUpdate",function(){if(!f._opts.isLive){var g=f.bufferInfo(),E=g.end,_=g.nextEnd;Math.abs((E||_)-f.media.duration)<1&&(f._end(),f.media.readyState<=2&&f._tick())}}),me(Pe(f),"_checkPreload",at(ke().mark(function g(){var E,_,S,D,P,F,H,W,$,ee;return ke().wrap(function(oe){for(;;)switch(oe.prev=oe.next){case 0:if(E=f.bufferInfo(),_=E.remaining,S=_===void 0?0:_,D=f._opts,P=f._keyframes.filepositions,F=f._keyframes.times,H=f.media.currentTime,!(S<D.preloadTime)){oe.next=19;break}if(W=Hn(f._keyframes.times,H+S+Oi),$=Hn(f._keyframes.times,H+S+f._opts.preloadTime),$===W&&($=W+1),f._preLoadEndPoint!==$){oe.next=11;break}return oe.abrupt("return");case 11:if(ee=P[W],ee!=null){oe.next=14;break}return oe.abrupt("return");case 14:return oe.next=16,f._mediaLoader.cancel();case 16:f._loadData(null,[ee,P[$]]),f._preLoadEndPoint=$,f._bufferService.unContiguous(F[W]);case 19:case"end":return oe.stop()}},g)}))),me(Pe(f),"_onFlvScriptData",function(g){var E,_,S,D,P=(E=g.data)===null||E===void 0||(_=E.onMetaData)===null||_===void 0?void 0:_.keyframes,F=(S=g.data)===null||S===void 0||(D=S.onMetaData)===null||D===void 0?void 0:D.duration;P&&(f._keyframes=P),!f._opts.isLive&&F&&f._bufferService.updateDuration(F)}),f._opts=qo(h),f.media=f._opts.media||document.createElement("video"),f._opts.media=null,f._firstProgressEmit=!1,f._mediaLoader=new xn(It(It({},f._opts.fetchOptions),{},{retry:f._opts.retryCount,retryDelay:f._opts.retryDelay,timeout:f._opts.loadTimeout,onRetryError:f._onRetryError,onProgress:f._onProgress,responseType:"arraybuffer"})),f._disconnectRetryCount=f._opts.disconnectRetryCount,f._transferCost=new Yo,f._bufferService=new zo(Pe(f),f._opts.softDecode?f.media:void 0,f._opts),f._seiService=new Cn(Pe(f)),f._bandwidthService=new kn({chunkCountForSpeed:f._opts.chunkCountForSpeed,skipChunkSize:f._opts.skipChunkSize,longtimeNoReceived:f._opts.longtimeNoReceived}),f._stats=new Dn(Pe(f)),f._opts.softDecode||(f._gapService=new Rn),f.media.addEventListener("play",f._onPlay),f.media.addEventListener("loadeddata",f._onLoadeddata),f.media.addEventListener("seeking",f._onSeeking),f.media.addEventListener("timeupdate",f._onTimeupdate),f.media.addEventListener("progress",f._onBufferUpdate),f.media.addEventListener("waiting",f._onWaiting),f.on(_e.FLV_SCRIPT_DATA,f._onFlvScriptData),f}return Lr(o,[{key:"version",get:function(){return"3.0.21"}},{key:"isLive",get:function(){return this._opts.isLive}},{key:"baseDts",get:function(){var f;return(f=this._bufferService)===null||f===void 0?void 0:f.baseDts}},{key:"seekable",get:function(){return!!this._keyframes&&this._acceptRanges}},{key:"loader",get:function(){return this._mediaLoader}},{key:"blobUrl",get:function(){var f;return(f=this._bufferService)===null||f===void 0?void 0:f.blobUrl}},{key:"speedInfo",value:function(){return{speed:this._bandwidthService.getLatestSpeed(),avgSpeed:this._bandwidthService.getAvgSpeed(),totalSize:this._bandwidthService.getTotalSize(),totalCost:this._bandwidthService.getTotalCost()}}},{key:"getStats",value:function(){return this._stats.getStats()}},{key:"bufferInfo",value:function(){var f,g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Oi;return tt.info(tt.get(this.media),(f=this.media)===null||f===void 0?void 0:f.currentTime,g)}},{key:"playbackQuality",value:function(){return An(this.media)}},{key:"load",value:function(){var h=at(ke().mark(function g(E){var _,S=arguments;return ke().wrap(function(P){for(;;)switch(P.prev=P.next){case 0:if(_=S.length>1&&S[1]!==void 0?S[1]:!1,this._bufferService){P.next=3;break}return P.abrupt("return");case 3:return P.next=5,this._reset(_);case 5:this._loadData(E,this._opts.isLive?[]:[0,this._opts.defaultVodLoadSize]),clearTimeout(this._tickTimer),this._tickTimer=setTimeout(this._tick,this._tickInterval);case 8:case"end":return P.stop()}},g,this)}));function f(g){return h.apply(this,arguments)}return f}()},{key:"replay",value:function(){var h=at(ke().mark(function g(){var E=this,_,S,D=arguments;return ke().wrap(function(F){for(;;)switch(F.prev=F.next){case 0:if(_=D.length>0&&D[0]!==void 0?D[0]:this._opts.seamlesslyReload,S=D.length>1?D[1]:void 0,this.media){F.next=4;break}return F.abrupt("return");case 4:if(this._resetDisconnectCount(),!_){F.next=11;break}return F.next=8,this._clear();case 8:setTimeout(function(){E._seamlessSwitching=!0,E._loadData(E._opts.url),E._bufferService.seamlessSwitch()}),F.next=13;break;case 11:return F.next=13,this.load();case 13:return F.abrupt("return",this.media.play(!S).catch(function(){}));case 14:case"end":return F.stop()}},g,this)}));function f(){return h.apply(this,arguments)}return f}()},{key:"disconnect",value:function(){var f;return Xt.debug("disconnect!"),(f=this._bufferService)===null||f===void 0||f.resetSeamlessSwitchStats(),this._clear()}},{key:"switchURL",value:function(){var h=at(ke().mark(function g(E,_){var S=this;return ke().wrap(function(P){for(;;)switch(P.prev=P.next){case 0:if(this._bufferService){P.next=2;break}return P.abrupt("return");case 2:if(this._resetDisconnectCount(),!(this._loading&&_)){P.next=6;break}return this._bufferService.seamlessLoadingSwitch=function(){var F=at(ke().mark(function H(W){return ke().wrap(function(ee){for(;;)switch(ee.prev=ee.next){case 0:return ee.next=2,S._clear();case 2:S._bufferService.seamlessLoadingSwitching=!0,S._urlSwitching=!0,S._seamlessSwitching=!0,S._bufferService.seamlessSwitch(),S._loadData(E);case 7:case"end":return ee.stop()}},H)}));return function(H){return F.apply(this,arguments)}}(),P.abrupt("return");case 6:if(!(!_||!this._opts.isLive)){P.next=11;break}return P.next=9,this.load(E);case 9:return this._urlSwitching=!0,P.abrupt("return",this.media.play(!0).catch(function(){}));case 11:return P.next=13,this._clear();case 13:setTimeout(function(){S._urlSwitching=!0,S._seamlessSwitching=!0,S._loadData(E),S._bufferService.seamlessSwitch()});case 14:case"end":return P.stop()}},g,this)}));function f(g,E){return h.apply(this,arguments)}return f}()},{key:"destroy",value:function(){var h=at(ke().mark(function g(){return ke().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:if(this.media){_.next=2;break}return _.abrupt("return");case 2:return this.removeAllListeners(),this._seiService.reset(),this.media.removeEventListener("play",this._onPlay),this.media.removeEventListener("loadeddata",this._onLoadeddata),this.media.removeEventListener("seeking",this._onSeeking),this.media.removeEventListener("timeupdate",this._onTimeupdate),this.media.removeEventListener("waiting",this._onWaiting),this.media.removeEventListener("progress",this._onBufferUpdate),_.next=12,Promise.all([this._clear(),this._bufferService.destroy()]);case 12:this.media=null,this._bufferService=null;case 14:case"end":return _.stop()}},g,this)}));function f(){return h.apply(this,arguments)}return f}()},{key:"_emitError",value:function(f){var g,E=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;Xt.table(f),Xt.error(f),Xt.error((g=this.media)===null||g===void 0?void 0:g.error),this._urlSwitching&&(this._urlSwitching=!1,this._seamlessSwitching=!1,this.emit(_e.SWITCH_URL_FAILED,f)),this.emit(_e.ERROR,f),E&&(this._seiService.reset(),this._end())}},{key:"_reset",value:function(){var h=at(ke().mark(function g(){var E,_=arguments;return ke().wrap(function(D){for(;;)switch(D.prev=D.next){case 0:return E=_.length>0&&_[0]!==void 0?_[0]:!1,this._seiService.reset(),this._bandwidthService.reset(),this._stats.reset(),D.next=6,this._clear();case 6:return D.next=8,this._bufferService.reset(E);case 8:case"end":return D.stop()}},g,this)}));function f(){return h.apply(this,arguments)}return f}()},{key:"_loadData",value:function(){var h=at(ke().mark(function g(E,_){var S;return ke().wrap(function(P){for(;;)switch(P.prev=P.next){case 0:if(E&&(this._opts.url=E),S=E=this._opts.url,E){P.next=4;break}throw new Error("Source url is missing");case 4:if(this._opts.preProcessUrl&&(S=this._opts.preProcessUrl(E).url),this._mediaLoader.finnalUrl=S,this.emit(_e.LOAD_START,{url:S,seamlessSwitching:this._seamlessSwitching}),Xt.debug("load data, loading:",this._loading,S),!this._loading){P.next=11;break}return P.next=11,this._mediaLoader.cancel();case 11:return this._loading=!0,P.prev=12,P.next=15,this._mediaLoader.load({url:S,range:_});case 15:P.next=21;break;case 17:return P.prev=17,P.t0=P.catch(12),this._loading=!1,P.abrupt("return",this._emitError(pt.network(P.t0),!1));case 21:case"end":return P.stop()}},g,this,[[12,17]])}));function f(g,E){return h.apply(this,arguments)}return f}()},{key:"_clear",value:function(){var h=at(ke().mark(function g(){return ke().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:if(!this._mediaLoader){_.next=3;break}return _.next=3,this._mediaLoader.cancel();case 3:clearTimeout(this._maxChunkWaitTimer),clearTimeout(this._tickTimer),this._loading=!1,this._firstProgressEmit=!1;case 7:case"end":return _.stop()}},g,this)}));function f(){return h.apply(this,arguments)}return f}()}],[{key:"isSupported",value:function(f){return!f||f==="video"||f==="audio"?fr.isSupported():typeof WebAssembly<"u"}},{key:"enableLogger",value:function(){Ct.enable(),pr.enable()}},{key:"disableLogger",value:function(){Ct.disable(),pr.disable()}}]),o}($o.default);try{localStorage.getItem("xgd")?Dr.enableLogger():Dr.disableLogger()}catch{}var Wn=Ar(Qo(),1);
34
+
35
+ if(__exports != exports)module.exports = exports;return module.exports}));