mirror of
https://gitee.com/niucloud-team/niucloud-admin.git
synced 2026-01-07 13:38:10 +00:00
23 lines
370 KiB
JavaScript
23 lines
370 KiB
JavaScript
/* empty css *//* empty css */import{v as ve,T as at,a as It,w as Ze,u as ut}from"./error-492b6a5b.js";import{c as Ce,e as Q,n as Se,h as Ue,u as G,v as ce,d as we,L as ge,f as K,q,x as J,r as me,C as ue,M as Te,w as ze,o as mt,O as yt,p as Z,F as Pe,t as je,b as $,as as Ke,at as Ve,A as Et,l as Ct,y as Tt,m as De,K as wt,g as xt,ab as _e}from"./runtime-core.esm-bundler-7c3fd514.js";/* empty css *//* empty css */import"./el-overlay-f7f710bd.js";/* empty css *//* empty css *//* empty css *//* empty css *//* empty css */import{b as Ot,q as Pt,v as Ft,k as Mt,l as Nt,j as Bt}from"./index-aae906bf.js";/* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css */import{t as ie}from"./index-5f4ce139.js";import{a as st}from"./index-be5dc120.js";import{E as St}from"./index-95693143.js";import{E as bt}from"./index-4862d1b3.js";import{E as Ut}from"./index-be5868d6.js";import{a as Gt,u as jt,d as Kt,b as Vt,m as Ht,g as Wt,c as Yt}from"./sys-aa893c6b.js";import{g as qt,a as zt,i as tt,d as dt}from"./common-465e36b3.js";import{E as ct}from"./index-548a7823.js";import{E as Xt}from"./index-2f0b1bf3.js";import{a as $t}from"./index-9bac81c5.js";import{E as Qt,a as Zt}from"./index-f97852b4.js";import{E as Jt}from"./index-cf47f151.js";import{E as er}from"./index-381e0c1f.js";import{E as tr}from"./index-470ade69.js";import{E as rr}from"./index-800b62de.js";import{a as ir,E as nr}from"./index-9fbce820.js";import{a as ar,E as sr}from"./index-624573cc.js";import{E as or}from"./index-4683bff4.js";import{v as lr}from"./directive-a07a10ed.js";import{_ as ur}from"./_plugin-vue_export-helper-c27b6911.js";var dr=Object.defineProperty,cr=Object.defineProperties,hr=Object.getOwnPropertyDescriptors,ht=Object.getOwnPropertySymbols,fr=Object.prototype.hasOwnProperty,gr=Object.prototype.propertyIsEnumerable,ft=(N,C,f)=>C in N?dr(N,C,{enumerable:!0,configurable:!0,writable:!0,value:f}):N[C]=f,ot=(N,C)=>{for(var f in C||(C={}))fr.call(C,f)&&ft(N,f,C[f]);if(ht)for(var f of ht(C))gr.call(C,f)&&ft(N,f,C[f]);return N},lt=(N,C)=>cr(N,hr(C));function gt(N,C,f,R){var E,A=!1,D=0;function I(){E&&clearTimeout(E)}function _(){for(var l=arguments.length,L=new Array(l),m=0;m<l;m++)L[m]=arguments[m];var h=this,T=Date.now()-D;function y(){D=Date.now(),f.apply(h,L)}function c(){E=void 0}A||(R&&!E&&y(),I(),R===void 0&&T>N?y():C!==!0&&(E=setTimeout(R?c:y,R===void 0?N-T:N)))}return typeof C!="boolean"&&(R=f,f=C,C=void 0),_.cancel=function(){I(),A=!0},_}function vt(N,C,f){return f===void 0?gt(N,C,!1):gt(N,f,C!==!1)}function vr(N){return N&&N.__esModule&&Object.prototype.hasOwnProperty.call(N,"default")?N.default:N}var Lt={exports:{}};typeof window<"u"&&(Lt.exports=function(N){var C={};function f(R){if(C[R])return C[R].exports;var E=C[R]={i:R,l:!1,exports:{}};return N[R].call(E.exports,E,E.exports,f),E.l=!0,E.exports}return f.m=N,f.c=C,f.d=function(R,E,A){f.o(R,E)||Object.defineProperty(R,E,{enumerable:!0,get:A})},f.r=function(R){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(R,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(R,"__esModule",{value:!0})},f.t=function(R,E){if(1&E&&(R=f(R)),8&E||4&E&&typeof R=="object"&&R&&R.__esModule)return R;var A=Object.create(null);if(f.r(A),Object.defineProperty(A,"default",{enumerable:!0,value:R}),2&E&&typeof R!="string")for(var D in R)f.d(A,D,function(I){return R[I]}.bind(null,D));return A},f.n=function(R){var E=R&&R.__esModule?function(){return R.default}:function(){return R};return f.d(E,"a",E),E},f.o=function(R,E){return Object.prototype.hasOwnProperty.call(R,E)},f.p="/dist/",f(f.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(N,C,f){var R=Object.prototype.hasOwnProperty,E="~";function A(){}function D(L,m,h){this.fn=L,this.context=m,this.once=h||!1}function I(L,m,h,T,y){if(typeof h!="function")throw new TypeError("The listener must be a function");var c=new D(h,T||L,y),e=E?E+m:m;return L._events[e]?L._events[e].fn?L._events[e]=[L._events[e],c]:L._events[e].push(c):(L._events[e]=c,L._eventsCount++),L}function _(L,m){--L._eventsCount==0?L._events=new A:delete L._events[m]}function l(){this._events=new A,this._eventsCount=0}Object.create&&(A.prototype=Object.create(null),new A().__proto__||(E=!1)),l.prototype.eventNames=function(){var L,m,h=[];if(this._eventsCount===0)return h;for(m in L=this._events)R.call(L,m)&&h.push(E?m.slice(1):m);return Object.getOwnPropertySymbols?h.concat(Object.getOwnPropertySymbols(L)):h},l.prototype.listeners=function(L){var m=E?E+L:L,h=this._events[m];if(!h)return[];if(h.fn)return[h.fn];for(var T=0,y=h.length,c=new Array(y);T<y;T++)c[T]=h[T].fn;return c},l.prototype.listenerCount=function(L){var m=E?E+L:L,h=this._events[m];return h?h.fn?1:h.length:0},l.prototype.emit=function(L,m,h,T,y,c){var e=E?E+L:L;if(!this._events[e])return!1;var a,t,s=this._events[e],d=arguments.length;if(s.fn){switch(s.once&&this.removeListener(L,s.fn,void 0,!0),d){case 1:return s.fn.call(s.context),!0;case 2:return s.fn.call(s.context,m),!0;case 3:return s.fn.call(s.context,m,h),!0;case 4:return s.fn.call(s.context,m,h,T),!0;case 5:return s.fn.call(s.context,m,h,T,y),!0;case 6:return s.fn.call(s.context,m,h,T,y,c),!0}for(t=1,a=new Array(d-1);t<d;t++)a[t-1]=arguments[t];s.fn.apply(s.context,a)}else{var n,u=s.length;for(t=0;t<u;t++)switch(s[t].once&&this.removeListener(L,s[t].fn,void 0,!0),d){case 1:s[t].fn.call(s[t].context);break;case 2:s[t].fn.call(s[t].context,m);break;case 3:s[t].fn.call(s[t].context,m,h);break;case 4:s[t].fn.call(s[t].context,m,h,T);break;default:if(!a)for(n=1,a=new Array(d-1);n<d;n++)a[n-1]=arguments[n];s[t].fn.apply(s[t].context,a)}}return!0},l.prototype.on=function(L,m,h){return I(this,L,m,h,!1)},l.prototype.once=function(L,m,h){return I(this,L,m,h,!0)},l.prototype.removeListener=function(L,m,h,T){var y=E?E+L:L;if(!this._events[y])return this;if(!m)return _(this,y),this;var c=this._events[y];if(c.fn)c.fn!==m||T&&!c.once||h&&c.context!==h||_(this,y);else{for(var e=0,a=[],t=c.length;e<t;e++)(c[e].fn!==m||T&&!c[e].once||h&&c[e].context!==h)&&a.push(c[e]);a.length?this._events[y]=a.length===1?a[0]:a:_(this,y)}return this},l.prototype.removeAllListeners=function(L){var m;return L?(m=E?E+L:L,this._events[m]&&_(this,m)):(this._events=new A,this._eventsCount=0),this},l.prototype.off=l.prototype.removeListener,l.prototype.addListener=l.prototype.on,l.prefixed=E,l.EventEmitter=l,N.exports=l},"./node_modules/url-toolkit/src/url-toolkit.js":function(N,C,f){var R,E,A,D,I;R=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/,E=/^([^\/?#]*)([^]*)$/,A=/(?:\/|^)\.(?=\/)/g,D=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,I={buildAbsoluteURL:function(_,l,L){if(L=L||{},_=_.trim(),!(l=l.trim())){if(!L.alwaysNormalize)return _;var m=I.parseURL(_);if(!m)throw new Error("Error trying to parse base URL.");return m.path=I.normalizePath(m.path),I.buildURLFromParts(m)}var h=I.parseURL(l);if(!h)throw new Error("Error trying to parse relative URL.");if(h.scheme)return L.alwaysNormalize?(h.path=I.normalizePath(h.path),I.buildURLFromParts(h)):l;var T=I.parseURL(_);if(!T)throw new Error("Error trying to parse base URL.");if(!T.netLoc&&T.path&&T.path[0]!=="/"){var y=E.exec(T.path);T.netLoc=y[1],T.path=y[2]}T.netLoc&&!T.path&&(T.path="/");var c={scheme:T.scheme,netLoc:h.netLoc,path:null,params:h.params,query:h.query,fragment:h.fragment};if(!h.netLoc&&(c.netLoc=T.netLoc,h.path[0]!=="/"))if(h.path){var e=T.path,a=e.substring(0,e.lastIndexOf("/")+1)+h.path;c.path=I.normalizePath(a)}else c.path=T.path,h.params||(c.params=T.params,h.query||(c.query=T.query));return c.path===null&&(c.path=L.alwaysNormalize?I.normalizePath(h.path):h.path),I.buildURLFromParts(c)},parseURL:function(_){var l=R.exec(_);return l?{scheme:l[1]||"",netLoc:l[2]||"",path:l[3]||"",params:l[4]||"",query:l[5]||"",fragment:l[6]||""}:null},normalizePath:function(_){for(_=_.split("").reverse().join("").replace(A,"");_.length!==(_=_.replace(D,"")).length;);return _.split("").reverse().join("")},buildURLFromParts:function(_){return _.scheme+_.netLoc+_.path+_.params+_.query+_.fragment}},N.exports=I},"./node_modules/webworkify-webpack/index.js":function(N,C,f){function R(l){var L={};function m(T){if(L[T])return L[T].exports;var y=L[T]={i:T,l:!1,exports:{}};return l[T].call(y.exports,y,y.exports,m),y.l=!0,y.exports}m.m=l,m.c=L,m.i=function(T){return T},m.d=function(T,y,c){m.o(T,y)||Object.defineProperty(T,y,{configurable:!1,enumerable:!0,get:c})},m.r=function(T){Object.defineProperty(T,"__esModule",{value:!0})},m.n=function(T){var y=T&&T.__esModule?function(){return T.default}:function(){return T};return m.d(y,"a",y),y},m.o=function(T,y){return Object.prototype.hasOwnProperty.call(T,y)},m.p="/",m.oe=function(T){throw console.error(T),T};var h=m(m.s=ENTRY_MODULE);return h.default||h}var E="[\\.|\\-|\\+|\\w|/|@]+",A="\\(\\s*(/\\*.*?\\*/)?\\s*.*?([\\.|\\-|\\+|\\w|/|@]+).*?\\)";function D(l){return(l+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function I(l,L,m){var h={};h[m]=[];var T=L.toString(),y=T.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!y)return h;for(var c,e=y[1],a=new RegExp("(\\\\n|\\W)"+D(e)+A,"g");c=a.exec(T);)c[3]!=="dll-reference"&&h[m].push(c[3]);for(a=new RegExp("\\("+D(e)+'\\("(dll-reference\\s('+E+'))"\\)\\)'+A,"g");c=a.exec(T);)l[c[2]]||(h[m].push(c[1]),l[c[2]]=f(c[1]).m),h[c[2]]=h[c[2]]||[],h[c[2]].push(c[4]);for(var t,s=Object.keys(h),d=0;d<s.length;d++)for(var n=0;n<h[s[d]].length;n++)t=h[s[d]][n],isNaN(1*t)||(h[s[d]][n]=1*h[s[d]][n]);return h}function _(l){return Object.keys(l).reduce(function(L,m){return L||l[m].length>0},!1)}N.exports=function(l,L){L=L||{};var m={main:f.m},h=L.all?{main:Object.keys(m.main)}:function(a,t){for(var s={main:[t]},d={main:[]},n={main:{}};_(s);)for(var u=Object.keys(s),p=0;p<u.length;p++){var g=u[p],v=s[g].pop();if(n[g]=n[g]||{},!n[g][v]&&a[g][v]){n[g][v]=!0,d[g]=d[g]||[],d[g].push(v);for(var i=I(a,a[g][v],g),r=Object.keys(i),o=0;o<r.length;o++)s[r[o]]=s[r[o]]||[],s[r[o]]=s[r[o]].concat(i[r[o]])}}return d}(m,l),T="";Object.keys(h).filter(function(a){return a!=="main"}).forEach(function(a){for(var t=0;h[a][t];)t++;h[a].push(t),m[a][t]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",T=T+"var "+a+" = ("+R.toString().replace("ENTRY_MODULE",JSON.stringify(t))+")({"+h[a].map(function(s){return JSON.stringify(s)+": "+m[a][s].toString()}).join(",")+`});
|
||
`}),T=T+"new (("+R.toString().replace("ENTRY_MODULE",JSON.stringify(l))+")({"+h.main.map(function(a){return JSON.stringify(a)+": "+m.main[a].toString()}).join(",")+"}))(self);";var y=new window.Blob([T],{type:"text/javascript"});if(L.bare)return y;var c=(window.URL||window.webkitURL||window.mozURL||window.msURL).createObjectURL(y),e=new window.Worker(c);return e.objectURL=c,e}},"./src/config.ts":function(N,C,f){f.r(C),f.d(C,"hlsDefaultConfig",function(){return u}),f.d(C,"mergeConfig",function(){return p}),f.d(C,"enableStreamingMode",function(){return g});var R=f("./src/controller/abr-controller.ts"),E=f("./src/controller/audio-stream-controller.ts"),A=f("./src/controller/audio-track-controller.ts"),D=f("./src/controller/subtitle-stream-controller.ts"),I=f("./src/controller/subtitle-track-controller.ts"),_=f("./src/controller/buffer-controller.ts"),l=f("./src/controller/timeline-controller.ts"),L=f("./src/controller/cap-level-controller.ts"),m=f("./src/controller/fps-controller.ts"),h=f("./src/controller/eme-controller.ts"),T=f("./src/utils/xhr-loader.ts"),y=f("./src/utils/fetch-loader.ts"),c=f("./src/utils/cues.ts"),e=f("./src/utils/mediakeys-helper.ts"),a=f("./src/utils/logger.ts");function t(){return(t=Object.assign||function(v){for(var i=1;i<arguments.length;i++){var r=arguments[i];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(v[o]=r[o])}return v}).apply(this,arguments)}function s(v,i){var r=Object.keys(v);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(v);i&&(o=o.filter(function(S){return Object.getOwnPropertyDescriptor(v,S).enumerable})),r.push.apply(r,o)}return r}function d(v){for(var i=1;i<arguments.length;i++){var r=arguments[i]!=null?arguments[i]:{};i%2?s(Object(r),!0).forEach(function(o){n(v,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(v,Object.getOwnPropertyDescriptors(r)):s(Object(r)).forEach(function(o){Object.defineProperty(v,o,Object.getOwnPropertyDescriptor(r,o))})}return v}function n(v,i,r){return i in v?Object.defineProperty(v,i,{value:r,enumerable:!0,configurable:!0,writable:!0}):v[i]=r,v}var u=d(d({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!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:T.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:R.default,bufferController:_.default,capLevelController:L.default,fpsController:m.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,drmSystemOptions:{},requestMediaKeySystemAccessFunc:e.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0},{cueHandler:c.default,enableCEA708Captions:!0,enableWebVTT:!0,enableIMSC1:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:D.SubtitleStreamController,subtitleTrackController:I.default,timelineController:l.TimelineController,audioStreamController:E.default,audioTrackController:A.default,emeController:h.default});function p(v,i){if((i.liveSyncDurationCount||i.liveMaxLatencyDurationCount)&&(i.liveSyncDuration||i.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(i.liveMaxLatencyDurationCount!==void 0&&(i.liveSyncDurationCount===void 0||i.liveMaxLatencyDurationCount<=i.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(i.liveMaxLatencyDuration!==void 0&&(i.liveSyncDuration===void 0||i.liveMaxLatencyDuration<=i.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return t({},v,i)}function g(v){var i=v.loader;i!==y.default&&i!==T.default?(a.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),v.progressive=!1):Object(y.fetchSupported)()&&(v.loader=y.default,v.progressive=!0,v.enableSoftwareAES=!0,a.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}},"./src/controller/abr-controller.ts":function(N,C,f){f.r(C);var R=f("./src/polyfills/number.ts"),E=f("./src/utils/ewma-bandwidth-estimator.ts"),A=f("./src/events.ts"),D=f("./src/utils/buffer-helper.ts"),I=f("./src/errors.ts"),_=f("./src/types/loader.ts"),l=f("./src/utils/logger.ts");function L(h,T){for(var y=0;y<T.length;y++){var c=T[y];c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(h,c.key,c)}}var m=function(){function h(e){this.hls=void 0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=void 0,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=e;var a=e.config;this.bwEstimator=new E.default(a.abrEwmaSlowVoD,a.abrEwmaFastVoD,a.abrEwmaDefaultEstimate),this.registerListeners()}var T,y,c=h.prototype;return c.registerListeners=function(){var e=this.hls;e.on(A.Events.FRAG_LOADING,this.onFragLoading,this),e.on(A.Events.FRAG_LOADED,this.onFragLoaded,this),e.on(A.Events.FRAG_BUFFERED,this.onFragBuffered,this),e.on(A.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(A.Events.ERROR,this.onError,this)},c.unregisterListeners=function(){var e=this.hls;e.off(A.Events.FRAG_LOADING,this.onFragLoading,this),e.off(A.Events.FRAG_LOADED,this.onFragLoaded,this),e.off(A.Events.FRAG_BUFFERED,this.onFragBuffered,this),e.off(A.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(A.Events.ERROR,this.onError,this)},c.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},c.onFragLoading=function(e,a){var t,s=a.frag;s.type===_.PlaylistLevelType.MAIN&&(this.timer||(this.fragCurrent=s,this.partCurrent=(t=a.part)!=null?t:null,this.timer=self.setInterval(this.onCheck,100)))},c.onLevelLoaded=function(e,a){var t=this.hls.config;a.details.live?this.bwEstimator.update(t.abrEwmaSlowLive,t.abrEwmaFastLive):this.bwEstimator.update(t.abrEwmaSlowVoD,t.abrEwmaFastVoD)},c._abandonRulesCheck=function(){var e=this.fragCurrent,a=this.partCurrent,t=this.hls,s=t.autoLevelEnabled,d=t.config,n=t.media;if(e&&n){var u=a?a.stats:e.stats,p=a?a.duration:e.duration;if(u.aborted)return l.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),void(this._nextAutoLevel=-1);if(s&&!n.paused&&n.playbackRate&&n.readyState){var g=performance.now()-u.loading.start,v=Math.abs(n.playbackRate);if(!(g<=500*p/v)){var i=t.levels,r=t.minAutoLevel,o=i[e.level],S=u.total||Math.max(u.loaded,Math.round(p*o.maxBitrate/8)),b=Math.max(1,u.bwEstimate?u.bwEstimate/8:1e3*u.loaded/g),k=(S-u.loaded)/b,x=n.currentTime,w=(D.BufferHelper.bufferInfo(n,x,d.maxBufferHole).end-x)/v;if(!(w>=2*p/v||k<=w)){var O,P=Number.POSITIVE_INFINITY;for(O=e.level-1;O>r&&!((P=p*i[O].maxBitrate/(6.4*b))<w);O--);if(!(P>=k)){var F=this.bwEstimator.getEstimate();l.logger.warn("Fragment "+e.sn+(a?" part "+a.index:"")+" of level "+e.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+O+`
|
||
Current BW estimate: `+(Object(R.isFiniteNumber)(F)?(F/1024).toFixed(3):"Unknown")+` Kb/s
|
||
Estimated load time for current fragment: `+k.toFixed(3)+` s
|
||
Estimated load time for the next fragment: `+P.toFixed(3)+` s
|
||
Time to underbuffer: `+w.toFixed(3)+" s"),t.nextLoadLevel=O,this.bwEstimator.sample(g,u.loaded),this.clearTimer(),e.loader&&(this.fragCurrent=this.partCurrent=null,e.loader.abort()),t.trigger(A.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:e,part:a,stats:u})}}}}}},c.onFragLoaded=function(e,a){var t=a.frag,s=a.part;if(t.type===_.PlaylistLevelType.MAIN&&Object(R.isFiniteNumber)(t.sn)){var d=s?s.stats:t.stats,n=s?s.duration:t.duration;if(this.clearTimer(),this.lastLoadedFragLevel=t.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var u=this.hls.levels[t.level],p=(u.loaded?u.loaded.bytes:0)+d.loaded,g=(u.loaded?u.loaded.duration:0)+n;u.loaded={bytes:p,duration:g},u.realBitrate=Math.round(8*p/g)}if(t.bitrateTest){var v={stats:d,frag:t,part:s,id:t.type};this.onFragBuffered(A.Events.FRAG_BUFFERED,v),t.bitrateTest=!1}}},c.onFragBuffered=function(e,a){var t=a.frag,s=a.part,d=s?s.stats:t.stats;if(!d.aborted&&t.type===_.PlaylistLevelType.MAIN&&t.sn!=="initSegment"){var n=d.parsing.end-d.loading.start;this.bwEstimator.sample(n,d.loaded),d.bwEstimate=this.bwEstimator.getEstimate(),t.bitrateTest?this.bitrateTestDelay=n/1e3:this.bitrateTestDelay=0}},c.onError=function(e,a){switch(a.details){case I.ErrorDetails.FRAG_LOAD_ERROR:case I.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer()}},c.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},c.getNextABRAutoLevel=function(){var e=this.fragCurrent,a=this.partCurrent,t=this.hls,s=t.maxAutoLevel,d=t.config,n=t.minAutoLevel,u=t.media,p=a?a.duration:e?e.duration:0,g=u?u.currentTime:0,v=u&&u.playbackRate!==0?Math.abs(u.playbackRate):1,i=this.bwEstimator?this.bwEstimator.getEstimate():d.abrEwmaDefaultEstimate,r=(D.BufferHelper.bufferInfo(u,g,d.maxBufferHole).end-g)/v,o=this.findBestLevel(i,n,s,r,d.abrBandWidthFactor,d.abrBandWidthUpFactor);if(o>=0)return o;l.logger.trace((r?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var S=p?Math.min(p,d.maxStarvationDelay):d.maxStarvationDelay,b=d.abrBandWidthFactor,k=d.abrBandWidthUpFactor;if(!r){var x=this.bitrateTestDelay;x&&(S=(p?Math.min(p,d.maxLoadingDelay):d.maxLoadingDelay)-x,l.logger.trace("bitrate test took "+Math.round(1e3*x)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*S)+" ms"),b=k=1)}return o=this.findBestLevel(i,n,s,r+S,b,k),Math.max(o,0)},c.findBestLevel=function(e,a,t,s,d,n){for(var u,p=this.fragCurrent,g=this.partCurrent,v=this.lastLoadedFragLevel,i=this.hls.levels,r=i[v],o=!(r==null||(u=r.details)===null||u===void 0||!u.live),S=r==null?void 0:r.codecSet,b=g?g.duration:p?p.duration:0,k=t;k>=a;k--){var x=i[k];if(x&&(!S||x.codecSet===S)){var w=x.details,O=(g?w==null?void 0:w.partTarget:w==null?void 0:w.averagetargetduration)||b,P=void 0;P=k<=v?d*e:n*e;var F=i[k].maxBitrate,M=F*O/P;if(l.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+k+"/"+Math.round(P)+"/"+F+"/"+O+"/"+s+"/"+M),P>F&&(!M||o&&!this.bitrateTestDelay||M<s))return k}}return-1},T=h,(y=[{key:"nextAutoLevel",get:function(){var e=this._nextAutoLevel,a=this.bwEstimator;if(!(e===-1||a&&a.canEstimate()))return e;var t=this.getNextABRAutoLevel();return e!==-1&&(t=Math.min(e,t)),t},set:function(e){this._nextAutoLevel=e}}])&&L(T.prototype,y),h}();C.default=m},"./src/controller/audio-stream-controller.ts":function(N,C,f){f.r(C);var R=f("./src/polyfills/number.ts"),E=f("./src/controller/base-stream-controller.ts"),A=f("./src/events.ts"),D=f("./src/utils/buffer-helper.ts"),I=f("./src/controller/fragment-tracker.ts"),_=f("./src/types/level.ts"),l=f("./src/types/loader.ts"),L=f("./src/loader/fragment.ts"),m=f("./src/demux/chunk-cache.ts"),h=f("./src/demux/transmuxer-interface.ts"),T=f("./src/types/transmuxer.ts"),y=f("./src/controller/fragment-finders.ts"),c=f("./src/utils/discontinuities.ts"),e=f("./src/errors.ts"),a=f("./src/utils/logger.ts");function t(){return(t=Object.assign||function(n){for(var u=1;u<arguments.length;u++){var p=arguments[u];for(var g in p)Object.prototype.hasOwnProperty.call(p,g)&&(n[g]=p[g])}return n}).apply(this,arguments)}function s(n,u){return(s=Object.setPrototypeOf||function(p,g){return p.__proto__=g,p})(n,u)}var d=function(n){var u,p;function g(i,r){var o;return(o=n.call(this,i,r,"[audio-stream-controller]")||this).videoBuffer=null,o.videoTrackCC=-1,o.waitingVideoCC=-1,o.audioSwitch=!1,o.trackId=-1,o.waitingData=null,o.mainDetails=null,o.bufferFlushed=!1,o._registerListeners(),o}p=n,(u=g).prototype=Object.create(p.prototype),u.prototype.constructor=u,s(u,p);var v=g.prototype;return v.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},v._registerListeners=function(){var i=this.hls;i.on(A.Events.MEDIA_ATTACHED,this.onMediaAttached,this),i.on(A.Events.MEDIA_DETACHING,this.onMediaDetaching,this),i.on(A.Events.MANIFEST_LOADING,this.onManifestLoading,this),i.on(A.Events.LEVEL_LOADED,this.onLevelLoaded,this),i.on(A.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),i.on(A.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),i.on(A.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),i.on(A.Events.ERROR,this.onError,this),i.on(A.Events.BUFFER_RESET,this.onBufferReset,this),i.on(A.Events.BUFFER_CREATED,this.onBufferCreated,this),i.on(A.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),i.on(A.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),i.on(A.Events.FRAG_BUFFERED,this.onFragBuffered,this)},v._unregisterListeners=function(){var i=this.hls;i.off(A.Events.MEDIA_ATTACHED,this.onMediaAttached,this),i.off(A.Events.MEDIA_DETACHING,this.onMediaDetaching,this),i.off(A.Events.MANIFEST_LOADING,this.onManifestLoading,this),i.off(A.Events.LEVEL_LOADED,this.onLevelLoaded,this),i.off(A.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),i.off(A.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),i.off(A.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),i.off(A.Events.ERROR,this.onError,this),i.off(A.Events.BUFFER_RESET,this.onBufferReset,this),i.off(A.Events.BUFFER_CREATED,this.onBufferCreated,this),i.off(A.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),i.off(A.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),i.off(A.Events.FRAG_BUFFERED,this.onFragBuffered,this)},v.onInitPtsFound=function(i,r){var o=r.frag,S=r.id,b=r.initPTS;if(S==="main"){var k=o.cc;this.initPTS[o.cc]=b,this.log("InitPTS for cc: "+k+" found from main: "+b),this.videoTrackCC=k,this.state===E.State.WAITING_INIT_PTS&&this.tick()}},v.startLoad=function(i){if(!this.levels)return this.startPosition=i,void(this.state=E.State.STOPPED);var r=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),this.fragLoadError=0,r>0&&i===-1?(this.log("Override startPosition with lastCurrentTime @"+r.toFixed(3)),this.state=E.State.IDLE):(this.loadedmetadata=!1,this.state=E.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=i,this.tick()},v.doTick=function(){switch(this.state){case E.State.IDLE:this.doTickIdle();break;case E.State.WAITING_TRACK:var i,r=this.levels,o=this.trackId,S=r==null||(i=r[o])===null||i===void 0?void 0:i.details;if(S){if(this.waitForCdnTuneIn(S))break;this.state=E.State.WAITING_INIT_PTS}break;case E.State.FRAG_LOADING_WAITING_RETRY:var b,k=performance.now(),x=this.retryDate;(!x||k>=x||(b=this.media)!==null&&b!==void 0&&b.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.state=E.State.IDLE);break;case E.State.WAITING_INIT_PTS:var w=this.waitingData;if(w){var O=w.frag,P=w.part,F=w.cache,M=w.complete;if(this.initPTS[O.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=E.State.FRAG_LOADING;var B={frag:O,part:P,payload:F.flush(),networkDetails:null};this._handleFragmentLoadProgress(B),M&&n.prototype._handleFragmentLoadComplete.call(this,B)}else if(this.videoTrackCC!==this.waitingVideoCC)a.logger.log("Waiting fragment cc ("+O.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var U=this.getLoadPosition(),j=D.BufferHelper.bufferInfo(this.mediaBuffer,U,this.config.maxBufferHole);Object(y.fragmentWithinToleranceTest)(j.end,this.config.maxFragLookUpTolerance,O)<0&&(a.logger.log("Waiting fragment cc ("+O.cc+") @ "+O.start+" cancelled because another fragment at "+j.end+" is needed"),this.clearWaitingFragment())}}else this.state=E.State.IDLE}this.onTickEnd()},v.clearWaitingFragment=function(){var i=this.waitingData;i&&(this.fragmentTracker.removeFragment(i.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=E.State.IDLE)},v.onTickEnd=function(){var i=this.media;if(i&&i.readyState){var r=(this.mediaBuffer?this.mediaBuffer:i).buffered;!this.loadedmetadata&&r.length&&(this.loadedmetadata=!0),this.lastCurrentTime=i.currentTime}},v.doTickIdle=function(){var i,r,o=this.hls,S=this.levels,b=this.media,k=this.trackId,x=o.config;if(S&&S[k]&&(b||!this.startFragRequested&&x.startFragPrefetch)){var w=S[k].details;if(!w||w.live&&this.levelLastLoaded!==k||this.waitForCdnTuneIn(w))this.state=E.State.WAITING_TRACK;else{this.bufferFlushed&&(this.bufferFlushed=!1,this.afterBufferFlushed(this.mediaBuffer?this.mediaBuffer:this.media,L.ElementaryStreamTypes.AUDIO,l.PlaylistLevelType.AUDIO));var O=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,l.PlaylistLevelType.AUDIO);if(O!==null){var P=O.len,F=this.getMaxBufferLength(),M=this.audioSwitch;if(!(P>=F)||M){if(!M&&this._streamEnded(O,w))return o.trigger(A.Events.BUFFER_EOS,{type:"audio"}),void(this.state=E.State.ENDED);var B=w.fragments[0].start,U=O.end;if(M){var j=this.getLoadPosition();U=j,w.PTSKnown&&j<B&&(O.end>B||O.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),b.currentTime=B+.05)}var V=this.getNextFragment(U,w);V?((i=V.decryptdata)===null||i===void 0?void 0:i.keyFormat)!=="identity"||(r=V.decryptdata)!==null&&r!==void 0&&r.key?this.loadFragment(V,w,U):this.loadKey(V,w):this.bufferFlushed=!0}}}}},v.getMaxBufferLength=function(){var i=n.prototype.getMaxBufferLength.call(this),r=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,l.PlaylistLevelType.MAIN);return r===null?i:Math.max(i,r.len)},v.onMediaDetaching=function(){this.videoBuffer=null,n.prototype.onMediaDetaching.call(this)},v.onAudioTracksUpdated=function(i,r){var o=r.audioTracks;this.resetTransmuxer(),this.levels=o.map(function(S){return new _.Level(S)})},v.onAudioTrackSwitching=function(i,r){var o=!!r.url;this.trackId=r.id;var S=this.fragCurrent;S!=null&&S.loader&&S.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),o?this.setInterval(100):this.resetTransmuxer(),o?(this.audioSwitch=!0,this.state=E.State.IDLE):this.state=E.State.STOPPED,this.tick()},v.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},v.onLevelLoaded=function(i,r){this.mainDetails=r.details},v.onAudioTrackLoaded=function(i,r){var o,S=this.levels,b=r.details,k=r.id;if(S){this.log("Track "+k+" loaded ["+b.startSN+","+b.endSN+"],duration:"+b.totalduration);var x=S[k],w=0;if(b.live||(o=x.details)!==null&&o!==void 0&&o.live){var O=this.mainDetails;if(b.fragments[0]||(b.deltaUpdateFailed=!0),b.deltaUpdateFailed||!O)return;!x.details&&b.hasProgramDateTime&&O.hasProgramDateTime?(Object(c.alignPDT)(b,O),w=b.fragments[0].start):w=this.alignPlaylists(b,x.details)}x.details=b,this.levelLastLoaded=k,this.startFragRequested||!this.mainDetails&&b.live||this.setStartPosition(x.details,w),this.state!==E.State.WAITING_TRACK||this.waitForCdnTuneIn(b)||(this.state=E.State.IDLE),this.tick()}else this.warn("Audio tracks were reset while loading level "+k)},v._handleFragmentLoadProgress=function(i){var r,o=i.frag,S=i.part,b=i.payload,k=this.config,x=this.trackId,w=this.levels;if(w){var O=w[x];console.assert(O,"Audio track is defined on fragment load progress");var P=O.details;console.assert(P,"Audio track details are defined on fragment load progress");var F=k.defaultAudioCodec||O.audioCodec||"mp4a.40.2",M=this.transmuxer;M||(M=this.transmuxer=new h.default(this.hls,l.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var B=this.initPTS[o.cc],U=(r=o.initSegment)===null||r===void 0?void 0:r.data;if(B!==void 0){var j=S?S.index:-1,V=j!==-1,H=new T.ChunkMetadata(o.level,o.sn,o.stats.chunkCount,b.byteLength,j,V);M.push(b,U,F,"",o,S,P.totalduration,!1,H,B)}else a.logger.log("Unknown video PTS for cc "+o.cc+", waiting for video PTS before demuxing audio frag "+o.sn+" of ["+P.startSN+" ,"+P.endSN+"],track "+x),(this.waitingData=this.waitingData||{frag:o,part:S,cache:new m.default,complete:!1}).cache.push(new Uint8Array(b)),this.waitingVideoCC=this.videoTrackCC,this.state=E.State.WAITING_INIT_PTS}else this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+o.sn+" of level "+o.level+" will not be buffered")},v._handleFragmentLoadComplete=function(i){this.waitingData?this.waitingData.complete=!0:n.prototype._handleFragmentLoadComplete.call(this,i)},v.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},v.onBufferCreated=function(i,r){var o=r.tracks.audio;o&&(this.mediaBuffer=o.buffer),r.tracks.video&&(this.videoBuffer=r.tracks.video.buffer)},v.onFragBuffered=function(i,r){var o=r.frag,S=r.part;o.type===l.PlaylistLevelType.AUDIO&&(this.fragContextChanged(o)?this.warn("Fragment "+o.sn+(S?" p: "+S.index:"")+" of level "+o.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch):(o.sn!=="initSegment"&&(this.fragPrevious=o,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(A.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(o,S)))},v.onError=function(i,r){switch(r.details){case e.ErrorDetails.FRAG_LOAD_ERROR:case e.ErrorDetails.FRAG_LOAD_TIMEOUT:case e.ErrorDetails.KEY_LOAD_ERROR:case e.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(l.PlaylistLevelType.AUDIO,r);break;case e.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case e.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==E.State.ERROR&&this.state!==E.State.STOPPED&&(this.state=r.fatal?E.State.ERROR:E.State.IDLE,this.warn(r.details+" while loading frag, switching to "+this.state+" state"));break;case e.ErrorDetails.BUFFER_FULL_ERROR:if(r.parent==="audio"&&(this.state===E.State.PARSING||this.state===E.State.PARSED)){var o=!0,S=this.getFwdBufferInfo(this.mediaBuffer,l.PlaylistLevelType.AUDIO);S&&S.len>.5&&(o=!this.reduceMaxBufferLength(S.len)),o&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,n.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}}},v.onBufferFlushed=function(i,r){r.type===L.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},v._handleTransmuxComplete=function(i){var r,o="audio",S=this.hls,b=i.remuxResult,k=i.chunkMeta,x=this.getCurrentContext(k);if(!x)return this.warn("The loading context changed while buffering fragment "+k.sn+" of level "+k.level+". This chunk will not be buffered."),void this.resetLiveStartWhenNotLoaded(k.level);var w=x.frag,O=x.part,P=b.audio,F=b.text,M=b.id3,B=b.initSegment;if(!this.fragContextChanged(w)){if(this.state=E.State.PARSING,this.audioSwitch&&P&&this.completeAudioSwitch(),B!=null&&B.tracks&&(this._bufferInitSegment(B.tracks,w,k),S.trigger(A.Events.FRAG_PARSING_INIT_SEGMENT,{frag:w,id:o,tracks:B.tracks})),P){var U=P.startPTS,j=P.endPTS,V=P.startDTS,H=P.endDTS;O&&(O.elementaryStreams[L.ElementaryStreamTypes.AUDIO]={startPTS:U,endPTS:j,startDTS:V,endDTS:H}),w.setElementaryStreamInfo(L.ElementaryStreamTypes.AUDIO,U,j,V,H),this.bufferFragmentData(P,w,O,k)}if(M!=null&&(r=M.samples)!==null&&r!==void 0&&r.length){var z=t({frag:w,id:o},M);S.trigger(A.Events.FRAG_PARSING_METADATA,z)}if(F){var W=t({frag:w,id:o},F);S.trigger(A.Events.FRAG_PARSING_USERDATA,W)}}},v._bufferInitSegment=function(i,r,o){if(this.state===E.State.PARSING){i.video&&delete i.video;var S=i.audio;if(S){S.levelCodec=S.codec,S.id="audio",this.log("Init audio buffer, container:"+S.container+", codecs[parsed]=["+S.codec+"]"),this.hls.trigger(A.Events.BUFFER_CODECS,i);var b=S.initSegment;if(b!=null&&b.byteLength){var k={type:"audio",frag:r,part:null,chunkMeta:o,parent:r.type,data:b};this.hls.trigger(A.Events.BUFFER_APPENDING,k)}this.tick()}}},v.loadFragment=function(i,r,o){var S=this.fragmentTracker.getState(i);this.fragCurrent=i,(this.audioSwitch||S===I.FragmentState.NOT_LOADED||S===I.FragmentState.PARTIAL)&&(i.sn==="initSegment"?this._loadInitSegment(i):r.live&&!Object(R.isFiniteNumber)(this.initPTS[i.cc])?(this.log("Waiting for video PTS in continuity counter "+i.cc+" of live stream before loading audio fragment "+i.sn+" of level "+this.trackId),this.state=E.State.WAITING_INIT_PTS):(this.startFragRequested=!0,n.prototype.loadFragment.call(this,i,r,o)))},v.completeAudioSwitch=function(){var i=this.hls,r=this.media,o=this.trackId;r&&(this.log("Switching audio track : flushing all audio"),n.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,i.trigger(A.Events.AUDIO_TRACK_SWITCHED,{id:o})},g}(E.default);C.default=d},"./src/controller/audio-track-controller.ts":function(N,C,f){f.r(C);var R=f("./src/events.ts"),E=f("./src/errors.ts"),A=f("./src/controller/base-playlist-controller.ts"),D=f("./src/types/loader.ts");function I(L,m){for(var h=0;h<m.length;h++){var T=m[h];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(L,T.key,T)}}function _(L,m){return(_=Object.setPrototypeOf||function(h,T){return h.__proto__=T,h})(L,m)}var l=function(L){var m,h;function T(a){var t;return(t=L.call(this,a,"[audio-track-controller]")||this).tracks=[],t.groupId=null,t.tracksInGroup=[],t.trackId=-1,t.trackName="",t.selectDefaultTrack=!0,t.registerListeners(),t}h=L,(m=T).prototype=Object.create(h.prototype),m.prototype.constructor=m,_(m,h);var y,c,e=T.prototype;return e.registerListeners=function(){var a=this.hls;a.on(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.on(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),a.on(R.Events.LEVEL_LOADING,this.onLevelLoading,this),a.on(R.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),a.on(R.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),a.on(R.Events.ERROR,this.onError,this)},e.unregisterListeners=function(){var a=this.hls;a.off(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.off(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),a.off(R.Events.LEVEL_LOADING,this.onLevelLoading,this),a.off(R.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),a.off(R.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),a.off(R.Events.ERROR,this.onError,this)},e.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,L.prototype.destroy.call(this)},e.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},e.onManifestParsed=function(a,t){this.tracks=t.audioTracks||[]},e.onAudioTrackLoaded=function(a,t){var s=t.id,d=t.details,n=this.tracksInGroup[s];if(n){var u=n.details;n.details=t.details,this.log("audioTrack "+s+" loaded ["+d.startSN+"-"+d.endSN+"]"),s===this.trackId&&(this.retryCount=0,this.playlistLoaded(s,t,u))}else this.warn("Invalid audio track id "+s)},e.onLevelLoading=function(a,t){this.switchLevel(t.level)},e.onLevelSwitching=function(a,t){this.switchLevel(t.level)},e.switchLevel=function(a){var t=this.hls.levels[a];if(t!=null&&t.audioGroupIds){var s=t.audioGroupIds[t.urlId];if(this.groupId!==s){this.groupId=s;var d=this.tracks.filter(function(u){return!s||u.groupId===s});this.selectDefaultTrack&&!d.some(function(u){return u.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=d;var n={audioTracks:d};this.log("Updating audio tracks, "+d.length+' track(s) found in "'+s+'" group-id'),this.hls.trigger(R.Events.AUDIO_TRACKS_UPDATED,n),this.selectInitialTrack()}}},e.onError=function(a,t){L.prototype.onError.call(this,a,t),!t.fatal&&t.context&&t.context.type===D.PlaylistContextType.AUDIO_TRACK&&t.context.id===this.trackId&&t.context.groupId===this.groupId&&this.retryLoadingOrFail(t)},e.setAudioTrack=function(a){var t=this.tracksInGroup;if(a<0||a>=t.length)this.warn("Invalid id passed to audio-track controller");else{this.clearTimer();var s=t[this.trackId];this.log("Now switching to audio-track index "+a);var d=t[a],n=d.id,u=d.groupId,p=u===void 0?"":u,g=d.name,v=d.type,i=d.url;if(this.trackId=a,this.trackName=g,this.selectDefaultTrack=!1,this.hls.trigger(R.Events.AUDIO_TRACK_SWITCHING,{id:n,groupId:p,name:g,type:v,url:i}),!d.details||d.details.live){var r=this.switchParams(d.url,s==null?void 0:s.details);this.loadPlaylist(r)}}},e.selectInitialTrack=function(){var a=this.tracksInGroup;console.assert(a.length,"Initial audio track should be selected when tracks are known");var t=this.trackName,s=this.findTrackId(t)||this.findTrackId();s!==-1?this.setAudioTrack(s):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(R.Events.ERROR,{type:E.ErrorTypes.MEDIA_ERROR,details:E.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},e.findTrackId=function(a){for(var t=this.tracksInGroup,s=0;s<t.length;s++){var d=t[s];if((!this.selectDefaultTrack||d.default)&&(!a||a===d.name))return d.id}return-1},e.loadPlaylist=function(a){var t=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(t)){var s=t.id,d=t.groupId,n=t.url;if(a)try{n=a.addDirectives(n)}catch(u){this.warn("Could not construct new URL with HLS Delivery Directives: "+u)}this.log("loading audio-track playlist for id: "+s),this.clearTimer(),this.hls.trigger(R.Events.AUDIO_TRACK_LOADING,{url:n,id:s,groupId:d,deliveryDirectives:a||null})}},y=T,(c=[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(a){this.selectDefaultTrack=!1,this.setAudioTrack(a)}}])&&I(y.prototype,c),T}(A.default);C.default=l},"./src/controller/base-playlist-controller.ts":function(N,C,f){f.r(C),f.d(C,"default",function(){return _});var R=f("./src/polyfills/number.ts"),E=f("./src/types/level.ts"),A=f("./src/controller/level-helper.ts"),D=f("./src/utils/logger.ts"),I=f("./src/errors.ts"),_=function(){function l(m,h){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=D.logger.log.bind(D.logger,h+":"),this.warn=D.logger.warn.bind(D.logger,h+":"),this.hls=m}var L=l.prototype;return L.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},L.onError=function(m,h){h.fatal&&h.type===I.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},L.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},L.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},L.stopLoad=function(){this.canLoad=!1,this.clearTimer()},L.switchParams=function(m,h){var T=h==null?void 0:h.renditionReports;if(T)for(var y=0;y<T.length;y++){var c=T[y],e=""+c.URI;if(e===m.substr(-e.length)){var a=parseInt(c["LAST-MSN"]),t=parseInt(c["LAST-PART"]);if(h&&this.hls.config.lowLatencyMode){var s=Math.min(h.age-h.partTarget,h.targetduration);t!==void 0&&s>h.partTarget&&(t+=1)}if(Object(R.isFiniteNumber)(a))return new E.HlsUrlParameters(a,Object(R.isFiniteNumber)(t)?t:void 0,E.HlsSkip.No)}}},L.loadPlaylist=function(m){},L.shouldLoadTrack=function(m){return this.canLoad&&m&&!!m.url&&(!m.details||m.details.live)},L.playlistLoaded=function(m,h,T){var y=this,c=h.details,e=h.stats,a=e.loading.end?Math.max(0,self.performance.now()-e.loading.end):0;if(c.advancedDateTime=Date.now()-a,c.live||T!=null&&T.live){if(c.reloaded(T),T&&this.log("live playlist "+m+" "+(c.advanced?"REFRESHED "+c.lastPartSn+"-"+c.lastPartIndex:"MISSED")),T&&c.fragments.length>0&&Object(A.mergeDetails)(T,c),!this.canLoad||!c.live)return;var t,s=void 0,d=void 0;if(c.canBlockReload&&c.endSN&&c.advanced){var n=this.hls.config.lowLatencyMode,u=c.lastPartSn,p=c.endSN,g=c.lastPartIndex,v=u===p;g!==-1?(s=v?p+1:u,d=v?n?0:g:g+1):s=p+1;var i=c.age,r=i+c.ageHeader,o=Math.min(r-c.partTarget,1.5*c.targetduration);if(o>0){if(T&&o>T.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+T.tuneInGoal+" to: "+o+" with playlist age: "+c.age),o=0;else{var S=Math.floor(o/c.targetduration);s+=S,d!==void 0&&(d+=Math.round(o%c.targetduration/c.partTarget)),this.log("CDN Tune-in age: "+c.ageHeader+"s last advanced "+i.toFixed(2)+"s goal: "+o+" skip sn "+S+" to part "+d)}c.tuneInGoal=o}if(t=this.getDeliveryDirectives(c,h.deliveryDirectives,s,d),n||!v)return void this.loadPlaylist(t)}else t=this.getDeliveryDirectives(c,h.deliveryDirectives,s,d);var b=Object(A.computeReloadInterval)(c,e);s!==void 0&&c.canBlockReload&&(b-=c.partTarget||1),this.log("reload live playlist "+m+" in "+Math.round(b)+" ms"),this.timer=self.setTimeout(function(){return y.loadPlaylist(t)},b)}else this.clearTimer()},L.getDeliveryDirectives=function(m,h,T,y){var c=Object(E.getSkipValue)(m,T);return h!=null&&h.skip&&m.deltaUpdateFailed&&(T=h.msn,y=h.part,c=E.HlsSkip.No),new E.HlsUrlParameters(T,y,c)},L.retryLoadingOrFail=function(m){var h,T=this,y=this.hls.config,c=this.retryCount<y.levelLoadingMaxRetry;if(c)if(this.retryCount++,m.details.indexOf("LoadTimeOut")>-1&&(h=m.context)!==null&&h!==void 0&&h.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+m.details+'"'),this.loadPlaylist();else{var e=Math.min(Math.pow(2,this.retryCount)*y.levelLoadingRetryDelay,y.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return T.loadPlaylist()},e),this.warn("retry playlist loading #"+this.retryCount+" in "+e+' ms after "'+m.details+'"')}else this.warn('cannot recover from error "'+m.details+'"'),this.clearTimer(),m.fatal=!0;return c},l}()},"./src/controller/base-stream-controller.ts":function(N,C,f){f.r(C),f.d(C,"State",function(){return n}),f.d(C,"default",function(){return u});var R=f("./src/polyfills/number.ts"),E=f("./src/task-loop.ts"),A=f("./src/controller/fragment-tracker.ts"),D=f("./src/utils/buffer-helper.ts"),I=f("./src/utils/logger.ts"),_=f("./src/events.ts"),l=f("./src/errors.ts"),L=f("./src/types/transmuxer.ts"),m=f("./src/utils/mp4-tools.ts"),h=f("./src/utils/discontinuities.ts"),T=f("./src/controller/fragment-finders.ts"),y=f("./src/controller/level-helper.ts"),c=f("./src/loader/fragment-loader.ts"),e=f("./src/crypt/decrypter.ts"),a=f("./src/utils/time-ranges.ts"),t=f("./src/types/loader.ts");function s(p,g){for(var v=0;v<g.length;v++){var i=g[v];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(p,i.key,i)}}function d(p,g){return(d=Object.setPrototypeOf||function(v,i){return v.__proto__=i,v})(p,g)}var n={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",BACKTRACKING:"BACKTRACKING",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},u=function(p){var g,v;function i(b,k,x){var w;return(w=p.call(this)||this).hls=void 0,w.fragPrevious=null,w.fragCurrent=null,w.fragmentTracker=void 0,w.transmuxer=null,w._state=n.STOPPED,w.media=void 0,w.mediaBuffer=void 0,w.config=void 0,w.bitrateTest=!1,w.lastCurrentTime=0,w.nextLoadPosition=0,w.startPosition=0,w.loadedmetadata=!1,w.fragLoadError=0,w.retryDate=0,w.levels=null,w.fragmentLoader=void 0,w.levelLastLoaded=null,w.startFragRequested=!1,w.decrypter=void 0,w.initPTS=[],w.onvseeking=null,w.onvended=null,w.logPrefix="",w.log=void 0,w.warn=void 0,w.logPrefix=x,w.log=I.logger.log.bind(I.logger,x+":"),w.warn=I.logger.warn.bind(I.logger,x+":"),w.hls=b,w.fragmentLoader=new c.default(b.config),w.fragmentTracker=k,w.config=b.config,w.decrypter=new e.default(b,b.config),b.on(_.Events.KEY_LOADED,w.onKeyLoaded,function(O){if(O===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return O}(w)),w}v=p,(g=i).prototype=Object.create(v.prototype),g.prototype.constructor=g,d(g,v);var r,o,S=i.prototype;return S.doTick=function(){this.onTickEnd()},S.onTickEnd=function(){},S.startLoad=function(b){},S.stopLoad=function(){this.fragmentLoader.abort();var b=this.fragCurrent;b&&this.fragmentTracker.removeFragment(b),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=n.STOPPED},S._streamEnded=function(b,k){var x=this.fragCurrent,w=this.fragmentTracker;if(!k.live&&x&&x.sn===k.endSN&&!b.nextStart){var O=w.getState(x);return O===A.FragmentState.PARTIAL||O===A.FragmentState.OK}return!1},S.onMediaAttached=function(b,k){var x=this.media=this.mediaBuffer=k.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),x.addEventListener("seeking",this.onvseeking),x.addEventListener("ended",this.onvended);var w=this.config;this.levels&&w.autoStartLoad&&this.state===n.STOPPED&&this.startLoad(w.startPosition)},S.onMediaDetaching=function(){var b=this.media;b!=null&&b.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),b&&(b.removeEventListener("seeking",this.onvseeking),b.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},S.onMediaSeeking=function(){var b=this.config,k=this.fragCurrent,x=this.media,w=this.mediaBuffer,O=this.state,P=x?x.currentTime:0,F=D.BufferHelper.bufferInfo(w||x,P,b.maxBufferHole);if(this.log("media seeking to "+(Object(R.isFiniteNumber)(P)?P.toFixed(3):P)+", state: "+O),O===n.ENDED)this.resetLoadingState();else if(k&&!F.len){var M=b.maxFragLookUpTolerance,B=k.start-M,U=P>k.start+k.duration+M;(P<B||U)&&(U&&k.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),k.loader.abort()),this.resetLoadingState())}x&&(this.lastCurrentTime=P),this.loadedmetadata||F.len||(this.nextLoadPosition=this.startPosition=P),this.tickImmediate()},S.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},S.onKeyLoaded=function(b,k){if(this.state===n.KEY_LOADING&&k.frag===this.fragCurrent&&this.levels){this.state=n.IDLE;var x=this.levels[k.frag.level].details;x&&this.loadFragment(k.frag,x,k.frag.start)}},S.onHandlerDestroying=function(){this.stopLoad(),p.prototype.onHandlerDestroying.call(this)},S.onHandlerDestroyed=function(){this.state=n.STOPPED,this.hls.off(_.Events.KEY_LOADED,this.onKeyLoaded,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.fragmentLoader=this.fragmentTracker=null,p.prototype.onHandlerDestroyed.call(this)},S.loadKey=function(b,k){this.log("Loading key for "+b.sn+" of ["+k.startSN+"-"+k.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+b.level),this.state=n.KEY_LOADING,this.fragCurrent=b,this.hls.trigger(_.Events.KEY_LOADING,{frag:b})},S.loadFragment=function(b,k,x){this._loadFragForPlayback(b,k,x)},S._loadFragForPlayback=function(b,k,x){var w=this;this._doFragLoad(b,k,x,function(O){if(w.fragContextChanged(b))return w.warn("Fragment "+b.sn+(O.part?" p: "+O.part.index:"")+" of level "+b.level+" was dropped during download."),void w.fragmentTracker.removeFragment(b);b.stats.chunkCount++,w._handleFragmentLoadProgress(O)}).then(function(O){if(O){w.fragLoadError=0;var P=w.state;if(!w.fragContextChanged(b))return"payload"in O&&(w.log("Loaded fragment "+b.sn+" of level "+b.level),w.hls.trigger(_.Events.FRAG_LOADED,O),w.state===n.BACKTRACKING)?(w.fragmentTracker.backtrack(b,O),void w.resetFragmentLoading(b)):void w._handleFragmentLoadComplete(O);(P===n.FRAG_LOADING||P===n.BACKTRACKING||!w.fragCurrent&&P===n.PARSING)&&(w.fragmentTracker.removeFragment(b),w.state=n.IDLE)}}).catch(function(O){w.warn(O),w.resetFragmentLoading(b)})},S.flushMainBuffer=function(b,k,x){if(x===void 0&&(x=null),b-k){var w={startOffset:b,endOffset:k,type:x};this.fragLoadError=0,this.hls.trigger(_.Events.BUFFER_FLUSHING,w)}},S._loadInitSegment=function(b){var k=this;this._doFragLoad(b).then(function(x){if(!x||k.fragContextChanged(b)||!k.levels)throw new Error("init load aborted");return x}).then(function(x){var w=k.hls,O=x.payload,P=b.decryptdata;if(O&&O.byteLength>0&&P&&P.key&&P.iv&&P.method==="AES-128"){var F=self.performance.now();return k.decrypter.webCryptoDecrypt(new Uint8Array(O),P.key.buffer,P.iv.buffer).then(function(M){var B=self.performance.now();return w.trigger(_.Events.FRAG_DECRYPTED,{frag:b,payload:M,stats:{tstart:F,tdecrypt:B}}),x.payload=M,x})}return x}).then(function(x){var w=k.fragCurrent,O=k.hls,P=k.levels;if(!P)throw new Error("init load aborted, missing levels");var F=P[b.level].details;console.assert(F,"Level details are defined when init segment is loaded");var M=b.stats;k.state=n.IDLE,k.fragLoadError=0,b.data=new Uint8Array(x.payload),M.parsing.start=M.buffering.start=self.performance.now(),M.parsing.end=M.buffering.end=self.performance.now(),x.frag===w&&O.trigger(_.Events.FRAG_BUFFERED,{stats:M,frag:w,part:null,id:b.type}),k.tick()}).catch(function(x){k.warn(x),k.resetFragmentLoading(b)})},S.fragContextChanged=function(b){var k=this.fragCurrent;return!b||!k||b.level!==k.level||b.sn!==k.sn||b.urlId!==k.urlId},S.fragBufferedComplete=function(b,k){var x=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+b.type+" sn: "+b.sn+(k?" part: "+k.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+b.level+" "+a.default.toString(D.BufferHelper.getBuffered(x))),this.state=n.IDLE,this.tick()},S._handleFragmentLoadComplete=function(b){var k=this.transmuxer;if(k){var x=b.frag,w=b.part,O=b.partsLoaded,P=!O||O.length===0||O.some(function(M){return!M}),F=new L.ChunkMetadata(x.level,x.sn,x.stats.chunkCount+1,0,w?w.index:-1,!P);k.flush(F)}},S._handleFragmentLoadProgress=function(b){},S._doFragLoad=function(b,k,x,w){var O=this;if(x===void 0&&(x=null),!this.levels)throw new Error("frag load aborted, missing levels");if(x=Math.max(b.start,x||0),this.config.lowLatencyMode&&k){var P=k.partList;if(P&&w){x>b.end&&k.fragmentHint&&(b=k.fragmentHint);var F=this.getNextPart(P,b,x);if(F>-1){var M=P[F];return this.log("Loading part sn: "+b.sn+" p: "+M.index+" cc: "+b.cc+" of playlist ["+k.startSN+"-"+k.endSN+"] parts [0-"+F+"-"+(P.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+b.level+", target: "+parseFloat(x.toFixed(3))),this.nextLoadPosition=M.start+M.duration,this.state=n.FRAG_LOADING,this.hls.trigger(_.Events.FRAG_LOADING,{frag:b,part:P[F],targetBufferTime:x}),this.doFragPartsLoad(b,P,F,w).catch(function(B){return O.handleFragLoadError(B)})}if(!b.url||this.loadedEndOfParts(P,x))return Promise.resolve(null)}}return this.log("Loading fragment "+b.sn+" cc: "+b.cc+" "+(k?"of ["+k.startSN+"-"+k.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+b.level+", target: "+parseFloat(x.toFixed(3))),Object(R.isFiniteNumber)(b.sn)&&!this.bitrateTest&&(this.nextLoadPosition=b.start+b.duration),this.state=n.FRAG_LOADING,this.hls.trigger(_.Events.FRAG_LOADING,{frag:b,targetBufferTime:x}),this.fragmentLoader.load(b,w).catch(function(B){return O.handleFragLoadError(B)})},S.doFragPartsLoad=function(b,k,x,w){var O=this;return new Promise(function(P,F){var M=[];(function B(U){var j=k[U];O.fragmentLoader.loadPart(b,j,w).then(function(V){M[j.index]=V;var H=V.part;O.hls.trigger(_.Events.FRAG_LOADED,V);var z=k[U+1];if(!z||z.fragment!==b)return P({frag:b,part:H,partsLoaded:M});B(U+1)}).catch(F)})(x)})},S.handleFragLoadError=function(b){var k=b.data;return k&&k.details===l.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(k.frag,k.part):this.hls.trigger(_.Events.ERROR,k),null},S._handleTransmuxerFlush=function(b){var k=this.getCurrentContext(b);if(k&&this.state===n.PARSING){var x=k.frag,w=k.part,O=k.level,P=self.performance.now();x.stats.parsing.end=P,w&&(w.stats.parsing.end=P),this.updateLevelTiming(x,w,O,b.partial)}else this.fragCurrent||(this.state=n.IDLE)},S.getCurrentContext=function(b){var k=this.levels,x=b.level,w=b.sn,O=b.part;if(!k||!k[x])return this.warn("Levels object was unset while buffering fragment "+w+" of level "+x+". The current chunk will not be buffered."),null;var P=k[x],F=O>-1?Object(y.getPartWith)(P,w,O):null,M=F?F.fragment:Object(y.getFragmentWithSN)(P,w,this.fragCurrent);return M?{frag:M,part:F,level:P}:null},S.bufferFragmentData=function(b,k,x,w){if(b&&this.state===n.PARSING){var O=b.data1,P=b.data2,F=O;if(O&&P&&(F=Object(m.appendUint8Array)(O,P)),F&&F.length){var M={type:b.type,frag:k,part:x,chunkMeta:w,parent:k.type,data:F};this.hls.trigger(_.Events.BUFFER_APPENDING,M),b.dropped&&b.independent&&!x&&this.flushBufferGap(k)}}},S.flushBufferGap=function(b){var k=this.media;if(k)if(D.BufferHelper.isBuffered(k,k.currentTime)){var x=k.currentTime,w=D.BufferHelper.bufferInfo(k,x,0),O=b.duration,P=Math.min(2*this.config.maxFragLookUpTolerance,.25*O),F=Math.max(Math.min(b.start-P,w.end-P),x+P);b.start-F>P&&this.flushMainBuffer(F,b.start)}else this.flushMainBuffer(0,b.start)},S.getFwdBufferInfo=function(b,k){var x=this.config,w=this.getLoadPosition();if(!Object(R.isFiniteNumber)(w))return null;var O=D.BufferHelper.bufferInfo(b,w,x.maxBufferHole);if(O.len===0&&O.nextStart!==void 0){var P=this.fragmentTracker.getBufferedFrag(w,k);if(P&&O.nextStart<P.end)return D.BufferHelper.bufferInfo(b,w,Math.max(O.nextStart,x.maxBufferHole))}return O},S.getMaxBufferLength=function(b){var k,x=this.config;return k=b?Math.max(8*x.maxBufferSize/b,x.maxBufferLength):x.maxBufferLength,Math.min(k,x.maxMaxBufferLength)},S.reduceMaxBufferLength=function(b){var k=this.config,x=b||k.maxBufferLength;return k.maxMaxBufferLength>=x&&(k.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+k.maxMaxBufferLength+"s"),!0)},S.getNextFragment=function(b,k){var x,w,O=k.fragments,P=O.length;if(!P)return null;var F,M=this.config,B=O[0].start;if(k.live){var U=M.initialLiveManifestSize;if(P<U)return this.warn("Not enough fragments to start playback (have: "+P+", need: "+U+")"),null;k.PTSKnown||this.startFragRequested||this.startPosition!==-1||(F=this.getInitialLiveFragment(k,O),this.startPosition=F?this.hls.liveSyncPosition||F.start:b)}else b<=B&&(F=O[0]);if(!F){var j=M.lowLatencyMode?k.partEnd:k.fragmentEnd;F=this.getFragmentAtPosition(b,j,k)}return(x=F)===null||x===void 0||!x.initSegment||(w=F)!==null&&w!==void 0&&w.initSegment.data||this.bitrateTest||(F=F.initSegment),F},S.getNextPart=function(b,k,x){for(var w=-1,O=!1,P=!0,F=0,M=b.length;F<M;F++){var B=b[F];if(P=P&&!B.independent,w>-1&&x<B.start)break;var U=B.loaded;!U&&(O||B.independent||P)&&B.fragment===k&&(w=F),O=U}return w},S.loadedEndOfParts=function(b,k){var x=b[b.length-1];return x&&k>x.start&&x.loaded},S.getInitialLiveFragment=function(b,k){var x=this.fragPrevious,w=null;if(x){if(b.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+x.programDateTime),w=Object(T.findFragmentByPDT)(k,x.endProgramDateTime,this.config.maxFragLookUpTolerance)),!w){var O=x.sn+1;if(O>=b.startSN&&O<=b.endSN){var P=k[O-b.startSN];x.cc===P.cc&&(w=P,this.log("Live playlist, switching playlist, load frag with next SN: "+w.sn))}w||(w=Object(T.findFragWithCC)(k,x.cc))&&this.log("Live playlist, switching playlist, load frag with same CC: "+w.sn)}}else{var F=this.hls.liveSyncPosition;F!==null&&(w=this.getFragmentAtPosition(F,this.bitrateTest?b.fragmentEnd:b.edge,b))}return w},S.getFragmentAtPosition=function(b,k,x){var w,O=this.config,P=this.fragPrevious,F=x.fragments,M=x.endSN,B=x.fragmentHint,U=O.maxFragLookUpTolerance,j=!!(O.lowLatencyMode&&x.partList&&B);if(j&&B&&!this.bitrateTest&&(F=F.concat(B),M=B.sn),b<k){var V=b>k-U?0:U;w=Object(T.findFragmentByPTS)(P,F,b,V)}else w=F[F.length-1];if(w){var H=w.sn-x.startSN,z=P&&w.level===P.level,W=F[H+1];if(this.fragmentTracker.getState(w)===A.FragmentState.BACKTRACKED){w=null;for(var X=H;F[X]&&this.fragmentTracker.getState(F[X])===A.FragmentState.BACKTRACKED;)w=P?F[X--]:F[--X];w||(w=W)}else P&&w.sn===P.sn&&!j&&z&&(w.sn<M&&this.fragmentTracker.getState(W)!==A.FragmentState.OK?(this.log("SN "+w.sn+" just loaded, load next one: "+W.sn),w=W):w=null)}return w},S.synchronizeToLiveEdge=function(b){var k=this.config,x=this.media;if(x){var w=this.hls.liveSyncPosition,O=x.currentTime,P=b.fragments[0].start,F=b.edge,M=O>=P-k.maxFragLookUpTolerance&&O<=F;if(w!==null&&x.duration>w&&(O<w||!M)){var B=k.liveMaxLatencyDuration!==void 0?k.liveMaxLatencyDuration:k.liveMaxLatencyDurationCount*b.targetduration;(!M&&x.readyState<4||O<F-B)&&(this.loadedmetadata||(this.nextLoadPosition=w),x.readyState&&(this.warn("Playback: "+O.toFixed(3)+" is located too far from the end of live sliding playlist: "+F+", reset currentTime to : "+w.toFixed(3)),x.currentTime=w))}}},S.alignPlaylists=function(b,k){var x=this.levels,w=this.levelLastLoaded,O=this.fragPrevious,P=w!==null?x[w]:null,F=b.fragments.length;if(!F)return this.warn("No fragments in live playlist"),0;var M=b.fragments[0].start,B=!k,U=b.alignedSliding&&Object(R.isFiniteNumber)(M);if(B||!U&&!M){Object(h.alignStream)(O,P,b);var j=b.fragments[0].start;return this.log("Live playlist sliding: "+j.toFixed(2)+" start-sn: "+(k?k.startSN:"na")+"->"+b.startSN+" prev-sn: "+(O?O.sn:"na")+" fragments: "+F),j}return M},S.waitForCdnTuneIn=function(b){return b.live&&b.canBlockReload&&b.tuneInGoal>Math.max(b.partHoldBack,3*b.partTarget)},S.setStartPosition=function(b,k){var x=this.startPosition;if(x<k&&(x=-1),x===-1||this.lastCurrentTime===-1){var w=b.startTimeOffset;Object(R.isFiniteNumber)(w)?(x=k+w,w<0&&(x+=b.totalduration),x=Math.min(Math.max(k,x),k+b.totalduration),this.log("Start time offset "+w+" found in playlist, adjust startPosition to "+x),this.startPosition=x):b.live?x=this.hls.liveSyncPosition||k:this.startPosition=x=0,this.lastCurrentTime=x}this.nextLoadPosition=x},S.getLoadPosition=function(){var b=this.media,k=0;return this.loadedmetadata&&b?k=b.currentTime:this.nextLoadPosition&&(k=this.nextLoadPosition),k},S.handleFragLoadAborted=function(b,k){this.transmuxer&&b.sn!=="initSegment"&&b.stats.aborted&&(this.warn("Fragment "+b.sn+(k?" part"+k.index:"")+" of level "+b.level+" was aborted"),this.resetFragmentLoading(b))},S.resetFragmentLoading=function(b){this.fragCurrent&&this.fragContextChanged(b)||(this.state=n.IDLE)},S.onFragmentOrKeyLoadError=function(b,k){if(!k.fatal){var x=k.frag;if(x&&x.type===b){var w=this.fragCurrent;console.assert(w&&x.sn===w.sn&&x.level===w.level&&x.urlId===w.urlId,"Frag load error must match current frag to retry");var O=this.config;if(this.fragLoadError+1<=O.fragLoadingMaxRetry){if(this.resetLiveStartWhenNotLoaded(x.level))return;var P=Math.min(Math.pow(2,this.fragLoadError)*O.fragLoadingRetryDelay,O.fragLoadingMaxRetryTimeout);this.warn("Fragment "+x.sn+" of "+b+" "+x.level+" failed to load, retrying in "+P+"ms"),this.retryDate=self.performance.now()+P,this.fragLoadError++,this.state=n.FRAG_LOADING_WAITING_RETRY}else k.levelRetry?(b===t.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=n.IDLE):(I.logger.error(k.details+" reaches max retry, redispatch as fatal ..."),k.fatal=!0,this.hls.stopLoad(),this.state=n.ERROR)}}},S.afterBufferFlushed=function(b,k,x){if(b){var w=D.BufferHelper.getBuffered(b);this.fragmentTracker.detectEvictedFragments(k,w,x),this.state===n.ENDED&&this.resetLoadingState()}},S.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=n.IDLE},S.resetLiveStartWhenNotLoaded=function(b){if(!this.loadedmetadata){this.startFragRequested=!1;var k=this.levels?this.levels[b].details:null;if(k!=null&&k.live)return this.startPosition=-1,this.setStartPosition(k,0),this.resetLoadingState(),!0;this.nextLoadPosition=this.startPosition}return!1},S.updateLevelTiming=function(b,k,x,w){var O=this,P=x.details;console.assert(!!P,"level.details must be defined"),Object.keys(b.elementaryStreams).reduce(function(F,M){var B=b.elementaryStreams[M];if(B){var U=B.endPTS-B.startPTS;if(U<=0)return O.warn("Could not parse fragment "+b.sn+" "+M+" duration reliably ("+U+") resetting transmuxer to fallback to playlist timing"),O.resetTransmuxer(),F||!1;var j=w?0:Object(y.updateFragPTSDTS)(P,b,B.startPTS,B.endPTS,B.startDTS,B.endDTS);return O.hls.trigger(_.Events.LEVEL_PTS_UPDATED,{details:P,level:x,drift:j,type:M,frag:b,start:B.startPTS,end:B.endPTS}),!0}return F},!1)?(this.state=n.PARSED,this.hls.trigger(_.Events.FRAG_PARSED,{frag:b,part:k})):this.resetLoadingState()},S.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},r=i,(o=[{key:"state",get:function(){return this._state},set:function(b){var k=this._state;k!==b&&(this._state=b,this.log(k+"->"+b))}}])&&s(r.prototype,o),i}(E.default)},"./src/controller/buffer-controller.ts":function(N,C,f){f.r(C),f.d(C,"default",function(){return T});var R=f("./src/polyfills/number.ts"),E=f("./src/events.ts"),A=f("./src/utils/logger.ts"),D=f("./src/errors.ts"),I=f("./src/utils/buffer-helper.ts"),_=f("./src/utils/mediasource-helper.ts"),l=f("./src/loader/fragment.ts"),L=f("./src/controller/buffer-operation-queue.ts"),m=Object(_.getMediaSource)(),h=/([ha]vc.)(?:\.[^.,]+)+/,T=function(){function y(e){var a=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.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var t=a.hls,s=a.media,d=a.mediaSource;A.logger.log("[buffer-controller]: Media source opened"),s&&(a.updateMediaElementDuration(),t.trigger(E.Events.MEDIA_ATTACHED,{media:s})),d&&d.removeEventListener("sourceopen",a._onMediaSourceOpen),a.checkPendingTracks()},this._onMediaSourceClose=function(){A.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){A.logger.log("[buffer-controller]: Media source ended")},this.hls=e,this._initSourceBuffer(),this.registerListeners()}var c=y.prototype;return c.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},c.destroy=function(){this.unregisterListeners(),this.details=null},c.registerListeners=function(){var e=this.hls;e.on(E.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(E.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.Events.BUFFER_RESET,this.onBufferReset,this),e.on(E.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.on(E.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.on(E.Events.BUFFER_EOS,this.onBufferEos,this),e.on(E.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(E.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(E.Events.FRAG_PARSED,this.onFragParsed,this),e.on(E.Events.FRAG_CHANGED,this.onFragChanged,this)},c.unregisterListeners=function(){var e=this.hls;e.off(E.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(E.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.Events.BUFFER_RESET,this.onBufferReset,this),e.off(E.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.off(E.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(E.Events.BUFFER_EOS,this.onBufferEos,this),e.off(E.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(E.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(E.Events.FRAG_PARSED,this.onFragParsed,this),e.off(E.Events.FRAG_CHANGED,this.onFragChanged,this)},c._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new L.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},c.onManifestParsed=function(e,a){var t=2;(a.audio&&!a.video||!a.altAudio)&&(t=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=t,this.details=null,A.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},c.onMediaAttaching=function(e,a){var t=this.media=a.media;if(t&&m){var s=this.mediaSource=new m;s.addEventListener("sourceopen",this._onMediaSourceOpen),s.addEventListener("sourceended",this._onMediaSourceEnded),s.addEventListener("sourceclose",this._onMediaSourceClose),t.src=self.URL.createObjectURL(s),this._objectUrl=t.src}},c.onMediaDetaching=function(){var e=this.media,a=this.mediaSource,t=this._objectUrl;if(a){if(A.logger.log("[buffer-controller]: media source detaching"),a.readyState==="open")try{a.endOfStream()}catch(s){A.logger.warn("[buffer-controller]: onMediaDetaching: "+s.message+" while calling endOfStream")}this.onBufferReset(),a.removeEventListener("sourceopen",this._onMediaSourceOpen),a.removeEventListener("sourceended",this._onMediaSourceEnded),a.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(t&&self.URL.revokeObjectURL(t),e.src===t?(e.removeAttribute("src"),e.load()):A.logger.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(E.Events.MEDIA_DETACHED,void 0)},c.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach(function(a){var t=e.sourceBuffer[a];try{t&&(e.removeBufferListeners(a),e.mediaSource&&e.mediaSource.removeSourceBuffer(t),e.sourceBuffer[a]=void 0)}catch(s){A.logger.warn("[buffer-controller]: Failed to reset the "+a+" buffer",s)}}),this._initSourceBuffer()},c.onBufferCodecs=function(e,a){var t=this,s=this.getSourceBufferTypes().length;Object.keys(a).forEach(function(d){if(s){var n=t.tracks[d];if(n&&typeof n.buffer.changeType=="function"){var u=a[d],p=u.codec,g=u.levelCodec,v=u.container;if((n.levelCodec||n.codec).replace(h,"$1")!==(g||p).replace(h,"$1")){var i=v+";codecs="+(g||p);t.appendChangeType(d,i)}}}else t.pendingTracks[d]=a[d]}),s||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},c.appendChangeType=function(e,a){var t=this,s=this.operationQueue,d={execute:function(){var n=t.sourceBuffer[e];n&&(A.logger.log("[buffer-controller]: changing "+e+" sourceBuffer type to "+a),n.changeType(a)),s.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(n){A.logger.warn("[buffer-controller]: Failed to change "+e+" SourceBuffer type",n)}};s.append(d,e)},c.onBufferAppending=function(e,a){var t=this,s=this.hls,d=this.operationQueue,n=this.tracks,u=a.data,p=a.type,g=a.frag,v=a.part,i=a.chunkMeta,r=i.buffering[p],o=self.performance.now();r.start=o;var S=g.stats.buffering,b=v?v.stats.buffering:null;S.start===0&&(S.start=o),b&&b.start===0&&(b.start=o);var k=n.audio,x=p==="audio"&&i.id===1&&(k==null?void 0:k.container)==="audio/mpeg",w={execute:function(){if(r.executeStart=self.performance.now(),x){var O=t.sourceBuffer[p];if(O){var P=g.start-O.timestampOffset;Math.abs(P)>=.1&&(A.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+g.start+" (delta: "+P+") sn: "+g.sn+")"),O.timestampOffset=g.start)}}t.appendExecutor(u,p)},onStart:function(){},onComplete:function(){var O=self.performance.now();r.executeEnd=r.end=O,S.first===0&&(S.first=O),b&&b.first===0&&(b.first=O);var P=t.sourceBuffer,F={};for(var M in P)F[M]=I.BufferHelper.getBuffered(P[M]);t.appendError=0,t.hls.trigger(E.Events.BUFFER_APPENDED,{type:p,frag:g,part:v,chunkMeta:i,parent:g.type,timeRanges:F})},onError:function(O){A.logger.error("[buffer-controller]: Error encountered while trying to append to the "+p+" SourceBuffer",O);var P={type:D.ErrorTypes.MEDIA_ERROR,parent:g.type,details:D.ErrorDetails.BUFFER_APPEND_ERROR,err:O,fatal:!1};O.code===DOMException.QUOTA_EXCEEDED_ERR?P.details=D.ErrorDetails.BUFFER_FULL_ERROR:(t.appendError++,P.details=D.ErrorDetails.BUFFER_APPEND_ERROR,t.appendError>s.config.appendErrorMaxRetry&&(A.logger.error("[buffer-controller]: Failed "+s.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),P.fatal=!0)),s.trigger(E.Events.ERROR,P)}};d.append(w,p)},c.onBufferFlushing=function(e,a){var t=this,s=this.operationQueue,d=function(n){return{execute:t.removeExecutor.bind(t,n,a.startOffset,a.endOffset),onStart:function(){},onComplete:function(){t.hls.trigger(E.Events.BUFFER_FLUSHED,{type:n})},onError:function(u){A.logger.warn("[buffer-controller]: Failed to remove from "+n+" SourceBuffer",u)}}};a.type?s.append(d(a.type),a.type):this.getSourceBufferTypes().forEach(function(n){s.append(d(n),n)})},c.onFragParsed=function(e,a){var t=this,s=a.frag,d=a.part,n=[],u=d?d.elementaryStreams:s.elementaryStreams;u[l.ElementaryStreamTypes.AUDIOVIDEO]?n.push("audiovideo"):(u[l.ElementaryStreamTypes.AUDIO]&&n.push("audio"),u[l.ElementaryStreamTypes.VIDEO]&&n.push("video")),n.length===0&&A.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+s.type+" level: "+s.level+" sn: "+s.sn),this.blockBuffers(function(){var p=self.performance.now();s.stats.buffering.end=p,d&&(d.stats.buffering.end=p);var g=d?d.stats:s.stats;t.hls.trigger(E.Events.FRAG_BUFFERED,{frag:s,part:d,stats:g,id:s.type})},n)},c.onFragChanged=function(e,a){this.flushBackBuffer()},c.onBufferEos=function(e,a){var t=this;this.getSourceBufferTypes().reduce(function(s,d){var n=t.sourceBuffer[d];return a.type&&a.type!==d||n&&!n.ended&&(n.ended=!0,A.logger.log("[buffer-controller]: "+d+" sourceBuffer now EOS")),s&&!(n&&!n.ended)},!0)&&this.blockBuffers(function(){var s=t.mediaSource;s&&s.readyState==="open"&&s.endOfStream()})},c.onLevelUpdated=function(e,a){var t=a.details;t.fragments.length&&(this.details=t,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},c.flushBackBuffer=function(){var e=this.hls,a=this.details,t=this.media,s=this.sourceBuffer;if(t&&a!==null){var d=this.getSourceBufferTypes();if(d.length){var n=a.live&&e.config.liveBackBufferLength!==null?e.config.liveBackBufferLength:e.config.backBufferLength;if(Object(R.isFiniteNumber)(n)&&!(n<0)){var u=t.currentTime,p=a.levelTargetDuration,g=Math.max(n,p),v=Math.floor(u/p)*p-g;d.forEach(function(i){var r=s[i];if(r){var o=I.BufferHelper.getBuffered(r);o.length>0&&v>o.start(0)&&(e.trigger(E.Events.BACK_BUFFER_REACHED,{bufferEnd:v}),a.live&&e.trigger(E.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:v}),e.trigger(E.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:v,type:i}))}})}}}},c.updateMediaElementDuration=function(){if(this.details&&this.media&&this.mediaSource&&this.mediaSource.readyState==="open"){var e=this.details,a=this.hls,t=this.media,s=this.mediaSource,d=e.fragments[0].start+e.totalduration,n=t.duration,u=Object(R.isFiniteNumber)(s.duration)?s.duration:0;e.live&&a.config.liveDurationInfinity?(A.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),s.duration=1/0,this.updateSeekableRange(e)):(d>u&&d>n||!Object(R.isFiniteNumber)(n))&&(A.logger.log("[buffer-controller]: Updating Media Source duration to "+d.toFixed(3)),s.duration=d)}},c.updateSeekableRange=function(e){var a=this.mediaSource,t=e.fragments;if(t.length&&e.live&&a!=null&&a.setLiveSeekableRange){var s=Math.max(0,t[0].start),d=Math.max(s,s+e.totalduration);a.setLiveSeekableRange(s,d)}},c.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,a=this.operationQueue,t=this.pendingTracks,s=Object.keys(t).length;if(s&&!e||s===2){this.createSourceBuffers(t),this.pendingTracks={};var d=this.getSourceBufferTypes();if(d.length===0)return void this.hls.trigger(E.Events.ERROR,{type:D.ErrorTypes.MEDIA_ERROR,details:D.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});d.forEach(function(n){a.executeNext(n)})}},c.createSourceBuffers=function(e){var a=this.sourceBuffer,t=this.mediaSource;if(!t)throw Error("createSourceBuffers called when mediaSource was null");var s=0;for(var d in e)if(!a[d]){var n=e[d];if(!n)throw Error("source buffer exists for track "+d+", however track does not");var u=n.levelCodec||n.codec,p=n.container+";codecs="+u;A.logger.log("[buffer-controller]: creating sourceBuffer("+p+")");try{var g=a[d]=t.addSourceBuffer(p),v=d;this.addBufferListener(v,"updatestart",this._onSBUpdateStart),this.addBufferListener(v,"updateend",this._onSBUpdateEnd),this.addBufferListener(v,"error",this._onSBUpdateError),this.tracks[d]={buffer:g,codec:u,container:n.container,levelCodec:n.levelCodec,id:n.id},s++}catch(i){A.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+i.message),this.hls.trigger(E.Events.ERROR,{type:D.ErrorTypes.MEDIA_ERROR,details:D.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:i,mimeType:p})}}s&&this.hls.trigger(E.Events.BUFFER_CREATED,{tracks:this.tracks})},c._onSBUpdateStart=function(e){this.operationQueue.current(e).onStart()},c._onSBUpdateEnd=function(e){var a=this.operationQueue;a.current(e).onComplete(),a.shiftAndExecuteNext(e)},c._onSBUpdateError=function(e,a){A.logger.error("[buffer-controller]: "+e+" SourceBuffer error",a),this.hls.trigger(E.Events.ERROR,{type:D.ErrorTypes.MEDIA_ERROR,details:D.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var t=this.operationQueue.current(e);t&&t.onError(a)},c.removeExecutor=function(e,a,t){var s=this.media,d=this.mediaSource,n=this.operationQueue,u=this.sourceBuffer[e];if(!s||!d||!u)return A.logger.warn("[buffer-controller]: Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),void n.shiftAndExecuteNext(e);var p=Object(R.isFiniteNumber)(s.duration)?s.duration:1/0,g=Object(R.isFiniteNumber)(d.duration)?d.duration:1/0,v=Math.max(0,a),i=Math.min(t,p,g);i>v?(A.logger.log("[buffer-controller]: Removing ["+v+","+i+"] from the "+e+" SourceBuffer"),console.assert(!u.updating,e+" sourceBuffer must not be updating"),u.remove(v,i)):n.shiftAndExecuteNext(e)},c.appendExecutor=function(e,a){var t=this.operationQueue,s=this.sourceBuffer[a];if(!s)return A.logger.warn("[buffer-controller]: Attempting to append to the "+a+" SourceBuffer, but it does not exist"),void t.shiftAndExecuteNext(a);s.ended=!1,console.assert(!s.updating,a+" sourceBuffer must not be updating"),s.appendBuffer(e)},c.blockBuffers=function(e,a){var t=this;if(a===void 0&&(a=this.getSourceBufferTypes()),!a.length)return A.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve(e);var s=this.operationQueue,d=a.map(function(n){return s.appendBlocker(n)});Promise.all(d).then(function(){e(),a.forEach(function(n){var u=t.sourceBuffer[n];u&&u.updating||s.shiftAndExecuteNext(n)})})},c.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},c.addBufferListener=function(e,a,t){var s=this.sourceBuffer[e];if(s){var d=t.bind(this,e);this.listeners[e].push({event:a,listener:d}),s.addEventListener(a,d)}},c.removeBufferListeners=function(e){var a=this.sourceBuffer[e];a&&this.listeners[e].forEach(function(t){a.removeEventListener(t.event,t.listener)})},y}()},"./src/controller/buffer-operation-queue.ts":function(N,C,f){f.r(C),f.d(C,"default",function(){return E});var R=f("./src/utils/logger.ts"),E=function(){function A(I){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=I}var D=A.prototype;return D.append=function(I,_){var l=this.queues[_];l.push(I),l.length===1&&this.buffers[_]&&this.executeNext(_)},D.insertAbort=function(I,_){this.queues[_].unshift(I),this.executeNext(_)},D.appendBlocker=function(I){var _,l=new Promise(function(m){_=m}),L={execute:_,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(L,I),l},D.executeNext=function(I){var _=this.buffers,l=this.queues,L=_[I],m=l[I];if(m.length){var h=m[0];try{h.execute()}catch(T){R.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),h.onError(T),L&&L.updating||(m.shift(),this.executeNext(I))}}},D.shiftAndExecuteNext=function(I){this.queues[I].shift(),this.executeNext(I)},D.current=function(I){return this.queues[I][0]},A}()},"./src/controller/cap-level-controller.ts":function(N,C,f){f.r(C);var R=f("./src/events.ts");function E(D,I){for(var _=0;_<I.length;_++){var l=I[_];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(D,l.key,l)}}var A=function(){function D(m){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=m,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var I,_,l,L=D.prototype;return L.setStreamController=function(m){this.streamController=m},L.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},L.registerListeners=function(){var m=this.hls;m.on(R.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),m.on(R.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),m.on(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),m.on(R.Events.BUFFER_CODECS,this.onBufferCodecs,this),m.on(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},L.unregisterListener=function(){var m=this.hls;m.off(R.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),m.off(R.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),m.off(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),m.off(R.Events.BUFFER_CODECS,this.onBufferCodecs,this),m.off(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},L.onFpsDropLevelCapping=function(m,h){D.isLevelAllowed(h.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(h.droppedLevel)},L.onMediaAttaching=function(m,h){this.media=h.media instanceof HTMLVideoElement?h.media:null},L.onManifestParsed=function(m,h){var T=this.hls;this.restrictedLevels=[],this.firstLevel=h.firstLevel,T.config.capLevelToPlayerSize&&h.video&&this.startCapping()},L.onBufferCodecs=function(m,h){this.hls.config.capLevelToPlayerSize&&h.video&&this.startCapping()},L.onMediaDetaching=function(){this.stopCapping()},L.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var m=this.hls.levels;if(m.length){var h=this.hls;h.autoLevelCapping=this.getMaxLevel(m.length-1),h.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=h.autoLevelCapping}}},L.getMaxLevel=function(m){var h=this,T=this.hls.levels;if(!T.length)return-1;var y=T.filter(function(c,e){return D.isLevelAllowed(e,h.restrictedLevels)&&e<=m});return this.clientRect=null,D.getMaxLevelByMediaSize(y,this.mediaWidth,this.mediaHeight)},L.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())},L.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},L.getDimensions=function(){if(this.clientRect)return this.clientRect;var m=this.media,h={width:0,height:0};if(m){var T=m.getBoundingClientRect();h.width=T.width,h.height=T.height,h.width||h.height||(h.width=T.right-T.left||m.width||0,h.height=T.bottom-T.top||m.height||0)}return this.clientRect=h,h},D.isLevelAllowed=function(m,h){return h===void 0&&(h=[]),h.indexOf(m)===-1},D.getMaxLevelByMediaSize=function(m,h,T){if(!m||!m.length)return-1;for(var y,c,e=m.length-1,a=0;a<m.length;a+=1){var t=m[a];if((t.width>=h||t.height>=T)&&(y=t,!(c=m[a+1])||y.width!==c.width||y.height!==c.height)){e=a;break}}return e},I=D,l=[{key:"contentScaleFactor",get:function(){var m=1;try{m=self.devicePixelRatio}catch{}return m}}],(_=[{key:"mediaWidth",get:function(){return this.getDimensions().width*D.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*D.contentScaleFactor}}])&&E(I.prototype,_),l&&E(I,l),D}();C.default=A},"./src/controller/eme-controller.ts":function(N,C,f){f.r(C);var R=f("./src/events.ts"),E=f("./src/errors.ts"),A=f("./src/utils/logger.ts"),D=f("./src/utils/mediakeys-helper.ts");function I(l,L){for(var m=0;m<L.length;m++){var h=L[m];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(l,h.key,h)}}var _=function(){function l(T){this.hls=void 0,this._widevineLicenseUrl=void 0,this._licenseXhrSetup=void 0,this._licenseResponseCallback=void 0,this._emeEnabled=void 0,this._requestMediaKeySystemAccess=void 0,this._drmSystemOptions=void 0,this._config=void 0,this._mediaKeysList=[],this._media=null,this._hasSetMediaKeys=!1,this._requestLicenseFailureCount=0,this.mediaKeysPromise=null,this._onMediaEncrypted=this.onMediaEncrypted.bind(this),this.hls=T,this._config=T.config,this._widevineLicenseUrl=this._config.widevineLicenseUrl,this._licenseXhrSetup=this._config.licenseXhrSetup,this._licenseResponseCallback=this._config.licenseResponseCallback,this._emeEnabled=this._config.emeEnabled,this._requestMediaKeySystemAccess=this._config.requestMediaKeySystemAccessFunc,this._drmSystemOptions=this._config.drmSystemOptions,this._registerListeners()}var L,m,h=l.prototype;return h.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},h._registerListeners=function(){this.hls.on(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(R.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(R.Events.MANIFEST_PARSED,this.onManifestParsed,this)},h._unregisterListeners=function(){this.hls.off(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(R.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(R.Events.MANIFEST_PARSED,this.onManifestParsed,this)},h.getLicenseServerUrl=function(T){switch(T){case D.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+T+'"')},h._attemptKeySystemAccess=function(T,y,c){var e=this,a=function(s,d,n,u){switch(s){case D.KeySystems.WIDEVINE:return function(p,g,v){var i={audioCapabilities:[],videoCapabilities:[]};return p.forEach(function(r){i.audioCapabilities.push({contentType:'audio/mp4; codecs="'+r+'"',robustness:v.audioRobustness||""})}),g.forEach(function(r){i.videoCapabilities.push({contentType:'video/mp4; codecs="'+r+'"',robustness:v.videoRobustness||""})}),[i]}(d,n,u);default:throw new Error("Unknown key-system: "+s)}}(T,y,c,this._drmSystemOptions);A.logger.log("Requesting encrypted media key-system access");var t=this.requestMediaKeySystemAccess(T,a);this.mediaKeysPromise=t.then(function(s){return e._onMediaKeySystemAccessObtained(T,s)}),t.catch(function(s){A.logger.error('Failed to obtain key-system "'+T+'" access:',s)})},h._onMediaKeySystemAccessObtained=function(T,y){var c=this;A.logger.log('Access for key-system "'+T+'" obtained');var e={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:y,mediaKeySystemDomain:T};this._mediaKeysList.push(e);var a=Promise.resolve().then(function(){return y.createMediaKeys()}).then(function(t){return e.mediaKeys=t,A.logger.log('Media-keys created for key-system "'+T+'"'),c._onMediaKeysCreated(),t});return a.catch(function(t){A.logger.error("Failed to create media-keys:",t)}),a},h._onMediaKeysCreated=function(){var T=this;this._mediaKeysList.forEach(function(y){y.mediaKeysSession||(y.mediaKeysSession=y.mediaKeys.createSession(),T._onNewMediaKeySession(y.mediaKeysSession))})},h._onNewMediaKeySession=function(T){var y=this;A.logger.log("New key-system session "+T.sessionId),T.addEventListener("message",function(c){y._onKeySessionMessage(T,c.message)},!1)},h._onKeySessionMessage=function(T,y){A.logger.log("Got EME message event, creating license request"),this._requestLicense(y,function(c){A.logger.log("Received license data (length: "+(c&&c.byteLength)+"), updating key-session"),T.update(c)})},h.onMediaEncrypted=function(T){var y=this;if(A.logger.log('Media is encrypted using "'+T.initDataType+'" init data type'),!this.mediaKeysPromise)return A.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),void this.hls.trigger(R.Events.ERROR,{type:E.ErrorTypes.KEY_SYSTEM_ERROR,details:E.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});var c=function(e){y._media&&(y._attemptSetMediaKeys(e),y._generateRequestWithPreferredKeySession(T.initDataType,T.initData))};this.mediaKeysPromise.then(c).catch(c)},h._attemptSetMediaKeys=function(T){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var y=this._mediaKeysList[0];if(!y||!y.mediaKeys)return A.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),void this.hls.trigger(R.Events.ERROR,{type:E.ErrorTypes.KEY_SYSTEM_ERROR,details:E.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});A.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(y.mediaKeys),this._hasSetMediaKeys=!0}},h._generateRequestWithPreferredKeySession=function(T,y){var c=this,e=this._mediaKeysList[0];if(!e)return A.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),void this.hls.trigger(R.Events.ERROR,{type:E.ErrorTypes.KEY_SYSTEM_ERROR,details:E.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});if(e.mediaKeysSessionInitialized)A.logger.warn("Key-Session already initialized but requested again");else{var a=e.mediaKeysSession;if(!a)return A.logger.error("Fatal: Media is encrypted but no key-session existing"),void this.hls.trigger(R.Events.ERROR,{type:E.ErrorTypes.KEY_SYSTEM_ERROR,details:E.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});if(!y)return A.logger.warn("Fatal: initData required for generating a key session is null"),void this.hls.trigger(R.Events.ERROR,{type:E.ErrorTypes.KEY_SYSTEM_ERROR,details:E.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});A.logger.log('Generating key-session request for "'+T+'" init data type'),e.mediaKeysSessionInitialized=!0,a.generateRequest(T,y).then(function(){A.logger.debug("Key-session generation succeeded")}).catch(function(t){A.logger.error("Error generating key-session request:",t),c.hls.trigger(R.Events.ERROR,{type:E.ErrorTypes.KEY_SYSTEM_ERROR,details:E.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})}},h._createLicenseXhr=function(T,y,c){var e=new XMLHttpRequest;e.responseType="arraybuffer",e.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,e,T,y,c);var a=this._licenseXhrSetup;if(a)try{a.call(this.hls,e,T),a=void 0}catch(t){A.logger.error(t)}try{e.readyState||e.open("POST",T,!0),a&&a.call(this.hls,e,T)}catch(t){throw new Error("issue setting up KeySystem license XHR "+t)}return e},h._onLicenseRequestReadyStageChange=function(T,y,c,e){switch(T.readyState){case 4:if(T.status===200){this._requestLicenseFailureCount=0,A.logger.log("License request succeeded");var a=T.response,t=this._licenseResponseCallback;if(t)try{a=t.call(this.hls,T,y)}catch(d){A.logger.error(d)}e(a)}else{if(A.logger.error("License Request XHR failed ("+y+"). Status: "+T.status+" ("+T.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>3)return void this.hls.trigger(R.Events.ERROR,{type:E.ErrorTypes.KEY_SYSTEM_ERROR,details:E.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});var s=3-this._requestLicenseFailureCount+1;A.logger.warn("Retrying license request, "+s+" attempts left"),this._requestLicense(c,e)}}},h._generateLicenseRequestChallenge=function(T,y){switch(T.mediaKeySystemDomain){case D.KeySystems.WIDEVINE:return y}throw new Error("unsupported key-system: "+T.mediaKeySystemDomain)},h._requestLicense=function(T,y){A.logger.log("Requesting content license for key-system");var c=this._mediaKeysList[0];if(!c)return A.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),void this.hls.trigger(R.Events.ERROR,{type:E.ErrorTypes.KEY_SYSTEM_ERROR,details:E.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});try{var e=this.getLicenseServerUrl(c.mediaKeySystemDomain),a=this._createLicenseXhr(e,T,y);A.logger.log("Sending license request to URL: "+e);var t=this._generateLicenseRequestChallenge(c,T);a.send(t)}catch(s){A.logger.error("Failure requesting DRM license: "+s),this.hls.trigger(R.Events.ERROR,{type:E.ErrorTypes.KEY_SYSTEM_ERROR,details:E.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},h.onMediaAttached=function(T,y){if(this._emeEnabled){var c=y.media;this._media=c,c.addEventListener("encrypted",this._onMediaEncrypted)}},h.onMediaDetached=function(){var T=this._media,y=this._mediaKeysList;T&&(T.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(y.map(function(c){if(c.mediaKeysSession)return c.mediaKeysSession.close().catch(function(){})})).then(function(){return T.setMediaKeys(null)}).catch(function(){}))},h.onManifestParsed=function(T,y){if(this._emeEnabled){var c=y.levels.map(function(a){return a.audioCodec}).filter(function(a){return!!a}),e=y.levels.map(function(a){return a.videoCodec}).filter(function(a){return!!a});this._attemptKeySystemAccess(D.KeySystems.WIDEVINE,c,e)}},L=l,(m=[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}])&&I(L.prototype,m),l}();C.default=_},"./src/controller/fps-controller.ts":function(N,C,f){f.r(C);var R=f("./src/events.ts"),E=f("./src/utils/logger.ts"),A=function(){function D(_){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=_,this.registerListeners()}var I=D.prototype;return I.setStreamController=function(_){this.streamController=_},I.registerListeners=function(){this.hls.on(R.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},I.unregisterListeners=function(){this.hls.off(R.Events.MEDIA_ATTACHING,this.onMediaAttaching)},I.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},I.onMediaAttaching=function(_,l){var L=this.hls.config;if(L.capLevelOnFPSDrop){var m=l.media instanceof self.HTMLVideoElement?l.media:null;this.media=m,m&&typeof m.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),L.fpsDroppedMonitoringPeriod)}},I.checkFPS=function(_,l,L){var m=performance.now();if(l){if(this.lastTime){var h=m-this.lastTime,T=L-this.lastDroppedFrames,y=l-this.lastDecodedFrames,c=1e3*T/h,e=this.hls;if(e.trigger(R.Events.FPS_DROP,{currentDropped:T,currentDecoded:y,totalDroppedFrames:L}),c>0&&T>e.config.fpsDroppedMonitoringThreshold*y){var a=e.currentLevel;E.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+a),a>0&&(e.autoLevelCapping===-1||e.autoLevelCapping>=a)&&(a-=1,e.trigger(R.Events.FPS_DROP_LEVEL_CAPPING,{level:a,droppedLevel:e.currentLevel}),e.autoLevelCapping=a,this.streamController.nextLevelSwitch())}}this.lastTime=m,this.lastDroppedFrames=L,this.lastDecodedFrames=l}},I.checkFPSInterval=function(){var _=this.media;if(_)if(this.isVideoPlaybackQualityAvailable){var l=_.getVideoPlaybackQuality();this.checkFPS(_,l.totalVideoFrames,l.droppedVideoFrames)}else this.checkFPS(_,_.webkitDecodedFrameCount,_.webkitDroppedFrameCount)},D}();C.default=A},"./src/controller/fragment-finders.ts":function(N,C,f){f.r(C),f.d(C,"findFragmentByPDT",function(){return A}),f.d(C,"findFragmentByPTS",function(){return D}),f.d(C,"fragmentWithinToleranceTest",function(){return I}),f.d(C,"pdtWithinToleranceTest",function(){return _}),f.d(C,"findFragWithCC",function(){return l});var R=f("./src/polyfills/number.ts"),E=f("./src/utils/binary-search.ts");function A(L,m,h){if(m===null||!Array.isArray(L)||!L.length||!Object(R.isFiniteNumber)(m)||m<(L[0].programDateTime||0)||m>=(L[L.length-1].endProgramDateTime||0))return null;h=h||0;for(var T=0;T<L.length;++T){var y=L[T];if(_(m,h,y))return y}return null}function D(L,m,h,T){h===void 0&&(h=0),T===void 0&&(T=0);var y=null;if(L?y=m[L.sn-m[0].sn+1]||null:h===0&&m[0].start===0&&(y=m[0]),y&&I(h,T,y)===0)return y;var c=E.default.search(m,I.bind(null,h,T));return c||y}function I(L,m,h){L===void 0&&(L=0),m===void 0&&(m=0);var T=Math.min(m,h.duration+(h.deltaPTS?h.deltaPTS:0));return h.start+h.duration-T<=L?1:h.start-T>L&&h.start?-1:0}function _(L,m,h){var T=1e3*Math.min(m,h.duration+(h.deltaPTS?h.deltaPTS:0));return(h.endProgramDateTime||0)-T>L}function l(L,m){return E.default.search(L,function(h){return h.cc<m?1:h.cc>m?-1:0})}},"./src/controller/fragment-tracker.ts":function(N,C,f){f.r(C),f.d(C,"FragmentState",function(){return R}),f.d(C,"FragmentTracker",function(){return I});var R,E,A=f("./src/events.ts"),D=f("./src/types/loader.ts");(E=R||(R={})).NOT_LOADED="NOT_LOADED",E.BACKTRACKED="BACKTRACKED",E.APPENDING="APPENDING",E.PARTIAL="PARTIAL",E.OK="OK";var I=function(){function L(h){this.activeFragment=null,this.activeParts=null,this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hls=h,this._registerListeners()}var m=L.prototype;return m._registerListeners=function(){var h=this.hls;h.on(A.Events.BUFFER_APPENDED,this.onBufferAppended,this),h.on(A.Events.FRAG_BUFFERED,this.onFragBuffered,this),h.on(A.Events.FRAG_LOADED,this.onFragLoaded,this)},m._unregisterListeners=function(){var h=this.hls;h.off(A.Events.BUFFER_APPENDED,this.onBufferAppended,this),h.off(A.Events.FRAG_BUFFERED,this.onFragBuffered,this),h.off(A.Events.FRAG_LOADED,this.onFragLoaded,this)},m.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},m.getAppendedFrag=function(h,T){if(T===D.PlaylistLevelType.MAIN){var y=this.activeFragment,c=this.activeParts;if(!y)return null;if(c)for(var e=c.length;e--;){var a=c[e],t=a?a.end:y.appendedPTS;if(a.start<=h&&t!==void 0&&h<=t)return e>9&&(this.activeParts=c.slice(e-9)),a}else if(y.start<=h&&y.appendedPTS!==void 0&&h<=y.appendedPTS)return y}return this.getBufferedFrag(h,T)},m.getBufferedFrag=function(h,T){for(var y=this.fragments,c=Object.keys(y),e=c.length;e--;){var a=y[c[e]];if((a==null?void 0:a.body.type)===T&&a.buffered){var t=a.body;if(t.start<=h&&h<=t.end)return t}}return null},m.detectEvictedFragments=function(h,T,y){var c=this;Object.keys(this.fragments).forEach(function(e){var a=c.fragments[e];if(a)if(a.buffered){var t=a.range[h];t&&t.time.some(function(s){var d=!c.isTimeBuffered(s.startPTS,s.endPTS,T);return d&&c.removeFragment(a.body),d})}else a.body.type===y&&c.removeFragment(a.body)})},m.detectPartialFragments=function(h){var T=this,y=this.timeRanges,c=h.frag,e=h.part;if(y&&c.sn!=="initSegment"){var a=l(c),t=this.fragments[a];t&&(Object.keys(y).forEach(function(s){var d=c.elementaryStreams[s];if(d){var n=y[s],u=e!==null||d.partial===!0;t.range[s]=T.getBufferedTimes(c,e,u,n)}}),t.backtrack=t.loaded=null,Object.keys(t.range).length?t.buffered=!0:this.removeFragment(t.body))}},m.fragBuffered=function(h){var T=l(h),y=this.fragments[T];y&&(y.backtrack=y.loaded=null,y.buffered=!0)},m.getBufferedTimes=function(h,T,y,c){for(var e={time:[],partial:y},a=T?T.start:h.start,t=T?T.end:h.end,s=h.minEndPTS||t,d=h.maxStartPTS||a,n=0;n<c.length;n++){var u=c.start(n)-this.bufferPadding,p=c.end(n)+this.bufferPadding;if(d>=u&&s<=p){e.time.push({startPTS:Math.max(a,c.start(n)),endPTS:Math.min(t,c.end(n))});break}if(a<p&&t>u)e.partial=!0,e.time.push({startPTS:Math.max(a,c.start(n)),endPTS:Math.min(t,c.end(n))});else if(t<=u)break}return e},m.getPartialFragment=function(h){var T,y,c,e=null,a=0,t=this.bufferPadding,s=this.fragments;return Object.keys(s).forEach(function(d){var n=s[d];n&&_(n)&&(y=n.body.start-t,c=n.body.end+t,h>=y&&h<=c&&(T=Math.min(h-y,c-h),a<=T&&(e=n.body,a=T)))}),e},m.getState=function(h){var T=l(h),y=this.fragments[T];return y?y.buffered?_(y)?R.PARTIAL:R.OK:y.backtrack?R.BACKTRACKED:R.APPENDING:R.NOT_LOADED},m.backtrack=function(h,T){var y=l(h),c=this.fragments[y];if(!c||c.backtrack)return null;var e=c.backtrack=T||c.loaded;return c.loaded=null,e},m.getBacktrackData=function(h){var T=l(h),y=this.fragments[T];if(y){var c,e=y.backtrack;if(e!=null&&(c=e.payload)!==null&&c!==void 0&&c.byteLength)return e;this.removeFragment(h)}return null},m.isTimeBuffered=function(h,T,y){for(var c,e,a=0;a<y.length;a++){if(c=y.start(a)-this.bufferPadding,e=y.end(a)+this.bufferPadding,h>=c&&T<=e)return!0;if(T<=c)return!1}return!1},m.onFragLoaded=function(h,T){var y=T.frag,c=T.part;if(y.sn!=="initSegment"&&!y.bitrateTest&&!c){var e=l(y);this.fragments[e]={body:y,loaded:T,backtrack:null,buffered:!1,range:Object.create(null)}}},m.onBufferAppended=function(h,T){var y=this,c=T.frag,e=T.part,a=T.timeRanges;if(c.type===D.PlaylistLevelType.MAIN)if(this.activeFragment=c,e){var t=this.activeParts;t||(this.activeParts=t=[]),t.push(e)}else this.activeParts=null;this.timeRanges=a,Object.keys(a).forEach(function(s){var d=a[s];if(y.detectEvictedFragments(s,d),!e)for(var n=0;n<d.length;n++)c.appendedPTS=Math.max(d.end(n),c.appendedPTS||0)})},m.onFragBuffered=function(h,T){this.detectPartialFragments(T)},m.hasFragment=function(h){var T=l(h);return!!this.fragments[T]},m.removeFragmentsInRange=function(h,T,y){var c=this;Object.keys(this.fragments).forEach(function(e){var a=c.fragments[e];if(a&&a.buffered){var t=a.body;t.type===y&&t.start<T&&t.end>h&&c.removeFragment(t)}})},m.removeFragment=function(h){var T=l(h);h.stats.loaded=0,h.clearElementaryStreamInfo(),delete this.fragments[T]},m.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},L}();function _(L){var m,h;return L.buffered&&(((m=L.range.video)===null||m===void 0?void 0:m.partial)||((h=L.range.audio)===null||h===void 0?void 0:h.partial))}function l(L){return L.type+"_"+L.level+"_"+L.urlId+"_"+L.sn}},"./src/controller/gap-controller.ts":function(N,C,f){f.r(C),f.d(C,"STALL_MINIMUM_DURATION_MS",function(){return I}),f.d(C,"MAX_START_GAP_JUMP",function(){return _}),f.d(C,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return l}),f.d(C,"SKIP_BUFFER_RANGE_START",function(){return L}),f.d(C,"default",function(){return m});var R=f("./src/utils/buffer-helper.ts"),E=f("./src/errors.ts"),A=f("./src/events.ts"),D=f("./src/utils/logger.ts"),I=250,_=2,l=.1,L=.05,m=function(){function h(y,c,e,a){this.config=void 0,this.media=void 0,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=y,this.media=c,this.fragmentTracker=e,this.hls=a}var T=h.prototype;return T.destroy=function(){this.hls=this.fragmentTracker=this.media=null},T.poll=function(y){var c=this.config,e=this.media,a=this.stalled,t=e.currentTime,s=e.seeking,d=this.seeking&&!s,n=!this.seeking&&s;if(this.seeking=s,t===y){if((n||d)&&(this.stalled=null),!e.paused&&!e.ended&&e.playbackRate!==0&&R.BufferHelper.getBuffered(e).length){var u=R.BufferHelper.bufferInfo(e,t,0),p=u.len>0,g=u.nextStart||0;if(p||g){if(s){var v=u.len>_,i=!g||g-t>_&&!this.fragmentTracker.getPartialFragment(t);if(v||i)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var r,o=Math.max(g,u.start||0)-t,S=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,b=!(S==null||(r=S.details)===null||r===void 0)&&r.live?2*S.details.targetduration:_;if(o>0&&o<=b)return void this._trySkipBufferHole(null)}var k=self.performance.now();if(a!==null){var x=k-a;!s&&x>=I&&this._reportStall(u.len);var w=R.BufferHelper.bufferInfo(e,t,c.maxBufferHole);this._tryFixBufferStall(w,x)}else this.stalled=k}}}else if(this.moved=!0,a!==null){if(this.stallReported){var O=self.performance.now()-a;D.logger.warn("playback not stuck anymore @"+t+", after "+Math.round(O)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}},T._tryFixBufferStall=function(y,c){var e=this.config,a=this.fragmentTracker,t=this.media.currentTime,s=a.getPartialFragment(t);s&&this._trySkipBufferHole(s)||y.len>e.maxBufferHole&&c>1e3*e.highBufferWatchdogPeriod&&(D.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},T._reportStall=function(y){var c=this.hls,e=this.media;this.stallReported||(this.stallReported=!0,D.logger.warn("Playback stalling at @"+e.currentTime+" due to low buffer (buffer="+y+")"),c.trigger(A.Events.ERROR,{type:E.ErrorTypes.MEDIA_ERROR,details:E.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:y}))},T._trySkipBufferHole=function(y){for(var c=this.config,e=this.hls,a=this.media,t=a.currentTime,s=0,d=R.BufferHelper.getBuffered(a),n=0;n<d.length;n++){var u=d.start(n);if(t+c.maxBufferHole>=s&&t<u){var p=Math.max(u+L,a.currentTime+l);return D.logger.warn("skipping hole, adjusting currentTime from "+t+" to "+p),this.moved=!0,this.stalled=null,a.currentTime=p,y&&e.trigger(A.Events.ERROR,{type:E.ErrorTypes.MEDIA_ERROR,details:E.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+t+" to "+p,frag:y}),p}s=d.end(n)}return 0},T._tryNudgeBuffer=function(){var y=this.config,c=this.hls,e=this.media,a=e.currentTime,t=(this.nudgeRetry||0)+1;if(this.nudgeRetry=t,t<y.nudgeMaxRetry){var s=a+t*y.nudgeOffset;D.logger.warn("Nudging 'currentTime' from "+a+" to "+s),e.currentTime=s,c.trigger(A.Events.ERROR,{type:E.ErrorTypes.MEDIA_ERROR,details:E.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else D.logger.error("Playhead still not moving while enough data buffered @"+a+" after "+y.nudgeMaxRetry+" nudges"),c.trigger(A.Events.ERROR,{type:E.ErrorTypes.MEDIA_ERROR,details:E.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})},h}()},"./src/controller/id3-track-controller.ts":function(N,C,f){f.r(C);var R=f("./src/events.ts"),E=f("./src/utils/texttrack-utils.ts"),A=f("./src/demux/id3.ts"),D=function(){function I(l){this.hls=void 0,this.id3Track=null,this.media=null,this.hls=l,this._registerListeners()}var _=I.prototype;return _.destroy=function(){this._unregisterListeners()},_._registerListeners=function(){var l=this.hls;l.on(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),l.on(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),l.on(R.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),l.on(R.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},_._unregisterListeners=function(){var l=this.hls;l.off(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),l.off(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),l.off(R.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),l.off(R.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},_.onMediaAttached=function(l,L){this.media=L.media},_.onMediaDetaching=function(){this.id3Track&&(Object(E.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null)},_.getID3Track=function(l){if(this.media){for(var L=0;L<l.length;L++){var m=l[L];if(m.kind==="metadata"&&m.label==="id3")return Object(E.sendAddTrackEvent)(m,this.media),m}return this.media.addTextTrack("metadata","id3")}},_.onFragParsingMetadata=function(l,L){if(this.media){var m=L.frag,h=L.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var T=self.WebKitDataCue||self.VTTCue||self.TextTrackCue,y=0;y<h.length;y++){var c=A.getID3Frames(h[y].data);if(c){var e=h[y].pts,a=y<h.length-1?h[y+1].pts:m.end;a-e<=0&&(a=e+.25);for(var t=0;t<c.length;t++){var s=c[t];if(!A.isTimeStampFrame(s)){var d=new T(e,a,"");d.value=s,this.id3Track.addCue(d)}}}}}},_.onBufferFlushing=function(l,L){var m=L.startOffset,h=L.endOffset,T=L.type;if(!T||T==="audio"){var y=this.id3Track;y&&Object(E.removeCuesInRange)(y,m,h)}},I}();C.default=D},"./src/controller/latency-controller.ts":function(N,C,f){f.r(C),f.d(C,"default",function(){return I});var R=f("./src/errors.ts"),E=f("./src/events.ts"),A=f("./src/utils/logger.ts");function D(_,l){for(var L=0;L<l.length;L++){var m=l[L];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(_,m.key,m)}}var I=function(){function _(h){var T=this;this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=function(){return T.timeupdate()},this.hls=h,this.config=h.config,this.registerListeners()}var l,L,m=_.prototype;return m.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},m.registerListeners=function(){this.hls.on(E.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(E.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(E.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(E.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(E.Events.ERROR,this.onError,this)},m.unregisterListeners=function(){this.hls.off(E.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(E.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(E.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(E.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(E.Events.ERROR,this.onError)},m.onMediaAttached=function(h,T){this.media=T.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},m.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},m.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},m.onLevelUpdated=function(h,T){var y=T.details;this.levelDetails=y,y.advanced&&this.timeupdate(),!y.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},m.onError=function(h,T){T.details===R.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,A.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},m.timeupdate=function(){var h=this.media,T=this.levelDetails;if(h&&T){this.currentTime=h.currentTime;var y=this.computeLatency();if(y!==null){this._latency=y;var c=this.config,e=c.lowLatencyMode,a=c.maxLiveSyncPlaybackRate;if(e&&a!==1){var t=this.targetLatency;if(t!==null){var s=y-t,d=s<Math.min(this.maxLatency,t+T.targetduration);if(T.live&&d&&s>.05&&this.forwardBufferLength>1){var n=Math.min(2,Math.max(1,a)),u=Math.round(2/(1+Math.exp(-.75*s-this.edgeStalled))*20)/20;h.playbackRate=Math.min(n,Math.max(1,u))}else h.playbackRate!==1&&h.playbackRate!==0&&(h.playbackRate=1)}}}}},m.estimateLiveEdge=function(){var h=this.levelDetails;return h===null?null:h.edge+h.age},m.computeLatency=function(){var h=this.estimateLiveEdge();return h===null?null:h-this.currentTime},l=_,(L=[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var h=this.config,T=this.levelDetails;return h.liveMaxLatencyDuration!==void 0?h.liveMaxLatencyDuration:T?h.liveMaxLatencyDurationCount*T.targetduration:0}},{key:"targetLatency",get:function(){var h=this.levelDetails;if(h===null)return null;var T=h.holdBack,y=h.partHoldBack,c=h.targetduration,e=this.config,a=e.liveSyncDuration,t=e.liveSyncDurationCount,s=e.lowLatencyMode,d=this.hls.userConfig,n=s&&y||T;(d.liveSyncDuration||d.liveSyncDurationCount||n===0)&&(n=a!==void 0?a:t*c);var u=c;return n+Math.min(1*this.stallCount,u)}},{key:"liveSyncPosition",get:function(){var h=this.estimateLiveEdge(),T=this.targetLatency,y=this.levelDetails;if(h===null||T===null||y===null)return null;var c=y.edge,e=h-T-this.edgeStalled,a=c-y.totalduration,t=c-(this.config.lowLatencyMode&&y.partTarget||y.targetduration);return Math.min(Math.max(a,e),t)}},{key:"drift",get:function(){var h=this.levelDetails;return h===null?1:h.drift}},{key:"edgeStalled",get:function(){var h=this.levelDetails;if(h===null)return 0;var T=3*(this.config.lowLatencyMode&&h.partTarget||h.targetduration);return Math.max(h.age-T,0)}},{key:"forwardBufferLength",get:function(){var h=this.media,T=this.levelDetails;if(!h||!T)return 0;var y=h.buffered.length;return y?h.buffered.end(y-1):T.edge-this.currentTime}}])&&D(l.prototype,L),_}()},"./src/controller/level-controller.ts":function(N,C,f){f.r(C),f.d(C,"default",function(){return y});var R=f("./src/types/level.ts"),E=f("./src/events.ts"),A=f("./src/errors.ts"),D=f("./src/utils/codecs.ts"),I=f("./src/controller/level-helper.ts"),_=f("./src/controller/base-playlist-controller.ts"),l=f("./src/types/loader.ts");function L(){return(L=Object.assign||function(c){for(var e=1;e<arguments.length;e++){var a=arguments[e];for(var t in a)Object.prototype.hasOwnProperty.call(a,t)&&(c[t]=a[t])}return c}).apply(this,arguments)}function m(c,e){for(var a=0;a<e.length;a++){var t=e[a];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(c,t.key,t)}}function h(c,e){return(h=Object.setPrototypeOf||function(a,t){return a.__proto__=t,a})(c,e)}var T=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),y=function(c){var e,a;function t(u){var p;return(p=c.call(this,u,"[level-controller]")||this)._levels=[],p._firstLevel=-1,p._startLevel=void 0,p.currentLevelIndex=-1,p.manualLevelIndex=-1,p.onParsedComplete=void 0,p._registerListeners(),p}a=c,(e=t).prototype=Object.create(a.prototype),e.prototype.constructor=e,h(e,a);var s,d,n=t.prototype;return n._registerListeners=function(){var u=this.hls;u.on(E.Events.MANIFEST_LOADED,this.onManifestLoaded,this),u.on(E.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.on(E.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),u.on(E.Events.FRAG_LOADED,this.onFragLoaded,this),u.on(E.Events.ERROR,this.onError,this)},n._unregisterListeners=function(){var u=this.hls;u.off(E.Events.MANIFEST_LOADED,this.onManifestLoaded,this),u.off(E.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.off(E.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),u.off(E.Events.FRAG_LOADED,this.onFragLoaded,this),u.off(E.Events.ERROR,this.onError,this)},n.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,c.prototype.destroy.call(this)},n.startLoad=function(){this._levels.forEach(function(u){u.loadError=0}),c.prototype.startLoad.call(this)},n.onManifestLoaded=function(u,p){var g,v,i=[],r=[],o=[],S={},b=!1,k=!1,x=!1;if(p.levels.forEach(function(F){var M=F.attrs;b=b||!(!F.width||!F.height),k=k||!!F.videoCodec,x=x||!!F.audioCodec,T&&F.audioCodec&&F.audioCodec.indexOf("mp4a.40.34")!==-1&&(F.audioCodec=void 0);var B=F.bitrate+"-"+F.attrs.RESOLUTION+"-"+F.attrs.CODECS;(v=S[B])?v.url.push(F.url):(v=new R.Level(F),S[B]=v,i.push(v)),M&&(M.AUDIO&&Object(I.addGroupId)(v,"audio",M.AUDIO),M.SUBTITLES&&Object(I.addGroupId)(v,"text",M.SUBTITLES))}),(b||k)&&x&&(i=i.filter(function(F){var M=F.videoCodec,B=F.width,U=F.height;return!!M||!(!B||!U)})),i=i.filter(function(F){var M=F.audioCodec,B=F.videoCodec;return(!M||Object(D.isCodecSupportedInMp4)(M,"audio"))&&(!B||Object(D.isCodecSupportedInMp4)(B,"video"))}),p.audioTracks&&(r=p.audioTracks.filter(function(F){return!F.audioCodec||Object(D.isCodecSupportedInMp4)(F.audioCodec,"audio")}),Object(I.assignTrackIdsByGroup)(r)),p.subtitles&&(o=p.subtitles,Object(I.assignTrackIdsByGroup)(o)),i.length>0){g=i[0].bitrate,i.sort(function(F,M){return F.bitrate-M.bitrate}),this._levels=i;for(var w=0;w<i.length;w++)if(i[w].bitrate===g){this._firstLevel=w,this.log("manifest loaded, "+i.length+" level(s) found, first bitrate: "+g);break}var O=x&&!k,P={levels:i,audioTracks:r,subtitleTracks:o,firstLevel:this._firstLevel,stats:p.stats,audio:x,video:k,altAudio:!O&&r.some(function(F){return!!F.url})};this.hls.trigger(E.Events.MANIFEST_PARSED,P),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(E.Events.ERROR,{type:A.ErrorTypes.MEDIA_ERROR,details:A.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:p.url,reason:"no level with compatible codecs found in manifest"})},n.onError=function(u,p){if(c.prototype.onError.call(this,u,p),!p.fatal){var g=p.context,v=this._levels[this.currentLevelIndex];if(g&&(g.type===l.PlaylistContextType.AUDIO_TRACK&&v.audioGroupIds&&g.groupId===v.audioGroupIds[v.urlId]||g.type===l.PlaylistContextType.SUBTITLE_TRACK&&v.textGroupIds&&g.groupId===v.textGroupIds[v.urlId]))this.redundantFailover(this.currentLevelIndex);else{var i,r=!1,o=!0;switch(p.details){case A.ErrorDetails.FRAG_LOAD_ERROR:case A.ErrorDetails.FRAG_LOAD_TIMEOUT:case A.ErrorDetails.KEY_LOAD_ERROR:case A.ErrorDetails.KEY_LOAD_TIMEOUT:if(p.frag){var S=this._levels[p.frag.level];S?(S.fragmentError++,S.fragmentError>this.hls.config.fragLoadingMaxRetry&&(i=p.frag.level)):i=p.frag.level}break;case A.ErrorDetails.LEVEL_LOAD_ERROR:case A.ErrorDetails.LEVEL_LOAD_TIMEOUT:g&&(g.deliveryDirectives&&(o=!1),i=g.level),r=!0;break;case A.ErrorDetails.REMUX_ALLOC_ERROR:i=p.level,r=!0}i!==void 0&&this.recoverLevel(p,i,r,o)}}},n.recoverLevel=function(u,p,g,v){var i=u.details,r=this._levels[p];if(r.loadError++,g){if(!this.retryLoadingOrFail(u))return void(this.currentLevelIndex=-1);u.levelRetry=!0}if(v){var o=r.url.length;if(o>1&&r.loadError<o)u.levelRetry=!0,this.redundantFailover(p);else if(this.manualLevelIndex===-1){var S=p===0?this._levels.length-1:p-1;this.currentLevelIndex!==S&&this._levels[S].loadError===0&&(this.warn(i+": switch to "+S),u.levelRetry=!0,this.hls.nextAutoLevel=S)}}},n.redundantFailover=function(u){var p=this._levels[u],g=p.url.length;if(g>1){var v=(p.urlId+1)%g;this.warn("Switching to redundant URL-id "+v),this._levels.forEach(function(i){i.urlId=v}),this.level=u}},n.onFragLoaded=function(u,p){var g=p.frag;if(g!==void 0&&g.type===l.PlaylistLevelType.MAIN){var v=this._levels[g.level];v!==void 0&&(v.fragmentError=0,v.loadError=0)}},n.onLevelLoaded=function(u,p){var g,v,i=p.level,r=p.details,o=this._levels[i];if(!o)return this.warn("Invalid level index "+i),void((v=p.deliveryDirectives)!==null&&v!==void 0&&v.skip&&(r.deltaUpdateFailed=!0));i===this.currentLevelIndex?(o.fragmentError===0&&(o.loadError=0,this.retryCount=0),this.playlistLoaded(i,p,o.details)):(g=p.deliveryDirectives)!==null&&g!==void 0&&g.skip&&(r.deltaUpdateFailed=!0)},n.onAudioTrackSwitched=function(u,p){var g=this.hls.levels[this.currentLevelIndex];if(g&&g.audioGroupIds){for(var v=-1,i=this.hls.audioTracks[p.id].groupId,r=0;r<g.audioGroupIds.length;r++)if(g.audioGroupIds[r]===i){v=r;break}v!==g.urlId&&(g.urlId=v,this.startLoad())}},n.loadPlaylist=function(u){var p=this.currentLevelIndex,g=this._levels[p];if(this.canLoad&&g&&g.url.length>0){var v=g.urlId,i=g.url[v];if(u)try{i=u.addDirectives(i)}catch(r){this.warn("Could not construct new URL with HLS Delivery Directives: "+r)}this.log("Attempt loading level index "+p+(u?" at sn "+u.msn+" part "+u.part:"")+" with URL-id "+v+" "+i),this.clearTimer(),this.hls.trigger(E.Events.LEVEL_LOADING,{url:i,level:p,id:v,deliveryDirectives:u||null})}},n.removeLevel=function(u,p){var g=function(i,r){return r!==p},v=this._levels.filter(function(i,r){return r!==u||i.url.length>1&&p!==void 0&&(i.url=i.url.filter(g),i.audioGroupIds&&(i.audioGroupIds=i.audioGroupIds.filter(g)),i.textGroupIds&&(i.textGroupIds=i.textGroupIds.filter(g)),i.urlId=0,!0)}).map(function(i,r){var o=i.details;return o!=null&&o.fragments&&o.fragments.forEach(function(S){S.level=r}),i});this._levels=v,this.hls.trigger(E.Events.LEVELS_UPDATED,{levels:v})},s=t,(d=[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(u){var p,g=this._levels;if(g.length!==0&&(this.currentLevelIndex!==u||(p=g[u])===null||p===void 0||!p.details)){if(u<0||u>=g.length){var v=u<0;if(this.hls.trigger(E.Events.ERROR,{type:A.ErrorTypes.OTHER_ERROR,details:A.ErrorDetails.LEVEL_SWITCH_ERROR,level:u,fatal:v,reason:"invalid level idx"}),v)return;u=Math.min(u,g.length-1)}this.clearTimer();var i=this.currentLevelIndex,r=g[i],o=g[u];this.log("switching to level "+u+" from "+i),this.currentLevelIndex=u;var S=L({},o,{level:u,maxBitrate:o.maxBitrate,uri:o.uri,urlId:o.urlId});delete S._urlId,this.hls.trigger(E.Events.LEVEL_SWITCHING,S);var b=o.details;if(!b||b.live){var k=this.switchParams(o.uri,r==null?void 0:r.details);this.loadPlaylist(k)}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(u){this.manualLevelIndex=u,this._startLevel===void 0&&(this._startLevel=u),u!==-1&&(this.level=u)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(u){this._firstLevel=u}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var u=this.hls.config.startLevel;return u!==void 0?u:this._firstLevel}return this._startLevel},set:function(u){this._startLevel=u}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(u){this.level=u,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=u)}}])&&m(s.prototype,d),t}(_.default)},"./src/controller/level-helper.ts":function(N,C,f){f.r(C),f.d(C,"addGroupId",function(){return A}),f.d(C,"assignTrackIdsByGroup",function(){return D}),f.d(C,"updatePTS",function(){return I}),f.d(C,"updateFragPTSDTS",function(){return l}),f.d(C,"mergeDetails",function(){return L}),f.d(C,"mapPartIntersection",function(){return m}),f.d(C,"mapFragmentIntersection",function(){return h}),f.d(C,"adjustSliding",function(){return T}),f.d(C,"addSliding",function(){return y}),f.d(C,"computeReloadInterval",function(){return c}),f.d(C,"getFragmentWithSN",function(){return e}),f.d(C,"getPartWith",function(){return a});var R=f("./src/polyfills/number.ts"),E=f("./src/utils/logger.ts");function A(t,s,d){switch(s){case"audio":t.audioGroupIds||(t.audioGroupIds=[]),t.audioGroupIds.push(d);break;case"text":t.textGroupIds||(t.textGroupIds=[]),t.textGroupIds.push(d)}}function D(t){var s={};t.forEach(function(d){var n=d.groupId||"";d.id=s[n]=s[n]||0,s[n]++})}function I(t,s,d){_(t[s],t[d])}function _(t,s){var d=s.startPTS;if(Object(R.isFiniteNumber)(d)){var n,u=0;s.sn>t.sn?(u=d-t.start,n=t):(u=t.start-d,n=s),n.duration!==u&&(n.duration=u)}else s.sn>t.sn?t.cc===s.cc&&t.minEndPTS?s.start=t.start+(t.minEndPTS-t.start):s.start=t.start+t.duration:s.start=Math.max(t.start-s.duration,0)}function l(t,s,d,n,u,p){n-d<=0&&(E.logger.warn("Fragment should have a positive duration",s),n=d+s.duration,p=u+s.duration);var g=d,v=n,i=s.startPTS,r=s.endPTS;if(Object(R.isFiniteNumber)(i)){var o=Math.abs(i-d);Object(R.isFiniteNumber)(s.deltaPTS)?s.deltaPTS=Math.max(o,s.deltaPTS):s.deltaPTS=o,g=Math.max(d,i),d=Math.min(d,i),u=Math.min(u,s.startDTS),v=Math.min(n,r),n=Math.max(n,r),p=Math.max(p,s.endDTS)}s.duration=n-d;var S=d-s.start;s.appendedPTS=n,s.start=s.startPTS=d,s.maxStartPTS=g,s.startDTS=u,s.endPTS=n,s.minEndPTS=v,s.endDTS=p;var b,k=s.sn;if(!t||k<t.startSN||k>t.endSN)return 0;var x=k-t.startSN,w=t.fragments;for(w[x]=s,b=x;b>0;b--)_(w[b],w[b-1]);for(b=x;b<w.length-1;b++)_(w[b],w[b+1]);return t.fragmentHint&&_(w[w.length-1],t.fragmentHint),t.PTSKnown=t.alignedSliding=!0,S}function L(t,s){for(var d=null,n=t.fragments,u=n.length-1;u>=0;u--){var p=n[u].initSegment;if(p){d=p;break}}t.fragmentHint&&delete t.fragmentHint.endPTS;var g,v=0;if(h(t,s,function(k,x){var w;k.relurl&&(v=k.cc-x.cc),Object(R.isFiniteNumber)(k.startPTS)&&Object(R.isFiniteNumber)(k.endPTS)&&(x.start=x.startPTS=k.startPTS,x.startDTS=k.startDTS,x.appendedPTS=k.appendedPTS,x.maxStartPTS=k.maxStartPTS,x.endPTS=k.endPTS,x.endDTS=k.endDTS,x.minEndPTS=k.minEndPTS,x.duration=k.endPTS-k.startPTS,x.duration&&(g=x),s.PTSKnown=s.alignedSliding=!0),x.elementaryStreams=k.elementaryStreams,x.loader=k.loader,x.stats=k.stats,x.urlId=k.urlId,k.initSegment?(x.initSegment=k.initSegment,d=k.initSegment):x.initSegment&&x.initSegment.relurl!=((w=d)===null||w===void 0?void 0:w.relurl)||(x.initSegment=d)}),s.skippedSegments&&(s.deltaUpdateFailed=s.fragments.some(function(k){return!k}),s.deltaUpdateFailed)){E.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var i=s.skippedSegments;i--;)s.fragments.shift();s.startSN=s.fragments[0].sn,s.startCC=s.fragments[0].cc}var r=s.fragments;if(v){E.logger.warn("discontinuity sliding from playlist, take drift into account");for(var o=0;o<r.length;o++)r[o].cc+=v}s.skippedSegments&&(s.startCC=s.fragments[0].cc),m(t.partList,s.partList,function(k,x){x.elementaryStreams=k.elementaryStreams,x.stats=k.stats}),g?l(s,g,g.startPTS,g.endPTS,g.startDTS,g.endDTS):T(t,s),r.length&&(s.totalduration=s.edge-r[0].start),s.driftStartTime=t.driftStartTime,s.driftStart=t.driftStart;var S=s.advancedDateTime;if(s.advanced&&S){var b=s.edge;s.driftStart||(s.driftStartTime=S,s.driftStart=b),s.driftEndTime=S,s.driftEnd=b}else s.driftEndTime=t.driftEndTime,s.driftEnd=t.driftEnd,s.advancedDateTime=t.advancedDateTime}function m(t,s,d){if(t&&s)for(var n=0,u=0,p=t.length;u<=p;u++){var g=t[u],v=s[u+n];g&&v&&g.index===v.index&&g.fragment.sn===v.fragment.sn?d(g,v):n--}}function h(t,s,d){for(var n=s.skippedSegments,u=Math.max(t.startSN,s.startSN)-s.startSN,p=(t.fragmentHint?1:0)+(n?s.endSN:Math.min(t.endSN,s.endSN))-s.startSN,g=s.startSN-t.startSN,v=s.fragmentHint?s.fragments.concat(s.fragmentHint):s.fragments,i=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,r=u;r<=p;r++){var o=i[g+r],S=v[r];n&&!S&&r<n&&(S=s.fragments[r]=o),o&&S&&d(o,S)}}function T(t,s){var d=s.startSN+s.skippedSegments-t.startSN,n=t.fragments;d<0||d>=n.length||y(s,n[d].start)}function y(t,s){if(s){for(var d=t.fragments,n=t.skippedSegments;n<d.length;n++)d[n].start+=s;t.fragmentHint&&(t.fragmentHint.start+=s)}}function c(t,s){var d,n=1e3*t.levelTargetDuration,u=n/2,p=t.age,g=p>0&&p<3*n,v=s.loading.end-s.loading.start,i=t.availabilityDelay;if(t.updated===!1)if(g){var r=333*t.misses;d=Math.max(Math.min(u,2*v),r),t.availabilityDelay=(t.availabilityDelay||0)+d}else d=u;else g?(i=Math.min(i||n/2,p),t.availabilityDelay=i,d=i+n-p):d=n-v;return Math.round(d)}function e(t,s,d){if(!t||!t.details)return null;var n=t.details,u=n.fragments[s-n.startSN];return u||((u=n.fragmentHint)&&u.sn===s?u:s<n.startSN&&d&&d.sn===s?d:null)}function a(t,s,d){if(!t||!t.details)return null;var n=t.details.partList;if(n)for(var u=n.length;u--;){var p=n[u];if(p.index===d&&p.fragment.sn===s)return p}return null}},"./src/controller/stream-controller.ts":function(N,C,f){f.r(C),f.d(C,"default",function(){return t});var R=f("./src/polyfills/number.ts"),E=f("./src/controller/base-stream-controller.ts"),A=f("./src/is-supported.ts"),D=f("./src/events.ts"),I=f("./src/utils/buffer-helper.ts"),_=f("./src/controller/fragment-tracker.ts"),l=f("./src/types/loader.ts"),L=f("./src/loader/fragment.ts"),m=f("./src/demux/transmuxer-interface.ts"),h=f("./src/types/transmuxer.ts"),T=f("./src/controller/gap-controller.ts"),y=f("./src/errors.ts"),c=f("./src/utils/logger.ts");function e(s,d){for(var n=0;n<d.length;n++){var u=d[n];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(s,u.key,u)}}function a(s,d){return(a=Object.setPrototypeOf||function(n,u){return n.__proto__=u,n})(s,d)}var t=function(s){var d,n;function u(i,r){var o;return(o=s.call(this,i,r,"[stream-controller]")||this).audioCodecSwap=!1,o.gapController=null,o.level=-1,o._forceStartLoad=!1,o.altAudio=!1,o.audioOnly=!1,o.fragPlaying=null,o.onvplaying=null,o.onvseeked=null,o.fragLastKbps=0,o.stalled=!1,o.couldBacktrack=!1,o.audioCodecSwitch=!1,o.videoBuffer=null,o._registerListeners(),o}n=s,(d=u).prototype=Object.create(n.prototype),d.prototype.constructor=d,a(d,n);var p,g,v=u.prototype;return v._registerListeners=function(){var i=this.hls;i.on(D.Events.MEDIA_ATTACHED,this.onMediaAttached,this),i.on(D.Events.MEDIA_DETACHING,this.onMediaDetaching,this),i.on(D.Events.MANIFEST_LOADING,this.onManifestLoading,this),i.on(D.Events.MANIFEST_PARSED,this.onManifestParsed,this),i.on(D.Events.LEVEL_LOADING,this.onLevelLoading,this),i.on(D.Events.LEVEL_LOADED,this.onLevelLoaded,this),i.on(D.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),i.on(D.Events.ERROR,this.onError,this),i.on(D.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),i.on(D.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),i.on(D.Events.BUFFER_CREATED,this.onBufferCreated,this),i.on(D.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),i.on(D.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),i.on(D.Events.FRAG_BUFFERED,this.onFragBuffered,this)},v._unregisterListeners=function(){var i=this.hls;i.off(D.Events.MEDIA_ATTACHED,this.onMediaAttached,this),i.off(D.Events.MEDIA_DETACHING,this.onMediaDetaching,this),i.off(D.Events.MANIFEST_LOADING,this.onManifestLoading,this),i.off(D.Events.MANIFEST_PARSED,this.onManifestParsed,this),i.off(D.Events.LEVEL_LOADED,this.onLevelLoaded,this),i.off(D.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),i.off(D.Events.ERROR,this.onError,this),i.off(D.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),i.off(D.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),i.off(D.Events.BUFFER_CREATED,this.onBufferCreated,this),i.off(D.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),i.off(D.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),i.off(D.Events.FRAG_BUFFERED,this.onFragBuffered,this)},v.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},v.startLoad=function(i){if(this.levels){var r=this.lastCurrentTime,o=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var S=o.startLevel;S===-1&&(o.config.testBandwidth?(S=0,this.bitrateTest=!0):S=o.nextAutoLevel),this.level=o.nextLoadLevel=S,this.loadedmetadata=!1}r>0&&i===-1&&(this.log("Override startPosition with lastCurrentTime @"+r.toFixed(3)),i=r),this.state=E.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=i,this.tick()}else this._forceStartLoad=!0,this.state=E.State.STOPPED},v.stopLoad=function(){this._forceStartLoad=!1,s.prototype.stopLoad.call(this)},v.doTick=function(){switch(this.state){case E.State.IDLE:this.doTickIdle();break;case E.State.WAITING_LEVEL:var i,r=this.levels,o=this.level,S=r==null||(i=r[o])===null||i===void 0?void 0:i.details;if(S&&(!S.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(S))break;this.state=E.State.IDLE;break}break;case E.State.FRAG_LOADING_WAITING_RETRY:var b,k=self.performance.now(),x=this.retryDate;(!x||k>=x||(b=this.media)!==null&&b!==void 0&&b.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.state=E.State.IDLE)}this.onTickEnd()},v.onTickEnd=function(){s.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},v.doTickIdle=function(){var i,r,o=this.hls,S=this.levelLastLoaded,b=this.levels,k=this.media,x=o.config,w=o.nextLoadLevel;if(S!==null&&(k||!this.startFragRequested&&x.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)&&b&&b[w]){var O=b[w];this.level=o.nextLoadLevel=w;var P=O.details;if(!P||this.state===E.State.WAITING_LEVEL||P.live&&this.levelLastLoaded!==w)this.state=E.State.WAITING_LEVEL;else{var F=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:k,l.PlaylistLevelType.MAIN);if(F!==null&&!(F.len>=this.getMaxBufferLength(O.maxBitrate))){if(this._streamEnded(F,P)){var M={};return this.altAudio&&(M.type="video"),this.hls.trigger(D.Events.BUFFER_EOS,M),void(this.state=E.State.ENDED)}var B=F.end,U=this.getNextFragment(B,P);if(this.couldBacktrack&&!this.fragPrevious&&U&&U.sn!=="initSegment"){var j=U.sn-P.startSN;j>1&&(U=P.fragments[j-1],this.fragmentTracker.removeFragment(U))}if(U&&this.fragmentTracker.getState(U)===_.FragmentState.OK&&this.nextLoadPosition>B){var V=this.audioOnly&&!this.altAudio?L.ElementaryStreamTypes.AUDIO:L.ElementaryStreamTypes.VIDEO;this.afterBufferFlushed(k,V,l.PlaylistLevelType.MAIN),U=this.getNextFragment(this.nextLoadPosition,P)}U&&(!U.initSegment||U.initSegment.data||this.bitrateTest||(U=U.initSegment),((i=U.decryptdata)===null||i===void 0?void 0:i.keyFormat)!=="identity"||(r=U.decryptdata)!==null&&r!==void 0&&r.key?this.loadFragment(U,P,B):this.loadKey(U,P))}}}},v.loadFragment=function(i,r,o){var S,b=this.fragmentTracker.getState(i);if(this.fragCurrent=i,b===_.FragmentState.BACKTRACKED){var k=this.fragmentTracker.getBacktrackData(i);if(k)return this._handleFragmentLoadProgress(k),void this._handleFragmentLoadComplete(k);b=_.FragmentState.NOT_LOADED}b===_.FragmentState.NOT_LOADED||b===_.FragmentState.PARTIAL?i.sn==="initSegment"?this._loadInitSegment(i):this.bitrateTest?(i.bitrateTest=!0,this.log("Fragment "+i.sn+" of level "+i.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(i)):(this.startFragRequested=!0,s.prototype.loadFragment.call(this,i,r,o)):b===_.FragmentState.APPENDING?this.reduceMaxBufferLength(i.duration)&&this.fragmentTracker.removeFragment(i):((S=this.media)===null||S===void 0?void 0:S.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},v.getAppendedFrag=function(i){var r=this.fragmentTracker.getAppendedFrag(i,l.PlaylistLevelType.MAIN);return r&&"fragment"in r?r.fragment:r},v.getBufferedFrag=function(i){return this.fragmentTracker.getBufferedFrag(i,l.PlaylistLevelType.MAIN)},v.followingBufferedFrag=function(i){return i?this.getBufferedFrag(i.end+.5):null},v.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},v.nextLevelSwitch=function(){var i=this.levels,r=this.media;if(r!=null&&r.readyState){var o,S=this.getAppendedFrag(r.currentTime);if(S&&S.start>1&&this.flushMainBuffer(0,S.start-1),!r.paused&&i){var b=i[this.hls.nextLoadLevel],k=this.fragLastKbps;o=k&&this.fragCurrent?this.fragCurrent.duration*b.maxBitrate/(1e3*k)+1:0}else o=0;var x=this.getBufferedFrag(r.currentTime+o);if(x){var w=this.followingBufferedFrag(x);if(w){this.abortCurrentFrag();var O=w.maxStartPTS?w.maxStartPTS:w.start,P=w.duration,F=Math.max(x.end,O+Math.min(Math.max(P-this.config.maxFragLookUpTolerance,.5*P),.75*P));this.flushMainBuffer(F,Number.POSITIVE_INFINITY)}}}},v.abortCurrentFrag=function(){var i=this.fragCurrent;this.fragCurrent=null,i!=null&&i.loader&&i.loader.abort(),this.state===E.State.KEY_LOADING&&(this.state=E.State.IDLE),this.nextLoadPosition=this.getLoadPosition()},v.flushMainBuffer=function(i,r){s.prototype.flushMainBuffer.call(this,i,r,this.altAudio?"video":null)},v.onMediaAttached=function(i,r){s.prototype.onMediaAttached.call(this,i,r);var o=r.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),o.addEventListener("playing",this.onvplaying),o.addEventListener("seeked",this.onvseeked),this.gapController=new T.default(this.config,o,this.fragmentTracker,this.hls)},v.onMediaDetaching=function(){var i=this.media;i&&(i.removeEventListener("playing",this.onvplaying),i.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),s.prototype.onMediaDetaching.call(this)},v.onMediaPlaying=function(){this.tick()},v.onMediaSeeked=function(){var i=this.media,r=i?i.currentTime:null;Object(R.isFiniteNumber)(r)&&this.log("Media seeked to "+r.toFixed(3)),this.tick()},v.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(D.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=this.stalled=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null},v.onManifestParsed=function(i,r){var o,S=!1,b=!1;r.levels.forEach(function(k){(o=k.audioCodec)&&(o.indexOf("mp4a.40.2")!==-1&&(S=!0),o.indexOf("mp4a.40.5")!==-1&&(b=!0))}),this.audioCodecSwitch=S&&b&&!Object(A.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=r.levels,this.startFragRequested=!1},v.onLevelLoading=function(i,r){var o=this.levels;if(o&&this.state===E.State.IDLE){var S=o[r.level];(!S.details||S.details.live&&this.levelLastLoaded!==r.level||this.waitForCdnTuneIn(S.details))&&(this.state=E.State.WAITING_LEVEL)}},v.onLevelLoaded=function(i,r){var o,S=this.levels,b=r.level,k=r.details,x=k.totalduration;if(S){this.log("Level "+b+" loaded ["+k.startSN+","+k.endSN+"], cc ["+k.startCC+", "+k.endCC+"] duration:"+x);var w=this.fragCurrent;!w||this.state!==E.State.FRAG_LOADING&&this.state!==E.State.FRAG_LOADING_WAITING_RETRY||w.level!==r.level&&w.loader&&(this.state=E.State.IDLE,w.loader.abort());var O=S[b],P=0;if(k.live||(o=O.details)!==null&&o!==void 0&&o.live){if(k.fragments[0]||(k.deltaUpdateFailed=!0),k.deltaUpdateFailed)return;P=this.alignPlaylists(k,O.details)}if(O.details=k,this.levelLastLoaded=b,this.hls.trigger(D.Events.LEVEL_UPDATED,{details:k,level:b}),this.state===E.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(k))return;this.state=E.State.IDLE}this.startFragRequested?k.live&&this.synchronizeToLiveEdge(k):this.setStartPosition(k,P),this.tick()}else this.warn("Levels were reset while loading level "+b)},v._handleFragmentLoadProgress=function(i){var r,o=i.frag,S=i.part,b=i.payload,k=this.levels;if(k){var x=k[o.level],w=x.details;if(w){var O=x.videoCodec,P=w.PTSKnown||!w.live,F=(r=o.initSegment)===null||r===void 0?void 0:r.data,M=this._getAudioCodec(x),B=this.transmuxer=this.transmuxer||new m.default(this.hls,l.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),U=S?S.index:-1,j=U!==-1,V=new h.ChunkMetadata(o.level,o.sn,o.stats.chunkCount,b.byteLength,U,j),H=this.initPTS[o.cc];B.push(b,F,M,O,o,S,w.totalduration,P,V,H)}else this.warn("Dropping fragment "+o.sn+" of level "+o.level+" after level details were reset")}else this.warn("Levels were reset while fragment load was in progress. Fragment "+o.sn+" of level "+o.level+" will not be buffered")},v.onAudioTrackSwitching=function(i,r){var o=this.altAudio,S=!!r.url,b=r.id;if(!S){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var k=this.fragCurrent;k!=null&&k.loader&&(this.log("Switching to main audio track, cancel main fragment load"),k.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var x=this.hls;o&&x.trigger(D.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),x.trigger(D.Events.AUDIO_TRACK_SWITCHED,{id:b})}},v.onAudioTrackSwitched=function(i,r){var o=r.id,S=!!this.hls.audioTracks[o].url;if(S){var b=this.videoBuffer;b&&this.mediaBuffer!==b&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=b)}this.altAudio=S,this.tick()},v.onBufferCreated=function(i,r){var o,S,b=r.tracks,k=!1;for(var x in b){var w=b[x];if(w.id==="main"){if(S=x,o=w,x==="video"){var O=b[x];O&&(this.videoBuffer=O.buffer)}}else k=!0}k&&o?(this.log("Alternate track found, use "+S+".buffered to schedule main fragment loading"),this.mediaBuffer=o.buffer):this.mediaBuffer=this.media},v.onFragBuffered=function(i,r){var o=r.frag,S=r.part;if(!o||o.type===l.PlaylistLevelType.MAIN){if(this.fragContextChanged(o))return this.warn("Fragment "+o.sn+(S?" p: "+S.index:"")+" of level "+o.level+" finished buffering, but was aborted. state: "+this.state),void(this.state===E.State.PARSED&&(this.state=E.State.IDLE));var b=S?S.stats:o.stats;this.fragLastKbps=Math.round(8*b.total/(b.buffering.end-b.loading.first)),o.sn!=="initSegment"&&(this.fragPrevious=o),this.fragBufferedComplete(o,S)}},v.onError=function(i,r){switch(r.details){case y.ErrorDetails.FRAG_LOAD_ERROR:case y.ErrorDetails.FRAG_LOAD_TIMEOUT:case y.ErrorDetails.KEY_LOAD_ERROR:case y.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(l.PlaylistLevelType.MAIN,r);break;case y.ErrorDetails.LEVEL_LOAD_ERROR:case y.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==E.State.ERROR&&(r.fatal?(this.warn(""+r.details),this.state=E.State.ERROR):r.levelRetry||this.state!==E.State.WAITING_LEVEL||(this.state=E.State.IDLE));break;case y.ErrorDetails.BUFFER_FULL_ERROR:if(r.parent==="main"&&(this.state===E.State.PARSING||this.state===E.State.PARSED)){var o=!0,S=this.getFwdBufferInfo(this.media,l.PlaylistLevelType.MAIN);S&&S.len>.5&&(o=!this.reduceMaxBufferLength(S.len)),o&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}}},v.checkBuffer=function(){var i=this.media,r=this.gapController;if(i&&r&&i.readyState){var o=I.BufferHelper.getBuffered(i);!this.loadedmetadata&&o.length?(this.loadedmetadata=!0,this.seekToStartPos()):r.poll(this.lastCurrentTime),this.lastCurrentTime=i.currentTime}},v.onFragLoadEmergencyAborted=function(){this.state=E.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},v.onBufferFlushed=function(i,r){var o=r.type;if(o!==L.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var S=(o===L.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(S,o,l.PlaylistLevelType.MAIN)}},v.onLevelsUpdated=function(i,r){this.levels=r.levels},v.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},v.seekToStartPos=function(){var i=this.media,r=i.currentTime,o=this.startPosition;if(o>=0&&r<o){if(i.seeking)return void c.logger.log("could not seek to "+o+", already seeking at "+r);var S=I.BufferHelper.getBuffered(i),b=(S.length?S.start(0):0)-o;b>0&&b<this.config.maxBufferHole&&(c.logger.log("adjusting start position by "+b+" to match buffer start"),o+=b,this.startPosition=o),this.log("seek to target start position "+o+" from current time "+r),i.currentTime=o}},v._getAudioCodec=function(i){var r=this.config.defaultAudioCodec||i.audioCodec;return this.audioCodecSwap&&r&&(this.log("Swapping audio codec"),r=r.indexOf("mp4a.40.5")!==-1?"mp4a.40.2":"mp4a.40.5"),r},v._loadBitrateTestFrag=function(i){var r=this;this._doFragLoad(i).then(function(o){var S=r.hls;if(o&&!S.nextLoadLevel&&!r.fragContextChanged(i)){r.fragLoadError=0,r.state=E.State.IDLE,r.startFragRequested=!1,r.bitrateTest=!1;var b=i.stats;b.parsing.start=b.parsing.end=b.buffering.start=b.buffering.end=self.performance.now(),S.trigger(D.Events.FRAG_LOADED,o)}})},v._handleTransmuxComplete=function(i){var r,o="main",S=this.hls,b=i.remuxResult,k=i.chunkMeta,x=this.getCurrentContext(k);if(!x)return this.warn("The loading context changed while buffering fragment "+k.sn+" of level "+k.level+". This chunk will not be buffered."),void this.resetLiveStartWhenNotLoaded(k.level);var w=x.frag,O=x.part,P=x.level,F=b.video,M=b.text,B=b.id3,U=b.initSegment,j=this.altAudio?void 0:b.audio;if(!this.fragContextChanged(w)){if(this.state=E.State.PARSING,U){U.tracks&&(this._bufferInitSegment(P,U.tracks,w,k),S.trigger(D.Events.FRAG_PARSING_INIT_SEGMENT,{frag:w,id:o,tracks:U.tracks}));var V=U.initPTS,H=U.timescale;Object(R.isFiniteNumber)(V)&&(this.initPTS[w.cc]=V,S.trigger(D.Events.INIT_PTS_FOUND,{frag:w,id:o,initPTS:V,timescale:H}))}if(F&&b.independent!==!1){if(P.details){var z=F.startPTS,W=F.endPTS,X=F.startDTS,ne=F.endDTS;if(O)O.elementaryStreams[F.type]={startPTS:z,endPTS:W,startDTS:X,endDTS:ne};else if(F.firstKeyFrame&&F.independent&&(this.couldBacktrack=!0),F.dropped&&F.independent){if(this.getLoadPosition()+this.config.maxBufferHole<z)return void this.backtrack(w);w.setElementaryStreamInfo(F.type,w.start,W,w.start,ne,!0)}w.setElementaryStreamInfo(F.type,z,W,X,ne),this.bufferFragmentData(F,w,O,k)}}else if(b.independent===!1)return void this.backtrack(w);if(j){var se=j.startPTS,oe=j.endPTS,te=j.startDTS,de=j.endDTS;O&&(O.elementaryStreams[L.ElementaryStreamTypes.AUDIO]={startPTS:se,endPTS:oe,startDTS:te,endDTS:de}),w.setElementaryStreamInfo(L.ElementaryStreamTypes.AUDIO,se,oe,te,de),this.bufferFragmentData(j,w,O,k)}if(B!=null&&(r=B.samples)!==null&&r!==void 0&&r.length){var re={frag:w,id:o,samples:B.samples};S.trigger(D.Events.FRAG_PARSING_METADATA,re)}if(M){var ae={frag:w,id:o,samples:M.samples};S.trigger(D.Events.FRAG_PARSING_USERDATA,ae)}}},v._bufferInitSegment=function(i,r,o,S){var b=this;if(this.state===E.State.PARSING){this.audioOnly=!!r.audio&&!r.video,this.altAudio&&!this.audioOnly&&delete r.audio;var k=r.audio,x=r.video,w=r.audiovideo;if(k){var O=i.audioCodec,P=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(O&&(O=O.indexOf("mp4a.40.5")!==-1?"mp4a.40.2":"mp4a.40.5"),k.metadata.channelCount!==1&&P.indexOf("firefox")===-1&&(O="mp4a.40.5")),P.indexOf("android")!==-1&&k.container!=="audio/mpeg"&&(O="mp4a.40.2",this.log("Android: force audio codec to "+O)),i.audioCodec&&i.audioCodec!==O&&this.log('Swapping manifest audio codec "'+i.audioCodec+'" for "'+O+'"'),k.levelCodec=O,k.id="main",this.log("Init audio buffer, container:"+k.container+", codecs[selected/level/parsed]=["+(O||"")+"/"+(i.audioCodec||"")+"/"+k.codec+"]")}x&&(x.levelCodec=i.videoCodec,x.id="main",this.log("Init video buffer, container:"+x.container+", codecs[level/parsed]=["+(i.videoCodec||"")+"/"+x.codec+"]")),w&&this.log("Init audiovideo buffer, container:"+w.container+", codecs[level/parsed]=["+(i.attrs.CODECS||"")+"/"+w.codec+"]"),this.hls.trigger(D.Events.BUFFER_CODECS,r),Object.keys(r).forEach(function(F){var M=r[F].initSegment;M!=null&&M.byteLength&&b.hls.trigger(D.Events.BUFFER_APPENDING,{type:F,data:M,frag:o,part:null,chunkMeta:S,parent:o.type})}),this.tick()}},v.backtrack=function(i){this.couldBacktrack=!0,this.resetTransmuxer(),this.flushBufferGap(i);var r=this.fragmentTracker.backtrack(i);this.fragPrevious=null,this.nextLoadPosition=i.start,r?this.resetFragmentLoading(i):this.state=E.State.BACKTRACKING},v.checkFragmentChanged=function(){var i=this.media,r=null;if(i&&i.readyState>1&&i.seeking===!1){var o=i.currentTime;if(I.BufferHelper.isBuffered(i,o)?r=this.getAppendedFrag(o):I.BufferHelper.isBuffered(i,o+.1)&&(r=this.getAppendedFrag(o+.1)),r){var S=this.fragPlaying,b=r.level;S&&r.sn===S.sn&&S.level===b&&r.urlId===S.urlId||(this.hls.trigger(D.Events.FRAG_CHANGED,{frag:r}),S&&S.level===b||this.hls.trigger(D.Events.LEVEL_SWITCHED,{level:b}),this.fragPlaying=r)}}},p=u,(g=[{key:"nextLevel",get:function(){var i=this.nextBufferedFrag;return i?i.level:-1}},{key:"currentLevel",get:function(){var i=this.media;if(i){var r=this.getAppendedFrag(i.currentTime);if(r)return r.level}return-1}},{key:"nextBufferedFrag",get:function(){var i=this.media;if(i){var r=this.getAppendedFrag(i.currentTime);return this.followingBufferedFrag(r)}return null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}])&&e(p.prototype,g),u}(E.default)},"./src/controller/subtitle-stream-controller.ts":function(N,C,f){f.r(C),f.d(C,"SubtitleStreamController",function(){return c});var R=f("./src/events.ts"),E=f("./src/utils/logger.ts"),A=f("./src/utils/buffer-helper.ts"),D=f("./src/controller/fragment-finders.ts"),I=f("./src/utils/discontinuities.ts"),_=f("./src/controller/level-helper.ts"),l=f("./src/controller/fragment-tracker.ts"),L=f("./src/controller/base-stream-controller.ts"),m=f("./src/types/loader.ts"),h=f("./src/types/level.ts");function T(e,a){for(var t=0;t<a.length;t++){var s=a[t];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}function y(e,a){return(y=Object.setPrototypeOf||function(t,s){return t.__proto__=s,t})(e,a)}var c=function(e){var a,t;function s(p,g){var v;return(v=e.call(this,p,g,"[subtitle-stream-controller]")||this).levels=[],v.currentTrackId=-1,v.tracksBuffered=[],v.mainDetails=null,v._registerListeners(),v}t=e,(a=s).prototype=Object.create(t.prototype),a.prototype.constructor=a,y(a,t);var d,n,u=s.prototype;return u.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},u._registerListeners=function(){var p=this.hls;p.on(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),p.on(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),p.on(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),p.on(R.Events.LEVEL_LOADED,this.onLevelLoaded,this),p.on(R.Events.ERROR,this.onError,this),p.on(R.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),p.on(R.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),p.on(R.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),p.on(R.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),p.on(R.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},u._unregisterListeners=function(){var p=this.hls;p.off(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),p.off(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),p.off(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),p.off(R.Events.LEVEL_LOADED,this.onLevelLoaded,this),p.off(R.Events.ERROR,this.onError,this),p.off(R.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),p.off(R.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),p.off(R.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),p.off(R.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),p.off(R.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},u.startLoad=function(){this.stopLoad(),this.state=L.State.IDLE,this.setInterval(500),this.tick()},u.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},u.onLevelLoaded=function(p,g){this.mainDetails=g.details},u.onSubtitleFragProcessed=function(p,g){var v=g.frag,i=g.success;if(this.fragPrevious=v,this.state=L.State.IDLE,i){var r=this.tracksBuffered[this.currentTrackId];if(r){for(var o,S=v.start,b=0;b<r.length;b++)if(S>=r[b].start&&S<=r[b].end){o=r[b];break}var k=v.start+v.duration;o?o.end=k:(o={start:S,end:k},r.push(o)),this.fragmentTracker.fragBuffered(v)}}},u.onBufferFlushing=function(p,g){var v=g.startOffset,i=g.endOffset;if(v===0&&i!==Number.POSITIVE_INFINITY){var r=this.currentTrackId,o=this.levels;if(!o.length||!o[r]||!o[r].details)return;var S=i-o[r].details.targetduration;if(S<=0)return;g.endOffsetSubtitles=Math.max(0,S),this.tracksBuffered.forEach(function(b){for(var k=0;k<b.length;)if(b[k].end<=S)b.shift();else{if(!(b[k].start<S))break;b[k].start=S,k++}}),this.fragmentTracker.removeFragmentsInRange(v,S,m.PlaylistLevelType.SUBTITLE)}},u.onError=function(p,g){var v,i=g.frag;i&&i.type===m.PlaylistLevelType.SUBTITLE&&((v=this.fragCurrent)!==null&&v!==void 0&&v.loader&&this.fragCurrent.loader.abort(),this.state=L.State.IDLE)},u.onSubtitleTracksUpdated=function(p,g){var v=this,i=g.subtitleTracks;this.tracksBuffered=[],this.levels=i.map(function(r){return new h.Level(r)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(r){v.tracksBuffered[r.id]=[]}),this.mediaBuffer=null},u.onSubtitleTrackSwitch=function(p,g){if(this.currentTrackId=g.id,this.levels.length&&this.currentTrackId!==-1){var v=this.levels[this.currentTrackId];v!=null&&v.details?(this.mediaBuffer=this.mediaBufferTimeRanges,this.setInterval(500)):this.mediaBuffer=null}else this.clearInterval()},u.onSubtitleTrackLoaded=function(p,g){var v,i=g.details,r=g.id,o=this.currentTrackId,S=this.levels;if(S.length){var b=S[o];if(!(r>=S.length||r!==o)&&b){if(this.mediaBuffer=this.mediaBufferTimeRanges,i.live||(v=b.details)!==null&&v!==void 0&&v.live){var k=this.mainDetails;if(i.deltaUpdateFailed||!k)return;var x=k.fragments[0];b.details?this.alignPlaylists(i,b.details)===0&&x&&Object(_.addSliding)(i,x.start):i.hasProgramDateTime&&k.hasProgramDateTime?Object(I.alignPDT)(i,k):x&&Object(_.addSliding)(i,x.start)}b.details=i,this.levelLastLoaded=r,this.tick(),i.live&&!this.fragCurrent&&this.media&&this.state===L.State.IDLE&&(Object(D.findFragmentByPTS)(null,i.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),b.details=void 0))}}},u._handleFragmentLoadComplete=function(p){var g=p.frag,v=p.payload,i=g.decryptdata,r=this.hls;if(!this.fragContextChanged(g)&&v&&v.byteLength>0&&i&&i.key&&i.iv&&i.method==="AES-128"){var o=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(v),i.key.buffer,i.iv.buffer).then(function(S){var b=performance.now();r.trigger(R.Events.FRAG_DECRYPTED,{frag:g,payload:S,stats:{tstart:o,tdecrypt:b}})})}},u.doTick=function(){if(this.media){if(this.state===L.State.IDLE){var p,g=this.currentTrackId,v=this.levels;if(!v.length||!v[g]||!v[g].details)return;var i=v[g].details,r=i.targetduration,o=this.config,S=this.media,b=A.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,S.currentTime-r,o.maxBufferHole),k=b.end;if(b.len>this.getMaxBufferLength()+r)return;console.assert(i,"Subtitle track details are defined on idle subtitle stream controller tick");var x,w=i.fragments,O=w.length,P=i.edge,F=this.fragPrevious;if(k<P){var M=o.maxFragLookUpTolerance;F&&i.hasProgramDateTime&&(x=Object(D.findFragmentByPDT)(w,F.endProgramDateTime,M)),x||!(x=Object(D.findFragmentByPTS)(F,w,k,M))&&F&&F.start<w[0].start&&(x=w[0])}else x=w[O-1];(p=x)!==null&&p!==void 0&&p.encrypted?(E.logger.log("Loading key for "+x.sn),this.state=L.State.KEY_LOADING,this.hls.trigger(R.Events.KEY_LOADING,{frag:x})):x&&this.fragmentTracker.getState(x)===l.FragmentState.NOT_LOADED&&this.loadFragment(x,i,k)}}else this.state=L.State.IDLE},u.loadFragment=function(p,g,v){this.fragCurrent=p,e.prototype.loadFragment.call(this,p,g,v)},d=s,(n=[{key:"mediaBufferTimeRanges",get:function(){return this.tracksBuffered[this.currentTrackId]||[]}}])&&T(d.prototype,n),s}(L.default)},"./src/controller/subtitle-track-controller.ts":function(N,C,f){f.r(C);var R=f("./src/events.ts"),E=f("./src/utils/texttrack-utils.ts"),A=f("./src/controller/base-playlist-controller.ts"),D=f("./src/types/loader.ts");function I(m,h){for(var T=0;T<h.length;T++){var y=h[T];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(m,y.key,y)}}function _(m,h){return(_=Object.setPrototypeOf||function(T,y){return T.__proto__=y,T})(m,h)}var l=function(m){var h,T;function y(t){var s;return(s=m.call(this,t,"[subtitle-track-controller]")||this).media=null,s.tracks=[],s.groupId=null,s.tracksInGroup=[],s.trackId=-1,s.selectDefaultTrack=!0,s.queuedDefaultTrack=-1,s.trackChangeListener=function(){return s.onTextTracksChanged()},s.asyncPollTrackChange=function(){return s.pollTrackChange(0)},s.useTextTrackPolling=!1,s.subtitlePollingInterval=-1,s.subtitleDisplay=!0,s.registerListeners(),s}T=m,(h=y).prototype=Object.create(T.prototype),h.prototype.constructor=h,_(h,T);var c,e,a=y.prototype;return a.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,m.prototype.destroy.call(this)},a.registerListeners=function(){var t=this.hls;t.on(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(R.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(R.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(R.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(R.Events.ERROR,this.onError,this)},a.unregisterListeners=function(){var t=this.hls;t.off(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(R.Events.LEVEL_LOADING,this.onLevelLoading,this),t.off(R.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(R.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(R.Events.ERROR,this.onError,this)},a.onMediaAttached=function(t,s){this.media=s.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))},a.pollTrackChange=function(t){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,t)},a.onMediaDetaching=function(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),L(this.media.textTracks).forEach(function(t){Object(E.clearCurrentCues)(t)}),this.subtitleTrack=-1,this.media=null)},a.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},a.onManifestParsed=function(t,s){this.tracks=s.subtitleTracks},a.onSubtitleTrackLoaded=function(t,s){var d=s.id,n=s.details,u=this.trackId,p=this.tracksInGroup[u];if(p){var g=p.details;p.details=s.details,this.log("subtitle track "+d+" loaded ["+n.startSN+"-"+n.endSN+"]"),d===this.trackId&&(this.retryCount=0,this.playlistLoaded(d,s,g))}else this.warn("Invalid subtitle track id "+d)},a.onLevelLoading=function(t,s){this.switchLevel(s.level)},a.onLevelSwitching=function(t,s){this.switchLevel(s.level)},a.switchLevel=function(t){var s=this.hls.levels[t];if(s!=null&&s.textGroupIds){var d=s.textGroupIds[s.urlId];if(this.groupId!==d){var n=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,u=this.tracks.filter(function(v){return!d||v.groupId===d});this.tracksInGroup=u;var p=this.findTrackId(n==null?void 0:n.name)||this.findTrackId();this.groupId=d;var g={subtitleTracks:u};this.log("Updating subtitle tracks, "+u.length+' track(s) found in "'+d+'" group-id'),this.hls.trigger(R.Events.SUBTITLE_TRACKS_UPDATED,g),p!==-1&&this.setSubtitleTrack(p,n)}}},a.findTrackId=function(t){for(var s=this.tracksInGroup,d=0;d<s.length;d++){var n=s[d];if((!this.selectDefaultTrack||n.default)&&(!t||t===n.name))return n.id}return-1},a.onError=function(t,s){m.prototype.onError.call(this,t,s),!s.fatal&&s.context&&s.context.type===D.PlaylistContextType.SUBTITLE_TRACK&&s.context.id===this.trackId&&s.context.groupId===this.groupId&&this.retryLoadingOrFail(s)},a.loadPlaylist=function(t){var s=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(s)){var d=s.id,n=s.groupId,u=s.url;if(t)try{u=t.addDirectives(u)}catch(p){this.warn("Could not construct new URL with HLS Delivery Directives: "+p)}this.log("Loading subtitle playlist for id "+d),this.hls.trigger(R.Events.SUBTITLE_TRACK_LOADING,{url:u,id:d,groupId:n,deliveryDirectives:t||null})}},a.toggleTrackModes=function(t){var s=this,d=this.media,n=this.subtitleDisplay,u=this.trackId;if(d){var p=L(d.textTracks),g=p.filter(function(r){return r.groupId===s.groupId});if(t===-1)[].slice.call(p).forEach(function(r){r.mode="disabled"});else{var v=g[u];v&&(v.mode="disabled")}var i=g[t];i&&(i.mode=n?"showing":"hidden")}},a.setSubtitleTrack=function(t,s){var d,n=this.tracksInGroup;if(this.media){if(this.trackId!==t&&this.toggleTrackModes(t),!(this.trackId===t&&(t===-1||(d=n[t])!==null&&d!==void 0&&d.details)||t<-1||t>=n.length)){this.clearTimer();var u=n[t];if(this.log("Switching to subtitle track "+t),this.trackId=t,u){var p=u.id,g=u.groupId,v=g===void 0?"":g,i=u.name,r=u.type,o=u.url;this.hls.trigger(R.Events.SUBTITLE_TRACK_SWITCH,{id:p,groupId:v,name:i,type:r,url:o});var S=this.switchParams(u.url,s==null?void 0:s.details);this.loadPlaylist(S)}else this.hls.trigger(R.Events.SUBTITLE_TRACK_SWITCH,{id:t})}}else this.queuedDefaultTrack=t},a.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),this.media&&this.hls.config.renderTextTracksNatively){for(var t=-1,s=L(this.media.textTracks),d=0;d<s.length;d++)if(s[d].mode==="hidden")t=d;else if(s[d].mode==="showing"){t=d;break}this.subtitleTrack!==t&&(this.subtitleTrack=t)}},c=y,(e=[{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(t){this.selectDefaultTrack=!1;var s=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(t,s)}}])&&I(c.prototype,e),y}(A.default);function L(m){for(var h=[],T=0;T<m.length;T++){var y=m[T];y.kind==="subtitles"&&y.label&&h.push(m[T])}return h}C.default=l},"./src/controller/timeline-controller.ts":function(N,C,f){f.r(C),f.d(C,"TimelineController",function(){return h});var R=f("./src/polyfills/number.ts"),E=f("./src/events.ts"),A=f("./src/utils/cea-608-parser.ts"),D=f("./src/utils/output-filter.ts"),I=f("./src/utils/webvtt-parser.ts"),_=f("./src/utils/texttrack-utils.ts"),l=f("./src/utils/imsc1-ttml-parser.ts"),L=f("./src/types/loader.ts"),m=f("./src/utils/logger.ts"),h=function(){function y(e){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.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}},this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.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 a=new D.default(this,"textTrack1"),t=new D.default(this,"textTrack2"),s=new D.default(this,"textTrack3"),d=new D.default(this,"textTrack4");this.cea608Parser1=new A.default(1,a,t),this.cea608Parser2=new A.default(3,s,d)}e.on(E.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(E.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(E.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(E.Events.FRAG_LOADING,this.onFragLoading,this),e.on(E.Events.FRAG_LOADED,this.onFragLoaded,this),e.on(E.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(E.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(E.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(E.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(E.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var c=y.prototype;return c.destroy=function(){var e=this.hls;e.off(E.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(E.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(E.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(E.Events.FRAG_LOADING,this.onFragLoading,this),e.off(E.Events.FRAG_LOADED,this.onFragLoaded,this),e.off(E.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(E.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(E.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(E.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(E.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},c.addCues=function(e,a,t,s,d){for(var n,u,p,g,v=!1,i=d.length;i--;){var r=d[i],o=(n=r[0],u=r[1],p=a,g=t,Math.min(u,g)-Math.max(n,p));if(o>=0&&(r[0]=Math.min(r[0],a),r[1]=Math.max(r[1],t),v=!0,o/(t-a)>.5))return}if(v||d.push([a,t]),this.config.renderTextTracksNatively){var S=this.captionsTracks[e];this.Cues.newCue(S,a,t,s)}else{var b=this.Cues.newCue(null,a,t,s);this.hls.trigger(E.Events.CUES_PARSED,{type:"captions",cues:b,track:e})}},c.onInitPtsFound=function(e,a){var t=this,s=a.frag,d=a.id,n=a.initPTS,u=a.timescale,p=this.unparsedVttFrags;d==="main"&&(this.initPTS[s.cc]=n,this.timescale[s.cc]=u),p.length&&(this.unparsedVttFrags=[],p.forEach(function(g){t.onFragLoaded(E.Events.FRAG_LOADED,g)}))},c.getExistingTrack=function(e){var a=this.media;if(a)for(var t=0;t<a.textTracks.length;t++){var s=a.textTracks[t];if(s[e])return s}return null},c.createCaptionsTrack=function(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)},c.createNativeTrack=function(e){if(!this.captionsTracks[e]){var a=this.captionsProperties,t=this.captionsTracks,s=this.media,d=a[e],n=d.label,u=d.languageCode,p=this.getExistingTrack(e);if(p)t[e]=p,Object(_.clearCurrentCues)(t[e]),Object(_.sendAddTrackEvent)(t[e],s);else{var g=this.createTextTrack("captions",n,u);g&&(g[e]=!0,t[e]=g)}}},c.createNonNativeTrack=function(e){if(!this.nonNativeCaptionsTracks[e]){var a=this.captionsProperties[e];if(a){var t={_id:e,label:a.label,kind:"captions",default:!!a.media&&!!a.media.default,closedCaptions:a.media};this.nonNativeCaptionsTracks[e]=t,this.hls.trigger(E.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[t]})}}},c.createTextTrack=function(e,a,t){var s=this.media;if(s)return s.addTextTrack(e,a,t)},c.onMediaAttaching=function(e,a){this.media=a.media,this._cleanTracks()},c.onMediaDetaching=function(){var e=this.captionsTracks;Object.keys(e).forEach(function(a){Object(_.clearCurrentCues)(e[a]),delete e[a]}),this.nonNativeCaptionsTracks={}},c.onManifestLoading=function(){this.lastSn=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}},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())},c._cleanTracks=function(){var e=this.media;if(e){var a=e.textTracks;if(a)for(var t=0;t<a.length;t++)Object(_.clearCurrentCues)(a[t])}},c.onSubtitleTracksUpdated=function(e,a){var t=this;this.textTracks=[];var s=a.subtitleTracks||[],d=s.some(function(g){return g.textCodec===l.IMSC1_CODEC});if(this.config.enableWebVTT||d&&this.config.enableIMSC1){var n=this.tracks&&s&&this.tracks.length===s.length;if(this.tracks=s||[],this.config.renderTextTracksNatively){var u=this.media?this.media.textTracks:[];this.tracks.forEach(function(g,v){var i;if(v<u.length){for(var r=null,o=0;o<u.length;o++)if(T(u[o],g)){r=u[o];break}r&&(i=r)}i?Object(_.clearCurrentCues)(i):(i=t.createTextTrack("subtitles",g.name,g.lang))&&(i.mode="disabled"),i&&(i.groupId=g.groupId,t.textTracks.push(i))})}else if(!n&&this.tracks&&this.tracks.length){var p=this.tracks.map(function(g){return{label:g.name,kind:g.type.toLowerCase(),default:g.default,subtitleTrack:g}});this.hls.trigger(E.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:p})}}},c.onManifestLoaded=function(e,a){var t=this;this.config.enableCEA708Captions&&a.captions&&a.captions.forEach(function(s){var d=/(?:CC|SERVICE)([1-4])/.exec(s.instreamId);if(d){var n="textTrack"+d[1],u=t.captionsProperties[n];u&&(u.label=s.name,s.lang&&(u.languageCode=s.lang),u.media=s)}})},c.onFragLoading=function(e,a){var t=this.cea608Parser1,s=this.cea608Parser2,d=this.lastSn;if(this.enabled&&t&&s&&a.frag.type===L.PlaylistLevelType.MAIN){var n=a.frag.sn;n!==d+1&&(t.reset(),s.reset()),this.lastSn=n}},c.onFragLoaded=function(e,a){var t=a.frag,s=a.payload,d=this.initPTS,n=this.unparsedVttFrags;if(t.type===L.PlaylistLevelType.SUBTITLE)if(s.byteLength){if(!Object(R.isFiniteNumber)(d[t.cc]))return n.push(a),void(d.length&&this.hls.trigger(E.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:new Error("Missing initial subtitle PTS")}));var u=t.decryptdata;if(u==null||u.key==null||u.method!=="AES-128"){var p=this.tracks[t.level],g=this.vttCCs;g[t.cc]||(g[t.cc]={start:t.start,prevCC:this.prevCC,new:!0},this.prevCC=t.cc),p&&p.textCodec===l.IMSC1_CODEC?this._parseIMSC1(t,s):this._parseVTTs(t,s,g)}}else this.hls.trigger(E.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:new Error("Empty subtitle payload")})},c._parseIMSC1=function(e,a){var t=this,s=this.hls;Object(l.parseIMSC1)(a,this.initPTS[e.cc],this.timescale[e.cc],function(d){t._appendCues(d,e.level),s.trigger(E.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},function(d){m.logger.log("Failed to parse IMSC1: "+d),s.trigger(E.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:d})})},c._parseVTTs=function(e,a,t){var s=this,d=this.hls;Object(I.parseWebVTT)(a,this.initPTS[e.cc],this.timescale[e.cc],t,e.cc,e.start,function(n){s._appendCues(n,e.level),d.trigger(E.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},function(n){s._fallbackToIMSC1(e,a),m.logger.log("Failed to parse VTT cue: "+n),d.trigger(E.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:n})})},c._fallbackToIMSC1=function(e,a){var t=this,s=this.tracks[e.level];s.textCodec||Object(l.parseIMSC1)(a,this.initPTS[e.cc],this.timescale[e.cc],function(){s.textCodec=l.IMSC1_CODEC,t._parseIMSC1(e,a)},function(){s.textCodec="wvtt"})},c._appendCues=function(e,a){var t=this.hls;if(this.config.renderTextTracksNatively){var s=this.textTracks[a];if(s.mode==="disabled")return;e.forEach(function(n){return Object(_.addCueToTrack)(s,n)})}else{var d=this.tracks[a].default?"default":"subtitles"+a;t.trigger(E.Events.CUES_PARSED,{type:"subtitles",cues:e,track:d})}},c.onFragDecrypted=function(e,a){var t=a.frag;if(t.type===L.PlaylistLevelType.SUBTITLE){if(!Object(R.isFiniteNumber)(this.initPTS[t.cc]))return void this.unparsedVttFrags.push(a);this.onFragLoaded(E.Events.FRAG_LOADED,a)}},c.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},c.onFragParsingUserdata=function(e,a){var t=this.cea608Parser1,s=this.cea608Parser2;if(this.enabled&&t&&s)for(var d=0;d<a.samples.length;d++){var n=a.samples[d].bytes;if(n){var u=this.extractCea608Data(n);t.addData(a.samples[d].pts,u[0]),s.addData(a.samples[d].pts,u[1])}}},c.onBufferFlushing=function(e,a){var t=a.startOffset,s=a.endOffset,d=a.endOffsetSubtitles,n=a.type,u=this.media;if(u&&!(u.currentTime<s)){if(!n||n==="video"){var p=this.captionsTracks;Object.keys(p).forEach(function(v){return Object(_.removeCuesInRange)(p[v],t,s)})}if(this.config.renderTextTracksNatively&&t===0&&d!==void 0){var g=this.textTracks;Object.keys(g).forEach(function(v){return Object(_.removeCuesInRange)(g[v],t,d)})}}},c.extractCea608Data=function(e){for(var a=31&e[0],t=2,s=[[],[]],d=0;d<a;d++){var n=e[t++],u=127&e[t++],p=127&e[t++],g=3&n;u===0&&p===0||4&n&&(g!==0&&g!==1||(s[g].push(u),s[g].push(p)))}return s},y}();function T(y,c){return y&&y.label===c.name&&!(y.textTrack1||y.textTrack2)}},"./src/crypt/aes-crypto.ts":function(N,C,f){f.r(C),f.d(C,"default",function(){return R});var R=function(){function E(A,D){this.subtle=void 0,this.aesIV=void 0,this.subtle=A,this.aesIV=D}return E.prototype.decrypt=function(A,D){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},D,A)},E}()},"./src/crypt/aes-decryptor.ts":function(N,C,f){f.r(C),f.d(C,"removePadding",function(){return E}),f.d(C,"default",function(){return A});var R=f("./src/utils/typed-array.ts");function E(D){var I=D.byteLength,_=I&&new DataView(D.buffer).getUint8(I-1);return _?Object(R.sliceUint8)(D,0,I-_):D}var A=function(){function D(){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 I=D.prototype;return I.uint8ArrayToUint32Array_=function(_){for(var l=new DataView(_),L=new Uint32Array(4),m=0;m<4;m++)L[m]=l.getUint32(4*m);return L},I.initTable=function(){var _=this.sBox,l=this.invSBox,L=this.subMix,m=L[0],h=L[1],T=L[2],y=L[3],c=this.invSubMix,e=c[0],a=c[1],t=c[2],s=c[3],d=new Uint32Array(256),n=0,u=0,p=0;for(p=0;p<256;p++)d[p]=p<128?p<<1:p<<1^283;for(p=0;p<256;p++){var g=u^u<<1^u<<2^u<<3^u<<4;g=g>>>8^255&g^99,_[n]=g,l[g]=n;var v=d[n],i=d[v],r=d[i],o=257*d[g]^16843008*g;m[n]=o<<24|o>>>8,h[n]=o<<16|o>>>16,T[n]=o<<8|o>>>24,y[n]=o,o=16843009*r^65537*i^257*v^16843008*n,e[g]=o<<24|o>>>8,a[g]=o<<16|o>>>16,t[g]=o<<8|o>>>24,s[g]=o,n?(n=v^d[d[d[r^v]]],u^=d[d[u]]):n=u=1}},I.expandKey=function(_){for(var l=this.uint8ArrayToUint32Array_(_),L=!0,m=0;m<l.length&&L;)L=l[m]===this.key[m],m++;if(!L){this.key=l;var h=this.keySize=l.length;if(h!==4&&h!==6&&h!==8)throw new Error("Invalid aes key size="+h);var T,y,c,e,a=this.ksRows=4*(h+6+1),t=this.keySchedule=new Uint32Array(a),s=this.invKeySchedule=new Uint32Array(a),d=this.sBox,n=this.rcon,u=this.invSubMix,p=u[0],g=u[1],v=u[2],i=u[3];for(T=0;T<a;T++)T<h?c=t[T]=l[T]:(e=c,T%h==0?(e=d[(e=e<<8|e>>>24)>>>24]<<24|d[e>>>16&255]<<16|d[e>>>8&255]<<8|d[255&e],e^=n[T/h|0]<<24):h>6&&T%h==4&&(e=d[e>>>24]<<24|d[e>>>16&255]<<16|d[e>>>8&255]<<8|d[255&e]),t[T]=c=(t[T-h]^e)>>>0);for(y=0;y<a;y++)T=a-y,e=3&y?t[T]:t[T-4],s[y]=y<4||T<=4?e:p[d[e>>>24]]^g[d[e>>>16&255]]^v[d[e>>>8&255]]^i[d[255&e]],s[y]=s[y]>>>0}},I.networkToHostOrderSwap=function(_){return _<<24|(65280&_)<<8|(16711680&_)>>8|_>>>24},I.decrypt=function(_,l,L){for(var m,h,T,y,c,e,a,t,s,d,n,u,p,g,v=this.keySize+6,i=this.invKeySchedule,r=this.invSBox,o=this.invSubMix,S=o[0],b=o[1],k=o[2],x=o[3],w=this.uint8ArrayToUint32Array_(L),O=w[0],P=w[1],F=w[2],M=w[3],B=new Int32Array(_),U=new Int32Array(B.length),j=this.networkToHostOrderSwap;l<B.length;){for(s=j(B[l]),d=j(B[l+1]),n=j(B[l+2]),u=j(B[l+3]),c=s^i[0],e=u^i[1],a=n^i[2],t=d^i[3],p=4,g=1;g<v;g++)m=S[c>>>24]^b[e>>16&255]^k[a>>8&255]^x[255&t]^i[p],h=S[e>>>24]^b[a>>16&255]^k[t>>8&255]^x[255&c]^i[p+1],T=S[a>>>24]^b[t>>16&255]^k[c>>8&255]^x[255&e]^i[p+2],y=S[t>>>24]^b[c>>16&255]^k[e>>8&255]^x[255&a]^i[p+3],c=m,e=h,a=T,t=y,p+=4;m=r[c>>>24]<<24^r[e>>16&255]<<16^r[a>>8&255]<<8^r[255&t]^i[p],h=r[e>>>24]<<24^r[a>>16&255]<<16^r[t>>8&255]<<8^r[255&c]^i[p+1],T=r[a>>>24]<<24^r[t>>16&255]<<16^r[c>>8&255]<<8^r[255&e]^i[p+2],y=r[t>>>24]<<24^r[c>>16&255]<<16^r[e>>8&255]<<8^r[255&a]^i[p+3],U[l]=j(m^O),U[l+1]=j(y^P),U[l+2]=j(T^F),U[l+3]=j(h^M),O=s,P=d,F=n,M=u,l+=4}return U.buffer},D}()},"./src/crypt/decrypter.ts":function(N,C,f){f.r(C),f.d(C,"default",function(){return l});var R=f("./src/crypt/aes-crypto.ts"),E=f("./src/crypt/fast-aes-key.ts"),A=f("./src/crypt/aes-decryptor.ts"),D=f("./src/utils/logger.ts"),I=f("./src/utils/mp4-tools.ts"),_=f("./src/utils/typed-array.ts"),l=function(){function L(h,T,y){var c=(y===void 0?{}:y).removePKCS7Padding,e=c===void 0||c;if(this.logEnabled=!0,this.observer=void 0,this.config=void 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.observer=h,this.config=T,this.removePKCS7Padding=e,e)try{var a=self.crypto;a&&(this.subtle=a.subtle||a.webkitSubtle)}catch{}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var m=L.prototype;return m.destroy=function(){this.observer=null},m.isSync=function(){return this.config.enableSoftwareAES},m.flush=function(){var h=this.currentResult;if(h){var T=new Uint8Array(h);return this.reset(),this.removePKCS7Padding?Object(A.removePadding)(T):T}this.reset()},m.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},m.decrypt=function(h,T,y,c){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(h),T,y);var e=this.flush();e&&c(e.buffer)}else this.webCryptoDecrypt(new Uint8Array(h),T,y).then(c)},m.softwareDecrypt=function(h,T,y){var c=this.currentIV,e=this.currentResult,a=this.remainderData;this.logOnce("JS AES decrypt"),a&&(h=Object(I.appendUint8Array)(a,h),this.remainderData=null);var t=this.getValidChunk(h);if(!t.length)return null;c&&(y=c);var s=this.softwareDecrypter;s||(s=this.softwareDecrypter=new A.default),s.expandKey(T);var d=e;return this.currentResult=s.decrypt(t.buffer,0,y),this.currentIV=Object(_.sliceUint8)(t,-16).buffer,d||null},m.webCryptoDecrypt=function(h,T,y){var c=this,e=this.subtle;return this.key===T&&this.fastAesKey||(this.key=T,this.fastAesKey=new E.default(e,T)),this.fastAesKey.expandKey().then(function(a){return e?new R.default(e,y).decrypt(h.buffer,a):Promise.reject(new Error("web crypto not initialized"))}).catch(function(a){return c.onWebCryptoError(a,h,T,y)})},m.onWebCryptoError=function(h,T,y,c){return D.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",h),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(T,y,c)},m.getValidChunk=function(h){var T=h,y=h.length-h.length%16;return y!==h.length&&(T=Object(_.sliceUint8)(h,0,y),this.remainderData=Object(_.sliceUint8)(h,y)),T},m.logOnce=function(h){this.logEnabled&&(D.logger.log("[decrypter.ts]: "+h),this.logEnabled=!1)},L}()},"./src/crypt/fast-aes-key.ts":function(N,C,f){f.r(C),f.d(C,"default",function(){return R});var R=function(){function E(A,D){this.subtle=void 0,this.key=void 0,this.subtle=A,this.key=D}return E.prototype.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},E}()},"./src/demux/aacdemuxer.ts":function(N,C,f){f.r(C);var R=f("./src/demux/base-audio-demuxer.ts"),E=f("./src/demux/adts.ts"),A=f("./src/utils/logger.ts"),D=f("./src/demux/id3.ts");function I(l,L){return(I=Object.setPrototypeOf||function(m,h){return m.__proto__=h,m})(l,L)}var _=function(l){var L,m;function h(y,c){var e;return(e=l.call(this)||this).observer=void 0,e.config=void 0,e.observer=y,e.config=c,e}m=l,(L=h).prototype=Object.create(m.prototype),L.prototype.constructor=L,I(L,m);var T=h.prototype;return T.resetInitSegment=function(y,c,e){l.prototype.resetInitSegment.call(this,y,c,e),this._audioTrack={container:"audio/adts",type:"audio",id:0,pid:-1,sequenceNumber:0,isAAC:!0,samples:[],manifestCodec:y,duration:e,inputTimeScale:9e4,dropped:0}},h.probe=function(y){if(!y)return!1;for(var c=(D.getID3Data(y,0)||[]).length,e=y.length;c<e;c++)if(E.probe(y,c))return A.logger.log("ADTS sync word found !"),!0;return!1},T.canParse=function(y,c){return E.canParse(y,c)},T.appendFrame=function(y,c,e){E.initTrackConfig(y,this.observer,c,e,y.manifestCodec);var a=E.appendFrame(y,c,e,this.initPTS,this.frameIndex);if(a&&a.missing===0)return a},h}(R.default);_.minProbeByteLength=9,C.default=_},"./src/demux/adts.ts":function(N,C,f){f.r(C),f.d(C,"getAudioConfig",function(){return D}),f.d(C,"isHeaderPattern",function(){return I}),f.d(C,"getHeaderLength",function(){return _}),f.d(C,"getFullFrameLength",function(){return l}),f.d(C,"canGetFrameLength",function(){return L}),f.d(C,"isHeader",function(){return m}),f.d(C,"canParse",function(){return h}),f.d(C,"probe",function(){return T}),f.d(C,"initTrackConfig",function(){return y}),f.d(C,"getFrameDuration",function(){return c}),f.d(C,"parseFrameHeader",function(){return e}),f.d(C,"appendFrame",function(){return a});var R=f("./src/utils/logger.ts"),E=f("./src/errors.ts"),A=f("./src/events.ts");function D(t,s,d,n){var u,p,g,v,i=navigator.userAgent.toLowerCase(),r=n,o=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];u=1+((192&s[d+2])>>>6);var S=(60&s[d+2])>>>2;if(!(S>o.length-1))return g=(1&s[d+2])<<2,g|=(192&s[d+3])>>>6,R.logger.log("manifest codec:"+n+", ADTS type:"+u+", samplingIndex:"+S),/firefox/i.test(i)?S>=6?(u=5,v=new Array(4),p=S-3):(u=2,v=new Array(2),p=S):i.indexOf("android")!==-1?(u=2,v=new Array(2),p=S):(u=5,v=new Array(4),n&&(n.indexOf("mp4a.40.29")!==-1||n.indexOf("mp4a.40.5")!==-1)||!n&&S>=6?p=S-3:((n&&n.indexOf("mp4a.40.2")!==-1&&(S>=6&&g===1||/vivaldi/i.test(i))||!n&&g===1)&&(u=2,v=new Array(2)),p=S)),v[0]=u<<3,v[0]|=(14&S)>>1,v[1]|=(1&S)<<7,v[1]|=g<<3,u===5&&(v[1]|=(14&p)>>1,v[2]=(1&p)<<7,v[2]|=8,v[3]=0),{config:v,samplerate:o[S],channelCount:g,codec:"mp4a.40."+u,manifestCodec:r};t.trigger(A.Events.ERROR,{type:E.ErrorTypes.MEDIA_ERROR,details:E.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+S})}function I(t,s){return t[s]===255&&(246&t[s+1])==240}function _(t,s){return 1&t[s+1]?7:9}function l(t,s){return(3&t[s+3])<<11|t[s+4]<<3|(224&t[s+5])>>>5}function L(t,s){return s+5<t.length}function m(t,s){return s+1<t.length&&I(t,s)}function h(t,s){return L(t,s)&&I(t,s)&&l(t,s)<=t.length-s}function T(t,s){if(m(t,s)){var d=_(t,s);if(s+d>=t.length)return!1;var n=l(t,s);if(n<=d)return!1;var u=s+n;return u===t.length||m(t,u)}return!1}function y(t,s,d,n,u){if(!t.samplerate){var p=D(s,d,n,u);if(!p)return;t.config=p.config,t.samplerate=p.samplerate,t.channelCount=p.channelCount,t.codec=p.codec,t.manifestCodec=p.manifestCodec,R.logger.log("parsed codec:"+t.codec+", rate:"+p.samplerate+", channels:"+p.channelCount)}}function c(t){return 9216e4/t}function e(t,s,d,n,u){var p=_(t,s),g=l(t,s);if((g-=p)>0)return{headerLength:p,frameLength:g,stamp:d+n*u}}function a(t,s,d,n,u){var p=e(s,d,n,u,c(t.samplerate));if(p){var g,v=p.frameLength,i=p.headerLength,r=p.stamp,o=i+v,S=Math.max(0,d+o-s.length);S?(g=new Uint8Array(o-i)).set(s.subarray(d+i,s.length),0):g=s.subarray(d+i,d+o);var b={unit:g,pts:r};return S||t.samples.push(b),{sample:b,length:o,missing:S}}}},"./src/demux/base-audio-demuxer.ts":function(N,C,f){f.r(C),f.d(C,"initPTSFn",function(){return l});var R=f("./src/polyfills/number.ts"),E=f("./src/demux/id3.ts"),A=f("./src/demux/dummy-demuxed-track.ts"),D=f("./src/utils/mp4-tools.ts"),I=f("./src/utils/typed-array.ts"),_=function(){function L(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.initPTS=null}var m=L.prototype;return m.resetInitSegment=function(h,T,y){this._id3Track={type:"id3",id:0,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},m.resetTimeStamp=function(){},m.resetContiguity=function(){},m.canParse=function(h,T){return!1},m.appendFrame=function(h,T,y){},m.demux=function(h,T){this.cachedData&&(h=Object(D.appendUint8Array)(this.cachedData,h),this.cachedData=null);var y,c,e=E.getID3Data(h,0),a=e?e.length:0,t=this._audioTrack,s=this._id3Track,d=e?E.getTimeStamp(e):void 0,n=h.length;for(this.frameIndex!==0&&this.initPTS!==null||(this.initPTS=l(d,T)),e&&e.length>0&&s.samples.push({pts:this.initPTS,dts:this.initPTS,data:e}),c=this.initPTS;a<n;){if(this.canParse(h,a)){var u=this.appendFrame(t,h,a);u?(this.frameIndex++,c=u.sample.pts,y=a+=u.length):a=n}else E.canParse(h,a)?(e=E.getID3Data(h,a),s.samples.push({pts:c,dts:c,data:e}),y=a+=e.length):a++;if(a===n&&y!==n){var p=Object(I.sliceUint8)(h,y);this.cachedData?this.cachedData=Object(D.appendUint8Array)(this.cachedData,p):this.cachedData=p}}return{audioTrack:t,avcTrack:Object(A.dummyTrack)(),id3Track:s,textTrack:Object(A.dummyTrack)()}},m.demuxSampleAes=function(h,T,y){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},m.flush=function(h){var T=this.cachedData;return T&&(this.cachedData=null,this.demux(T,0)),this.frameIndex=0,{audioTrack:this._audioTrack,avcTrack:Object(A.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(A.dummyTrack)()}},m.destroy=function(){},L}(),l=function(L,m){return Object(R.isFiniteNumber)(L)?90*L:9e4*m};C.default=_},"./src/demux/chunk-cache.ts":function(N,C,f){f.r(C),f.d(C,"default",function(){return R});var R=function(){function E(){this.chunks=[],this.dataLength=0}var A=E.prototype;return A.push=function(D){this.chunks.push(D),this.dataLength+=D.length},A.flush=function(){var D,I=this.chunks,_=this.dataLength;return I.length?(D=I.length===1?I[0]:function(l,L){for(var m=new Uint8Array(L),h=0,T=0;T<l.length;T++){var y=l[T];m.set(y,h),h+=y.length}return m}(I,_),this.reset(),D):new Uint8Array(0)},A.reset=function(){this.chunks.length=0,this.dataLength=0},E}()},"./src/demux/dummy-demuxed-track.ts":function(N,C,f){function R(){return{type:"",id:-1,pid:-1,inputTimeScale:9e4,sequenceNumber:-1,samples:[],dropped:0}}f.r(C),f.d(C,"dummyTrack",function(){return R})},"./src/demux/exp-golomb.ts":function(N,C,f){f.r(C);var R=f("./src/utils/logger.ts"),E=function(){function A(I){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=I,this.bytesAvailable=I.byteLength,this.word=0,this.bitsAvailable=0}var D=A.prototype;return D.loadWord=function(){var I=this.data,_=this.bytesAvailable,l=I.byteLength-_,L=new Uint8Array(4),m=Math.min(4,_);if(m===0)throw new Error("no bytes available");L.set(I.subarray(l,l+m)),this.word=new DataView(L.buffer).getUint32(0),this.bitsAvailable=8*m,this.bytesAvailable-=m},D.skipBits=function(I){var _;this.bitsAvailable>I?(this.word<<=I,this.bitsAvailable-=I):(I-=this.bitsAvailable,I-=(_=I>>3)>>3,this.bytesAvailable-=_,this.loadWord(),this.word<<=I,this.bitsAvailable-=I)},D.readBits=function(I){var _=Math.min(this.bitsAvailable,I),l=this.word>>>32-_;return I>32&&R.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=_,this.bitsAvailable>0?this.word<<=_:this.bytesAvailable>0&&this.loadWord(),(_=I-_)>0&&this.bitsAvailable?l<<_|this.readBits(_):l},D.skipLZ=function(){var I;for(I=0;I<this.bitsAvailable;++I)if(this.word&2147483648>>>I)return this.word<<=I,this.bitsAvailable-=I,I;return this.loadWord(),I+this.skipLZ()},D.skipUEG=function(){this.skipBits(1+this.skipLZ())},D.skipEG=function(){this.skipBits(1+this.skipLZ())},D.readUEG=function(){var I=this.skipLZ();return this.readBits(I+1)-1},D.readEG=function(){var I=this.readUEG();return 1&I?1+I>>>1:-1*(I>>>1)},D.readBoolean=function(){return this.readBits(1)===1},D.readUByte=function(){return this.readBits(8)},D.readUShort=function(){return this.readBits(16)},D.readUInt=function(){return this.readBits(32)},D.skipScalingList=function(I){for(var _=8,l=8,L=0;L<I;L++)l!==0&&(l=(_+this.readEG()+256)%256),_=l===0?_:l},D.readSPS=function(){var I,_,l,L=0,m=0,h=0,T=0,y=this.readUByte.bind(this),c=this.readBits.bind(this),e=this.readUEG.bind(this),a=this.readBoolean.bind(this),t=this.skipBits.bind(this),s=this.skipEG.bind(this),d=this.skipUEG.bind(this),n=this.skipScalingList.bind(this);y();var u=y();if(c(5),t(3),y(),d(),u===100||u===110||u===122||u===244||u===44||u===83||u===86||u===118||u===128){var p=e();if(p===3&&t(1),d(),d(),t(1),a())for(_=p!==3?8:12,l=0;l<_;l++)a()&&n(l<6?16:64)}d();var g=e();if(g===0)e();else if(g===1)for(t(1),s(),s(),I=e(),l=0;l<I;l++)s();d(),t(1);var v=e(),i=e(),r=c(1);r===0&&t(1),t(1),a()&&(L=e(),m=e(),h=e(),T=e());var o=[1,1];if(a()&&a())switch(y()){case 1:o=[1,1];break;case 2:o=[12,11];break;case 3:o=[10,11];break;case 4:o=[16,11];break;case 5:o=[40,33];break;case 6:o=[24,11];break;case 7:o=[20,11];break;case 8:o=[32,11];break;case 9:o=[80,33];break;case 10:o=[18,11];break;case 11:o=[15,11];break;case 12:o=[64,33];break;case 13:o=[160,99];break;case 14:o=[4,3];break;case 15:o=[3,2];break;case 16:o=[2,1];break;case 255:o=[y()<<8|y(),y()<<8|y()]}return{width:Math.ceil(16*(v+1)-2*L-2*m),height:(2-r)*(i+1)*16-(r?2:4)*(h+T),pixelRatio:o}},D.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},A}();C.default=E},"./src/demux/id3.ts":function(N,C,f){f.r(C),f.d(C,"isHeader",function(){return E}),f.d(C,"isFooter",function(){return A}),f.d(C,"getID3Data",function(){return D}),f.d(C,"canParse",function(){return _}),f.d(C,"getTimeStamp",function(){return l}),f.d(C,"isTimeStampFrame",function(){return L}),f.d(C,"getID3Frames",function(){return h}),f.d(C,"decodeFrame",function(){return T}),f.d(C,"utf8ArrayToStr",function(){return t}),f.d(C,"testables",function(){return s});var R,E=function(d,n){return n+10<=d.length&&d[n]===73&&d[n+1]===68&&d[n+2]===51&&d[n+3]<255&&d[n+4]<255&&d[n+6]<128&&d[n+7]<128&&d[n+8]<128&&d[n+9]<128},A=function(d,n){return n+10<=d.length&&d[n]===51&&d[n+1]===68&&d[n+2]===73&&d[n+3]<255&&d[n+4]<255&&d[n+6]<128&&d[n+7]<128&&d[n+8]<128&&d[n+9]<128},D=function(d,n){for(var u=n,p=0;E(d,n);)p+=10,p+=I(d,n+6),A(d,n+10)&&(p+=10),n+=p;if(p>0)return d.subarray(u,u+p)},I=function(d,n){var u=0;return u=(127&d[n])<<21,u|=(127&d[n+1])<<14,u|=(127&d[n+2])<<7,u|=127&d[n+3]},_=function(d,n){return E(d,n)&&I(d,n+6)+10<=d.length-n},l=function(d){for(var n=h(d),u=0;u<n.length;u++){var p=n[u];if(L(p))return a(p)}},L=function(d){return d&&d.key==="PRIV"&&d.info==="com.apple.streaming.transportStreamTimestamp"},m=function(d){var n=String.fromCharCode(d[0],d[1],d[2],d[3]),u=I(d,4);return{type:n,size:u,data:d.subarray(10,10+u)}},h=function(d){for(var n=0,u=[];E(d,n);){for(var p=I(d,n+6),g=(n+=10)+p;n+8<g;){var v=m(d.subarray(n)),i=T(v);i&&u.push(i),n+=v.size+10}A(d,n)&&(n+=10)}return u},T=function(d){return d.type==="PRIV"?y(d):d.type[0]==="W"?e(d):c(d)},y=function(d){if(!(d.size<2)){var n=t(d.data,!0),u=new Uint8Array(d.data.subarray(n.length+1));return{key:d.type,info:n,data:u.buffer}}},c=function(d){if(!(d.size<2)){if(d.type==="TXXX"){var n=1,u=t(d.data.subarray(n),!0);n+=u.length+1;var p=t(d.data.subarray(n));return{key:d.type,info:u,data:p}}var g=t(d.data.subarray(1));return{key:d.type,data:g}}},e=function(d){if(d.type==="WXXX"){if(d.size<2)return;var n=1,u=t(d.data.subarray(n),!0);n+=u.length+1;var p=t(d.data.subarray(n));return{key:d.type,info:u,data:p}}var g=t(d.data);return{key:d.type,data:g}},a=function(d){if(d.data.byteLength===8){var n=new Uint8Array(d.data),u=1&n[3],p=(n[4]<<23)+(n[5]<<15)+(n[6]<<7)+n[7];return p/=45,u&&(p+=4772185884e-2),Math.round(p)}},t=function(d,n){n===void 0&&(n=!1);var u=(R||self.TextDecoder===void 0||(R=new self.TextDecoder("utf-8")),R);if(u){var p=u.decode(d);if(n){var g=p.indexOf("\0");return g!==-1?p.substring(0,g):p}return p.replace(/\0/g,"")}for(var v,i,r,o=d.length,S="",b=0;b<o;){if((v=d[b++])===0&&n)return S;if(v!==0&&v!==3)switch(v>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:S+=String.fromCharCode(v);break;case 12:case 13:i=d[b++],S+=String.fromCharCode((31&v)<<6|63&i);break;case 14:i=d[b++],r=d[b++],S+=String.fromCharCode((15&v)<<12|(63&i)<<6|(63&r)<<0)}}return S},s={decodeTextFrame:c}},"./src/demux/mp3demuxer.ts":function(N,C,f){f.r(C);var R=f("./src/demux/base-audio-demuxer.ts"),E=f("./src/demux/id3.ts"),A=f("./src/utils/logger.ts"),D=f("./src/demux/mpegaudio.ts");function I(l,L){return(I=Object.setPrototypeOf||function(m,h){return m.__proto__=h,m})(l,L)}var _=function(l){var L,m;function h(){return l.apply(this,arguments)||this}m=l,(L=h).prototype=Object.create(m.prototype),L.prototype.constructor=L,I(L,m);var T=h.prototype;return T.resetInitSegment=function(y,c,e){l.prototype.resetInitSegment.call(this,y,c,e),this._audioTrack={container:"audio/mpeg",type:"audio",id:0,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:y,duration:e,inputTimeScale:9e4,dropped:0}},h.probe=function(y){if(!y)return!1;for(var c=(E.getID3Data(y,0)||[]).length,e=y.length;c<e;c++)if(D.probe(y,c))return A.logger.log("MPEG Audio sync word found !"),!0;return!1},T.canParse=function(y,c){return D.canParse(y,c)},T.appendFrame=function(y,c,e){if(this.initPTS!==null)return D.appendFrame(y,c,e,this.initPTS,this.frameIndex)},h}(R.default);_.minProbeByteLength=4,C.default=_},"./src/demux/mp4demuxer.ts":function(N,C,f){f.r(C);var R=f("./src/utils/mp4-tools.ts"),E=f("./src/demux/dummy-demuxed-track.ts"),A=function(){function D(_,l){this.remainderData=null,this.config=void 0,this.config=l}var I=D.prototype;return I.resetTimeStamp=function(){},I.resetInitSegment=function(){},I.resetContiguity=function(){},D.probe=function(_){return Object(R.findBox)({data:_,start:0,end:Math.min(_.length,16384)},["moof"]).length>0},I.demux=function(_){var l=_,L=Object(E.dummyTrack)();if(this.config.progressive){this.remainderData&&(l=Object(R.appendUint8Array)(this.remainderData,_));var m=Object(R.segmentValidRange)(l);this.remainderData=m.remainder,L.samples=m.valid||new Uint8Array}else L.samples=l;return{audioTrack:Object(E.dummyTrack)(),avcTrack:L,id3Track:Object(E.dummyTrack)(),textTrack:Object(E.dummyTrack)()}},I.flush=function(){var _=Object(E.dummyTrack)();return _.samples=this.remainderData||new Uint8Array,this.remainderData=null,{audioTrack:Object(E.dummyTrack)(),avcTrack:_,id3Track:Object(E.dummyTrack)(),textTrack:Object(E.dummyTrack)()}},I.demuxSampleAes=function(_,l,L){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},I.destroy=function(){},D}();A.minProbeByteLength=1024,C.default=A},"./src/demux/mpegaudio.ts":function(N,C,f){f.r(C),f.d(C,"appendFrame",function(){return _}),f.d(C,"parseHeader",function(){return l}),f.d(C,"isHeaderPattern",function(){return L}),f.d(C,"isHeader",function(){return m}),f.d(C,"canParse",function(){return h}),f.d(C,"probe",function(){return T});var R=null,E=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],A=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],D=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],I=[0,1,1,4];function _(y,c,e,a,t){if(!(e+24>c.length)){var s=l(c,e);if(s&&e+s.frameLength<=c.length){var d=a+t*(9e4*s.samplesPerFrame/s.sampleRate),n={unit:c.subarray(e,e+s.frameLength),pts:d,dts:d};return y.config=[],y.channelCount=s.channelCount,y.samplerate=s.sampleRate,y.samples.push(n),{sample:n,length:s.frameLength,missing:0}}}}function l(y,c){var e=y[c+1]>>3&3,a=y[c+1]>>1&3,t=y[c+2]>>4&15,s=y[c+2]>>2&3;if(e!==1&&t!==0&&t!==15&&s!==3){var d=y[c+2]>>1&1,n=y[c+3]>>6,u=1e3*E[14*(e===3?3-a:a===3?3:4)+t-1],p=A[3*(e===3?0:e===2?1:2)+s],g=n===3?1:2,v=D[e][a],i=I[a],r=8*v*i,o=Math.floor(v*u/p+d)*i;if(R===null){var S=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);R=S?parseInt(S[1]):0}return R&&R<=87&&a===2&&u>=224e3&&n===0&&(y[c+3]=128|y[c+3]),{sampleRate:p,channelCount:g,frameLength:o,samplesPerFrame:r}}}function L(y,c){return y[c]===255&&(224&y[c+1])==224&&(6&y[c+1])!=0}function m(y,c){return c+1<y.length&&L(y,c)}function h(y,c){return L(y,c)&&4<=y.length-c}function T(y,c){if(c+1<y.length&&L(y,c)){var e=l(y,c),a=4;e!=null&&e.frameLength&&(a=e.frameLength);var t=c+a;return t===y.length||m(y,t)}return!1}},"./src/demux/sample-aes.ts":function(N,C,f){f.r(C);var R=f("./src/crypt/decrypter.ts"),E=f("./src/demux/tsdemuxer.ts"),A=function(){function D(_,l,L){this.keyData=void 0,this.decrypter=void 0,this.keyData=L,this.decrypter=new R.default(_,l,{removePKCS7Padding:!1})}var I=D.prototype;return I.decryptBuffer=function(_,l){this.decrypter.decrypt(_,this.keyData.key.buffer,this.keyData.iv.buffer,l)},I.decryptAacSample=function(_,l,L,m){var h=_[l].unit,T=h.subarray(16,h.length-h.length%16),y=T.buffer.slice(T.byteOffset,T.byteOffset+T.length),c=this;this.decryptBuffer(y,function(e){var a=new Uint8Array(e);h.set(a,16),m||c.decryptAacSamples(_,l+1,L)})},I.decryptAacSamples=function(_,l,L){for(;;l++){if(l>=_.length)return void L();if(!(_[l].unit.length<32)){var m=this.decrypter.isSync();if(this.decryptAacSample(_,l,L,m),!m)return}}},I.getAvcEncryptedData=function(_){for(var l=16*Math.floor((_.length-48)/160)+16,L=new Int8Array(l),m=0,h=32;h<=_.length-16;h+=160,m+=16)L.set(_.subarray(h,h+16),m);return L},I.getAvcDecryptedUnit=function(_,l){for(var L=new Uint8Array(l),m=0,h=32;h<=_.length-16;h+=160,m+=16)_.set(L.subarray(m,m+16),h);return _},I.decryptAvcSample=function(_,l,L,m,h,T){var y=Object(E.discardEPB)(h.data),c=this.getAvcEncryptedData(y),e=this;this.decryptBuffer(c.buffer,function(a){h.data=e.getAvcDecryptedUnit(y,a),T||e.decryptAvcSamples(_,l,L+1,m)})},I.decryptAvcSamples=function(_,l,L,m){if(_ instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;l++,L=0){if(l>=_.length)return void m();for(var h=_[l].units;!(L>=h.length);L++){var T=h[L];if(!(T.data.length<=48||T.type!==1&&T.type!==5)){var y=this.decrypter.isSync();if(this.decryptAvcSample(_,l,L,m,T,y),!y)return}}}},D}();C.default=A},"./src/demux/transmuxer-interface.ts":function(N,C,f){f.r(C),f.d(C,"default",function(){return m});var R=f("./node_modules/webworkify-webpack/index.js"),E=f("./src/events.ts"),A=f("./src/demux/transmuxer.ts"),D=f("./src/utils/logger.ts"),I=f("./src/errors.ts"),_=f("./src/utils/mediasource-helper.ts"),l=f("./node_modules/eventemitter3/index.js"),L=Object(_.getMediaSource)()||{isTypeSupported:function(){return!1}},m=function(){function h(y,c,e,a){var t=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.hls=y,this.id=c,this.onTransmuxComplete=e,this.onFlush=a;var s=y.config,d=function(g,v){(v=v||{}).frag=t.frag,v.id=t.id,y.trigger(g,v)};this.observer=new l.EventEmitter,this.observer.on(E.Events.FRAG_DECRYPTED,d),this.observer.on(E.Events.ERROR,d);var n={mp4:L.isTypeSupported("video/mp4"),mpeg:L.isTypeSupported("audio/mpeg"),mp3:L.isTypeSupported('audio/mp4; codecs="mp3"')},u=navigator.vendor;if(s.enableWorker&&typeof Worker<"u"){var p;D.logger.log("demuxing in webworker");try{p=this.worker=R("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),p.addEventListener("message",this.onwmsg),p.onerror=function(g){y.trigger(E.Events.ERROR,{type:I.ErrorTypes.OTHER_ERROR,details:I.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(g.message+" ("+g.filename+":"+g.lineno+")")})},p.postMessage({cmd:"init",typeSupported:n,vendor:u,id:c,config:JSON.stringify(s)})}catch(g){D.logger.warn("Error in worker:",g),D.logger.error("Error while initializing DemuxerWorker, fallback to inline"),p&&self.URL.revokeObjectURL(p.objectURL),this.transmuxer=new A.default(this.observer,n,s,u,c),this.worker=null}}else this.transmuxer=new A.default(this.observer,n,s,u,c)}var T=h.prototype;return T.destroy=function(){var y=this.worker;if(y)y.removeEventListener("message",this.onwmsg),y.terminate(),this.worker=null;else{var c=this.transmuxer;c&&(c.destroy(),this.transmuxer=null)}var e=this.observer;e&&e.removeAllListeners(),this.observer=null},T.push=function(y,c,e,a,t,s,d,n,u,p){var g=this;u.transmuxing.start=self.performance.now();var v=this.transmuxer,i=this.worker,r=s?s.start:t.start,o=t.decryptdata,S=this.frag,b=!(S&&t.cc===S.cc),k=!(S&&u.level===S.level),x=S?u.sn-S.sn:-1,w=this.part?u.part-this.part.index:1,O=!k&&(x===1||x===0&&w===1),P=self.performance.now();(k||x||t.stats.parsing.start===0)&&(t.stats.parsing.start=P),!s||!w&&O||(s.stats.parsing.start=P);var F=new A.TransmuxState(b,O,n,k,r);if(!O||b){D.logger.log("[transmuxer-interface, "+t.type+"]: Starting new transmux session for sn: "+u.sn+" p: "+u.part+" level: "+u.level+" id: "+u.id+`
|
||
discontinuity: `+b+`
|
||
trackSwitch: `+k+`
|
||
contiguous: `+O+`
|
||
accurateTimeOffset: `+n+`
|
||
timeOffset: `+r);var M=new A.TransmuxConfig(e,a,c,d,p);this.configureTransmuxer(M)}if(this.frag=t,this.part=s,i)i.postMessage({cmd:"demux",data:y,decryptdata:o,chunkMeta:u,state:F},y instanceof ArrayBuffer?[y]:[]);else if(v){var B=v.push(y,o,u,F);Object(A.isPromise)(B)?B.then(function(U){g.handleTransmuxComplete(U)}):this.handleTransmuxComplete(B)}},T.flush=function(y){var c=this;y.transmuxing.start=self.performance.now();var e=this.transmuxer,a=this.worker;if(a)a.postMessage({cmd:"flush",chunkMeta:y});else if(e){var t=e.flush(y);Object(A.isPromise)(t)?t.then(function(s){c.handleFlushResult(s,y)}):this.handleFlushResult(t,y)}},T.handleFlushResult=function(y,c){var e=this;y.forEach(function(a){e.handleTransmuxComplete(a)}),this.onFlush(c)},T.onWorkerMessage=function(y){var c=y.data,e=this.hls;switch(c.event){case"init":self.URL.revokeObjectURL(this.worker.objectURL);break;case"transmuxComplete":this.handleTransmuxComplete(c.data);break;case"flush":this.onFlush(c.data);break;default:c.data=c.data||{},c.data.frag=this.frag,c.data.id=this.id,e.trigger(c.event,c.data)}},T.configureTransmuxer=function(y){var c=this.worker,e=this.transmuxer;c?c.postMessage({cmd:"configure",config:y}):e&&e.configure(y)},T.handleTransmuxComplete=function(y){y.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(y)},h}()},"./src/demux/transmuxer-worker.ts":function(N,C,f){f.r(C),f.d(C,"default",function(){return I});var R=f("./src/demux/transmuxer.ts"),E=f("./src/events.ts"),A=f("./src/utils/logger.ts"),D=f("./node_modules/eventemitter3/index.js");function I(m){var h=new D.EventEmitter,T=function(y,c){m.postMessage({event:y,data:c})};h.on(E.Events.FRAG_DECRYPTED,T),h.on(E.Events.ERROR,T),m.addEventListener("message",function(y){var c=y.data;switch(c.cmd){case"init":var e=JSON.parse(c.config);m.transmuxer=new R.default(h,c.typeSupported,e,c.vendor,c.id),Object(A.enableLogs)(e.debug),T("init",null);break;case"configure":m.transmuxer.configure(c.config);break;case"demux":var a=m.transmuxer.push(c.data,c.decryptdata,c.chunkMeta,c.state);Object(R.isPromise)(a)?a.then(function(d){_(m,d)}):_(m,a);break;case"flush":var t=c.chunkMeta,s=m.transmuxer.flush(t);Object(R.isPromise)(s)?s.then(function(d){L(m,d,t)}):L(m,s,t)}})}function _(m,h){if((T=h.remuxResult).audio||T.video||T.text||T.id3||T.initSegment){var T,y=[],c=h.remuxResult,e=c.audio,a=c.video;e&&l(y,e),a&&l(y,a),m.postMessage({event:"transmuxComplete",data:h},y)}}function l(m,h){h.data1&&m.push(h.data1.buffer),h.data2&&m.push(h.data2.buffer)}function L(m,h,T){h.forEach(function(y){_(m,y)}),m.postMessage({event:"flush",data:T})}},"./src/demux/transmuxer.ts":function(N,C,f){f.r(C),f.d(C,"default",function(){return t}),f.d(C,"isPromise",function(){return d}),f.d(C,"TransmuxConfig",function(){return n}),f.d(C,"TransmuxState",function(){return u});var R,E=f("./src/events.ts"),A=f("./src/errors.ts"),D=f("./src/crypt/decrypter.ts"),I=f("./src/demux/aacdemuxer.ts"),_=f("./src/demux/mp4demuxer.ts"),l=f("./src/demux/tsdemuxer.ts"),L=f("./src/demux/mp3demuxer.ts"),m=f("./src/remux/mp4-remuxer.ts"),h=f("./src/remux/passthrough-remuxer.ts"),T=f("./src/demux/chunk-cache.ts"),y=f("./src/utils/mp4-tools.ts"),c=f("./src/utils/logger.ts");try{R=self.performance.now.bind(self.performance)}catch{c.logger.debug("Unable to use Performance API on this environment"),R=self.Date.now}var e=[{demux:l.default,remux:m.default},{demux:_.default,remux:h.default},{demux:I.default,remux:m.default},{demux:L.default,remux:m.default}],a=1024;e.forEach(function(p){var g=p.demux;a=Math.max(a,g.minProbeByteLength)});var t=function(){function p(v,i,r,o,S){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.cache=new T.default,this.observer=v,this.typeSupported=i,this.config=r,this.vendor=o,this.id=S}var g=p.prototype;return g.configure=function(v){this.transmuxConfig=v,this.decrypter&&this.decrypter.reset()},g.push=function(v,i,r,o){var S=this,b=r.transmuxing;b.executeStart=R();var k=new Uint8Array(v),x=this.cache,w=this.config,O=this.currentTransmuxState,P=this.transmuxConfig;o&&(this.currentTransmuxState=o);var F=function(Y,ee){var le=null;return Y.byteLength>0&&ee!=null&&ee.key!=null&&ee.iv!==null&&ee.method!=null&&(le=ee),le}(k,i);if(F&&F.method==="AES-128"){var M=this.getDecrypter();if(!w.enableSoftwareAES)return this.decryptionPromise=M.webCryptoDecrypt(k,F.key.buffer,F.iv.buffer).then(function(Y){var ee=S.push(Y,null,r);return S.decryptionPromise=null,ee}),this.decryptionPromise;var B=M.softwareDecrypt(k,F.key.buffer,F.iv.buffer);if(!B)return b.executeEnd=R(),s(r);k=new Uint8Array(B)}var U=o||O,j=U.contiguous,V=U.discontinuity,H=U.trackSwitch,z=U.accurateTimeOffset,W=U.timeOffset,X=P.audioCodec,ne=P.videoCodec,se=P.defaultInitPts,oe=P.duration,te=P.initSegmentData;if((V||H)&&this.resetInitSegment(te,X,ne,oe),V&&this.resetInitialTimestamp(se),j||this.resetContiguity(),this.needsProbing(k,V,H)){if(x.dataLength){var de=x.flush();k=Object(y.appendUint8Array)(de,k)}this.configureTransmuxer(k,P)}var re=this.transmux(k,F,W,z,r),ae=this.currentTransmuxState;return ae.contiguous=!0,ae.discontinuity=!1,ae.trackSwitch=!1,b.executeEnd=R(),re},g.flush=function(v){var i=this,r=v.transmuxing;r.executeStart=R();var o=this.decrypter,S=this.cache,b=this.currentTransmuxState,k=this.decryptionPromise;if(k)return k.then(function(){return i.flush(v)});var x=[],w=b.timeOffset;if(o){var O=o.flush();O&&x.push(this.push(O,null,v))}var P=S.dataLength;S.reset();var F=this.demuxer,M=this.remuxer;if(!F||!M)return P>=a&&this.observer.emit(E.Events.ERROR,E.Events.ERROR,{type:A.ErrorTypes.MEDIA_ERROR,details:A.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),r.executeEnd=R(),[s(v)];var B=F.flush(w);return d(B)?B.then(function(U){return i.flushRemux(x,U,v),x}):(this.flushRemux(x,B,v),x)},g.flushRemux=function(v,i,r){var o=i.audioTrack,S=i.avcTrack,b=i.id3Track,k=i.textTrack,x=this.currentTransmuxState,w=x.accurateTimeOffset,O=x.timeOffset;c.logger.log("[transmuxer.ts]: Flushed fragment "+r.sn+(r.part>-1?" p: "+r.part:"")+" of level "+r.level);var P=this.remuxer.remux(o,S,b,k,O,w,!0,this.id);v.push({remuxResult:P,chunkMeta:r}),r.transmuxing.executeEnd=R()},g.resetInitialTimestamp=function(v){var i=this.demuxer,r=this.remuxer;i&&r&&(i.resetTimeStamp(v),r.resetTimeStamp(v))},g.resetContiguity=function(){var v=this.demuxer,i=this.remuxer;v&&i&&(v.resetContiguity(),i.resetNextTimestamp())},g.resetInitSegment=function(v,i,r,o){var S=this.demuxer,b=this.remuxer;S&&b&&(S.resetInitSegment(i,r,o),b.resetInitSegment(v,i,r))},g.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},g.transmux=function(v,i,r,o,S){return i&&i.method==="SAMPLE-AES"?this.transmuxSampleAes(v,i,r,o,S):this.transmuxUnencrypted(v,r,o,S)},g.transmuxUnencrypted=function(v,i,r,o){var S=this.demuxer.demux(v,i,!1,!this.config.progressive),b=S.audioTrack,k=S.avcTrack,x=S.id3Track,w=S.textTrack;return{remuxResult:this.remuxer.remux(b,k,x,w,i,r,!1,this.id),chunkMeta:o}},g.transmuxSampleAes=function(v,i,r,o,S){var b=this;return this.demuxer.demuxSampleAes(v,i,r).then(function(k){return{remuxResult:b.remuxer.remux(k.audioTrack,k.avcTrack,k.id3Track,k.textTrack,r,o,!1,b.id),chunkMeta:S}})},g.configureTransmuxer=function(v,i){for(var r,o=this.config,S=this.observer,b=this.typeSupported,k=this.vendor,x=i.audioCodec,w=i.defaultInitPts,O=i.duration,P=i.initSegmentData,F=i.videoCodec,M=0,B=e.length;M<B;M++)if(e[M].demux.probe(v)){r=e[M];break}r||(c.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),r={demux:_.default,remux:h.default});var U=this.demuxer,j=this.remuxer,V=r.remux,H=r.demux;j&&j instanceof V||(this.remuxer=new V(S,o,b,k)),U&&U instanceof H||(this.demuxer=new H(S,o,b),this.probe=H.probe),this.resetInitSegment(P,x,F,O),this.resetInitialTimestamp(w)},g.needsProbing=function(v,i,r){return!this.demuxer||!this.remuxer||i||r},g.getDecrypter=function(){var v=this.decrypter;return v||(v=this.decrypter=new D.default(this.observer,this.config)),v},p}(),s=function(p){return{remuxResult:{},chunkMeta:p}};function d(p){return"then"in p&&p.then instanceof Function}var n=function(p,g,v,i,r){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=p,this.videoCodec=g,this.initSegmentData=v,this.duration=i,this.defaultInitPts=r},u=function(p,g,v,i,r){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.discontinuity=p,this.contiguous=g,this.accurateTimeOffset=v,this.trackSwitch=i,this.timeOffset=r}},"./src/demux/tsdemuxer.ts":function(N,C,f){f.r(C),f.d(C,"discardEPB",function(){return d});var R=f("./src/demux/adts.ts"),E=f("./src/demux/mpegaudio.ts"),A=f("./src/demux/exp-golomb.ts"),D=f("./src/demux/id3.ts"),I=f("./src/demux/sample-aes.ts"),_=f("./src/events.ts"),l=f("./src/utils/mp4-tools.ts"),L=f("./src/utils/logger.ts"),m=f("./src/errors.ts"),h={video:1,audio:2,id3:3,text:4},T=function(){function n(p,g,v){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.aacLastPTS=null,this._initPTS=null,this._initDTS=null,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=p,this.config=g,this.typeSupported=v}n.probe=function(p){var g=n.syncOffset(p);return!(g<0||(g&&L.logger.warn("MPEG2-TS detected but first sync word found @ offset "+g+", junk ahead ?"),0))},n.syncOffset=function(p){for(var g=Math.min(1e3,p.length-564),v=0;v<g;){if(p[v]===71&&p[v+188]===71&&p[v+376]===71)return v;v++}return-1},n.createTrack=function(p,g){return{container:p==="video"||p==="audio"?"video/mp2t":void 0,type:p,id:h[p],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:p==="audio"?g:void 0}};var u=n.prototype;return u.resetInitSegment=function(p,g,v){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=n.createTrack("video",v),this._audioTrack=n.createTrack("audio",v),this._id3Track=n.createTrack("id3",v),this._txtTrack=n.createTrack("text",v),this._audioTrack.isAAC=!0,this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=p,this.videoCodec=g,this._duration=v},u.resetTimeStamp=function(){},u.resetContiguity=function(){var p=this._audioTrack,g=this._avcTrack,v=this._id3Track;p&&(p.pesData=null),g&&(g.pesData=null),v&&(v.pesData=null),this.aacOverFlow=null,this.aacLastPTS=null},u.demux=function(p,g,v,i){var r;v===void 0&&(v=!1),i===void 0&&(i=!1),v||(this.sampleAes=null);var o=this._avcTrack,S=this._audioTrack,b=this._id3Track,k=o.pid,x=o.pesData,w=S.pid,O=b.pid,P=S.pesData,F=b.pesData,M=!1,B=this.pmtParsed,U=this._pmtId,j=p.length;if(this.remainderData&&(j=(p=Object(l.appendUint8Array)(this.remainderData,p)).length,this.remainderData=null),j<188&&!i)return this.remainderData=p,{audioTrack:S,avcTrack:o,id3Track:b,textTrack:this._txtTrack};var V=Math.max(0,n.syncOffset(p));(j-=(j+V)%188)<p.byteLength&&!i&&(this.remainderData=new Uint8Array(p.buffer,j,p.buffer.byteLength-j));for(var H=V;H<j;H+=188)if(p[H]===71){var z=!!(64&p[H+1]),W=((31&p[H+1])<<8)+p[H+2],X=void 0;if((48&p[H+3])>>4>1){if((X=H+5+p[H+4])===H+188)continue}else X=H+4;switch(W){case k:z&&(x&&(r=a(x))&&this.parseAVCPES(r,!1),x={data:[],size:0}),x&&(x.data.push(p.subarray(X,H+188)),x.size+=H+188-X);break;case w:z&&(P&&(r=a(P))&&(S.isAAC?this.parseAACPES(r):this.parseMPEGPES(r)),P={data:[],size:0}),P&&(P.data.push(p.subarray(X,H+188)),P.size+=H+188-X);break;case O:z&&(F&&(r=a(F))&&this.parseID3PES(r),F={data:[],size:0}),F&&(F.data.push(p.subarray(X,H+188)),F.size+=H+188-X);break;case 0:z&&(X+=p[X]+1),U=this._pmtId=c(p,X);break;case U:z&&(X+=p[X]+1);var ne=e(p,X,this.typeSupported.mpeg===!0||this.typeSupported.mp3===!0,v);(k=ne.avc)>0&&(o.pid=k),(w=ne.audio)>0&&(S.pid=w,S.isAAC=ne.isAAC),(O=ne.id3)>0&&(b.pid=O),M&&!B&&(L.logger.log("reparse from beginning"),M=!1,H=V-188),B=this.pmtParsed=!0;break;case 17:case 8191:break;default:M=!0}}else this.observer.emit(_.Events.ERROR,_.Events.ERROR,{type:m.ErrorTypes.MEDIA_ERROR,details:m.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});o.pesData=x,S.pesData=P,b.pesData=F;var se={audioTrack:S,avcTrack:o,id3Track:b,textTrack:this._txtTrack};return i&&this.extractRemainingSamples(se),se},u.flush=function(){var p,g=this.remainderData;return this.remainderData=null,p=g?this.demux(g,-1,!1,!0):{audioTrack:this._audioTrack,avcTrack:this._avcTrack,textTrack:this._txtTrack,id3Track:this._id3Track},this.extractRemainingSamples(p),this.sampleAes?this.decrypt(p,this.sampleAes):p},u.extractRemainingSamples=function(p){var g,v=p.audioTrack,i=p.avcTrack,r=p.id3Track,o=i.pesData,S=v.pesData,b=r.pesData;o&&(g=a(o))?(this.parseAVCPES(g,!0),i.pesData=null):i.pesData=o,S&&(g=a(S))?(v.isAAC?this.parseAACPES(g):this.parseMPEGPES(g),v.pesData=null):(S!=null&&S.size&&L.logger.log("last AAC PES packet truncated,might overlap between fragments"),v.pesData=S),b&&(g=a(b))?(this.parseID3PES(g),r.pesData=null):r.pesData=b},u.demuxSampleAes=function(p,g,v){var i=this.demux(p,v,!0,!this.config.progressive),r=this.sampleAes=new I.default(this.observer,this.config,g);return this.decrypt(i,r)},u.decrypt=function(p,g){return new Promise(function(v){var i=p.audioTrack,r=p.avcTrack;i.samples&&i.isAAC?g.decryptAacSamples(i.samples,0,function(){r.samples?g.decryptAvcSamples(r.samples,0,0,function(){v(p)}):v(p)}):r.samples&&g.decryptAvcSamples(r.samples,0,0,function(){v(p)})})},u.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},u.parseAVCPES=function(p,g){var v,i=this,r=this._avcTrack,o=this.parseAVCNALu(p.data),S=this.avcSample,b=!1;p.data=null,S&&o.length&&!r.audFound&&(t(S,r),S=this.avcSample=y(!1,p.pts,p.dts,"")),o.forEach(function(k){switch(k.type){case 1:v=!0,S||(S=i.avcSample=y(!0,p.pts,p.dts,"")),S.frame=!0;var x=k.data;if(b&&x.length>4){var w=new A.default(x).readSliceType();w!==2&&w!==4&&w!==7&&w!==9||(S.key=!0)}break;case 5:v=!0,S||(S=i.avcSample=y(!0,p.pts,p.dts,"")),S.key=!0,S.frame=!0;break;case 6:v=!0;var O=new A.default(d(k.data));O.readUByte();for(var P=0,F=0,M=!1,B=0;!M&&O.bytesAvailable>1;){P=0;do P+=B=O.readUByte();while(B===255);F=0;do F+=B=O.readUByte();while(B===255);if(P===4&&O.bytesAvailable!==0){if(M=!0,O.readUByte()===181&&O.readUShort()===49&&O.readUInt()===1195456820&&O.readUByte()===3){for(var U=O.readUByte(),j=31&U,V=[U,O.readUByte()],H=0;H<j;H++)V.push(O.readUByte()),V.push(O.readUByte()),V.push(O.readUByte());s(i._txtTrack.samples,{type:3,pts:p.pts,bytes:V})}}else if(P===5&&O.bytesAvailable!==0){if(M=!0,F>16){for(var z=[],W=0;W<16;W++)z.push(O.readUByte().toString(16)),W!==3&&W!==5&&W!==7&&W!==9||z.push("-");for(var X=F-16,ne=new Uint8Array(X),se=0;se<X;se++)ne[se]=O.readUByte();s(i._txtTrack.samples,{pts:p.pts,payloadType:P,uuid:z.join(""),userData:Object(D.utf8ArrayToStr)(ne),userDataBytes:ne})}}else if(F<O.bytesAvailable)for(var oe=0;oe<F;oe++)O.readUByte()}break;case 7:if(v=!0,b=!0,!r.sps){var te=new A.default(k.data).readSPS();r.width=te.width,r.height=te.height,r.pixelRatio=te.pixelRatio,r.sps=[k.data],r.duration=i._duration;for(var de=k.data.subarray(1,4),re="avc1.",ae=0;ae<3;ae++){var Y=de[ae].toString(16);Y.length<2&&(Y="0"+Y),re+=Y}r.codec=re}break;case 8:v=!0,r.pps||(r.pps=[k.data]);break;case 9:v=!1,r.audFound=!0,S&&t(S,r),S=i.avcSample=y(!1,p.pts,p.dts,"");break;case 12:v=!1;break;default:v=!1,S&&(S.debug+="unknown NAL "+k.type+" ")}S&&v&&S.units.push(k)}),g&&S&&(t(S,r),this.avcSample=null)},u.getLastNalUnit=function(){var p,g,v=this.avcSample;if(!v||v.units.length===0){var i=this._avcTrack.samples;v=i[i.length-1]}if((p=v)!==null&&p!==void 0&&p.units){var r=v.units;g=r[r.length-1]}return g},u.parseAVCNALu=function(p){var g,v,i=p.byteLength,r=this._avcTrack,o=r.naluState||0,S=o,b=[],k=0,x=-1,w=0;for(o===-1&&(x=0,w=31&p[0],o=0,k=1);k<i;)if(g=p[k++],o)if(o!==1)if(g)if(g===1){if(x>=0){var O={data:p.subarray(x,k-o-1),type:w};b.push(O)}else{var P=this.getLastNalUnit();if(P&&(S&&k<=4-S&&P.state&&(P.data=P.data.subarray(0,P.data.byteLength-S)),(v=k-o-1)>0)){var F=new Uint8Array(P.data.byteLength+v);F.set(P.data,0),F.set(p.subarray(0,v),P.data.byteLength),P.data=F}}k<i?(x=k,w=31&p[k],o=0):o=-1}else o=0;else o=3;else o=g?0:2;else o=g?0:1;if(x>=0&&o>=0){var M={data:p.subarray(x,i),type:w,state:o};b.push(M)}if(b.length===0){var B=this.getLastNalUnit();if(B){var U=new Uint8Array(B.data.byteLength+p.byteLength);U.set(B.data,0),U.set(p,B.data.byteLength),B.data=U}}return r.naluState=o,b},u.parseAACPES=function(p){var g,v,i,r,o,S=0,b=this._audioTrack,k=this.aacOverFlow,x=p.data;if(k){this.aacOverFlow=null;var w=k.sample.unit.byteLength,O=Math.min(k.missing,w),P=w-O;k.sample.unit.set(x.subarray(0,O),P),b.samples.push(k.sample),S=k.missing}for(g=S,v=x.length;g<v-1&&!R.isHeader(x,g);g++);if(g===S||(g<v-1?(i="AAC PES did not start with ADTS header,offset:"+g,r=!1):(i="no ADTS header found in AAC PES",r=!0),L.logger.warn("parsing error:"+i),this.observer.emit(_.Events.ERROR,_.Events.ERROR,{type:m.ErrorTypes.MEDIA_ERROR,details:m.ErrorDetails.FRAG_PARSING_ERROR,fatal:r,reason:i}),!r)){if(R.initTrackConfig(b,this.observer,x,g,this.audioCodec),p.pts!==void 0)o=p.pts;else{if(!k)return void L.logger.warn("[tsdemuxer]: AAC PES unknown PTS");var F=R.getFrameDuration(b.samplerate);o=k.sample.pts+F}for(var M=0;g<v;){if(R.isHeader(x,g)){if(g+5<v){var B=R.appendFrame(b,x,g,o,M);if(B){if(!B.missing){g+=B.length,M++;continue}this.aacOverFlow=B}}break}g++}}},u.parseMPEGPES=function(p){var g=p.data,v=g.length,i=0,r=0,o=p.pts;if(o!==void 0)for(;r<v;)if(E.isHeader(g,r)){var S=E.appendFrame(this._audioTrack,g,r,o,i);if(!S)break;r+=S.length,i++}else r++;else L.logger.warn("[tsdemuxer]: MPEG PES unknown PTS")},u.parseID3PES=function(p){p.pts!==void 0?this._id3Track.samples.push(p):L.logger.warn("[tsdemuxer]: ID3 PES unknown PTS")},n}();function y(n,u,p,g){return{key:n,frame:!1,pts:u,dts:p,units:[],debug:g,length:0}}function c(n,u){return(31&n[u+10])<<8|n[u+11]}function e(n,u,p,g){var v={audio:-1,avc:-1,id3:-1,isAAC:!0},i=u+3+((15&n[u+1])<<8|n[u+2])-4;for(u+=12+((15&n[u+10])<<8|n[u+11]);u<i;){var r=(31&n[u+1])<<8|n[u+2];switch(n[u]){case 207:if(!g){L.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:v.audio===-1&&(v.audio=r);break;case 21:v.id3===-1&&(v.id3=r);break;case 219:if(!g){L.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:v.avc===-1&&(v.avc=r);break;case 3:case 4:p?v.audio===-1&&(v.audio=r,v.isAAC=!1):L.logger.log("MPEG audio found, not supported in this browser");break;case 36:L.logger.warn("Unsupported HEVC stream type found")}u+=5+((15&n[u+3])<<8|n[u+4])}return v}function a(n){var u,p,g,v,i,r=0,o=n.data;if(!n||n.size===0)return null;for(;o[0].length<19&&o.length>1;){var S=new Uint8Array(o[0].length+o[1].length);S.set(o[0]),S.set(o[1],o[0].length),o[0]=S,o.splice(1,1)}if(((u=o[0])[0]<<16)+(u[1]<<8)+u[2]===1){if((p=(u[4]<<8)+u[5])&&p>n.size-6)return null;var b=u[7];192&b&&(v=536870912*(14&u[9])+4194304*(255&u[10])+16384*(254&u[11])+128*(255&u[12])+(254&u[13])/2,64&b?v-(i=536870912*(14&u[14])+4194304*(255&u[15])+16384*(254&u[16])+128*(255&u[17])+(254&u[18])/2)>54e5&&(L.logger.warn(Math.round((v-i)/9e4)+"s delta between PTS and DTS, align them"),v=i):i=v);var k=(g=u[8])+9;if(n.size<=k)return null;n.size-=k;for(var x=new Uint8Array(n.size),w=0,O=o.length;w<O;w++){var P=(u=o[w]).byteLength;if(k){if(k>P){k-=P;continue}u=u.subarray(k),P-=k,k=0}x.set(u,r),r+=P}return p&&(p-=g+3),{data:x,pts:v,dts:i,len:p}}return null}function t(n,u){if(n.units.length&&n.frame){if(n.pts===void 0){var p=u.samples,g=p.length;if(!g)return void u.dropped++;var v=p[g-1];n.pts=v.pts,n.dts=v.dts}u.samples.push(n)}n.debug.length&&L.logger.log(n.pts+"/"+n.dts+":"+n.debug)}function s(n,u){var p=n.length;if(p>0){if(u.pts>=n[p-1].pts)n.push(u);else for(var g=p-1;g>=0;g--)if(u.pts<n[g].pts){n.splice(g,0,u);break}}else n.push(u)}function d(n){for(var u=n.byteLength,p=[],g=1;g<u-2;)n[g]===0&&n[g+1]===0&&n[g+2]===3?(p.push(g+2),g+=2):g++;if(p.length===0)return n;var v=u-p.length,i=new Uint8Array(v),r=0;for(g=0;g<v;r++,g++)r===p[0]&&(r++,p.shift()),i[g]=n[r];return i}T.minProbeByteLength=188,C.default=T},"./src/errors.ts":function(N,C,f){var R,E,A,D;f.r(C),f.d(C,"ErrorTypes",function(){return R}),f.d(C,"ErrorDetails",function(){return A}),(E=R||(R={})).NETWORK_ERROR="networkError",E.MEDIA_ERROR="mediaError",E.KEY_SYSTEM_ERROR="keySystemError",E.MUX_ERROR="muxError",E.OTHER_ERROR="otherError",(D=A||(A={})).KEY_SYSTEM_NO_KEYS="keySystemNoKeys",D.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",D.KEY_SYSTEM_NO_SESSION="keySystemNoSession",D.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",D.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",D.MANIFEST_LOAD_ERROR="manifestLoadError",D.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",D.MANIFEST_PARSING_ERROR="manifestParsingError",D.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",D.LEVEL_EMPTY_ERROR="levelEmptyError",D.LEVEL_LOAD_ERROR="levelLoadError",D.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",D.LEVEL_SWITCH_ERROR="levelSwitchError",D.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",D.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",D.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",D.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",D.FRAG_LOAD_ERROR="fragLoadError",D.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",D.FRAG_DECRYPT_ERROR="fragDecryptError",D.FRAG_PARSING_ERROR="fragParsingError",D.REMUX_ALLOC_ERROR="remuxAllocError",D.KEY_LOAD_ERROR="keyLoadError",D.KEY_LOAD_TIMEOUT="keyLoadTimeOut",D.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",D.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",D.BUFFER_APPEND_ERROR="bufferAppendError",D.BUFFER_APPENDING_ERROR="bufferAppendingError",D.BUFFER_STALLED_ERROR="bufferStalledError",D.BUFFER_FULL_ERROR="bufferFullError",D.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",D.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",D.INTERNAL_EXCEPTION="internalException",D.INTERNAL_ABORTED="aborted",D.UNKNOWN="unknown"},"./src/events.ts":function(N,C,f){var R,E;f.r(C),f.d(C,"Events",function(){return R}),(E=R||(R={})).MEDIA_ATTACHING="hlsMediaAttaching",E.MEDIA_ATTACHED="hlsMediaAttached",E.MEDIA_DETACHING="hlsMediaDetaching",E.MEDIA_DETACHED="hlsMediaDetached",E.BUFFER_RESET="hlsBufferReset",E.BUFFER_CODECS="hlsBufferCodecs",E.BUFFER_CREATED="hlsBufferCreated",E.BUFFER_APPENDING="hlsBufferAppending",E.BUFFER_APPENDED="hlsBufferAppended",E.BUFFER_EOS="hlsBufferEos",E.BUFFER_FLUSHING="hlsBufferFlushing",E.BUFFER_FLUSHED="hlsBufferFlushed",E.MANIFEST_LOADING="hlsManifestLoading",E.MANIFEST_LOADED="hlsManifestLoaded",E.MANIFEST_PARSED="hlsManifestParsed",E.LEVEL_SWITCHING="hlsLevelSwitching",E.LEVEL_SWITCHED="hlsLevelSwitched",E.LEVEL_LOADING="hlsLevelLoading",E.LEVEL_LOADED="hlsLevelLoaded",E.LEVEL_UPDATED="hlsLevelUpdated",E.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",E.LEVELS_UPDATED="hlsLevelsUpdated",E.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",E.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",E.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",E.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",E.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",E.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",E.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",E.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",E.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",E.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",E.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",E.CUES_PARSED="hlsCuesParsed",E.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",E.INIT_PTS_FOUND="hlsInitPtsFound",E.FRAG_LOADING="hlsFragLoading",E.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",E.FRAG_LOADED="hlsFragLoaded",E.FRAG_DECRYPTED="hlsFragDecrypted",E.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",E.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",E.FRAG_PARSING_METADATA="hlsFragParsingMetadata",E.FRAG_PARSED="hlsFragParsed",E.FRAG_BUFFERED="hlsFragBuffered",E.FRAG_CHANGED="hlsFragChanged",E.FPS_DROP="hlsFpsDrop",E.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",E.ERROR="hlsError",E.DESTROYING="hlsDestroying",E.KEY_LOADING="hlsKeyLoading",E.KEY_LOADED="hlsKeyLoaded",E.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",E.BACK_BUFFER_REACHED="hlsBackBufferReached"},"./src/hls.ts":function(N,C,f){f.r(C),f.d(C,"default",function(){return t});var R=f("./node_modules/url-toolkit/src/url-toolkit.js"),E=f("./src/loader/playlist-loader.ts"),A=f("./src/loader/key-loader.ts"),D=f("./src/controller/id3-track-controller.ts"),I=f("./src/controller/latency-controller.ts"),_=f("./src/controller/level-controller.ts"),l=f("./src/controller/fragment-tracker.ts"),L=f("./src/controller/stream-controller.ts"),m=f("./src/is-supported.ts"),h=f("./src/utils/logger.ts"),T=f("./src/config.ts"),y=f("./node_modules/eventemitter3/index.js"),c=f("./src/events.ts"),e=f("./src/errors.ts");function a(s,d){for(var n=0;n<d.length;n++){var u=d[n];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(s,u.key,u)}}var t=function(){function s(g){g===void 0&&(g={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new y.EventEmitter,this._autoLevelCapping=void 0,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._media=null,this.url=null;var v=this.config=Object(T.mergeConfig)(s.DefaultConfig,g);this.userConfig=g,Object(h.enableLogs)(v.debug),this._autoLevelCapping=-1,v.progressive&&Object(T.enableStreamingMode)(v);var i=v.abrController,r=v.bufferController,o=v.capLevelController,S=v.fpsController,b=this.abrController=new i(this),k=this.bufferController=new r(this),x=this.capLevelController=new o(this),w=new S(this),O=new E.default(this),P=new A.default(this),F=new D.default(this),M=this.levelController=new _.default(this),B=new l.FragmentTracker(this),U=this.streamController=new L.default(this,B);x.setStreamController(U),w.setStreamController(U);var j=[M,U];this.networkControllers=j;var V=[O,P,b,k,x,w,F,B];this.audioTrackController=this.createController(v.audioTrackController,null,j),this.createController(v.audioStreamController,B,j),this.subtitleTrackController=this.createController(v.subtitleTrackController,null,j),this.createController(v.subtitleStreamController,B,j),this.createController(v.timelineController,null,V),this.emeController=this.createController(v.emeController,null,V),this.latencyController=this.createController(I.default,null,V),this.coreComponents=V}s.isSupported=function(){return Object(m.isSupported)()};var d,n,u,p=s.prototype;return p.createController=function(g,v,i){if(g){var r=v?new g(this,v):new g(this);return i&&i.push(r),r}return null},p.on=function(g,v,i){i===void 0&&(i=this),this._emitter.on(g,v,i)},p.once=function(g,v,i){i===void 0&&(i=this),this._emitter.once(g,v,i)},p.removeAllListeners=function(g){this._emitter.removeAllListeners(g)},p.off=function(g,v,i,r){i===void 0&&(i=this),this._emitter.off(g,v,i,r)},p.listeners=function(g){return this._emitter.listeners(g)},p.emit=function(g,v,i){return this._emitter.emit(g,v,i)},p.trigger=function(g,v){if(this.config.debug)return this.emit(g,g,v);try{return this.emit(g,g,v)}catch(i){h.logger.error("An internal error happened while handling event "+g+'. Error message: "'+i.message+'". Here is a stacktrace:',i),this.trigger(c.Events.ERROR,{type:e.ErrorTypes.OTHER_ERROR,details:e.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:g,error:i})}return!1},p.listenerCount=function(g){return this._emitter.listenerCount(g)},p.destroy=function(){h.logger.log("destroy"),this.trigger(c.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(g){return g.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(g){return g.destroy()}),this.coreComponents.length=0},p.attachMedia=function(g){h.logger.log("attachMedia"),this._media=g,this.trigger(c.Events.MEDIA_ATTACHING,{media:g})},p.detachMedia=function(){h.logger.log("detachMedia"),this.trigger(c.Events.MEDIA_DETACHING,void 0),this._media=null},p.loadSource=function(g){this.stopLoad();var v=this.media,i=this.url,r=this.url=R.buildAbsoluteURL(self.location.href,g,{alwaysNormalize:!0});h.logger.log("loadSource:"+r),v&&i&&i!==r&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(v)),this.trigger(c.Events.MANIFEST_LOADING,{url:g})},p.startLoad=function(g){g===void 0&&(g=-1),h.logger.log("startLoad("+g+")"),this.networkControllers.forEach(function(v){v.startLoad(g)})},p.stopLoad=function(){h.logger.log("stopLoad"),this.networkControllers.forEach(function(g){g.stopLoad()})},p.swapAudioCodec=function(){h.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},p.recoverMediaError=function(){h.logger.log("recoverMediaError");var g=this._media;this.detachMedia(),g&&this.attachMedia(g)},p.removeLevel=function(g,v){v===void 0&&(v=0),this.levelController.removeLevel(g,v)},d=s,u=[{key:"version",get:function(){return"1.0.10"}},{key:"Events",get:function(){return c.Events}},{key:"ErrorTypes",get:function(){return e.ErrorTypes}},{key:"ErrorDetails",get:function(){return e.ErrorDetails}},{key:"DefaultConfig",get:function(){return s.defaultConfig?s.defaultConfig:T.hlsDefaultConfig},set:function(g){s.defaultConfig=g}}],(n=[{key:"levels",get:function(){var g=this.levelController.levels;return g||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(g){h.logger.log("set currentLevel:"+g),this.loadLevel=g,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(g){h.logger.log("set nextLevel:"+g),this.levelController.manualLevel=g,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(g){h.logger.log("set loadLevel:"+g),this.levelController.manualLevel=g}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(g){this.levelController.nextLoadLevel=g}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(g){h.logger.log("set firstLevel:"+g),this.levelController.firstLevel=g}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(g){h.logger.log("set startLevel:"+g),g!==-1&&(g=Math.max(g,this.minAutoLevel)),this.levelController.startLevel=g}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(g){var v=!!g;v!==this.config.capLevelToPlayerSize&&(v?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=v)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(g){this._autoLevelCapping!==g&&(h.logger.log("set autoLevelCapping:"+g),this._autoLevelCapping=g)}},{key:"bandwidthEstimate",get:function(){var g=this.abrController.bwEstimator;return g?g.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var g=this.levels,v=this.config.minAutoBitrate;if(!g)return 0;for(var i=g.length,r=0;r<i;r++)if(g[r].maxBitrate>v)return r;return 0}},{key:"maxAutoLevel",get:function(){var g=this.levels,v=this.autoLevelCapping;return v===-1&&g&&g.length?g.length-1:v}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(g){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,g)}},{key:"audioTracks",get:function(){var g=this.audioTrackController;return g?g.audioTracks:[]}},{key:"audioTrack",get:function(){var g=this.audioTrackController;return g?g.audioTrack:-1},set:function(g){var v=this.audioTrackController;v&&(v.audioTrack=g)}},{key:"subtitleTracks",get:function(){var g=this.subtitleTrackController;return g?g.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var g=this.subtitleTrackController;return g?g.subtitleTrack:-1},set:function(g){var v=this.subtitleTrackController;v&&(v.subtitleTrack=g)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var g=this.subtitleTrackController;return!!g&&g.subtitleDisplay},set:function(g){var v=this.subtitleTrackController;v&&(v.subtitleDisplay=g)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(g){this.config.lowLatencyMode=g}},{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}}])&&a(d.prototype,n),u&&a(d,u),s}();t.defaultConfig=void 0},"./src/is-supported.ts":function(N,C,f){f.r(C),f.d(C,"isSupported",function(){return A}),f.d(C,"changeTypeSupported",function(){return D});var R=f("./src/utils/mediasource-helper.ts");function E(){return self.SourceBuffer||self.WebKitSourceBuffer}function A(){var I=Object(R.getMediaSource)();if(!I)return!1;var _=E(),l=I&&typeof I.isTypeSupported=="function"&&I.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),L=!_||_.prototype&&typeof _.prototype.appendBuffer=="function"&&typeof _.prototype.remove=="function";return!!l&&!!L}function D(){var I,_=E();return typeof(_==null||(I=_.prototype)===null||I===void 0?void 0:I.changeType)=="function"}},"./src/loader/fragment-loader.ts":function(N,C,f){f.r(C),f.d(C,"default",function(){return m}),f.d(C,"LoadError",function(){return T});var R=f("./src/polyfills/number.ts"),E=f("./src/errors.ts");function A(y){var c=typeof Map=="function"?new Map:void 0;return(A=function(e){if(e===null||(a=e,Function.toString.call(a).indexOf("[native code]")===-1))return e;var a;if(typeof e!="function")throw new TypeError("Super expression must either be null or a function");if(c!==void 0){if(c.has(e))return c.get(e);c.set(e,t)}function t(){return D(e,arguments,l(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),_(t,e)})(y)}function D(y,c,e){return(D=I()?Reflect.construct:function(a,t,s){var d=[null];d.push.apply(d,t);var n=new(Function.bind.apply(a,d));return s&&_(n,s.prototype),n}).apply(null,arguments)}function I(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function _(y,c){return(_=Object.setPrototypeOf||function(e,a){return e.__proto__=a,e})(y,c)}function l(y){return(l=Object.setPrototypeOf?Object.getPrototypeOf:function(c){return c.__proto__||Object.getPrototypeOf(c)})(y)}var L=Math.pow(2,17),m=function(){function y(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}var c=y.prototype;return c.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},c.abort=function(){this.loader&&this.loader.abort()},c.load=function(e,a){var t=this,s=e.url;if(!s)return Promise.reject(new T({type:E.ErrorTypes.NETWORK_ERROR,details:E.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,networkDetails:null},"Fragment does not have a "+(s?"part list":"url")));this.abort();var d=this.config,n=d.fLoader,u=d.loader;return new Promise(function(p,g){t.loader&&t.loader.destroy();var v=t.loader=e.loader=n?new n(d):new u(d),i=h(e),r={timeout:d.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:d.fragLoadingMaxRetryTimeout,highWaterMark:L};e.stats=v.stats,v.load(i,r,{onSuccess:function(o,S,b,k){t.resetLoader(e,v),p({frag:e,part:null,payload:o.data,networkDetails:k})},onError:function(o,S,b){t.resetLoader(e,v),g(new T({type:E.ErrorTypes.NETWORK_ERROR,details:E.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:o,networkDetails:b}))},onAbort:function(o,S,b){t.resetLoader(e,v),g(new T({type:E.ErrorTypes.NETWORK_ERROR,details:E.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:e,networkDetails:b}))},onTimeout:function(o,S,b){t.resetLoader(e,v),g(new T({type:E.ErrorTypes.NETWORK_ERROR,details:E.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,networkDetails:b}))},onProgress:function(o,S,b,k){a&&a({frag:e,part:null,payload:b,networkDetails:k})}})})},c.loadPart=function(e,a,t){var s=this;this.abort();var d=this.config,n=d.fLoader,u=d.loader;return new Promise(function(p,g){s.loader&&s.loader.destroy();var v=s.loader=e.loader=n?new n(d):new u(d),i=h(e,a),r={timeout:d.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:d.fragLoadingMaxRetryTimeout,highWaterMark:L};a.stats=v.stats,v.load(i,r,{onSuccess:function(o,S,b,k){s.resetLoader(e,v),s.updateStatsFromPart(e,a);var x={frag:e,part:a,payload:o.data,networkDetails:k};t(x),p(x)},onError:function(o,S,b){s.resetLoader(e,v),g(new T({type:E.ErrorTypes.NETWORK_ERROR,details:E.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:a,response:o,networkDetails:b}))},onAbort:function(o,S,b){e.stats.aborted=a.stats.aborted,s.resetLoader(e,v),g(new T({type:E.ErrorTypes.NETWORK_ERROR,details:E.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:e,part:a,networkDetails:b}))},onTimeout:function(o,S,b){s.resetLoader(e,v),g(new T({type:E.ErrorTypes.NETWORK_ERROR,details:E.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:a,networkDetails:b}))}})})},c.updateStatsFromPart=function(e,a){var t=e.stats,s=a.stats,d=s.total;if(t.loaded+=s.loaded,d){var n=Math.round(e.duration/a.duration),u=Math.min(Math.round(t.loaded/d),n),p=(n-u)*Math.round(t.loaded/u);t.total=t.loaded+p}else t.total=Math.max(t.loaded,t.total);var g=t.loading,v=s.loading;g.start?g.first+=v.first-v.start:(g.start=v.start,g.first=v.first),g.end=v.end},c.resetLoader=function(e,a){e.loader=null,this.loader===a&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),a.destroy()},y}();function h(y,c){c===void 0&&(c=null);var e=c||y,a={frag:y,part:c,responseType:"arraybuffer",url:e.url,rangeStart:0,rangeEnd:0},t=e.byteRangeStartOffset,s=e.byteRangeEndOffset;return Object(R.isFiniteNumber)(t)&&Object(R.isFiniteNumber)(s)&&(a.rangeStart=t,a.rangeEnd=s),a}var T=function(y){var c,e;function a(t){for(var s,d=arguments.length,n=new Array(d>1?d-1:0),u=1;u<d;u++)n[u-1]=arguments[u];return(s=y.call.apply(y,[this].concat(n))||this).data=void 0,s.data=t,s}return e=y,(c=a).prototype=Object.create(e.prototype),c.prototype.constructor=c,_(c,e),a}(A(Error))},"./src/loader/fragment.ts":function(N,C,f){f.r(C),f.d(C,"ElementaryStreamTypes",function(){return R}),f.d(C,"BaseSegment",function(){return y}),f.d(C,"Fragment",function(){return c}),f.d(C,"Part",function(){return e});var R,E,A=f("./src/polyfills/number.ts"),D=f("./node_modules/url-toolkit/src/url-toolkit.js"),I=f("./src/utils/logger.ts"),_=f("./src/loader/level-key.ts"),l=f("./src/loader/load-stats.ts");function L(a,t){a.prototype=Object.create(t.prototype),a.prototype.constructor=a,m(a,t)}function m(a,t){return(m=Object.setPrototypeOf||function(s,d){return s.__proto__=d,s})(a,t)}function h(a,t){for(var s=0;s<t.length;s++){var d=t[s];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}function T(a,t,s){return t&&h(a.prototype,t),s&&h(a,s),a}(E=R||(R={})).AUDIO="audio",E.VIDEO="video",E.AUDIOVIDEO="audiovideo";var y=function(){function a(t){var s;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((s={})[R.AUDIO]=null,s[R.VIDEO]=null,s[R.AUDIOVIDEO]=null,s),this.baseurl=t}return a.prototype.setByteRange=function(t,s){var d=t.split("@",2),n=[];d.length===1?n[0]=s?s.byteRangeEndOffset:0:n[0]=parseInt(d[1]),n[1]=parseInt(d[0])+n[0],this._byteRange=n},T(a,[{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=Object(D.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(t){this._url=t}}]),a}(),c=function(a){function t(d,n){var u;return(u=a.call(this,n)||this)._decryptdata=null,u.rawProgramDateTime=null,u.programDateTime=null,u.tagList=[],u.duration=0,u.sn=0,u.levelkey=void 0,u.type=void 0,u.loader=null,u.level=-1,u.cc=0,u.startPTS=void 0,u.endPTS=void 0,u.appendedPTS=void 0,u.startDTS=void 0,u.endDTS=void 0,u.start=0,u.deltaPTS=void 0,u.maxStartPTS=void 0,u.minEndPTS=void 0,u.stats=new l.LoadStats,u.urlId=0,u.data=void 0,u.bitrateTest=!1,u.title=null,u.initSegment=null,u.type=d,u}L(t,a);var s=t.prototype;return s.createInitializationVector=function(d){for(var n=new Uint8Array(16),u=12;u<16;u++)n[u]=d>>8*(15-u)&255;return n},s.setDecryptDataFromLevelKey=function(d,n){var u=d;return(d==null?void 0:d.method)==="AES-128"&&d.uri&&!d.iv&&((u=_.LevelKey.fromURI(d.uri)).method=d.method,u.iv=this.createInitializationVector(n),u.keyFormat="identity"),u},s.setElementaryStreamInfo=function(d,n,u,p,g,v){v===void 0&&(v=!1);var i=this.elementaryStreams,r=i[d];r?(r.startPTS=Math.min(r.startPTS,n),r.endPTS=Math.max(r.endPTS,u),r.startDTS=Math.min(r.startDTS,p),r.endDTS=Math.max(r.endDTS,g)):i[d]={startPTS:n,endPTS:u,startDTS:p,endDTS:g,partial:v}},s.clearElementaryStreamInfo=function(){var d=this.elementaryStreams;d[R.AUDIO]=null,d[R.VIDEO]=null,d[R.AUDIOVIDEO]=null},T(t,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var d=this.sn;typeof d!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&I.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),d=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,d)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null||!Object(A.isFiniteNumber)(this.programDateTime))return null;var d=Object(A.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+1e3*d}},{key:"encrypted",get:function(){var d;return!((d=this.decryptdata)===null||d===void 0||!d.keyFormat||!this.decryptdata.uri)}}]),t}(y),e=function(a){function t(s,d,n,u,p){var g;(g=a.call(this,n)||this).fragOffset=0,g.duration=0,g.gap=!1,g.independent=!1,g.relurl=void 0,g.fragment=void 0,g.index=void 0,g.stats=new l.LoadStats,g.duration=s.decimalFloatingPoint("DURATION"),g.gap=s.bool("GAP"),g.independent=s.bool("INDEPENDENT"),g.relurl=s.enumeratedString("URI"),g.fragment=d,g.index=u;var v=s.enumeratedString("BYTERANGE");return v&&g.setByteRange(v,p),p&&(g.fragOffset=p.fragOffset+p.duration),g}return L(t,a),T(t,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var s=this.elementaryStreams;return!!(s.audio||s.video||s.audiovideo)}}]),t}(y)},"./src/loader/key-loader.ts":function(N,C,f){f.r(C),f.d(C,"default",function(){return D});var R=f("./src/events.ts"),E=f("./src/errors.ts"),A=f("./src/utils/logger.ts"),D=function(){function I(l){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=l,this._registerListeners()}var _=I.prototype;return _._registerListeners=function(){this.hls.on(R.Events.KEY_LOADING,this.onKeyLoading,this)},_._unregisterListeners=function(){this.hls.off(R.Events.KEY_LOADING,this.onKeyLoading)},_.destroy=function(){for(var l in this._unregisterListeners(),this.loaders){var L=this.loaders[l];L&&L.destroy()}this.loaders={}},_.onKeyLoading=function(l,L){var m=L.frag,h=m.type,T=this.loaders[h];if(m.decryptdata){var y=m.decryptdata.uri;if(y!==this.decrypturl||this.decryptkey===null){var c=this.hls.config;if(T&&(A.logger.warn("abort previous key loader for type:"+h),T.abort()),!y)return void A.logger.warn("key uri is falsy");var e=c.loader,a=m.loader=this.loaders[h]=new e(c);this.decrypturl=y,this.decryptkey=null;var t={url:y,frag:m,responseType:"arraybuffer"},s={timeout:c.fragLoadingTimeOut,maxRetry:0,retryDelay:c.fragLoadingRetryDelay,maxRetryDelay:c.fragLoadingMaxRetryTimeout,highWaterMark:0},d={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};a.load(t,s,d)}else this.decryptkey&&(m.decryptdata.key=this.decryptkey,this.hls.trigger(R.Events.KEY_LOADED,{frag:m}))}else A.logger.warn("Missing decryption data on fragment in onKeyLoading")},_.loadsuccess=function(l,L,m){var h=m.frag;h.decryptdata?(this.decryptkey=h.decryptdata.key=new Uint8Array(l.data),h.loader=null,delete this.loaders[h.type],this.hls.trigger(R.Events.KEY_LOADED,{frag:h})):A.logger.error("after key load, decryptdata unset")},_.loaderror=function(l,L){var m=L.frag,h=m.loader;h&&h.abort(),delete this.loaders[m.type],this.hls.trigger(R.Events.ERROR,{type:E.ErrorTypes.NETWORK_ERROR,details:E.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:m,response:l})},_.loadtimeout=function(l,L){var m=L.frag,h=m.loader;h&&h.abort(),delete this.loaders[m.type],this.hls.trigger(R.Events.ERROR,{type:E.ErrorTypes.NETWORK_ERROR,details:E.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:m})},I}()},"./src/loader/level-details.ts":function(N,C,f){f.r(C),f.d(C,"LevelDetails",function(){return A});var R=f("./src/polyfills/number.ts");function E(D,I){for(var _=0;_<I.length;_++){var l=I[_];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(D,l.key,l)}}var A=function(){function D(l){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.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.needSidxRanges=!1,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.fragments=[],this.url=l}var I,_;return D.prototype.reloaded=function(l){if(!l)return this.advanced=!0,void(this.updated=!0);var L=this.lastPartSn-l.lastPartSn,m=this.lastPartIndex-l.lastPartIndex;this.updated=this.endSN!==l.endSN||!!m||!!L,this.advanced=this.endSN>l.endSN||L>0||L===0&&m>0,this.updated||this.advanced?this.misses=Math.floor(.6*l.misses):this.misses=l.misses+1,this.availabilityDelay=l.availabilityDelay},I=D,(_=[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&Object(R.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var l=this.driftEndTime-this.driftStartTime;return l>0?1e3*(this.driftEnd-this.driftStart)/l:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var l;return(l=this.partList)!==null&&l!==void 0&&l.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var l;return(l=this.fragments)!==null&&l!==void 0&&l.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 l;return(l=this.partList)!==null&&l!==void 0&&l.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var l;return(l=this.partList)!==null&&l!==void 0&&l.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}])&&E(I.prototype,_),D}()},"./src/loader/level-key.ts":function(N,C,f){f.r(C),f.d(C,"LevelKey",function(){return A});var R=f("./node_modules/url-toolkit/src/url-toolkit.js");function E(D,I){for(var _=0;_<I.length;_++){var l=I[_];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(D,l.key,l)}}var A=function(){function D(l,L){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,this._uri=L?Object(R.buildAbsoluteURL)(l,L,{alwaysNormalize:!0}):l}var I,_;return D.fromURL=function(l,L){return new D(l,L)},D.fromURI=function(l){return new D(l)},I=D,(_=[{key:"uri",get:function(){return this._uri}}])&&E(I.prototype,_),D}()},"./src/loader/load-stats.ts":function(N,C,f){f.r(C),f.d(C,"LoadStats",function(){return R});var R=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":function(N,C,f){f.r(C),f.d(C,"default",function(){return e});var R=f("./src/polyfills/number.ts"),E=f("./node_modules/url-toolkit/src/url-toolkit.js"),A=f("./src/loader/fragment.ts"),D=f("./src/loader/level-details.ts"),I=f("./src/loader/level-key.ts"),_=f("./src/utils/attr-list.ts"),l=f("./src/utils/logger.ts"),L=f("./src/utils/codecs.ts"),m=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,h=/#EXT-X-MEDIA:(.*)/g,T=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),y=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(PLAYLIST-TYPE):(.+)/.source,/#EXT-X-(MEDIA-SEQUENCE): *(\d+)/.source,/#EXT-X-(SKIP):(.+)/.source,/#EXT-X-(TARGETDURATION): *(\d+)/.source,/#EXT-X-(KEY):(.+)/.source,/#EXT-X-(START):(.+)/.source,/#EXT-X-(ENDLIST)/.source,/#EXT-X-(DISCONTINUITY-SEQ)UENCE: *(\d+)/.source,/#EXT-X-(DIS)CONTINUITY/.source,/#EXT-X-(VERSION):(\d+)/.source,/#EXT-X-(MAP):(.+)/.source,/#EXT-X-(SERVER-CONTROL):(.+)/.source,/#EXT-X-(PART-INF):(.+)/.source,/#EXT-X-(GAP)/.source,/#EXT-X-(BITRATE):\s*(\d+)/.source,/#EXT-X-(PART):(.+)/.source,/#EXT-X-(PRELOAD-HINT):(.+)/.source,/#EXT-X-(RENDITION-REPORT):(.+)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),c=/\.(mp4|m4s|m4v|m4a)$/i,e=function(){function d(){}return d.findGroup=function(n,u){for(var p=0;p<n.length;p++){var g=n[p];if(g.id===u)return g}},d.convertAVC1ToAVCOTI=function(n){var u=n.split(".");if(u.length>2){var p=u.shift()+".";return p+=parseInt(u.shift()).toString(16),p+=("000"+parseInt(u.shift()).toString(16)).substr(-4)}return n},d.resolve=function(n,u){return E.buildAbsoluteURL(u,n,{alwaysNormalize:!0})},d.parseMasterPlaylist=function(n,u){var p,g=[],v={},i=!1;for(m.lastIndex=0;(p=m.exec(n))!=null;)if(p[1]){var r=new _.AttrList(p[1]),o={attrs:r,bitrate:r.decimalInteger("AVERAGE-BANDWIDTH")||r.decimalInteger("BANDWIDTH"),name:r.NAME,url:d.resolve(p[2],u)},S=r.decimalResolution("RESOLUTION");S&&(o.width=S.width,o.height=S.height),a((r.CODECS||"").split(/[ ,]+/).filter(function(k){return k}),o),o.videoCodec&&o.videoCodec.indexOf("avc1")!==-1&&(o.videoCodec=d.convertAVC1ToAVCOTI(o.videoCodec)),g.push(o)}else if(p[3]){var b=new _.AttrList(p[3]);b["DATA-ID"]&&(i=!0,v[b["DATA-ID"]]=b)}return{levels:g,sessionData:i?v:null}},d.parseMasterPlaylistMedia=function(n,u,p,g){var v;g===void 0&&(g=[]);var i=[],r=0;for(h.lastIndex=0;(v=h.exec(n))!==null;){var o=new _.AttrList(v[1]);if(o.TYPE===p){var S={attrs:o,bitrate:0,id:r++,groupId:o["GROUP-ID"],instreamId:o["INSTREAM-ID"],name:o.NAME||o.LANGUAGE||"",type:p,default:o.bool("DEFAULT"),autoselect:o.bool("AUTOSELECT"),forced:o.bool("FORCED"),lang:o.LANGUAGE,url:o.URI?d.resolve(o.URI,u):""};if(g.length){var b=d.findGroup(g,S.groupId)||g[0];t(S,b,"audioCodec"),t(S,b,"textCodec")}i.push(S)}}return i},d.parseLevelPlaylist=function(n,u,p,g,v){var i,r,o,S=new D.LevelDetails(u),b=S.fragments,k=null,x=0,w=0,O=0,P=0,F=null,M=new A.Fragment(g,u),B=-1,U=!1;for(T.lastIndex=0,S.m3u8=n;(i=T.exec(n))!==null;){U&&(U=!1,(M=new A.Fragment(g,u)).start=O,M.sn=x,M.cc=P,M.level=p,k&&(M.initSegment=k,M.rawProgramDateTime=k.rawProgramDateTime));var j=i[1];if(j){M.duration=parseFloat(j);var V=(" "+i[2]).slice(1);M.title=V||null,M.tagList.push(V?["INF",j,V]:["INF",j])}else if(i[3])Object(R.isFiniteNumber)(M.duration)&&(M.start=O,o&&(M.levelkey=o),M.sn=x,M.level=p,M.cc=P,M.urlId=v,b.push(M),M.relurl=(" "+i[3]).slice(1),s(M,F),F=M,O+=M.duration,x++,w=0,U=!0);else if(i[4]){var H=(" "+i[4]).slice(1);F?M.setByteRange(H,F):M.setByteRange(H)}else if(i[5])M.rawProgramDateTime=(" "+i[5]).slice(1),M.tagList.push(["PROGRAM-DATE-TIME",M.rawProgramDateTime]),B===-1&&(B=b.length);else{if(!(i=i[0].match(y))){l.logger.warn("No matches on slow regex match for level playlist!");continue}for(r=1;r<i.length&&i[r]===void 0;r++);var z=(" "+i[r]).slice(1),W=(" "+i[r+1]).slice(1),X=i[r+2]?(" "+i[r+2]).slice(1):"";switch(z){case"PLAYLIST-TYPE":S.type=W.toUpperCase();break;case"MEDIA-SEQUENCE":x=S.startSN=parseInt(W);break;case"SKIP":var ne=new _.AttrList(W),se=ne.decimalInteger("SKIPPED-SEGMENTS");if(Object(R.isFiniteNumber)(se)){S.skippedSegments=se;for(var oe=se;oe--;)b.unshift(null);x+=se}var te=ne.enumeratedString("RECENTLY-REMOVED-DATERANGES");te&&(S.recentlyRemovedDateranges=te.split(" "));break;case"TARGETDURATION":S.targetduration=parseFloat(W);break;case"VERSION":S.version=parseInt(W);break;case"EXTM3U":break;case"ENDLIST":S.live=!1;break;case"#":(W||X)&&M.tagList.push(X?[W,X]:[W]);break;case"DIS":P++;case"GAP":M.tagList.push([z]);break;case"BITRATE":M.tagList.push([z,W]);break;case"DISCONTINUITY-SEQ":P=parseInt(W);break;case"KEY":var de,re=new _.AttrList(W),ae=re.enumeratedString("METHOD"),Y=re.URI,ee=re.hexadecimalInteger("IV"),le=re.enumeratedString("KEYFORMATVERSIONS"),ye=re.enumeratedString("KEYID"),Ee=(de=re.enumeratedString("KEYFORMAT"))!=null?de:"identity";if(["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"].indexOf(Ee)>-1){l.logger.warn("Keyformat "+Ee+" is not supported from the manifest");continue}if(Ee!=="identity")continue;ae&&(o=I.LevelKey.fromURL(u,Y),Y&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(ae)>=0&&(o.method=ae,o.keyFormat=Ee,ye&&(o.keyID=ye),le&&(o.keyFormatVersions=le),o.iv=ee));break;case"START":var Le=new _.AttrList(W).decimalFloatingPoint("TIME-OFFSET");Object(R.isFiniteNumber)(Le)&&(S.startTimeOffset=Le);break;case"MAP":var fe=new _.AttrList(W);M.relurl=fe.URI,fe.BYTERANGE&&M.setByteRange(fe.BYTERANGE),M.level=p,M.sn="initSegment",o&&(M.levelkey=o),M.initSegment=null,k=M,U=!0;break;case"SERVER-CONTROL":var he=new _.AttrList(W);S.canBlockReload=he.bool("CAN-BLOCK-RELOAD"),S.canSkipUntil=he.optionalFloat("CAN-SKIP-UNTIL",0),S.canSkipDateRanges=S.canSkipUntil>0&&he.bool("CAN-SKIP-DATERANGES"),S.partHoldBack=he.optionalFloat("PART-HOLD-BACK",0),S.holdBack=he.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var He=new _.AttrList(W);S.partTarget=He.decimalFloatingPoint("PART-TARGET");break;case"PART":var Ae=S.partList;Ae||(Ae=S.partList=[]);var xe=w>0?Ae[Ae.length-1]:void 0,We=w++,Fe=new A.Part(new _.AttrList(W),M,u,We,xe);Ae.push(Fe),M.duration+=Fe.duration;break;case"PRELOAD-HINT":var Re=new _.AttrList(W);S.preloadHint=Re;break;case"RENDITION-REPORT":var $e=new _.AttrList(W);S.renditionReports=S.renditionReports||[],S.renditionReports.push($e);break;default:l.logger.warn("line parsed but not handled: "+i)}}}F&&!F.relurl?(b.pop(),O-=F.duration,S.partList&&(S.fragmentHint=F)):S.partList&&(s(M,F),M.cc=P,S.fragmentHint=M);var Ye=b.length,Ie=b[0],Qe=b[Ye-1];if((O+=S.skippedSegments*S.targetduration)>0&&Ye&&Qe){S.averagetargetduration=O/Ye;var qe=Qe.sn;S.endSN=qe!=="initSegment"?qe:0,Ie&&(S.startCC=Ie.cc,Ie.initSegment||S.fragments.every(function(Me){return Me.relurl&&(Oe=Me.relurl,c.test((Ne=(ke=E.parseURL(Oe))===null||ke===void 0?void 0:ke.path)!=null?Ne:""));var Oe,Ne,ke})&&(l.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),(M=new A.Fragment(g,u)).relurl=Qe.relurl,M.level=p,M.sn="initSegment",Ie.initSegment=M,S.needSidxRanges=!0))}else S.endSN=0,S.startCC=0;return S.fragmentHint&&(O+=S.fragmentHint.duration),S.totalduration=O,S.endCC=P,B>0&&function(Me,Oe){for(var Ne=Me[Oe],ke=Oe;ke--;){var Be=Me[ke];if(!Be)return;Be.programDateTime=Ne.programDateTime-1e3*Be.duration,Ne=Be}}(b,B),S},d}();function a(d,n){["video","audio","text"].forEach(function(u){var p=d.filter(function(v){return Object(L.isCodecType)(v,u)});if(p.length){var g=p.filter(function(v){return v.lastIndexOf("avc1",0)===0||v.lastIndexOf("mp4a",0)===0});n[u+"Codec"]=g.length>0?g[0]:p[0],d=d.filter(function(v){return p.indexOf(v)===-1})}}),n.unknownCodecs=d}function t(d,n,u){var p=n[u];p&&(d[u]=p)}function s(d,n){d.rawProgramDateTime?d.programDateTime=Date.parse(d.rawProgramDateTime):n!=null&&n.programDateTime&&(d.programDateTime=n.endProgramDateTime),Object(R.isFiniteNumber)(d.programDateTime)||(d.programDateTime=null,d.rawProgramDateTime=null)}},"./src/loader/playlist-loader.ts":function(N,C,f){f.r(C);var R=f("./src/polyfills/number.ts"),E=f("./src/events.ts"),A=f("./src/errors.ts"),D=f("./src/utils/logger.ts"),I=f("./src/utils/mp4-tools.ts"),_=f("./src/loader/m3u8-parser.ts"),l=f("./src/types/loader.ts"),L=f("./src/utils/attr-list.ts");function m(T,y){var c=T.url;return c!==void 0&&c.indexOf("data:")!==0||(c=y.url),c}var h=function(){function T(c){this.hls=void 0,this.loaders=Object.create(null),this.hls=c,this.registerListeners()}var y=T.prototype;return y.registerListeners=function(){var c=this.hls;c.on(E.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.on(E.Events.LEVEL_LOADING,this.onLevelLoading,this),c.on(E.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),c.on(E.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},y.unregisterListeners=function(){var c=this.hls;c.off(E.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.off(E.Events.LEVEL_LOADING,this.onLevelLoading,this),c.off(E.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),c.off(E.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},y.createInternalLoader=function(c){var e=this.hls.config,a=e.pLoader,t=e.loader,s=new(a||t)(e);return c.loader=s,this.loaders[c.type]=s,s},y.getInternalLoader=function(c){return this.loaders[c.type]},y.resetInternalLoader=function(c){this.loaders[c]&&delete this.loaders[c]},y.destroyInternalLoaders=function(){for(var c in this.loaders){var e=this.loaders[c];e&&e.destroy(),this.resetInternalLoader(c)}},y.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},y.onManifestLoading=function(c,e){var a=e.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:l.PlaylistContextType.MANIFEST,url:a,deliveryDirectives:null})},y.onLevelLoading=function(c,e){var a=e.id,t=e.level,s=e.url,d=e.deliveryDirectives;this.load({id:a,groupId:null,level:t,responseType:"text",type:l.PlaylistContextType.LEVEL,url:s,deliveryDirectives:d})},y.onAudioTrackLoading=function(c,e){var a=e.id,t=e.groupId,s=e.url,d=e.deliveryDirectives;this.load({id:a,groupId:t,level:null,responseType:"text",type:l.PlaylistContextType.AUDIO_TRACK,url:s,deliveryDirectives:d})},y.onSubtitleTrackLoading=function(c,e){var a=e.id,t=e.groupId,s=e.url,d=e.deliveryDirectives;this.load({id:a,groupId:t,level:null,responseType:"text",type:l.PlaylistContextType.SUBTITLE_TRACK,url:s,deliveryDirectives:d})},y.load=function(c){var e,a,t,s,d,n,u=this.hls.config,p=this.getInternalLoader(c);if(p){var g=p.context;if(g&&g.url===c.url)return void D.logger.trace("[playlist-loader]: playlist request ongoing");D.logger.log("[playlist-loader]: aborting previous loader for type: "+c.type),p.abort()}switch(c.type){case l.PlaylistContextType.MANIFEST:a=u.manifestLoadingMaxRetry,t=u.manifestLoadingTimeOut,s=u.manifestLoadingRetryDelay,d=u.manifestLoadingMaxRetryTimeout;break;case l.PlaylistContextType.LEVEL:case l.PlaylistContextType.AUDIO_TRACK:case l.PlaylistContextType.SUBTITLE_TRACK:a=0,t=u.levelLoadingTimeOut;break;default:a=u.levelLoadingMaxRetry,t=u.levelLoadingTimeOut,s=u.levelLoadingRetryDelay,d=u.levelLoadingMaxRetryTimeout}if(p=this.createInternalLoader(c),(e=c.deliveryDirectives)!==null&&e!==void 0&&e.part&&(c.type===l.PlaylistContextType.LEVEL&&c.level!==null?n=this.hls.levels[c.level].details:c.type===l.PlaylistContextType.AUDIO_TRACK&&c.id!==null?n=this.hls.audioTracks[c.id].details:c.type===l.PlaylistContextType.SUBTITLE_TRACK&&c.id!==null&&(n=this.hls.subtitleTracks[c.id].details),n)){var v=n.partTarget,i=n.targetduration;v&&i&&(t=Math.min(1e3*Math.max(3*v,.8*i),t))}var r={timeout:t,maxRetry:a,retryDelay:s,maxRetryDelay:d,highWaterMark:0},o={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};p.load(c,r,o)},y.loadsuccess=function(c,e,a,t){if(t===void 0&&(t=null),a.isSidxRequest)return this.handleSidxRequest(c,a),void this.handlePlaylistLoaded(c,e,a,t);this.resetInternalLoader(a.type);var s=c.data;s.indexOf("#EXTM3U")===0?(e.parsing.start=performance.now(),s.indexOf("#EXTINF:")>0||s.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(c,e,a,t):this.handleMasterPlaylist(c,e,a,t)):this.handleManifestParsingError(c,a,"no EXTM3U delimiter",t)},y.loaderror=function(c,e,a){a===void 0&&(a=null),this.handleNetworkError(e,a,!1,c)},y.loadtimeout=function(c,e,a){a===void 0&&(a=null),this.handleNetworkError(e,a,!0)},y.handleMasterPlaylist=function(c,e,a,t){var s=this.hls,d=c.data,n=m(c,a),u=_.default.parseMasterPlaylist(d,n),p=u.levels,g=u.sessionData;if(p.length){var v=p.map(function(b){return{id:b.attrs.AUDIO,audioCodec:b.audioCodec}}),i=p.map(function(b){return{id:b.attrs.SUBTITLES,textCodec:b.textCodec}}),r=_.default.parseMasterPlaylistMedia(d,n,"AUDIO",v),o=_.default.parseMasterPlaylistMedia(d,n,"SUBTITLES",i),S=_.default.parseMasterPlaylistMedia(d,n,"CLOSED-CAPTIONS");r.length&&(r.some(function(b){return!b.url})||!p[0].audioCodec||p[0].attrs.AUDIO||(D.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),r.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new L.AttrList({}),bitrate:0,url:""}))),s.trigger(E.Events.MANIFEST_LOADED,{levels:p,audioTracks:r,subtitles:o,captions:S,url:n,stats:e,networkDetails:t,sessionData:g})}else this.handleManifestParsingError(c,a,"no level found in manifest",t)},y.handleTrackOrLevelPlaylist=function(c,e,a,t){var s=this.hls,d=a.id,n=a.level,u=a.type,p=m(c,a),g=Object(R.isFiniteNumber)(d)?d:0,v=Object(R.isFiniteNumber)(n)?n:g,i=function(k){switch(k.type){case l.PlaylistContextType.AUDIO_TRACK:return l.PlaylistLevelType.AUDIO;case l.PlaylistContextType.SUBTITLE_TRACK:return l.PlaylistLevelType.SUBTITLE;default:return l.PlaylistLevelType.MAIN}}(a),r=_.default.parseLevelPlaylist(c.data,p,v,i,g);if(r.fragments.length){if(u===l.PlaylistContextType.MANIFEST){var o={attrs:new L.AttrList({}),bitrate:0,details:r,name:"",url:p};s.trigger(E.Events.MANIFEST_LOADED,{levels:[o],audioTracks:[],url:p,stats:e,networkDetails:t,sessionData:null})}if(e.parsing.end=performance.now(),r.needSidxRanges){var S,b=(S=r.fragments[0].initSegment)===null||S===void 0?void 0:S.url;this.load({url:b,isSidxRequest:!0,type:u,level:n,levelDetails:r,id:d,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null})}else a.levelDetails=r,this.handlePlaylistLoaded(c,e,a,t)}else s.trigger(E.Events.ERROR,{type:A.ErrorTypes.NETWORK_ERROR,details:A.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:p,reason:"no fragments found in level",level:typeof a.level=="number"?a.level:void 0})},y.handleSidxRequest=function(c,e){var a=Object(I.parseSegmentIndex)(new Uint8Array(c.data));if(a){var t=a.references,s=e.levelDetails;t.forEach(function(d,n){var u=d.info,p=s.fragments[n];p.byteRange.length===0&&p.setByteRange(String(1+u.end-u.start)+"@"+String(u.start)),p.initSegment&&p.initSegment.setByteRange(String(a.moovEndOffset)+"@0")})}},y.handleManifestParsingError=function(c,e,a,t){this.hls.trigger(E.Events.ERROR,{type:A.ErrorTypes.NETWORK_ERROR,details:A.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:e.type===l.PlaylistContextType.MANIFEST,url:c.url,reason:a,response:c,context:e,networkDetails:t})},y.handleNetworkError=function(c,e,a,t){a===void 0&&(a=!1),D.logger.warn("[playlist-loader]: A network "+(a?"timeout":"error")+" occurred while loading "+c.type+" level: "+c.level+" id: "+c.id+' group-id: "'+c.groupId+'"');var s=A.ErrorDetails.UNKNOWN,d=!1,n=this.getInternalLoader(c);switch(c.type){case l.PlaylistContextType.MANIFEST:s=a?A.ErrorDetails.MANIFEST_LOAD_TIMEOUT:A.ErrorDetails.MANIFEST_LOAD_ERROR,d=!0;break;case l.PlaylistContextType.LEVEL:s=a?A.ErrorDetails.LEVEL_LOAD_TIMEOUT:A.ErrorDetails.LEVEL_LOAD_ERROR,d=!1;break;case l.PlaylistContextType.AUDIO_TRACK:s=a?A.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:A.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,d=!1;break;case l.PlaylistContextType.SUBTITLE_TRACK:s=a?A.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:A.ErrorDetails.SUBTITLE_LOAD_ERROR,d=!1}n&&this.resetInternalLoader(c.type);var u={type:A.ErrorTypes.NETWORK_ERROR,details:s,fatal:d,url:c.url,loader:n,context:c,networkDetails:e};t&&(u.response=t),this.hls.trigger(E.Events.ERROR,u)},y.handlePlaylistLoaded=function(c,e,a,t){var s=a.type,d=a.level,n=a.id,u=a.groupId,p=a.loader,g=a.levelDetails,v=a.deliveryDirectives;if(g!=null&&g.targetduration){if(p)switch(g.live&&(p.getCacheAge&&(g.ageHeader=p.getCacheAge()||0),p.getCacheAge&&!isNaN(g.ageHeader)||(g.ageHeader=0)),s){case l.PlaylistContextType.MANIFEST:case l.PlaylistContextType.LEVEL:this.hls.trigger(E.Events.LEVEL_LOADED,{details:g,level:d||0,id:n||0,stats:e,networkDetails:t,deliveryDirectives:v});break;case l.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(E.Events.AUDIO_TRACK_LOADED,{details:g,id:n||0,groupId:u||"",stats:e,networkDetails:t,deliveryDirectives:v});break;case l.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(E.Events.SUBTITLE_TRACK_LOADED,{details:g,id:n||0,groupId:u||"",stats:e,networkDetails:t,deliveryDirectives:v})}}else this.handleManifestParsingError(c,a,"invalid target duration",t)},T}();C.default=h},"./src/polyfills/number.ts":function(N,C,f){f.r(C),f.d(C,"isFiniteNumber",function(){return R}),f.d(C,"MAX_SAFE_INTEGER",function(){return E});var R=Number.isFinite||function(A){return typeof A=="number"&&isFinite(A)},E=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(N,C,f){f.r(C);var R=function(){function E(){}return E.getSilentFrame=function(A,D){switch(A){case"mp4a.40.2":if(D===1)return new Uint8Array([0,200,0,128,35,128]);if(D===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(D===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(D===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(D===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(D===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(D===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(D===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(D===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}},E}();C.default=R},"./src/remux/mp4-generator.ts":function(N,C,f){f.r(C);var R=Math.pow(2,32)-1,E=function(){function A(){}return A.init=function(){var D;for(D in A.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:[]},A.types)A.types.hasOwnProperty(D)&&(A.types[D]=[D.charCodeAt(0),D.charCodeAt(1),D.charCodeAt(2),D.charCodeAt(3)]);var I=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]),_=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);A.HDLR_TYPES={video:I,audio:_};var l=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),L=new Uint8Array([0,0,0,0,0,0,0,0]);A.STTS=A.STSC=A.STCO=L,A.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),A.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),A.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),A.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var m=new Uint8Array([105,115,111,109]),h=new Uint8Array([97,118,99,49]),T=new Uint8Array([0,0,0,1]);A.FTYP=A.box(A.types.ftyp,m,T,m,h),A.DINF=A.box(A.types.dinf,A.box(A.types.dref,l))},A.box=function(D){for(var I=8,_=arguments.length,l=new Array(_>1?_-1:0),L=1;L<_;L++)l[L-1]=arguments[L];for(var m=l.length,h=m;m--;)I+=l[m].byteLength;var T=new Uint8Array(I);for(T[0]=I>>24&255,T[1]=I>>16&255,T[2]=I>>8&255,T[3]=255&I,T.set(D,4),m=0,I=8;m<h;m++)T.set(l[m],I),I+=l[m].byteLength;return T},A.hdlr=function(D){return A.box(A.types.hdlr,A.HDLR_TYPES[D])},A.mdat=function(D){return A.box(A.types.mdat,D)},A.mdhd=function(D,I){I*=D;var _=Math.floor(I/(R+1)),l=Math.floor(I%(R+1));return A.box(A.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,D>>24&255,D>>16&255,D>>8&255,255&D,_>>24,_>>16&255,_>>8&255,255&_,l>>24,l>>16&255,l>>8&255,255&l,85,196,0,0]))},A.mdia=function(D){return A.box(A.types.mdia,A.mdhd(D.timescale,D.duration),A.hdlr(D.type),A.minf(D))},A.mfhd=function(D){return A.box(A.types.mfhd,new Uint8Array([0,0,0,0,D>>24,D>>16&255,D>>8&255,255&D]))},A.minf=function(D){return D.type==="audio"?A.box(A.types.minf,A.box(A.types.smhd,A.SMHD),A.DINF,A.stbl(D)):A.box(A.types.minf,A.box(A.types.vmhd,A.VMHD),A.DINF,A.stbl(D))},A.moof=function(D,I,_){return A.box(A.types.moof,A.mfhd(D),A.traf(_,I))},A.moov=function(D){for(var I=D.length,_=[];I--;)_[I]=A.trak(D[I]);return A.box.apply(null,[A.types.moov,A.mvhd(D[0].timescale,D[0].duration)].concat(_).concat(A.mvex(D)))},A.mvex=function(D){for(var I=D.length,_=[];I--;)_[I]=A.trex(D[I]);return A.box.apply(null,[A.types.mvex].concat(_))},A.mvhd=function(D,I){I*=D;var _=Math.floor(I/(R+1)),l=Math.floor(I%(R+1)),L=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,D>>24&255,D>>16&255,D>>8&255,255&D,_>>24,_>>16&255,_>>8&255,255&_,l>>24,l>>16&255,l>>8&255,255&l,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 A.box(A.types.mvhd,L)},A.sdtp=function(D){var I,_,l=D.samples||[],L=new Uint8Array(4+l.length);for(I=0;I<l.length;I++)_=l[I].flags,L[I+4]=_.dependsOn<<4|_.isDependedOn<<2|_.hasRedundancy;return A.box(A.types.sdtp,L)},A.stbl=function(D){return A.box(A.types.stbl,A.stsd(D),A.box(A.types.stts,A.STTS),A.box(A.types.stsc,A.STSC),A.box(A.types.stsz,A.STSZ),A.box(A.types.stco,A.STCO))},A.avc1=function(D){var I,_,l,L=[],m=[];for(I=0;I<D.sps.length;I++)l=(_=D.sps[I]).byteLength,L.push(l>>>8&255),L.push(255&l),L=L.concat(Array.prototype.slice.call(_));for(I=0;I<D.pps.length;I++)l=(_=D.pps[I]).byteLength,m.push(l>>>8&255),m.push(255&l),m=m.concat(Array.prototype.slice.call(_));var h=A.box(A.types.avcC,new Uint8Array([1,L[3],L[4],L[5],255,224|D.sps.length].concat(L).concat([D.pps.length]).concat(m))),T=D.width,y=D.height,c=D.pixelRatio[0],e=D.pixelRatio[1];return A.box(A.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,T>>8&255,255&T,y>>8&255,255&y,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),h,A.box(A.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),A.box(A.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,255&c,e>>24,e>>16&255,e>>8&255,255&e])))},A.esds=function(D){var I=D.config.length;return new Uint8Array([0,0,0,0,3,23+I,0,1,0,4,15+I,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([I]).concat(D.config).concat([6,1,2]))},A.mp4a=function(D){var I=D.samplerate;return A.box(A.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,D.channelCount,0,16,0,0,0,0,I>>8&255,255&I,0,0]),A.box(A.types.esds,A.esds(D)))},A.mp3=function(D){var I=D.samplerate;return A.box(A.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,D.channelCount,0,16,0,0,0,0,I>>8&255,255&I,0,0]))},A.stsd=function(D){return D.type==="audio"?D.isAAC||D.codec!=="mp3"?A.box(A.types.stsd,A.STSD,A.mp4a(D)):A.box(A.types.stsd,A.STSD,A.mp3(D)):A.box(A.types.stsd,A.STSD,A.avc1(D))},A.tkhd=function(D){var I=D.id,_=D.duration*D.timescale,l=D.width,L=D.height,m=Math.floor(_/(R+1)),h=Math.floor(_%(R+1));return A.box(A.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,I>>24&255,I>>16&255,I>>8&255,255&I,0,0,0,0,m>>24,m>>16&255,m>>8&255,255&m,h>>24,h>>16&255,h>>8&255,255&h,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,l>>8&255,255&l,0,0,L>>8&255,255&L,0,0]))},A.traf=function(D,I){var _=A.sdtp(D),l=D.id,L=Math.floor(I/(R+1)),m=Math.floor(I%(R+1));return A.box(A.types.traf,A.box(A.types.tfhd,new Uint8Array([0,0,0,0,l>>24,l>>16&255,l>>8&255,255&l])),A.box(A.types.tfdt,new Uint8Array([1,0,0,0,L>>24,L>>16&255,L>>8&255,255&L,m>>24,m>>16&255,m>>8&255,255&m])),A.trun(D,_.length+16+20+8+16+8+8),_)},A.trak=function(D){return D.duration=D.duration||4294967295,A.box(A.types.trak,A.tkhd(D),A.mdia(D))},A.trex=function(D){var I=D.id;return A.box(A.types.trex,new Uint8Array([0,0,0,0,I>>24,I>>16&255,I>>8&255,255&I,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},A.trun=function(D,I){var _,l,L,m,h,T,y=D.samples||[],c=y.length,e=12+16*c,a=new Uint8Array(e);for(I+=8+e,a.set([0,0,15,1,c>>>24&255,c>>>16&255,c>>>8&255,255&c,I>>>24&255,I>>>16&255,I>>>8&255,255&I],0),_=0;_<c;_++)L=(l=y[_]).duration,m=l.size,h=l.flags,T=l.cts,a.set([L>>>24&255,L>>>16&255,L>>>8&255,255&L,m>>>24&255,m>>>16&255,m>>>8&255,255&m,h.isLeading<<2|h.dependsOn,h.isDependedOn<<6|h.hasRedundancy<<4|h.paddingValue<<1|h.isNonSync,61440&h.degradPrio,15&h.degradPrio,T>>>24&255,T>>>16&255,T>>>8&255,255&T],12+16*_);return A.box(A.types.trun,a)},A.initSegment=function(D){A.types||A.init();var I=A.moov(D),_=new Uint8Array(A.FTYP.byteLength+I.byteLength);return _.set(A.FTYP),_.set(I,A.FTYP.byteLength),_},A}();E.types=void 0,E.HDLR_TYPES=void 0,E.STTS=void 0,E.STSC=void 0,E.STCO=void 0,E.STSZ=void 0,E.VMHD=void 0,E.SMHD=void 0,E.STSD=void 0,E.FTYP=void 0,E.DINF=void 0,C.default=E},"./src/remux/mp4-remuxer.ts":function(N,C,f){f.r(C),f.d(C,"default",function(){return c}),f.d(C,"normalizePts",function(){return e});var R=f("./src/polyfills/number.ts"),E=f("./src/remux/aac-helper.ts"),A=f("./src/remux/mp4-generator.ts"),D=f("./src/events.ts"),I=f("./src/errors.ts"),_=f("./src/utils/logger.ts"),l=f("./src/types/loader.ts"),L=f("./src/utils/timescale-conversion.ts");function m(){return(m=Object.assign||function(s){for(var d=1;d<arguments.length;d++){var n=arguments[d];for(var u in n)Object.prototype.hasOwnProperty.call(n,u)&&(s[u]=n[u])}return s}).apply(this,arguments)}var h=null,T=null,y=!1,c=function(){function s(n,u,p,g){if(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.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=n,this.config=u,this.typeSupported=p,this.ISGenerated=!1,h===null){var v=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);h=v?parseInt(v[1]):0}if(T===null){var i=navigator.userAgent.match(/Safari\/(\d+)/i);T=i?parseInt(i[1]):0}y=!!h&&h<75||!!T&&T<600}var d=s.prototype;return d.destroy=function(){},d.resetTimeStamp=function(n){_.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=n},d.resetNextTimestamp=function(){_.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},d.resetInitSegment=function(){_.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},d.getVideoStartPts=function(n){var u=!1,p=n.reduce(function(g,v){var i=v.pts-g;return i<-4294967296?(u=!0,e(g,v.pts)):i>0?g:v.pts},n[0].pts);return u&&_.logger.debug("PTS rollover detected"),p},d.remux=function(n,u,p,g,v,i,r,o){var S,b,k,x,w,O,P=v,F=v,M=n.pid>-1,B=u.pid>-1,U=u.samples.length,j=n.samples.length>0,V=U>1;if((!M||j)&&(!B||V)||this.ISGenerated||r){this.ISGenerated||(k=this.generateIS(n,u,v));var H=this.isVideoContiguous,z=-1;if(V&&(z=function(oe){for(var te=0;te<oe.length;te++)if(oe[te].key)return te;return-1}(u.samples),!H&&this.config.forceKeyFrameOnDiscontinuity))if(O=!0,z>0){_.logger.warn("[mp4-remuxer]: Dropped "+z+" out of "+U+" video samples due to a missing keyframe");var W=this.getVideoStartPts(u.samples);u.samples=u.samples.slice(z),u.dropped+=z,F+=(u.samples[0].pts-W)/(u.timescale||9e4)}else z===-1&&(_.logger.warn("[mp4-remuxer]: No keyframe found out of "+U+" video samples"),O=!1);if(this.ISGenerated){if(j&&V){var X=this.getVideoStartPts(u.samples),ne=(e(n.samples[0].pts,X)-X)/u.inputTimeScale;P+=Math.max(0,ne),F+=Math.max(0,-ne)}if(j){if(n.samplerate||(_.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),k=this.generateIS(n,u,v)),b=this.remuxAudio(n,P,this.isAudioContiguous,i,B||V||o===l.PlaylistLevelType.AUDIO?F:void 0),V){var se=b?b.endPTS-b.startPTS:0;u.inputTimeScale||(_.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),k=this.generateIS(n,u,v)),S=this.remuxVideo(u,F,H,se)}}else V&&(S=this.remuxVideo(u,F,H,0));S&&(S.firstKeyFrame=z,S.independent=z!==-1)}}return this.ISGenerated&&(p.samples.length&&(w=this.remuxID3(p,v)),g.samples.length&&(x=this.remuxText(g,v))),{audio:b,video:S,initSegment:k,independent:O,text:x,id3:w}},d.generateIS=function(n,u,p){var g,v,i,r=n.samples,o=u.samples,S=this.typeSupported,b={},k=!Object(R.isFiniteNumber)(this._initPTS),x="audio/mp4";if(k&&(g=v=1/0),n.config&&r.length&&(n.timescale=n.samplerate,n.isAAC||(S.mpeg?(x="audio/mpeg",n.codec=""):S.mp3&&(n.codec="mp3")),b.audio={id:"audio",container:x,codec:n.codec,initSegment:!n.isAAC&&S.mpeg?new Uint8Array(0):A.default.initSegment([n]),metadata:{channelCount:n.channelCount}},k&&(i=n.inputTimeScale,g=v=r[0].pts-Math.round(i*p))),u.sps&&u.pps&&o.length&&(u.timescale=u.inputTimeScale,b.video={id:"main",container:"video/mp4",codec:u.codec,initSegment:A.default.initSegment([u]),metadata:{width:u.width,height:u.height}},k)){i=u.inputTimeScale;var w=this.getVideoStartPts(o),O=Math.round(i*p);v=Math.min(v,e(o[0].dts,w)-O),g=Math.min(g,w-O)}if(Object.keys(b).length)return this.ISGenerated=!0,k&&(this._initPTS=g,this._initDTS=v),{tracks:b,initPTS:g,timescale:i}},d.remuxVideo=function(n,u,p,g){var v,i,r,o=n.inputTimeScale,S=n.samples,b=[],k=S.length,x=this._initPTS,w=this.nextAvcDts,O=8,P=Number.POSITIVE_INFINITY,F=Number.NEGATIVE_INFINITY,M=0,B=!1;p&&w!==null||(w=u*o-(S[0].pts-e(S[0].dts,S[0].pts)));for(var U=0;U<k;U++){var j=S[U];j.pts=e(j.pts-x,w),j.dts=e(j.dts-x,w),j.dts>j.pts&&(M=Math.max(Math.min(M,j.pts-j.dts),-18e3)),j.dts<S[U>0?U-1:U].dts&&(B=!0)}B&&S.sort(function(ke,Be){var Dt=ke.dts-Be.dts,Rt=ke.pts-Be.pts;return Dt||Rt}),i=S[0].dts,r=S[S.length-1].dts;var V=Math.round((r-i)/(k-1));if(M<0){if(M<-2*V){_.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(L.toMsFromMpegTsClock)(-V,!0)+" ms");for(var H=M,z=0;z<k;z++)S[z].dts=H=Math.max(H,S[z].pts-V),S[z].pts=Math.max(H,S[z].pts)}else{_.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Object(L.toMsFromMpegTsClock)(M,!0)+" ms to overcome this issue");for(var W=0;W<k;W++)S[W].dts=S[W].dts+M}i=S[0].dts}if(p){var X=i-w,ne=X>V;if(ne||X<-1){ne?_.logger.warn("AVC: "+Object(L.toMsFromMpegTsClock)(X,!0)+" ms ("+X+"dts) hole between fragments detected, filling it"):_.logger.warn("AVC: "+Object(L.toMsFromMpegTsClock)(-X,!0)+" ms ("+X+"dts) overlapping between fragments detected"),i=w;var se=S[0].pts-X;S[0].dts=i,S[0].pts=se,_.logger.log("Video: First PTS/DTS adjusted: "+Object(L.toMsFromMpegTsClock)(se,!0)+"/"+Object(L.toMsFromMpegTsClock)(i,!0)+", delta: "+Object(L.toMsFromMpegTsClock)(X,!0)+" ms")}}y&&(i=Math.max(0,i));for(var oe=0,te=0,de=0;de<k;de++){for(var re=S[de],ae=re.units,Y=ae.length,ee=0,le=0;le<Y;le++)ee+=ae[le].data.length;te+=ee,oe+=Y,re.length=ee,re.dts=Math.max(re.dts,i),re.pts=Math.max(re.pts,re.dts,0),P=Math.min(re.pts,P),F=Math.max(re.pts,F)}r=S[k-1].dts;var ye,Ee=te+4*oe+8;try{ye=new Uint8Array(Ee)}catch{return void this.observer.emit(D.Events.ERROR,D.Events.ERROR,{type:I.ErrorTypes.MUX_ERROR,details:I.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Ee,reason:"fail allocating video mdat "+Ee})}var Le=new DataView(ye.buffer);Le.setUint32(0,Ee),ye.set(A.default.types.mdat,4);for(var fe=0;fe<k;fe++){for(var he=S[fe],He=he.units,Ae=0,xe=0,We=He.length;xe<We;xe++){var Fe=He[xe],Re=Fe.data,$e=Fe.data.byteLength;Le.setUint32(O,$e),O+=4,ye.set(Re,O),O+=$e,Ae+=4+$e}if(fe<k-1)v=S[fe+1].dts-he.dts;else{var Ye=this.config,Ie=he.dts-S[fe>0?fe-1:fe].dts;if(Ye.stretchShortVideoTrack&&this.nextAudioPts!==null){var Qe=Math.floor(Ye.maxBufferHole*o),qe=(g?P+g*o:this.nextAudioPts)-he.pts;qe>Qe?((v=qe-Ie)<0&&(v=Ie),_.logger.log("[mp4-remuxer]: It is approximately "+qe/90+" ms to the next segment; using duration "+v/90+" ms for the last video frame.")):v=Ie}else v=Ie}var Me=Math.round(he.pts-he.dts);b.push(new a(he.key,v,Ae,Me))}if(b.length&&h&&h<70){var Oe=b[0].flags;Oe.dependsOn=2,Oe.isNonSync=0}console.assert(v!==void 0,"mp4SampleDuration must be computed"),this.nextAvcDts=w=r+v,this.isVideoContiguous=!0;var Ne={data1:A.default.moof(n.sequenceNumber++,i,m({},n,{samples:b})),data2:ye,startPTS:P/o,endPTS:(F+v)/o,startDTS:i/o,endDTS:w/o,type:"video",hasAudio:!1,hasVideo:!0,nb:b.length,dropped:n.dropped};return n.samples=[],n.dropped=0,console.assert(ye.length,"MDAT length must not be zero"),Ne},d.remuxAudio=function(n,u,p,g,v){var i=n.inputTimeScale,r=i/(n.samplerate?n.samplerate:i),o=n.isAAC?1024:1152,S=o*r,b=this._initPTS,k=!n.isAAC&&this.typeSupported.mpeg,x=[],w=n.samples,O=k?0:8,P=this.nextAudioPts||-1,F=u*i;if(this.isAudioContiguous=p=p||w.length&&P>0&&(g&&Math.abs(F-P)<9e3||Math.abs(e(w[0].pts-b,F)-P)<20*S),w.forEach(function(Re){Re.pts=e(Re.pts-b,F)}),!p||P<0){if(!(w=w.filter(function(Re){return Re.pts>=0})).length)return;P=v===0?0:g?Math.max(0,F):w[0].pts}if(n.isAAC)for(var M=v!==void 0,B=this.config.maxAudioFramesDrift,U=0,j=P;U<w.length;U++){var V=w[U],H=V.pts,z=H-j,W=Math.abs(1e3*z/i);if(z<=-B*S&&M)U===0&&(_.logger.warn("Audio frame @ "+(H/i).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*z/i)+" ms."),this.nextAudioPts=P=j=H);else if(z>=B*S&&W<1e4&&M){var X=Math.round(z/S);(j=H-X*S)<0&&(X--,j+=S),U===0&&(this.nextAudioPts=P=j),_.logger.warn("[mp4-remuxer]: Injecting "+X+" audio frame @ "+(j/i).toFixed(3)+"s due to "+Math.round(1e3*z/i)+" ms gap.");for(var ne=0;ne<X;ne++){var se=Math.max(j,0),oe=E.default.getSilentFrame(n.manifestCodec||n.codec,n.channelCount);oe||(_.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),oe=V.unit.subarray()),w.splice(U,0,{unit:oe,pts:se}),j+=S,U++}}V.pts=j,j+=S}for(var te,de=null,re=null,ae=0,Y=w.length;Y--;)ae+=w[Y].unit.byteLength;for(var ee=0,le=w.length;ee<le;ee++){var ye=w[ee],Ee=ye.unit,Le=ye.pts;if(re!==null)x[ee-1].duration=Math.round((Le-re)/r);else{if(p&&n.isAAC&&(Le=P),de=Le,!(ae>0))return;ae+=O;try{te=new Uint8Array(ae)}catch{return void this.observer.emit(D.Events.ERROR,D.Events.ERROR,{type:I.ErrorTypes.MUX_ERROR,details:I.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:ae,reason:"fail allocating audio mdat "+ae})}k||(new DataView(te.buffer).setUint32(0,ae),te.set(A.default.types.mdat,4))}te.set(Ee,O);var fe=Ee.byteLength;O+=fe,x.push(new a(!0,o,fe,0)),re=Le}var he=x.length;if(he){var He=x[x.length-1];this.nextAudioPts=P=re+r*He.duration;var Ae=k?new Uint8Array(0):A.default.moof(n.sequenceNumber++,de/r,m({},n,{samples:x}));n.samples=[];var xe=de/i,We=P/i,Fe={data1:Ae,data2:te,startPTS:xe,endPTS:We,startDTS:xe,endDTS:We,type:"audio",hasAudio:!0,hasVideo:!1,nb:he};return this.isAudioContiguous=!0,console.assert(te.length,"MDAT length must not be zero"),Fe}},d.remuxEmptyAudio=function(n,u,p,g){var v=n.inputTimeScale,i=v/(n.samplerate?n.samplerate:v),r=this.nextAudioPts,o=(r!==null?r:g.startDTS*v)+this._initDTS,S=g.endDTS*v+this._initDTS,b=1024*i,k=Math.ceil((S-o)/b),x=E.default.getSilentFrame(n.manifestCodec||n.codec,n.channelCount);if(_.logger.warn("[mp4-remuxer]: remux empty Audio"),x){for(var w=[],O=0;O<k;O++){var P=o+O*b;w.push({unit:x,pts:P,dts:P})}return n.samples=w,this.remuxAudio(n,u,p,!1)}_.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec")},d.remuxID3=function(n,u){var p=n.samples.length;if(p){for(var g=n.inputTimeScale,v=this._initPTS,i=this._initDTS,r=0;r<p;r++){var o=n.samples[r];o.pts=e(o.pts-v,u*g)/g,o.dts=e(o.dts-i,u*g)/g}var S=n.samples;return n.samples=[],{samples:S}}},d.remuxText=function(n,u){var p=n.samples.length;if(p){for(var g=n.inputTimeScale,v=this._initPTS,i=0;i<p;i++){var r=n.samples[i];r.pts=e(r.pts-v,u*g)/g}n.samples.sort(function(S,b){return S.pts-b.pts});var o=n.samples;return n.samples=[],{samples:o}}},s}();function e(s,d){var n;if(d===null)return s;for(n=d<s?-8589934592:8589934592;Math.abs(s-d)>4294967296;)s+=n;return s}var a=function(s,d,n,u){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=d,this.size=n,this.cts=u,this.flags=new t(s)},t=function(s){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=s?2:1,this.isNonSync=s?0:1}},"./src/remux/passthrough-remuxer.ts":function(N,C,f){f.r(C);var R=f("./src/polyfills/number.ts"),E=f("./src/utils/mp4-tools.ts"),A=f("./src/loader/fragment.ts"),D=f("./src/utils/logger.ts"),I=function(){function L(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndDTS=null}var m=L.prototype;return m.destroy=function(){},m.resetTimeStamp=function(h){this.initPTS=h,this.lastEndDTS=null},m.resetNextTimestamp=function(){this.lastEndDTS=null},m.resetInitSegment=function(h,T,y){this.audioCodec=T,this.videoCodec=y,this.generateInitSegment(h),this.emitInitSegment=!0},m.generateInitSegment=function(h){var T=this.audioCodec,y=this.videoCodec;if(!h||!h.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var c=this.initData=Object(E.parseInitSegment)(h);T||(T=l(c.audio,A.ElementaryStreamTypes.AUDIO)),y||(y=l(c.video,A.ElementaryStreamTypes.VIDEO));var e={};c.audio&&c.video?e.audiovideo={container:"video/mp4",codec:T+","+y,initSegment:h,id:"main"}:c.audio?e.audio={container:"audio/mp4",codec:T,initSegment:h,id:"audio"}:c.video?e.video={container:"video/mp4",codec:y,initSegment:h,id:"main"}:D.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=e},m.remux=function(h,T,y,c,e){var a=this.initPTS,t=this.lastEndDTS,s={audio:void 0,video:void 0,text:c,id3:y,initSegment:void 0};Object(R.isFiniteNumber)(t)||(t=this.lastEndDTS=e||0);var d=T.samples;if(!d||!d.length)return s;var n={initPTS:void 0,timescale:1},u=this.initData;if(u&&u.length||(this.generateInitSegment(d),u=this.initData),!u||!u.length)return D.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),s;this.emitInitSegment&&(n.tracks=this.initTracks,this.emitInitSegment=!1),Object(R.isFiniteNumber)(a)||(this.initPTS=n.initPTS=a=_(u,d,t));var p=Object(E.getDuration)(d,u),g=t,v=p+g;Object(E.offsetStartDTS)(u,d,a),p>0?this.lastEndDTS=v:(D.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var i=!!u.audio,r=!!u.video,o="";i&&(o+="audio"),r&&(o+="video");var S={data1:d,startPTS:g,startDTS:g,endPTS:v,endDTS:v,type:o,hasAudio:i,hasVideo:r,nb:1,dropped:0};return s.audio=S.type==="audio"?S:void 0,s.video=S.type!=="audio"?S:void 0,s.text=c,s.id3=y,s.initSegment=n,s},L}(),_=function(L,m,h){return Object(E.getStartDTS)(L,m)-h};function l(L,m){var h=L==null?void 0:L.codec;return h&&h.length>4?h:h==="hvc1"?"hvc1.1.c.L120.90":h==="av01"?"av01.0.04M.08":h==="avc1"||m===A.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}C.default=I},"./src/task-loop.ts":function(N,C,f){f.r(C),f.d(C,"default",function(){return R});var R=function(){function E(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var A=E.prototype;return A.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},A.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},A.onHandlerDestroyed=function(){},A.hasInterval=function(){return!!this._tickInterval},A.hasNextTick=function(){return!!this._tickTimer},A.setInterval=function(D){return!this._tickInterval&&(this._tickInterval=self.setInterval(this._boundTick,D),!0)},A.clearInterval=function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)},A.clearNextTick=function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)},A.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},A.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},A.doTick=function(){},E}()},"./src/types/level.ts":function(N,C,f){function R(l,L){for(var m=0;m<L.length;m++){var h=L[m];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(l,h.key,h)}}var E,A;function D(l,L){var m=l.canSkipUntil,h=l.canSkipDateRanges,T=l.endSN;return m&&(L!==void 0?L-T:0)<m?h?E.v2:E.Yes:E.No}f.r(C),f.d(C,"HlsSkip",function(){return E}),f.d(C,"getSkipValue",function(){return D}),f.d(C,"HlsUrlParameters",function(){return I}),f.d(C,"Level",function(){return _}),(A=E||(E={})).No="",A.Yes="YES",A.v2="v2";var I=function(){function l(L,m,h){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=L,this.part=m,this.skip=h}return l.prototype.addDirectives=function(L){var m=new self.URL(L);return this.msn!==void 0&&m.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&m.searchParams.set("_HLS_part",this.part.toString()),this.skip&&m.searchParams.set("_HLS_skip",this.skip),m.toString()},l}(),_=function(){function l(h){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=[h.url],this.attrs=h.attrs,this.bitrate=h.bitrate,h.details&&(this.details=h.details),this.id=h.id||0,this.name=h.name,this.width=h.width||0,this.height=h.height||0,this.audioCodec=h.audioCodec,this.videoCodec=h.videoCodec,this.unknownCodecs=h.unknownCodecs,this.codecSet=[h.videoCodec,h.audioCodec].filter(function(T){return T}).join(",").replace(/\.[^.,]+/g,"")}var L,m;return L=l,(m=[{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(h){var T=h%this.url.length;this._urlId!==T&&(this.details=void 0,this._urlId=T)}}])&&R(L.prototype,m),l}()},"./src/types/loader.ts":function(N,C,f){var R,E,A,D;f.r(C),f.d(C,"PlaylistContextType",function(){return R}),f.d(C,"PlaylistLevelType",function(){return A}),(E=R||(R={})).MANIFEST="manifest",E.LEVEL="level",E.AUDIO_TRACK="audioTrack",E.SUBTITLE_TRACK="subtitleTrack",(D=A||(A={})).MAIN="main",D.AUDIO="audio",D.SUBTITLE="subtitle"},"./src/types/transmuxer.ts":function(N,C,f){f.r(C),f.d(C,"ChunkMetadata",function(){return R});var R=function(E,A,D,I,_,l){I===void 0&&(I=0),_===void 0&&(_=-1),l===void 0&&(l=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=E,this.sn=A,this.id=D,this.size=I,this.part=_,this.partial=l}},"./src/utils/attr-list.ts":function(N,C,f){f.r(C),f.d(C,"AttrList",function(){return A});var R=/^(\d+)x(\d+)$/,E=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,A=function(){function D(_){for(var l in typeof _=="string"&&(_=D.parseAttrList(_)),_)_.hasOwnProperty(l)&&(this[l]=_[l])}var I=D.prototype;return I.decimalInteger=function(_){var l=parseInt(this[_],10);return l>Number.MAX_SAFE_INTEGER?1/0:l},I.hexadecimalInteger=function(_){if(this[_]){var l=(this[_]||"0x").slice(2);l=(1&l.length?"0":"")+l;for(var L=new Uint8Array(l.length/2),m=0;m<l.length/2;m++)L[m]=parseInt(l.slice(2*m,2*m+2),16);return L}return null},I.hexadecimalIntegerAsNumber=function(_){var l=parseInt(this[_],16);return l>Number.MAX_SAFE_INTEGER?1/0:l},I.decimalFloatingPoint=function(_){return parseFloat(this[_])},I.optionalFloat=function(_,l){var L=this[_];return L?parseFloat(L):l},I.enumeratedString=function(_){return this[_]},I.bool=function(_){return this[_]==="YES"},I.decimalResolution=function(_){var l=R.exec(this[_]);if(l!==null)return{width:parseInt(l[1],10),height:parseInt(l[2],10)}},D.parseAttrList=function(_){var l,L={};for(E.lastIndex=0;(l=E.exec(_))!==null;){var m=l[2];m.indexOf('"')===0&&m.lastIndexOf('"')===m.length-1&&(m=m.slice(1,-1)),L[l[1]]=m}return L},D}()},"./src/utils/binary-search.ts":function(N,C,f){f.r(C),C.default={search:function(R,E){for(var A=0,D=R.length-1,I=null,_=null;A<=D;){var l=E(_=R[I=(A+D)/2|0]);if(l>0)A=I+1;else{if(!(l<0))return _;D=I-1}}return null}}},"./src/utils/buffer-helper.ts":function(N,C,f){f.r(C),f.d(C,"BufferHelper",function(){return A});var R=f("./src/utils/logger.ts"),E={length:0,start:function(){return 0},end:function(){return 0}},A=function(){function D(){}return D.isBuffered=function(I,_){try{if(I){for(var l=D.getBuffered(I),L=0;L<l.length;L++)if(_>=l.start(L)&&_<=l.end(L))return!0}}catch{}return!1},D.bufferInfo=function(I,_,l){try{if(I){var L,m=D.getBuffered(I),h=[];for(L=0;L<m.length;L++)h.push({start:m.start(L),end:m.end(L)});return this.bufferedInfo(h,_,l)}}catch{}return{len:0,start:_,end:_,nextStart:void 0}},D.bufferedInfo=function(I,_,l){_=Math.max(0,_),I.sort(function(n,u){var p=n.start-u.start;return p||u.end-n.end});var L=[];if(l)for(var m=0;m<I.length;m++){var h=L.length;if(h){var T=L[h-1].end;I[m].start-T<l?I[m].end>T&&(L[h-1].end=I[m].end):L.push(I[m])}else L.push(I[m])}else L=I;for(var y,c=0,e=_,a=_,t=0;t<L.length;t++){var s=L[t].start,d=L[t].end;if(_+l>=s&&_<d)e=s,c=(a=d)-_;else if(_+l<s){y=s;break}}return{len:c,start:e||0,end:a||0,nextStart:y}},D.getBuffered=function(I){try{return I.buffered}catch(_){return R.logger.log("failed to get media.buffered",_),E}},D}()},"./src/utils/cea-608-parser.ts":function(N,C,f){f.r(C),f.d(C,"Row",function(){return s}),f.d(C,"CaptionScreen",function(){return d});var R,E,A=f("./src/utils/logger.ts"),D={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},I=function(v){var i=v;return D.hasOwnProperty(v)&&(i=D[v]),String.fromCharCode(i)},_=15,l=100,L={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},m={17:2,18:4,21:6,22:8,23:10,19:13,20:15},h={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},T={25:2,26:4,29:6,30:8,31:10,27:13,28:15},y=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];(E=R||(R={}))[E.ERROR=0]="ERROR",E[E.TEXT=1]="TEXT",E[E.WARNING=2]="WARNING",E[E.INFO=2]="INFO",E[E.DEBUG=3]="DEBUG",E[E.DATA=3]="DATA";var c=function(){function v(){this.time=null,this.verboseLevel=R.ERROR}return v.prototype.log=function(i,r){this.verboseLevel>=i&&A.logger.log(this.time+" ["+i+"] "+r)},v}(),e=function(v){for(var i=[],r=0;r<v.length;r++)i.push(v[r].toString(16));return i},a=function(){function v(r,o,S,b,k){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=r||"white",this.underline=o||!1,this.italics=S||!1,this.background=b||"black",this.flash=k||!1}var i=v.prototype;return i.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},i.setStyles=function(r){for(var o=["foreground","underline","italics","background","flash"],S=0;S<o.length;S++){var b=o[S];r.hasOwnProperty(b)&&(this[b]=r[b])}},i.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},i.equals=function(r){return this.foreground===r.foreground&&this.underline===r.underline&&this.italics===r.italics&&this.background===r.background&&this.flash===r.flash},i.copy=function(r){this.foreground=r.foreground,this.underline=r.underline,this.italics=r.italics,this.background=r.background,this.flash=r.flash},i.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},v}(),t=function(){function v(r,o,S,b,k,x){this.uchar=void 0,this.penState=void 0,this.uchar=r||" ",this.penState=new a(o,S,b,k,x)}var i=v.prototype;return i.reset=function(){this.uchar=" ",this.penState.reset()},i.setChar=function(r,o){this.uchar=r,this.penState.copy(o)},i.setPenState=function(r){this.penState.copy(r)},i.equals=function(r){return this.uchar===r.uchar&&this.penState.equals(r.penState)},i.copy=function(r){this.uchar=r.uchar,this.penState.copy(r.penState)},i.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},v}(),s=function(){function v(r){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var o=0;o<l;o++)this.chars.push(new t);this.logger=r,this.pos=0,this.currPenState=new a}var i=v.prototype;return i.equals=function(r){for(var o=!0,S=0;S<l;S++)if(!this.chars[S].equals(r.chars[S])){o=!1;break}return o},i.copy=function(r){for(var o=0;o<l;o++)this.chars[o].copy(r.chars[o])},i.isEmpty=function(){for(var r=!0,o=0;o<l;o++)if(!this.chars[o].isEmpty()){r=!1;break}return r},i.setCursor=function(r){this.pos!==r&&(this.pos=r),this.pos<0?(this.logger.log(R.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>l&&(this.logger.log(R.DEBUG,"Too large cursor position "+this.pos),this.pos=l)},i.moveCursor=function(r){var o=this.pos+r;if(r>1)for(var S=this.pos+1;S<o+1;S++)this.chars[S].setPenState(this.currPenState);this.setCursor(o)},i.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},i.insertChar=function(r){r>=144&&this.backSpace();var o=I(r);this.pos>=l?this.logger.log(R.ERROR,"Cannot insert "+r.toString(16)+" ("+o+") at position "+this.pos+". Skipping it!"):(this.chars[this.pos].setChar(o,this.currPenState),this.moveCursor(1))},i.clearFromPos=function(r){var o;for(o=r;o<l;o++)this.chars[o].reset()},i.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},i.clearToEndOfRow=function(){this.clearFromPos(this.pos)},i.getTextString=function(){for(var r=[],o=!0,S=0;S<l;S++){var b=this.chars[S].uchar;b!==" "&&(o=!1),r.push(b)}return o?"":r.join("")},i.setPenStyles=function(r){this.currPenState.setStyles(r),this.chars[this.pos].setPenState(this.currPenState)},v}(),d=function(){function v(r){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var o=0;o<_;o++)this.rows.push(new s(r));this.logger=r,this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var i=v.prototype;return i.reset=function(){for(var r=0;r<_;r++)this.rows[r].clear();this.currRow=14},i.equals=function(r){for(var o=!0,S=0;S<_;S++)if(!this.rows[S].equals(r.rows[S])){o=!1;break}return o},i.copy=function(r){for(var o=0;o<_;o++)this.rows[o].copy(r.rows[o])},i.isEmpty=function(){for(var r=!0,o=0;o<_;o++)if(!this.rows[o].isEmpty()){r=!1;break}return r},i.backSpace=function(){this.rows[this.currRow].backSpace()},i.clearToEndOfRow=function(){this.rows[this.currRow].clearToEndOfRow()},i.insertChar=function(r){this.rows[this.currRow].insertChar(r)},i.setPen=function(r){this.rows[this.currRow].setPenStyles(r)},i.moveCursor=function(r){this.rows[this.currRow].moveCursor(r)},i.setCursor=function(r){this.logger.log(R.INFO,"setCursor: "+r),this.rows[this.currRow].setCursor(r)},i.setPAC=function(r){this.logger.log(R.INFO,"pacData = "+JSON.stringify(r));var o=r.row-1;if(this.nrRollUpRows&&o<this.nrRollUpRows-1&&(o=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==o){for(var S=0;S<_;S++)this.rows[S].clear();var b=this.currRow+1-this.nrRollUpRows,k=this.lastOutputScreen;if(k){var x=k.rows[b].cueStartTime,w=this.logger.time;if(x&&w!==null&&x<w)for(var O=0;O<this.nrRollUpRows;O++)this.rows[o-this.nrRollUpRows+O+1].copy(k.rows[b+O])}}this.currRow=o;var P=this.rows[this.currRow];if(r.indent!==null){var F=r.indent,M=Math.max(F-1,0);P.setCursor(r.indent),r.color=P.chars[M].penState.foreground}var B={foreground:r.color,underline:r.underline,italics:r.italics,background:"black",flash:!1};this.setPen(B)},i.setBkgData=function(r){this.logger.log(R.INFO,"bkgData = "+JSON.stringify(r)),this.backSpace(),this.setPen(r),this.insertChar(32)},i.setRollUpRows=function(r){this.nrRollUpRows=r},i.rollUp=function(){if(this.nrRollUpRows!==null){this.logger.log(R.TEXT,this.getDisplayText());var r=this.currRow+1-this.nrRollUpRows,o=this.rows.splice(r,1)[0];o.clear(),this.rows.splice(this.currRow,0,o),this.logger.log(R.INFO,"Rolling up")}else this.logger.log(R.DEBUG,"roll_up but nrRollUpRows not set yet")},i.getDisplayText=function(r){r=r||!1;for(var o=[],S="",b=-1,k=0;k<_;k++){var x=this.rows[k].getTextString();x&&(b=k+1,r?o.push("Row "+b+": '"+x+"'"):o.push(x.trim()))}return o.length>0&&(S=r?"["+o.join(" | ")+"]":o.join(`
|
||
`)),S},i.getTextAndFormat=function(){return this.rows},v}(),n=function(){function v(r,o,S){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=r,this.outputFilter=o,this.mode=null,this.verbose=0,this.displayedMemory=new d(S),this.nonDisplayedMemory=new d(S),this.lastOutputScreen=new d(S),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=S}var i=v.prototype;return i.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},i.getHandler=function(){return this.outputFilter},i.setHandler=function(r){this.outputFilter=r},i.setPAC=function(r){this.writeScreen.setPAC(r)},i.setBkgData=function(r){this.writeScreen.setBkgData(r)},i.setMode=function(r){r!==this.mode&&(this.mode=r,this.logger.log(R.INFO,"MODE="+r),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=r)},i.insertChars=function(r){for(var o=0;o<r.length;o++)this.writeScreen.insertChar(r[o]);var S=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(R.INFO,S+": "+this.writeScreen.getDisplayText(!0)),this.mode!=="MODE_PAINT-ON"&&this.mode!=="MODE_ROLL-UP"||(this.logger.log(R.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},i.ccRCL=function(){this.logger.log(R.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},i.ccBS=function(){this.logger.log(R.INFO,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},i.ccAOF=function(){},i.ccAON=function(){},i.ccDER=function(){this.logger.log(R.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},i.ccRU=function(r){this.logger.log(R.INFO,"RU("+r+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(r)},i.ccFON=function(){this.logger.log(R.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},i.ccRDC=function(){this.logger.log(R.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},i.ccTR=function(){this.logger.log(R.INFO,"TR"),this.setMode("MODE_TEXT")},i.ccRTD=function(){this.logger.log(R.INFO,"RTD"),this.setMode("MODE_TEXT")},i.ccEDM=function(){this.logger.log(R.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},i.ccCR=function(){this.logger.log(R.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},i.ccENM=function(){this.logger.log(R.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},i.ccEOC=function(){if(this.logger.log(R.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var r=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=r,this.writeScreen=this.nonDisplayedMemory,this.logger.log(R.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},i.ccTO=function(r){this.logger.log(R.INFO,"TO("+r+") - Tab Offset"),this.writeScreen.moveCursor(r)},i.ccMIDROW=function(r){var o={flash:!1};if(o.underline=r%2==1,o.italics=r>=46,o.italics)o.foreground="white";else{var S=Math.floor(r/2)-16;o.foreground=["white","green","blue","cyan","red","yellow","magenta"][S]}this.logger.log(R.INFO,"MIDROW: "+JSON.stringify(o)),this.writeScreen.setPen(o)},i.outputDataUpdate=function(r){r===void 0&&(r=!1);var o=this.logger.time;o!==null&&this.outputFilter&&(this.cueStartTime!==null||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,o,this.lastOutputScreen),r&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:o):this.cueStartTime=o,this.lastOutputScreen.copy(this.displayedMemory))},i.cueSplitAtTime=function(r){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,r,this.displayedMemory),this.cueStartTime=r))},v}(),u=function(){function v(r,o,S){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var b=new c;this.channels=[null,new n(r,o,b),new n(r+1,S,b)],this.cmdHistory={a:null,b:null},this.logger=b}var i=v.prototype;return i.getHandler=function(r){return this.channels[r].getHandler()},i.setHandler=function(r,o){this.channels[r].setHandler(o)},i.addData=function(r,o){var S,b,k,x=!1;this.logger.time=r;for(var w=0;w<o.length;w+=2)if(b=127&o[w],k=127&o[w+1],b!==0||k!==0){if(this.logger.log(R.DATA,"["+e([o[w],o[w+1]])+"] -> ("+e([b,k])+")"),(S=this.parseCmd(b,k))||(S=this.parseMidrow(b,k)),S||(S=this.parsePAC(b,k)),S||(S=this.parseBackgroundAttributes(b,k)),!S&&(x=this.parseChars(b,k))){var O=this.currentChannel;O&&O>0?this.channels[O].insertChars(x):this.logger.log(R.WARNING,"No channel found yet. TEXT-MODE?")}S||x||this.logger.log(R.WARNING,"Couldn't parse cleaned data "+e([b,k])+" orig: "+e([o[w],o[w+1]]))}},i.parseCmd=function(r,o){var S=this.cmdHistory;if(!((r===20||r===28||r===21||r===29)&&o>=32&&o<=47||(r===23||r===31)&&o>=33&&o<=35))return!1;if(g(r,o,S))return p(null,null,S),this.logger.log(R.DEBUG,"Repeated command ("+e([r,o])+") is dropped"),!0;var b=r===20||r===21||r===23?1:2,k=this.channels[b];return r===20||r===21||r===28||r===29?o===32?k.ccRCL():o===33?k.ccBS():o===34?k.ccAOF():o===35?k.ccAON():o===36?k.ccDER():o===37?k.ccRU(2):o===38?k.ccRU(3):o===39?k.ccRU(4):o===40?k.ccFON():o===41?k.ccRDC():o===42?k.ccTR():o===43?k.ccRTD():o===44?k.ccEDM():o===45?k.ccCR():o===46?k.ccENM():o===47&&k.ccEOC():k.ccTO(o-32),p(r,o,S),this.currentChannel=b,!0},i.parseMidrow=function(r,o){var S=0;if((r===17||r===25)&&o>=32&&o<=47){if((S=r===17?1:2)!==this.currentChannel)return this.logger.log(R.ERROR,"Mismatch channel in midrow parsing"),!1;var b=this.channels[S];return!!b&&(b.ccMIDROW(o),this.logger.log(R.DEBUG,"MIDROW ("+e([r,o])+")"),!0)}return!1},i.parsePAC=function(r,o){var S,b=this.cmdHistory;if(!((r>=17&&r<=23||r>=25&&r<=31)&&o>=64&&o<=127||(r===16||r===24)&&o>=64&&o<=95))return!1;if(g(r,o,b))return p(null,null,b),!0;var k=r<=23?1:2;S=o>=64&&o<=95?k===1?L[r]:h[r]:k===1?m[r]:T[r];var x=this.channels[k];return!!x&&(x.setPAC(this.interpretPAC(S,o)),p(r,o,b),this.currentChannel=k,!0)},i.interpretPAC=function(r,o){var S,b={color:null,italics:!1,indent:null,underline:!1,row:r};return S=o>95?o-96:o-64,b.underline=(1&S)==1,S<=13?b.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(S/2)]:S<=15?(b.italics=!0,b.color="white"):b.indent=4*Math.floor((S-16)/2),b},i.parseChars=function(r,o){var S,b,k=null,x=null;if(r>=25?(S=2,x=r-8):(S=1,x=r),x>=17&&x<=19?(b=x===17?o+80:x===18?o+112:o+144,this.logger.log(R.INFO,"Special char '"+I(b)+"' in channel "+S),k=[b]):r>=32&&r<=127&&(k=o===0?[r]:[r,o]),k){var w=e(k);this.logger.log(R.DEBUG,"Char codes = "+w.join(",")),p(r,o,this.cmdHistory)}return k},i.parseBackgroundAttributes=function(r,o){var S;if(!((r===16||r===24)&&o>=32&&o<=47||(r===23||r===31)&&o>=45&&o<=47))return!1;var b={};r===16||r===24?(S=Math.floor((o-32)/2),b.background=y[S],o%2==1&&(b.background=b.background+"_semi")):o===45?b.background="transparent":(b.foreground="black",o===47&&(b.underline=!0));var k=r<=23?1:2;return this.channels[k].setBkgData(b),p(r,o,this.cmdHistory),!0},i.reset=function(){for(var r=0;r<Object.keys(this.channels).length;r++){var o=this.channels[r];o&&o.reset()}this.cmdHistory={a:null,b:null}},i.cueSplitAtTime=function(r){for(var o=0;o<this.channels.length;o++){var S=this.channels[o];S&&S.cueSplitAtTime(r)}},v}();function p(v,i,r){r.a=v,r.b=i}function g(v,i,r){return r.a===v&&r.b===i}C.default=u},"./src/utils/codecs.ts":function(N,C,f){f.r(C),f.d(C,"isCodecType",function(){return E}),f.d(C,"isCodecSupportedInMp4",function(){return A});var R={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,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,dvav:!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 E(D,I){var _=R[I];return!!_&&_[D.slice(0,4)]===!0}function A(D,I){return MediaSource.isTypeSupported((I||"video")+'/mp4;codecs="'+D+'"')}},"./src/utils/cues.ts":function(N,C,f){f.r(C);var R=f("./src/utils/vttparser.ts"),E=f("./src/utils/webvtt-parser.ts"),A=f("./src/utils/texttrack-utils.ts"),D=/\s/,I={newCue:function(_,l,L,m){for(var h,T,y,c,e,a=[],t=self.VTTCue||self.TextTrackCue,s=0;s<m.rows.length;s++)if(y=!0,c=0,e="",!(h=m.rows[s]).isEmpty()){for(var d=0;d<h.chars.length;d++)D.test(h.chars[d].uchar)&&y?c++:(e+=h.chars[d].uchar,y=!1);h.cueStartTime=l,l===L&&(L+=1e-4),c>=16?c--:c++;var n=Object(R.fixLineBreaks)(e.trim()),u=Object(E.generateCueId)(l,L,n);_&&_.cues&&_.cues.getCueById(u)||((T=new t(l,L,n)).id=u,T.line=s+1,T.align="left",T.position=10+Math.min(80,10*Math.floor(8*c/32)),a.push(T))}return _&&a.length&&(a.sort(function(p,g){return p.line==="auto"||g.line==="auto"?0:p.line>8&&g.line>8?g.line-p.line:p.line-g.line}),a.forEach(function(p){return Object(A.addCueToTrack)(_,p)})),a}};C.default=I},"./src/utils/discontinuities.ts":function(N,C,f){f.r(C),f.d(C,"findFirstFragWithCC",function(){return D}),f.d(C,"shouldAlignOnDiscontinuities",function(){return I}),f.d(C,"findDiscontinuousReferenceFrag",function(){return _}),f.d(C,"adjustSlidingStart",function(){return L}),f.d(C,"alignStream",function(){return m}),f.d(C,"alignPDT",function(){return h});var R=f("./src/polyfills/number.ts"),E=f("./src/utils/logger.ts"),A=f("./src/controller/level-helper.ts");function D(T,y){for(var c=null,e=0,a=T.length;e<a;e++){var t=T[e];if(t&&t.cc===y){c=t;break}}return c}function I(T,y,c){return!(!y.details||!(c.endCC>c.startCC||T&&T.cc<c.startCC))}function _(T,y){var c=T.fragments,e=y.fragments;if(e.length&&c.length){var a=D(c,e[0].cc);if(a&&(!a||a.startPTS))return a;E.logger.log("No frag in previous level to align on")}else E.logger.log("No fragments to align")}function l(T,y){if(T){var c=T.start+y;T.start=T.startPTS=c,T.endPTS=c+T.duration}}function L(T,y){for(var c=y.fragments,e=0,a=c.length;e<a;e++)l(c[e],T);y.fragmentHint&&l(y.fragmentHint,T),y.alignedSliding=!0}function m(T,y,c){y&&(function(e,a,t){if(I(e,t,a)){var s=_(t.details,a);s&&Object(R.isFiniteNumber)(s.start)&&(E.logger.log("Adjusting PTS using last level due to CC increase within current level "+a.url),L(s.start,a))}}(T,c,y),!c.alignedSliding&&y.details&&h(c,y.details),c.alignedSliding||!y.details||c.skippedSegments||Object(A.adjustSliding)(y.details,c))}function h(T,y){if(y.fragments.length&&T.hasProgramDateTime&&y.hasProgramDateTime){var c=y.fragments[0].programDateTime,e=T.fragments[0].programDateTime,a=(e-c)/1e3+y.fragments[0].start;a&&Object(R.isFiniteNumber)(a)&&(E.logger.log("Adjusting PTS using programDateTime delta "+(e-c)+"ms, sliding:"+a.toFixed(3)+" "+T.url+" "),L(a,T))}}},"./src/utils/ewma-bandwidth-estimator.ts":function(N,C,f){f.r(C);var R=f("./src/utils/ewma.ts"),E=function(){function A(I,_,l){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=l,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new R.default(I),this.fast_=new R.default(_)}var D=A.prototype;return D.update=function(I,_){var l=this.slow_,L=this.fast_;this.slow_.halfLife!==I&&(this.slow_=new R.default(I,l.getEstimate(),l.getTotalWeight())),this.fast_.halfLife!==_&&(this.fast_=new R.default(_,L.getEstimate(),L.getTotalWeight()))},D.sample=function(I,_){var l=(I=Math.max(I,this.minDelayMs_))/1e3,L=8*_/l;this.fast_.sample(l,L),this.slow_.sample(l,L)},D.canEstimate=function(){var I=this.fast_;return I&&I.getTotalWeight()>=this.minWeight_},D.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},D.destroy=function(){},A}();C.default=E},"./src/utils/ewma.ts":function(N,C,f){f.r(C);var R=function(){function E(D,I,_){I===void 0&&(I=0),_===void 0&&(_=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=D,this.alpha_=D?Math.exp(Math.log(.5)/D):0,this.estimate_=I,this.totalWeight_=_}var A=E.prototype;return A.sample=function(D,I){var _=Math.pow(this.alpha_,D);this.estimate_=I*(1-_)+_*this.estimate_,this.totalWeight_+=D},A.getTotalWeight=function(){return this.totalWeight_},A.getEstimate=function(){if(this.alpha_){var D=1-Math.pow(this.alpha_,this.totalWeight_);if(D)return this.estimate_/D}return this.estimate_},E}();C.default=R},"./src/utils/fetch-loader.ts":function(N,C,f){f.r(C),f.d(C,"fetchSupported",function(){return m});var R=f("./src/polyfills/number.ts"),E=f("./src/loader/load-stats.ts"),A=f("./src/demux/chunk-cache.ts");function D(c){var e=typeof Map=="function"?new Map:void 0;return(D=function(a){if(a===null||(t=a,Function.toString.call(t).indexOf("[native code]")===-1))return a;var t;if(typeof a!="function")throw new TypeError("Super expression must either be null or a function");if(e!==void 0){if(e.has(a))return e.get(a);e.set(a,s)}function s(){return I(a,arguments,L(this).constructor)}return s.prototype=Object.create(a.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),l(s,a)})(c)}function I(c,e,a){return(I=_()?Reflect.construct:function(t,s,d){var n=[null];n.push.apply(n,s);var u=new(Function.bind.apply(t,n));return d&&l(u,d.prototype),u}).apply(null,arguments)}function _(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function l(c,e){return(l=Object.setPrototypeOf||function(a,t){return a.__proto__=t,a})(c,e)}function L(c){return(L=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(c)}function m(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var h=function(){function c(a){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=a.fetchSetup||T,this.controller=new self.AbortController,this.stats=new E.LoadStats}var e=c.prototype;return e.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},e.abortInternal=function(){var a=this.response;a&&a.ok||(this.stats.aborted=!0,this.controller.abort())},e.abort=function(){var a;this.abortInternal(),(a=this.callbacks)!==null&&a!==void 0&&a.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},e.load=function(a,t,s){var d=this,n=this.stats;if(n.loading.start)throw new Error("Loader can only be used once.");n.loading.start=self.performance.now();var u=function(i,r){var o={method:"GET",mode:"cors",credentials:"same-origin",signal:r};return i.rangeEnd&&(o.headers=new self.Headers({Range:"bytes="+i.rangeStart+"-"+String(i.rangeEnd-1)})),o}(a,this.controller.signal),p=s.onProgress,g=a.responseType==="arraybuffer",v=g?"byteLength":"length";this.context=a,this.config=t,this.callbacks=s,this.request=this.fetchSetup(a,u),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){d.abortInternal(),s.onTimeout(n,a,d.response)},t.timeout),self.fetch(this.request).then(function(i){if(d.response=d.loader=i,!i.ok){var r=i.status,o=i.statusText;throw new y(o||"fetch, bad network response",r,i)}return n.loading.first=Math.max(self.performance.now(),n.loading.start),n.total=parseInt(i.headers.get("Content-Length")||"0"),p&&Object(R.isFiniteNumber)(t.highWaterMark)?d.loadProgressively(i,n,a,t.highWaterMark,p):g?i.arrayBuffer():i.text()}).then(function(i){var r=d.response;self.clearTimeout(d.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first),n.loaded=n.total=i[v];var o={url:r.url,data:i};p&&!Object(R.isFiniteNumber)(t.highWaterMark)&&p(n,a,i,r),s.onSuccess(o,n,a,r)}).catch(function(i){if(self.clearTimeout(d.requestTimeout),!n.aborted){var r=i.code||0;s.onError({code:r,text:i.message},a,i.details)}})},e.getCacheAge=function(){var a=null;if(this.response){var t=this.response.headers.get("age");a=t?parseFloat(t):null}return a},e.loadProgressively=function(a,t,s,d,n){d===void 0&&(d=0);var u=new A.default,p=a.body.getReader();return function g(){return p.read().then(function(v){if(v.done)return u.dataLength&&n(t,s,u.flush(),a),Promise.resolve(new ArrayBuffer(0));var i=v.value,r=i.length;return t.loaded+=r,r<d||u.dataLength?(u.push(i),u.dataLength>=d&&n(t,s,u.flush(),a)):n(t,s,i,a),g()}).catch(function(){return Promise.reject()})}()},c}();function T(c,e){return new self.Request(c.url,e)}var y=function(c){var e,a;function t(s,d,n){var u;return(u=c.call(this,s)||this).code=void 0,u.details=void 0,u.code=d,u.details=n,u}return a=c,(e=t).prototype=Object.create(a.prototype),e.prototype.constructor=e,l(e,a),t}(D(Error));C.default=h},"./src/utils/imsc1-ttml-parser.ts":function(N,C,f){f.r(C),f.d(C,"IMSC1_CODEC",function(){return L}),f.d(C,"parseIMSC1",function(){return y});var R=f("./src/utils/mp4-tools.ts"),E=f("./src/utils/vttparser.ts"),A=f("./src/utils/vttcue.ts"),D=f("./src/demux/id3.ts"),I=f("./src/utils/timescale-conversion.ts"),_=f("./src/utils/webvtt-parser.ts");function l(){return(l=Object.assign||function(n){for(var u=1;u<arguments.length;u++){var p=arguments[u];for(var g in p)Object.prototype.hasOwnProperty.call(p,g)&&(n[g]=p[g])}return n}).apply(this,arguments)}var L="stpp.ttml.im1t",m=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,h=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,T={left:"start",center:"center",right:"end",start:"start",end:"end"};function y(n,u,p,g,v){var i=Object(R.findBox)(new Uint8Array(n),["mdat"]);if(i.length!==0){var r=i[0],o=Object(D.utf8ArrayToStr)(new Uint8Array(n,r.start,r.end-r.start)),S=Object(I.toTimescaleFromScale)(u,1,p);try{g(function(b,k){var x=new DOMParser().parseFromString(b,"text/xml").getElementsByTagName("tt")[0];if(!x)throw new Error("Invalid ttml");var w={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},O=Object.keys(w).reduce(function(U,j){return U[j]=x.getAttribute("ttp:"+j)||w[j],U},{}),P=x.getAttribute("xml:space")!=="preserve",F=e(c(x,"styling","style")),M=e(c(x,"layout","region")),B=c(x,"body","[begin]");return[].map.call(B,function(U){var j=a(U,P);if(!j||!U.hasAttribute("begin"))return null;var V=d(U.getAttribute("begin"),O),H=d(U.getAttribute("dur"),O),z=d(U.getAttribute("end"),O);if(V===null)throw s(U);if(z===null){if(H===null)throw s(U);z=V+H}var W=new A.default(V-k,z-k,j);W.id=Object(_.generateCueId)(W.startTime,W.endTime,W.text);var X=M[U.getAttribute("region")],ne=F[U.getAttribute("style")];W.position=10,W.size=80;var se=function(de,re){var ae="http://www.w3.org/ns/ttml#styling";return["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"].reduce(function(Y,ee){var le=t(re,ae,ee)||t(de,ae,ee);return le&&(Y[ee]=le),Y},{})}(X,ne),oe=se.textAlign;if(oe){var te=T[oe];te&&(W.lineAlign=te),W.align=oe}return l(W,se),W}).filter(function(U){return U!==null})}(o,S))}catch(b){v(b)}}else v(new Error("Could not parse IMSC1 mdat"))}function c(n,u,p){var g=n.getElementsByTagName(u)[0];return g?[].slice.call(g.querySelectorAll(p)):[]}function e(n){return n.reduce(function(u,p){var g=p.getAttribute("xml:id");return g&&(u[g]=p),u},{})}function a(n,u){return[].slice.call(n.childNodes).reduce(function(p,g,v){var i;return g.nodeName==="br"&&v?p+`
|
||
`:(i=g.childNodes)!==null&&i!==void 0&&i.length?a(g,u):u?p+g.textContent.trim().replace(/\s+/g," "):p+g.textContent},"")}function t(n,u,p){return n.hasAttributeNS(u,p)?n.getAttributeNS(u,p):null}function s(n){return new Error("Could not parse ttml timestamp "+n)}function d(n,u){if(!n)return null;var p=Object(E.parseTimeStamp)(n);return p===null&&(m.test(n)?p=function(g,v){var i=m.exec(g),r=(0|i[4])+(0|i[5])/v.subFrameRate;return 3600*(0|i[1])+60*(0|i[2])+(0|i[3])+r/v.frameRate}(n,u):h.test(n)&&(p=function(g,v){var i=h.exec(g),r=Number(i[1]);switch(i[2]){case"h":return 3600*r;case"m":return 60*r;case"ms":return 1e3*r;case"f":return r/v.frameRate;case"t":return r/v.tickRate}return r}(n,u))),p}},"./src/utils/logger.ts":function(N,C,f){f.r(C),f.d(C,"enableLogs",function(){return I}),f.d(C,"logger",function(){return _});var R=function(){},E={trace:R,debug:R,log:R,warn:R,info:R,error:R},A=E;function D(l){var L=self.console[l];return L?L.bind(self.console,"["+l+"] >"):R}function I(l){if(self.console&&l===!0||typeof l=="object"){(function(L){for(var m=arguments.length,h=new Array(m>1?m-1:0),T=1;T<m;T++)h[T-1]=arguments[T];h.forEach(function(y){A[y]=L[y]?L[y].bind(L):D(y)})})(l,"debug","log","info","warn","error");try{A.log()}catch{A=E}}else A=E}var _=E},"./src/utils/mediakeys-helper.ts":function(N,C,f){var R,E;f.r(C),f.d(C,"KeySystems",function(){return R}),f.d(C,"requestMediaKeySystemAccess",function(){return A}),(E=R||(R={})).WIDEVINE="com.widevine.alpha",E.PLAYREADY="com.microsoft.playready";var A=typeof self<"u"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null},"./src/utils/mediasource-helper.ts":function(N,C,f){function R(){return self.MediaSource||self.WebKitMediaSource}f.r(C),f.d(C,"getMediaSource",function(){return R})},"./src/utils/mp4-tools.ts":function(N,C,f){f.r(C),f.d(C,"bin2str",function(){return I}),f.d(C,"readUint16",function(){return _}),f.d(C,"readUint32",function(){return l}),f.d(C,"writeUint32",function(){return L}),f.d(C,"findBox",function(){return m}),f.d(C,"parseSegmentIndex",function(){return h}),f.d(C,"parseInitSegment",function(){return T}),f.d(C,"getStartDTS",function(){return y}),f.d(C,"getDuration",function(){return c}),f.d(C,"computeRawDurationFromSamples",function(){return e}),f.d(C,"offsetStartDTS",function(){return a}),f.d(C,"segmentValidRange",function(){return t}),f.d(C,"appendUint8Array",function(){return s});var R=f("./src/utils/typed-array.ts"),E=f("./src/loader/fragment.ts"),A=Math.pow(2,32)-1,D=[].push;function I(d){return String.fromCharCode.apply(null,d)}function _(d,n){"data"in d&&(n+=d.start,d=d.data);var u=d[n]<<8|d[n+1];return u<0?65536+u:u}function l(d,n){"data"in d&&(n+=d.start,d=d.data);var u=d[n]<<24|d[n+1]<<16|d[n+2]<<8|d[n+3];return u<0?4294967296+u:u}function L(d,n,u){"data"in d&&(n+=d.start,d=d.data),d[n]=u>>24,d[n+1]=u>>16&255,d[n+2]=u>>8&255,d[n+3]=255&u}function m(d,n){var u,p,g,v=[];if(!n.length)return v;"data"in d?(u=d.data,p=d.start,g=d.end):(p=0,g=(u=d).byteLength);for(var i=p;i<g;){var r=l(u,i),o=r>1?i+r:g;if(I(u.subarray(i+4,i+8))===n[0])if(n.length===1)v.push({data:u,start:i+8,end:o});else{var S=m({data:u,start:i+8,end:o},n.slice(1));S.length&&D.apply(v,S)}i=o}return v}function h(d){var n=m(d,["moov"])[0],u=n?n.end:null,p=m(d,["sidx"]);if(!p||!p[0])return null;var g=[],v=p[0],i=v.data[0],r=i===0?8:16,o=l(v,r);r+=4,r+=i===0?8:16,r+=2;var S=v.end+0,b=_(v,r);r+=2;for(var k=0;k<b;k++){var x=r,w=l(v,x);x+=4;var O=2147483647&w;if((2147483648&w)>>>31==1)return console.warn("SIDX has hierarchical references (not supported)"),null;var P=l(v,x);x+=4,g.push({referenceSize:O,subsegmentDuration:P,info:{duration:P/o,start:S,end:S+O-1}}),S+=O,r=x+=4}return{earliestPresentationTime:0,timescale:o,version:i,referencesCount:b,references:g,moovEndOffset:u}}function T(d){for(var n=[],u=m(d,["moov","trak"]),p=0;p<u.length;p++){var g=u[p],v=m(g,["tkhd"])[0];if(v){var i=v.data[v.start],r=i===0?12:20,o=l(v,r),S=m(g,["mdia","mdhd"])[0];if(S){var b=l(S,r=(i=S.data[S.start])===0?12:20),k=m(g,["mdia","hdlr"])[0];if(k){var x=I(k.data.subarray(k.start+8,k.start+12)),w={soun:E.ElementaryStreamTypes.AUDIO,vide:E.ElementaryStreamTypes.VIDEO}[x];if(w){var O=m(g,["mdia","minf","stbl","stsd"])[0],P=void 0;O&&(P=I(O.data.subarray(O.start+12,O.start+16))),n[o]={timescale:b,type:w},n[w]={timescale:b,id:o,codec:P}}}}}}return m(d,["moov","mvex","trex"]).forEach(function(F){var M=l(F,4),B=n[M];B&&(B.default={duration:l(F,12),flags:l(F,20)})}),n}function y(d,n){return m(n,["moof","traf"]).reduce(function(u,p){var g=m(p,["tfdt"])[0],v=g.data[g.start],i=m(p,["tfhd"]).reduce(function(r,o){var S=l(o,4),b=d[S];if(b){var k=l(g,4);v===1&&(k*=Math.pow(2,32),k+=l(g,8));var x=k/(b.timescale||9e4);if(isFinite(x)&&(r===null||x<r))return x}return r},null);return i!==null&&isFinite(i)&&(u===null||i<u)?i:u},null)||0}function c(d,n){for(var u=0,p=0,g=0,v=m(d,["moof","traf"]),i=0;i<v.length;i++){var r=v[i],o=m(r,["tfhd"])[0],S=n[l(o,4)];if(S){var b=S.default,k=l(o,0)|(b==null?void 0:b.flags),x=b==null?void 0:b.duration;8&k&&(x=l(o,2&k?12:8));for(var w=S.timescale||9e4,O=m(r,["trun"]),P=0;P<O.length;P++)u=x?x*l(O[P],4):e(O[P]),S.type===E.ElementaryStreamTypes.VIDEO?p+=u/w:S.type===E.ElementaryStreamTypes.AUDIO&&(g+=u/w)}}if(p===0&&g===0){var F=h(d);if(F!=null&&F.references)return F.references.reduce(function(M,B){return M+B.info.duration||0},0)}return p||g}function e(d){var n=l(d,0),u=8;1&n&&(u+=4),4&n&&(u+=4);for(var p=0,g=l(d,4),v=0;v<g;v++)256&n&&(p+=l(d,u),u+=4),512&n&&(u+=4),1024&n&&(u+=4),2048&n&&(u+=4);return p}function a(d,n,u){m(n,["moof","traf"]).forEach(function(p){m(p,["tfhd"]).forEach(function(g){var v=l(g,4),i=d[v];if(i){var r=i.timescale||9e4;m(p,["tfdt"]).forEach(function(o){var S=o.data[o.start],b=l(o,4);if(S===0)L(o,4,b-u*r);else{b*=Math.pow(2,32),b+=l(o,8),b-=u*r,b=Math.max(b,0);var k=Math.floor(b/(A+1)),x=Math.floor(b%(A+1));L(o,4,k),L(o,8,x)}})}})})}function t(d){var n={valid:null,remainder:null},u=m(d,["moof"]);if(!u)return n;if(u.length<2)return n.remainder=d,n;var p=u[u.length-1];return n.valid=Object(R.sliceUint8)(d,0,p.start-8),n.remainder=Object(R.sliceUint8)(d,p.start-8),n}function s(d,n){var u=new Uint8Array(d.length+n.length);return u.set(d),u.set(n,d.length),u}},"./src/utils/output-filter.ts":function(N,C,f){f.r(C),f.d(C,"default",function(){return R});var R=function(){function E(D,I){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=D,this.trackName=I}var A=E.prototype;return A.dispatchCue=function(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},A.newCue=function(D,I,_){(this.startTime===null||this.startTime>D)&&(this.startTime=D),this.endTime=I,this.screen=_,this.timelineController.createCaptionsTrack(this.trackName)},A.reset=function(){this.cueRanges=[]},E}()},"./src/utils/texttrack-utils.ts":function(N,C,f){f.r(C),f.d(C,"sendAddTrackEvent",function(){return E}),f.d(C,"addCueToTrack",function(){return A}),f.d(C,"clearCurrentCues",function(){return D}),f.d(C,"removeCuesInRange",function(){return I}),f.d(C,"getCuesInRange",function(){return _});var R=f("./src/utils/logger.ts");function E(l,L){var m;try{m=new Event("addtrack")}catch{(m=document.createEvent("Event")).initEvent("addtrack",!1,!1)}m.track=l,L.dispatchEvent(m)}function A(l,L){var m=l.mode;if(m==="disabled"&&(l.mode="hidden"),l.cues&&!l.cues.getCueById(L.id))try{if(l.addCue(L),!l.cues.getCueById(L.id))throw new Error("addCue is failed for: "+L)}catch(T){R.logger.debug("[texttrack-utils]: "+T);var h=new self.TextTrackCue(L.startTime,L.endTime,L.text);h.id=L.id,l.addCue(h)}m==="disabled"&&(l.mode=m)}function D(l){var L=l.mode;if(L==="disabled"&&(l.mode="hidden"),l.cues)for(var m=l.cues.length;m--;)l.removeCue(l.cues[m]);L==="disabled"&&(l.mode=L)}function I(l,L,m){var h=l.mode;if(h==="disabled"&&(l.mode="hidden"),l.cues&&l.cues.length>0)for(var T=_(l.cues,L,m),y=0;y<T.length;y++)l.removeCue(T[y]);h==="disabled"&&(l.mode=h)}function _(l,L,m){var h=[],T=function(a,t){if(t<a[0].startTime)return 0;var s=a.length-1;if(t>a[s].endTime)return-1;for(var d=0,n=s;d<=n;){var u=Math.floor((n+d)/2);if(t<a[u].startTime)n=u-1;else{if(!(t>a[u].startTime&&d<s))return u;d=u+1}}return a[d].startTime-t<t-a[n].startTime?d:n}(l,L);if(T>-1)for(var y=T,c=l.length;y<c;y++){var e=l[y];if(e.startTime>=L&&e.endTime<=m)h.push(e);else if(e.startTime>m)return h}return h}},"./src/utils/time-ranges.ts":function(N,C,f){f.r(C),C.default={toString:function(R){for(var E="",A=R.length,D=0;D<A;D++)E+="["+R.start(D).toFixed(3)+","+R.end(D).toFixed(3)+"]";return E}}},"./src/utils/timescale-conversion.ts":function(N,C,f){function R(I,_,l,L){l===void 0&&(l=1),L===void 0&&(L=!1);var m=I*_*l;return L?Math.round(m):m}function E(I,_,l,L){return l===void 0&&(l=1),L===void 0&&(L=!1),R(I,_,1/l,L)}function A(I,_){return _===void 0&&(_=!1),R(I,1e3,1/9e4,_)}function D(I,_){return _===void 0&&(_=1),R(I,9e4,1/_)}f.r(C),f.d(C,"toTimescaleFromBase",function(){return R}),f.d(C,"toTimescaleFromScale",function(){return E}),f.d(C,"toMsFromMpegTsClock",function(){return A}),f.d(C,"toMpegTsClockFromTimescale",function(){return D})},"./src/utils/typed-array.ts":function(N,C,f){function R(E,A,D){return Uint8Array.prototype.slice?E.slice(A,D):new Uint8Array(Array.prototype.slice.call(E,A,D))}f.r(C),f.d(C,"sliceUint8",function(){return R})},"./src/utils/vttcue.ts":function(N,C,f){f.r(C),C.default=function(){if(typeof self<"u"&&self.VTTCue)return self.VTTCue;var R=["","lr","rl"],E=["start","middle","end","left","right"];function A(l,L){if(typeof L!="string"||!Array.isArray(l))return!1;var m=L.toLowerCase();return!!~l.indexOf(m)&&m}function D(l){return A(E,l)}function I(l){for(var L=arguments.length,m=new Array(L>1?L-1:0),h=1;h<L;h++)m[h-1]=arguments[h];for(var T=1;T<arguments.length;T++){var y=arguments[T];for(var c in y)l[c]=y[c]}return l}function _(l,L,m){var h=this,T={enumerable:!0};h.hasBeenReset=!1;var y="",c=!1,e=l,a=L,t=m,s=null,d="",n=!0,u="auto",p="start",g=50,v="middle",i=50,r="middle";Object.defineProperty(h,"id",I({},T,{get:function(){return y},set:function(o){y=""+o}})),Object.defineProperty(h,"pauseOnExit",I({},T,{get:function(){return c},set:function(o){c=!!o}})),Object.defineProperty(h,"startTime",I({},T,{get:function(){return e},set:function(o){if(typeof o!="number")throw new TypeError("Start time must be set to a number.");e=o,this.hasBeenReset=!0}})),Object.defineProperty(h,"endTime",I({},T,{get:function(){return a},set:function(o){if(typeof o!="number")throw new TypeError("End time must be set to a number.");a=o,this.hasBeenReset=!0}})),Object.defineProperty(h,"text",I({},T,{get:function(){return t},set:function(o){t=""+o,this.hasBeenReset=!0}})),Object.defineProperty(h,"region",I({},T,{get:function(){return s},set:function(o){s=o,this.hasBeenReset=!0}})),Object.defineProperty(h,"vertical",I({},T,{get:function(){return d},set:function(o){var S=function(b){return A(R,b)}(o);if(S===!1)throw new SyntaxError("An invalid or illegal string was specified.");d=S,this.hasBeenReset=!0}})),Object.defineProperty(h,"snapToLines",I({},T,{get:function(){return n},set:function(o){n=!!o,this.hasBeenReset=!0}})),Object.defineProperty(h,"line",I({},T,{get:function(){return u},set:function(o){if(typeof o!="number"&&o!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");u=o,this.hasBeenReset=!0}})),Object.defineProperty(h,"lineAlign",I({},T,{get:function(){return p},set:function(o){var S=D(o);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");p=S,this.hasBeenReset=!0}})),Object.defineProperty(h,"position",I({},T,{get:function(){return g},set:function(o){if(o<0||o>100)throw new Error("Position must be between 0 and 100.");g=o,this.hasBeenReset=!0}})),Object.defineProperty(h,"positionAlign",I({},T,{get:function(){return v},set:function(o){var S=D(o);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");v=S,this.hasBeenReset=!0}})),Object.defineProperty(h,"size",I({},T,{get:function(){return i},set:function(o){if(o<0||o>100)throw new Error("Size must be between 0 and 100.");i=o,this.hasBeenReset=!0}})),Object.defineProperty(h,"align",I({},T,{get:function(){return r},set:function(o){var S=D(o);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");r=S,this.hasBeenReset=!0}})),h.displayState=void 0}return _.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},_}()},"./src/utils/vttparser.ts":function(N,C,f){f.r(C),f.d(C,"parseTimeStamp",function(){return A}),f.d(C,"fixLineBreaks",function(){return m}),f.d(C,"VTTParser",function(){return h});var R=f("./src/utils/vttcue.ts"),E=function(){function T(){}return T.prototype.decode=function(y,c){if(!y)return"";if(typeof y!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(y))},T}();function A(T){function y(e,a,t,s){return 3600*(0|e)+60*(0|a)+(0|t)+parseFloat(s||0)}var c=T.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return c?parseFloat(c[2])>59?y(c[2],c[3],0,c[4]):y(c[1],c[2],c[3],c[4]):null}var D=function(){function T(){this.values=Object.create(null)}var y=T.prototype;return y.set=function(c,e){this.get(c)||e===""||(this.values[c]=e)},y.get=function(c,e,a){return a?this.has(c)?this.values[c]:e[a]:this.has(c)?this.values[c]:e},y.has=function(c){return c in this.values},y.alt=function(c,e,a){for(var t=0;t<a.length;++t)if(e===a[t]){this.set(c,e);break}},y.integer=function(c,e){/^-?\d+$/.test(e)&&this.set(c,parseInt(e,10))},y.percent=function(c,e){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(e)){var a=parseFloat(e);if(a>=0&&a<=100)return this.set(c,a),!0}return!1},T}();function I(T,y,c,e){var a=e?T.split(e):[T];for(var t in a)if(typeof a[t]=="string"){var s=a[t].split(c);s.length===2&&y(s[0],s[1])}}var _=new R.default(0,0,""),l=_.align==="middle"?"middle":"center";function L(T,y,c){var e=T;function a(){var s=A(T);if(s===null)throw new Error("Malformed timestamp: "+e);return T=T.replace(/^[^\sa-zA-Z-]+/,""),s}function t(){T=T.replace(/^\s+/,"")}if(t(),y.startTime=a(),t(),T.substr(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+e);T=T.substr(3),t(),y.endTime=a(),t(),function(s,d){var n=new D;I(s,function(g,v){var i;switch(g){case"region":for(var r=c.length-1;r>=0;r--)if(c[r].id===v){n.set(g,c[r].region);break}break;case"vertical":n.alt(g,v,["rl","lr"]);break;case"line":i=v.split(","),n.integer(g,i[0]),n.percent(g,i[0])&&n.set("snapToLines",!1),n.alt(g,i[0],["auto"]),i.length===2&&n.alt("lineAlign",i[1],["start",l,"end"]);break;case"position":i=v.split(","),n.percent(g,i[0]),i.length===2&&n.alt("positionAlign",i[1],["start",l,"end","line-left","line-right","auto"]);break;case"size":n.percent(g,v);break;case"align":n.alt(g,v,["start",l,"end","left","right"])}},/:/,/\s/),d.region=n.get("region",null),d.vertical=n.get("vertical","");var u=n.get("line","auto");u==="auto"&&_.line===-1&&(u=-1),d.line=u,d.lineAlign=n.get("lineAlign","start"),d.snapToLines=n.get("snapToLines",!0),d.size=n.get("size",100),d.align=n.get("align",l);var p=n.get("position","auto");p==="auto"&&_.position===50&&(p=d.align==="start"||d.align==="left"?0:d.align==="end"||d.align==="right"?100:50),d.position=p}(T,y)}function m(T){return T.replace(/<br(?: \/)?>/gi,`
|
||
`)}var h=function(){function T(){this.state="INITIAL",this.buffer="",this.decoder=new E,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var y=T.prototype;return y.parse=function(c){var e=this;function a(){var u=e.buffer,p=0;for(u=m(u);p<u.length&&u[p]!=="\r"&&u[p]!==`
|
||
`;)++p;var g=u.substr(0,p);return u[p]==="\r"&&++p,u[p]===`
|
||
`&&++p,e.buffer=u.substr(p),g}c&&(e.buffer+=e.decoder.decode(c,{stream:!0}));try{var t="";if(e.state==="INITIAL"){if(!/\r\n|\n/.test(e.buffer))return this;var s=(t=a()).match(/^()?WEBVTT([ \t].*)?$/);if(!s||!s[0])throw new Error("Malformed WebVTT signature.");e.state="HEADER"}for(var d=!1;e.buffer;){if(!/\r\n|\n/.test(e.buffer))return this;switch(d?d=!1:t=a(),e.state){case"HEADER":/:/.test(t)?I(t,function(u,p){},/:/):t||(e.state="ID");continue;case"NOTE":t||(e.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(t)){e.state="NOTE";break}if(!t)continue;if(e.cue=new R.default(0,0,""),e.state="CUE",t.indexOf("-->")===-1){e.cue.id=t;continue}case"CUE":if(!e.cue){e.state="BADCUE";continue}try{L(t,e.cue,e.regionList)}catch{e.cue=null,e.state="BADCUE";continue}e.state="CUETEXT";continue;case"CUETEXT":var n=t.indexOf("-->")!==-1;if(!t||n&&(d=!0)){e.oncue&&e.cue&&e.oncue(e.cue),e.cue=null,e.state="ID";continue}if(e.cue===null)continue;e.cue.text&&(e.cue.text+=`
|
||
`),e.cue.text+=t;continue;case"BADCUE":t||(e.state="ID")}}}catch{e.state==="CUETEXT"&&e.cue&&e.oncue&&e.oncue(e.cue),e.cue=null,e.state=e.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},y.flush=function(){var c=this;try{if((c.cue||c.state==="HEADER")&&(c.buffer+=`
|
||
|
||
`,c.parse()),c.state==="INITIAL"||c.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(e){c.onparsingerror&&c.onparsingerror(e)}return c.onflush&&c.onflush(),this},T}()},"./src/utils/webvtt-parser.ts":function(N,C,f){f.r(C),f.d(C,"generateCueId",function(){return m}),f.d(C,"parseWebVTT",function(){return h});var R=f("./src/polyfills/number.ts"),E=f("./src/utils/vttparser.ts"),A=f("./src/demux/id3.ts"),D=f("./src/utils/timescale-conversion.ts"),I=f("./src/remux/mp4-remuxer.ts"),_=/\r\n|\n\r|\n|\r/g,l=function(T,y,c){return c===void 0&&(c=0),T.substr(c,y.length)===y},L=function(T){for(var y=5381,c=T.length;c;)y=33*y^T.charCodeAt(--c);return(y>>>0).toString()};function m(T,y,c){return L(T.toString())+L(y.toString())+L(c)}function h(T,y,c,e,a,t,s,d){var n,u=new E.VTTParser,p=Object(A.utf8ArrayToStr)(new Uint8Array(T)).trim().replace(_,`
|
||
`).split(`
|
||
`),g=[],v=Object(D.toMpegTsClockFromTimescale)(y,c),i="00:00.000",r=0,o=0,S=!0,b=!1;u.oncue=function(k){var x=e[a],w=e.ccOffset,O=(r-v)/9e4;if(x!=null&&x.new&&(o!==void 0?w=e.ccOffset=x.start:function(B,U,j){var V=B[U],H=B[V.prevCC];if(!H||!H.new&&V.new)return B.ccOffset=B.presentationOffset=V.start,void(V.new=!1);for(;(z=H)!==null&&z!==void 0&&z.new;){var z;B.ccOffset+=V.start-H.start,V.new=!1,H=B[(V=H).prevCC]}B.presentationOffset=j}(e,a,O)),O&&(w=O-e.presentationOffset),b){var P=k.endTime-k.startTime,F=Object(I.normalizePts)(9e4*(k.startTime+w-o),9e4*t)/9e4;k.startTime=F,k.endTime=F+P}var M=k.text.trim();k.text=decodeURIComponent(encodeURIComponent(M)),k.id||(k.id=m(k.startTime,k.endTime,M)),k.endTime>0&&g.push(k)},u.onparsingerror=function(k){n=k},u.onflush=function(){n?d(n):s(g)},p.forEach(function(k){if(S){if(l(k,"X-TIMESTAMP-MAP=")){S=!1,b=!0,k.substr(16).split(",").forEach(function(x){l(x,"LOCAL:")?i=x.substr(6):l(x,"MPEGTS:")&&(r=parseInt(x.substr(7)))});try{o=function(x){var w=parseInt(x.substr(-3)),O=parseInt(x.substr(-6,2)),P=parseInt(x.substr(-9,2)),F=x.length>9?parseInt(x.substr(0,x.indexOf(":"))):0;if(!(Object(R.isFiniteNumber)(w)&&Object(R.isFiniteNumber)(O)&&Object(R.isFiniteNumber)(P)&&Object(R.isFiniteNumber)(F)))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+x);return w+=1e3*O,(w+=6e4*P)+36e5*F}(i)/1e3}catch(x){b=!1,n=x}return}k===""&&(S=!1)}u.parse(k+`
|
||
`)}),u.flush()}},"./src/utils/xhr-loader.ts":function(N,C,f){f.r(C);var R=f("./src/utils/logger.ts"),E=f("./src/loader/load-stats.ts"),A=/^age:\s*[\d.]+\s*$/m,D=function(){function I(l){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=l?l.xhrSetup:null,this.stats=new E.LoadStats,this.retryDelay=0}var _=I.prototype;return _.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},_.abortInternal=function(){var l=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),l&&(l.onreadystatechange=null,l.onprogress=null,l.readyState!==4&&(this.stats.aborted=!0,l.abort()))},_.abort=function(){var l;this.abortInternal(),(l=this.callbacks)!==null&&l!==void 0&&l.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},_.load=function(l,L,m){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=l,this.config=L,this.callbacks=m,this.retryDelay=L.retryDelay,this.loadInternal()},_.loadInternal=function(){var l=this.config,L=this.context;if(l){var m=this.loader=new self.XMLHttpRequest,h=this.stats;h.loading.first=0,h.loaded=0;var T=this.xhrSetup;try{if(T)try{T(m,L.url)}catch{m.open("GET",L.url,!0),T(m,L.url)}m.readyState||m.open("GET",L.url,!0)}catch(y){return void this.callbacks.onError({code:m.status,text:y.message},L,m)}L.rangeEnd&&m.setRequestHeader("Range","bytes="+L.rangeStart+"-"+(L.rangeEnd-1)),m.onreadystatechange=this.readystatechange.bind(this),m.onprogress=this.loadprogress.bind(this),m.responseType=L.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),l.timeout),m.send()}},_.readystatechange=function(){var l=this.context,L=this.loader,m=this.stats;if(l&&L){var h=L.readyState,T=this.config;if(!m.aborted&&h>=2)if(self.clearTimeout(this.requestTimeout),m.loading.first===0&&(m.loading.first=Math.max(self.performance.now(),m.loading.start)),h===4){L.onreadystatechange=null,L.onprogress=null;var y=L.status;if(y>=200&&y<300){var c,e;if(m.loading.end=Math.max(self.performance.now(),m.loading.first),e=l.responseType==="arraybuffer"?(c=L.response).byteLength:(c=L.responseText).length,m.loaded=m.total=e,!this.callbacks)return;var a=this.callbacks.onProgress;if(a&&a(m,l,c,L),!this.callbacks)return;var t={url:L.responseURL,data:c};this.callbacks.onSuccess(t,m,l,L)}else m.retry>=T.maxRetry||y>=400&&y<499?(R.logger.error(y+" while loading "+l.url),this.callbacks.onError({code:y,text:L.statusText},l,L)):(R.logger.warn(y+" while loading "+l.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,T.maxRetryDelay),m.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),T.timeout)}},_.loadtimeout=function(){R.logger.warn("timeout while loading "+this.context.url);var l=this.callbacks;l&&(this.abortInternal(),l.onTimeout(this.stats,this.context,this.loader))},_.loadprogress=function(l){var L=this.stats;L.loaded=l.loaded,l.lengthComputable&&(L.total=l.total)},_.getCacheAge=function(){var l=null;if(this.loader&&A.test(this.loader.getAllResponseHeaders())){var L=this.loader.getResponseHeader("age");l=L?parseFloat(L):null}return l},I}();C.default=D}}).default);var it=vr(Lt.exports);const pr={name:"d-icon"},be=Object.assign(pr,{props:{icon:String,size:[Number,String]},setup:function(N){const C=N,f=Ce(()=>({fontSize:/^\d+$/.test(C.size)?C.size+"px":C.size}));return(R,E)=>($(),Q("i",{class:Se(["d-icon iconfont",N.icon]),style:Ue(G(f))},null,6))}});be.__scopeId="data-v-0c690e66";Ke("data-v-4cb76d59");const mr={class:"d-player-top"},yr={class:"top-title"},Er={class:"top-title"};Ve();const Tr={props:{title:{default:""}},setup(N){Date.prototype.format=function(R){let E={"h+":this.getHours(),"m+":this.getMinutes(),"s+":this.getSeconds()};for(var A in E)new RegExp("("+A+")").test(R)&&(R=R.replace(RegExp.$1,RegExp.$1.length==1?E[A]:("00"+E[A]).substr((""+E[A]).length)));return R};let C=me("00:00:00");C.value=new Date().format("hh:mm:ss");let f=null;return f=setInterval(()=>{C.value=new Date().format("hh:mm:ss")},1e3),yt(()=>{clearInterval(f)}),(R,E)=>($(),Q("div",mr,[K("p",yr,J(N.title||""),1),K("p",Er,J(G(C)),1)]))},__scopeId:"data-v-4cb76d59"};Ke("data-v-ac2469ec");const Sr={class:"d-status"},br={class:"d-flex-center"},Lr={class:"d-flex-center"},Ar=ce("5X速播放中 ");Ve();var At=we({props:["state"],setup:N=>(C,f)=>ge(($(),Q("div",Sr,[ge(K("li",br,[q(be,{size:"18",class:"d-status-icon",icon:"icon-volume-"+(N.state.volume==0?"mute":N.state.volume>.5?"up":"down")},null,8,["icon"]),ce(" "+J(~~(100*N.state.volume))+"% ",1)],512),[[ve,N.state.handleType=="volume"]]),ge(K("li",Lr,[q(be,{size:"12",icon:"icon-play"}),q(be,{size:"12",icon:"icon-play",style:{"margin-right":"5px"}}),Ar],512),[[ve,N.state.handleType=="playbackRate"||N.state.isMultiplesPlay]])],512)),[[ve,N.state.handleType||N.state.isMultiplesPlay]])});At.__scopeId="data-v-ac2469ec",Ke("data-v-385f7870");const kr=["checked","true-value","false-value"],_r=K("span",{class:"d-switch_action"},null,-1);Ve();var rt=we({props:{modelValue:{type:[Number,String,Boolean]},width:{type:String,default:"40px"},trueValue:{type:[Number,String,Boolean],default:!0},falseValue:{type:[Number,String,Boolean],default:!0},activeColor:{type:[String],default:"#409EFF"}},emits:["update:modelValue","change"],setup(N,{emit:C}){const f=N;ut(D=>({"014e5dc0":N.width,e4e32852:N.activeColor}));const R=me(null),E=Ce(()=>f.modelValue===f.trueValue),A=()=>{Et(()=>{const D=R.value.checked;C("update:modelValue",D),C("change",D)})};return(D,I)=>($(),Q("div",{class:Se(["d-switch",{"is-checked":G(E)}])},[K("input",{class:"d-switch__input",ref:R,type:"checkbox",checked:G(E),onChange:A,"true-value":N.trueValue,"false-value":N.falseValue},null,40,kr),_r],2))}});rt.__scopeId="data-v-385f7870",Ke("data-v-b2384226");const Dr={key:0},Rr=K("i",{class:"rotating iconfont icon-loading f50"},null,-1),Ir=[K("i",{class:"rotating iconfont icon-loading f50"},null,-1),K("p",null,"正在缓冲...",-1)],Cr=[K("i",{class:"iconfont icon-replay f24 mr5"},null,-1),ce("重新播放 ")],wr=[K("i",{class:"iconfont icon-replay f24 mr5"},null,-1),ce("请求错误 ")];Ve();var kt=we({props:{loadType:String,text:{type:String,default:""}},setup(N){const C=N,{proxy:f}=wt(),R=["loadstart","waiting","ended","error","stalled"],E=()=>{f.$parent.play()},A=Ce(()=>{let D="background: rgba(0, 0, 0, .1);z-index:1";return C.loadType=="loadstart"&&(D="background: rgba(0, 0, 0, 1);;z-index:3"),D});return(D,I)=>ge(($(),Q("div",{class:"d-loading",style:Ue(G(A))},[K("div",null,[N.loadType=="loadstart"?($(),Q("span",Dr,[Rr,K("p",null,J(N.text),1)])):ue("",!0),ge(K("span",null,Ir,512),[[ve,N.loadType=="waiting"]]),ge(K("span",null,[K("p",{onClick:E,class:"d-flex-x d-pointer"},Cr)],512),[[ve,N.loadType=="ended"]]),ge(K("span",null,[K("p",{onClick:E,class:"d-flex-x d-pointer"},wr)],512),[[ve,N.loadType=="error"||N.loadType=="stalled"]])])],4)),[[ve,R.includes(N.loadType)]])}});kt.__scopeId="data-v-b2384226";const Ge=function(N,C,f,R=!1){N&&C&&f&&N.addEventListener(C,f,R)},pe=function(N,C,f,R=!1){N&&C&&f&&N.removeEventListener(C,f,R)};Ke("data-v-5a794390");const xr=["onMousedown"];Ve();var Xe=we(lt(ot({},{name:"DSlider"}),{props:{modelValue:{required:!0,type:Number,default:0},disabled:{type:Boolean,default:!1},vertical:{type:Boolean,default:!1},hover:{type:Boolean,default:!0},hoverText:{type:String,default:""},preload:{type:Number,default:0},size:{type:String,default:"10px"}},emits:["update:modelValue","change","onMousemove"],setup:function(N,{emit:C}){const f=N;ut(e=>({"5242b67b":N.size}));const R=me(null),E=me(null),A=Te({dragging:!1,hoverPosition:0,hoverTipsLeft:"50%"}),D=Ce(()=>{let e=f.modelValue<0?0:f.modelValue>1?1:f.modelValue;return f.vertical?`height:${100*e}%`:`width:${100*e}%`}),I=Ce(()=>{let e=f.preload<0?0:f.preload>1?1:f.preload;return f.vertical?`height:${100*e}%`:`width:${100*e}%`}),_=Ce(()=>{let e=A.hoverPosition<0?0:A.hoverPosition>1?1:A.hoverPosition;return f.vertical?`bottom:${100*e}%`:`left:${100*e}%`}),l=e=>{e.preventDefault()},L=e=>{f.disabled||(e.preventDefault(),A.dragging=!0,h(e),Ge(window,"mousemove",y),Ge(window,"touchmove",y),Ge(window,"mouseup",c),Ge(window,"touchend",c))},m=e=>{if(!f.hover)return;let a=T(e);if(C("onMousemove",e,a),A.hoverPosition=a,f.vertical)return;let t=R.value,s=E.value.clientWidth/2,d=e.clientX-t.getBoundingClientRect().left;d<s?A.hoverTipsLeft=s-d+"px":t.clientWidth-d<s?A.hoverTipsLeft=t.clientWidth-d-s+"px":A.hoverTipsLeft="50%"},h=e=>{let a=T(e);C("update:modelValue",a),C("change",e,a)},T=e=>{let a=R.value,t=0;if(f.vertical){let s=a.clientHeight;t=(a.getBoundingClientRect().bottom-e.clientY)/s}else t=(e.clientX-a.getBoundingClientRect().left)/a.clientWidth;return t<0?0:t>1?1:t},y=e=>{h(e)},c=e=>{A.dragging&&(pe(window,"mousemove",y),pe(window,"touchmove",y),pe(window,"mouseup",c),pe(window,"touchend",c),pe(window,"contextmenu",c),setTimeout(()=>{A.dragging=!1},0))};return(e,a)=>($(),Q("div",{ref:R,class:Se(["d-slider",{"is-vertical":f.vertical}]),onMousedown:It(L,["stop"]),onContextmenu:l},[K("div",{class:"d-slider__runway",onMousemove:m},[ge(K("div",{class:"d-slider__cursor",style:Ue(G(_))},[ge(K("div",{class:"d-slider__tips",ref:E,style:Ue({left:G(A).hoverTipsLeft})},J(f.hoverText),5),[[ve,f.hoverText]])],4),[[ve,f.hover]]),K("div",{class:"d-slider__preload",style:Ue(G(I))},null,4),K("div",{class:"d-slider__bar",style:Ue(G(D))},null,4)],32)],42,xr))}}));Xe.__scopeId="data-v-5a794390";Ke("data-v-570fa0d1");const Or={key:0,class:"d-player-dialog"},Pr={class:"d-player-dialog-body"},Fr={class:"d-player-dialog-title"},Mr={class:"d-player-hotkey-panel"},Nr={class:"d-player-filter-panel"},Br={class:"d-player-filter-panel-item"},Ur=K("span",null,"饱和度",-1),Gr={class:"d-player-filter-panel-item"},jr=K("span",null,"亮度",-1),Kr={class:"d-player-filter-panel-item"},Vr=K("span",null,"对比度",-1),Hr={key:0,class:"d-player-contextmenu"},Wr=["dplayerKeyCode"],Yr=K("input",{class:"d-player-copyText"},null,-1);Ve();var _t=we({setup(N){const C=Te({show:!1,dialogType:"",dialogTitle:"",version:"1.3.1-beta.6",mouseX:0,mouseY:0}),f=[{label:"视频色彩调整",key:"filter"},{label:"快捷键说明",key:"hotkey"},{label:"复制视频网址",key:"copy"},{label:"版本:1.3.1-beta.6",key:"version"}],R=[{key:"Space",label:"播放/暂停"},{key:"→",label:"单次快进10s,长按5倍速播放"},{key:"←",label:"快退5s"},{key:"↑",label:"音量增加10%"},{key:"↓",label:"音量增加降低10%"},{key:"Esc",label:"退出全屏/退出网页全屏"},{key:"F",label:"全屏/退出全屏"}],E=Te({saturate:.392,brightness:.392,contrast:.392}),A=Ce(()=>({left:C.mouseX+"px",top:C.mouseY+"px"}));ze(E,L=>{let m=document.querySelector("#dPlayerVideo"),h=(2.55*L.saturate).toFixed(2),T=(2.55*L.brightness).toFixed(2),y=(2.55*L.contrast).toFixed(2);m.style.filter=`saturate(${h}) brightness(${T}) contrast(${y})`});const D=()=>{E.saturate=.392,E.brightness=.392,E.contrast=.392},I=L=>{L.key=="Escape"&&l(0)},_=L=>{L.preventDefault(),Ge(window,"keydown",I),Ge(window,"click",l);let m=document.querySelector("#refPlayerWrap"),h=m.clientWidth;m.clientHeight,C.mouseX=L.clientX-m.getBoundingClientRect().left,h-C.mouseX<130&&(C.mouseX=C.mouseX+(h-C.mouseX-130)),C.mouseY=L.clientY-m.getBoundingClientRect().top,C.show=!0},l=L=>{let m=L.path[0].tagName=="LI",h=L.path[0].attributes.dplayerKeyCode&&L.path[0].attributes.dplayerKeyCode.value,T=f.map(y=>y.key);if(m&&T.includes(h))if(C.dialogTitle=L.path[0].innerText,C.dialogType=h,h=="copy"){let y=document.querySelector(".d-player-copyText");y.value=window.location.href,y.select(),document.execCommand("copy"),C.dialogType=""}else h=="version"&&(C.dialogType="");C.show=!1,pe(window,"keydown",I),pe(window,"click",l)};return mt(()=>{let L=document.querySelector("#refPlayerWrap");pe(window,"keydown",I),pe(window,"click",l),pe(L,"contextmenu",_),Ge(L,"contextmenu",_)}),yt(()=>{let L=document.querySelector("#refPlayerWrap");pe(window,"keydown",I),pe(window,"click",l),pe(L,"contextmenu",_)}),(L,m)=>($(),Q("div",null,[q(at,{name:"d-fade-in"},{default:Z(()=>[G(C).dialogType?($(),Q("div",Or,[K("div",Pr,[K("h5",Fr,[ce(J(G(C).dialogTitle)+" ",1),K("i",{onClick:m[0]||(m[0]=h=>G(C).dialogType=!1),class:"icon icon-close"},"X")]),ge(K("ul",Mr,[($(),Q(Pe,null,je(R,h=>K("li",{class:"d-player-hotkey-panel-item",key:h.key},[K("span",null,J(h.key),1),K("span",null,J(h.label),1)])),64))],512),[[ve,G(C).dialogType=="hotkey"]]),ge(K("ul",Nr,[K("li",Br,[Ur,q(Xe,{class:"filter-panel-slider",size:"5px",modelValue:G(E).saturate,"onUpdate:modelValue":m[1]||(m[1]=h=>G(E).saturate=h)},null,8,["modelValue"]),K("span",null,J(Math.round(255*G(E).saturate)),1)]),K("li",Gr,[jr,q(Xe,{class:"filter-panel-slider",size:"5px",modelValue:G(E).brightness,"onUpdate:modelValue":m[2]||(m[2]=h=>G(E).brightness=h)},null,8,["modelValue"]),K("span",null,J(Math.round(255*G(E).brightness)),1)]),K("li",Kr,[Vr,q(Xe,{class:"filter-panel-slider",size:"5px",modelValue:G(E).contrast,"onUpdate:modelValue":m[3]||(m[3]=h=>G(E).contrast=h)},null,8,["modelValue"]),K("span",null,J(Math.round(255*G(E).contrast)),1)]),K("span",{onClick:D,title:"重置","aria-label":"重置",class:"d-player-filter-reset"},"重置")],512),[[ve,G(C).dialogType=="filter"]])])])):ue("",!0)]),_:1}),G(C).show?($(),Q("div",Hr,[K("ul",{class:"d-player-contextmenu-body",style:Ue(G(A))},[($(),Q(Pe,null,je(f,h=>K("li",{dplayerKeyCode:h.key,key:h.key},J(h.label),9,Wr)),64))],4),Yr])):ue("",!0)]))}});_t.__scopeId="data-v-570fa0d1";const nt=N=>{let C=~~(N/3600),f=~~(N%3600/60),R=~~(N%60);return C=C<10?"0"+C:C,f=f<10?"0"+f:f,R=R<10?"0"+R:R,`${C}:${f}:${R}`},Je="ontouchstart"in window,pt=["loadstart","play","pause","playing","seeking","seeked","waiting","durationchange","progress","canplay","timeupdate","ended","error","stalled"],qr={width:{type:String,default:"800px"},height:{type:String,default:"450px"},color:{type:String,default:"#409eff"},src:{required:!0,type:String,default:""},title:{type:String,default:""},type:{type:String,default:"video/mp4"},poster:{type:String,default:""},webFullScreen:{type:Boolean,default:!1},speed:{type:Boolean,default:!0},currentTime:{type:Number,default:0},playsinline:{type:Boolean,default:!1},muted:{type:Boolean,default:!1},speedRate:{type:Array,default:()=>["2.0","1.5","1.25","1.0","0.75","0.5"]},autoPlay:{type:Boolean,default:!1},loop:{type:Boolean,default:!1},mirror:{type:Boolean,default:!1},ligthOff:{type:Boolean,default:!1},volume:{type:[String,Number],default:.3},control:{type:Boolean,default:!0},controlBtns:{type:Array,default:["audioTrack","quality","speedRate","volume","setting","pip","pageFullScreen","fullScreen"]},preload:{type:String,default:"auto"}};Ke("data-v-01791e9e");const zr={class:"d-player-video",id:"dPlayerVideo"},Xr=["controls","webkit-playsinline","playsinline","volume","muted","loop","preload","src","poster"],$r={class:"d-player-lightoff"},Qr={key:1,class:"d-player-state"},Zr={class:"d-play-btn"},Jr=["onKeyup","onKeydown"],ei={class:"d-control-progress"},ti={class:"d-tool-bar"},ri={key:0,class:"d-tool-item d-tool-time audioTrack-btn"},ii=K("span",{style:{margin:"0 3px"}},"/",-1),ni={class:"total-time"},ai={class:"d-tool-bar"},si={key:0,class:"d-tool-item quality-btn"},oi={class:"d-tool-item-main"},li={class:"speed-main",style:{"text-align":"center"}},ui=["onClick"],di={key:1,class:"d-tool-item speedRate-btn"},ci={class:"d-tool-item-main"},hi={class:"speed-main"},fi=["onClick"],gi={key:2,class:"d-tool-item volume-btn"},vi={class:"d-tool-item-main volume-box",style:{width:"52px"}},pi={class:"volume-text-size"},mi={key:3,class:"d-tool-item setting-btn"},yi={class:"d-tool-item-main"},Ei={class:"speed-main"},Ti=ce(" 镜像画面 "),Si=ce(" 循环播放 "),bi=ce(" 关灯模式 "),Li=K("div",{class:"d-tool-item-main"},"画中画",-1),Ai=K("div",{class:"d-tool-item-main"},"网页全屏",-1),ki=K("div",{class:"d-tool-item-main"},"全屏",-1);Ve();var et=we(lt(ot({},{name:"vue3VideoPlay",inheritAttrs:!1}),{props:qr,emits:[...pt,"mirrorChange","loopChange","lightOffChange"],setup:function(N,{expose:C,emit:f}){const R=N;ut(w=>({"51d4439c":G(T),"77e758a6":w.width,b8a1afc0:w.height}));const E=new it({fragLoadingTimeOut:2e3}),A=me(null),D=me(null),I=me(null),_=me(null),l=Te(lt(ot({dVideo:null},R),{muted:R.muted,playBtnState:R.autoPlay?"pause":"play",loadStateType:"loadstart",fullScreen:!1,handleType:"",currentTime:"00:00:00",preloadBar:0,totalTime:"00:00:00",isVideoHovering:!0,speedActive:"1.0",playProgress:0,isMultiplesPlay:!1,longPressTimeout:null,progressCursorTime:"00:00:00",qualityLevels:[],currentLevel:0})),L=(...w)=>O=>w.reverse().reduce((P,F)=>F(P),O),m=pt.reduce((w,O)=>{var P;return w[`on${P=O,P.charAt(0).toUpperCase()+P.slice(1)}`]=F=>{l.loadStateType=O,f(O,F)},w},{});m.onCanplay=L(m.onCanplay,()=>{l.playBtnState!="play"&&l.dVideo.play(),l.autoPlay&&(l.dVideo.play(),l.playBtnState="pause")}),m.onEnded=L(m.onEnded,()=>{l.playBtnState="replay"}),m.onDurationchange=w=>{f("durationchange",w),R.currentTime!=0&&(l.dVideo.currentTime=R.currentTime),m.onTimeupdate(w)},m.onProgress=w=>{console.log("缓冲中..."),f("progress",w);let O=w.target.duration,P=w.target.buffered,F=w.target.buffered.length&&w.target.buffered.end(P-1);l.preloadBar=F/O},m.onTimeupdate=w=>{f("timeupdate",w);let O=w.duration||w.target.duration||0,P=w.currentTime||w.target.currentTime;l.playProgress=P/O,l.currentTime=nt(P),l.totalTime=nt(O)},m.onError=L(m.onError,()=>{l.playBtnState="replay"});let h=Ct();for(let w in h)m[w]=h[w];const T=(y=l.color,`${parseInt("0x"+y.slice(1,3))},${parseInt("0x"+y.slice(3,5))},${parseInt("0x"+y.slice(5,7))}`);var y;const c=vt(500,()=>{l.handleType=""}),e=w=>{w.preventDefault(),w.code=="ArrowUp"?l.volume=l.volume+.1>1?1:l.volume+.1:l.volume=l.volume-.1<0?0:l.volume-.1,l.muted=!1,l.handleType="volume",c()},a=w=>{R.speed&&(l.dVideo.currentTime=l.dVideo.currentTime<10?.1:l.dVideo.currentTime-10,m.onTimeupdate(l.dVideo),d())},t=w=>{w.preventDefault();let O=w.type;if(w.key=="ArrowRight"){if(d(),O=="keyup"){if(clearTimeout(l.longPressTimeout),!R.speed&&!l.longPressTimeout)return;l.isMultiplesPlay?(l.dVideo.playbackRate=l.speedActive,l.isMultiplesPlay=!1):(l.dVideo.currentTime=l.dVideo.currentTime+10,m.onTimeupdate(l.dVideo))}else if(O=="keydown"){if(!R.speed)return;l.isMultiplesPlay&&clearTimeout(l.longPressTimeout),l.longPressTimeout=setTimeout(()=>{l.isMultiplesPlay=!0,l.dVideo.playbackRate=5,l.handleType="playbackRate",c()},500)}}},s=()=>{Je||_.value.focus()},d=()=>{l.loadStateType="play",l.dVideo.play().catch(()=>{setTimeout(()=>{l.playBtnState="replay",l.loadStateType="error"},500)}),l.playBtnState="pause"},n=()=>{l.dVideo.pause(),l.playBtnState="play"},u=w=>{w&&w.preventDefault(),l.playBtnState=="play"||l.playBtnState=="replay"?d():l.playBtnState=="pause"&&n()},p=()=>{l.muted=!l.muted,l.volume==0&&(l.volume=.05)},g=(w,O)=>{let P=l.dVideo.duration||l.dVideo.target.duration;l.dVideo.currentTime=P*O,l.playBtnState=="play"&&(l.dVideo.play(),l.playBtnState="pause")},v=(w,O)=>{l.progressCursorTime=nt(l.dVideo.duration*O)},i=vt(2500,()=>{l.isVideoHovering=!1}),r=w=>{l.isVideoHovering=!0,i()},o=w=>{f("mirrorChange",w,l.dVideo)},S=w=>{f("loopChange",w,l.dVideo)},b=w=>{f("lightOffChange",w,l.dVideo)},k=()=>{var w;w=l.dVideo,document.pictureInPictureElement?document.exitPictureInPicture().catch(O=>{console.log(O,"Video failed to leave Picture-in-Picture mode.")}):w.requestPictureInPicture().catch(O=>{console.log(O,"Video failed to enter Picture-in-Picture mode.")})},x=()=>{l.fullScreen=(w=>{let O=document,P=O.webkitIsFullScreen||O.fullscreen;return P?(document.exitFullscreen||O.webkitExitFullScreen).call(O):(w.requestFullscreen||w.webkitRequestFullScreen).call(w),!P})(A.value)};return ze(()=>R.src,()=>{Et(()=>{l.dVideo.canPlayType(R.type)||l.dVideo.canPlayType("application/vnd.apple.mpegurl")?l.muted=R.autoPlay:it.isSupported()&&(E.detachMedia(),E.attachMedia(l.dVideo),E.on(it.Events.MEDIA_ATTACHED,()=>{E.loadSource(R.src),E.on("hlsManifestParsed",(w,O)=>{console.log(O),l.currentLevel=O.level,l.qualityLevels=O.levels||[]})}),E.on("hlsLevelSwitching",(w,O)=>{console.log(O),console.log("LEVEL_SWITCHING")}),E.on("hlsLevelSwitched",(w,O)=>{l.currentLevel=O.level,console.log("LEVEL_SWITCHED")}))})},{immediate:!0}),mt(()=>{l.dVideo=D,s()}),C({play:d,pause:n,togglePlay:u}),(w,O)=>($(),Q("div",{ref:A,id:"refPlayerWrap",class:Se(["d-player-wrap",{"web-full-screen":G(l).webFullScreen,"is-lightoff":G(l).lightOff,"d-player-wrap-hover":G(l).playBtnState=="play"||G(l).isVideoHovering}]),onMousemove:r},[K("div",zr,[K("video",Tt({ref:D,class:["d-player-video-main",{"video-mirror":G(l).mirror}],id:"dPlayerVideoMain",controls:!(!G(Je)||!G(l).speed),"webkit-playsinline":R.playsinline,playsinline:R.playsinline},G(m),{volume:G(l).volume,muted:G(l).muted,loop:G(l).loop,preload:w.preload,width:"100%",height:"100%",src:R.src,poster:R.poster}),"您的浏览器不支持Video标签。",16,Xr)]),q(at,{name:"d-fade-in"},{default:Z(()=>[ge(K("div",$r,null,512),[[ve,G(l).lightOff]])]),_:1}),G(l).fullScreen?($(),De(Tr,{key:0,title:R.title},null,8,["title"])):ue("",!0),G(Je)?ue("",!0):($(),Q("div",Qr,[q(at,{name:"d-scale-out"},{default:Z(()=>[ge(K("div",Zr,[q(be,{icon:"icon-play",size:40})],512),[[ve,G(l).playBtnState=="play"]])]),_:1}),q(At,{state:G(l)},null,8,["state"])])),G(Je)?ue("",!0):($(),Q("input",{key:2,type:"input",readonly:"readonly",ref:_,onDblclick:x,onKeyup:[Ze(x,["f"]),O[0]||(O[0]=Ze(P=>G(l).webFullScreen=!1,["esc"])),t],onClick:u,onKeydown:[Ze(u,["space"]),Ze(a,["arrow-left"]),Ze(e,["arrow-up","arrow-down"]),t],class:"d-player-input",maxlength:"0"},null,40,Jr)),q(kt,{loadType:G(l).loadStateType},null,8,["loadType"]),q(_t),!G(Je)&&G(l).control?($(),Q("div",{key:3,class:"d-player-control",ref:I},[K("div",ei,[q(Xe,{class:"d-progress-bar",onOnMousemove:v,onChange:g,disabled:!G(l).speed,hoverText:G(l).progressCursorTime,modelValue:G(l).playProgress,"onUpdate:modelValue":O[1]||(O[1]=P=>G(l).playProgress=P),preload:G(l).preloadBar},null,8,["disabled","hoverText","modelValue","preload"])]),K("div",{class:"d-control-tool",onClick:s},[K("div",ti,[K("div",{class:"d-tool-item",onClick:u},[q(be,{size:"24",icon:`icon-${G(l).playBtnState}`},null,8,["icon"])]),R.controlBtns.includes("audioTrack")?($(),Q("div",ri,[K("span",null,J(G(l).currentTime),1),ii,K("span",ni,J(G(l).totalTime),1)])):ue("",!0)]),K("div",ai,[G(l).qualityLevels.length&&R.controlBtns.includes("quality")?($(),Q("div",si,[ce(J(G(l).qualityLevels.length&&(G(l).qualityLevels[G(l).currentLevel]||{}).height)+"P ",1),K("div",oi,[K("ul",li,[($(!0),Q(Pe,null,je(G(l).qualityLevels,(P,F)=>($(),Q("li",{class:Se({"speed-active":G(l).currentLevel==F}),onClick:M=>((B,U)=>{E.currentLevel=U,l.currentLevel=U})(0,F),key:P},J(P.height)+"P",11,ui))),128))])])])):ue("",!0),R.controlBtns.includes("speedRate")?($(),Q("div",di,[ce(J(G(l).speedActive=="1.0"?"倍速":G(l).speedActive+"x")+" ",1),K("div",ci,[K("ul",hi,[($(!0),Q(Pe,null,je(G(l).speedRate,P=>($(),Q("li",{class:Se({"speed-active":G(l).speedActive==P}),onClick:F=>(M=>{l.speedActive=M,l.dVideo.playbackRate=M})(P),key:P},J(P)+"x",11,fi))),128))])])])):ue("",!0),R.controlBtns.includes("volume")?($(),Q("div",gi,[K("div",vi,[K("div",{class:Se(["volume-main",{"is-muted":G(l).muted}])},[K("span",pi,J(G(l).muted?0:~~(100*G(l).volume))+"%",1),q(Xe,{onChange:O[2]||(O[2]=P=>G(l).muted=!1),hover:!1,size:"5px",vertical:!0,modelValue:G(l).volume,"onUpdate:modelValue":O[3]||(O[3]=P=>G(l).volume=P)},null,8,["modelValue"])],2)]),K("span",{onClick:p,style:{display:"flex"}},[q(be,{size:"20",icon:"icon-volume-"+(G(l).volume==0||G(l).muted?"mute":G(l).volume>.5?"up":"down")},null,8,["icon"])])])):ue("",!0),R.controlBtns.includes("setting")?($(),Q("div",mi,[q(be,{size:"20",class:"rotateHover",icon:"icon-settings"}),K("div",yi,[K("ul",Ei,[K("li",null,[Ti,q(rt,{onChange:o,modelValue:G(l).mirror,"onUpdate:modelValue":O[4]||(O[4]=P=>G(l).mirror=P)},null,8,["modelValue"])]),K("li",null,[Si,q(rt,{onChange:S,modelValue:G(l).loop,"onUpdate:modelValue":O[5]||(O[5]=P=>G(l).loop=P)},null,8,["modelValue"])]),K("li",null,[bi,q(rt,{onChange:b,modelValue:G(l).lightOff,"onUpdate:modelValue":O[6]||(O[6]=P=>G(l).lightOff=P)},null,8,["modelValue"])])])])])):ue("",!0),R.controlBtns.includes("pip")?($(),Q("div",{key:4,class:"d-tool-item pip-btn",onClick:k},[q(be,{size:"20",icon:"icon-pip"}),Li])):ue("",!0),R.controlBtns.includes("pageFullScreen")?($(),Q("div",{key:5,class:"d-tool-item pip-btn",onClick:O[7]||(O[7]=P=>G(l).webFullScreen=!G(l).webFullScreen)},[q(be,{size:"20",icon:"icon-web-screen"}),Ai])):ue("",!0),R.controlBtns.includes("fullScreen")?($(),Q("div",{key:6,class:"d-tool-item fullScreen-btn",onClick:x},[ki,q(be,{size:"20",icon:"icon-screen"})])):ue("",!0)])])],512)):ue("",!0)],34))}}));function _i(N){N.component(et.name,et)}et.__scopeId="data-v-01791e9e",et.install=_i;const Di=we({__name:"index",setup(N){return(C,f)=>($(),De(G(et)))}});const Ri={class:"text-right mt-[15px]"},Ii=we({__name:"index",props:{width:{type:String,default:"350px"},value:{type:String,default:""},placeholder:{type:String,default:""},required:{type:Boolean,default:!0},maxlength:{type:Number,default:10}},emits:["confirm"],setup(N,{emit:C}){const f=N,R=me(f.value),E=me(!1);ze(E,()=>{E.value||(R.value="")});const A=()=>{if(!/[\S]+/.test(R.value)){st.error(f.placeholder||"不能为空");return}C("confirm",R.value),E.value=!1};return(D,I)=>{const _=St,l=bt,L=Ut;return $(),De(L,{placement:"top",trigger:"click",width:f.width,visible:E.value,"onUpdate:visible":I[2]||(I[2]=m=>E.value=m)},{reference:Z(()=>[xt(D.$slots,"default")]),default:Z(()=>[q(_,{modelValue:R.value,"onUpdate:modelValue":I[0]||(I[0]=m=>R.value=m),placeholder:f.placeholder,clearable:"",class:"mr-[10px]",maxlength:f.maxlength,"show-word-limit":!0},null,8,["modelValue","placeholder","maxlength"]),K("div",Ri,[q(l,{onClick:I[1]||(I[1]=m=>E.value=!1)},{default:Z(()=>[ce(J(G(ie)("cancel")),1)]),_:1}),q(l,{type:"primary",onClick:A},{default:Z(()=>[ce(J(G(ie)("confirm")),1)]),_:1})])]),_:3},8,["width","visible"])}}}),Ci={class:"group-wrap w-[180px] p-[15px] h-full border-r border-color flex flex-col"},wi={class:"group-list flex-1 my-[10px]"},xi=["onClick"],Oi={key:0,class:"leading-none operate py-[10px]"},Pi={class:"text-primary"},Fi=["onClick"],Mi={class:"attachment-list-wrap flex flex-col p-[15px] flex-1"},Ni={class:"flex-1 my-[15px] h-0"},Bi={key:0,class:"flex flex-wrap"},Ui=["onClick"],Gi=["src"],ji={class:"absolute z-[1] flex items-center justify-center w-full h-full inset-0 bg-black bg-opacity-60"},Ki={class:"flex items-center"},Vi={class:"truncate my-[10px] cursor-pointer text-base flex-1"},Hi={class:"text-center w-full"},Wi={class:"text-center w-full"},Yi={class:"text-center w-full"},qi={class:"text-center w-full"},zi={key:1,class:"flex items-center justify-center"},Xi={class:"flex items-center"},$i={class:"flex h-full justify-end items-center"},Qi={class:"dialog-footer"},Zi=we({__name:"attachment",props:{limit:{type:Number,default:1},type:{type:String,default:"image"},scene:{type:String,default:"select"}},setup(N,{expose:C}){const f=N,R=Te({}),E=Te({data:[]}),A=Te({loading:!1,page:1,total:0,limit:f.scene=="select"?10:20,data:[]}),D=Te({name:""}),I=Te({real_name:"",cate_id:0}),_=dt(()=>{Wt({type:f.type,...D}).then(r=>{E.data=r.data}).catch(()=>{})});_();const l=dt((r=1)=>{A.loading=!0,A.page=r,Yt({page:A.page,limit:A.limit,att_type:f.type,...I}).then(o=>{A.data=o.data.data,A.total=o.data.total,A.loading=!1,f.scene=="attachment"&&e()}).catch(()=>{A.loading=!1})});l(),ze(()=>I.cate_id,()=>{l()});const L=r=>{Gt({type:f.type,name:r}).then(o=>{_(1)}).catch(()=>{})},m=(r,o)=>{jt({id:E.data[o].id,name:r}).then(S=>{E.data[o].name=r}).catch(()=>{})},h=r=>{ct.confirm(ie("upload.deleteCategoryTips"),ie("warning"),{confirmButtonText:ie("confirm"),cancelButtonText:ie("cancel"),type:"warning"}).then(()=>{Kt(E.data[r].id).then(()=>{E.data.splice(r,1)}).catch(()=>{})})},T=me(null),y=Ce(()=>{const r={};return r.token=qt(),r["site-id"]=zt.get("siteId")||0,{action:`/adminapi//sys/${f.type}`,multiple:!0,data:{cate_id:I.cate_id},headers:r,onSuccess:(o,S,b)=>{var k;o.code==200?(l(),(k=T.value)==null||k.handleRemove(S)):(S.status="fail",st({message:o.msg,type:"error"}))}}}),c=me(!1);ze(c,()=>{if(c.value){const r=Object.keys(_e(R));A.data.forEach(o=>{r.includes(o.att_id)||(R[o.att_id]=_e(o))})}else e()});const e=()=>{const r=Object.keys(_e(R));r.length&&(r.forEach(o=>{delete R[o]}),c.value=!1)},a=r=>{if(R[r.att_id])delete R[r.att_id];else if(f.scene=="select"){const o=Object.keys(_e(R)),S=o.length;if(f.limit==1&&S==f.limit)delete R[o[0]];else if(S>=f.limit){st.info(ie("upload.triggerUpperLimit"));return}R[r.att_id]=_e(r)}else R[r.att_id]=_e(r)},t=(r=null)=>{const o=r===null?Object.keys(_e(R)):[A.data[r].att_id];ct.confirm(ie("upload.deleteAttachmentTips"),ie("warning"),{confirmButtonText:ie("confirm"),cancelButtonText:ie("cancel"),type:"warning"}).then(()=>{Vt({att_ids:o}).then(()=>{l()}).catch(()=>{})})},s=Te({cateId:"",loading:!1,visible:!1}),d=(r=null)=>{const o=r===null?Object.keys(_e(R)):[A.data[r].att_id];s.visible=!0,s.cateId=E.data[0].id,s.confirm=()=>{s.loading=!0,Ht({cate_id:s.cateId,att_ids:o}).then(()=>{s.visible=!1,s.loading=!1,l()}).catch(()=>{s.loading=!1})}},n=me(!0);ze(R,()=>{n.value=Object.keys(_e(R)).length==0});const u=Te({show:!1,index:0}),p=r=>{u.show=!0,u.index=r},g=Ce(()=>_e(A.data).map(r=>tt(r.url))),v=Te({visible:!1,src:""}),i=r=>{v.visible=!0,v.src=tt(A.data[r].url)};return C({selectedFile:R}),(r,o)=>{const S=St,b=Ii,k=Xt,x=bt,w=$t,O=Ot,P=Pt,F=Qt,M=Ft,B=Jt,U=Mt,j=Nt,V=Bt,H=er,z=tr,W=rr,X=ir,ne=nr,se=ar,oe=sr,te=or,de=Zt,re=Di,ae=lr;return $(),Q("div",{class:Se(["flex border-t border-b main-wrap border-color w-full",N.scene=="select"?"h-[40vh]":"h-full"])},[K("div",Ci,[q(S,{modelValue:D.name,"onUpdate:modelValue":o[0]||(o[0]=Y=>D.name=Y),class:"m-0",placeholder:G(ie)("upload.attachmentCategoryPlaceholder"),"prefix-icon":"Search",onInput:o[1]||(o[1]=Y=>G(_)())},null,8,["modelValue","placeholder"]),K("div",wi,[q(k,null,{default:Z(()=>[K("div",{class:Se(["group-item p-[10px] leading-none text-xs rounded cursor-pointer",{active:I.cate_id==0}]),onClick:o[2]||(o[2]=Y=>I.cate_id=0)},J(G(ie)("selectPlaceholder")),3),($(!0),Q(Pe,null,je(E.data,(Y,ee)=>($(),Q("div",{class:Se(["group-item px-[10px] text-xs rounded cursor-pointer flex",{active:I.cate_id==Y.id}]),key:ee},[K("div",{class:"flex-1 leading-none truncate py-[10px]",onClick:le=>I.cate_id=Y.id},J(Y.name),9,xi),N.scene=="attachment"?($(),Q("div",Oi,[q(b,{placeholder:G(ie)("upload.attachmentCategoryPlaceholder"),onConfirm:le=>m(le,ee),value:Y.name},{default:Z(()=>[K("span",Pi,J(G(ie)("edit")),1)]),_:2},1032,["placeholder","onConfirm","value"]),K("span",{class:"text-danger ml-[5px]",onClick:le=>h(ee)},J(G(ie)("delete")),9,Fi)])):ue("",!0)],2))),128))]),_:1})]),q(b,{placeholder:G(ie)("upload.attachmentCategoryPlaceholder"),onConfirm:L},{default:Z(()=>[q(x,null,{default:Z(()=>[ce(J(G(ie)("upload.addAttachmentCategory")),1)]),_:1})]),_:1},8,["placeholder"])]),K("div",Mi,[q(P,{gutter:15,class:"h-[32px]"},{default:Z(()=>[q(O,{span:12},{default:Z(()=>[q(w,Tt(G(y),{ref_key:"uploadRef",ref:T}),{default:Z(()=>[q(x,{type:"primary"},{default:Z(()=>[ce(J(G(ie)("upload.upload"+N.type)),1)]),_:1})]),_:1},16)]),_:1}),q(O,{span:12,class:"text-right"},{default:Z(()=>[q(S,{modelValue:I.real_name,"onUpdate:modelValue":o[3]||(o[3]=Y=>I.real_name=Y),class:"m-0 w-[200px]",placeholder:G(ie)("upload.placeholder"+N.type+"Name"),"prefix-icon":"Search",onInput:o[4]||(o[4]=Y=>G(l)())},null,8,["modelValue","placeholder"])]),_:1})]),_:1}),ge(($(),Q("div",Ni,[q(k,null,{default:Z(()=>[A.data.length?($(),Q("div",Bi,[($(!0),Q(Pe,null,je(A.data,(Y,ee)=>($(),Q("div",{class:Se(["attachment-item mr-[10px]",N.scene=="select"?"w-[100px]":"w-[120px]"]),key:ee},[K("div",{class:Se(["attachment-wrap w-full rounded cursor-pointer overflow-hidden relative flex items-center justify-center",N.scene=="select"?"h-[100px]":"h-[120px]"]),onClick:le=>a(Y)},[N.type=="image"?($(),De(F,{key:0,src:G(tt)(Y.url),fit:"contain"},null,8,["src"])):($(),Q("video",{key:1,src:G(tt)(Y.url)},null,8,Gi)),ge(K("div",ji,[q(M,{name:"element-Select",color:"#fff",size:"25px"})],512),[[ve,R[Y.att_id]]])],10,Ui),K("div",Ki,[q(B,{placement:"top"},{content:Z(()=>[ce(J(Y.real_name),1)]),default:Z(()=>[K("div",Vi,J(Y.real_name),1)]),_:2},1024),N.scene=="attachment"?($(),De(V,{key:0,"hide-on-click":!1},{dropdown:Z(()=>[q(j,null,{default:Z(()=>[Y.att_type=="image"?($(),De(U,{key:0,class:"text-center",onClick:le=>p(ee)},{default:Z(()=>[K("div",Hi,J(G(ie)("lookOver")),1)]),_:2},1032,["onClick"])):ue("",!0),Y.att_type=="video"?($(),De(U,{key:1,class:"text-center",onClick:le=>i(ee)},{default:Z(()=>[K("div",Wi,J(G(ie)("lookOver")),1)]),_:2},1032,["onClick"])):ue("",!0),q(U,{class:"text-center",onClick:le=>d(ee)},{default:Z(()=>[K("div",Yi,J(G(ie)("upload.move")),1)]),_:2},1032,["onClick"]),q(U,{onClick:le=>t(ee)},{default:Z(()=>[K("div",qi,J(G(ie)("delete")),1)]),_:2},1032,["onClick"])]),_:2},1024)]),default:Z(()=>[q(M,{name:"element-MoreFilled",class:"cursor-pointer ml-[10px]",size:"14px"})]),_:2},1024)):ue("",!0)])],2))),128))])):($(),Q("div",zi,[q(H,{description:G(ie)("upload.attachmentEmpty"),"image-size":100},null,8,["description"])]))]),_:1})])),[[ae,A.loading]]),q(P,{gutter:20},{default:Z(()=>[N.scene=="attachment"?($(),De(O,{key:0,span:8},{default:Z(()=>[K("div",Xi,[q(z,{modelValue:c.value,"onUpdate:modelValue":o[5]||(o[5]=Y=>c.value=Y),label:G(ie)("selectAll"),size:"large"},null,8,["modelValue","label"]),q(x,{class:"ml-[15px]",disabled:n.value,onClick:o[6]||(o[6]=Y=>t())},{default:Z(()=>[ce(J(G(ie)("delete")),1)]),_:1},8,["disabled"]),q(x,{disabled:n.value,onClick:o[7]||(o[7]=Y=>d())},{default:Z(()=>[ce(J(G(ie)("upload.move")),1)]),_:1},8,["disabled"])])]),_:1})):ue("",!0),q(O,{span:N.scene=="attachment"?16:24},{default:Z(()=>[K("div",$i,[q(W,{"current-page":A.page,"onUpdate:currentPage":o[8]||(o[8]=Y=>A.page=Y),small:!0,"page-size":A.limit,"onUpdate:pageSize":o[9]||(o[9]=Y=>A.limit=Y),"page-sizes":[10,20,40,60],layout:"total, sizes, prev, pager, next, jumper",total:A.total,onSizeChange:o[10]||(o[10]=Y=>G(l)()),onCurrentChange:G(l)},null,8,["current-page","page-size","total","onCurrentChange"])])]),_:1},8,["span"])]),_:1})]),N.scene=="attachment"?($(),Q(Pe,{key:0},[q(te,{modelValue:s.visible,"onUpdate:modelValue":o[14]||(o[14]=Y=>s.visible=Y),title:G(ie)("upload.moveCategory"),width:"350px"},{footer:Z(()=>[K("span",Qi,[q(x,{onClick:o[12]||(o[12]=Y=>s.visible=!1)},{default:Z(()=>[ce(J(G(ie)("cancel")),1)]),_:1}),q(x,{type:"primary",loading:s.loading,onClick:o[13]||(o[13]=Y=>s.confirm())},{default:Z(()=>[ce(J(G(ie)("confirm")),1)]),_:1},8,["loading"])])]),default:Z(()=>[q(oe,{"label-width":"60px"},{default:Z(()=>[q(se,{label:G(ie)("upload.moveTo"),style:{"margin-bottom":"0"}},{default:Z(()=>[q(ne,{modelValue:s.cateId,"onUpdate:modelValue":o[11]||(o[11]=Y=>s.cateId=Y),class:"input-width"},{default:Z(()=>[($(!0),Q(Pe,null,je(E.data,(Y,ee)=>($(),De(X,{label:Y.name,value:Y.id,key:ee},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1},8,["label"])]),_:1})]),_:1},8,["modelValue","title"]),u.show?($(),De(de,{key:0,"url-list":G(g),onClose:o[15]||(o[15]=Y=>u.show=!1),"initial-index":u.index,"zoom-rate":1},null,8,["url-list","initial-index"])):ue("",!0),q(te,{modelValue:v.visible,"onUpdate:modelValue":o[16]||(o[16]=Y=>v.visible=Y),width:"50%","align-center":"","destroy-on-close":!0,"custom-class":"video-preview"},{default:Z(()=>[q(re,{src:v.src,width:"100%"},null,8,["src"])]),_:1},8,["modelValue"])],64)):ue("",!0)],2)}}});const Un=ur(Zi,[["__scopeId","data-v-179a13a7"]]);export{Di as _,Un as a};
|