933.js 287 KB

123
  1. /*! For license information please see 933.js.LICENSE.txt */
  2. (globalThis.webpackChunksakurairo_scripts=globalThis.webpackChunksakurairo_scripts||[]).push([[933],{933:function(e){var t;"undefined"!=typeof window&&(t=()=>(()=>{var e={"./src/config.ts":(e,t,r)=>{r.r(t),r.d(t,{enableStreamingMode:()=>E,hlsDefaultConfig:()=>p,mergeConfig:()=>y});var i=r("./src/controller/abr-controller.ts"),n=r("./src/empty.js"),a=r.n(n),s=r("./src/controller/buffer-controller.ts"),o=r("./src/controller/cap-level-controller.ts"),l=r("./src/controller/fps-controller.ts"),u=r("./src/utils/xhr-loader.ts"),d=r("./src/utils/fetch-loader.ts"),c=r("./src/utils/mediakeys-helper.ts"),h=r("./src/utils/logger.ts");function f(){return f=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},f.apply(this,arguments)}function v(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function g(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?v(Object(r),!0).forEach((function(t){m(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):v(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function m(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var p=g(g({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:6e7,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:void 0,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:u.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:i.default,bufferController:s.default,capLevelController:o.default,fpsController:l.default,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:c.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0},{cueHandler:a(),enableWebVTT:!1,enableIMSC1:!1,enableCEA708Captions:!1,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:void 0,subtitleTrackController:void 0,timelineController:void 0,audioStreamController:void 0,audioTrackController:void 0,emeController:void 0,cmcdController:void 0});function y(e,t){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==t.liveMaxLatencyDurationCount&&(void 0===t.liveSyncDurationCount||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==t.liveMaxLatencyDuration&&(void 0===t.liveSyncDuration||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return f({},e,t)}function E(e){var t=e.loader;t!==d.default&&t!==u.default?(h.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),e.progressive=!1):(0,d.fetchSupported)()&&(e.loader=d.default,e.progressive=!0,e.enableSoftwareAES=!0,h.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}},"./src/controller/abr-controller.ts":(e,t,r)=>{r.r(t),r.d(t,{default:()=>d});var i=r("./src/polyfills/number.ts"),n=r("./src/utils/ewma-bandwidth-estimator.ts"),a=r("./src/events.ts"),s=r("./src/errors.ts"),o=r("./src/types/loader.ts"),l=r("./src/utils/logger.ts");function u(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(n=i.key,a=void 0,"symbol"==typeof(a=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(n,"string"))?a:String(a)),i)}var n,a}const d=function(){function e(e){this.hls=void 0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=void 0,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=e;var t=e.config;this.bwEstimator=new n.default(t.abrEwmaSlowVoD,t.abrEwmaFastVoD,t.abrEwmaDefaultEstimate),this.registerListeners()}var t,r,d,c=e.prototype;return c.registerListeners=function(){var e=this.hls;e.on(a.Events.FRAG_LOADING,this.onFragLoading,this),e.on(a.Events.FRAG_LOADED,this.onFragLoaded,this),e.on(a.Events.FRAG_BUFFERED,this.onFragBuffered,this),e.on(a.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(a.Events.ERROR,this.onError,this)},c.unregisterListeners=function(){var e=this.hls;e.off(a.Events.FRAG_LOADING,this.onFragLoading,this),e.off(a.Events.FRAG_LOADED,this.onFragLoaded,this),e.off(a.Events.FRAG_BUFFERED,this.onFragBuffered,this),e.off(a.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(a.Events.ERROR,this.onError,this)},c.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},c.onFragLoading=function(e,t){var r,i=t.frag;i.type===o.PlaylistLevelType.MAIN&&(this.timer||(this.fragCurrent=i,this.partCurrent=null!=(r=t.part)?r:null,this.timer=self.setInterval(this.onCheck,100)))},c.onLevelLoaded=function(e,t){var r=this.hls.config;t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)},c._abandonRulesCheck=function(){var e=this.fragCurrent,t=this.partCurrent,r=this.hls,n=r.autoLevelEnabled,s=r.media;if(e&&s){var o=t?t.stats:e.stats,u=t?t.duration:e.duration;if(o.aborted||o.loaded&&o.loaded===o.total||0===e.level)return this.clearTimer(),void(this._nextAutoLevel=-1);if(n&&!s.paused&&s.playbackRate&&s.readyState){var d=r.mainForwardBufferInfo;if(null!==d){var c=performance.now()-o.loading.start,h=Math.abs(s.playbackRate);if(!(c<=500*u/h)){var f=o.loaded&&o.loading.first,v=this.bwEstimator.getEstimate(),g=r.levels,m=r.minAutoLevel,p=g[e.level],y=o.total||Math.max(o.loaded,Math.round(u*p.maxBitrate/8)),E=f?1e3*o.loaded/c:0,T=E?(y-o.loaded)/E:8*y/v,S=d.len/h;if(!(T<=S)){var b,L=Number.POSITIVE_INFINITY;for(b=e.level-1;b>m;b--){var A=g[b].maxBitrate;if((L=E?u*A/(6.4*E):u*A/v)<S)break}L>=T||(l.logger.warn("Fragment "+e.sn+(t?" part "+t.index:"")+" of level "+e.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+b+"\n Current BW estimate: "+((0,i.isFiniteNumber)(v)?(v/1024).toFixed(3):"Unknown")+" Kb/s\n Estimated load time for current fragment: "+T.toFixed(3)+" s\n Estimated load time for the next fragment: "+L.toFixed(3)+" s\n Time to underbuffer: "+S.toFixed(3)+" s"),r.nextLoadLevel=b,f&&this.bwEstimator.sample(c,o.loaded),this.clearTimer(),(e.loader||e.keyLoader)&&(this.fragCurrent=this.partCurrent=null,e.abortRequests()),r.trigger(a.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:e,part:t,stats:o}))}}}}}},c.onFragLoaded=function(e,t){var r=t.frag,n=t.part;if(r.type===o.PlaylistLevelType.MAIN&&(0,i.isFiniteNumber)(r.sn)){var s=n?n.stats:r.stats,l=n?n.duration:r.duration;if(this.clearTimer(),this.lastLoadedFragLevel=r.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var u=this.hls.levels[r.level],d=(u.loaded?u.loaded.bytes:0)+s.loaded,c=(u.loaded?u.loaded.duration:0)+l;u.loaded={bytes:d,duration:c},u.realBitrate=Math.round(8*d/c)}if(r.bitrateTest){var h={stats:s,frag:r,part:n,id:r.type};this.onFragBuffered(a.Events.FRAG_BUFFERED,h)}}},c.onFragBuffered=function(e,t){var r=t.frag,i=t.part,n=i?i.stats:r.stats;if(!n.aborted&&r.type===o.PlaylistLevelType.MAIN&&"initSegment"!==r.sn){var a=n.parsing.end-n.loading.start;this.bwEstimator.sample(a,n.loaded),n.bwEstimate=this.bwEstimator.getEstimate(),r.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}},c.onError=function(e,t){var r;if((null===(r=t.frag)||void 0===r?void 0:r.type)===o.PlaylistLevelType.MAIN){if(t.type===s.ErrorTypes.KEY_SYSTEM_ERROR)return void this.clearTimer();switch(t.details){case s.ErrorDetails.FRAG_LOAD_ERROR:case s.ErrorDetails.FRAG_LOAD_TIMEOUT:case s.ErrorDetails.KEY_LOAD_ERROR:case s.ErrorDetails.KEY_LOAD_TIMEOUT:this.clearTimer()}}},c.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},c.getNextABRAutoLevel=function(){var e=this.fragCurrent,t=this.partCurrent,r=this.hls,i=r.maxAutoLevel,n=r.config,a=r.minAutoLevel,s=r.media,o=t?t.duration:e?e.duration:0,u=s&&0!==s.playbackRate?Math.abs(s.playbackRate):1,d=this.bwEstimator?this.bwEstimator.getEstimate():n.abrEwmaDefaultEstimate,c=r.mainForwardBufferInfo,h=(c?c.len:0)/u,f=this.findBestLevel(d,a,i,h,n.abrBandWidthFactor,n.abrBandWidthUpFactor);if(f>=0)return f;l.logger.trace((h?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var v=o?Math.min(o,n.maxStarvationDelay):n.maxStarvationDelay,g=n.abrBandWidthFactor,m=n.abrBandWidthUpFactor;if(!h){var p=this.bitrateTestDelay;p&&(v=(o?Math.min(o,n.maxLoadingDelay):n.maxLoadingDelay)-p,l.logger.trace("bitrate test took "+Math.round(1e3*p)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*v)+" ms"),g=m=1)}return f=this.findBestLevel(d,a,i,h+v,g,m),Math.max(f,0)},c.findBestLevel=function(e,t,r,n,a,s){for(var o,u=this.fragCurrent,d=this.partCurrent,c=this.lastLoadedFragLevel,h=this.hls.levels,f=h[c],v=!(null==f||null===(o=f.details)||void 0===o||!o.live),g=null==f?void 0:f.codecSet,m=d?d.duration:u?u.duration:0,p=r;p>=t;p--){var y=h[p];if(y&&(!g||y.codecSet===g)){var E=y.details,T=(d?null==E?void 0:E.partTarget:null==E?void 0:E.averagetargetduration)||m,S=void 0;S=p<=c?a*e:s*e;var b=h[p].maxBitrate,L=b*T/S;if(l.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+p+"/"+Math.round(S)+"/"+b+"/"+T+"/"+n+"/"+L),S>b&&(0===L||!(0,i.isFiniteNumber)(L)||v&&!this.bitrateTestDelay||L<n))return p}}return-1},t=e,(r=[{key:"nextAutoLevel",get:function(){var e=this._nextAutoLevel,t=this.bwEstimator;if(-1!==e&&!t.canEstimate())return e;var r=this.getNextABRAutoLevel();return-1!==e&&this.hls.levels[r].loadError?e:(-1!==e&&(r=Math.min(e,r)),r)},set:function(e){this._nextAutoLevel=e}}])&&u(t.prototype,r),d&&u(t,d),Object.defineProperty(t,"prototype",{writable:!1}),e}()},"./src/controller/base-playlist-controller.ts":(e,t,r)=>{r.r(t),r.d(t,{default:()=>o});var i=r("./src/types/level.ts"),n=r("./src/controller/level-helper.ts"),a=r("./src/utils/logger.ts"),s=r("./src/errors.ts"),o=function(){function e(e,t){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=a.logger.log.bind(a.logger,t+":"),this.warn=a.logger.warn.bind(a.logger,t+":"),this.hls=e}var t=e.prototype;return t.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},t.onError=function(e,t){!t.fatal||t.type!==s.ErrorTypes.NETWORK_ERROR&&t.type!==s.ErrorTypes.KEY_SYSTEM_ERROR||this.stopLoad()},t.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},t.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.requestScheduled=-1,this.loadPlaylist()},t.stopLoad=function(){this.canLoad=!1,this.clearTimer()},t.switchParams=function(e,t){var r=null==t?void 0:t.renditionReports;if(r)for(var n=0;n<r.length;n++){var s=r[n],o=void 0;try{o=new self.URL(s.URI,t.url).href}catch(e){a.logger.warn("Could not construct new URL for Rendition Report: "+e),o=s.URI||""}if(o===e.slice(-o.length)){var l=parseInt(s["LAST-MSN"])||(null==t?void 0:t.lastPartSn),u=parseInt(s["LAST-PART"])||(null==t?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){var d=Math.min(t.age-t.partTarget,t.targetduration);u>=0&&d>t.partTarget&&(u+=1)}return new i.HlsUrlParameters(l,u>=0?u:void 0,i.HlsSkip.No)}}},t.loadPlaylist=function(e){-1===this.requestScheduled&&(this.requestScheduled=self.performance.now())},t.shouldLoadTrack=function(e){return this.canLoad&&e&&!!e.url&&(!e.details||e.details.live)},t.playlistLoaded=function(e,t,r){var i=this,a=t.details,s=t.stats,o=self.performance.now(),l=s.loading.first?Math.max(0,o-s.loading.first):0;if(a.advancedDateTime=Date.now()-l,a.live||null!=r&&r.live){if(a.reloaded(r),r&&this.log("live playlist "+e+" "+(a.advanced?"REFRESHED "+a.lastPartSn+"-"+a.lastPartIndex:"MISSED")),r&&a.fragments.length>0&&(0,n.mergeDetails)(r,a),!this.canLoad||!a.live)return;var u,d=void 0,c=void 0;if(a.canBlockReload&&a.endSN&&a.advanced){var h=this.hls.config.lowLatencyMode,f=a.lastPartSn,v=a.endSN,g=a.lastPartIndex,m=f===v;-1!==g?(d=m?v+1:f,c=m?h?0:g:g+1):d=v+1;var p=a.age,y=p+a.ageHeader,E=Math.min(y-a.partTarget,1.5*a.targetduration);if(E>0){if(r&&E>r.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+r.tuneInGoal+" to: "+E+" with playlist age: "+a.age),E=0;else{var T=Math.floor(E/a.targetduration);d+=T,void 0!==c&&(c+=Math.round(E%a.targetduration/a.partTarget)),this.log("CDN Tune-in age: "+a.ageHeader+"s last advanced "+p.toFixed(2)+"s goal: "+E+" skip sn "+T+" to part "+c)}a.tuneInGoal=E}if(u=this.getDeliveryDirectives(a,t.deliveryDirectives,d,c),h||!m)return void this.loadPlaylist(u)}else u=this.getDeliveryDirectives(a,t.deliveryDirectives,d,c);var S=this.hls.mainForwardBufferInfo,b=S?S.end-S.len:0,L=1e3*(a.edge-b),A=(0,n.computeReloadInterval)(a,L);a.updated?o>this.requestScheduled+A&&(this.requestScheduled=s.loading.start):this.requestScheduled=-1,void 0!==d&&a.canBlockReload?this.requestScheduled=s.loading.first+A-(1e3*a.partTarget||1e3):this.requestScheduled=(-1===this.requestScheduled?o:this.requestScheduled)+A;var D=this.requestScheduled-o;D=Math.max(0,D),this.log("reload live playlist "+e+" in "+Math.round(D)+" ms"),this.timer=self.setTimeout((function(){return i.loadPlaylist(u)}),D)}else this.clearTimer()},t.getDeliveryDirectives=function(e,t,r,n){var a=(0,i.getSkipValue)(e,r);return null!=t&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,n=t.part,a=i.HlsSkip.No),new i.HlsUrlParameters(r,n,a)},t.retryLoadingOrFail=function(e){var t,r=this,i=this.hls.config,n=this.retryCount<i.levelLoadingMaxRetry;if(n)if(this.requestScheduled=-1,this.retryCount++,e.details.indexOf("LoadTimeOut")>-1&&null!==(t=e.context)&&void 0!==t&&t.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+e.details+'"'),this.loadPlaylist();else{var a=Math.min(Math.pow(2,this.retryCount)*i.levelLoadingRetryDelay,i.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout((function(){return r.loadPlaylist()}),a),this.warn("retry playlist loading #"+this.retryCount+" in "+a+' ms after "'+e.details+'"')}else this.warn('cannot recover from error "'+e.details+'"'),this.clearTimer(),e.fatal=!0;return n},e}()},"./src/controller/base-stream-controller.ts":(e,t,r)=>{r.r(t),r.d(t,{State:()=>S,default:()=>b});var i=r("./src/polyfills/number.ts"),n=r("./src/task-loop.ts"),a=r("./src/controller/fragment-tracker.ts"),s=r("./src/utils/buffer-helper.ts"),o=r("./src/utils/logger.ts"),l=r("./src/events.ts"),u=r("./src/errors.ts"),d=r("./src/types/transmuxer.ts"),c=r("./src/utils/mp4-tools.ts"),h=r("./src/utils/discontinuities.ts"),f=r("./src/controller/fragment-finders.ts"),v=r("./src/controller/level-helper.ts"),g=r("./src/loader/fragment-loader.ts"),m=r("./src/crypt/decrypter.ts"),p=r("./src/utils/time-ranges.ts"),y=r("./src/types/loader.ts");function E(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(n=i.key,a=void 0,"symbol"==typeof(a=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(n,"string"))?a:String(a)),i)}var n,a}function T(e,t){return T=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},T(e,t)}var S={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},b=function(e){var t,r;function n(t,r,i,n){var a;return(a=e.call(this)||this).hls=void 0,a.fragPrevious=null,a.fragCurrent=null,a.fragmentTracker=void 0,a.transmuxer=null,a._state=S.STOPPED,a.media=null,a.mediaBuffer=null,a.config=void 0,a.bitrateTest=!1,a.lastCurrentTime=0,a.nextLoadPosition=0,a.startPosition=0,a.loadedmetadata=!1,a.fragLoadError=0,a.retryDate=0,a.levels=null,a.fragmentLoader=void 0,a.keyLoader=void 0,a.levelLastLoaded=null,a.startFragRequested=!1,a.decrypter=void 0,a.initPTS=[],a.onvseeking=null,a.onvended=null,a.logPrefix="",a.log=void 0,a.warn=void 0,a.logPrefix=n,a.log=o.logger.log.bind(o.logger,n+":"),a.warn=o.logger.warn.bind(o.logger,n+":"),a.hls=t,a.fragmentLoader=new g.default(t.config),a.keyLoader=i,a.fragmentTracker=r,a.config=t.config,a.decrypter=new m.default(t.config),t.on(l.Events.LEVEL_SWITCHING,a.onLevelSwitching,function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(a)),a}r=e,(t=n).prototype=Object.create(r.prototype),t.prototype.constructor=t,T(t,r);var b,L,A,D=n.prototype;return D.doTick=function(){this.onTickEnd()},D.onTickEnd=function(){},D.startLoad=function(e){},D.stopLoad=function(){this.fragmentLoader.abort(),this.keyLoader.abort();var e=this.fragCurrent;e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=S.STOPPED},D._streamEnded=function(e,t){if(t.live||e.nextStart||!e.end||!this.media)return!1;var r=t.partList;if(null!=r&&r.length){var i=r[r.length-1];return s.BufferHelper.isBuffered(this.media,i.start+i.duration/2)}var n=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(n)},D.getLevelDetails=function(){var e;if(this.levels&&null!==this.levelLastLoaded)return null===(e=this.levels[this.levelLastLoaded])||void 0===e?void 0:e.details},D.onMediaAttached=function(e,t){var r=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),r.addEventListener("seeking",this.onvseeking),r.addEventListener("ended",this.onvended);var i=this.config;this.levels&&i.autoStartLoad&&this.state===S.STOPPED&&this.startLoad(i.startPosition)},D.onMediaDetaching=function(){var e=this.media;null!=e&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&this.onvseeking&&this.onvended&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},D.onMediaSeeking=function(){var e=this.config,t=this.fragCurrent,r=this.media,n=this.mediaBuffer,a=this.state,o=r?r.currentTime:0,l=s.BufferHelper.bufferInfo(n||r,o,e.maxBufferHole);if(this.log("media seeking to "+((0,i.isFiniteNumber)(o)?o.toFixed(3):o)+", state: "+a),this.state===S.ENDED)this.resetLoadingState();else if(t){var u=e.maxFragLookUpTolerance,d=t.start-u,c=t.start+t.duration+u;if(!l.len||c<l.start||d>l.end){var h=o>c;(o<d||h)&&(h&&t.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),t.abortRequests()),this.resetLoadingState())}}r&&(this.lastCurrentTime=o),this.loadedmetadata||l.len||(this.nextLoadPosition=this.startPosition=o),this.tickImmediate()},D.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},D.onLevelSwitching=function(e,t){this.fragLoadError=0},D.onHandlerDestroying=function(){this.stopLoad(),e.prototype.onHandlerDestroying.call(this)},D.onHandlerDestroyed=function(){this.state=S.STOPPED,this.hls.off(l.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),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,e.prototype.onHandlerDestroyed.call(this)},D.loadFragment=function(e,t,r){this._loadFragForPlayback(e,t,r)},D._loadFragForPlayback=function(e,t,r){var i=this;this._doFragLoad(e,t,r,(function(t){if(i.fragContextChanged(e))return i.warn("Fragment "+e.sn+(t.part?" p: "+t.part.index:"")+" of level "+e.level+" was dropped during download."),void i.fragmentTracker.removeFragment(e);e.stats.chunkCount++,i._handleFragmentLoadProgress(t)})).then((function(t){if(t){i.fragLoadError=0;var r=i.state;i.fragContextChanged(e)?(r===S.FRAG_LOADING||!i.fragCurrent&&r===S.PARSING)&&(i.fragmentTracker.removeFragment(e),i.state=S.IDLE):("payload"in t&&(i.log("Loaded fragment "+e.sn+" of level "+e.level),i.hls.trigger(l.Events.FRAG_LOADED,t)),i._handleFragmentLoadComplete(t))}})).catch((function(t){i.state!==S.STOPPED&&i.state!==S.ERROR&&(i.warn(t),i.resetFragmentLoading(e))}))},D.flushMainBuffer=function(e,t,r){if(void 0===r&&(r=null),e-t){var i={startOffset:e,endOffset:t,type:r};this.fragLoadError=0,this.hls.trigger(l.Events.BUFFER_FLUSHING,i)}},D._loadInitSegment=function(e,t){var r=this;this._doFragLoad(e,t).then((function(t){if(!t||r.fragContextChanged(e)||!r.levels)throw new Error("init load aborted");return t})).then((function(t){var i=r.hls,n=t.payload,a=e.decryptdata;if(n&&n.byteLength>0&&a&&a.key&&a.iv&&"AES-128"===a.method){var s=self.performance.now();return r.decrypter.decrypt(new Uint8Array(n),a.key.buffer,a.iv.buffer).then((function(r){var n=self.performance.now();return i.trigger(l.Events.FRAG_DECRYPTED,{frag:e,payload:r,stats:{tstart:s,tdecrypt:n}}),t.payload=r,t}))}return t})).then((function(t){var i=r.fragCurrent,n=r.hls,a=r.levels;if(!a)throw new Error("init load aborted, missing levels");var s=a[e.level].details;console.assert(s,"Level details are defined when init segment is loaded");var o=e.stats;r.state=S.IDLE,r.fragLoadError=0,e.data=new Uint8Array(t.payload),o.parsing.start=o.buffering.start=self.performance.now(),o.parsing.end=o.buffering.end=self.performance.now(),t.frag===i&&n.trigger(l.Events.FRAG_BUFFERED,{stats:o,frag:i,part:null,id:e.type}),r.tick()})).catch((function(t){r.state!==S.STOPPED&&r.state!==S.ERROR&&(r.warn(t),r.resetFragmentLoading(e))}))},D.fragContextChanged=function(e){var t=this.fragCurrent;return!e||!t||e.level!==t.level||e.sn!==t.sn||e.urlId!==t.urlId},D.fragBufferedComplete=function(e,t){var r,i,n,a,o=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+e.type+" sn: "+e.sn+(t?" part: "+t.index:"")+" of "+("[stream-controller]"===this.logPrefix?"level":"track")+" "+e.level+" (frag:["+(null!=(r=e.startPTS)?r:NaN).toFixed(3)+"-"+(null!=(i=e.endPTS)?i:NaN).toFixed(3)+"] > buffer:"+(o?p.default.toString(s.BufferHelper.getBuffered(o)):"(detached)")+")"),this.state=S.IDLE,o&&(!this.loadedmetadata&&e.type==y.PlaylistLevelType.MAIN&&o.buffered.length&&(null===(n=this.fragCurrent)||void 0===n?void 0:n.sn)===(null===(a=this.fragPrevious)||void 0===a?void 0:a.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},D.seekToStartPos=function(){},D._handleFragmentLoadComplete=function(e){var t=this.transmuxer;if(t){var r=e.frag,i=e.part,n=e.partsLoaded,a=!n||0===n.length||n.some((function(e){return!e})),s=new d.ChunkMetadata(r.level,r.sn,r.stats.chunkCount+1,0,i?i.index:-1,!a);t.flush(s)}},D._handleFragmentLoadProgress=function(e){},D._doFragLoad=function(e,t,r,n){var a,s=this;if(void 0===r&&(r=null),!this.levels)throw new Error("frag load aborted, missing levels");var o=null;if(!e.encrypted||null!==(a=e.decryptdata)&&void 0!==a&&a.key?!e.encrypted&&t.encryptedFragments.length&&this.keyLoader.loadClear(e,t.encryptedFragments):(this.log("Loading key for "+e.sn+" of ["+t.startSN+"-"+t.endSN+"], "+("[stream-controller]"===this.logPrefix?"level":"track")+" "+e.level),this.state=S.KEY_LOADING,this.fragCurrent=e,o=this.keyLoader.load(e).then((function(e){if(!s.fragContextChanged(e.frag))return s.hls.trigger(l.Events.KEY_LOADED,e),s.state===S.KEY_LOADING&&(s.state=S.IDLE),e})),this.hls.trigger(l.Events.KEY_LOADING,{frag:e}),this.throwIfFragContextChanged("KEY_LOADING")),r=Math.max(e.start,r||0),this.config.lowLatencyMode&&t){var u=t.partList;if(u&&n){r>e.end&&t.fragmentHint&&(e=t.fragmentHint);var d=this.getNextPart(u,e,r);if(d>-1){var c=u[d];return this.log("Loading part sn: "+e.sn+" p: "+c.index+" cc: "+e.cc+" of playlist ["+t.startSN+"-"+t.endSN+"] parts [0-"+d+"-"+(u.length-1)+"] "+("[stream-controller]"===this.logPrefix?"level":"track")+": "+e.level+", target: "+parseFloat(r.toFixed(3))),this.nextLoadPosition=c.start+c.duration,this.state=S.FRAG_LOADING,this.hls.trigger(l.Events.FRAG_LOADING,{frag:e,part:u[d],targetBufferTime:r}),this.throwIfFragContextChanged("FRAG_LOADING parts"),o?o.then((function(t){return!t||s.fragContextChanged(t.frag)?null:s.doFragPartsLoad(e,u,d,n)})).catch((function(e){return s.handleFragLoadError(e)})):this.doFragPartsLoad(e,u,d,n).catch((function(e){return s.handleFragLoadError(e)}))}if(!e.url||this.loadedEndOfParts(u,r))return Promise.resolve(null)}}this.log("Loading fragment "+e.sn+" cc: "+e.cc+" "+(t?"of ["+t.startSN+"-"+t.endSN+"] ":"")+("[stream-controller]"===this.logPrefix?"level":"track")+": "+e.level+", target: "+parseFloat(r.toFixed(3))),(0,i.isFiniteNumber)(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=S.FRAG_LOADING,this.hls.trigger(l.Events.FRAG_LOADING,{frag:e,targetBufferTime:r}),this.throwIfFragContextChanged("FRAG_LOADING");var h=this.config.progressive;return h&&o?o.then((function(t){return!t||s.fragContextChanged(null==t?void 0:t.frag)?null:s.fragmentLoader.load(e,n)})).catch((function(e){return s.handleFragLoadError(e)})):Promise.all([this.fragmentLoader.load(e,h?n:void 0),o]).then((function(e){var t=e[0];return!h&&t&&n&&n(t),t})).catch((function(e){return s.handleFragLoadError(e)}))},D.throwIfFragContextChanged=function(e){if(null===this.fragCurrent)throw new Error("frag load aborted, context changed in "+e)},D.doFragPartsLoad=function(e,t,r,i){var n=this;return new Promise((function(a,s){var o=[];!function r(u){var d=t[u];n.fragmentLoader.loadPart(e,d,i).then((function(i){o[d.index]=i;var s=i.part;n.hls.trigger(l.Events.FRAG_LOADED,i);var c=t[u+1];if(!c||c.fragment!==e)return a({frag:e,part:s,partsLoaded:o});r(u+1)})).catch(s)}(r)}))},D.handleFragLoadError=function(e){if("data"in e){var t=e.data;e.data&&t.details===u.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(l.Events.ERROR,t)}else this.hls.trigger(l.Events.ERROR,{type:u.ErrorTypes.OTHER_ERROR,details:u.ErrorDetails.INTERNAL_EXCEPTION,err:e,fatal:!0});return null},D._handleTransmuxerFlush=function(e){var t=this.getCurrentContext(e);if(t&&this.state===S.PARSING){var r=t.frag,i=t.part,n=t.level,a=self.performance.now();r.stats.parsing.end=a,i&&(i.stats.parsing.end=a),this.updateLevelTiming(r,i,n,e.partial)}else this.fragCurrent||this.state===S.STOPPED||this.state===S.ERROR||(this.state=S.IDLE)},D.getCurrentContext=function(e){var t=this.levels,r=e.level,i=e.sn,n=e.part;if(!t||!t[r])return this.warn("Levels object was unset while buffering fragment "+i+" of level "+r+". The current chunk will not be buffered."),null;var a=t[r],s=n>-1?(0,v.getPartWith)(a,i,n):null,o=s?s.fragment:(0,v.getFragmentWithSN)(a,i,this.fragCurrent);return o?{frag:o,part:s,level:a}:null},D.bufferFragmentData=function(e,t,r,i){if(e&&this.state===S.PARSING){var n=e.data1,a=e.data2,s=n;if(n&&a&&(s=(0,c.appendUint8Array)(n,a)),s&&s.length){var o={type:e.type,frag:t,part:r,chunkMeta:i,parent:t.type,data:s};this.hls.trigger(l.Events.BUFFER_APPENDING,o),e.dropped&&e.independent&&!r&&this.flushBufferGap(t)}}},D.flushBufferGap=function(e){var t=this.media;if(t)if(s.BufferHelper.isBuffered(t,t.currentTime)){var r=t.currentTime,i=s.BufferHelper.bufferInfo(t,r,0),n=e.duration,a=Math.min(2*this.config.maxFragLookUpTolerance,.25*n),o=Math.max(Math.min(e.start-a,i.end-a),r+a);e.start-o>a&&this.flushMainBuffer(o,e.start)}else this.flushMainBuffer(0,e.start)},D.getFwdBufferInfo=function(e,t){var r=this.config,n=this.getLoadPosition();if(!(0,i.isFiniteNumber)(n))return null;var a=s.BufferHelper.bufferInfo(e,n,r.maxBufferHole);if(0===a.len&&void 0!==a.nextStart){var o=this.fragmentTracker.getBufferedFrag(n,t);if(o&&a.nextStart<o.end)return s.BufferHelper.bufferInfo(e,n,Math.max(a.nextStart,r.maxBufferHole))}return a},D.getMaxBufferLength=function(e){var t,r=this.config;return t=e?Math.max(8*r.maxBufferSize/e,r.maxBufferLength):r.maxBufferLength,Math.min(t,r.maxMaxBufferLength)},D.reduceMaxBufferLength=function(e){var t=this.config,r=e||t.maxBufferLength;return t.maxMaxBufferLength>=r&&(t.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+t.maxMaxBufferLength+"s"),!0)},D.getNextFragment=function(e,t){var r=t.fragments,i=r.length;if(!i)return null;var n,a=this.config,s=r[0].start;if(t.live){var o=a.initialLiveManifestSize;if(i<o)return this.warn("Not enough fragments to start playback (have: "+i+", need: "+o+")"),null;t.PTSKnown||this.startFragRequested||-1!==this.startPosition||(n=this.getInitialLiveFragment(t,r),this.startPosition=n?this.hls.liveSyncPosition||n.start:e)}else e<=s&&(n=r[0]);if(!n){var l=a.lowLatencyMode?t.partEnd:t.fragmentEnd;n=this.getFragmentAtPosition(e,l,t)}return this.mapToInitFragWhenRequired(n)},D.mapToInitFragWhenRequired=function(e){return null==e||!e.initSegment||null!=e&&e.initSegment.data||this.bitrateTest?e:e.initSegment},D.getNextPart=function(e,t,r){for(var i=-1,n=!1,a=!0,s=0,o=e.length;s<o;s++){var l=e[s];if(a=a&&!l.independent,i>-1&&r<l.start)break;var u=l.loaded;u?i=-1:(n||l.independent||a)&&l.fragment===t&&(i=s),n=u}return i},D.loadedEndOfParts=function(e,t){var r=e[e.length-1];return r&&t>r.start&&r.loaded},D.getInitialLiveFragment=function(e,t){var r=this.fragPrevious,i=null;if(r){if(e.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+r.programDateTime),i=(0,f.findFragmentByPDT)(t,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!i){var n=r.sn+1;if(n>=e.startSN&&n<=e.endSN){var a=t[n-e.startSN];r.cc===a.cc&&(i=a,this.log("Live playlist, switching playlist, load frag with next SN: "+i.sn))}i||(i=(0,f.findFragWithCC)(t,r.cc))&&this.log("Live playlist, switching playlist, load frag with same CC: "+i.sn)}}else{var s=this.hls.liveSyncPosition;null!==s&&(i=this.getFragmentAtPosition(s,this.bitrateTest?e.fragmentEnd:e.edge,e))}return i},D.getFragmentAtPosition=function(e,t,r){var i,n=this.config,s=this.fragPrevious,o=r.fragments,l=r.endSN,u=r.fragmentHint,d=n.maxFragLookUpTolerance,c=!!(n.lowLatencyMode&&r.partList&&u);if(c&&u&&!this.bitrateTest&&(o=o.concat(u),l=u.sn),e<t){var h=e>t-d?0:d;i=(0,f.findFragmentByPTS)(s,o,e,h)}else i=o[o.length-1];if(i){var v=i.sn-r.startSN;if(this.fragmentTracker.getState(i)===a.FragmentState.OK&&(s=i),s&&i.sn===s.sn&&!c&&s&&i.level===s.level){var g=o[v+1];i.sn<l&&this.fragmentTracker.getState(g)!==a.FragmentState.OK?(this.log("SN "+i.sn+" just loaded, load next one: "+g.sn),i=g):i=null}}return i},D.synchronizeToLiveEdge=function(e){var t=this.config,r=this.media;if(r){var i=this.hls.liveSyncPosition,n=r.currentTime,a=e.fragments[0].start,s=e.edge,o=n>=a-t.maxFragLookUpTolerance&&n<=s;if(null!==i&&r.duration>i&&(n<i||!o)){var l=void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;(!o&&r.readyState<4||n<s-l)&&(this.loadedmetadata||(this.nextLoadPosition=i),r.readyState&&(this.warn("Playback: "+n.toFixed(3)+" is located too far from the end of live sliding playlist: "+s+", reset currentTime to : "+i.toFixed(3)),r.currentTime=i))}}},D.alignPlaylists=function(e,t){var r=this.levels,n=this.levelLastLoaded,a=this.fragPrevious,s=null!==n?r[n]:null,o=e.fragments.length;if(!o)return this.warn("No fragments in live playlist"),0;var l=e.fragments[0].start,u=!t,d=e.alignedSliding&&(0,i.isFiniteNumber)(l);if(u||!d&&!l){(0,h.alignStream)(a,s,e);var c=e.fragments[0].start;return this.log("Live playlist sliding: "+c.toFixed(2)+" start-sn: "+(t?t.startSN:"na")+"->"+e.startSN+" prev-sn: "+(a?a.sn:"na")+" fragments: "+o),c}return l},D.waitForCdnTuneIn=function(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)},D.setStartPosition=function(e,t){var r=this.startPosition;if(r<t&&(r=-1),-1===r||-1===this.lastCurrentTime){var n=e.startTimeOffset;(0,i.isFiniteNumber)(n)?(r=t+n,n<0&&(r+=e.totalduration),r=Math.min(Math.max(t,r),t+e.totalduration),this.log("Start time offset "+n+" found in playlist, adjust startPosition to "+r),this.startPosition=r):e.live?r=this.hls.liveSyncPosition||t:this.startPosition=r=0,this.lastCurrentTime=r}this.nextLoadPosition=r},D.getLoadPosition=function(){var e=this.media,t=0;return this.loadedmetadata&&e?t=e.currentTime:this.nextLoadPosition&&(t=this.nextLoadPosition),t},D.handleFragLoadAborted=function(e,t){this.transmuxer&&"initSegment"!==e.sn&&e.stats.aborted&&(this.warn("Fragment "+e.sn+(t?" part"+t.index:"")+" of level "+e.level+" was aborted"),this.resetFragmentLoading(e))},D.resetFragmentLoading=function(e){this.fragCurrent&&(this.fragContextChanged(e)||this.state===S.FRAG_LOADING_WAITING_RETRY)||(this.state=S.IDLE)},D.onFragmentOrKeyLoadError=function(e,t){if(t.fatal)return this.stopLoad(),void(this.state=S.ERROR);var r=this.config;if(t.chunkMeta){var i=this.getCurrentContext(t.chunkMeta);i&&(t.frag=i.frag,t.levelRetry=!0,this.fragLoadError=r.fragLoadingMaxRetry)}var n=t.frag;if(n&&n.type===e){var a=this.fragCurrent;if(console.assert(a&&n.sn===a.sn&&n.level===a.level&&n.urlId===a.urlId,"Frag load error must match current frag to retry"),this.fragLoadError+1<=r.fragLoadingMaxRetry){this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition);var s=Math.min(Math.pow(2,this.fragLoadError)*r.fragLoadingRetryDelay,r.fragLoadingMaxRetryTimeout);this.warn("Fragment "+n.sn+" of "+e+" "+n.level+" failed to load, retrying in "+s+"ms"),this.retryDate=self.performance.now()+s,this.fragLoadError++,this.state=S.FRAG_LOADING_WAITING_RETRY}else t.levelRetry?(e===y.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=S.IDLE):(o.logger.error(t.details+" reaches max retry, redispatch as fatal ..."),t.fatal=!0,this.hls.stopLoad(),this.state=S.ERROR)}},D.afterBufferFlushed=function(e,t,r){if(e){var i=s.BufferHelper.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,i,r),this.state===S.ENDED&&this.resetLoadingState()}},D.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=S.IDLE},D.resetStartWhenNotLoaded=function(e){if(!this.loadedmetadata){this.startFragRequested=!1;var t=this.levels?this.levels[e].details:null;null!=t&&t.live?(this.startPosition=-1,this.setStartPosition(t,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},D.updateLevelTiming=function(e,t,r,i){var n=this,a=r.details;console.assert(!!a,"level.details must be defined"),Object.keys(e.elementaryStreams).reduce((function(t,s){var o=e.elementaryStreams[s];if(o){var u=o.endPTS-o.startPTS;if(u<=0)return n.warn("Could not parse fragment "+e.sn+" "+s+" duration reliably ("+u+")"),t||!1;var d=i?0:(0,v.updateFragPTSDTS)(a,e,o.startPTS,o.endPTS,o.startDTS,o.endDTS);return n.hls.trigger(l.Events.LEVEL_PTS_UPDATED,{details:a,level:r,drift:d,type:s,frag:e,start:o.startPTS,end:o.endPTS}),!0}return t}),!1)||(this.warn("Found no media in fragment "+e.sn+" of level "+r.id+" resetting transmuxer to fallback to playlist timing"),this.resetTransmuxer()),this.state=S.PARSED,this.hls.trigger(l.Events.FRAG_PARSED,{frag:e,part:t})},D.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},b=n,(L=[{key:"state",get:function(){return this._state},set:function(e){var t=this._state;t!==e&&(this._state=e,this.log(t+"->"+e))}}])&&E(b.prototype,L),A&&E(b,A),Object.defineProperty(b,"prototype",{writable:!1}),n}(n.default)},"./src/controller/buffer-controller.ts":(e,t,r)=>{r.r(t),r.d(t,{default:()=>f});var i=r("./src/polyfills/number.ts"),n=r("./src/events.ts"),a=r("./src/utils/logger.ts"),s=r("./src/errors.ts"),o=r("./src/utils/buffer-helper.ts"),l=r("./src/utils/mediasource-helper.ts"),u=r("./src/loader/fragment.ts"),d=r("./src/controller/buffer-operation-queue.ts"),c=(0,l.getMediaSource)(),h=/([ha]vc.)(?:\.[^.,]+)+/,f=function(){function e(e){var t=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var e=t.media,r=t.mediaSource;a.logger.log("[buffer-controller]: Media source opened"),e&&(e.removeEventListener("emptied",t._onMediaEmptied),t.updateMediaElementDuration(),t.hls.trigger(n.Events.MEDIA_ATTACHED,{media:e})),r&&r.removeEventListener("sourceopen",t._onMediaSourceOpen),t.checkPendingTracks()},this._onMediaSourceClose=function(){a.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){a.logger.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=function(){var e=t.media,r=t._objectUrl;e&&e.src!==r&&a.logger.error("Media element src was set while attaching MediaSource ("+r+" > "+e.src+")")},this.hls=e,this._initSourceBuffer(),this.registerListeners()}var t=e.prototype;return t.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},t.destroy=function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null},t.registerListeners=function(){var e=this.hls;e.on(n.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(n.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(n.Events.BUFFER_RESET,this.onBufferReset,this),e.on(n.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.on(n.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.on(n.Events.BUFFER_EOS,this.onBufferEos,this),e.on(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(n.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(n.Events.FRAG_PARSED,this.onFragParsed,this),e.on(n.Events.FRAG_CHANGED,this.onFragChanged,this)},t.unregisterListeners=function(){var e=this.hls;e.off(n.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(n.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(n.Events.BUFFER_RESET,this.onBufferReset,this),e.off(n.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.off(n.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(n.Events.BUFFER_EOS,this.onBufferEos,this),e.off(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(n.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(n.Events.FRAG_PARSED,this.onFragParsed,this),e.off(n.Events.FRAG_CHANGED,this.onFragChanged,this)},t._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new d.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null},t.onManifestParsed=function(e,t){var r=2;(t.audio&&!t.video||!t.altAudio)&&(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,this.details=null,a.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},t.onMediaAttaching=function(e,t){var r=this.media=t.media;if(r&&c){var i=this.mediaSource=new c;i.addEventListener("sourceopen",this._onMediaSourceOpen),i.addEventListener("sourceended",this._onMediaSourceEnded),i.addEventListener("sourceclose",this._onMediaSourceClose),r.src=self.URL.createObjectURL(i),this._objectUrl=r.src,r.addEventListener("emptied",this._onMediaEmptied)}},t.onMediaDetaching=function(){var e=this.media,t=this.mediaSource,r=this._objectUrl;if(t){if(a.logger.log("[buffer-controller]: media source detaching"),"open"===t.readyState)try{t.endOfStream()}catch(e){a.logger.warn("[buffer-controller]: onMediaDetaching: "+e.message+" while calling endOfStream")}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(e.removeEventListener("emptied",this._onMediaEmptied),r&&self.URL.revokeObjectURL(r),e.src===r?(e.removeAttribute("src"),e.load()):a.logger.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(n.Events.MEDIA_DETACHED,void 0)},t.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach((function(t){var r=e.sourceBuffer[t];try{r&&(e.removeBufferListeners(t),e.mediaSource&&e.mediaSource.removeSourceBuffer(r),e.sourceBuffer[t]=void 0)}catch(e){a.logger.warn("[buffer-controller]: Failed to reset the "+t+" buffer",e)}})),this._initSourceBuffer()},t.onBufferCodecs=function(e,t){var r=this,i=this.getSourceBufferTypes().length;Object.keys(t).forEach((function(e){if(i){var n=r.tracks[e];if(n&&"function"==typeof n.buffer.changeType){var s=t[e],o=s.id,l=s.codec,u=s.levelCodec,d=s.container,c=s.metadata,f=(n.levelCodec||n.codec).replace(h,"$1"),v=(u||l).replace(h,"$1");if(f!==v){var g=d+";codecs="+(u||l);r.appendChangeType(e,g),a.logger.log("[buffer-controller]: switching codec "+f+" to "+v),r.tracks[e]={buffer:n.buffer,codec:l,container:d,levelCodec:u,metadata:c,id:o}}}}else r.pendingTracks[e]=t[e]})),i||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks())},t.appendChangeType=function(e,t){var r=this,i=this.operationQueue,n={execute:function(){var n=r.sourceBuffer[e];n&&(a.logger.log("[buffer-controller]: changing "+e+" sourceBuffer type to "+t),n.changeType(t)),i.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(t){a.logger.warn("[buffer-controller]: Failed to change "+e+" SourceBuffer type",t)}};i.append(n,e)},t.onBufferAppending=function(e,t){var r=this,i=this.hls,l=this.operationQueue,u=this.tracks,d=t.data,c=t.type,h=t.frag,f=t.part,v=t.chunkMeta,g=v.buffering[c],m=self.performance.now();g.start=m;var p=h.stats.buffering,y=f?f.stats.buffering:null;0===p.start&&(p.start=m),y&&0===y.start&&(y.start=m);var E=u.audio,T=!1;"audio"===c&&"audio/mpeg"===(null==E?void 0:E.container)&&(T=!this.lastMpegAudioChunk||1===v.id||this.lastMpegAudioChunk.sn!==v.sn,this.lastMpegAudioChunk=v);var S=h.start,b={execute:function(){if(g.executeStart=self.performance.now(),T){var e=r.sourceBuffer[c];if(e){var t=S-e.timestampOffset;Math.abs(t)>=.1&&(a.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+S+" (delta: "+t+") sn: "+h.sn+")"),e.timestampOffset=S)}}r.appendExecutor(d,c)},onStart:function(){},onComplete:function(){var e=self.performance.now();g.executeEnd=g.end=e,0===p.first&&(p.first=e),y&&0===y.first&&(y.first=e);var t=r.sourceBuffer,i={};for(var a in t)i[a]=o.BufferHelper.getBuffered(t[a]);r.appendError=0,r.hls.trigger(n.Events.BUFFER_APPENDED,{type:c,frag:h,part:f,chunkMeta:v,parent:h.type,timeRanges:i})},onError:function(e){a.logger.error("[buffer-controller]: Error encountered while trying to append to the "+c+" SourceBuffer",e);var t={type:s.ErrorTypes.MEDIA_ERROR,parent:h.type,details:s.ErrorDetails.BUFFER_APPEND_ERROR,err:e,fatal:!1};e.code===DOMException.QUOTA_EXCEEDED_ERR?t.details=s.ErrorDetails.BUFFER_FULL_ERROR:(r.appendError++,t.details=s.ErrorDetails.BUFFER_APPEND_ERROR,r.appendError>i.config.appendErrorMaxRetry&&(a.logger.error("[buffer-controller]: Failed "+i.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),t.fatal=!0,i.stopLoad())),i.trigger(n.Events.ERROR,t)}};l.append(b,c)},t.onBufferFlushing=function(e,t){var r=this,i=this.operationQueue,s=function(e){return{execute:r.removeExecutor.bind(r,e,t.startOffset,t.endOffset),onStart:function(){},onComplete:function(){r.hls.trigger(n.Events.BUFFER_FLUSHED,{type:e})},onError:function(t){a.logger.warn("[buffer-controller]: Failed to remove from "+e+" SourceBuffer",t)}}};t.type?i.append(s(t.type),t.type):this.getSourceBufferTypes().forEach((function(e){i.append(s(e),e)}))},t.onFragParsed=function(e,t){var r=this,i=t.frag,s=t.part,o=[],l=s?s.elementaryStreams:i.elementaryStreams;l[u.ElementaryStreamTypes.AUDIOVIDEO]?o.push("audiovideo"):(l[u.ElementaryStreamTypes.AUDIO]&&o.push("audio"),l[u.ElementaryStreamTypes.VIDEO]&&o.push("video")),0===o.length&&a.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+i.type+" level: "+i.level+" sn: "+i.sn),this.blockBuffers((function(){var e=self.performance.now();i.stats.buffering.end=e,s&&(s.stats.buffering.end=e);var t=s?s.stats:i.stats;r.hls.trigger(n.Events.FRAG_BUFFERED,{frag:i,part:s,stats:t,id:i.type})}),o)},t.onFragChanged=function(e,t){this.flushBackBuffer()},t.onBufferEos=function(e,t){var r=this;this.getSourceBufferTypes().reduce((function(e,i){var n=r.sourceBuffer[i];return!n||t.type&&t.type!==i||(n.ending=!0,n.ended||(n.ended=!0,a.logger.log("[buffer-controller]: "+i+" sourceBuffer now EOS"))),e&&!(n&&!n.ended)}),!0)&&(a.logger.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers((function(){r.getSourceBufferTypes().forEach((function(e){var t=r.sourceBuffer[e];t&&(t.ending=!1)}));var e=r.mediaSource;e&&"open"===e.readyState?(a.logger.log("[buffer-controller]: Calling mediaSource.endOfStream()"),e.endOfStream()):e&&a.logger.info("[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: "+e.readyState)})))},t.onLevelUpdated=function(e,t){var r=t.details;r.fragments.length&&(this.details=r,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},t.flushBackBuffer=function(){var e=this.hls,t=this.details,r=this.media,s=this.sourceBuffer;if(r&&null!==t){var l=this.getSourceBufferTypes();if(l.length){var u=t.live&&null!==e.config.liveBackBufferLength?e.config.liveBackBufferLength:e.config.backBufferLength;if((0,i.isFiniteNumber)(u)&&!(u<0)){var d=r.currentTime,c=t.levelTargetDuration,h=Math.max(u,c),f=Math.floor(d/c)*c-h;l.forEach((function(r){var i=s[r];if(i){var l=o.BufferHelper.getBuffered(i);if(l.length>0&&f>l.start(0)){if(e.trigger(n.Events.BACK_BUFFER_REACHED,{bufferEnd:f}),t.live)e.trigger(n.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:f});else if(i.ended&&l.end(l.length-1)-d<2*c)return void a.logger.info("[buffer-controller]: Cannot flush "+r+" back buffer while SourceBuffer is in ended state");e.trigger(n.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:f,type:r})}}}))}}}},t.updateMediaElementDuration=function(){if(this.details&&this.media&&this.mediaSource&&"open"===this.mediaSource.readyState){var e=this.details,t=this.hls,r=this.media,n=this.mediaSource,s=e.fragments[0].start+e.totalduration,o=r.duration,l=(0,i.isFiniteNumber)(n.duration)?n.duration:0;e.live&&t.config.liveDurationInfinity?(a.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),n.duration=1/0,this.updateSeekableRange(e)):(s>l&&s>o||!(0,i.isFiniteNumber)(o))&&(a.logger.log("[buffer-controller]: Updating Media Source duration to "+s.toFixed(3)),n.duration=s)}},t.updateSeekableRange=function(e){var t=this.mediaSource,r=e.fragments;if(r.length&&e.live&&null!=t&&t.setLiveSeekableRange){var i=Math.max(0,r[0].start),n=Math.max(i,i+e.totalduration);t.setLiveSeekableRange(i,n)}},t.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,t=this.operationQueue,r=this.pendingTracks,i=Object.keys(r).length;if(i&&!e||2===i){this.createSourceBuffers(r),this.pendingTracks={};var a=this.getSourceBufferTypes();if(0===a.length)return void this.hls.trigger(n.Events.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});a.forEach((function(e){t.executeNext(e)}))}},t.createSourceBuffers=function(e){var t=this.sourceBuffer,r=this.mediaSource;if(!r)throw Error("createSourceBuffers called when mediaSource was null");var i=0;for(var o in e)if(!t[o]){var l=e[o];if(!l)throw Error("source buffer exists for track "+o+", however track does not");var u=l.levelCodec||l.codec,d=l.container+";codecs="+u;a.logger.log("[buffer-controller]: creating sourceBuffer("+d+")");try{var c=t[o]=r.addSourceBuffer(d),h=o;this.addBufferListener(h,"updatestart",this._onSBUpdateStart),this.addBufferListener(h,"updateend",this._onSBUpdateEnd),this.addBufferListener(h,"error",this._onSBUpdateError),this.tracks[o]={buffer:c,codec:u,container:l.container,levelCodec:l.levelCodec,metadata:l.metadata,id:l.id},i++}catch(e){a.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+e.message),this.hls.trigger(n.Events.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,mimeType:d})}}i&&this.hls.trigger(n.Events.BUFFER_CREATED,{tracks:this.tracks})},t._onSBUpdateStart=function(e){this.operationQueue.current(e).onStart()},t._onSBUpdateEnd=function(e){var t=this.operationQueue;t.current(e).onComplete(),t.shiftAndExecuteNext(e)},t._onSBUpdateError=function(e,t){a.logger.error("[buffer-controller]: "+e+" SourceBuffer error",t),this.hls.trigger(n.Events.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var r=this.operationQueue.current(e);r&&r.onError(t)},t.removeExecutor=function(e,t,r){var n=this.media,s=this.mediaSource,o=this.operationQueue,l=this.sourceBuffer[e];if(!n||!s||!l)return a.logger.warn("[buffer-controller]: Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),void o.shiftAndExecuteNext(e);var u=(0,i.isFiniteNumber)(n.duration)?n.duration:1/0,d=(0,i.isFiniteNumber)(s.duration)?s.duration:1/0,c=Math.max(0,t),h=Math.min(r,u,d);h>c&&!l.ending?(l.ended=!1,a.logger.log("[buffer-controller]: Removing ["+c+","+h+"] from the "+e+" SourceBuffer"),console.assert(!l.updating,e+" sourceBuffer must not be updating"),l.remove(c,h)):o.shiftAndExecuteNext(e)},t.appendExecutor=function(e,t){var r=this.operationQueue,i=this.sourceBuffer[t];if(!i)return a.logger.warn("[buffer-controller]: Attempting to append to the "+t+" SourceBuffer, but it does not exist"),void r.shiftAndExecuteNext(t);i.ended=!1,console.assert(!i.updating,t+" sourceBuffer must not be updating"),i.appendBuffer(e)},t.blockBuffers=function(e,t){var r=this;if(void 0===t&&(t=this.getSourceBufferTypes()),!t.length)return a.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve().then(e);var i=this.operationQueue,n=t.map((function(e){return i.appendBlocker(e)}));Promise.all(n).then((function(){e(),t.forEach((function(e){var t=r.sourceBuffer[e];t&&t.updating||i.shiftAndExecuteNext(e)}))}))},t.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},t.addBufferListener=function(e,t,r){var i=this.sourceBuffer[e];if(i){var n=r.bind(this,e);this.listeners[e].push({event:t,listener:n}),i.addEventListener(t,n)}},t.removeBufferListeners=function(e){var t=this.sourceBuffer[e];t&&this.listeners[e].forEach((function(e){t.removeEventListener(e.event,e.listener)}))},e}()},"./src/controller/buffer-operation-queue.ts":(e,t,r)=>{r.r(t),r.d(t,{default:()=>n});var i=r("./src/utils/logger.ts"),n=function(){function e(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}var t=e.prototype;return t.append=function(e,t){var r=this.queues[t];r.push(e),1===r.length&&this.buffers[t]&&this.executeNext(t)},t.insertAbort=function(e,t){this.queues[t].unshift(e),this.executeNext(t)},t.appendBlocker=function(e){var t,r=new Promise((function(e){t=e})),i={execute:t,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(i,e),r},t.executeNext=function(e){var t=this.buffers,r=this.queues,n=t[e],a=r[e];if(a.length){var s=a[0];try{s.execute()}catch(t){i.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),s.onError(t),n&&n.updating||(a.shift(),this.executeNext(e))}}},t.shiftAndExecuteNext=function(e){this.queues[e].shift(),this.executeNext(e)},t.current=function(e){return this.queues[e][0]},e}()},"./src/controller/cap-level-controller.ts":(e,t,r)=>{r.r(t),r.d(t,{default:()=>a});var i=r("./src/events.ts");function n(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(n=i.key,a=void 0,"symbol"==typeof(a=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(n,"string"))?a:String(a)),i)}var n,a}const a=function(){function e(e){this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.hls=void 0,this.streamController=void 0,this.clientRect=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var t,r,a,s=e.prototype;return s.setStreamController=function(e){this.streamController=e},s.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},s.registerListeners=function(){var e=this.hls;e.on(i.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(i.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(i.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(i.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.on(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},s.unregisterListener=function(){var e=this.hls;e.off(i.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(i.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(i.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(i.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},s.onFpsDropLevelCapping=function(t,r){e.isLevelAllowed(r.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(r.droppedLevel)},s.onMediaAttaching=function(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null},s.onManifestParsed=function(e,t){var r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()},s.onBufferCodecs=function(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()},s.onMediaDetaching=function(){this.stopCapping()},s.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var e=this.hls.levels;if(e.length){var t=this.hls;t.autoLevelCapping=this.getMaxLevel(e.length-1),t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}},s.getMaxLevel=function(t){var r=this,i=this.hls.levels;if(!i.length)return-1;var n=i.filter((function(i,n){return e.isLevelAllowed(n,r.restrictedLevels)&&n<=t}));return this.clientRect=null,e.getMaxLevelByMediaSize(n,this.mediaWidth,this.mediaHeight)},s.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),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 e=this.media,t={width:0,height:0};if(e){var r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,t.width||t.height||(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t},e.isLevelAllowed=function(e,t){return void 0===t&&(t=[]),-1===t.indexOf(e)},e.getMaxLevelByMediaSize=function(e,t,r){if(!e||!e.length)return-1;for(var i,n,a=e.length-1,s=0;s<e.length;s+=1){var o=e[s];if((o.width>=t||o.height>=r)&&(i=o,!(n=e[s+1])||i.width!==n.width||i.height!==n.height)){a=s;break}}return a},t=e,(r=[{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 e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch(e){}return e}}])&&n(t.prototype,r),a&&n(t,a),Object.defineProperty(t,"prototype",{writable:!1}),e}()},"./src/controller/fps-controller.ts":(e,t,r)=>{r.r(t),r.d(t,{default:()=>a});var i=r("./src/events.ts"),n=r("./src/utils/logger.ts");const a=function(){function e(e){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=e,this.registerListeners()}var t=e.prototype;return t.setStreamController=function(e){this.streamController=e},t.registerListeners=function(){this.hls.on(i.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},t.unregisterListeners=function(){this.hls.off(i.Events.MEDIA_ATTACHING,this.onMediaAttaching)},t.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},t.onMediaAttaching=function(e,t){var r=this.hls.config;if(r.capLevelOnFPSDrop){var i=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=i,i&&"function"==typeof i.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}},t.checkFPS=function(e,t,r){var a=performance.now();if(t){if(this.lastTime){var s=a-this.lastTime,o=r-this.lastDroppedFrames,l=t-this.lastDecodedFrames,u=1e3*o/s,d=this.hls;if(d.trigger(i.Events.FPS_DROP,{currentDropped:o,currentDecoded:l,totalDroppedFrames:r}),u>0&&o>d.config.fpsDroppedMonitoringThreshold*l){var c=d.currentLevel;n.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+c),c>0&&(-1===d.autoLevelCapping||d.autoLevelCapping>=c)&&(c-=1,d.trigger(i.Events.FPS_DROP_LEVEL_CAPPING,{level:c,droppedLevel:d.currentLevel}),d.autoLevelCapping=c,this.streamController.nextLevelSwitch())}}this.lastTime=a,this.lastDroppedFrames=r,this.lastDecodedFrames=t}},t.checkFPSInterval=function(){var e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){var t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)},e}()},"./src/controller/fragment-finders.ts":(e,t,r)=>{r.r(t),r.d(t,{findFragWithCC:()=>u,findFragmentByPDT:()=>a,findFragmentByPTS:()=>s,fragmentWithinToleranceTest:()=>o,pdtWithinToleranceTest:()=>l});var i=r("./src/polyfills/number.ts"),n=r("./src/utils/binary-search.ts");function a(e,t,r){if(null===t||!Array.isArray(e)||!e.length||!(0,i.isFiniteNumber)(t))return null;if(t<(e[0].programDateTime||0))return null;if(t>=(e[e.length-1].endProgramDateTime||0))return null;r=r||0;for(var n=0;n<e.length;++n){var a=e[n];if(l(t,r,a))return a}return null}function s(e,t,r,i){void 0===r&&(r=0),void 0===i&&(i=0);var a=null;if(e?a=t[e.sn-t[0].sn+1]||null:0===r&&0===t[0].start&&(a=t[0]),a&&0===o(r,i,a))return a;var s=n.default.search(t,o.bind(null,r,i));return!s||s===e&&a?a:s}function o(e,t,r){if(void 0===e&&(e=0),void 0===t&&(t=0),r.start<=e&&r.start+r.duration>e)return 0;var i=Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return r.start+r.duration-i<=e?1:r.start-i>e&&r.start?-1:0}function l(e,t,r){var i=1e3*Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return(r.endProgramDateTime||0)-i>e}function u(e,t){return n.default.search(e,(function(e){return e.cc<t?1:e.cc>t?-1:0}))}},"./src/controller/fragment-tracker.ts":(e,t,r)=>{r.r(t),r.d(t,{FragmentState:()=>i,FragmentTracker:()=>s});var i,n=r("./src/events.ts"),a=r("./src/types/loader.ts");!function(e){e.NOT_LOADED="NOT_LOADED",e.APPENDING="APPENDING",e.PARTIAL="PARTIAL",e.OK="OK"}(i||(i={}));var s=function(){function e(e){this.activeFragment=null,this.activeParts=null,this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hls=e,this._registerListeners()}var t=e.prototype;return t._registerListeners=function(){var e=this.hls;e.on(n.Events.BUFFER_APPENDED,this.onBufferAppended,this),e.on(n.Events.FRAG_BUFFERED,this.onFragBuffered,this),e.on(n.Events.FRAG_LOADED,this.onFragLoaded,this)},t._unregisterListeners=function(){var e=this.hls;e.off(n.Events.BUFFER_APPENDED,this.onBufferAppended,this),e.off(n.Events.FRAG_BUFFERED,this.onFragBuffered,this),e.off(n.Events.FRAG_LOADED,this.onFragLoaded,this)},t.destroy=function(){this._unregisterListeners(),this.fragments=this.endListFragments=this.timeRanges=this.activeFragment=this.activeParts=null},t.getAppendedFrag=function(e,t){if(t===a.PlaylistLevelType.MAIN){var r=this.activeFragment,i=this.activeParts;if(!r)return null;if(i)for(var n=i.length;n--;){var s=i[n],o=s?s.end:r.appendedPTS;if(s.start<=e&&void 0!==o&&e<=o)return n>9&&(this.activeParts=i.slice(n-9)),s}else if(r.start<=e&&void 0!==r.appendedPTS&&e<=r.appendedPTS)return r}return this.getBufferedFrag(e,t)},t.getBufferedFrag=function(e,t){for(var r=this.fragments,i=Object.keys(r),n=i.length;n--;){var a=r[i[n]];if((null==a?void 0:a.body.type)===t&&a.buffered){var s=a.body;if(s.start<=e&&e<=s.end)return s}}return null},t.detectEvictedFragments=function(e,t,r){var i=this;this.timeRanges&&(this.timeRanges[e]=t),Object.keys(this.fragments).forEach((function(n){var a=i.fragments[n];if(a)if(a.buffered||a.loaded){var s=a.range[e];s&&s.time.some((function(e){var r=!i.isTimeBuffered(e.startPTS,e.endPTS,t);return r&&i.removeFragment(a.body),r}))}else a.body.type===r&&i.removeFragment(a.body)}))},t.detectPartialFragments=function(e){var t=this,r=this.timeRanges,i=e.frag,n=e.part;if(r&&"initSegment"!==i.sn){var a=l(i),s=this.fragments[a];s&&(Object.keys(r).forEach((function(e){var a=i.elementaryStreams[e];if(a){var o=r[e],l=null!==n||!0===a.partial;s.range[e]=t.getBufferedTimes(i,n,l,o)}})),s.loaded=null,Object.keys(s.range).length?(s.buffered=!0,s.body.endList&&(this.endListFragments[s.body.type]=s)):this.removeFragment(s.body))}},t.fragBuffered=function(e){var t=l(e),r=this.fragments[t];r&&(r.loaded=null,r.buffered=!0)},t.getBufferedTimes=function(e,t,r,i){for(var n={time:[],partial:r},a=t?t.start:e.start,s=t?t.end:e.end,o=e.minEndPTS||s,l=e.maxStartPTS||a,u=0;u<i.length;u++){var d=i.start(u)-this.bufferPadding,c=i.end(u)+this.bufferPadding;if(l>=d&&o<=c){n.time.push({startPTS:Math.max(a,i.start(u)),endPTS:Math.min(s,i.end(u))});break}if(a<c&&s>d)n.partial=!0,n.time.push({startPTS:Math.max(a,i.start(u)),endPTS:Math.min(s,i.end(u))});else if(s<=d)break}return n},t.getPartialFragment=function(e){var t,r,i,n=null,a=0,s=this.bufferPadding,l=this.fragments;return Object.keys(l).forEach((function(u){var d=l[u];d&&o(d)&&(r=d.body.start-s,i=d.body.end+s,e>=r&&e<=i&&(t=Math.min(e-r,i-e),a<=t&&(n=d.body,a=t)))})),n},t.isEndListAppended=function(e){var t=this.endListFragments[e];return void 0!==t&&(t.buffered||o(t))},t.getState=function(e){var t=l(e),r=this.fragments[t];return r?r.buffered?o(r)?i.PARTIAL:i.OK:i.APPENDING:i.NOT_LOADED},t.isTimeBuffered=function(e,t,r){for(var i,n,a=0;a<r.length;a++){if(i=r.start(a)-this.bufferPadding,n=r.end(a)+this.bufferPadding,e>=i&&t<=n)return!0;if(t<=i)return!1}return!1},t.onFragLoaded=function(e,t){var r=t.frag,i=t.part;if("initSegment"!==r.sn&&!r.bitrateTest&&!i){var n=l(r);this.fragments[n]={body:r,loaded:t,buffered:!1,range:Object.create(null)}}},t.onBufferAppended=function(e,t){var r=this,i=t.frag,n=t.part,s=t.timeRanges;if(i.type===a.PlaylistLevelType.MAIN)if(this.activeFragment!==i&&(this.activeFragment=i,i.appendedPTS=void 0),n){var o=this.activeParts;o||(this.activeParts=o=[]),o.push(n)}else this.activeParts=null;this.timeRanges=s,Object.keys(s).forEach((function(e){var t=s[e];if(r.detectEvictedFragments(e,t),!n&&i.type===a.PlaylistLevelType.MAIN){var o=i.elementaryStreams[e];if(!o)return;for(var l=0;l<t.length;l++){var u=t.end(l);u<=o.endPTS&&u>o.startPTS?i.appendedPTS=Math.max(u,i.appendedPTS||0):i.appendedPTS=o.endPTS}}}))},t.onFragBuffered=function(e,t){this.detectPartialFragments(t)},t.hasFragment=function(e){var t=l(e);return!!this.fragments[t]},t.removeFragmentsInRange=function(e,t,r){var i=this;Object.keys(this.fragments).forEach((function(n){var a=i.fragments[n];if(a&&a.buffered){var s=a.body;s.type===r&&s.start<t&&s.end>e&&i.removeFragment(s)}}))},t.removeFragment=function(e){var t=l(e);e.stats.loaded=0,e.clearElementaryStreamInfo(),e.appendedPTS=void 0,delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]},t.removeAllFragments=function(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activeFragment=null,this.activeParts=null},e}();function o(e){var t,r;return e.buffered&&((null===(t=e.range.video)||void 0===t?void 0:t.partial)||(null===(r=e.range.audio)||void 0===r?void 0:r.partial))}function l(e){return e.type+"_"+e.level+"_"+e.urlId+"_"+e.sn}},"./src/controller/gap-controller.ts":(e,t,r)=>{r.r(t),r.d(t,{MAX_START_GAP_JUMP:()=>l,SKIP_BUFFER_HOLE_STEP_SECONDS:()=>u,SKIP_BUFFER_RANGE_START:()=>d,STALL_MINIMUM_DURATION_MS:()=>o,default:()=>c});var i=r("./src/utils/buffer-helper.ts"),n=r("./src/errors.ts"),a=r("./src/events.ts"),s=r("./src/utils/logger.ts"),o=250,l=2,u=.1,d=.05,c=function(){function e(e,t,r,i){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=e,this.media=t,this.fragmentTracker=r,this.hls=i}var t=e.prototype;return t.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},t.poll=function(e,t){var r=this.config,n=this.media,a=this.stalled;if(null!==n){var u=n.currentTime,d=n.seeking,c=this.seeking&&!d,h=!this.seeking&&d;if(this.seeking=d,u===e){if((h||c)&&(this.stalled=null),!(n.paused&&!d||n.ended||0===n.playbackRate)&&i.BufferHelper.getBuffered(n).length){var f=i.BufferHelper.bufferInfo(n,u,0),v=f.len>0,g=f.nextStart||0;if(v||g){if(d){var m=f.len>l,p=!g||t&&t.start<=u||g-u>l&&!this.fragmentTracker.getPartialFragment(u);if(m||p)return;this.moved=!1}if(!this.moved&&null!==this.stalled){var y,E=Math.max(g,f.start||0)-u,T=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,S=(null==T||null===(y=T.details)||void 0===y?void 0:y.live)?2*T.details.targetduration:l;if(E>0&&E<=S)return void this._trySkipBufferHole(null)}var b=self.performance.now();if(null!==a){var L=b-a;if(d||!(L>=o)||(this._reportStall(f),this.media)){var A=i.BufferHelper.bufferInfo(n,u,r.maxBufferHole);this._tryFixBufferStall(A,L)}}else this.stalled=b}}}else if(this.moved=!0,null!==a){if(this.stallReported){var D=self.performance.now()-a;s.logger.warn("playback not stuck anymore @"+u+", after "+Math.round(D)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}}},t._tryFixBufferStall=function(e,t){var r=this.config,i=this.fragmentTracker,n=this.media;if(null!==n){var a=n.currentTime,o=i.getPartialFragment(a);if(o&&(this._trySkipBufferHole(o)||!this.media))return;e.len>r.maxBufferHole&&t>1e3*r.highBufferWatchdogPeriod&&(s.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},t._reportStall=function(e){var t=this.hls,r=this.media;!this.stallReported&&r&&(this.stallReported=!0,s.logger.warn("Playback stalling at @"+r.currentTime+" due to low buffer ("+JSON.stringify(e)+")"),t.trigger(a.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:e.len}))},t._trySkipBufferHole=function(e){var t=this.config,r=this.hls,o=this.media;if(null===o)return 0;for(var l=o.currentTime,c=0,h=i.BufferHelper.getBuffered(o),f=0;f<h.length;f++){var v=h.start(f);if(l+t.maxBufferHole>=c&&l<v){var g=Math.max(v+d,o.currentTime+u);return s.logger.warn("skipping hole, adjusting currentTime from "+l+" to "+g),this.moved=!0,this.stalled=null,o.currentTime=g,e&&r.trigger(a.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+l+" to "+g,frag:e}),g}c=h.end(f)}return 0},t._tryNudgeBuffer=function(){var e=this.config,t=this.hls,r=this.media,i=this.nudgeRetry;if(null!==r){var o=r.currentTime;if(this.nudgeRetry++,i<e.nudgeMaxRetry){var l=o+(i+1)*e.nudgeOffset;s.logger.warn("Nudging 'currentTime' from "+o+" to "+l),r.currentTime=l,t.trigger(a.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else s.logger.error("Playhead still not moving while enough data buffered @"+o+" after "+e.nudgeMaxRetry+" nudges"),t.trigger(a.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})}},e}()},"./src/controller/id3-track-controller.ts":(e,t,r)=>{r.r(t),r.d(t,{default:()=>h});var i=r("./src/polyfills/number.ts"),n=r("./src/events.ts"),a=r("./src/utils/texttrack-utils.ts"),s=r("./src/demux/id3.ts"),o=r("./src/loader/date-range.ts"),l=r("./src/types/demuxer.ts");function u(){return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}var d=function(){var e=u();try{new e(0,Number.POSITIVE_INFINITY,"")}catch(e){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function c(e,t){return e.getTime()/1e3-t}const h=function(){function e(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}var t=e.prototype;return t.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},t._registerListeners=function(){var e=this.hls;e.on(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(n.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(n.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},t._unregisterListeners=function(){var e=this.hls;e.off(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(n.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(n.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},t.onMediaAttached=function(e,t){this.media=t.media},t.onMediaDetaching=function(){this.id3Track&&((0,a.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},t.onManifestLoading=function(){this.dateRangeCuesAppended={}},t.createTrack=function(e){var t=this.getID3Track(e.textTracks);return t.mode="hidden",t},t.getID3Track=function(e){if(this.media){for(var t=0;t<e.length;t++){var r=e[t];if("metadata"===r.kind&&"id3"===r.label)return(0,a.sendAddTrackEvent)(r,this.media),r}return this.media.addTextTrack("metadata","id3")}},t.onFragParsingMetadata=function(e,t){if(this.media){var r=this.hls.config,i=r.enableEmsgMetadataCues,n=r.enableID3MetadataCues;if(i||n){var a=t.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));for(var o=u(),c=0;c<a.length;c++){var h=a[c].type;if((h!==l.MetadataSchema.emsg||i)&&n){var f=s.getID3Frames(a[c].data);if(f){var v=a[c].pts,g=v+a[c].duration;g>d&&(g=d),g-v<=0&&(g=v+.25);for(var m=0;m<f.length;m++){var p=f[m];if(!s.isTimeStampFrame(p)){this.updateId3CueEnds(v);var y=new o(v,g,"");y.value=p,h&&(y.type=h),this.id3Track.addCue(y)}}}}}}}},t.updateId3CueEnds=function(e){var t,r=null===(t=this.id3Track)||void 0===t?void 0:t.cues;if(r)for(var i=r.length;i--;){var n=r[i];n.startTime<e&&n.endTime===d&&(n.endTime=e)}},t.onBufferFlushing=function(e,t){var r=t.startOffset,i=t.endOffset,n=t.type,s=this.id3Track,o=this.hls;if(o){var u,d=o.config,c=d.enableEmsgMetadataCues,h=d.enableID3MetadataCues;s&&(c||h)&&(u="audio"===n?function(e){return e.type===l.MetadataSchema.audioId3&&h}:"video"===n?function(e){return e.type===l.MetadataSchema.emsg&&c}:function(e){return e.type===l.MetadataSchema.audioId3&&h||e.type===l.MetadataSchema.emsg&&c},(0,a.removeCuesInRange)(s,r,i,u))}},t.onLevelUpdated=function(e,t){var r=this,n=t.details;if(this.media&&n.hasProgramDateTime&&this.hls.config.enableDateRangeMetadataCues){var a=this.dateRangeCuesAppended,s=this.id3Track,h=n.dateRanges,f=Object.keys(h);if(s)for(var v=Object.keys(a).filter((function(e){return!f.includes(e)})),g=function(e){var t=v[e];Object.keys(a[t].cues).forEach((function(e){s.removeCue(a[t].cues[e])})),delete a[t]},m=v.length;m--;)g(m);var p=n.fragments[n.fragments.length-1];if(0!==f.length&&(0,i.isFiniteNumber)(null==p?void 0:p.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var y=p.programDateTime/1e3-p.start,E=u(),T=function(e){var t=f[e],i=h[t],n=a[t],s=(null==n?void 0:n.cues)||{},u=(null==n?void 0:n.durationKnown)||!1,v=c(i.startDate,y),g=d,m=i.endDate;if(m)g=c(m,y),u=!0;else if(i.endOnNext&&!u){var p=f.reduce((function(e,t){var r=h[t];return r.class===i.class&&r.id!==t&&r.startDate>i.startDate&&e.push(r),e}),[]).sort((function(e,t){return e.startDate.getTime()-t.startDate.getTime()}))[0];p&&(g=c(p.startDate,y),u=!0)}for(var T,S=Object.keys(i.attr),b=0;b<S.length;b++){var L=S[b];if(L!==o.DateRangeAttribute.ID&&L!==o.DateRangeAttribute.CLASS&&L!==o.DateRangeAttribute.START_DATE&&L!==o.DateRangeAttribute.DURATION&&L!==o.DateRangeAttribute.END_DATE&&L!==o.DateRangeAttribute.END_ON_NEXT){var A=s[L];if(A)u&&!n.durationKnown&&(A.endTime=g);else{var D=i.attr[L];A=new E(v,g,""),L!==o.DateRangeAttribute.SCTE35_OUT&&L!==o.DateRangeAttribute.SCTE35_IN||(T=D,D=Uint8Array.from(T.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer),A.value={key:L,data:D},A.type=l.MetadataSchema.dateRange,r.id3Track.addCue(A),s[L]=A}}}a[t]={cues:s,dateRange:i,durationKnown:u}},S=0;S<f.length;S++)T(S)}}},e}()},"./src/controller/latency-controller.ts":(e,t,r)=>{r.r(t),r.d(t,{default:()=>o});var i=r("./src/errors.ts"),n=r("./src/events.ts"),a=r("./src/utils/logger.ts");function s(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(n=i.key,a=void 0,"symbol"==typeof(a=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(n,"string"))?a:String(a)),i)}var n,a}var o=function(){function e(e){var t=this;this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=function(){return t.timeupdate()},this.hls=e,this.config=e.config,this.registerListeners()}var t,r,o,l=e.prototype;return l.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},l.registerListeners=function(){this.hls.on(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(n.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(n.Events.ERROR,this.onError,this)},l.unregisterListeners=function(){this.hls.off(n.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(n.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(n.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(n.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(n.Events.ERROR,this.onError)},l.onMediaAttached=function(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},l.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},l.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},l.onLevelUpdated=function(e,t){var r=t.details;this.levelDetails=r,r.advanced&&this.timeupdate(),!r.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},l.onError=function(e,t){t.details===i.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,a.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},l.timeupdate=function(){var e=this.media,t=this.levelDetails;if(e&&t){this.currentTime=e.currentTime;var r=this.computeLatency();if(null!==r){this._latency=r;var i=this.config,n=i.lowLatencyMode,a=i.maxLiveSyncPlaybackRate;if(n&&1!==a){var s=this.targetLatency;if(null!==s){var o=r-s,l=o<Math.min(this.maxLatency,s+t.targetduration);if(t.live&&l&&o>.05&&this.forwardBufferLength>1){var u=Math.min(2,Math.max(1,a)),d=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;e.playbackRate=Math.min(u,Math.max(1,d))}else 1!==e.playbackRate&&0!==e.playbackRate&&(e.playbackRate=1)}}}}},l.estimateLiveEdge=function(){var e=this.levelDetails;return null===e?null:e.edge+e.age},l.computeLatency=function(){var e=this.estimateLiveEdge();return null===e?null:e-this.currentTime},t=e,(r=[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var e=this.config,t=this.levelDetails;return void 0!==e.liveMaxLatencyDuration?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}},{key:"targetLatency",get:function(){var e=this.levelDetails;if(null===e)return null;var t=e.holdBack,r=e.partHoldBack,i=e.targetduration,n=this.config,a=n.liveSyncDuration,s=n.liveSyncDurationCount,o=n.lowLatencyMode,l=this.hls.userConfig,u=o&&r||t;(l.liveSyncDuration||l.liveSyncDurationCount||0===u)&&(u=void 0!==a?a:s*i);var d=i;return u+Math.min(1*this.stallCount,d)}},{key:"liveSyncPosition",get:function(){var e=this.estimateLiveEdge(),t=this.targetLatency,r=this.levelDetails;if(null===e||null===t||null===r)return null;var i=r.edge,n=e-t-this.edgeStalled,a=i-r.totalduration,s=i-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(a,n),s)}},{key:"drift",get:function(){var e=this.levelDetails;return null===e?1:e.drift}},{key:"edgeStalled",get:function(){var e=this.levelDetails;if(null===e)return 0;var t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}},{key:"forwardBufferLength",get:function(){var e=this.media,t=this.levelDetails;if(!e||!t)return 0;var r=e.buffered.length;return(r?e.buffered.end(r-1):t.edge)-this.currentTime}}])&&s(t.prototype,r),o&&s(t,o),Object.defineProperty(t,"prototype",{writable:!1}),e}()},"./src/controller/level-controller.ts":(e,t,r)=>{r.r(t),r.d(t,{default:()=>v});var i=r("./src/types/level.ts"),n=r("./src/events.ts"),a=r("./src/errors.ts"),s=r("./src/utils/codecs.ts"),o=r("./src/controller/level-helper.ts"),l=r("./src/controller/base-playlist-controller.ts"),u=r("./src/types/loader.ts");function d(){return d=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},d.apply(this,arguments)}function c(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(n=i.key,a=void 0,"symbol"==typeof(a=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(n,"string"))?a:String(a)),i)}var n,a}function h(e,t){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},h(e,t)}var f=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),v=function(e){var t,r;function l(t){var r;return(r=e.call(this,t,"[level-controller]")||this)._levels=[],r._firstLevel=-1,r._startLevel=void 0,r.currentLevelIndex=-1,r.manualLevelIndex=-1,r.onParsedComplete=void 0,r._registerListeners(),r}r=e,(t=l).prototype=Object.create(r.prototype),t.prototype.constructor=t,h(t,r);var v,g,m,p=l.prototype;return p._registerListeners=function(){var e=this.hls;e.on(n.Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(n.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(n.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(n.Events.FRAG_LOADED,this.onFragLoaded,this),e.on(n.Events.ERROR,this.onError,this)},p._unregisterListeners=function(){var e=this.hls;e.off(n.Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(n.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(n.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(n.Events.FRAG_LOADED,this.onFragLoaded,this),e.off(n.Events.ERROR,this.onError,this)},p.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,e.prototype.destroy.call(this)},p.startLoad=function(){this._levels.forEach((function(e){e.loadError=0})),e.prototype.startLoad.call(this)},p.onManifestLoaded=function(e,t){var r,l,u=[],d=[],c=[],h={},v=!1,g=!1,m=!1;if(t.levels.forEach((function(e){var t=e.attrs;v=v||!(!e.width||!e.height),g=g||!!e.videoCodec,m=m||!!e.audioCodec,f&&e.audioCodec&&-1!==e.audioCodec.indexOf("mp4a.40.34")&&(e.audioCodec=void 0);var r=e.bitrate+"-"+e.attrs.RESOLUTION+"-"+e.attrs.CODECS;(l=h[r])?l.url.push(e.url):(l=new i.Level(e),h[r]=l,u.push(l)),t&&(t.AUDIO&&(0,o.addGroupId)(l,"audio",t.AUDIO),t.SUBTITLES&&(0,o.addGroupId)(l,"text",t.SUBTITLES))})),(v||g)&&m&&(u=u.filter((function(e){var t=e.videoCodec,r=e.width,i=e.height;return!!t||!(!r||!i)}))),u=u.filter((function(e){var t=e.audioCodec,r=e.videoCodec;return(!t||(0,s.isCodecSupportedInMp4)(t,"audio"))&&(!r||(0,s.isCodecSupportedInMp4)(r,"video"))})),t.audioTracks&&(d=t.audioTracks.filter((function(e){return!e.audioCodec||(0,s.isCodecSupportedInMp4)(e.audioCodec,"audio")})),(0,o.assignTrackIdsByGroup)(d)),t.subtitles&&(c=t.subtitles,(0,o.assignTrackIdsByGroup)(c)),u.length>0){r=u[0].bitrate,u.sort((function(e,t){return e.attrs["HDCP-LEVEL"]!==t.attrs["HDCP-LEVEL"]?(e.attrs["HDCP-LEVEL"]||"")>(t.attrs["HDCP-LEVEL"]||"")?1:-1:e.bitrate!==t.bitrate?e.bitrate-t.bitrate:e.attrs.SCORE!==t.attrs.SCORE?e.attrs.decimalFloatingPoint("SCORE")-t.attrs.decimalFloatingPoint("SCORE"):v&&e.height!==t.height?e.height-t.height:0})),this._levels=u;for(var p=0;p<u.length;p++)if(u[p].bitrate===r){this._firstLevel=p,this.log("manifest loaded, "+u.length+" level(s) found, first bitrate: "+r);break}var y=m&&!g,E={levels:u,audioTracks:d,subtitleTracks:c,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:m,video:g,altAudio:!y&&d.some((function(e){return!!e.url}))};this.hls.trigger(n.Events.MANIFEST_PARSED,E),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(n.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,reason:"no level with compatible codecs found in manifest"})},p.onError=function(t,r){var n,s;if(e.prototype.onError.call(this,t,r),!r.fatal){var o=r.context,l=this._levels[this.currentLevelIndex];if(o&&(o.type===u.PlaylistContextType.AUDIO_TRACK&&l.audioGroupIds&&o.groupId===l.audioGroupIds[l.urlId]||o.type===u.PlaylistContextType.SUBTITLE_TRACK&&l.textGroupIds&&o.groupId===l.textGroupIds[l.urlId]))this.redundantFailover(this.currentLevelIndex);else{var d,c=!1,h=!0;switch(r.details){case a.ErrorDetails.FRAG_LOAD_ERROR:case a.ErrorDetails.FRAG_LOAD_TIMEOUT:case a.ErrorDetails.KEY_LOAD_ERROR:case a.ErrorDetails.KEY_LOAD_TIMEOUT:if(r.frag){var f=r.frag.type===u.PlaylistLevelType.MAIN?r.frag.level:this.currentLevelIndex,v=this._levels[f];v?(v.fragmentError++,v.fragmentError>this.hls.config.fragLoadingMaxRetry&&(d=f)):d=f}break;case a.ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:var g=l.attrs["HDCP-LEVEL"];g&&(this.hls.maxHdcpLevel=i.HdcpLevels[i.HdcpLevels.indexOf(g)-1],this.warn('Restricting playback to HDCP-LEVEL of "'+this.hls.maxHdcpLevel+'" or lower'));case a.ErrorDetails.FRAG_PARSING_ERROR:case a.ErrorDetails.KEY_SYSTEM_NO_SESSION:d=(null===(n=r.frag)||void 0===n?void 0:n.type)===u.PlaylistLevelType.MAIN?r.frag.level:this.currentLevelIndex,r.levelRetry=!1;break;case a.ErrorDetails.LEVEL_LOAD_ERROR:case a.ErrorDetails.LEVEL_LOAD_TIMEOUT:o&&(o.deliveryDirectives&&(h=!1),d=o.level),c=!0;break;case a.ErrorDetails.REMUX_ALLOC_ERROR:d=null!=(s=r.level)?s:this.currentLevelIndex,c=!0}void 0!==d&&this.recoverLevel(r,d,c,h)}}},p.recoverLevel=function(e,t,r,i){var n=e.details,a=this._levels[t];if(a.loadError++,r){if(!this.retryLoadingOrFail(e))return void(this.currentLevelIndex=-1);e.levelRetry=!0}if(i){var s=a.url.length;if(s>1&&a.loadError<s)e.levelRetry=!0,this.redundantFailover(t);else if(-1===this.manualLevelIndex){for(var o=-1,l=this._levels,u=l.length;u--;){var d=(u+this.currentLevelIndex)%l.length;if(d!==this.currentLevelIndex&&0===l[d].loadError){o=d;break}}o>-1&&this.currentLevelIndex!==o?(this.warn(n+": switch to "+o),e.levelRetry=!0,this.hls.nextAutoLevel=o):!1===e.levelRetry&&(e.fatal=!0)}}},p.redundantFailover=function(e){var t=this._levels[e],r=t.url.length;if(r>1){var i=(t.urlId+1)%r;this.warn("Switching to redundant URL-id "+i),this._levels.forEach((function(e){e.urlId=i})),this.level=e}},p.onFragLoaded=function(e,t){var r=t.frag;if(void 0!==r&&r.type===u.PlaylistLevelType.MAIN){var i=this._levels[r.level];void 0!==i&&(i.fragmentError=0,i.loadError=0)}},p.onLevelLoaded=function(e,t){var r,i,n=t.level,a=t.details,s=this._levels[n];if(!s)return this.warn("Invalid level index "+n),void(null!==(i=t.deliveryDirectives)&&void 0!==i&&i.skip&&(a.deltaUpdateFailed=!0));n===this.currentLevelIndex?(0===s.fragmentError&&(s.loadError=0,this.retryCount=0),this.playlistLoaded(n,t,s.details)):null!==(r=t.deliveryDirectives)&&void 0!==r&&r.skip&&(a.deltaUpdateFailed=!0)},p.onAudioTrackSwitched=function(e,t){var r=this.hls.levels[this.currentLevelIndex];if(r&&r.audioGroupIds){for(var i=-1,n=this.hls.audioTracks[t.id].groupId,a=0;a<r.audioGroupIds.length;a++)if(r.audioGroupIds[a]===n){i=a;break}i!==r.urlId&&(r.urlId=i,this.startLoad())}},p.loadPlaylist=function(t){e.prototype.loadPlaylist.call(this);var r=this.currentLevelIndex,i=this._levels[r];if(this.canLoad&&i&&i.url.length>0){var a=i.urlId,s=i.url[a];if(t)try{s=t.addDirectives(s)}catch(e){this.warn("Could not construct new URL with HLS Delivery Directives: "+e)}this.log("Attempt loading level index "+r+(void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:"")+" with URL-id "+a+" "+s),this.clearTimer(),this.hls.trigger(n.Events.LEVEL_LOADING,{url:s,level:r,id:a,deliveryDirectives:t||null})}},p.removeLevel=function(e,t){var r=function(e,r){return r!==t},i=this._levels.filter((function(i,n){return n!==e||i.url.length>1&&void 0!==t&&(i.url=i.url.filter(r),i.audioGroupIds&&(i.audioGroupIds=i.audioGroupIds.filter(r)),i.textGroupIds&&(i.textGroupIds=i.textGroupIds.filter(r)),i.urlId=0,!0)})).map((function(e,t){var r=e.details;return null!=r&&r.fragments&&r.fragments.forEach((function(e){e.level=t})),e}));this._levels=i,this.hls.trigger(n.Events.LEVELS_UPDATED,{levels:i})},v=l,(g=[{key:"levels",get:function(){return 0===this._levels.length?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(e){var t,r=this._levels;if(0!==r.length&&(this.currentLevelIndex!==e||null===(t=r[e])||void 0===t||!t.details)){if(e<0||e>=r.length){var i=e<0;if(this.hls.trigger(n.Events.ERROR,{type:a.ErrorTypes.OTHER_ERROR,details:a.ErrorDetails.LEVEL_SWITCH_ERROR,level:e,fatal:i,reason:"invalid level idx"}),i)return;e=Math.min(e,r.length-1)}this.clearTimer();var s=this.currentLevelIndex,o=r[s],l=r[e];this.log("switching to level "+e+" from "+s),this.currentLevelIndex=e;var u=d({},l,{level:e,maxBitrate:l.maxBitrate,uri:l.uri,urlId:l.urlId});delete u._urlId,this.hls.trigger(n.Events.LEVEL_SWITCHING,u);var c=l.details;if(!c||c.live){var h=this.switchParams(l.uri,null==o?void 0:o.details);this.loadPlaylist(h)}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(e){this._firstLevel=e}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var e=this.hls.config.startLevel;return void 0!==e?e:this._firstLevel}return this._startLevel},set:function(e){this._startLevel=e}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}}])&&c(v.prototype,g),m&&c(v,m),Object.defineProperty(v,"prototype",{writable:!1}),l}(l.default)},"./src/controller/level-helper.ts":(e,t,r)=>{r.r(t),r.d(t,{addGroupId:()=>o,addSliding:()=>m,adjustSliding:()=>g,assignTrackIdsByGroup:()=>l,computeReloadInterval:()=>p,getFragmentWithSN:()=>y,getPartWith:()=>E,mapFragmentIntersection:()=>v,mapPartIntersection:()=>f,mergeDetails:()=>h,updateFragPTSDTS:()=>c,updatePTS:()=>u});var i=r("./src/polyfills/number.ts"),n=r("./src/utils/logger.ts"),a=r("./src/loader/date-range.ts");function s(){return s=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},s.apply(this,arguments)}function o(e,t,r){switch(t){case"audio":e.audioGroupIds||(e.audioGroupIds=[]),e.audioGroupIds.push(r);break;case"text":e.textGroupIds||(e.textGroupIds=[]),e.textGroupIds.push(r)}}function l(e){var t={};e.forEach((function(e){var r=e.groupId||"";e.id=t[r]=t[r]||0,t[r]++}))}function u(e,t,r){d(e[t],e[r])}function d(e,t){var r=t.startPTS;if((0,i.isFiniteNumber)(r)){var n,a=0;t.sn>e.sn?(a=r-e.start,n=e):(a=e.start-r,n=t),n.duration!==a&&(n.duration=a)}else t.sn>e.sn?e.cc===t.cc&&e.minEndPTS?t.start=e.start+(e.minEndPTS-e.start):t.start=e.start+e.duration:t.start=Math.max(e.start-t.duration,0)}function c(e,t,r,a,s,o){a-r<=0&&(n.logger.warn("Fragment should have a positive duration",t),a=r+t.duration,o=s+t.duration);var l=r,u=a,c=t.startPTS,h=t.endPTS;if((0,i.isFiniteNumber)(c)){var f=Math.abs(c-r);(0,i.isFiniteNumber)(t.deltaPTS)?t.deltaPTS=Math.max(f,t.deltaPTS):t.deltaPTS=f,l=Math.max(r,c),r=Math.min(r,c),s=Math.min(s,t.startDTS),u=Math.min(a,h),a=Math.max(a,h),o=Math.max(o,t.endDTS)}t.duration=a-r;var v=r-t.start;t.start=t.startPTS=r,t.maxStartPTS=l,t.startDTS=s,t.endPTS=a,t.minEndPTS=u,t.endDTS=o;var g,m=t.sn;if(!e||m<e.startSN||m>e.endSN)return 0;var p=m-e.startSN,y=e.fragments;for(y[p]=t,g=p;g>0;g--)d(y[g],y[g-1]);for(g=p;g<y.length-1;g++)d(y[g],y[g+1]);return e.fragmentHint&&d(y[y.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,v}function h(e,t){for(var r=null,o=e.fragments,l=o.length-1;l>=0;l--){var u=o[l].initSegment;if(u){r=u;break}}e.fragmentHint&&delete e.fragmentHint.endPTS;var d,h,m,p,y,E=0;if(v(e,t,(function(e,n){e.relurl&&(E=e.cc-n.cc),(0,i.isFiniteNumber)(e.startPTS)&&(0,i.isFiniteNumber)(e.endPTS)&&(n.start=n.startPTS=e.startPTS,n.startDTS=e.startDTS,n.appendedPTS=e.appendedPTS,n.maxStartPTS=e.maxStartPTS,n.endPTS=e.endPTS,n.endDTS=e.endDTS,n.minEndPTS=e.minEndPTS,n.duration=e.endPTS-e.startPTS,n.duration&&(d=n),t.PTSKnown=t.alignedSliding=!0),n.elementaryStreams=e.elementaryStreams,n.loader=e.loader,n.stats=e.stats,n.urlId=e.urlId,e.initSegment&&(n.initSegment=e.initSegment,r=e.initSegment)})),r&&(t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments).forEach((function(e){var t;e.initSegment&&e.initSegment.relurl!==(null===(t=r)||void 0===t?void 0:t.relurl)||(e.initSegment=r)})),t.skippedSegments)if(t.deltaUpdateFailed=t.fragments.some((function(e){return!e})),t.deltaUpdateFailed){n.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var T=t.skippedSegments;T--;)t.fragments.shift();t.startSN=t.fragments[0].sn,t.startCC=t.fragments[0].cc}else t.canSkipDateRanges&&(t.dateRanges=(h=e.dateRanges,m=t.dateRanges,p=t.recentlyRemovedDateranges,y=s({},h),p&&p.forEach((function(e){delete y[e]})),Object.keys(m).forEach((function(e){var t=new a.DateRange(m[e].attr,y[e]);t.isValid?y[e]=t:n.logger.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(m[e].attr)+'"')})),y));var S=t.fragments;if(E){n.logger.warn("discontinuity sliding from playlist, take drift into account");for(var b=0;b<S.length;b++)S[b].cc+=E}t.skippedSegments&&(t.startCC=t.fragments[0].cc),f(e.partList,t.partList,(function(e,t){t.elementaryStreams=e.elementaryStreams,t.stats=e.stats})),d?c(t,d,d.startPTS,d.endPTS,d.startDTS,d.endDTS):g(e,t),S.length&&(t.totalduration=t.edge-S[0].start),t.driftStartTime=e.driftStartTime,t.driftStart=e.driftStart;var L=t.advancedDateTime;if(t.advanced&&L){var A=t.edge;t.driftStart||(t.driftStartTime=L,t.driftStart=A),t.driftEndTime=L,t.driftEnd=A}else t.driftEndTime=e.driftEndTime,t.driftEnd=e.driftEnd,t.advancedDateTime=e.advancedDateTime}function f(e,t,r){if(e&&t)for(var i=0,n=0,a=e.length;n<=a;n++){var s=e[n],o=t[n+i];s&&o&&s.index===o.index&&s.fragment.sn===o.fragment.sn?r(s,o):i--}}function v(e,t,r){for(var i=t.skippedSegments,n=Math.max(e.startSN,t.startSN)-t.startSN,a=(e.fragmentHint?1:0)+(i?t.endSN:Math.min(e.endSN,t.endSN))-t.startSN,s=t.startSN-e.startSN,o=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,l=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,u=n;u<=a;u++){var d=l[s+u],c=o[u];i&&!c&&u<i&&(c=t.fragments[u]=d),d&&c&&r(d,c)}}function g(e,t){var r=t.startSN+t.skippedSegments-e.startSN,i=e.fragments;r<0||r>=i.length||m(t,i[r].start)}function m(e,t){if(t){for(var r=e.fragments,i=e.skippedSegments;i<r.length;i++)r[i].start+=t;e.fragmentHint&&(e.fragmentHint.start+=t)}}function p(e,t){void 0===t&&(t=1/0);var r=1e3*e.targetduration;if(e.updated){var i=e.fragments;if(i.length&&4*r>t){var n=1e3*i[i.length-1].duration;n<r&&(r=n)}}else r/=2;return Math.round(r)}function y(e,t,r){if(!e||!e.details)return null;var i=e.details,n=i.fragments[t-i.startSN];return n||((n=i.fragmentHint)&&n.sn===t?n:t<i.startSN&&r&&r.sn===t?r:null)}function E(e,t,r){if(!e||!e.details)return null;var i=e.details.partList;if(i)for(var n=i.length;n--;){var a=i[n];if(a.index===r&&a.fragment.sn===t)return a}return null}},"./src/controller/stream-controller.ts":(e,t,r)=>{r.r(t),r.d(t,{default:()=>p});var i=r("./src/polyfills/number.ts"),n=r("./src/controller/base-stream-controller.ts"),a=r("./src/is-supported.ts"),s=r("./src/events.ts"),o=r("./src/utils/buffer-helper.ts"),l=r("./src/controller/fragment-tracker.ts"),u=r("./src/types/loader.ts"),d=r("./src/loader/fragment.ts"),c=r("./src/demux/transmuxer-interface.ts"),h=r("./src/types/transmuxer.ts"),f=r("./src/controller/gap-controller.ts"),v=r("./src/errors.ts");function g(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(n=i.key,a=void 0,"symbol"==typeof(a=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(n,"string"))?a:String(a)),i)}var n,a}function m(e,t){return m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},m(e,t)}var p=function(e){var t,r;function p(t,r,i){var n;return(n=e.call(this,t,r,i,"[stream-controller]")||this).audioCodecSwap=!1,n.gapController=null,n.level=-1,n._forceStartLoad=!1,n.altAudio=!1,n.audioOnly=!1,n.fragPlaying=null,n.onvplaying=null,n.onvseeked=null,n.fragLastKbps=0,n.couldBacktrack=!1,n.backtrackFragment=null,n.audioCodecSwitch=!1,n.videoBuffer=null,n._registerListeners(),n}r=e,(t=p).prototype=Object.create(r.prototype),t.prototype.constructor=t,m(t,r);var y,E,T,S=p.prototype;return S._registerListeners=function(){var e=this.hls;e.on(s.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(s.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(s.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(s.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(s.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(s.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(s.Events.ERROR,this.onError,this),e.on(s.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(s.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(s.Events.BUFFER_CREATED,this.onBufferCreated,this),e.on(s.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(s.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(s.Events.FRAG_BUFFERED,this.onFragBuffered,this)},S._unregisterListeners=function(){var e=this.hls;e.off(s.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(s.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(s.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(s.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(s.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(s.Events.ERROR,this.onError,this),e.off(s.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(s.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(s.Events.BUFFER_CREATED,this.onBufferCreated,this),e.off(s.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(s.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(s.Events.FRAG_BUFFERED,this.onFragBuffered,this)},S.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},S.startLoad=function(e){if(this.levels){var t=this.lastCurrentTime,r=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var i=r.startLevel;-1===i&&(r.config.testBandwidth&&this.levels.length>1?(i=0,this.bitrateTest=!0):i=r.nextAutoLevel),this.level=r.nextLoadLevel=i,this.loadedmetadata=!1}t>0&&-1===e&&(this.log("Override startPosition with lastCurrentTime @"+t.toFixed(3)),e=t),this.state=n.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=n.State.STOPPED},S.stopLoad=function(){this._forceStartLoad=!1,e.prototype.stopLoad.call(this)},S.doTick=function(){switch(this.state){case n.State.IDLE:this.doTickIdle();break;case n.State.WAITING_LEVEL:var e,t=this.levels,r=this.level,i=null==t||null===(e=t[r])||void 0===e?void 0:e.details;if(i&&(!i.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(i))break;this.state=n.State.IDLE;break}break;case n.State.FRAG_LOADING_WAITING_RETRY:var a,s=self.performance.now(),o=this.retryDate;(!o||s>=o||null!==(a=this.media)&&void 0!==a&&a.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.level),this.state=n.State.IDLE)}this.onTickEnd()},S.onTickEnd=function(){e.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},S.doTickIdle=function(){var e=this.hls,t=this.levelLastLoaded,r=this.levels,i=this.media,a=e.config,o=e.nextLoadLevel;if(null!==t&&(i||!this.startFragRequested&&a.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)&&r&&r[o]){var c=r[o],h=this.getMainFwdBufferInfo();if(null!==h){var f=this.getLevelDetails();if(f&&this._streamEnded(h,f)){var v={};return this.altAudio&&(v.type="video"),this.hls.trigger(s.Events.BUFFER_EOS,v),void(this.state=n.State.ENDED)}this.level=e.nextLoadLevel=o;var g=c.details;if(!g||this.state===n.State.WAITING_LEVEL||g.live&&this.levelLastLoaded!==o)return this.level=o,void(this.state=n.State.WAITING_LEVEL);if(!(h.len>=this.getMaxBufferLength(c.maxBitrate))){this.backtrackFragment&&this.backtrackFragment.start>h.end&&(this.backtrackFragment=null);var m=this.backtrackFragment?this.backtrackFragment.start:h.end,p=this.getNextFragment(m,g);if(this.couldBacktrack&&!this.fragPrevious&&p&&"initSegment"!==p.sn&&this.fragmentTracker.getState(p)!==l.FragmentState.OK){var y,E=(null!=(y=this.backtrackFragment)?y:p).sn-g.startSN,T=g.fragments[E-1];T&&p.cc===T.cc&&(p=T,this.fragmentTracker.removeFragment(T))}else this.backtrackFragment&&h.len&&(this.backtrackFragment=null);if(p&&this.fragmentTracker.getState(p)===l.FragmentState.OK&&this.nextLoadPosition>m){var S=this.audioOnly&&!this.altAudio?d.ElementaryStreamTypes.AUDIO:d.ElementaryStreamTypes.VIDEO,b=(S===d.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;b&&this.afterBufferFlushed(b,S,u.PlaylistLevelType.MAIN),p=this.getNextFragment(this.nextLoadPosition,g)}p&&(!p.initSegment||p.initSegment.data||this.bitrateTest||(p=p.initSegment),this.loadFragment(p,g,m))}}}},S.loadFragment=function(t,r,i){var n,a=this.fragmentTracker.getState(t);this.fragCurrent=t,a===l.FragmentState.NOT_LOADED?"initSegment"===t.sn?this._loadInitSegment(t,r):this.bitrateTest?(this.log("Fragment "+t.sn+" of level "+t.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(t,r)):(this.startFragRequested=!0,e.prototype.loadFragment.call(this,t,r,i)):a===l.FragmentState.APPENDING?this.reduceMaxBufferLength(t.duration)&&this.fragmentTracker.removeFragment(t):0===(null===(n=this.media)||void 0===n?void 0:n.buffered.length)&&this.fragmentTracker.removeAllFragments()},S.getAppendedFrag=function(e){var t=this.fragmentTracker.getAppendedFrag(e,u.PlaylistLevelType.MAIN);return t&&"fragment"in t?t.fragment:t},S.getBufferedFrag=function(e){return this.fragmentTracker.getBufferedFrag(e,u.PlaylistLevelType.MAIN)},S.followingBufferedFrag=function(e){return e?this.getBufferedFrag(e.end+.5):null},S.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},S.nextLevelSwitch=function(){var e=this.levels,t=this.media;if(null!=t&&t.readyState){var r,i=this.getAppendedFrag(t.currentTime);if(i&&i.start>1&&this.flushMainBuffer(0,i.start-1),!t.paused&&e){var n=e[this.hls.nextLoadLevel],a=this.fragLastKbps;r=a&&this.fragCurrent?this.fragCurrent.duration*n.maxBitrate/(1e3*a)+1:0}else r=0;var s=this.getBufferedFrag(t.currentTime+r);if(s){var o=this.followingBufferedFrag(s);if(o){this.abortCurrentFrag();var l=o.maxStartPTS?o.maxStartPTS:o.start,u=o.duration,d=Math.max(s.end,l+Math.min(Math.max(u-this.config.maxFragLookUpTolerance,.5*u),.75*u));this.flushMainBuffer(d,Number.POSITIVE_INFINITY)}}}},S.abortCurrentFrag=function(){var e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&e.abortRequests(),this.state){case n.State.KEY_LOADING:case n.State.FRAG_LOADING:case n.State.FRAG_LOADING_WAITING_RETRY:case n.State.PARSING:case n.State.PARSED:this.state=n.State.IDLE}this.nextLoadPosition=this.getLoadPosition()},S.flushMainBuffer=function(t,r){e.prototype.flushMainBuffer.call(this,t,r,this.altAudio?"video":null)},S.onMediaAttached=function(t,r){e.prototype.onMediaAttached.call(this,t,r);var i=r.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),i.addEventListener("playing",this.onvplaying),i.addEventListener("seeked",this.onvseeked),this.gapController=new f.default(this.config,i,this.fragmentTracker,this.hls)},S.onMediaDetaching=function(){var t=this.media;t&&this.onvplaying&&this.onvseeked&&(t.removeEventListener("playing",this.onvplaying),t.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),e.prototype.onMediaDetaching.call(this)},S.onMediaPlaying=function(){this.tick()},S.onMediaSeeked=function(){var e=this.media,t=e?e.currentTime:null;(0,i.isFiniteNumber)(t)&&this.log("Media seeked to "+t.toFixed(3)),this.tick()},S.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(s.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null,this.backtrackFragment=null},S.onManifestParsed=function(e,t){var r,i=!1,n=!1;t.levels.forEach((function(e){(r=e.audioCodec)&&(-1!==r.indexOf("mp4a.40.2")&&(i=!0),-1!==r.indexOf("mp4a.40.5")&&(n=!0))})),this.audioCodecSwitch=i&&n&&!(0,a.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1},S.onLevelLoading=function(e,t){var r=this.levels;if(r&&this.state===n.State.IDLE){var i=r[t.level];(!i.details||i.details.live&&this.levelLastLoaded!==t.level||this.waitForCdnTuneIn(i.details))&&(this.state=n.State.WAITING_LEVEL)}},S.onLevelLoaded=function(e,t){var r,i=this.levels,a=t.level,o=t.details,l=o.totalduration;if(i){this.log("Level "+a+" loaded ["+o.startSN+","+o.endSN+"], cc ["+o.startCC+", "+o.endCC+"] duration:"+l);var u=this.fragCurrent;!u||this.state!==n.State.FRAG_LOADING&&this.state!==n.State.FRAG_LOADING_WAITING_RETRY||u.level!==t.level&&u.loader&&(this.state=n.State.IDLE,this.backtrackFragment=null,u.abortRequests());var d=i[a],c=0;if(o.live||null!==(r=d.details)&&void 0!==r&&r.live){if(o.fragments[0]||(o.deltaUpdateFailed=!0),o.deltaUpdateFailed)return;c=this.alignPlaylists(o,d.details)}if(d.details=o,this.levelLastLoaded=a,this.hls.trigger(s.Events.LEVEL_UPDATED,{details:o,level:a}),this.state===n.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(o))return;this.state=n.State.IDLE}this.startFragRequested?o.live&&this.synchronizeToLiveEdge(o):this.setStartPosition(o,c),this.tick()}else this.warn("Levels were reset while loading level "+a)},S._handleFragmentLoadProgress=function(e){var t,r=e.frag,i=e.part,n=e.payload,a=this.levels;if(a){var s=a[r.level],o=s.details;if(o){var l=s.videoCodec,d=o.PTSKnown||!o.live,f=null===(t=r.initSegment)||void 0===t?void 0:t.data,v=this._getAudioCodec(s),g=this.transmuxer=this.transmuxer||new c.default(this.hls,u.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),m=i?i.index:-1,p=-1!==m,y=new h.ChunkMetadata(r.level,r.sn,r.stats.chunkCount,n.byteLength,m,p),E=this.initPTS[r.cc];g.push(n,f,v,l,r,i,o.totalduration,d,y,E)}else this.warn("Dropping fragment "+r.sn+" of level "+r.level+" after level details were reset")}else this.warn("Levels were reset while fragment load was in progress. Fragment "+r.sn+" of level "+r.level+" will not be buffered")},S.onAudioTrackSwitching=function(e,t){var r=this.altAudio,i=!!t.url,n=t.id;if(!i){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var a=this.fragCurrent;a&&(this.log("Switching to main audio track, cancel main fragment load"),a.abortRequests()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var o=this.hls;r&&o.trigger(s.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),o.trigger(s.Events.AUDIO_TRACK_SWITCHED,{id:n})}},S.onAudioTrackSwitched=function(e,t){var r=t.id,i=!!this.hls.audioTracks[r].url;if(i){var n=this.videoBuffer;n&&this.mediaBuffer!==n&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=n)}this.altAudio=i,this.tick()},S.onBufferCreated=function(e,t){var r,i,n=t.tracks,a=!1;for(var s in n){var o=n[s];if("main"===o.id){if(i=s,r=o,"video"===s){var l=n[s];l&&(this.videoBuffer=l.buffer)}}else a=!0}a&&r?(this.log("Alternate track found, use "+i+".buffered to schedule main fragment loading"),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media},S.onFragBuffered=function(e,t){var r=t.frag,i=t.part;if(!r||r.type===u.PlaylistLevelType.MAIN){if(this.fragContextChanged(r))return this.warn("Fragment "+r.sn+(i?" p: "+i.index:"")+" of level "+r.level+" finished buffering, but was aborted. state: "+this.state),void(this.state===n.State.PARSED&&(this.state=n.State.IDLE));var a=i?i.stats:r.stats;this.fragLastKbps=Math.round(8*a.total/(a.buffering.end-a.loading.first)),"initSegment"!==r.sn&&(this.fragPrevious=r),this.fragBufferedComplete(r,i)}},S.onError=function(e,t){if(t.type!==v.ErrorTypes.KEY_SYSTEM_ERROR)switch(t.details){case v.ErrorDetails.FRAG_LOAD_ERROR:case v.ErrorDetails.FRAG_LOAD_TIMEOUT:case v.ErrorDetails.FRAG_PARSING_ERROR:case v.ErrorDetails.KEY_LOAD_ERROR:case v.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(u.PlaylistLevelType.MAIN,t);break;case v.ErrorDetails.LEVEL_LOAD_ERROR:case v.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==n.State.ERROR&&(t.fatal?(this.warn(""+t.details),this.state=n.State.ERROR):t.levelRetry||this.state!==n.State.WAITING_LEVEL||(this.state=n.State.IDLE));break;case v.ErrorDetails.BUFFER_FULL_ERROR:if("main"===t.parent&&(this.state===n.State.PARSING||this.state===n.State.PARSED)){var r=!0,i=this.getFwdBufferInfo(this.media,u.PlaylistLevelType.MAIN);i&&i.len>.5&&(r=!this.reduceMaxBufferLength(i.len)),r&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}}else this.onFragmentOrKeyLoadError(u.PlaylistLevelType.MAIN,t)},S.checkBuffer=function(){var e=this.media,t=this.gapController;if(e&&t&&e.readyState){if(this.loadedmetadata||!o.BufferHelper.getBuffered(e).length){var r=this.state!==n.State.IDLE?this.fragCurrent:null;t.poll(this.lastCurrentTime,r)}this.lastCurrentTime=e.currentTime}},S.onFragLoadEmergencyAborted=function(){this.state=n.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},S.onBufferFlushed=function(e,t){var r=t.type;if(r!==d.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var i=(r===d.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(i,r,u.PlaylistLevelType.MAIN)}},S.onLevelsUpdated=function(e,t){this.levels=t.levels},S.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},S.seekToStartPos=function(){var e=this.media;if(e){var t=e.currentTime,r=this.startPosition;if(r>=0&&t<r){if(e.seeking)return void this.log("could not seek to "+r+", already seeking at "+t);var i=o.BufferHelper.getBuffered(e),n=(i.length?i.start(0):0)-r;n>0&&(n<this.config.maxBufferHole||n<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+n+" to match buffer start"),r+=n,this.startPosition=r),this.log("seek to target start position "+r+" from current time "+t),e.currentTime=r}}},S._getAudioCodec=function(e){var t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t=-1!==t.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),t},S._loadBitrateTestFrag=function(e,t){var r=this;e.bitrateTest=!0,this._doFragLoad(e,t).then((function(t){var i=r.hls;if(t&&!r.fragContextChanged(e)){r.fragLoadError=0,r.state=n.State.IDLE,r.startFragRequested=!1,r.bitrateTest=!1;var a=e.stats;a.parsing.start=a.parsing.end=a.buffering.start=a.buffering.end=self.performance.now(),i.trigger(s.Events.FRAG_LOADED,t),e.bitrateTest=!1}}))},S._handleTransmuxComplete=function(e){var t,r="main",a=this.hls,o=e.remuxResult,l=e.chunkMeta,u=this.getCurrentContext(l);if(!u)return this.warn("The loading context changed while buffering fragment "+l.sn+" of level "+l.level+". This chunk will not be buffered."),void this.resetStartWhenNotLoaded(l.level);var c=u.frag,h=u.part,f=u.level,v=o.video,g=o.text,m=o.id3,p=o.initSegment,y=f.details,E=this.altAudio?void 0:o.audio;if(!this.fragContextChanged(c)){if(this.state=n.State.PARSING,p){p.tracks&&(this._bufferInitSegment(f,p.tracks,c,l),a.trigger(s.Events.FRAG_PARSING_INIT_SEGMENT,{frag:c,id:r,tracks:p.tracks}));var T=p.initPTS,S=p.timescale;(0,i.isFiniteNumber)(T)&&(this.initPTS[c.cc]=T,a.trigger(s.Events.INIT_PTS_FOUND,{frag:c,id:r,initPTS:T,timescale:S}))}if(v&&!1!==o.independent){if(y){var b=v.startPTS,L=v.endPTS,A=v.startDTS,D=v.endDTS;if(h)h.elementaryStreams[v.type]={startPTS:b,endPTS:L,startDTS:A,endDTS:D};else if(v.firstKeyFrame&&v.independent&&1===l.id&&(this.couldBacktrack=!0),v.dropped&&v.independent){var R=this.getMainFwdBufferInfo();if((R?R.end:this.getLoadPosition())+this.config.maxBufferHole<(v.firstKeyFramePTS?v.firstKeyFramePTS:b)-this.config.maxBufferHole)return void this.backtrack(c);c.setElementaryStreamInfo(v.type,c.start,L,c.start,D,!0)}c.setElementaryStreamInfo(v.type,b,L,A,D),this.backtrackFragment&&(this.backtrackFragment=c),this.bufferFragmentData(v,c,h,l)}}else if(!1===o.independent)return void this.backtrack(c);if(E){var k=E.startPTS,I=E.endPTS,_=E.startDTS,x=E.endDTS;h&&(h.elementaryStreams[d.ElementaryStreamTypes.AUDIO]={startPTS:k,endPTS:I,startDTS:_,endDTS:x}),c.setElementaryStreamInfo(d.ElementaryStreamTypes.AUDIO,k,I,_,x),this.bufferFragmentData(E,c,h,l)}if(y&&null!=m&&null!==(t=m.samples)&&void 0!==t&&t.length){var C={id:r,frag:c,details:y,samples:m.samples};a.trigger(s.Events.FRAG_PARSING_METADATA,C)}if(y&&g){var w={id:r,frag:c,details:y,samples:g.samples};a.trigger(s.Events.FRAG_PARSING_USERDATA,w)}}},S._bufferInitSegment=function(e,t,r,i){var a=this;if(this.state===n.State.PARSING){this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;var o=t.audio,l=t.video,u=t.audiovideo;if(o){var d=e.audioCodec,c=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(d&&(d=-1!==d.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),1!==o.metadata.channelCount&&-1===c.indexOf("firefox")&&(d="mp4a.40.5")),-1!==c.indexOf("android")&&"audio/mpeg"!==o.container&&(d="mp4a.40.2",this.log("Android: force audio codec to "+d)),e.audioCodec&&e.audioCodec!==d&&this.log('Swapping manifest audio codec "'+e.audioCodec+'" for "'+d+'"'),o.levelCodec=d,o.id="main",this.log("Init audio buffer, container:"+o.container+", codecs[selected/level/parsed]=["+(d||"")+"/"+(e.audioCodec||"")+"/"+o.codec+"]")}l&&(l.levelCodec=e.videoCodec,l.id="main",this.log("Init video buffer, container:"+l.container+", codecs[level/parsed]=["+(e.videoCodec||"")+"/"+l.codec+"]")),u&&this.log("Init audiovideo buffer, container:"+u.container+", codecs[level/parsed]=["+(e.attrs.CODECS||"")+"/"+u.codec+"]"),this.hls.trigger(s.Events.BUFFER_CODECS,t),Object.keys(t).forEach((function(e){var n=t[e].initSegment;null!=n&&n.byteLength&&a.hls.trigger(s.Events.BUFFER_APPENDING,{type:e,data:n,frag:r,part:null,chunkMeta:i,parent:r.type})})),this.tick()}},S.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,u.PlaylistLevelType.MAIN)},S.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=n.State.IDLE},S.checkFragmentChanged=function(){var e=this.media,t=null;if(e&&e.readyState>1&&!1===e.seeking){var r=e.currentTime;if(o.BufferHelper.isBuffered(e,r)?t=this.getAppendedFrag(r):o.BufferHelper.isBuffered(e,r+.1)&&(t=this.getAppendedFrag(r+.1)),t){this.backtrackFragment=null;var i=this.fragPlaying,n=t.level;i&&t.sn===i.sn&&i.level===n&&t.urlId===i.urlId||(this.fragPlaying=t,this.hls.trigger(s.Events.FRAG_CHANGED,{frag:t}),i&&i.level===n||this.hls.trigger(s.Events.LEVEL_SWITCHED,{level:n}))}}},y=p,(E=[{key:"nextLevel",get:function(){var e=this.nextBufferedFrag;return e?e.level:-1}},{key:"currentFrag",get:function(){var e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}},{key:"currentProgramDateTime",get:function(){var e=this.media;if(e){var t=e.currentTime,r=this.currentFrag;if(r&&(0,i.isFiniteNumber)(t)&&(0,i.isFiniteNumber)(r.programDateTime)){var n=r.programDateTime+1e3*(t-r.start);return new Date(n)}}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}}])&&g(y.prototype,E),T&&g(y,T),Object.defineProperty(y,"prototype",{writable:!1}),p}(n.default)},"./src/crypt/aes-crypto.ts":(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});var i=function(){function e(e,t){this.subtle=void 0,this.aesIV=void 0,this.subtle=e,this.aesIV=t}return e.prototype.decrypt=function(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)},e}()},"./src/crypt/aes-decryptor.ts":(e,t,r)=>{r.r(t),r.d(t,{default:()=>a,removePadding:()=>n});var i=r("./src/utils/typed-array.ts");function n(e){var t=e.byteLength,r=t&&new DataView(e.buffer).getUint8(t-1);return r?(0,i.sliceUint8)(e,0,t-r):e}var a=function(){function e(){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 t=e.prototype;return t.uint8ArrayToUint32Array_=function(e){for(var t=new DataView(e),r=new Uint32Array(4),i=0;i<4;i++)r[i]=t.getUint32(4*i);return r},t.initTable=function(){var e=this.sBox,t=this.invSBox,r=this.subMix,i=r[0],n=r[1],a=r[2],s=r[3],o=this.invSubMix,l=o[0],u=o[1],d=o[2],c=o[3],h=new Uint32Array(256),f=0,v=0,g=0;for(g=0;g<256;g++)h[g]=g<128?g<<1:g<<1^283;for(g=0;g<256;g++){var m=v^v<<1^v<<2^v<<3^v<<4;m=m>>>8^255&m^99,e[f]=m,t[m]=f;var p=h[f],y=h[p],E=h[y],T=257*h[m]^16843008*m;i[f]=T<<24|T>>>8,n[f]=T<<16|T>>>16,a[f]=T<<8|T>>>24,s[f]=T,T=16843009*E^65537*y^257*p^16843008*f,l[m]=T<<24|T>>>8,u[m]=T<<16|T>>>16,d[m]=T<<8|T>>>24,c[m]=T,f?(f=p^h[h[h[E^p]]],v^=h[h[v]]):f=v=1}},t.expandKey=function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,i=0;i<t.length&&r;)r=t[i]===this.key[i],i++;if(!r){this.key=t;var n=this.keySize=t.length;if(4!==n&&6!==n&&8!==n)throw new Error("Invalid aes key size="+n);var a,s,o,l,u=this.ksRows=4*(n+6+1),d=this.keySchedule=new Uint32Array(u),c=this.invKeySchedule=new Uint32Array(u),h=this.sBox,f=this.rcon,v=this.invSubMix,g=v[0],m=v[1],p=v[2],y=v[3];for(a=0;a<u;a++)a<n?o=d[a]=t[a]:(l=o,a%n==0?(l=h[(l=l<<8|l>>>24)>>>24]<<24|h[l>>>16&255]<<16|h[l>>>8&255]<<8|h[255&l],l^=f[a/n|0]<<24):n>6&&a%n==4&&(l=h[l>>>24]<<24|h[l>>>16&255]<<16|h[l>>>8&255]<<8|h[255&l]),d[a]=o=(d[a-n]^l)>>>0);for(s=0;s<u;s++)a=u-s,l=3&s?d[a]:d[a-4],c[s]=s<4||a<=4?l:g[h[l>>>24]]^m[h[l>>>16&255]]^p[h[l>>>8&255]]^y[h[255&l]],c[s]=c[s]>>>0}},t.networkToHostOrderSwap=function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24},t.decrypt=function(e,t,r){for(var i,n,a,s,o,l,u,d,c,h,f,v,g,m,p=this.keySize+6,y=this.invKeySchedule,E=this.invSBox,T=this.invSubMix,S=T[0],b=T[1],L=T[2],A=T[3],D=this.uint8ArrayToUint32Array_(r),R=D[0],k=D[1],I=D[2],_=D[3],x=new Int32Array(e),C=new Int32Array(x.length),w=this.networkToHostOrderSwap;t<x.length;){for(c=w(x[t]),h=w(x[t+1]),f=w(x[t+2]),v=w(x[t+3]),o=c^y[0],l=v^y[1],u=f^y[2],d=h^y[3],g=4,m=1;m<p;m++)i=S[o>>>24]^b[l>>16&255]^L[u>>8&255]^A[255&d]^y[g],n=S[l>>>24]^b[u>>16&255]^L[d>>8&255]^A[255&o]^y[g+1],a=S[u>>>24]^b[d>>16&255]^L[o>>8&255]^A[255&l]^y[g+2],s=S[d>>>24]^b[o>>16&255]^L[l>>8&255]^A[255&u]^y[g+3],o=i,l=n,u=a,d=s,g+=4;i=E[o>>>24]<<24^E[l>>16&255]<<16^E[u>>8&255]<<8^E[255&d]^y[g],n=E[l>>>24]<<24^E[u>>16&255]<<16^E[d>>8&255]<<8^E[255&o]^y[g+1],a=E[u>>>24]<<24^E[d>>16&255]<<16^E[o>>8&255]<<8^E[255&l]^y[g+2],s=E[d>>>24]<<24^E[o>>16&255]<<16^E[l>>8&255]<<8^E[255&u]^y[g+3],C[t]=w(i^R),C[t+1]=w(s^k),C[t+2]=w(a^I),C[t+3]=w(n^_),R=c,k=h,I=f,_=v,t+=4}return C.buffer},e}()},"./src/crypt/decrypter.ts":(e,t,r)=>{r.r(t),r.d(t,{default:()=>u});var i=r("./src/crypt/aes-crypto.ts"),n=r("./src/crypt/fast-aes-key.ts"),a=r("./src/crypt/aes-decryptor.ts"),s=r("./src/utils/logger.ts"),o=r("./src/utils/mp4-tools.ts"),l=r("./src/utils/typed-array.ts"),u=function(){function e(e,t){var r=(void 0===t?{}:t).removePKCS7Padding,i=void 0===r||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.useSoftware=e.enableSoftwareAES,this.removePKCS7Padding=i,i)try{var n=self.crypto;n&&(this.subtle=n.subtle||n.webkitSubtle)}catch(e){}null===this.subtle&&(this.useSoftware=!0)}var t=e.prototype;return t.destroy=function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},t.isSync=function(){return this.useSoftware},t.flush=function(){var e=this.currentResult,t=this.remainderData;if(!e||t)return this.reset(),null;var r=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?(0,a.removePadding)(r):r},t.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},t.decrypt=function(e,t,r){var i=this;return this.useSoftware?new Promise((function(n,a){i.softwareDecrypt(new Uint8Array(e),t,r);var s=i.flush();s?n(s.buffer):a(new Error("[softwareDecrypt] Failed to decrypt data"))})):this.webCryptoDecrypt(new Uint8Array(e),t,r)},t.softwareDecrypt=function(e,t,r){var i=this.currentIV,n=this.currentResult,s=this.remainderData;this.logOnce("JS AES decrypt"),s&&(e=(0,o.appendUint8Array)(s,e),this.remainderData=null);var u=this.getValidChunk(e);if(!u.length)return null;i&&(r=i);var d=this.softwareDecrypter;d||(d=this.softwareDecrypter=new a.default),d.expandKey(t);var c=n;return this.currentResult=d.decrypt(u.buffer,0,r),this.currentIV=(0,l.sliceUint8)(u,-16).buffer,c||null},t.webCryptoDecrypt=function(e,t,r){var a=this,o=this.subtle;return this.key===t&&this.fastAesKey||(this.key=t,this.fastAesKey=new n.default(o,t)),this.fastAesKey.expandKey().then((function(t){return o?(a.logOnce("WebCrypto AES decrypt"),new i.default(o,new Uint8Array(r)).decrypt(e.buffer,t)):Promise.reject(new Error("web crypto not initialized"))})).catch((function(i){return s.logger.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+i.name+": "+i.message),a.onWebCryptoError(e,t,r)}))},t.onWebCryptoError=function(e,t,r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r);var i=this.flush();if(i)return i.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")},t.getValidChunk=function(e){var t=e,r=e.length-e.length%16;return r!==e.length&&(t=(0,l.sliceUint8)(e,0,r),this.remainderData=(0,l.sliceUint8)(e,r)),t},t.logOnce=function(e){this.logEnabled&&(s.logger.log("[decrypter]: "+e),this.logEnabled=!1)},e}()},"./src/crypt/fast-aes-key.ts":(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});var i=function(){function e(e,t){this.subtle=void 0,this.key=void 0,this.subtle=e,this.key=t}return e.prototype.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},e}()},"./src/demux/aacdemuxer.ts":(e,t,r)=>{r.r(t),r.d(t,{default:()=>l});var i=r("./src/demux/base-audio-demuxer.ts"),n=r("./src/demux/adts.ts"),a=r("./src/utils/logger.ts"),s=r("./src/demux/id3.ts");function o(e,t){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},o(e,t)}const l=function(e){var t,r;function i(t,r){var i;return(i=e.call(this)||this).observer=void 0,i.config=void 0,i.observer=t,i.config=r,i}r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,o(t,r);var l=i.prototype;return l.resetInitSegment=function(t,r,i,n){e.prototype.resetInitSegment.call(this,t,r,i,n),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:r,duration:n,inputTimeScale:9e4,dropped:0}},i.probe=function(e){if(!e)return!1;for(var t=(s.getID3Data(e,0)||[]).length,r=e.length;t<r;t++)if(n.probe(e,t))return a.logger.log("ADTS sync word found !"),!0;return!1},l.canParse=function(e,t){return n.canParse(e,t)},l.appendFrame=function(e,t,r){n.initTrackConfig(e,this.observer,t,r,e.manifestCodec);var i=n.appendFrame(e,t,r,this.basePTS,this.frameIndex);if(i&&0===i.missing)return i},i}(i.default)},"./src/demux/adts.ts":(e,t,r)=>{r.r(t),r.d(t,{appendFrame:()=>p,canGetFrameLength:()=>d,canParse:()=>h,getAudioConfig:()=>s,getFrameDuration:()=>g,getFullFrameLength:()=>u,getHeaderLength:()=>l,initTrackConfig:()=>v,isHeader:()=>c,isHeaderPattern:()=>o,parseFrameHeader:()=>m,probe:()=>f});var i=r("./src/utils/logger.ts"),n=r("./src/errors.ts"),a=r("./src/events.ts");function s(e,t,r,s){var o,l,u,d,c=navigator.userAgent.toLowerCase(),h=s,f=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];o=1+((192&t[r+2])>>>6);var v=(60&t[r+2])>>>2;if(!(v>f.length-1))return u=(1&t[r+2])<<2,u|=(192&t[r+3])>>>6,i.logger.log("manifest codec:"+s+", ADTS type:"+o+", samplingIndex:"+v),/firefox/i.test(c)?v>=6?(o=5,d=new Array(4),l=v-3):(o=2,d=new Array(2),l=v):-1!==c.indexOf("android")?(o=2,d=new Array(2),l=v):(o=5,d=new Array(4),s&&(-1!==s.indexOf("mp4a.40.29")||-1!==s.indexOf("mp4a.40.5"))||!s&&v>=6?l=v-3:((s&&-1!==s.indexOf("mp4a.40.2")&&(v>=6&&1===u||/vivaldi/i.test(c))||!s&&1===u)&&(o=2,d=new Array(2)),l=v)),d[0]=o<<3,d[0]|=(14&v)>>1,d[1]|=(1&v)<<7,d[1]|=u<<3,5===o&&(d[1]|=(14&l)>>1,d[2]=(1&l)<<7,d[2]|=8,d[3]=0),{config:d,samplerate:f[v],channelCount:u,codec:"mp4a.40."+o,manifestCodec:h};e.trigger(a.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+v})}function o(e,t){return 255===e[t]&&240==(246&e[t+1])}function l(e,t){return 1&e[t+1]?7:9}function u(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function d(e,t){return t+5<e.length}function c(e,t){return t+1<e.length&&o(e,t)}function h(e,t){return d(e,t)&&o(e,t)&&u(e,t)<=e.length-t}function f(e,t){if(c(e,t)){var r=l(e,t);if(t+r>=e.length)return!1;var i=u(e,t);if(i<=r)return!1;var n=t+i;return n===e.length||c(e,n)}return!1}function v(e,t,r,n,a){if(!e.samplerate){var o=s(t,r,n,a);if(!o)return;e.config=o.config,e.samplerate=o.samplerate,e.channelCount=o.channelCount,e.codec=o.codec,e.manifestCodec=o.manifestCodec,i.logger.log("parsed codec:"+e.codec+", rate:"+o.samplerate+", channels:"+o.channelCount)}}function g(e){return 9216e4/e}function m(e,t){var r=l(e,t);if(t+r<=e.length){var i=u(e,t)-r;if(i>0)return{headerLength:r,frameLength:i}}}function p(e,t,r,i,n){var a,s=i+n*g(e.samplerate),o=m(t,r);if(o){var l=o.frameLength,u=o.headerLength,d=u+l,c=Math.max(0,r+d-t.length);c?(a=new Uint8Array(d-u)).set(t.subarray(r+u,t.length),0):a=t.subarray(r+u,r+d);var h={unit:a,pts:s};return c||e.samples.push(h),{sample:h,length:d,missing:c}}var f=t.length-r;return(a=new Uint8Array(f)).set(t.subarray(r,t.length),0),{sample:{unit:a,pts:s},length:f,missing:-1}}},"./src/demux/base-audio-demuxer.ts":(e,t,r)=>{r.r(t),r.d(t,{default:()=>c,initPTSFn:()=>d});var i=r("./src/polyfills/number.ts"),n=r("./src/demux/id3.ts"),a=r("./src/types/demuxer.ts"),s=r("./src/demux/dummy-demuxed-track.ts"),o=r("./src/utils/mp4-tools.ts"),l=r("./src/utils/typed-array.ts"),u=function(){function e(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var t=e.prototype;return t.resetInitSegment=function(e,t,r,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},t.resetTimeStamp=function(e){this.initPTS=e,this.resetContiguity()},t.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},t.canParse=function(e,t){return!1},t.appendFrame=function(e,t,r){},t.demux=function(e,t){this.cachedData&&(e=(0,o.appendUint8Array)(this.cachedData,e),this.cachedData=null);var r,u=n.getID3Data(e,0),c=u?u.length:0,h=this._audioTrack,f=this._id3Track,v=u?n.getTimeStamp(u):void 0,g=e.length;for((null===this.basePTS||0===this.frameIndex&&(0,i.isFiniteNumber)(v))&&(this.basePTS=d(v,t,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),u&&u.length>0&&f.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:u,type:a.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY});c<g;){if(this.canParse(e,c)){var m=this.appendFrame(h,e,c);m?(this.frameIndex++,this.lastPTS=m.sample.pts,r=c+=m.length):c=g}else n.canParse(e,c)?(u=n.getID3Data(e,c),f.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:u,type:a.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY}),r=c+=u.length):c++;if(c===g&&r!==g){var p=(0,l.sliceUint8)(e,r);this.cachedData?this.cachedData=(0,o.appendUint8Array)(this.cachedData,p):this.cachedData=p}}return{audioTrack:h,videoTrack:(0,s.dummyTrack)(),id3Track:f,textTrack:(0,s.dummyTrack)()}},t.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},t.flush=function(e){var t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:(0,s.dummyTrack)(),id3Track:this._id3Track,textTrack:(0,s.dummyTrack)()}},t.destroy=function(){},e}(),d=function(e,t,r){return(0,i.isFiniteNumber)(e)?90*e:9e4*t+(r||0)};const c=u},"./src/demux/chunk-cache.ts":(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});var i=function(){function e(){this.chunks=[],this.dataLength=0}var t=e.prototype;return t.push=function(e){this.chunks.push(e),this.dataLength+=e.length},t.flush=function(){var e,t=this.chunks,r=this.dataLength;return t.length?(e=1===t.length?t[0]:function(e,t){for(var r=new Uint8Array(t),i=0,n=0;n<e.length;n++){var a=e[n];r.set(a,i),i+=a.length}return r}(t,r),this.reset(),e):new Uint8Array(0)},t.reset=function(){this.chunks.length=0,this.dataLength=0},e}()},"./src/demux/dummy-demuxed-track.ts":(e,t,r)=>{function i(e,t){return void 0===e&&(e=""),void 0===t&&(t=9e4),{type:e,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}r.r(t),r.d(t,{dummyTrack:()=>i})},"./src/demux/exp-golomb.ts":(e,t,r)=>{r.r(t),r.d(t,{default:()=>n});var i=r("./src/utils/logger.ts");const n=function(){function e(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}var t=e.prototype;return t.loadWord=function(){var e=this.data,t=this.bytesAvailable,r=e.byteLength-t,i=new Uint8Array(4),n=Math.min(4,t);if(0===n)throw new Error("no bytes available");i.set(e.subarray(r,r+n)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*n,this.bytesAvailable-=n},t.skipBits=function(e){var t;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,e-=(t=e>>3)<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)},t.readBits=function(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;if(e>32&&i.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return(t=e-t)>0&&this.bitsAvailable?r<<t|this.readBits(t):r},t.skipLZ=function(){var e;for(e=0;e<this.bitsAvailable;++e)if(0!=(this.word&2147483648>>>e))return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()},t.skipUEG=function(){this.skipBits(1+this.skipLZ())},t.skipEG=function(){this.skipBits(1+this.skipLZ())},t.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},t.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},t.readBoolean=function(){return 1===this.readBits(1)},t.readUByte=function(){return this.readBits(8)},t.readUShort=function(){return this.readBits(16)},t.readUInt=function(){return this.readBits(32)},t.skipScalingList=function(e){for(var t=8,r=8,i=0;i<e;i++)0!==r&&(r=(t+this.readEG()+256)%256),t=0===r?t:r},t.readSPS=function(){var e,t,r,i=0,n=0,a=0,s=0,o=this.readUByte.bind(this),l=this.readBits.bind(this),u=this.readUEG.bind(this),d=this.readBoolean.bind(this),c=this.skipBits.bind(this),h=this.skipEG.bind(this),f=this.skipUEG.bind(this),v=this.skipScalingList.bind(this);o();var g=o();if(l(5),c(3),o(),f(),100===g||110===g||122===g||244===g||44===g||83===g||86===g||118===g||128===g){var m=u();if(3===m&&c(1),f(),f(),c(1),d())for(t=3!==m?8:12,r=0;r<t;r++)d()&&v(r<6?16:64)}f();var p=u();if(0===p)u();else if(1===p)for(c(1),h(),h(),e=u(),r=0;r<e;r++)h();f(),c(1);var y=u(),E=u(),T=l(1);0===T&&c(1),c(1),d()&&(i=u(),n=u(),a=u(),s=u());var S=[1,1];if(d()&&d())switch(o()){case 1:S=[1,1];break;case 2:S=[12,11];break;case 3:S=[10,11];break;case 4:S=[16,11];break;case 5:S=[40,33];break;case 6:S=[24,11];break;case 7:S=[20,11];break;case 8:S=[32,11];break;case 9:S=[80,33];break;case 10:S=[18,11];break;case 11:S=[15,11];break;case 12:S=[64,33];break;case 13:S=[160,99];break;case 14:S=[4,3];break;case 15:S=[3,2];break;case 16:S=[2,1];break;case 255:S=[o()<<8|o(),o()<<8|o()]}return{width:Math.ceil(16*(y+1)-2*i-2*n),height:(2-T)*(E+1)*16-(T?2:4)*(a+s),pixelRatio:S}},t.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},e}()},"./src/demux/id3.ts":(e,t,r)=>{r.r(t),r.d(t,{canParse:()=>l,decodeFrame:()=>f,getID3Data:()=>s,getID3Frames:()=>h,getTimeStamp:()=>u,isFooter:()=>a,isHeader:()=>n,isTimeStampFrame:()=>d,testables:()=>E,utf8ArrayToStr:()=>y});var i,n=function(e,t){return t+10<=e.length&&73===e[t]&&68===e[t+1]&&51===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128},a=function(e,t){return t+10<=e.length&&51===e[t]&&68===e[t+1]&&73===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128},s=function(e,t){for(var r=t,i=0;n(e,t);)i+=10,i+=o(e,t+6),a(e,t+10)&&(i+=10),t+=i;if(i>0)return e.subarray(r,r+i)},o=function(e,t){var r=0;return r=(127&e[t])<<21,r|=(127&e[t+1])<<14,r|=(127&e[t+2])<<7,r|=127&e[t+3]},l=function(e,t){return n(e,t)&&o(e,t+6)+10<=e.length-t},u=function(e){for(var t=h(e),r=0;r<t.length;r++){var i=t[r];if(d(i))return p(i)}},d=function(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info},c=function(e){var t=String.fromCharCode(e[0],e[1],e[2],e[3]),r=o(e,4);return{type:t,size:r,data:e.subarray(10,10+r)}},h=function(e){for(var t=0,r=[];n(e,t);){for(var i=o(e,t+6),s=(t+=10)+i;t+8<s;){var l=c(e.subarray(t)),u=f(l);u&&r.push(u),t+=l.size+10}a(e,t)&&(t+=10)}return r},f=function(e){return"PRIV"===e.type?v(e):"W"===e.type[0]?m(e):g(e)},v=function(e){if(!(e.size<2)){var t=y(e.data,!0),r=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:r.buffer}}},g=function(e){if(!(e.size<2)){if("TXXX"===e.type){var t=1,r=y(e.data.subarray(t),!0);t+=r.length+1;var i=y(e.data.subarray(t));return{key:e.type,info:r,data:i}}var n=y(e.data.subarray(1));return{key:e.type,data:n}}},m=function(e){if("WXXX"===e.type){if(e.size<2)return;var t=1,r=y(e.data.subarray(t),!0);t+=r.length+1;var i=y(e.data.subarray(t));return{key:e.type,info:r,data:i}}var n=y(e.data);return{key:e.type,data:n}},p=function(e){if(8===e.data.byteLength){var t=new Uint8Array(e.data),r=1&t[3],i=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return i/=45,r&&(i+=47721858.84),Math.round(i)}},y=function(e,t){void 0===t&&(t=!1);var r=T();if(r){var i=r.decode(e);if(t){var n=i.indexOf("\0");return-1!==n?i.substring(0,n):i}return i.replace(/\0/g,"")}for(var a,s,o,l=e.length,u="",d=0;d<l;){if(0===(a=e[d++])&&t)return u;if(0!==a&&3!==a)switch(a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:u+=String.fromCharCode(a);break;case 12:case 13:s=e[d++],u+=String.fromCharCode((31&a)<<6|63&s);break;case 14:s=e[d++],o=e[d++],u+=String.fromCharCode((15&a)<<12|(63&s)<<6|(63&o)<<0)}}return u},E={decodeTextFrame:g};function T(){return i||void 0===self.TextDecoder||(i=new self.TextDecoder("utf-8")),i}},"./src/demux/mp3demuxer.ts":(e,t,r)=>{r.r(t),r.d(t,{default:()=>u});var i=r("./src/demux/base-audio-demuxer.ts"),n=r("./src/demux/id3.ts"),a=r("./src/utils/logger.ts"),s=r("./src/demux/mpegaudio.ts");function o(e,t){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},o(e,t)}var l=function(e){var t,r;function i(){return e.apply(this,arguments)||this}r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,o(t,r);var l=i.prototype;return l.resetInitSegment=function(t,r,i,n){e.prototype.resetInitSegment.call(this,t,r,i,n),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:r,duration:n,inputTimeScale:9e4,dropped:0}},i.probe=function(e){if(!e)return!1;for(var t=(n.getID3Data(e,0)||[]).length,r=e.length;t<r;t++)if(s.probe(e,t))return a.logger.log("MPEG Audio sync word found !"),!0;return!1},l.canParse=function(e,t){return s.canParse(e,t)},l.appendFrame=function(e,t,r){if(null!==this.basePTS)return s.appendFrame(e,t,r,this.basePTS,this.frameIndex)},i}(i.default);const u=l},"./src/demux/mp4demuxer.ts":(e,t,r)=>{r.r(t),r.d(t,{default:()=>l});var i=r("./src/polyfills/number.ts"),n=r("./src/types/demuxer.ts"),a=r("./src/utils/mp4-tools.ts"),s=r("./src/demux/dummy-demuxed-track.ts"),o=/\/emsg[-/]ID3/i;const l=function(){function e(e,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 t=e.prototype;return t.resetTimeStamp=function(){},t.resetInitSegment=function(e,t,r,i){var n=this.videoTrack=(0,s.dummyTrack)("video",1),o=this.audioTrack=(0,s.dummyTrack)("audio",1),l=this.txtTrack=(0,s.dummyTrack)("text",1);if(this.id3Track=(0,s.dummyTrack)("id3",1),this.timeOffset=0,e&&e.byteLength){var u=(0,a.parseInitSegment)(e);if(u.video){var d=u.video,c=d.id,h=d.timescale,f=d.codec;n.id=c,n.timescale=l.timescale=h,n.codec=f}if(u.audio){var v=u.audio,g=v.id,m=v.timescale,p=v.codec;o.id=g,o.timescale=m,o.codec=p}l.id=a.RemuxerTrackIdConfig.text,n.sampleDuration=0,n.duration=o.duration=i}},t.resetContiguity=function(){},e.probe=function(e){return e=e.length>16384?e.subarray(0,16384):e,(0,a.findBox)(e,["moof"]).length>0},t.demux=function(e,t){this.timeOffset=t;var r=e,i=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=(0,a.appendUint8Array)(this.remainderData,e));var s=(0,a.segmentValidRange)(r);this.remainderData=s.remainder,i.samples=s.valid||new Uint8Array}else i.samples=r;var o=this.extractID3Track(i,t);return n.samples=(0,a.parseSamples)(t,i),{videoTrack:i,audioTrack:this.audioTrack,id3Track:o,textTrack:this.txtTrack}},t.flush=function(){var e=this.timeOffset,t=this.videoTrack,r=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;var i=this.extractID3Track(t,this.timeOffset);return r.samples=(0,a.parseSamples)(e,t),{videoTrack:t,audioTrack:(0,s.dummyTrack)(),id3Track:i,textTrack:(0,s.dummyTrack)()}},t.extractID3Track=function(e,t){var r=this.id3Track;if(e.samples.length){var s=(0,a.findBox)(e.samples,["emsg"]);s&&s.forEach((function(e){var s=(0,a.parseEmsg)(e);if(o.test(s.schemeIdUri)){var l=(0,i.isFiniteNumber)(s.presentationTime)?s.presentationTime/s.timeScale:t+s.presentationTimeDelta/s.timeScale,u=4294967295===s.eventDuration?Number.POSITIVE_INFINITY:s.eventDuration/s.timeScale;u<=.001&&(u=Number.POSITIVE_INFINITY);var d=s.payload;r.samples.push({data:d,len:d.byteLength,dts:l,pts:l,type:n.MetadataSchema.emsg,duration:u})}}))}return r},t.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},t.destroy=function(){},e}()},"./src/demux/mpegaudio.ts":(e,t,r)=>{r.r(t),r.d(t,{appendFrame:()=>l,canParse:()=>h,isHeader:()=>c,isHeaderPattern:()=>d,parseHeader:()=>u,probe:()=>f});var i=null,n=[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],a=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],s=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],o=[0,1,1,4];function l(e,t,r,i,n){if(!(r+24>t.length)){var a=u(t,r);if(a&&r+a.frameLength<=t.length){var s=i+n*(9e4*a.samplesPerFrame/a.sampleRate),o={unit:t.subarray(r,r+a.frameLength),pts:s,dts:s};return e.config=[],e.channelCount=a.channelCount,e.samplerate=a.sampleRate,e.samples.push(o),{sample:o,length:a.frameLength,missing:0}}}}function u(e,t){var r=e[t+1]>>3&3,l=e[t+1]>>1&3,u=e[t+2]>>4&15,d=e[t+2]>>2&3;if(1!==r&&0!==u&&15!==u&&3!==d){var c=e[t+2]>>1&1,h=e[t+3]>>6,f=1e3*n[14*(3===r?3-l:3===l?3:4)+u-1],v=a[3*(3===r?0:2===r?1:2)+d],g=3===h?1:2,m=s[r][l],p=o[l],y=8*m*p,E=Math.floor(m*f/v+c)*p;if(null===i){var T=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);i=T?parseInt(T[1]):0}return!!i&&i<=87&&2===l&&f>=224e3&&0===h&&(e[t+3]=128|e[t+3]),{sampleRate:v,channelCount:g,frameLength:E,samplesPerFrame:y}}}function d(e,t){return 255===e[t]&&224==(224&e[t+1])&&0!=(6&e[t+1])}function c(e,t){return t+1<e.length&&d(e,t)}function h(e,t){return d(e,t)&&4<=e.length-t}function f(e,t){if(t+1<e.length&&d(e,t)){var r=u(e,t),i=4;null!=r&&r.frameLength&&(i=r.frameLength);var n=t+i;return n===e.length||c(e,n)}return!1}},"./src/demux/sample-aes.ts":(e,t,r)=>{r.r(t),r.d(t,{default:()=>a});var i=r("./src/crypt/decrypter.ts"),n=r("./src/utils/mp4-tools.ts");const a=function(){function e(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new i.default(t,{removePKCS7Padding:!1})}var t=e.prototype;return t.decryptBuffer=function(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)},t.decryptAacSample=function(e,t,r){var i=this,n=e[t].unit;if(!(n.length<=16)){var a=n.subarray(16,n.length-n.length%16),s=a.buffer.slice(a.byteOffset,a.byteOffset+a.length);this.decryptBuffer(s).then((function(a){var s=new Uint8Array(a);n.set(s,16),i.decrypter.isSync()||i.decryptAacSamples(e,t+1,r)}))}},t.decryptAacSamples=function(e,t,r){for(;;t++){if(t>=e.length)return void r();if(!(e[t].unit.length<32||(this.decryptAacSample(e,t,r),this.decrypter.isSync())))return}},t.getAvcEncryptedData=function(e){for(var t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t),i=0,n=32;n<e.length-16;n+=160,i+=16)r.set(e.subarray(n,n+16),i);return r},t.getAvcDecryptedUnit=function(e,t){for(var r=new Uint8Array(t),i=0,n=32;n<e.length-16;n+=160,i+=16)e.set(r.subarray(i,i+16),n);return e},t.decryptAvcSample=function(e,t,r,i,a){var s=this,o=(0,n.discardEPB)(a.data),l=this.getAvcEncryptedData(o);this.decryptBuffer(l.buffer).then((function(n){a.data=s.getAvcDecryptedUnit(o,n),s.decrypter.isSync()||s.decryptAvcSamples(e,t,r+1,i)}))},t.decryptAvcSamples=function(e,t,r,i){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length)return void i();for(var n=e[t].units;!(r>=n.length);r++){var a=n[r];if(!(a.data.length<=48||1!==a.type&&5!==a.type||(this.decryptAvcSample(e,t,r,i,a),this.decrypter.isSync())))return}}},e}()},"./src/demux/transmuxer-interface.ts":(e,t,r)=>{r.r(t),r.d(t,{default:()=>c});var i=r("./src/demux/webworkify-webpack.js"),n=r("./src/events.ts"),a=r("./src/demux/transmuxer.ts"),s=r("./src/utils/logger.ts"),o=r("./src/errors.ts"),l=r("./src/utils/mediasource-helper.ts"),u=r("./node_modules/eventemitter3/index.js"),d=(0,l.getMediaSource)()||{isTypeSupported:function(){return!1}},c=function(){function e(e,t,r,l){var c=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;var h=e.config;this.hls=e,this.id=t,this.useWorker=!!h.enableWorker,this.onTransmuxComplete=r,this.onFlush=l;var f=function(e,t){(t=t||{}).frag=c.frag,t.id=c.id,c.hls.trigger(e,t)};this.observer=new u.EventEmitter,this.observer.on(n.Events.FRAG_DECRYPTED,f),this.observer.on(n.Events.ERROR,f);var v={mp4:d.isTypeSupported("video/mp4"),mpeg:d.isTypeSupported("audio/mpeg"),mp3:d.isTypeSupported('audio/mp4; codecs="mp3"')},g=navigator.vendor;if(this.useWorker&&"undefined"!=typeof Worker){var m;s.logger.log("demuxing in webworker");try{m=this.worker=(0,i.default)("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),m.addEventListener("message",this.onwmsg),m.onerror=function(e){c.useWorker=!1,s.logger.warn("Exception in webworker, fallback to inline"),c.hls.trigger(n.Events.ERROR,{type:o.ErrorTypes.OTHER_ERROR,details:o.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:new Error(e.message+" ("+e.filename+":"+e.lineno+")")})},m.postMessage({cmd:"init",typeSupported:v,vendor:g,id:t,config:JSON.stringify(h)})}catch(e){s.logger.warn("Error in worker:",e),s.logger.error("Error while initializing DemuxerWorker, fallback to inline"),m&&self.URL.revokeObjectURL(m.objectURL),this.transmuxer=new a.default(this.observer,v,h,g,t),this.worker=null}}else this.transmuxer=new a.default(this.observer,v,h,g,t)}var t=e.prototype;return t.destroy=function(){var e=this.worker;if(e)e.removeEventListener("message",this.onwmsg),e.terminate(),this.worker=null,this.onwmsg=void 0;else{var t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}var r=this.observer;r&&r.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},t.push=function(e,t,r,i,n,o,l,u,d,c){var h,f,v=this;d.transmuxing.start=self.performance.now();var g=this.transmuxer,m=this.worker,p=o?o.start:n.start,y=n.decryptdata,E=this.frag,T=!(E&&n.cc===E.cc),S=!(E&&d.level===E.level),b=E?d.sn-E.sn:-1,L=this.part?d.part-this.part.index:-1,A=0===b&&d.id>1&&d.id===(null==E?void 0:E.stats.chunkCount),D=!S&&(1===b||0===b&&(1===L||A&&L<=0)),R=self.performance.now();(S||b||0===n.stats.parsing.start)&&(n.stats.parsing.start=R),!o||!L&&D||(o.stats.parsing.start=R);var k=!(E&&(null===(h=n.initSegment)||void 0===h?void 0:h.url)===(null===(f=E.initSegment)||void 0===f?void 0:f.url)),I=new a.TransmuxState(T,D,u,S,p,k);if(!D||T||k){s.logger.log("[transmuxer-interface, "+n.type+"]: Starting new transmux session for sn: "+d.sn+" p: "+d.part+" level: "+d.level+" id: "+d.id+"\n discontinuity: "+T+"\n trackSwitch: "+S+"\n contiguous: "+D+"\n accurateTimeOffset: "+u+"\n timeOffset: "+p+"\n initSegmentChange: "+k);var _=new a.TransmuxConfig(r,i,t,l,c);this.configureTransmuxer(_)}if(this.frag=n,this.part=o,m)m.postMessage({cmd:"demux",data:e,decryptdata:y,chunkMeta:d,state:I},e instanceof ArrayBuffer?[e]:[]);else if(g){var x=g.push(e,y,d,I);(0,a.isPromise)(x)?(g.async=!0,x.then((function(e){v.handleTransmuxComplete(e)})).catch((function(e){v.transmuxerError(e,d,"transmuxer-interface push error")}))):(g.async=!1,this.handleTransmuxComplete(x))}},t.flush=function(e){var t=this;e.transmuxing.start=self.performance.now();var r=this.transmuxer,i=this.worker;if(i)i.postMessage({cmd:"flush",chunkMeta:e});else if(r){var n=r.flush(e);(0,a.isPromise)(n)||r.async?((0,a.isPromise)(n)||(n=Promise.resolve(n)),n.then((function(r){t.handleFlushResult(r,e)})).catch((function(r){t.transmuxerError(r,e,"transmuxer-interface flush error")}))):this.handleFlushResult(n,e)}},t.transmuxerError=function(e,t,r){this.hls&&this.hls.trigger(n.Events.ERROR,{type:o.ErrorTypes.MEDIA_ERROR,details:o.ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:t,fatal:!1,error:e,err:e,reason:r})},t.handleFlushResult=function(e,t){var r=this;e.forEach((function(e){r.handleTransmuxComplete(e)})),this.onFlush(t)},t.onWorkerMessage=function(e){var t=e.data,r=this.hls;switch(t.event){case"init":self.URL.revokeObjectURL(this.worker.objectURL);break;case"transmuxComplete":this.handleTransmuxComplete(t.data);break;case"flush":this.onFlush(t.data);break;case"workerLog":s.logger[t.data.logType]&&s.logger[t.data.logType](t.data.message);break;default:t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,r.trigger(t.event,t.data)}},t.configureTransmuxer=function(e){var t=this.worker,r=this.transmuxer;t?t.postMessage({cmd:"configure",config:e}):r&&r.configure(e)},t.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},e}()},"./src/demux/transmuxer-worker.ts":(e,t,r)=>{r.r(t),r.d(t,{default:()=>l});var i=r("./src/demux/transmuxer.ts"),n=r("./src/events.ts"),a=r("./src/utils/logger.ts"),s=r("./node_modules/eventemitter3/index.js"),o=r("./src/errors.ts");function l(e){var t=new s.EventEmitter,r=function(t,r){e.postMessage({event:t,data:r})};t.on(n.Events.FRAG_DECRYPTED,r),t.on(n.Events.ERROR,r),e.addEventListener("message",(function(s){var l=s.data;switch(l.cmd){case"init":var d=JSON.parse(l.config);e.transmuxer=new i.default(t,l.typeSupported,d,l.vendor,l.id),(0,a.enableLogs)(d.debug,l.id),function(){var e=function(e){a.logger[e]=function(t){r("workerLog",{logType:e,message:t})}};for(var t in a.logger)e(t)}(),r("init",null);break;case"configure":e.transmuxer.configure(l.config);break;case"demux":var h=e.transmuxer.push(l.data,l.decryptdata,l.chunkMeta,l.state);(0,i.isPromise)(h)?(e.transmuxer.async=!0,h.then((function(t){u(e,t)})).catch((function(e){r(n.Events.ERROR,{type:o.ErrorTypes.MEDIA_ERROR,details:o.ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:l.chunkMeta,fatal:!1,error:e,err:e,reason:"transmuxer-worker push error"})}))):(e.transmuxer.async=!1,u(e,h));break;case"flush":var f=l.chunkMeta,v=e.transmuxer.flush(f);(0,i.isPromise)(v)||e.transmuxer.async?((0,i.isPromise)(v)||(v=Promise.resolve(v)),v.then((function(t){c(e,t,f)})).catch((function(e){r(n.Events.ERROR,{type:o.ErrorTypes.MEDIA_ERROR,details:o.ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:l.chunkMeta,fatal:!1,error:e,err:e,reason:"transmuxer-worker flush error"})}))):c(e,v,f)}}))}function u(e,t){if(!((r=t.remuxResult).audio||r.video||r.text||r.id3||r.initSegment))return!1;var r,i=[],n=t.remuxResult,a=n.audio,s=n.video;return a&&d(i,a),s&&d(i,s),e.postMessage({event:"transmuxComplete",data:t},i),!0}function d(e,t){t.data1&&e.push(t.data1.buffer),t.data2&&e.push(t.data2.buffer)}function c(e,t,r){t.reduce((function(t,r){return u(e,r)||t}),!1)||e.postMessage({event:"transmuxComplete",data:t[0]}),e.postMessage({event:"flush",data:r})}},"./src/demux/transmuxer.ts":(e,t,r)=>{r.r(t),r.d(t,{TransmuxConfig:()=>y,TransmuxState:()=>E,default:()=>g,isPromise:()=>p});var i,n=r("./src/events.ts"),a=r("./src/errors.ts"),s=r("./src/crypt/decrypter.ts"),o=r("./src/demux/aacdemuxer.ts"),l=r("./src/demux/mp4demuxer.ts"),u=r("./src/demux/tsdemuxer.ts"),d=r("./src/demux/mp3demuxer.ts"),c=r("./src/remux/mp4-remuxer.ts"),h=r("./src/remux/passthrough-remuxer.ts"),f=r("./src/utils/logger.ts");try{i=self.performance.now.bind(self.performance)}catch(e){f.logger.debug("Unable to use Performance API on this environment"),i=self.Date.now}var v=[{demux:l.default,remux:h.default},{demux:u.default,remux:c.default},{demux:o.default,remux:c.default},{demux:d.default,remux:c.default}],g=function(){function e(e,t,r,i,n){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=r,this.vendor=i,this.id=n}var t=e.prototype;return t.configure=function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()},t.push=function(e,t,r,n){var a=this,s=r.transmuxing;s.executeStart=i();var o=new Uint8Array(e),l=this.currentTransmuxState,u=this.transmuxConfig;n&&(this.currentTransmuxState=n);var d=n||l,c=d.contiguous,h=d.discontinuity,f=d.trackSwitch,v=d.accurateTimeOffset,g=d.timeOffset,p=d.initSegmentChange,y=u.audioCodec,E=u.videoCodec,T=u.defaultInitPts,S=u.duration,b=u.initSegmentData,L=function(e,t){var r=null;return e.byteLength>0&&null!=t&&null!=t.key&&null!==t.iv&&null!=t.method&&(r=t),r}(o,t);if(L&&"AES-128"===L.method){var A=this.getDecrypter();if(!A.isSync())return this.decryptionPromise=A.webCryptoDecrypt(o,L.key.buffer,L.iv.buffer).then((function(e){var t=a.push(e,null,r);return a.decryptionPromise=null,t})),this.decryptionPromise;var D=A.softwareDecrypt(o,L.key.buffer,L.iv.buffer);if(r.part>-1&&(D=A.flush()),!D)return s.executeEnd=i(),m(r);o=new Uint8Array(D)}var R=this.needsProbing(h,f);R&&this.configureTransmuxer(o),(h||f||p||R)&&this.resetInitSegment(b,y,E,S,t),(h||p||R)&&this.resetInitialTimestamp(T),c||this.resetContiguity();var k=this.transmux(o,L,g,v,r),I=this.currentTransmuxState;return I.contiguous=!0,I.discontinuity=!1,I.trackSwitch=!1,s.executeEnd=i(),k},t.flush=function(e){var t=this,r=e.transmuxing;r.executeStart=i();var s=this.decrypter,o=this.currentTransmuxState,l=this.decryptionPromise;if(l)return l.then((function(){return t.flush(e)}));var u=[],d=o.timeOffset;if(s){var c=s.flush();c&&u.push(this.push(c,null,e))}var h=this.demuxer,f=this.remuxer;if(!h||!f)return this.observer.emit(n.Events.ERROR,n.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),r.executeEnd=i(),[m(e)];var v=h.flush(d);return p(v)?v.then((function(r){return t.flushRemux(u,r,e),u})):(this.flushRemux(u,v,e),u)},t.flushRemux=function(e,t,r){var n=t.audioTrack,a=t.videoTrack,s=t.id3Track,o=t.textTrack,l=this.currentTransmuxState,u=l.accurateTimeOffset,d=l.timeOffset;f.logger.log("[transmuxer.ts]: Flushed fragment "+r.sn+(r.part>-1?" p: "+r.part:"")+" of level "+r.level);var c=this.remuxer.remux(n,a,s,o,d,u,!0,this.id);e.push({remuxResult:c,chunkMeta:r}),r.transmuxing.executeEnd=i()},t.resetInitialTimestamp=function(e){var t=this.demuxer,r=this.remuxer;t&&r&&(t.resetTimeStamp(e),r.resetTimeStamp(e))},t.resetContiguity=function(){var e=this.demuxer,t=this.remuxer;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())},t.resetInitSegment=function(e,t,r,i,n){var a=this.demuxer,s=this.remuxer;a&&s&&(a.resetInitSegment(e,t,r,i),s.resetInitSegment(e,t,r,n))},t.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},t.transmux=function(e,t,r,i,n){return t&&"SAMPLE-AES"===t.method?this.transmuxSampleAes(e,t,r,i,n):this.transmuxUnencrypted(e,r,i,n)},t.transmuxUnencrypted=function(e,t,r,i){var n=this.demuxer.demux(e,t,!1,!this.config.progressive),a=n.audioTrack,s=n.videoTrack,o=n.id3Track,l=n.textTrack;return{remuxResult:this.remuxer.remux(a,s,o,l,t,r,!1,this.id),chunkMeta:i}},t.transmuxSampleAes=function(e,t,r,i,n){var a=this;return this.demuxer.demuxSampleAes(e,t,r).then((function(e){return{remuxResult:a.remuxer.remux(e.audioTrack,e.videoTrack,e.id3Track,e.textTrack,r,i,!1,a.id),chunkMeta:n}}))},t.configureTransmuxer=function(e){for(var t,r=this.config,i=this.observer,n=this.typeSupported,a=this.vendor,s=0,o=v.length;s<o;s++)if(v[s].demux.probe(e)){t=v[s];break}t||(f.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),t={demux:l.default,remux:h.default});var u=this.demuxer,d=this.remuxer,c=t.remux,g=t.demux;d&&d instanceof c||(this.remuxer=new c(i,r,n,a)),u&&u instanceof g||(this.demuxer=new g(i,r,n),this.probe=g.probe)},t.needsProbing=function(e,t){return!this.demuxer||!this.remuxer||e||t},t.getDecrypter=function(){var e=this.decrypter;return e||(e=this.decrypter=new s.default(this.config)),e},e}(),m=function(e){return{remuxResult:{},chunkMeta:e}};function p(e){return"then"in e&&e.then instanceof Function}var y=function(e,t,r,i,n){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=r,this.duration=i,this.defaultInitPts=n},E=function(e,t,r,i,n,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=e,this.contiguous=t,this.accurateTimeOffset=r,this.trackSwitch=i,this.timeOffset=n,this.initSegmentChange=a}},"./src/demux/tsdemuxer.ts":(e,t,r)=>{r.r(t),r.d(t,{default:()=>T});var i=r("./src/demux/adts.ts"),n=r("./src/demux/mpegaudio.ts"),a=r("./src/demux/exp-golomb.ts"),s=r("./src/demux/sample-aes.ts"),o=r("./src/events.ts"),l=r("./src/utils/mp4-tools.ts"),u=r("./src/utils/logger.ts"),d=r("./src/errors.ts"),c=r("./src/types/demuxer.ts");function h(){return h=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},h.apply(this,arguments)}var f=188;function v(e,t,r,i){return{key:e,frame:!1,pts:t,dts:r,units:[],debug:i,length:0}}function g(e,t){return((31&e[t+1])<<8)+e[t+2]}function m(e,t){return(31&e[t+10])<<8|e[t+11]}function p(e,t,r,i){var n={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},a=t+3+((15&e[t+1])<<8|e[t+2])-4;for(t+=12+((15&e[t+10])<<8|e[t+11]);t<a;){var s=g(e,t);switch(e[t]){case 207:if(!i){u.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:-1===n.audio&&(n.audio=s);break;case 21:-1===n.id3&&(n.id3=s);break;case 219:if(!i){u.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:-1===n.avc&&(n.avc=s);break;case 3:case 4:!0!==r.mpeg&&!0!==r.mp3?u.logger.log("MPEG audio found, not supported in this browser"):-1===n.audio&&(n.audio=s,n.segmentCodec="mp3");break;case 36:u.logger.warn("Unsupported HEVC stream type found")}t+=5+((15&e[t+3])<<8|e[t+4])}return n}function y(e){var t,r,i,n,a,s=0,o=e.data;if(!e||0===e.size)return null;for(;o[0].length<19&&o.length>1;){var l=new Uint8Array(o[0].length+o[1].length);l.set(o[0]),l.set(o[1],o[0].length),o[0]=l,o.splice(1,1)}if(1===((t=o[0])[0]<<16)+(t[1]<<8)+t[2]){if((r=(t[4]<<8)+t[5])&&r>e.size-6)return null;var d=t[7];192&d&&(n=536870912*(14&t[9])+4194304*(255&t[10])+16384*(254&t[11])+128*(255&t[12])+(254&t[13])/2,64&d?n-(a=536870912*(14&t[14])+4194304*(255&t[15])+16384*(254&t[16])+128*(255&t[17])+(254&t[18])/2)>54e5&&(u.logger.warn(Math.round((n-a)/9e4)+"s delta between PTS and DTS, align them"),n=a):a=n);var c=(i=t[8])+9;if(e.size<=c)return null;e.size-=c;for(var h=new Uint8Array(e.size),f=0,v=o.length;f<v;f++){var g=(t=o[f]).byteLength;if(c){if(c>g){c-=g;continue}t=t.subarray(c),g-=c,c=0}h.set(t,s),s+=g}return r&&(r-=i+3),{data:h,pts:n,dts:a,len:r}}return null}function E(e,t){if(e.units.length&&e.frame){if(void 0===e.pts){var r=t.samples,i=r.length;if(!i)return void t.dropped++;var n=r[i-1];e.pts=n.pts,e.dts=n.dts}t.samples.push(e)}e.debug.length&&u.logger.log(e.pts+"/"+e.dts+":"+e.debug)}const T=function(){function e(e,t,r){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=e,this.config=t,this.typeSupported=r}e.probe=function(t){var r=e.syncOffset(t);return r>0&&u.logger.warn("MPEG2-TS detected but first sync word found @ offset "+r),-1!==r},e.syncOffset=function(e){for(var t=e.length,r=Math.min(940,e.length-f)+1,i=0;i<r;){for(var n=!1,a=i;a<t&&71===e[a];a+=f)if(n||0!==g(e,a)||(n=!0),n&&a+f>r)return i;i++}return-1},e.createTrack=function(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:l.RemuxerTrackIdConfig[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}};var t=e.prototype;return t.resetInitSegment=function(t,r,i,n){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=e.createTrack("video"),this._audioTrack=e.createTrack("audio",n),this._id3Track=e.createTrack("id3"),this._txtTrack=e.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=r,this.videoCodec=i,this._duration=n},t.resetTimeStamp=function(){},t.resetContiguity=function(){var e=this._audioTrack,t=this._avcTrack,r=this._id3Track;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null},t.demux=function(t,r,i,n){var a;void 0===i&&(i=!1),void 0===n&&(n=!1),i||(this.sampleAes=null);var s=this._avcTrack,c=this._audioTrack,h=this._id3Track,v=this._txtTrack,E=s.pid,T=s.pesData,S=c.pid,b=h.pid,L=c.pesData,A=h.pesData,D=null,R=this.pmtParsed,k=this._pmtId,I=t.length;if(this.remainderData&&(I=(t=(0,l.appendUint8Array)(this.remainderData,t)).length,this.remainderData=null),I<f&&!n)return this.remainderData=t,{audioTrack:c,videoTrack:s,id3Track:h,textTrack:v};var _=Math.max(0,e.syncOffset(t));(I-=(I-_)%f)<t.byteLength&&!n&&(this.remainderData=new Uint8Array(t.buffer,I,t.buffer.byteLength-I));for(var x=0,C=_;C<I;C+=f)if(71===t[C]){var w=!!(64&t[C+1]),P=g(t,C),O=void 0;if((48&t[C+3])>>4>1){if((O=C+5+t[C+4])===C+f)continue}else O=C+4;switch(P){case E:w&&(T&&(a=y(T))&&this.parseAVCPES(s,v,a,!1),T={data:[],size:0}),T&&(T.data.push(t.subarray(O,C+f)),T.size+=C+f-O);break;case S:if(w){if(L&&(a=y(L)))switch(c.segmentCodec){case"aac":this.parseAACPES(c,a);break;case"mp3":this.parseMPEGPES(c,a)}L={data:[],size:0}}L&&(L.data.push(t.subarray(O,C+f)),L.size+=C+f-O);break;case b:w&&(A&&(a=y(A))&&this.parseID3PES(h,a),A={data:[],size:0}),A&&(A.data.push(t.subarray(O,C+f)),A.size+=C+f-O);break;case 0:w&&(O+=t[O]+1),k=this._pmtId=m(t,O);break;case k:w&&(O+=t[O]+1);var F=p(t,O,this.typeSupported,i);(E=F.avc)>0&&(s.pid=E),(S=F.audio)>0&&(c.pid=S,c.segmentCodec=F.segmentCodec),(b=F.id3)>0&&(h.pid=b),null===D||R||(u.logger.warn("MPEG-TS PMT found at "+C+" after unknown PID '"+D+"'. Backtracking to sync byte @"+_+" to parse all TS packets."),D=null,C=_-188),R=this.pmtParsed=!0;break;case 17:case 8191:break;default:D=P}}else x++;x>0&&this.observer.emit(o.Events.ERROR,o.Events.ERROR,{type:d.ErrorTypes.MEDIA_ERROR,details:d.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"Found "+x+" TS packet/s that do not start with 0x47"}),s.pesData=T,c.pesData=L,h.pesData=A;var M={audioTrack:c,videoTrack:s,id3Track:h,textTrack:v};return n&&this.extractRemainingSamples(M),M},t.flush=function(){var e,t=this.remainderData;return this.remainderData=null,e=t?this.demux(t,-1,!1,!0):{videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e},t.extractRemainingSamples=function(e){var t,r=e.audioTrack,i=e.videoTrack,n=e.id3Track,a=e.textTrack,s=i.pesData,o=r.pesData,l=n.pesData;if(s&&(t=y(s))?(this.parseAVCPES(i,a,t,!0),i.pesData=null):i.pesData=s,o&&(t=y(o))){switch(r.segmentCodec){case"aac":this.parseAACPES(r,t);break;case"mp3":this.parseMPEGPES(r,t)}r.pesData=null}else null!=o&&o.size&&u.logger.log("last AAC PES packet truncated,might overlap between fragments"),r.pesData=o;l&&(t=y(l))?(this.parseID3PES(n,t),n.pesData=null):n.pesData=l},t.demuxSampleAes=function(e,t,r){var i=this.demux(e,r,!0,!this.config.progressive),n=this.sampleAes=new s.default(this.observer,this.config,t);return this.decrypt(i,n)},t.decrypt=function(e,t){return new Promise((function(r){var i=e.audioTrack,n=e.videoTrack;i.samples&&"aac"===i.segmentCodec?t.decryptAacSamples(i.samples,0,(function(){n.samples?t.decryptAvcSamples(n.samples,0,0,(function(){r(e)})):r(e)})):n.samples&&t.decryptAvcSamples(n.samples,0,0,(function(){r(e)}))}))},t.destroy=function(){this._duration=0},t.parseAVCPES=function(e,t,r,i){var n,s=this,o=this.parseAVCNALu(e,r.data),u=this.avcSample,d=!1;r.data=null,u&&o.length&&!e.audFound&&(E(u,e),u=this.avcSample=v(!1,r.pts,r.dts,"")),o.forEach((function(i){switch(i.type){case 1:n=!0,u||(u=s.avcSample=v(!0,r.pts,r.dts,"")),u.frame=!0;var o=i.data;if(d&&o.length>4){var c=new a.default(o).readSliceType();2!==c&&4!==c&&7!==c&&9!==c||(u.key=!0)}break;case 5:n=!0,u||(u=s.avcSample=v(!0,r.pts,r.dts,"")),u.key=!0,u.frame=!0;break;case 6:n=!0,(0,l.parseSEIMessageFromNALu)(i.data,1,r.pts,t.samples);break;case 7:if(n=!0,d=!0,!e.sps){var h=new a.default(i.data).readSPS();e.width=h.width,e.height=h.height,e.pixelRatio=h.pixelRatio,e.sps=[i.data],e.duration=s._duration;for(var f=i.data.subarray(1,4),g="avc1.",m=0;m<3;m++){var p=f[m].toString(16);p.length<2&&(p="0"+p),g+=p}e.codec=g}break;case 8:n=!0,e.pps||(e.pps=[i.data]);break;case 9:n=!1,e.audFound=!0,u&&E(u,e),u=s.avcSample=v(!1,r.pts,r.dts,"");break;case 12:n=!0;break;default:n=!1,u&&(u.debug+="unknown NAL "+i.type+" ")}u&&n&&u.units.push(i)})),i&&u&&(E(u,e),this.avcSample=null)},t.getLastNalUnit=function(e){var t,r,i=this.avcSample;if(i&&0!==i.units.length||(i=e[e.length-1]),null!==(t=i)&&void 0!==t&&t.units){var n=i.units;r=n[n.length-1]}return r},t.parseAVCNALu=function(e,t){var r,i,n=t.byteLength,a=e.naluState||0,s=a,o=[],l=0,u=-1,d=0;for(-1===a&&(u=0,d=31&t[0],a=0,l=1);l<n;)if(r=t[l++],a)if(1!==a)if(r)if(1===r){if(u>=0){var c={data:t.subarray(u,l-a-1),type:d};o.push(c)}else{var h=this.getLastNalUnit(e.samples);if(h&&(s&&l<=4-s&&h.state&&(h.data=h.data.subarray(0,h.data.byteLength-s)),(i=l-a-1)>0)){var f=new Uint8Array(h.data.byteLength+i);f.set(h.data,0),f.set(t.subarray(0,i),h.data.byteLength),h.data=f,h.state=0}}l<n?(u=l,d=31&t[l],a=0):a=-1}else a=0;else a=3;else a=r?0:2;else a=r?0:1;if(u>=0&&a>=0){var v={data:t.subarray(u,n),type:d,state:a};o.push(v)}if(0===o.length){var g=this.getLastNalUnit(e.samples);if(g){var m=new Uint8Array(g.data.byteLength+t.byteLength);m.set(g.data,0),m.set(t,g.data.byteLength),g.data=m}}return e.naluState=a,o},t.parseAACPES=function(e,t){var r,n,a,s,l,c=0,h=this.aacOverFlow,f=t.data;if(h){this.aacOverFlow=null;var v=h.missing,g=h.sample.unit.byteLength;if(-1===v){var m=new Uint8Array(g+f.byteLength);m.set(h.sample.unit,0),m.set(f,g),f=m}else{var p=g-v;h.sample.unit.set(f.subarray(0,v),p),e.samples.push(h.sample),c=h.missing}}for(r=c,n=f.length;r<n-1&&!i.isHeader(f,r);r++);if(r===c||(r<n-1?(a="AAC PES did not start with ADTS header,offset:"+r,s=!1):(a="no ADTS header found in AAC PES",s=!0),u.logger.warn("parsing error:"+a),this.observer.emit(o.Events.ERROR,o.Events.ERROR,{type:d.ErrorTypes.MEDIA_ERROR,details:d.ErrorDetails.FRAG_PARSING_ERROR,fatal:s,reason:a}),!s)){if(i.initTrackConfig(e,this.observer,f,r,this.audioCodec),void 0!==t.pts)l=t.pts;else{if(!h)return void u.logger.warn("[tsdemuxer]: AAC PES unknown PTS");var y=i.getFrameDuration(e.samplerate);l=h.sample.pts+y}for(var E,T=0;r<n;){if(r+=(E=i.appendFrame(e,f,r,l,T)).length,E.missing){this.aacOverFlow=E;break}for(T++;r<n-1&&!i.isHeader(f,r);r++);}}},t.parseMPEGPES=function(e,t){var r=t.data,i=r.length,a=0,s=0,o=t.pts;if(void 0!==o)for(;s<i;)if(n.isHeader(r,s)){var l=n.appendFrame(e,r,s,o,a);if(!l)break;s+=l.length,a++}else s++;else u.logger.warn("[tsdemuxer]: MPEG PES unknown PTS")},t.parseID3PES=function(e,t){if(void 0!==t.pts){var r=h({},t,{type:this._avcTrack?c.MetadataSchema.emsg:c.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(r)}else u.logger.warn("[tsdemuxer]: ID3 PES unknown PTS")},e}()},"./src/demux/webworkify-webpack.js":(e,t,r)=>{r.r(t),r.d(t,{default:()=>d});var i=function(){var e=ENTRY_MODULE,t={},r=function r(i){var n=t[i];if(void 0!==n)return n.exports;var a=t[i]={exports:{}};return e[i].call(a.exports,a,a.exports,r),a.exports};r.m=e,r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i=r(ENTRY_MODULE);return i.default||i}.toString().split("ENTRY_MODULE"),n="[\\.|\\-|\\+|\\w|/|@]+",a="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+n+").*?\\)";function s(e){return(e+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function o(e,t,i){var o={};o[i]=[];var l=t.toString().replace(/^"[^"]+"/,"function"),u=l.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/)||l.match(/^\(\w+,\s*\w+,\s*(\w+)\)\s?\=\s?\>/);if(!u)return o;for(var d,c=u[1],h=new RegExp("(\\\\n|\\W)"+s(c)+a,"g");d=h.exec(l);)"dll-reference"!==d[3]&&o[i].push(d[3]);for(h=new RegExp("\\("+s(c)+'\\("(dll-reference\\s('+n+'))"\\)\\)'+a,"g");d=h.exec(l);)e[d[2]]||(o[i].push(d[1]),e[d[2]]=r(d[1]).m),o[d[2]]=o[d[2]]||[],o[d[2]].push(d[4]);for(var f,v=Object.keys(o),g=0;g<v.length;g++)for(var m=0;m<o[v[g]].length;m++)f=o[v[g]][m],isNaN(1*f)||(o[v[g]][m]=1*o[v[g]][m]);return o}function l(e){return Object.keys(e).reduce((function(t,r){return t||e[r].length>0}),!1)}function u(e,t,r,n){var a=e[n].map((function(e){return'"'+e+'": '+t[n][e].toString().replace(/^"[^"]+"/,"function")})).join(",");return i[0]+"{"+a+"}"+i[1]+'"'+r+'"'+i[2]}function d(e,t){t=t||{};var i={main:r.m},n=t.all?{main:Object.keys(i.main)}:function(e,t){for(var r={main:[t]},i={main:[]},n={main:{}};l(r);)for(var a=Object.keys(r),s=0;s<a.length;s++){var u=a[s],d=r[u].pop();if(n[u]=n[u]||{},!n[u][d]&&e[u][d]){n[u][d]=!0,i[u]=i[u]||[],i[u].push(d);for(var c=o(e,e[u][d],u),h=Object.keys(c),f=0;f<h.length;f++)r[h[f]]=r[h[f]]||[],r[h[f]]=r[h[f]].concat(c[h[f]])}}return i}(i,e),a="";Object.keys(n).filter((function(e){return"main"!==e})).forEach((function(e){for(var t=0;n[e][t];)t++;n[e].push(t),i[e][t]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",a=a+"var "+e+" = ("+u(n,i,t,modules)+")();\n"})),a=a+"new (("+u(n,i,e,"main")+")())(self);";var s=new window.Blob([a],{type:"text/javascript"}),d=(window.URL||window.webkitURL||window.mozURL||window.msURL).createObjectURL(s),c=new window.Worker(d);return c.objectURL=d,c}},"./src/empty.js":e=>{e.exports=void 0},"./src/errors.ts":(e,t,r)=>{var i,n;r.r(t),r.d(t,{ErrorDetails:()=>n,ErrorTypes:()=>i}),function(e){e.NETWORK_ERROR="networkError",e.MEDIA_ERROR="mediaError",e.KEY_SYSTEM_ERROR="keySystemError",e.MUX_ERROR="muxError",e.OTHER_ERROR="otherError"}(i||(i={})),function(e){e.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",e.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",e.KEY_SYSTEM_NO_SESSION="keySystemNoSession",e.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",e.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",e.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",e.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",e.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",e.MANIFEST_LOAD_ERROR="manifestLoadError",e.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",e.MANIFEST_PARSING_ERROR="manifestParsingError",e.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",e.LEVEL_EMPTY_ERROR="levelEmptyError",e.LEVEL_LOAD_ERROR="levelLoadError",e.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",e.LEVEL_SWITCH_ERROR="levelSwitchError",e.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",e.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",e.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",e.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",e.FRAG_LOAD_ERROR="fragLoadError",e.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",e.FRAG_DECRYPT_ERROR="fragDecryptError",e.FRAG_PARSING_ERROR="fragParsingError",e.REMUX_ALLOC_ERROR="remuxAllocError",e.KEY_LOAD_ERROR="keyLoadError",e.KEY_LOAD_TIMEOUT="keyLoadTimeOut",e.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",e.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",e.BUFFER_APPEND_ERROR="bufferAppendError",e.BUFFER_APPENDING_ERROR="bufferAppendingError",e.BUFFER_STALLED_ERROR="bufferStalledError",e.BUFFER_FULL_ERROR="bufferFullError",e.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",e.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",e.INTERNAL_EXCEPTION="internalException",e.INTERNAL_ABORTED="aborted",e.UNKNOWN="unknown"}(n||(n={}))},"./src/events.ts":(e,t,r)=>{var i;r.r(t),r.d(t,{Events:()=>i}),function(e){e.MEDIA_ATTACHING="hlsMediaAttaching",e.MEDIA_ATTACHED="hlsMediaAttached",e.MEDIA_DETACHING="hlsMediaDetaching",e.MEDIA_DETACHED="hlsMediaDetached",e.BUFFER_RESET="hlsBufferReset",e.BUFFER_CODECS="hlsBufferCodecs",e.BUFFER_CREATED="hlsBufferCreated",e.BUFFER_APPENDING="hlsBufferAppending",e.BUFFER_APPENDED="hlsBufferAppended",e.BUFFER_EOS="hlsBufferEos",e.BUFFER_FLUSHING="hlsBufferFlushing",e.BUFFER_FLUSHED="hlsBufferFlushed",e.MANIFEST_LOADING="hlsManifestLoading",e.MANIFEST_LOADED="hlsManifestLoaded",e.MANIFEST_PARSED="hlsManifestParsed",e.LEVEL_SWITCHING="hlsLevelSwitching",e.LEVEL_SWITCHED="hlsLevelSwitched",e.LEVEL_LOADING="hlsLevelLoading",e.LEVEL_LOADED="hlsLevelLoaded",e.LEVEL_UPDATED="hlsLevelUpdated",e.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",e.LEVELS_UPDATED="hlsLevelsUpdated",e.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",e.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",e.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",e.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",e.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",e.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",e.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",e.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",e.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",e.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",e.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",e.CUES_PARSED="hlsCuesParsed",e.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",e.INIT_PTS_FOUND="hlsInitPtsFound",e.FRAG_LOADING="hlsFragLoading",e.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",e.FRAG_LOADED="hlsFragLoaded",e.FRAG_DECRYPTED="hlsFragDecrypted",e.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",e.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",e.FRAG_PARSING_METADATA="hlsFragParsingMetadata",e.FRAG_PARSED="hlsFragParsed",e.FRAG_BUFFERED="hlsFragBuffered",e.FRAG_CHANGED="hlsFragChanged",e.FPS_DROP="hlsFpsDrop",e.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",e.ERROR="hlsError",e.DESTROYING="hlsDestroying",e.KEY_LOADING="hlsKeyLoading",e.KEY_LOADED="hlsKeyLoaded",e.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",e.BACK_BUFFER_REACHED="hlsBackBufferReached"}(i||(i={}))},"./src/hls.ts":(e,t,r)=>{r.r(t),r.d(t,{default:()=>E});var i=r("./node_modules/url-toolkit/src/url-toolkit.js"),n=r("./src/loader/playlist-loader.ts"),a=r("./src/controller/id3-track-controller.ts"),s=r("./src/controller/latency-controller.ts"),o=r("./src/controller/level-controller.ts"),l=r("./src/controller/fragment-tracker.ts"),u=r("./src/loader/key-loader.ts"),d=r("./src/controller/stream-controller.ts"),c=r("./src/is-supported.ts"),h=r("./src/utils/logger.ts"),f=r("./src/config.ts"),v=r("./node_modules/eventemitter3/index.js"),g=r("./src/events.ts"),m=r("./src/errors.ts"),p=r("./src/types/level.ts");function y(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(n=i.key,a=void 0,"symbol"==typeof(a=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(n,"string"))?a:String(a)),i)}var n,a}var E=function(){function e(t){void 0===t&&(t={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new v.EventEmitter,this._autoLevelCapping=void 0,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null;var r=this.config=(0,f.mergeConfig)(e.DefaultConfig,t);this.userConfig=t,(0,h.enableLogs)(r.debug,"Hls instance"),this._autoLevelCapping=-1,r.progressive&&(0,f.enableStreamingMode)(r);var i=r.abrController,c=r.bufferController,g=r.capLevelController,m=r.fpsController,p=this.abrController=new i(this),y=this.bufferController=new c(this),E=this.capLevelController=new g(this),T=new m(this),S=new n.default(this),b=new a.default(this),L=this.levelController=new o.default(this),A=new l.FragmentTracker(this),D=new u.default(this.config),R=this.streamController=new d.default(this,A,D);E.setStreamController(R),T.setStreamController(R);var k=[S,L,R];this.networkControllers=k;var I=[p,y,E,T,b,A];this.audioTrackController=this.createController(r.audioTrackController,k);var _=r.audioStreamController;_&&k.push(new _(this,A,D)),this.subtitleTrackController=this.createController(r.subtitleTrackController,k);var x=r.subtitleStreamController;x&&k.push(new x(this,A,D)),this.createController(r.timelineController,I),D.emeController=this.emeController=this.createController(r.emeController,I),this.cmcdController=this.createController(r.cmcdController,I),this.latencyController=this.createController(s.default,I),this.coreComponents=I}e.isSupported=function(){return(0,c.isSupported)()};var t,r,E,T=e.prototype;return T.createController=function(e,t){if(e){var r=new e(this);return t&&t.push(r),r}return null},T.on=function(e,t,r){void 0===r&&(r=this),this._emitter.on(e,t,r)},T.once=function(e,t,r){void 0===r&&(r=this),this._emitter.once(e,t,r)},T.removeAllListeners=function(e){this._emitter.removeAllListeners(e)},T.off=function(e,t,r,i){void 0===r&&(r=this),this._emitter.off(e,t,r,i)},T.listeners=function(e){return this._emitter.listeners(e)},T.emit=function(e,t,r){return this._emitter.emit(e,t,r)},T.trigger=function(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(t){h.logger.error("An internal error happened while handling event "+e+'. Error message: "'+t.message+'". Here is a stacktrace:',t),this.trigger(g.Events.ERROR,{type:m.ErrorTypes.OTHER_ERROR,details:m.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:e,error:t})}return!1},T.listenerCount=function(e){return this._emitter.listenerCount(e)},T.destroy=function(){h.logger.log("destroy"),this.trigger(g.Events.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},T.attachMedia=function(e){h.logger.log("attachMedia"),this._media=e,this.trigger(g.Events.MEDIA_ATTACHING,{media:e})},T.detachMedia=function(){h.logger.log("detachMedia"),this.trigger(g.Events.MEDIA_DETACHING,void 0),this._media=null},T.loadSource=function(e){this.stopLoad();var t=this.media,r=this.url,n=this.url=i.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});h.logger.log("loadSource:"+n),t&&r&&r!==n&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(t)),this.trigger(g.Events.MANIFEST_LOADING,{url:e})},T.startLoad=function(e){void 0===e&&(e=-1),h.logger.log("startLoad("+e+")"),this.networkControllers.forEach((function(t){t.startLoad(e)}))},T.stopLoad=function(){h.logger.log("stopLoad"),this.networkControllers.forEach((function(e){e.stopLoad()}))},T.swapAudioCodec=function(){h.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},T.recoverMediaError=function(){h.logger.log("recoverMediaError");var e=this._media;this.detachMedia(),e&&this.attachMedia(e)},T.removeLevel=function(e,t){void 0===t&&(t=0),this.levelController.removeLevel(e,t)},t=e,E=[{key:"version",get:function(){return"1.3.5"}},{key:"Events",get:function(){return g.Events}},{key:"ErrorTypes",get:function(){return m.ErrorTypes}},{key:"ErrorDetails",get:function(){return m.ErrorDetails}},{key:"DefaultConfig",get:function(){return e.defaultConfig?e.defaultConfig:f.hlsDefaultConfig},set:function(t){e.defaultConfig=t}}],(r=[{key:"levels",get:function(){var e=this.levelController.levels;return e||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(e){h.logger.log("set currentLevel:"+e),this.loadLevel=e,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){h.logger.log("set nextLevel:"+e),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){h.logger.log("set loadLevel:"+e),this.levelController.manualLevel=e}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(e){this.levelController.nextLoadLevel=e}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(e){h.logger.log("set firstLevel:"+e),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(e){h.logger.log("set startLevel:"+e),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(e){var t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){this._autoLevelCapping!==e&&(h.logger.log("set autoLevelCapping:"+e),this._autoLevelCapping=e)}},{key:"bandwidthEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimate():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(e){p.HdcpLevels.indexOf(e)>-1&&(this._maxHdcpLevel=e)}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var e=this.levels,t=this.config.minAutoBitrate;if(!e)return 0;for(var r=e.length,i=0;i<r;i++)if(e[i].maxBitrate>=t)return i;return 0}},{key:"maxAutoLevel",get:function(){var e,t=this.levels,r=this.autoLevelCapping,i=this.maxHdcpLevel;if(e=-1===r&&t&&t.length?t.length-1:r,i)for(var n=e;n--;){var a=t[n].attrs["HDCP-LEVEL"];if(a&&a<=i)return n}return e}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(e){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,e)}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"audioTracks",get:function(){var e=this.audioTrackController;return e?e.audioTracks:[]}},{key:"audioTrack",get:function(){var e=this.audioTrackController;return e?e.audioTrack:-1},set:function(e){var t=this.audioTrackController;t&&(t.audioTrack=e)}},{key:"subtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(e){this.config.lowLatencyMode=e}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}])&&y(t.prototype,r),E&&y(t,E),Object.defineProperty(t,"prototype",{writable:!1}),e}();E.defaultConfig=void 0},"./src/is-supported.ts":(e,t,r)=>{r.r(t),r.d(t,{changeTypeSupported:()=>s,isSupported:()=>a});var i=r("./src/utils/mediasource-helper.ts");function n(){return self.SourceBuffer||self.WebKitSourceBuffer}function a(){var e=(0,i.getMediaSource)();if(!e)return!1;var t=n(),r=e&&"function"==typeof e.isTypeSupported&&e.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),a=!t||t.prototype&&"function"==typeof t.prototype.appendBuffer&&"function"==typeof t.prototype.remove;return!!r&&!!a}function s(){var e,t=n();return"function"==typeof(null==t||null===(e=t.prototype)||void 0===e?void 0:e.changeType)}},"./src/loader/date-range.ts":(e,t,r)=>{r.r(t),r.d(t,{DateRange:()=>u,DateRangeAttribute:()=>i});var i,n=r("./src/polyfills/number.ts"),a=r("./src/utils/attr-list.ts"),s=r("./src/utils/logger.ts");function o(){return o=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},o.apply(this,arguments)}function l(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(n=i.key,a=void 0,"symbol"==typeof(a=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(n,"string"))?a:String(a)),i)}var n,a}!function(e){e.ID="ID",e.CLASS="CLASS",e.START_DATE="START-DATE",e.DURATION="DURATION",e.END_DATE="END-DATE",e.END_ON_NEXT="END-ON-NEXT",e.PLANNED_DURATION="PLANNED-DURATION",e.SCTE35_OUT="SCTE35-OUT",e.SCTE35_IN="SCTE35-IN"}(i||(i={}));var u=function(){function e(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){var r=t.attr;for(var l in r)if(Object.prototype.hasOwnProperty.call(e,l)&&e[l]!==r[l]){s.logger.warn('DATERANGE tag attribute: "'+l+'" does not match for tags with ID: "'+e.ID+'"'),this._badValueForSameId=l;break}e=o(new a.AttrList({}),r,e)}if(this.attr=e,this._startDate=new Date(e[i.START_DATE]),i.END_DATE in this.attr){var u=new Date(this.attr[i.END_DATE]);(0,n.isFiniteNumber)(u.getTime())&&(this._endDate=u)}}var t,r,u;return t=e,(r=[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){if(this._endDate)return this._endDate;var e=this.duration;return null!==e?new Date(this._startDate.getTime()+1e3*e):null}},{key:"duration",get:function(){if(i.DURATION in this.attr){var e=this.attr.decimalFloatingPoint(i.DURATION);if((0,n.isFiniteNumber)(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return i.PLANNED_DURATION in this.attr?this.attr.decimalFloatingPoint(i.PLANNED_DURATION):null}},{key:"endOnNext",get:function(){return this.attr.bool(i.END_ON_NEXT)}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&(0,n.isFiniteNumber)(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)}}])&&l(t.prototype,r),u&&l(t,u),Object.defineProperty(t,"prototype",{writable:!1}),e}()},"./src/loader/fragment-loader.ts":(e,t,r)=>{r.r(t),r.d(t,{LoadError:()=>h,default:()=>d});var i=r("./src/polyfills/number.ts"),n=r("./src/errors.ts");function a(e){var t="function"==typeof Map?new Map:void 0;return a=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,i)}function i(){return s(e,arguments,l(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),o(i,e)},a(e)}function s(e,t,r){return s=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}()?Reflect.construct.bind():function(e,t,r){var i=[null];i.push.apply(i,t);var n=new(Function.bind.apply(e,i));return r&&o(n,r.prototype),n},s.apply(null,arguments)}function o(e,t){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},o(e,t)}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}var u=Math.pow(2,17),d=function(){function e(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}var t=e.prototype;return t.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},t.abort=function(){this.loader&&this.loader.abort()},t.load=function(e,t){var r=this,i=e.url;if(!i)return Promise.reject(new h({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,networkDetails:null},"Fragment does not have a "+(i?"part list":"url")));this.abort();var a=this.config,s=a.fLoader,o=a.loader;return new Promise((function(i,l){r.loader&&r.loader.destroy();var d=r.loader=e.loader=s?new s(a):new o(a),f=c(e),v={timeout:a.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:a.fragLoadingMaxRetryTimeout,highWaterMark:"initSegment"===e.sn?1/0:u};e.stats=d.stats,d.load(f,v,{onSuccess:function(t,n,a,s){r.resetLoader(e,d);var o=t.data;a.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(o.slice(0,16)),o=o.slice(16)),i({frag:e,part:null,payload:o,networkDetails:s})},onError:function(t,i,a){r.resetLoader(e,d),l(new h({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:t,networkDetails:a}))},onAbort:function(t,i,a){r.resetLoader(e,d),l(new h({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:e,networkDetails:a}))},onTimeout:function(t,i,a){r.resetLoader(e,d),l(new h({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,networkDetails:a}))},onProgress:function(r,i,n,a){t&&t({frag:e,part:null,payload:n,networkDetails:a})}})}))},t.loadPart=function(e,t,r){var i=this;this.abort();var a=this.config,s=a.fLoader,o=a.loader;return new Promise((function(l,d){i.loader&&i.loader.destroy();var f=i.loader=e.loader=s?new s(a):new o(a),v=c(e,t),g={timeout:a.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:a.fragLoadingMaxRetryTimeout,highWaterMark:u};t.stats=f.stats,f.load(v,g,{onSuccess:function(n,a,s,o){i.resetLoader(e,f),i.updateStatsFromPart(e,t);var u={frag:e,part:t,payload:n.data,networkDetails:o};r(u),l(u)},onError:function(r,a,s){i.resetLoader(e,f),d(new h({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:r,networkDetails:s}))},onAbort:function(r,a,s){e.stats.aborted=t.stats.aborted,i.resetLoader(e,f),d(new h({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,networkDetails:s}))},onTimeout:function(r,a,s){i.resetLoader(e,f),d(new h({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,networkDetails:s}))}})}))},t.updateStatsFromPart=function(e,t){var r=e.stats,i=t.stats,n=i.total;if(r.loaded+=i.loaded,n){var a=Math.round(e.duration/t.duration),s=Math.min(Math.round(r.loaded/n),a),o=(a-s)*Math.round(r.loaded/s);r.total=r.loaded+o}else r.total=Math.max(r.loaded,r.total);var l=r.loading,u=i.loading;l.start?l.first+=u.first-u.start:(l.start=u.start,l.first=u.first),l.end=u.end},t.resetLoader=function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()},e}();function c(e,t){void 0===t&&(t=null);var r=t||e,n={frag:e,part:t,responseType:"arraybuffer",url:r.url,headers:{},rangeStart:0,rangeEnd:0},a=r.byteRangeStartOffset,s=r.byteRangeEndOffset;if((0,i.isFiniteNumber)(a)&&(0,i.isFiniteNumber)(s)){var o,l=a,u=s;if("initSegment"===e.sn&&"AES-128"===(null===(o=e.decryptdata)||void 0===o?void 0:o.method)){var d=s-a;d%16&&(u=s+(16-d%16)),0!==a&&(n.resetIV=!0,l=a-16)}n.rangeStart=l,n.rangeEnd=u}return n}var h=function(e){var t,r;function i(t){for(var r,i=arguments.length,n=new Array(i>1?i-1:0),a=1;a<i;a++)n[a-1]=arguments[a];return(r=e.call.apply(e,[this].concat(n))||this).data=void 0,r.data=t,r}return r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,o(t,r),i}(a(Error))},"./src/loader/fragment.ts":(e,t,r)=>{r.r(t),r.d(t,{BaseSegment:()=>c,ElementaryStreamTypes:()=>i,Fragment:()=>h,Part:()=>f});var i,n=r("./src/polyfills/number.ts"),a=r("./node_modules/url-toolkit/src/url-toolkit.js"),s=r("./src/loader/load-stats.ts");function o(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,l(e,t)}function l(e,t){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},l(e,t)}function u(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(n=i.key,a=void 0,"symbol"==typeof(a=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(n,"string"))?a:String(a)),i)}var n,a}function d(e,t,r){return t&&u(e.prototype,t),r&&u(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}!function(e){e.AUDIO="audio",e.VIDEO="video",e.AUDIOVIDEO="audiovideo"}(i||(i={}));var c=function(){function e(e){var t;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((t={})[i.AUDIO]=null,t[i.VIDEO]=null,t[i.AUDIOVIDEO]=null,t),this.baseurl=e}return e.prototype.setByteRange=function(e,t){var r=e.split("@",2),i=[];1===r.length?i[0]=t?t.byteRangeEndOffset:0:i[0]=parseInt(r[1]),i[1]=parseInt(r[0])+i[0],this._byteRange=i},d(e,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=(0,a.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(e){this._url=e}}]),e}(),h=function(e){function t(t,r){var i;return(i=e.call(this,r)||this)._decryptdata=null,i.rawProgramDateTime=null,i.programDateTime=null,i.tagList=[],i.duration=0,i.sn=0,i.levelkeys=void 0,i.type=void 0,i.loader=null,i.keyLoader=null,i.level=-1,i.cc=0,i.startPTS=void 0,i.endPTS=void 0,i.appendedPTS=void 0,i.startDTS=void 0,i.endDTS=void 0,i.start=0,i.deltaPTS=void 0,i.maxStartPTS=void 0,i.minEndPTS=void 0,i.stats=new s.LoadStats,i.urlId=0,i.data=void 0,i.bitrateTest=!1,i.title=null,i.initSegment=null,i.endList=void 0,i.type=t,i}o(t,e);var r=t.prototype;return r.setKeyFormat=function(e){if(this.levelkeys){var t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}},r.abortRequests=function(){var e,t;null===(e=this.loader)||void 0===e||e.abort(),null===(t=this.keyLoader)||void 0===t||t.abort()},r.setElementaryStreamInfo=function(e,t,r,i,n,a){void 0===a&&(a=!1);var s=this.elementaryStreams,o=s[e];o?(o.startPTS=Math.min(o.startPTS,t),o.endPTS=Math.max(o.endPTS,r),o.startDTS=Math.min(o.startDTS,i),o.endDTS=Math.max(o.endDTS,n)):s[e]={startPTS:t,endPTS:r,startDTS:i,endDTS:n,partial:a}},r.clearElementaryStreamInfo=function(){var e=this.elementaryStreams;e[i.AUDIO]=null,e[i.VIDEO]=null,e[i.AUDIOVIDEO]=null},d(t,[{key:"decryptdata",get:function(){if(!this.levelkeys&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var e=this.levelkeys.identity;if(e)this._decryptdata=e.getDecryptData(this.sn);else{var t=Object.keys(this.levelkeys);if(1===t.length)return this._decryptdata=this.levelkeys[t[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;if(!(0,n.isFiniteNumber)(this.programDateTime))return null;var e=(0,n.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+1e3*e}},{key:"encrypted",get:function(){var e;if(null!==(e=this._decryptdata)&&void 0!==e&&e.encrypted)return!0;if(this.levelkeys){var t=Object.keys(this.levelkeys),r=t.length;if(r>1||1===r&&this.levelkeys[t[0]].encrypted)return!0}return!1}}]),t}(c),f=function(e){function t(t,r,i,n,a){var o;(o=e.call(this,i)||this).fragOffset=0,o.duration=0,o.gap=!1,o.independent=!1,o.relurl=void 0,o.fragment=void 0,o.index=void 0,o.stats=new s.LoadStats,o.duration=t.decimalFloatingPoint("DURATION"),o.gap=t.bool("GAP"),o.independent=t.bool("INDEPENDENT"),o.relurl=t.enumeratedString("URI"),o.fragment=r,o.index=n;var l=t.enumeratedString("BYTERANGE");return l&&o.setByteRange(l,a),a&&(o.fragOffset=a.fragOffset+a.duration),o}return o(t,e),d(t,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var e=this.elementaryStreams;return!!(e.audio||e.video||e.audiovideo)}}]),t}(c)},"./src/loader/key-loader.ts":(e,t,r)=>{r.r(t),r.d(t,{default:()=>a});var i=r("./src/errors.ts"),n=r("./src/loader/fragment-loader.ts"),a=function(){function e(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}var t=e.prototype;return t.abort=function(){for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e].loader;t&&t.abort()}},t.detach=function(){for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}},t.destroy=function(){for(var e in this.detach(),this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}},t.createKeyLoadError=function(e,t,r,a){return void 0===t&&(t=i.ErrorDetails.KEY_LOAD_ERROR),new n.LoadError({type:i.ErrorTypes.NETWORK_ERROR,details:t,fatal:!1,frag:e,networkDetails:r})},t.loadClear=function(e,t){var r=this;if(this.emeController&&this.config.emeEnabled)for(var i=e.sn,n=e.cc,a=function(e){var a=t[e];if(n<=a.cc&&("initSegment"===i||i<a.sn))return r.emeController.selectKeySystemFormat(a).then((function(e){a.setKeyFormat(e)})),"break"},s=0;s<t.length&&"break"!==a(s);s++);},t.load=function(e){var t=this;return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then((function(r){return t.loadInternal(e,r)})):this.loadInternal(e)},t.loadInternal=function(e,t){var r,n;t&&e.setKeyFormat(t);var a=e.decryptdata;if(!a){var s=t?"Expected frag.decryptdata to be defined after setting format "+t:"Missing decryption data on fragment in onKeyLoading";return Promise.reject(this.createKeyLoadError(e,i.ErrorDetails.KEY_LOAD_ERROR,null,s))}var o=a.uri;if(!o)return Promise.reject(this.createKeyLoadError(e,i.ErrorDetails.KEY_LOAD_ERROR,null,'Invalid key URI: "'+o+'"'));var l,u=this.keyUriToKeyInfo[o];if(null!==(r=u)&&void 0!==r&&r.decryptdata.key)return a.key=u.decryptdata.key,Promise.resolve({frag:e,keyInfo:u});if(null!==(n=u)&&void 0!==n&&n.keyLoadPromise)switch(null===(l=u.mediaKeySessionContext)||void 0===l?void 0:l.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return u.keyLoadPromise.then((function(t){return a.key=t.keyInfo.decryptdata.key,{frag:e,keyInfo:u}}))}switch(u=this.keyUriToKeyInfo[o]={decryptdata:a,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},a.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===a.keyFormat?this.loadKeyHTTP(u,e):this.loadKeyEME(u,e);case"AES-128":return this.loadKeyHTTP(u,e);default:return Promise.reject(this.createKeyLoadError(e,i.ErrorDetails.KEY_LOAD_ERROR,null,'Key supplied with unsupported METHOD: "'+a.method+'"'))}},t.loadKeyEME=function(e,t){var r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var i=this.emeController.loadKey(r);if(i)return(e.keyLoadPromise=i.then((function(t){return e.mediaKeySessionContext=t,r}))).catch((function(t){throw e.keyLoadPromise=null,t}))}return Promise.resolve(r)},t.loadKeyHTTP=function(e,t){var r=this,n=this.config,a=new(0,n.loader)(n);return t.keyLoader=e.loader=a,e.keyLoadPromise=new Promise((function(s,o){var l={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},u={timeout:n.fragLoadingTimeOut,maxRetry:0,retryDelay:n.fragLoadingRetryDelay,maxRetryDelay:n.fragLoadingMaxRetryTimeout,highWaterMark:0},d={onSuccess:function(e,t,n,a){var l=n.frag,u=n.keyInfo,d=n.url;if(!l.decryptdata||u!==r.keyUriToKeyInfo[d])return o(r.createKeyLoadError(l,i.ErrorDetails.KEY_LOAD_ERROR,a,"after key load, decryptdata unset or changed"));u.decryptdata.key=l.decryptdata.key=new Uint8Array(e.data),l.keyLoader=null,u.loader=null,s({frag:l,keyInfo:u})},onError:function(e,n,a){r.resetLoader(n),o(r.createKeyLoadError(t,i.ErrorDetails.KEY_LOAD_ERROR,a))},onTimeout:function(e,n,a){r.resetLoader(n),o(r.createKeyLoadError(t,i.ErrorDetails.KEY_LOAD_TIMEOUT,a))},onAbort:function(e,n,a){r.resetLoader(n),o(r.createKeyLoadError(t,i.ErrorDetails.INTERNAL_ABORTED,a))}};a.load(l,u,d)}))},t.resetLoader=function(e){var t=e.frag,r=e.keyInfo,i=e.url,n=r.loader;t.keyLoader===n&&(t.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[i],n&&n.destroy()},e}()},"./src/loader/level-details.ts":(e,t,r)=>{r.r(t),r.d(t,{LevelDetails:()=>a});var i=r("./src/polyfills/number.ts");function n(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(n=i.key,a=void 0,"symbol"==typeof(a=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(n,"string"))?a:String(a)),i)}var n,a}var a=function(){function e(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}var t,r,a;return e.prototype.reloaded=function(e){if(!e)return this.advanced=!0,void(this.updated=!0);var t=this.lastPartSn-e.lastPartSn,r=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!r||!!t,this.advanced=this.endSN>e.endSN||t>0||0===t&&r>0,this.updated||this.advanced?this.misses=Math.floor(.6*e.misses):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay},t=e,(r=[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&(0,i.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var e=this.driftEndTime-this.driftStartTime;return e>0?1e3*(this.driftEnd-this.driftStart)/e:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var e;return null!==(e=this.partList)&&void 0!==e&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var e;return null!==(e=this.fragments)&&void 0!==e&&e.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var e;return null!==(e=this.partList)&&void 0!==e&&e.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var e;return null!==(e=this.partList)&&void 0!==e&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}])&&n(t.prototype,r),a&&n(t,a),Object.defineProperty(t,"prototype",{writable:!1}),e}()},"./src/loader/level-key.ts":(e,t,r)=>{r.r(t),r.d(t,{LevelKey:()=>u});var i=r("./src/utils/keysystem-util.ts"),n=r("./src/utils/mediakeys-helper.ts"),a=r("./src/utils/mp4-tools.ts"),s=r("./src/utils/logger.ts"),o=r("./src/utils/numeric-encoding-utils.ts"),l={},u=function(){function e(e,t,r,i,n){void 0===i&&(i=[1]),void 0===n&&(n=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=e,this.uri=t,this.keyFormat=r,this.keyFormatVersions=i,this.iv=n,this.encrypted=!!e&&"NONE"!==e,this.isCommonEncryption=this.encrypted&&"AES-128"!==e}e.clearKeyUriToKeyIdMap=function(){l={}};var t=e.prototype;return t.isSupported=function(){if(this.method){if("AES-128"===this.method||"NONE"===this.method)return!0;switch(this.keyFormat){case"identity":return"SAMPLE-AES"===this.method;case n.KeySystemFormats.FAIRPLAY:case n.KeySystemFormats.WIDEVINE:case n.KeySystemFormats.PLAYREADY:case n.KeySystemFormats.CLEARKEY:return-1!==["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)}}return!1},t.getDecryptData=function(t){if(!this.encrypted||!this.uri)return null;if("AES-128"===this.method&&this.uri&&!this.iv){"number"!=typeof t&&("AES-128"!==this.method||this.iv||s.logger.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),t=0);var r=function(e){for(var t=new Uint8Array(16),r=12;r<16;r++)t[r]=e>>8*(15-r)&255;return t}(t);return new e(this.method,this.uri,"identity",this.keyFormatVersions,r)}var u=(0,i.convertDataUriToArrayBytes)(this.uri);if(u)switch(this.keyFormat){case n.KeySystemFormats.WIDEVINE:this.pssh=u,u.length>=22&&(this.keyId=u.subarray(u.length-22,u.length-6));break;case n.KeySystemFormats.PLAYREADY:var d=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=(0,a.mp4pssh)(d,null,u);var c=new Uint16Array(u.buffer,u.byteOffset,u.byteLength/2),h=String.fromCharCode.apply(null,Array.from(c)),f=h.substring(h.indexOf("<"),h.length),v=(new DOMParser).parseFromString(f,"text/xml").getElementsByTagName("KID")[0];if(v){var g=v.childNodes[0]?v.childNodes[0].nodeValue:v.getAttribute("VALUE");if(g){var m=(0,o.base64Decode)(g).subarray(0,16);(0,i.changeEndianness)(m),this.keyId=m}}break;default:var p=u.subarray(0,16);if(16!==p.length){var y=new Uint8Array(16);y.set(p,16-p.length),p=y}this.keyId=p}if(!this.keyId||16!==this.keyId.byteLength){var E=l[this.uri];if(!E){var T=Object.keys(l).length%Number.MAX_SAFE_INTEGER;E=new Uint8Array(16),new DataView(E.buffer,12,4).setUint32(0,T),l[this.uri]=E}this.keyId=E}return this},e}()},"./src/loader/load-stats.ts":(e,t,r)=>{r.r(t),r.d(t,{LoadStats:()=>i});var i=function(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}},"./src/loader/m3u8-parser.ts":(e,t,r)=>{r.r(t),r.d(t,{default:()=>p});var i=r("./src/polyfills/number.ts"),n=r("./node_modules/url-toolkit/src/url-toolkit.js"),a=r("./src/loader/date-range.ts"),s=r("./src/loader/fragment.ts"),o=r("./src/loader/level-details.ts"),l=r("./src/loader/level-key.ts"),u=r("./src/utils/attr-list.ts"),d=r("./src/utils/logger.ts"),c=r("./src/utils/codecs.ts");function h(){return h=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},h.apply(this,arguments)}var f=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+|#EXT-X-SESSION-KEY:([^\n\r]*)[\r\n]+/g,v=/#EXT-X-MEDIA:(.*)/g,g=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),m=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),p=function(){function e(){}return e.findGroup=function(e,t){for(var r=0;r<e.length;r++){var i=e[r];if(i.id===t)return i}},e.convertAVC1ToAVCOTI=function(e){var t=e.split(".");if(t.length>2){var r=t.shift()+".";return r+=parseInt(t.shift()).toString(16),r+=("000"+parseInt(t.shift()).toString(16)).slice(-4)}return e},e.resolve=function(e,t){return(0,n.buildAbsoluteURL)(t,e,{alwaysNormalize:!0})},e.parseMasterPlaylist=function(t,r){var i,n=[],a=[],s={},o=[],l=!1;for(f.lastIndex=0;null!=(i=f.exec(t));)if(i[1]){var c,h=new u.AttrList(i[1]),v={attrs:h,bitrate:h.decimalInteger("AVERAGE-BANDWIDTH")||h.decimalInteger("BANDWIDTH"),name:h.NAME,url:e.resolve(i[2],r)},g=h.decimalResolution("RESOLUTION");g&&(v.width=g.width,v.height=g.height),E((h.CODECS||"").split(/[ ,]+/).filter((function(e){return e})),v),v.videoCodec&&-1!==v.videoCodec.indexOf("avc1")&&(v.videoCodec=e.convertAVC1ToAVCOTI(v.videoCodec)),null!==(c=v.unknownCodecs)&&void 0!==c&&c.length||a.push(v),n.push(v)}else if(i[3]){var m=new u.AttrList(i[3]);m["DATA-ID"]&&(l=!0,s[m["DATA-ID"]]=m)}else if(i[4]){var p=i[4],T=y(p,r);T.encrypted&&T.isSupported()?o.push(T):d.logger.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+p+'"')}return{levels:a.length>0&&a.length<n.length?a:n,sessionData:l?s:null,sessionKeys:o.length?o:null}},e.parseMasterPlaylistMedia=function(t,r,i,n){var a;void 0===n&&(n=[]);var s=[],o=0;for(v.lastIndex=0;null!==(a=v.exec(t));){var l=new u.AttrList(a[1]);if(l.TYPE===i){var d={attrs:l,bitrate:0,id:o++,groupId:l["GROUP-ID"],instreamId:l["INSTREAM-ID"],name:l.NAME||l.LANGUAGE||"",type:i,default:l.bool("DEFAULT"),autoselect:l.bool("AUTOSELECT"),forced:l.bool("FORCED"),lang:l.LANGUAGE,url:l.URI?e.resolve(l.URI,r):""};if(n.length){var c=e.findGroup(n,d.groupId)||n[0];T(d,c,"audioCodec"),T(d,c,"textCodec")}s.push(d)}}return s},e.parseLevelPlaylist=function(e,t,r,n,l){var c,f,v,p=new o.LevelDetails(t),E=p.fragments,T=null,A=0,D=0,R=0,k=0,I=null,_=new s.Fragment(n,t),x=-1,C=!1;for(g.lastIndex=0,p.m3u8=e;null!==(c=g.exec(e));){C&&(C=!1,(_=new s.Fragment(n,t)).start=R,_.sn=A,_.cc=k,_.level=r,T&&(_.initSegment=T,_.rawProgramDateTime=T.rawProgramDateTime,T.rawProgramDateTime=null));var w=c[1];if(w){_.duration=parseFloat(w);var P=(" "+c[2]).slice(1);_.title=P||null,_.tagList.push(P?["INF",w,P]:["INF",w])}else if(c[3])(0,i.isFiniteNumber)(_.duration)&&(_.start=R,v&&L(_,v,p),_.sn=A,_.level=r,_.cc=k,_.urlId=l,E.push(_),_.relurl=(" "+c[3]).slice(1),S(_,I),I=_,R+=_.duration,A++,D=0,C=!0);else if(c[4]){var O=(" "+c[4]).slice(1);I?_.setByteRange(O,I):_.setByteRange(O)}else if(c[5])_.rawProgramDateTime=(" "+c[5]).slice(1),_.tagList.push(["PROGRAM-DATE-TIME",_.rawProgramDateTime]),-1===x&&(x=E.length);else{if(!(c=c[0].match(m))){d.logger.warn("No matches on slow regex match for level playlist!");continue}for(f=1;f<c.length&&void 0===c[f];f++);var F=(" "+c[f]).slice(1),M=(" "+c[f+1]).slice(1),N=c[f+2]?(" "+c[f+2]).slice(1):"";switch(F){case"PLAYLIST-TYPE":p.type=M.toUpperCase();break;case"MEDIA-SEQUENCE":A=p.startSN=parseInt(M);break;case"SKIP":var U=new u.AttrList(M),B=U.decimalInteger("SKIPPED-SEGMENTS");if((0,i.isFiniteNumber)(B)){p.skippedSegments=B;for(var G=B;G--;)E.unshift(null);A+=B}var K=U.enumeratedString("RECENTLY-REMOVED-DATERANGES");K&&(p.recentlyRemovedDateranges=K.split("\t"));break;case"TARGETDURATION":p.targetduration=parseFloat(M);break;case"VERSION":p.version=parseInt(M);break;case"EXTM3U":break;case"ENDLIST":p.live=!1;break;case"#":(M||N)&&_.tagList.push(N?[M,N]:[M]);break;case"DISCONTINUITY":k++,_.tagList.push(["DIS"]);break;case"GAP":_.tagList.push([F]);break;case"BITRATE":_.tagList.push([F,M]);break;case"DATERANGE":var H=new u.AttrList(M),V=new a.DateRange(H,p.dateRanges[H.ID]);V.isValid||p.skippedSegments?p.dateRanges[V.id]=V:d.logger.warn('Ignoring invalid DATERANGE tag: "'+M+'"'),_.tagList.push(["EXT-X-DATERANGE",M]);break;case"DISCONTINUITY-SEQUENCE":k=parseInt(M);break;case"KEY":var j=y(M,t);if(j.isSupported()){if("NONE"===j.method){v=void 0;break}v||(v={}),v[j.keyFormat]&&(v=h({},v)),v[j.keyFormat]=j}else d.logger.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+M+'"');break;case"START":var Y=new u.AttrList(M).decimalFloatingPoint("TIME-OFFSET");(0,i.isFiniteNumber)(Y)&&(p.startTimeOffset=Y);break;case"MAP":var W=new u.AttrList(M);if(_.duration){var q=new s.Fragment(n,t);b(q,W,r,v),T=q,_.initSegment=T,T.rawProgramDateTime&&!_.rawProgramDateTime&&(_.rawProgramDateTime=T.rawProgramDateTime)}else b(_,W,r,v),T=_,C=!0;break;case"SERVER-CONTROL":var z=new u.AttrList(M);p.canBlockReload=z.bool("CAN-BLOCK-RELOAD"),p.canSkipUntil=z.optionalFloat("CAN-SKIP-UNTIL",0),p.canSkipDateRanges=p.canSkipUntil>0&&z.bool("CAN-SKIP-DATERANGES"),p.partHoldBack=z.optionalFloat("PART-HOLD-BACK",0),p.holdBack=z.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var X=new u.AttrList(M);p.partTarget=X.decimalFloatingPoint("PART-TARGET");break;case"PART":var Q=p.partList;Q||(Q=p.partList=[]);var $=D>0?Q[Q.length-1]:void 0,Z=D++,J=new s.Part(new u.AttrList(M),_,t,Z,$);Q.push(J),_.duration+=J.duration;break;case"PRELOAD-HINT":var ee=new u.AttrList(M);p.preloadHint=ee;break;case"RENDITION-REPORT":var te=new u.AttrList(M);p.renditionReports=p.renditionReports||[],p.renditionReports.push(te);break;default:d.logger.warn("line parsed but not handled: "+c)}}}I&&!I.relurl?(E.pop(),R-=I.duration,p.partList&&(p.fragmentHint=I)):p.partList&&(S(_,I),_.cc=k,p.fragmentHint=_,v&&L(_,v,p));var re=E.length,ie=E[0],ne=E[re-1];if((R+=p.skippedSegments*p.targetduration)>0&&re&&ne){p.averagetargetduration=R/re;var ae=ne.sn;p.endSN="initSegment"!==ae?ae:0,p.live||(ne.endList=!0),ie&&(p.startCC=ie.cc)}else p.endSN=0,p.startCC=0;return p.fragmentHint&&(R+=p.fragmentHint.duration),p.totalduration=R,p.endCC=k,x>0&&function(e,t){for(var r=e[t],i=t;i--;){var n=e[i];if(!n)return;n.programDateTime=r.programDateTime-1e3*n.duration,r=n}}(E,x),p},e}();function y(e,t){var r,i,n=new u.AttrList(e),a=null!=(r=n.enumeratedString("METHOD"))?r:"",s=n.URI,o=n.hexadecimalInteger("IV"),c=n.enumeratedString("KEYFORMATVERSIONS"),h=null!=(i=n.enumeratedString("KEYFORMAT"))?i:"identity";s&&n.IV&&!o&&d.logger.error("Invalid IV: "+n.IV);var f=s?p.resolve(s,t):"",v=(c||"1").split("/").map(Number).filter(Number.isFinite);return new l.LevelKey(a,f,h,v,o)}function E(e,t){["video","audio","text"].forEach((function(r){var i=e.filter((function(e){return(0,c.isCodecType)(e,r)}));if(i.length){var n=i.filter((function(e){return 0===e.lastIndexOf("avc1",0)||0===e.lastIndexOf("mp4a",0)}));t[r+"Codec"]=n.length>0?n[0]:i[0],e=e.filter((function(e){return-1===i.indexOf(e)}))}})),t.unknownCodecs=e}function T(e,t,r){var i=t[r];i&&(e[r]=i)}function S(e,t){e.rawProgramDateTime?e.programDateTime=Date.parse(e.rawProgramDateTime):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime),(0,i.isFiniteNumber)(e.programDateTime)||(e.programDateTime=null,e.rawProgramDateTime=null)}function b(e,t,r,i){e.relurl=t.URI,t.BYTERANGE&&e.setByteRange(t.BYTERANGE),e.level=r,e.sn="initSegment",i&&(e.levelkeys=i),e.initSegment=null}function L(e,t,r){e.levelkeys=t;var i=r.encryptedFragments;i.length&&i[i.length-1].levelkeys===t||!Object.keys(t).some((function(e){return t[e].isCommonEncryption}))||i.push(e)}},"./src/loader/playlist-loader.ts":(e,t,r)=>{r.r(t),r.d(t,{default:()=>c});var i=r("./src/polyfills/number.ts"),n=r("./src/events.ts"),a=r("./src/errors.ts"),s=r("./src/utils/logger.ts"),o=r("./src/loader/m3u8-parser.ts"),l=r("./src/types/loader.ts"),u=r("./src/utils/attr-list.ts");function d(e,t){var r=e.url;return void 0!==r&&0!==r.indexOf("data:")||(r=t.url),r}const c=function(){function e(e){this.hls=void 0,this.loaders=Object.create(null),this.hls=e,this.registerListeners()}var t=e.prototype;return t.startLoad=function(e){},t.stopLoad=function(){this.destroyInternalLoaders()},t.registerListeners=function(){var e=this.hls;e.on(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(n.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(n.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(n.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},t.unregisterListeners=function(){var e=this.hls;e.off(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(n.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(n.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(n.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},t.createInternalLoader=function(e){var t=this.hls.config,r=t.pLoader,i=t.loader,n=new(r||i)(t);return e.loader=n,this.loaders[e.type]=n,n},t.getInternalLoader=function(e){return this.loaders[e.type]},t.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},t.destroyInternalLoaders=function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}},t.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},t.onManifestLoading=function(e,t){var r=t.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:l.PlaylistContextType.MANIFEST,url:r,deliveryDirectives:null})},t.onLevelLoading=function(e,t){var r=t.id,i=t.level,n=t.url,a=t.deliveryDirectives;this.load({id:r,groupId:null,level:i,responseType:"text",type:l.PlaylistContextType.LEVEL,url:n,deliveryDirectives:a})},t.onAudioTrackLoading=function(e,t){var r=t.id,i=t.groupId,n=t.url,a=t.deliveryDirectives;this.load({id:r,groupId:i,level:null,responseType:"text",type:l.PlaylistContextType.AUDIO_TRACK,url:n,deliveryDirectives:a})},t.onSubtitleTrackLoading=function(e,t){var r=t.id,i=t.groupId,n=t.url,a=t.deliveryDirectives;this.load({id:r,groupId:i,level:null,responseType:"text",type:l.PlaylistContextType.SUBTITLE_TRACK,url:n,deliveryDirectives:a})},t.load=function(e){var t,r,i,n,a,o,u=this.hls.config,d=this.getInternalLoader(e);if(d){var c=d.context;if(c&&c.url===e.url)return void s.logger.trace("[playlist-loader]: playlist request ongoing");s.logger.log("[playlist-loader]: aborting previous loader for type: "+e.type),d.abort()}switch(e.type){case l.PlaylistContextType.MANIFEST:r=u.manifestLoadingMaxRetry,i=u.manifestLoadingTimeOut,n=u.manifestLoadingRetryDelay,a=u.manifestLoadingMaxRetryTimeout;break;case l.PlaylistContextType.LEVEL:case l.PlaylistContextType.AUDIO_TRACK:case l.PlaylistContextType.SUBTITLE_TRACK:r=0,i=u.levelLoadingTimeOut;break;default:r=u.levelLoadingMaxRetry,i=u.levelLoadingTimeOut,n=u.levelLoadingRetryDelay,a=u.levelLoadingMaxRetryTimeout}if(d=this.createInternalLoader(e),null!==(t=e.deliveryDirectives)&&void 0!==t&&t.part&&(e.type===l.PlaylistContextType.LEVEL&&null!==e.level?o=this.hls.levels[e.level].details:e.type===l.PlaylistContextType.AUDIO_TRACK&&null!==e.id?o=this.hls.audioTracks[e.id].details:e.type===l.PlaylistContextType.SUBTITLE_TRACK&&null!==e.id&&(o=this.hls.subtitleTracks[e.id].details),o)){var h=o.partTarget,f=o.targetduration;h&&f&&(i=Math.min(1e3*Math.max(3*h,.8*f),i))}var v={timeout:i,maxRetry:r,retryDelay:n,maxRetryDelay:a,highWaterMark:0},g={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};d.load(e,v,g)},t.loadsuccess=function(e,t,r,i){void 0===i&&(i=null),this.resetInternalLoader(r.type);var n=e.data;0===n.indexOf("#EXTM3U")?(t.parsing.start=performance.now(),n.indexOf("#EXTINF:")>0||n.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(e,t,r,i):this.handleMasterPlaylist(e,t,r,i)):this.handleManifestParsingError(e,r,"no EXTM3U delimiter",i)},t.loaderror=function(e,t,r){void 0===r&&(r=null),this.handleNetworkError(t,r,!1,e)},t.loadtimeout=function(e,t,r){void 0===r&&(r=null),this.handleNetworkError(t,r,!0)},t.handleMasterPlaylist=function(e,t,r,i){var a=this.hls,l=e.data,c=d(e,r),h=o.default.parseMasterPlaylist(l,c),f=h.levels,v=h.sessionData,g=h.sessionKeys;if(f.length){var m=f.map((function(e){return{id:e.attrs.AUDIO,audioCodec:e.audioCodec}})),p=f.map((function(e){return{id:e.attrs.SUBTITLES,textCodec:e.textCodec}})),y=o.default.parseMasterPlaylistMedia(l,c,"AUDIO",m),E=o.default.parseMasterPlaylistMedia(l,c,"SUBTITLES",p),T=o.default.parseMasterPlaylistMedia(l,c,"CLOSED-CAPTIONS");y.length&&(y.some((function(e){return!e.url}))||!f[0].audioCodec||f[0].attrs.AUDIO||(s.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),y.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new u.AttrList({}),bitrate:0,url:""}))),a.trigger(n.Events.MANIFEST_LOADED,{levels:f,audioTracks:y,subtitles:E,captions:T,url:c,stats:t,networkDetails:i,sessionData:v,sessionKeys:g})}else this.handleManifestParsingError(e,r,"no level found in manifest",i)},t.handleTrackOrLevelPlaylist=function(e,t,r,s){var c=this.hls,h=r.id,f=r.level,v=r.type,g=d(e,r),m=(0,i.isFiniteNumber)(h)?h:0,p=(0,i.isFiniteNumber)(f)?f:m,y=function(e){switch(e.type){case l.PlaylistContextType.AUDIO_TRACK:return l.PlaylistLevelType.AUDIO;case l.PlaylistContextType.SUBTITLE_TRACK:return l.PlaylistLevelType.SUBTITLE;default:return l.PlaylistLevelType.MAIN}}(r),E=o.default.parseLevelPlaylist(e.data,g,p,y,m);if(E.fragments.length){if(v===l.PlaylistContextType.MANIFEST){var T={attrs:new u.AttrList({}),bitrate:0,details:E,name:"",url:g};c.trigger(n.Events.MANIFEST_LOADED,{levels:[T],audioTracks:[],url:g,stats:t,networkDetails:s,sessionData:null,sessionKeys:null})}t.parsing.end=performance.now(),r.levelDetails=E,this.handlePlaylistLoaded(e,t,r,s)}else c.trigger(n.Events.ERROR,{type:a.ErrorTypes.NETWORK_ERROR,details:a.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:g,reason:"no fragments found in level",level:"number"==typeof r.level?r.level:void 0})},t.handleManifestParsingError=function(e,t,r,i){this.hls.trigger(n.Events.ERROR,{type:a.ErrorTypes.NETWORK_ERROR,details:a.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:t.type===l.PlaylistContextType.MANIFEST,url:e.url,reason:r,response:e,context:t,networkDetails:i})},t.handleNetworkError=function(e,t,r,i){void 0===r&&(r=!1),s.logger.warn("[playlist-loader]: A network "+(r?"timeout":"error")+" occurred while loading "+e.type+" level: "+e.level+" id: "+e.id+' group-id: "'+e.groupId+'"');var o=a.ErrorDetails.UNKNOWN,u=!1,d=this.getInternalLoader(e);switch(e.type){case l.PlaylistContextType.MANIFEST:o=r?a.ErrorDetails.MANIFEST_LOAD_TIMEOUT:a.ErrorDetails.MANIFEST_LOAD_ERROR,u=!0;break;case l.PlaylistContextType.LEVEL:o=r?a.ErrorDetails.LEVEL_LOAD_TIMEOUT:a.ErrorDetails.LEVEL_LOAD_ERROR,u=!1;break;case l.PlaylistContextType.AUDIO_TRACK:o=r?a.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:a.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,u=!1;break;case l.PlaylistContextType.SUBTITLE_TRACK:o=r?a.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:a.ErrorDetails.SUBTITLE_LOAD_ERROR,u=!1}d&&this.resetInternalLoader(e.type);var c={type:a.ErrorTypes.NETWORK_ERROR,details:o,fatal:u,url:e.url,loader:d,context:e,networkDetails:t};i&&(c.response=i),this.hls.trigger(n.Events.ERROR,c)},t.handlePlaylistLoaded=function(e,t,r,i){var a=r.type,s=r.level,o=r.id,u=r.groupId,d=r.loader,c=r.levelDetails,h=r.deliveryDirectives;if(null!=c&&c.targetduration){if(d)switch(c.live&&(d.getCacheAge&&(c.ageHeader=d.getCacheAge()||0),d.getCacheAge&&!isNaN(c.ageHeader)||(c.ageHeader=0)),a){case l.PlaylistContextType.MANIFEST:case l.PlaylistContextType.LEVEL:this.hls.trigger(n.Events.LEVEL_LOADED,{details:c,level:s||0,id:o||0,stats:t,networkDetails:i,deliveryDirectives:h});break;case l.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(n.Events.AUDIO_TRACK_LOADED,{details:c,id:o||0,groupId:u||"",stats:t,networkDetails:i,deliveryDirectives:h});break;case l.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(n.Events.SUBTITLE_TRACK_LOADED,{details:c,id:o||0,groupId:u||"",stats:t,networkDetails:i,deliveryDirectives:h})}}else this.handleManifestParsingError(e,r,"invalid target duration",i)},e}()},"./src/polyfills/number.ts":(e,t,r)=>{r.r(t),r.d(t,{MAX_SAFE_INTEGER:()=>n,isFiniteNumber:()=>i});var i=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},n=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});const i=function(){function e(){}return e.getSilentFrame=function(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)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(6===t)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])}else{if(1===t)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(2===t)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(3===t)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])}},e}()},"./src/remux/mp4-generator.ts":(e,t,r)=>{r.r(t),r.d(t,{default:()=>a});var i=Math.pow(2,32)-1,n=function(){function e(){}return e.init=function(){var t;for(t in e.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},e.types)e.types.hasOwnProperty(t)&&(e.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);var r=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]),i=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]);e.HDLR_TYPES={video:r,audio:i};var n=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]);e.STTS=e.STSC=e.STCO=a,e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),e.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var s=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);e.FTYP=e.box(e.types.ftyp,s,l,s,o),e.DINF=e.box(e.types.dinf,e.box(e.types.dref,n))},e.box=function(e){for(var t=8,r=arguments.length,i=new Array(r>1?r-1:0),n=1;n<r;n++)i[n-1]=arguments[n];for(var a=i.length,s=a;a--;)t+=i[a].byteLength;var o=new Uint8Array(t);for(o[0]=t>>24&255,o[1]=t>>16&255,o[2]=t>>8&255,o[3]=255&t,o.set(e,4),a=0,t=8;a<s;a++)o.set(i[a],t),t+=i[a].byteLength;return o},e.hdlr=function(t){return e.box(e.types.hdlr,e.HDLR_TYPES[t])},e.mdat=function(t){return e.box(e.types.mdat,t)},e.mdhd=function(t,r){r*=t;var n=Math.floor(r/(i+1)),a=Math.floor(r%(i+1));return e.box(e.types.mdhd,new Uint8Array([1,0,0,0,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,255&t,n>>24,n>>16&255,n>>8&255,255&n,a>>24,a>>16&255,a>>8&255,255&a,85,196,0,0]))},e.mdia=function(t){return e.box(e.types.mdia,e.mdhd(t.timescale,t.duration),e.hdlr(t.type),e.minf(t))},e.mfhd=function(t){return e.box(e.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))},e.minf=function(t){return"audio"===t.type?e.box(e.types.minf,e.box(e.types.smhd,e.SMHD),e.DINF,e.stbl(t)):e.box(e.types.minf,e.box(e.types.vmhd,e.VMHD),e.DINF,e.stbl(t))},e.moof=function(t,r,i){return e.box(e.types.moof,e.mfhd(t),e.traf(i,r))},e.moov=function(t){for(var r=t.length,i=[];r--;)i[r]=e.trak(t[r]);return e.box.apply(null,[e.types.moov,e.mvhd(t[0].timescale,t[0].duration)].concat(i).concat(e.mvex(t)))},e.mvex=function(t){for(var r=t.length,i=[];r--;)i[r]=e.trex(t[r]);return e.box.apply(null,[e.types.mvex].concat(i))},e.mvhd=function(t,r){r*=t;var n=Math.floor(r/(i+1)),a=Math.floor(r%(i+1)),s=new Uint8Array([1,0,0,0,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,255&t,n>>24,n>>16&255,n>>8&255,255&n,a>>24,a>>16&255,a>>8&255,255&a,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 e.box(e.types.mvhd,s)},e.sdtp=function(t){var r,i,n=t.samples||[],a=new Uint8Array(4+n.length);for(r=0;r<n.length;r++)i=n[r].flags,a[r+4]=i.dependsOn<<4|i.isDependedOn<<2|i.hasRedundancy;return e.box(e.types.sdtp,a)},e.stbl=function(t){return e.box(e.types.stbl,e.stsd(t),e.box(e.types.stts,e.STTS),e.box(e.types.stsc,e.STSC),e.box(e.types.stsz,e.STSZ),e.box(e.types.stco,e.STCO))},e.avc1=function(t){var r,i,n,a=[],s=[];for(r=0;r<t.sps.length;r++)n=(i=t.sps[r]).byteLength,a.push(n>>>8&255),a.push(255&n),a=a.concat(Array.prototype.slice.call(i));for(r=0;r<t.pps.length;r++)n=(i=t.pps[r]).byteLength,s.push(n>>>8&255),s.push(255&n),s=s.concat(Array.prototype.slice.call(i));var o=e.box(e.types.avcC,new Uint8Array([1,a[3],a[4],a[5],255,224|t.sps.length].concat(a).concat([t.pps.length]).concat(s))),l=t.width,u=t.height,d=t.pixelRatio[0],c=t.pixelRatio[1];return e.box(e.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,l>>8&255,255&l,u>>8&255,255&u,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]),o,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),e.box(e.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,255&d,c>>24,c>>16&255,c>>8&255,255&c])))},e.esds=function(e){var t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))},e.mp4a=function(t){var r=t.samplerate;return e.box(e.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,r>>8&255,255&r,0,0]),e.box(e.types.esds,e.esds(t)))},e.mp3=function(t){var r=t.samplerate;return e.box(e.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,r>>8&255,255&r,0,0]))},e.stsd=function(t){return"audio"===t.type?"mp3"===t.segmentCodec&&"mp3"===t.codec?e.box(e.types.stsd,e.STSD,e.mp3(t)):e.box(e.types.stsd,e.STSD,e.mp4a(t)):e.box(e.types.stsd,e.STSD,e.avc1(t))},e.tkhd=function(t){var r=t.id,n=t.duration*t.timescale,a=t.width,s=t.height,o=Math.floor(n/(i+1)),l=Math.floor(n%(i+1));return e.box(e.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,o>>24,o>>16&255,o>>8&255,255&o,l>>24,l>>16&255,l>>8&255,255&l,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,a>>8&255,255&a,0,0,s>>8&255,255&s,0,0]))},e.traf=function(t,r){var n=e.sdtp(t),a=t.id,s=Math.floor(r/(i+1)),o=Math.floor(r%(i+1));return e.box(e.types.traf,e.box(e.types.tfhd,new Uint8Array([0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a])),e.box(e.types.tfdt,new Uint8Array([1,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,o>>24,o>>16&255,o>>8&255,255&o])),e.trun(t,n.length+16+20+8+16+8+8),n)},e.trak=function(t){return t.duration=t.duration||4294967295,e.box(e.types.trak,e.tkhd(t),e.mdia(t))},e.trex=function(t){var r=t.id;return e.box(e.types.trex,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},e.trun=function(t,r){var i,n,a,s,o,l,u=t.samples||[],d=u.length,c=12+16*d,h=new Uint8Array(c);for(r+=8+c,h.set(["video"===t.type?1:0,0,15,1,d>>>24&255,d>>>16&255,d>>>8&255,255&d,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0),i=0;i<d;i++)a=(n=u[i]).duration,s=n.size,o=n.flags,l=n.cts,h.set([a>>>24&255,a>>>16&255,a>>>8&255,255&a,s>>>24&255,s>>>16&255,s>>>8&255,255&s,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,61440&o.degradPrio,15&o.degradPrio,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*i);return e.box(e.types.trun,h)},e.initSegment=function(t){e.types||e.init();var r=e.moov(t),i=new Uint8Array(e.FTYP.byteLength+r.byteLength);return i.set(e.FTYP),i.set(r,e.FTYP.byteLength),i},e}();n.types=void 0,n.HDLR_TYPES=void 0,n.STTS=void 0,n.STSC=void 0,n.STCO=void 0,n.STSZ=void 0,n.VMHD=void 0,n.SMHD=void 0,n.STSD=void 0,n.FTYP=void 0,n.DINF=void 0;const a=n},"./src/remux/mp4-remuxer.ts":(e,t,r)=>{r.r(t),r.d(t,{default:()=>v,flushTextTrackMetadataCueSamples:()=>m,flushTextTrackUserdataCueSamples:()=>p,normalizePts:()=>g});var i=r("./src/polyfills/number.ts"),n=r("./src/remux/aac-helper.ts"),a=r("./src/remux/mp4-generator.ts"),s=r("./src/events.ts"),o=r("./src/errors.ts"),l=r("./src/utils/logger.ts"),u=r("./src/types/loader.ts"),d=r("./src/utils/timescale-conversion.ts");function c(){return c=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},c.apply(this,arguments)}var h=null,f=null,v=function(){function e(e,t,r,i){if(void 0===i&&(i=""),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=void 0,this._initDTS=void 0,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=e,this.config=t,this.typeSupported=r,this.ISGenerated=!1,null===h){var n=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);h=n?parseInt(n[1]):0}if(null===f){var a=navigator.userAgent.match(/Safari\/(\d+)/i);f=a?parseInt(a[1]):0}}var t=e.prototype;return t.destroy=function(){},t.resetTimeStamp=function(e){l.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e},t.resetNextTimestamp=function(){l.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},t.resetInitSegment=function(){l.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},t.getVideoStartPts=function(e){var t=!1,r=e.reduce((function(e,r){var i=r.pts-e;return i<-4294967296?(t=!0,g(e,r.pts)):i>0?e:r.pts}),e[0].pts);return t&&l.logger.debug("PTS rollover detected"),r},t.remux=function(e,t,r,i,n,a,s,o){var d,c,h,f,v,y,E=n,T=n,S=e.pid>-1,b=t.pid>-1,L=t.samples.length,A=e.samples.length>0,D=s&&L>0||L>1;if((!S||A)&&(!b||D)||this.ISGenerated||s){this.ISGenerated||(h=this.generateIS(e,t,n));var R,k=this.isVideoContiguous,I=-1;if(D&&(I=function(e){for(var t=0;t<e.length;t++)if(e[t].key)return t;return-1}(t.samples),!k&&this.config.forceKeyFrameOnDiscontinuity))if(y=!0,I>0){l.logger.warn("[mp4-remuxer]: Dropped "+I+" out of "+L+" video samples due to a missing keyframe");var _=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(I),t.dropped+=I,R=T+=(t.samples[0].pts-_)/t.inputTimeScale}else-1===I&&(l.logger.warn("[mp4-remuxer]: No keyframe found out of "+L+" video samples"),y=!1);if(this.ISGenerated){if(A&&D){var x=this.getVideoStartPts(t.samples),C=(g(e.samples[0].pts,x)-x)/t.inputTimeScale;E+=Math.max(0,C),T+=Math.max(0,-C)}if(A){if(e.samplerate||(l.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),h=this.generateIS(e,t,n)),c=this.remuxAudio(e,E,this.isAudioContiguous,a,b||D||o===u.PlaylistLevelType.AUDIO?T:void 0),D){var w=c?c.endPTS-c.startPTS:0;t.inputTimeScale||(l.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),h=this.generateIS(e,t,n)),d=this.remuxVideo(t,T,k,w)}}else D&&(d=this.remuxVideo(t,T,k,0));d&&(d.firstKeyFrame=I,d.independent=-1!==I,d.firstKeyFramePTS=R)}}return this.ISGenerated&&(r.samples.length&&(v=m(r,n,this._initPTS,this._initDTS)),i.samples.length&&(f=p(i,n,this._initPTS))),{audio:c,video:d,initSegment:h,independent:y,text:f,id3:v}},t.generateIS=function(e,t,r){var n,s,o,l=e.samples,u=t.samples,d=this.typeSupported,c={},h=!(0,i.isFiniteNumber)(this._initPTS),f="audio/mp4";if(h&&(n=s=1/0),e.config&&l.length&&(e.timescale=e.samplerate,"mp3"===e.segmentCodec&&(d.mpeg?(f="audio/mpeg",e.codec=""):d.mp3&&(e.codec="mp3")),c.audio={id:"audio",container:f,codec:e.codec,initSegment:"mp3"===e.segmentCodec&&d.mpeg?new Uint8Array(0):a.default.initSegment([e]),metadata:{channelCount:e.channelCount}},h&&(o=e.inputTimeScale,n=s=l[0].pts-Math.round(o*r))),t.sps&&t.pps&&u.length&&(t.timescale=t.inputTimeScale,c.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:a.default.initSegment([t]),metadata:{width:t.width,height:t.height}},h)){o=t.inputTimeScale;var v=this.getVideoStartPts(u),m=Math.round(o*r);s=Math.min(s,g(u[0].dts,v)-m),n=Math.min(n,v-m)}if(Object.keys(c).length)return this.ISGenerated=!0,h&&(this._initPTS=n,this._initDTS=s),{tracks:c,initPTS:n,timescale:o}},t.remuxVideo=function(e,t,r,i){var n,u,v=e.inputTimeScale,m=e.samples,p=[],E=m.length,T=this._initPTS,S=this.nextAvcDts,b=8,L=this.videoSampleDuration,A=Number.POSITIVE_INFINITY,D=Number.NEGATIVE_INFINITY,R=!1;r&&null!==S||(S=t*v-(m[0].pts-g(m[0].dts,m[0].pts)));for(var k=0;k<E;k++){var I=m[k];I.pts=g(I.pts-T,S),I.dts=g(I.dts-T,S),I.dts<m[k>0?k-1:k].dts&&(R=!0)}R&&m.sort((function(e,t){var r=e.dts-t.dts,i=e.pts-t.pts;return r||i})),n=m[0].dts;var _=(u=m[m.length-1].dts)-n,x=_?Math.round(_/(E-1)):L||e.inputTimeScale/30;if(r){var C=n-S,w=C>x,P=C<-1;if((w||P)&&(w?l.logger.warn("AVC: "+(0,d.toMsFromMpegTsClock)(C,!0)+" ms ("+C+"dts) hole between fragments detected, filling it"):l.logger.warn("AVC: "+(0,d.toMsFromMpegTsClock)(-C,!0)+" ms ("+C+"dts) overlapping between fragments detected"),!P||S>m[0].pts)){n=S;var O=m[0].pts-C;m[0].dts=n,m[0].pts=O,l.logger.log("Video: First PTS/DTS adjusted: "+(0,d.toMsFromMpegTsClock)(O,!0)+"/"+(0,d.toMsFromMpegTsClock)(n,!0)+", delta: "+(0,d.toMsFromMpegTsClock)(C,!0)+" ms")}}n=Math.max(0,n);for(var F=0,M=0,N=0;N<E;N++){for(var U=m[N],B=U.units,G=B.length,K=0,H=0;H<G;H++)K+=B[H].data.length;M+=K,F+=G,U.length=K,U.dts=Math.max(U.dts,n),A=Math.min(U.pts,A),D=Math.max(U.pts,D)}u=m[E-1].dts;var V,j=M+4*F+8;try{V=new Uint8Array(j)}catch(e){return void this.observer.emit(s.Events.ERROR,s.Events.ERROR,{type:o.ErrorTypes.MUX_ERROR,details:o.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:j,reason:"fail allocating video mdat "+j})}var Y=new DataView(V.buffer);Y.setUint32(0,j),V.set(a.default.types.mdat,4);for(var W=!1,q=Number.POSITIVE_INFINITY,z=Number.POSITIVE_INFINITY,X=Number.NEGATIVE_INFINITY,Q=Number.NEGATIVE_INFINITY,$=0;$<E;$++){for(var Z=m[$],J=Z.units,ee=0,te=0,re=J.length;te<re;te++){var ie=J[te],ne=ie.data,ae=ie.data.byteLength;Y.setUint32(b,ae),b+=4,V.set(ne,b),b+=ae,ee+=4+ae}var se=void 0;if($<E-1)L=m[$+1].dts-Z.dts,se=m[$+1].pts-Z.pts;else{var oe=this.config,le=$>0?Z.dts-m[$-1].dts:x;if(se=$>0?Z.pts-m[$-1].pts:x,oe.stretchShortVideoTrack&&null!==this.nextAudioPts){var ue=Math.floor(oe.maxBufferHole*v),de=(i?A+i*v:this.nextAudioPts)-Z.pts;de>ue?((L=de-le)<0?L=le:W=!0,l.logger.log("[mp4-remuxer]: It is approximately "+de/90+" ms to the next segment; using duration "+L/90+" ms for the last video frame.")):L=le}else L=le}var ce=Math.round(Z.pts-Z.dts);q=Math.min(q,L),X=Math.max(X,L),z=Math.min(z,se),Q=Math.max(Q,se),p.push(new y(Z.key,L,ee,ce))}if(p.length)if(h){if(h<70){var he=p[0].flags;he.dependsOn=2,he.isNonSync=0}}else if(f&&Q-z<X-q&&x/X<.025&&0===p[0].cts){l.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var fe=n,ve=0,ge=p.length;ve<ge;ve++){var me=fe+p[ve].duration,pe=fe+p[ve].cts;if(ve<ge-1){var ye=me+p[ve+1].cts;p[ve].duration=ye-pe}else p[ve].duration=ve?p[ve-1].duration:x;p[ve].cts=0,fe=me}}console.assert(null!==L,"mp4SampleDuration must be computed"),L=W||!L?x:L,this.nextAvcDts=S=u+L,this.videoSampleDuration=L,this.isVideoContiguous=!0;var Ee={data1:a.default.moof(e.sequenceNumber++,n,c({},e,{samples:p})),data2:V,startPTS:A/v,endPTS:(D+L)/v,startDTS:n/v,endDTS:S/v,type:"video",hasAudio:!1,hasVideo:!0,nb:p.length,dropped:e.dropped};return e.samples=[],e.dropped=0,console.assert(V.length,"MDAT length must not be zero"),Ee},t.remuxAudio=function(e,t,r,i,u){var d=e.inputTimeScale,h=d/(e.samplerate?e.samplerate:d),f="aac"===e.segmentCodec?1024:1152,v=f*h,m=this._initPTS,p="mp3"===e.segmentCodec&&this.typeSupported.mpeg,E=[],T=void 0!==u,S=e.samples,b=p?0:8,L=this.nextAudioPts||-1,A=t*d;if(this.isAudioContiguous=r=r||S.length&&L>0&&(i&&Math.abs(A-L)<9e3||Math.abs(g(S[0].pts-m,A)-L)<20*v),S.forEach((function(e){e.pts=g(e.pts-m,A)})),!r||L<0){if(S=S.filter((function(e){return e.pts>=0})),!S.length)return;L=0===u?0:i&&!T?Math.max(0,A):S[0].pts}if("aac"===e.segmentCodec)for(var D=this.config.maxAudioFramesDrift,R=0,k=L;R<S.length;R++){var I=S[R],_=I.pts,x=_-k,C=Math.abs(1e3*x/d);if(x<=-D*v&&T)0===R&&(l.logger.warn("Audio frame @ "+(_/d).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*x/d)+" ms."),this.nextAudioPts=L=k=_);else if(x>=D*v&&C<1e4&&T){var w=Math.round(x/v);(k=_-w*v)<0&&(w--,k+=v),0===R&&(this.nextAudioPts=L=k),l.logger.warn("[mp4-remuxer]: Injecting "+w+" audio frame @ "+(k/d).toFixed(3)+"s due to "+Math.round(1e3*x/d)+" ms gap.");for(var P=0;P<w;P++){var O=Math.max(k,0),F=n.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);F||(l.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),F=I.unit.subarray()),S.splice(R,0,{unit:F,pts:O}),k+=v,R++}}I.pts=k,k+=v}for(var M,N=null,U=null,B=0,G=S.length;G--;)B+=S[G].unit.byteLength;for(var K=0,H=S.length;K<H;K++){var V=S[K],j=V.unit,Y=V.pts;if(null!==U)E[K-1].duration=Math.round((Y-U)/h);else{if(r&&"aac"===e.segmentCodec&&(Y=L),N=Y,!(B>0))return;B+=b;try{M=new Uint8Array(B)}catch(e){return void this.observer.emit(s.Events.ERROR,s.Events.ERROR,{type:o.ErrorTypes.MUX_ERROR,details:o.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:B,reason:"fail allocating audio mdat "+B})}p||(new DataView(M.buffer).setUint32(0,B),M.set(a.default.types.mdat,4))}M.set(j,b);var W=j.byteLength;b+=W,E.push(new y(!0,f,W,0)),U=Y}var q=E.length;if(q){var z=E[E.length-1];this.nextAudioPts=L=U+h*z.duration;var X=p?new Uint8Array(0):a.default.moof(e.sequenceNumber++,N/h,c({},e,{samples:E}));e.samples=[];var Q=N/d,$=L/d,Z={data1:X,data2:M,startPTS:Q,endPTS:$,startDTS:Q,endDTS:$,type:"audio",hasAudio:!0,hasVideo:!1,nb:q};return this.isAudioContiguous=!0,console.assert(M.length,"MDAT length must not be zero"),Z}},t.remuxEmptyAudio=function(e,t,r,i){var a=e.inputTimeScale,s=a/(e.samplerate?e.samplerate:a),o=this.nextAudioPts,u=(null!==o?o:i.startDTS*a)+this._initDTS,d=i.endDTS*a+this._initDTS,c=1024*s,h=Math.ceil((d-u)/c),f=n.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(l.logger.warn("[mp4-remuxer]: remux empty Audio"),f){for(var v=[],g=0;g<h;g++){var m=u+g*c;v.push({unit:f,pts:m,dts:m})}return e.samples=v,this.remuxAudio(e,t,r,!1)}l.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec")},e}();function g(e,t){var r;if(null===t)return e;for(r=t<e?-8589934592:8589934592;Math.abs(e-t)>4294967296;)e+=r;return e}function m(e,t,r,i){var n=e.samples.length;if(n){for(var a=e.inputTimeScale,s=0;s<n;s++){var o=e.samples[s];o.pts=g(o.pts-r,t*a)/a,o.dts=g(o.dts-i,t*a)/a}var l=e.samples;return e.samples=[],{samples:l}}}function p(e,t,r){var i=e.samples.length;if(i){for(var n=e.inputTimeScale,a=0;a<i;a++){var s=e.samples[a];s.pts=g(s.pts-r,t*n)/n}e.samples.sort((function(e,t){return e.pts-t.pts}));var o=e.samples;return e.samples=[],{samples:o}}}var y=function(e,t,r,i){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=r,this.cts=i,this.flags=new E(e)},E=function(e){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=e?2:1,this.isNonSync=e?0:1}},"./src/remux/passthrough-remuxer.ts":(e,t,r)=>{r.r(t),r.d(t,{default:()=>u});var i=r("./src/polyfills/number.ts"),n=r("./src/remux/mp4-remuxer.ts"),a=r("./src/utils/mp4-tools.ts"),s=r("./src/loader/fragment.ts"),o=r("./src/utils/logger.ts");function l(e,t){var r=null==e?void 0:e.codec;return r&&r.length>4?r:"hvc1"===r||"hev1"===r?"hvc1.1.c.L120.90":"av01"===r?"av01.0.04M.08":"avc1"===r||t===s.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}const u=function(){function e(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndTime=null}var t=e.prototype;return t.destroy=function(){},t.resetTimeStamp=function(e){this.initPTS=e,this.lastEndTime=null},t.resetNextTimestamp=function(){this.lastEndTime=null},t.resetInitSegment=function(e,t,r,i){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment((0,a.patchEncyptionData)(e,i)),this.emitInitSegment=!0},t.generateInitSegment=function(e){var t=this.audioCodec,r=this.videoCodec;if(!e||!e.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var i=this.initData=(0,a.parseInitSegment)(e);t||(t=l(i.audio,s.ElementaryStreamTypes.AUDIO)),r||(r=l(i.video,s.ElementaryStreamTypes.VIDEO));var n={};i.audio&&i.video?n.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:e,id:"main"}:i.audio?n.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:i.video?n.video={container:"video/mp4",codec:r,initSegment:e,id:"main"}:o.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=n},t.remux=function(e,t,r,s,l){var u,d=this.initPTS,c=this.lastEndTime,h={audio:void 0,video:void 0,text:s,id3:r,initSegment:void 0};(0,i.isFiniteNumber)(c)||(c=this.lastEndTime=l||0);var f=t.samples;if(!f||!f.length)return h;var v={initPTS:void 0,timescale:1},g=this.initData;if(g&&g.length||(this.generateInitSegment(f),g=this.initData),!g||!g.length)return o.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),h;this.emitInitSegment&&(v.tracks=this.initTracks,this.emitInitSegment=!1);var m=(0,a.getStartDTS)(g,f);(0,i.isFiniteNumber)(d)||(this.initPTS=v.initPTS=d=m-l);var p=(0,a.getDuration)(f,g),y=e?m-d:c,E=y+p;(0,a.offsetStartDTS)(g,f,d),p>0?this.lastEndTime=E:(o.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var T=!!g.audio,S=!!g.video,b="";T&&(b+="audio"),S&&(b+="video");var L={data1:f,startPTS:y,startDTS:y,endPTS:E,endDTS:E,type:b,hasAudio:T,hasVideo:S,nb:1,dropped:0};h.audio="audio"===L.type?L:void 0,h.video="audio"!==L.type?L:void 0,h.initSegment=v;var A=null!=(u=this.initPTS)?u:0;return h.id3=(0,n.flushTextTrackMetadataCueSamples)(r,l,A,A),s.samples.length&&(h.text=(0,n.flushTextTrackUserdataCueSamples)(s,l,A)),h},e}()},"./src/task-loop.ts":(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});var i=function(){function e(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var t=e.prototype;return t.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},t.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},t.onHandlerDestroyed=function(){},t.hasInterval=function(){return!!this._tickInterval},t.hasNextTick=function(){return!!this._tickTimer},t.setInterval=function(e){return!this._tickInterval&&(this._tickInterval=self.setInterval(this._boundTick,e),!0)},t.clearInterval=function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)},t.clearNextTick=function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)},t.tick=function(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},t.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},t.doTick=function(){},e}()},"./src/types/demuxer.ts":(e,t,r)=>{var i;r.r(t),r.d(t,{MetadataSchema:()=>i}),function(e){e.audioId3="org.id3",e.dateRange="com.apple.quicktime.HLS",e.emsg="https://aomedia.org/emsg/ID3"}(i||(i={}))},"./src/types/level.ts":(e,t,r)=>{function i(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(n=i.key,a=void 0,"symbol"==typeof(a=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(n,"string"))?a:String(a)),i)}var n,a}r.r(t),r.d(t,{HdcpLevels:()=>a,HlsSkip:()=>n,HlsUrlParameters:()=>o,Level:()=>l,getSkipValue:()=>s});var n,a=["NONE","TYPE-0","TYPE-1","TYPE-2",null];function s(e,t){var r=e.canSkipUntil,i=e.canSkipDateRanges,a=e.endSN;return r&&(void 0!==t?t-a:0)<r?i?n.v2:n.Yes:n.No}!function(e){e.No="",e.Yes="YES",e.v2="v2"}(n||(n={}));var o=function(){function e(e,t,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=r}return e.prototype.addDirectives=function(e){var t=new self.URL(e);return void 0!==this.msn&&t.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href},e}(),l=function(){function e(e){this.attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[e.url],this.attrs=e.attrs,this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.unknownCodecs=e.unknownCodecs,this.codecSet=[e.videoCodec,e.audioCodec].filter((function(e){return e})).join(",").replace(/\.[^.,]+/g,"")}var t,r,n;return t=e,(r=[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(e){var t=e%this.url.length;this._urlId!==t&&(this.details=void 0,this._urlId=t)}}])&&i(t.prototype,r),n&&i(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}()},"./src/types/loader.ts":(e,t,r)=>{var i,n;r.r(t),r.d(t,{PlaylistContextType:()=>i,PlaylistLevelType:()=>n}),function(e){e.MANIFEST="manifest",e.LEVEL="level",e.AUDIO_TRACK="audioTrack",e.SUBTITLE_TRACK="subtitleTrack"}(i||(i={})),function(e){e.MAIN="main",e.AUDIO="audio",e.SUBTITLE="subtitle"}(n||(n={}))},"./src/types/transmuxer.ts":(e,t,r)=>{r.r(t),r.d(t,{ChunkMetadata:()=>i});var i=function(e,t,r,i,n,a){void 0===i&&(i=0),void 0===n&&(n=-1),void 0===a&&(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={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=e,this.sn=t,this.id=r,this.size=i,this.part=n,this.partial=a}},"./src/utils/attr-list.ts":(e,t,r)=>{r.r(t),r.d(t,{AttrList:()=>a});var i=/^(\d+)x(\d+)$/,n=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,a=function(){function e(t){for(var r in"string"==typeof t&&(t=e.parseAttrList(t)),t)t.hasOwnProperty(r)&&(this[r]=t[r])}var t=e.prototype;return t.decimalInteger=function(e){var t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t},t.hexadecimalInteger=function(e){if(this[e]){var t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;for(var r=new Uint8Array(t.length/2),i=0;i<t.length/2;i++)r[i]=parseInt(t.slice(2*i,2*i+2),16);return r}return null},t.hexadecimalIntegerAsNumber=function(e){var t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t},t.decimalFloatingPoint=function(e){return parseFloat(this[e])},t.optionalFloat=function(e,t){var r=this[e];return r?parseFloat(r):t},t.enumeratedString=function(e){return this[e]},t.bool=function(e){return"YES"===this[e]},t.decimalResolution=function(e){var t=i.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}},e.parseAttrList=function(e){var t,r={};for(n.lastIndex=0;null!==(t=n.exec(e));){var i=t[2];0===i.indexOf('"')&&i.lastIndexOf('"')===i.length-1&&(i=i.slice(1,-1)),r[t[1]]=i}return r},e}()},"./src/utils/binary-search.ts":(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});const i={search:function(e,t){for(var r=0,i=e.length-1,n=null,a=null;r<=i;){var s=t(a=e[n=(r+i)/2|0]);if(s>0)r=n+1;else{if(!(s<0))return a;i=n-1}}return null}}},"./src/utils/buffer-helper.ts":(e,t,r)=>{r.r(t),r.d(t,{BufferHelper:()=>a});var i=r("./src/utils/logger.ts"),n={length:0,start:function(){return 0},end:function(){return 0}},a=function(){function e(){}return e.isBuffered=function(t,r){try{if(t)for(var i=e.getBuffered(t),n=0;n<i.length;n++)if(r>=i.start(n)&&r<=i.end(n))return!0}catch(e){}return!1},e.bufferInfo=function(t,r,i){try{if(t){var n,a=e.getBuffered(t),s=[];for(n=0;n<a.length;n++)s.push({start:a.start(n),end:a.end(n)});return this.bufferedInfo(s,r,i)}}catch(e){}return{len:0,start:r,end:r,nextStart:void 0}},e.bufferedInfo=function(e,t,r){t=Math.max(0,t),e.sort((function(e,t){var r=e.start-t.start;return r||t.end-e.end}));var i=[];if(r)for(var n=0;n<e.length;n++){var a=i.length;if(a){var s=i[a-1].end;e[n].start-s<r?e[n].end>s&&(i[a-1].end=e[n].end):i.push(e[n])}else i.push(e[n])}else i=e;for(var o,l=0,u=t,d=t,c=0;c<i.length;c++){var h=i[c].start,f=i[c].end;if(t+r>=h&&t<f)u=h,l=(d=f)-t;else if(t+r<h){o=h;break}}return{len:l,start:u||0,end:d||0,nextStart:o}},e.getBuffered=function(e){try{return e.buffered}catch(e){return i.logger.log("failed to get media.buffered",e),n}},e}()},"./src/utils/codecs.ts":(e,t,r)=>{r.r(t),r.d(t,{isCodecSupportedInMp4:()=>a,isCodecType:()=>n});var i={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dva1:!0,dvav:!0,dvh1:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}};function n(e,t){var r=i[t];return!!r&&!0===r[e.slice(0,4)]}function a(e,t){return MediaSource.isTypeSupported((t||"video")+'/mp4;codecs="'+e+'"')}},"./src/utils/discontinuities.ts":(e,t,r)=>{r.r(t),r.d(t,{adjustSlidingStart:()=>d,alignMediaPlaylistByPDT:()=>f,alignPDT:()=>h,alignStream:()=>c,findDiscontinuousReferenceFrag:()=>l,findFirstFragWithCC:()=>s,shouldAlignOnDiscontinuities:()=>o});var i=r("./src/polyfills/number.ts"),n=r("./src/utils/logger.ts"),a=r("./src/controller/level-helper.ts");function s(e,t){for(var r=null,i=0,n=e.length;i<n;i++){var a=e[i];if(a&&a.cc===t){r=a;break}}return r}function o(e,t,r){return!(!t.details||!(r.endCC>r.startCC||e&&e.cc<r.startCC))}function l(e,t,r){void 0===r&&(r=0);var i=e.fragments,a=t.fragments;if(a.length&&i.length){var o=s(i,a[0].cc);if(o&&(!o||o.startPTS))return o;n.logger.log("No frag in previous level to align on")}else n.logger.log("No fragments to align")}function u(e,t){if(e){var r=e.start+t;e.start=e.startPTS=r,e.endPTS=r+e.duration}}function d(e,t){for(var r=t.fragments,i=0,n=r.length;i<n;i++)u(r[i],e);t.fragmentHint&&u(t.fragmentHint,e),t.alignedSliding=!0}function c(e,t,r){t&&(function(e,t,r){if(o(e,r,t)){var a=l(r.details,t);a&&(0,i.isFiniteNumber)(a.start)&&(n.logger.log("Adjusting PTS using last level due to CC increase within current level "+t.url),d(a.start,t))}}(e,r,t),!r.alignedSliding&&t.details&&h(r,t.details),r.alignedSliding||!t.details||r.skippedSegments||(0,a.adjustSliding)(t.details,r))}function h(e,t){if(t.fragments.length&&e.hasProgramDateTime&&t.hasProgramDateTime){var r=t.fragments[0].programDateTime,a=e.fragments[0].programDateTime,s=(a-r)/1e3+t.fragments[0].start;s&&(0,i.isFiniteNumber)(s)&&(n.logger.log("Adjusting PTS using programDateTime delta "+(a-r)+"ms, sliding:"+s.toFixed(3)+" "+e.url+" "),d(s,e))}}function f(e,t){if(e.hasProgramDateTime&&t.hasProgramDateTime){var r=e.fragments,i=t.fragments;if(r.length&&i.length){var n=i[Math.round(i.length/2)-1],a=s(r,n.cc)||r[Math.round(r.length/2)-1],o=n.programDateTime,l=a.programDateTime;null!==o&&null!==l&&d((l-o)/1e3-(a.start-n.start),e)}}}},"./src/utils/ewma-bandwidth-estimator.ts":(e,t,r)=>{r.r(t),r.d(t,{default:()=>n});var i=r("./src/utils/ewma.ts");const n=function(){function e(e,t,r){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new i.default(e),this.fast_=new i.default(t)}var t=e.prototype;return t.update=function(e,t){var r=this.slow_,n=this.fast_;this.slow_.halfLife!==e&&(this.slow_=new i.default(e,r.getEstimate(),r.getTotalWeight())),this.fast_.halfLife!==t&&(this.fast_=new i.default(t,n.getEstimate(),n.getTotalWeight()))},t.sample=function(e,t){var r=(e=Math.max(e,this.minDelayMs_))/1e3,i=8*t/r;this.fast_.sample(r,i),this.slow_.sample(r,i)},t.canEstimate=function(){var e=this.fast_;return e&&e.getTotalWeight()>=this.minWeight_},t.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},t.destroy=function(){},e}()},"./src/utils/ewma.ts":(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});const i=function(){function e(e,t,r){void 0===t&&(t=0),void 0===r&&(r=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=r}var t=e.prototype;return t.sample=function(e,t){var r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e},t.getTotalWeight=function(){return this.totalWeight_},t.getEstimate=function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_},e}()},"./src/utils/fetch-loader.ts":(e,t,r)=>{r.r(t),r.d(t,{default:()=>g,fetchSupported:()=>c});var i=r("./src/polyfills/number.ts"),n=r("./src/loader/load-stats.ts"),a=r("./src/demux/chunk-cache.ts");function s(e){var t="function"==typeof Map?new Map:void 0;return s=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,i)}function i(){return o(e,arguments,u(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),l(i,e)},s(e)}function o(e,t,r){return o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}()?Reflect.construct.bind():function(e,t,r){var i=[null];i.push.apply(i,t);var n=new(Function.bind.apply(e,i));return r&&l(n,r.prototype),n},o.apply(null,arguments)}function l(e,t){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},l(e,t)}function u(e){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},u(e)}function d(){return d=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},d.apply(this,arguments)}function c(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(e){}return!1}var h=function(){function e(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||f,this.controller=new self.AbortController,this.stats=new n.LoadStats}var t=e.prototype;return t.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},t.abortInternal=function(){var e=this.response;e&&e.ok||(this.stats.aborted=!0,this.controller.abort())},t.abort=function(){var e;this.abortInternal(),null!==(e=this.callbacks)&&void 0!==e&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},t.load=function(e,t,r){var n=this,a=this.stats;if(a.loading.start)throw new Error("Loader can only be used once.");a.loading.start=self.performance.now();var s=function(e,t){var r={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(d({},e.headers))};return e.rangeEnd&&r.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1)),r}(e,this.controller.signal),o=r.onProgress,l="arraybuffer"===e.responseType,u=l?"byteLength":"length";this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,s),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout((function(){n.abortInternal(),r.onTimeout(a,e,n.response)}),t.timeout),self.fetch(this.request).then((function(r){if(n.response=n.loader=r,!r.ok){var s=r.status,u=r.statusText;throw new v(u||"fetch, bad network response",s,r)}return a.loading.first=Math.max(self.performance.now(),a.loading.start),a.total=parseInt(r.headers.get("Content-Length")||"0"),o&&(0,i.isFiniteNumber)(t.highWaterMark)?n.loadProgressively(r,a,e,t.highWaterMark,o):l?r.arrayBuffer():r.text()})).then((function(s){var l=n.response;self.clearTimeout(n.requestTimeout),a.loading.end=Math.max(self.performance.now(),a.loading.first);var d=s[u];d&&(a.loaded=a.total=d);var c={url:l.url,data:s};o&&!(0,i.isFiniteNumber)(t.highWaterMark)&&o(a,e,s,l),r.onSuccess(c,a,e,l)})).catch((function(t){if(self.clearTimeout(n.requestTimeout),!a.aborted){var i=t&&t.code||0,s=t?t.message:null;r.onError({code:i,text:s},e,t?t.details:null)}}))},t.getCacheAge=function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?parseFloat(t):null}return e},t.loadProgressively=function(e,t,r,i,n){void 0===i&&(i=0);var s=new a.default,o=e.body.getReader();return function a(){return o.read().then((function(o){if(o.done)return s.dataLength&&n(t,r,s.flush(),e),Promise.resolve(new ArrayBuffer(0));var l=o.value,u=l.length;return t.loaded+=u,u<i||s.dataLength?(s.push(l),s.dataLength>=i&&n(t,r,s.flush(),e)):n(t,r,l,e),a()})).catch((function(){return Promise.reject()}))}()},e}();function f(e,t){return new self.Request(e.url,t)}var v=function(e){var t,r;function i(t,r,i){var n;return(n=e.call(this,t)||this).code=void 0,n.details=void 0,n.code=r,n.details=i,n}return r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,l(t,r),i}(s(Error));const g=h},"./src/utils/hex.ts":(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});const i={hexDump:function(e){for(var t="",r=0;r<e.length;r++){var i=e[r].toString(16);i.length<2&&(i="0"+i),t+=i}return t}}},"./src/utils/keysystem-util.ts":(e,t,r)=>{r.r(t),r.d(t,{changeEndianness:()=>n,convertDataUriToArrayBytes:()=>a,strToUtf8array:()=>s});var i=r("./src/utils/numeric-encoding-utils.ts");function n(e){var t=function(e,t,r){var i=e[t];e[t]=e[r],e[r]=i};t(e,0,3),t(e,1,2),t(e,4,5),t(e,6,7)}function a(e){var t,r,n=e.split(":"),a=null;if("data"===n[0]&&2===n.length){var o=n[1].split(";"),l=o[o.length-1].split(",");if(2===l.length){var u="base64"===l[0],d=l[1];u?(o.splice(-1,1),a=(0,i.base64Decode)(d)):(t=s(d).subarray(0,16),(r=new Uint8Array(16)).set(t,16-t.length),a=r)}}return a}function s(e){return Uint8Array.from(unescape(encodeURIComponent(e)),(function(e){return e.charCodeAt(0)}))}},"./src/utils/logger.ts":(e,t,r)=>{r.r(t),r.d(t,{enableLogs:()=>o,logger:()=>l});var i=function(){},n={trace:i,debug:i,log:i,warn:i,info:i,error:i},a=n;function s(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];r.forEach((function(t){a[t]=e[t]?e[t].bind(e):function(e){var t=self.console[e];return t?t.bind(self.console,"["+e+"] >"):i}(t)}))}function o(e,t){if(self.console&&!0===e||"object"==typeof e){s(e,"debug","log","info","warn","error");try{a.log('Debug logs enabled for "'+t+'"')}catch(e){a=n}}else a=n}var l=n},"./src/utils/mediakeys-helper.ts":(e,t,r)=>{var i,n,a;function s(e){switch(e){case n.FAIRPLAY:return i.FAIRPLAY;case n.PLAYREADY:return i.PLAYREADY;case n.WIDEVINE:return i.WIDEVINE;case n.CLEARKEY:return i.CLEARKEY}}function o(e){if(e===a.WIDEVINE)return i.WIDEVINE}function l(e){switch(e){case i.FAIRPLAY:return n.FAIRPLAY;case i.PLAYREADY:return n.PLAYREADY;case i.WIDEVINE:return n.WIDEVINE;case i.CLEARKEY:return n.CLEARKEY}}function u(e){var t=e.drmSystems,r=e.widevineLicenseUrl,n=t?[i.FAIRPLAY,i.WIDEVINE,i.PLAYREADY,i.CLEARKEY].filter((function(e){return!!t[e]})):[];return!n[i.WIDEVINE]&&r&&n.push(i.WIDEVINE),n}r.r(t),r.d(t,{KeySystemFormats:()=>n,KeySystemIds:()=>a,KeySystems:()=>i,getKeySystemsForConfig:()=>u,getSupportedMediaKeySystemConfigurations:()=>c,keySystemDomainToKeySystemFormat:()=>l,keySystemFormatToKeySystemDomain:()=>s,keySystemIdToKeySystemDomain:()=>o,requestMediaKeySystemAccess:()=>d}),function(e){e.CLEARKEY="org.w3.clearkey",e.FAIRPLAY="com.apple.fps",e.PLAYREADY="com.microsoft.playready",e.WIDEVINE="com.widevine.alpha"}(i||(i={})),function(e){e.CLEARKEY="org.w3.clearkey",e.FAIRPLAY="com.apple.streamingkeydelivery",e.PLAYREADY="com.microsoft.playready",e.WIDEVINE="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"}(n||(n={})),function(e){e.WIDEVINE="edef8ba979d64acea3c827dcd51d21ed"}(a||(a={}));var d="undefined"!=typeof self&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function c(e,t,r,n){var a;switch(e){case i.FAIRPLAY:a=["cenc","sinf"];break;case i.WIDEVINE:case i.PLAYREADY:a=["cenc"];break;case i.CLEARKEY:a=["cenc","keyids"];break;default:throw new Error("Unknown key-system: "+e)}return function(e,t,r,i){var n={initDataTypes:e,persistentState:i.persistentState||"not-allowed",distinctiveIdentifier:i.distinctiveIdentifier||"not-allowed",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:t.map((function(e){return{contentType:'audio/mp4; codecs="'+e+'"',robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null}})),videoCapabilities:r.map((function(e){return{contentType:'video/mp4; codecs="'+e+'"',robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}}))};return[n]}(a,t,r,n)}},"./src/utils/mediasource-helper.ts":(e,t,r)=>{function i(){return self.MediaSource||self.WebKitMediaSource}r.r(t),r.d(t,{getMediaSource:()=>i})},"./src/utils/mp4-tools.ts":(e,t,r)=>{r.r(t),r.d(t,{RemuxerTrackIdConfig:()=>d,appendUint8Array:()=>R,bin2str:()=>c,computeRawDurationFromSamples:()=>L,discardEPB:()=>x,findBox:()=>m,getDuration:()=>b,getStartDTS:()=>S,mp4Box:()=>w,mp4pssh:()=>P,offsetStartDTS:()=>A,parseEmsg:()=>C,parseInitSegment:()=>y,parsePssh:()=>O,parseSEIMessageFromNALu:()=>_,parseSamples:()=>k,parseSegmentIndex:()=>p,parseSinf:()=>T,patchEncyptionData:()=>E,readSint32:()=>v,readUint16:()=>h,readUint32:()=>f,segmentValidRange:()=>D,writeUint32:()=>g});var i=r("./src/loader/fragment.ts"),n=r("./src/utils/typed-array.ts"),a=r("./src/demux/id3.ts"),s=r("./src/utils/logger.ts"),o=r("./src/utils/hex.ts"),l=Math.pow(2,32)-1,u=[].push,d={video:1,audio:2,id3:3,text:4};function c(e){return String.fromCharCode.apply(null,e)}function h(e,t){var r=e[t]<<8|e[t+1];return r<0?65536+r:r}function f(e,t){var r=v(e,t);return r<0?4294967296+r:r}function v(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function g(e,t,r){e[t]=r>>24,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r}function m(e,t){var r=[];if(!t.length)return r;for(var i=e.byteLength,n=0;n<i;){var a=f(e,n),s=a>1?n+a:i;if(c(e.subarray(n+4,n+8))===t[0])if(1===t.length)r.push(e.subarray(n+8,s));else{var o=m(e.subarray(n+8,s),t.slice(1));o.length&&u.apply(r,o)}n=s}return r}function p(e){var t=[],r=e[0],i=8,n=f(e,i);i+=4,i+=0===r?8:16,i+=2;var a=e.length+0,s=h(e,i);i+=2;for(var o=0;o<s;o++){var l=i,u=f(e,l);l+=4;var d=2147483647&u;if(1==(2147483648&u)>>>31)return console.warn("SIDX has hierarchical references (not supported)"),null;var c=f(e,l);l+=4,t.push({referenceSize:d,subsegmentDuration:c,info:{duration:c/n,start:a,end:a+d-1}}),a+=d,i=l+=4}return{earliestPresentationTime:0,timescale:n,version:r,referencesCount:s,references:t}}function y(e){for(var t=[],r=m(e,["moov","trak"]),n=0;n<r.length;n++){var a=r[n],s=m(a,["tkhd"])[0];if(s){var o=s[0],l=0===o?12:20,u=f(s,l),d=m(a,["mdia","mdhd"])[0];if(d){var h=f(d,l=0===(o=d[0])?12:20),v=m(a,["mdia","hdlr"])[0];if(v){var g=c(v.subarray(8,12)),p={soun:i.ElementaryStreamTypes.AUDIO,vide:i.ElementaryStreamTypes.VIDEO}[g];if(p){var y=m(a,["mdia","minf","stbl","stsd"])[0],E=void 0;y&&(E=c(y.subarray(12,16))),t[u]={timescale:h,type:p},t[p]={timescale:h,id:u,codec:E}}}}}}return m(e,["moov","mvex","trex"]).forEach((function(e){var r=f(e,4),i=t[r];i&&(i.default={duration:f(e,12),flags:f(e,20)})})),t}function E(e,t){if(!e||!t)return e;var r=t.keyId;return r&&t.isCommonEncryption&&m(e,["moov","trak"]).forEach((function(e){var t=m(e,["mdia","minf","stbl","stsd"])[0].subarray(8),i=m(t,["enca"]),n=i.length>0;n||(i=m(t,["encv"])),i.forEach((function(e){m(n?e.subarray(28):e.subarray(78),["sinf"]).forEach((function(e){var t=T(e);if(t){var i=t.subarray(8,24);i.some((function(e){return 0!==e}))||(s.logger.log("[eme] Patching keyId in 'enc"+(n?"a":"v")+">sinf>>tenc' box: "+o.default.hexDump(i)+" -> "+o.default.hexDump(r)),t.set(r,8))}}))}))})),e}function T(e){var t=m(e,["schm"])[0];if(t){var r=c(t.subarray(4,8));if("cbcs"===r||"cenc"===r)return m(e,["schi","tenc"])[0]}return s.logger.error("[eme] missing 'schm' box"),null}function S(e,t){return m(t,["moof","traf"]).reduce((function(t,r){var i=m(r,["tfdt"])[0],n=i[0],a=m(r,["tfhd"]).reduce((function(t,r){var a=f(r,4),s=e[a];if(s){var o=f(i,4);1===n&&(o*=Math.pow(2,32),o+=f(i,8));var l=o/(s.timescale||9e4);if(isFinite(l)&&(null===t||l<t))return l}return t}),null);return null!==a&&isFinite(a)&&(null===t||a<t)?a:t}),null)||0}function b(e,t){for(var r=0,n=0,a=0,s=m(e,["moof","traf"]),o=0;o<s.length;o++){var l=s[o],u=m(l,["tfhd"])[0],d=t[f(u,4)];if(d){var c=d.default,h=f(u,0)|(null==c?void 0:c.flags),v=null==c?void 0:c.duration;8&h&&(v=f(u,2&h?12:8));for(var g=d.timescale||9e4,y=m(l,["trun"]),E=0;E<y.length;E++)!(r=L(y[E]))&&v&&(r=v*f(y[E],4)),d.type===i.ElementaryStreamTypes.VIDEO?n+=r/g:d.type===i.ElementaryStreamTypes.AUDIO&&(a+=r/g)}}if(0===n&&0===a){for(var T=0,S=m(e,["sidx"]),b=0;b<S.length;b++){var A=p(S[b]);null!=A&&A.references&&(T+=A.references.reduce((function(e,t){return e+t.info.duration||0}),0))}return T}return n||a}function L(e){var t=f(e,0),r=8;1&t&&(r+=4),4&t&&(r+=4);for(var i=0,n=f(e,4),a=0;a<n;a++)256&t&&(i+=f(e,r),r+=4),512&t&&(r+=4),1024&t&&(r+=4),2048&t&&(r+=4);return i}function A(e,t,r){m(t,["moof","traf"]).forEach((function(t){m(t,["tfhd"]).forEach((function(i){var n=f(i,4),a=e[n];if(a){var s=a.timescale||9e4;m(t,["tfdt"]).forEach((function(e){var t=e[0],i=f(e,4);if(0===t)i-=r*s,g(e,4,i=Math.max(i,0));else{i*=Math.pow(2,32),i+=f(e,8),i-=r*s,i=Math.max(i,0);var n=Math.floor(i/(l+1)),a=Math.floor(i%(l+1));g(e,4,n),g(e,8,a)}}))}}))}))}function D(e){var t={valid:null,remainder:null},r=m(e,["moof"]);if(!r)return t;if(r.length<2)return t.remainder=e,t;var i=r[r.length-1];return t.valid=(0,n.sliceUint8)(e,0,i.byteOffset-8),t.remainder=(0,n.sliceUint8)(e,i.byteOffset-8),t}function R(e,t){var r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function k(e,t){var r=[],n=t.samples,a=t.timescale,s=t.id,o=!1;return m(n,["moof"]).map((function(l){var u=l.byteOffset-8;m(l,["traf"]).map((function(l){var d=m(l,["tfdt"]).map((function(e){var t=e[0],r=f(e,4);return 1===t&&(r*=Math.pow(2,32),r+=f(e,8)),r/a}))[0];return void 0!==d&&(e=d),m(l,["tfhd"]).map((function(d){var c=f(d,4),h=16777215&f(d,0),g=0,p=0!=(16&h),y=0,E=0!=(32&h),T=8;c===s&&(0!=(1&h)&&(T+=8),0!=(2&h)&&(T+=4),0!=(8&h)&&(g=f(d,T),T+=4),p&&(y=f(d,T),T+=4),E&&(T+=4),"video"===t.type&&(o=function(e){if(!e)return!1;var t=e.indexOf("."),r=t<0?e:e.substring(0,t);return"hvc1"===r||"hev1"===r||"dvh1"===r||"dvhe"===r}(t.codec)),m(l,["trun"]).map((function(s){var l=s[0],d=16777215&f(s,0),c=0!=(1&d),h=0,m=0!=(4&d),p=0!=(256&d),E=0,T=0!=(512&d),S=0,b=0!=(1024&d),L=0!=(2048&d),A=0,D=f(s,4),R=8;c&&(h=f(s,R),R+=4),m&&(R+=4);for(var k=h+u,x=0;x<D;x++){if(p?(E=f(s,R),R+=4):E=g,T?(S=f(s,R),R+=4):S=y,b&&(R+=4),L&&(A=0===l?f(s,R):v(s,R),R+=4),t.type===i.ElementaryStreamTypes.VIDEO)for(var C=0;C<S;){var w=f(n,k);I(o,n[k+=4])&&_(n.subarray(k,k+w),o?2:1,e+A/a,r),k+=w,C+=w+4}e+=E/a}})))}))}))})),r}function I(e,t){if(e){var r=t>>1&63;return 39===r||40===r}return 6==(31&t)}function _(e,t,r,i){var n=x(e),s=0;s+=t;for(var o=0,l=0,u=!1,d=0;s<n.length;){o=0;do{if(s>=n.length)break;o+=d=n[s++]}while(255===d);l=0;do{if(s>=n.length)break;l+=d=n[s++]}while(255===d);var c=n.length-s;if(!u&&4===o&&s<n.length){if(u=!0,181===n[s++]){var v=h(n,s);if(s+=2,49===v){var g=f(n,s);if(s+=4,1195456820===g){var m=n[s++];if(3===m){var p=n[s++],y=64&p,E=y?2+3*(31&p):0,T=new Uint8Array(E);if(y){T[0]=p;for(var S=1;S<E;S++)T[S]=n[s++]}i.push({type:m,payloadType:o,pts:r,bytes:T})}}}}}else if(5===o&&l<c){if(u=!0,l>16){for(var b=[],L=0;L<16;L++){var A=n[s++].toString(16);b.push(1==A.length?"0"+A:A),3!==L&&5!==L&&7!==L&&9!==L||b.push("-")}for(var D=l-16,R=new Uint8Array(D),k=0;k<D;k++)R[k]=n[s++];i.push({payloadType:o,pts:r,uuid:b.join(""),userData:(0,a.utf8ArrayToStr)(R),userDataBytes:R})}}else if(l<c)s+=l;else if(l>c)break}}function x(e){for(var t=e.byteLength,r=[],i=1;i<t-2;)0===e[i]&&0===e[i+1]&&3===e[i+2]?(r.push(i+2),i+=2):i++;if(0===r.length)return e;var n=t-r.length,a=new Uint8Array(n),s=0;for(i=0;i<n;s++,i++)s===r[0]&&(s++,r.shift()),a[i]=e[s];return a}function C(e){var t=e[0],r="",i="",n=0,a=0,s=0,o=0,l=0,u=0;if(0===t){for(;"\0"!==c(e.subarray(u,u+1));)r+=c(e.subarray(u,u+1)),u+=1;for(r+=c(e.subarray(u,u+1)),u+=1;"\0"!==c(e.subarray(u,u+1));)i+=c(e.subarray(u,u+1)),u+=1;i+=c(e.subarray(u,u+1)),u+=1,n=f(e,12),a=f(e,16),o=f(e,20),l=f(e,24),u=28}else if(1===t){n=f(e,u+=4);var d=f(e,u+=4),h=f(e,u+=4);for(u+=4,s=Math.pow(2,32)*d+h,Number.isSafeInteger(s)||(s=Number.MAX_SAFE_INTEGER,console.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=f(e,u),l=f(e,u+=4),u+=4;"\0"!==c(e.subarray(u,u+1));)r+=c(e.subarray(u,u+1)),u+=1;for(r+=c(e.subarray(u,u+1)),u+=1;"\0"!==c(e.subarray(u,u+1));)i+=c(e.subarray(u,u+1)),u+=1;i+=c(e.subarray(u,u+1)),u+=1}return{schemeIdUri:r,value:i,timeScale:n,presentationTime:s,presentationTimeDelta:a,eventDuration:o,id:l,payload:e.subarray(u,e.byteLength)}}function w(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];for(var n=r.length,a=8,s=n;s--;)a+=r[s].byteLength;var o=new Uint8Array(a);for(o[0]=a>>24&255,o[1]=a>>16&255,o[2]=a>>8&255,o[3]=255&a,o.set(e,4),s=0,a=8;s<n;s++)o.set(r[s],a),a+=r[s].byteLength;return o}function P(e,t,r){if(16!==e.byteLength)throw new RangeError("Invalid system id");var i,n,a;if(t){i=1,n=new Uint8Array(16*t.length);for(var s=0;s<t.length;s++){var o=t[s];if(16!==o.byteLength)throw new RangeError("Invalid key");n.set(o,16*s)}}else i=0,n=new Uint8Array;i>0?(a=new Uint8Array(4),t.length>0&&new DataView(a.buffer).setUint32(0,t.length,!1)):a=new Uint8Array;var l=new Uint8Array(4);return r&&r.byteLength>0&&new DataView(l.buffer).setUint32(0,r.byteLength,!1),w([112,115,115,104],new Uint8Array([i,0,0,0]),e,a,n,l,r||new Uint8Array)}function O(e){if(!(e instanceof ArrayBuffer)||e.byteLength<32)return null;var t={version:0,systemId:"",kids:null,data:null},r=new DataView(e),i=r.getUint32(0);if(e.byteLength!==i&&i>44)return null;if(1886614376!==r.getUint32(4))return null;if(t.version=r.getUint32(8)>>>24,t.version>1)return null;t.systemId=o.default.hexDump(new Uint8Array(e,12,16));var n=r.getUint32(28);if(0===t.version){if(i-32<n)return null;t.data=new Uint8Array(e,32,n)}else if(1===t.version){t.kids=[];for(var a=0;a<n;a++)t.kids.push(new Uint8Array(e,32+16*a,16))}return t}},"./src/utils/numeric-encoding-utils.ts":(e,t,r)=>{function i(e){return e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function n(e){return btoa(e)}function a(e){return atob(e)}function s(e){return btoa(String.fromCharCode.apply(String,e))}function o(e){return i(s(e))}function l(e){return Uint8Array.from(atob(e),(function(e){return e.charCodeAt(0)}))}r.r(t),r.d(t,{base64Decode:()=>l,base64DecodeToStr:()=>a,base64Encode:()=>s,base64ToBase64Url:()=>i,base64UrlEncode:()=>o,strToBase64Encode:()=>n})},"./src/utils/texttrack-utils.ts":(e,t,r)=>{r.r(t),r.d(t,{addCueToTrack:()=>a,clearCurrentCues:()=>s,getCuesInRange:()=>l,removeCuesInRange:()=>o,sendAddTrackEvent:()=>n});var i=r("./src/utils/logger.ts");function n(e,t){var r;try{r=new Event("addtrack")}catch(e){(r=document.createEvent("Event")).initEvent("addtrack",!1,!1)}r.track=e,t.dispatchEvent(r)}function a(e,t){var r=e.mode;if("disabled"===r&&(e.mode="hidden"),e.cues&&!e.cues.getCueById(t.id))try{if(e.addCue(t),!e.cues.getCueById(t.id))throw new Error("addCue is failed for: "+t)}catch(r){i.logger.debug("[texttrack-utils]: "+r);var n=new self.TextTrackCue(t.startTime,t.endTime,t.text);n.id=t.id,e.addCue(n)}"disabled"===r&&(e.mode=r)}function s(e){var t=e.mode;if("disabled"===t&&(e.mode="hidden"),e.cues)for(var r=e.cues.length;r--;)e.removeCue(e.cues[r]);"disabled"===t&&(e.mode=t)}function o(e,t,r,i){var n=e.mode;if("disabled"===n&&(e.mode="hidden"),e.cues&&e.cues.length>0)for(var a=l(e.cues,t,r),s=0;s<a.length;s++)i&&!i(a[s])||e.removeCue(a[s]);"disabled"===n&&(e.mode=n)}function l(e,t,r){var i=[],n=function(e,t){if(t<e[0].startTime)return 0;var r=e.length-1;if(t>e[r].endTime)return-1;for(var i=0,n=r;i<=n;){var a=Math.floor((n+i)/2);if(t<e[a].startTime)n=a-1;else{if(!(t>e[a].startTime&&i<r))return a;i=a+1}}return e[i].startTime-t<t-e[n].startTime?i:n}(e,t);if(n>-1)for(var a=n,s=e.length;a<s;a++){var o=e[a];if(o.startTime>=t&&o.endTime<=r)i.push(o);else if(o.startTime>r)return i}return i}},"./src/utils/time-ranges.ts":(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});const i={toString:function(e){for(var t="",r=e.length,i=0;i<r;i++)t+="["+e.start(i).toFixed(3)+"-"+e.end(i).toFixed(3)+"]";return t}}},"./src/utils/timescale-conversion.ts":(e,t,r)=>{r.r(t),r.d(t,{toMpegTsClockFromTimescale:()=>o,toMsFromMpegTsClock:()=>s,toTimescaleFromBase:()=>n,toTimescaleFromScale:()=>a});var i=9e4;function n(e,t,r,i){void 0===r&&(r=1),void 0===i&&(i=!1);var n=e*t*r;return i?Math.round(n):n}function a(e,t,r,i){return void 0===r&&(r=1),void 0===i&&(i=!1),n(e,t,1/r,i)}function s(e,t){return void 0===t&&(t=!1),n(e,1e3,1/i,t)}function o(e,t){return void 0===t&&(t=1),n(e,i,1/t)}},"./src/utils/typed-array.ts":(e,t,r)=>{function i(e,t,r){return Uint8Array.prototype.slice?e.slice(t,r):new Uint8Array(Array.prototype.slice.call(e,t,r))}r.r(t),r.d(t,{sliceUint8:()=>i})},"./src/utils/xhr-loader.ts":(e,t,r)=>{r.r(t),r.d(t,{default:()=>s});var i=r("./src/utils/logger.ts"),n=r("./src/loader/load-stats.ts"),a=/^age:\s*[\d.]+\s*$/m;const s=function(){function e(e){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=e?e.xhrSetup:null,this.stats=new n.LoadStats,this.retryDelay=0}var t=e.prototype;return t.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},t.abortInternal=function(){var e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,4!==e.readyState&&(this.stats.aborted=!0,e.abort()))},t.abort=function(){var e;this.abortInternal(),null!==(e=this.callbacks)&&void 0!==e&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},t.load=function(e,t,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=r,this.retryDelay=t.retryDelay,this.loadInternal()},t.loadInternal=function(){var e=this.config,t=this.context;if(e){var r=this.loader=new self.XMLHttpRequest,i=this.stats;i.loading.first=0,i.loaded=0;var n=this.xhrSetup;try{if(n)try{n(r,t.url)}catch(e){r.open("GET",t.url,!0),n(r,t.url)}r.readyState||r.open("GET",t.url,!0);var a=this.context.headers;if(a)for(var s in a)r.setRequestHeader(s,a[s])}catch(e){return void this.callbacks.onError({code:r.status,text:e.message},t,r)}t.rangeEnd&&r.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),r.onreadystatechange=this.readystatechange.bind(this),r.onprogress=this.loadprogress.bind(this),r.responseType=t.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),e.timeout),r.send()}},t.readystatechange=function(){var e=this.context,t=this.loader,r=this.stats;if(e&&t){var n=t.readyState,a=this.config;if(!r.aborted&&n>=2)if(self.clearTimeout(this.requestTimeout),0===r.loading.first&&(r.loading.first=Math.max(self.performance.now(),r.loading.start)),4===n){t.onreadystatechange=null,t.onprogress=null;var s=t.status,o="arraybuffer"===t.responseType;if(s>=200&&s<300&&(o&&t.response||null!==t.responseText)){var l,u;if(r.loading.end=Math.max(self.performance.now(),r.loading.first),u=o?(l=t.response).byteLength:(l=t.responseText).length,r.loaded=r.total=u,!this.callbacks)return;var d=this.callbacks.onProgress;if(d&&d(r,e,l,t),!this.callbacks)return;var c={url:t.responseURL,data:l};this.callbacks.onSuccess(c,r,e,t)}else r.retry>=a.maxRetry||s>=400&&s<499?(i.logger.error(s+" while loading "+e.url),this.callbacks.onError({code:s,text:t.statusText},e,t)):(i.logger.warn(s+" while loading "+e.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,a.maxRetryDelay),r.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),a.timeout)}},t.loadtimeout=function(){i.logger.warn("timeout while loading "+this.context.url);var e=this.callbacks;e&&(this.abortInternal(),e.onTimeout(this.stats,this.context,this.loader))},t.loadprogress=function(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)},t.getCacheAge=function(){var e=null;if(this.loader&&a.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e},e}()},"./node_modules/eventemitter3/index.js":e=>{var t=Object.prototype.hasOwnProperty,r="~";function i(){}function n(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function a(e,t,i,a,s){if("function"!=typeof i)throw new TypeError("The listener must be a function");var o=new n(i,a||e,s),l=r?r+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],o]:e._events[l].push(o):(e._events[l]=o,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new i:delete e._events[t]}function o(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(r=!1)),o.prototype.eventNames=function(){var e,i,n=[];if(0===this._eventsCount)return n;for(i in e=this._events)t.call(e,i)&&n.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},o.prototype.listeners=function(e){var t=r?r+e:e,i=this._events[t];if(!i)return[];if(i.fn)return[i.fn];for(var n=0,a=i.length,s=new Array(a);n<a;n++)s[n]=i[n].fn;return s},o.prototype.listenerCount=function(e){var t=r?r+e:e,i=this._events[t];return i?i.fn?1:i.length:0},o.prototype.emit=function(e,t,i,n,a,s){var o=r?r+e:e;if(!this._events[o])return!1;var l,u,d=this._events[o],c=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),c){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,t),!0;case 3:return d.fn.call(d.context,t,i),!0;case 4:return d.fn.call(d.context,t,i,n),!0;case 5:return d.fn.call(d.context,t,i,n,a),!0;case 6:return d.fn.call(d.context,t,i,n,a,s),!0}for(u=1,l=new Array(c-1);u<c;u++)l[u-1]=arguments[u];d.fn.apply(d.context,l)}else{var h,f=d.length;for(u=0;u<f;u++)switch(d[u].once&&this.removeListener(e,d[u].fn,void 0,!0),c){case 1:d[u].fn.call(d[u].context);break;case 2:d[u].fn.call(d[u].context,t);break;case 3:d[u].fn.call(d[u].context,t,i);break;case 4:d[u].fn.call(d[u].context,t,i,n);break;default:if(!l)for(h=1,l=new Array(c-1);h<c;h++)l[h-1]=arguments[h];d[u].fn.apply(d[u].context,l)}}return!0},o.prototype.on=function(e,t,r){return a(this,e,t,r,!1)},o.prototype.once=function(e,t,r){return a(this,e,t,r,!0)},o.prototype.removeListener=function(e,t,i,n){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn!==t||n&&!o.once||i&&o.context!==i||s(this,a);else{for(var l=0,u=[],d=o.length;l<d;l++)(o[l].fn!==t||n&&!o[l].once||i&&o[l].context!==i)&&u.push(o[l]);u.length?this._events[a]=1===u.length?u[0]:u:s(this,a)}return this},o.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=r,o.EventEmitter=o,e.exports=o},"./node_modules/url-toolkit/src/url-toolkit.js":function(e){var t,r,i,n,a;t=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,r=/^(?=([^\/?#]*))\1([^]*)$/,i=/(?:\/|^)\.(?=\/)/g,n=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,a={buildAbsoluteURL:function(e,t,i){if(i=i||{},e=e.trim(),!(t=t.trim())){if(!i.alwaysNormalize)return e;var n=a.parseURL(e);if(!n)throw new Error("Error trying to parse base URL.");return n.path=a.normalizePath(n.path),a.buildURLFromParts(n)}var s=a.parseURL(t);if(!s)throw new Error("Error trying to parse relative URL.");if(s.scheme)return i.alwaysNormalize?(s.path=a.normalizePath(s.path),a.buildURLFromParts(s)):t;var o=a.parseURL(e);if(!o)throw new Error("Error trying to parse base URL.");if(!o.netLoc&&o.path&&"/"!==o.path[0]){var l=r.exec(o.path);o.netLoc=l[1],o.path=l[2]}o.netLoc&&!o.path&&(o.path="/");var u={scheme:o.scheme,netLoc:s.netLoc,path:null,params:s.params,query:s.query,fragment:s.fragment};if(!s.netLoc&&(u.netLoc=o.netLoc,"/"!==s.path[0]))if(s.path){var d=o.path,c=d.substring(0,d.lastIndexOf("/")+1)+s.path;u.path=a.normalizePath(c)}else u.path=o.path,s.params||(u.params=o.params,s.query||(u.query=o.query));return null===u.path&&(u.path=i.alwaysNormalize?a.normalizePath(s.path):s.path),a.buildURLFromParts(u)},parseURL:function(e){var r=t.exec(e);return r?{scheme:r[1]||"",netLoc:r[2]||"",path:r[3]||"",params:r[4]||"",query:r[5]||"",fragment:r[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(i,"");e.length!==(e=e.replace(n,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}},e.exports=a}},t={};function r(i){var n=t[i];if(void 0!==n)return n.exports;var a=t[i]={exports:{}};return e[i].call(a.exports,a,a.exports,r),a.exports}r.m=e,r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i=r("./src/hls.ts");return i=i.default})(),e.exports=t())}}]);
  3. //# sourceMappingURL=933.js.map