banko-ai-assistant 1.0.0__py3-none-any.whl → 1.0.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- banko_ai/static/creditcard_files/0dbda187ceb472a466dff54b7015b1d4.jpg +0 -0
- banko_ai/static/creditcard_files/10903-7f8736e237ced107.mjs +2 -0
- banko_ai/static/creditcard_files/10966-809952783184ae4b.mjs +4 -0
- banko_ai/static/creditcard_files/13351-8a7dda060266efff.mjs +2 -0
- banko_ai/static/creditcard_files/1342-c79d3d17da82f23c.mjs +11 -0
- banko_ai/static/creditcard_files/16142-bdecf7bfdd6d70ae.mjs +2 -0
- banko_ai/static/creditcard_files/16550-e89f65017860221d.mjs +2 -0
- banko_ai/static/creditcard_files/17492-942c70b114fdcce1.mjs +10 -0
- banko_ai/static/creditcard_files/18352-481d67e871cc6985.mjs +2 -0
- banko_ai/static/creditcard_files/18555-0d9763eb744f7a77.mjs +2 -0
- banko_ai/static/creditcard_files/19437-575ba467ea85e866.mjs +2 -0
- banko_ai/static/creditcard_files/1aca1669c3b4a07f0966c4733c939d6d.jpg +0 -0
- banko_ai/static/creditcard_files/20126-602c15db592cf3c4.mjs +26 -0
- banko_ai/static/creditcard_files/20224-b6de2c08cc8ad497.mjs +66 -0
- banko_ai/static/creditcard_files/2029a63f9af76541f860b6a6a4ec0c90.jpg +0 -0
- banko_ai/static/creditcard_files/21662-1214728138c72aa2.css +1 -0
- banko_ai/static/creditcard_files/22517-5f7ab2631d424b77.mjs +9 -0
- banko_ai/static/creditcard_files/23019-be3b8956cee94725.mjs +2 -0
- banko_ai/static/creditcard_files/26067-cb77f2673c5f757c.mjs +2 -0
- banko_ai/static/creditcard_files/27405-880a12623820964d.mjs +9 -0
- banko_ai/static/creditcard_files/27503-82078c18034012ed.mjs +38 -0
- banko_ai/static/creditcard_files/28090-8e4b5fd6c88f8eb2.mjs +6 -0
- banko_ai/static/creditcard_files/2c66dacf04db64cc1099835f2e2328d5.jpg +0 -0
- banko_ai/static/creditcard_files/30090868cb2b559a7093999fec5fbcc8.jpg +0 -0
- banko_ai/static/creditcard_files/30102-608e861dccc907f1.mjs +2 -0
- banko_ai/static/creditcard_files/31600-ca2e152d871d51d5.mjs +2 -0
- banko_ai/static/creditcard_files/31d5156a9cc5fe5fd780c2d9e59db98f.jpg +0 -0
- banko_ai/static/creditcard_files/34713-54729fd9c7517d50.mjs +2 -0
- banko_ai/static/creditcard_files/35074-d765c14dc3e8eafc.mjs +77 -0
- banko_ai/static/creditcard_files/38230-4d6eb1a608eecdeb.mjs +7 -0
- banko_ai/static/creditcard_files/40566-e2dbb4226dd2ab42.mjs +6 -0
- banko_ai/static/creditcard_files/42298-668aa166e1146c6c.mjs +2 -0
- banko_ai/static/creditcard_files/43203-3a1e46e5259313c8.mjs +14 -0
- banko_ai/static/creditcard_files/44429-6534f772a6bd895b.mjs +13 -0
- banko_ai/static/creditcard_files/48327-48fb70091d7ac731.mjs +2 -0
- banko_ai/static/creditcard_files/49923-dc71193d54a0b99c.mjs +2 -0
- banko_ai/static/creditcard_files/49c3cac3c5a09ca104a2efea48536d14.jpg +0 -0
- banko_ai/static/creditcard_files/50040-3c27b1fe14ca588b.mjs +2 -0
- banko_ai/static/creditcard_files/5047473e06297bbccfae9c43ca36bd93.jpg +0 -0
- banko_ai/static/creditcard_files/51531-253e8d8f8f527d9c.mjs +26 -0
- banko_ai/static/creditcard_files/58103-d6be57f2d624e7b4.mjs +2 -0
- banko_ai/static/creditcard_files/58822-d1779ebe9d4fab59.mjs +51 -0
- banko_ai/static/creditcard_files/61b440e4366b35d7213172be53d3864e.jpg +0 -0
- banko_ai/static/creditcard_files/61d121a699367070f3988f633ed6ac7d.jpg +0 -0
- banko_ai/static/creditcard_files/65610-15f55d146aa3cc6f.mjs +2 -0
- banko_ai/static/creditcard_files/65662-2b7065d2ddcf6a0c.mjs +2 -0
- banko_ai/static/creditcard_files/67631-9d4d7f4aab06e79c.mjs +2 -0
- banko_ai/static/creditcard_files/68445-8aae26e83c03d9bc.mjs +7 -0
- banko_ai/static/creditcard_files/6863-da15e99ca946f07a.mjs +2 -0
- banko_ai/static/creditcard_files/71526-518cf6126a32651b.mjs +2 -0
- banko_ai/static/creditcard_files/72268-8f69a6e8585b9af2.mjs +2 -0
- banko_ai/static/creditcard_files/76f1a52015cf2a243ed085586f3d44e8.jpg +0 -0
- banko_ai/static/creditcard_files/80538-65bd348271403336.mjs +2 -0
- banko_ai/static/creditcard_files/81505-387f6ddb644ae967.mjs +38 -0
- banko_ai/static/creditcard_files/8151-1a0cf04ea45ad513.mjs +2 -0
- banko_ai/static/creditcard_files/83119-1cf7ca2f5ba0e1ab.mjs +9 -0
- banko_ai/static/creditcard_files/83485-27ce97f9e7369ed7.mjs +5 -0
- banko_ai/static/creditcard_files/8575-e1977ceb3b34da9c.mjs +2 -0
- banko_ai/static/creditcard_files/8962-664b3c9b21ec2e0f.mjs +2 -0
- banko_ai/static/creditcard_files/90123-40fd5c2d5dc1c0a1.mjs +2 -0
- banko_ai/static/creditcard_files/91846-55cc5635c18159a0.mjs +47 -0
- banko_ai/static/creditcard_files/91936-56d11562a38b3f77.mjs +2 -0
- banko_ai/static/creditcard_files/96833-fbcb1ab8436924d4.mjs +36 -0
- banko_ai/static/creditcard_files/99246-889e96fc0a42e07a.mjs +2 -0
- banko_ai/static/creditcard_files/99961-ee8d9a1207a9db7a.mjs +2 -0
- banko_ai/static/creditcard_files/DefaultPinRep-78e567622e9cb382.mjs +27 -0
- banko_ai/static/creditcard_files/DesktopUnauthPageWrapper-26b3c2c050f09d27.css +1 -0
- banko_ai/static/creditcard_files/DesktopUnauthPageWrapper-a120f0b0faa773a2.mjs +252 -0
- banko_ai/static/creditcard_files/KkWFeSURekXGycdprVC-UY6ED-ZF5ll2JCMiHhJE2Rk.js +1 -0
- banko_ai/static/creditcard_files/MobileAndUnauthPinPage-0083f61f79e906d2.mjs +400 -0
- banko_ai/static/creditcard_files/UnauthCloseupRelatedPins-d98c713ac2e141a7.mjs +2 -0
- banko_ai/static/creditcard_files/[id]-87f8f6f1f81e3a8a.mjs +2 -0
- banko_ai/static/creditcard_files/_client-49638f60bdf5658e.mjs +43 -0
- banko_ai/static/creditcard_files/a7ee24644496b7a3131cd4e13b8c6edb.jpg +0 -0
- banko_ai/static/creditcard_files/a8ada9395c00dffc8fb81a7b76bd34b5.jpg +0 -0
- banko_ai/static/creditcard_files/abbf5a82906bef8c6be49ab38eaeea7c.jpg +0 -0
- banko_ai/static/creditcard_files/ad910641231bb413f6a985e4e9961efb.jpg +0 -0
- banko_ai/static/creditcard_files/anchor.html +186 -0
- banko_ai/static/creditcard_files/b6083df3cfa26856caef114c51a8d21e.jpg +0 -0
- banko_ai/static/creditcard_files/b957829ac112a8c28b313307e5ff0df6.jpg +0 -0
- banko_ai/static/creditcard_files/bb2d3d28e3421d901d8d431c33f0c6ed.jpg +0 -0
- banko_ai/static/creditcard_files/bb2d3d28e3421d901d8d431c33f0c6ed.png +0 -0
- banko_ai/static/creditcard_files/c3031b4a938377789e00d3d2f3b2438c.jpg +0 -0
- banko_ai/static/creditcard_files/client +300 -0
- banko_ai/static/creditcard_files/ct.html +3 -0
- banko_ai/static/creditcard_files/d03e6db9649ea3479b799d5a21008ac2.jpg +0 -0
- banko_ai/static/creditcard_files/d3d38fd9aa0c808a28ff5bd9ae5b5576.jpg +0 -0
- banko_ai/static/creditcard_files/de7cb9e198b4ebc9430824132ccfce2e.jpg +0 -0
- banko_ai/static/creditcard_files/e4330b4a4e71a3f77dd0682b99037cad.jpg +0 -0
- banko_ai/static/creditcard_files/ecdf72d4d54e70608e9416020f8ad67d.jpg +0 -0
- banko_ai/static/creditcard_files/eef64355b9f10e89c355b138adbae1e9.jpg +0 -0
- banko_ai/static/creditcard_files/enterprise.js +1 -0
- banko_ai/static/creditcard_files/f1354f6bb993409ea12235a01a978936.jpg +0 -0
- banko_ai/static/creditcard_files/f7c30e2615fe0e57d9ab6e41aac5e738.jpg +0 -0
- banko_ai/static/creditcard_files/fa72fa1ae9bb3ec93f41595333d22d16.jpg +0 -0
- banko_ai/static/creditcard_files/fb09ce3b0feb4931402867cf109cd618.jpg +0 -0
- banko_ai/static/creditcard_files/i +0 -0
- banko_ai/static/creditcard_files/locale-en_US-lite-js-d0d346142714beb1.mjs +2 -0
- banko_ai/static/creditcard_files/login-3c695aa28fdc27a5.mjs +161 -0
- banko_ai/static/creditcard_files/login-e161a84cea9cd0a3.css +1 -0
- banko_ai/static/creditcard_files/packages-rich-snippet-LeafSnippet-b7f61038a4431021.mjs +2 -0
- banko_ai/static/creditcard_files/polyfills-c5ca6e711f8975ec.mjs +2 -0
- banko_ai/static/creditcard_files/recaptcha__en.js +1011 -0
- banko_ai/static/creditcard_files/repin-62bbd4d7c8e22f17.css +1 -0
- banko_ai/static/creditcard_files/repin-d49f19d89ddd3cbe.mjs +292 -0
- banko_ai/static/creditcard_files/runtime-505e4380476a458b.mjs +2 -0
- banko_ai/static/creditcard_files/saved_resource(1).html +7 -0
- banko_ai/static/creditcard_files/saved_resource(2).html +3 -0
- banko_ai/static/creditcard_files/saved_resource.html +3 -0
- banko_ai/static/creditcard_files/sdk(1).js +22 -0
- banko_ai/static/creditcard_files/sdk.js +228 -0
- banko_ai/static/creditcard_files/select.html +387 -0
- banko_ai/static/creditcard_files/style +1 -0
- banko_ai/static/creditcard_files/styles__ltr.css +1 -0
- banko_ai/static/creditcard_files/unnamed.jpg +0 -0
- banko_ai/static/creditcard_files/vendor-react-76e71fd67c83934b.mjs +54 -0
- banko_ai/static/creditcard_files/visual-search-fe95849c7568d600.mjs +123 -0
- banko_ai/static/css/style.css +1274 -0
- banko_ai/templates/dashboard.html +5 -5
- banko_ai/templates/index.html +6 -6
- banko_ai/web/app.py +18 -4
- {banko_ai_assistant-1.0.0.dist-info → banko_ai_assistant-1.0.3.dist-info}/METADATA +2 -2
- banko_ai_assistant-1.0.3.dist-info/RECORD +164 -0
- banko_ai_assistant-1.0.0.dist-info/RECORD +0 -46
- {banko_ai_assistant-1.0.0.dist-info → banko_ai_assistant-1.0.3.dist-info}/WHEEL +0 -0
- {banko_ai_assistant-1.0.0.dist-info → banko_ai_assistant-1.0.3.dist-info}/entry_points.txt +0 -0
- {banko_ai_assistant-1.0.0.dist-info → banko_ai_assistant-1.0.3.dist-info}/licenses/LICENSE +0 -0
- {banko_ai_assistant-1.0.0.dist-info → banko_ai_assistant-1.0.3.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,2 @@
|
|
1
|
+
(self.__LOADABLE_LOADED_CHUNKS__=self.__LOADABLE_LOADED_CHUNKS__||[]).push([[67631],{867631:function(t){"undefined"!=typeof window&&(t.exports=(()=>{var t={"./src/config.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{enableStreamingMode:()=>D,hlsDefaultConfig:()=>b,mergeConfig:()=>L});var i=r(/*! ./controller/abr-controller */"./src/controller/abr-controller.ts"),n=r(/*! ./controller/audio-stream-controller */"./src/controller/audio-stream-controller.ts"),s=r(/*! ./controller/audio-track-controller */"./src/controller/audio-track-controller.ts"),a=r(/*! ./controller/subtitle-stream-controller */"./src/controller/subtitle-stream-controller.ts"),o=r(/*! ./controller/subtitle-track-controller */"./src/controller/subtitle-track-controller.ts"),l=r(/*! ./controller/buffer-controller */"./src/controller/buffer-controller.ts"),u=r(/*! ./controller/timeline-controller */"./src/controller/timeline-controller.ts"),d=r(/*! ./controller/cap-level-controller */"./src/controller/cap-level-controller.ts"),c=r(/*! ./controller/fps-controller */"./src/controller/fps-controller.ts"),h=r(/*! ./controller/eme-controller */"./src/controller/eme-controller.ts"),f=r(/*! ./controller/cmcd-controller */"./src/controller/cmcd-controller.ts"),g=r(/*! ./utils/xhr-loader */"./src/utils/xhr-loader.ts"),v=r(/*! ./utils/fetch-loader */"./src/utils/fetch-loader.ts"),p=r(/*! ./utils/cues */"./src/utils/cues.ts"),m=r(/*! ./utils/mediakeys-helper */"./src/utils/mediakeys-helper.ts"),y=r(/*! ./utils/logger */"./src/utils/logger.ts");function E(){return(E=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t}).apply(this,arguments)}function T(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,i)}return r}function S(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?T(Object(r),!0).forEach(function(e){var i,n;i=e,n=r[e],(i=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var i=r.call(t,e||"default");if("object"!=typeof i)return i;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(i))in t?Object.defineProperty(t,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[i]=n}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):T(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}var b=S(S({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:g.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:i.default,bufferController:l.default,capLevelController:d.default,fpsController:c.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:m.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0},{cueHandler:p.default,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:a.SubtitleStreamController,subtitleTrackController:o.default,timelineController:u.TimelineController,audioStreamController:n.default,audioTrackController:s.default,emeController:h.default,cmcdController:f.default});function L(t,e){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==e.liveMaxLatencyDurationCount&&(void 0===e.liveSyncDurationCount||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==e.liveMaxLatencyDuration&&(void 0===e.liveSyncDuration||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return E({},t,e)}function D(t){var e=t.loader;e!==v.default&&e!==g.default?(y.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),t.progressive=!1):(0,v.fetchSupported)()&&(t.loader=v.default,t.progressive=!0,t.enableSoftwareAES=!0,y.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}},"./src/controller/abr-controller.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>c});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../utils/ewma-bandwidth-estimator */"./src/utils/ewma-bandwidth-estimator.ts"),s=r(/*! ../events */"./src/events.ts"),a=r(/*! ../errors */"./src/errors.ts"),o=r(/*! ../types/loader */"./src/types/loader.ts"),l=r(/*! ../utils/logger */"./src/utils/logger.ts");function u(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var i=r.call(t,e||"default");if("object"!=typeof i)return i;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(i.key),i)}}var d=function(){function t(t){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=t;var e=t.config;this.bwEstimator=new n.default(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate),this.registerListeners()}var e,r,d=t.prototype;return d.registerListeners=function(){var t=this.hls;t.on(s.Events.FRAG_LOADING,this.onFragLoading,this),t.on(s.Events.FRAG_LOADED,this.onFragLoaded,this),t.on(s.Events.FRAG_BUFFERED,this.onFragBuffered,this),t.on(s.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(s.Events.ERROR,this.onError,this)},d.unregisterListeners=function(){var t=this.hls;t.off(s.Events.FRAG_LOADING,this.onFragLoading,this),t.off(s.Events.FRAG_LOADED,this.onFragLoaded,this),t.off(s.Events.FRAG_BUFFERED,this.onFragBuffered,this),t.off(s.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(s.Events.ERROR,this.onError,this)},d.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},d.onFragLoading=function(t,e){var r,i=e.frag;i.type!==o.PlaylistLevelType.MAIN||this.timer||(this.fragCurrent=i,this.partCurrent=null!=(r=e.part)?r:null,this.timer=self.setInterval(this.onCheck,100))},d.onLevelLoaded=function(t,e){var r=this.hls.config;e.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)},d._abandonRulesCheck=function(){var t,e=this.fragCurrent,r=this.partCurrent,n=this.hls,a=n.autoLevelEnabled,o=n.media;if(!e||!o)return;var u=r?r.stats:e.stats,d=r?r.duration:e.duration;if(u.aborted||u.loaded&&u.loaded===u.total||0===e.level){this.clearTimer(),this._nextAutoLevel=-1;return}if(!!a&&!o.paused&&!!o.playbackRate&&!!o.readyState){var c=n.mainForwardBufferInfo;if(null!==c){var h=performance.now()-u.loading.start,f=Math.abs(o.playbackRate);if(!(h<=500*d/f)){var g=u.loaded&&u.loading.first,v=this.bwEstimator.getEstimate(),p=n.levels,m=n.minAutoLevel,y=p[e.level],E=u.total||Math.max(u.loaded,Math.round(d*y.maxBitrate/8)),T=g?1e3*u.loaded/h:0,S=T?(E-u.loaded)/T:8*E/v,b=c.len/f;if(!(S<=b)){var L=Number.POSITIVE_INFINITY;for(t=e.level-1;t>m;t--){var D=p[t].maxBitrate;if((L=T?d*D/(6.4*T):d*D/v)<b)break}L>=S||(l.logger.warn("Fragment "+e.sn+(r?" part "+r.index:"")+" of level "+e.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+t+"\n Current BW estimate: "+((0,i.isFiniteNumber)(v)?(v/1024).toFixed(3):"Unknown")+" Kb/s\n Estimated load time for current fragment: "+S.toFixed(3)+" s\n Estimated load time for the next fragment: "+L.toFixed(3)+" s\n Time to underbuffer: "+b.toFixed(3)+" s"),n.nextLoadLevel=t,g&&this.bwEstimator.sample(h,u.loaded),this.clearTimer(),(e.loader||e.keyLoader)&&(this.fragCurrent=this.partCurrent=null,e.abortRequests()),n.trigger(s.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:e,part:r,stats:u}))}}}}},d.onFragLoaded=function(t,e){var r=e.frag,n=e.part;if(r.type===o.PlaylistLevelType.MAIN&&(0,i.isFiniteNumber)(r.sn)){var a=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)+a.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:a,frag:r,part:n,id:r.type};this.onFragBuffered(s.Events.FRAG_BUFFERED,h)}}},d.onFragBuffered=function(t,e){var r=e.frag,i=e.part,n=i?i.stats:r.stats;if(!n.aborted&&r.type===o.PlaylistLevelType.MAIN&&"initSegment"!==r.sn){var s=n.parsing.end-n.loading.start;this.bwEstimator.sample(s,n.loaded),n.bwEstimate=this.bwEstimator.getEstimate(),r.bitrateTest?this.bitrateTestDelay=s/1e3:this.bitrateTestDelay=0}},d.onError=function(t,e){var r;if((null===(r=e.frag)||void 0===r?void 0:r.type)===o.PlaylistLevelType.MAIN){if(e.type===a.ErrorTypes.KEY_SYSTEM_ERROR){this.clearTimer();return}switch(e.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:this.clearTimer()}}},d.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},d.getNextABRAutoLevel=function(){var t=this.fragCurrent,e=this.partCurrent,r=this.hls,i=r.maxAutoLevel,n=r.config,s=r.minAutoLevel,a=r.media,o=e?e.duration:t?t.duration:0,u=a&&0!==a.playbackRate?Math.abs(a.playbackRate):1,d=this.bwEstimator?this.bwEstimator.getEstimate():n.abrEwmaDefaultEstimate,c=r.mainForwardBufferInfo,h=(c?c.len:0)/u,f=this.findBestLevel(d,s,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 g=o?Math.min(o,n.maxStarvationDelay):n.maxStarvationDelay,v=n.abrBandWidthFactor,p=n.abrBandWidthUpFactor;if(!h){var m=this.bitrateTestDelay;m&&(g=(o?Math.min(o,n.maxLoadingDelay):n.maxLoadingDelay)-m,l.logger.trace("bitrate test took "+Math.round(1e3*m)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*g)+" ms"),v=p=1)}return Math.max(f=this.findBestLevel(d,s,i,h+g,v,p),0)},d.findBestLevel=function(t,e,r,n,s,a){for(var o,u=this.fragCurrent,d=this.partCurrent,c=this.lastLoadedFragLevel,h=this.hls.levels,f=h[c],g=!!(null!=f&&null!==(o=f.details)&&void 0!==o&&o.live),v=null==f?void 0:f.codecSet,p=d?d.duration:u?u.duration:0,m=r;m>=e;m--){var y=h[m];if(y&&(!v||y.codecSet===v)){var E=y.details,T=(d?null==E?void 0:E.partTarget:null==E?void 0:E.averagetargetduration)||p,S=void 0;S=m<=c?s*t:a*t;var b=h[m].maxBitrate,L=b*T/S;if(l.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+m+"/"+Math.round(S)+"/"+b+"/"+T+"/"+n+"/"+L),S>b&&(0===L||!(0,i.isFiniteNumber)(L)||g&&!this.bitrateTestDelay||L<n))return m}}return -1},e=[{key:"nextAutoLevel",get:function(){var t=this._nextAutoLevel,e=this.bwEstimator;if(-1!==t&&!e.canEstimate())return t;var r=this.getNextABRAutoLevel();return -1!==t&&this.hls.levels[r].loadError?t:(-1!==t&&(r=Math.min(t,r)),r)},set:function(t){this._nextAutoLevel=t}}],u(t.prototype,e),r&&u(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}();let c=d},"./src/controller/audio-stream-controller.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>T});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ./base-stream-controller */"./src/controller/base-stream-controller.ts"),s=r(/*! ../events */"./src/events.ts"),a=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),o=r(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),l=r(/*! ../types/level */"./src/types/level.ts"),u=r(/*! ../types/loader */"./src/types/loader.ts"),d=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),c=r(/*! ../demux/chunk-cache */"./src/demux/chunk-cache.ts"),h=r(/*! ../demux/transmuxer-interface */"./src/demux/transmuxer-interface.ts"),f=r(/*! ../types/transmuxer */"./src/types/transmuxer.ts"),g=r(/*! ./fragment-finders */"./src/controller/fragment-finders.ts"),v=r(/*! ../utils/discontinuities */"./src/utils/discontinuities.ts"),p=r(/*! ../errors */"./src/errors.ts");function m(){return(m=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t}).apply(this,arguments)}function y(t,e){return(y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}var E=function(t){function e(e,r,i){var n;return(n=t.call(this,e,r,i,"[audio-stream-controller]")||this).videoBuffer=null,n.videoTrackCC=-1,n.waitingVideoCC=-1,n.audioSwitch=!1,n.trackId=-1,n.waitingData=null,n.mainDetails=null,n.bufferFlushed=!1,n.cachedTrackLoadedData=null,n._registerListeners(),n}e.prototype=Object.create(t.prototype),e.prototype.constructor=e,y(e,t);var r=e.prototype;return r.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},r._registerListeners=function(){var t=this.hls;t.on(s.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(s.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(s.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(s.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.on(s.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(s.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(s.Events.ERROR,this.onError,this),t.on(s.Events.BUFFER_RESET,this.onBufferReset,this),t.on(s.Events.BUFFER_CREATED,this.onBufferCreated,this),t.on(s.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(s.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(s.Events.FRAG_BUFFERED,this.onFragBuffered,this)},r._unregisterListeners=function(){var t=this.hls;t.off(s.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(s.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(s.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(s.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.off(s.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(s.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(s.Events.ERROR,this.onError,this),t.off(s.Events.BUFFER_RESET,this.onBufferReset,this),t.off(s.Events.BUFFER_CREATED,this.onBufferCreated,this),t.off(s.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(s.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(s.Events.FRAG_BUFFERED,this.onFragBuffered,this)},r.onInitPtsFound=function(t,e){var r=e.frag,i=e.id,s=e.initPTS;if("main"===i){var a=r.cc;this.initPTS[r.cc]=s,this.log("InitPTS for cc: "+a+" found from main: "+s),this.videoTrackCC=a,this.state===n.State.WAITING_INIT_PTS&&this.tick()}},r.startLoad=function(t){if(!this.levels){this.startPosition=t,this.state=n.State.STOPPED;return}var e=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),this.fragLoadError=0,e>0&&-1===t?(this.log("Override startPosition with lastCurrentTime @"+e.toFixed(3)),t=e,this.state=n.State.IDLE):(this.loadedmetadata=!1,this.state=n.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()},r.doTick=function(){switch(this.state){case n.State.IDLE:this.doTickIdle();break;case n.State.WAITING_TRACK:var e,r=this.levels,i=this.trackId,s=null==r?void 0:null===(e=r[i])||void 0===e?void 0:e.details;if(s){if(this.waitForCdnTuneIn(s))break;this.state=n.State.WAITING_INIT_PTS}break;case n.State.FRAG_LOADING_WAITING_RETRY:var o,l=performance.now(),u=this.retryDate;(!u||l>=u||null!==(o=this.media)&&void 0!==o&&o.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=n.State.IDLE);break;case n.State.WAITING_INIT_PTS:var d=this.waitingData;if(d){var c=d.frag,h=d.part,f=d.cache,v=d.complete;if(void 0!==this.initPTS[c.cc]){this.waitingData=null,this.waitingVideoCC=-1,this.state=n.State.FRAG_LOADING;var p={frag:c,part:h,payload:f.flush(),networkDetails:null};this._handleFragmentLoadProgress(p),v&&t.prototype._handleFragmentLoadComplete.call(this,p)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log("Waiting fragment cc ("+c.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var m=this.getLoadPosition(),y=a.BufferHelper.bufferInfo(this.mediaBuffer,m,this.config.maxBufferHole);0>(0,g.fragmentWithinToleranceTest)(y.end,this.config.maxFragLookUpTolerance,c)&&(this.log("Waiting fragment cc ("+c.cc+") @ "+c.start+" cancelled because another fragment at "+y.end+" is needed"),this.clearWaitingFragment())}}else this.state=n.State.IDLE}this.onTickEnd()},r.clearWaitingFragment=function(){var t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=n.State.IDLE)},r.resetLoadingState=function(){this.clearWaitingFragment(),t.prototype.resetLoadingState.call(this)},r.onTickEnd=function(){var t=this.media;t&&t.readyState&&(this.lastCurrentTime=t.currentTime)},r.doTickIdle=function(){var t=this.hls,e=this.levels,r=this.media,i=this.trackId,a=t.config;if(e&&e[i]&&(r||!this.startFragRequested&&a.startFragPrefetch)){var o=e[i].details;if(!o||o.live&&this.levelLastLoaded!==i||this.waitForCdnTuneIn(o)){this.state=n.State.WAITING_TRACK;return}var l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,d.ElementaryStreamTypes.AUDIO,u.PlaylistLevelType.AUDIO));var c=this.getFwdBufferInfo(l,u.PlaylistLevelType.AUDIO);if(null!==c){var h=this.audioSwitch;if(!h&&this._streamEnded(c,o)){t.trigger(s.Events.BUFFER_EOS,{type:"audio"}),this.state=n.State.ENDED;return}var f=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,u.PlaylistLevelType.MAIN);if(!(c.len>=this.getMaxBufferLength(null==f?void 0:f.len))||h){var g=o.fragments[0].start,v=c.end;if(h&&r){var p=this.getLoadPosition();v=p,o.PTSKnown&&p<g&&(c.end>g||c.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),r.currentTime=g+.05)}if((!f||!(v>f.end+o.targetduration))&&(f&&f.len||!c.len)){var m=this.getNextFragment(v,o);if(!m){this.bufferFlushed=!0;return}this.loadFragment(m,o,v)}}}}},r.getMaxBufferLength=function(e){var r=t.prototype.getMaxBufferLength.call(this);return e?Math.max(r,e):r},r.onMediaDetaching=function(){this.videoBuffer=null,t.prototype.onMediaDetaching.call(this)},r.onAudioTracksUpdated=function(t,e){var r=e.audioTracks;this.resetTransmuxer(),this.levels=r.map(function(t){return new l.Level(t)})},r.onAudioTrackSwitching=function(t,e){var r=!!e.url;this.trackId=e.id;var i=this.fragCurrent;i&&i.abortRequests(),this.fragCurrent=null,this.clearWaitingFragment(),r?this.setInterval(100):this.resetTransmuxer(),r?(this.audioSwitch=!0,this.state=n.State.IDLE):this.state=n.State.STOPPED,this.tick()},r.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},r.onLevelLoaded=function(t,e){this.mainDetails=e.details,null!==this.cachedTrackLoadedData&&(this.hls.trigger(s.Events.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)},r.onAudioTrackLoaded=function(t,e){if(null==this.mainDetails){this.cachedTrackLoadedData=e;return}var r,i=this.levels,s=e.details,a=e.id;if(!i){this.warn("Audio tracks were reset while loading level "+a);return}this.log("Track "+a+" loaded ["+s.startSN+","+s.endSN+"],duration:"+s.totalduration);var o=i[a],l=0;if(s.live||null!==(r=o.details)&&void 0!==r&&r.live){var u=this.mainDetails;if(s.fragments[0]||(s.deltaUpdateFailed=!0),s.deltaUpdateFailed||!u)return;!o.details&&s.hasProgramDateTime&&u.hasProgramDateTime?((0,v.alignMediaPlaylistByPDT)(s,u),l=s.fragments[0].start):l=this.alignPlaylists(s,o.details)}o.details=s,this.levelLastLoaded=a,this.startFragRequested||!this.mainDetails&&s.live||this.setStartPosition(o.details,l),this.state!==n.State.WAITING_TRACK||this.waitForCdnTuneIn(s)||(this.state=n.State.IDLE),this.tick()},r._handleFragmentLoadProgress=function(t){var e,r=t.frag,i=t.part,s=t.payload,a=this.config,o=this.trackId,l=this.levels;if(!l){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+r.sn+" of level "+r.level+" will not be buffered");return}var d=l[o];console.assert(d,"Audio track is defined on fragment load progress");var g=d.details;console.assert(g,"Audio track details are defined on fragment load progress");var v=a.defaultAudioCodec||d.audioCodec||"mp4a.40.2",p=this.transmuxer;p||(p=this.transmuxer=new h.default(this.hls,u.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var m=this.initPTS[r.cc],y=null===(e=r.initSegment)||void 0===e?void 0:e.data;if(void 0!==m){var E=i?i.index:-1,T=-1!==E,S=new f.ChunkMetadata(r.level,r.sn,r.stats.chunkCount,s.byteLength,E,T);p.push(s,y,v,"",r,i,g.totalduration,!1,S,m)}else this.log("Unknown video PTS for cc "+r.cc+", waiting for video PTS before demuxing audio frag "+r.sn+" of ["+g.startSN+" ,"+g.endSN+"],track "+o),(this.waitingData=this.waitingData||{frag:r,part:i,cache:new c.default,complete:!1}).cache.push(new Uint8Array(s)),this.waitingVideoCC=this.videoTrackCC,this.state=n.State.WAITING_INIT_PTS},r._handleFragmentLoadComplete=function(e){if(this.waitingData){this.waitingData.complete=!0;return}t.prototype._handleFragmentLoadComplete.call(this,e)},r.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},r.onBufferCreated=function(t,e){var r=e.tracks.audio;r&&(this.mediaBuffer=r.buffer||null),e.tracks.video&&(this.videoBuffer=e.tracks.video.buffer||null)},r.onFragBuffered=function(t,e){var r,i=e.frag,n=e.part;if(i.type!==u.PlaylistLevelType.AUDIO){!this.loadedmetadata&&i.type===u.PlaylistLevelType.MAIN&&null!==(r=this.videoBuffer||this.media)&&void 0!==r&&r.buffered.length&&(this.loadedmetadata=!0);return}if(this.fragContextChanged(i)){this.warn("Fragment "+i.sn+(n?" p: "+n.index:"")+" of level "+i.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}"initSegment"!==i.sn&&(this.fragPrevious=i,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(s.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(i,n)},r.onError=function(e,r){if(r.type===p.ErrorTypes.KEY_SYSTEM_ERROR){this.onFragmentOrKeyLoadError(u.PlaylistLevelType.AUDIO,r);return}switch(r.details){case p.ErrorDetails.FRAG_LOAD_ERROR:case p.ErrorDetails.FRAG_LOAD_TIMEOUT:case p.ErrorDetails.FRAG_PARSING_ERROR:case p.ErrorDetails.KEY_LOAD_ERROR:case p.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(u.PlaylistLevelType.AUDIO,r);break;case p.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case p.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==n.State.ERROR&&this.state!==n.State.STOPPED&&(this.state=r.fatal?n.State.ERROR:n.State.IDLE,this.warn(r.details+" while loading frag, switching to "+this.state+" state"));break;case p.ErrorDetails.BUFFER_FULL_ERROR:if("audio"===r.parent&&(this.state===n.State.PARSING||this.state===n.State.PARSED)){var i=!0,s=this.getFwdBufferInfo(this.mediaBuffer,u.PlaylistLevelType.AUDIO);s&&s.len>.5&&(i=!this.reduceMaxBufferLength(s.len)),i&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,t.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}}},r.onBufferFlushed=function(t,e){e.type===d.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0,this.state===n.State.ENDED&&(this.state=n.State.IDLE))},r._handleTransmuxComplete=function(t){var e,r="audio",i=this.hls,a=t.remuxResult,o=t.chunkMeta,l=this.getCurrentContext(o);if(!l){this.warn("The loading context changed while buffering fragment "+o.sn+" of level "+o.level+". This chunk will not be buffered."),this.resetStartWhenNotLoaded(o.level);return}var u=l.frag,c=l.part,h=l.level.details,f=a.audio,g=a.text,v=a.id3,p=a.initSegment;if(!this.fragContextChanged(u)&&h){if(this.state=n.State.PARSING,this.audioSwitch&&f&&this.completeAudioSwitch(),null!=p&&p.tracks&&(this._bufferInitSegment(p.tracks,u,o),i.trigger(s.Events.FRAG_PARSING_INIT_SEGMENT,{frag:u,id:r,tracks:p.tracks})),f){var y=f.startPTS,E=f.endPTS,T=f.startDTS,S=f.endDTS;c&&(c.elementaryStreams[d.ElementaryStreamTypes.AUDIO]={startPTS:y,endPTS:E,startDTS:T,endDTS:S}),u.setElementaryStreamInfo(d.ElementaryStreamTypes.AUDIO,y,E,T,S),this.bufferFragmentData(f,u,c,o)}if(null!=v&&null!==(e=v.samples)&&void 0!==e&&e.length){var b=m({id:r,frag:u,details:h},v);i.trigger(s.Events.FRAG_PARSING_METADATA,b)}if(g){var L=m({id:r,frag:u,details:h},g);i.trigger(s.Events.FRAG_PARSING_USERDATA,L)}}},r._bufferInitSegment=function(t,e,r){if(this.state===n.State.PARSING){t.video&&delete t.video;var i=t.audio;if(i){i.levelCodec=i.codec,i.id="audio",this.log("Init audio buffer, container:"+i.container+", codecs[parsed]=["+i.codec+"]"),this.hls.trigger(s.Events.BUFFER_CODECS,t);var a=i.initSegment;if(null!=a&&a.byteLength){var o={type:"audio",frag:e,part:null,chunkMeta:r,parent:e.type,data:a};this.hls.trigger(s.Events.BUFFER_APPENDING,o)}this.tick()}}},r.loadFragment=function(e,r,s){var a=this.fragmentTracker.getState(e);this.fragCurrent=e,(this.audioSwitch||a===o.FragmentState.NOT_LOADED||a===o.FragmentState.PARTIAL)&&("initSegment"===e.sn?this._loadInitSegment(e,r):r.live&&!(0,i.isFiniteNumber)(this.initPTS[e.cc])?(this.log("Waiting for video PTS in continuity counter "+e.cc+" of live stream before loading audio fragment "+e.sn+" of level "+this.trackId),this.state=n.State.WAITING_INIT_PTS):(this.startFragRequested=!0,t.prototype.loadFragment.call(this,e,r,s)))},r.completeAudioSwitch=function(){var e=this.hls,r=this.media,i=this.trackId;r&&(this.log("Switching audio track : flushing all audio"),t.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,e.trigger(s.Events.AUDIO_TRACK_SWITCHED,{id:i})},e}(n.default);let T=E},"./src/controller/audio-track-controller.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>d});var i=r(/*! ../events */"./src/events.ts"),n=r(/*! ../errors */"./src/errors.ts"),s=r(/*! ./base-playlist-controller */"./src/controller/base-playlist-controller.ts"),a=r(/*! ../types/loader */"./src/types/loader.ts");function o(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var i=r.call(t,e||"default");if("object"!=typeof i)return i;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(i.key),i)}}function l(t,e){return(l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}var u=function(t){function e(e){var r;return(r=t.call(this,e,"[audio-track-controller]")||this).tracks=[],r.groupId=null,r.tracksInGroup=[],r.trackId=-1,r.trackName="",r.selectDefaultTrack=!0,r.registerListeners(),r}e.prototype=Object.create(t.prototype),e.prototype.constructor=e,l(e,t);var r,s,u=e.prototype;return u.registerListeners=function(){var t=this.hls;t.on(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(i.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(i.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(i.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(i.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(i.Events.ERROR,this.onError,this)},u.unregisterListeners=function(){var t=this.hls;t.off(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(i.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(i.Events.LEVEL_LOADING,this.onLevelLoading,this),t.off(i.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(i.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(i.Events.ERROR,this.onError,this)},u.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,t.prototype.destroy.call(this)},u.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},u.onManifestParsed=function(t,e){this.tracks=e.audioTracks||[]},u.onAudioTrackLoaded=function(t,e){var r=e.id,i=e.details,n=this.tracksInGroup[r];if(!n){this.warn("Invalid audio track id "+r);return}var s=n.details;n.details=e.details,this.log("audioTrack "+r+" loaded ["+i.startSN+"-"+i.endSN+"]"),r===this.trackId&&(this.retryCount=0,this.playlistLoaded(r,e,s))},u.onLevelLoading=function(t,e){this.switchLevel(e.level)},u.onLevelSwitching=function(t,e){this.switchLevel(e.level)},u.switchLevel=function(t){var e=this.hls.levels[t];if(null!=e&&e.audioGroupIds){var r=e.audioGroupIds[e.urlId];if(this.groupId!==r){this.groupId=r;var n=this.tracks.filter(function(t){return!r||t.groupId===r});this.selectDefaultTrack&&!n.some(function(t){return t.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=n,this.log("Updating audio tracks, "+n.length+' track(s) found in "'+r+'" group-id'),this.hls.trigger(i.Events.AUDIO_TRACKS_UPDATED,{audioTracks:n}),this.selectInitialTrack()}}},u.onError=function(e,r){t.prototype.onError.call(this,e,r),r.fatal||!r.context||r.context.type!==a.PlaylistContextType.AUDIO_TRACK||r.context.id!==this.trackId||r.context.groupId!==this.groupId||this.retryLoadingOrFail(r)},u.setAudioTrack=function(t){var e=this.tracksInGroup;if(t<0||t>=e.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var r=e[this.trackId];this.log("Now switching to audio-track index "+t);var n=e[t],s=n.id,a=n.groupId,o=n.name,l=n.type,u=n.url;if(this.trackId=t,this.trackName=o,this.selectDefaultTrack=!1,this.hls.trigger(i.Events.AUDIO_TRACK_SWITCHING,{id:s,groupId:void 0===a?"":a,name:o,type:l,url:u}),!n.details||n.details.live){var d=this.switchParams(n.url,null==r?void 0:r.details);this.loadPlaylist(d)}},u.selectInitialTrack=function(){console.assert(this.tracksInGroup.length,"Initial audio track should be selected when tracks are known");var t=this.trackName,e=this.findTrackId(t)||this.findTrackId();-1!==e?this.setAudioTrack(e):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},u.findTrackId=function(t){for(var e=this.tracksInGroup,r=0;r<e.length;r++){var i=e[r];if((!this.selectDefaultTrack||i.default)&&(!t||t===i.name))return i.id}return -1},u.loadPlaylist=function(e){t.prototype.loadPlaylist.call(this);var r=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(r)){var n=r.id,s=r.groupId,a=r.url;if(e)try{a=e.addDirectives(a)}catch(t){this.warn("Could not construct new URL with HLS Delivery Directives: "+t)}this.log("loading audio-track playlist for id: "+n),this.clearTimer(),this.hls.trigger(i.Events.AUDIO_TRACK_LOADING,{url:a,id:n,groupId:s,deliveryDirectives:e||null})}},r=[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(t){this.selectDefaultTrack=!1,this.setAudioTrack(t)}}],o(e.prototype,r),s&&o(e,s),Object.defineProperty(e,"prototype",{writable:!1}),e}(s.default);let d=u},"./src/controller/base-playlist-controller.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>o});var i=r(/*! ../types/level */"./src/types/level.ts"),n=r(/*! ./level-helper */"./src/controller/level-helper.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),a=r(/*! ../errors */"./src/errors.ts"),o=function(){function t(t,e){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=s.logger.log.bind(s.logger,e+":"),this.warn=s.logger.warn.bind(s.logger,e+":"),this.hls=t}var e=t.prototype;return e.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},e.onError=function(t,e){e.fatal&&(e.type===a.ErrorTypes.NETWORK_ERROR||e.type===a.ErrorTypes.KEY_SYSTEM_ERROR)&&this.stopLoad()},e.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},e.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.requestScheduled=-1,this.loadPlaylist()},e.stopLoad=function(){this.canLoad=!1,this.clearTimer()},e.switchParams=function(t,e){var r=null==e?void 0:e.renditionReports;if(r)for(var n=0;n<r.length;n++){var a=r[n],o=void 0;try{o=new self.URL(a.URI,e.url).href}catch(t){s.logger.warn("Could not construct new URL for Rendition Report: "+t),o=a.URI||""}if(o===t.slice(-o.length)){var l=parseInt(a["LAST-MSN"])||(null==e?void 0:e.lastPartSn),u=parseInt(a["LAST-PART"])||(null==e?void 0:e.lastPartIndex);if(this.hls.config.lowLatencyMode){var d=Math.min(e.age-e.partTarget,e.targetduration);u>=0&&d>e.partTarget&&(u+=1)}return new i.HlsUrlParameters(l,u>=0?u:void 0,i.HlsSkip.No)}}},e.loadPlaylist=function(t){-1===this.requestScheduled&&(this.requestScheduled=self.performance.now())},e.shouldLoadTrack=function(t){return this.canLoad&&t&&!!t.url&&(!t.details||t.details.live)},e.playlistLoaded=function(t,e,r){var i=this,s=e.details,a=e.stats,o=self.performance.now(),l=a.loading.first?Math.max(0,o-a.loading.first):0;if(s.advancedDateTime=Date.now()-l,s.live||null!=r&&r.live){if(s.reloaded(r),r&&this.log("live playlist "+t+" "+(s.advanced?"REFRESHED "+s.lastPartSn+"-"+s.lastPartIndex:"MISSED")),r&&s.fragments.length>0&&(0,n.mergeDetails)(r,s),!this.canLoad||!s.live)return;var u,d=void 0,c=void 0;if(s.canBlockReload&&s.endSN&&s.advanced){var h=this.hls.config.lowLatencyMode,f=s.lastPartSn,g=s.endSN,v=s.lastPartIndex,p=f===g;-1!==v?(d=p?g+1:f,c=p?h?0:v:v+1):d=g+1;var m=s.age,y=Math.min(m+s.ageHeader-s.partTarget,1.5*s.targetduration);if(y>0){if(r&&y>r.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+r.tuneInGoal+" to: "+y+" with playlist age: "+s.age),y=0;else{var E=Math.floor(y/s.targetduration);d+=E,void 0!==c&&(c+=Math.round(y%s.targetduration/s.partTarget)),this.log("CDN Tune-in age: "+s.ageHeader+"s last advanced "+m.toFixed(2)+"s goal: "+y+" skip sn "+E+" to part "+c)}s.tuneInGoal=y}if(u=this.getDeliveryDirectives(s,e.deliveryDirectives,d,c),h||!p){this.loadPlaylist(u);return}}else u=this.getDeliveryDirectives(s,e.deliveryDirectives,d,c);var T=this.hls.mainForwardBufferInfo,S=T?T.end-T.len:0,b=(s.edge-S)*1e3,L=(0,n.computeReloadInterval)(s,b);s.updated?o>this.requestScheduled+L&&(this.requestScheduled=a.loading.start):this.requestScheduled=-1,void 0!==d&&s.canBlockReload?this.requestScheduled=a.loading.first+L-(1e3*s.partTarget||1e3):this.requestScheduled=(-1===this.requestScheduled?o:this.requestScheduled)+L;var D=this.requestScheduled-o;D=Math.max(0,D),this.log("reload live playlist "+t+" in "+Math.round(D)+" ms"),this.timer=self.setTimeout(function(){return i.loadPlaylist(u)},D)}else this.clearTimer()},e.getDeliveryDirectives=function(t,e,r,n){var s=(0,i.getSkipValue)(t,r);return null!=e&&e.skip&&t.deltaUpdateFailed&&(r=e.msn,n=e.part,s=i.HlsSkip.No),new i.HlsUrlParameters(r,n,s)},e.retryLoadingOrFail=function(t){var e,r=this,i=this.hls.config,n=this.retryCount<i.levelLoadingMaxRetry;if(n){if(this.requestScheduled=-1,this.retryCount++,t.details.indexOf("LoadTimeOut")>-1&&null!==(e=t.context)&&void 0!==e&&e.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+t.details+'"'),this.loadPlaylist();else{var s=Math.min(Math.pow(2,this.retryCount)*i.levelLoadingRetryDelay,i.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return r.loadPlaylist()},s),this.warn("retry playlist loading #"+this.retryCount+" in "+s+' ms after "'+t.details+'"')}}else this.warn('cannot recover from error "'+t.details+'"'),this.clearTimer(),t.fatal=!0;return n},t}()},"./src/controller/base-stream-controller.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{State:()=>S,default:()=>b});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../task-loop */"./src/task-loop.ts"),s=r(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),a=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),o=r(/*! ../utils/logger */"./src/utils/logger.ts"),l=r(/*! ../events */"./src/events.ts"),u=r(/*! ../errors */"./src/errors.ts"),d=r(/*! ../types/transmuxer */"./src/types/transmuxer.ts"),c=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),h=r(/*! ../utils/discontinuities */"./src/utils/discontinuities.ts"),f=r(/*! ./fragment-finders */"./src/controller/fragment-finders.ts"),g=r(/*! ./level-helper */"./src/controller/level-helper.ts"),v=r(/*! ../loader/fragment-loader */"./src/loader/fragment-loader.ts"),p=r(/*! ../crypt/decrypter */"./src/crypt/decrypter.ts"),m=r(/*! ../utils/time-ranges */"./src/utils/time-ranges.ts"),y=r(/*! ../types/loader */"./src/types/loader.ts");function E(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var i=r.call(t,e||"default");if("object"!=typeof i)return i;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(i.key),i)}}function T(t,e){return(T=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}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(t){function e(e,r,i,n){var s;return(s=t.call(this)||this).hls=void 0,s.fragPrevious=null,s.fragCurrent=null,s.fragmentTracker=void 0,s.transmuxer=null,s._state=S.STOPPED,s.media=null,s.mediaBuffer=null,s.config=void 0,s.bitrateTest=!1,s.lastCurrentTime=0,s.nextLoadPosition=0,s.startPosition=0,s.loadedmetadata=!1,s.fragLoadError=0,s.retryDate=0,s.levels=null,s.fragmentLoader=void 0,s.keyLoader=void 0,s.levelLastLoaded=null,s.startFragRequested=!1,s.decrypter=void 0,s.initPTS=[],s.onvseeking=null,s.onvended=null,s.logPrefix="",s.log=void 0,s.warn=void 0,s.logPrefix=n,s.log=o.logger.log.bind(o.logger,n+":"),s.warn=o.logger.warn.bind(o.logger,n+":"),s.hls=e,s.fragmentLoader=new v.default(e.config),s.keyLoader=i,s.fragmentTracker=r,s.config=e.config,s.decrypter=new p.default(e.config),e.on(l.Events.LEVEL_SWITCHING,s.onLevelSwitching,function(t){if(void 0===t)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(s)),s}e.prototype=Object.create(t.prototype),e.prototype.constructor=e,T(e,t);var r,n,b=e.prototype;return b.doTick=function(){this.onTickEnd()},b.onTickEnd=function(){},b.startLoad=function(t){},b.stopLoad=function(){this.fragmentLoader.abort(),this.keyLoader.abort();var t=this.fragCurrent;t&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=S.STOPPED},b._streamEnded=function(t,e){if(e.live||t.nextStart||!t.end||!this.media)return!1;var r=e.partList;if(null!=r&&r.length){var i=r[r.length-1];return a.BufferHelper.isBuffered(this.media,i.start+i.duration/2)}var n=e.fragments[e.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(n)},b.getLevelDetails=function(){if(this.levels&&null!==this.levelLastLoaded){var t;return null===(t=this.levels[this.levelLastLoaded])||void 0===t?void 0:t.details}},b.onMediaAttached=function(t,e){var r=this.media=this.mediaBuffer=e.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)},b.onMediaDetaching=function(){var t=this.media;null!=t&&t.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),t&&this.onvseeking&&this.onvended&&(t.removeEventListener("seeking",this.onvseeking),t.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()},b.onMediaSeeking=function(){var t=this.config,e=this.fragCurrent,r=this.media,n=this.mediaBuffer,s=this.state,o=r?r.currentTime:0,l=a.BufferHelper.bufferInfo(n||r,o,t.maxBufferHole);if(this.log("media seeking to "+((0,i.isFiniteNumber)(o)?o.toFixed(3):o)+", state: "+s),this.state===S.ENDED)this.resetLoadingState();else if(e){var u=t.maxFragLookUpTolerance,d=e.start-u,c=e.start+e.duration+u;if(!l.len||c<l.start||d>l.end){var h=o>c;(o<d||h)&&(h&&e.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),e.abortRequests()),this.resetLoadingState())}}r&&(this.lastCurrentTime=o),this.loadedmetadata||l.len||(this.nextLoadPosition=this.startPosition=o),this.tickImmediate()},b.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},b.onLevelSwitching=function(t,e){this.fragLoadError=0},b.onHandlerDestroying=function(){this.stopLoad(),t.prototype.onHandlerDestroying.call(this)},b.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,t.prototype.onHandlerDestroyed.call(this)},b.loadFragment=function(t,e,r){this._loadFragForPlayback(t,e,r)},b._loadFragForPlayback=function(t,e,r){var i=this;this._doFragLoad(t,e,r,function(e){if(i.fragContextChanged(t)){i.warn("Fragment "+t.sn+(e.part?" p: "+e.part.index:"")+" of level "+t.level+" was dropped during download."),i.fragmentTracker.removeFragment(t);return}t.stats.chunkCount++,i._handleFragmentLoadProgress(e)}).then(function(e){if(e){i.fragLoadError=0;var r=i.state;if(i.fragContextChanged(t)){r!==S.FRAG_LOADING&&(i.fragCurrent||r!==S.PARSING)||(i.fragmentTracker.removeFragment(t),i.state=S.IDLE);return}"payload"in e&&(i.log("Loaded fragment "+t.sn+" of level "+t.level),i.hls.trigger(l.Events.FRAG_LOADED,e)),i._handleFragmentLoadComplete(e)}}).catch(function(e){i.state!==S.STOPPED&&i.state!==S.ERROR&&(i.warn(e),i.resetFragmentLoading(t))})},b.flushMainBuffer=function(t,e,r){if(void 0===r&&(r=null),t-e){var i={startOffset:t,endOffset:e,type:r};this.fragLoadError=0,this.hls.trigger(l.Events.BUFFER_FLUSHING,i)}},b._loadInitSegment=function(t,e){var r=this;this._doFragLoad(t,e).then(function(e){if(!e||r.fragContextChanged(t)||!r.levels)throw Error("init load aborted");return e}).then(function(e){var i=r.hls,n=e.payload,s=t.decryptdata;if(n&&n.byteLength>0&&s&&s.key&&s.iv&&"AES-128"===s.method){var a=self.performance.now();return r.decrypter.decrypt(new Uint8Array(n),s.key.buffer,s.iv.buffer).then(function(r){var n=self.performance.now();return i.trigger(l.Events.FRAG_DECRYPTED,{frag:t,payload:r,stats:{tstart:a,tdecrypt:n}}),e.payload=r,e})}return e}).then(function(e){var i=r.fragCurrent,n=r.hls,s=r.levels;if(!s)throw Error("init load aborted, missing levels");console.assert(s[t.level].details,"Level details are defined when init segment is loaded");var a=t.stats;r.state=S.IDLE,r.fragLoadError=0,t.data=new Uint8Array(e.payload),a.parsing.start=a.buffering.start=self.performance.now(),a.parsing.end=a.buffering.end=self.performance.now(),e.frag===i&&n.trigger(l.Events.FRAG_BUFFERED,{stats:a,frag:i,part:null,id:t.type}),r.tick()}).catch(function(e){r.state!==S.STOPPED&&r.state!==S.ERROR&&(r.warn(e),r.resetFragmentLoading(t))})},b.fragContextChanged=function(t){var e=this.fragCurrent;return!t||!e||t.level!==e.level||t.sn!==e.sn||t.urlId!==e.urlId},b.fragBufferedComplete=function(t,e){var r,i,n,s,o=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+t.type+" sn: "+t.sn+(e?" part: "+e.index:"")+" of "+("[stream-controller]"===this.logPrefix?"level":"track")+" "+t.level+" (frag:["+(null!=(r=t.startPTS)?r:NaN).toFixed(3)+"-"+(null!=(i=t.endPTS)?i:NaN).toFixed(3)+"] > buffer:"+(o?m.default.toString(a.BufferHelper.getBuffered(o)):"(detached)")+")"),this.state=S.IDLE,o&&(!this.loadedmetadata&&t.type==y.PlaylistLevelType.MAIN&&o.buffered.length&&(null===(n=this.fragCurrent)||void 0===n?void 0:n.sn)===(null===(s=this.fragPrevious)||void 0===s?void 0:s.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},b.seekToStartPos=function(){},b._handleFragmentLoadComplete=function(t){var e=this.transmuxer;if(e){var r=t.frag,i=t.part,n=t.partsLoaded,s=!n||0===n.length||n.some(function(t){return!t}),a=new d.ChunkMetadata(r.level,r.sn,r.stats.chunkCount+1,0,i?i.index:-1,!s);e.flush(a)}},b._handleFragmentLoadProgress=function(t){},b._doFragLoad=function(t,e,r,n){var s,a=this;if(void 0===r&&(r=null),!this.levels)throw Error("frag load aborted, missing levels");var o=null;if(t.encrypted&&!(null!==(s=t.decryptdata)&&void 0!==s&&s.key)?(this.log("Loading key for "+t.sn+" of ["+e.startSN+"-"+e.endSN+"], "+("[stream-controller]"===this.logPrefix?"level":"track")+" "+t.level),this.state=S.KEY_LOADING,this.fragCurrent=t,o=this.keyLoader.load(t).then(function(t){if(!a.fragContextChanged(t.frag))return a.hls.trigger(l.Events.KEY_LOADED,t),a.state===S.KEY_LOADING&&(a.state=S.IDLE),t}),this.hls.trigger(l.Events.KEY_LOADING,{frag:t}),this.throwIfFragContextChanged("KEY_LOADING")):!t.encrypted&&e.encryptedFragments.length&&this.keyLoader.loadClear(t,e.encryptedFragments),r=Math.max(t.start,r||0),this.config.lowLatencyMode&&e){var u=e.partList;if(u&&n){r>t.end&&e.fragmentHint&&(t=e.fragmentHint);var d=this.getNextPart(u,t,r);if(d>-1){var c=u[d];return(this.log("Loading part sn: "+t.sn+" p: "+c.index+" cc: "+t.cc+" of playlist ["+e.startSN+"-"+e.endSN+"] parts [0-"+d+"-"+(u.length-1)+"] "+("[stream-controller]"===this.logPrefix?"level":"track")+": "+t.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:t,part:u[d],targetBufferTime:r}),this.throwIfFragContextChanged("FRAG_LOADING parts"),o)?o.then(function(e){return!e||a.fragContextChanged(e.frag)?null:a.doFragPartsLoad(t,u,d,n)}).catch(function(t){return a.handleFragLoadError(t)}):this.doFragPartsLoad(t,u,d,n).catch(function(t){return a.handleFragLoadError(t)})}if(!t.url||this.loadedEndOfParts(u,r))return Promise.resolve(null)}}this.log("Loading fragment "+t.sn+" cc: "+t.cc+" "+(e?"of ["+e.startSN+"-"+e.endSN+"] ":"")+("[stream-controller]"===this.logPrefix?"level":"track")+": "+t.level+", target: "+parseFloat(r.toFixed(3))),(0,i.isFiniteNumber)(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=S.FRAG_LOADING,this.hls.trigger(l.Events.FRAG_LOADING,{frag:t,targetBufferTime:r}),this.throwIfFragContextChanged("FRAG_LOADING");var h=this.config.progressive;return h&&o?o.then(function(e){return!e||a.fragContextChanged(null==e?void 0:e.frag)?null:a.fragmentLoader.load(t,n)}).catch(function(t){return a.handleFragLoadError(t)}):Promise.all([this.fragmentLoader.load(t,h?n:void 0),o]).then(function(t){var e=t[0];return!h&&e&&n&&n(e),e}).catch(function(t){return a.handleFragLoadError(t)})},b.throwIfFragContextChanged=function(t){if(null===this.fragCurrent)throw Error("frag load aborted, context changed in "+t)},b.doFragPartsLoad=function(t,e,r,i){var n=this;return new Promise(function(s,a){var o=[];!function r(u){var d=e[u];n.fragmentLoader.loadPart(t,d,i).then(function(i){o[d.index]=i;var a=i.part;n.hls.trigger(l.Events.FRAG_LOADED,i);var c=e[u+1];if(!c||c.fragment!==t)return s({frag:t,part:a,partsLoaded:o});r(u+1)}).catch(a)}(r)})},b.handleFragLoadError=function(t){if("data"in t){var e=t.data;t.data&&e.details===u.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(e.frag,e.part):this.hls.trigger(l.Events.ERROR,e)}else this.hls.trigger(l.Events.ERROR,{type:u.ErrorTypes.OTHER_ERROR,details:u.ErrorDetails.INTERNAL_EXCEPTION,err:t,fatal:!0});return null},b._handleTransmuxerFlush=function(t){var e=this.getCurrentContext(t);if(!e||this.state!==S.PARSING){this.fragCurrent||this.state===S.STOPPED||this.state===S.ERROR||(this.state=S.IDLE);return}var r=e.frag,i=e.part,n=e.level,s=self.performance.now();r.stats.parsing.end=s,i&&(i.stats.parsing.end=s),this.updateLevelTiming(r,i,n,t.partial)},b.getCurrentContext=function(t){var e=this.levels,r=t.level,i=t.sn,n=t.part;if(!e||!e[r])return this.warn("Levels object was unset while buffering fragment "+i+" of level "+r+". The current chunk will not be buffered."),null;var s=e[r],a=n>-1?(0,g.getPartWith)(s,i,n):null,o=a?a.fragment:(0,g.getFragmentWithSN)(s,i,this.fragCurrent);return o?{frag:o,part:a,level:s}:null},b.bufferFragmentData=function(t,e,r,i){if(t&&this.state===S.PARSING){var n=t.data1,s=t.data2,a=n;if(n&&s&&(a=(0,c.appendUint8Array)(n,s)),a&&a.length){var o={type:t.type,frag:e,part:r,chunkMeta:i,parent:e.type,data:a};this.hls.trigger(l.Events.BUFFER_APPENDING,o),t.dropped&&t.independent&&!r&&this.flushBufferGap(e)}}},b.flushBufferGap=function(t){var e=this.media;if(e){if(!a.BufferHelper.isBuffered(e,e.currentTime)){this.flushMainBuffer(0,t.start);return}var r=e.currentTime,i=a.BufferHelper.bufferInfo(e,r,0),n=t.duration,s=Math.min(2*this.config.maxFragLookUpTolerance,.25*n),o=Math.max(Math.min(t.start-s,i.end-s),r+s);t.start-o>s&&this.flushMainBuffer(o,t.start)}},b.getFwdBufferInfo=function(t,e){var r=this.config,n=this.getLoadPosition();if(!(0,i.isFiniteNumber)(n))return null;var s=a.BufferHelper.bufferInfo(t,n,r.maxBufferHole);if(0===s.len&&void 0!==s.nextStart){var o=this.fragmentTracker.getBufferedFrag(n,e);if(o&&s.nextStart<o.end)return a.BufferHelper.bufferInfo(t,n,Math.max(s.nextStart,r.maxBufferHole))}return s},b.getMaxBufferLength=function(t){var e=this.config;return Math.min(t?Math.max(8*e.maxBufferSize/t,e.maxBufferLength):e.maxBufferLength,e.maxMaxBufferLength)},b.reduceMaxBufferLength=function(t){var e=this.config,r=t||e.maxBufferLength;return e.maxMaxBufferLength>=r&&(e.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+e.maxMaxBufferLength+"s"),!0)},b.getNextFragment=function(t,e){var r,i=e.fragments,n=i.length;if(!n)return null;var s=this.config,a=i[0].start;if(e.live){var o=s.initialLiveManifestSize;if(n<o)return this.warn("Not enough fragments to start playback (have: "+n+", need: "+o+")"),null;e.PTSKnown||this.startFragRequested||-1!==this.startPosition||(r=this.getInitialLiveFragment(e,i),this.startPosition=r?this.hls.liveSyncPosition||r.start:t)}else t<=a&&(r=i[0]);if(!r){var l=s.lowLatencyMode?e.partEnd:e.fragmentEnd;r=this.getFragmentAtPosition(t,l,e)}return this.mapToInitFragWhenRequired(r)},b.mapToInitFragWhenRequired=function(t){return null==t||!t.initSegment||null!=t&&t.initSegment.data||this.bitrateTest?t:t.initSegment},b.getNextPart=function(t,e,r){for(var i=-1,n=!1,s=!0,a=0,o=t.length;a<o;a++){var l=t[a];if(s=s&&!l.independent,i>-1&&r<l.start)break;var u=l.loaded;u?i=-1:(n||l.independent||s)&&l.fragment===e&&(i=a),n=u}return i},b.loadedEndOfParts=function(t,e){var r=t[t.length-1];return r&&e>r.start&&r.loaded},b.getInitialLiveFragment=function(t,e){var r=this.fragPrevious,i=null;if(r){if(t.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+r.programDateTime),i=(0,f.findFragmentByPDT)(e,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!i){var n=r.sn+1;if(n>=t.startSN&&n<=t.endSN){var s=e[n-t.startSN];r.cc===s.cc&&(i=s,this.log("Live playlist, switching playlist, load frag with next SN: "+i.sn))}!i&&(i=(0,f.findFragWithCC)(e,r.cc))&&this.log("Live playlist, switching playlist, load frag with same CC: "+i.sn)}}else{var a=this.hls.liveSyncPosition;null!==a&&(i=this.getFragmentAtPosition(a,this.bitrateTest?t.fragmentEnd:t.edge,t))}return i},b.getFragmentAtPosition=function(t,e,r){var i,n=this.config,a=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),t<e){var h=t>e-d?0:d;i=(0,f.findFragmentByPTS)(a,o,t,h)}else i=o[o.length-1];if(i){var g=i.sn-r.startSN;if(this.fragmentTracker.getState(i)===s.FragmentState.OK&&(a=i),a&&i.sn===a.sn&&!c&&a&&i.level===a.level){var v=o[g+1];i.sn<l&&this.fragmentTracker.getState(v)!==s.FragmentState.OK?(this.log("SN "+i.sn+" just loaded, load next one: "+v.sn),i=v):i=null}}return i},b.synchronizeToLiveEdge=function(t){var e=this.config,r=this.media;if(r){var i=this.hls.liveSyncPosition,n=r.currentTime,s=t.fragments[0].start,a=t.edge,o=n>=s-e.maxFragLookUpTolerance&&n<=a;if(null!==i&&r.duration>i&&(n<i||!o)){var l=void 0!==e.liveMaxLatencyDuration?e.liveMaxLatencyDuration:e.liveMaxLatencyDurationCount*t.targetduration;(!o&&r.readyState<4||n<a-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: "+a+", reset currentTime to : "+i.toFixed(3)),r.currentTime=i))}}},b.alignPlaylists=function(t,e){var r=this.levels,n=this.levelLastLoaded,s=this.fragPrevious,a=null!==n?r[n]:null,o=t.fragments.length;if(!o)return this.warn("No fragments in live playlist"),0;var l=t.fragments[0].start,u=!e,d=t.alignedSliding&&(0,i.isFiniteNumber)(l);if(u||!d&&!l){(0,h.alignStream)(s,a,t);var c=t.fragments[0].start;return this.log("Live playlist sliding: "+c.toFixed(2)+" start-sn: "+(e?e.startSN:"na")+"->"+t.startSN+" prev-sn: "+(s?s.sn:"na")+" fragments: "+o),c}return l},b.waitForCdnTuneIn=function(t){return t.live&&t.canBlockReload&&t.partTarget&&t.tuneInGoal>Math.max(t.partHoldBack,3*t.partTarget)},b.setStartPosition=function(t,e){var r=this.startPosition;if(r<e&&(r=-1),-1===r||-1===this.lastCurrentTime){var n=t.startTimeOffset;(0,i.isFiniteNumber)(n)?(r=e+n,n<0&&(r+=t.totalduration),r=Math.min(Math.max(e,r),e+t.totalduration),this.log("Start time offset "+n+" found in playlist, adjust startPosition to "+r),this.startPosition=r):t.live?r=this.hls.liveSyncPosition||e:this.startPosition=r=0,this.lastCurrentTime=r}this.nextLoadPosition=r},b.getLoadPosition=function(){var t=this.media,e=0;return this.loadedmetadata&&t?e=t.currentTime:this.nextLoadPosition&&(e=this.nextLoadPosition),e},b.handleFragLoadAborted=function(t,e){this.transmuxer&&"initSegment"!==t.sn&&t.stats.aborted&&(this.warn("Fragment "+t.sn+(e?" part"+e.index:"")+" of level "+t.level+" was aborted"),this.resetFragmentLoading(t))},b.resetFragmentLoading=function(t){this.fragCurrent&&(this.fragContextChanged(t)||this.state===S.FRAG_LOADING_WAITING_RETRY)||(this.state=S.IDLE)},b.onFragmentOrKeyLoadError=function(t,e){if(e.fatal){this.stopLoad(),this.state=S.ERROR;return}var r=this.config;if(e.chunkMeta){var i=this.getCurrentContext(e.chunkMeta);i&&(e.frag=i.frag,e.levelRetry=!0,this.fragLoadError=r.fragLoadingMaxRetry)}var n=e.frag;if(n&&n.type===t){var s=this.fragCurrent;if(console.assert(s&&n.sn===s.sn&&n.level===s.level&&n.urlId===s.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 a=Math.min(Math.pow(2,this.fragLoadError)*r.fragLoadingRetryDelay,r.fragLoadingMaxRetryTimeout);this.warn("Fragment "+n.sn+" of "+t+" "+n.level+" failed to load, retrying in "+a+"ms"),this.retryDate=self.performance.now()+a,this.fragLoadError++,this.state=S.FRAG_LOADING_WAITING_RETRY}else e.levelRetry?(t===y.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=S.IDLE):(o.logger.error(e.details+" reaches max retry, redispatch as fatal ..."),e.fatal=!0,this.hls.stopLoad(),this.state=S.ERROR)}},b.afterBufferFlushed=function(t,e,r){if(t){var i=a.BufferHelper.getBuffered(t);this.fragmentTracker.detectEvictedFragments(e,i,r),this.state===S.ENDED&&this.resetLoadingState()}},b.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=S.IDLE},b.resetStartWhenNotLoaded=function(t){if(!this.loadedmetadata){this.startFragRequested=!1;var e=this.levels?this.levels[t].details:null;null!=e&&e.live?(this.startPosition=-1,this.setStartPosition(e,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},b.updateLevelTiming=function(t,e,r,i){var n=this,s=r.details;console.assert(!!s,"level.details must be defined"),Object.keys(t.elementaryStreams).reduce(function(e,a){var o=t.elementaryStreams[a];if(o){var u=o.endPTS-o.startPTS;if(u<=0)return n.warn("Could not parse fragment "+t.sn+" "+a+" duration reliably ("+u+")"),e||!1;var d=i?0:(0,g.updateFragPTSDTS)(s,t,o.startPTS,o.endPTS,o.startDTS,o.endDTS);return n.hls.trigger(l.Events.LEVEL_PTS_UPDATED,{details:s,level:r,drift:d,type:a,frag:t,start:o.startPTS,end:o.endPTS}),!0}return e},!1)||(this.warn("Found no media in fragment "+t.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:t,part:e})},b.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},r=[{key:"state",get:function(){return this._state},set:function(t){var e=this._state;e!==t&&(this._state=t,this.log(e+"->"+t))}}],E(e.prototype,r),n&&E(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}(n.default)},"./src/controller/buffer-controller.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>f});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../events */"./src/events.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),a=r(/*! ../errors */"./src/errors.ts"),o=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),l=r(/*! ../utils/mediasource-helper */"./src/utils/mediasource-helper.ts"),u=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),d=r(/*! ./buffer-operation-queue */"./src/controller/buffer-operation-queue.ts"),c=(0,l.getMediaSource)(),h=/([ha]vc.)(?:\.[^.,]+)+/,f=function(){function t(t){var e=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 t=e.media,r=e.mediaSource;s.logger.log("[buffer-controller]: Media source opened"),t&&(t.removeEventListener("emptied",e._onMediaEmptied),e.updateMediaElementDuration(),e.hls.trigger(n.Events.MEDIA_ATTACHED,{media:t})),r&&r.removeEventListener("sourceopen",e._onMediaSourceOpen),e.checkPendingTracks()},this._onMediaSourceClose=function(){s.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){s.logger.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=function(){var t=e.media,r=e._objectUrl;t&&t.src!==r&&s.logger.error("Media element src was set while attaching MediaSource ("+r+" > "+t.src+")")},this.hls=t,this._initSourceBuffer(),this.registerListeners()}var e=t.prototype;return e.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},e.destroy=function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null},e.registerListeners=function(){var t=this.hls;t.on(n.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(n.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(n.Events.BUFFER_RESET,this.onBufferReset,this),t.on(n.Events.BUFFER_APPENDING,this.onBufferAppending,this),t.on(n.Events.BUFFER_CODECS,this.onBufferCodecs,this),t.on(n.Events.BUFFER_EOS,this.onBufferEos,this),t.on(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(n.Events.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(n.Events.FRAG_PARSED,this.onFragParsed,this),t.on(n.Events.FRAG_CHANGED,this.onFragChanged,this)},e.unregisterListeners=function(){var t=this.hls;t.off(n.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(n.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(n.Events.BUFFER_RESET,this.onBufferReset,this),t.off(n.Events.BUFFER_APPENDING,this.onBufferAppending,this),t.off(n.Events.BUFFER_CODECS,this.onBufferCodecs,this),t.off(n.Events.BUFFER_EOS,this.onBufferEos,this),t.off(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(n.Events.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(n.Events.FRAG_PARSED,this.onFragParsed,this),t.off(n.Events.FRAG_CHANGED,this.onFragChanged,this)},e._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new d.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null},e.onManifestParsed=function(t,e){var r=2;(!e.audio||e.video)&&e.altAudio||(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,this.details=null,s.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},e.onMediaAttaching=function(t,e){var r=this.media=e.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)}},e.onMediaDetaching=function(){var t=this.media,e=this.mediaSource,r=this._objectUrl;if(e){if(s.logger.log("[buffer-controller]: media source detaching"),"open"===e.readyState)try{e.endOfStream()}catch(t){s.logger.warn("[buffer-controller]: onMediaDetaching: "+t.message+" while calling endOfStream")}this.onBufferReset(),e.removeEventListener("sourceopen",this._onMediaSourceOpen),e.removeEventListener("sourceended",this._onMediaSourceEnded),e.removeEventListener("sourceclose",this._onMediaSourceClose),t&&(t.removeEventListener("emptied",this._onMediaEmptied),r&&self.URL.revokeObjectURL(r),t.src===r?(t.removeAttribute("src"),t.load()):s.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)},e.onBufferReset=function(){var t=this;this.getSourceBufferTypes().forEach(function(e){var r=t.sourceBuffer[e];try{r&&(t.removeBufferListeners(e),t.mediaSource&&t.mediaSource.removeSourceBuffer(r),t.sourceBuffer[e]=void 0)}catch(t){s.logger.warn("[buffer-controller]: Failed to reset the "+e+" buffer",t)}}),this._initSourceBuffer()},e.onBufferCodecs=function(t,e){var r=this,i=this.getSourceBufferTypes().length;Object.keys(e).forEach(function(t){if(i){var n=r.tracks[t];if(n&&"function"==typeof n.buffer.changeType){var a=e[t],o=a.id,l=a.codec,u=a.levelCodec,d=a.container,c=a.metadata,f=(n.levelCodec||n.codec).replace(h,"$1"),g=(u||l).replace(h,"$1");if(f!==g){var v=d+";codecs="+(u||l);r.appendChangeType(t,v),s.logger.log("[buffer-controller]: switching codec "+f+" to "+g),r.tracks[t]={buffer:n.buffer,codec:l,container:d,levelCodec:u,metadata:c,id:o}}}}else r.pendingTracks[t]=e[t]}),!i&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks())},e.appendChangeType=function(t,e){var r=this,i=this.operationQueue;i.append({execute:function(){var n=r.sourceBuffer[t];n&&(s.logger.log("[buffer-controller]: changing "+t+" sourceBuffer type to "+e),n.changeType(e)),i.shiftAndExecuteNext(t)},onStart:function(){},onComplete:function(){},onError:function(e){s.logger.warn("[buffer-controller]: Failed to change "+t+" SourceBuffer type",e)}},t)},e.onBufferAppending=function(t,e){var r=this,i=this.hls,l=this.operationQueue,u=this.tracks,d=e.data,c=e.type,h=e.frag,f=e.part,g=e.chunkMeta,v=g.buffering[c],p=self.performance.now();v.start=p;var m=h.stats.buffering,y=f?f.stats.buffering:null;0===m.start&&(m.start=p),y&&0===y.start&&(y.start=p);var E=u.audio,T=!1;"audio"===c&&(null==E?void 0:E.container)==="audio/mpeg"&&(T=!this.lastMpegAudioChunk||1===g.id||this.lastMpegAudioChunk.sn!==g.sn,this.lastMpegAudioChunk=g);var S=h.start;l.append({execute:function(){if(v.executeStart=self.performance.now(),T){var t=r.sourceBuffer[c];if(t){var e=S-t.timestampOffset;Math.abs(e)>=.1&&(s.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+S+" (delta: "+e+") sn: "+h.sn+")"),t.timestampOffset=S)}}r.appendExecutor(d,c)},onStart:function(){},onComplete:function(){var t=self.performance.now();v.executeEnd=v.end=t,0===m.first&&(m.first=t),y&&0===y.first&&(y.first=t);var e=r.sourceBuffer,i={};for(var s in e)i[s]=o.BufferHelper.getBuffered(e[s]);r.appendError=0,r.hls.trigger(n.Events.BUFFER_APPENDED,{type:c,frag:h,part:f,chunkMeta:g,parent:h.type,timeRanges:i})},onError:function(t){s.logger.error("[buffer-controller]: Error encountered while trying to append to the "+c+" SourceBuffer",t);var e={type:a.ErrorTypes.MEDIA_ERROR,parent:h.type,details:a.ErrorDetails.BUFFER_APPEND_ERROR,err:t,fatal:!1};t.code===DOMException.QUOTA_EXCEEDED_ERR?e.details=a.ErrorDetails.BUFFER_FULL_ERROR:(r.appendError++,e.details=a.ErrorDetails.BUFFER_APPEND_ERROR,r.appendError>i.config.appendErrorMaxRetry&&(s.logger.error("[buffer-controller]: Failed "+i.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),e.fatal=!0,i.stopLoad())),i.trigger(n.Events.ERROR,e)}},c)},e.onBufferFlushing=function(t,e){var r=this,i=this.operationQueue,a=function(t){return{execute:r.removeExecutor.bind(r,t,e.startOffset,e.endOffset),onStart:function(){},onComplete:function(){r.hls.trigger(n.Events.BUFFER_FLUSHED,{type:t})},onError:function(e){s.logger.warn("[buffer-controller]: Failed to remove from "+t+" SourceBuffer",e)}}};e.type?i.append(a(e.type),e.type):this.getSourceBufferTypes().forEach(function(t){i.append(a(t),t)})},e.onFragParsed=function(t,e){var r=this,i=e.frag,a=e.part,o=[],l=a?a.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&&s.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+i.type+" level: "+i.level+" sn: "+i.sn),this.blockBuffers(function(){var t=self.performance.now();i.stats.buffering.end=t,a&&(a.stats.buffering.end=t);var e=a?a.stats:i.stats;r.hls.trigger(n.Events.FRAG_BUFFERED,{frag:i,part:a,stats:e,id:i.type})},o)},e.onFragChanged=function(t,e){this.flushBackBuffer()},e.onBufferEos=function(t,e){var r=this;this.getSourceBufferTypes().reduce(function(t,i){var n=r.sourceBuffer[i];return!n||e.type&&e.type!==i||(n.ending=!0,n.ended||(n.ended=!0,s.logger.log("[buffer-controller]: "+i+" sourceBuffer now EOS"))),t&&!!(!n||n.ended)},!0)&&(s.logger.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(function(){r.getSourceBufferTypes().forEach(function(t){var e=r.sourceBuffer[t];e&&(e.ending=!1)});var t=r.mediaSource;if(!t||"open"!==t.readyState){t&&s.logger.info("[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: "+t.readyState);return}s.logger.log("[buffer-controller]: Calling mediaSource.endOfStream()"),t.endOfStream()}))},e.onLevelUpdated=function(t,e){var r=e.details;r.fragments.length&&(this.details=r,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},e.flushBackBuffer=function(){var t=this.hls,e=this.details,r=this.media,a=this.sourceBuffer;if(r&&null!==e){var l=this.getSourceBufferTypes();if(l.length){var u=e.live&&null!==t.config.liveBackBufferLength?t.config.liveBackBufferLength:t.config.backBufferLength;if((0,i.isFiniteNumber)(u)&&!(u<0)){var d=r.currentTime,c=e.levelTargetDuration,h=Math.max(u,c),f=Math.floor(d/c)*c-h;l.forEach(function(r){var i=a[r];if(i){var l=o.BufferHelper.getBuffered(i);if(l.length>0&&f>l.start(0)){if(t.trigger(n.Events.BACK_BUFFER_REACHED,{bufferEnd:f}),e.live)t.trigger(n.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:f});else if(i.ended&&l.end(l.length-1)-d<2*c){s.logger.info("[buffer-controller]: Cannot flush "+r+" back buffer while SourceBuffer is in ended state");return}t.trigger(n.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:f,type:r})}}})}}}},e.updateMediaElementDuration=function(){if(this.details&&this.media&&this.mediaSource&&"open"===this.mediaSource.readyState){var t=this.details,e=this.hls,r=this.media,n=this.mediaSource,a=t.fragments[0].start+t.totalduration,o=r.duration,l=(0,i.isFiniteNumber)(n.duration)?n.duration:0;t.live&&e.config.liveDurationInfinity?(s.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),n.duration=1/0,this.updateSeekableRange(t)):(a>l&&a>o||!(0,i.isFiniteNumber)(o))&&(s.logger.log("[buffer-controller]: Updating Media Source duration to "+a.toFixed(3)),n.duration=a)}},e.updateSeekableRange=function(t){var e=this.mediaSource,r=t.fragments;if(r.length&&t.live&&null!=e&&e.setLiveSeekableRange){var i=Math.max(0,r[0].start),n=Math.max(i,i+t.totalduration);e.setLiveSeekableRange(i,n)}},e.checkPendingTracks=function(){var t=this.bufferCodecEventsExpected,e=this.operationQueue,r=this.pendingTracks,i=Object.keys(r).length;if(i&&!t||2===i){this.createSourceBuffers(r),this.pendingTracks={};var s=this.getSourceBufferTypes();if(0===s.length){this.hls.trigger(n.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}s.forEach(function(t){e.executeNext(t)})}},e.createSourceBuffers=function(t){var e=this.sourceBuffer,r=this.mediaSource;if(!r)throw Error("createSourceBuffers called when mediaSource was null");var i=0;for(var o in t)if(!e[o]){var l=t[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;s.logger.log("[buffer-controller]: creating sourceBuffer("+d+")");try{var c=e[o]=r.addSourceBuffer(d);this.addBufferListener(o,"updatestart",this._onSBUpdateStart),this.addBufferListener(o,"updateend",this._onSBUpdateEnd),this.addBufferListener(o,"error",this._onSBUpdateError),this.tracks[o]={buffer:c,codec:u,container:l.container,levelCodec:l.levelCodec,metadata:l.metadata,id:l.id},i++}catch(t){s.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+t.message),this.hls.trigger(n.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:t,mimeType:d})}}i&&this.hls.trigger(n.Events.BUFFER_CREATED,{tracks:this.tracks})},e._onSBUpdateStart=function(t){this.operationQueue.current(t).onStart()},e._onSBUpdateEnd=function(t){var e=this.operationQueue;e.current(t).onComplete(),e.shiftAndExecuteNext(t)},e._onSBUpdateError=function(t,e){s.logger.error("[buffer-controller]: "+t+" SourceBuffer error",e),this.hls.trigger(n.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var r=this.operationQueue.current(t);r&&r.onError(e)},e.removeExecutor=function(t,e,r){var n=this.media,a=this.mediaSource,o=this.operationQueue,l=this.sourceBuffer[t];if(!n||!a||!l){s.logger.warn("[buffer-controller]: Attempting to remove from the "+t+" SourceBuffer, but it does not exist"),o.shiftAndExecuteNext(t);return}var u=(0,i.isFiniteNumber)(n.duration)?n.duration:1/0,d=(0,i.isFiniteNumber)(a.duration)?a.duration:1/0,c=Math.max(0,e),h=Math.min(r,u,d);h>c&&!l.ending?(l.ended=!1,s.logger.log("[buffer-controller]: Removing ["+c+","+h+"] from the "+t+" SourceBuffer"),console.assert(!l.updating,t+" sourceBuffer must not be updating"),l.remove(c,h)):o.shiftAndExecuteNext(t)},e.appendExecutor=function(t,e){var r=this.operationQueue,i=this.sourceBuffer[e];if(!i){s.logger.warn("[buffer-controller]: Attempting to append to the "+e+" SourceBuffer, but it does not exist"),r.shiftAndExecuteNext(e);return}i.ended=!1,console.assert(!i.updating,e+" sourceBuffer must not be updating"),i.appendBuffer(t)},e.blockBuffers=function(t,e){var r=this;if(void 0===e&&(e=this.getSourceBufferTypes()),!e.length){s.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(t);return}var i=this.operationQueue;Promise.all(e.map(function(t){return i.appendBlocker(t)})).then(function(){t(),e.forEach(function(t){var e=r.sourceBuffer[t];e&&e.updating||i.shiftAndExecuteNext(t)})})},e.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},e.addBufferListener=function(t,e,r){var i=this.sourceBuffer[t];if(i){var n=r.bind(this,t);this.listeners[t].push({event:e,listener:n}),i.addEventListener(e,n)}},e.removeBufferListeners=function(t){var e=this.sourceBuffer[t];e&&this.listeners[t].forEach(function(t){e.removeEventListener(t.event,t.listener)})},t}()},"./src/controller/buffer-operation-queue.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>n});var i=r(/*! ../utils/logger */"./src/utils/logger.ts"),n=function(){function t(t){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=t}var e=t.prototype;return e.append=function(t,e){var r=this.queues[e];r.push(t),1===r.length&&this.buffers[e]&&this.executeNext(e)},e.insertAbort=function(t,e){this.queues[e].unshift(t),this.executeNext(e)},e.appendBlocker=function(t){var e,r=new Promise(function(t){e=t}),i={execute:e,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(i,t),r},e.executeNext=function(t){var e=this.buffers,r=this.queues,n=e[t],s=r[t];if(s.length){var a=s[0];try{a.execute()}catch(e){i.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),a.onError(e),n&&n.updating||(s.shift(),this.executeNext(t))}}},e.shiftAndExecuteNext=function(t){this.queues[t].shift(),this.executeNext(t)},e.current=function(t){return this.queues[t][0]},t}()},"./src/controller/cap-level-controller.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>a});var i=r(/*! ../events */"./src/events.ts");function n(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var i=r.call(t,e||"default");if("object"!=typeof i)return i;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(i.key),i)}}var s=function(){function t(t){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=t,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var e,r,s=t.prototype;return s.setStreamController=function(t){this.streamController=t},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 t=this.hls;t.on(i.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.on(i.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(i.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(i.Events.BUFFER_CODECS,this.onBufferCodecs,this),t.on(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},s.unregisterListener=function(){var t=this.hls;t.off(i.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.off(i.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(i.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(i.Events.BUFFER_CODECS,this.onBufferCodecs,this),t.off(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},s.onFpsDropLevelCapping=function(e,r){t.isLevelAllowed(r.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(r.droppedLevel)},s.onMediaAttaching=function(t,e){this.media=e.media instanceof HTMLVideoElement?e.media:null,this.clientRect=null},s.onManifestParsed=function(t,e){var r=this.hls;this.restrictedLevels=[],this.firstLevel=e.firstLevel,r.config.capLevelToPlayerSize&&e.video&&this.startCapping()},s.onBufferCodecs=function(t,e){this.hls.config.capLevelToPlayerSize&&e.video&&this.startCapping()},s.onMediaDetaching=function(){this.stopCapping()},s.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var t=this.hls.levels;if(t.length){var e=this.hls;e.autoLevelCapping=this.getMaxLevel(t.length-1),e.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=e.autoLevelCapping}}},s.getMaxLevel=function(e){var r=this,i=this.hls.levels;if(!i.length)return -1;var n=i.filter(function(i,n){return t.isLevelAllowed(n,r.restrictedLevels)&&n<=e});return this.clientRect=null,t.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 t=this.media,e={width:0,height:0};if(t){var r=t.getBoundingClientRect();e.width=r.width,e.height=r.height,e.width||e.height||(e.width=r.right-r.left||t.width||0,e.height=r.bottom-r.top||t.height||0)}return this.clientRect=e,e},t.isLevelAllowed=function(t,e){return void 0===e&&(e=[]),-1===e.indexOf(t)},t.getMaxLevelByMediaSize=function(t,e,r){if(!t||!t.length)return -1;for(var i=t.length-1,n=0;n<t.length;n+=1){var s,a=t[n];if((a.width>=e||a.height>=r)&&(!(s=t[n+1])||a.width!==s.width||a.height!==s.height)){i=n;break}}return i},e=[{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var t=1;if(!this.hls.config.ignoreDevicePixelRatio)try{t=self.devicePixelRatio}catch(t){}return t}}],n(t.prototype,e),r&&n(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}();let a=s},"./src/controller/cmcd-controller.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>h});var i=r(/*! ../events */"./src/events.ts"),n=r(/*! ../types/cmcd */"./src/types/cmcd.ts"),s=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts");function o(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var i=r.call(t,e||"default");if("object"!=typeof i)return i;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(i.key),i)}}function l(t,e,r){return e&&o(t.prototype,e),r&&o(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function u(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(r)return(r=r.call(t)).next.bind(r);if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return d(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if("Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return d(t,e)}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var i=0;return function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function d(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=Array(e);r<e;r++)i[r]=t[r];return i}function c(){return(c=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t}).apply(this,arguments)}var h=function(){function t(e){var r=this;this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){r.initialized&&(r.starved=!0),r.buffering=!0},this.onPlaying=function(){r.initialized||(r.initialized=!0),r.buffering=!1},this.applyPlaylistData=function(t){try{r.apply(t,{ot:n.CMCDObjectType.MANIFEST,su:!r.initialized})}catch(t){a.logger.warn("Could not generate manifest CMCD data.",t)}},this.applyFragmentData=function(t){try{var e=t.frag,i=r.hls.levels[e.level],s=r.getObjectType(e),o={d:1e3*e.duration,ot:s};(s===n.CMCDObjectType.VIDEO||s===n.CMCDObjectType.AUDIO||s==n.CMCDObjectType.MUXED)&&(o.br=i.bitrate/1e3,o.tb=r.getTopBandwidth(s)/1e3,o.bl=r.getBufferLength(s)),r.apply(t,o)}catch(t){a.logger.warn("Could not generate segment CMCD data.",t)}},this.hls=e;var i=this.config=e.config,s=i.cmcd;null!=s&&(i.pLoader=this.createPlaylistLoader(),i.fLoader=this.createFragmentLoader(),this.sid=s.sessionId||t.uuid(),this.cid=s.contentId,this.useHeaders=!0===s.useHeaders,this.registerListeners())}var e=t.prototype;return e.registerListeners=function(){var t=this.hls;t.on(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(i.Events.MEDIA_DETACHED,this.onMediaDetached,this),t.on(i.Events.BUFFER_CREATED,this.onBufferCreated,this)},e.unregisterListeners=function(){var t=this.hls;t.off(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(i.Events.MEDIA_DETACHED,this.onMediaDetached,this),t.off(i.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},e.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},e.onMediaAttached=function(t,e){this.media=e.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},e.onMediaDetached=function(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},e.onBufferCreated=function(t,e){var r,i;this.audioBuffer=null===(r=e.tracks.audio)||void 0===r?void 0:r.buffer,this.videoBuffer=null===(i=e.tracks.video)||void 0===i?void 0:i.buffer},e.createData=function(){var t;return{v:n.CMCDVersion,sf:n.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:null===(t=this.media)||void 0===t?void 0:t.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},e.apply=function(e,r){void 0===r&&(r={}),c(r,this.createData());var i=r.ot===n.CMCDObjectType.INIT||r.ot===n.CMCDObjectType.VIDEO||r.ot===n.CMCDObjectType.MUXED;if(this.starved&&i&&(r.bs=!0,r.su=!0,this.starved=!1),null==r.su&&(r.su=this.buffering),this.useHeaders){var s=t.toHeaders(r);if(!Object.keys(s).length)return;e.headers||(e.headers={}),c(e.headers,s)}else{var a=t.toQuery(r);if(!a)return;e.url=t.appendQueryToUri(e.url,a)}},e.getObjectType=function(t){var e=t.type;return"subtitle"===e?n.CMCDObjectType.TIMED_TEXT:"initSegment"===t.sn?n.CMCDObjectType.INIT:"audio"===e?n.CMCDObjectType.AUDIO:"main"===e?this.hls.audioTracks.length?n.CMCDObjectType.VIDEO:n.CMCDObjectType.MUXED:void 0},e.getTopBandwidth=function(t){var e=0,r=this.hls;if(t===n.CMCDObjectType.AUDIO)a=r.audioTracks;else{var i=r.maxAutoLevel,s=i>-1?i+1:r.levels.length;a=r.levels.slice(0,s)}for(var a,o,l=u(a);!(o=l()).done;){var d=o.value;d.bitrate>e&&(e=d.bitrate)}return e>0?e:NaN},e.getBufferLength=function(t){var e=this.hls.media,r=t===n.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;return r&&e?1e3*s.BufferHelper.bufferInfo(r,e.currentTime,this.config.maxBufferHole).len:NaN},e.createPlaylistLoader=function(){var t=this.config.pLoader,e=this.applyPlaylistData,r=t||this.config.loader;return function(){function t(t){this.loader=void 0,this.loader=new r(t)}var i=t.prototype;return i.destroy=function(){this.loader.destroy()},i.abort=function(){this.loader.abort()},i.load=function(t,r,i){e(t),this.loader.load(t,r,i)},l(t,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),t}()},e.createFragmentLoader=function(){var t=this.config.fLoader,e=this.applyFragmentData,r=t||this.config.loader;return function(){function t(t){this.loader=void 0,this.loader=new r(t)}var i=t.prototype;return i.destroy=function(){this.loader.destroy()},i.abort=function(){this.loader.abort()},i.load=function(t,r,i){e(t),this.loader.load(t,r,i)},l(t,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),t}()},t.uuid=function(){var t=URL.createObjectURL(new Blob),e=t.toString();return URL.revokeObjectURL(t),e.slice(e.lastIndexOf("/")+1)},t.serialize=function(t){for(var e,r=[],i=function(t){return Math.round(t)},n=function(t){return 100*i(t/100)},s={br:i,d:i,bl:n,dl:n,mtp:n,nor:function(t){return encodeURIComponent(t)},rtp:n,tb:i},a=Object.keys(t||{}).sort(),o=u(a);!(e=o()).done;){var l,d=e.value,c=t[d];if(!Number.isNaN(l=c)&&null!=l&&""!==l&&!1!==l&&("v"!==d||1!==c)&&("pr"!=d||1!==c)){var h=s[d];h&&(c=h(c));var f=typeof c,g=void 0;g="ot"===d||"sf"===d||"st"===d?d+"="+c:"boolean"===f?d:"number"===f?d+"="+c:d+"="+JSON.stringify(c),r.push(g)}}return r.join(",")},t.toHeaders=function(e){for(var r=Object.keys(e),i={},n=["Object","Request","Session","Status"],s=[{},{},{},{}],a={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3},o=0;o<r.length;o++){var l=r[o];s[null!=a[l]?a[l]:1][l]=e[l]}for(var u=0;u<s.length;u++){var d=t.serialize(s[u]);d&&(i["CMCD-"+n[u]]=d)}return i},t.toQuery=function(e){return"CMCD="+encodeURIComponent(t.serialize(e))},t.appendQueryToUri=function(t,e){if(!e)return t;var r=t.includes("?")?"&":"?";return""+t+r+e},t}()},"./src/controller/eme-controller.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>S});var i=r(/*! ../events */"./src/events.ts"),n=r(/*! ../errors */"./src/errors.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),a=r(/*! ../utils/mediakeys-helper */"./src/utils/mediakeys-helper.ts"),o=r(/*! ../utils/keysystem-util */"./src/utils/keysystem-util.ts"),l=r(/*! ../utils/numeric-encoding-utils */"./src/utils/numeric-encoding-utils.ts"),u=r(/*! ../loader/level-key */"./src/loader/level-key.ts"),d=r(/*! ../utils/hex */"./src/utils/hex.ts"),c=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),h=r(/*! eventemitter3 */"./node_modules/eventemitter3/index.js"),f=r.n(h);function g(t){var e="function"==typeof Map?new Map:void 0;return(g=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return v(t,arguments,m(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),p(r,t)})(t)}function v(t,e,r){return(v=!function(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}()?function(t,e,r){var i=[null];i.push.apply(i,e);var n=new(Function.bind.apply(t,i));return r&&p(n,r.prototype),n}:Reflect.construct.bind()).apply(null,arguments)}function p(t,e){return(p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}function m(t){return(m=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var y="[eme]",E=function(){function t(e){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=t.CDMCleanupPromise?[t.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=s.logger.debug.bind(s.logger,y),this.log=s.logger.log.bind(s.logger,y),this.warn=s.logger.warn.bind(s.logger,y),this.error=s.logger.error.bind(s.logger,y),this.hls=e,this.config=e.config,this.registerListeners()}var e=t.prototype;return e.destroy=function(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null},e.registerListeners=function(){this.hls.on(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(i.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(i.Events.MANIFEST_LOADED,this.onManifestLoaded,this)},e.unregisterListeners=function(){this.hls.off(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(i.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(i.Events.MANIFEST_LOADED,this.onManifestLoaded,this)},e.getLicenseServerUrl=function(t){var e=this.config,r=e.drmSystems,i=e.widevineLicenseUrl,n=r[t];if(n)return n.licenseUrl;if(t===a.KeySystems.WIDEVINE&&i)return i;throw Error('no license server URL configured for key-system "'+t+'"')},e.getServerCertificateUrl=function(t){var e=this.config.drmSystems[t];if(e)return e.serverCertificateUrl;this.log('No Server Certificate in config.drmSystems["'+t+'"]')},e.attemptKeySystemAccess=function(t){var e=this,r=this.hls.levels,i=function(t,e,r){return!!t&&r.indexOf(t)===e},s=r.map(function(t){return t.audioCodec}).filter(i),a=r.map(function(t){return t.videoCodec}).filter(i);return s.length+a.length===0&&a.push("avc1.42e01e"),new Promise(function(r,i){!function t(o){var l=o.shift();e.getMediaKeysPromise(l,s,a).then(function(t){return r({keySystem:l,mediaKeys:t})}).catch(function(e){o.length?t(o):e instanceof T?i(e):i(new T({type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_ACCESS,error:e,fatal:!0},e.message))})}(t)})},e.requestMediaKeySystemAccess=function(t,e){var r=this.config.requestMediaKeySystemAccessFunc;if("function"!=typeof r){var i="Configured requestMediaKeySystemAccess is not a function "+r;return null===a.requestMediaKeySystemAccess&&"http:"===self.location.protocol&&(i="navigator.requestMediaKeySystemAccess is not available over insecure protocol "+location.protocol),Promise.reject(Error(i))}return r(t,e)},e.getMediaKeysPromise=function(t,e,r){var i=this,n=(0,a.getSupportedMediaKeySystemConfigurations)(t,e,r,this.config.drmSystemOptions),s=this.keySystemAccessPromises[t],o=null==s?void 0:s.keySystemAccess;if(!o){this.log('Requesting encrypted media "'+t+'" key-system access with config: '+JSON.stringify(n)),o=this.requestMediaKeySystemAccess(t,n);var l=this.keySystemAccessPromises[t]={keySystemAccess:o};return o.catch(function(e){i.log('Failed to obtain access to key-system "'+t+'": '+e)}),o.then(function(e){i.log('Access for key-system "'+e.keySystem+'" obtained');var r=i.fetchServerCertificate(t);return i.log('Create media-keys for "'+t+'"'),l.mediaKeys=e.createMediaKeys().then(function(e){return i.log('Media-keys created for "'+t+'"'),r.then(function(r){return r?i.setMediaKeysServerCertificate(e,t,r):e})}),l.mediaKeys.catch(function(e){i.error('Failed to create media-keys for "'+t+'"}: '+e)}),l.mediaKeys})}return o.then(function(){return s.mediaKeys})},e.createMediaKeySessionContext=function(t){var e=t.decryptdata,r=t.keySystem,i=t.mediaKeys;console.assert(!!i,"mediaKeys is defined"),this.log('Creating key-system session "'+r+'" keyId: '+d.default.hexDump(e.keyId||[]));var n=i.createSession(),s={decryptdata:e,keySystem:r,mediaKeys:i,mediaKeysSession:n,keyStatus:"status-pending"};return this.mediaKeySessions.push(s),s},e.renewKeySession=function(t){var e=t.decryptdata;if(e.pssh){var r=this.createMediaKeySessionContext(t),i=this.getKeyIdString(e);this.keyIdToKeySessionPromise[i]=this.generateRequestWithPreferredKeySession(r,"cenc",e.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(t)},e.getKeyIdString=function(t){if(!t)throw Error("Could not read keyId of undefined decryptdata");if(null===t.keyId)throw Error("keyId is null");return d.default.hexDump(t.keyId)},e.updateKeySession=function(t,e){var r,i=t.mediaKeysSession;return this.log('Updating key-session "'+i.sessionId+'" for keyID '+d.default.hexDump((null===(r=t.decryptdata)||void 0===r?void 0:r.keyId)||[])+"\n } (data length: "+(e?e.byteLength:e)+")"),i.update(e)},e.selectKeySystemFormat=function(t){var e=Object.keys(t.levelkeys||{});return this.keyFormatPromise||(this.log("Selecting key-system from fragment (sn: "+t.sn+" "+t.type+": "+t.level+") key formats "+e.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(e)),this.keyFormatPromise},e.getKeyFormatPromise=function(t){var e=this;return new Promise(function(r,i){var n=(0,a.getKeySystemsForConfig)(e.config),s=t.map(a.keySystemFormatToKeySystemDomain).filter(function(t){return!!t&&-1!==n.indexOf(t)});return e.getKeySystemSelectionPromise(s).then(function(t){var e=t.keySystem,n=(0,a.keySystemDomainToKeySystemFormat)(e);n?r(n):i(Error('Unable to find format for key-system "'+e+'"'))}).catch(i)})},e.loadKey=function(t){var e=this,r=t.keyInfo.decryptdata,i=this.getKeyIdString(r),n="(keyId: "+i+' format: "'+r.keyFormat+'" method: '+r.method+" uri: "+r.uri+")";this.log("Starting session for key "+n);var s=this.keyIdToKeySessionPromise[i];return s||(s=this.keyIdToKeySessionPromise[i]=this.getKeySystemForKeyPromise(r).then(function(i){var s=i.keySystem,a=i.mediaKeys;return e.throwIfDestroyed(),e.log("Handle encrypted media sn: "+t.frag.sn+" "+t.frag.type+": "+t.frag.level+" using key "+n),e.attemptSetMediaKeys(s,a).then(function(){e.throwIfDestroyed();var t=e.createMediaKeySessionContext({keySystem:s,mediaKeys:a,decryptdata:r});return e.generateRequestWithPreferredKeySession(t,"cenc",r.pssh,"playlist-key")})})).catch(function(t){return e.handleError(t)}),s},e.throwIfDestroyed=function(t){if(void 0===t&&(t="Invalid state"),!this.hls)throw Error("invalid state")},e.handleError=function(t){this.hls&&(this.error(t.message),t instanceof T?this.hls.trigger(i.Events.ERROR,t.data):this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_KEYS,error:t,fatal:!0}))},e.getKeySystemForKeyPromise=function(t){var e=this.getKeyIdString(t),r=this.keyIdToKeySessionPromise[e];if(!r){var i=(0,a.keySystemFormatToKeySystemDomain)(t.keyFormat),n=i?[i]:(0,a.getKeySystemsForConfig)(this.config);return this.attemptKeySystemAccess(n)}return r},e.getKeySystemSelectionPromise=function(t){if(t.length||(t=(0,a.getKeySystemsForConfig)(this.config)),0===t.length)throw new T({type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},"Missing key-system license configuration options "+JSON.stringify({drmSystems:this.config.drmSystems}));return this.attemptKeySystemAccess(t)},e._onMediaEncrypted=function(t){var e,r,i=this,n=t.initDataType,s=t.initData;if(this.debug('"'+t.type+'" event: init data type: "'+n+'"'),null!==s){if("sinf"===n&&this.config.drmSystems[a.KeySystems.FAIRPLAY]){var o=(0,c.bin2str)(new Uint8Array(s));try{var h=(0,l.base64Decode)(JSON.parse(o).sinf),f=(0,c.parseSinf)(new Uint8Array(h));if(!f)return;e=f.subarray(8,24),r=a.KeySystems.FAIRPLAY}catch(t){this.warn('Failed to parse sinf "encrypted" event message initData');return}}else{var g=(0,c.parsePssh)(s);if(null===g)return;0===g.version&&g.systemId===a.KeySystemIds.WIDEVINE&&g.data&&(e=g.data.subarray(8,24)),r=(0,a.keySystemIdToKeySystemDomain)(g.systemId)}if(r&&e){for(var v=d.default.hexDump(e),p=this.keyIdToKeySessionPromise,m=this.mediaKeySessions,y=p[v],E=0;E<m.length;E++){var T=function(t){var r=m[t],a=r.decryptdata;if(a.pssh||!a.keyId)return"continue";var o=d.default.hexDump(a.keyId);if(v===o||-1!==a.uri.replace(/-/g,"").indexOf(v))return y=p[o],delete p[o],a.pssh=new Uint8Array(s),a.keyId=e,y=p[v]=y.then(function(){return i.generateRequestWithPreferredKeySession(r,n,s,"encrypted-event-key-match")}),"break"}(E);if("continue"!==T&&"break"===T)break}y||(y=p[v]=this.getKeySystemSelectionPromise([r]).then(function(t){var r,o=t.keySystem,l=t.mediaKeys;i.throwIfDestroyed();var d=new u.LevelKey("ISO-23001-7",v,null!=(r=(0,a.keySystemDomainToKeySystemFormat)(o))?r:"");return d.pssh=new Uint8Array(s),d.keyId=e,i.attemptSetMediaKeys(o,l).then(function(){i.throwIfDestroyed();var t=i.createMediaKeySessionContext({decryptdata:d,keySystem:o,mediaKeys:l});return i.generateRequestWithPreferredKeySession(t,n,s,"encrypted-event-no-match")})})),y.catch(function(t){return i.handleError(t)})}}},e._onWaitingForKey=function(t){this.log('"'+t.type+'" event')},e.attemptSetMediaKeys=function(t,e){var r=this,i=this.setMediaKeysQueue.slice();this.log('Setting media-keys for "'+t+'"');var n=Promise.all(i).then(function(){if(!r.media)throw Error("Attempted to set mediaKeys without media element attached");return r.media.setMediaKeys(e)});return this.setMediaKeysQueue.push(n),n.then(function(){r.log('Media-keys set for "'+t+'"'),i.push(n),r.setMediaKeysQueue=r.setMediaKeysQueue.filter(function(t){return -1===i.indexOf(t)})})},e.generateRequestWithPreferredKeySession=function(t,e,r,i){var s,l,u=this,d=null===(s=this.config.drmSystems)||void 0===s?void 0:null===(l=s[t.keySystem])||void 0===l?void 0:l.generateRequest;if(d)try{var c,h=d.call(this.hls,e,r,t);if(!h)throw Error("Invalid response from configured generateRequest filter");e=h.initDataType,r=t.decryptdata.pssh=h.initData?new Uint8Array(h.initData):null}catch(t){if(this.warn(t.message),null!==(c=this.hls)&&void 0!==c&&c.config.debug)throw t}if(null===r)return this.log('Skipping key-session request for "'+i+'" (no initData)'),Promise.resolve(t);var g=this.getKeyIdString(t.decryptdata);this.log('Generating key-session request for "'+i+'": '+g+" (init data type: "+e+" length: "+(r?r.byteLength:null)+")");var v=new(f());t.mediaKeysSession.onmessage=function(e){var r=t.mediaKeysSession;if(!r){v.emit("error",Error("invalid state"));return}var i=e.messageType,n=e.message;u.log('"'+i+'" message event for session "'+r.sessionId+'" message size: '+n.byteLength),"license-request"===i||"license-renewal"===i?u.renewLicense(t,n).catch(function(t){u.handleError(t),v.emit("error",t)}):"license-release"===i?t.keySystem===a.KeySystems.FAIRPLAY&&(u.updateKeySession(t,(0,o.strToUtf8array)("acknowledged")),u.removeSession(t)):u.warn('unhandled media key message type "'+i+'"')},t.mediaKeysSession.onkeystatuseschange=function(e){if(!t.mediaKeysSession){v.emit("error",Error("invalid state"));return}u.onKeyStatusChange(t);var r=t.keyStatus;v.emit("keyStatus",r),"expired"===r&&(u.warn(t.keySystem+" expired for key "+g),u.renewKeySession(t))};var p=new Promise(function(t,e){v.on("error",e),v.on("keyStatus",function(r){r.startsWith("usable")?t():"output-restricted"===r?e(new T({type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):"internal-error"===r?e(new T({type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},'key status changed to "'+r+'"')):"expired"===r?e(Error("key expired while generating request")):u.warn('unhandled key status change "'+r+'"')})});return t.mediaKeysSession.generateRequest(e,r).then(function(){var e;u.log('Request generated for key-session "'+(null===(e=t.mediaKeysSession)||void 0===e?void 0:e.sessionId)+'" keyId: '+g)}).catch(function(t){throw new T({type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_SESSION,error:t,fatal:!1},"Error generating key-session request: "+t)}).then(function(){return p}).catch(function(e){throw v.removeAllListeners(),u.removeSession(t),e}).then(function(){return v.removeAllListeners(),t})},e.onKeyStatusChange=function(t){var e=this;t.mediaKeysSession.keyStatuses.forEach(function(r,i){e.log('key status change "'+r+'" for keyStatuses keyId: '+d.default.hexDump("buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i))+" session keyId: "+d.default.hexDump(new Uint8Array(t.decryptdata.keyId||[]))+" uri: "+t.decryptdata.uri),t.keyStatus=r})},e.fetchServerCertificate=function(t){var e=this;return new Promise(function(r,i){var s=e.getServerCertificateUrl(t);if(!s)return r();e.log('Fetching serverCertificate for "'+t+'"');var a=new XMLHttpRequest;a.open("GET",s,!0),a.responseType="arraybuffer",a.onreadystatechange=function(){a.readyState===XMLHttpRequest.DONE&&(200===a.status?r(a.response):i(new T({type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:a},'"'+t+'" certificate request XHR failed ('+s+"). Status: "+a.status+" ("+a.statusText+")")))},a.send()})},e.setMediaKeysServerCertificate=function(t,e,r){var i=this;return new Promise(function(s,a){t.setServerCertificate(r).then(function(n){i.log("setServerCertificate "+(n?"success":"not supported by CDM")+" ("+(null==r?void 0:r.byteLength)+') on "'+e+'"'),s(t)}).catch(function(t){a(new T({type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:t,fatal:!0},t.message))})})},e.renewLicense=function(t,e){var r=this;return this.requestLicense(t,new Uint8Array(e)).then(function(e){return r.updateKeySession(t,new Uint8Array(e)).catch(function(t){throw new T({type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:t,fatal:!0},t.message)})})},e.setupLicenseXHR=function(t,e,r,i){var n=this,s=this.config.licenseXhrSetup;return s?Promise.resolve().then(function(){if(!r.decryptdata)throw Error("Key removed");return s.call(n.hls,t,e,r,i)}).catch(function(a){if(!r.decryptdata)throw a;return t.open("POST",e,!0),s.call(n.hls,t,e,r,i)}).then(function(r){return t.readyState||t.open("POST",e,!0),{xhr:t,licenseChallenge:r||i}}):(t.open("POST",e,!0),Promise.resolve({xhr:t,licenseChallenge:i}))},e.requestLicense=function(t,e){var r=this;return new Promise(function(i,s){var a=r.getLicenseServerUrl(t.keySystem);r.log("Sending license request to URL: "+a);var o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=function(){if(!r.hls||!t.mediaKeysSession)return s(Error("invalid state"));if(4===o.readyState){if(200===o.status){r._requestLicenseFailureCount=0;var l=o.response;r.log("License received "+(l instanceof ArrayBuffer?l.byteLength:l));var u=r.config.licenseResponseCallback;if(u)try{l=u.call(r.hls,o,a,t)}catch(t){r.error(t)}i(l)}else if(r._requestLicenseFailureCount++,r._requestLicenseFailureCount>3||o.status>=400&&o.status<500)s(new T({type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:o},"License Request XHR failed ("+a+"). Status: "+o.status+" ("+o.statusText+")"));else{var d=3-r._requestLicenseFailureCount+1;r.warn("Retrying license request, "+d+" attempts left"),r.requestLicense(t,e).then(i,s)}}},t.licenseXhr&&t.licenseXhr.readyState!==XMLHttpRequest.DONE&&t.licenseXhr.abort(),t.licenseXhr=o,r.setupLicenseXHR(o,a,t,e).then(function(t){var e=t.xhr,r=t.licenseChallenge;e.send(r)})})},e.onMediaAttached=function(t,e){if(this.config.emeEnabled){var r=e.media;this.media=r,r.addEventListener("encrypted",this.onMediaEncrypted),r.addEventListener("waitingforkey",this.onWaitingForKey)}},e.onMediaDetached=function(){var e=this,r=this.media,i=this.mediaKeySessions;r&&(r.removeEventListener("encrypted",this.onMediaEncrypted),r.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},u.LevelKey.clearKeyUriToKeyIdMap();var n=i.length;t.CDMCleanupPromise=Promise.all(i.map(function(t){return e.removeSession(t)}).concat(null==r?void 0:r.setMediaKeys(null).catch(function(t){e.log("Could not clear media keys: "+t+". media.src: "+(null==r?void 0:r.src))}))).then(function(){n&&(e.log("finished closing key sessions and clearing media keys"),i.length=0)}).catch(function(t){e.log("Could not close sessions and clear media keys: "+t+". media.src: "+(null==r?void 0:r.src))})},e.onManifestLoaded=function(t,e){var r=e.sessionKeys;if(r&&this.config.emeEnabled&&!this.keyFormatPromise){var i=r.reduce(function(t,e){return -1===t.indexOf(e.keyFormat)&&t.push(e.keyFormat),t},[]);this.log("Selecting key-system from session-keys "+i.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(i)}},e.removeSession=function(t){var e=this,r=t.mediaKeysSession,i=t.licenseXhr;if(r){this.log("Remove licenses and keys and close session "+r.sessionId),r.onmessage=null,r.onkeystatuseschange=null,i&&i.readyState!==XMLHttpRequest.DONE&&i.abort(),t.mediaKeysSession=t.decryptdata=t.licenseXhr=void 0;var n=this.mediaKeySessions.indexOf(t);return n>-1&&this.mediaKeySessions.splice(n,1),r.remove().catch(function(t){e.log("Could not remove session: "+t)}).then(function(){return r.close()}).catch(function(t){e.log("Could not close session: "+t)})}},t}();E.CDMCleanupPromise=void 0;var T=function(t){function e(e,r){var i;return(i=t.call(this,r)||this).data=void 0,i.data=e,e.err=e.error,i}return e.prototype=Object.create(t.prototype),e.prototype.constructor=e,p(e,t),e}(g(Error));let S=E},"./src/controller/fps-controller.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>a});var i=r(/*! ../events */"./src/events.ts"),n=r(/*! ../utils/logger */"./src/utils/logger.ts"),s=function(){function t(t){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=t,this.registerListeners()}var e=t.prototype;return e.setStreamController=function(t){this.streamController=t},e.registerListeners=function(){this.hls.on(i.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},e.unregisterListeners=function(){this.hls.off(i.Events.MEDIA_ATTACHING,this.onMediaAttaching)},e.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},e.onMediaAttaching=function(t,e){var r=this.hls.config;if(r.capLevelOnFPSDrop){var i=e.media instanceof self.HTMLVideoElement?e.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)}},e.checkFPS=function(t,e,r){var s=performance.now();if(e){if(this.lastTime){var a=s-this.lastTime,o=r-this.lastDroppedFrames,l=e-this.lastDecodedFrames,u=this.hls;if(u.trigger(i.Events.FPS_DROP,{currentDropped:o,currentDecoded:l,totalDroppedFrames:r}),1e3*o/a>0&&o>u.config.fpsDroppedMonitoringThreshold*l){var d=u.currentLevel;n.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+d),d>0&&(-1===u.autoLevelCapping||u.autoLevelCapping>=d)&&(d-=1,u.trigger(i.Events.FPS_DROP_LEVEL_CAPPING,{level:d,droppedLevel:u.currentLevel}),u.autoLevelCapping=d,this.streamController.nextLevelSwitch())}}this.lastTime=s,this.lastDroppedFrames=r,this.lastDecodedFrames=e}},e.checkFPSInterval=function(){var t=this.media;if(t){if(this.isVideoPlaybackQualityAvailable){var e=t.getVideoPlaybackQuality();this.checkFPS(t,e.totalVideoFrames,e.droppedVideoFrames)}else this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount)}},t}();let a=s},"./src/controller/fragment-finders.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{findFragWithCC:()=>u,findFragmentByPDT:()=>s,findFragmentByPTS:()=>a,fragmentWithinToleranceTest:()=>o,pdtWithinToleranceTest:()=>l});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../utils/binary-search */"./src/utils/binary-search.ts");function s(t,e,r){if(null===e||!Array.isArray(t)||!t.length||!(0,i.isFiniteNumber)(e)||e<(t[0].programDateTime||0)||e>=(t[t.length-1].endProgramDateTime||0))return null;r=r||0;for(var n=0;n<t.length;++n){var s=t[n];if(l(e,r,s))return s}return null}function a(t,e,r,i){void 0===r&&(r=0),void 0===i&&(i=0);var s=null;if(t?s=e[t.sn-e[0].sn+1]||null:0===r&&0===e[0].start&&(s=e[0]),s&&0===o(r,i,s))return s;var a=n.default.search(e,o.bind(null,r,i));return a&&(a!==t||!s)?a:s}function o(t,e,r){if(void 0===t&&(t=0),void 0===e&&(e=0),r.start<=t&&r.start+r.duration>t)return 0;var i=Math.min(e,r.duration+(r.deltaPTS?r.deltaPTS:0));return r.start+r.duration-i<=t?1:r.start-i>t&&r.start?-1:0}function l(t,e,r){var i=1e3*Math.min(e,r.duration+(r.deltaPTS?r.deltaPTS:0));return(r.endProgramDateTime||0)-i>t}function u(t,e){return n.default.search(t,function(t){return t.cc<e?1:t.cc>e?-1:0})}},"./src/controller/fragment-tracker.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{FragmentState:()=>n,FragmentTracker:()=>o});var i,n,s=r(/*! ../events */"./src/events.ts"),a=r(/*! ../types/loader */"./src/types/loader.ts");(i=n||(n={})).NOT_LOADED="NOT_LOADED",i.APPENDING="APPENDING",i.PARTIAL="PARTIAL",i.OK="OK";var o=function(){function t(t){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=t,this._registerListeners()}var e=t.prototype;return e._registerListeners=function(){var t=this.hls;t.on(s.Events.BUFFER_APPENDED,this.onBufferAppended,this),t.on(s.Events.FRAG_BUFFERED,this.onFragBuffered,this),t.on(s.Events.FRAG_LOADED,this.onFragLoaded,this)},e._unregisterListeners=function(){var t=this.hls;t.off(s.Events.BUFFER_APPENDED,this.onBufferAppended,this),t.off(s.Events.FRAG_BUFFERED,this.onFragBuffered,this),t.off(s.Events.FRAG_LOADED,this.onFragLoaded,this)},e.destroy=function(){this._unregisterListeners(),this.fragments=this.endListFragments=this.timeRanges=this.activeFragment=this.activeParts=null},e.getAppendedFrag=function(t,e){if(e===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<=t&&void 0!==o&&t<=o)return n>9&&(this.activeParts=i.slice(n-9)),s}else if(r.start<=t&&void 0!==r.appendedPTS&&t<=r.appendedPTS)return r}return this.getBufferedFrag(t,e)},e.getBufferedFrag=function(t,e){for(var r=this.fragments,i=Object.keys(r),n=i.length;n--;){var s=r[i[n]];if((null==s?void 0:s.body.type)===e&&s.buffered){var a=s.body;if(a.start<=t&&t<=a.end)return a}}return null},e.detectEvictedFragments=function(t,e,r){var i=this;this.timeRanges&&(this.timeRanges[t]=e),Object.keys(this.fragments).forEach(function(n){var s=i.fragments[n];if(s){if(!s.buffered&&!s.loaded){s.body.type===r&&i.removeFragment(s.body);return}var a=s.range[t];a&&a.time.some(function(t){var r=!i.isTimeBuffered(t.startPTS,t.endPTS,e);return r&&i.removeFragment(s.body),r})}})},e.detectPartialFragments=function(t){var e=this,r=this.timeRanges,i=t.frag,n=t.part;if(r&&"initSegment"!==i.sn){var s=u(i),a=this.fragments[s];a&&(Object.keys(r).forEach(function(t){var s=i.elementaryStreams[t];if(s){var o=r[t],l=null!==n||!0===s.partial;a.range[t]=e.getBufferedTimes(i,n,l,o)}}),a.loaded=null,Object.keys(a.range).length?(a.buffered=!0,a.body.endList&&(this.endListFragments[a.body.type]=a)):this.removeFragment(a.body))}},e.fragBuffered=function(t){var e=u(t),r=this.fragments[e];r&&(r.loaded=null,r.buffered=!0)},e.getBufferedTimes=function(t,e,r,i){for(var n={time:[],partial:r},s=e?e.start:t.start,a=e?e.end:t.end,o=t.minEndPTS||a,l=t.maxStartPTS||s,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(s,i.start(u)),endPTS:Math.min(a,i.end(u))});break}if(s<c&&a>d)n.partial=!0,n.time.push({startPTS:Math.max(s,i.start(u)),endPTS:Math.min(a,i.end(u))});else if(a<=d)break}return n},e.getPartialFragment=function(t){var e,r,i,n=null,s=0,a=this.bufferPadding,o=this.fragments;return Object.keys(o).forEach(function(u){var d=o[u];d&&l(d)&&(r=d.body.start-a,i=d.body.end+a,t>=r&&t<=i&&s<=(e=Math.min(t-r,i-t))&&(n=d.body,s=e))}),n},e.isEndListAppended=function(t){var e=this.endListFragments[t];return void 0!==e&&(e.buffered||l(e))},e.getState=function(t){var e=u(t),r=this.fragments[e];return r?r.buffered?l(r)?n.PARTIAL:n.OK:n.APPENDING:n.NOT_LOADED},e.isTimeBuffered=function(t,e,r){for(var i,n,s=0;s<r.length;s++){if(i=r.start(s)-this.bufferPadding,n=r.end(s)+this.bufferPadding,t>=i&&e<=n)return!0;if(e<=i)break}return!1},e.onFragLoaded=function(t,e){var r=e.frag,i=e.part;if("initSegment"!==r.sn&&!r.bitrateTest&&!i){var n=u(r);this.fragments[n]={body:r,loaded:e,buffered:!1,range:Object.create(null)}}},e.onBufferAppended=function(t,e){var r=this,i=e.frag,n=e.part,s=e.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(t){var e=s[t];if(r.detectEvictedFragments(t,e),!n&&i.type===a.PlaylistLevelType.MAIN){var o=i.elementaryStreams[t];if(!o)return;for(var l=0;l<e.length;l++){var u=e.end(l);u<=o.endPTS&&u>o.startPTS?i.appendedPTS=Math.max(u,i.appendedPTS||0):i.appendedPTS=o.endPTS}}})},e.onFragBuffered=function(t,e){this.detectPartialFragments(e)},e.hasFragment=function(t){var e=u(t);return!!this.fragments[e]},e.removeFragmentsInRange=function(t,e,r){var i=this;Object.keys(this.fragments).forEach(function(n){var s=i.fragments[n];if(s&&s.buffered){var a=s.body;a.type===r&&a.start<e&&a.end>t&&i.removeFragment(a)}})},e.removeFragment=function(t){var e=u(t);t.stats.loaded=0,t.clearElementaryStreamInfo(),t.appendedPTS=void 0,delete this.fragments[e],t.endList&&delete this.endListFragments[t.type]},e.removeAllFragments=function(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activeFragment=null,this.activeParts=null},t}();function l(t){var e,r;return t.buffered&&((null===(e=t.range.video)||void 0===e?void 0:e.partial)||(null===(r=t.range.audio)||void 0===r?void 0:r.partial))}function u(t){return t.type+"_"+t.level+"_"+t.urlId+"_"+t.sn}},"./src/controller/gap-controller.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{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(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),n=r(/*! ../errors */"./src/errors.ts"),s=r(/*! ../events */"./src/events.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=250,l=2,u=.1,d=.05,c=function(){function t(t,e,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=t,this.media=e,this.fragmentTracker=r,this.hls=i}var e=t.prototype;return e.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},e.poll=function(t,e){var r=this.config,n=this.media,s=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!==t){if(this.moved=!0,null!==s){if(this.stallReported){var f=self.performance.now()-s;a.logger.warn("playback not stuck anymore @"+u+", after "+Math.round(f)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((h||c)&&(this.stalled=null),(!n.paused||d)&&!n.ended&&0!==n.playbackRate&&i.BufferHelper.getBuffered(n).length){var g=i.BufferHelper.bufferInfo(n,u,0),v=g.len>0,p=g.nextStart||0;if(v||p){if(d){var m=g.len>l,y=!p||e&&e.start<=u||p-u>l&&!this.fragmentTracker.getPartialFragment(u);if(m||y)return;this.moved=!1}if(!this.moved&&null!==this.stalled){var E,T=Math.max(p,g.start||0)-u,S=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,b=(null==S?void 0:null===(E=S.details)||void 0===E?void 0:E.live)?2*S.details.targetduration:l;if(T>0&&T<=b){this._trySkipBufferHole(null);return}}var L=self.performance.now();if(null===s){this.stalled=L;return}var D=L-s;if(d||!(D>=o)||(this._reportStall(g),this.media)){var A=i.BufferHelper.bufferInfo(n,u,r.maxBufferHole);this._tryFixBufferStall(A,D)}}}}},e._tryFixBufferStall=function(t,e){var r=this.config,i=this.fragmentTracker,n=this.media;if(null!==n){var s=n.currentTime,o=i.getPartialFragment(s);!(o&&(this._trySkipBufferHole(o)||!this.media))&&t.len>r.maxBufferHole&&e>1e3*r.highBufferWatchdogPeriod&&(a.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},e._reportStall=function(t){var e=this.hls,r=this.media;!this.stallReported&&r&&(this.stallReported=!0,a.logger.warn("Playback stalling at @"+r.currentTime+" due to low buffer ("+JSON.stringify(t)+")"),e.trigger(s.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:t.len}))},e._trySkipBufferHole=function(t){var e=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 g=h.start(f);if(l+e.maxBufferHole>=c&&l<g){var v=Math.max(g+d,o.currentTime+u);return a.logger.warn("skipping hole, adjusting currentTime from "+l+" to "+v),this.moved=!0,this.stalled=null,o.currentTime=v,t&&r.trigger(s.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 "+v,frag:t}),v}c=h.end(f)}return 0},e._tryNudgeBuffer=function(){var t=this.config,e=this.hls,r=this.media,i=this.nudgeRetry;if(null!==r){var o=r.currentTime;if(this.nudgeRetry++,i<t.nudgeMaxRetry){var l=o+(i+1)*t.nudgeOffset;a.logger.warn("Nudging 'currentTime' from "+o+" to "+l),r.currentTime=l,e.trigger(s.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else a.logger.error("Playhead still not moving while enough data buffered @"+o+" after "+t.nudgeMaxRetry+" nudges"),e.trigger(s.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})}},t}()},"./src/controller/id3-track-controller.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>f});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../events */"./src/events.ts"),s=r(/*! ../utils/texttrack-utils */"./src/utils/texttrack-utils.ts"),a=r(/*! ../demux/id3 */"./src/demux/id3.ts"),o=r(/*! ../loader/date-range */"./src/loader/date-range.ts"),l=r(/*! ../types/demuxer */"./src/types/demuxer.ts");function u(){return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}var d=function(){var t=u();try{new t(0,Number.POSITIVE_INFINITY,"")}catch(t){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function c(t,e){return t.getTime()/1e3-e}var h=function(){function t(t){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=t,this._registerListeners()}var e=t.prototype;return e.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},e._registerListeners=function(){var t=this.hls;t.on(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(n.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.on(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(n.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},e._unregisterListeners=function(){var t=this.hls;t.off(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(n.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.off(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(n.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},e.onMediaAttached=function(t,e){this.media=e.media},e.onMediaDetaching=function(){this.id3Track&&((0,s.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},e.onManifestLoading=function(){this.dateRangeCuesAppended={}},e.createTrack=function(t){var e=this.getID3Track(t.textTracks);return e.mode="hidden",e},e.getID3Track=function(t){if(this.media){for(var e=0;e<t.length;e++){var r=t[e];if("metadata"===r.kind&&"id3"===r.label)return(0,s.sendAddTrackEvent)(r,this.media),r}return this.media.addTextTrack("metadata","id3")}},e.onFragParsingMetadata=function(t,e){if(this.media){var r=this.hls.config,i=r.enableEmsgMetadataCues,n=r.enableID3MetadataCues;if(i||n){var s=e.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));for(var o=u(),c=0;c<s.length;c++){var h=s[c].type;if((h!==l.MetadataSchema.emsg||i)&&n){var f=a.getID3Frames(s[c].data);if(f){var g=s[c].pts,v=g+s[c].duration;v>d&&(v=d),v-g<=0&&(v=g+.25);for(var p=0;p<f.length;p++){var m=f[p];if(!a.isTimeStampFrame(m)){this.updateId3CueEnds(g);var y=new o(g,v,"");y.value=m,h&&(y.type=h),this.id3Track.addCue(y)}}}}}}}},e.updateId3CueEnds=function(t){var e,r=null===(e=this.id3Track)||void 0===e?void 0:e.cues;if(r)for(var i=r.length;i--;){var n=r[i];n.startTime<t&&n.endTime===d&&(n.endTime=t)}},e.onBufferFlushing=function(t,e){var r,i=e.startOffset,n=e.endOffset,a=e.type,o=this.id3Track,u=this.hls;if(u){var d=u.config,c=d.enableEmsgMetadataCues,h=d.enableID3MetadataCues;o&&(c||h)&&(r="audio"===a?function(t){return t.type===l.MetadataSchema.audioId3&&h}:"video"===a?function(t){return t.type===l.MetadataSchema.emsg&&c}:function(t){return t.type===l.MetadataSchema.audioId3&&h||t.type===l.MetadataSchema.emsg&&c},(0,s.removeCuesInRange)(o,i,n,r))}},e.onLevelUpdated=function(t,e){var r=this,n=e.details;if(this.media&&n.hasProgramDateTime&&this.hls.config.enableDateRangeMetadataCues){var s=this.dateRangeCuesAppended,a=this.id3Track,h=n.dateRanges,f=Object.keys(h);if(a)for(var g=Object.keys(s).filter(function(t){return!f.includes(t)}),v=g.length;v--;)!function(t){var e=g[t];Object.keys(s[e].cues).forEach(function(t){a.removeCue(s[e].cues[t])}),delete s[e]}(v);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 m=p.programDateTime/1e3-p.start,y=u(),E=0;E<f.length;E++)!function(t){var e=f[t],i=h[e],n=s[e],a=(null==n?void 0:n.cues)||{},u=(null==n?void 0:n.durationKnown)||!1,g=c(i.startDate,m),v=d,p=i.endDate;if(p)v=c(p,m),u=!0;else if(i.endOnNext&&!u){var E=f.reduce(function(t,e){var r=h[e];return r.class===i.class&&r.id!==e&&r.startDate>i.startDate&&t.push(r),t},[]).sort(function(t,e){return t.startDate.getTime()-e.startDate.getTime()})[0];E&&(v=c(E.startDate,m),u=!0)}for(var T=Object.keys(i.attr),S=0;S<T.length;S++){var b=T[S];if(b!==o.DateRangeAttribute.ID&&b!==o.DateRangeAttribute.CLASS&&b!==o.DateRangeAttribute.START_DATE&&b!==o.DateRangeAttribute.DURATION&&b!==o.DateRangeAttribute.END_DATE&&b!==o.DateRangeAttribute.END_ON_NEXT){var L=a[b];if(L)u&&!n.durationKnown&&(L.endTime=v);else{var D,A=i.attr[b];L=new y(g,v,""),(b===o.DateRangeAttribute.SCTE35_OUT||b===o.DateRangeAttribute.SCTE35_IN)&&(D=A,A=Uint8Array.from(D.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer),L.value={key:b,data:A},L.type=l.MetadataSchema.dateRange,r.id3Track.addCue(L),a[b]=L}}}s[e]={cues:a,dateRange:i,durationKnown:u}}(E)}}},t}();let f=h},"./src/controller/latency-controller.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>o});var i=r(/*! ../errors */"./src/errors.ts"),n=r(/*! ../events */"./src/events.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts");function a(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var i=r.call(t,e||"default");if("object"!=typeof i)return i;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(i.key),i)}}var o=function(){function t(t){var e=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 e.timeupdate()},this.hls=t,this.config=t.config,this.registerListeners()}var e,r,o=t.prototype;return o.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},o.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)},o.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)},o.onMediaAttached=function(t,e){this.media=e.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},o.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},o.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},o.onLevelUpdated=function(t,e){var r=e.details;this.levelDetails=r,r.advanced&&this.timeupdate(),!r.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},o.onError=function(t,e){e.details===i.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,s.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},o.timeupdate=function(){var t=this.media,e=this.levelDetails;if(t&&e){this.currentTime=t.currentTime;var r=this.computeLatency();if(null!==r){this._latency=r;var i=this.config,n=i.lowLatencyMode,s=i.maxLiveSyncPlaybackRate;if(n&&1!==s){var a=this.targetLatency;if(null!==a){var o=r-a,l=Math.min(this.maxLatency,a+e.targetduration);if(e.live&&o<l&&o>.05&&this.forwardBufferLength>1){var u=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;t.playbackRate=Math.min(Math.min(2,Math.max(1,s)),Math.max(1,u))}else 1!==t.playbackRate&&0!==t.playbackRate&&(t.playbackRate=1)}}}}},o.estimateLiveEdge=function(){var t=this.levelDetails;return null===t?null:t.edge+t.age},o.computeLatency=function(){var t=this.estimateLiveEdge();return null===t?null:t-this.currentTime},e=[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var t=this.config,e=this.levelDetails;return void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:e?t.liveMaxLatencyDurationCount*e.targetduration:0}},{key:"targetLatency",get:function(){var t=this.levelDetails;if(null===t)return null;var e=t.holdBack,r=t.partHoldBack,i=t.targetduration,n=this.config,s=n.liveSyncDuration,a=n.liveSyncDurationCount,o=n.lowLatencyMode,l=this.hls.userConfig,u=o&&r||e;return(l.liveSyncDuration||l.liveSyncDurationCount||0===u)&&(u=void 0!==s?s:a*i),u+Math.min(1*this.stallCount,i)}},{key:"liveSyncPosition",get:function(){var t=this.estimateLiveEdge(),e=this.targetLatency,r=this.levelDetails;if(null===t||null===e||null===r)return null;var i=r.edge,n=t-e-this.edgeStalled;return Math.min(Math.max(i-r.totalduration,n),i-(this.config.lowLatencyMode&&r.partTarget||r.targetduration))}},{key:"drift",get:function(){var t=this.levelDetails;return null===t?1:t.drift}},{key:"edgeStalled",get:function(){var t=this.levelDetails;if(null===t)return 0;var e=3*(this.config.lowLatencyMode&&t.partTarget||t.targetduration);return Math.max(t.age-e,0)}},{key:"forwardBufferLength",get:function(){var t=this.media,e=this.levelDetails;if(!t||!e)return 0;var r=t.buffered.length;return(r?t.buffered.end(r-1):e.edge)-this.currentTime}}],a(t.prototype,e),r&&a(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}()},"./src/controller/level-controller.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>g});var i=r(/*! ../types/level */"./src/types/level.ts"),n=r(/*! ../events */"./src/events.ts"),s=r(/*! ../errors */"./src/errors.ts"),a=r(/*! ../utils/codecs */"./src/utils/codecs.ts"),o=r(/*! ./level-helper */"./src/controller/level-helper.ts"),l=r(/*! ./base-playlist-controller */"./src/controller/base-playlist-controller.ts"),u=r(/*! ../types/loader */"./src/types/loader.ts");function d(){return(d=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t}).apply(this,arguments)}function c(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var i=r.call(t,e||"default");if("object"!=typeof i)return i;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(i.key),i)}}function h(t,e){return(h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}var f=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),g=function(t){function e(e){var r;return(r=t.call(this,e,"[level-controller]")||this)._levels=[],r._firstLevel=-1,r._startLevel=void 0,r.currentLevelIndex=-1,r.manualLevelIndex=-1,r.onParsedComplete=void 0,r._registerListeners(),r}e.prototype=Object.create(t.prototype),e.prototype.constructor=e,h(e,t);var r,l,g=e.prototype;return g._registerListeners=function(){var t=this.hls;t.on(n.Events.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(n.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(n.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(n.Events.FRAG_LOADED,this.onFragLoaded,this),t.on(n.Events.ERROR,this.onError,this)},g._unregisterListeners=function(){var t=this.hls;t.off(n.Events.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(n.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(n.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(n.Events.FRAG_LOADED,this.onFragLoaded,this),t.off(n.Events.ERROR,this.onError,this)},g.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,t.prototype.destroy.call(this)},g.startLoad=function(){this._levels.forEach(function(t){t.loadError=0}),t.prototype.startLoad.call(this)},g.onManifestLoaded=function(t,e){var r,l,u=[],d=[],c=[],h={},g=!1,v=!1,p=!1;if(e.levels.forEach(function(t){var e=t.attrs;g=g||!!(t.width&&t.height),v=v||!!t.videoCodec,p=p||!!t.audioCodec,f&&t.audioCodec&&-1!==t.audioCodec.indexOf("mp4a.40.34")&&(t.audioCodec=void 0);var r=t.bitrate+"-"+t.attrs.RESOLUTION+"-"+t.attrs.CODECS;(l=h[r])?l.url.push(t.url):(l=new i.Level(t),h[r]=l,u.push(l)),e&&(e.AUDIO&&(0,o.addGroupId)(l,"audio",e.AUDIO),e.SUBTITLES&&(0,o.addGroupId)(l,"text",e.SUBTITLES))}),(g||v)&&p&&(u=u.filter(function(t){var e=t.videoCodec,r=t.width,i=t.height;return!!e||!!(r&&i)})),u=u.filter(function(t){var e=t.audioCodec,r=t.videoCodec;return(!e||(0,a.isCodecSupportedInMp4)(e,"audio"))&&(!r||(0,a.isCodecSupportedInMp4)(r,"video"))}),e.audioTracks&&(d=e.audioTracks.filter(function(t){return!t.audioCodec||(0,a.isCodecSupportedInMp4)(t.audioCodec,"audio")}),(0,o.assignTrackIdsByGroup)(d)),e.subtitles&&(c=e.subtitles,(0,o.assignTrackIdsByGroup)(c)),u.length>0){r=u[0].bitrate,u.sort(function(t,e){return t.attrs["HDCP-LEVEL"]!==e.attrs["HDCP-LEVEL"]?(t.attrs["HDCP-LEVEL"]||"")>(e.attrs["HDCP-LEVEL"]||"")?1:-1:t.bitrate!==e.bitrate?t.bitrate-e.bitrate:t.attrs.SCORE!==e.attrs.SCORE?t.attrs.decimalFloatingPoint("SCORE")-e.attrs.decimalFloatingPoint("SCORE"):g&&t.height!==e.height?t.height-e.height:0}),this._levels=u;for(var m=0;m<u.length;m++)if(u[m].bitrate===r){this._firstLevel=m,this.log("manifest loaded, "+u.length+" level(s) found, first bitrate: "+r);break}var y=p&&!v,E={levels:u,audioTracks:d,subtitleTracks:c,sessionData:e.sessionData,sessionKeys:e.sessionKeys,firstLevel:this._firstLevel,stats:e.stats,audio:p,video:v,altAudio:!y&&d.some(function(t){return!!t.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:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:e.url,reason:"no level with compatible codecs found in manifest"})},g.onError=function(e,r){if(t.prototype.onError.call(this,e,r),!r.fatal){var n,a,o,l=r.context,d=this._levels[this.currentLevelIndex];if(l&&(l.type===u.PlaylistContextType.AUDIO_TRACK&&d.audioGroupIds&&l.groupId===d.audioGroupIds[d.urlId]||l.type===u.PlaylistContextType.SUBTITLE_TRACK&&d.textGroupIds&&l.groupId===d.textGroupIds[d.urlId])){this.redundantFailover(this.currentLevelIndex);return}var c=!1,h=!0;switch(r.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:if(r.frag){var f=r.frag.type===u.PlaylistLevelType.MAIN?r.frag.level:this.currentLevelIndex,g=this._levels[f];g?(g.fragmentError++,g.fragmentError>this.hls.config.fragLoadingMaxRetry&&(o=f)):o=f}break;case s.ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:var v=d.attrs["HDCP-LEVEL"];v&&(this.hls.maxHdcpLevel=i.HdcpLevels[i.HdcpLevels.indexOf(v)-1],this.warn('Restricting playback to HDCP-LEVEL of "'+this.hls.maxHdcpLevel+'" or lower'));case s.ErrorDetails.FRAG_PARSING_ERROR:case s.ErrorDetails.KEY_SYSTEM_NO_SESSION:o=(null===(n=r.frag)||void 0===n?void 0:n.type)===u.PlaylistLevelType.MAIN?r.frag.level:this.currentLevelIndex,r.levelRetry=!1;break;case s.ErrorDetails.LEVEL_LOAD_ERROR:case s.ErrorDetails.LEVEL_LOAD_TIMEOUT:l&&(l.deliveryDirectives&&(h=!1),o=l.level),c=!0;break;case s.ErrorDetails.REMUX_ALLOC_ERROR:o=null!=(a=r.level)?a:this.currentLevelIndex,c=!0}void 0!==o&&this.recoverLevel(r,o,c,h)}},g.recoverLevel=function(t,e,r,i){var n=t.details,s=this._levels[e];if(s.loadError++,r){if(this.retryLoadingOrFail(t))t.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(i){var a=s.url.length;if(a>1&&s.loadError<a)t.levelRetry=!0,this.redundantFailover(e);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),t.levelRetry=!0,this.hls.nextAutoLevel=o):!1===t.levelRetry&&(t.fatal=!0)}}},g.redundantFailover=function(t){var e=this._levels[t],r=e.url.length;if(r>1){var i=(e.urlId+1)%r;this.warn("Switching to redundant URL-id "+i),this._levels.forEach(function(t){t.urlId=i}),this.level=t}},g.onFragLoaded=function(t,e){var r=e.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)}},g.onLevelLoaded=function(t,e){var r,i,n=e.level,s=e.details,a=this._levels[n];if(!a){this.warn("Invalid level index "+n),null!==(i=e.deliveryDirectives)&&void 0!==i&&i.skip&&(s.deltaUpdateFailed=!0);return}n===this.currentLevelIndex?(0===a.fragmentError&&(a.loadError=0,this.retryCount=0),this.playlistLoaded(n,e,a.details)):null!==(r=e.deliveryDirectives)&&void 0!==r&&r.skip&&(s.deltaUpdateFailed=!0)},g.onAudioTrackSwitched=function(t,e){var r=this.hls.levels[this.currentLevelIndex];if(r&&r.audioGroupIds){for(var i=-1,n=this.hls.audioTracks[e.id].groupId,s=0;s<r.audioGroupIds.length;s++)if(r.audioGroupIds[s]===n){i=s;break}i!==r.urlId&&(r.urlId=i,this.startLoad())}},g.loadPlaylist=function(e){t.prototype.loadPlaylist.call(this);var r=this.currentLevelIndex,i=this._levels[r];if(this.canLoad&&i&&i.url.length>0){var s=i.urlId,a=i.url[s];if(e)try{a=e.addDirectives(a)}catch(t){this.warn("Could not construct new URL with HLS Delivery Directives: "+t)}this.log("Attempt loading level index "+r+((null==e?void 0:e.msn)!==void 0?" at sn "+e.msn+" part "+e.part:"")+" with URL-id "+s+" "+a),this.clearTimer(),this.hls.trigger(n.Events.LEVEL_LOADING,{url:a,level:r,id:s,deliveryDirectives:e||null})}},g.removeLevel=function(t,e){var r=function(t,r){return r!==e},i=this._levels.filter(function(i,n){return n!==t||i.url.length>1&&void 0!==e&&(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(t,e){var r=t.details;return null!=r&&r.fragments&&r.fragments.forEach(function(t){t.level=e}),t});this._levels=i,this.hls.trigger(n.Events.LEVELS_UPDATED,{levels:i})},r=[{key:"levels",get:function(){return 0===this._levels.length?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(t){var e,r=this._levels;if(0!==r.length&&(this.currentLevelIndex!==t||null===(e=r[t])||void 0===e||!e.details)){if(t<0||t>=r.length){var i=t<0;if(this.hls.trigger(n.Events.ERROR,{type:s.ErrorTypes.OTHER_ERROR,details:s.ErrorDetails.LEVEL_SWITCH_ERROR,level:t,fatal:i,reason:"invalid level idx"}),i)return;t=Math.min(t,r.length-1)}this.clearTimer();var a=this.currentLevelIndex,o=r[a],l=r[t];this.log("switching to level "+t+" from "+a),this.currentLevelIndex=t;var u=d({},l,{level:t,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(t){this.manualLevelIndex=t,void 0===this._startLevel&&(this._startLevel=t),-1!==t&&(this.level=t)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(t){this._firstLevel=t}},{key:"startLevel",get:function(){if(void 0!==this._startLevel)return this._startLevel;var t=this.hls.config.startLevel;return void 0!==t?t:this._firstLevel},set:function(t){this._startLevel=t}},{key:"nextLoadLevel",get:function(){return -1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(t){this.level=t,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=t)}}],c(e.prototype,r),l&&c(e,l),Object.defineProperty(e,"prototype",{writable:!1}),e}(l.default)},"./src/controller/level-helper.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{addGroupId:()=>o,addSliding:()=>p,adjustSliding:()=>v,assignTrackIdsByGroup:()=>l,computeReloadInterval:()=>m,getFragmentWithSN:()=>y,getPartWith:()=>E,mapFragmentIntersection:()=>g,mapPartIntersection:()=>f,mergeDetails:()=>h,updateFragPTSDTS:()=>c,updatePTS:()=>u});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../utils/logger */"./src/utils/logger.ts"),s=r(/*! ../loader/date-range */"./src/loader/date-range.ts");function a(){return(a=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t}).apply(this,arguments)}function o(t,e,r){switch(e){case"audio":t.audioGroupIds||(t.audioGroupIds=[]),t.audioGroupIds.push(r);break;case"text":t.textGroupIds||(t.textGroupIds=[]),t.textGroupIds.push(r)}}function l(t){var e={};t.forEach(function(t){var r=t.groupId||"";t.id=e[r]=e[r]||0,e[r]++})}function u(t,e,r){d(t[e],t[r])}function d(t,e){var r=e.startPTS;if((0,i.isFiniteNumber)(r)){var n,s=0;e.sn>t.sn?(s=r-t.start,n=t):(s=t.start-r,n=e),n.duration!==s&&(n.duration=s)}else e.sn>t.sn?t.cc===e.cc&&t.minEndPTS?e.start=t.start+(t.minEndPTS-t.start):e.start=t.start+t.duration:e.start=Math.max(t.start-e.duration,0)}function c(t,e,r,s,a,o){s-r<=0&&(n.logger.warn("Fragment should have a positive duration",e),s=r+e.duration,o=a+e.duration);var l,u=r,c=s,h=e.startPTS,f=e.endPTS;if((0,i.isFiniteNumber)(h)){var g=Math.abs(h-r);(0,i.isFiniteNumber)(e.deltaPTS)?e.deltaPTS=Math.max(g,e.deltaPTS):e.deltaPTS=g,u=Math.max(r,h),r=Math.min(r,h),a=Math.min(a,e.startDTS),c=Math.min(s,f),s=Math.max(s,f),o=Math.max(o,e.endDTS)}e.duration=s-r;var v=r-e.start;e.start=e.startPTS=r,e.maxStartPTS=u,e.startDTS=a,e.endPTS=s,e.minEndPTS=c,e.endDTS=o;var p=e.sn;if(!t||p<t.startSN||p>t.endSN)return 0;var m=p-t.startSN,y=t.fragments;for(y[m]=e,l=m;l>0;l--)d(y[l],y[l-1]);for(l=m;l<y.length-1;l++)d(y[l],y[l+1]);return t.fragmentHint&&d(y[y.length-1],t.fragmentHint),t.PTSKnown=t.alignedSliding=!0,v}function h(t,e){for(var r,o=null,l=t.fragments,u=l.length-1;u>=0;u--){var d=l[u].initSegment;if(d){o=d;break}}t.fragmentHint&&delete t.fragmentHint.endPTS;var h=0;if(g(t,e,function(t,n){t.relurl&&(h=t.cc-n.cc),(0,i.isFiniteNumber)(t.startPTS)&&(0,i.isFiniteNumber)(t.endPTS)&&(n.start=n.startPTS=t.startPTS,n.startDTS=t.startDTS,n.appendedPTS=t.appendedPTS,n.maxStartPTS=t.maxStartPTS,n.endPTS=t.endPTS,n.endDTS=t.endDTS,n.minEndPTS=t.minEndPTS,n.duration=t.endPTS-t.startPTS,n.duration&&(r=n),e.PTSKnown=e.alignedSliding=!0),n.elementaryStreams=t.elementaryStreams,n.loader=t.loader,n.stats=t.stats,n.urlId=t.urlId,t.initSegment&&(n.initSegment=t.initSegment,o=t.initSegment)}),o&&(e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments).forEach(function(t){var e;t.initSegment&&t.initSegment.relurl!==(null===(e=o)||void 0===e?void 0:e.relurl)||(t.initSegment=o)}),e.skippedSegments){if(e.deltaUpdateFailed=e.fragments.some(function(t){return!t}),e.deltaUpdateFailed){n.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var p,m,y,E,T=e.skippedSegments;T--;)e.fragments.shift();e.startSN=e.fragments[0].sn,e.startCC=e.fragments[0].cc}else e.canSkipDateRanges&&(e.dateRanges=(p=t.dateRanges,m=e.dateRanges,y=e.recentlyRemovedDateranges,E=a({},p),y&&y.forEach(function(t){delete E[t]}),Object.keys(m).forEach(function(t){var e=new s.DateRange(m[t].attr,E[t]);e.isValid?E[t]=e:n.logger.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(m[t].attr)+'"')}),E))}var S=e.fragments;if(h){n.logger.warn("discontinuity sliding from playlist, take drift into account");for(var b=0;b<S.length;b++)S[b].cc+=h}e.skippedSegments&&(e.startCC=e.fragments[0].cc),f(t.partList,e.partList,function(t,e){e.elementaryStreams=t.elementaryStreams,e.stats=t.stats}),r?c(e,r,r.startPTS,r.endPTS,r.startDTS,r.endDTS):v(t,e),S.length&&(e.totalduration=e.edge-S[0].start),e.driftStartTime=t.driftStartTime,e.driftStart=t.driftStart;var L=e.advancedDateTime;if(e.advanced&&L){var D=e.edge;e.driftStart||(e.driftStartTime=L,e.driftStart=D),e.driftEndTime=L,e.driftEnd=D}else e.driftEndTime=t.driftEndTime,e.driftEnd=t.driftEnd,e.advancedDateTime=t.advancedDateTime}function f(t,e,r){if(t&&e)for(var i=0,n=0,s=t.length;n<=s;n++){var a=t[n],o=e[n+i];a&&o&&a.index===o.index&&a.fragment.sn===o.fragment.sn?r(a,o):i--}}function g(t,e,r){for(var i=e.skippedSegments,n=Math.max(t.startSN,e.startSN)-e.startSN,s=(t.fragmentHint?1:0)+(i?e.endSN:Math.min(t.endSN,e.endSN))-e.startSN,a=e.startSN-t.startSN,o=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,u=n;u<=s;u++){var d=l[a+u],c=o[u];i&&!c&&u<i&&(c=e.fragments[u]=d),d&&c&&r(d,c)}}function v(t,e){var r=e.startSN+e.skippedSegments-t.startSN,i=t.fragments;r<0||r>=i.length||p(e,i[r].start)}function p(t,e){if(e){for(var r=t.fragments,i=t.skippedSegments;i<r.length;i++)r[i].start+=e;t.fragmentHint&&(t.fragmentHint.start+=e)}}function m(t,e){void 0===e&&(e=1/0);var r=1e3*t.targetduration;if(t.updated){var i=t.fragments;if(i.length&&4*r>e){var n=1e3*i[i.length-1].duration;n<r&&(r=n)}}else r/=2;return Math.round(r)}function y(t,e,r){if(!t||!t.details)return null;var i=t.details,n=i.fragments[e-i.startSN];return n||(n=i.fragmentHint)&&n.sn===e?n:e<i.startSN&&r&&r.sn===e?r:null}function E(t,e,r){if(!t||!t.details)return null;var i=t.details.partList;if(i)for(var n=i.length;n--;){var s=i[n];if(s.index===r&&s.fragment.sn===e)return s}return null}},"./src/controller/stream-controller.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>m});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ./base-stream-controller */"./src/controller/base-stream-controller.ts"),s=r(/*! ../is-supported */"./src/is-supported.ts"),a=r(/*! ../events */"./src/events.ts"),o=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),l=r(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),u=r(/*! ../types/loader */"./src/types/loader.ts"),d=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),c=r(/*! ../demux/transmuxer-interface */"./src/demux/transmuxer-interface.ts"),h=r(/*! ../types/transmuxer */"./src/types/transmuxer.ts"),f=r(/*! ./gap-controller */"./src/controller/gap-controller.ts"),g=r(/*! ../errors */"./src/errors.ts");function v(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var i=r.call(t,e||"default");if("object"!=typeof i)return i;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(i.key),i)}}function p(t,e){return(p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}var m=function(t){function e(e,r,i){var n;return(n=t.call(this,e,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}e.prototype=Object.create(t.prototype),e.prototype.constructor=e,p(e,t);var r,m,y=e.prototype;return y._registerListeners=function(){var t=this.hls;t.on(a.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(a.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(a.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(a.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(a.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(a.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(a.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(a.Events.ERROR,this.onError,this),t.on(a.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(a.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(a.Events.BUFFER_CREATED,this.onBufferCreated,this),t.on(a.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(a.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(a.Events.FRAG_BUFFERED,this.onFragBuffered,this)},y._unregisterListeners=function(){var t=this.hls;t.off(a.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(a.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(a.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(a.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(a.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(a.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(a.Events.ERROR,this.onError,this),t.off(a.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(a.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(a.Events.BUFFER_CREATED,this.onBufferCreated,this),t.off(a.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(a.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(a.Events.FRAG_BUFFERED,this.onFragBuffered,this)},y.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},y.startLoad=function(t){if(this.levels){var e=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}e>0&&-1===t&&(this.log("Override startPosition with lastCurrentTime @"+e.toFixed(3)),t=e),this.state=n.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=n.State.STOPPED},y.stopLoad=function(){this._forceStartLoad=!1,t.prototype.stopLoad.call(this)},y.doTick=function(){switch(this.state){case n.State.IDLE:this.doTickIdle();break;case n.State.WAITING_LEVEL:var t,e=this.levels,r=this.level,i=null==e?void 0:null===(t=e[r])||void 0===t?void 0:t.details;if(i&&(!i.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(i))break;this.state=n.State.IDLE}break;case n.State.FRAG_LOADING_WAITING_RETRY:var s,a=self.performance.now(),o=this.retryDate;(!o||a>=o||null!==(s=this.media)&&void 0!==s&&s.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.level),this.state=n.State.IDLE)}this.onTickEnd()},y.onTickEnd=function(){t.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},y.doTickIdle=function(){var t=this.hls,e=this.levelLastLoaded,r=this.levels,i=this.media,s=t.config,o=t.nextLoadLevel;if(null!==e&&(i||!this.startFragRequested&&s.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 g={};this.altAudio&&(g.type="video"),this.hls.trigger(a.Events.BUFFER_EOS,g),this.state=n.State.ENDED;return}this.level=t.nextLoadLevel=o;var v=c.details;if(!v||this.state===n.State.WAITING_LEVEL||v.live&&this.levelLastLoaded!==o){this.level=o,this.state=n.State.WAITING_LEVEL;return}if(!(h.len>=this.getMaxBufferLength(c.maxBitrate))){this.backtrackFragment&&this.backtrackFragment.start>h.end&&(this.backtrackFragment=null);var p=this.backtrackFragment?this.backtrackFragment.start:h.end,m=this.getNextFragment(p,v);if(this.couldBacktrack&&!this.fragPrevious&&m&&"initSegment"!==m.sn&&this.fragmentTracker.getState(m)!==l.FragmentState.OK){var y,E=(null!=(y=this.backtrackFragment)?y:m).sn-v.startSN,T=v.fragments[E-1];T&&m.cc===T.cc&&(m=T,this.fragmentTracker.removeFragment(T))}else this.backtrackFragment&&h.len&&(this.backtrackFragment=null);if(m&&this.fragmentTracker.getState(m)===l.FragmentState.OK&&this.nextLoadPosition>p){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),m=this.getNextFragment(this.nextLoadPosition,v)}m&&(!m.initSegment||m.initSegment.data||this.bitrateTest||(m=m.initSegment),this.loadFragment(m,v,p))}}}},y.loadFragment=function(e,r,i){var n,s=this.fragmentTracker.getState(e);this.fragCurrent=e,s===l.FragmentState.NOT_LOADED?"initSegment"===e.sn?this._loadInitSegment(e,r):this.bitrateTest?(this.log("Fragment "+e.sn+" of level "+e.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(e,r)):(this.startFragRequested=!0,t.prototype.loadFragment.call(this,e,r,i)):s===l.FragmentState.APPENDING?this.reduceMaxBufferLength(e.duration)&&this.fragmentTracker.removeFragment(e):(null===(n=this.media)||void 0===n?void 0:n.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},y.getAppendedFrag=function(t){var e=this.fragmentTracker.getAppendedFrag(t,u.PlaylistLevelType.MAIN);return e&&"fragment"in e?e.fragment:e},y.getBufferedFrag=function(t){return this.fragmentTracker.getBufferedFrag(t,u.PlaylistLevelType.MAIN)},y.followingBufferedFrag=function(t){return t?this.getBufferedFrag(t.end+.5):null},y.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},y.nextLevelSwitch=function(){var t=this.levels,e=this.media;if(null!=e&&e.readyState){var r,i=this.getAppendedFrag(e.currentTime);if(i&&i.start>1&&this.flushMainBuffer(0,i.start-1),!e.paused&&t){var n=t[this.hls.nextLoadLevel],s=this.fragLastKbps;r=s&&this.fragCurrent?this.fragCurrent.duration*n.maxBitrate/(1e3*s)+1:0}else r=0;var a=this.getBufferedFrag(e.currentTime+r);if(a){var o=this.followingBufferedFrag(a);if(o){this.abortCurrentFrag();var l=o.maxStartPTS?o.maxStartPTS:o.start,u=o.duration,d=Math.max(a.end,l+Math.min(Math.max(u-this.config.maxFragLookUpTolerance,.5*u),.75*u));this.flushMainBuffer(d,Number.POSITIVE_INFINITY)}}}},y.abortCurrentFrag=function(){var t=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,t&&t.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()},y.flushMainBuffer=function(e,r){t.prototype.flushMainBuffer.call(this,e,r,this.altAudio?"video":null)},y.onMediaAttached=function(e,r){t.prototype.onMediaAttached.call(this,e,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)},y.onMediaDetaching=function(){var e=this.media;e&&this.onvplaying&&this.onvseeked&&(e.removeEventListener("playing",this.onvplaying),e.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),t.prototype.onMediaDetaching.call(this)},y.onMediaPlaying=function(){this.tick()},y.onMediaSeeked=function(){var t=this.media,e=t?t.currentTime:null;(0,i.isFiniteNumber)(e)&&this.log("Media seeked to "+e.toFixed(3)),this.tick()},y.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(a.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null,this.backtrackFragment=null},y.onManifestParsed=function(t,e){var r,i=!1,n=!1;e.levels.forEach(function(t){(r=t.audioCodec)&&(-1!==r.indexOf("mp4a.40.2")&&(i=!0),-1!==r.indexOf("mp4a.40.5")&&(n=!0))}),this.audioCodecSwitch=i&&n&&!(0,s.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=e.levels,this.startFragRequested=!1},y.onLevelLoading=function(t,e){var r=this.levels;if(r&&this.state===n.State.IDLE){var i=r[e.level];(!i.details||i.details.live&&this.levelLastLoaded!==e.level||this.waitForCdnTuneIn(i.details))&&(this.state=n.State.WAITING_LEVEL)}},y.onLevelLoaded=function(t,e){var r,i=this.levels,s=e.level,o=e.details,l=o.totalduration;if(!i){this.warn("Levels were reset while loading level "+s);return}this.log("Level "+s+" 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!==e.level&&u.loader&&(this.state=n.State.IDLE,this.backtrackFragment=null,u.abortRequests());var d=i[s],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=s,this.hls.trigger(a.Events.LEVEL_UPDATED,{details:o,level:s}),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()},y._handleFragmentLoadProgress=function(t){var e,r=t.frag,i=t.part,n=t.payload,s=this.levels;if(!s){this.warn("Levels were reset while fragment load was in progress. Fragment "+r.sn+" of level "+r.level+" will not be buffered");return}var a=s[r.level],o=a.details;if(!o){this.warn("Dropping fragment "+r.sn+" of level "+r.level+" after level details were reset");return}var l=a.videoCodec,d=o.PTSKnown||!o.live,f=null===(e=r.initSegment)||void 0===e?void 0:e.data,g=this._getAudioCodec(a),v=this.transmuxer=this.transmuxer||new c.default(this.hls,u.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),p=i?i.index:-1,m=-1!==p,y=new h.ChunkMetadata(r.level,r.sn,r.stats.chunkCount,n.byteLength,p,m),E=this.initPTS[r.cc];v.push(n,f,g,l,r,i,o.totalduration,d,y,E)},y.onAudioTrackSwitching=function(t,e){var r=this.altAudio,i=!!e.url,n=e.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 s=this.fragCurrent;s&&(this.log("Switching to main audio track, cancel main fragment load"),s.abortRequests()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var o=this.hls;r&&o.trigger(a.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),o.trigger(a.Events.AUDIO_TRACK_SWITCHED,{id:n})}},y.onAudioTrackSwitched=function(t,e){var r=e.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()},y.onBufferCreated=function(t,e){var r,i,n=e.tracks,s=!1;for(var a in n){var o=n[a];if("main"===o.id){if(i=a,r=o,"video"===a){var l=n[a];l&&(this.videoBuffer=l.buffer)}}else s=!0}s&&r?(this.log("Alternate track found, use "+i+".buffered to schedule main fragment loading"),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media},y.onFragBuffered=function(t,e){var r=e.frag,i=e.part;if(!r||r.type===u.PlaylistLevelType.MAIN){if(this.fragContextChanged(r)){this.warn("Fragment "+r.sn+(i?" p: "+i.index:"")+" of level "+r.level+" finished buffering, but was aborted. state: "+this.state),this.state===n.State.PARSED&&(this.state=n.State.IDLE);return}var s=i?i.stats:r.stats;this.fragLastKbps=Math.round(8*s.total/(s.buffering.end-s.loading.first)),"initSegment"!==r.sn&&(this.fragPrevious=r),this.fragBufferedComplete(r,i)}},y.onError=function(t,e){if(e.type===g.ErrorTypes.KEY_SYSTEM_ERROR){this.onFragmentOrKeyLoadError(u.PlaylistLevelType.MAIN,e);return}switch(e.details){case g.ErrorDetails.FRAG_LOAD_ERROR:case g.ErrorDetails.FRAG_LOAD_TIMEOUT:case g.ErrorDetails.FRAG_PARSING_ERROR:case g.ErrorDetails.KEY_LOAD_ERROR:case g.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(u.PlaylistLevelType.MAIN,e);break;case g.ErrorDetails.LEVEL_LOAD_ERROR:case g.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state===n.State.ERROR||(e.fatal?(this.warn(""+e.details),this.state=n.State.ERROR):e.levelRetry||this.state!==n.State.WAITING_LEVEL||(this.state=n.State.IDLE));break;case g.ErrorDetails.BUFFER_FULL_ERROR:if("main"===e.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()}}},y.checkBuffer=function(){var t=this.media,e=this.gapController;if(t&&e&&t.readyState){if(this.loadedmetadata||!o.BufferHelper.getBuffered(t).length){var r=this.state!==n.State.IDLE?this.fragCurrent:null;e.poll(this.lastCurrentTime,r)}this.lastCurrentTime=t.currentTime}},y.onFragLoadEmergencyAborted=function(){this.state=n.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},y.onBufferFlushed=function(t,e){var r=e.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)}},y.onLevelsUpdated=function(t,e){this.levels=e.levels},y.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},y.seekToStartPos=function(){var t=this.media;if(t){var e=t.currentTime,r=this.startPosition;if(r>=0&&e<r){if(t.seeking){this.log("could not seek to "+r+", already seeking at "+e);return}var i=o.BufferHelper.getBuffered(t),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 "+e),t.currentTime=r}}},y._getAudioCodec=function(t){var e=this.config.defaultAudioCodec||t.audioCodec;return this.audioCodecSwap&&e&&(this.log("Swapping audio codec"),e=-1!==e.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),e},y._loadBitrateTestFrag=function(t,e){var r=this;t.bitrateTest=!0,this._doFragLoad(t,e).then(function(e){var i=r.hls;if(!(!e||r.fragContextChanged(t))){r.fragLoadError=0,r.state=n.State.IDLE,r.startFragRequested=!1,r.bitrateTest=!1;var s=t.stats;s.parsing.start=s.parsing.end=s.buffering.start=s.buffering.end=self.performance.now(),i.trigger(a.Events.FRAG_LOADED,e),t.bitrateTest=!1}})},y._handleTransmuxComplete=function(t){var e,r="main",s=this.hls,o=t.remuxResult,l=t.chunkMeta,u=this.getCurrentContext(l);if(!u){this.warn("The loading context changed while buffering fragment "+l.sn+" of level "+l.level+". This chunk will not be buffered."),this.resetStartWhenNotLoaded(l.level);return}var c=u.frag,h=u.part,f=u.level,g=o.video,v=o.text,p=o.id3,m=o.initSegment,y=f.details,E=this.altAudio?void 0:o.audio;if(!this.fragContextChanged(c)){if(this.state=n.State.PARSING,m){m.tracks&&(this._bufferInitSegment(f,m.tracks,c,l),s.trigger(a.Events.FRAG_PARSING_INIT_SEGMENT,{frag:c,id:r,tracks:m.tracks}));var T=m.initPTS,S=m.timescale;(0,i.isFiniteNumber)(T)&&(this.initPTS[c.cc]=T,s.trigger(a.Events.INIT_PTS_FOUND,{frag:c,id:r,initPTS:T,timescale:S}))}if(g&&!1!==o.independent){if(y){var b=g.startPTS,L=g.endPTS,D=g.startDTS,A=g.endDTS;if(h)h.elementaryStreams[g.type]={startPTS:b,endPTS:L,startDTS:D,endDTS:A};else if(g.firstKeyFrame&&g.independent&&1===l.id&&(this.couldBacktrack=!0),g.dropped&&g.independent){var k=this.getMainFwdBufferInfo();if((k?k.end:this.getLoadPosition())+this.config.maxBufferHole<(g.firstKeyFramePTS?g.firstKeyFramePTS:b)-this.config.maxBufferHole){this.backtrack(c);return}c.setElementaryStreamInfo(g.type,c.start,L,c.start,A,!0)}c.setElementaryStreamInfo(g.type,b,L,D,A),this.backtrackFragment&&(this.backtrackFragment=c),this.bufferFragmentData(g,c,h,l)}}else if(!1===o.independent){this.backtrack(c);return}if(E){var I=E.startPTS,R=E.endPTS,C=E.startDTS,_=E.endDTS;h&&(h.elementaryStreams[d.ElementaryStreamTypes.AUDIO]={startPTS:I,endPTS:R,startDTS:C,endDTS:_}),c.setElementaryStreamInfo(d.ElementaryStreamTypes.AUDIO,I,R,C,_),this.bufferFragmentData(E,c,h,l)}if(y&&null!=p&&null!==(e=p.samples)&&void 0!==e&&e.length){var P={id:r,frag:c,details:y,samples:p.samples};s.trigger(a.Events.FRAG_PARSING_METADATA,P)}if(y&&v){var O={id:r,frag:c,details:y,samples:v.samples};s.trigger(a.Events.FRAG_PARSING_USERDATA,O)}}},y._bufferInitSegment=function(t,e,r,i){var s=this;if(this.state===n.State.PARSING){this.audioOnly=!!e.audio&&!e.video,this.altAudio&&!this.audioOnly&&delete e.audio;var o=e.audio,l=e.video,u=e.audiovideo;if(o){var d=t.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)),t.audioCodec&&t.audioCodec!==d&&this.log('Swapping manifest audio codec "'+t.audioCodec+'" for "'+d+'"'),o.levelCodec=d,o.id="main",this.log("Init audio buffer, container:"+o.container+", codecs[selected/level/parsed]=["+(d||"")+"/"+(t.audioCodec||"")+"/"+o.codec+"]")}l&&(l.levelCodec=t.videoCodec,l.id="main",this.log("Init video buffer, container:"+l.container+", codecs[level/parsed]=["+(t.videoCodec||"")+"/"+l.codec+"]")),u&&this.log("Init audiovideo buffer, container:"+u.container+", codecs[level/parsed]=["+(t.attrs.CODECS||"")+"/"+u.codec+"]"),this.hls.trigger(a.Events.BUFFER_CODECS,e),Object.keys(e).forEach(function(t){var n=e[t].initSegment;null!=n&&n.byteLength&&s.hls.trigger(a.Events.BUFFER_APPENDING,{type:t,data:n,frag:r,part:null,chunkMeta:i,parent:r.type})}),this.tick()}},y.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,u.PlaylistLevelType.MAIN)},y.backtrack=function(t){this.couldBacktrack=!0,this.backtrackFragment=t,this.resetTransmuxer(),this.flushBufferGap(t),this.fragmentTracker.removeFragment(t),this.fragPrevious=null,this.nextLoadPosition=t.start,this.state=n.State.IDLE},y.checkFragmentChanged=function(){var t=this.media,e=null;if(t&&t.readyState>1&&!1===t.seeking){var r=t.currentTime;if(o.BufferHelper.isBuffered(t,r)?e=this.getAppendedFrag(r):o.BufferHelper.isBuffered(t,r+.1)&&(e=this.getAppendedFrag(r+.1)),e){this.backtrackFragment=null;var i=this.fragPlaying,n=e.level;i&&e.sn===i.sn&&i.level===n&&e.urlId===i.urlId||(this.fragPlaying=e,this.hls.trigger(a.Events.FRAG_CHANGED,{frag:e}),i&&i.level===n||this.hls.trigger(a.Events.LEVEL_SWITCHED,{level:n}))}}},r=[{key:"nextLevel",get:function(){var t=this.nextBufferedFrag;return t?t.level:-1}},{key:"currentFrag",get:function(){var t=this.media;return t?this.fragPlaying||this.getAppendedFrag(t.currentTime):null}},{key:"currentProgramDateTime",get:function(){var t=this.media;if(t){var e=t.currentTime,r=this.currentFrag;if(r&&(0,i.isFiniteNumber)(e)&&(0,i.isFiniteNumber)(r.programDateTime)){var n=r.programDateTime+(e-r.start)*1e3;return new Date(n)}}return null}},{key:"currentLevel",get:function(){var t=this.currentFrag;return t?t.level:-1}},{key:"nextBufferedFrag",get:function(){var t=this.currentFrag;return t?this.followingBufferedFrag(t):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}],v(e.prototype,r),m&&v(e,m),Object.defineProperty(e,"prototype",{writable:!1}),e}(n.default)},"./src/controller/subtitle-stream-controller.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{SubtitleStreamController:()=>g});var i=r(/*! ../events */"./src/events.ts"),n=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),s=r(/*! ./fragment-finders */"./src/controller/fragment-finders.ts"),a=r(/*! ../utils/discontinuities */"./src/utils/discontinuities.ts"),o=r(/*! ./level-helper */"./src/controller/level-helper.ts"),l=r(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),u=r(/*! ./base-stream-controller */"./src/controller/base-stream-controller.ts"),d=r(/*! ../types/loader */"./src/types/loader.ts"),c=r(/*! ../types/level */"./src/types/level.ts");function h(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var i=r.call(t,e||"default");if("object"!=typeof i)return i;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(i.key),i)}}function f(t,e){return(f=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}var g=function(t){function e(e,r,i){var n;return(n=t.call(this,e,r,i,"[subtitle-stream-controller]")||this).levels=[],n.currentTrackId=-1,n.tracksBuffered=[],n.mainDetails=null,n._registerListeners(),n}e.prototype=Object.create(t.prototype),e.prototype.constructor=e,f(e,t);var r,g,p=e.prototype;return p.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},p._registerListeners=function(){var t=this.hls;t.on(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(i.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(i.Events.ERROR,this.onError,this),t.on(i.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(i.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.on(i.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(i.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.on(i.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(i.Events.FRAG_BUFFERED,this.onFragBuffered,this)},p._unregisterListeners=function(){var t=this.hls;t.off(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(i.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(i.Events.ERROR,this.onError,this),t.off(i.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(i.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.off(i.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(i.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.off(i.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(i.Events.FRAG_BUFFERED,this.onFragBuffered,this)},p.startLoad=function(t){this.stopLoad(),this.state=u.State.IDLE,this.setInterval(500),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()},p.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},p.onLevelLoaded=function(t,e){this.mainDetails=e.details},p.onSubtitleFragProcessed=function(t,e){var r,i=e.frag,n=e.success;if(this.fragPrevious=i,this.state=u.State.IDLE,n){var s=this.tracksBuffered[this.currentTrackId];if(s){for(var a=i.start,o=0;o<s.length;o++)if(a>=s[o].start&&a<=s[o].end){r=s[o];break}var l=i.start+i.duration;r?r.end=l:(r={start:a,end:l},s.push(r)),this.fragmentTracker.fragBuffered(i)}}},p.onBufferFlushing=function(t,e){var r=e.startOffset,i=e.endOffset;if(0===r&&i!==Number.POSITIVE_INFINITY){var n=this.currentTrackId,s=this.levels;if(!s.length||!s[n]||!s[n].details)return;var a=i-s[n].details.targetduration;if(a<=0)return;e.endOffsetSubtitles=Math.max(0,a),this.tracksBuffered.forEach(function(t){for(var e=0;e<t.length;){if(t[e].end<=a){t.shift();continue}if(t[e].start<a)t[e].start=a;else break;e++}}),this.fragmentTracker.removeFragmentsInRange(r,a,d.PlaylistLevelType.SUBTITLE)}},p.onFragBuffered=function(t,e){if(!this.loadedmetadata&&e.frag.type===d.PlaylistLevelType.MAIN){var r;null!==(r=this.media)&&void 0!==r&&r.buffered.length&&(this.loadedmetadata=!0)}},p.onError=function(t,e){var r=e.frag;r&&r.type===d.PlaylistLevelType.SUBTITLE&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state=u.State.IDLE)},p.onSubtitleTracksUpdated=function(t,e){var r=this,i=e.subtitleTracks;this.tracksBuffered=[],this.levels=i.map(function(t){return new c.Level(t)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(t){r.tracksBuffered[t.id]=[]}),this.mediaBuffer=null},p.onSubtitleTrackSwitch=function(t,e){if(this.currentTrackId=e.id,!this.levels.length||-1===this.currentTrackId){this.clearInterval();return}var r=this.levels[this.currentTrackId];null!=r&&r.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,r&&this.setInterval(500)},p.onSubtitleTrackLoaded=function(t,e){var r,i=e.details,n=e.id,l=this.currentTrackId,d=this.levels;if(d.length){var c=d[l];if(!(n>=d.length)&&n===l&&c){this.mediaBuffer=this.mediaBufferTimeRanges;var h=0;if(i.live||null!==(r=c.details)&&void 0!==r&&r.live){var f=this.mainDetails;if(i.deltaUpdateFailed||!f)return;var g=f.fragments[0];c.details?0===(h=this.alignPlaylists(i,c.details))&&g&&(h=g.start,(0,o.addSliding)(i,h)):i.hasProgramDateTime&&f.hasProgramDateTime?((0,a.alignMediaPlaylistByPDT)(i,f),h=i.fragments[0].start):g&&(h=g.start,(0,o.addSliding)(i,h))}c.details=i,this.levelLastLoaded=n,this.startFragRequested||!this.mainDetails&&i.live||this.setStartPosition(c.details,h),this.tick(),i.live&&!this.fragCurrent&&this.media&&this.state===u.State.IDLE&&!(0,s.findFragmentByPTS)(null,i.fragments,this.media.currentTime,0)&&(this.warn("Subtitle playlist not aligned with playback"),c.details=void 0)}}},p._handleFragmentLoadComplete=function(t){var e=this,r=t.frag,n=t.payload,s=r.decryptdata,a=this.hls;if(!this.fragContextChanged(r)&&n&&n.byteLength>0&&s&&s.key&&s.iv&&"AES-128"===s.method){var o=performance.now();this.decrypter.decrypt(new Uint8Array(n),s.key.buffer,s.iv.buffer).then(function(t){var e=performance.now();a.trigger(i.Events.FRAG_DECRYPTED,{frag:r,payload:t,stats:{tstart:o,tdecrypt:e}})}).catch(function(t){e.warn(t.name+": "+t.message),e.state=u.State.IDLE})}},p.doTick=function(){if(!this.media){this.state=u.State.IDLE;return}if(this.state===u.State.IDLE){var t=this.currentTrackId,e=this.levels;if(!e.length||!e[t]||!e[t].details)return;var r=e[t].details,i=r.targetduration,a=this.config,o=this.getLoadPosition(),c=n.BufferHelper.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],o-i,a.maxBufferHole),h=c.end,f=c.len,g=this.getFwdBufferInfo(this.media,d.PlaylistLevelType.MAIN);if(f>this.getMaxBufferLength(null==g?void 0:g.len)+i)return;console.assert(r,"Subtitle track details are defined on idle subtitle stream controller tick");var v=r.fragments,p=v.length,m=r.edge,y=null,E=this.fragPrevious;if(h<m){var T=a.maxFragLookUpTolerance;(y=(0,s.findFragmentByPTS)(E,v,Math.max(v[0].start,h),T))||!E||!(E.start<v[0].start)||(y=v[0])}else y=v[p-1];if(!y)return;y=this.mapToInitFragWhenRequired(y),this.fragmentTracker.getState(y)===l.FragmentState.NOT_LOADED&&this.loadFragment(y,r,h)}},p.getMaxBufferLength=function(e){var r=t.prototype.getMaxBufferLength.call(this);return e?Math.max(r,e):r},p.loadFragment=function(e,r,i){this.fragCurrent=e,"initSegment"===e.sn?this._loadInitSegment(e,r):(this.startFragRequested=!0,t.prototype.loadFragment.call(this,e,r,i))},r=[{key:"mediaBufferTimeRanges",get:function(){return new v(this.tracksBuffered[this.currentTrackId]||[])}}],h(e.prototype,r),g&&h(e,g),Object.defineProperty(e,"prototype",{writable:!1}),e}(u.default),v=function(t){this.buffered=void 0;var e=function(e,r,i){if((r>>>=0)>i-1)throw new DOMException("Failed to execute '"+e+"' on 'TimeRanges': The index provided ("+r+") is greater than the maximum bound ("+i+")");return t[r][e]};this.buffered={get length(){return t.length},end:function(r){return e("end",r,t.length)},start:function(r){return e("start",r,t.length)}}}},"./src/controller/subtitle-track-controller.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>c});var i=r(/*! ../events */"./src/events.ts"),n=r(/*! ../utils/texttrack-utils */"./src/utils/texttrack-utils.ts"),s=r(/*! ./base-playlist-controller */"./src/controller/base-playlist-controller.ts"),a=r(/*! ../types/loader */"./src/types/loader.ts");function o(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var i=r.call(t,e||"default");if("object"!=typeof i)return i;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(i.key),i)}}function l(t,e){return(l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}var u=function(t){function e(e){var r;return(r=t.call(this,e,"[subtitle-track-controller]")||this).media=null,r.tracks=[],r.groupId=null,r.tracksInGroup=[],r.trackId=-1,r.selectDefaultTrack=!0,r.queuedDefaultTrack=-1,r.trackChangeListener=function(){return r.onTextTracksChanged()},r.asyncPollTrackChange=function(){return r.pollTrackChange(0)},r.useTextTrackPolling=!1,r.subtitlePollingInterval=-1,r._subtitleDisplay=!0,r.registerListeners(),r}e.prototype=Object.create(t.prototype),e.prototype.constructor=e,l(e,t);var r,s,u=e.prototype;return u.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,t.prototype.destroy.call(this)},u.registerListeners=function(){var t=this.hls;t.on(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(i.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(i.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(i.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(i.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(i.Events.ERROR,this.onError,this)},u.unregisterListeners=function(){var t=this.hls;t.off(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(i.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(i.Events.LEVEL_LOADING,this.onLevelLoading,this),t.off(i.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(i.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(i.Events.ERROR,this.onError,this)},u.onMediaAttached=function(t,e){this.media=e.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))},u.pollTrackChange=function(t){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,t)},u.onMediaDetaching=function(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),d(this.media.textTracks).forEach(function(t){(0,n.clearCurrentCues)(t)}),this.subtitleTrack=-1,this.media=null)},u.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},u.onManifestParsed=function(t,e){this.tracks=e.subtitleTracks},u.onSubtitleTrackLoaded=function(t,e){var r=e.id,i=e.details,n=this.trackId,s=this.tracksInGroup[n];if(!s){this.warn("Invalid subtitle track id "+r);return}var a=s.details;s.details=e.details,this.log("subtitle track "+r+" loaded ["+i.startSN+"-"+i.endSN+"]"),r===this.trackId&&(this.retryCount=0,this.playlistLoaded(r,e,a))},u.onLevelLoading=function(t,e){this.switchLevel(e.level)},u.onLevelSwitching=function(t,e){this.switchLevel(e.level)},u.switchLevel=function(t){var e=this.hls.levels[t];if(null!=e&&e.textGroupIds){var r=e.textGroupIds[e.urlId];if(this.groupId!==r){var n=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,s=this.tracks.filter(function(t){return!r||t.groupId===r});this.tracksInGroup=s;var a=this.findTrackId(null==n?void 0:n.name)||this.findTrackId();this.groupId=r,this.log("Updating subtitle tracks, "+s.length+' track(s) found in "'+r+'" group-id'),this.hls.trigger(i.Events.SUBTITLE_TRACKS_UPDATED,{subtitleTracks:s}),-1!==a&&this.setSubtitleTrack(a,n)}}},u.findTrackId=function(t){for(var e=this.tracksInGroup,r=0;r<e.length;r++){var i=e[r];if((!this.selectDefaultTrack||i.default)&&(!t||t===i.name))return i.id}return -1},u.onError=function(e,r){t.prototype.onError.call(this,e,r),r.fatal||!r.context||r.context.type!==a.PlaylistContextType.SUBTITLE_TRACK||r.context.id!==this.trackId||r.context.groupId!==this.groupId||this.retryLoadingOrFail(r)},u.loadPlaylist=function(e){t.prototype.loadPlaylist.call(this);var r=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(r)){var n=r.id,s=r.groupId,a=r.url;if(e)try{a=e.addDirectives(a)}catch(t){this.warn("Could not construct new URL with HLS Delivery Directives: "+t)}this.log("Loading subtitle playlist for id "+n),this.hls.trigger(i.Events.SUBTITLE_TRACK_LOADING,{url:a,id:n,groupId:s,deliveryDirectives:e||null})}},u.toggleTrackModes=function(t){var e=this,r=this.media,i=this.trackId;if(r){var n=d(r.textTracks),s=n.filter(function(t){return t.groupId===e.groupId});if(-1===t)[].slice.call(n).forEach(function(t){t.mode="disabled"});else{var a=s[i];a&&(a.mode="disabled")}var o=s[t];o&&(o.mode=this.subtitleDisplay?"showing":"hidden")}},u.setSubtitleTrack=function(t,e){var r,n=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=t;return}if(this.trackId!==t&&this.toggleTrackModes(t),(this.trackId!==t||-1!==t&&(null===(r=n[t])||void 0===r||!r.details))&&!(t<-1)&&!(t>=n.length)){this.clearTimer();var s=n[t];if(this.log("Switching to subtitle track "+t),this.trackId=t,s){var a=s.id,o=s.groupId,l=s.name,u=s.type,d=s.url;this.hls.trigger(i.Events.SUBTITLE_TRACK_SWITCH,{id:a,groupId:void 0===o?"":o,name:l,type:u,url:d});var c=this.switchParams(s.url,null==e?void 0:e.details);this.loadPlaylist(c)}else this.hls.trigger(i.Events.SUBTITLE_TRACK_SWITCH,{id:t})}},u.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),this.media&&this.hls.config.renderTextTracksNatively){for(var t=-1,e=d(this.media.textTracks),r=0;r<e.length;r++)if("hidden"===e[r].mode)t=r;else if("showing"===e[r].mode){t=r;break}this.subtitleTrack!==t&&(this.subtitleTrack=t)}},r=[{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(t){this._subtitleDisplay=t,this.trackId>-1&&this.toggleTrackModes(this.trackId)}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(t){this.selectDefaultTrack=!1;var e=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(t,e)}}],o(e.prototype,r),s&&o(e,s),Object.defineProperty(e,"prototype",{writable:!1}),e}(s.default);function d(t){for(var e=[],r=0;r<t.length;r++){var i=t[r];("subtitles"===i.kind||"captions"===i.kind)&&i.label&&e.push(t[r])}return e}let c=u},"./src/controller/timeline-controller.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{TimelineController:()=>f});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../events */"./src/events.ts"),s=r(/*! ../utils/cea-608-parser */"./src/utils/cea-608-parser.ts"),a=r(/*! ../utils/output-filter */"./src/utils/output-filter.ts"),o=r(/*! ../utils/webvtt-parser */"./src/utils/webvtt-parser.ts"),l=r(/*! ../utils/texttrack-utils */"./src/utils/texttrack-utils.ts"),u=r(/*! ../utils/imsc1-ttml-parser */"./src/utils/imsc1-ttml-parser.ts"),d=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),c=r(/*! ../types/loader */"./src/types/loader.ts"),h=r(/*! ../utils/logger */"./src/utils/logger.ts"),f=function(){function t(t){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.timescale=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=g(),this.captionsProperties=void 0,this.hls=t,this.config=t.config,this.Cues=t.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){var e=new a.default(this,"textTrack1"),r=new a.default(this,"textTrack2"),i=new a.default(this,"textTrack3"),o=new a.default(this,"textTrack4");this.cea608Parser1=new s.default(1,e,r),this.cea608Parser2=new s.default(3,i,o)}t.on(n.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(n.Events.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(n.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(n.Events.FRAG_LOADING,this.onFragLoading,this),t.on(n.Events.FRAG_LOADED,this.onFragLoaded,this),t.on(n.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.on(n.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),t.on(n.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(n.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.on(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var e=t.prototype;return e.destroy=function(){var t=this.hls;t.off(n.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(n.Events.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(n.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(n.Events.FRAG_LOADING,this.onFragLoading,this),t.off(n.Events.FRAG_LOADED,this.onFragLoaded,this),t.off(n.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.off(n.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),t.off(n.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(n.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.off(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},e.addCues=function(t,e,r,i,s){for(var a=!1,o=s.length;o--;){var l,u=s[o],d=(l=u[0],Math.min(u[1],r)-Math.max(l,e));if(d>=0&&(u[0]=Math.min(u[0],e),u[1]=Math.max(u[1],r),a=!0,d/(r-e)>.5))return}if(a||s.push([e,r]),this.config.renderTextTracksNatively){var c=this.captionsTracks[t];this.Cues.newCue(c,e,r,i)}else{var h=this.Cues.newCue(null,e,r,i);this.hls.trigger(n.Events.CUES_PARSED,{type:"captions",cues:h,track:t})}},e.onInitPtsFound=function(t,e){var r=this,i=e.frag,s=e.id,a=e.initPTS,o=e.timescale,l=this.unparsedVttFrags;"main"===s&&(this.initPTS[i.cc]=a,this.timescale[i.cc]=o),l.length&&(this.unparsedVttFrags=[],l.forEach(function(t){r.onFragLoaded(n.Events.FRAG_LOADED,t)}))},e.getExistingTrack=function(t){var e=this.media;if(e)for(var r=0;r<e.textTracks.length;r++){var i=e.textTracks[r];if(i[t])return i}return null},e.createCaptionsTrack=function(t){this.config.renderTextTracksNatively?this.createNativeTrack(t):this.createNonNativeTrack(t)},e.createNativeTrack=function(t){if(!this.captionsTracks[t]){var e=this.captionsProperties,r=this.captionsTracks,i=this.media,n=e[t],s=n.label,a=n.languageCode,o=this.getExistingTrack(t);if(o)r[t]=o,(0,l.clearCurrentCues)(r[t]),(0,l.sendAddTrackEvent)(r[t],i);else{var u=this.createTextTrack("captions",s,a);u&&(u[t]=!0,r[t]=u)}}},e.createNonNativeTrack=function(t){if(!this.nonNativeCaptionsTracks[t]){var e=this.captionsProperties[t];if(e){var r={_id:t,label:e.label,kind:"captions",default:!!e.media&&!!e.media.default,closedCaptions:e.media};this.nonNativeCaptionsTracks[t]=r,this.hls.trigger(n.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[r]})}}},e.createTextTrack=function(t,e,r){var i=this.media;if(i)return i.addTextTrack(t,e,r)},e.onMediaAttaching=function(t,e){this.media=e.media,this._cleanTracks()},e.onMediaDetaching=function(){var t=this.captionsTracks;Object.keys(t).forEach(function(e){(0,l.clearCurrentCues)(t[e]),delete t[e]}),this.nonNativeCaptionsTracks={}},e.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=g(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.timescale=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},e._cleanTracks=function(){var t=this.media;if(t){var e=t.textTracks;if(e)for(var r=0;r<e.length;r++)(0,l.clearCurrentCues)(e[r])}},e.onSubtitleTracksUpdated=function(t,e){var r=this;this.textTracks=[];var i=e.subtitleTracks||[],s=i.some(function(t){return t.textCodec===u.IMSC1_CODEC});if(this.config.enableWebVTT||s&&this.config.enableIMSC1){var a=this.tracks&&i&&this.tracks.length===i.length;if(this.tracks=i||[],this.config.renderTextTracksNatively){var o=this.media?this.media.textTracks:[];this.tracks.forEach(function(t,e){var i;if(e<o.length){for(var n,s=null,a=0;a<o.length;a++)if((n=o[a])&&n.label===t.name&&!(n.textTrack1||n.textTrack2)){s=o[a];break}s&&(i=s)}if(i)(0,l.clearCurrentCues)(i);else{var u=r._captionsOrSubtitlesFromCharacteristics(t);(i=r.createTextTrack(u,t.name,t.lang))&&(i.mode="disabled")}i&&(i.groupId=t.groupId,r.textTracks.push(i))})}else if(!a&&this.tracks&&this.tracks.length){var d=this.tracks.map(function(t){return{label:t.name,kind:t.type.toLowerCase(),default:t.default,subtitleTrack:t}});this.hls.trigger(n.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:d})}}},e._captionsOrSubtitlesFromCharacteristics=function(t){var e;if(null!==(e=t.attrs)&&void 0!==e&&e.CHARACTERISTICS){var r=/transcribes-spoken-dialog/gi.test(t.attrs.CHARACTERISTICS),i=/describes-music-and-sound/gi.test(t.attrs.CHARACTERISTICS);if(r&&i)return"captions"}return"subtitles"},e.onManifestLoaded=function(t,e){var r=this;this.config.enableCEA708Captions&&e.captions&&e.captions.forEach(function(t){var e=/(?:CC|SERVICE)([1-4])/.exec(t.instreamId);if(e){var i="textTrack"+e[1],n=r.captionsProperties[i];n&&(n.label=t.name,t.lang&&(n.languageCode=t.lang),n.media=t)}})},e.closedCaptionsForLevel=function(t){var e=this.hls.levels[t.level];return null==e?void 0:e.attrs["CLOSED-CAPTIONS"]},e.onFragLoading=function(t,e){var r=this.cea608Parser1,i=this.cea608Parser2,n=this.lastSn,s=this.lastPartIndex;if(this.enabled&&r&&i&&e.frag.type===c.PlaylistLevelType.MAIN){var a,o,l=e.frag.sn,u=null!=(a=null==e?void 0:null===(o=e.part)||void 0===o?void 0:o.index)?a:-1;l===n+1||l===n&&u===s+1||(r.reset(),i.reset()),this.lastSn=l,this.lastPartIndex=u}},e.onFragLoaded=function(t,e){var r=e.frag,s=e.payload,a=this.initPTS,o=this.unparsedVttFrags;if(r.type===c.PlaylistLevelType.SUBTITLE){if(s.byteLength){if(!(0,i.isFiniteNumber)(a[r.cc])){o.push(e),a.length&&this.hls.trigger(n.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:Error("Missing initial subtitle PTS")});return}var l=r.decryptdata,d="stats"in e;if(null==l||!l.encrypted||d){var h=this.tracks[r.level],f=this.vttCCs;f[r.cc]||(f[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),h&&h.textCodec===u.IMSC1_CODEC?this._parseIMSC1(r,s):this._parseVTTs(r,s,f)}}else this.hls.trigger(n.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:Error("Empty subtitle payload")})}},e._parseIMSC1=function(t,e){var r=this,i=this.hls;(0,u.parseIMSC1)(e,this.initPTS[t.cc],this.timescale[t.cc],function(e){r._appendCues(e,t.level),i.trigger(n.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})},function(e){h.logger.log("Failed to parse IMSC1: "+e),i.trigger(n.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:e})})},e._parseVTTs=function(t,e,r){var i,s=this,a=this.hls,l=null!==(i=t.initSegment)&&void 0!==i&&i.data?(0,d.appendUint8Array)(t.initSegment.data,new Uint8Array(e)):e;(0,o.parseWebVTT)(l,this.initPTS[t.cc],this.timescale[t.cc],r,t.cc,t.start,function(e){s._appendCues(e,t.level),a.trigger(n.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})},function(r){s._fallbackToIMSC1(t,e),h.logger.log("Failed to parse VTT cue: "+r),a.trigger(n.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:r})})},e._fallbackToIMSC1=function(t,e){var r=this,i=this.tracks[t.level];i.textCodec||(0,u.parseIMSC1)(e,this.initPTS[t.cc],this.timescale[t.cc],function(){i.textCodec=u.IMSC1_CODEC,r._parseIMSC1(t,e)},function(){i.textCodec="wvtt"})},e._appendCues=function(t,e){var r=this.hls;if(this.config.renderTextTracksNatively){var i=this.textTracks[e];if(!i||"disabled"===i.mode)return;t.forEach(function(t){return(0,l.addCueToTrack)(i,t)})}else{var s=this.tracks[e];if(!s)return;var a=s.default?"default":"subtitles"+e;r.trigger(n.Events.CUES_PARSED,{type:"subtitles",cues:t,track:a})}},e.onFragDecrypted=function(t,e){var r=e.frag;if(r.type===c.PlaylistLevelType.SUBTITLE){if(!(0,i.isFiniteNumber)(this.initPTS[r.cc])){this.unparsedVttFrags.push(e);return}this.onFragLoaded(n.Events.FRAG_LOADED,e)}},e.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},e.onFragParsingUserdata=function(t,e){var r=this.cea608Parser1,i=this.cea608Parser2;if(this.enabled&&r&&i){var n=e.frag,s=e.samples;if(n.type!==c.PlaylistLevelType.MAIN||"NONE"!==this.closedCaptionsForLevel(n))for(var a=0;a<s.length;a++){var o=s[a].bytes;if(o){var l=this.extractCea608Data(o);r.addData(s[a].pts,l[0]),i.addData(s[a].pts,l[1])}}}},e.onBufferFlushing=function(t,e){var r=e.startOffset,i=e.endOffset,n=e.endOffsetSubtitles,s=e.type,a=this.media;if(a&&!(a.currentTime<i)){if(!s||"video"===s){var o=this.captionsTracks;Object.keys(o).forEach(function(t){return(0,l.removeCuesInRange)(o[t],r,i)})}if(this.config.renderTextTracksNatively&&0===r&&void 0!==n){var u=this.textTracks;Object.keys(u).forEach(function(t){return(0,l.removeCuesInRange)(u[t],r,n)})}}},e.extractCea608Data=function(t){for(var e=[[],[]],r=31&t[0],i=2,n=0;n<r;n++){var s=t[i++],a=127&t[i++],o=127&t[i++];if((0!==a||0!==o)&&(4&s)!=0){var l=3&s;(0===l||1===l)&&(e[l].push(a),e[l].push(o))}}return e},t}();function g(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}},"./src/crypt/aes-crypto.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>i});var i=function(){function t(t,e){this.subtle=void 0,this.aesIV=void 0,this.subtle=t,this.aesIV=e}return t.prototype.decrypt=function(t,e){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},e,t)},t}()},"./src/crypt/aes-decryptor.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>s,removePadding:()=>n});var i=r(/*! ../utils/typed-array */"./src/utils/typed-array.ts");function n(t){var e=t.byteLength,r=e&&new DataView(t.buffer).getUint8(e-1);return r?(0,i.sliceUint8)(t,0,e-r):t}var s=function(){function t(){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 e=t.prototype;return e.uint8ArrayToUint32Array_=function(t){for(var e=new DataView(t),r=new Uint32Array(4),i=0;i<4;i++)r[i]=e.getUint32(4*i);return r},e.initTable=function(){var t=this.sBox,e=this.invSBox,r=this.subMix,i=r[0],n=r[1],s=r[2],a=r[3],o=this.invSubMix,l=o[0],u=o[1],d=o[2],c=o[3],h=new Uint32Array(256),f=0,g=0,v=0;for(v=0;v<256;v++)v<128?h[v]=v<<1:h[v]=v<<1^283;for(v=0;v<256;v++){var p=g^g<<1^g<<2^g<<3^g<<4;p=p>>>8^255&p^99,t[f]=p,e[p]=f;var m=h[f],y=h[m],E=h[y],T=257*h[p]^16843008*p;i[f]=T<<24|T>>>8,n[f]=T<<16|T>>>16,s[f]=T<<8|T>>>24,a[f]=T,T=16843009*E^65537*y^257*m^16843008*f,l[p]=T<<24|T>>>8,u[p]=T<<16|T>>>16,d[p]=T<<8|T>>>24,c[p]=T,f?(f=m^h[h[h[E^m]]],g^=h[h[g]]):f=g=1}},e.expandKey=function(t){for(var e,r,i,n,s=this.uint8ArrayToUint32Array_(t),a=!0,o=0;o<s.length&&a;)a=s[o]===this.key[o],o++;if(!a){this.key=s;var l=this.keySize=s.length;if(4!==l&&6!==l&&8!==l)throw Error("Invalid aes key size="+l);var u=this.ksRows=(l+6+1)*4,d=this.keySchedule=new Uint32Array(u),c=this.invKeySchedule=new Uint32Array(u),h=this.sBox,f=this.rcon,g=this.invSubMix,v=g[0],p=g[1],m=g[2],y=g[3];for(e=0;e<u;e++){if(e<l){i=d[e]=s[e];continue}n=i,e%l==0?n=(h[(n=n<<8|n>>>24)>>>24]<<24|h[n>>>16&255]<<16|h[n>>>8&255]<<8|h[255&n])^f[e/l|0]<<24:l>6&&e%l==4&&(n=h[n>>>24]<<24|h[n>>>16&255]<<16|h[n>>>8&255]<<8|h[255&n]),d[e]=i=(d[e-l]^n)>>>0}for(r=0;r<u;r++)e=u-r,n=3&r?d[e]:d[e-4],r<4||e<=4?c[r]=n:c[r]=v[h[n>>>24]]^p[h[n>>>16&255]]^m[h[n>>>8&255]]^y[h[255&n]],c[r]=c[r]>>>0}},e.networkToHostOrderSwap=function(t){return t<<24|(65280&t)<<8|(16711680&t)>>8|t>>>24},e.decrypt=function(t,e,r){for(var i,n,s,a,o,l,u,d,c,h,f,g,v,p,m=this.keySize+6,y=this.invKeySchedule,E=this.invSBox,T=this.invSubMix,S=T[0],b=T[1],L=T[2],D=T[3],A=this.uint8ArrayToUint32Array_(r),k=A[0],I=A[1],R=A[2],C=A[3],_=new Int32Array(t),P=new Int32Array(_.length),O=this.networkToHostOrderSwap;e<_.length;){for(p=1,c=O(_[e]),h=O(_[e+1]),f=O(_[e+2]),g=O(_[e+3]),o=c^y[0],l=g^y[1],u=f^y[2],d=h^y[3],v=4;p<m;p++)i=S[o>>>24]^b[l>>16&255]^L[u>>8&255]^D[255&d]^y[v],n=S[l>>>24]^b[u>>16&255]^L[d>>8&255]^D[255&o]^y[v+1],s=S[u>>>24]^b[d>>16&255]^L[o>>8&255]^D[255&l]^y[v+2],a=S[d>>>24]^b[o>>16&255]^L[l>>8&255]^D[255&u]^y[v+3],o=i,l=n,u=s,d=a,v+=4;i=E[o>>>24]<<24^E[l>>16&255]<<16^E[u>>8&255]<<8^E[255&d]^y[v],n=E[l>>>24]<<24^E[u>>16&255]<<16^E[d>>8&255]<<8^E[255&o]^y[v+1],s=E[u>>>24]<<24^E[d>>16&255]<<16^E[o>>8&255]<<8^E[255&l]^y[v+2],a=E[d>>>24]<<24^E[o>>16&255]<<16^E[l>>8&255]<<8^E[255&u]^y[v+3],P[e]=O(i^k),P[e+1]=O(a^I),P[e+2]=O(s^R),P[e+3]=O(n^C),k=c,I=h,R=f,C=g,e+=4}return P.buffer},t}()},"./src/crypt/decrypter.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>u});var i=r(/*! ./aes-crypto */"./src/crypt/aes-crypto.ts"),n=r(/*! ./fast-aes-key */"./src/crypt/fast-aes-key.ts"),s=r(/*! ./aes-decryptor */"./src/crypt/aes-decryptor.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),l=r(/*! ../utils/typed-array */"./src/utils/typed-array.ts"),u=function(){function t(t,e){var r=(void 0===e?{}:e).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=t.enableSoftwareAES,this.removePKCS7Padding=i,i)try{var n=self.crypto;n&&(this.subtle=n.subtle||n.webkitSubtle)}catch(t){}null===this.subtle&&(this.useSoftware=!0)}var e=t.prototype;return e.destroy=function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},e.isSync=function(){return this.useSoftware},e.flush=function(){var t=this.currentResult,e=this.remainderData;if(!t||e)return this.reset(),null;var r=new Uint8Array(t);return(this.reset(),this.removePKCS7Padding)?(0,s.removePadding)(r):r},e.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},e.decrypt=function(t,e,r){var i=this;return this.useSoftware?new Promise(function(n,s){i.softwareDecrypt(new Uint8Array(t),e,r);var a=i.flush();a?n(a.buffer):s(Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(t),e,r)},e.softwareDecrypt=function(t,e,r){var i=this.currentIV,n=this.currentResult,a=this.remainderData;this.logOnce("JS AES decrypt"),a&&(t=(0,o.appendUint8Array)(a,t),this.remainderData=null);var u=this.getValidChunk(t);if(!u.length)return null;i&&(r=i);var d=this.softwareDecrypter;return(d||(d=this.softwareDecrypter=new s.default),d.expandKey(e),this.currentResult=d.decrypt(u.buffer,0,r),this.currentIV=(0,l.sliceUint8)(u,-16).buffer,n)?n:null},e.webCryptoDecrypt=function(t,e,r){var s=this,o=this.subtle;return this.key===e&&this.fastAesKey||(this.key=e,this.fastAesKey=new n.default(o,e)),this.fastAesKey.expandKey().then(function(e){return o?(s.logOnce("WebCrypto AES decrypt"),new i.default(o,new Uint8Array(r)).decrypt(t.buffer,e)):Promise.reject(Error("web crypto not initialized"))}).catch(function(i){return a.logger.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+i.name+": "+i.message),s.onWebCryptoError(t,e,r)})},e.onWebCryptoError=function(t,e,r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(t,e,r);var i=this.flush();if(i)return i.buffer;throw Error("WebCrypto and softwareDecrypt: failed to decrypt data")},e.getValidChunk=function(t){var e=t,r=t.length-t.length%16;return r!==t.length&&(e=(0,l.sliceUint8)(t,0,r),this.remainderData=(0,l.sliceUint8)(t,r)),e},e.logOnce=function(t){this.logEnabled&&(a.logger.log("[decrypter]: "+t),this.logEnabled=!1)},t}()},"./src/crypt/fast-aes-key.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>i});var i=function(){function t(t,e){this.subtle=void 0,this.key=void 0,this.subtle=t,this.key=e}return t.prototype.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},t}()},"./src/demux/aacdemuxer.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>u});var i=r(/*! ./base-audio-demuxer */"./src/demux/base-audio-demuxer.ts"),n=r(/*! ./adts */"./src/demux/adts.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),a=r(/*! ../demux/id3 */"./src/demux/id3.ts");function o(t,e){return(o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}var l=function(t){function e(e,r){var i;return(i=t.call(this)||this).observer=void 0,i.config=void 0,i.observer=e,i.config=r,i}e.prototype=Object.create(t.prototype),e.prototype.constructor=e,o(e,t);var r=e.prototype;return r.resetInitSegment=function(e,r,i,n){t.prototype.resetInitSegment.call(this,e,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}},e.probe=function(t){if(!t)return!1;for(var e=(a.getID3Data(t,0)||[]).length,r=t.length;e<r;e++)if(n.probe(t,e))return s.logger.log("ADTS sync word found !"),!0;return!1},r.canParse=function(t,e){return n.canParse(t,e)},r.appendFrame=function(t,e,r){n.initTrackConfig(t,this.observer,e,r,t.manifestCodec);var i=n.appendFrame(t,e,r,this.basePTS,this.frameIndex);if(i&&0===i.missing)return i},e}(i.default);let u=l},"./src/demux/adts.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{appendFrame:()=>m,canGetFrameLength:()=>d,canParse:()=>h,getAudioConfig:()=>a,getFrameDuration:()=>v,getFullFrameLength:()=>u,getHeaderLength:()=>l,initTrackConfig:()=>g,isHeader:()=>c,isHeaderPattern:()=>o,parseFrameHeader:()=>p,probe:()=>f});var i=r(/*! ../utils/logger */"./src/utils/logger.ts"),n=r(/*! ../errors */"./src/errors.ts"),s=r(/*! ../events */"./src/events.ts");function a(t,e,r,a){var o,l,u,d,c=navigator.userAgent.toLowerCase(),h=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];o=((192&e[r+2])>>>6)+1;var f=(60&e[r+2])>>>2;if(f>h.length-1){t.trigger(s.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+f});return}return u=(1&e[r+2])<<2|(192&e[r+3])>>>6,i.logger.log("manifest codec:"+a+", ADTS type:"+o+", samplingIndex:"+f),/firefox/i.test(c)?f>=6?(o=5,d=[,,,,],l=f-3):(o=2,d=[,,],l=f):-1!==c.indexOf("android")?(o=2,d=[,,],l=f):(o=5,d=[,,,,],a&&(-1!==a.indexOf("mp4a.40.29")||-1!==a.indexOf("mp4a.40.5"))||!a&&f>=6?l=f-3:((a&&-1!==a.indexOf("mp4a.40.2")&&(f>=6&&1===u||/vivaldi/i.test(c))||!a&&1===u)&&(o=2,d=[,,]),l=f)),d[0]=o<<3,d[0]|=(14&f)>>1,d[1]|=(1&f)<<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:h[f],channelCount:u,codec:"mp4a.40."+o,manifestCodec:a}}function o(t,e){return 255===t[e]&&(246&t[e+1])==240}function l(t,e){return 1&t[e+1]?7:9}function u(t,e){return(3&t[e+3])<<11|t[e+4]<<3|(224&t[e+5])>>>5}function d(t,e){return e+5<t.length}function c(t,e){return e+1<t.length&&o(t,e)}function h(t,e){return d(t,e)&&o(t,e)&&u(t,e)<=t.length-e}function f(t,e){if(c(t,e)){var r=l(t,e);if(e+r>=t.length)return!1;var i=u(t,e);if(i<=r)return!1;var n=e+i;return n===t.length||c(t,n)}return!1}function g(t,e,r,n,s){if(!t.samplerate){var o=a(e,r,n,s);o&&(t.config=o.config,t.samplerate=o.samplerate,t.channelCount=o.channelCount,t.codec=o.codec,t.manifestCodec=o.manifestCodec,i.logger.log("parsed codec:"+t.codec+", rate:"+o.samplerate+", channels:"+o.channelCount))}}function v(t){return 9216e4/t}function p(t,e){var r=l(t,e);if(e+r<=t.length){var i=u(t,e)-r;if(i>0)return{headerLength:r,frameLength:i}}}function m(t,e,r,i,n){var s,a=i+n*v(t.samplerate),o=p(e,r);if(o){var l=o.frameLength,u=o.headerLength,d=u+l,c=Math.max(0,r+d-e.length);c?(s=new Uint8Array(d-u)).set(e.subarray(r+u,e.length),0):s=e.subarray(r+u,r+d);var h={unit:s,pts:a};return c||t.samples.push(h),{sample:h,length:d,missing:c}}var f=e.length-r;return(s=new Uint8Array(f)).set(e.subarray(r,e.length),0),{sample:{unit:s,pts:a},length:f,missing:-1}}},"./src/demux/base-audio-demuxer.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>c,initPTSFn:()=>d});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../demux/id3 */"./src/demux/id3.ts"),s=r(/*! ../types/demuxer */"./src/types/demuxer.ts"),a=r(/*! ./dummy-demuxed-track */"./src/demux/dummy-demuxed-track.ts"),o=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),l=r(/*! ../utils/typed-array */"./src/utils/typed-array.ts"),u=function(){function t(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var e=t.prototype;return e.resetInitSegment=function(t,e,r,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},e.resetTimeStamp=function(t){this.initPTS=t,this.resetContiguity()},e.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},e.canParse=function(t,e){return!1},e.appendFrame=function(t,e,r){},e.demux=function(t,e){this.cachedData&&(t=(0,o.appendUint8Array)(this.cachedData,t),this.cachedData=null);var r,u=n.getID3Data(t,0),c=u?u.length:0,h=this._audioTrack,f=this._id3Track,g=u?n.getTimeStamp(u):void 0,v=t.length;for((null===this.basePTS||0===this.frameIndex&&(0,i.isFiniteNumber)(g))&&(this.basePTS=d(g,e,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:s.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY});c<v;){if(this.canParse(t,c)){var p=this.appendFrame(h,t,c);p?(this.frameIndex++,this.lastPTS=p.sample.pts,c+=p.length,r=c):c=v}else n.canParse(t,c)?(u=n.getID3Data(t,c),f.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:u,type:s.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY}),c+=u.length,r=c):c++;if(c===v&&r!==v){var m=(0,l.sliceUint8)(t,r);this.cachedData?this.cachedData=(0,o.appendUint8Array)(this.cachedData,m):this.cachedData=m}}return{audioTrack:h,videoTrack:(0,a.dummyTrack)(),id3Track:f,textTrack:(0,a.dummyTrack)()}},e.demuxSampleAes=function(t,e,r){return Promise.reject(Error("["+this+"] This demuxer does not support Sample-AES decryption"))},e.flush=function(t){var e=this.cachedData;return e&&(this.cachedData=null,this.demux(e,0)),{audioTrack:this._audioTrack,videoTrack:(0,a.dummyTrack)(),id3Track:this._id3Track,textTrack:(0,a.dummyTrack)()}},e.destroy=function(){},t}(),d=function(t,e,r){return(0,i.isFiniteNumber)(t)?90*t:9e4*e+(r||0)};let c=u},"./src/demux/chunk-cache.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>i});var i=function(){function t(){this.chunks=[],this.dataLength=0}var e=t.prototype;return e.push=function(t){this.chunks.push(t),this.dataLength+=t.length},e.flush=function(){var t,e=this.chunks,r=this.dataLength;return e.length?(t=1===e.length?e[0]:function(t,e){for(var r=new Uint8Array(e),i=0,n=0;n<t.length;n++){var s=t[n];r.set(s,i),i+=s.length}return r}(e,r),this.reset(),t):new Uint8Array(0)},e.reset=function(){this.chunks.length=0,this.dataLength=0},t}()},"./src/demux/dummy-demuxed-track.ts":(t,e,r)=>{"use strict";function i(t,e){return void 0===t&&(t=""),void 0===e&&(e=9e4),{type:t,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}r.r(e),r.d(e,{dummyTrack:()=>i})},"./src/demux/exp-golomb.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>s});var i=r(/*! ../utils/logger */"./src/utils/logger.ts"),n=function(){function t(t){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=t,this.bytesAvailable=t.byteLength,this.word=0,this.bitsAvailable=0}var e=t.prototype;return e.loadWord=function(){var t=this.data,e=this.bytesAvailable,r=t.byteLength-e,i=new Uint8Array(4),n=Math.min(4,e);if(0===n)throw Error("no bytes available");i.set(t.subarray(r,r+n)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*n,this.bytesAvailable-=n},e.skipBits=function(t){var e;t=Math.min(t,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>t||(t-=this.bitsAvailable,e=t>>3,t-=e<<3,this.bytesAvailable-=e,this.loadWord()),this.word<<=t,this.bitsAvailable-=t},e.readBits=function(t){var e=Math.min(this.bitsAvailable,t),r=this.word>>>32-e;if(t>32&&i.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=e,this.bitsAvailable>0)this.word<<=e;else if(this.bytesAvailable>0)this.loadWord();else throw Error("no bits available");return(e=t-e)>0&&this.bitsAvailable?r<<e|this.readBits(e):r},e.skipLZ=function(){var t;for(t=0;t<this.bitsAvailable;++t)if((this.word&2147483648>>>t)!=0)return this.word<<=t,this.bitsAvailable-=t,t;return this.loadWord(),t+this.skipLZ()},e.skipUEG=function(){this.skipBits(1+this.skipLZ())},e.skipEG=function(){this.skipBits(1+this.skipLZ())},e.readUEG=function(){var t=this.skipLZ();return this.readBits(t+1)-1},e.readEG=function(){var t=this.readUEG();return 1&t?1+t>>>1:-1*(t>>>1)},e.readBoolean=function(){return 1===this.readBits(1)},e.readUByte=function(){return this.readBits(8)},e.readUShort=function(){return this.readBits(16)},e.readUInt=function(){return this.readBits(32)},e.skipScalingList=function(t){for(var e=8,r=8,i=0;i<t;i++)0!==r&&(r=(e+this.readEG()+256)%256),e=0===r?e:r},e.readSPS=function(){var t,e,r,i=0,n=0,s=0,a=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),g=this.skipScalingList.bind(this);o();var v=o();if(l(5),c(3),o(),f(),100===v||110===v||122===v||244===v||44===v||83===v||86===v||118===v||128===v){var p=u();if(3===p&&c(1),f(),f(),c(1),d())for(r=0,e=3!==p?8:12;r<e;r++)d()&&g(r<6?16:64)}f();var m=u();if(0===m)u();else if(1===m)for(c(1),h(),h(),t=u(),r=0;r<t;r++)h();f(),c(1);var y=u(),E=u(),T=l(1);0===T&&c(1),c(1),d()&&(i=u(),n=u(),s=u(),a=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((y+1)*16-2*i-2*n),height:(2-T)*(E+1)*16-(T?2:4)*(s+a),pixelRatio:S}},e.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},t}();let s=n},"./src/demux/id3.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{canParse:()=>l,decodeFrame:()=>f,getID3Data:()=>a,getID3Frames:()=>h,getTimeStamp:()=>u,isFooter:()=>s,isHeader:()=>n,isTimeStampFrame:()=>d,testables:()=>E,utf8ArrayToStr:()=>y});var i,n=function(t,e){return e+10<=t.length&&73===t[e]&&68===t[e+1]&&51===t[e+2]&&t[e+3]<255&&t[e+4]<255&&t[e+6]<128&&t[e+7]<128&&t[e+8]<128&&t[e+9]<128},s=function(t,e){return e+10<=t.length&&51===t[e]&&68===t[e+1]&&73===t[e+2]&&t[e+3]<255&&t[e+4]<255&&t[e+6]<128&&t[e+7]<128&&t[e+8]<128&&t[e+9]<128},a=function(t,e){for(var r=e,i=0;n(t,e);)i+=10+o(t,e+6),s(t,e+10)&&(i+=10),e+=i;if(i>0)return t.subarray(r,r+i)},o=function(t,e){return(127&t[e])<<21|(127&t[e+1])<<14|(127&t[e+2])<<7|127&t[e+3]},l=function(t,e){return n(t,e)&&o(t,e+6)+10<=t.length-e},u=function(t){for(var e=h(t),r=0;r<e.length;r++){var i=e[r];if(d(i))return m(i)}},d=function(t){return t&&"PRIV"===t.key&&"com.apple.streaming.transportStreamTimestamp"===t.info},c=function(t){var e=String.fromCharCode(t[0],t[1],t[2],t[3]),r=o(t,4);return{type:e,size:r,data:t.subarray(10,10+r)}},h=function(t){for(var e=0,r=[];n(t,e);){for(var i=o(t,e+6),a=(e+=10)+i;e+8<a;){var l=c(t.subarray(e)),u=f(l);u&&r.push(u),e+=l.size+10}s(t,e)&&(e+=10)}return r},f=function(t){return"PRIV"===t.type?g(t):"W"===t.type[0]?p(t):v(t)},g=function(t){if(!(t.size<2)){var e=y(t.data,!0),r=new Uint8Array(t.data.subarray(e.length+1));return{key:t.type,info:e,data:r.buffer}}},v=function(t){if(!(t.size<2)){if("TXXX"===t.type){var e=1,r=y(t.data.subarray(e),!0);e+=r.length+1;var i=y(t.data.subarray(e));return{key:t.type,info:r,data:i}}var n=y(t.data.subarray(1));return{key:t.type,data:n}}},p=function(t){if("WXXX"===t.type){if(t.size<2)return;var e=1,r=y(t.data.subarray(e),!0);e+=r.length+1;var i=y(t.data.subarray(e));return{key:t.type,info:r,data:i}}var n=y(t.data);return{key:t.type,data:n}},m=function(t){if(8===t.data.byteLength){var e=new Uint8Array(t.data),r=1&e[3],i=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return i/=45,r&&(i+=47721858.84),Math.round(i)}},y=function(t,e){void 0===e&&(e=!1);var r,n,s=(i||void 0===self.TextDecoder||(i=new self.TextDecoder("utf-8")),i);if(s){var a=s.decode(t);if(e){var o=a.indexOf("\x00");return -1!==o?a.substring(0,o):a}return a.replace(/\0/g,"")}for(var l=t.length,u="",d=0;d<l&&(0!==(r=t[d++])||!e);)if(0!==r&&3!==r)switch(r>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:u+=String.fromCharCode(r);break;case 12:case 13:u+=String.fromCharCode((31&r)<<6|63&t[d++]);break;case 14:u+=String.fromCharCode((15&r)<<12|(63&t[d++])<<6|(63&t[d++])<<0)}return u},E={decodeTextFrame:v}},"./src/demux/mp3demuxer.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>u});var i=r(/*! ./base-audio-demuxer */"./src/demux/base-audio-demuxer.ts"),n=r(/*! ../demux/id3 */"./src/demux/id3.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),a=r(/*! ./mpegaudio */"./src/demux/mpegaudio.ts");function o(t,e){return(o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}var l=function(t){function e(){return t.apply(this,arguments)||this}e.prototype=Object.create(t.prototype),e.prototype.constructor=e,o(e,t);var r=e.prototype;return r.resetInitSegment=function(e,r,i,n){t.prototype.resetInitSegment.call(this,e,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}},e.probe=function(t){if(!t)return!1;for(var e=(n.getID3Data(t,0)||[]).length,r=t.length;e<r;e++)if(a.probe(t,e))return s.logger.log("MPEG Audio sync word found !"),!0;return!1},r.canParse=function(t,e){return a.canParse(t,e)},r.appendFrame=function(t,e,r){if(null!==this.basePTS)return a.appendFrame(t,e,r,this.basePTS,this.frameIndex)},e}(i.default);let u=l},"./src/demux/mp4demuxer.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>u});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../types/demuxer */"./src/types/demuxer.ts"),s=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),a=r(/*! ./dummy-demuxed-track */"./src/demux/dummy-demuxed-track.ts"),o=/\/emsg[-/]ID3/i,l=function(){function t(t,e){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=e}var e=t.prototype;return e.resetTimeStamp=function(){},e.resetInitSegment=function(t,e,r,i){var n=this.videoTrack=(0,a.dummyTrack)("video",1),o=this.audioTrack=(0,a.dummyTrack)("audio",1),l=this.txtTrack=(0,a.dummyTrack)("text",1);if(this.id3Track=(0,a.dummyTrack)("id3",1),this.timeOffset=0,t&&t.byteLength){var u=(0,s.parseInitSegment)(t);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 g=u.audio,v=g.id,p=g.timescale,m=g.codec;o.id=v,o.timescale=p,o.codec=m}l.id=s.RemuxerTrackIdConfig.text,n.sampleDuration=0,n.duration=o.duration=i}},e.resetContiguity=function(){},t.probe=function(t){return t=t.length>16384?t.subarray(0,16384):t,(0,s.findBox)(t,["moof"]).length>0},e.demux=function(t,e){this.timeOffset=e;var r=t,i=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=(0,s.appendUint8Array)(this.remainderData,t));var a=(0,s.segmentValidRange)(r);this.remainderData=a.remainder,i.samples=a.valid||new Uint8Array}else i.samples=r;var o=this.extractID3Track(i,e);return n.samples=(0,s.parseSamples)(e,i),{videoTrack:i,audioTrack:this.audioTrack,id3Track:o,textTrack:this.txtTrack}},e.flush=function(){var t=this.timeOffset,e=this.videoTrack,r=this.txtTrack;e.samples=this.remainderData||new Uint8Array,this.remainderData=null;var i=this.extractID3Track(e,this.timeOffset);return r.samples=(0,s.parseSamples)(t,e),{videoTrack:e,audioTrack:(0,a.dummyTrack)(),id3Track:i,textTrack:(0,a.dummyTrack)()}},e.extractID3Track=function(t,e){var r=this.id3Track;if(t.samples.length){var a=(0,s.findBox)(t.samples,["emsg"]);a&&a.forEach(function(t){var a=(0,s.parseEmsg)(t);if(o.test(a.schemeIdUri)){var l=(0,i.isFiniteNumber)(a.presentationTime)?a.presentationTime/a.timeScale:e+a.presentationTimeDelta/a.timeScale,u=4294967295===a.eventDuration?Number.POSITIVE_INFINITY:a.eventDuration/a.timeScale;u<=.001&&(u=Number.POSITIVE_INFINITY);var d=a.payload;r.samples.push({data:d,len:d.byteLength,dts:l,pts:l,type:n.MetadataSchema.emsg,duration:u})}})}return r},e.demuxSampleAes=function(t,e,r){return Promise.reject(Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},e.destroy=function(){},t}();let u=l},"./src/demux/mpegaudio.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{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],s=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],a=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],o=[0,1,1,4];function l(t,e,r,i,n){if(!(r+24>e.length)){var s=u(e,r);if(s&&r+s.frameLength<=e.length){var a=i+n*(9e4*s.samplesPerFrame/s.sampleRate),o={unit:e.subarray(r,r+s.frameLength),pts:a,dts:a};return t.config=[],t.channelCount=s.channelCount,t.samplerate=s.sampleRate,t.samples.push(o),{sample:o,length:s.frameLength,missing:0}}}}function u(t,e){var r=t[e+1]>>3&3,l=t[e+1]>>1&3,u=t[e+2]>>4&15,d=t[e+2]>>2&3;if(1!==r&&0!==u&&15!==u&&3!==d){var c=t[e+2]>>1&1,h=t[e+3]>>6,f=1e3*n[14*(3===r?3-l:3===l?3:4)+u-1],g=s[3*(3===r?0:2===r?1:2)+d],v=a[r][l],p=o[l];if(null===i){var m=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);i=m?parseInt(m[1]):0}return i&&i<=87&&2===l&&f>=224e3&&0===h&&(t[e+3]=128|t[e+3]),{sampleRate:g,channelCount:3===h?1:2,frameLength:Math.floor(v*f/g+c)*p,samplesPerFrame:8*v*p}}}function d(t,e){return 255===t[e]&&(224&t[e+1])==224&&(6&t[e+1])!=0}function c(t,e){return e+1<t.length&&d(t,e)}function h(t,e){return d(t,e)&&4<=t.length-e}function f(t,e){if(e+1<t.length&&d(t,e)){var r=u(t,e),i=4;null!=r&&r.frameLength&&(i=r.frameLength);var n=e+i;return n===t.length||c(t,n)}return!1}},"./src/demux/sample-aes.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>a});var i=r(/*! ../crypt/decrypter */"./src/crypt/decrypter.ts"),n=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),s=function(){function t(t,e,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new i.default(e,{removePKCS7Padding:!1})}var e=t.prototype;return e.decryptBuffer=function(t){return this.decrypter.decrypt(t,this.keyData.key.buffer,this.keyData.iv.buffer)},e.decryptAacSample=function(t,e,r){var i=this,n=t[e].unit;if(!(n.length<=16)){var s=n.subarray(16,n.length-n.length%16),a=s.buffer.slice(s.byteOffset,s.byteOffset+s.length);this.decryptBuffer(a).then(function(s){var a=new Uint8Array(s);n.set(a,16),i.decrypter.isSync()||i.decryptAacSamples(t,e+1,r)})}},e.decryptAacSamples=function(t,e,r){for(;;e++){if(e>=t.length){r();return}if(!(t[e].unit.length<32)&&(this.decryptAacSample(t,e,r),!this.decrypter.isSync()))return}},e.getAvcEncryptedData=function(t){for(var e=16*Math.floor((t.length-48)/160)+16,r=new Int8Array(e),i=0,n=32;n<t.length-16;n+=160,i+=16)r.set(t.subarray(n,n+16),i);return r},e.getAvcDecryptedUnit=function(t,e){for(var r=new Uint8Array(e),i=0,n=32;n<t.length-16;n+=160,i+=16)t.set(r.subarray(i,i+16),n);return t},e.decryptAvcSample=function(t,e,r,i,s){var a=this,o=(0,n.discardEPB)(s.data),l=this.getAvcEncryptedData(o);this.decryptBuffer(l.buffer).then(function(n){s.data=a.getAvcDecryptedUnit(o,n),a.decrypter.isSync()||a.decryptAvcSamples(t,e,r+1,i)})},e.decryptAvcSamples=function(t,e,r,i){if(t instanceof Uint8Array)throw Error("Cannot decrypt samples of type Uint8Array");for(;;e++,r=0){if(e>=t.length){i();return}for(var n=t[e].units;!(r>=n.length);r++){var s=n[r];if(!(s.data.length<=48)&&(1===s.type||5===s.type)&&(this.decryptAvcSample(t,e,r,i,s),!this.decrypter.isSync()))return}}},t}();let a=s},"./src/demux/transmuxer-interface.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>c});var i=r(/*! ./webworkify-webpack */"./src/demux/webworkify-webpack.js"),n=r(/*! ../events */"./src/events.ts"),s=r(/*! ../demux/transmuxer */"./src/demux/transmuxer.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=r(/*! ../errors */"./src/errors.ts"),l=r(/*! ../utils/mediasource-helper */"./src/utils/mediasource-helper.ts"),u=r(/*! eventemitter3 */"./node_modules/eventemitter3/index.js"),d=(0,l.getMediaSource)()||{isTypeSupported:function(){return!1}},c=function(){function t(t,e,r,l){var c,h=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 f=t.config;this.hls=t,this.id=e,this.useWorker=!!f.enableWorker,this.onTransmuxComplete=r,this.onFlush=l;var g=function(t,e){(e=e||{}).frag=h.frag,e.id=h.id,h.hls.trigger(t,e)};this.observer=new u.EventEmitter,this.observer.on(n.Events.FRAG_DECRYPTED,g),this.observer.on(n.Events.ERROR,g);var v={mp4:d.isTypeSupported("video/mp4"),mpeg:d.isTypeSupported("audio/mpeg"),mp3:d.isTypeSupported('audio/mp4; codecs="mp3"')},p=navigator.vendor;if(this.useWorker&&"undefined"!=typeof Worker){a.logger.log("demuxing in webworker");try{c=this.worker=(0,i.default)(/*! ../demux/transmuxer-worker.ts */"./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),c.addEventListener("message",this.onwmsg),c.onerror=function(t){h.useWorker=!1,a.logger.warn("Exception in webworker, fallback to inline"),h.hls.trigger(n.Events.ERROR,{type:o.ErrorTypes.OTHER_ERROR,details:o.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:Error(t.message+" ("+t.filename+":"+t.lineno+")")})},c.postMessage({cmd:"init",typeSupported:v,vendor:p,id:e,config:JSON.stringify(f)})}catch(t){a.logger.warn("Error in worker:",t),a.logger.error("Error while initializing DemuxerWorker, fallback to inline"),c&&self.URL.revokeObjectURL(c.objectURL),this.transmuxer=new s.default(this.observer,v,f,p,e),this.worker=null}}else this.transmuxer=new s.default(this.observer,v,f,p,e)}var e=t.prototype;return e.destroy=function(){var t=this.worker;if(t)t.removeEventListener("message",this.onwmsg),t.terminate(),this.worker=null,this.onwmsg=void 0;else{var e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}var r=this.observer;r&&r.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},e.push=function(t,e,r,i,n,o,l,u,d,c){var h,f,g=this;d.transmuxing.start=self.performance.now();var v=this.transmuxer,p=this.worker,m=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,D=0===b&&d.id>1&&d.id===(null==E?void 0:E.stats.chunkCount),A=!S&&(1===b||0===b&&(1===L||D&&L<=0)),k=self.performance.now();(S||b||0===n.stats.parsing.start)&&(n.stats.parsing.start=k),o&&(L||!A)&&(o.stats.parsing.start=k);var I=!(E&&(null===(h=n.initSegment)||void 0===h?void 0:h.url)===(null===(f=E.initSegment)||void 0===f?void 0:f.url)),R=new s.TransmuxState(T,A,u,S,m,I);if(!A||T||I){a.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: "+A+"\n accurateTimeOffset: "+u+"\n timeOffset: "+m+"\n initSegmentChange: "+I);var C=new s.TransmuxConfig(r,i,e,l,c);this.configureTransmuxer(C)}if(this.frag=n,this.part=o,p)p.postMessage({cmd:"demux",data:t,decryptdata:y,chunkMeta:d,state:R},t instanceof ArrayBuffer?[t]:[]);else if(v){var _=v.push(t,y,d,R);(0,s.isPromise)(_)?(v.async=!0,_.then(function(t){g.handleTransmuxComplete(t)}).catch(function(t){g.transmuxerError(t,d,"transmuxer-interface push error")})):(v.async=!1,this.handleTransmuxComplete(_))}},e.flush=function(t){var e=this;t.transmuxing.start=self.performance.now();var r=this.transmuxer,i=this.worker;if(i)i.postMessage({cmd:"flush",chunkMeta:t});else if(r){var n=r.flush(t);(0,s.isPromise)(n)||r.async?((0,s.isPromise)(n)||(n=Promise.resolve(n)),n.then(function(r){e.handleFlushResult(r,t)}).catch(function(r){e.transmuxerError(r,t,"transmuxer-interface flush error")})):this.handleFlushResult(n,t)}},e.transmuxerError=function(t,e,r){this.hls&&this.hls.trigger(n.Events.ERROR,{type:o.ErrorTypes.MEDIA_ERROR,details:o.ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:e,fatal:!1,error:t,err:t,reason:r})},e.handleFlushResult=function(t,e){var r=this;t.forEach(function(t){r.handleTransmuxComplete(t)}),this.onFlush(e)},e.onWorkerMessage=function(t){var e=t.data,r=this.hls;switch(e.event){case"init":self.URL.revokeObjectURL(this.worker.objectURL);break;case"transmuxComplete":this.handleTransmuxComplete(e.data);break;case"flush":this.onFlush(e.data);break;case"workerLog":a.logger[e.data.logType]&&a.logger[e.data.logType](e.data.message);break;default:e.data=e.data||{},e.data.frag=this.frag,e.data.id=this.id,r.trigger(e.event,e.data)}},e.configureTransmuxer=function(t){var e=this.worker,r=this.transmuxer;e?e.postMessage({cmd:"configure",config:t}):r&&r.configure(t)},e.handleTransmuxComplete=function(t){t.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(t)},t}()},"./src/demux/transmuxer-worker.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>l});var i=r(/*! ../demux/transmuxer */"./src/demux/transmuxer.ts"),n=r(/*! ../events */"./src/events.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),a=r(/*! eventemitter3 */"./node_modules/eventemitter3/index.js"),o=r(/*! ../errors */"./src/errors.ts");function l(t){var e=new a.EventEmitter,r=function(e,r){t.postMessage({event:e,data:r})};e.on(n.Events.FRAG_DECRYPTED,r),e.on(n.Events.ERROR,r);var l=function(){var t=function(t){s.logger[t]=function(e){r("workerLog",{logType:t,message:e})}};for(var e in s.logger)t(e)};t.addEventListener("message",function(a){var d=a.data;switch(d.cmd){case"init":var h=JSON.parse(d.config);t.transmuxer=new i.default(e,d.typeSupported,h,d.vendor,d.id),(0,s.enableLogs)(h.debug,d.id),l(),r("init",null);break;case"configure":t.transmuxer.configure(d.config);break;case"demux":var f=t.transmuxer.push(d.data,d.decryptdata,d.chunkMeta,d.state);(0,i.isPromise)(f)?(t.transmuxer.async=!0,f.then(function(e){u(t,e)}).catch(function(t){r(n.Events.ERROR,{type:o.ErrorTypes.MEDIA_ERROR,details:o.ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:d.chunkMeta,fatal:!1,error:t,err:t,reason:"transmuxer-worker push error"})})):(t.transmuxer.async=!1,u(t,f));break;case"flush":var g=d.chunkMeta,v=t.transmuxer.flush(g);(0,i.isPromise)(v)||t.transmuxer.async?((0,i.isPromise)(v)||(v=Promise.resolve(v)),v.then(function(e){c(t,e,g)}).catch(function(t){r(n.Events.ERROR,{type:o.ErrorTypes.MEDIA_ERROR,details:o.ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:d.chunkMeta,fatal:!1,error:t,err:t,reason:"transmuxer-worker flush error"})})):c(t,v,g)}})}function u(t,e){if(!(r=e.remuxResult).audio&&!r.video&&!r.text&&!r.id3&&!r.initSegment)return!1;var r,i=[],n=e.remuxResult,s=n.audio,a=n.video;return s&&d(i,s),a&&d(i,a),t.postMessage({event:"transmuxComplete",data:e},i),!0}function d(t,e){e.data1&&t.push(e.data1.buffer),e.data2&&t.push(e.data2.buffer)}function c(t,e,r){e.reduce(function(e,r){return u(t,r)||e},!1)||t.postMessage({event:"transmuxComplete",data:e[0]}),t.postMessage({event:"flush",data:r})}},"./src/demux/transmuxer.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{TransmuxConfig:()=>y,TransmuxState:()=>E,default:()=>v,isPromise:()=>m});var i,n=r(/*! ../events */"./src/events.ts"),s=r(/*! ../errors */"./src/errors.ts"),a=r(/*! ../crypt/decrypter */"./src/crypt/decrypter.ts"),o=r(/*! ../demux/aacdemuxer */"./src/demux/aacdemuxer.ts"),l=r(/*! ../demux/mp4demuxer */"./src/demux/mp4demuxer.ts"),u=r(/*! ../demux/tsdemuxer */"./src/demux/tsdemuxer.ts"),d=r(/*! ../demux/mp3demuxer */"./src/demux/mp3demuxer.ts"),c=r(/*! ../remux/mp4-remuxer */"./src/remux/mp4-remuxer.ts"),h=r(/*! ../remux/passthrough-remuxer */"./src/remux/passthrough-remuxer.ts"),f=r(/*! ../utils/logger */"./src/utils/logger.ts");try{i=self.performance.now.bind(self.performance)}catch(t){f.logger.debug("Unable to use Performance API on this environment"),i=self.Date.now}var g=[{demux:l.default,remux:h.default},{demux:u.default,remux:c.default},{demux:o.default,remux:c.default},{demux:d.default,remux:c.default}],v=function(){function t(t,e,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=t,this.typeSupported=e,this.config=r,this.vendor=i,this.id=n}var e=t.prototype;return e.configure=function(t){this.transmuxConfig=t,this.decrypter&&this.decrypter.reset()},e.push=function(t,e,r,n){var s,a=this,o=r.transmuxing;o.executeStart=i();var l=new Uint8Array(t),u=this.currentTransmuxState,d=this.transmuxConfig;n&&(this.currentTransmuxState=n);var c=n||u,h=c.contiguous,f=c.discontinuity,g=c.trackSwitch,v=c.accurateTimeOffset,m=c.timeOffset,y=c.initSegmentChange,E=d.audioCodec,T=d.videoCodec,S=d.defaultInitPts,b=d.duration,L=d.initSegmentData,D=(s=null,l.byteLength>0&&null!=e&&null!=e.key&&null!==e.iv&&null!=e.method&&(s=e),s);if(D&&"AES-128"===D.method){var A=this.getDecrypter();if(!A.isSync())return this.decryptionPromise=A.webCryptoDecrypt(l,D.key.buffer,D.iv.buffer).then(function(t){var e=a.push(t,null,r);return a.decryptionPromise=null,e}),this.decryptionPromise;var k=A.softwareDecrypt(l,D.key.buffer,D.iv.buffer);if(r.part>-1&&(k=A.flush()),!k)return o.executeEnd=i(),p(r);l=new Uint8Array(k)}var I=this.needsProbing(f,g);I&&this.configureTransmuxer(l),(f||g||y||I)&&this.resetInitSegment(L,E,T,b,e),(f||y||I)&&this.resetInitialTimestamp(S),h||this.resetContiguity();var R=this.transmux(l,D,m,v,r),C=this.currentTransmuxState;return C.contiguous=!0,C.discontinuity=!1,C.trackSwitch=!1,o.executeEnd=i(),R},e.flush=function(t){var e=this,r=t.transmuxing;r.executeStart=i();var a=this.decrypter,o=this.currentTransmuxState,l=this.decryptionPromise;if(l)return l.then(function(){return e.flush(t)});var u=[],d=o.timeOffset;if(a){var c=a.flush();c&&u.push(this.push(c,null,t))}var h=this.demuxer,f=this.remuxer;if(!h||!f)return this.observer.emit(n.Events.ERROR,n.Events.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),r.executeEnd=i(),[p(t)];var g=h.flush(d);return m(g)?g.then(function(r){return e.flushRemux(u,r,t),u}):(this.flushRemux(u,g,t),u)},e.flushRemux=function(t,e,r){var n=e.audioTrack,s=e.videoTrack,a=e.id3Track,o=e.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,s,a,o,d,u,!0,this.id);t.push({remuxResult:c,chunkMeta:r}),r.transmuxing.executeEnd=i()},e.resetInitialTimestamp=function(t){var e=this.demuxer,r=this.remuxer;e&&r&&(e.resetTimeStamp(t),r.resetTimeStamp(t))},e.resetContiguity=function(){var t=this.demuxer,e=this.remuxer;t&&e&&(t.resetContiguity(),e.resetNextTimestamp())},e.resetInitSegment=function(t,e,r,i,n){var s=this.demuxer,a=this.remuxer;s&&a&&(s.resetInitSegment(t,e,r,i),a.resetInitSegment(t,e,r,n))},e.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},e.transmux=function(t,e,r,i,n){return e&&"SAMPLE-AES"===e.method?this.transmuxSampleAes(t,e,r,i,n):this.transmuxUnencrypted(t,r,i,n)},e.transmuxUnencrypted=function(t,e,r,i){var n=this.demuxer.demux(t,e,!1,!this.config.progressive),s=n.audioTrack,a=n.videoTrack,o=n.id3Track,l=n.textTrack;return{remuxResult:this.remuxer.remux(s,a,o,l,e,r,!1,this.id),chunkMeta:i}},e.transmuxSampleAes=function(t,e,r,i,n){var s=this;return this.demuxer.demuxSampleAes(t,e,r).then(function(t){return{remuxResult:s.remuxer.remux(t.audioTrack,t.videoTrack,t.id3Track,t.textTrack,r,i,!1,s.id),chunkMeta:n}})},e.configureTransmuxer=function(t){for(var e,r=this.config,i=this.observer,n=this.typeSupported,s=this.vendor,a=0,o=g.length;a<o;a++)if(g[a].demux.probe(t)){e=g[a];break}e||(f.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),e={demux:l.default,remux:h.default});var u=this.demuxer,d=this.remuxer,c=e.remux,v=e.demux;d&&d instanceof c||(this.remuxer=new c(i,r,n,s)),u&&u instanceof v||(this.demuxer=new v(i,r,n),this.probe=v.probe)},e.needsProbing=function(t,e){return!this.demuxer||!this.remuxer||t||e},e.getDecrypter=function(){var t=this.decrypter;return t||(t=this.decrypter=new a.default(this.config)),t},t}(),p=function(t){return{remuxResult:{},chunkMeta:t}};function m(t){return"then"in t&&t.then instanceof Function}var y=function(t,e,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=t,this.videoCodec=e,this.initSegmentData=r,this.duration=i,this.defaultInitPts=n},E=function(t,e,r,i,n,s){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=t,this.contiguous=e,this.accurateTimeOffset=r,this.trackSwitch=i,this.timeOffset=n,this.initSegmentChange=s}},"./src/demux/tsdemuxer.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>y});var i=r(/*! ./adts */"./src/demux/adts.ts"),n=r(/*! ./mpegaudio */"./src/demux/mpegaudio.ts"),s=r(/*! ./exp-golomb */"./src/demux/exp-golomb.ts"),a=r(/*! ./sample-aes */"./src/demux/sample-aes.ts"),o=r(/*! ../events */"./src/events.ts"),l=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),u=r(/*! ../utils/logger */"./src/utils/logger.ts"),d=r(/*! ../errors */"./src/errors.ts"),c=r(/*! ../types/demuxer */"./src/types/demuxer.ts");function h(){return(h=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t}).apply(this,arguments)}var f=function(){function t(t,e,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=t,this.config=e,this.typeSupported=r}t.probe=function(e){var r=t.syncOffset(e);return r>0&&u.logger.warn("MPEG2-TS detected but first sync word found @ offset "+r),-1!==r},t.syncOffset=function(t){for(var e=t.length,r=Math.min(940,t.length-188)+1,i=0;i<r;){for(var n=!1,s=i;s<e;s+=188)if(71===t[s]){if(n||0!==v(t,s)||(n=!0),n&&s+188>r)return i}else break;i++}return -1},t.createTrack=function(t,e){return{container:"video"===t||"audio"===t?"video/mp2t":void 0,type:t,id:l.RemuxerTrackIdConfig[t],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===t?e:void 0}};var e=t.prototype;return e.resetInitSegment=function(e,r,i,n){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=t.createTrack("video"),this._audioTrack=t.createTrack("audio",n),this._id3Track=t.createTrack("id3"),this._txtTrack=t.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=r,this.videoCodec=i,this._duration=n},e.resetTimeStamp=function(){},e.resetContiguity=function(){var t=this._audioTrack,e=this._avcTrack,r=this._id3Track;t&&(t.pesData=null),e&&(e.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null},e.demux=function(e,r,i,n){void 0===i&&(i=!1),void 0===n&&(n=!1),i||(this.sampleAes=null);var s,a=this._avcTrack,c=this._audioTrack,h=this._id3Track,f=this._txtTrack,g=a.pid,m=a.pesData,y=c.pid,E=h.pid,T=c.pesData,S=h.pesData,b=null,L=this.pmtParsed,D=this._pmtId,A=e.length;if(this.remainderData&&(A=(e=(0,l.appendUint8Array)(this.remainderData,e)).length,this.remainderData=null),A<188&&!n)return this.remainderData=e,{audioTrack:c,videoTrack:a,id3Track:h,textTrack:f};var k=Math.max(0,t.syncOffset(e));(A-=(A-k)%188)<e.byteLength&&!n&&(this.remainderData=new Uint8Array(e.buffer,A,e.buffer.byteLength-A));for(var I=0,R=k;R<A;R+=188)if(71===e[R]){var C,_,P=!!(64&e[R+1]),O=v(e,R),w=(48&e[R+3])>>4,x=void 0;if(w>1){if((x=R+5+e[R+4])===R+188)continue}else x=R+4;switch(O){case g:P&&(m&&(s=p(m))&&this.parseAVCPES(a,f,s,!1),m={data:[],size:0}),m&&(m.data.push(e.subarray(x,R+188)),m.size+=R+188-x);break;case y:if(P){if(T&&(s=p(T)))switch(c.segmentCodec){case"aac":this.parseAACPES(c,s);break;case"mp3":this.parseMPEGPES(c,s)}T={data:[],size:0}}T&&(T.data.push(e.subarray(x,R+188)),T.size+=R+188-x);break;case E:P&&(S&&(s=p(S))&&this.parseID3PES(h,s),S={data:[],size:0}),S&&(S.data.push(e.subarray(x,R+188)),S.size+=R+188-x);break;case 0:P&&(x+=e[x]+1),D=this._pmtId=(31&(C=e)[(_=x)+10])<<8|C[_+11];break;case D:P&&(x+=e[x]+1);var F=function(t,e,r,i){var n={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},s=(15&t[e+1])<<8|t[e+2],a=e+3+s-4,o=(15&t[e+10])<<8|t[e+11];for(e+=12+o;e<a;){var l=v(t,e);switch(t[e]){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=l);break;case 21:-1===n.id3&&(n.id3=l);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=l);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=l,n.segmentCodec="mp3");break;case 36:u.logger.warn("Unsupported HEVC stream type found")}e+=((15&t[e+3])<<8|t[e+4])+5}return n}(e,x,this.typeSupported,i);(g=F.avc)>0&&(a.pid=g),(y=F.audio)>0&&(c.pid=y,c.segmentCodec=F.segmentCodec),(E=F.id3)>0&&(h.pid=E),null===b||L||(u.logger.warn("MPEG-TS PMT found at "+R+" after unknown PID '"+b+"'. Backtracking to sync byte @"+k+" to parse all TS packets."),b=null,R=k-188),L=this.pmtParsed=!0;break;case 17:case 8191:break;default:b=O}}else I++;I>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 "+I+" TS packet/s that do not start with 0x47"}),a.pesData=m,c.pesData=T,h.pesData=S;var M={audioTrack:c,videoTrack:a,id3Track:h,textTrack:f};return n&&this.extractRemainingSamples(M),M},e.flush=function(){var t,e=this.remainderData;return(this.remainderData=null,t=e?this.demux(e,-1,!1,!0):{videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes)?this.decrypt(t,this.sampleAes):t},e.extractRemainingSamples=function(t){var e,r=t.audioTrack,i=t.videoTrack,n=t.id3Track,s=t.textTrack,a=i.pesData,o=r.pesData,l=n.pesData;if(a&&(e=p(a))?(this.parseAVCPES(i,s,e,!0),i.pesData=null):i.pesData=a,o&&(e=p(o))){switch(r.segmentCodec){case"aac":this.parseAACPES(r,e);break;case"mp3":this.parseMPEGPES(r,e)}r.pesData=null}else null!=o&&o.size&&u.logger.log("last AAC PES packet truncated,might overlap between fragments"),r.pesData=o;l&&(e=p(l))?(this.parseID3PES(n,e),n.pesData=null):n.pesData=l},e.demuxSampleAes=function(t,e,r){var i=this.demux(t,r,!0,!this.config.progressive),n=this.sampleAes=new a.default(this.observer,this.config,e);return this.decrypt(i,n)},e.decrypt=function(t,e){return new Promise(function(r){var i=t.audioTrack,n=t.videoTrack;i.samples&&"aac"===i.segmentCodec?e.decryptAacSamples(i.samples,0,function(){n.samples?e.decryptAvcSamples(n.samples,0,0,function(){r(t)}):r(t)}):n.samples&&e.decryptAvcSamples(n.samples,0,0,function(){r(t)})})},e.destroy=function(){this._duration=0},e.parseAVCPES=function(t,e,r,i){var n,a=this,o=this.parseAVCNALu(t,r.data),u=this.avcSample,d=!1;r.data=null,u&&o.length&&!t.audFound&&(m(u,t),u=this.avcSample=g(!1,r.pts,r.dts,"")),o.forEach(function(i){switch(i.type){case 1:n=!0,u||(u=a.avcSample=g(!0,r.pts,r.dts,"")),u.frame=!0;var o=i.data;if(d&&o.length>4){var c=new s.default(o).readSliceType();(2===c||4===c||7===c||9===c)&&(u.key=!0)}break;case 5:n=!0,u||(u=a.avcSample=g(!0,r.pts,r.dts,"")),u.key=!0,u.frame=!0;break;case 6:n=!0,(0,l.parseSEIMessageFromNALu)(i.data,1,r.pts,e.samples);break;case 7:if(n=!0,d=!0,!t.sps){var h=new s.default(i.data).readSPS();t.width=h.width,t.height=h.height,t.pixelRatio=h.pixelRatio,t.sps=[i.data],t.duration=a._duration;for(var f=i.data.subarray(1,4),v="avc1.",p=0;p<3;p++){var y=f[p].toString(16);y.length<2&&(y="0"+y),v+=y}t.codec=v}break;case 8:n=!0,t.pps||(t.pps=[i.data]);break;case 9:n=!1,t.audFound=!0,u&&m(u,t),u=a.avcSample=g(!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&&(m(u,t),this.avcSample=null)},e.getLastNalUnit=function(t){var e,r,i=this.avcSample;if(i&&0!==i.units.length||(i=t[t.length-1]),null!==(e=i)&&void 0!==e&&e.units){var n=i.units;r=n[n.length-1]}return r},e.parseAVCNALu=function(t,e){var r,i,n,s=e.byteLength,a=t.naluState||0,o=a,l=[],u=0,d=-1,c=0;for(-1===a&&(d=0,c=31&e[0],a=0,u=1);u<s;){if(r=e[u++],!a){a=r?0:1;continue}if(1===a){a=r?0:2;continue}if(r){if(1===r){if(d>=0){var h={data:e.subarray(d,u-a-1),type:c};l.push(h)}else{var f=this.getLastNalUnit(t.samples);if(f&&(o&&u<=4-o&&f.state&&(f.data=f.data.subarray(0,f.data.byteLength-o)),(i=u-a-1)>0)){var g=new Uint8Array(f.data.byteLength+i);g.set(f.data,0),g.set(e.subarray(0,i),f.data.byteLength),f.data=g,f.state=0}}u<s?(n=31&e[u],d=u,c=n,a=0):a=-1}else a=0}else a=3}if(d>=0&&a>=0){var v={data:e.subarray(d,s),type:c,state:a};l.push(v)}if(0===l.length){var p=this.getLastNalUnit(t.samples);if(p){var m=new Uint8Array(p.data.byteLength+e.byteLength);m.set(p.data,0),m.set(e,p.data.byteLength),p.data=m}}return t.naluState=a,l},e.parseAACPES=function(t,e){var r,n,s,a,l,c,h=0,f=this.aacOverFlow,g=e.data;if(f){this.aacOverFlow=null;var v=f.missing,p=f.sample.unit.byteLength;if(-1===v){var m=new Uint8Array(p+g.byteLength);m.set(f.sample.unit,0),m.set(g,p),g=m}else{var y=p-v;f.sample.unit.set(g.subarray(0,v),y),t.samples.push(f.sample),h=f.missing}}for(r=h,n=g.length;r<n-1&&!i.isHeader(g,r);r++);if(r===h||(r<n-1?(s="AAC PES did not start with ADTS header,offset:"+r,a=!1):(s="no ADTS header found in AAC PES",a=!0),u.logger.warn("parsing error:"+s),this.observer.emit(o.Events.ERROR,o.Events.ERROR,{type:d.ErrorTypes.MEDIA_ERROR,details:d.ErrorDetails.FRAG_PARSING_ERROR,fatal:a,reason:s}),!a)){if(i.initTrackConfig(t,this.observer,g,r,this.audioCodec),void 0!==e.pts)l=e.pts;else if(f){var E=i.getFrameDuration(t.samplerate);l=f.sample.pts+E}else{u.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var T=0;r<n;){if(c=i.appendFrame(t,g,r,l,T),r+=c.length,c.missing){this.aacOverFlow=c;break}for(T++;r<n-1&&!i.isHeader(g,r);r++);}}},e.parseMPEGPES=function(t,e){var r=e.data,i=r.length,s=0,a=0,o=e.pts;if(void 0===o){u.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<i;)if(n.isHeader(r,a)){var l=n.appendFrame(t,r,a,o,s);if(l)a+=l.length,s++;else break}else a++},e.parseID3PES=function(t,e){if(void 0===e.pts){u.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}var r=h({},e,{type:this._avcTrack?c.MetadataSchema.emsg:c.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY});t.samples.push(r)},t}();function g(t,e,r,i){return{key:t,frame:!1,pts:e,dts:r,units:[],debug:i,length:0}}function v(t,e){return((31&t[e+1])<<8)+t[e+2]}function p(t){var e,r,i,n,s,a=0,o=t.data;if(!t||0===t.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===((e=o[0])[0]<<16)+(e[1]<<8)+e[2]){if((r=(e[4]<<8)+e[5])&&r>t.size-6)return null;var d=e[7];192&d&&(n=(14&e[9])*536870912+(255&e[10])*4194304+(254&e[11])*16384+(255&e[12])*128+(254&e[13])/2,64&d?n-(s=(14&e[14])*536870912+(255&e[15])*4194304+(254&e[16])*16384+(255&e[17])*128+(254&e[18])/2)>54e5&&(u.logger.warn(Math.round((n-s)/9e4)+"s delta between PTS and DTS, align them"),n=s):s=n);var c=(i=e[8])+9;if(t.size<=c)return null;t.size-=c;for(var h=new Uint8Array(t.size),f=0,g=o.length;f<g;f++){var v=(e=o[f]).byteLength;if(c){if(c>v){c-=v;continue}e=e.subarray(c),v-=c,c=0}h.set(e,a),a+=v}return r&&(r-=i+3),{data:h,pts:n,dts:s,len:r}}return null}function m(t,e){if(t.units.length&&t.frame){if(void 0===t.pts){var r=e.samples,i=r.length;if(i){var n=r[i-1];t.pts=n.pts,t.dts=n.dts}else{e.dropped++;return}}e.samples.push(t)}t.debug.length&&u.logger.log(t.pts+"/"+t.dts+":"+t.debug)}let y=f},"./src/demux/webworkify-webpack.js":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>l});var i=(function(){var t=ENTRY_MODULE,e={},r=function r(i){var n=e[i];if(void 0!==n)return n.exports;var s=e[i]={exports:{}};return t[i].call(s.exports,s,s.exports,r),s.exports};r.m=t,r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,{a:e}),e},r.d=function(t,e){for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i=r(ENTRY_MODULE);return i.default||i}).toString().split("ENTRY_MODULE"),n="[\\.|\\-|\\+|\\w|/|@]+",s="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+n+").*?\\)";function a(t){return(t+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function o(t,e,r,n){var s=t[n].map(function(t){return'"'+t+'": '+e[n][t].toString().replace(/^"[^"]+"/,"function")}).join(",");return i[0]+"{"+s+"}"+i[1]+'"'+r+'"'+i[2]}function l(t,e){e=e||{};var i={main:r.m},l=e.all?{main:Object.keys(i.main)}:function(t,e){for(var i={main:[e]},o={main:[]},l={main:{}};Object.keys(i).reduce(function(t,e){return t||i[e].length>0},!1);)for(var u=Object.keys(i),d=0;d<u.length;d++){var c=u[d],h=i[c].pop();if(l[c]=l[c]||{},!l[c][h]&&t[c][h]){l[c][h]=!0,o[c]=o[c]||[],o[c].push(h);for(var f=function(t,e,i){var o,l={};l[i]=[];var u=e.toString().replace(/^"[^"]+"/,"function"),d=u.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/)||u.match(/^\(\w+,\s*\w+,\s*(\w+)\)\s?\=\s?\>/);if(!d)return l;for(var c=d[1],h=RegExp("(\\\\n|\\W)"+a(c)+s,"g");o=h.exec(u);)"dll-reference"!==o[3]&&l[i].push(o[3]);for(h=RegExp("\\("+a(c)+'\\("(dll-reference\\s('+n+'))"\\)\\)'+s,"g");o=h.exec(u);)t[o[2]]||(l[i].push(o[1]),t[o[2]]=r(o[1]).m),l[o[2]]=l[o[2]]||[],l[o[2]].push(o[4]);for(var f=Object.keys(l),g=0;g<f.length;g++)for(var v=0;v<l[f[g]].length;v++)isNaN(1*l[f[g]][v])||(l[f[g]][v]=1*l[f[g]][v]);return l}(t,t[c][h],c),g=Object.keys(f),v=0;v<g.length;v++)i[g[v]]=i[g[v]]||[],i[g[v]]=i[g[v]].concat(f[g[v]])}}return o}(i,t),u="";Object.keys(l).filter(function(t){return"main"!==t}).forEach(function(t){for(var e=0;l[t][e];)e++;l[t].push(e),i[t][e]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",u=u+"var "+t+" = ("+o(l,i,e,modules)+")();\n"}),u=u+"new (("+o(l,i,t,"main")+")())(self);";var d=new window.Blob([u],{type:"text/javascript"}),c=(window.URL||window.webkitURL||window.mozURL||window.msURL).createObjectURL(d),h=new window.Worker(c);return h.objectURL=c,h}},"./src/errors.ts":(t,e,r)=>{"use strict";var i,n,s,a;r.r(e),r.d(e,{ErrorDetails:()=>n,ErrorTypes:()=>i}),(s=i||(i={})).NETWORK_ERROR="networkError",s.MEDIA_ERROR="mediaError",s.KEY_SYSTEM_ERROR="keySystemError",s.MUX_ERROR="muxError",s.OTHER_ERROR="otherError",(a=n||(n={})).KEY_SYSTEM_NO_KEYS="keySystemNoKeys",a.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",a.KEY_SYSTEM_NO_SESSION="keySystemNoSession",a.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",a.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",a.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",a.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",a.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",a.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",a.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",a.MANIFEST_LOAD_ERROR="manifestLoadError",a.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",a.MANIFEST_PARSING_ERROR="manifestParsingError",a.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",a.LEVEL_EMPTY_ERROR="levelEmptyError",a.LEVEL_LOAD_ERROR="levelLoadError",a.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",a.LEVEL_SWITCH_ERROR="levelSwitchError",a.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",a.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",a.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",a.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",a.FRAG_LOAD_ERROR="fragLoadError",a.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",a.FRAG_DECRYPT_ERROR="fragDecryptError",a.FRAG_PARSING_ERROR="fragParsingError",a.REMUX_ALLOC_ERROR="remuxAllocError",a.KEY_LOAD_ERROR="keyLoadError",a.KEY_LOAD_TIMEOUT="keyLoadTimeOut",a.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",a.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",a.BUFFER_APPEND_ERROR="bufferAppendError",a.BUFFER_APPENDING_ERROR="bufferAppendingError",a.BUFFER_STALLED_ERROR="bufferStalledError",a.BUFFER_FULL_ERROR="bufferFullError",a.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",a.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",a.INTERNAL_EXCEPTION="internalException",a.INTERNAL_ABORTED="aborted",a.UNKNOWN="unknown"},"./src/events.ts":(t,e,r)=>{"use strict";var i,n;r.r(e),r.d(e,{Events:()=>i}),(n=i||(i={})).MEDIA_ATTACHING="hlsMediaAttaching",n.MEDIA_ATTACHED="hlsMediaAttached",n.MEDIA_DETACHING="hlsMediaDetaching",n.MEDIA_DETACHED="hlsMediaDetached",n.BUFFER_RESET="hlsBufferReset",n.BUFFER_CODECS="hlsBufferCodecs",n.BUFFER_CREATED="hlsBufferCreated",n.BUFFER_APPENDING="hlsBufferAppending",n.BUFFER_APPENDED="hlsBufferAppended",n.BUFFER_EOS="hlsBufferEos",n.BUFFER_FLUSHING="hlsBufferFlushing",n.BUFFER_FLUSHED="hlsBufferFlushed",n.MANIFEST_LOADING="hlsManifestLoading",n.MANIFEST_LOADED="hlsManifestLoaded",n.MANIFEST_PARSED="hlsManifestParsed",n.LEVEL_SWITCHING="hlsLevelSwitching",n.LEVEL_SWITCHED="hlsLevelSwitched",n.LEVEL_LOADING="hlsLevelLoading",n.LEVEL_LOADED="hlsLevelLoaded",n.LEVEL_UPDATED="hlsLevelUpdated",n.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",n.LEVELS_UPDATED="hlsLevelsUpdated",n.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",n.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",n.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",n.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",n.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",n.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",n.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",n.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",n.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",n.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",n.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",n.CUES_PARSED="hlsCuesParsed",n.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",n.INIT_PTS_FOUND="hlsInitPtsFound",n.FRAG_LOADING="hlsFragLoading",n.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",n.FRAG_LOADED="hlsFragLoaded",n.FRAG_DECRYPTED="hlsFragDecrypted",n.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",n.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",n.FRAG_PARSING_METADATA="hlsFragParsingMetadata",n.FRAG_PARSED="hlsFragParsed",n.FRAG_BUFFERED="hlsFragBuffered",n.FRAG_CHANGED="hlsFragChanged",n.FPS_DROP="hlsFpsDrop",n.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",n.ERROR="hlsError",n.DESTROYING="hlsDestroying",n.KEY_LOADING="hlsKeyLoading",n.KEY_LOADED="hlsKeyLoaded",n.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",n.BACK_BUFFER_REACHED="hlsBackBufferReached"},"./src/hls.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>E});var i=r(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js"),n=r(/*! ./loader/playlist-loader */"./src/loader/playlist-loader.ts"),s=r(/*! ./controller/id3-track-controller */"./src/controller/id3-track-controller.ts"),a=r(/*! ./controller/latency-controller */"./src/controller/latency-controller.ts"),o=r(/*! ./controller/level-controller */"./src/controller/level-controller.ts"),l=r(/*! ./controller/fragment-tracker */"./src/controller/fragment-tracker.ts"),u=r(/*! ./loader/key-loader */"./src/loader/key-loader.ts"),d=r(/*! ./controller/stream-controller */"./src/controller/stream-controller.ts"),c=r(/*! ./is-supported */"./src/is-supported.ts"),h=r(/*! ./utils/logger */"./src/utils/logger.ts"),f=r(/*! ./config */"./src/config.ts"),g=r(/*! eventemitter3 */"./node_modules/eventemitter3/index.js"),v=r(/*! ./events */"./src/events.ts"),p=r(/*! ./errors */"./src/errors.ts"),m=r(/*! ./types/level */"./src/types/level.ts");function y(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var i=r.call(t,e||"default");if("object"!=typeof i)return i;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(i.key),i)}}var E=function(){function t(e){void 0===e&&(e={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new g.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)(t.DefaultConfig,e);this.userConfig=e,(0,h.enableLogs)(r.debug,"Hls instance"),this._autoLevelCapping=-1,r.progressive&&(0,f.enableStreamingMode)(r);var i=r.abrController,c=r.bufferController,v=r.capLevelController,p=r.fpsController,m=this.abrController=new i(this),y=this.bufferController=new c(this),E=this.capLevelController=new v(this),T=new p(this),S=new n.default(this),b=new s.default(this),L=this.levelController=new o.default(this),D=new l.FragmentTracker(this),A=new u.default(this.config),k=this.streamController=new d.default(this,D,A);E.setStreamController(k),T.setStreamController(k);var I=[S,L,k];this.networkControllers=I;var R=[m,y,E,T,b,D];this.audioTrackController=this.createController(r.audioTrackController,I);var C=r.audioStreamController;C&&I.push(new C(this,D,A)),this.subtitleTrackController=this.createController(r.subtitleTrackController,I);var _=r.subtitleStreamController;_&&I.push(new _(this,D,A)),this.createController(r.timelineController,R),A.emeController=this.emeController=this.createController(r.emeController,R),this.cmcdController=this.createController(r.cmcdController,R),this.latencyController=this.createController(a.default,R),this.coreComponents=R}t.isSupported=function(){return(0,c.isSupported)()};var e,r,E=t.prototype;return E.createController=function(t,e){if(t){var r=new t(this);return e&&e.push(r),r}return null},E.on=function(t,e,r){void 0===r&&(r=this),this._emitter.on(t,e,r)},E.once=function(t,e,r){void 0===r&&(r=this),this._emitter.once(t,e,r)},E.removeAllListeners=function(t){this._emitter.removeAllListeners(t)},E.off=function(t,e,r,i){void 0===r&&(r=this),this._emitter.off(t,e,r,i)},E.listeners=function(t){return this._emitter.listeners(t)},E.emit=function(t,e,r){return this._emitter.emit(t,e,r)},E.trigger=function(t,e){if(this.config.debug)return this.emit(t,t,e);try{return this.emit(t,t,e)}catch(e){h.logger.error("An internal error happened while handling event "+t+'. Error message: "'+e.message+'". Here is a stacktrace:',e),this.trigger(v.Events.ERROR,{type:p.ErrorTypes.OTHER_ERROR,details:p.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:t,error:e})}return!1},E.listenerCount=function(t){return this._emitter.listenerCount(t)},E.destroy=function(){h.logger.log("destroy"),this.trigger(v.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(t){return t.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(t){return t.destroy()}),this.coreComponents.length=0},E.attachMedia=function(t){h.logger.log("attachMedia"),this._media=t,this.trigger(v.Events.MEDIA_ATTACHING,{media:t})},E.detachMedia=function(){h.logger.log("detachMedia"),this.trigger(v.Events.MEDIA_DETACHING,void 0),this._media=null},E.loadSource=function(t){this.stopLoad();var e=this.media,r=this.url,n=this.url=i.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});h.logger.log("loadSource:"+n),e&&r&&r!==n&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(e)),this.trigger(v.Events.MANIFEST_LOADING,{url:t})},E.startLoad=function(t){void 0===t&&(t=-1),h.logger.log("startLoad("+t+")"),this.networkControllers.forEach(function(e){e.startLoad(t)})},E.stopLoad=function(){h.logger.log("stopLoad"),this.networkControllers.forEach(function(t){t.stopLoad()})},E.swapAudioCodec=function(){h.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},E.recoverMediaError=function(){h.logger.log("recoverMediaError");var t=this._media;this.detachMedia(),t&&this.attachMedia(t)},E.removeLevel=function(t,e){void 0===e&&(e=0),this.levelController.removeLevel(t,e)},e=[{key:"levels",get:function(){return this.levelController.levels||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(t){h.logger.log("set currentLevel:"+t),this.loadLevel=t,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(t){h.logger.log("set nextLevel:"+t),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(t){h.logger.log("set loadLevel:"+t),this.levelController.manualLevel=t}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(t){this.levelController.nextLoadLevel=t}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(t){h.logger.log("set firstLevel:"+t),this.levelController.firstLevel=t}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(t){h.logger.log("set startLevel:"+t),-1!==t&&(t=Math.max(t,this.minAutoLevel)),this.levelController.startLevel=t}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(t){var e=!!t;e!==this.config.capLevelToPlayerSize&&(e?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=e)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(t){this._autoLevelCapping!==t&&(h.logger.log("set autoLevelCapping:"+t),this._autoLevelCapping=t)}},{key:"bandwidthEstimate",get:function(){var t=this.abrController.bwEstimator;return t?t.getEstimate():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(t){m.HdcpLevels.indexOf(t)>-1&&(this._maxHdcpLevel=t)}},{key:"autoLevelEnabled",get:function(){return -1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var t=this.levels,e=this.config.minAutoBitrate;if(!t)return 0;for(var r=t.length,i=0;i<r;i++)if(t[i].maxBitrate>=e)return i;return 0}},{key:"maxAutoLevel",get:function(){var t,e=this.levels,r=this.autoLevelCapping,i=this.maxHdcpLevel;if(t=-1===r&&e&&e.length?e.length-1:r,i)for(var n=t;n--;){var s=e[n].attrs["HDCP-LEVEL"];if(s&&s<=i)return n}return t}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(t){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,t)}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"audioTracks",get:function(){var t=this.audioTrackController;return t?t.audioTracks:[]}},{key:"audioTrack",get:function(){var t=this.audioTrackController;return t?t.audioTrack:-1},set:function(t){var e=this.audioTrackController;e&&(e.audioTrack=t)}},{key:"subtitleTracks",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTrack:-1},set:function(t){var e=this.subtitleTrackController;e&&(e.subtitleTrack=t)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var t=this.subtitleTrackController;return!!t&&t.subtitleDisplay},set:function(t){var e=this.subtitleTrackController;e&&(e.subtitleDisplay=t)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(t){this.config.lowLatencyMode=t}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],r=[{key:"version",get:function(){return"1.3.5"}},{key:"Events",get:function(){return v.Events}},{key:"ErrorTypes",get:function(){return p.ErrorTypes}},{key:"ErrorDetails",get:function(){return p.ErrorDetails}},{key:"DefaultConfig",get:function(){return t.defaultConfig?t.defaultConfig:f.hlsDefaultConfig},set:function(e){t.defaultConfig=e}}],e&&y(t.prototype,e),r&&y(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}();E.defaultConfig=void 0},"./src/is-supported.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{changeTypeSupported:()=>a,isSupported:()=>s});var i=r(/*! ./utils/mediasource-helper */"./src/utils/mediasource-helper.ts");function n(){return self.SourceBuffer||self.WebKitSourceBuffer}function s(){var t=(0,i.getMediaSource)();if(!t)return!1;var e=n(),r=t&&"function"==typeof t.isTypeSupported&&t.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),s=!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove;return!!r&&!!s}function a(){var t,e=n();return"function"==typeof(null==e?void 0:null===(t=e.prototype)||void 0===t?void 0:t.changeType)}},"./src/loader/date-range.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{DateRange:()=>d,DateRangeAttribute:()=>n});var i,n,s=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),a=r(/*! ../utils/attr-list */"./src/utils/attr-list.ts"),o=r(/*! ../utils/logger */"./src/utils/logger.ts");function l(){return(l=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t}).apply(this,arguments)}function u(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var i=r.call(t,e||"default");if("object"!=typeof i)return i;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(i.key),i)}}(i=n||(n={})).ID="ID",i.CLASS="CLASS",i.START_DATE="START-DATE",i.DURATION="DURATION",i.END_DATE="END-DATE",i.END_ON_NEXT="END-ON-NEXT",i.PLANNED_DURATION="PLANNED-DURATION",i.SCTE35_OUT="SCTE35-OUT",i.SCTE35_IN="SCTE35-IN";var d=function(){var t,e;function r(t,e){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,e){var r=e.attr;for(var i in r)if(Object.prototype.hasOwnProperty.call(t,i)&&t[i]!==r[i]){o.logger.warn('DATERANGE tag attribute: "'+i+'" does not match for tags with ID: "'+t.ID+'"'),this._badValueForSameId=i;break}t=l(new a.AttrList({}),r,t)}if(this.attr=t,this._startDate=new Date(t[n.START_DATE]),n.END_DATE in this.attr){var u=new Date(this.attr[n.END_DATE]);(0,s.isFiniteNumber)(u.getTime())&&(this._endDate=u)}}return t=[{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 t=this.duration;return null!==t?new Date(this._startDate.getTime()+1e3*t):null}},{key:"duration",get:function(){if(n.DURATION in this.attr){var t=this.attr.decimalFloatingPoint(n.DURATION);if((0,s.isFiniteNumber)(t))return t}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return n.PLANNED_DURATION in this.attr?this.attr.decimalFloatingPoint(n.PLANNED_DURATION):null}},{key:"endOnNext",get:function(){return this.attr.bool(n.END_ON_NEXT)}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&(0,s.isFiniteNumber)(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)}}],u(r.prototype,t),e&&u(r,e),Object.defineProperty(r,"prototype",{writable:!1}),r}()},"./src/loader/fragment-loader.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{LoadError:()=>c,default:()=>u});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../errors */"./src/errors.ts");function s(t){var e="function"==typeof Map?new Map:void 0;return(s=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return a(t,arguments,l(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),o(r,t)})(t)}function a(t,e,r){return(a=!function(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}()?function(t,e,r){var i=[null];i.push.apply(i,e);var n=new(Function.bind.apply(t,i));return r&&o(n,r.prototype),n}:Reflect.construct.bind()).apply(null,arguments)}function o(t,e){return(o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}function l(t){return(l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var u=function(){function t(t){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t}var e=t.prototype;return e.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},e.abort=function(){this.loader&&this.loader.abort()},e.load=function(t,e){var r=this,i=t.url;if(!i)return Promise.reject(new c({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:t,networkDetails:null},"Fragment does not have a "+(i?"part list":"url")));this.abort();var s=this.config,a=s.fLoader,o=s.loader;return new Promise(function(i,l){r.loader&&r.loader.destroy();var u=r.loader=t.loader=a?new a(s):new o(s),h=d(t),f={timeout:s.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:s.fragLoadingMaxRetryTimeout,highWaterMark:"initSegment"===t.sn?1/0:131072};t.stats=u.stats,u.load(h,f,{onSuccess:function(e,n,s,a){r.resetLoader(t,u);var o=e.data;s.resetIV&&t.decryptdata&&(t.decryptdata.iv=new Uint8Array(o.slice(0,16)),o=o.slice(16)),i({frag:t,part:null,payload:o,networkDetails:a})},onError:function(e,i,s){r.resetLoader(t,u),l(new c({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:t,response:e,networkDetails:s}))},onAbort:function(e,i,s){r.resetLoader(t,u),l(new c({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:t,networkDetails:s}))},onTimeout:function(e,i,s){r.resetLoader(t,u),l(new c({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,networkDetails:s}))},onProgress:function(r,i,n,s){e&&e({frag:t,part:null,payload:n,networkDetails:s})}})})},e.loadPart=function(t,e,r){var i=this;this.abort();var s=this.config,a=s.fLoader,o=s.loader;return new Promise(function(l,u){i.loader&&i.loader.destroy();var h=i.loader=t.loader=a?new a(s):new o(s),f=d(t,e),g={timeout:s.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:s.fragLoadingMaxRetryTimeout,highWaterMark:131072};e.stats=h.stats,h.load(f,g,{onSuccess:function(n,s,a,o){i.resetLoader(t,h),i.updateStatsFromPart(t,e);var u={frag:t,part:e,payload:n.data,networkDetails:o};r(u),l(u)},onError:function(r,s,a){i.resetLoader(t,h),u(new c({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:t,part:e,response:r,networkDetails:a}))},onAbort:function(r,s,a){t.stats.aborted=e.stats.aborted,i.resetLoader(t,h),u(new c({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:t,part:e,networkDetails:a}))},onTimeout:function(r,s,a){i.resetLoader(t,h),u(new c({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,part:e,networkDetails:a}))}})})},e.updateStatsFromPart=function(t,e){var r=t.stats,i=e.stats,n=i.total;if(r.loaded+=i.loaded,n){var s=Math.round(t.duration/e.duration),a=Math.min(Math.round(r.loaded/n),s),o=(s-a)*Math.round(r.loaded/a);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},e.resetLoader=function(t,e){t.loader=null,this.loader===e&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),e.destroy()},t}();function d(t,e){void 0===e&&(e=null);var r=e||t,n={frag:t,part:e,responseType:"arraybuffer",url:r.url,headers:{},rangeStart:0,rangeEnd:0},s=r.byteRangeStartOffset,a=r.byteRangeEndOffset;if((0,i.isFiniteNumber)(s)&&(0,i.isFiniteNumber)(a)){var o,l=s,u=a;if("initSegment"===t.sn&&(null===(o=t.decryptdata)||void 0===o?void 0:o.method)==="AES-128"){var d=a-s;d%16&&(u=a+(16-d%16)),0!==s&&(n.resetIV=!0,l=s-16)}n.rangeStart=l,n.rangeEnd=u}return n}var c=function(t){function e(e){for(var r,i=arguments.length,n=Array(i>1?i-1:0),s=1;s<i;s++)n[s-1]=arguments[s];return(r=t.call.apply(t,[this].concat(n))||this).data=void 0,r.data=e,r}return e.prototype=Object.create(t.prototype),e.prototype.constructor=e,o(e,t),e}(s(Error))},"./src/loader/fragment.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{BaseSegment:()=>h,ElementaryStreamTypes:()=>n,Fragment:()=>f,Part:()=>g});var i,n,s=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),a=r(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js"),o=r(/*! ./load-stats */"./src/loader/load-stats.ts");function l(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,u(t,e)}function u(t,e){return(u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}function d(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var i=r.call(t,e||"default");if("object"!=typeof i)return i;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(i.key),i)}}function c(t,e,r){return e&&d(t.prototype,e),r&&d(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(i=n||(n={})).AUDIO="audio",i.VIDEO="video",i.AUDIOVIDEO="audiovideo";var h=function(){function t(t){var e;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((e={})[n.AUDIO]=null,e[n.VIDEO]=null,e[n.AUDIOVIDEO]=null,e),this.baseurl=t}return t.prototype.setByteRange=function(t,e){var r=t.split("@",2),i=[];1===r.length?i[0]=e?e.byteRangeEndOffset:0:i[0]=parseInt(r[1]),i[1]=parseInt(r[0])+i[0],this._byteRange=i},c(t,[{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(t){this._url=t}}]),t}(),f=function(t){function e(e,r){var i;return(i=t.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 o.LoadStats,i.urlId=0,i.data=void 0,i.bitrateTest=!1,i.title=null,i.initSegment=null,i.endList=void 0,i.type=e,i}l(e,t);var r=e.prototype;return r.setKeyFormat=function(t){if(this.levelkeys){var e=this.levelkeys[t];e&&!this._decryptdata&&(this._decryptdata=e.getDecryptData(this.sn))}},r.abortRequests=function(){var t,e;null===(t=this.loader)||void 0===t||t.abort(),null===(e=this.keyLoader)||void 0===e||e.abort()},r.setElementaryStreamInfo=function(t,e,r,i,n,s){void 0===s&&(s=!1);var a=this.elementaryStreams,o=a[t];if(!o){a[t]={startPTS:e,endPTS:r,startDTS:i,endDTS:n,partial:s};return}o.startPTS=Math.min(o.startPTS,e),o.endPTS=Math.max(o.endPTS,r),o.startDTS=Math.min(o.startDTS,i),o.endDTS=Math.max(o.endDTS,n)},r.clearElementaryStreamInfo=function(){var t=this.elementaryStreams;t[n.AUDIO]=null,t[n.VIDEO]=null,t[n.AUDIOVIDEO]=null},c(e,[{key:"decryptdata",get:function(){if(!this.levelkeys&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var t=this.levelkeys.identity;if(t)this._decryptdata=t.getDecryptData(this.sn);else{var e=Object.keys(this.levelkeys);if(1===e.length)return this._decryptdata=this.levelkeys[e[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime||!(0,s.isFiniteNumber)(this.programDateTime))return null;var t=(0,s.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+1e3*t}},{key:"encrypted",get:function(){var t;if(null!==(t=this._decryptdata)&&void 0!==t&&t.encrypted)return!0;if(this.levelkeys){var e=Object.keys(this.levelkeys),r=e.length;if(r>1||1===r&&this.levelkeys[e[0]].encrypted)return!0}return!1}}]),e}(h),g=function(t){function e(e,r,i,n,s){(a=t.call(this,i)||this).fragOffset=0,a.duration=0,a.gap=!1,a.independent=!1,a.relurl=void 0,a.fragment=void 0,a.index=void 0,a.stats=new o.LoadStats,a.duration=e.decimalFloatingPoint("DURATION"),a.gap=e.bool("GAP"),a.independent=e.bool("INDEPENDENT"),a.relurl=e.enumeratedString("URI"),a.fragment=r,a.index=n;var a,l=e.enumeratedString("BYTERANGE");return l&&a.setByteRange(l,s),s&&(a.fragOffset=s.fragOffset+s.duration),a}return l(e,t),c(e,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var t=this.elementaryStreams;return!!(t.audio||t.video||t.audiovideo)}}]),e}(h)},"./src/loader/key-loader.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>s});var i=r(/*! ../errors */"./src/errors.ts"),n=r(/*! ./fragment-loader */"./src/loader/fragment-loader.ts"),s=function(){function t(t){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=t}var e=t.prototype;return e.abort=function(){for(var t in this.keyUriToKeyInfo){var e=this.keyUriToKeyInfo[t].loader;e&&e.abort()}},e.detach=function(){for(var t in this.keyUriToKeyInfo){var e=this.keyUriToKeyInfo[t];(e.mediaKeySessionContext||e.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[t]}},e.destroy=function(){for(var t in this.detach(),this.keyUriToKeyInfo){var e=this.keyUriToKeyInfo[t].loader;e&&e.destroy()}this.keyUriToKeyInfo={}},e.createKeyLoadError=function(t,e,r,s){return void 0===e&&(e=i.ErrorDetails.KEY_LOAD_ERROR),new n.LoadError({type:i.ErrorTypes.NETWORK_ERROR,details:e,fatal:!1,frag:t,networkDetails:r})},e.loadClear=function(t,e){var r=this;if(this.emeController&&this.config.emeEnabled)for(var i=t.sn,n=t.cc,s=0;s<e.length&&"break"!==function(t){var s=e[t];if(n<=s.cc&&("initSegment"===i||i<s.sn))return r.emeController.selectKeySystemFormat(s).then(function(t){s.setKeyFormat(t)}),"break"}(s);s++);},e.load=function(t){var e=this;return!t.decryptdata&&t.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(t).then(function(r){return e.loadInternal(t,r)}):this.loadInternal(t)},e.loadInternal=function(t,e){e&&t.setKeyFormat(e);var r,n,s,a=t.decryptdata;if(!a){var o=e?"Expected frag.decryptdata to be defined after setting format "+e:"Missing decryption data on fragment in onKeyLoading";return Promise.reject(this.createKeyLoadError(t,i.ErrorDetails.KEY_LOAD_ERROR,null,o))}var l=a.uri;if(!l)return Promise.reject(this.createKeyLoadError(t,i.ErrorDetails.KEY_LOAD_ERROR,null,'Invalid key URI: "'+l+'"'));var u=this.keyUriToKeyInfo[l];if(null!==(r=u)&&void 0!==r&&r.decryptdata.key)return a.key=u.decryptdata.key,Promise.resolve({frag:t,keyInfo:u});if(null!==(n=u)&&void 0!==n&&n.keyLoadPromise)switch(null===(s=u.mediaKeySessionContext)||void 0===s?void 0:s.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return u.keyLoadPromise.then(function(e){return a.key=e.keyInfo.decryptdata.key,{frag:t,keyInfo:u}})}switch(u=this.keyUriToKeyInfo[l]={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":if("identity"===a.keyFormat)return this.loadKeyHTTP(u,t);return this.loadKeyEME(u,t);case"AES-128":return this.loadKeyHTTP(u,t);default:return Promise.reject(this.createKeyLoadError(t,i.ErrorDetails.KEY_LOAD_ERROR,null,'Key supplied with unsupported METHOD: "'+a.method+'"'))}},e.loadKeyEME=function(t,e){var r={frag:e,keyInfo:t};if(this.emeController&&this.config.emeEnabled){var i=this.emeController.loadKey(r);if(i)return(t.keyLoadPromise=i.then(function(e){return t.mediaKeySessionContext=e,r})).catch(function(e){throw t.keyLoadPromise=null,e})}return Promise.resolve(r)},e.loadKeyHTTP=function(t,e){var r=this,n=this.config,s=new n.loader(n);return e.keyLoader=t.loader=s,t.keyLoadPromise=new Promise(function(a,o){var l={keyInfo:t,frag:e,responseType:"arraybuffer",url:t.decryptdata.uri},u={timeout:n.fragLoadingTimeOut,maxRetry:0,retryDelay:n.fragLoadingRetryDelay,maxRetryDelay:n.fragLoadingMaxRetryTimeout,highWaterMark:0};s.load(l,u,{onSuccess:function(t,e,n,s){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,s,"after key load, decryptdata unset or changed"));u.decryptdata.key=l.decryptdata.key=new Uint8Array(t.data),l.keyLoader=null,u.loader=null,a({frag:l,keyInfo:u})},onError:function(t,n,s){r.resetLoader(n),o(r.createKeyLoadError(e,i.ErrorDetails.KEY_LOAD_ERROR,s))},onTimeout:function(t,n,s){r.resetLoader(n),o(r.createKeyLoadError(e,i.ErrorDetails.KEY_LOAD_TIMEOUT,s))},onAbort:function(t,n,s){r.resetLoader(n),o(r.createKeyLoadError(e,i.ErrorDetails.INTERNAL_ABORTED,s))}})})},e.resetLoader=function(t){var e=t.frag,r=t.keyInfo,i=t.url,n=r.loader;e.keyLoader===n&&(e.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[i],n&&n.destroy()},t}()},"./src/loader/level-details.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{LevelDetails:()=>s});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");function n(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var i=r.call(t,e||"default");if("object"!=typeof i)return i;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(i.key),i)}}var s=function(){var t;function e(t){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=t}return e.prototype.reloaded=function(t){if(!t){this.advanced=!0,this.updated=!0;return}var e=this.lastPartSn-t.lastPartSn,r=this.lastPartIndex-t.lastPartIndex;this.updated=this.endSN!==t.endSN||!!r||!!e,this.advanced=this.endSN>t.endSN||e>0||0===e&&r>0,this.updated||this.advanced?this.misses=Math.floor(.6*t.misses):this.misses=t.misses+1,this.availabilityDelay=t.availabilityDelay},n(e.prototype,[{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 t=this.driftEndTime-this.driftStartTime;return t>0?1e3*(this.driftEnd-this.driftStart)/t:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var t;return null!==(t=this.partList)&&void 0!==t&&t.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var t;return null!==(t=this.fragments)&&void 0!==t&&t.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 t;return null!==(t=this.partList)&&void 0!==t&&t.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var t;return null!==(t=this.partList)&&void 0!==t&&t.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),t&&n(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}()},"./src/loader/level-key.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{LevelKey:()=>u});var i=r(/*! ../utils/keysystem-util */"./src/utils/keysystem-util.ts"),n=r(/*! ../utils/mediakeys-helper */"./src/utils/mediakeys-helper.ts"),s=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=r(/*! ../utils/numeric-encoding-utils */"./src/utils/numeric-encoding-utils.ts"),l={},u=function(){function t(t,e,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=t,this.uri=e,this.keyFormat=r,this.keyFormatVersions=i,this.iv=n,this.encrypted=!!t&&"NONE"!==t,this.isCommonEncryption=this.encrypted&&"AES-128"!==t}t.clearKeyUriToKeyIdMap=function(){l={}};var e=t.prototype;return e.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},e.getDecryptData=function(e){if(!this.encrypted||!this.uri)return null;if("AES-128"===this.method&&this.uri&&!this.iv){"number"!=typeof e&&("AES-128"!==this.method||this.iv||a.logger.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),e=0);var r=function(t){for(var e=new Uint8Array(16),r=12;r<16;r++)e[r]=t>>8*(15-r)&255;return e}(e);return new t(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,s.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),g=new DOMParser().parseFromString(f,"text/xml").getElementsByTagName("KID")[0];if(g){var v=g.childNodes[0]?g.childNodes[0].nodeValue:g.getAttribute("VALUE");if(v){var p=(0,o.base64Decode)(v).subarray(0,16);(0,i.changeEndianness)(p),this.keyId=p}}break;default:var m=u.subarray(0,16);if(16!==m.length){var y=new Uint8Array(16);y.set(m,16-m.length),m=y}this.keyId=m}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},t}()},"./src/loader/load-stats.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{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":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>m});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js"),s=r(/*! ./date-range */"./src/loader/date-range.ts"),a=r(/*! ./fragment */"./src/loader/fragment.ts"),o=r(/*! ./level-details */"./src/loader/level-details.ts"),l=r(/*! ./level-key */"./src/loader/level-key.ts"),u=r(/*! ../utils/attr-list */"./src/utils/attr-list.ts"),d=r(/*! ../utils/logger */"./src/utils/logger.ts"),c=r(/*! ../utils/codecs */"./src/utils/codecs.ts");function h(){return(h=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t}).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,g=/#EXT-X-MEDIA:(.*)/g,v=RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),p=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("|")),m=function(){function t(){}return t.findGroup=function(t,e){for(var r=0;r<t.length;r++){var i=t[r];if(i.id===e)return i}},t.convertAVC1ToAVCOTI=function(t){var e=t.split(".");return e.length>2?e.shift()+"."+(parseInt(e.shift()).toString(16)+("000"+parseInt(e.shift()).toString(16)).slice(-4)):t},t.resolve=function(t,e){return(0,n.buildAbsoluteURL)(e,t,{alwaysNormalize:!0})},t.parseMasterPlaylist=function(e,r){var i=[],n=[],s={},a=[],o=!1;for(f.lastIndex=0;null!=(l=f.exec(e));)if(l[1]){var l,h,g=new u.AttrList(l[1]),v={attrs:g,bitrate:g.decimalInteger("AVERAGE-BANDWIDTH")||g.decimalInteger("BANDWIDTH"),name:g.NAME,url:t.resolve(l[2],r)},p=g.decimalResolution("RESOLUTION");p&&(v.width=p.width,v.height=p.height),function(t,e){["video","audio","text"].forEach(function(r){var i=t.filter(function(t){return(0,c.isCodecType)(t,r)});if(i.length){var n=i.filter(function(t){return 0===t.lastIndexOf("avc1",0)||0===t.lastIndexOf("mp4a",0)});e[r+"Codec"]=n.length>0?n[0]:i[0],t=t.filter(function(t){return -1===i.indexOf(t)})}}),e.unknownCodecs=t}((g.CODECS||"").split(/[ ,]+/).filter(function(t){return t}),v),v.videoCodec&&-1!==v.videoCodec.indexOf("avc1")&&(v.videoCodec=t.convertAVC1ToAVCOTI(v.videoCodec)),null!==(h=v.unknownCodecs)&&void 0!==h&&h.length||n.push(v),i.push(v)}else if(l[3]){var m=new u.AttrList(l[3]);m["DATA-ID"]&&(o=!0,s[m["DATA-ID"]]=m)}else if(l[4]){var E=l[4],T=y(E,r);T.encrypted&&T.isSupported()?a.push(T):d.logger.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+E+'"')}return{levels:n.length>0&&n.length<i.length?n:i,sessionData:o?s:null,sessionKeys:a.length?a:null}},t.parseMasterPlaylistMedia=function(e,r,i,n){void 0===n&&(n=[]);var s,a=[],o=0;for(g.lastIndex=0;null!==(s=g.exec(e));){var l=new u.AttrList(s[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?t.resolve(l.URI,r):""};if(n.length){var c=t.findGroup(n,d.groupId)||n[0];E(d,c,"audioCodec"),E(d,c,"textCodec")}a.push(d)}}return a},t.parseLevelPlaylist=function(t,e,r,n,l){var c,f,g,m=new o.LevelDetails(e),E=m.fragments,L=null,D=0,A=0,k=0,I=0,R=null,C=new a.Fragment(n,e),_=-1,P=!1;for(v.lastIndex=0,m.m3u8=t;null!==(c=v.exec(t));){P&&(P=!1,(C=new a.Fragment(n,e)).start=k,C.sn=D,C.cc=I,C.level=r,L&&(C.initSegment=L,C.rawProgramDateTime=L.rawProgramDateTime,L.rawProgramDateTime=null));var O=c[1];if(O){C.duration=parseFloat(O);var w=(" "+c[2]).slice(1);C.title=w||null,C.tagList.push(w?["INF",O,w]:["INF",O])}else if(c[3])(0,i.isFiniteNumber)(C.duration)&&(C.start=k,g&&b(C,g,m),C.sn=D,C.level=r,C.cc=I,C.urlId=l,E.push(C),C.relurl=(" "+c[3]).slice(1),T(C,R),R=C,k+=C.duration,D++,A=0,P=!0);else if(c[4]){var x=(" "+c[4]).slice(1);R?C.setByteRange(x,R):C.setByteRange(x)}else if(c[5])C.rawProgramDateTime=(" "+c[5]).slice(1),C.tagList.push(["PROGRAM-DATE-TIME",C.rawProgramDateTime]),-1===_&&(_=E.length);else{if(!(c=c[0].match(p))){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":m.type=M.toUpperCase();break;case"MEDIA-SEQUENCE":D=m.startSN=parseInt(M);break;case"SKIP":var U=new u.AttrList(M),B=U.decimalInteger("SKIPPED-SEGMENTS");if((0,i.isFiniteNumber)(B)){m.skippedSegments=B;for(var G=B;G--;)E.unshift(null);D+=B}var K=U.enumeratedString("RECENTLY-REMOVED-DATERANGES");K&&(m.recentlyRemovedDateranges=K.split(" "));break;case"TARGETDURATION":m.targetduration=parseFloat(M);break;case"VERSION":m.version=parseInt(M);break;case"EXTM3U":break;case"ENDLIST":m.live=!1;break;case"#":(M||N)&&C.tagList.push(N?[M,N]:[M]);break;case"DISCONTINUITY":I++,C.tagList.push(["DIS"]);break;case"GAP":C.tagList.push([F]);break;case"BITRATE":C.tagList.push([F,M]);break;case"DATERANGE":var H=new u.AttrList(M),j=new s.DateRange(H,m.dateRanges[H.ID]);j.isValid||m.skippedSegments?m.dateRanges[j.id]=j:d.logger.warn('Ignoring invalid DATERANGE tag: "'+M+'"'),C.tagList.push(["EXT-X-DATERANGE",M]);break;case"DISCONTINUITY-SEQUENCE":I=parseInt(M);break;case"KEY":var V=y(M,e);if(V.isSupported()){if("NONE"===V.method){g=void 0;break}g||(g={}),g[V.keyFormat]&&(g=h({},g)),g[V.keyFormat]=V}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)&&(m.startTimeOffset=Y);break;case"MAP":var W=new u.AttrList(M);if(C.duration){var q=new a.Fragment(n,e);S(q,W,r,g),L=q,C.initSegment=L,L.rawProgramDateTime&&!C.rawProgramDateTime&&(C.rawProgramDateTime=L.rawProgramDateTime)}else S(C,W,r,g),L=C,P=!0;break;case"SERVER-CONTROL":var X=new u.AttrList(M);m.canBlockReload=X.bool("CAN-BLOCK-RELOAD"),m.canSkipUntil=X.optionalFloat("CAN-SKIP-UNTIL",0),m.canSkipDateRanges=m.canSkipUntil>0&&X.bool("CAN-SKIP-DATERANGES"),m.partHoldBack=X.optionalFloat("PART-HOLD-BACK",0),m.holdBack=X.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var z=new u.AttrList(M);m.partTarget=z.decimalFloatingPoint("PART-TARGET");break;case"PART":var Q=m.partList;Q||(Q=m.partList=[]);var $=A>0?Q[Q.length-1]:void 0,J=A++,Z=new a.Part(new u.AttrList(M),C,e,J,$);Q.push(Z),C.duration+=Z.duration;break;case"PRELOAD-HINT":var tt=new u.AttrList(M);m.preloadHint=tt;break;case"RENDITION-REPORT":var te=new u.AttrList(M);m.renditionReports=m.renditionReports||[],m.renditionReports.push(te);break;default:d.logger.warn("line parsed but not handled: "+c)}}}R&&!R.relurl?(E.pop(),k-=R.duration,m.partList&&(m.fragmentHint=R)):m.partList&&(T(C,R),C.cc=I,m.fragmentHint=C,g&&b(C,g,m));var tr=E.length,ti=E[0],tn=E[tr-1];if((k+=m.skippedSegments*m.targetduration)>0&&tr&&tn){m.averagetargetduration=k/tr;var ts=tn.sn;m.endSN="initSegment"!==ts?ts:0,m.live||(tn.endList=!0),ti&&(m.startCC=ti.cc)}else m.endSN=0,m.startCC=0;return m.fragmentHint&&(k+=m.fragmentHint.duration),m.totalduration=k,m.endCC=I,_>0&&function(t,e){for(var r=t[e],i=e;i--;){var n=t[i];if(!n)return;n.programDateTime=r.programDateTime-1e3*n.duration,r=n}}(E,_),m},t}();function y(t,e){var r,i,n=new u.AttrList(t),s=null!=(r=n.enumeratedString("METHOD"))?r:"",a=n.URI,o=n.hexadecimalInteger("IV"),c=n.enumeratedString("KEYFORMATVERSIONS"),h=null!=(i=n.enumeratedString("KEYFORMAT"))?i:"identity";a&&n.IV&&!o&&d.logger.error("Invalid IV: "+n.IV);var f=a?m.resolve(a,e):"",g=(c||"1").split("/").map(Number).filter(Number.isFinite);return new l.LevelKey(s,f,h,g,o)}function E(t,e,r){var i=e[r];i&&(t[r]=i)}function T(t,e){t.rawProgramDateTime?t.programDateTime=Date.parse(t.rawProgramDateTime):null!=e&&e.programDateTime&&(t.programDateTime=e.endProgramDateTime),(0,i.isFiniteNumber)(t.programDateTime)||(t.programDateTime=null,t.rawProgramDateTime=null)}function S(t,e,r,i){t.relurl=e.URI,e.BYTERANGE&&t.setByteRange(e.BYTERANGE),t.level=r,t.sn="initSegment",i&&(t.levelkeys=i),t.initSegment=null}function b(t,e,r){t.levelkeys=e;var i=r.encryptedFragments;(!i.length||i[i.length-1].levelkeys!==e)&&Object.keys(e).some(function(t){return e[t].isCommonEncryption})&&i.push(t)}},"./src/loader/playlist-loader.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>h});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../events */"./src/events.ts"),s=r(/*! ../errors */"./src/errors.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=r(/*! ./m3u8-parser */"./src/loader/m3u8-parser.ts"),l=r(/*! ../types/loader */"./src/types/loader.ts"),u=r(/*! ../utils/attr-list */"./src/utils/attr-list.ts");function d(t,e){var r=t.url;return(void 0===r||0===r.indexOf("data:"))&&(r=e.url),r}var c=function(){function t(t){this.hls=void 0,this.loaders=Object.create(null),this.hls=t,this.registerListeners()}var e=t.prototype;return e.startLoad=function(t){},e.stopLoad=function(){this.destroyInternalLoaders()},e.registerListeners=function(){var t=this.hls;t.on(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(n.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(n.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.on(n.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},e.unregisterListeners=function(){var t=this.hls;t.off(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(n.Events.LEVEL_LOADING,this.onLevelLoading,this),t.off(n.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.off(n.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},e.createInternalLoader=function(t){var e=this.hls.config,r=e.pLoader,i=e.loader,n=new(r||i)(e);return t.loader=n,this.loaders[t.type]=n,n},e.getInternalLoader=function(t){return this.loaders[t.type]},e.resetInternalLoader=function(t){this.loaders[t]&&delete this.loaders[t]},e.destroyInternalLoaders=function(){for(var t in this.loaders){var e=this.loaders[t];e&&e.destroy(),this.resetInternalLoader(t)}},e.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},e.onManifestLoading=function(t,e){var r=e.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:l.PlaylistContextType.MANIFEST,url:r,deliveryDirectives:null})},e.onLevelLoading=function(t,e){var r=e.id,i=e.level,n=e.url,s=e.deliveryDirectives;this.load({id:r,groupId:null,level:i,responseType:"text",type:l.PlaylistContextType.LEVEL,url:n,deliveryDirectives:s})},e.onAudioTrackLoading=function(t,e){var r=e.id,i=e.groupId,n=e.url,s=e.deliveryDirectives;this.load({id:r,groupId:i,level:null,responseType:"text",type:l.PlaylistContextType.AUDIO_TRACK,url:n,deliveryDirectives:s})},e.onSubtitleTrackLoading=function(t,e){var r=e.id,i=e.groupId,n=e.url,s=e.deliveryDirectives;this.load({id:r,groupId:i,level:null,responseType:"text",type:l.PlaylistContextType.SUBTITLE_TRACK,url:n,deliveryDirectives:s})},e.load=function(t){var e,r,i,n,s,o,u=this.hls.config,d=this.getInternalLoader(t);if(d){var c=d.context;if(c&&c.url===t.url){a.logger.trace("[playlist-loader]: playlist request ongoing");return}a.logger.log("[playlist-loader]: aborting previous loader for type: "+t.type),d.abort()}switch(t.type){case l.PlaylistContextType.MANIFEST:r=u.manifestLoadingMaxRetry,i=u.manifestLoadingTimeOut,n=u.manifestLoadingRetryDelay,s=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,s=u.levelLoadingMaxRetryTimeout}if(d=this.createInternalLoader(t),null!==(e=t.deliveryDirectives)&&void 0!==e&&e.part&&(t.type===l.PlaylistContextType.LEVEL&&null!==t.level?o=this.hls.levels[t.level].details:t.type===l.PlaylistContextType.AUDIO_TRACK&&null!==t.id?o=this.hls.audioTracks[t.id].details:t.type===l.PlaylistContextType.SUBTITLE_TRACK&&null!==t.id&&(o=this.hls.subtitleTracks[t.id].details),o)){var h=o.partTarget,f=o.targetduration;h&&f&&(i=Math.min(1e3*Math.max(3*h,.8*f),i))}var g={timeout:i,maxRetry:r,retryDelay:n,maxRetryDelay:s,highWaterMark:0},v={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};d.load(t,g,v)},e.loadsuccess=function(t,e,r,i){void 0===i&&(i=null),this.resetInternalLoader(r.type);var n=t.data;if(0!==n.indexOf("#EXTM3U")){this.handleManifestParsingError(t,r,"no EXTM3U delimiter",i);return}e.parsing.start=performance.now(),n.indexOf("#EXTINF:")>0||n.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(t,e,r,i):this.handleMasterPlaylist(t,e,r,i)},e.loaderror=function(t,e,r){void 0===r&&(r=null),this.handleNetworkError(e,r,!1,t)},e.loadtimeout=function(t,e,r){void 0===r&&(r=null),this.handleNetworkError(e,r,!0)},e.handleMasterPlaylist=function(t,e,r,i){var s=this.hls,l=t.data,c=d(t,r),h=o.default.parseMasterPlaylist(l,c),f=h.levels,g=h.sessionData,v=h.sessionKeys;if(!f.length){this.handleManifestParsingError(t,r,"no level found in manifest",i);return}var p=f.map(function(t){return{id:t.attrs.AUDIO,audioCodec:t.audioCodec}}),m=f.map(function(t){return{id:t.attrs.SUBTITLES,textCodec:t.textCodec}}),y=o.default.parseMasterPlaylistMedia(l,c,"AUDIO",p),E=o.default.parseMasterPlaylistMedia(l,c,"SUBTITLES",m),T=o.default.parseMasterPlaylistMedia(l,c,"CLOSED-CAPTIONS");y.length&&!y.some(function(t){return!t.url})&&f[0].audioCodec&&!f[0].attrs.AUDIO&&(a.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:""})),s.trigger(n.Events.MANIFEST_LOADED,{levels:f,audioTracks:y,subtitles:E,captions:T,url:c,stats:e,networkDetails:i,sessionData:g,sessionKeys:v})},e.handleTrackOrLevelPlaylist=function(t,e,r,a){var c=this.hls,h=r.id,f=r.level,g=r.type,v=d(t,r),p=(0,i.isFiniteNumber)(h)?h:0,m=(0,i.isFiniteNumber)(f)?f:p,y=function(t){switch(t.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(t.data,v,m,y,p);if(!E.fragments.length){c.trigger(n.Events.ERROR,{type:s.ErrorTypes.NETWORK_ERROR,details:s.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:v,reason:"no fragments found in level",level:"number"==typeof r.level?r.level:void 0});return}if(g===l.PlaylistContextType.MANIFEST){var T={attrs:new u.AttrList({}),bitrate:0,details:E,name:"",url:v};c.trigger(n.Events.MANIFEST_LOADED,{levels:[T],audioTracks:[],url:v,stats:e,networkDetails:a,sessionData:null,sessionKeys:null})}e.parsing.end=performance.now(),r.levelDetails=E,this.handlePlaylistLoaded(t,e,r,a)},e.handleManifestParsingError=function(t,e,r,i){this.hls.trigger(n.Events.ERROR,{type:s.ErrorTypes.NETWORK_ERROR,details:s.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:e.type===l.PlaylistContextType.MANIFEST,url:t.url,reason:r,response:t,context:e,networkDetails:i})},e.handleNetworkError=function(t,e,r,i){void 0===r&&(r=!1),a.logger.warn("[playlist-loader]: A network "+(r?"timeout":"error")+" occurred while loading "+t.type+" level: "+t.level+" id: "+t.id+' group-id: "'+t.groupId+'"');var o=s.ErrorDetails.UNKNOWN,u=!1,d=this.getInternalLoader(t);switch(t.type){case l.PlaylistContextType.MANIFEST:o=r?s.ErrorDetails.MANIFEST_LOAD_TIMEOUT:s.ErrorDetails.MANIFEST_LOAD_ERROR,u=!0;break;case l.PlaylistContextType.LEVEL:o=r?s.ErrorDetails.LEVEL_LOAD_TIMEOUT:s.ErrorDetails.LEVEL_LOAD_ERROR,u=!1;break;case l.PlaylistContextType.AUDIO_TRACK:o=r?s.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:s.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,u=!1;break;case l.PlaylistContextType.SUBTITLE_TRACK:o=r?s.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:s.ErrorDetails.SUBTITLE_LOAD_ERROR,u=!1}d&&this.resetInternalLoader(t.type);var c={type:s.ErrorTypes.NETWORK_ERROR,details:o,fatal:u,url:t.url,loader:d,context:t,networkDetails:e};i&&(c.response=i),this.hls.trigger(n.Events.ERROR,c)},e.handlePlaylistLoaded=function(t,e,r,i){var s=r.type,a=r.level,o=r.id,u=r.groupId,d=r.loader,c=r.levelDetails,h=r.deliveryDirectives;if(!(null!=c&&c.targetduration)){this.handleManifestParsingError(t,r,"invalid target duration",i);return}if(d)switch(c.live&&(d.getCacheAge&&(c.ageHeader=d.getCacheAge()||0),(!d.getCacheAge||isNaN(c.ageHeader))&&(c.ageHeader=0)),s){case l.PlaylistContextType.MANIFEST:case l.PlaylistContextType.LEVEL:this.hls.trigger(n.Events.LEVEL_LOADED,{details:c,level:a||0,id:o||0,stats:e,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:e,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:e,networkDetails:i,deliveryDirectives:h})}},t}();let h=c},"./src/polyfills/number.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{MAX_SAFE_INTEGER:()=>n,isFiniteNumber:()=>i});var i=Number.isFinite||function(t){return"number"==typeof t&&isFinite(t)},n=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>n});var i=function(){function t(){}return t.getSilentFrame=function(t,e){if("mp4a.40.2"===t){if(1===e)return new Uint8Array([0,200,0,128,35,128]);if(2===e)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);else if(6===e)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===e)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===e||3===e)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])}},t}();let n=i},"./src/remux/mp4-generator.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>n});var i=function(){function t(){}return t.init=function(){for(e in t.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:[]},t.types)t.types.hasOwnProperty(e)&&(t.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);var e,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]);t.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]),s=new Uint8Array([0,0,0,0,0,0,0,0]);t.STTS=t.STSC=t.STCO=s,t.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),t.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),t.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),t.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var a=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);t.FTYP=t.box(t.types.ftyp,a,l,a,o),t.DINF=t.box(t.types.dinf,t.box(t.types.dref,n))},t.box=function(t){for(var e=8,r=arguments.length,i=Array(r>1?r-1:0),n=1;n<r;n++)i[n-1]=arguments[n];for(var s=i.length,a=s;s--;)e+=i[s].byteLength;var o=new Uint8Array(e);for(o[0]=e>>24&255,o[1]=e>>16&255,o[2]=e>>8&255,o[3]=255&e,o.set(t,4),s=0,e=8;s<a;s++)o.set(i[s],e),e+=i[s].byteLength;return o},t.hdlr=function(e){return t.box(t.types.hdlr,t.HDLR_TYPES[e])},t.mdat=function(e){return t.box(t.types.mdat,e)},t.mdhd=function(e,r){var i=Math.floor((r*=e)/4294967296),n=Math.floor(r%4294967296);return t.box(t.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,i>>24,i>>16&255,i>>8&255,255&i,n>>24,n>>16&255,n>>8&255,255&n,85,196,0,0]))},t.mdia=function(e){return t.box(t.types.mdia,t.mdhd(e.timescale,e.duration),t.hdlr(e.type),t.minf(e))},t.mfhd=function(e){return t.box(t.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e]))},t.minf=function(e){return"audio"===e.type?t.box(t.types.minf,t.box(t.types.smhd,t.SMHD),t.DINF,t.stbl(e)):t.box(t.types.minf,t.box(t.types.vmhd,t.VMHD),t.DINF,t.stbl(e))},t.moof=function(e,r,i){return t.box(t.types.moof,t.mfhd(e),t.traf(i,r))},t.moov=function(e){for(var r=e.length,i=[];r--;)i[r]=t.trak(e[r]);return t.box.apply(null,[t.types.moov,t.mvhd(e[0].timescale,e[0].duration)].concat(i).concat(t.mvex(e)))},t.mvex=function(e){for(var r=e.length,i=[];r--;)i[r]=t.trex(e[r]);return t.box.apply(null,[t.types.mvex].concat(i))},t.mvhd=function(e,r){var i=Math.floor((r*=e)/4294967296),n=Math.floor(r%4294967296),s=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,i>>24,i>>16&255,i>>8&255,255&i,n>>24,n>>16&255,n>>8&255,255&n,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 t.box(t.types.mvhd,s)},t.sdtp=function(e){var r,i,n=e.samples||[],s=new Uint8Array(4+n.length);for(r=0;r<n.length;r++)i=n[r].flags,s[r+4]=i.dependsOn<<4|i.isDependedOn<<2|i.hasRedundancy;return t.box(t.types.sdtp,s)},t.stbl=function(e){return t.box(t.types.stbl,t.stsd(e),t.box(t.types.stts,t.STTS),t.box(t.types.stsc,t.STSC),t.box(t.types.stsz,t.STSZ),t.box(t.types.stco,t.STCO))},t.avc1=function(e){var r,i,n,s=[],a=[];for(r=0;r<e.sps.length;r++)n=(i=e.sps[r]).byteLength,s.push(n>>>8&255),s.push(255&n),s=s.concat(Array.prototype.slice.call(i));for(r=0;r<e.pps.length;r++)n=(i=e.pps[r]).byteLength,a.push(n>>>8&255),a.push(255&n),a=a.concat(Array.prototype.slice.call(i));var o=t.box(t.types.avcC,new Uint8Array([1,s[3],s[4],s[5],255,224|e.sps.length].concat(s).concat([e.pps.length]).concat(a))),l=e.width,u=e.height,d=e.pixelRatio[0],c=e.pixelRatio[1];return t.box(t.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,t.box(t.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),t.box(t.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,255&d,c>>24,c>>16&255,c>>8&255,255&c])))},t.esds=function(t){var e=t.config.length;return new Uint8Array([0,0,0,0,3,23+e,0,1,0,4,15+e,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([e]).concat(t.config).concat([6,1,2]))},t.mp4a=function(e){var r=e.samplerate;return t.box(t.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,r>>8&255,255&r,0,0]),t.box(t.types.esds,t.esds(e)))},t.mp3=function(e){var r=e.samplerate;return t.box(t.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,r>>8&255,255&r,0,0]))},t.stsd=function(e){return"audio"!==e.type?t.box(t.types.stsd,t.STSD,t.avc1(e)):"mp3"===e.segmentCodec&&"mp3"===e.codec?t.box(t.types.stsd,t.STSD,t.mp3(e)):t.box(t.types.stsd,t.STSD,t.mp4a(e))},t.tkhd=function(e){var r=e.id,i=e.duration*e.timescale,n=e.width,s=e.height,a=Math.floor(i/4294967296),o=Math.floor(i%4294967296);return t.box(t.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,a>>24,a>>16&255,a>>8&255,255&a,o>>24,o>>16&255,o>>8&255,255&o,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,n>>8&255,255&n,0,0,s>>8&255,255&s,0,0]))},t.traf=function(e,r){var i=t.sdtp(e),n=e.id,s=Math.floor(r/4294967296),a=Math.floor(r%4294967296);return t.box(t.types.traf,t.box(t.types.tfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,255&n])),t.box(t.types.tfdt,new Uint8Array([1,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,a>>24,a>>16&255,a>>8&255,255&a])),t.trun(e,i.length+16+20+8+16+8+8),i)},t.trak=function(e){return e.duration=e.duration||4294967295,t.box(t.types.trak,t.tkhd(e),t.mdia(e))},t.trex=function(e){var r=e.id;return t.box(t.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]))},t.trun=function(e,r){var i,n,s,a,o,l,u=e.samples||[],d=u.length,c=12+16*d,h=new Uint8Array(c);for(r+=8+c,h.set(["video"===e.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++)s=(n=u[i]).duration,a=n.size,o=n.flags,l=n.cts,h.set([s>>>24&255,s>>>16&255,s>>>8&255,255&s,a>>>24&255,a>>>16&255,a>>>8&255,255&a,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 t.box(t.types.trun,h)},t.initSegment=function(e){t.types||t.init();var r=t.moov(e),i=new Uint8Array(t.FTYP.byteLength+r.byteLength);return i.set(t.FTYP),i.set(r,t.FTYP.byteLength),i},t}();i.types=void 0,i.HDLR_TYPES=void 0,i.STTS=void 0,i.STSC=void 0,i.STCO=void 0,i.STSZ=void 0,i.VMHD=void 0,i.SMHD=void 0,i.STSD=void 0,i.FTYP=void 0,i.DINF=void 0;let n=i},"./src/remux/mp4-remuxer.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>g,flushTextTrackMetadataCueSamples:()=>p,flushTextTrackUserdataCueSamples:()=>m,normalizePts:()=>v});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ./aac-helper */"./src/remux/aac-helper.ts"),s=r(/*! ./mp4-generator */"./src/remux/mp4-generator.ts"),a=r(/*! ../events */"./src/events.ts"),o=r(/*! ../errors */"./src/errors.ts"),l=r(/*! ../utils/logger */"./src/utils/logger.ts"),u=r(/*! ../types/loader */"./src/types/loader.ts"),d=r(/*! ../utils/timescale-conversion */"./src/utils/timescale-conversion.ts");function c(){return(c=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t}).apply(this,arguments)}var h=null,f=null,g=function(){function t(t,e,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=t,this.config=e,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 s=navigator.userAgent.match(/Safari\/(\d+)/i);f=s?parseInt(s[1]):0}}var e=t.prototype;return e.destroy=function(){},e.resetTimeStamp=function(t){l.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=t},e.resetNextTimestamp=function(){l.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},e.resetInitSegment=function(){l.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},e.getVideoStartPts=function(t){var e=!1,r=t.reduce(function(t,r){var i=r.pts-t;return i<-4294967296?(e=!0,v(t,r.pts)):i>0?t:r.pts},t[0].pts);return e&&l.logger.debug("PTS rollover detected"),r},e.remux=function(t,e,r,i,n,s,a,o){var d=n,c=n,h=t.pid>-1,f=e.pid>-1,g=e.samples.length,y=t.samples.length>0,E=a&&g>0||g>1;if((!h||y)&&(!f||E)||this.ISGenerated||a){this.ISGenerated||(b=this.generateIS(t,e,n));var T,S,b,L,D,A,k,I=this.isVideoContiguous,R=-1;if(E&&(R=function(t){for(var e=0;e<t.length;e++)if(t[e].key)return e;return -1}(e.samples),!I&&this.config.forceKeyFrameOnDiscontinuity)){if(A=!0,R>0){l.logger.warn("[mp4-remuxer]: Dropped "+R+" out of "+g+" video samples due to a missing keyframe");var C=this.getVideoStartPts(e.samples);e.samples=e.samples.slice(R),e.dropped+=R,c+=(e.samples[0].pts-C)/e.inputTimeScale,k=c}else -1===R&&(l.logger.warn("[mp4-remuxer]: No keyframe found out of "+g+" video samples"),A=!1)}if(this.ISGenerated){if(y&&E){var _=this.getVideoStartPts(e.samples),P=(v(t.samples[0].pts,_)-_)/e.inputTimeScale;d+=Math.max(0,P),c+=Math.max(0,-P)}if(y){if(t.samplerate||(l.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),b=this.generateIS(t,e,n)),S=this.remuxAudio(t,d,this.isAudioContiguous,s,f||E||o===u.PlaylistLevelType.AUDIO?c:void 0),E){var O=S?S.endPTS-S.startPTS:0;e.inputTimeScale||(l.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),b=this.generateIS(t,e,n)),T=this.remuxVideo(e,c,I,O)}}else E&&(T=this.remuxVideo(e,c,I,0));T&&(T.firstKeyFrame=R,T.independent=-1!==R,T.firstKeyFramePTS=k)}}return this.ISGenerated&&(r.samples.length&&(D=p(r,n,this._initPTS,this._initDTS)),i.samples.length&&(L=m(i,n,this._initPTS))),{audio:S,video:T,initSegment:b,independent:A,text:L,id3:D}},e.generateIS=function(t,e,r){var n,a,o,l=t.samples,u=e.samples,d=this.typeSupported,c={},h=!(0,i.isFiniteNumber)(this._initPTS),f="audio/mp4";if(h&&(n=a=1/0),t.config&&l.length&&(t.timescale=t.samplerate,"mp3"===t.segmentCodec&&(d.mpeg?(f="audio/mpeg",t.codec=""):d.mp3&&(t.codec="mp3")),c.audio={id:"audio",container:f,codec:t.codec,initSegment:"mp3"===t.segmentCodec&&d.mpeg?new Uint8Array(0):s.default.initSegment([t]),metadata:{channelCount:t.channelCount}},h&&(o=t.inputTimeScale,n=a=l[0].pts-Math.round(o*r))),e.sps&&e.pps&&u.length&&(e.timescale=e.inputTimeScale,c.video={id:"main",container:"video/mp4",codec:e.codec,initSegment:s.default.initSegment([e]),metadata:{width:e.width,height:e.height}},h)){o=e.inputTimeScale;var g=this.getVideoStartPts(u),p=Math.round(o*r);a=Math.min(a,v(u[0].dts,g)-p),n=Math.min(n,g-p)}if(Object.keys(c).length)return this.ISGenerated=!0,h&&(this._initPTS=n,this._initDTS=a),{tracks:c,initPTS:n,timescale:o}},e.remuxVideo=function(t,e,r,i){var n,u,g,p=t.inputTimeScale,m=t.samples,E=[],T=m.length,S=this._initPTS,b=this.nextAvcDts,L=8,D=this.videoSampleDuration,A=Number.POSITIVE_INFINITY,k=Number.NEGATIVE_INFINITY,I=!1;r&&null!==b||(b=e*p-(m[0].pts-v(m[0].dts,m[0].pts)));for(var R=0;R<T;R++){var C=m[R];C.pts=v(C.pts-S,b),C.dts=v(C.dts-S,b),C.dts<m[R>0?R-1:R].dts&&(I=!0)}I&&m.sort(function(t,e){var r=t.dts-e.dts,i=t.pts-e.pts;return r||i}),n=m[0].dts;var _=(u=m[m.length-1].dts)-n,P=_?Math.round(_/(T-1)):D||t.inputTimeScale/30;if(r){var O=n-b,w=O>P,x=O<-1;if((w||x)&&(w?l.logger.warn("AVC: "+(0,d.toMsFromMpegTsClock)(O,!0)+" ms ("+O+"dts) hole between fragments detected, filling it"):l.logger.warn("AVC: "+(0,d.toMsFromMpegTsClock)(-O,!0)+" ms ("+O+"dts) overlapping between fragments detected"),!x||b>m[0].pts)){n=b;var F=m[0].pts-O;m[0].dts=n,m[0].pts=F,l.logger.log("Video: First PTS/DTS adjusted: "+(0,d.toMsFromMpegTsClock)(F,!0)+"/"+(0,d.toMsFromMpegTsClock)(n,!0)+", delta: "+(0,d.toMsFromMpegTsClock)(O,!0)+" ms")}}n=Math.max(0,n);for(var M=0,N=0,U=0;U<T;U++){for(var B=m[U],G=B.units,K=G.length,H=0,j=0;j<K;j++)H+=G[j].data.length;N+=H,M+=K,B.length=H,B.dts=Math.max(B.dts,n),A=Math.min(B.pts,A),k=Math.max(B.pts,k)}u=m[T-1].dts;var V=N+4*M+8;try{g=new Uint8Array(V)}catch(t){this.observer.emit(a.Events.ERROR,a.Events.ERROR,{type:o.ErrorTypes.MUX_ERROR,details:o.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:V,reason:"fail allocating video mdat "+V});return}var Y=new DataView(g.buffer);Y.setUint32(0,V),g.set(s.default.types.mdat,4);for(var W=!1,q=Number.POSITIVE_INFINITY,X=Number.POSITIVE_INFINITY,z=Number.NEGATIVE_INFINITY,Q=Number.NEGATIVE_INFINITY,$=0;$<T;$++){for(var J=m[$],Z=J.units,tt=0,te=0,tr=Z.length;te<tr;te++){var ti=Z[te],tn=ti.data,ts=ti.data.byteLength;Y.setUint32(L,ts),L+=4,g.set(tn,L),L+=ts,tt+=4+ts}var ta=void 0;if($<T-1)D=m[$+1].dts-J.dts,ta=m[$+1].pts-J.pts;else{var to=this.config,tl=$>0?J.dts-m[$-1].dts:P;if(ta=$>0?J.pts-m[$-1].pts:P,to.stretchShortVideoTrack&&null!==this.nextAudioPts){var tu=Math.floor(to.maxBufferHole*p),td=(i?A+i*p:this.nextAudioPts)-J.pts;td>tu?((D=td-tl)<0?D=tl:W=!0,l.logger.log("[mp4-remuxer]: It is approximately "+td/90+" ms to the next segment; using duration "+D/90+" ms for the last video frame.")):D=tl}else D=tl}var tc=Math.round(J.pts-J.dts);q=Math.min(q,D),z=Math.max(z,D),X=Math.min(X,ta),Q=Math.max(Q,ta),E.push(new y(J.key,D,tt,tc))}if(E.length){if(h){if(h<70){var th=E[0].flags;th.dependsOn=2,th.isNonSync=0}}else if(f&&Q-X<z-q&&P/z<.025&&0===E[0].cts){l.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var tf=n,tg=0,tv=E.length;tg<tv;tg++){var tp=tf+E[tg].duration,tm=tf+E[tg].cts;if(tg<tv-1){var ty=tp+E[tg+1].cts;E[tg].duration=ty-tm}else E[tg].duration=tg?E[tg-1].duration:P;E[tg].cts=0,tf=tp}}}console.assert(null!==D,"mp4SampleDuration must be computed"),D=W||!D?P:D,this.nextAvcDts=b=u+D,this.videoSampleDuration=D,this.isVideoContiguous=!0;var tE={data1:s.default.moof(t.sequenceNumber++,n,c({},t,{samples:E})),data2:g,startPTS:A/p,endPTS:(k+D)/p,startDTS:n/p,endDTS:b/p,type:"video",hasAudio:!1,hasVideo:!0,nb:E.length,dropped:t.dropped};return t.samples=[],t.dropped=0,console.assert(g.length,"MDAT length must not be zero"),tE},e.remuxAudio=function(t,e,r,i,u){var d,h=t.inputTimeScale,f=t.samplerate?t.samplerate:h,g=h/f,p="aac"===t.segmentCodec?1024:1152,m=p*g,E=this._initPTS,T="mp3"===t.segmentCodec&&this.typeSupported.mpeg,S=[],b=void 0!==u,L=t.samples,D=T?0:8,A=this.nextAudioPts||-1,k=e*h;if(this.isAudioContiguous=r=r||L.length&&A>0&&(i&&9e3>Math.abs(k-A)||Math.abs(v(L[0].pts-E,k)-A)<20*m),L.forEach(function(t){t.pts=v(t.pts-E,k)}),!r||A<0){if(!(L=L.filter(function(t){return t.pts>=0})).length)return;A=0===u?0:i&&!b?Math.max(0,k):L[0].pts}if("aac"===t.segmentCodec)for(var I=this.config.maxAudioFramesDrift,R=0,C=A;R<L.length;R++){var _=L[R],P=_.pts,O=P-C,w=Math.abs(1e3*O/h);if(O<=-I*m&&b)0===R&&(l.logger.warn("Audio frame @ "+(P/h).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*O/h)+" ms."),this.nextAudioPts=A=C=P);else if(O>=I*m&&w<1e4&&b){var x=Math.round(O/m);(C=P-x*m)<0&&(x--,C+=m),0===R&&(this.nextAudioPts=A=C),l.logger.warn("[mp4-remuxer]: Injecting "+x+" audio frame @ "+(C/h).toFixed(3)+"s due to "+Math.round(1e3*O/h)+" ms gap.");for(var F=0;F<x;F++){var M=Math.max(C,0),N=n.default.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);N||(l.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),N=_.unit.subarray()),L.splice(R,0,{unit:N,pts:M}),C+=m,R++}}_.pts=C,C+=m}for(var U=null,B=null,G=0,K=L.length;K--;)G+=L[K].unit.byteLength;for(var H=0,j=L.length;H<j;H++){var V=L[H],Y=V.unit,W=V.pts;if(null!==B)S[H-1].duration=Math.round((W-B)/g);else{if(r&&"aac"===t.segmentCodec&&(W=A),U=W,!(G>0))return;G+=D;try{d=new Uint8Array(G)}catch(t){this.observer.emit(a.Events.ERROR,a.Events.ERROR,{type:o.ErrorTypes.MUX_ERROR,details:o.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:G,reason:"fail allocating audio mdat "+G});return}T||(new DataView(d.buffer).setUint32(0,G),d.set(s.default.types.mdat,4))}d.set(Y,D);var q=Y.byteLength;D+=q,S.push(new y(!0,p,q,0)),B=W}var X=S.length;if(X){var z=S[S.length-1];this.nextAudioPts=A=B+g*z.duration;var Q=T?new Uint8Array(0):s.default.moof(t.sequenceNumber++,U/g,c({},t,{samples:S}));t.samples=[];var $=U/h,J=A/h,Z={data1:Q,data2:d,startPTS:$,endPTS:J,startDTS:$,endDTS:J,type:"audio",hasAudio:!0,hasVideo:!1,nb:X};return this.isAudioContiguous=!0,console.assert(d.length,"MDAT length must not be zero"),Z}},e.remuxEmptyAudio=function(t,e,r,i){var s=t.inputTimeScale,a=t.samplerate?t.samplerate:s,o=this.nextAudioPts,u=(null!==o?o:i.startDTS*s)+this._initDTS,d=i.endDTS*s+this._initDTS,c=s/a*1024,h=Math.ceil((d-u)/c),f=n.default.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);if(l.logger.warn("[mp4-remuxer]: remux empty Audio"),!f){l.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var g=[],v=0;v<h;v++){var p=u+v*c;g.push({unit:f,pts:p,dts:p})}return t.samples=g,this.remuxAudio(t,e,r,!1)},t}();function v(t,e){var r;if(null===e)return t;for(r=e<t?-8589934592:8589934592;Math.abs(t-e)>4294967296;)t+=r;return t}function p(t,e,r,i){var n=t.samples.length;if(n){for(var s=t.inputTimeScale,a=0;a<n;a++){var o=t.samples[a];o.pts=v(o.pts-r,e*s)/s,o.dts=v(o.dts-i,e*s)/s}var l=t.samples;return t.samples=[],{samples:l}}}function m(t,e,r){var i=t.samples.length;if(i){for(var n=t.inputTimeScale,s=0;s<i;s++){var a=t.samples[s];a.pts=v(a.pts-r,e*n)/n}t.samples.sort(function(t,e){return t.pts-e.pts});var o=t.samples;return t.samples=[],{samples:o}}}var y=function(t,e,r,i){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=e,this.size=r,this.cts=i,this.flags=new E(t)},E=function(t){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=t?2:1,this.isNonSync=t?0:1}},"./src/remux/passthrough-remuxer.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>d});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ./mp4-remuxer */"./src/remux/mp4-remuxer.ts"),s=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),a=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),o=r(/*! ../utils/logger */"./src/utils/logger.ts"),l=function(){function t(){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 e=t.prototype;return e.destroy=function(){},e.resetTimeStamp=function(t){this.initPTS=t,this.lastEndTime=null},e.resetNextTimestamp=function(){this.lastEndTime=null},e.resetInitSegment=function(t,e,r,i){this.audioCodec=e,this.videoCodec=r,this.generateInitSegment((0,s.patchEncyptionData)(t,i)),this.emitInitSegment=!0},e.generateInitSegment=function(t){var e=this.audioCodec,r=this.videoCodec;if(!t||!t.byteLength){this.initTracks=void 0,this.initData=void 0;return}var i=this.initData=(0,s.parseInitSegment)(t);e||(e=u(i.audio,a.ElementaryStreamTypes.AUDIO)),r||(r=u(i.video,a.ElementaryStreamTypes.VIDEO));var n={};i.audio&&i.video?n.audiovideo={container:"video/mp4",codec:e+","+r,initSegment:t,id:"main"}:i.audio?n.audio={container:"audio/mp4",codec:e,initSegment:t,id:"audio"}:i.video?n.video={container:"video/mp4",codec:r,initSegment:t,id:"main"}:o.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=n},e.remux=function(t,e,r,a,l){var u,d=this.initPTS,c=this.lastEndTime,h={audio:void 0,video:void 0,text:a,id3:r,initSegment:void 0};(0,i.isFiniteNumber)(c)||(c=this.lastEndTime=l||0);var f=e.samples;if(!f||!f.length)return h;var g={initPTS:void 0,timescale:1},v=this.initData;if(v&&v.length||(this.generateInitSegment(f),v=this.initData),!v||!v.length)return o.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),h;this.emitInitSegment&&(g.tracks=this.initTracks,this.emitInitSegment=!1);var p=(0,s.getStartDTS)(v,f);(0,i.isFiniteNumber)(d)||(this.initPTS=g.initPTS=d=p-l);var m=(0,s.getDuration)(f,v),y=t?p-d:c,E=y+m;(0,s.offsetStartDTS)(v,f,d),m>0?this.lastEndTime=E:(o.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var T=!!v.audio,S=!!v.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=g;var D=null!=(u=this.initPTS)?u:0;return h.id3=(0,n.flushTextTrackMetadataCueSamples)(r,l,D,D),a.samples.length&&(h.text=(0,n.flushTextTrackUserdataCueSamples)(a,l,D)),h},t}();function u(t,e){var r=null==t?void 0:t.codec;return r&&r.length>4?r:"hvc1"===r||"hev1"===r?"hvc1.1.c.L120.90":"av01"===r?"av01.0.04M.08":"avc1"===r||e===a.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}let d=l},"./src/task-loop.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>i});var i=function(){function t(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var e=t.prototype;return e.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},e.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},e.onHandlerDestroyed=function(){},e.hasInterval=function(){return!!this._tickInterval},e.hasNextTick=function(){return!!this._tickTimer},e.setInterval=function(t){return!this._tickInterval&&(this._tickInterval=self.setInterval(this._boundTick,t),!0)},e.clearInterval=function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)},e.clearNextTick=function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)},e.tick=function(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},e.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},e.doTick=function(){},t}()},"./src/types/cmcd.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{CMCDObjectType:()=>a,CMCDStreamType:()=>l,CMCDStreamingFormat:()=>o,CMCDVersion:()=>u});var i,n,s,a,o,l,u=1;(i=a||(a={})).MANIFEST="m",i.AUDIO="a",i.VIDEO="v",i.MUXED="av",i.INIT="i",i.CAPTION="c",i.TIMED_TEXT="tt",i.KEY="k",i.OTHER="o",(n=o||(o={})).DASH="d",n.HLS="h",n.SMOOTH="s",n.OTHER="o",(s=l||(l={})).VOD="v",s.LIVE="l"},"./src/types/demuxer.ts":(t,e,r)=>{"use strict";var i,n;r.r(e),r.d(e,{MetadataSchema:()=>i}),(n=i||(i={})).audioId3="org.id3",n.dateRange="com.apple.quicktime.HLS",n.emsg="https://aomedia.org/emsg/ID3"},"./src/types/level.ts":(t,e,r)=>{"use strict";function i(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var i=r.call(t,e||"default");if("object"!=typeof i)return i;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(i.key),i)}}r.r(e),r.d(e,{HdcpLevels:()=>a,HlsSkip:()=>s,HlsUrlParameters:()=>l,Level:()=>u,getSkipValue:()=>o});var n,s,a=["NONE","TYPE-0","TYPE-1","TYPE-2",null];function o(t,e){var r=t.canSkipUntil,i=t.canSkipDateRanges,n=t.endSN;return r&&(void 0!==e?e-n:0)<r?i?s.v2:s.Yes:s.No}(n=s||(s={})).No="",n.Yes="YES",n.v2="v2";var l=function(){function t(t,e,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=t,this.part=e,this.skip=r}return t.prototype.addDirectives=function(t){var e=new self.URL(t);return void 0!==this.msn&&e.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&e.searchParams.set("_HLS_part",this.part.toString()),this.skip&&e.searchParams.set("_HLS_skip",this.skip),e.href},t}(),u=function(){var t;function e(t){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=[t.url],this.attrs=t.attrs,this.bitrate=t.bitrate,t.details&&(this.details=t.details),this.id=t.id||0,this.name=t.name,this.width=t.width||0,this.height=t.height||0,this.audioCodec=t.audioCodec,this.videoCodec=t.videoCodec,this.unknownCodecs=t.unknownCodecs,this.codecSet=[t.videoCodec,t.audioCodec].filter(function(t){return t}).join(",").replace(/\.[^.,]+/g,"")}return i(e.prototype,[{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(t){var e=t%this.url.length;this._urlId!==e&&(this.details=void 0,this._urlId=e)}}]),t&&i(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}()},"./src/types/loader.ts":(t,e,r)=>{"use strict";var i,n,s,a;r.r(e),r.d(e,{PlaylistContextType:()=>i,PlaylistLevelType:()=>n}),(s=i||(i={})).MANIFEST="manifest",s.LEVEL="level",s.AUDIO_TRACK="audioTrack",s.SUBTITLE_TRACK="subtitleTrack",(a=n||(n={})).MAIN="main",a.AUDIO="audio",a.SUBTITLE="subtitle"},"./src/types/transmuxer.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{ChunkMetadata:()=>i});var i=function(t,e,r,i,s,a){void 0===i&&(i=0),void 0===s&&(s=-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=n(),this.buffering={audio:n(),video:n(),audiovideo:n()},this.level=t,this.sn=e,this.id=r,this.size=i,this.part=s,this.partial=a};function n(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{AttrList:()=>s});var i=/^(\d+)x(\d+)$/,n=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,s=function(){function t(e){for(var r in"string"==typeof e&&(e=t.parseAttrList(e)),e)e.hasOwnProperty(r)&&(this[r]=e[r])}var e=t.prototype;return e.decimalInteger=function(t){var e=parseInt(this[t],10);return e>Number.MAX_SAFE_INTEGER?1/0:e},e.hexadecimalInteger=function(t){if(!this[t])return null;var e=(this[t]||"0x").slice(2);e=(1&e.length?"0":"")+e;for(var r=new Uint8Array(e.length/2),i=0;i<e.length/2;i++)r[i]=parseInt(e.slice(2*i,2*i+2),16);return r},e.hexadecimalIntegerAsNumber=function(t){var e=parseInt(this[t],16);return e>Number.MAX_SAFE_INTEGER?1/0:e},e.decimalFloatingPoint=function(t){return parseFloat(this[t])},e.optionalFloat=function(t,e){var r=this[t];return r?parseFloat(r):e},e.enumeratedString=function(t){return this[t]},e.bool=function(t){return"YES"===this[t]},e.decimalResolution=function(t){var e=i.exec(this[t]);if(null!==e)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}},t.parseAttrList=function(t){var e,r={};for(n.lastIndex=0;null!==(e=n.exec(t));){var i=e[2];0===i.indexOf('"')&&i.lastIndexOf('"')===i.length-1&&(i=i.slice(1,-1)),r[e[1]]=i}return r},t}()},"./src/utils/binary-search.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>i});let i={search:function(t,e){for(var r=0,i=t.length-1,n=null,s=null;r<=i;){var a=e(s=t[n=(r+i)/2|0]);if(a>0)r=n+1;else{if(!(a<0))return s;i=n-1}}return null}}},"./src/utils/buffer-helper.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{BufferHelper:()=>s});var i=r(/*! ./logger */"./src/utils/logger.ts"),n={length:0,start:function(){return 0},end:function(){return 0}},s=function(){function t(){}return t.isBuffered=function(e,r){try{if(e){for(var i=t.getBuffered(e),n=0;n<i.length;n++)if(r>=i.start(n)&&r<=i.end(n))return!0}}catch(t){}return!1},t.bufferInfo=function(e,r,i){try{if(e){var n,s=t.getBuffered(e),a=[];for(n=0;n<s.length;n++)a.push({start:s.start(n),end:s.end(n)});return this.bufferedInfo(a,r,i)}}catch(t){}return{len:0,start:r,end:r,nextStart:void 0}},t.bufferedInfo=function(t,e,r){e=Math.max(0,e),t.sort(function(t,e){return t.start-e.start||e.end-t.end});var i,n=[];if(r)for(var s=0;s<t.length;s++){var a=n.length;if(a){var o=n[a-1].end;t[s].start-o<r?t[s].end>o&&(n[a-1].end=t[s].end):n.push(t[s])}else n.push(t[s])}else n=t;for(var l=0,u=e,d=e,c=0;c<n.length;c++){var h=n[c].start,f=n[c].end;if(e+r>=h&&e<f)u=h,l=(d=f)-e;else if(e+r<h){i=h;break}}return{len:l,start:u||0,end:d||0,nextStart:i}},t.getBuffered=function(t){try{return t.buffered}catch(t){return i.logger.log("failed to get media.buffered",t),n}},t}()},"./src/utils/cea-608-parser.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{CaptionScreen:()=>y,Row:()=>m,default:()=>D});var i,n,s=r(/*! ../utils/logger */"./src/utils/logger.ts"),a={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},o=function(t){var e=t;return a.hasOwnProperty(t)&&(e=a[t]),String.fromCharCode(e)},l={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},u={17:2,18:4,21:6,22:8,23:10,19:13,20:15},d={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},c={25:2,26:4,29:6,30:8,31:10,27:13,28:15},h=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];(i=n||(n={}))[i.ERROR=0]="ERROR",i[i.TEXT=1]="TEXT",i[i.WARNING=2]="WARNING",i[i.INFO=2]="INFO",i[i.DEBUG=3]="DEBUG",i[i.DATA=3]="DATA";var f=function(){function t(){this.time=null,this.verboseLevel=n.ERROR}return t.prototype.log=function(t,e){if(this.verboseLevel>=t){var r="function"==typeof e?e():e;s.logger.log(this.time+" ["+t+"] "+r)}},t}(),g=function(t){for(var e=[],r=0;r<t.length;r++)e.push(t[r].toString(16));return e},v=function(){function t(t,e,r,i,n){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=t||"white",this.underline=e||!1,this.italics=r||!1,this.background=i||"black",this.flash=n||!1}var e=t.prototype;return e.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},e.setStyles=function(t){for(var e=["foreground","underline","italics","background","flash"],r=0;r<e.length;r++){var i=e[r];t.hasOwnProperty(i)&&(this[i]=t[i])}},e.isDefault=function(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash},e.equals=function(t){return this.foreground===t.foreground&&this.underline===t.underline&&this.italics===t.italics&&this.background===t.background&&this.flash===t.flash},e.copy=function(t){this.foreground=t.foreground,this.underline=t.underline,this.italics=t.italics,this.background=t.background,this.flash=t.flash},e.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},t}(),p=function(){function t(t,e,r,i,n,s){this.uchar=void 0,this.penState=void 0,this.uchar=t||" ",this.penState=new v(e,r,i,n,s)}var e=t.prototype;return e.reset=function(){this.uchar=" ",this.penState.reset()},e.setChar=function(t,e){this.uchar=t,this.penState.copy(e)},e.setPenState=function(t){this.penState.copy(t)},e.equals=function(t){return this.uchar===t.uchar&&this.penState.equals(t.penState)},e.copy=function(t){this.uchar=t.uchar,this.penState.copy(t.penState)},e.isEmpty=function(){return" "===this.uchar&&this.penState.isDefault()},t}(),m=function(){function t(t){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var e=0;e<100;e++)this.chars.push(new p);this.logger=t,this.pos=0,this.currPenState=new v}var e=t.prototype;return e.equals=function(t){for(var e=!0,r=0;r<100;r++)if(!this.chars[r].equals(t.chars[r])){e=!1;break}return e},e.copy=function(t){for(var e=0;e<100;e++)this.chars[e].copy(t.chars[e])},e.isEmpty=function(){for(var t=!0,e=0;e<100;e++)if(!this.chars[e].isEmpty()){t=!1;break}return t},e.setCursor=function(t){this.pos!==t&&(this.pos=t),this.pos<0?(this.logger.log(n.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>100&&(this.logger.log(n.DEBUG,"Too large cursor position "+this.pos),this.pos=100)},e.moveCursor=function(t){var e=this.pos+t;if(t>1)for(var r=this.pos+1;r<e+1;r++)this.chars[r].setPenState(this.currPenState);this.setCursor(e)},e.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},e.insertChar=function(t){var e=this;t>=144&&this.backSpace();var r=o(t);if(this.pos>=100){this.logger.log(n.ERROR,function(){return"Cannot insert "+t.toString(16)+" ("+r+") at position "+e.pos+". Skipping it!"});return}this.chars[this.pos].setChar(r,this.currPenState),this.moveCursor(1)},e.clearFromPos=function(t){var e;for(e=t;e<100;e++)this.chars[e].reset()},e.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},e.clearToEndOfRow=function(){this.clearFromPos(this.pos)},e.getTextString=function(){for(var t=[],e=!0,r=0;r<100;r++){var i=this.chars[r].uchar;" "!==i&&(e=!1),t.push(i)}return e?"":t.join("")},e.setPenStyles=function(t){this.currPenState.setStyles(t),this.chars[this.pos].setPenState(this.currPenState)},t}(),y=function(){function t(t){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var e=0;e<15;e++)this.rows.push(new m(t));this.logger=t,this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var e=t.prototype;return e.reset=function(){for(var t=0;t<15;t++)this.rows[t].clear();this.currRow=14},e.equals=function(t){for(var e=!0,r=0;r<15;r++)if(!this.rows[r].equals(t.rows[r])){e=!1;break}return e},e.copy=function(t){for(var e=0;e<15;e++)this.rows[e].copy(t.rows[e])},e.isEmpty=function(){for(var t=!0,e=0;e<15;e++)if(!this.rows[e].isEmpty()){t=!1;break}return t},e.backSpace=function(){this.rows[this.currRow].backSpace()},e.clearToEndOfRow=function(){this.rows[this.currRow].clearToEndOfRow()},e.insertChar=function(t){this.rows[this.currRow].insertChar(t)},e.setPen=function(t){this.rows[this.currRow].setPenStyles(t)},e.moveCursor=function(t){this.rows[this.currRow].moveCursor(t)},e.setCursor=function(t){this.logger.log(n.INFO,"setCursor: "+t),this.rows[this.currRow].setCursor(t)},e.setPAC=function(t){this.logger.log(n.INFO,function(){return"pacData = "+JSON.stringify(t)});var e=t.row-1;if(this.nrRollUpRows&&e<this.nrRollUpRows-1&&(e=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==e){for(var r=0;r<15;r++)this.rows[r].clear();var i=this.currRow+1-this.nrRollUpRows,s=this.lastOutputScreen;if(s){var a=s.rows[i].cueStartTime,o=this.logger.time;if(a&&null!==o&&a<o)for(var l=0;l<this.nrRollUpRows;l++)this.rows[e-this.nrRollUpRows+l+1].copy(s.rows[i+l])}}this.currRow=e;var u=this.rows[this.currRow];if(null!==t.indent){var d=t.indent;u.setCursor(t.indent),t.color=u.chars[Math.max(d-1,0)].penState.foreground}var c={foreground:t.color,underline:t.underline,italics:t.italics,background:"black",flash:!1};this.setPen(c)},e.setBkgData=function(t){this.logger.log(n.INFO,function(){return"bkgData = "+JSON.stringify(t)}),this.backSpace(),this.setPen(t),this.insertChar(32)},e.setRollUpRows=function(t){this.nrRollUpRows=t},e.rollUp=function(){var t=this;if(null===this.nrRollUpRows){this.logger.log(n.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(n.TEXT,function(){return t.getDisplayText()});var e=this.currRow+1-this.nrRollUpRows,r=this.rows.splice(e,1)[0];r.clear(),this.rows.splice(this.currRow,0,r),this.logger.log(n.INFO,"Rolling up")},e.getDisplayText=function(t){t=t||!1;for(var e=[],r="",i=-1,n=0;n<15;n++){var s=this.rows[n].getTextString();s&&(i=n+1,t?e.push("Row "+i+": '"+s+"'"):e.push(s.trim()))}return e.length>0&&(r=t?"["+e.join(" | ")+"]":e.join("\n")),r},e.getTextAndFormat=function(){return this.rows},t}(),E=function(){function t(t,e,r){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=t,this.outputFilter=e,this.mode=null,this.verbose=0,this.displayedMemory=new y(r),this.nonDisplayedMemory=new y(r),this.lastOutputScreen=new y(r),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=r}var e=t.prototype;return e.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},e.getHandler=function(){return this.outputFilter},e.setHandler=function(t){this.outputFilter=t},e.setPAC=function(t){this.writeScreen.setPAC(t)},e.setBkgData=function(t){this.writeScreen.setBkgData(t)},e.setMode=function(t){t!==this.mode&&(this.mode=t,this.logger.log(n.INFO,function(){return"MODE="+t}),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=t)},e.insertChars=function(t){for(var e=this,r=0;r<t.length;r++)this.writeScreen.insertChar(t[r]);var i=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(n.INFO,function(){return i+": "+e.writeScreen.getDisplayText(!0)}),("MODE_PAINT-ON"===this.mode||"MODE_ROLL-UP"===this.mode)&&(this.logger.log(n.TEXT,function(){return"DISPLAYED: "+e.displayedMemory.getDisplayText(!0)}),this.outputDataUpdate())},e.ccRCL=function(){this.logger.log(n.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},e.ccBS=function(){this.logger.log(n.INFO,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},e.ccAOF=function(){},e.ccAON=function(){},e.ccDER=function(){this.logger.log(n.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},e.ccRU=function(t){this.logger.log(n.INFO,"RU("+t+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(t)},e.ccFON=function(){this.logger.log(n.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},e.ccRDC=function(){this.logger.log(n.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},e.ccTR=function(){this.logger.log(n.INFO,"TR"),this.setMode("MODE_TEXT")},e.ccRTD=function(){this.logger.log(n.INFO,"RTD"),this.setMode("MODE_TEXT")},e.ccEDM=function(){this.logger.log(n.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},e.ccCR=function(){this.logger.log(n.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},e.ccENM=function(){this.logger.log(n.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},e.ccEOC=function(){var t=this;if(this.logger.log(n.INFO,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){var e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(n.TEXT,function(){return"DISP: "+t.displayedMemory.getDisplayText()})}this.outputDataUpdate(!0)},e.ccTO=function(t){this.logger.log(n.INFO,"TO("+t+") - Tab Offset"),this.writeScreen.moveCursor(t)},e.ccMIDROW=function(t){var e={flash:!1};e.underline=t%2==1,e.italics=t>=46,e.italics?e.foreground="white":e.foreground=["white","green","blue","cyan","red","yellow","magenta"][Math.floor(t/2)-16],this.logger.log(n.INFO,"MIDROW: "+JSON.stringify(e)),this.writeScreen.setPen(e)},e.outputDataUpdate=function(t){void 0===t&&(t=!1);var e=this.logger.time;null!==e&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,e,this.lastOutputScreen),t&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:e):this.cueStartTime=e,this.lastOutputScreen.copy(this.displayedMemory))},e.cueSplitAtTime=function(t){this.outputFilter&&!this.displayedMemory.isEmpty()&&(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,t,this.displayedMemory),this.cueStartTime=t)},t}(),T=function(){function t(t,e,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var i=new f;this.channels=[null,new E(t,e,i),new E(t+1,r,i)],this.cmdHistory=L(),this.logger=i}var e=t.prototype;return e.getHandler=function(t){return this.channels[t].getHandler()},e.setHandler=function(t,e){this.channels[t].setHandler(e)},e.addData=function(t,e){var r,i,s,a=!1;this.logger.time=t;for(var o=0;o<e.length;o+=2)if(i=127&e[o],s=127&e[o+1],0!==i||0!==s){if(this.logger.log(n.DATA,"["+g([e[o],e[o+1]])+"] -> ("+g([i,s])+")"),(r=this.parseCmd(i,s))||(r=this.parseMidrow(i,s)),r||(r=this.parsePAC(i,s)),r||(r=this.parseBackgroundAttributes(i,s)),!r&&(a=this.parseChars(i,s))){var l=this.currentChannel;l&&l>0?this.channels[l].insertChars(a):this.logger.log(n.WARNING,"No channel found yet. TEXT-MODE?")}r||a||this.logger.log(n.WARNING,"Couldn't parse cleaned data "+g([i,s])+" orig: "+g([e[o],e[o+1]]))}},e.parseCmd=function(t,e){var r=this.cmdHistory,i=(20===t||28===t||21===t||29===t)&&e>=32&&e<=47,s=(23===t||31===t)&&e>=33&&e<=35;if(!(i||s))return!1;if(b(t,e,r))return S(null,null,r),this.logger.log(n.DEBUG,"Repeated command ("+g([t,e])+") is dropped"),!0;var a=20===t||21===t||23===t?1:2,o=this.channels[a];return 20===t||21===t||28===t||29===t?32===e?o.ccRCL():33===e?o.ccBS():34===e?o.ccAOF():35===e?o.ccAON():36===e?o.ccDER():37===e?o.ccRU(2):38===e?o.ccRU(3):39===e?o.ccRU(4):40===e?o.ccFON():41===e?o.ccRDC():42===e?o.ccTR():43===e?o.ccRTD():44===e?o.ccEDM():45===e?o.ccCR():46===e?o.ccENM():47===e&&o.ccEOC():o.ccTO(e-32),S(t,e,r),this.currentChannel=a,!0},e.parseMidrow=function(t,e){var r=0;if((17===t||25===t)&&e>=32&&e<=47){if((r=17===t?1:2)!==this.currentChannel)return this.logger.log(n.ERROR,"Mismatch channel in midrow parsing"),!1;var i=this.channels[r];return!!i&&(i.ccMIDROW(e),this.logger.log(n.DEBUG,"MIDROW ("+g([t,e])+")"),!0)}return!1},e.parsePAC=function(t,e){var r,i=this.cmdHistory,n=(t>=17&&t<=23||t>=25&&t<=31)&&e>=64&&e<=127,s=(16===t||24===t)&&e>=64&&e<=95;if(!(n||s))return!1;if(b(t,e,i))return S(null,null,i),!0;var a=t<=23?1:2;r=e>=64&&e<=95?1===a?l[t]:d[t]:1===a?u[t]:c[t];var o=this.channels[a];return!!o&&(o.setPAC(this.interpretPAC(r,e)),S(t,e,i),this.currentChannel=a,!0)},e.interpretPAC=function(t,e){var r,i={color:null,italics:!1,indent:null,underline:!1,row:t};return r=e>95?e-96:e-64,i.underline=(1&r)==1,r<=13?i.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(i.italics=!0,i.color="white"):i.indent=4*Math.floor((r-16)/2),i},e.parseChars=function(t,e){var r,i,s=null,a=null;if(t>=25?(r=2,a=t-8):(r=1,a=t),a>=17&&a<=19?(i=17===a?e+80:18===a?e+112:e+144,this.logger.log(n.INFO,"Special char '"+o(i)+"' in channel "+r),s=[i]):t>=32&&t<=127&&(s=0===e?[t]:[t,e]),s){var l=g(s);this.logger.log(n.DEBUG,"Char codes = "+l.join(",")),S(t,e,this.cmdHistory)}return s},e.parseBackgroundAttributes=function(t,e){var r,i=(16===t||24===t)&&e>=32&&e<=47,n=(23===t||31===t)&&e>=45&&e<=47;if(!(i||n))return!1;var s={};16===t||24===t?(r=Math.floor((e-32)/2),s.background=h[r],e%2==1&&(s.background=s.background+"_semi")):45===e?s.background="transparent":(s.foreground="black",47===e&&(s.underline=!0));var a=t<=23?1:2;return this.channels[a].setBkgData(s),S(t,e,this.cmdHistory),!0},e.reset=function(){for(var t=0;t<Object.keys(this.channels).length;t++){var e=this.channels[t];e&&e.reset()}this.cmdHistory=L()},e.cueSplitAtTime=function(t){for(var e=0;e<this.channels.length;e++){var r=this.channels[e];r&&r.cueSplitAtTime(t)}},t}();function S(t,e,r){r.a=t,r.b=e}function b(t,e,r){return r.a===t&&r.b===e}function L(){return{a:null,b:null}}let D=T},"./src/utils/codecs.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{isCodecSupportedInMp4:()=>s,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(t,e){var r=i[e];return!!r&&!0===r[t.slice(0,4)]}function s(t,e){return MediaSource.isTypeSupported((e||"video")+'/mp4;codecs="'+t+'"')}},"./src/utils/cues.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>o});var i=r(/*! ./vttparser */"./src/utils/vttparser.ts"),n=r(/*! ./webvtt-parser */"./src/utils/webvtt-parser.ts"),s=r(/*! ./texttrack-utils */"./src/utils/texttrack-utils.ts"),a=/\s/;let o={newCue:function(t,e,r,o){for(var l,u,d,c,h,f=[],g=self.VTTCue||self.TextTrackCue,v=0;v<o.rows.length;v++)if(l=o.rows[v],d=!0,c=0,h="",!l.isEmpty()){for(var p=0;p<l.chars.length;p++)a.test(l.chars[p].uchar)&&d?c++:(h+=l.chars[p].uchar,d=!1);l.cueStartTime=e,e===r&&(r+=1e-4),c>=16?c--:c++;var m=(0,i.fixLineBreaks)(h.trim()),y=(0,n.generateCueId)(e,r,m);t&&t.cues&&t.cues.getCueById(y)||((u=new g(e,r,m)).id=y,u.line=v+1,u.align="left",u.position=10+Math.min(80,10*Math.floor(8*c/32)),f.push(u))}return t&&f.length&&(f.sort(function(t,e){return"auto"===t.line||"auto"===e.line?0:t.line>8&&e.line>8?e.line-t.line:t.line-e.line}),f.forEach(function(e){return(0,s.addCueToTrack)(t,e)})),f}}},"./src/utils/discontinuities.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{adjustSlidingStart:()=>d,alignMediaPlaylistByPDT:()=>f,alignPDT:()=>h,alignStream:()=>c,findDiscontinuousReferenceFrag:()=>l,findFirstFragWithCC:()=>a,shouldAlignOnDiscontinuities:()=>o});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ./logger */"./src/utils/logger.ts"),s=r(/*! ../controller/level-helper */"./src/controller/level-helper.ts");function a(t,e){for(var r=null,i=0,n=t.length;i<n;i++){var s=t[i];if(s&&s.cc===e){r=s;break}}return r}function o(t,e,r){return!!e.details&&(r.endCC>r.startCC||!!t&&t.cc<r.startCC)}function l(t,e,r){void 0===r&&(r=0);var i=t.fragments,s=e.fragments;if(!s.length||!i.length){n.logger.log("No fragments to align");return}var o=a(i,s[0].cc);if(!o||o&&!o.startPTS){n.logger.log("No frag in previous level to align on");return}return o}function u(t,e){if(t){var r=t.start+e;t.start=t.startPTS=r,t.endPTS=r+t.duration}}function d(t,e){for(var r=e.fragments,i=0,n=r.length;i<n;i++)u(r[i],t);e.fragmentHint&&u(e.fragmentHint,t),e.alignedSliding=!0}function c(t,e,r){e&&(function(t,e,r){if(o(t,r,e)){var s=l(r.details,e);s&&(0,i.isFiniteNumber)(s.start)&&(n.logger.log("Adjusting PTS using last level due to CC increase within current level "+e.url),d(s.start,e))}}(t,r,e),!r.alignedSliding&&e.details&&h(r,e.details),r.alignedSliding||!e.details||r.skippedSegments||(0,s.adjustSliding)(e.details,r))}function h(t,e){if(e.fragments.length&&t.hasProgramDateTime&&e.hasProgramDateTime){var r=e.fragments[0].programDateTime,s=t.fragments[0].programDateTime,a=(s-r)/1e3+e.fragments[0].start;a&&(0,i.isFiniteNumber)(a)&&(n.logger.log("Adjusting PTS using programDateTime delta "+(s-r)+"ms, sliding:"+a.toFixed(3)+" "+t.url+" "),d(a,t))}}function f(t,e){if(t.hasProgramDateTime&&e.hasProgramDateTime){var r=t.fragments,i=e.fragments;if(r.length&&i.length){var n=Math.round(i.length/2)-1,s=i[n],o=a(r,s.cc)||r[Math.round(r.length/2)-1],l=s.programDateTime,u=o.programDateTime;null!==l&&null!==u&&d((u-l)/1e3-(o.start-s.start),t)}}}},"./src/utils/ewma-bandwidth-estimator.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>s});var i=r(/*! ../utils/ewma */"./src/utils/ewma.ts"),n=function(){function t(t,e,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(t),this.fast_=new i.default(e)}var e=t.prototype;return e.update=function(t,e){var r=this.slow_,n=this.fast_;this.slow_.halfLife!==t&&(this.slow_=new i.default(t,r.getEstimate(),r.getTotalWeight())),this.fast_.halfLife!==e&&(this.fast_=new i.default(e,n.getEstimate(),n.getTotalWeight()))},e.sample=function(t,e){var r=(t=Math.max(t,this.minDelayMs_))/1e3,i=8*e/r;this.fast_.sample(r,i),this.slow_.sample(r,i)},e.canEstimate=function(){var t=this.fast_;return t&&t.getTotalWeight()>=this.minWeight_},e.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},e.destroy=function(){},t}();let s=n},"./src/utils/ewma.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>n});var i=function(){function t(t,e,r){void 0===e&&(e=0),void 0===r&&(r=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=t,this.alpha_=t?Math.exp(Math.log(.5)/t):0,this.estimate_=e,this.totalWeight_=r}var e=t.prototype;return e.sample=function(t,e){var r=Math.pow(this.alpha_,t);this.estimate_=e*(1-r)+r*this.estimate_,this.totalWeight_+=t},e.getTotalWeight=function(){return this.totalWeight_},e.getEstimate=function(){if(this.alpha_){var t=1-Math.pow(this.alpha_,this.totalWeight_);if(t)return this.estimate_/t}return this.estimate_},t}();let n=i},"./src/utils/fetch-loader.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>v,fetchSupported:()=>c});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../loader/load-stats */"./src/loader/load-stats.ts"),s=r(/*! ../demux/chunk-cache */"./src/demux/chunk-cache.ts");function a(t){var e="function"==typeof Map?new Map:void 0;return(a=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return o(t,arguments,u(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),l(r,t)})(t)}function o(t,e,r){return(o=!function(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}()?function(t,e,r){var i=[null];i.push.apply(i,e);var n=new(Function.bind.apply(t,i));return r&&l(n,r.prototype),n}:Reflect.construct.bind()).apply(null,arguments)}function l(t,e){return(l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}function u(t){return(u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function d(){return(d=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t}).apply(this,arguments)}function c(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(t){}return!1}var h=function(){function t(t){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=t.fetchSetup||f,this.controller=new self.AbortController,this.stats=new n.LoadStats}var e=t.prototype;return e.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},e.abortInternal=function(){var t=this.response;t&&t.ok||(this.stats.aborted=!0,this.controller.abort())},e.abort=function(){var t;this.abortInternal(),null!==(t=this.callbacks)&&void 0!==t&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},e.load=function(t,e,r){var n,s=this,a=this.stats;if(a.loading.start)throw Error("Loader can only be used once.");a.loading.start=self.performance.now();var o=(n={method:"GET",mode:"cors",credentials:"same-origin",signal:this.controller.signal,headers:new self.Headers(d({},t.headers))},t.rangeEnd&&n.headers.set("Range","bytes="+t.rangeStart+"-"+String(t.rangeEnd-1)),n),l=r.onProgress,u="arraybuffer"===t.responseType,c=u?"byteLength":"length";this.context=t,this.config=e,this.callbacks=r,this.request=this.fetchSetup(t,o),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){s.abortInternal(),r.onTimeout(a,t,s.response)},e.timeout),self.fetch(this.request).then(function(r){if(s.response=s.loader=r,!r.ok){var n=r.status,o=r.statusText;throw new g(o||"fetch, bad network response",n,r)}return(a.loading.first=Math.max(self.performance.now(),a.loading.start),a.total=parseInt(r.headers.get("Content-Length")||"0"),l&&(0,i.isFiniteNumber)(e.highWaterMark))?s.loadProgressively(r,a,t,e.highWaterMark,l):u?r.arrayBuffer():r.text()}).then(function(n){var o=s.response;self.clearTimeout(s.requestTimeout),a.loading.end=Math.max(self.performance.now(),a.loading.first);var u=n[c];u&&(a.loaded=a.total=u);var d={url:o.url,data:n};l&&!(0,i.isFiniteNumber)(e.highWaterMark)&&l(a,t,n,o),r.onSuccess(d,a,t,o)}).catch(function(e){if(self.clearTimeout(s.requestTimeout),!a.aborted){var i=e&&e.code||0,n=e?e.message:null;r.onError({code:i,text:n},t,e?e.details:null)}})},e.getCacheAge=function(){var t=null;if(this.response){var e=this.response.headers.get("age");t=e?parseFloat(e):null}return t},e.loadProgressively=function(t,e,r,i,n){void 0===i&&(i=0);var a=new s.default,o=t.body.getReader();return function s(){return o.read().then(function(o){if(o.done)return a.dataLength&&n(e,r,a.flush(),t),Promise.resolve(new ArrayBuffer(0));var l=o.value,u=l.length;return e.loaded+=u,u<i||a.dataLength?(a.push(l),a.dataLength>=i&&n(e,r,a.flush(),t)):n(e,r,l,t),s()}).catch(function(){return Promise.reject()})}()},t}();function f(t,e){return new self.Request(t.url,e)}var g=function(t){function e(e,r,i){var n;return(n=t.call(this,e)||this).code=void 0,n.details=void 0,n.code=r,n.details=i,n}return e.prototype=Object.create(t.prototype),e.prototype.constructor=e,l(e,t),e}(a(Error));let v=h},"./src/utils/hex.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>i});let i={hexDump:function(t){for(var e="",r=0;r<t.length;r++){var i=t[r].toString(16);i.length<2&&(i="0"+i),e+=i}return e}}},"./src/utils/imsc1-ttml-parser.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{IMSC1_CODEC:()=>d,parseIMSC1:()=>g});var i=r(/*! ./mp4-tools */"./src/utils/mp4-tools.ts"),n=r(/*! ./vttparser */"./src/utils/vttparser.ts"),s=r(/*! ./vttcue */"./src/utils/vttcue.ts"),a=r(/*! ../demux/id3 */"./src/demux/id3.ts"),o=r(/*! ./timescale-conversion */"./src/utils/timescale-conversion.ts"),l=r(/*! ./webvtt-parser */"./src/utils/webvtt-parser.ts");function u(){return(u=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t}).apply(this,arguments)}var d="stpp.ttml.im1t",c=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,h=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,f={left:"start",center:"center",right:"end",start:"start",end:"end"};function g(t,e,r,n,d){var c=(0,i.findBox)(new Uint8Array(t),["mdat"]);if(0===c.length){d(Error("Could not parse IMSC1 mdat"));return}var h=c.map(function(t){return(0,a.utf8ArrayToStr)(t)}),g=(0,o.toTimescaleFromScale)(e,1,r);try{h.forEach(function(t){return n(function(t,e){var r=new DOMParser().parseFromString(t,"text/xml").getElementsByTagName("tt")[0];if(!r)throw Error("Invalid ttml");var i={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},n=Object.keys(i).reduce(function(t,e){return t[e]=r.getAttribute("ttp:"+e)||i[e],t},{}),a="preserve"!==r.getAttribute("xml:space"),o=p(v(r,"styling","style")),d=p(v(r,"layout","region")),c=v(r,"body","[begin]");return[].map.call(c,function(t){var r,i,c,h,g,v=function t(e,r){return[].slice.call(e.childNodes).reduce(function(e,i,n){var s;return"br"===i.nodeName&&n?e+"\n":null!==(s=i.childNodes)&&void 0!==s&&s.length?t(i,r):r?e+i.textContent.trim().replace(/\s+/g," "):e+i.textContent},"")}(t,a);if(!v||!t.hasAttribute("begin"))return null;var p=E(t.getAttribute("begin"),n),T=E(t.getAttribute("dur"),n),S=E(t.getAttribute("end"),n);if(null===p)throw y(t);if(null===S){if(null===T)throw y(t);S=p+T}var b=new s.default(p-e,S-e,v);b.id=(0,l.generateCueId)(b.startTime,b.endTime,b.text);var L=(r=d[t.getAttribute("region")],i=o[t.getAttribute("style")],c="http://www.w3.org/ns/ttml#styling",h=null,(g=null!=r&&r.hasAttribute("style")?r.getAttribute("style"):null)&&o.hasOwnProperty(g)&&(h=o[g]),["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"].reduce(function(t,e){var n=m(i,c,e)||m(r,c,e)||m(h,c,e);return n&&(t[e]=n),t},{})),D=L.textAlign;if(D){var A=f[D];A&&(b.lineAlign=A),b.align=D}return u(b,L),b}).filter(function(t){return null!==t})}(t,g))})}catch(t){d(t)}}function v(t,e,r){var i=t.getElementsByTagName(e)[0];return i?[].slice.call(i.querySelectorAll(r)):[]}function p(t){return t.reduce(function(t,e){var r=e.getAttribute("xml:id");return r&&(t[r]=e),t},{})}function m(t,e,r){return t&&t.hasAttributeNS(e,r)?t.getAttributeNS(e,r):null}function y(t){return Error("Could not parse ttml timestamp "+t)}function E(t,e){if(!t)return null;var r,i,s=(0,n.parseTimeStamp)(t);return null===s&&(c.test(t)?(i=(0|(r=c.exec(t))[4])+(0|r[5])/e.subFrameRate,s=(0|r[1])*3600+(0|r[2])*60+(0|r[3])+i/e.frameRate):h.test(t)&&(s=function(t,e){var r=h.exec(t),i=Number(r[1]);switch(r[2]){case"h":return 3600*i;case"m":return 60*i;case"ms":return 1e3*i;case"f":return i/e.frameRate;case"t":return i/e.tickRate}return i}(t,e))),s}},"./src/utils/keysystem-util.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{changeEndianness:()=>n,convertDataUriToArrayBytes:()=>s,strToUtf8array:()=>a});var i=r(/*! ./numeric-encoding-utils */"./src/utils/numeric-encoding-utils.ts");function n(t){var e=function(t,e,r){var i=t[e];t[e]=t[r],t[r]=i};e(t,0,3),e(t,1,2),e(t,4,5),e(t,6,7)}function s(t){var e=t.split(":"),r=null;if("data"===e[0]&&2===e.length){var n=e[1].split(";"),s=n[n.length-1].split(",");if(2===s.length){var o,l,u="base64"===s[0],d=s[1];u?(n.splice(-1,1),r=(0,i.base64Decode)(d)):(o=a(d).subarray(0,16),(l=new Uint8Array(16)).set(o,16-o.length),r=l)}}return r}function a(t){return Uint8Array.from(unescape(encodeURIComponent(t)),function(t){return t.charCodeAt(0)})}},"./src/utils/logger.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{enableLogs:()=>a,logger:()=>o});var i=function(){},n={trace:i,debug:i,log:i,warn:i,info:i,error:i},s=n;function a(t,e){if(self.console&&!0===t||"object"==typeof t){!function(t){for(var e=arguments.length,r=Array(e>1?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];r.forEach(function(e){var r;s[e]=t[e]?t[e].bind(t):(r=self.console[e])?r.bind(self.console,"["+e+"] >"):i})}(t,"debug","log","info","warn","error");try{s.log('Debug logs enabled for "'+e+'"')}catch(t){s=n}}else s=n}var o=s},"./src/utils/mediakeys-helper.ts":(t,e,r)=>{"use strict";function i(t){switch(t){case d.FAIRPLAY:return u.FAIRPLAY;case d.PLAYREADY:return u.PLAYREADY;case d.WIDEVINE:return u.WIDEVINE;case d.CLEARKEY:return u.CLEARKEY}}function n(t){if(t===c.WIDEVINE)return u.WIDEVINE}function s(t){switch(t){case u.FAIRPLAY:return d.FAIRPLAY;case u.PLAYREADY:return d.PLAYREADY;case u.WIDEVINE:return d.WIDEVINE;case u.CLEARKEY:return d.CLEARKEY}}function a(t){var e=t.drmSystems,r=t.widevineLicenseUrl,i=e?[u.FAIRPLAY,u.WIDEVINE,u.PLAYREADY,u.CLEARKEY].filter(function(t){return!!e[t]}):[];return!i[u.WIDEVINE]&&r&&i.push(u.WIDEVINE),i}r.r(e),r.d(e,{KeySystemFormats:()=>d,KeySystemIds:()=>c,KeySystems:()=>u,getKeySystemsForConfig:()=>a,getSupportedMediaKeySystemConfigurations:()=>f,keySystemDomainToKeySystemFormat:()=>s,keySystemFormatToKeySystemDomain:()=>i,keySystemIdToKeySystemDomain:()=>n,requestMediaKeySystemAccess:()=>h}),(o=u||(u={})).CLEARKEY="org.w3.clearkey",o.FAIRPLAY="com.apple.fps",o.PLAYREADY="com.microsoft.playready",o.WIDEVINE="com.widevine.alpha",(l=d||(d={})).CLEARKEY="org.w3.clearkey",l.FAIRPLAY="com.apple.streamingkeydelivery",l.PLAYREADY="com.microsoft.playready",l.WIDEVINE="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed",(c||(c={})).WIDEVINE="edef8ba979d64acea3c827dcd51d21ed";var o,l,u,d,c,h="undefined"!=typeof self&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function f(t,e,r,i){var n;switch(t){case u.FAIRPLAY:n=["cenc","sinf"];break;case u.WIDEVINE:case u.PLAYREADY:n=["cenc"];break;case u.CLEARKEY:n=["cenc","keyids"];break;default:throw Error("Unknown key-system: "+t)}return[{initDataTypes:n,persistentState:i.persistentState||"not-allowed",distinctiveIdentifier:i.distinctiveIdentifier||"not-allowed",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:e.map(function(t){return{contentType:'audio/mp4; codecs="'+t+'"',robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null}}),videoCapabilities:r.map(function(t){return{contentType:'video/mp4; codecs="'+t+'"',robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}})}]}},"./src/utils/mediasource-helper.ts":(t,e,r)=>{"use strict";function i(){return self.MediaSource||self.WebKitMediaSource}r.r(e),r.d(e,{getMediaSource:()=>i})},"./src/utils/mp4-tools.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{RemuxerTrackIdConfig:()=>u,appendUint8Array:()=>A,bin2str:()=>d,computeRawDurationFromSamples:()=>b,discardEPB:()=>R,findBox:()=>v,getDuration:()=>S,getStartDTS:()=>T,mp4Box:()=>_,mp4pssh:()=>P,offsetStartDTS:()=>L,parseEmsg:()=>C,parseInitSegment:()=>m,parsePssh:()=>O,parseSEIMessageFromNALu:()=>I,parseSamples:()=>k,parseSegmentIndex:()=>p,parseSinf:()=>E,patchEncyptionData:()=>y,readSint32:()=>f,readUint16:()=>c,readUint32:()=>h,segmentValidRange:()=>D,writeUint32:()=>g});var i=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),n=r(/*! ./typed-array */"./src/utils/typed-array.ts"),s=r(/*! ../demux/id3 */"./src/demux/id3.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=r(/*! ./hex */"./src/utils/hex.ts"),l=[].push,u={video:1,audio:2,id3:3,text:4};function d(t){return String.fromCharCode.apply(null,t)}function c(t,e){var r=t[e]<<8|t[e+1];return r<0?65536+r:r}function h(t,e){var r=f(t,e);return r<0?4294967296+r:r}function f(t,e){return t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]}function g(t,e,r){t[e]=r>>24,t[e+1]=r>>16&255,t[e+2]=r>>8&255,t[e+3]=255&r}function v(t,e){var r=[];if(!e.length)return r;for(var i=t.byteLength,n=0;n<i;){var s=h(t,n),a=d(t.subarray(n+4,n+8)),o=s>1?n+s:i;if(a===e[0]){if(1===e.length)r.push(t.subarray(n+8,o));else{var u=v(t.subarray(n+8,o),e.slice(1));u.length&&l.apply(r,u)}}n=o}return r}function p(t){var e=[],r=t[0],i=8,n=h(t,8);i+=4,0===r?i+=8:i+=16,i+=2;var s=t.length+0,a=c(t,i);i+=2;for(var o=0;o<a;o++){var l=i,u=h(t,l);l+=4;var d=2147483647&u;if(1==(2147483648&u)>>>31)return console.warn("SIDX has hierarchical references (not supported)"),null;var f=h(t,l);l+=4,e.push({referenceSize:d,subsegmentDuration:f,info:{duration:f/n,start:s,end:s+d-1}}),s+=d,l+=4,i=l}return{earliestPresentationTime:0,timescale:n,version:r,referencesCount:a,references:e}}function m(t){for(var e=[],r=v(t,["moov","trak"]),n=0;n<r.length;n++){var s=r[n],a=v(s,["tkhd"])[0];if(a){var o=a[0],l=0===o?12:20,u=h(a,l),c=v(s,["mdia","mdhd"])[0];if(c){l=0===(o=c[0])?12:20;var f=h(c,l),g=v(s,["mdia","hdlr"])[0];if(g){var p=d(g.subarray(8,12)),m={soun:i.ElementaryStreamTypes.AUDIO,vide:i.ElementaryStreamTypes.VIDEO}[p];if(m){var y=v(s,["mdia","minf","stbl","stsd"])[0],E=void 0;y&&(E=d(y.subarray(12,16))),e[u]={timescale:f,type:m},e[m]={timescale:f,id:u,codec:E}}}}}}return v(t,["moov","mvex","trex"]).forEach(function(t){var r=e[h(t,4)];r&&(r.default={duration:h(t,12),flags:h(t,20)})}),e}function y(t,e){if(!t||!e)return t;var r=e.keyId;return r&&e.isCommonEncryption&&v(t,["moov","trak"]).forEach(function(t){var e=v(t,["mdia","minf","stbl","stsd"])[0].subarray(8),i=v(e,["enca"]),n=i.length>0;n||(i=v(e,["encv"])),i.forEach(function(t){v(n?t.subarray(28):t.subarray(78),["sinf"]).forEach(function(t){var e=E(t);if(e){var i=e.subarray(8,24);i.some(function(t){return 0!==t})||(a.logger.log("[eme] Patching keyId in 'enc"+(n?"a":"v")+">sinf>>tenc' box: "+o.default.hexDump(i)+" -> "+o.default.hexDump(r)),e.set(r,8))}})})}),t}function E(t){var e=v(t,["schm"])[0];if(e){var r=d(e.subarray(4,8));if("cbcs"===r||"cenc"===r)return v(t,["schi","tenc"])[0]}return a.logger.error("[eme] missing 'schm' box"),null}function T(t,e){return v(e,["moof","traf"]).reduce(function(e,r){var i=v(r,["tfdt"])[0],n=i[0],s=v(r,["tfhd"]).reduce(function(e,r){var s=t[h(r,4)];if(s){var a=h(i,4);1===n&&(a*=4294967296,a+=h(i,8));var o=a/(s.timescale||9e4);if(isFinite(o)&&(null===e||o<e))return o}return e},null);return null!==s&&isFinite(s)&&(null===e||s<e)?s:e},null)||0}function S(t,e){for(var r=0,n=0,s=0,a=v(t,["moof","traf"]),o=0;o<a.length;o++){var l=a[o],u=v(l,["tfhd"])[0],d=e[h(u,4)];if(d){var c=d.default,f=h(u,0)|(null==c?void 0:c.flags),g=null==c?void 0:c.duration;8&f&&(g=2&f?h(u,12):h(u,8));for(var m=d.timescale||9e4,y=v(l,["trun"]),E=0;E<y.length;E++)(r=b(y[E]))||!g||(r=g*h(y[E],4)),d.type===i.ElementaryStreamTypes.VIDEO?n+=r/m:d.type===i.ElementaryStreamTypes.AUDIO&&(s+=r/m)}}if(0===n&&0===s){for(var T=0,S=v(t,["sidx"]),L=0;L<S.length;L++){var D=p(S[L]);null!=D&&D.references&&(T+=D.references.reduce(function(t,e){return t+e.info.duration||0},0))}return T}return n||s}function b(t){var e=h(t,0),r=8;1&e&&(r+=4),4&e&&(r+=4);for(var i=0,n=h(t,4),s=0;s<n;s++)256&e&&(i+=h(t,r),r+=4),512&e&&(r+=4),1024&e&&(r+=4),2048&e&&(r+=4);return i}function L(t,e,r){v(e,["moof","traf"]).forEach(function(e){v(e,["tfhd"]).forEach(function(i){var n=t[h(i,4)];if(n){var s=n.timescale||9e4;v(e,["tfdt"]).forEach(function(t){var e=t[0],i=h(t,4);if(0===e)i-=r*s,g(t,4,i=Math.max(i,0));else{i*=4294967296,i+=h(t,8),i-=r*s;var n=Math.floor((i=Math.max(i,0))/4294967296),a=Math.floor(i%4294967296);g(t,4,n),g(t,8,a)}})}})})}function D(t){var e={valid:null,remainder:null},r=v(t,["moof"]);if(!r)return e;if(r.length<2)return e.remainder=t,e;var i=r[r.length-1];return e.valid=(0,n.sliceUint8)(t,0,i.byteOffset-8),e.remainder=(0,n.sliceUint8)(t,i.byteOffset-8),e}function A(t,e){var r=new Uint8Array(t.length+e.length);return r.set(t),r.set(e,t.length),r}function k(t,e){var r=[],n=e.samples,s=e.timescale,a=e.id,o=!1;return v(n,["moof"]).map(function(l){var u=l.byteOffset-8;v(l,["traf"]).map(function(l){var d=v(l,["tfdt"]).map(function(t){var e=t[0],r=h(t,4);return 1===e&&(r*=4294967296,r+=h(t,8)),r/s})[0];return void 0!==d&&(t=d),v(l,["tfhd"]).map(function(d){var c=h(d,4),g=16777215&h(d,0),p=0,m=0,y=8;c===a&&((1&g)!=0&&(y+=8),(2&g)!=0&&(y+=4),(8&g)!=0&&(p=h(d,y),y+=4),(16&g)!=0&&(m=h(d,y),y+=4),(32&g)!=0&&(y+=4),"video"===e.type&&(o=function(t){if(!t)return!1;var e=t.indexOf("."),r=e<0?t:t.substring(0,e);return"hvc1"===r||"hev1"===r||"dvh1"===r||"dvhe"===r}(e.codec)),v(l,["trun"]).map(function(a){var l=a[0],d=16777215&h(a,0),c=0,g=(256&d)!=0,v=0,y=(512&d)!=0,E=0,T=(1024&d)!=0,S=(2048&d)!=0,b=0,L=h(a,4),D=8;(1&d)!=0&&(c=h(a,D),D+=4),(4&d)!=0&&(D+=4);for(var A=c+u,k=0;k<L;k++){if(g?(v=h(a,D),D+=4):v=p,y?(E=h(a,D),D+=4):E=m,T&&(D+=4),S&&(b=0===l?h(a,D):f(a,D),D+=4),e.type===i.ElementaryStreamTypes.VIDEO)for(var R=0;R<E;){var C=h(n,A);A+=4,function(t,e){if(!t)return 6==(31&e);var r=e>>1&63;return 39===r||40===r}(o,n[A])&&I(n.subarray(A,A+C),o?2:1,t+b/s,r),A+=C,R+=C+4}t+=v/s}}))})})}),r}function I(t,e,r,i){var n,a=R(t);n=0+e;for(var o=0,l=0,u=!1,d=0;n<a.length;){o=0;do{if(n>=a.length)break;o+=d=a[n++]}while(255===d)l=0;do{if(n>=a.length)break;l+=d=a[n++]}while(255===d)var f=a.length-n;if(!u&&4===o&&n<a.length){if(u=!0,181===a[n++]){var g=c(a,n);if(n+=2,49===g){var v=h(a,n);if(n+=4,1195456820===v){var p=a[n++];if(3===p){var m=a[n++],y=31&m,E=64&m,T=E?2+3*y:0,S=new Uint8Array(T);if(E){S[0]=m;for(var b=1;b<T;b++)S[b]=a[n++]}i.push({type:p,payloadType:o,pts:r,bytes:S})}}}}}else if(5===o&&l<f){if(u=!0,l>16){for(var L=[],D=0;D<16;D++){var A=a[n++].toString(16);L.push(1==A.length?"0"+A:A),(3===D||5===D||7===D||9===D)&&L.push("-")}for(var k=l-16,I=new Uint8Array(k),C=0;C<k;C++)I[C]=a[n++];i.push({payloadType:o,pts:r,uuid:L.join(""),userData:(0,s.utf8ArrayToStr)(I),userDataBytes:I})}}else if(l<f)n+=l;else if(l>f)break}}function R(t){for(var e=t.byteLength,r=[],i=1;i<e-2;)0===t[i]&&0===t[i+1]&&3===t[i+2]?(r.push(i+2),i+=2):i++;if(0===r.length)return t;var n=e-r.length,s=new Uint8Array(n),a=0;for(i=0;i<n;a++,i++)a===r[0]&&(a++,r.shift()),s[i]=t[a];return s}function C(t){var e=t[0],r="",i="",n=0,s=0,a=0,o=0,l=0,u=0;if(0===e){for(;"\x00"!==d(t.subarray(u,u+1));)r+=d(t.subarray(u,u+1)),u+=1;for(r+=d(t.subarray(u,u+1)),u+=1;"\x00"!==d(t.subarray(u,u+1));)i+=d(t.subarray(u,u+1)),u+=1;i+=d(t.subarray(u,u+1)),u+=1,n=h(t,12),s=h(t,16),o=h(t,20),l=h(t,24),u=28}else if(1===e){u+=4,n=h(t,u);var c=h(t,u+=4),f=h(t,u+=4);for(u+=4,Number.isSafeInteger(a=4294967296*c+f)||(a=Number.MAX_SAFE_INTEGER,console.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=h(t,u),u+=4,l=h(t,u),u+=4;"\x00"!==d(t.subarray(u,u+1));)r+=d(t.subarray(u,u+1)),u+=1;for(r+=d(t.subarray(u,u+1)),u+=1;"\x00"!==d(t.subarray(u,u+1));)i+=d(t.subarray(u,u+1)),u+=1;i+=d(t.subarray(u,u+1)),u+=1}return{schemeIdUri:r,value:i,timeScale:n,presentationTime:a,presentationTimeDelta:s,eventDuration:o,id:l,payload:t.subarray(u,t.byteLength)}}function _(t){for(var e=arguments.length,r=Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];for(var n=r.length,s=8,a=n;a--;)s+=r[a].byteLength;var o=new Uint8Array(s);for(o[0]=s>>24&255,o[1]=s>>16&255,o[2]=s>>8&255,o[3]=255&s,o.set(t,4),a=0,s=8;a<n;a++)o.set(r[a],s),s+=r[a].byteLength;return o}function P(t,e,r){if(16!==t.byteLength)throw RangeError("Invalid system id");if(e){i=1,n=new Uint8Array(16*e.length);for(var i,n,s,a=0;a<e.length;a++){var o=e[a];if(16!==o.byteLength)throw RangeError("Invalid key");n.set(o,16*a)}}else i=0,n=new Uint8Array;i>0?(s=new Uint8Array(4),e.length>0&&new DataView(s.buffer).setUint32(0,e.length,!1)):s=new Uint8Array;var l=new Uint8Array(4);return r&&r.byteLength>0&&new DataView(l.buffer).setUint32(0,r.byteLength,!1),_([112,115,115,104],new Uint8Array([i,0,0,0]),t,s,n,l,r||new Uint8Array)}function O(t){if(!(t instanceof ArrayBuffer)||t.byteLength<32)return null;var e={version:0,systemId:"",kids:null,data:null},r=new DataView(t),i=r.getUint32(0);if(t.byteLength!==i&&i>44||1886614376!==r.getUint32(4)||(e.version=r.getUint32(8)>>>24,e.version>1))return null;e.systemId=o.default.hexDump(new Uint8Array(t,12,16));var n=r.getUint32(28);if(0===e.version){if(i-32<n)return null;e.data=new Uint8Array(t,32,n)}else if(1===e.version){e.kids=[];for(var s=0;s<n;s++)e.kids.push(new Uint8Array(t,32+16*s,16))}return e}},"./src/utils/numeric-encoding-utils.ts":(t,e,r)=>{"use strict";function i(t){return t.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function n(t){return btoa(t)}function s(t){return atob(t)}function a(t){return btoa(String.fromCharCode.apply(String,t))}function o(t){return i(a(t))}function l(t){return Uint8Array.from(atob(t),function(t){return t.charCodeAt(0)})}r.r(e),r.d(e,{base64Decode:()=>l,base64DecodeToStr:()=>s,base64Encode:()=>a,base64ToBase64Url:()=>i,base64UrlEncode:()=>o,strToBase64Encode:()=>n})},"./src/utils/output-filter.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>i});var i=function(){function t(t,e){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=t,this.trackName=e}var e=t.prototype;return e.dispatchCue=function(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},e.newCue=function(t,e,r){(null===this.startTime||this.startTime>t)&&(this.startTime=t),this.endTime=e,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)},e.reset=function(){this.cueRanges=[],this.startTime=null},t}()},"./src/utils/texttrack-utils.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{addCueToTrack:()=>s,clearCurrentCues:()=>a,getCuesInRange:()=>l,removeCuesInRange:()=>o,sendAddTrackEvent:()=>n});var i=r(/*! ./logger */"./src/utils/logger.ts");function n(t,e){var r;try{r=new Event("addtrack")}catch(t){(r=document.createEvent("Event")).initEvent("addtrack",!1,!1)}r.track=t,e.dispatchEvent(r)}function s(t,e){var r=t.mode;if("disabled"===r&&(t.mode="hidden"),t.cues&&!t.cues.getCueById(e.id))try{if(t.addCue(e),!t.cues.getCueById(e.id))throw Error("addCue is failed for: "+e)}catch(r){i.logger.debug("[texttrack-utils]: "+r);var n=new self.TextTrackCue(e.startTime,e.endTime,e.text);n.id=e.id,t.addCue(n)}"disabled"===r&&(t.mode=r)}function a(t){var e=t.mode;if("disabled"===e&&(t.mode="hidden"),t.cues)for(var r=t.cues.length;r--;)t.removeCue(t.cues[r]);"disabled"===e&&(t.mode=e)}function o(t,e,r,i){var n=t.mode;if("disabled"===n&&(t.mode="hidden"),t.cues&&t.cues.length>0)for(var s=l(t.cues,e,r),a=0;a<s.length;a++)(!i||i(s[a]))&&t.removeCue(s[a]);"disabled"===n&&(t.mode=n)}function l(t,e,r){var i=[],n=function(t,e){if(e<t[0].startTime)return 0;var r=t.length-1;if(e>t[r].endTime)return -1;for(var i=0,n=r;i<=n;){var s=Math.floor((n+i)/2);if(e<t[s].startTime)n=s-1;else{if(!(e>t[s].startTime)||!(i<r))return s;i=s+1}}return t[i].startTime-e<e-t[n].startTime?i:n}(t,e);if(n>-1)for(var s=n,a=t.length;s<a;s++){var o=t[s];if(o.startTime>=e&&o.endTime<=r)i.push(o);else if(o.startTime>r)break}return i}},"./src/utils/time-ranges.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>i});let i={toString:function(t){for(var e="",r=t.length,i=0;i<r;i++)e+="["+t.start(i).toFixed(3)+"-"+t.end(i).toFixed(3)+"]";return e}}},"./src/utils/timescale-conversion.ts":(t,e,r)=>{"use strict";function i(t,e,r,i){void 0===r&&(r=1),void 0===i&&(i=!1);var n=t*e*r;return i?Math.round(n):n}function n(t,e,r,n){return void 0===r&&(r=1),void 0===n&&(n=!1),i(t,e,1/r,n)}function s(t,e){return void 0===e&&(e=!1),i(t,1e3,11111111111111112e-21,e)}function a(t,e){return void 0===e&&(e=1),i(t,9e4,1/e)}r.r(e),r.d(e,{toMpegTsClockFromTimescale:()=>a,toMsFromMpegTsClock:()=>s,toTimescaleFromBase:()=>i,toTimescaleFromScale:()=>n})},"./src/utils/typed-array.ts":(t,e,r)=>{"use strict";function i(t,e,r){return Uint8Array.prototype.slice?t.slice(e,r):new Uint8Array(Array.prototype.slice.call(t,e,r))}r.r(e),r.d(e,{sliceUint8:()=>i})},"./src/utils/vttcue.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>i});let i=function(){if("undefined"!=typeof self&&self.VTTCue)return self.VTTCue;var t=["","lr","rl"],e=["start","middle","end","left","right"];function r(t,e){if("string"!=typeof e||!Array.isArray(t))return!1;var r=e.toLowerCase();return!!~t.indexOf(r)&&r}function i(t){for(var e=arguments.length,r=Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];for(var n=1;n<arguments.length;n++){var s=arguments[n];for(var a in s)t[a]=s[a]}return t}function n(n,s,a){var o={enumerable:!0};this.hasBeenReset=!1;var l="",u=!1,d=n,c=s,h=a,f=null,g="",v=!0,p="auto",m="start",y=50,E="middle",T=50,S="middle";Object.defineProperty(this,"id",i({},o,{get:function(){return l},set:function(t){l=""+t}})),Object.defineProperty(this,"pauseOnExit",i({},o,{get:function(){return u},set:function(t){u=!!t}})),Object.defineProperty(this,"startTime",i({},o,{get:function(){return d},set:function(t){if("number"!=typeof t)throw TypeError("Start time must be set to a number.");d=t,this.hasBeenReset=!0}})),Object.defineProperty(this,"endTime",i({},o,{get:function(){return c},set:function(t){if("number"!=typeof t)throw TypeError("End time must be set to a number.");c=t,this.hasBeenReset=!0}})),Object.defineProperty(this,"text",i({},o,{get:function(){return h},set:function(t){h=""+t,this.hasBeenReset=!0}})),Object.defineProperty(this,"region",i({},o,{get:function(){return f},set:function(t){f=t,this.hasBeenReset=!0}})),Object.defineProperty(this,"vertical",i({},o,{get:function(){return g},set:function(e){var i=r(t,e);if(!1===i)throw SyntaxError("An invalid or illegal string was specified.");g=i,this.hasBeenReset=!0}})),Object.defineProperty(this,"snapToLines",i({},o,{get:function(){return v},set:function(t){v=!!t,this.hasBeenReset=!0}})),Object.defineProperty(this,"line",i({},o,{get:function(){return p},set:function(t){if("number"!=typeof t&&"auto"!==t)throw SyntaxError("An invalid number or illegal string was specified.");p=t,this.hasBeenReset=!0}})),Object.defineProperty(this,"lineAlign",i({},o,{get:function(){return m},set:function(t){var i=r(e,t);if(!i)throw SyntaxError("An invalid or illegal string was specified.");m=i,this.hasBeenReset=!0}})),Object.defineProperty(this,"position",i({},o,{get:function(){return y},set:function(t){if(t<0||t>100)throw Error("Position must be between 0 and 100.");y=t,this.hasBeenReset=!0}})),Object.defineProperty(this,"positionAlign",i({},o,{get:function(){return E},set:function(t){var i=r(e,t);if(!i)throw SyntaxError("An invalid or illegal string was specified.");E=i,this.hasBeenReset=!0}})),Object.defineProperty(this,"size",i({},o,{get:function(){return T},set:function(t){if(t<0||t>100)throw Error("Size must be between 0 and 100.");T=t,this.hasBeenReset=!0}})),Object.defineProperty(this,"align",i({},o,{get:function(){return S},set:function(t){var i=r(e,t);if(!i)throw SyntaxError("An invalid or illegal string was specified.");S=i,this.hasBeenReset=!0}})),this.displayState=void 0}return n.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},n}()},"./src/utils/vttparser.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{VTTParser:()=>c,fixLineBreaks:()=>d,parseTimeStamp:()=>s});var i=r(/*! ./vttcue */"./src/utils/vttcue.ts"),n=function(){function t(){}return t.prototype.decode=function(t,e){if(!t)return"";if("string"!=typeof t)throw Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(t))},t}();function s(t){function e(t,e,r,i){return(0|t)*3600+(0|e)*60+(0|r)+parseFloat(i||0)}var r=t.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return r?parseFloat(r[2])>59?e(r[2],r[3],0,r[4]):e(r[1],r[2],r[3],r[4]):null}var a=function(){function t(){this.values=Object.create(null)}var e=t.prototype;return e.set=function(t,e){this.get(t)||""===e||(this.values[t]=e)},e.get=function(t,e,r){return r?this.has(t)?this.values[t]:e[r]:this.has(t)?this.values[t]:e},e.has=function(t){return t in this.values},e.alt=function(t,e,r){for(var i=0;i<r.length;++i)if(e===r[i]){this.set(t,e);break}},e.integer=function(t,e){/^-?\d+$/.test(e)&&this.set(t,parseInt(e,10))},e.percent=function(t,e){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(e)){var r=parseFloat(e);if(r>=0&&r<=100)return this.set(t,r),!0}return!1},t}();function o(t,e,r,i){var n=i?t.split(i):[t];for(var s in n)if("string"==typeof n[s]){var a=n[s].split(r);2===a.length&&e(a[0],a[1])}}var l=new i.default(0,0,""),u="middle"===l.align?"middle":"center";function d(t){return t.replace(/<br(?: \/)?>/gi,"\n")}var c=function(){function t(){this.state="INITIAL",this.buffer="",this.decoder=new n,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var e=t.prototype;return e.parse=function(t){var e=this;function r(){var t=e.buffer,r=0;for(t=d(t);r<t.length&&"\r"!==t[r]&&"\n"!==t[r];)++r;var i=t.slice(0,r);return"\r"===t[r]&&++r,"\n"===t[r]&&++r,e.buffer=t.slice(r),i}t&&(e.buffer+=e.decoder.decode(t,{stream:!0}));try{var n,c="";if("INITIAL"===e.state){if(!/\r\n|\n/.test(e.buffer))return this;var h=(c=r()).match(/^()?WEBVTT([ \t].*)?$/);if(!h||!h[0])throw Error("Malformed WebVTT signature.");e.state="HEADER"}for(var f=!1;e.buffer&&/\r\n|\n/.test(e.buffer);)switch(f?f=!1:c=r(),e.state){case"HEADER":/:/.test(c)?(n=c,o(n,function(t,e){},/:/)):c||(e.state="ID");continue;case"NOTE":c||(e.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(c)){e.state="NOTE";break}if(!c)continue;if(e.cue=new i.default(0,0,""),e.state="CUE",-1===c.indexOf("-->")){e.cue.id=c;continue}case"CUE":if(!e.cue){e.state="BADCUE";continue}try{!function(t,e,r){var i,n,d,c,h=t;function f(){var e=s(t);if(null===e)throw Error("Malformed timestamp: "+h);return t=t.replace(/^[^\sa-zA-Z-]+/,""),e}function g(){t=t.replace(/^\s+/,"")}if(g(),e.startTime=f(),g(),"-->"!==t.slice(0,3))throw Error("Malformed time stamp (time stamps must be separated by '-->'): "+h);t=t.slice(3),g(),e.endTime=f(),g(),i=t,n=new a,o(i,function(t,e){var i;switch(t){case"region":for(var s=r.length-1;s>=0;s--)if(r[s].id===e){n.set(t,r[s].region);break}break;case"vertical":n.alt(t,e,["rl","lr"]);break;case"line":i=e.split(","),n.integer(t,i[0]),n.percent(t,i[0])&&n.set("snapToLines",!1),n.alt(t,i[0],["auto"]),2===i.length&&n.alt("lineAlign",i[1],["start",u,"end"]);break;case"position":i=e.split(","),n.percent(t,i[0]),2===i.length&&n.alt("positionAlign",i[1],["start",u,"end","line-left","line-right","auto"]);break;case"size":n.percent(t,e);break;case"align":n.alt(t,e,["start",u,"end","left","right"])}},/:/,/\s/),e.region=n.get("region",null),e.vertical=n.get("vertical",""),"auto"===(d=n.get("line","auto"))&&-1===l.line&&(d=-1),e.line=d,e.lineAlign=n.get("lineAlign","start"),e.snapToLines=n.get("snapToLines",!0),e.size=n.get("size",100),e.align=n.get("align",u),"auto"===(c=n.get("position","auto"))&&50===l.position&&(c="start"===e.align||"left"===e.align?0:"end"===e.align||"right"===e.align?100:50),e.position=c}(c,e.cue,e.regionList)}catch(t){e.cue=null,e.state="BADCUE";continue}e.state="CUETEXT";continue;case"CUETEXT":var g=-1!==c.indexOf("-->");if(!c||g&&(f=!0)){e.oncue&&e.cue&&e.oncue(e.cue),e.cue=null,e.state="ID";continue}if(null===e.cue)continue;e.cue.text&&(e.cue.text+="\n"),e.cue.text+=c;continue;case"BADCUE":c||(e.state="ID")}}catch(t){"CUETEXT"===e.state&&e.cue&&e.oncue&&e.oncue(e.cue),e.cue=null,e.state="INITIAL"===e.state?"BADWEBVTT":"BADCUE"}return this},e.flush=function(){try{if((this.cue||"HEADER"===this.state)&&(this.buffer+="\n\n",this.parse()),"INITIAL"===this.state||"BADWEBVTT"===this.state)throw Error("Malformed WebVTT signature.")}catch(t){this.onparsingerror&&this.onparsingerror(t)}return this.onflush&&this.onflush(),this},t}()},"./src/utils/webvtt-parser.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{generateCueId:()=>h,parseWebVTT:()=>g});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ./vttparser */"./src/utils/vttparser.ts"),s=r(/*! ../demux/id3 */"./src/demux/id3.ts"),a=r(/*! ./timescale-conversion */"./src/utils/timescale-conversion.ts"),o=r(/*! ../remux/mp4-remuxer */"./src/remux/mp4-remuxer.ts"),l=/\r\n|\n\r|\n|\r/g,u=function(t,e,r){return void 0===r&&(r=0),t.slice(r,r+e.length)===e},d=function(t){var e=parseInt(t.slice(-3)),r=parseInt(t.slice(-6,-4)),n=parseInt(t.slice(-9,-7)),s=t.length>9?parseInt(t.substring(0,t.indexOf(":"))):0;if(!(0,i.isFiniteNumber)(e)||!(0,i.isFiniteNumber)(r)||!(0,i.isFiniteNumber)(n)||!(0,i.isFiniteNumber)(s))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+t);return e+(1e3*r+6e4*n+36e5*s)},c=function(t){for(var e=5381,r=t.length;r;)e=33*e^t.charCodeAt(--r);return(e>>>0).toString()};function h(t,e,r){return c(t.toString())+c(e.toString())+c(r)}var f=function(t,e,r){var i,n=t[e],s=t[n.prevCC];if(!s||!s.new&&n.new){t.ccOffset=t.presentationOffset=n.start,n.new=!1;return}for(;null!==(i=s)&&void 0!==i&&i.new;)t.ccOffset+=n.start-s.start,n.new=!1,s=t[(n=s).prevCC];t.presentationOffset=r};function g(t,e,r,i,c,g,v,p){var m,y=new n.VTTParser,E=(0,s.utf8ArrayToStr)(new Uint8Array(t)).trim().replace(l,"\n").split("\n"),T=[],S=(0,a.toMpegTsClockFromTimescale)(e,r),b="00:00.000",L=0,D=0,A=!0;y.oncue=function(t){var e=i[c],r=i.ccOffset,n=(L-S)/9e4;null!=e&&e.new&&(void 0!==D?r=i.ccOffset=e.start:f(i,c,n)),n&&(r=n-i.presentationOffset);var s=t.endTime-t.startTime,a=(0,o.normalizePts)((t.startTime+r-D)*9e4,9e4*g)/9e4;t.startTime=Math.max(a,0),t.endTime=Math.max(a+s,0);var l=t.text.trim();t.text=decodeURIComponent(encodeURIComponent(l)),t.id||(t.id=h(t.startTime,t.endTime,l)),t.endTime>0&&T.push(t)},y.onparsingerror=function(t){m=t},y.onflush=function(){if(m){p(m);return}v(T)},E.forEach(function(t){if(A){if(u(t,"X-TIMESTAMP-MAP=")){A=!1,t.slice(16).split(",").forEach(function(t){u(t,"LOCAL:")?b=t.slice(6):u(t,"MPEGTS:")&&(L=parseInt(t.slice(7)))});try{D=d(b)/1e3}catch(t){m=t}return}""===t&&(A=!1)}y.parse(t+"\n")}),y.flush()}},"./src/utils/xhr-loader.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>o});var i=r(/*! ../utils/logger */"./src/utils/logger.ts"),n=r(/*! ../loader/load-stats */"./src/loader/load-stats.ts"),s=/^age:\s*[\d.]+\s*$/m,a=function(){function t(t){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=t?t.xhrSetup:null,this.stats=new n.LoadStats,this.retryDelay=0}var e=t.prototype;return e.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},e.abortInternal=function(){var t=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),t&&(t.onreadystatechange=null,t.onprogress=null,4!==t.readyState&&(this.stats.aborted=!0,t.abort()))},e.abort=function(){var t;this.abortInternal(),null!==(t=this.callbacks)&&void 0!==t&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},e.load=function(t,e,r){if(this.stats.loading.start)throw Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=t,this.config=e,this.callbacks=r,this.retryDelay=e.retryDelay,this.loadInternal()},e.loadInternal=function(){var t=this.config,e=this.context;if(t){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,e.url)}catch(t){r.open("GET",e.url,!0),n(r,e.url)}r.readyState||r.open("GET",e.url,!0);var s=this.context.headers;if(s)for(var a in s)r.setRequestHeader(a,s[a])}catch(t){this.callbacks.onError({code:r.status,text:t.message},e,r);return}e.rangeEnd&&r.setRequestHeader("Range","bytes="+e.rangeStart+"-"+(e.rangeEnd-1)),r.onreadystatechange=this.readystatechange.bind(this),r.onprogress=this.loadprogress.bind(this),r.responseType=e.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),t.timeout),r.send()}},e.readystatechange=function(){var t=this.context,e=this.loader,r=this.stats;if(t&&e){var n=e.readyState,s=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){e.onreadystatechange=null,e.onprogress=null;var a=e.status,o="arraybuffer"===e.responseType;if(a>=200&&a<300&&(o&&e.response||null!==e.responseText)){if(r.loading.end=Math.max(self.performance.now(),r.loading.first),u=o?(l=e.response).byteLength:(l=e.responseText).length,r.loaded=r.total=u,!this.callbacks)return;var l,u,d=this.callbacks.onProgress;if(d&&d(r,t,l,e),!this.callbacks)return;var c={url:e.responseURL,data:l};this.callbacks.onSuccess(c,r,t,e)}else r.retry>=s.maxRetry||a>=400&&a<499?(i.logger.error(a+" while loading "+t.url),this.callbacks.onError({code:a,text:e.statusText},t,e)):(i.logger.warn(a+" while loading "+t.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,s.maxRetryDelay),r.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),s.timeout)}}},e.loadtimeout=function(){i.logger.warn("timeout while loading "+this.context.url);var t=this.callbacks;t&&(this.abortInternal(),t.onTimeout(this.stats,this.context,this.loader))},e.loadprogress=function(t){var e=this.stats;e.loaded=t.loaded,t.lengthComputable&&(e.total=t.total)},e.getCacheAge=function(){var t=null;if(this.loader&&s.test(this.loader.getAllResponseHeaders())){var e=this.loader.getResponseHeader("age");t=e?parseFloat(e):null}return t},t}();let o=a},"./node_modules/eventemitter3/index.js":t=>{"use strict";var e=Object.prototype.hasOwnProperty,r="~";function i(){}function n(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function s(t,e,i,s,a){if("function"!=typeof i)throw TypeError("The listener must be a function");var o=new n(i,s||t,a),l=r?r+e:e;return t._events[l]?t._events[l].fn?t._events[l]=[t._events[l],o]:t._events[l].push(o):(t._events[l]=o,t._eventsCount++),t}function a(t,e){0==--t._eventsCount?t._events=new i:delete t._events[e]}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 t,i,n=[];if(0===this._eventsCount)return n;for(i in t=this._events)e.call(t,i)&&n.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(t)):n},o.prototype.listeners=function(t){var e=r?r+t:t,i=this._events[e];if(!i)return[];if(i.fn)return[i.fn];for(var n=0,s=i.length,a=Array(s);n<s;n++)a[n]=i[n].fn;return a},o.prototype.listenerCount=function(t){var e=r?r+t:t,i=this._events[e];return i?i.fn?1:i.length:0},o.prototype.emit=function(t,e,i,n,s,a){var o=r?r+t:t;if(!this._events[o])return!1;var l,u,d=this._events[o],c=arguments.length;if(d.fn){switch(d.once&&this.removeListener(t,d.fn,void 0,!0),c){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,e),!0;case 3:return d.fn.call(d.context,e,i),!0;case 4:return d.fn.call(d.context,e,i,n),!0;case 5:return d.fn.call(d.context,e,i,n,s),!0;case 6:return d.fn.call(d.context,e,i,n,s,a),!0}for(u=1,l=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(t,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,e);break;case 3:d[u].fn.call(d[u].context,e,i);break;case 4:d[u].fn.call(d[u].context,e,i,n);break;default:if(!l)for(h=1,l=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(t,e,r){return s(this,t,e,r,!1)},o.prototype.once=function(t,e,r){return s(this,t,e,r,!0)},o.prototype.removeListener=function(t,e,i,n){var s=r?r+t:t;if(!this._events[s])return this;if(!e)return a(this,s),this;var o=this._events[s];if(o.fn)o.fn!==e||n&&!o.once||i&&o.context!==i||a(this,s);else{for(var l=0,u=[],d=o.length;l<d;l++)(o[l].fn!==e||n&&!o[l].once||i&&o[l].context!==i)&&u.push(o[l]);u.length?this._events[s]=1===u.length?u[0]:u:a(this,s)}return this},o.prototype.removeAllListeners=function(t){var e;return t?(e=r?r+t:t,this._events[e]&&a(this,e)):(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,t.exports=o},"./node_modules/url-toolkit/src/url-toolkit.js":function(t){var e,r,i,n,s;e=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,r=/^(?=([^\/?#]*))\1([^]*)$/,i=/(?:\/|^)\.(?=\/)/g,n=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,s={buildAbsoluteURL:function(t,e,i){if(i=i||{},t=t.trim(),!(e=e.trim())){if(!i.alwaysNormalize)return t;var n=s.parseURL(t);if(!n)throw Error("Error trying to parse base URL.");return n.path=s.normalizePath(n.path),s.buildURLFromParts(n)}var a=s.parseURL(e);if(!a)throw Error("Error trying to parse relative URL.");if(a.scheme)return i.alwaysNormalize?(a.path=s.normalizePath(a.path),s.buildURLFromParts(a)):e;var o=s.parseURL(t);if(!o)throw 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:a.netLoc,path:null,params:a.params,query:a.query,fragment:a.fragment};if(!a.netLoc&&(u.netLoc=o.netLoc,"/"!==a.path[0])){if(a.path){var d=o.path,c=d.substring(0,d.lastIndexOf("/")+1)+a.path;u.path=s.normalizePath(c)}else u.path=o.path,a.params||(u.params=o.params,a.query||(u.query=o.query))}return null===u.path&&(u.path=i.alwaysNormalize?s.normalizePath(a.path):a.path),s.buildURLFromParts(u)},parseURL:function(t){var r=e.exec(t);return r?{scheme:r[1]||"",netLoc:r[2]||"",path:r[3]||"",params:r[4]||"",query:r[5]||"",fragment:r[6]||""}:null},normalizePath:function(t){for(t=t.split("").reverse().join("").replace(i,"");t.length!==(t=t.replace(n,"")).length;);return t.split("").reverse().join("")},buildURLFromParts:function(t){return t.scheme+t.netLoc+t.path+t.params+t.query+t.fragment}},t.exports=s}},e={};function r(i){var n=e[i];if(void 0!==n)return n.exports;var s=e[i]={exports:{}};return t[i].call(s.exports,s,s.exports,r),s.exports}return r.m=t,r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r("./src/hls.ts").default})())}}]);
|
2
|
+
//# sourceMappingURL=https://sm.pinimg.com/webapp/67631-9d4d7f4aab06e79c.mjs.map
|