lemon-mse 0.2.6 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/es/index.js CHANGED
@@ -1 +1,19 @@
1
- var e={228:e=>{var t=Object.prototype.hasOwnProperty,r="~";function i(){}function n(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function a(e,t,i,a,s){if("function"!=typeof i)throw new TypeError("The listener must be a function");var o=new n(i,a||e,s),u=r?r+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],o]:e._events[u].push(o):(e._events[u]=o,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new i:delete e._events[t]}function o(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(r=!1)),o.prototype.eventNames=function(){var e,i,n=[];if(0===this._eventsCount)return n;for(i in e=this._events)t.call(e,i)&&n.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},o.prototype.listeners=function(e){var t=r?r+e:e,i=this._events[t];if(!i)return[];if(i.fn)return[i.fn];for(var n=0,a=i.length,s=new Array(a);n<a;n++)s[n]=i[n].fn;return s},o.prototype.listenerCount=function(e){var t=r?r+e:e,i=this._events[t];return i?i.fn?1:i.length:0},o.prototype.emit=function(e,t,i,n,a,s){var o=r?r+e:e;if(!this._events[o])return!1;var u,l,d=this._events[o],h=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),h){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,t),!0;case 3:return d.fn.call(d.context,t,i),!0;case 4:return d.fn.call(d.context,t,i,n),!0;case 5:return d.fn.call(d.context,t,i,n,a),!0;case 6:return d.fn.call(d.context,t,i,n,a,s),!0}for(l=1,u=new Array(h-1);l<h;l++)u[l-1]=arguments[l];d.fn.apply(d.context,u)}else{var c,f=d.length;for(l=0;l<f;l++)switch(d[l].once&&this.removeListener(e,d[l].fn,void 0,!0),h){case 1:d[l].fn.call(d[l].context);break;case 2:d[l].fn.call(d[l].context,t);break;case 3:d[l].fn.call(d[l].context,t,i);break;case 4:d[l].fn.call(d[l].context,t,i,n);break;default:if(!u)for(c=1,u=new Array(h-1);c<h;c++)u[c-1]=arguments[c];d[l].fn.apply(d[l].context,u)}}return!0},o.prototype.on=function(e,t,r){return a(this,e,t,r,!1)},o.prototype.once=function(e,t,r){return a(this,e,t,r,!0)},o.prototype.removeListener=function(e,t,i,n){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn!==t||n&&!o.once||i&&o.context!==i||s(this,a);else{for(var u=0,l=[],d=o.length;u<d;u++)(o[u].fn!==t||n&&!o[u].once||i&&o[u].context!==i)&&l.push(o[u]);l.length?this._events[a]=1===l.length?l[0]:l:s(this,a)}return this},o.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=r,o.EventEmitter=o,e.exports=o},539:e=>{!function t(r){e.exports=function(){function e(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function i(t){for(var r=1;r<arguments.length;r++){var i=null!=arguments[r]?arguments[r]:{};r%2?e(Object(i),!0).forEach((function(e){var r,a,s;r=t,a=e,s=i[e],(a=n(a))in r?Object.defineProperty(r,a,{value:s,enumerable:!0,configurable:!0,writable:!0}):r[a]=s})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):e(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function n(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function a(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,n(i.key),i)}}function s(e,t,r){return t&&a(e.prototype,t),r&&a(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function o(){return o=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},o.apply(this,arguments)}function u(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,d(e,t)}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}function d(e,t){return d=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},d(e,t)}function h(e,t,r){return h=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}()?Reflect.construct.bind():function(e,t,r){var i=[null];i.push.apply(i,t);var n=new(Function.bind.apply(e,i));return r&&d(n,r.prototype),n},h.apply(null,arguments)}function c(e){var t="function"==typeof Map?new Map:void 0;return c=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return h(e,arguments,l(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),d(r,e)},c(e)}function f(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var v={exports:{}};!function(e){var t,r,i,n,a;t=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,r=/^(?=([^\/?#]*))\1([^]*)$/,i=/(?:\/|^)\.(?=\/)/g,n=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,a={buildAbsoluteURL:function(e,t,i){if(i=i||{},e=e.trim(),!(t=t.trim())){if(!i.alwaysNormalize)return e;var n=a.parseURL(e);if(!n)throw new Error("Error trying to parse base URL.");return n.path=a.normalizePath(n.path),a.buildURLFromParts(n)}var s=a.parseURL(t);if(!s)throw new Error("Error trying to parse relative URL.");if(s.scheme)return i.alwaysNormalize?(s.path=a.normalizePath(s.path),a.buildURLFromParts(s)):t;var o=a.parseURL(e);if(!o)throw new Error("Error trying to parse base URL.");if(!o.netLoc&&o.path&&"/"!==o.path[0]){var u=r.exec(o.path);o.netLoc=u[1],o.path=u[2]}o.netLoc&&!o.path&&(o.path="/");var l={scheme:o.scheme,netLoc:s.netLoc,path:null,params:s.params,query:s.query,fragment:s.fragment};if(!s.netLoc&&(l.netLoc=o.netLoc,"/"!==s.path[0]))if(s.path){var d=o.path,h=d.substring(0,d.lastIndexOf("/")+1)+s.path;l.path=a.normalizePath(h)}else l.path=o.path,s.params||(l.params=o.params,s.query||(l.query=o.query));return null===l.path&&(l.path=i.alwaysNormalize?a.normalizePath(s.path):s.path),a.buildURLFromParts(l)},parseURL:function(e){var r=t.exec(e);return r?{scheme:r[1]||"",netLoc:r[2]||"",path:r[3]||"",params:r[4]||"",query:r[5]||"",fragment:r[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(i,"");e.length!==(e=e.replace(n,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}},e.exports=a}(v);var p=v.exports,g=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},m=Number.isSafeInteger||function(e){return"number"==typeof e&&Math.abs(e)<=y},y=Number.MAX_SAFE_INTEGER||9007199254740991,_=function(e){return e.MEDIA_ATTACHING="hlsMediaAttaching",e.MEDIA_ATTACHED="hlsMediaAttached",e.MEDIA_DETACHING="hlsMediaDetaching",e.MEDIA_DETACHED="hlsMediaDetached",e.BUFFER_RESET="hlsBufferReset",e.BUFFER_CODECS="hlsBufferCodecs",e.BUFFER_CREATED="hlsBufferCreated",e.BUFFER_APPENDING="hlsBufferAppending",e.BUFFER_APPENDED="hlsBufferAppended",e.BUFFER_EOS="hlsBufferEos",e.BUFFER_FLUSHING="hlsBufferFlushing",e.BUFFER_FLUSHED="hlsBufferFlushed",e.MANIFEST_LOADING="hlsManifestLoading",e.MANIFEST_LOADED="hlsManifestLoaded",e.MANIFEST_PARSED="hlsManifestParsed",e.LEVEL_SWITCHING="hlsLevelSwitching",e.LEVEL_SWITCHED="hlsLevelSwitched",e.LEVEL_LOADING="hlsLevelLoading",e.LEVEL_LOADED="hlsLevelLoaded",e.LEVEL_UPDATED="hlsLevelUpdated",e.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",e.LEVELS_UPDATED="hlsLevelsUpdated",e.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",e.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",e.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",e.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",e.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",e.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",e.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",e.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",e.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",e.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",e.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",e.CUES_PARSED="hlsCuesParsed",e.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",e.INIT_PTS_FOUND="hlsInitPtsFound",e.FRAG_LOADING="hlsFragLoading",e.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",e.FRAG_LOADED="hlsFragLoaded",e.FRAG_DECRYPTED="hlsFragDecrypted",e.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",e.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",e.FRAG_PARSING_METADATA="hlsFragParsingMetadata",e.FRAG_PARSED="hlsFragParsed",e.FRAG_BUFFERED="hlsFragBuffered",e.FRAG_CHANGED="hlsFragChanged",e.FPS_DROP="hlsFpsDrop",e.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",e.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",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",e.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",e}({}),b=function(e){return e.NETWORK_ERROR="networkError",e.MEDIA_ERROR="mediaError",e.KEY_SYSTEM_ERROR="keySystemError",e.MUX_ERROR="muxError",e.OTHER_ERROR="otherError",e}({}),E=function(e){return e.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",e.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",e.KEY_SYSTEM_NO_SESSION="keySystemNoSession",e.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",e.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",e.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",e.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",e.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",e.MANIFEST_LOAD_ERROR="manifestLoadError",e.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",e.MANIFEST_PARSING_ERROR="manifestParsingError",e.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",e.LEVEL_EMPTY_ERROR="levelEmptyError",e.LEVEL_LOAD_ERROR="levelLoadError",e.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",e.LEVEL_PARSING_ERROR="levelParsingError",e.LEVEL_SWITCH_ERROR="levelSwitchError",e.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",e.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",e.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",e.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",e.FRAG_LOAD_ERROR="fragLoadError",e.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",e.FRAG_DECRYPT_ERROR="fragDecryptError",e.FRAG_PARSING_ERROR="fragParsingError",e.FRAG_GAP="fragGap",e.REMUX_ALLOC_ERROR="remuxAllocError",e.KEY_LOAD_ERROR="keyLoadError",e.KEY_LOAD_TIMEOUT="keyLoadTimeOut",e.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",e.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",e.BUFFER_APPEND_ERROR="bufferAppendError",e.BUFFER_APPENDING_ERROR="bufferAppendingError",e.BUFFER_STALLED_ERROR="bufferStalledError",e.BUFFER_FULL_ERROR="bufferFullError",e.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",e.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",e.INTERNAL_EXCEPTION="internalException",e.INTERNAL_ABORTED="aborted",e.UNKNOWN="unknown",e}({}),T=function(){},S={trace:T,debug:T,log:T,warn:T,info:T,error:T},L=S;function k(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];r.forEach((function(t){L[t]=e[t]?e[t].bind(e):function(e){var t=self.console[e];return t?t.bind(self.console,"["+e+"] >"):T}(t)}))}function w(e,t){if("object"==typeof console&&!0===e||"object"==typeof e){k(e,"debug","log","info","warn","error");try{L.log('Debug logs enabled for "'+t+'" in hls.js version 1.5.17')}catch(e){L=S}}else L=S}var x=L,A=/^(\d+)x(\d+)$/,R=/(.+?)=(".*?"|.*?)(?:,|$)/g,D=function(){function e(t){"string"==typeof t&&(t=e.parseAttrList(t)),o(this,t)}var t=e.prototype;return t.decimalInteger=function(e){var t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t},t.hexadecimalInteger=function(e){if(this[e]){var t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;for(var r=new Uint8Array(t.length/2),i=0;i<t.length/2;i++)r[i]=parseInt(t.slice(2*i,2*i+2),16);return r}return null},t.hexadecimalIntegerAsNumber=function(e){var t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t},t.decimalFloatingPoint=function(e){return parseFloat(this[e])},t.optionalFloat=function(e,t){var r=this[e];return r?parseFloat(r):t},t.enumeratedString=function(e){return this[e]},t.bool=function(e){return"YES"===this[e]},t.decimalResolution=function(e){var t=A.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}},e.parseAttrList=function(e){var t,r={};for(R.lastIndex=0;null!==(t=R.exec(e));){var i=t[2];0===i.indexOf('"')&&i.lastIndexOf('"')===i.length-1&&(i=i.slice(1,-1)),r[t[1].trim()]=i}return r},s(e,[{key:"clientAttrs",get:function(){return Object.keys(this).filter((function(e){return"X-"===e.substring(0,2)}))}}]),e}();function C(e){return"SCTE35-OUT"===e||"SCTE35-IN"===e}var P=function(){function e(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){var r=t.attr;for(var i in r)if(Object.prototype.hasOwnProperty.call(e,i)&&e[i]!==r[i]){x.warn('DATERANGE tag attribute: "'+i+'" does not match for tags with ID: "'+e.ID+'"'),this._badValueForSameId=i;break}e=o(new D({}),r,e)}if(this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){var n=new Date(this.attr["END-DATE"]);g(n.getTime())&&(this._endDate=n)}}return s(e,[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){if(this._endDate)return this._endDate;var e=this.duration;return null!==e?new Date(this._startDate.getTime()+1e3*e):null}},{key:"duration",get:function(){if("DURATION"in this.attr){var e=this.attr.decimalFloatingPoint("DURATION");if(g(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}},{key:"endOnNext",get:function(){return this.attr.bool("END-ON-NEXT")}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&g(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),e}(),O=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}},I="audio",F="video",M="audiovideo",B=function(){function e(e){var t;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((t={})[I]=null,t[F]=null,t[M]=null,t),this.baseurl=e}return e.prototype.setByteRange=function(e,t){var r,i=e.split("@",2);r=1===i.length?(null==t?void 0:t.byteRangeEndOffset)||0:parseInt(i[1]),this._byteRange=[r,parseInt(i[0])+r]},s(e,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=p.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(e){this._url=e}}]),e}(),N=function(e){function t(t,r){var i;return(i=e.call(this,r)||this)._decryptdata=null,i.rawProgramDateTime=null,i.programDateTime=null,i.tagList=[],i.duration=0,i.sn=0,i.levelkeys=void 0,i.type=void 0,i.loader=null,i.keyLoader=null,i.level=-1,i.cc=0,i.startPTS=void 0,i.endPTS=void 0,i.startDTS=void 0,i.endDTS=void 0,i.start=0,i.deltaPTS=void 0,i.maxStartPTS=void 0,i.minEndPTS=void 0,i.stats=new O,i.data=void 0,i.bitrateTest=!1,i.title=null,i.initSegment=null,i.endList=void 0,i.gap=void 0,i.urlId=0,i.type=t,i}u(t,e);var r=t.prototype;return r.setKeyFormat=function(e){if(this.levelkeys){var t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}},r.abortRequests=function(){var e,t;null==(e=this.loader)||e.abort(),null==(t=this.keyLoader)||t.abort()},r.setElementaryStreamInfo=function(e,t,r,i,n,a){void 0===a&&(a=!1);var s=this.elementaryStreams,o=s[e];o?(o.startPTS=Math.min(o.startPTS,t),o.endPTS=Math.max(o.endPTS,r),o.startDTS=Math.min(o.startDTS,i),o.endDTS=Math.max(o.endDTS,n)):s[e]={startPTS:t,endPTS:r,startDTS:i,endDTS:n,partial:a}},r.clearElementaryStreamInfo=function(){var e=this.elementaryStreams;e[I]=null,e[F]=null,e[M]=null},s(t,[{key:"decryptdata",get:function(){if(!this.levelkeys&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var e=this.levelkeys.identity;if(e)this._decryptdata=e.getDecryptData(this.sn);else{var t=Object.keys(this.levelkeys);if(1===t.length)return this._decryptdata=this.levelkeys[t[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;if(!g(this.programDateTime))return null;var e=g(this.duration)?this.duration:0;return this.programDateTime+1e3*e}},{key:"encrypted",get:function(){var e;if(null!=(e=this._decryptdata)&&e.encrypted)return!0;if(this.levelkeys){var t=Object.keys(this.levelkeys),r=t.length;if(r>1||1===r&&this.levelkeys[t[0]].encrypted)return!0}return!1}}]),t}(B),U=function(e){function t(t,r,i,n,a){var s;(s=e.call(this,i)||this).fragOffset=0,s.duration=0,s.gap=!1,s.independent=!1,s.relurl=void 0,s.fragment=void 0,s.index=void 0,s.stats=new O,s.duration=t.decimalFloatingPoint("DURATION"),s.gap=t.bool("GAP"),s.independent=t.bool("INDEPENDENT"),s.relurl=t.enumeratedString("URI"),s.fragment=r,s.index=n;var o=t.enumeratedString("BYTERANGE");return o&&s.setByteRange(o,a),a&&(s.fragOffset=a.fragOffset+a.duration),s}return u(t,e),s(t,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var e=this.elementaryStreams;return!!(e.audio||e.video||e.audiovideo)}}]),t}(B),G=function(){function e(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}return e.prototype.reloaded=function(e){if(!e)return this.advanced=!0,void(this.updated=!0);var t=this.lastPartSn-e.lastPartSn,r=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!r||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||0===t&&r>0,this.updated||this.advanced?this.misses=Math.floor(.6*e.misses):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay},s(e,[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&g(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var e=this.driftEndTime-this.driftStartTime;return e>0?1e3*(this.driftEnd-this.driftStart)/e:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var e;return null!=(e=this.fragments)&&e.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),e}(),V=f(void 0);function j(e,t,r){return Uint8Array.prototype.slice?e.slice(t,r):new Uint8Array(Array.prototype.slice.call(e,t,r))}var H,K=function(e,t){return t+10<=e.length&&73===e[t]&&68===e[t+1]&&51===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128},z=function(e,t){return t+10<=e.length&&51===e[t]&&68===e[t+1]&&73===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128},W=function(e,t){for(var r=t,i=0;K(e,t);)i+=10,i+=q(e,t+6),z(e,t+10)&&(i+=10),t+=i;if(i>0)return e.subarray(r,r+i)},q=function(e,t){var r=0;return r=(127&e[t])<<21,r|=(127&e[t+1])<<14,(r|=(127&e[t+2])<<7)|127&e[t+3]},Y=function(e,t){return K(e,t)&&q(e,t+6)+10<=e.length-t},X=function(e){for(var t=Z(e),r=0;r<t.length;r++){var i=t[r];if(Q(i))return ie(i)}},Q=function(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info},J=function(e){var t=String.fromCharCode(e[0],e[1],e[2],e[3]),r=q(e,4);return{type:t,size:r,data:e.subarray(10,10+r)}},Z=function(e){for(var t=0,r=[];K(e,t);){for(var i=q(e,t+6),n=(t+=10)+i;t+8<n;){var a=J(e.subarray(t)),s=$(a);s&&r.push(s),t+=a.size+10}z(e,t)&&(t+=10)}return r},$=function(e){return"PRIV"===e.type?ee(e):"W"===e.type[0]?re(e):te(e)},ee=function(e){if(!(e.size<2)){var t=ne(e.data,!0),r=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:r.buffer}}},te=function(e){if(!(e.size<2)){if("TXXX"===e.type){var t=1,r=ne(e.data.subarray(t),!0);t+=r.length+1;var i=ne(e.data.subarray(t));return{key:e.type,info:r,data:i}}var n=ne(e.data.subarray(1));return{key:e.type,data:n}}},re=function(e){if("WXXX"===e.type){if(e.size<2)return;var t=1,r=ne(e.data.subarray(t),!0);t+=r.length+1;var i=ne(e.data.subarray(t));return{key:e.type,info:r,data:i}}var n=ne(e.data);return{key:e.type,data:n}},ie=function(e){if(8===e.data.byteLength){var t=new Uint8Array(e.data),r=1&t[3],i=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return i/=45,r&&(i+=47721858.84),Math.round(i)}},ne=function(e,t){void 0===t&&(t=!1);var r=ae();if(r){var i=r.decode(e);if(t){var n=i.indexOf("\0");return-1!==n?i.substring(0,n):i}return i.replace(/\0/g,"")}for(var a,s,o,u=e.length,l="",d=0;d<u;){if(0===(a=e[d++])&&t)return l;if(0!==a&&3!==a)switch(a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:l+=String.fromCharCode(a);break;case 12:case 13:s=e[d++],l+=String.fromCharCode((31&a)<<6|63&s);break;case 14:s=e[d++],o=e[d++],l+=String.fromCharCode((15&a)<<12|(63&s)<<6|63&o)}}return l};function ae(){if(!navigator.userAgent.includes("PlayStation 4"))return H||void 0===self.TextDecoder||(H=new self.TextDecoder("utf-8")),H}var se=function(e){for(var t="",r=0;r<e.length;r++){var i=e[r].toString(16);i.length<2&&(i="0"+i),t+=i}return t},oe=Math.pow(2,32)-1,ue=[].push,le={video:1,audio:2,id3:3,text:4};function de(e){return String.fromCharCode.apply(null,e)}function he(e,t){var r=e[t]<<8|e[t+1];return r<0?65536+r:r}function ce(e,t){var r=ve(e,t);return r<0?4294967296+r:r}function fe(e,t){var r=ce(e,t);return(r*=Math.pow(2,32))+ce(e,t+4)}function ve(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function pe(e,t,r){e[t]=r>>24,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r}function ge(e,t){var r=[];if(!t.length)return r;for(var i=e.byteLength,n=0;n<i;){var a=ce(e,n),s=a>1?n+a:i;if(de(e.subarray(n+4,n+8))===t[0])if(1===t.length)r.push(e.subarray(n+8,s));else{var o=ge(e.subarray(n+8,s),t.slice(1));o.length&&ue.apply(r,o)}n=s}return r}function me(e){var t=[],r=e[0],i=8,n=ce(e,i);i+=4;var a=0,s=0;0===r?(a=ce(e,i),s=ce(e,i+4),i+=8):(a=fe(e,i),s=fe(e,i+8),i+=16),i+=2;var o=e.length+s,u=he(e,i);i+=2;for(var l=0;l<u;l++){var d=i,h=ce(e,d);d+=4;var c=2147483647&h;if(1==(2147483648&h)>>>31)return x.warn("SIDX has hierarchical references (not supported)"),null;var f=ce(e,d);d+=4,t.push({referenceSize:c,subsegmentDuration:f,info:{duration:f/n,start:o,end:o+c-1}}),o+=c,i=d+=4}return{earliestPresentationTime:a,timescale:n,version:r,referencesCount:u,references:t}}function ye(e){for(var t=[],r=ge(e,["moov","trak"]),n=0;n<r.length;n++){var a=r[n],s=ge(a,["tkhd"])[0];if(s){var o=s[0],u=ce(s,0===o?12:20),l=ge(a,["mdia","mdhd"])[0];if(l){var d=ce(l,0===(o=l[0])?12:20),h=ge(a,["mdia","hdlr"])[0];if(h){var c=de(h.subarray(8,12)),f={soun:I,vide:F}[c];if(f){var v=_e(ge(a,["mdia","minf","stbl","stsd"])[0]);t[u]={timescale:d,type:f},t[f]=i({timescale:d,id:u},v)}}}}}return ge(e,["moov","mvex","trex"]).forEach((function(e){var r=ce(e,4),i=t[r];i&&(i.default={duration:ce(e,12),flags:ce(e,20)})})),t}function _e(e){var t=e.subarray(8),r=t.subarray(86),i=de(t.subarray(4,8)),n=i,a="enca"===i||"encv"===i;if(a){var s=ge(t,[i])[0];ge(s.subarray("enca"===i?28:78),["sinf"]).forEach((function(e){var t=ge(e,["schm"])[0];if(t){var r=de(t.subarray(4,8));if("cbcs"===r||"cenc"===r){var i=ge(e,["frma"])[0];i&&(n=de(i))}}}))}switch(n){case"avc1":case"avc2":case"avc3":case"avc4":var o=ge(r,["avcC"])[0];n+="."+Ee(o[1])+Ee(o[2])+Ee(o[3]);break;case"mp4a":var u=ge(t,[i])[0],l=ge(u.subarray(28),["esds"])[0];if(l&&l.length>12){var d=4;if(3!==l[d++])break;d=be(l,d),d+=2;var h=l[d++];if(128&h&&(d+=2),64&h&&(d+=l[d++]),4!==l[d++])break;d=be(l,d);var c=l[d++];if(64!==c)break;if(n+="."+Ee(c),d+=12,5!==l[d++])break;d=be(l,d);var f=l[d++],v=(248&f)>>3;31===v&&(v+=1+((7&f)<<3)+((224&l[d])>>5)),n+="."+v}break;case"hvc1":case"hev1":var p=ge(r,["hvcC"])[0],g=p[1],m=["","A","B","C"][g>>6],y=31&g,_=ce(p,2),b=(32&g)>>5?"H":"L",E=p[12],T=p.subarray(6,12);n+="."+m+y,n+="."+_.toString(16).toUpperCase(),n+="."+b+E;for(var S="",L=T.length;L--;){var k=T[L];(k||S)&&(S="."+k.toString(16).toUpperCase()+S)}n+=S;break;case"dvh1":case"dvhe":var w=ge(r,["dvcC"])[0],x=w[2]>>1&127,A=w[2]<<5&32|w[3]>>3&31;n+="."+Te(x)+"."+Te(A);break;case"vp09":var R=ge(r,["vpcC"])[0],D=R[4],C=R[5],P=R[6]>>4&15;n+="."+Te(D)+"."+Te(C)+"."+Te(P);break;case"av01":var O=ge(r,["av1C"])[0],I=O[1]>>>5,F=31&O[1],M=O[2]>>>7?"H":"M",B=(64&O[2])>>6,N=(32&O[2])>>5,U=2===I&&B?N?12:10:B?10:8,G=(16&O[2])>>4,V=(8&O[2])>>3,j=(4&O[2])>>2,H=3&O[2];n+="."+I+"."+Te(F)+M+"."+Te(U)+"."+G+"."+V+j+H+"."+Te(1)+"."+Te(1)+"."+Te(1)+".0"}return{codec:n,encrypted:a}}function be(e,t){for(var r=t+5;128&e[t++]&&t<r;);return t}function Ee(e){return("0"+e.toString(16).toUpperCase()).slice(-2)}function Te(e){return(e<10?"0":"")+e}function Se(e,t){if(!e||!t)return e;var r=t.keyId;return r&&t.isCommonEncryption&&ge(e,["moov","trak"]).forEach((function(e){var t=ge(e,["mdia","minf","stbl","stsd"])[0].subarray(8),i=ge(t,["enca"]),n=i.length>0;n||(i=ge(t,["encv"])),i.forEach((function(e){ge(n?e.subarray(28):e.subarray(78),["sinf"]).forEach((function(e){var t=function(e){var t=ge(e,["schm"])[0];if(t){var r=de(t.subarray(4,8));if("cbcs"===r||"cenc"===r)return ge(e,["schi","tenc"])[0]}return null}(e);if(t){var i=t.subarray(8,24);i.some((function(e){return 0!==e}))||(x.log("[eme] Patching keyId in 'enc"+(n?"a":"v")+">sinf>>tenc' box: "+se(i)+" -> "+se(r)),t.set(r,8))}}))}))})),e}function Le(e){var t=ce(e,0),r=8;1&t&&(r+=4),4&t&&(r+=4);for(var i=0,n=ce(e,4),a=0;a<n;a++)256&t&&(i+=ce(e,r),r+=4),512&t&&(r+=4),1024&t&&(r+=4),2048&t&&(r+=4);return i}function ke(e,t){var r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function we(e,t){var r=[],i=t.samples,n=t.timescale,a=t.id,s=!1;return ge(i,["moof"]).map((function(o){var u=o.byteOffset-8;ge(o,["traf"]).map((function(o){var l=ge(o,["tfdt"]).map((function(e){var t=e[0],r=ce(e,4);return 1===t&&(r*=Math.pow(2,32),r+=ce(e,8)),r/n}))[0];return void 0!==l&&(e=l),ge(o,["tfhd"]).map((function(l){var d=ce(l,4),h=16777215&ce(l,0),c=0,f=!!(16&h),v=0,p=!!(32&h),g=8;d===a&&(!!(1&h)&&(g+=8),!!(2&h)&&(g+=4),!!(8&h)&&(c=ce(l,g),g+=4),f&&(v=ce(l,g),g+=4),p&&(g+=4),"video"===t.type&&(s=function(e){if(!e)return!1;var t=e.indexOf("."),r=t<0?e:e.substring(0,t);return"hvc1"===r||"hev1"===r||"dvh1"===r||"dvhe"===r}(t.codec)),ge(o,["trun"]).map((function(a){var o=a[0],l=16777215&ce(a,0),d=!!(1&l),h=0,f=!!(4&l),p=!!(256&l),g=0,m=!!(512&l),y=0,_=!!(1024&l),b=!!(2048&l),E=0,T=ce(a,4),S=8;d&&(h=ce(a,S),S+=4),f&&(S+=4);for(var L=h+u,k=0;k<T;k++){if(p?(g=ce(a,S),S+=4):g=c,m?(y=ce(a,S),S+=4):y=v,_&&(S+=4),b&&(E=0===o?ce(a,S):ve(a,S),S+=4),t.type===F)for(var w=0;w<y;){var x=ce(i,L);xe(s,i[L+=4])&&Ae(i.subarray(L,L+x),s?2:1,e+E/n,r),L+=x,w+=x+4}e+=g/n}})))}))}))})),r}function xe(e,t){if(e){var r=t>>1&63;return 39===r||40===r}return 6==(31&t)}function Ae(e,t,r,i){var n=Re(e),a=0;a+=t;for(var s=0,o=0,u=0;a<n.length;){s=0;do{if(a>=n.length)break;s+=u=n[a++]}while(255===u);o=0;do{if(a>=n.length)break;o+=u=n[a++]}while(255===u);var l=n.length-a,d=a;if(o<l)a+=o;else if(o>l){x.error("Malformed SEI payload. "+o+" is too small, only "+l+" bytes left to parse.");break}if(4===s){if(181===n[d++]){var h=he(n,d);if(d+=2,49===h){var c=ce(n,d);if(d+=4,1195456820===c){var f=n[d++];if(3===f){var v=n[d++],p=64&v,g=p?2+3*(31&v):0,m=new Uint8Array(g);if(p){m[0]=v;for(var y=1;y<g;y++)m[y]=n[d++]}i.push({type:f,payloadType:s,pts:r,bytes:m})}}}}}else if(5===s&&o>16){for(var _=[],b=0;b<16;b++){var E=n[d++].toString(16);_.push(1==E.length?"0"+E:E),3!==b&&5!==b&&7!==b&&9!==b||_.push("-")}for(var T=o-16,S=new Uint8Array(T),L=0;L<T;L++)S[L]=n[d++];i.push({payloadType:s,pts:r,uuid:_.join(""),userData:ne(S),userDataBytes:S})}}}function Re(e){for(var t=e.byteLength,r=[],i=1;i<t-2;)0===e[i]&&0===e[i+1]&&3===e[i+2]?(r.push(i+2),i+=2):i++;if(0===r.length)return e;var n=t-r.length,a=new Uint8Array(n),s=0;for(i=0;i<n;s++,i++)s===r[0]&&(s++,r.shift()),a[i]=e[s];return a}var De=function(){function e(e,t,r,i,n){void 0===i&&(i=[1]),void 0===n&&(n=null),this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=e,this.uri=t,this.keyFormat=r,this.keyFormatVersions=i,this.iv=n,this.encrypted=!!e&&"NONE"!==e,this.isCommonEncryption=this.encrypted&&"AES-128"!==e}e.clearKeyUriToKeyIdMap=function(){};var t=e.prototype;return t.isSupported=function(){if(this.method){if("AES-128"===this.method||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method}return!1},t.getDecryptData=function(t){if(!this.encrypted||!this.uri)return null;if("AES-128"===this.method&&this.uri&&!this.iv){"number"!=typeof t&&("AES-128"!==this.method||this.iv||x.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),t=0);var r=function(e){for(var t=new Uint8Array(16),r=12;r<16;r++)t[r]=e>>8*(15-r)&255;return t}(t);return new e(this.method,this.uri,"identity",this.keyFormatVersions,r)}return this},e}();function Ce(e){if(void 0===e&&(e=!0),"undefined"!=typeof self)return(e||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}var Pe={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function Oe(e,t,r){return void 0===r&&(r=!0),!e.split(",").some((function(e){return!Ie(e,t,r)}))}function Ie(e,t,r){var i;void 0===r&&(r=!0);var n=Ce(r);return null!=(i=null==n?void 0:n.isTypeSupported(Fe(e,t)))&&i}function Fe(e,t){return t+'/mp4;codecs="'+e+'"'}function Me(e){if(e){var t=e.substring(0,4);return Pe.video[t]}return 2}function Be(e){return e.split(",").reduce((function(e,t){var r=Pe.video[t];return r?(2*r+e)/(e?3:2):(Pe.audio[t]+e)/(e?2:1)}),0)}var Ne={};var Ue=/flac|opus/i;function Ge(e,t){return void 0===t&&(t=!0),e.replace(Ue,(function(e){return function(e,t){if(void 0===t&&(t=!0),Ne[e])return Ne[e];for(var r={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"]}[e],i=0;i<r.length;i++)if(Ie(r[i],"audio",t))return Ne[e]=r[i],r[i];return e}(e.toLowerCase(),t)}))}function Ve(e,t){return e&&"mp4a"!==e?e:t?t.split(",")[0]:t}var je=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,He=/#EXT-X-MEDIA:(.*)/g,Ke=/^#EXT(?:INF|-X-TARGETDURATION):/m,ze=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),We=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),qe=function(){function e(){}return e.findGroup=function(e,t){for(var r=0;r<e.length;r++){var i=e[r];if(i.id===t)return i}},e.resolve=function(e,t){return p.buildAbsoluteURL(t,e,{alwaysNormalize:!0})},e.isMediaPlaylist=function(e){return Ke.test(e)},e.parseMasterPlaylist=function(t,r){var i,n={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:!1},a=[];for(je.lastIndex=0;null!=(i=je.exec(t));)if(i[1]){var s,o=new D(i[1]),u=i[2],l={attrs:o,bitrate:o.decimalInteger("BANDWIDTH")||o.decimalInteger("AVERAGE-BANDWIDTH"),name:o.NAME,url:e.resolve(u,r)},d=o.decimalResolution("RESOLUTION");d&&(l.width=d.width,l.height=d.height),Qe(o.CODECS,l),null!=(s=l.unknownCodecs)&&s.length||a.push(l),n.levels.push(l)}else if(i[3]){var h=i[3],c=i[4];switch(h){case"SESSION-DATA":var f=new D(c),v=f["DATA-ID"];v&&(null===n.sessionData&&(n.sessionData={}),n.sessionData[v]=f);break;case"SESSION-KEY":var p=Ye(c,r);p.encrypted&&p.isSupported()?(null===n.sessionKeys&&(n.sessionKeys=[]),n.sessionKeys.push(p)):x.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+c+'"');break;case"DEFINE":break;case"CONTENT-STEERING":var g=new D(c);n.contentSteering={uri:e.resolve(g["SERVER-URI"],r),pathwayId:g["PATHWAY-ID"]||"."};break;case"START":n.startTimeOffset=Xe(c)}}var m=a.length>0&&a.length<n.levels.length;return n.levels=m?a:n.levels,0===n.levels.length&&(n.playlistParsingError=new Error("no levels found in manifest")),n},e.parseMasterPlaylistMedia=function(t,r,i){var n,a={},s=i.levels,o={AUDIO:s.map((function(e){return{id:e.attrs.AUDIO,audioCodec:e.audioCodec}})),SUBTITLES:s.map((function(e){return{id:e.attrs.SUBTITLES,textCodec:e.textCodec}})),"CLOSED-CAPTIONS":[]},u=0;for(He.lastIndex=0;null!==(n=He.exec(t));){var l=new D(n[1]),d=l.TYPE;if(d){var h=o[d],c=a[d]||[];a[d]=c;var f=l.LANGUAGE,v=l["ASSOC-LANGUAGE"],p=l.CHANNELS,g=l.CHARACTERISTICS,m=l["INSTREAM-ID"],y={attrs:l,bitrate:0,id:u++,groupId:l["GROUP-ID"]||"",name:l.NAME||f||"",type:d,default:l.bool("DEFAULT"),autoselect:l.bool("AUTOSELECT"),forced:l.bool("FORCED"),lang:f,url:l.URI?e.resolve(l.URI,r):""};if(v&&(y.assocLang=v),p&&(y.channels=p),g&&(y.characteristics=g),m&&(y.instreamId=m),null!=h&&h.length){var _=e.findGroup(h,y.groupId)||h[0];Je(y,_,"audioCodec"),Je(y,_,"textCodec")}c.push(y)}}return a},e.parseLevelPlaylist=function(e,t,r,i,n,a){var s,u,l,d=new G(t),h=d.fragments,c=null,f=0,v=0,p=0,m=0,y=null,_=new N(i,t),b=-1,E=!1,T=null;for(ze.lastIndex=0,d.m3u8=e,d.hasVariableRefs=!1;null!==(s=ze.exec(e));){E&&(E=!1,(_=new N(i,t)).start=p,_.sn=f,_.cc=m,_.level=r,c&&(_.initSegment=c,_.rawProgramDateTime=c.rawProgramDateTime,c.rawProgramDateTime=null,T&&(_.setByteRange(T),T=null)));var S=s[1];if(S){_.duration=parseFloat(S);var L=(" "+s[2]).slice(1);_.title=L||null,_.tagList.push(L?["INF",S,L]:["INF",S])}else if(s[3]){if(g(_.duration)){_.start=p,l&&et(_,l,d),_.sn=f,_.level=r,_.cc=m,h.push(_);var k=(" "+s[3]).slice(1);_.relurl=k,Ze(_,y),y=_,p+=_.duration,f++,v=0,E=!0}}else if(s[4]){var w=(" "+s[4]).slice(1);y?_.setByteRange(w,y):_.setByteRange(w)}else if(s[5])_.rawProgramDateTime=(" "+s[5]).slice(1),_.tagList.push(["PROGRAM-DATE-TIME",_.rawProgramDateTime]),-1===b&&(b=h.length);else{if(!(s=s[0].match(We))){x.warn("No matches on slow regex match for level playlist!");continue}for(u=1;u<s.length&&void 0===s[u];u++);var A=(" "+s[u]).slice(1),R=(" "+s[u+1]).slice(1),C=s[u+2]?(" "+s[u+2]).slice(1):"";switch(A){case"PLAYLIST-TYPE":d.type=R.toUpperCase();break;case"MEDIA-SEQUENCE":f=d.startSN=parseInt(R);break;case"SKIP":var O=new D(R),I=O.decimalInteger("SKIPPED-SEGMENTS");if(g(I)){d.skippedSegments=I;for(var F=I;F--;)h.unshift(null);f+=I}var M=O.enumeratedString("RECENTLY-REMOVED-DATERANGES");M&&(d.recentlyRemovedDateranges=M.split("\t"));break;case"TARGETDURATION":d.targetduration=Math.max(parseInt(R),1);break;case"VERSION":d.version=parseInt(R);break;case"INDEPENDENT-SEGMENTS":case"EXTM3U":case"DEFINE":break;case"ENDLIST":d.live=!1;break;case"#":(R||C)&&_.tagList.push(C?[R,C]:[R]);break;case"DISCONTINUITY":m++,_.tagList.push(["DIS"]);break;case"GAP":_.gap=!0,_.tagList.push([A]);break;case"BITRATE":_.tagList.push([A,R]);break;case"DATERANGE":var B=new D(R),V=new P(B,d.dateRanges[B.ID]);V.isValid||d.skippedSegments?d.dateRanges[V.id]=V:x.warn('Ignoring invalid DATERANGE tag: "'+R+'"'),_.tagList.push(["EXT-X-DATERANGE",R]);break;case"DISCONTINUITY-SEQUENCE":m=parseInt(R);break;case"KEY":var j=Ye(R,t);if(j.isSupported()){if("NONE"===j.method){l=void 0;break}l||(l={}),l[j.keyFormat]&&(l=o({},l)),l[j.keyFormat]=j}else x.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+R+'"');break;case"START":d.startTimeOffset=Xe(R);break;case"MAP":var H=new D(R);if(_.duration){var K=new N(i,t);$e(K,H,r,l),c=K,_.initSegment=c,c.rawProgramDateTime&&!_.rawProgramDateTime&&(_.rawProgramDateTime=c.rawProgramDateTime)}else{var z=_.byteRangeEndOffset;if(z){var W=_.byteRangeStartOffset;T=z-W+"@"+W}else T=null;$e(_,H,r,l),c=_,E=!0}break;case"SERVER-CONTROL":var q=new D(R);d.canBlockReload=q.bool("CAN-BLOCK-RELOAD"),d.canSkipUntil=q.optionalFloat("CAN-SKIP-UNTIL",0),d.canSkipDateRanges=d.canSkipUntil>0&&q.bool("CAN-SKIP-DATERANGES"),d.partHoldBack=q.optionalFloat("PART-HOLD-BACK",0),d.holdBack=q.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var Y=new D(R);d.partTarget=Y.decimalFloatingPoint("PART-TARGET");break;case"PART":var X=d.partList;X||(X=d.partList=[]);var Q=v>0?X[X.length-1]:void 0,J=v++,Z=new D(R),$=new U(Z,_,t,J,Q);X.push($),_.duration+=$.duration;break;case"PRELOAD-HINT":var ee=new D(R);d.preloadHint=ee;break;case"RENDITION-REPORT":var te=new D(R);d.renditionReports=d.renditionReports||[],d.renditionReports.push(te);break;default:x.warn("line parsed but not handled: "+s)}}}y&&!y.relurl?(h.pop(),p-=y.duration,d.partList&&(d.fragmentHint=y)):d.partList&&(Ze(_,y),_.cc=m,d.fragmentHint=_,l&&et(_,l,d));var re=h.length,ie=h[0],ne=h[re-1];if((p+=d.skippedSegments*d.targetduration)>0&&re&&ne){d.averagetargetduration=p/re;var ae=ne.sn;d.endSN="initSegment"!==ae?ae:0,d.live||(ne.endList=!0),ie&&(d.startCC=ie.cc)}else d.endSN=0,d.startCC=0;return d.fragmentHint&&(p+=d.fragmentHint.duration),d.totalduration=p,d.endCC=m,b>0&&function(e,t){for(var r=e[t],i=t;i--;){var n=e[i];if(!n)return;n.programDateTime=r.programDateTime-1e3*n.duration,r=n}}(h,b),d},e}();function Ye(e,t,r){var i,n,a=new D(e),s=null!=(i=a.METHOD)?i:"",o=a.URI,u=a.hexadecimalInteger("IV"),l=a.KEYFORMATVERSIONS,d=null!=(n=a.KEYFORMAT)?n:"identity";o&&a.IV&&!u&&x.error("Invalid IV: "+a.IV);var h=o?qe.resolve(o,t):"",c=(l||"1").split("/").map(Number).filter(Number.isFinite);return new De(s,h,d,c,u)}function Xe(e){var t=new D(e).decimalFloatingPoint("TIME-OFFSET");return g(t)?t:null}function Qe(e,t){var r=(e||"").split(/[ ,]+/).filter((function(e){return e}));["video","audio","text"].forEach((function(e){var i=r.filter((function(t){return function(e,t){var r=Pe[t];return!!r&&!!r[e.slice(0,4)]}(t,e)}));i.length&&(t[e+"Codec"]=i.join(","),r=r.filter((function(e){return-1===i.indexOf(e)})))})),t.unknownCodecs=r}function Je(e,t,r){var i=t[r];i&&(e[r]=i)}function Ze(e,t){e.rawProgramDateTime?e.programDateTime=Date.parse(e.rawProgramDateTime):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime),g(e.programDateTime)||(e.programDateTime=null,e.rawProgramDateTime=null)}function $e(e,t,r,i){e.relurl=t.URI,t.BYTERANGE&&e.setByteRange(t.BYTERANGE),e.level=r,e.sn="initSegment",i&&(e.levelkeys=i),e.initSegment=null}function et(e,t,r){e.levelkeys=t;var i=r.encryptedFragments;i.length&&i[i.length-1].levelkeys===t||!Object.keys(t).some((function(e){return t[e].isCommonEncryption}))||i.push(e)}var tt="manifest",rt="level",it="audioTrack",nt="subtitleTrack",at="main",st="audio",ot="subtitle";function ut(e){switch(e.type){case it:return st;case nt:return ot;default:return at}}function lt(e,t){var r=e.url;return void 0!==r&&0!==r.indexOf("data:")||(r=t.url),r}var dt=function(){function e(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}var t=e.prototype;return t.startLoad=function(e){},t.stopLoad=function(){this.destroyInternalLoaders()},t.registerListeners=function(){var e=this.hls;e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.LEVEL_LOADING,this.onLevelLoading,this),e.on(_.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(_.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},t.unregisterListeners=function(){var e=this.hls;e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.LEVEL_LOADING,this.onLevelLoading,this),e.off(_.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(_.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},t.createInternalLoader=function(e){var t=this.hls.config,r=t.pLoader,i=t.loader,n=new(r||i)(t);return this.loaders[e.type]=n,n},t.getInternalLoader=function(e){return this.loaders[e.type]},t.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},t.destroyInternalLoaders=function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}},t.destroy=function(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()},t.onManifestLoading=function(e,t){var r=t.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:tt,url:r,deliveryDirectives:null})},t.onLevelLoading=function(e,t){var r=t.id,i=t.level,n=t.pathwayId,a=t.url,s=t.deliveryDirectives;this.load({id:r,level:i,pathwayId:n,responseType:"text",type:rt,url:a,deliveryDirectives:s})},t.onAudioTrackLoading=function(e,t){var r=t.id,i=t.groupId,n=t.url,a=t.deliveryDirectives;this.load({id:r,groupId:i,level:null,responseType:"text",type:it,url:n,deliveryDirectives:a})},t.onSubtitleTrackLoading=function(e,t){var r=t.id,i=t.groupId,n=t.url,a=t.deliveryDirectives;this.load({id:r,groupId:i,level:null,responseType:"text",type:nt,url:n,deliveryDirectives:a})},t.load=function(e){var t,r,i,n=this,a=this.hls.config,s=this.getInternalLoader(e);if(s){var u=s.context;if(u&&u.url===e.url&&u.level===e.level)return void x.trace("[playlist-loader]: playlist request ongoing");x.log("[playlist-loader]: aborting previous loader for type: "+e.type),s.abort()}if(r=e.type===tt?a.manifestLoadPolicy.default:o({},a.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(e),g(null==(t=e.deliveryDirectives)?void 0:t.part)&&(e.type===rt&&null!==e.level?i=this.hls.levels[e.level].details:e.type===it&&null!==e.id?i=this.hls.audioTracks[e.id].details:e.type===nt&&null!==e.id&&(i=this.hls.subtitleTracks[e.id].details),i)){var l=i.partTarget,d=i.targetduration;if(l&&d){var h=1e3*Math.max(3*l,.8*d);r=o({},r,{maxTimeToFirstByteMs:Math.min(h,r.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(h,r.maxTimeToFirstByteMs)})}}var c=r.errorRetry||r.timeoutRetry||{},f={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:c.maxNumRetry||0,retryDelay:c.retryDelayMs||0,maxRetryDelay:c.maxRetryDelayMs||0},v={onSuccess:function(e,t,r,i){var a=n.getInternalLoader(r);n.resetInternalLoader(r.type);var s=e.data;0===s.indexOf("#EXTM3U")?(t.parsing.start=performance.now(),qe.isMediaPlaylist(s)?n.handleTrackOrLevelPlaylist(e,t,r,i||null,a):n.handleMasterPlaylist(e,t,r,i)):n.handleManifestParsingError(e,r,new Error("no EXTM3U delimiter"),i||null,t)},onError:function(e,t,r,i){n.handleNetworkError(t,r,!1,e,i)},onTimeout:function(e,t,r){n.handleNetworkError(t,r,!0,void 0,e)}};s.load(e,f,v)},t.handleMasterPlaylist=function(e,t,r,i){var n=this.hls,a=e.data,s=lt(e,r),o=qe.parseMasterPlaylist(a,s);if(o.playlistParsingError)this.handleManifestParsingError(e,r,o.playlistParsingError,i,t);else{var u=o.contentSteering,l=o.levels,d=o.sessionData,h=o.sessionKeys,c=o.startTimeOffset,f=o.variableList;this.variableList=f;var v=qe.parseMasterPlaylistMedia(a,s,o),p=v.AUDIO,g=void 0===p?[]:p,m=v.SUBTITLES,y=v["CLOSED-CAPTIONS"];g.length&&(g.some((function(e){return!e.url}))||!l[0].audioCodec||l[0].attrs.AUDIO||(x.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),g.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new D({}),bitrate:0,url:""}))),n.trigger(_.MANIFEST_LOADED,{levels:l,audioTracks:g,subtitles:m,captions:y,contentSteering:u,url:s,stats:t,networkDetails:i,sessionData:d,sessionKeys:h,startTimeOffset:c,variableList:f})}},t.handleTrackOrLevelPlaylist=function(e,t,r,i,n){var a=this.hls,s=r.id,o=r.level,u=r.type,l=lt(e,r),d=g(o)?o:g(s)?s:0,h=ut(r),c=qe.parseLevelPlaylist(e.data,l,d,h,0,this.variableList);if(u===tt){var f={attrs:new D({}),bitrate:0,details:c,name:"",url:l};a.trigger(_.MANIFEST_LOADED,{levels:[f],audioTracks:[],url:l,stats:t,networkDetails:i,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=c,this.handlePlaylistLoaded(c,e,t,r,i,n)},t.handleManifestParsingError=function(e,t,r,i,n){this.hls.trigger(_.ERROR,{type:b.NETWORK_ERROR,details:E.MANIFEST_PARSING_ERROR,fatal:t.type===tt,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:i,stats:n})},t.handleNetworkError=function(e,t,r,n,a){void 0===r&&(r=!1);var s="A network "+(r?"timeout":"error"+(n?" (status "+n.code+")":""))+" occurred while loading "+e.type;e.type===rt?s+=": "+e.level+" id: "+e.id:e.type!==it&&e.type!==nt||(s+=" id: "+e.id+' group-id: "'+e.groupId+'"');var o=new Error(s);x.warn("[playlist-loader]: "+s);var u=E.UNKNOWN,l=!1,d=this.getInternalLoader(e);switch(e.type){case tt:u=r?E.MANIFEST_LOAD_TIMEOUT:E.MANIFEST_LOAD_ERROR,l=!0;break;case rt:u=r?E.LEVEL_LOAD_TIMEOUT:E.LEVEL_LOAD_ERROR,l=!1;break;case it:u=r?E.AUDIO_TRACK_LOAD_TIMEOUT:E.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case nt:u=r?E.SUBTITLE_TRACK_LOAD_TIMEOUT:E.SUBTITLE_LOAD_ERROR,l=!1}d&&this.resetInternalLoader(e.type);var h={type:b.NETWORK_ERROR,details:u,fatal:l,url:e.url,loader:d,context:e,error:o,networkDetails:t,stats:a};if(n){var c=(null==t?void 0:t.url)||e.url;h.response=i({url:c,data:void 0},n)}this.hls.trigger(_.ERROR,h)},t.handlePlaylistLoaded=function(e,t,r,i,n,a){var s=this.hls,o=i.type,u=i.level,l=i.id,d=i.groupId,h=i.deliveryDirectives,c=lt(t,i),f=ut(i),v="number"==typeof i.level&&f===at?u:void 0;if(e.fragments.length){e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));var p=e.playlistParsingError;if(p)s.trigger(_.ERROR,{type:b.NETWORK_ERROR,details:E.LEVEL_PARSING_ERROR,fatal:!1,url:c,error:p,reason:p.message,response:t,context:i,level:v,parent:f,networkDetails:n,stats:r});else switch(e.live&&a&&(a.getCacheAge&&(e.ageHeader=a.getCacheAge()||0),a.getCacheAge&&!isNaN(e.ageHeader)||(e.ageHeader=0)),o){case tt:case rt:s.trigger(_.LEVEL_LOADED,{details:e,level:v||0,id:l||0,stats:r,networkDetails:n,deliveryDirectives:h});break;case it:s.trigger(_.AUDIO_TRACK_LOADED,{details:e,id:l||0,groupId:d||"",stats:r,networkDetails:n,deliveryDirectives:h});break;case nt:s.trigger(_.SUBTITLE_TRACK_LOADED,{details:e,id:l||0,groupId:d||"",stats:r,networkDetails:n,deliveryDirectives:h})}}else{var g=new Error("No Segments found in Playlist");s.trigger(_.ERROR,{type:b.NETWORK_ERROR,details:E.LEVEL_EMPTY_ERROR,fatal:!1,url:c,error:g,reason:g.message,response:t,context:i,level:v,parent:f,networkDetails:n,stats:r})}},e}();function ht(e,t){var r;try{r=new Event("addtrack")}catch(e){(r=document.createEvent("Event")).initEvent("addtrack",!1,!1)}r.track=e,t.dispatchEvent(r)}function ct(e,t,r,i){var n=e.mode;if("disabled"===n&&(e.mode="hidden"),e.cues&&e.cues.length>0)for(var a=function(e,t,r){var i=[],n=function(e,t){if(t<e[0].startTime)return 0;var r=e.length-1;if(t>e[r].endTime)return-1;for(var i=0,n=r;i<=n;){var a=Math.floor((n+i)/2);if(t<e[a].startTime)n=a-1;else{if(!(t>e[a].startTime&&i<r))return a;i=a+1}}return e[i].startTime-t<t-e[n].startTime?i:n}(e,t);if(n>-1)for(var a=n,s=e.length;a<s;a++){var o=e[a];if(o.startTime>=t&&o.endTime<=r)i.push(o);else if(o.startTime>r)return i}return i}(e.cues,t,r),s=0;s<a.length;s++)i&&!i(a[s])||e.removeCue(a[s]);"disabled"===n&&(e.mode=n)}var ft="org.id3",vt="com.apple.quicktime.HLS",pt="https://aomedia.org/emsg/ID3";function gt(){if("undefined"!=typeof self)return self.VTTCue||self.TextTrackCue}function mt(e,t,r,n,a){var s=new e(t,r,"");try{s.value=n,a&&(s.type=a)}catch(o){s=new e(t,r,JSON.stringify(a?i({type:a},n):n))}return s}var yt=function(){var e=gt();try{e&&new e(0,Number.POSITIVE_INFINITY,"")}catch(e){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function _t(e,t){return e.getTime()/1e3-t}var bt=function(){function e(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}var t=e.prototype;return t.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},t._registerListeners=function(){var e=this.hls;e.on(_.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(_.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(_.LEVEL_UPDATED,this.onLevelUpdated,this)},t._unregisterListeners=function(){var e=this.hls;e.off(_.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(_.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(_.LEVEL_UPDATED,this.onLevelUpdated,this)},t.onMediaAttached=function(e,t){this.media=t.media},t.onMediaDetaching=function(){this.id3Track&&(function(e){var t=e.mode;if("disabled"===t&&(e.mode="hidden"),e.cues)for(var r=e.cues.length;r--;)e.removeCue(e.cues[r]);"disabled"===t&&(e.mode=t)}(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},t.onManifestLoading=function(){this.dateRangeCuesAppended={}},t.createTrack=function(e){var t=this.getID3Track(e.textTracks);return t.mode="hidden",t},t.getID3Track=function(e){if(this.media){for(var t=0;t<e.length;t++){var r=e[t];if("metadata"===r.kind&&"id3"===r.label)return ht(r,this.media),r}return this.media.addTextTrack("metadata","id3")}},t.onFragParsingMetadata=function(e,t){if(this.media){var r=this.hls.config,i=r.enableEmsgMetadataCues,n=r.enableID3MetadataCues;if(i||n){var a=t.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));var s=gt();if(s)for(var o=0;o<a.length;o++){var u=a[o].type;if((u!==pt||i)&&n){var l=Z(a[o].data);if(l){var d=a[o].pts,h=d+a[o].duration;h>yt&&(h=yt),h-d<=0&&(h=d+.25);for(var c=0;c<l.length;c++){var f=l[c];if(!Q(f)){this.updateId3CueEnds(d,u);var v=mt(s,d,h,f,u);v&&this.id3Track.addCue(v)}}}}}}}},t.updateId3CueEnds=function(e,t){var r,i=null==(r=this.id3Track)?void 0:r.cues;if(i)for(var n=i.length;n--;){var a=i[n];a.type===t&&a.startTime<e&&a.endTime===yt&&(a.endTime=e)}},t.onBufferFlushing=function(e,t){var r=t.startOffset,i=t.endOffset,n=t.type,a=this.id3Track,s=this.hls;if(s){var o=s.config,u=o.enableEmsgMetadataCues,l=o.enableID3MetadataCues;a&&(u||l)&&ct(a,r,i,"audio"===n?function(e){return e.type===ft&&l}:"video"===n?function(e){return e.type===pt&&u}:function(e){return e.type===ft&&l||e.type===pt&&u})}},t.onLevelUpdated=function(e,t){var r=this,i=t.details;if(this.media&&i.hasProgramDateTime&&this.hls.config.enableDateRangeMetadataCues){var n=this.dateRangeCuesAppended,a=this.id3Track,s=i.dateRanges,o=Object.keys(s);if(a)for(var u=Object.keys(n).filter((function(e){return!o.includes(e)})),l=function(){var e=u[d];Object.keys(n[e].cues).forEach((function(t){a.removeCue(n[e].cues[t])})),delete n[e]},d=u.length;d--;)l();var h=i.fragments[i.fragments.length-1];if(0!==o.length&&g(null==h?void 0:h.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var c=h.programDateTime/1e3-h.start,f=gt(),v=function(){var e,t,i=o[p],a=s[i],u=_t(a.startDate,c),l=n[i],d=(null==l?void 0:l.cues)||{},h=(null==l?void 0:l.durationKnown)||!1,v=yt,g=a.endDate;if(g)v=_t(g,c),h=!0;else if(a.endOnNext&&!h){var m=o.reduce((function(e,t){if(t!==a.id){var r=s[t];if(r.class===a.class&&r.startDate>a.startDate&&(!e||a.startDate<e.startDate))return r}return e}),null);m&&(v=_t(m.startDate,c),h=!0)}for(var y=Object.keys(a.attr),_=0;_<y.length;_++){var b=y[_];if("ID"!==(t=b)&&"CLASS"!==t&&"START-DATE"!==t&&"DURATION"!==t&&"END-DATE"!==t&&"END-ON-NEXT"!==t){var E=d[b];if(E)h&&!l.durationKnown&&(E.endTime=v);else if(f){var T=a.attr[b];C(b)&&(e=T,T=Uint8Array.from(e.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer);var S=mt(f,u,v,{key:b,data:T},vt);S&&(S.id=i,r.id3Track.addCue(S),d[b]=S)}}}n[i]={cues:d,dateRange:a,durationKnown:h}},p=0;p<o.length;p++)v()}}},e}(),Et=function(){function e(e){var t=this;this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=function(){return t.timeupdate()},this.hls=e,this.config=e.config,this.registerListeners()}var t=e.prototype;return t.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},t.registerListeners=function(){this.hls.on(_.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(_.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(_.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(_.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(_.ERROR,this.onError,this)},t.unregisterListeners=function(){this.hls.off(_.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(_.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(_.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(_.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(_.ERROR,this.onError,this)},t.onMediaAttached=function(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},t.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},t.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},t.onLevelUpdated=function(e,t){var r=t.details;this.levelDetails=r,r.advanced&&this.timeupdate(),!r.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},t.onError=function(e,t){var r;t.details===E.BUFFER_STALLED_ERROR&&(this.stallCount++,null!=(r=this.levelDetails)&&r.live&&x.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},t.timeupdate=function(){var e=this.media,t=this.levelDetails;if(e&&t){this.currentTime=e.currentTime;var r=this.computeLatency();if(null!==r){this._latency=r;var i=this.config,n=i.lowLatencyMode,a=i.maxLiveSyncPlaybackRate;if(n&&1!==a&&t.live){var s=this.targetLatency;if(null!==s){var o=r-s;if(o<Math.min(this.maxLatency,s+t.targetduration)&&o>.05&&this.forwardBufferLength>1){var u=Math.min(2,Math.max(1,a)),l=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;e.playbackRate=Math.min(u,Math.max(1,l))}else 1!==e.playbackRate&&0!==e.playbackRate&&(e.playbackRate=1)}}}}},t.estimateLiveEdge=function(){var e=this.levelDetails;return null===e?null:e.edge+e.age},t.computeLatency=function(){var e=this.estimateLiveEdge();return null===e?null:e-this.currentTime},s(e,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var e=this.config,t=this.levelDetails;return void 0!==e.liveMaxLatencyDuration?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}},{key:"targetLatency",get:function(){var e=this.levelDetails;if(null===e)return null;var t=e.holdBack,r=e.partHoldBack,i=e.targetduration,n=this.config,a=n.liveSyncDuration,s=n.liveSyncDurationCount,o=n.lowLatencyMode,u=this.hls.userConfig,l=o&&r||t;(u.liveSyncDuration||u.liveSyncDurationCount||0===l)&&(l=void 0!==a?a:s*i);var d=i;return l+Math.min(1*this.stallCount,d)}},{key:"liveSyncPosition",get:function(){var e=this.estimateLiveEdge(),t=this.targetLatency,r=this.levelDetails;if(null===e||null===t||null===r)return null;var i=r.edge,n=e-t-this.edgeStalled,a=i-r.totalduration,s=i-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(a,n),s)}},{key:"drift",get:function(){var e=this.levelDetails;return null===e?1:e.drift}},{key:"edgeStalled",get:function(){var e=this.levelDetails;if(null===e)return 0;var t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}},{key:"forwardBufferLength",get:function(){var e=this.media,t=this.levelDetails;if(!e||!t)return 0;var r=e.buffered.length;return(r?e.buffered.end(r-1):t.edge)-this.currentTime}}]),e}(),Tt=["NONE","TYPE-0","TYPE-1",null];var St=["SDR","PQ","HLG"];var Lt="",kt="YES",wt="v2";function xt(e){var t=e.canSkipUntil,r=e.canSkipDateRanges,i=e.age;return t&&i<t/2?r?wt:kt:Lt}var At=function(){function e(e,t,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=r}return e.prototype.addDirectives=function(e){var t=new self.URL(e);return void 0!==this.msn&&t.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href},e}(),Rt=function(){function e(e){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.frameRate=e.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=e.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.codecSet=[e.videoCodec,e.audioCodec].filter((function(e){return!!e})).map((function(e){return e.substring(0,4)})).join(","),this.addGroupId("audio",e.attrs.AUDIO),this.addGroupId("text",e.attrs.SUBTITLES)}var t=e.prototype;return t.hasAudioGroup=function(e){return Dt(this._audioGroups,e)},t.hasSubtitleGroup=function(e){return Dt(this._subtitleGroups,e)},t.addGroupId=function(e,t){if(t)if("audio"===e){var r=this._audioGroups;r||(r=this._audioGroups=[]),-1===r.indexOf(t)&&r.push(t)}else if("text"===e){var i=this._subtitleGroups;i||(i=this._subtitleGroups=[]),-1===i.indexOf(t)&&i.push(t)}},t.addFallback=function(){},s(e,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"averageBitrate",get:function(){return this._avgBitrate||this.realBitrate||this.bitrate}},{key:"attrs",get:function(){return this._attrs[0]}},{key:"codecs",get:function(){return this.attrs.CODECS||""}},{key:"pathwayId",get:function(){return this.attrs["PATHWAY-ID"]||"."}},{key:"videoRange",get:function(){return this.attrs["VIDEO-RANGE"]||"SDR"}},{key:"score",get:function(){return this.attrs.optionalFloat("SCORE",0)}},{key:"uri",get:function(){return this.url[0]||""}},{key:"audioGroups",get:function(){return this._audioGroups}},{key:"subtitleGroups",get:function(){return this._subtitleGroups}},{key:"urlId",get:function(){return 0},set:function(e){}},{key:"audioGroupIds",get:function(){return this.audioGroups?[this.audioGroupId]:void 0}},{key:"textGroupIds",get:function(){return this.subtitleGroups?[this.textGroupId]:void 0}},{key:"audioGroupId",get:function(){var e;return null==(e=this.audioGroups)?void 0:e[0]}},{key:"textGroupId",get:function(){var e;return null==(e=this.subtitleGroups)?void 0:e[0]}}]),e}();function Dt(e,t){return!(!t||!e)&&-1!==e.indexOf(t)}function Ct(e,t){var r=t.startPTS;if(g(r)){var i,n=0;t.sn>e.sn?(n=r-e.start,i=e):(n=e.start-r,i=t),i.duration!==n&&(i.duration=n)}else t.sn>e.sn?e.cc===t.cc&&e.minEndPTS?t.start=e.start+(e.minEndPTS-e.start):t.start=e.start+e.duration:t.start=Math.max(e.start-t.duration,0)}function Pt(e,t,r,i,n,a){i-r<=0&&(x.warn("Fragment should have a positive duration",t),i=r+t.duration,a=n+t.duration);var s=r,o=i,u=t.startPTS,l=t.endPTS;if(g(u)){var d=Math.abs(u-r);g(t.deltaPTS)?t.deltaPTS=Math.max(d,t.deltaPTS):t.deltaPTS=d,s=Math.max(r,u),r=Math.min(r,u),n=Math.min(n,t.startDTS),o=Math.min(i,l),i=Math.max(i,l),a=Math.max(a,t.endDTS)}var h=r-t.start;0!==t.start&&(t.start=r),t.duration=i-t.start,t.startPTS=r,t.maxStartPTS=s,t.startDTS=n,t.endPTS=i,t.minEndPTS=o,t.endDTS=a;var c,f=t.sn;if(!e||f<e.startSN||f>e.endSN)return 0;var v=f-e.startSN,p=e.fragments;for(p[v]=t,c=v;c>0;c--)Ct(p[c],p[c-1]);for(c=v;c<p.length-1;c++)Ct(p[c],p[c+1]);return e.fragmentHint&&Ct(p[p.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,h}function Ot(e,t){for(var r=null,i=e.fragments,n=i.length-1;n>=0;n--){var a=i[n].initSegment;if(a){r=a;break}}e.fragmentHint&&delete e.fragmentHint.endPTS;var s,u,l,d,h,c=0;if(function(e,t,r){for(var i=t.skippedSegments,n=Math.max(e.startSN,t.startSN)-t.startSN,a=(e.fragmentHint?1:0)+(i?t.endSN:Math.min(e.endSN,t.endSN))-t.startSN,s=t.startSN-e.startSN,o=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,u=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=n;l<=a;l++){var d=u[s+l],h=o[l];i&&!h&&l<i&&(h=t.fragments[l]=d),d&&h&&r(d,h)}}(e,t,(function(e,i){e.relurl&&(c=e.cc-i.cc),g(e.startPTS)&&g(e.endPTS)&&(i.start=i.startPTS=e.startPTS,i.startDTS=e.startDTS,i.maxStartPTS=e.maxStartPTS,i.endPTS=e.endPTS,i.endDTS=e.endDTS,i.minEndPTS=e.minEndPTS,i.duration=e.endPTS-e.startPTS,i.duration&&(s=i),t.PTSKnown=t.alignedSliding=!0),i.elementaryStreams=e.elementaryStreams,i.loader=e.loader,i.stats=e.stats,e.initSegment&&(i.initSegment=e.initSegment,r=e.initSegment)})),r&&(t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments).forEach((function(e){var t;!e||e.initSegment&&e.initSegment.relurl!==(null==(t=r)?void 0:t.relurl)||(e.initSegment=r)})),t.skippedSegments)if(t.deltaUpdateFailed=t.fragments.some((function(e){return!e})),t.deltaUpdateFailed){x.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var f=t.skippedSegments;f--;)t.fragments.shift();t.startSN=t.fragments[0].sn,t.startCC=t.fragments[0].cc}else t.canSkipDateRanges&&(t.dateRanges=(u=e.dateRanges,l=t.dateRanges,d=t.recentlyRemovedDateranges,h=o({},u),d&&d.forEach((function(e){delete h[e]})),Object.keys(l).forEach((function(e){var t=new P(l[e].attr,h[e]);t.isValid?h[e]=t:x.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(l[e].attr)+'"')})),h));var v=t.fragments;if(c){x.warn("discontinuity sliding from playlist, take drift into account");for(var p=0;p<v.length;p++)v[p].cc+=c}t.skippedSegments&&(t.startCC=t.fragments[0].cc),function(e,t,r){if(e&&t)for(var i=0,n=0,a=e.length;n<=a;n++){var s=e[n],o=t[n+i];s&&o&&s.index===o.index&&s.fragment.sn===o.fragment.sn?r(s,o):i--}}(e.partList,t.partList,(function(e,t){t.elementaryStreams=e.elementaryStreams,t.stats=e.stats})),s?Pt(t,s,s.startPTS,s.endPTS,s.startDTS,s.endDTS):It(e,t),v.length&&(t.totalduration=t.edge-v[0].start),t.driftStartTime=e.driftStartTime,t.driftStart=e.driftStart;var m=t.advancedDateTime;if(t.advanced&&m){var y=t.edge;t.driftStart||(t.driftStartTime=m,t.driftStart=y),t.driftEndTime=m,t.driftEnd=y}else t.driftEndTime=e.driftEndTime,t.driftEnd=e.driftEnd,t.advancedDateTime=e.advancedDateTime}function It(e,t){var r=t.startSN+t.skippedSegments-e.startSN,i=e.fragments;r<0||r>=i.length||function(e,t){if(t){for(var r=e.fragments,i=e.skippedSegments;i<r.length;i++)r[i].start+=t;e.fragmentHint&&(e.fragmentHint.start+=t)}}(t,i[r].start)}function Ft(e,t,r){var i;return null!=e&&e.details?Mt(null==(i=e.details)?void 0:i.partList,t,r):null}function Mt(e,t,r){if(e)for(var i=e.length;i--;){var n=e[i];if(n.index===r&&n.fragment.sn===t)return n}return null}function Bt(e){e.forEach((function(e,t){var r=e.details;null!=r&&r.fragments&&r.fragments.forEach((function(e){e.level=t}))}))}function Nt(e){switch(e.details){case E.FRAG_LOAD_TIMEOUT:case E.KEY_LOAD_TIMEOUT:case E.LEVEL_LOAD_TIMEOUT:case E.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function Ut(e,t){var r=Nt(t);return e.default[(r?"timeout":"error")+"Retry"]}function Gt(e,t){var r="linear"===e.backoff?1:Math.pow(2,t);return Math.min(r*e.retryDelayMs,e.maxRetryDelayMs)}function Vt(e){return i(i({},e),{errorRetry:null,timeoutRetry:null})}function jt(e,t,r,i){if(!e)return!1;var n=null==i?void 0:i.code,a=t<e.maxNumRetry&&(function(e){return 0===e&&!1===navigator.onLine||!!e&&(e<400||e>499)}(n)||!!r);return e.shouldRetry?e.shouldRetry(e,t,r,i,a):a}var Ht=function(e,t){for(var r=0,i=e.length-1,n=null,a=null;r<=i;){var s=t(a=e[n=(r+i)/2|0]);if(s>0)r=n+1;else{if(!(s<0))return a;i=n-1}}return null};function Kt(e,t,r,i,n){void 0===r&&(r=0),void 0===i&&(i=0),void 0===n&&(n=.005);var a=null;if(e){a=t[e.sn-t[0].sn+1]||null;var s=e.endDTS-r;s>0&&s<15e-7&&(r+=15e-7)}else 0===r&&0===t[0].start&&(a=t[0]);if(a&&((!e||e.level===a.level)&&0===zt(r,i,a)||function(e,t,r){if(t&&0===t.start&&t.level<e.level&&(t.endPTS||0)>0){var i=t.tagList.reduce((function(e,t){return"INF"===t[0]&&(e+=parseFloat(t[1])),e}),r);return e.start<=i}return!1}(a,e,Math.min(n,i))))return a;var o=Ht(t,zt.bind(null,r,i));return!o||o===e&&a?a:o}function zt(e,t,r){if(void 0===e&&(e=0),void 0===t&&(t=0),r.start<=e&&r.start+r.duration>e)return 0;var i=Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return r.start+r.duration-i<=e?1:r.start-i>e&&r.start?-1:0}function Wt(e,t,r){var i=1e3*Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return(r.endProgramDateTime||0)-i>e}var qt=0,Yt=2,Xt=3,Qt=5,Jt=0,Zt=1,$t=2,er=function(){function e(e){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=e,this.log=x.log.bind(x,"[info]:"),this.warn=x.warn.bind(x,"[warning]:"),this.error=x.error.bind(x,"[error]:"),this.registerListeners()}var t=e.prototype;return t.registerListeners=function(){var e=this.hls;e.on(_.ERROR,this.onError,this),e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.LEVEL_UPDATED,this.onLevelUpdated,this)},t.unregisterListeners=function(){var e=this.hls;e&&(e.off(_.ERROR,this.onError,this),e.off(_.ERROR,this.onErrorOut,this),e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.LEVEL_UPDATED,this.onLevelUpdated,this))},t.destroy=function(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}},t.startLoad=function(e){},t.stopLoad=function(){this.playlistError=0},t.getVariantLevelIndex=function(e){return(null==e?void 0:e.type)===at?e.level:this.hls.loadLevel},t.onManifestLoading=function(){this.playlistError=0,this.penalizedRenditions={}},t.onLevelUpdated=function(){this.playlistError=0},t.onError=function(e,t){var r,i;if(!t.fatal){var n=this.hls,a=t.context;switch(t.details){case E.FRAG_LOAD_ERROR:case E.FRAG_LOAD_TIMEOUT:case E.KEY_LOAD_ERROR:case E.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case E.FRAG_PARSING_ERROR:if(null!=(r=t.frag)&&r.gap)return void(t.errorAction={action:qt,flags:Jt});case E.FRAG_GAP:case E.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=Yt);case E.LEVEL_EMPTY_ERROR:case E.LEVEL_PARSING_ERROR:var s,o,u=t.parent===at?t.level:n.loadLevel;return void(t.details===E.LEVEL_EMPTY_ERROR&&null!=(s=t.context)&&null!=(o=s.levelDetails)&&o.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,u):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,u)));case E.LEVEL_LOAD_ERROR:case E.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==a?void 0:a.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.level)));case E.AUDIO_TRACK_LOAD_ERROR:case E.AUDIO_TRACK_LOAD_TIMEOUT:case E.SUBTITLE_LOAD_ERROR:case E.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){var l=n.levels[n.loadLevel];if(l&&(a.type===it&&l.hasAudioGroup(a.groupId)||a.type===nt&&l.hasSubtitleGroup(a.groupId)))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.loadLevel),t.errorAction.action=Yt,void(t.errorAction.flags=Zt)}return;case E.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:var d=n.levels[n.loadLevel],h=null==d?void 0:d.attrs["HDCP-LEVEL"];return void(h?t.errorAction={action:Yt,flags:$t,hdcpLevel:h}:this.keySystemError(t));case E.BUFFER_ADD_CODEC_ERROR:case E.REMUX_ALLOC_ERROR:case E.BUFFER_APPEND_ERROR:return void(t.errorAction=this.getLevelSwitchAction(t,null!=(i=t.level)?i:n.loadLevel));case E.INTERNAL_EXCEPTION:case E.BUFFER_APPENDING_ERROR:case E.BUFFER_FULL_ERROR:case E.LEVEL_SWITCH_ERROR:case E.BUFFER_STALLED_ERROR:case E.BUFFER_SEEK_OVER_HOLE:case E.BUFFER_NUDGE_ON_STALL:return void(t.errorAction={action:qt,flags:Jt})}t.type===b.KEY_SYSTEM_ERROR&&this.keySystemError(t)}},t.keySystemError=function(e){var t=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,t)},t.getPlaylistRetryOrSwitchAction=function(e,t){var r=Ut(this.hls.config.playlistLoadPolicy,e),i=this.playlistError++;if(jt(r,i,Nt(e),e.response))return{action:Qt,flags:Jt,retryConfig:r,retryCount:i};var n=this.getLevelSwitchAction(e,t);return r&&(n.retryConfig=r,n.retryCount=i),n},t.getFragRetryOrSwitchAction=function(e){var t=this.hls,r=this.getVariantLevelIndex(e.frag),i=t.levels[r],n=t.config,a=n.fragLoadPolicy,s=n.keyLoadPolicy,o=Ut(e.details.startsWith("key")?s:a,e),u=t.levels.reduce((function(e,t){return e+t.fragmentError}),0);if(i&&(e.details!==E.FRAG_GAP&&i.fragmentError++,jt(o,u,Nt(e),e.response)))return{action:Qt,flags:Jt,retryConfig:o,retryCount:u};var l=this.getLevelSwitchAction(e,r);return o&&(l.retryConfig=o,l.retryCount=u),l},t.getLevelSwitchAction=function(e,t){var r=this.hls;null==t&&(t=r.loadLevel);var i=this.hls.levels[t];if(i){var n,a,s=e.details;i.loadError++,s===E.BUFFER_APPEND_ERROR&&i.fragmentError++;var o=-1,u=r.levels,l=r.loadLevel,d=r.minAutoLevel,h=r.maxAutoLevel;r.autoLevelEnabled||(r.loadLevel=-1);for(var c,f=null==(n=e.frag)?void 0:n.type,v=(f===st&&s===E.FRAG_PARSING_ERROR||"audio"===e.sourceBufferName&&(s===E.BUFFER_ADD_CODEC_ERROR||s===E.BUFFER_APPEND_ERROR))&&u.some((function(e){var t=e.audioCodec;return i.audioCodec!==t})),p="video"===e.sourceBufferName&&(s===E.BUFFER_ADD_CODEC_ERROR||s===E.BUFFER_APPEND_ERROR)&&u.some((function(e){var t=e.codecSet,r=e.audioCodec;return i.codecSet!==t&&i.audioCodec===r})),g=null!=(a=e.context)?a:{},m=g.type,y=g.groupId,_=function(){var t=(b+l)%u.length;if(t!==l&&t>=d&&t<=h&&0===u[t].loadError){var r,n,a=u[t];if(s===E.FRAG_GAP&&f===at&&e.frag){var c=u[t].details;if(c){var g=Kt(e.frag,c.fragments,e.frag.start);if(null!=g&&g.gap)return 0}}else{if(m===it&&a.hasAudioGroup(y)||m===nt&&a.hasSubtitleGroup(y))return 0;if(f===st&&null!=(r=i.audioGroups)&&r.some((function(e){return a.hasAudioGroup(e)}))||f===ot&&null!=(n=i.subtitleGroups)&&n.some((function(e){return a.hasSubtitleGroup(e)}))||v&&i.audioCodec===a.audioCodec||!v&&i.audioCodec!==a.audioCodec||p&&i.codecSet===a.codecSet)return 0}return o=t,1}},b=u.length;b--&&(0===(c=_())||1!==c););if(o>-1&&r.loadLevel!==o)return e.levelRetry=!0,this.playlistError=0,{action:Yt,flags:Jt,nextAutoLevel:o}}return{action:Yt,flags:Zt}},t.onErrorOut=function(e,t){var r;switch(null==(r=t.errorAction)?void 0:r.action){case qt:break;case Yt:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===E.FRAG_GAP?/MediaSource readyState: ended/.test(t.error.message)&&(this.warn('MediaSource ended after "'+t.sourceBufferName+'" sourceBuffer append error. Attempting to recover from media error.'),this.hls.recoverMediaError()):t.fatal=!0}t.fatal&&this.hls.stopLoad()},t.sendAlternateToPenaltyBox=function(e){var t=this.hls,r=e.errorAction;if(r){var i=r.flags,n=r.hdcpLevel,a=r.nextAutoLevel;switch(i){case Jt:this.switchLevel(e,a);break;case $t:n&&(t.maxHdcpLevel=Tt[Tt.indexOf(n)-1],r.resolved=!0),this.warn('Restricting playback to HDCP-LEVEL of "'+t.maxHdcpLevel+'" or lower')}r.resolved||this.switchLevel(e,a)}},t.switchLevel=function(e,t){void 0!==t&&e.errorAction&&(this.warn("switching to level "+t+" after "+e.details),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)},e}(),tr=function(){function e(e,t){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=x.log.bind(x,t+":"),this.warn=x.warn.bind(x,t+":"),this.hls=e}var t=e.prototype;return t.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},t.clearTimer=function(){-1!==this.timer&&(self.clearTimeout(this.timer),this.timer=-1)},t.startLoad=function(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()},t.stopLoad=function(){this.canLoad=!1,this.clearTimer()},t.switchParams=function(e,t,r){var i=null==t?void 0:t.renditionReports;if(i){for(var n=-1,a=0;a<i.length;a++){var s=i[a],o=void 0;try{o=new self.URL(s.URI,t.url).href}catch(e){x.warn("Could not construct new URL for Rendition Report: "+e),o=s.URI||""}if(o===e){n=a;break}o===e.substring(0,o.length)&&(n=a)}if(-1!==n){var u=i[n],l=parseInt(u["LAST-MSN"])||(null==t?void 0:t.lastPartSn),d=parseInt(u["LAST-PART"])||(null==t?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){var h=Math.min(t.age-t.partTarget,t.targetduration);d>=0&&h>t.partTarget&&(d+=1)}var c=r&&xt(r);return new At(l,d>=0?d:void 0,c)}}},t.loadPlaylist=function(e){-1===this.requestScheduled&&(this.requestScheduled=self.performance.now())},t.shouldLoadPlaylist=function(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)},t.shouldReloadPlaylist=function(e){return-1===this.timer&&-1===this.requestScheduled&&this.shouldLoadPlaylist(e)},t.playlistLoaded=function(e,t,r){var i=this,n=t.details,a=t.stats,s=self.performance.now(),o=a.loading.first?Math.max(0,s-a.loading.first):0;if(n.advancedDateTime=Date.now()-o,n.live||null!=r&&r.live){if(n.reloaded(r),r&&this.log("live playlist "+e+" "+(n.advanced?"REFRESHED "+n.lastPartSn+"-"+n.lastPartIndex:n.updated?"UPDATED":"MISSED")),r&&n.fragments.length>0&&Ot(r,n),!this.canLoad||!n.live)return;var u,l=void 0,d=void 0;if(n.canBlockReload&&n.endSN&&n.advanced){var h=this.hls.config.lowLatencyMode,c=n.lastPartSn,f=n.endSN,v=n.lastPartIndex,p=c===f;-1!==v?(l=p?f+1:c,d=p?h?0:v:v+1):l=f+1;var g=n.age,m=g+n.ageHeader,y=Math.min(m-n.partTarget,1.5*n.targetduration);if(y>0){if(r&&y>r.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+r.tuneInGoal+" to: "+y+" with playlist age: "+n.age),y=0;else{var _=Math.floor(y/n.targetduration);l+=_,void 0!==d&&(d+=Math.round(y%n.targetduration/n.partTarget)),this.log("CDN Tune-in age: "+n.ageHeader+"s last advanced "+g.toFixed(2)+"s goal: "+y+" skip sn "+_+" to part "+d)}n.tuneInGoal=y}if(u=this.getDeliveryDirectives(n,t.deliveryDirectives,l,d),h||!p)return void this.loadPlaylist(u)}else(n.canBlockReload||n.canSkipUntil)&&(u=this.getDeliveryDirectives(n,t.deliveryDirectives,l,d));var b=this.hls.mainForwardBufferInfo,E=b?b.end-b.len:0,T=function(e,t){void 0===t&&(t=1/0);var r=1e3*e.targetduration;if(e.updated){var i=e.fragments;if(i.length&&4*r>t){var n=1e3*i[i.length-1].duration;n<r&&(r=n)}}else r/=2;return Math.round(r)}(n,1e3*(n.edge-E));n.updated&&s>this.requestScheduled+T&&(this.requestScheduled=a.loading.start),void 0!==l&&n.canBlockReload?this.requestScheduled=a.loading.first+T-(1e3*n.partTarget||1e3):-1===this.requestScheduled||this.requestScheduled+T<s?this.requestScheduled=s:this.requestScheduled-s<=0&&(this.requestScheduled+=T);var S=this.requestScheduled-s;S=Math.max(0,S),this.log("reload live playlist "+e+" in "+Math.round(S)+" ms"),this.timer=self.setTimeout((function(){return i.loadPlaylist(u)}),S)}else this.clearTimer()},t.getDeliveryDirectives=function(e,t,r,i){var n=xt(e);return null!=t&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,i=t.part,n=Lt),new At(r,i,n)},t.checkRetry=function(e){var t=this,r=e.details,i=Nt(e),n=e.errorAction,a=n||{},s=a.action,o=a.retryCount,u=void 0===o?0:o,l=a.retryConfig,d=!!n&&!!l&&(s===Qt||!n.resolved&&s===Yt);if(d){var h;if(this.requestScheduled=-1,u>=l.maxNumRetry)return!1;if(i&&null!=(h=e.context)&&h.deliveryDirectives)this.warn("Retrying playlist loading "+(u+1)+"/"+l.maxNumRetry+' after "'+r+'" without delivery-directives'),this.loadPlaylist();else{var c=Gt(l,u);this.timer=self.setTimeout((function(){return t.loadPlaylist()}),c),this.warn("Retrying playlist loading "+(u+1)+"/"+l.maxNumRetry+' after "'+r+'" in '+c+"ms")}e.levelRetry=!0,n.resolved=!0}return d},e}(),rr=function(){function e(e,t,r){void 0===t&&(t=0),void 0===r&&(r=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=r}var t=e.prototype;return t.sample=function(e,t){var r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e},t.getTotalWeight=function(){return this.totalWeight_},t.getEstimate=function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_},e}(),ir=function(){function e(e,t,r,i){void 0===i&&(i=100),this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new rr(e),this.fast_=new rr(t),this.defaultTTFB_=i,this.ttfb_=new rr(e)}var t=e.prototype;return t.update=function(e,t){var r=this.slow_,i=this.fast_,n=this.ttfb_;r.halfLife!==e&&(this.slow_=new rr(e,r.getEstimate(),r.getTotalWeight())),i.halfLife!==t&&(this.fast_=new rr(t,i.getEstimate(),i.getTotalWeight())),n.halfLife!==e&&(this.ttfb_=new rr(e,n.getEstimate(),n.getTotalWeight()))},t.sample=function(e,t){var r=(e=Math.max(e,this.minDelayMs_))/1e3,i=8*t/r;this.fast_.sample(r,i),this.slow_.sample(r,i)},t.sampleTTFB=function(e){var t=e/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(r,Math.max(e,5))},t.canEstimate=function(){return this.fast_.getTotalWeight()>=this.minWeight_},t.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},t.getEstimateTTFB=function(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_},t.destroy=function(){},e}();function nr(e,t){var r=!1,i=[];return e&&(r="SDR"!==e,i=[e]),t&&(i=t.allowedVideoRanges||St.slice(0),i=(r=void 0!==t.preferHDR?t.preferHDR:function(){if("function"==typeof matchMedia){var e=matchMedia("(dynamic-range: high)"),t=matchMedia("bad query");if(e.media!==t.media)return!0===e.matches}return!1}())?i.filter((function(e){return"SDR"!==e})):["SDR"]),{preferHDR:r,allowedVideoRanges:i}}function ar(e,t){x.log('[abr] start candidates with "'+e+'" ignored because '+t)}var sr=function(){function e(e){var t=this;this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this._abandonRulesCheck=function(){var e=t.fragCurrent,r=t.partCurrent,i=t.hls,n=i.autoLevelEnabled,a=i.media;if(e&&a){var s=performance.now(),o=r?r.stats:e.stats,u=r?r.duration:e.duration,l=s-o.loading.start,d=i.minAutoLevel;if(o.aborted||o.loaded&&o.loaded===o.total||e.level<=d)return t.clearTimer(),void(t._nextAutoLevel=-1);if(n&&!a.paused&&a.playbackRate&&a.readyState){var h=i.mainForwardBufferInfo;if(null!==h){var c=t.bwEstimator.getEstimateTTFB(),f=Math.abs(a.playbackRate);if(!(l<=Math.max(c,u/(2*f)*1e3))){var v=h.len/f,p=o.loading.first?o.loading.first-o.loading.start:-1,m=o.loaded&&p>-1,y=t.getBwEstimate(),b=i.levels,E=b[e.level],T=o.total||Math.max(o.loaded,Math.round(u*E.averageBitrate/8)),S=m?l-p:l;S<1&&m&&(S=Math.min(l,8*o.loaded/y));var L=m?1e3*o.loaded/S:0,k=L?(T-o.loaded)/L:8*T/y+c/1e3;if(!(k<=v)){var w,A=L?8*L:y,R=Number.POSITIVE_INFINITY;for(w=e.level-1;w>d;w--){var D=b[w].maxBitrate;if((R=t.getTimeToLoadFrag(c/1e3,A,u*D,!b[w].details))<v)break}if(!(R>=k||R>10*u)){i.nextLoadLevel=i.nextAutoLevel=w,m?t.bwEstimator.sample(l-Math.min(c,p),o.loaded):t.bwEstimator.sampleTTFB(l);var C=b[w].maxBitrate;t.getBwEstimate()*t.hls.config.abrBandWidthUpFactor>C&&t.resetEstimator(C),t.clearTimer(),x.warn("[abr] Fragment "+e.sn+(r?" part "+r.index:"")+" of level "+e.level+" is loading too slowly;\n Time to underbuffer: "+v.toFixed(3)+" s\n Estimated load time for current fragment: "+k.toFixed(3)+" s\n Estimated load time for down switch fragment: "+R.toFixed(3)+" s\n TTFB estimate: "+(0|p)+" ms\n Current BW estimate: "+(g(y)?0|y:"Unknown")+" bps\n New BW estimate: "+(0|t.getBwEstimate())+" bps\n Switching to level "+w+" @ "+(0|C)+" bps"),i.trigger(_.FRAG_LOAD_EMERGENCY_ABORTED,{frag:e,part:r,stats:o})}}}}}}},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners()}var t=e.prototype;return t.resetEstimator=function(e){e&&(x.log("setting initial bwe to "+e),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()},t.initEstimator=function(){var e=this.hls.config;return new ir(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)},t.registerListeners=function(){var e=this.hls;e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.FRAG_LOADING,this.onFragLoading,this),e.on(_.FRAG_LOADED,this.onFragLoaded,this),e.on(_.FRAG_BUFFERED,this.onFragBuffered,this),e.on(_.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(_.LEVEL_LOADED,this.onLevelLoaded,this),e.on(_.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(_.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(_.ERROR,this.onError,this)},t.unregisterListeners=function(){var e=this.hls;e&&(e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.FRAG_LOADING,this.onFragLoading,this),e.off(_.FRAG_LOADED,this.onFragLoaded,this),e.off(_.FRAG_BUFFERED,this.onFragBuffered,this),e.off(_.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(_.LEVEL_LOADED,this.onLevelLoaded,this),e.off(_.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(_.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(_.ERROR,this.onError,this))},t.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null},t.onManifestLoading=function(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()},t.onLevelsUpdated=function(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null},t.onMaxAutoLevelUpdated=function(){this.firstSelection=-1,this.nextAutoLevelKey=""},t.onFragLoading=function(e,t){var r,i=t.frag;this.ignoreFragment(i)||(i.bitrateTest||(this.fragCurrent=i,this.partCurrent=null!=(r=t.part)?r:null),this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100))},t.onLevelSwitching=function(e,t){this.clearTimer()},t.onError=function(e,t){if(!t.fatal)switch(t.details){case E.BUFFER_ADD_CODEC_ERROR:case E.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case E.FRAG_LOAD_TIMEOUT:var r=t.frag,i=this.fragCurrent,n=this.partCurrent;if(r&&i&&r.sn===i.sn&&r.level===i.level){var a=performance.now(),s=n?n.stats:r.stats,o=a-s.loading.start,u=s.loading.first?s.loading.first-s.loading.start:-1;if(s.loaded&&u>-1){var l=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(o-Math.min(l,u),s.loaded)}else this.bwEstimator.sampleTTFB(o)}}},t.getTimeToLoadFrag=function(e,t,r,i){return e+r/t+(i?this.lastLevelLoadSec:0)},t.onLevelLoaded=function(e,t){var r=this.hls.config,i=t.stats.loading,n=i.end-i.start;g(n)&&(this.lastLevelLoadSec=n/1e3),t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)},t.onFragLoaded=function(e,t){var r=t.frag,i=t.part,n=i?i.stats:r.stats;if(r.type===at&&this.bwEstimator.sampleTTFB(n.loading.first-n.loading.start),!this.ignoreFragment(r)){if(this.clearTimer(),r.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){var a=i?i.duration:r.duration,s=this.hls.levels[r.level],o=(s.loaded?s.loaded.bytes:0)+n.loaded,u=(s.loaded?s.loaded.duration:0)+a;s.loaded={bytes:o,duration:u},s.realBitrate=Math.round(8*o/u)}if(r.bitrateTest){var l={stats:n,frag:r,part:i,id:r.type};this.onFragBuffered(_.FRAG_BUFFERED,l),r.bitrateTest=!1}else this.lastLoadedFragLevel=r.level}},t.onFragBuffered=function(e,t){var r=t.frag,i=t.part,n=null!=i&&i.stats.loaded?i.stats:r.stats;if(!n.aborted&&!this.ignoreFragment(r)){var a=n.parsing.end-n.loading.start-Math.min(n.loading.first-n.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(a,n.loaded),n.bwEstimate=this.getBwEstimate(),r.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}},t.ignoreFragment=function(e){return e.type!==at||"initSegment"===e.sn},t.clearTimer=function(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)},t.getAutoLevelKey=function(){return this.getBwEstimate()+"_"+this.getStarvationDelay().toFixed(2)},t.getNextABRAutoLevel=function(){var e=this.fragCurrent,t=this.partCurrent,r=this.hls,i=r.maxAutoLevel,n=r.config,a=r.minAutoLevel,s=t?t.duration:e?e.duration:0,o=this.getBwEstimate(),u=this.getStarvationDelay(),l=n.abrBandWidthFactor,d=n.abrBandWidthUpFactor;if(u){var h=this.findBestLevel(o,a,i,u,0,l,d);if(h>=0)return h}var c=s?Math.min(s,n.maxStarvationDelay):n.maxStarvationDelay;if(!u){var f=this.bitrateTestDelay;f&&(c=(s?Math.min(s,n.maxLoadingDelay):n.maxLoadingDelay)-f,x.info("[abr] bitrate test took "+Math.round(1e3*f)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*c)+" ms"),l=d=1)}var v=this.findBestLevel(o,a,i,u,c,l,d);if(x.info("[abr] "+(u?"rebuffering expected":"buffer is empty")+", optimal quality level "+v),v>-1)return v;var p=r.levels[a],g=r.levels[r.loadLevel];return(null==p?void 0:p.bitrate)<(null==g?void 0:g.bitrate)?a:r.loadLevel},t.getStarvationDelay=function(){var e=this.hls,t=e.media;if(!t)return 1/0;var r=t&&0!==t.playbackRate?Math.abs(t.playbackRate):1,i=e.mainForwardBufferInfo;return(i?i.len:0)/r},t.getBwEstimate=function(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate},t.findBestLevel=function(e,t,r,i,n,a,s){var o,u=this,l=i+n,d=this.lastLoadedFragLevel,h=-1===d?this.hls.firstLevel:d,c=this.fragCurrent,f=this.partCurrent,v=this.hls,p=v.levels,m=v.allAudioTracks,y=v.loadLevel,_=v.config;if(1===p.length)return 0;var b,E=p[h],T=!(null==E||null==(o=E.details)||!o.live),S=-1===y||-1===d,L="SDR",k=(null==E?void 0:E.frameRate)||0,w=_.audioPreference,A=_.videoPreference;this.audioTracksByGroup||(this.audioTracksByGroup=function(e){return e.reduce((function(e,t){var r=e.groups[t.groupId];r||(r=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),r.tracks.push(t);var i=t.channels||"2";return r.channels[i]=(r.channels[i]||0)+1,r.hasDefault=r.hasDefault||t.default,r.hasAutoSelect=r.hasAutoSelect||t.autoselect,r.hasDefault&&(e.hasDefaultAudio=!0),r.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e}),{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}(m));if(S){if(-1!==this.firstSelection)return this.firstSelection;var R=function(e,t,r,i,n){for(var a=Object.keys(e),s=null==i?void 0:i.channels,o=null==i?void 0:i.audioCodec,u=s&&2===parseInt(s),l=!0,d=!1,h=1/0,c=1/0,f=1/0,v=0,p=[],m=nr(t,n),y=m.preferHDR,_=m.allowedVideoRanges,b=function(){var t=e[a[E]];l=t.channels[2]>0,h=Math.min(h,t.minHeight),c=Math.min(c,t.minFramerate),f=Math.min(f,t.minBitrate);var r=_.filter((function(e){return t.videoRanges[e]>0}));r.length>0&&(d=!0,p=r)},E=a.length;E--;)b();h=g(h)?h:0,c=g(c)?c:0;var T=Math.max(1080,h),S=Math.max(30,c);return f=g(f)?f:r,r=Math.max(f,r),d||(t=void 0,p=[]),{codecSet:a.reduce((function(t,i){var n=e[i];if(i===t)return t;if(n.minBitrate>r)return ar(i,"min bitrate of "+n.minBitrate+" > current estimate of "+r),t;if(!n.hasDefaultAudio)return ar(i,"no renditions with default or auto-select sound found"),t;if(o&&i.indexOf(o.substring(0,4))%5!=0)return ar(i,'audio codec preference "'+o+'" not found'),t;if(s&&!u){if(!n.channels[s])return ar(i,"no renditions with "+s+" channel sound found (channels options: "+Object.keys(n.channels)+")"),t}else if((!o||u)&&l&&0===n.channels[2])return ar(i,"no renditions with stereo sound found"),t;return n.minHeight>T?(ar(i,"min resolution of "+n.minHeight+" > maximum of "+T),t):n.minFramerate>S?(ar(i,"min framerate of "+n.minFramerate+" > maximum of "+S),t):p.some((function(e){return n.videoRanges[e]>0}))?n.maxScore<v?(ar(i,"max score of "+n.maxScore+" < selected max of "+v),t):t&&(Be(i)>=Be(t)||n.fragmentError>e[t].fragmentError)?t:(v=n.maxScore,i):(ar(i,"no variants with VIDEO-RANGE of "+JSON.stringify(p)+" found"),t)}),void 0),videoRanges:p,preferHDR:y,minFramerate:c,minBitrate:f}}(this.codecTiers||(this.codecTiers=function(e,t,r,i){return e.slice(r,i+1).reduce((function(e,t){if(!t.codecSet)return e;var r=t.audioGroups,i=e[t.codecSet];i||(e[t.codecSet]=i={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!r,fragmentError:0}),i.minBitrate=Math.min(i.minBitrate,t.bitrate);var n=Math.min(t.height,t.width);return i.minHeight=Math.min(i.minHeight,n),i.minFramerate=Math.min(i.minFramerate,t.frameRate),i.maxScore=Math.max(i.maxScore,t.score),i.fragmentError+=t.fragmentError,i.videoRanges[t.videoRange]=(i.videoRanges[t.videoRange]||0)+1,e}),{})}(p,0,t,r)),L,e,w,A),D=R.codecSet,C=R.videoRanges,P=R.minFramerate,O=R.minBitrate,I=R.preferHDR;b=D,L=I?C[C.length-1]:C[0],k=P,e=Math.max(e,O),x.log("[abr] picked start tier "+JSON.stringify(R))}else b=null==E?void 0:E.codecSet,L=null==E?void 0:E.videoRange;for(var F,M=f?f.duration:c?c.duration:0,B=this.bwEstimator.getEstimateTTFB()/1e3,N=[],U=function(){var t,o=p[G],c=G>h;if(!o)return 0;if(b&&o.codecSet!==b||L&&o.videoRange!==L||c&&k>o.frameRate||!c&&k>0&&k<o.frameRate||o.supportedResult&&(null==(t=o.supportedResult.decodingInfoResults)||!t[0].smooth))return N.push(G),0;var v,m=o.details,_=(f?null==m?void 0:m.partTarget:null==m?void 0:m.averagetargetduration)||M;v=c?s*e:a*e;var w=M&&i>=2*M&&0===n?p[G].averageBitrate:p[G].maxBitrate,A=u.getTimeToLoadFrag(B,v,w*_,void 0===m);if(v>=w&&(G===d||0===o.loadError&&0===o.fragmentError)&&(A<=B||!g(A)||T&&!u.bitrateTestDelay||A<l)){var R=u.forcedAutoLevel;return G===y||-1!==R&&R===y||(N.length&&x.trace("[abr] Skipped level(s) "+N.join(",")+" of "+r+' max with CODECS and VIDEO-RANGE:"'+p[N[0]].codecs+'" '+p[N[0]].videoRange+'; not compatible with "'+E.codecs+'" '+L),x.info("[abr] switch candidate:"+h+"->"+G+" adjustedbw("+Math.round(v)+")-bitrate="+Math.round(v-w)+" ttfb:"+B.toFixed(1)+" avgDuration:"+_.toFixed(1)+" maxFetchDuration:"+l.toFixed(1)+" fetchDuration:"+A.toFixed(1)+" firstSelection:"+S+" codecSet:"+b+" videoRange:"+L+" hls.loadLevel:"+y)),S&&(u.firstSelection=G),{v:G}}},G=r;G>=t;G--)if(0!==(F=U())&&F)return F.v;return-1},s(e,[{key:"firstAutoLevel",get:function(){var e=this.hls,t=e.maxAutoLevel,r=e.minAutoLevel,i=this.getBwEstimate(),n=this.hls.config.maxStarvationDelay,a=this.findBestLevel(i,r,t,0,n,1,1);if(a>-1)return a;var s=this.hls.firstLevel,o=Math.min(Math.max(s,r),t);return x.warn("[abr] Could not find best starting auto level. Defaulting to first in playlist "+s+" clamped to "+o),o}},{key:"forcedAutoLevel",get:function(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}},{key:"nextAutoLevel",get:function(){var e=this.forcedAutoLevel,t=this.bwEstimator.canEstimate(),r=this.lastLoadedFragLevel>-1;if(!(-1===e||t&&r&&this.nextAutoLevelKey!==this.getAutoLevelKey()))return e;var i=t&&r?this.getNextABRAutoLevel():this.firstAutoLevel;if(-1!==e){var n=this.hls.levels;if(n.length>Math.max(e,i)&&n[e].loadError<=n[i].loadError)return e}return this._nextAutoLevel=i,this.nextAutoLevelKey=this.getAutoLevelKey(),i},set:function(e){var t=this.hls,r=t.maxAutoLevel,i=t.minAutoLevel,n=Math.min(Math.max(e,i),r);this._nextAutoLevel!==n&&(this.nextAutoLevelKey="",this._nextAutoLevel=n)}}]),e}(),or={length:0,start:function(){return 0},end:function(){return 0}},ur=function(){function e(){}return e.isBuffered=function(t,r){try{if(t)for(var i=e.getBuffered(t),n=0;n<i.length;n++)if(r>=i.start(n)&&r<=i.end(n))return!0}catch(e){}return!1},e.bufferInfo=function(t,r,i){try{if(t){var n,a=e.getBuffered(t),s=[];for(n=0;n<a.length;n++)s.push({start:a.start(n),end:a.end(n)});return this.bufferedInfo(s,r,i)}}catch(e){}return{len:0,start:r,end:r,nextStart:void 0}},e.bufferedInfo=function(e,t,r){t=Math.max(0,t),e.sort((function(e,t){return e.start-t.start||t.end-e.end}));var i=[];if(r)for(var n=0;n<e.length;n++){var a=i.length;if(a){var s=i[a-1].end;e[n].start-s<r?e[n].end>s&&(i[a-1].end=e[n].end):i.push(e[n])}else i.push(e[n])}else i=e;for(var o,u=0,l=t,d=t,h=0;h<i.length;h++){var c=i[h].start,f=i[h].end;if(t+r>=c&&t<f)l=c,u=(d=f)-t;else if(t+r<c){o=c;break}}return{len:u,start:l||0,end:d||0,nextStart:o}},e.getBuffered=function(e){try{return e.buffered}catch(e){return x.log("failed to get media.buffered",e),or}},e}(),lr=function(){function e(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}var t=e.prototype;return t.append=function(e,t,r){var i=this.queues[t];i.push(e),1!==i.length||r||this.executeNext(t)},t.insertAbort=function(e,t){this.queues[t].unshift(e),this.executeNext(t)},t.appendBlocker=function(e){var t,r=new Promise((function(e){t=e})),i={execute:t,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(i,e),r},t.executeNext=function(e){var t=this.queues[e];if(t.length){var r=t[0];try{r.execute()}catch(t){x.warn('[buffer-operation-queue]: Exception executing "'+e+'" SourceBuffer operation: '+t),r.onError(t);var i=this.buffers[e];null!=i&&i.updating||this.shiftAndExecuteNext(e)}}},t.shiftAndExecuteNext=function(e){this.queues[e].shift(),this.executeNext(e)},t.current=function(e){return this.queues[e][0]},e}(),dr=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,hr=function(){function e(e){var t=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendSource=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this.log=void 0,this.warn=void 0,this.error=void 0,this._onEndStreaming=function(e){t.hls&&t.hls.pauseBuffering()},this._onStartStreaming=function(e){t.hls&&t.hls.resumeBuffering()},this._onMediaSourceOpen=function(){var e=t.media,r=t.mediaSource;t.log("Media source opened"),e&&(e.removeEventListener("emptied",t._onMediaEmptied),t.updateMediaElementDuration(),t.hls.trigger(_.MEDIA_ATTACHED,{media:e,mediaSource:r})),r&&r.removeEventListener("sourceopen",t._onMediaSourceOpen),t.checkPendingTracks()},this._onMediaSourceClose=function(){t.log("Media source closed")},this._onMediaSourceEnded=function(){t.log("Media source ended")},this._onMediaEmptied=function(){var e=t.mediaSrc,r=t._objectUrl;e!==r&&x.error("Media element src was set while attaching MediaSource ("+r+" > "+e+")")},this.hls=e;var r,i="[buffer-controller]";this.appendSource=(r=Ce(e.config.preferManagedMediaSource),"undefined"!=typeof self&&r===self.ManagedMediaSource),this.log=x.log.bind(x,i),this.warn=x.warn.bind(x,i),this.error=x.error.bind(x,i),this._initSourceBuffer(),this.registerListeners()}var t=e.prototype;return t.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},t.destroy=function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null,this.hls=null},t.registerListeners=function(){var e=this.hls;e.on(_.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.MANIFEST_PARSED,this.onManifestParsed,this),e.on(_.BUFFER_RESET,this.onBufferReset,this),e.on(_.BUFFER_APPENDING,this.onBufferAppending,this),e.on(_.BUFFER_CODECS,this.onBufferCodecs,this),e.on(_.BUFFER_EOS,this.onBufferEos,this),e.on(_.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(_.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(_.FRAG_PARSED,this.onFragParsed,this),e.on(_.FRAG_CHANGED,this.onFragChanged,this)},t.unregisterListeners=function(){var e=this.hls;e.off(_.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.MANIFEST_PARSED,this.onManifestParsed,this),e.off(_.BUFFER_RESET,this.onBufferReset,this),e.off(_.BUFFER_APPENDING,this.onBufferAppending,this),e.off(_.BUFFER_CODECS,this.onBufferCodecs,this),e.off(_.BUFFER_EOS,this.onBufferEos,this),e.off(_.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(_.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(_.FRAG_PARSED,this.onFragParsed,this),e.off(_.FRAG_CHANGED,this.onFragChanged,this)},t._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new lr(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.appendErrors={audio:0,video:0,audiovideo:0},this.lastMpegAudioChunk=null},t.onManifestLoading=function(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null},t.onManifestParsed=function(e,t){t.audio&&!t.video||t.altAudio,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=1,this.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},t.onMediaAttaching=function(e,t){var r=this.media=t.media,i=Ce(this.appendSource);if(r&&i){var n,a=this.mediaSource=new i;this.log("created media source: "+(null==(n=a.constructor)?void 0:n.name)),a.addEventListener("sourceopen",this._onMediaSourceOpen),a.addEventListener("sourceended",this._onMediaSourceEnded),a.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(a.addEventListener("startstreaming",this._onStartStreaming),a.addEventListener("endstreaming",this._onEndStreaming));var s=this._objectUrl=self.URL.createObjectURL(a);if(this.appendSource)try{r.removeAttribute("src");var o=self.ManagedMediaSource;r.disableRemotePlayback=r.disableRemotePlayback||o&&a instanceof o,cr(r),function(e,t){var r=self.document.createElement("source");r.type="video/mp4",r.src=t,e.appendChild(r)}(r,s),r.load()}catch(e){r.src=s}else r.src=s;r.addEventListener("emptied",this._onMediaEmptied)}},t.onMediaDetaching=function(){var e=this.media,t=this.mediaSource,r=this._objectUrl;if(t){if(this.log("media source detaching"),"open"===t.readyState)try{t.endOfStream()}catch(e){this.warn("onMediaDetaching: "+e.message+" while calling endOfStream")}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(t.removeEventListener("startstreaming",this._onStartStreaming),t.removeEventListener("endstreaming",this._onEndStreaming)),e&&(e.removeEventListener("emptied",this._onMediaEmptied),r&&self.URL.revokeObjectURL(r),this.mediaSrc===r?(e.removeAttribute("src"),this.appendSource&&cr(e),e.load()):this.warn("media|source.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(_.MEDIA_DETACHED,void 0)},t.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach((function(t){e.resetBuffer(t)})),this._initSourceBuffer()},t.resetBuffer=function(e){var t=this.sourceBuffer[e];try{var r;t&&(this.removeBufferListeners(e),this.sourceBuffer[e]=void 0,null!=(r=this.mediaSource)&&r.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(t))}catch(t){this.warn("onBufferReset "+e,t)}},t.onBufferCodecs=function(e,t){var r=this,i=this.getSourceBufferTypes().length,n=Object.keys(t);if(n.forEach((function(e){if(i){var n=r.tracks[e];if(n&&"function"==typeof n.buffer.changeType){var a,s=t[e],o=s.id,u=s.codec,l=s.levelCodec,d=s.container,h=s.metadata,c=Ve(n.codec,n.levelCodec),f=null==c?void 0:c.replace(dr,"$1"),v=Ve(u,l),p=null==(a=v)?void 0:a.replace(dr,"$1");if(v&&f!==p){"audio"===e.slice(0,5)&&(v=Ge(v,r.appendSource));var g=d+";codecs="+v;r.appendChangeType(e,g),r.log("switching codec "+c+" to "+v),r.tracks[e]={buffer:n.buffer,codec:u,container:d,levelCodec:l,metadata:h,id:o}}}}else r.pendingTracks[e]=t[e]})),!i){var a=Math.max(this.bufferCodecEventsExpected-1,0);this.bufferCodecEventsExpected!==a&&(this.log(a+" bufferCodec event(s) expected "+n.join(",")),this.bufferCodecEventsExpected=a),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks()}},t.appendChangeType=function(e,t){var r=this,i=this.operationQueue,n={execute:function(){var n=r.sourceBuffer[e];n&&(r.log("changing "+e+" sourceBuffer type to "+t),n.changeType(t)),i.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(t){r.warn("Failed to change "+e+" SourceBuffer type",t)}};i.append(n,e,!!this.pendingTracks[e])},t.onBufferAppending=function(e,t){var r=this,i=this.hls,n=this.operationQueue,a=this.tracks,s=t.data,o=t.type,u=t.frag,l=t.part,d=t.chunkMeta,h=d.buffering[o],c=self.performance.now();h.start=c;var f=u.stats.buffering,v=l?l.stats.buffering:null;0===f.start&&(f.start=c),v&&0===v.start&&(v.start=c);var p=a.audio,g=!1;"audio"===o&&"audio/mpeg"===(null==p?void 0:p.container)&&(g=!this.lastMpegAudioChunk||1===d.id||this.lastMpegAudioChunk.sn!==d.sn,this.lastMpegAudioChunk=d);var m=u.start,y={execute:function(){if(h.executeStart=self.performance.now(),g){var e=r.sourceBuffer[o];if(e){var t=m-e.timestampOffset;Math.abs(t)>=.1&&(r.log("Updating audio SourceBuffer timestampOffset to "+m+" (delta: "+t+") sn: "+u.sn+")"),e.timestampOffset=m)}}r.appendExecutor(s,o)},onStart:function(){},onComplete:function(){var e=self.performance.now();h.executeEnd=h.end=e,0===f.first&&(f.first=e),v&&0===v.first&&(v.first=e);var t=r.sourceBuffer,i={};for(var n in t)i[n]=ur.getBuffered(t[n]);r.appendErrors[o]=0,"audio"===o||"video"===o?r.appendErrors.audiovideo=0:(r.appendErrors.audio=0,r.appendErrors.video=0),r.hls.trigger(_.BUFFER_APPENDED,{type:o,frag:u,part:l,chunkMeta:d,parent:u.type,timeRanges:i})},onError:function(e){var t={type:b.MEDIA_ERROR,parent:u.type,details:E.BUFFER_APPEND_ERROR,sourceBufferName:o,frag:u,part:l,chunkMeta:d,error:e,err:e,fatal:!1};if(e.code===DOMException.QUOTA_EXCEEDED_ERR)t.details=E.BUFFER_FULL_ERROR;else{var n=++r.appendErrors[o];t.details=E.BUFFER_APPEND_ERROR,r.warn("Failed "+n+"/"+i.config.appendErrorMaxRetry+' times to append segment in "'+o+'" sourceBuffer'),n>=i.config.appendErrorMaxRetry&&(t.fatal=!0)}i.trigger(_.ERROR,t)}};n.append(y,o,!!this.pendingTracks[o])},t.onBufferFlushing=function(e,t){var r=this,i=this.operationQueue,n=function(e){return{execute:r.removeExecutor.bind(r,e,t.startOffset,t.endOffset),onStart:function(){},onComplete:function(){r.hls.trigger(_.BUFFER_FLUSHED,{type:e})},onError:function(t){r.warn("Failed to remove from "+e+" SourceBuffer",t)}}};t.type?i.append(n(t.type),t.type):this.getSourceBufferTypes().forEach((function(e){i.append(n(e),e)}))},t.onFragParsed=function(e,t){var r=this,i=t.frag,n=t.part,a=[],s=n?n.elementaryStreams:i.elementaryStreams;s[M]?a.push("audiovideo"):(s[I]&&a.push("audio"),s[F]&&a.push("video"));0===a.length&&this.warn("Fragments must have at least one ElementaryStreamType set. type: "+i.type+" level: "+i.level+" sn: "+i.sn),this.blockBuffers((function(){var e=self.performance.now();i.stats.buffering.end=e,n&&(n.stats.buffering.end=e);var t=n?n.stats:i.stats;r.hls.trigger(_.FRAG_BUFFERED,{frag:i,part:n,stats:t,id:i.type})}),a)},t.onFragChanged=function(e,t){this.trimBuffers()},t.onBufferEos=function(e,t){var r=this;this.getSourceBufferTypes().reduce((function(e,i){var n=r.sourceBuffer[i];return!n||t.type&&t.type!==i||(n.ending=!0,n.ended||(n.ended=!0,r.log(i+" sourceBuffer now EOS"))),e&&!(n&&!n.ended)}),!0)&&(this.log("Queueing mediaSource.endOfStream()"),this.blockBuffers((function(){r.getSourceBufferTypes().forEach((function(e){var t=r.sourceBuffer[e];t&&(t.ending=!1)}));var e=r.mediaSource;e&&"open"===e.readyState?(r.log("Calling mediaSource.endOfStream()"),e.endOfStream()):e&&r.log("Could not call mediaSource.endOfStream(). mediaSource.readyState: "+e.readyState)})))},t.onLevelUpdated=function(e,t){var r=t.details;r.fragments.length&&(this.details=r,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},t.trimBuffers=function(){var e=this.hls,t=this.details,r=this.media;if(r&&null!==t&&this.getSourceBufferTypes().length){var i=e.config,n=r.currentTime,a=t.levelTargetDuration,s=t.live&&null!==i.liveBackBufferLength?i.liveBackBufferLength:i.backBufferLength;if(g(s)&&s>0){var o=Math.max(s,a),u=Math.floor(n/a)*a-o;this.flushBackBuffer(n,a,u)}if(g(i.frontBufferFlushThreshold)&&i.frontBufferFlushThreshold>0){var l=Math.max(i.maxBufferLength,i.frontBufferFlushThreshold),d=Math.max(l,a),h=Math.floor(n/a)*a+d;this.flushFrontBuffer(n,a,h)}}},t.flushBackBuffer=function(e,t,r){var i=this,n=this.details,a=this.sourceBuffer;this.getSourceBufferTypes().forEach((function(s){var o=a[s];if(o){var u=ur.getBuffered(o);if(u.length>0&&r>u.start(0)){if(i.hls.trigger(_.BACK_BUFFER_REACHED,{bufferEnd:r}),null!=n&&n.live)i.hls.trigger(_.LIVE_BACK_BUFFER_REACHED,{bufferEnd:r});else if(o.ended&&u.end(u.length-1)-e<2*t)return void i.log("Cannot flush "+s+" back buffer while SourceBuffer is in ended state");i.hls.trigger(_.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:s})}}}))},t.flushFrontBuffer=function(e,t,r){var i=this,n=this.sourceBuffer;this.getSourceBufferTypes().forEach((function(a){var s=n[a];if(s){var o=ur.getBuffered(s),u=o.length;if(u<2)return;var l=o.start(u-1),d=o.end(u-1);if(r>l||e>=l&&e<=d)return;if(s.ended&&e-d<2*t)return void i.log("Cannot flush "+a+" front buffer while SourceBuffer is in ended state");i.hls.trigger(_.BUFFER_FLUSHING,{startOffset:l,endOffset:1/0,type:a})}}))},t.updateMediaElementDuration=function(){if(this.details&&this.media&&this.mediaSource&&"open"===this.mediaSource.readyState){var e=this.details,t=this.hls,r=this.media,i=this.mediaSource,n=e.fragments[0].start+e.totalduration,a=r.duration,s=g(i.duration)?i.duration:0;e.live&&t.config.liveDurationInfinity?(i.duration=1/0,this.updateSeekableRange(e)):(n>s&&n>a||!g(a))&&(this.log("Updating Media Source duration to "+n.toFixed(3)),i.duration=n)}},t.updateSeekableRange=function(e){var t=this.mediaSource,r=e.fragments;if(r.length&&e.live&&null!=t&&t.setLiveSeekableRange){var i=Math.max(0,r[0].start),n=Math.max(i,i+e.totalduration);this.log("Media Source duration is set to "+t.duration+". Setting seekable range to "+i+"-"+n+"."),t.setLiveSeekableRange(i,n)}},t.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,t=this.operationQueue,r=this.pendingTracks,i=Object.keys(r).length;if(i&&(!e||2===i||"audiovideo"in r)){this.createSourceBuffers(r),this.pendingTracks={};var n=this.getSourceBufferTypes();if(n.length)this.hls.trigger(_.BUFFER_CREATED,{tracks:this.tracks}),n.forEach((function(e){t.executeNext(e)}));else{var a=new Error("could not create source buffer for media codec(s)");this.hls.trigger(_.ERROR,{type:b.MEDIA_ERROR,details:E.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:a,reason:a.message})}}},t.createSourceBuffers=function(e){var t=this,r=this.sourceBuffer,i=this.mediaSource;if(!i)throw Error("createSourceBuffers called when mediaSource was null");var n=function(n){if(!r[n]){var a,s=e[n];if(!s)throw Error("source buffer exists for track "+n+", however track does not");var o=-1===(null==(a=s.levelCodec)?void 0:a.indexOf(","))?s.levelCodec:s.codec;o&&"audio"===n.slice(0,5)&&(o=Ge(o,t.appendSource));var u=s.container+";codecs="+o;t.log("creating sourceBuffer("+u+")");try{var l=r[n]=i.addSourceBuffer(u),d=n;t.addBufferListener(d,"updatestart",t._onSBUpdateStart),t.addBufferListener(d,"updateend",t._onSBUpdateEnd),t.addBufferListener(d,"error",t._onSBUpdateError),t.appendSource&&t.addBufferListener(d,"bufferedchange",(function(e,r){var i=r.removedRanges;null!=i&&i.length&&t.hls.trigger(_.BUFFER_FLUSHED,{type:n})})),t.tracks[n]={buffer:l,codec:o,container:s.container,levelCodec:s.levelCodec,metadata:s.metadata,id:s.id}}catch(e){t.error("error while trying to add sourceBuffer: "+e.message),t.hls.trigger(_.ERROR,{type:b.MEDIA_ERROR,details:E.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,sourceBufferName:n,mimeType:u})}}};for(var a in e)n(a)},t._onSBUpdateStart=function(e){this.operationQueue.current(e).onStart()},t._onSBUpdateEnd=function(e){var t;if("closed"!==(null==(t=this.mediaSource)?void 0:t.readyState)){var r=this.operationQueue;r.current(e).onComplete(),r.shiftAndExecuteNext(e)}else this.resetBuffer(e)},t._onSBUpdateError=function(e,t){var r,i=new Error(e+" SourceBuffer error. MediaSource readyState: "+(null==(r=this.mediaSource)?void 0:r.readyState));this.error(""+i,t),this.hls.trigger(_.ERROR,{type:b.MEDIA_ERROR,details:E.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:i,fatal:!1});var n=this.operationQueue.current(e);n&&n.onError(i)},t.removeExecutor=function(e,t,r){var i=this.media,n=this.mediaSource,a=this.operationQueue,s=this.sourceBuffer[e];if(!i||!n||!s)return this.warn("Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),void a.shiftAndExecuteNext(e);var o=g(i.duration)?i.duration:1/0,u=g(n.duration)?n.duration:1/0,l=Math.max(0,t),d=Math.min(r,o,u);d>l&&(!s.ending||s.ended)?(s.ended=!1,this.log("Removing ["+l+","+d+"] from the "+e+" SourceBuffer"),s.remove(l,d)):a.shiftAndExecuteNext(e)},t.appendExecutor=function(e,t){var r=this.sourceBuffer[t];if(r)r.ended=!1,r.appendBuffer(e);else if(!this.pendingTracks[t])throw new Error("Attempting to append to the "+t+" SourceBuffer, but it does not exist")},t.blockBuffers=function(e,t){var r=this;if(void 0===t&&(t=this.getSourceBufferTypes()),!t.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve().then(e);var i=this.operationQueue,n=t.map((function(e){return i.appendBlocker(e)}));Promise.all(n).then((function(){e(),t.forEach((function(e){var t=r.sourceBuffer[e];null!=t&&t.updating||i.shiftAndExecuteNext(e)}))}))},t.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},t.addBufferListener=function(e,t,r){var i=this.sourceBuffer[e];if(i){var n=r.bind(this,e);this.listeners[e].push({event:t,listener:n}),i.addEventListener(t,n)}},t.removeBufferListeners=function(e){var t=this.sourceBuffer[e];t&&this.listeners[e].forEach((function(e){t.removeEventListener(e.event,e.listener)}))},s(e,[{key:"mediaSrc",get:function(){var e,t,r=(null==(e=this.media)||null==(t=e.querySelector)?void 0:t.call(e,"source"))||this.media;return null==r?void 0:r.src}}]),e}();function cr(e){var t=e.querySelectorAll("source");[].slice.call(t).forEach((function(t){e.removeChild(t)}))}var fr=function(){function e(e){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var t=e.prototype;return t.setStreamController=function(e){this.streamController=e},t.destroy=function(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},t.registerListeners=function(){var e=this.hls;e.on(_.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(_.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(_.MANIFEST_PARSED,this.onManifestParsed,this),e.on(_.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(_.BUFFER_CODECS,this.onBufferCodecs,this),e.on(_.MEDIA_DETACHING,this.onMediaDetaching,this)},t.unregisterListener=function(){var e=this.hls;e.off(_.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(_.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(_.MANIFEST_PARSED,this.onManifestParsed,this),e.off(_.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(_.BUFFER_CODECS,this.onBufferCodecs,this),e.off(_.MEDIA_DETACHING,this.onMediaDetaching,this)},t.onFpsDropLevelCapping=function(e,t){var r=this.hls.levels[t.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})},t.onMediaAttaching=function(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()},t.onManifestParsed=function(e,t){var r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()},t.onLevelsUpdated=function(e,t){this.timer&&g(this.autoLevelCapping)&&this.detectPlayerSize()},t.onBufferCodecs=function(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()},t.onMediaDetaching=function(){this.stopCapping()},t.detectPlayerSize=function(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0)return void(this.clientRect=null);var e=this.hls.levels;if(e.length){var t=this.hls,r=this.getMaxLevel(e.length-1);r!==this.autoLevelCapping&&x.log("Setting autoLevelCapping to "+r+": "+e[r].height+"p@"+e[r].bitrate+" for media "+this.mediaWidth+"x"+this.mediaHeight),t.autoLevelCapping=r,t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}},t.getMaxLevel=function(t){var r=this,i=this.hls.levels;if(!i.length)return-1;var n=i.filter((function(e,i){return r.isLevelAllowed(e)&&i<=t}));return this.clientRect=null,e.getMaxLevelByMediaSize(n,this.mediaWidth,this.mediaHeight)},t.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},t.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},t.getDimensions=function(){if(this.clientRect)return this.clientRect;var e=this.media,t={width:0,height:0};if(e){var r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,t.width||t.height||(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t},t.isLevelAllowed=function(e){return!this.restrictedLevels.some((function(t){return e.bitrate===t.bitrate&&e.width===t.width&&e.height===t.height}))},e.getMaxLevelByMediaSize=function(e,t,r){if(null==e||!e.length)return-1;for(var i=e.length-1,n=Math.max(t,r),a=0;a<e.length;a+=1){var s=e[a];if((s.width>=n||s.height>=n)&&(o=s,!(u=e[a+1])||o.width!==u.width||o.height!==u.height)){i=a;break}}var o,u;return i},s(e,[{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch(e){}return e}}]),e}(),vr=function(){function e(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners()}var t=e.prototype;return t.setStreamController=function(e){this.streamController=e},t.registerListeners=function(){this.hls.on(_.MEDIA_ATTACHING,this.onMediaAttaching,this)},t.unregisterListeners=function(){this.hls.off(_.MEDIA_ATTACHING,this.onMediaAttaching,this)},t.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},t.onMediaAttaching=function(e,t){var r=this.hls.config;if(r.capLevelOnFPSDrop){var i=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=i,i&&"function"==typeof i.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}},t.checkFPS=function(e,t,r){var i=performance.now();if(t){if(this.lastTime){var n=i-this.lastTime,a=r-this.lastDroppedFrames,s=t-this.lastDecodedFrames,o=1e3*a/n,u=this.hls;if(u.trigger(_.FPS_DROP,{currentDropped:a,currentDecoded:s,totalDroppedFrames:r}),o>0&&a>u.config.fpsDroppedMonitoringThreshold*s){var l=u.currentLevel;x.warn("drop FPS ratio greater than max allowed value for currentLevel: "+l),l>0&&(-1===u.autoLevelCapping||u.autoLevelCapping>=l)&&(l-=1,u.trigger(_.FPS_DROP_LEVEL_CAPPING,{level:l,droppedLevel:u.currentLevel}),u.autoLevelCapping=l,this.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=r,this.lastDecodedFrames=t}},t.checkFPSInterval=function(){var e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){var t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)},e}(),pr=function(){function e(e){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.log=x.log.bind(x,"[content-steering]:"),this.registerListeners()}var t=e.prototype;return t.registerListeners=function(){var e=this.hls;e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(_.MANIFEST_PARSED,this.onManifestParsed,this),e.on(_.ERROR,this.onError,this)},t.unregisterListeners=function(){var e=this.hls;e&&(e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(_.MANIFEST_PARSED,this.onManifestParsed,this),e.off(_.ERROR,this.onError,this))},t.startLoad=function(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){var e=1e3*this.timeToLoad-(performance.now()-this.updated);if(e>0)return void this.scheduleRefresh(this.uri,e)}this.loadSteeringManifest(this.uri)}},t.stopLoad=function(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()},t.clearTimeout=function(){-1!==this.reloadTimer&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)},t.destroy=function(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null},t.removeLevel=function(e){var t=this.levels;t&&(this.levels=t.filter((function(t){return t!==e})))},t.onManifestLoading=function(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null},t.onManifestLoaded=function(e,t){var r=t.contentSteering;null!==r&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())},t.onManifestParsed=function(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks},t.onError=function(e,t){var r=t.errorAction;if((null==r?void 0:r.action)===Yt&&r.flags===Zt){var i=this.levels,n=this.pathwayPriority,a=this.pathwayId;if(t.context){var s=t.context,o=s.groupId,u=s.pathwayId,l=s.type;o&&i?a=this.getPathwayForGroupId(o,l,a):u&&(a=u)}a in this.penalizedPathways||(this.penalizedPathways[a]=performance.now()),!n&&i&&(n=i.reduce((function(e,t){return-1===e.indexOf(t.pathwayId)&&e.push(t.pathwayId),e}),[])),n&&n.length>1&&(this.updatePathwayPriority(n),r.resolved=this.pathwayId!==a),r.resolved||x.warn("Could not resolve "+t.details+' ("'+t.error.message+'") with content-steering for Pathway: '+a+" levels: "+(i?i.length:i)+" priorities: "+JSON.stringify(n)+" penalized: "+JSON.stringify(this.penalizedPathways))}},t.filterParsedLevels=function(e){this.levels=e;var t=this.getLevelsForPathway(this.pathwayId);if(0===t.length){var r=e[0].pathwayId;this.log("No levels found in Pathway "+this.pathwayId+'. Setting initial Pathway to "'+r+'"'),t=this.getLevelsForPathway(r),this.pathwayId=r}return t.length!==e.length&&this.log("Found "+t.length+"/"+e.length+' levels in Pathway "'+this.pathwayId+'"'),t},t.getLevelsForPathway=function(e){return null===this.levels?[]:this.levels.filter((function(t){return e===t.pathwayId}))},t.updatePathwayPriority=function(e){var t;this.pathwayPriority=e;var r=this.penalizedPathways,i=performance.now();Object.keys(r).forEach((function(e){i-r[e]>3e5&&delete r[e]}));for(var n=0;n<e.length;n++){var a=e[n];if(!(a in r)){if(a===this.pathwayId)return;var s=this.hls.nextLoadLevel,o=this.hls.levels[s];if((t=this.getLevelsForPathway(a)).length>0){this.log('Setting Pathway to "'+a+'"'),this.pathwayId=a,Bt(t),this.hls.trigger(_.LEVELS_UPDATED,{levels:t});var u=this.hls.levels[s];o&&u&&this.levels&&(u.attrs["STABLE-VARIANT-ID"]!==o.attrs["STABLE-VARIANT-ID"]&&u.bitrate!==o.bitrate&&this.log("Unstable Pathways change from bitrate "+o.bitrate+" to "+u.bitrate),this.hls.nextLoadLevel=s);break}}}},t.getPathwayForGroupId=function(e,t,r){for(var i=this.getLevelsForPathway(r).concat(this.levels||[]),n=0;n<i.length;n++)if(t===it&&i[n].hasAudioGroup(e)||t===nt&&i[n].hasSubtitleGroup(e))return i[n].pathwayId;return r},t.clonePathways=function(e){var t=this,r=this.levels;if(r){var i={},n={};e.forEach((function(e){var a=e.ID,s=e["BASE-ID"],o=e["URI-REPLACEMENT"];if(!r.some((function(e){return e.pathwayId===a}))){var u=t.getLevelsForPathway(s).map((function(e){var t=new D(e.attrs);t["PATHWAY-ID"]=a;var r=t.AUDIO&&t.AUDIO+"_clone_"+a,s=t.SUBTITLES&&t.SUBTITLES+"_clone_"+a;r&&(i[t.AUDIO]=r,t.AUDIO=r),s&&(n[t.SUBTITLES]=s,t.SUBTITLES=s);var u=mr(e.uri,t["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",o),l=new Rt({attrs:t,audioCodec:e.audioCodec,bitrate:e.bitrate,height:e.height,name:e.name,url:u,videoCodec:e.videoCodec,width:e.width});if(e.audioGroups)for(var d=1;d<e.audioGroups.length;d++)l.addGroupId("audio",e.audioGroups[d]+"_clone_"+a);if(e.subtitleGroups)for(var h=1;h<e.subtitleGroups.length;h++)l.addGroupId("text",e.subtitleGroups[h]+"_clone_"+a);return l}));r.push.apply(r,u),gr(t.audioTracks,i,o,a),gr(t.subtitleTracks,n,o,a)}}))}},t.loadSteeringManifest=function(e){var t,r=this,i=this.hls.config,n=i.loader;this.loader&&this.loader.destroy(),this.loader=new n(i);try{t=new self.URL(e)}catch(t){return this.enabled=!1,void this.log("Failed to parse Steering Manifest URI: "+e)}if("data:"!==t.protocol){var a=0|(this.hls.bandwidthEstimate||i.abrEwmaDefaultEstimate);t.searchParams.set("_HLS_pathway",this.pathwayId),t.searchParams.set("_HLS_throughput",""+a)}var s={responseType:"json",url:t.href},o=i.steeringManifestLoadPolicy.default,u=o.errorRetry||o.timeoutRetry||{},l={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:u.maxNumRetry||0,retryDelay:u.retryDelayMs||0,maxRetryDelay:u.maxRetryDelayMs||0},d={onSuccess:function(e,i,n,a){r.log('Loaded steering manifest: "'+t+'"');var s=e.data;if(1===s.VERSION){r.updated=performance.now(),r.timeToLoad=s.TTL;var o=s["RELOAD-URI"],u=s["PATHWAY-CLONES"],l=s["PATHWAY-PRIORITY"];if(o)try{r.uri=new self.URL(o,t).href}catch(e){return r.enabled=!1,void r.log("Failed to parse Steering Manifest RELOAD-URI: "+o)}r.scheduleRefresh(r.uri||n.url),u&&r.clonePathways(u);var d={steeringManifest:s,url:t.toString()};r.hls.trigger(_.STEERING_MANIFEST_LOADED,d),l&&r.updatePathwayPriority(l)}else r.log("Steering VERSION "+s.VERSION+" not supported!")},onError:function(e,t,i,n){if(r.log("Error loading steering manifest: "+e.code+" "+e.text+" ("+t.url+")"),r.stopLoad(),410===e.code)return r.enabled=!1,void r.log("Steering manifest "+t.url+" no longer available");var a=1e3*r.timeToLoad;if(429!==e.code)r.scheduleRefresh(r.uri||t.url,a);else{var s=r.loader;if("function"==typeof(null==s?void 0:s.getResponseHeader)){var o=s.getResponseHeader("Retry-After");o&&(a=1e3*parseFloat(o))}r.log("Steering manifest "+t.url+" rate limited")}},onTimeout:function(e,t,i){r.log("Timeout loading steering manifest ("+t.url+")"),r.scheduleRefresh(r.uri||t.url)}};this.log("Requesting steering manifest: "+t),this.loader.load(s,l,d)},t.scheduleRefresh=function(e,t){var r=this;void 0===t&&(t=1e3*this.timeToLoad),this.clearTimeout(),this.reloadTimer=self.setTimeout((function(){var t,i=null==(t=r.hls)?void 0:t.media;!i||i.ended?r.scheduleRefresh(e,1e3*r.timeToLoad):r.loadSteeringManifest(e)}),t)},e}();function gr(e,t,r,i){e&&Object.keys(t).forEach((function(n){var a=e.filter((function(e){return e.groupId===n})).map((function(e){var a=o({},e);return a.details=void 0,a.attrs=new D(a.attrs),a.url=a.attrs.URI=mr(e.url,e.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",r),a.groupId=a.attrs["GROUP-ID"]=t[n],a.attrs["PATHWAY-ID"]=i,a}));e.push.apply(e,a)}))}function mr(e,t,r,i){var n,a=i.HOST,s=i.PARAMS,o=i[r];t&&(n=null==o?void 0:o[t])&&(e=n);var u=new self.URL(e);return a&&!n&&(u.host=a),s&&Object.keys(s).sort().forEach((function(e){e&&u.searchParams.set(e,s[e])})),u.href}var yr=/^age:\s*[\d.]+\s*$/im,_r=function(){function e(e){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=e&&e.xhrSetup||null,this.stats=new O,this.retryDelay=0}var t=e.prototype;return t.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null},t.abortInternal=function(){var e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,4!==e.readyState&&(this.stats.aborted=!0,e.abort()))},t.abort=function(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},t.load=function(e,t,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=r,this.loadInternal()},t.loadInternal=function(){var e=this,t=this.config,r=this.context;if(t&&r){var i=this.loader=new self.XMLHttpRequest,n=this.stats;n.loading.first=0,n.loaded=0,n.aborted=!1;var a=this.xhrSetup;a?Promise.resolve().then((function(){if(e.loader===i&&!e.stats.aborted)return a(i,r.url)})).catch((function(t){if(e.loader===i&&!e.stats.aborted)return i.open("GET",r.url,!0),a(i,r.url)})).then((function(){e.loader!==i||e.stats.aborted||e.openAndSendXhr(i,r,t)})).catch((function(t){e.callbacks.onError({code:i.status,text:t.message},r,i,n)})):this.openAndSendXhr(i,r,t)}},t.openAndSendXhr=function(e,t,r){e.readyState||e.open("GET",t.url,!0);var i=t.headers,n=r.loadPolicy,a=n.maxTimeToFirstByteMs,s=n.maxLoadTimeMs;if(i)for(var o in i)e.setRequestHeader(o,i[o]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),r.timeout=a&&g(a)?a:s,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),e.send()},t.readystatechange=function(){var e=this.context,t=this.loader,r=this.stats;if(e&&t){var i=t.readyState,n=this.config;if(!r.aborted&&i>=2&&(0===r.loading.first&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),n.timeout!==n.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),n.timeout=n.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),n.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),4===i)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;var a=t.status,s="text"!==t.responseType;if(a>=200&&a<300&&(s&&t.response||null!==t.responseText)){r.loading.end=Math.max(self.performance.now(),r.loading.first);var o=s?t.response:t.responseText,u="arraybuffer"===t.responseType?o.byteLength:o.length;if(r.loaded=r.total=u,r.bwEstimate=8e3*r.total/(r.loading.end-r.loading.first),!this.callbacks)return;var l=this.callbacks.onProgress;if(l&&l(r,e,o,t),!this.callbacks)return;var d={url:t.responseURL,data:o,code:a};this.callbacks.onSuccess(d,r,e,t)}else{var h=n.loadPolicy.errorRetry;jt(h,r.retry,!1,{url:e.url,data:void 0,code:a})?this.retry(h):(x.error(a+" while loading "+e.url),this.callbacks.onError({code:a,text:t.statusText},e,t,r))}}}},t.loadtimeout=function(){if(this.config){var e=this.config.loadPolicy.timeoutRetry;if(jt(e,this.stats.retry,!0))this.retry(e);else{var t;x.warn("timeout while loading "+(null==(t=this.context)?void 0:t.url));var r=this.callbacks;r&&(this.abortInternal(),r.onTimeout(this.stats,this.context,this.loader))}}},t.retry=function(e){var t=this.context,r=this.stats;this.retryDelay=Gt(e,r.retry),r.retry++,x.warn((status?"HTTP Status "+status:"Timeout")+" while loading "+(null==t?void 0:t.url)+", retrying "+r.retry+"/"+e.maxNumRetry+" in "+this.retryDelay+"ms"),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)},t.loadprogress=function(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)},t.getCacheAge=function(){var e=null;if(this.loader&&yr.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e},t.getResponseHeader=function(e){return this.loader&&new RegExp("^"+e+":\\s*[\\d.]+\\s*$","im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null},e}(),br=function(){function e(){this.chunks=[],this.dataLength=0}var t=e.prototype;return t.push=function(e){this.chunks.push(e),this.dataLength+=e.length},t.flush=function(){var e,t=this.chunks,r=this.dataLength;return t.length?(e=1===t.length?t[0]:function(e,t){for(var r=new Uint8Array(t),i=0,n=0;n<e.length;n++){var a=e[n];r.set(a,i),i+=a.length}return r}(t,r),this.reset(),e):new Uint8Array(0)},t.reset=function(){this.chunks.length=0,this.dataLength=0},e}();var Er=/(\d+)-(\d+)\/(\d+)/,Tr=function(){function e(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||Sr,this.controller=new self.AbortController,this.stats=new O}var t=e.prototype;return t.destroy=function(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null},t.abortInternal=function(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())},t.abort=function(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},t.load=function(e,t,r){var i=this,n=this.stats;if(n.loading.start)throw new Error("Loader can only be used once.");n.loading.start=self.performance.now();var a=function(e,t){var r={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(o({},e.headers))};return e.rangeEnd&&r.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1)),r}(e,this.controller.signal),s=r.onProgress,u="arraybuffer"===e.responseType,l=u?"byteLength":"length",d=t.loadPolicy,h=d.maxTimeToFirstByteMs,c=d.maxLoadTimeMs;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,a),self.clearTimeout(this.requestTimeout),t.timeout=h&&g(h)?h:c,this.requestTimeout=self.setTimeout((function(){i.abortInternal(),r.onTimeout(n,e,i.response)}),t.timeout),self.fetch(this.request).then((function(a){i.response=i.loader=a;var o=Math.max(self.performance.now(),n.loading.start);if(self.clearTimeout(i.requestTimeout),t.timeout=c,i.requestTimeout=self.setTimeout((function(){i.abortInternal(),r.onTimeout(n,e,i.response)}),c-(o-n.loading.start)),!a.ok){var l=a.status,d=a.statusText;throw new kr(d||"fetch, bad network response",l,a)}return n.loading.first=o,n.total=function(e){var t=e.get("Content-Range");if(t){var r=function(e){var t=Er.exec(e);if(t)return parseInt(t[2])-parseInt(t[1])+1}(t);if(g(r))return r}var i=e.get("Content-Length");if(i)return parseInt(i)}(a.headers)||n.total,s&&g(t.highWaterMark)?i.loadProgressively(a,n,e,t.highWaterMark,s):u?a.arrayBuffer():"json"===e.responseType?a.json():a.text()})).then((function(a){var o=i.response;if(!o)throw new Error("loader destroyed");self.clearTimeout(i.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first);var u=a[l];u&&(n.loaded=n.total=u);var d={url:o.url,data:a,code:o.status};s&&!g(t.highWaterMark)&&s(n,e,a,o),r.onSuccess(d,n,e,o)})).catch((function(t){if(self.clearTimeout(i.requestTimeout),!n.aborted){var a=t&&t.code||0,s=t?t.message:null;r.onError({code:a,text:s},e,t?t.details:null,n)}}))},t.getCacheAge=function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?parseFloat(t):null}return e},t.getResponseHeader=function(e){return this.response?this.response.headers.get(e):null},t.loadProgressively=function(e,t,r,i,n){void 0===i&&(i=0);var a=new br,s=e.body.getReader();return function o(){return s.read().then((function(s){if(s.done)return a.dataLength&&n(t,r,a.flush(),e),Promise.resolve(new ArrayBuffer(0));var u=s.value,l=u.length;return t.loaded+=l,l<i||a.dataLength?(a.push(u),a.dataLength>=i&&n(t,r,a.flush(),e)):n(t,r,u,e),o()})).catch((function(){return Promise.reject()}))}()},e}();function Sr(e,t){return new self.Request(e.url,t)}var Lr,kr=function(e){function t(t,r,i){var n;return(n=e.call(this,t)||this).code=void 0,n.details=void 0,n.code=r,n.details=i,n}return u(t,e),t}(c(Error)),wr=i(i({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold: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,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:_r,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:sr,bufferController:hr,capLevelController:fr,errorController:er,fpsController:vr,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:null,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,useMediaCapabilities:!1,certLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null}},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},{cueHandler:V,enableWebVTT:!1,enableIMSC1:!1,enableCEA708Captions:!1,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:void 0,subtitleTrackController:void 0,timelineController:void 0,audioStreamController:void 0,audioTrackController:void 0,emeController:void 0,cmcdController:void 0,contentSteeringController:pr});function xr(e){return e&&"object"==typeof e?Array.isArray(e)?e.map(xr):Object.keys(e).reduce((function(t,r){return t[r]=xr(e[r]),t}),{}):e}function Ar(e){var t=e.loader;t!==Tr&&t!==_r?(x.log("[config]: Custom loader detected, cannot enable progressive streaming"),e.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(e){}return!1}()&&(e.loader=Tr,e.progressive=!0,e.enableSoftwareAES=!0,x.log("[config]: Progressive streaming enabled, using FetchLoader"))}var Rr=function(e){function t(t,r){var i;return(i=e.call(this,t,"[level-controller]")||this)._levels=[],i._firstLevel=-1,i._maxAutoLevel=-1,i._startLevel=void 0,i.currentLevel=null,i.currentLevelIndex=-1,i.manualLevelIndex=-1,i.steering=void 0,i.onParsedComplete=void 0,i.steering=r,i._registerListeners(),i}u(t,e);var r=t.prototype;return r._registerListeners=function(){var e=this.hls;e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(_.LEVEL_LOADED,this.onLevelLoaded,this),e.on(_.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(_.FRAG_BUFFERED,this.onFragBuffered,this),e.on(_.ERROR,this.onError,this)},r._unregisterListeners=function(){var e=this.hls;e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(_.LEVEL_LOADED,this.onLevelLoaded,this),e.off(_.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(_.FRAG_BUFFERED,this.onFragBuffered,this),e.off(_.ERROR,this.onError,this)},r.destroy=function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),e.prototype.destroy.call(this)},r.stopLoad=function(){this._levels.forEach((function(e){e.loadError=0,e.fragmentError=0})),e.prototype.stopLoad.call(this)},r.resetLevels=function(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1},r.onManifestLoading=function(e,t){this.resetLevels()},r.onManifestLoaded=function(e,t){var r=this.hls.config.preferManagedMediaSource,i=[],n={},a={},s=!1,o=!1,u=!1;t.levels.forEach((function(e){var t,l,d=e.attrs,h=e.audioCodec,c=e.videoCodec;-1!==(null==(t=h)?void 0:t.indexOf("mp4a.40.34"))&&(Lr||(Lr=/chrome|firefox/i.test(navigator.userAgent)),Lr&&(e.audioCodec=h=void 0)),h&&(e.audioCodec=h=Ge(h,r)),0===(null==(l=c)?void 0:l.indexOf("avc1"))&&(c=e.videoCodec=function(e){for(var t=e.split(","),r=0;r<t.length;r++){var i=t[r].split(".");if(i.length>2){var n=i.shift()+".";n+=parseInt(i.shift()).toString(16),n+=("000"+parseInt(i.shift()).toString(16)).slice(-4),t[r]=n}}return t.join(",")}(c));var f=e.width,v=e.height,p=e.unknownCodecs;if(s||(s=!(!f||!v)),o||(o=!!c),u||(u=!!h),!(null!=p&&p.length||h&&!Oe(h,"audio",r)||c&&!Oe(c,"video",r))){var g=d.CODECS,m=d["FRAME-RATE"],y=d["HDCP-LEVEL"],_=d["PATHWAY-ID"],b=d.RESOLUTION,E=d["VIDEO-RANGE"],T=(_||".")+"-"+e.bitrate+"-"+b+"-"+m+"-"+g+"-"+E+"-"+y;if(n[T])if(n[T].uri===e.url||e.attrs["PATHWAY-ID"])n[T].addGroupId("audio",d.AUDIO),n[T].addGroupId("text",d.SUBTITLES);else{var S=a[T]+=1;e.attrs["PATHWAY-ID"]=new Array(S+1).join(".");var L=new Rt(e);n[T]=L,i.push(L)}else{var k=new Rt(e);n[T]=k,a[T]=1,i.push(k)}}})),this.filterAndSortMediaOptions(i,t,s,o,u)},r.filterAndSortMediaOptions=function(e,t,r,i,n){var a=this,s=[],o=[],u=e;if((r||i)&&n&&(u=u.filter((function(e){var t,r=e.videoCodec,i=e.videoRange,n=e.width,a=e.height;return(!!r||!(!n||!a))&&(!!(t=i)&&St.indexOf(t)>-1)}))),0!==u.length){if(t.audioTracks){var l=this.hls.config.preferManagedMediaSource;Dr(s=t.audioTracks.filter((function(e){return!e.audioCodec||Oe(e.audioCodec,"audio",l)})))}t.subtitles&&Dr(o=t.subtitles);var d=u.slice(0);u.sort((function(e,t){if(e.attrs["HDCP-LEVEL"]!==t.attrs["HDCP-LEVEL"])return(e.attrs["HDCP-LEVEL"]||"")>(t.attrs["HDCP-LEVEL"]||"")?1:-1;if(r&&e.height!==t.height)return e.height-t.height;if(e.frameRate!==t.frameRate)return e.frameRate-t.frameRate;if(e.videoRange!==t.videoRange)return St.indexOf(e.videoRange)-St.indexOf(t.videoRange);if(e.videoCodec!==t.videoCodec){var i=Me(e.videoCodec),n=Me(t.videoCodec);if(i!==n)return n-i}if(e.uri===t.uri&&e.codecSet!==t.codecSet){var a=Be(e.codecSet),s=Be(t.codecSet);if(a!==s)return s-a}return e.averageBitrate!==t.averageBitrate?e.averageBitrate-t.averageBitrate:0}));var h=d[0];if(this.steering&&(u=this.steering.filterParsedLevels(u)).length!==d.length)for(var c=0;c<d.length;c++)if(d[c].pathwayId===u[0].pathwayId){h=d[c];break}this._levels=u;for(var f=0;f<u.length;f++)if(u[f]===h){var v;this._firstLevel=f;var p=h.bitrate,g=this.hls.bandwidthEstimate;if(this.log("manifest loaded, "+u.length+" level(s) found, first bitrate: "+p),void 0===(null==(v=this.hls.userConfig)?void 0:v.abrEwmaDefaultEstimate)){var m=Math.min(p,this.hls.config.abrEwmaDefaultEstimateMax);m>g&&g===wr.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=m)}break}var y=n&&!i,T={levels:u,audioTracks:s,subtitleTracks:o,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:n,video:i,altAudio:!y&&s.some((function(e){return!!e.url}))};this.hls.trigger(_.MANIFEST_PARSED,T),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else Promise.resolve().then((function(){if(a.hls){t.levels.length&&a.warn("One or more CODECS in variant not supported: "+JSON.stringify(t.levels[0].attrs));var e=new Error("no level with compatible codecs found in manifest");a.hls.trigger(_.ERROR,{type:b.MEDIA_ERROR,details:E.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:e,reason:e.message})}}))},r.onError=function(e,t){!t.fatal&&t.context&&t.context.type===rt&&t.context.level===this.level&&this.checkRetry(t)},r.onFragBuffered=function(e,t){var r=t.frag;if(void 0!==r&&r.type===at){var i=r.elementaryStreams;if(!Object.keys(i).some((function(e){return!!i[e]})))return;var n=this._levels[r.level];null!=n&&n.loadError&&(this.log("Resetting level error count of "+n.loadError+" on frag buffered"),n.loadError=0)}},r.onLevelLoaded=function(e,t){var r,i,n=t.level,a=t.details,s=this._levels[n];if(!s)return this.warn("Invalid level index "+n),void(null!=(i=t.deliveryDirectives)&&i.skip&&(a.deltaUpdateFailed=!0));n===this.currentLevelIndex?(0===s.fragmentError&&(s.loadError=0),this.playlistLoaded(n,t,s.details)):null!=(r=t.deliveryDirectives)&&r.skip&&(a.deltaUpdateFailed=!0)},r.loadPlaylist=function(t){e.prototype.loadPlaylist.call(this);var r=this.currentLevelIndex,i=this.currentLevel;if(i&&this.shouldLoadPlaylist(i)){var n=i.uri;if(t)try{n=t.addDirectives(n)}catch(e){this.warn("Could not construct new URL with HLS Delivery Directives: "+e)}var a=i.attrs["PATHWAY-ID"];this.log("Loading level index "+r+(void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:"")+" with"+(a?" Pathway "+a:"")+" "+n),this.clearTimer(),this.hls.trigger(_.LEVEL_LOADING,{url:n,level:r,pathwayId:i.attrs["PATHWAY-ID"],id:0,deliveryDirectives:t||null})}},r.removeLevel=function(e){var t,r=this,i=this._levels.filter((function(t,i){return i!==e||(r.steering&&r.steering.removeLevel(t),t===r.currentLevel&&(r.currentLevel=null,r.currentLevelIndex=-1,t.details&&t.details.fragments.forEach((function(e){return e.level=-1}))),!1)}));Bt(i),this._levels=i,this.currentLevelIndex>-1&&null!=(t=this.currentLevel)&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.hls.trigger(_.LEVELS_UPDATED,{levels:i})},r.onLevelsUpdated=function(e,t){var r=t.levels;this._levels=r},r.checkMaxAutoUpdated=function(){var e=this.hls,t=e.autoLevelCapping,r=e.maxAutoLevel,i=e.maxHdcpLevel;this._maxAutoLevel!==r&&(this._maxAutoLevel=r,this.hls.trigger(_.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:t,levels:this.levels,maxAutoLevel:r,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:i}))},s(t,[{key:"levels",get:function(){return 0===this._levels.length?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(e){var t=this._levels;if(0!==t.length){if(e<0||e>=t.length){var r=new Error("invalid level idx"),i=e<0;if(this.hls.trigger(_.ERROR,{type:b.OTHER_ERROR,details:E.LEVEL_SWITCH_ERROR,level:e,fatal:i,error:r,reason:r.message}),i)return;e=Math.min(e,t.length-1)}var n=this.currentLevelIndex,a=this.currentLevel,s=a?a.attrs["PATHWAY-ID"]:void 0,o=t[e],u=o.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=o,n!==e||!o.details||!a||s!==u){this.log("Switching to level "+e+" ("+(o.height?o.height+"p ":"")+(o.videoRange?o.videoRange+" ":"")+(o.codecSet?o.codecSet+" ":"")+"@"+o.bitrate+")"+(u?" with Pathway "+u:"")+" from level "+n+(s?" with Pathway "+s:""));var l={level:e,attrs:o.attrs,details:o.details,bitrate:o.bitrate,averageBitrate:o.averageBitrate,maxBitrate:o.maxBitrate,realBitrate:o.realBitrate,width:o.width,height:o.height,codecSet:o.codecSet,audioCodec:o.audioCodec,videoCodec:o.videoCodec,audioGroups:o.audioGroups,subtitleGroups:o.subtitleGroups,loaded:o.loaded,loadError:o.loadError,fragmentError:o.fragmentError,name:o.name,id:o.id,uri:o.uri,url:o.url,urlId:0,audioGroupIds:o.audioGroupIds,textGroupIds:o.textGroupIds};this.hls.trigger(_.LEVEL_SWITCHING,l);var d=o.details;if(!d||d.live){var h=this.switchParams(o.uri,null==a?void 0:a.details,d);this.loadPlaylist(h)}}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(e){this._firstLevel=e}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var e=this.hls.config.startLevel;return void 0!==e?e:this.hls.firstAutoLevel}return this._startLevel},set:function(e){this._startLevel=e}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}}]),t}(tr);function Dr(e){var t={};e.forEach((function(e){var r=e.groupId||"";e.id=t[r]=t[r]||0,t[r]++}))}var Cr="NOT_LOADED",Pr="APPENDING",Or="PARTIAL",Ir="OK",Fr=function(){function e(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}var t=e.prototype;return t._registerListeners=function(){var e=this.hls;e.on(_.BUFFER_APPENDED,this.onBufferAppended,this),e.on(_.FRAG_BUFFERED,this.onFragBuffered,this),e.on(_.FRAG_LOADED,this.onFragLoaded,this)},t._unregisterListeners=function(){var e=this.hls;e.off(_.BUFFER_APPENDED,this.onBufferAppended,this),e.off(_.FRAG_BUFFERED,this.onFragBuffered,this),e.off(_.FRAG_LOADED,this.onFragLoaded,this)},t.destroy=function(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null},t.getAppendedFrag=function(e,t){var r=this.activePartLists[t];if(r)for(var i=r.length;i--;){var n=r[i];if(!n)break;var a=n.end;if(n.start<=e&&null!==a&&e<=a)return n}return this.getBufferedFrag(e,t)},t.getBufferedFrag=function(e,t){for(var r=this.fragments,i=Object.keys(r),n=i.length;n--;){var a=r[i[n]];if((null==a?void 0:a.body.type)===t&&a.buffered){var s=a.body;if(s.start<=e&&e<=s.end)return s}}return null},t.detectEvictedFragments=function(e,t,r,i){var n=this;this.timeRanges&&(this.timeRanges[e]=t);var a=(null==i?void 0:i.fragment.sn)||-1;Object.keys(this.fragments).forEach((function(i){var s=n.fragments[i];if(s&&!(a>=s.body.sn))if(s.buffered||s.loaded){var o=s.range[e];o&&o.time.some((function(e){var r=!n.isTimeBuffered(e.startPTS,e.endPTS,t);return r&&n.removeFragment(s.body),r}))}else s.body.type===r&&n.removeFragment(s.body)}))},t.detectPartialFragments=function(e){var t=this,r=this.timeRanges,i=e.frag,n=e.part;if(r&&"initSegment"!==i.sn){var a=Br(i),s=this.fragments[a];if(!(!s||s.buffered&&i.gap)){var o=!i.relurl;Object.keys(r).forEach((function(e){var a=i.elementaryStreams[e];if(a){var u=r[e],l=o||!0===a.partial;s.range[e]=t.getBufferedTimes(i,n,l,u)}})),s.loaded=null,Object.keys(s.range).length?(s.buffered=!0,(s.body.endList=i.endList||s.body.endList)&&(this.endListFragments[s.body.type]=s),Mr(s)||this.removeParts(i.sn-1,i.type)):this.removeFragment(s.body)}}},t.removeParts=function(e,t){var r=this.activePartLists[t];r&&(this.activePartLists[t]=r.filter((function(t){return t.fragment.sn>=e})))},t.fragBuffered=function(e,t){var r=Br(e),i=this.fragments[r];!i&&t&&(i=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),i&&(i.loaded=null,i.buffered=!0)},t.getBufferedTimes=function(e,t,r,i){for(var n={time:[],partial:r},a=e.start,s=e.end,o=e.minEndPTS||s,u=e.maxStartPTS||a,l=0;l<i.length;l++){var d=i.start(l)-this.bufferPadding,h=i.end(l)+this.bufferPadding;if(u>=d&&o<=h){n.time.push({startPTS:Math.max(a,i.start(l)),endPTS:Math.min(s,i.end(l))});break}if(a<h&&s>d){var c=Math.max(a,i.start(l)),f=Math.min(s,i.end(l));f>c&&(n.partial=!0,n.time.push({startPTS:c,endPTS:f}))}else if(s<=d)break}return n},t.getPartialFragment=function(e){var t,r,i,n=null,a=0,s=this.bufferPadding,o=this.fragments;return Object.keys(o).forEach((function(u){var l=o[u];l&&Mr(l)&&(r=l.body.start-s,i=l.body.end+s,e>=r&&e<=i&&(t=Math.min(e-r,i-e),a<=t&&(n=l.body,a=t)))})),n},t.isEndListAppended=function(e){var t=this.endListFragments[e];return void 0!==t&&(t.buffered||Mr(t))},t.getState=function(e){var t=Br(e),r=this.fragments[t];return r?r.buffered?Mr(r)?Or:Ir:Pr:Cr},t.isTimeBuffered=function(e,t,r){for(var i,n,a=0;a<r.length;a++){if(i=r.start(a)-this.bufferPadding,n=r.end(a)+this.bufferPadding,e>=i&&t<=n)return!0;if(t<=i)return!1}return!1},t.onFragLoaded=function(e,t){var r=t.frag,i=t.part;if("initSegment"!==r.sn&&!r.bitrateTest){var n=i?null:t,a=Br(r);this.fragments[a]={body:r,appendedPTS:null,loaded:n,buffered:!1,range:Object.create(null)}}},t.onBufferAppended=function(e,t){var r=this,i=t.frag,n=t.part,a=t.timeRanges;if("initSegment"!==i.sn){var s=i.type;if(n){var o=this.activePartLists[s];o||(this.activePartLists[s]=o=[]),o.push(n)}this.timeRanges=a,Object.keys(a).forEach((function(e){var t=a[e];r.detectEvictedFragments(e,t,s,n)}))}},t.onFragBuffered=function(e,t){this.detectPartialFragments(t)},t.hasFragment=function(e){var t=Br(e);return!!this.fragments[t]},t.hasParts=function(e){var t;return!(null==(t=this.activePartLists[e])||!t.length)},t.removeFragmentsInRange=function(e,t,r,i,n){var a=this;i&&!this.hasGaps||Object.keys(this.fragments).forEach((function(s){var o=a.fragments[s];if(o){var u=o.body;u.type!==r||i&&!u.gap||u.start<t&&u.end>e&&(o.buffered||n)&&a.removeFragment(u)}}))},t.removeFragment=function(e){var t=Br(e);e.stats.loaded=0,e.clearElementaryStreamInfo();var r=this.activePartLists[e.type];if(r){var i=e.sn;this.activePartLists[e.type]=r.filter((function(e){return e.fragment.sn!==i}))}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]},t.removeAllFragments=function(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1},e}();function Mr(e){var t,r,i;return e.buffered&&(e.body.gap||(null==(t=e.range.video)?void 0:t.partial)||(null==(r=e.range.audio)?void 0:r.partial)||(null==(i=e.range.audiovideo)?void 0:i.partial))}function Br(e){return e.type+"_"+e.level+"_"+e.sn}var Nr=Math.pow(2,17),Ur=function(){function e(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}var t=e.prototype;return t.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},t.abort=function(){this.loader&&this.loader.abort()},t.load=function(e,t){var r=this,n=e.url;if(!n)return Promise.reject(new jr({type:b.NETWORK_ERROR,details:E.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a "+(n?"part list":"url")),networkDetails:null}));this.abort();var a=this.config,s=a.fLoader,o=a.loader;return new Promise((function(u,l){if(r.loader&&r.loader.destroy(),e.gap){if(e.tagList.some((function(e){return"GAP"===e[0]})))return void l(Vr(e));e.gap=!1}var d=r.loader=e.loader=s?new s(a):new o(a),h=Gr(e),c=Vt(a.fragLoadPolicy.default),f={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===e.sn?1/0:Nr};e.stats=d.stats,d.load(h,f,{onSuccess:function(t,i,n,a){r.resetLoader(e,d);var s=t.data;n.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(s.slice(0,16)),s=s.slice(16)),u({frag:e,part:null,payload:s,networkDetails:a})},onError:function(t,a,s,o){r.resetLoader(e,d),l(new jr({type:b.NETWORK_ERROR,details:E.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:i({url:n,data:void 0},t),error:new Error("HTTP Error "+t.code+" "+t.text),networkDetails:s,stats:o}))},onAbort:function(t,i,n){r.resetLoader(e,d),l(new jr({type:b.NETWORK_ERROR,details:E.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:n,stats:t}))},onTimeout:function(t,i,n){r.resetLoader(e,d),l(new jr({type:b.NETWORK_ERROR,details:E.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error("Timeout after "+f.timeout+"ms"),networkDetails:n,stats:t}))},onProgress:function(r,i,n,a){t&&t({frag:e,part:null,payload:n,networkDetails:a})}})}))},t.loadPart=function(e,t,r){var n=this;this.abort();var a=this.config,s=a.fLoader,o=a.loader;return new Promise((function(u,l){if(n.loader&&n.loader.destroy(),e.gap||t.gap)l(Vr(e,t));else{var d=n.loader=e.loader=s?new s(a):new o(a),h=Gr(e,t),c=Vt(a.fragLoadPolicy.default),f={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:Nr};t.stats=d.stats,d.load(h,f,{onSuccess:function(i,a,s,o){n.resetLoader(e,d),n.updateStatsFromPart(e,t);var l={frag:e,part:t,payload:i.data,networkDetails:o};r(l),u(l)},onError:function(r,a,s,o){n.resetLoader(e,d),l(new jr({type:b.NETWORK_ERROR,details:E.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:i({url:h.url,data:void 0},r),error:new Error("HTTP Error "+r.code+" "+r.text),networkDetails:s,stats:o}))},onAbort:function(r,i,a){e.stats.aborted=t.stats.aborted,n.resetLoader(e,d),l(new jr({type:b.NETWORK_ERROR,details:E.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:a,stats:r}))},onTimeout:function(r,i,a){n.resetLoader(e,d),l(new jr({type:b.NETWORK_ERROR,details:E.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error("Timeout after "+f.timeout+"ms"),networkDetails:a,stats:r}))}})}}))},t.updateStatsFromPart=function(e,t){var r=e.stats,i=t.stats,n=i.total;if(r.loaded+=i.loaded,n){var a=Math.round(e.duration/t.duration),s=Math.min(Math.round(r.loaded/n),a),o=(a-s)*Math.round(r.loaded/s);r.total=r.loaded+o}else r.total=Math.max(r.loaded,r.total);var u=r.loading,l=i.loading;u.start?u.first+=l.first-l.start:(u.start=l.start,u.first=l.first),u.end=l.end},t.resetLoader=function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()},e}();function Gr(e,t){void 0===t&&(t=null);var r=t||e,i={frag:e,part:t,responseType:"arraybuffer",url:r.url,headers:{},rangeStart:0,rangeEnd:0},n=r.byteRangeStartOffset,a=r.byteRangeEndOffset;if(g(n)&&g(a)){var s,o=n,u=a;if("initSegment"===e.sn&&"AES-128"===(null==(s=e.decryptdata)?void 0:s.method)){var l=a-n;l%16&&(u=a+(16-l%16)),0!==n&&(i.resetIV=!0,o=n-16)}i.rangeStart=o,i.rangeEnd=u}return i}function Vr(e,t){var r=new Error("GAP "+(e.gap?"tag":"attribute")+" found"),i={type:b.MEDIA_ERROR,details:E.FRAG_GAP,fatal:!1,frag:e,error:r,networkDetails:null};return t&&(i.part=t),(t||e).stats.aborted=!0,new jr(i)}var jr=function(e){function t(t){var r;return(r=e.call(this,t.error.message)||this).data=void 0,r.data=t,r}return u(t,e),t}(c(Error)),Hr=function(){function e(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}var t=e.prototype;return t.abort=function(e){for(var t in this.keyUriToKeyInfo){var r=this.keyUriToKeyInfo[t].loader;if(r){var i;if(e&&e!==(null==(i=r.context)?void 0:i.frag.type))return;r.abort()}}},t.detach=function(){for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}},t.destroy=function(){for(var e in this.detach(),this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}},t.createKeyLoadError=function(e,t,r,i,n){return void 0===t&&(t=E.KEY_LOAD_ERROR),new jr({type:b.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:n,error:r,networkDetails:i})},t.loadClear=function(e,t){var r=this;if(this.emeController&&this.config.emeEnabled)for(var i=e.sn,n=e.cc,a=function(){var e=t[s];if(n<=e.cc&&("initSegment"===i||"initSegment"===e.sn||i<e.sn))return r.emeController.selectKeySystemFormat(e).then((function(t){e.setKeyFormat(t)})),1},s=0;s<t.length&&!a();s++);},t.load=function(e){var t=this;return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then((function(r){return t.loadInternal(e,r)})):this.loadInternal(e)},t.loadInternal=function(e,t){var r,i;t&&e.setKeyFormat(t);var n=e.decryptdata;if(!n){var a=new Error(t?"Expected frag.decryptdata to be defined after setting format "+t:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,E.KEY_LOAD_ERROR,a))}var s=n.uri;if(!s)return Promise.reject(this.createKeyLoadError(e,E.KEY_LOAD_ERROR,new Error('Invalid key URI: "'+s+'"')));var o,u=this.keyUriToKeyInfo[s];if(null!=(r=u)&&r.decryptdata.key)return n.key=u.decryptdata.key,Promise.resolve({frag:e,keyInfo:u});if(null!=(i=u)&&i.keyLoadPromise)switch(null==(o=u.mediaKeySessionContext)?void 0:o.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return u.keyLoadPromise.then((function(t){return n.key=t.keyInfo.decryptdata.key,{frag:e,keyInfo:u}}))}switch(u=this.keyUriToKeyInfo[s]={decryptdata:n,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},n.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===n.keyFormat?this.loadKeyHTTP(u,e):this.loadKeyEME(u,e);case"AES-128":return this.loadKeyHTTP(u,e);default:return Promise.reject(this.createKeyLoadError(e,E.KEY_LOAD_ERROR,new Error('Key supplied with unsupported METHOD: "'+n.method+'"')))}},t.loadKeyEME=function(e,t){var r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var i=this.emeController.loadKey(r);if(i)return(e.keyLoadPromise=i.then((function(t){return e.mediaKeySessionContext=t,r}))).catch((function(t){throw e.keyLoadPromise=null,t}))}return Promise.resolve(r)},t.loadKeyHTTP=function(e,t){var r=this,n=this.config,a=new(0,n.loader)(n);return t.keyLoader=e.loader=a,e.keyLoadPromise=new Promise((function(s,o){var u={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},l=n.keyLoadPolicy.default,d={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},h={onSuccess:function(e,t,i,n){var a=i.frag,u=i.keyInfo,l=i.url;if(!a.decryptdata||u!==r.keyUriToKeyInfo[l])return o(r.createKeyLoadError(a,E.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),n));u.decryptdata.key=a.decryptdata.key=new Uint8Array(e.data),a.keyLoader=null,u.loader=null,s({frag:a,keyInfo:u})},onError:function(e,n,a,s){r.resetLoader(n),o(r.createKeyLoadError(t,E.KEY_LOAD_ERROR,new Error("HTTP Error "+e.code+" loading key "+e.text),a,i({url:u.url,data:void 0},e)))},onTimeout:function(e,i,n){r.resetLoader(i),o(r.createKeyLoadError(t,E.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),n))},onAbort:function(e,i,n){r.resetLoader(i),o(r.createKeyLoadError(t,E.INTERNAL_ABORTED,new Error("key loading aborted"),n))}};a.load(u,d,h)}))},t.resetLoader=function(e){var t=e.frag,r=e.keyInfo,i=e.url,n=r.loader;t.keyLoader===n&&(t.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[i],n&&n.destroy()},e}(),Kr=function(){function e(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var t=e.prototype;return t.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},t.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},t.onHandlerDestroyed=function(){},t.hasInterval=function(){return!!this._tickInterval},t.hasNextTick=function(){return!!this._tickTimer},t.setInterval=function(e){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)},t.clearInterval=function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)},t.clearNextTick=function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)},t.tick=function(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},t.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},t.doTick=function(){},e}(),zr=function(e,t,r,i,n,a){void 0===i&&(i=0),void 0===n&&(n=-1),void 0===a&&(a=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=e,this.sn=t,this.id=r,this.size=i,this.part=n,this.partial=a};function Wr(e,t){for(var r=0,i=e.length;r<i;r++){var n;if((null==(n=e[r])?void 0:n.cc)===t)return e[r]}return null}function qr(e,t){if(e){var r=e.start+t;e.start=e.startPTS=r,e.endPTS=r+e.duration}}function Yr(e,t){for(var r=t.fragments,i=0,n=r.length;i<n;i++)qr(r[i],e);t.fragmentHint&&qr(t.fragmentHint,e),t.alignedSliding=!0}function Xr(e,t,r){t&&(function(e,t,r){if(function(e,t,r){return!(!t||!(r.endCC>r.startCC||e&&e.cc<r.startCC))}(e,r,t)){var i=function(e,t){var r=e.fragments,i=t.fragments;if(i.length&&r.length){var n=Wr(r,i[0].cc);if(n&&(!n||n.startPTS))return n;x.log("No frag in previous level to align on")}else x.log("No fragments to align")}(r,t);i&&g(i.start)&&(x.log("Adjusting PTS using last level due to CC increase within current level "+t.url),Yr(i.start,t))}}(e,r,t),!r.alignedSliding&&t&&function(e,t){if(e.hasProgramDateTime&&t.hasProgramDateTime){var r=e.fragments,i=t.fragments;if(r.length&&i.length){var n,a,s=Math.min(t.endCC,e.endCC);t.startCC<s&&e.startCC<s&&(n=Wr(i,s),a=Wr(r,s)),n&&a||(a=Wr(r,(n=i[Math.floor(i.length/2)]).cc)||r[Math.floor(r.length/2)]);var o=n.programDateTime,u=a.programDateTime;o&&u&&Yr((u-o)/1e3-(a.start-n.start),e)}}}(r,t),r.alignedSliding||!t||r.skippedSegments||It(t,r))}var Qr=function(){function e(e,t){this.subtle=void 0,this.aesIV=void 0,this.subtle=e,this.aesIV=t}return e.prototype.decrypt=function(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)},e}(),Jr=function(){function e(e,t){this.subtle=void 0,this.key=void 0,this.subtle=e,this.key=t}return e.prototype.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},e}();var Zr=function(){function e(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var t=e.prototype;return t.uint8ArrayToUint32Array_=function(e){for(var t=new DataView(e),r=new Uint32Array(4),i=0;i<4;i++)r[i]=t.getUint32(4*i);return r},t.initTable=function(){var e=this.sBox,t=this.invSBox,r=this.subMix,i=r[0],n=r[1],a=r[2],s=r[3],o=this.invSubMix,u=o[0],l=o[1],d=o[2],h=o[3],c=new Uint32Array(256),f=0,v=0,p=0;for(p=0;p<256;p++)c[p]=p<128?p<<1:p<<1^283;for(p=0;p<256;p++){var g=v^v<<1^v<<2^v<<3^v<<4;g=g>>>8^255&g^99,e[f]=g,t[g]=f;var m=c[f],y=c[m],_=c[y],b=257*c[g]^16843008*g;i[f]=b<<24|b>>>8,n[f]=b<<16|b>>>16,a[f]=b<<8|b>>>24,s[f]=b,b=16843009*_^65537*y^257*m^16843008*f,u[g]=b<<24|b>>>8,l[g]=b<<16|b>>>16,d[g]=b<<8|b>>>24,h[g]=b,f?(f=m^c[c[c[_^m]]],v^=c[c[v]]):f=v=1}},t.expandKey=function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,i=0;i<t.length&&r;)r=t[i]===this.key[i],i++;if(!r){this.key=t;var n=this.keySize=t.length;if(4!==n&&6!==n&&8!==n)throw new Error("Invalid aes key size="+n);var a,s,o,u,l=this.ksRows=4*(n+6+1),d=this.keySchedule=new Uint32Array(l),h=this.invKeySchedule=new Uint32Array(l),c=this.sBox,f=this.rcon,v=this.invSubMix,p=v[0],g=v[1],m=v[2],y=v[3];for(a=0;a<l;a++)a<n?o=d[a]=t[a]:(u=o,a%n==0?(u=c[(u=u<<8|u>>>24)>>>24]<<24|c[u>>>16&255]<<16|c[u>>>8&255]<<8|c[255&u],u^=f[a/n|0]<<24):n>6&&a%n==4&&(u=c[u>>>24]<<24|c[u>>>16&255]<<16|c[u>>>8&255]<<8|c[255&u]),d[a]=o=(d[a-n]^u)>>>0);for(s=0;s<l;s++)a=l-s,u=3&s?d[a]:d[a-4],h[s]=s<4||a<=4?u:p[c[u>>>24]]^g[c[u>>>16&255]]^m[c[u>>>8&255]]^y[c[255&u]],h[s]=h[s]>>>0}},t.networkToHostOrderSwap=function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24},t.decrypt=function(e,t,r){for(var i,n,a,s,o,u,l,d,h,c,f,v,p,g,m=this.keySize+6,y=this.invKeySchedule,_=this.invSBox,b=this.invSubMix,E=b[0],T=b[1],S=b[2],L=b[3],k=this.uint8ArrayToUint32Array_(r),w=k[0],x=k[1],A=k[2],R=k[3],D=new Int32Array(e),C=new Int32Array(D.length),P=this.networkToHostOrderSwap;t<D.length;){for(h=P(D[t]),c=P(D[t+1]),f=P(D[t+2]),v=P(D[t+3]),o=h^y[0],u=v^y[1],l=f^y[2],d=c^y[3],p=4,g=1;g<m;g++)i=E[o>>>24]^T[u>>16&255]^S[l>>8&255]^L[255&d]^y[p],n=E[u>>>24]^T[l>>16&255]^S[d>>8&255]^L[255&o]^y[p+1],a=E[l>>>24]^T[d>>16&255]^S[o>>8&255]^L[255&u]^y[p+2],s=E[d>>>24]^T[o>>16&255]^S[u>>8&255]^L[255&l]^y[p+3],o=i,u=n,l=a,d=s,p+=4;i=_[o>>>24]<<24^_[u>>16&255]<<16^_[l>>8&255]<<8^_[255&d]^y[p],n=_[u>>>24]<<24^_[l>>16&255]<<16^_[d>>8&255]<<8^_[255&o]^y[p+1],a=_[l>>>24]<<24^_[d>>16&255]<<16^_[o>>8&255]<<8^_[255&u]^y[p+2],s=_[d>>>24]<<24^_[o>>16&255]<<16^_[u>>8&255]<<8^_[255&l]^y[p+3],C[t]=P(i^w),C[t+1]=P(s^x),C[t+2]=P(a^A),C[t+3]=P(n^R),w=h,x=c,A=f,R=v,t+=4}return C.buffer},e}(),$r=function(){function e(e,t){var r=(void 0===t?{}:t).removePKCS7Padding,i=void 0===r||r;if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=e.enableSoftwareAES,this.removePKCS7Padding=i,i)try{var n=self.crypto;n&&(this.subtle=n.subtle||n.webkitSubtle)}catch(e){}this.useSoftware=!this.subtle}var t=e.prototype;return t.destroy=function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},t.isSync=function(){return this.useSoftware},t.flush=function(){var e=this.currentResult,t=this.remainderData;if(!e||t)return this.reset(),null;var r,i,n,a=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?(i=(r=a).byteLength,(n=i&&new DataView(r.buffer).getUint8(i-1))?j(r,0,i-n):r):a},t.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},t.decrypt=function(e,t,r){var i=this;return this.useSoftware?new Promise((function(n,a){i.softwareDecrypt(new Uint8Array(e),t,r);var s=i.flush();s?n(s.buffer):a(new Error("[softwareDecrypt] Failed to decrypt data"))})):this.webCryptoDecrypt(new Uint8Array(e),t,r)},t.softwareDecrypt=function(e,t,r){var i=this.currentIV,n=this.currentResult,a=this.remainderData;this.logOnce("JS AES decrypt"),a&&(e=ke(a,e),this.remainderData=null);var s=this.getValidChunk(e);if(!s.length)return null;i&&(r=i);var o=this.softwareDecrypter;o||(o=this.softwareDecrypter=new Zr),o.expandKey(t);var u=n;return this.currentResult=o.decrypt(s.buffer,0,r),this.currentIV=j(s,-16).buffer,u||null},t.webCryptoDecrypt=function(e,t,r){var i=this;if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,r));this.key=t,this.fastAesKey=new Jr(this.subtle,t)}return this.fastAesKey.expandKey().then((function(t){return i.subtle?(i.logOnce("WebCrypto AES decrypt"),new Qr(i.subtle,new Uint8Array(r)).decrypt(e.buffer,t)):Promise.reject(new Error("web crypto not initialized"))})).catch((function(n){return x.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+n.name+": "+n.message),i.onWebCryptoError(e,t,r)}))},t.onWebCryptoError=function(e,t,r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r);var i=this.flush();if(i)return i.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")},t.getValidChunk=function(e){var t=e,r=e.length-e.length%16;return r!==e.length&&(t=j(e,0,r),this.remainderData=j(e,r)),t},t.logOnce=function(e){this.logEnabled&&(x.log("[decrypter]: "+e),this.logEnabled=!1)},e}(),ei=function(e){for(var t="",r=e.length,i=0;i<r;i++)t+="["+e.start(i).toFixed(3)+"-"+e.end(i).toFixed(3)+"]";return t},ti="STOPPED",ri="IDLE",ii="KEY_LOADING",ni="FRAG_LOADING",ai="FRAG_LOADING_WAITING_RETRY",si="PARSING",oi="PARSED",ui="ENDED",li="ERROR",di="WAITING_LEVEL",hi=function(e){function t(t,r,i,n,a){var s;return(s=e.call(this)||this).hls=void 0,s.fragPrevious=null,s.fragCurrent=null,s.fragmentTracker=void 0,s.transmuxer=null,s._state=ti,s.playlistType=void 0,s.media=null,s.mediaBuffer=null,s.config=void 0,s.bitrateTest=!1,s.lastCurrentTime=0,s.nextLoadPosition=0,s.startPosition=0,s.startTimeOffset=null,s.loadedmetadata=!1,s.retryDate=0,s.levels=null,s.fragmentLoader=void 0,s.keyLoader=void 0,s.levelLastLoaded=null,s.startFragRequested=!1,s.decrypter=void 0,s.initPTS=[],s.onvseeking=null,s.onvended=null,s.logPrefix="",s.log=void 0,s.warn=void 0,s.playlistType=a,s.logPrefix=n,s.log=x.log.bind(x,n+":"),s.warn=x.warn.bind(x,n+":"),s.hls=t,s.fragmentLoader=new Ur(t.config),s.keyLoader=i,s.fragmentTracker=r,s.config=t.config,s.decrypter=new $r(t.config),t.on(_.MANIFEST_LOADED,s.onManifestLoaded,function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(s)),s}u(t,e);var r=t.prototype;return r.doTick=function(){this.onTickEnd()},r.onTickEnd=function(){},r.startLoad=function(e){},r.stopLoad=function(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);var e=this.fragCurrent;null!=e&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=ti},r._streamEnded=function(e,t){if(t.live||e.nextStart||!e.end||!this.media)return!1;var r=t.partList;if(null!=r&&r.length){var i=r[r.length-1];return ur.isBuffered(this.media,i.start+i.duration/2)}var n=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(n)},r.getLevelDetails=function(){var e;if(this.levels&&null!==this.levelLastLoaded)return null==(e=this.levelLastLoaded)?void 0:e.details},r.onMediaAttached=function(e,t){var r=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),r.addEventListener("seeking",this.onvseeking),r.addEventListener("ended",this.onvended);var i=this.config;this.levels&&i.autoStartLoad&&this.state===ti&&this.startLoad(i.startPosition)},r.onMediaDetaching=function(){var e=this.media;null!=e&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&this.onvseeking&&this.onvended&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},r.onMediaSeeking=function(){var e=this.config,t=this.fragCurrent,r=this.media,i=this.mediaBuffer,n=this.state,a=r?r.currentTime:0,s=ur.bufferInfo(i||r,a,e.maxBufferHole);if(this.log("media seeking to "+(g(a)?a.toFixed(3):a)+", state: "+n),this.state===ui)this.resetLoadingState();else if(t){var o=e.maxFragLookUpTolerance,u=t.start-o,l=t.start+t.duration+o;if(!s.len||l<s.start||u>s.end){var d=a>l;(a<u||d)&&(d&&t.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),t.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}r&&(this.fragmentTracker.removeFragmentsInRange(a,1/0,this.playlistType,!0),this.lastCurrentTime=a),this.loadedmetadata||s.len||(this.nextLoadPosition=this.startPosition=a),this.tickImmediate()},r.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},r.onManifestLoaded=function(e,t){this.startTimeOffset=t.startTimeOffset,this.initPTS=[]},r.onHandlerDestroying=function(){this.hls.off(_.MANIFEST_LOADED,this.onManifestLoaded,this),this.stopLoad(),e.prototype.onHandlerDestroying.call(this),this.hls=null},r.onHandlerDestroyed=function(){this.state=ti,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,e.prototype.onHandlerDestroyed.call(this)},r.loadFragment=function(e,t,r){this._loadFragForPlayback(e,t,r)},r._loadFragForPlayback=function(e,t,r){var i=this;this._doFragLoad(e,t,r,(function(t){if(i.fragContextChanged(e))return i.warn("Fragment "+e.sn+(t.part?" p: "+t.part.index:"")+" of level "+e.level+" was dropped during download."),void i.fragmentTracker.removeFragment(e);e.stats.chunkCount++,i._handleFragmentLoadProgress(t)})).then((function(t){if(t){var r=i.state;i.fragContextChanged(e)?(r===ni||!i.fragCurrent&&r===si)&&(i.fragmentTracker.removeFragment(e),i.state=ri):("payload"in t&&(i.log("Loaded fragment "+e.sn+" of level "+e.level),i.hls.trigger(_.FRAG_LOADED,t)),i._handleFragmentLoadComplete(t))}})).catch((function(t){i.state!==ti&&i.state!==li&&(i.warn("Frag error: "+((null==t?void 0:t.message)||t)),i.resetFragmentLoading(e))}))},r.clearTrackerIfNeeded=function(e){var t,r=this.fragmentTracker;if(r.getState(e)===Pr){var i=e.type,n=this.getFwdBufferInfo(this.mediaBuffer,i),a=Math.max(e.duration,n?n.len:this.config.maxBufferLength),s=this.backtrackFragment;(1==(s?e.sn-s.sn:0)||this.reduceMaxBufferLength(a,e.duration))&&r.removeFragment(e)}else 0===(null==(t=this.mediaBuffer)?void 0:t.buffered.length)?r.removeAllFragments():r.hasParts(e.type)&&(r.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),r.getState(e)===Or&&r.removeFragment(e))},r.checkLiveUpdate=function(e){if(e.updated&&!e.live){var t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)},r.flushMainBuffer=function(e,t,r){if(void 0===r&&(r=null),e-t){var i={startOffset:e,endOffset:t,type:r};this.hls.trigger(_.BUFFER_FLUSHING,i)}},r._loadInitSegment=function(e,t){var r=this;this._doFragLoad(e,t).then((function(t){if(!t||r.fragContextChanged(e)||!r.levels)throw new Error("init load aborted");return t})).then((function(t){var i=r.hls,n=t.payload,a=e.decryptdata;if(n&&n.byteLength>0&&null!=a&&a.key&&a.iv&&"AES-128"===a.method){var s=self.performance.now();return r.decrypter.decrypt(new Uint8Array(n),a.key.buffer,a.iv.buffer).catch((function(t){throw i.trigger(_.ERROR,{type:b.MEDIA_ERROR,details:E.FRAG_DECRYPT_ERROR,fatal:!1,error:t,reason:t.message,frag:e}),t})).then((function(n){var a=self.performance.now();return i.trigger(_.FRAG_DECRYPTED,{frag:e,payload:n,stats:{tstart:s,tdecrypt:a}}),t.payload=n,r.completeInitSegmentLoad(t)}))}return r.completeInitSegmentLoad(t)})).catch((function(t){r.state!==ti&&r.state!==li&&(r.warn(t),r.resetFragmentLoading(e))}))},r.completeInitSegmentLoad=function(e){if(!this.levels)throw new Error("init load aborted, missing levels");var t=e.frag.stats;this.state=ri,e.frag.data=new Uint8Array(e.payload),t.parsing.start=t.buffering.start=self.performance.now(),t.parsing.end=t.buffering.end=self.performance.now(),this.tick()},r.fragContextChanged=function(e){var t=this.fragCurrent;return!e||!t||e.sn!==t.sn||e.level!==t.level},r.fragBufferedComplete=function(e,t){var r,i,n,a,s=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log("Buffered "+e.type+" sn: "+e.sn+(t?" part: "+t.index:"")+" of "+(this.playlistType===at?"level":"track")+" "+e.level+" (frag:["+(null!=(r=e.startPTS)?r:NaN).toFixed(3)+"-"+(null!=(i=e.endPTS)?i:NaN).toFixed(3)+"] > buffer:"+(s?ei(ur.getBuffered(s)):"(detached)")+")"),"initSegment"!==e.sn){var o;if(e.type!==ot){var u=e.elementaryStreams;if(!Object.keys(u).some((function(e){return!!u[e]})))return void(this.state=ri)}var l=null==(o=this.levels)?void 0:o[e.level];null!=l&&l.fragmentError&&(this.log("Resetting level fragment error count of "+l.fragmentError+" on frag buffered"),l.fragmentError=0)}this.state=ri,s&&(!this.loadedmetadata&&e.type==at&&s.buffered.length&&(null==(n=this.fragCurrent)?void 0:n.sn)===(null==(a=this.fragPrevious)?void 0:a.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},r.seekToStartPos=function(){},r._handleFragmentLoadComplete=function(e){var t=this.transmuxer;if(t){var r=e.frag,i=e.part,n=e.partsLoaded,a=!n||0===n.length||n.some((function(e){return!e})),s=new zr(r.level,r.sn,r.stats.chunkCount+1,0,i?i.index:-1,!a);t.flush(s)}},r._handleFragmentLoadProgress=function(e){},r._doFragLoad=function(e,t,r,i){var n,a=this;void 0===r&&(r=null);var s=null==t?void 0:t.details;if(!this.levels||!s)throw new Error("frag load aborted, missing level"+(s?"":" detail")+"s");var o=null;if(!e.encrypted||null!=(n=e.decryptdata)&&n.key?!e.encrypted&&s.encryptedFragments.length&&this.keyLoader.loadClear(e,s.encryptedFragments):(this.log("Loading key for "+e.sn+" of ["+s.startSN+"-"+s.endSN+"], "+("[stream-controller]"===this.logPrefix?"level":"track")+" "+e.level),this.state=ii,this.fragCurrent=e,o=this.keyLoader.load(e).then((function(e){if(!a.fragContextChanged(e.frag))return a.hls.trigger(_.KEY_LOADED,e),a.state===ii&&(a.state=ri),e})),this.hls.trigger(_.KEY_LOADING,{frag:e}),null===this.fragCurrent&&(o=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))),r=Math.max(e.start,r||0),this.config.lowLatencyMode&&"initSegment"!==e.sn){var u=s.partList;if(u&&i){r>e.end&&s.fragmentHint&&(e=s.fragmentHint);var l=this.getNextPart(u,e,r);if(l>-1){var d,h=u[l];return this.log("Loading part sn: "+e.sn+" p: "+h.index+" cc: "+e.cc+" of playlist ["+s.startSN+"-"+s.endSN+"] parts [0-"+l+"-"+(u.length-1)+"] "+("[stream-controller]"===this.logPrefix?"level":"track")+": "+e.level+", target: "+parseFloat(r.toFixed(3))),this.nextLoadPosition=h.start+h.duration,this.state=ni,d=o?o.then((function(r){return!r||a.fragContextChanged(r.frag)?null:a.doFragPartsLoad(e,h,t,i)})).catch((function(e){return a.handleFragLoadError(e)})):this.doFragPartsLoad(e,h,t,i).catch((function(e){return a.handleFragLoadError(e)})),this.hls.trigger(_.FRAG_LOADING,{frag:e,part:h,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):d}if(!e.url||this.loadedEndOfParts(u,r))return Promise.resolve(null)}}this.log("Loading fragment "+e.sn+" cc: "+e.cc+" "+(s?"of ["+s.startSN+"-"+s.endSN+"] ":"")+("[stream-controller]"===this.logPrefix?"level":"track")+": "+e.level+", target: "+parseFloat(r.toFixed(3))),g(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=ni;var c,f=this.config.progressive;return c=f&&o?o.then((function(t){return!t||a.fragContextChanged(null==t?void 0:t.frag)?null:a.fragmentLoader.load(e,i)})).catch((function(e){return a.handleFragLoadError(e)})):Promise.all([this.fragmentLoader.load(e,f?i:void 0),o]).then((function(e){var t=e[0];return!f&&t&&i&&i(t),t})).catch((function(e){return a.handleFragLoadError(e)})),this.hls.trigger(_.FRAG_LOADING,{frag:e,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):c},r.doFragPartsLoad=function(e,t,r,i){var n=this;return new Promise((function(a,s){var o,u=[],l=null==(o=r.details)?void 0:o.partList;!function t(o){n.fragmentLoader.loadPart(e,o,i).then((function(i){u[o.index]=i;var s=i.part;n.hls.trigger(_.FRAG_LOADED,i);var d=Ft(r,e.sn,o.index+1)||Mt(l,e.sn,o.index+1);if(!d)return a({frag:e,part:s,partsLoaded:u});t(d)})).catch(s)}(t)}))},r.handleFragLoadError=function(e){if("data"in e){var t=e.data;e.data&&t.details===E.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(_.ERROR,t)}else this.hls.trigger(_.ERROR,{type:b.OTHER_ERROR,details:E.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null},r._handleTransmuxerFlush=function(e){var t=this.getCurrentContext(e);if(t&&this.state===si){var r=t.frag,i=t.part,n=t.level,a=self.performance.now();r.stats.parsing.end=a,i&&(i.stats.parsing.end=a),this.updateLevelTiming(r,i,n,e.partial)}else this.fragCurrent||this.state===ti||this.state===li||(this.state=ri)},r.getCurrentContext=function(e){var t=this.levels,r=this.fragCurrent,i=e.level,n=e.sn,a=e.part;if(null==t||!t[i])return this.warn("Levels object was unset while buffering fragment "+n+" of level "+i+". The current chunk will not be buffered."),null;var s=t[i],o=a>-1?Ft(s,n,a):null,u=o?o.fragment:function(e,t,r){if(null==e||!e.details)return null;var i=e.details,n=i.fragments[t-i.startSN];return n||((n=i.fragmentHint)&&n.sn===t?n:t<i.startSN&&r&&r.sn===t?r:null)}(s,n,r);return u?(r&&r!==u&&(u.stats=r.stats),{frag:u,part:o,level:s}):null},r.bufferFragmentData=function(e,t,r,i,n){var a;if(e&&this.state===si){var s=e.data1,o=e.data2,u=s;if(s&&o&&(u=ke(s,o)),null!=(a=u)&&a.length){var l={type:e.type,frag:t,part:r,chunkMeta:i,parent:t.type,data:u};if(this.hls.trigger(_.BUFFER_APPENDING,l),e.dropped&&e.independent&&!r){if(n)return;this.flushBufferGap(t)}}}},r.flushBufferGap=function(e){var t=this.media;if(t)if(ur.isBuffered(t,t.currentTime)){var r=t.currentTime,i=ur.bufferInfo(t,r,0),n=e.duration,a=Math.min(2*this.config.maxFragLookUpTolerance,.25*n),s=Math.max(Math.min(e.start-a,i.end-a),r+a);e.start-s>a&&this.flushMainBuffer(s,e.start)}else this.flushMainBuffer(0,e.start)},r.getFwdBufferInfo=function(e,t){var r=this.getLoadPosition();return g(r)?this.getFwdBufferInfoAtPos(e,r,t):null},r.getFwdBufferInfoAtPos=function(e,t,r){var i=this.config.maxBufferHole,n=ur.bufferInfo(e,t,i);if(0===n.len&&void 0!==n.nextStart){var a=this.fragmentTracker.getBufferedFrag(t,r);if(a&&n.nextStart<a.end)return ur.bufferInfo(e,t,Math.max(n.nextStart,i))}return n},r.getMaxBufferLength=function(e){var t,r=this.config;return t=e?Math.max(8*r.maxBufferSize/e,r.maxBufferLength):r.maxBufferLength,Math.min(t,r.maxMaxBufferLength)},r.reduceMaxBufferLength=function(e,t){var r=this.config,i=Math.max(Math.min(e-t,r.maxBufferLength),t),n=Math.max(e-3*t,r.maxMaxBufferLength/2,i);return n>=i&&(r.maxMaxBufferLength=n,this.warn("Reduce max buffer length to "+n+"s"),!0)},r.getAppendedFrag=function(e,t){var r=this.fragmentTracker.getAppendedFrag(e,at);return r&&"fragment"in r?r.fragment:r},r.getNextFragment=function(e,t){var r=t.fragments,i=r.length;if(!i)return null;var n,a=this.config,s=r[0].start;if(t.live){var o=a.initialLiveManifestSize;if(i<o)return this.warn("Not enough fragments to start playback (have: "+i+", need: "+o+")"),null;(!t.PTSKnown&&!this.startFragRequested&&-1===this.startPosition||e<s)&&(n=this.getInitialLiveFragment(t,r),this.startPosition=this.nextLoadPosition=n?this.hls.liveSyncPosition||n.start:e)}else e<=s&&(n=r[0]);if(!n){var u=a.lowLatencyMode?t.partEnd:t.fragmentEnd;n=this.getFragmentAtPosition(e,u,t)}return this.mapToInitFragWhenRequired(n)},r.isLoopLoading=function(e,t){var r=this.fragmentTracker.getState(e);return(r===Ir||r===Or&&!!e.gap)&&this.nextLoadPosition>t},r.getNextFragmentLoopLoading=function(e,t,r,i,n){var a=e.gap,s=this.getNextFragment(this.nextLoadPosition,t);if(null===s)return s;if(e=s,a&&e&&!e.gap&&r.nextStart){var o=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,i);if(null!==o&&r.len+o.len>=n)return this.log('buffer full after gaps in "'+i+'" playlist starting at sn: '+e.sn),null}return e},r.mapToInitFragWhenRequired=function(e){return null==e||!e.initSegment||null!=e&&e.initSegment.data||this.bitrateTest?e:e.initSegment},r.getNextPart=function(e,t,r){for(var i=-1,n=!1,a=!0,s=0,o=e.length;s<o;s++){var u=e[s];if(a=a&&!u.independent,i>-1&&r<u.start)break;var l=u.loaded;l?i=-1:(n||u.independent||a)&&u.fragment===t&&(i=s),n=l}return i},r.loadedEndOfParts=function(e,t){var r=e[e.length-1];return r&&t>r.start&&r.loaded},r.getInitialLiveFragment=function(e,t){var r=this.fragPrevious,i=null;if(r){if(e.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+r.programDateTime),i=function(e,t,r){if(null===t||!Array.isArray(e)||!e.length||!g(t))return null;if(t<(e[0].programDateTime||0))return null;if(t>=(e[e.length-1].endProgramDateTime||0))return null;r=r||0;for(var i=0;i<e.length;++i){var n=e[i];if(Wt(t,r,n))return n}return null}(t,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!i){var n=r.sn+1;if(n>=e.startSN&&n<=e.endSN){var a=t[n-e.startSN];r.cc===a.cc&&(i=a,this.log("Live playlist, switching playlist, load frag with next SN: "+i.sn))}i||(i=function(e,t){return Ht(e,(function(e){return e.cc<t?1:e.cc>t?-1:0}))}(t,r.cc))&&this.log("Live playlist, switching playlist, load frag with same CC: "+i.sn)}}else{var s=this.hls.liveSyncPosition;null!==s&&(i=this.getFragmentAtPosition(s,this.bitrateTest?e.fragmentEnd:e.edge,e))}return i},r.getFragmentAtPosition=function(e,t,r){var i,n=this.config,a=this.fragPrevious,s=r.fragments,o=r.endSN,u=r.fragmentHint,l=n.maxFragLookUpTolerance,d=r.partList,h=!!(n.lowLatencyMode&&null!=d&&d.length&&u);if(h&&u&&!this.bitrateTest&&(s=s.concat(u),o=u.sn),i=e<t?Kt(a,s,e,e>t-l?0:l):s[s.length-1]){var c=i.sn-r.startSN,f=this.fragmentTracker.getState(i);if((f===Ir||f===Or&&i.gap)&&(a=i),a&&i.sn===a.sn&&(!h||d[0].fragment.sn>i.sn)&&a&&i.level===a.level){var v=s[c+1];i=i.sn<o&&this.fragmentTracker.getState(v)!==Ir?v:null}}return i},r.synchronizeToLiveEdge=function(e){var t=this.config,r=this.media;if(r){var i=this.hls.liveSyncPosition,n=r.currentTime,a=e.fragments[0].start,s=e.edge,o=n>=a-t.maxFragLookUpTolerance&&n<=s;if(null!==i&&r.duration>i&&(n<i||!o)){var u=void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;(!o&&r.readyState<4||n<s-u)&&(this.loadedmetadata||(this.nextLoadPosition=i),r.readyState&&(this.warn("Playback: "+n.toFixed(3)+" is located too far from the end of live sliding playlist: "+s+", reset currentTime to : "+i.toFixed(3)),r.currentTime=i))}}},r.alignPlaylists=function(e,t,r){var i=e.fragments.length;if(!i)return this.warn("No fragments in live playlist"),0;var n=e.fragments[0].start,a=!t,s=e.alignedSliding&&g(n);if(a||!s&&!n){var o=this.fragPrevious;Xr(o,r,e);var u=e.fragments[0].start;return this.log("Live playlist sliding: "+u.toFixed(2)+" start-sn: "+(t?t.startSN:"na")+"->"+e.startSN+" prev-sn: "+(o?o.sn:"na")+" fragments: "+i),u}return n},r.waitForCdnTuneIn=function(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)},r.setStartPosition=function(e,t){var r=this.startPosition;if(r<t&&(r=-1),-1===r||-1===this.lastCurrentTime){var i=null!==this.startTimeOffset,n=i?this.startTimeOffset:e.startTimeOffset;null!==n&&g(n)?(r=t+n,n<0&&(r+=e.totalduration),r=Math.min(Math.max(t,r),t+e.totalduration),this.log("Start time offset "+n+" found in "+(i?"multivariant":"media")+" playlist, adjust startPosition to "+r),this.startPosition=r):e.live?r=this.hls.liveSyncPosition||t:this.startPosition=r=0,this.lastCurrentTime=r}this.nextLoadPosition=r},r.getLoadPosition=function(){var e=this.media,t=0;return this.loadedmetadata&&e?t=e.currentTime:this.nextLoadPosition&&(t=this.nextLoadPosition),t},r.handleFragLoadAborted=function(e,t){this.transmuxer&&"initSegment"!==e.sn&&e.stats.aborted&&(this.warn("Fragment "+e.sn+(t?" part "+t.index:"")+" of level "+e.level+" was aborted"),this.resetFragmentLoading(e))},r.resetFragmentLoading=function(e){this.fragCurrent&&(this.fragContextChanged(e)||this.state===ai)||(this.state=ri)},r.onFragmentOrKeyLoadError=function(e,t){if(t.chunkMeta&&!t.frag){var r=this.getCurrentContext(t.chunkMeta);r&&(t.frag=r.frag)}var i=t.frag;if(i&&i.type===e&&this.levels)if(this.fragContextChanged(i)){var n;this.warn("Frag load error must match current frag to retry "+i.url+" > "+(null==(n=this.fragCurrent)?void 0:n.url))}else{var a=t.details===E.FRAG_GAP;a&&this.fragmentTracker.fragBuffered(i,!0);var s=t.errorAction,o=s||{},u=o.action,l=o.retryCount,d=void 0===l?0:l,h=o.retryConfig;if(s&&u===Qt&&h){this.resetStartWhenNotLoaded(this.levelLastLoaded);var c=Gt(h,d);this.warn("Fragment "+i.sn+" of "+e+" "+i.level+" errored with "+t.details+", retrying loading "+(d+1)+"/"+h.maxNumRetry+" in "+c+"ms"),s.resolved=!0,this.retryDate=self.performance.now()+c,this.state=ai}else if(h&&s){if(this.resetFragmentErrors(e),!(d<h.maxNumRetry))return void x.warn(t.details+" reached or exceeded max retry ("+d+")");a||u===Xt||(s.resolved=!0)}else(null==s?void 0:s.action)===Yt?this.state=di:this.state=li;this.tickImmediate()}},r.reduceLengthAndFlushBuffer=function(e){if(this.state===si||this.state===oi){var t=e.frag,r=e.parent,i=this.getFwdBufferInfo(this.mediaBuffer,r),n=i&&i.len>.5;n&&this.reduceMaxBufferLength(i.len,(null==t?void 0:t.duration)||10);var a=!n;return a&&this.warn("Buffer full error while media.currentTime is not buffered, flush "+r+" buffer"),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),a}return!1},r.resetFragmentErrors=function(e){e===st&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==ti&&(this.state=ri)},r.afterBufferFlushed=function(e,t,r){if(e){var i=ur.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,i,r),this.state===ui&&this.resetLoadingState()}},r.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=ri},r.resetStartWhenNotLoaded=function(e){if(!this.loadedmetadata){this.startFragRequested=!1;var t=e?e.details:null;null!=t&&t.live?(this.startPosition=-1,this.setStartPosition(t,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},r.resetWhenMissingContext=function(e){this.warn("The loading context changed while buffering fragment "+e.sn+" of level "+e.level+". This chunk will not be buffered."),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()},r.removeUnbufferedFrags=function(e){void 0===e&&(e=0),this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)},r.updateLevelTiming=function(e,t,r,i){var n,a=this,s=r.details;if(s){if(!Object.keys(e.elementaryStreams).reduce((function(t,n){var o=e.elementaryStreams[n];if(o){var u=o.endPTS-o.startPTS;if(u<=0)return a.warn("Could not parse fragment "+e.sn+" "+n+" duration reliably ("+u+")"),t||!1;var l=i?0:Pt(s,e,o.startPTS,o.endPTS,o.startDTS,o.endDTS);return a.hls.trigger(_.LEVEL_PTS_UPDATED,{details:s,level:r,drift:l,type:n,frag:e,start:o.startPTS,end:o.endPTS}),!0}return t}),!1)&&null===(null==(n=this.transmuxer)?void 0:n.error)){var o=new Error("Found no media in fragment "+e.sn+" of level "+e.level+" resetting transmuxer to fallback to playlist timing");if(0===r.fragmentError&&(r.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)),this.warn(o.message),this.hls.trigger(_.ERROR,{type:b.MEDIA_ERROR,details:E.FRAG_PARSING_ERROR,fatal:!1,error:o,frag:e,reason:"Found no media in msn "+e.sn+' of level "'+r.url+'"'}),!this.hls)return;this.resetTransmuxer()}this.state=oi,this.hls.trigger(_.FRAG_PARSED,{frag:e,part:t})}else this.warn("level.details undefined")},r.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},r.recoverWorkerError=function(e){"demuxerWorker"===e.event&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())},s(t,[{key:"state",get:function(){return this._state},set:function(e){var t=this._state;t!==e&&(this._state=e,this.log(t+"->"+e))}}]),t}(Kr);function ci(){return self.SourceBuffer||self.WebKitSourceBuffer}function fi(){if(!Ce())return!1;var e=ci();return!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove}function vi(e,t){return void 0===e&&(e=""),void 0===t&&(t=9e4),{type:e,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}var pi=function(){function e(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var t=e.prototype;return t.resetInitSegment=function(e,t,r,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},t.resetTimeStamp=function(e){this.initPTS=e,this.resetContiguity()},t.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},t.canParse=function(e,t){return!1},t.appendFrame=function(e,t,r){},t.demux=function(e,t){this.cachedData&&(e=ke(this.cachedData,e),this.cachedData=null);var r,i=W(e,0),n=i?i.length:0,a=this._audioTrack,s=this._id3Track,o=i?X(i):void 0,u=e.length;for((null===this.basePTS||0===this.frameIndex&&g(o))&&(this.basePTS=gi(o,t,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),i&&i.length>0&&s.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:ft,duration:Number.POSITIVE_INFINITY});n<u;){if(this.canParse(e,n)){var l=this.appendFrame(a,e,n);l?(this.frameIndex++,this.lastPTS=l.sample.pts,r=n+=l.length):n=u}else Y(e,n)?(i=W(e,n),s.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:ft,duration:Number.POSITIVE_INFINITY}),r=n+=i.length):n++;if(n===u&&r!==u){var d=j(e,r);this.cachedData?this.cachedData=ke(this.cachedData,d):this.cachedData=d}}return{audioTrack:a,videoTrack:vi(),id3Track:s,textTrack:vi()}},t.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},t.flush=function(e){var t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:vi(),id3Track:this._id3Track,textTrack:vi()}},t.destroy=function(){},e}(),gi=function(e,t,r){return g(e)?90*e:9e4*t+(r?9e4*r.baseTime/r.timescale:0)};function mi(e,t){return 255===e[t]&&240==(246&e[t+1])}function yi(e,t){return 1&e[t+1]?7:9}function _i(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function bi(e,t){return t+1<e.length&&mi(e,t)}function Ei(e,t){if(bi(e,t)){var r=yi(e,t);if(t+r>=e.length)return!1;var i=_i(e,t);if(i<=r)return!1;var n=t+i;return n===e.length||bi(e,n)}return!1}function Ti(e,t,r,i,n){if(!e.samplerate){var a=function(e,t,r,i){var n,a,s,o,u=navigator.userAgent.toLowerCase(),l=i,d=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];n=1+((192&t[r+2])>>>6);var h=(60&t[r+2])>>>2;if(!(h>d.length-1))return s=(1&t[r+2])<<2,s|=(192&t[r+3])>>>6,x.log("manifest codec:"+i+", ADTS type:"+n+", samplingIndex:"+h),/firefox/i.test(u)?h>=6?(n=5,o=new Array(4),a=h-3):(n=2,o=new Array(2),a=h):-1!==u.indexOf("android")?(n=2,o=new Array(2),a=h):(n=5,o=new Array(4),i&&(-1!==i.indexOf("mp4a.40.29")||-1!==i.indexOf("mp4a.40.5"))||!i&&h>=6?a=h-3:((i&&-1!==i.indexOf("mp4a.40.2")&&(h>=6&&1===s||/vivaldi/i.test(u))||!i&&1===s)&&(n=2,o=new Array(2)),a=h)),o[0]=n<<3,o[0]|=(14&h)>>1,o[1]|=(1&h)<<7,o[1]|=s<<3,5===n&&(o[1]|=(14&a)>>1,o[2]=(1&a)<<7,o[2]|=8,o[3]=0),{config:o,samplerate:d[h],channelCount:s,codec:"mp4a.40."+n,manifestCodec:l};var c=new Error("invalid ADTS sampling index:"+h);e.emit(_.ERROR,_.ERROR,{type:b.MEDIA_ERROR,details:E.FRAG_PARSING_ERROR,fatal:!0,error:c,reason:c.message})}(t,r,i,n);if(!a)return;e.config=a.config,e.samplerate=a.samplerate,e.channelCount=a.channelCount,e.codec=a.codec,e.manifestCodec=a.manifestCodec,x.log("parsed codec:"+e.codec+", rate:"+a.samplerate+", channels:"+a.channelCount)}}function Si(e){return 9216e4/e}function Li(e,t,r,i,n){var a,s=i+n*Si(e.samplerate),o=function(e,t){var r=yi(e,t);if(t+r<=e.length){var i=_i(e,t)-r;if(i>0)return{headerLength:r,frameLength:i}}}(t,r);if(o){var u=o.frameLength,l=o.headerLength,d=l+u,h=Math.max(0,r+d-t.length);h?(a=new Uint8Array(d-l)).set(t.subarray(r+l,t.length),0):a=t.subarray(r+l,r+d);var c={unit:a,pts:s};return h||e.samples.push(c),{sample:c,length:d,missing:h}}var f=t.length-r;return(a=new Uint8Array(f)).set(t.subarray(r,t.length),0),{sample:{unit:a,pts:s},length:f,missing:-1}}var ki=null,wi=[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],xi=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Ai=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Ri=[0,1,1,4];function Di(e,t,r,i,n){if(!(r+24>t.length)){var a=Ci(t,r);if(a&&r+a.frameLength<=t.length){var s=i+n*(9e4*a.samplesPerFrame/a.sampleRate),o={unit:t.subarray(r,r+a.frameLength),pts:s,dts:s};return e.config=[],e.channelCount=a.channelCount,e.samplerate=a.sampleRate,e.samples.push(o),{sample:o,length:a.frameLength,missing:0}}}}function Ci(e,t){var r=e[t+1]>>3&3,i=e[t+1]>>1&3,n=e[t+2]>>4&15,a=e[t+2]>>2&3;if(1!==r&&0!==n&&15!==n&&3!==a){var s=e[t+2]>>1&1,o=e[t+3]>>6,u=1e3*wi[14*(3===r?3-i:3===i?3:4)+n-1],l=xi[3*(3===r?0:2===r?1:2)+a],d=3===o?1:2,h=Ai[r][i],c=Ri[i],f=8*h*c,v=Math.floor(h*u/l+s)*c;if(null===ki){var p=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);ki=p?parseInt(p[1]):0}return!!ki&&ki<=87&&2===i&&u>=224e3&&0===o&&(e[t+3]=128|e[t+3]),{sampleRate:l,channelCount:d,frameLength:v,samplesPerFrame:f}}}function Pi(e,t){return!(255!==e[t]||224&~e[t+1]||!(6&e[t+1]))}function Oi(e,t){return t+1<e.length&&Pi(e,t)}function Ii(e,t){if(t+1<e.length&&Pi(e,t)){var r=Ci(e,t),i=4;null!=r&&r.frameLength&&(i=r.frameLength);var n=t+i;return n===e.length||Oi(e,n)}return!1}var Fi=function(e){function t(t,r){var i;return(i=e.call(this)||this).observer=void 0,i.config=void 0,i.observer=t,i.config=r,i}u(t,e);var r=t.prototype;return r.resetInitSegment=function(t,r,i,n){e.prototype.resetInitSegment.call(this,t,r,i,n),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:r,duration:n,inputTimeScale:9e4,dropped:0}},t.probe=function(e){if(!e)return!1;var t=W(e,0),r=(null==t?void 0:t.length)||0;if(Ii(e,r))return!1;for(var i=e.length;r<i;r++)if(Ei(e,r))return x.log("ADTS sync word found !"),!0;return!1},r.canParse=function(e,t){return function(e,t){return function(e,t){return t+5<e.length}(e,t)&&mi(e,t)&&_i(e,t)<=e.length-t}(e,t)},r.appendFrame=function(e,t,r){Ti(e,this.observer,t,r,e.manifestCodec);var i=Li(e,t,r,this.basePTS,this.frameIndex);if(i&&0===i.missing)return i},t}(pi),Mi=/\/emsg[-/]ID3/i,Bi=function(){function e(e,t){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=t}var t=e.prototype;return t.resetTimeStamp=function(){},t.resetInitSegment=function(e,t,r,i){var n=this.videoTrack=vi("video",1),a=this.audioTrack=vi("audio",1),s=this.txtTrack=vi("text",1);if(this.id3Track=vi("id3",1),this.timeOffset=0,null!=e&&e.byteLength){var o=ye(e);if(o.video){var u=o.video,l=u.id,d=u.timescale,h=u.codec;n.id=l,n.timescale=s.timescale=d,n.codec=h}if(o.audio){var c=o.audio,f=c.id,v=c.timescale,p=c.codec;a.id=f,a.timescale=v,a.codec=p}s.id=le.text,n.sampleDuration=0,n.duration=a.duration=i}},t.resetContiguity=function(){this.remainderData=null},e.probe=function(e){return function(e){for(var t=e.byteLength,r=0;r<t;){var i=ce(e,r);if(i>8&&109===e[r+4]&&111===e[r+5]&&111===e[r+6]&&102===e[r+7])return!0;r=i>1?r+i:t}return!1}(e)},t.demux=function(e,t){this.timeOffset=t;var r=e,i=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=ke(this.remainderData,e));var a=function(e){var t={valid:null,remainder:null},r=ge(e,["moof"]);if(r.length<2)return t.remainder=e,t;var i=r[r.length-1];return t.valid=j(e,0,i.byteOffset-8),t.remainder=j(e,i.byteOffset-8),t}(r);this.remainderData=a.remainder,i.samples=a.valid||new Uint8Array}else i.samples=r;var s=this.extractID3Track(i,t);return n.samples=we(t,i),{videoTrack:i,audioTrack:this.audioTrack,id3Track:s,textTrack:this.txtTrack}},t.flush=function(){var e=this.timeOffset,t=this.videoTrack,r=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;var i=this.extractID3Track(t,this.timeOffset);return r.samples=we(e,t),{videoTrack:t,audioTrack:vi(),id3Track:i,textTrack:vi()}},t.extractID3Track=function(e,t){var r=this.id3Track;if(e.samples.length){var i=ge(e.samples,["emsg"]);i&&i.forEach((function(e){var i=function(e){var t=e[0],r="",i="",n=0,a=0,s=0,o=0,u=0,l=0;if(0===t){for(;"\0"!==de(e.subarray(l,l+1));)r+=de(e.subarray(l,l+1)),l+=1;for(r+=de(e.subarray(l,l+1)),l+=1;"\0"!==de(e.subarray(l,l+1));)i+=de(e.subarray(l,l+1)),l+=1;i+=de(e.subarray(l,l+1)),l+=1,n=ce(e,12),a=ce(e,16),o=ce(e,20),u=ce(e,24),l=28}else if(1===t){n=ce(e,l+=4);var d=ce(e,l+=4),h=ce(e,l+=4);for(l+=4,s=Math.pow(2,32)*d+h,m(s)||(s=Number.MAX_SAFE_INTEGER,x.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=ce(e,l),u=ce(e,l+=4),l+=4;"\0"!==de(e.subarray(l,l+1));)r+=de(e.subarray(l,l+1)),l+=1;for(r+=de(e.subarray(l,l+1)),l+=1;"\0"!==de(e.subarray(l,l+1));)i+=de(e.subarray(l,l+1)),l+=1;i+=de(e.subarray(l,l+1)),l+=1}return{schemeIdUri:r,value:i,timeScale:n,presentationTime:s,presentationTimeDelta:a,eventDuration:o,id:u,payload:e.subarray(l,e.byteLength)}}(e);if(Mi.test(i.schemeIdUri)){var n=g(i.presentationTime)?i.presentationTime/i.timeScale:t+i.presentationTimeDelta/i.timeScale,a=4294967295===i.eventDuration?Number.POSITIVE_INFINITY:i.eventDuration/i.timeScale;a<=.001&&(a=Number.POSITIVE_INFINITY);var s=i.payload;r.samples.push({data:s,len:s.byteLength,dts:n,pts:n,type:pt,duration:a})}}))}return r},t.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},t.destroy=function(){},e}(),Ni=function(){function e(){this.VideoSample=null}var t=e.prototype;return t.createVideoSample=function(e,t,r,i){return{key:e,frame:!1,pts:t,dts:r,units:[],debug:i,length:0}},t.getLastNalUnit=function(e){var t,r,i=this.VideoSample;if(i&&0!==i.units.length||(i=e[e.length-1]),null!=(t=i)&&t.units){var n=i.units;r=n[n.length-1]}return r},t.pushAccessUnit=function(e,t){if(e.units.length&&e.frame){if(void 0===e.pts){var r=t.samples,i=r.length;if(!i)return void t.dropped++;var n=r[i-1];e.pts=n.pts,e.dts=n.dts}t.samples.push(e)}e.debug.length&&x.log(e.pts+"/"+e.dts+":"+e.debug)},e}(),Ui=function(){function e(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}var t=e.prototype;return t.loadWord=function(){var e=this.data,t=this.bytesAvailable,r=e.byteLength-t,i=new Uint8Array(4),n=Math.min(4,t);if(0===n)throw new Error("no bytes available");i.set(e.subarray(r,r+n)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*n,this.bytesAvailable-=n},t.skipBits=function(e){var t;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,e-=(t=e>>3)<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)},t.readBits=function(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;if(e>32&&x.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return(t=e-t)>0&&this.bitsAvailable?r<<t|this.readBits(t):r},t.skipLZ=function(){var e;for(e=0;e<this.bitsAvailable;++e)if(this.word&2147483648>>>e)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()},t.skipUEG=function(){this.skipBits(1+this.skipLZ())},t.skipEG=function(){this.skipBits(1+this.skipLZ())},t.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},t.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},t.readBoolean=function(){return 1===this.readBits(1)},t.readUByte=function(){return this.readBits(8)},t.readUShort=function(){return this.readBits(16)},t.readUInt=function(){return this.readBits(32)},t.skipScalingList=function(e){for(var t=8,r=8,i=0;i<e;i++)0!==r&&(r=(t+this.readEG()+256)%256),t=0===r?t:r},t.readSPS=function(){var e,t,r,i=0,n=0,a=0,s=0,o=this.readUByte.bind(this),u=this.readBits.bind(this),l=this.readUEG.bind(this),d=this.readBoolean.bind(this),h=this.skipBits.bind(this),c=this.skipEG.bind(this),f=this.skipUEG.bind(this),v=this.skipScalingList.bind(this);o();var p=o();if(u(5),h(3),o(),f(),100===p||110===p||122===p||244===p||44===p||83===p||86===p||118===p||128===p){var g=l();if(3===g&&h(1),f(),f(),h(1),d())for(t=3!==g?8:12,r=0;r<t;r++)d()&&v(r<6?16:64)}f();var m=l();if(0===m)l();else if(1===m)for(h(1),c(),c(),e=l(),r=0;r<e;r++)c();f(),h(1);var y=l(),_=l(),b=u(1);0===b&&h(1),h(1),d()&&(i=l(),n=l(),a=l(),s=l());var E=[1,1];if(d()&&d())switch(o()){case 1:E=[1,1];break;case 2:E=[12,11];break;case 3:E=[10,11];break;case 4:E=[16,11];break;case 5:E=[40,33];break;case 6:E=[24,11];break;case 7:E=[20,11];break;case 8:E=[32,11];break;case 9:E=[80,33];break;case 10:E=[18,11];break;case 11:E=[15,11];break;case 12:E=[64,33];break;case 13:E=[160,99];break;case 14:E=[4,3];break;case 15:E=[3,2];break;case 16:E=[2,1];break;case 255:E=[o()<<8|o(),o()<<8|o()]}return{width:Math.ceil(16*(y+1)-2*i-2*n),height:(2-b)*(_+1)*16-(b?2:4)*(a+s),pixelRatio:E}},t.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},e}(),Gi=function(e){function t(){return e.apply(this,arguments)||this}u(t,e);var r=t.prototype;return r.parseAVCPES=function(e,t,r,i,n){var a,s=this,o=this.parseAVCNALu(e,r.data),u=this.VideoSample,l=!1;r.data=null,u&&o.length&&!e.audFound&&(this.pushAccessUnit(u,e),u=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts,"")),o.forEach((function(i){var o;switch(i.type){case 1:var d=!1;a=!0;var h,c=i.data;if(l&&c.length>4){var f=new Ui(c).readSliceType();2!==f&&4!==f&&7!==f&&9!==f||(d=!0)}d&&null!=(h=u)&&h.frame&&!u.key&&(s.pushAccessUnit(u,e),u=s.VideoSample=null),u||(u=s.VideoSample=s.createVideoSample(!0,r.pts,r.dts,"")),u.frame=!0,u.key=d;break;case 5:a=!0,null!=(o=u)&&o.frame&&!u.key&&(s.pushAccessUnit(u,e),u=s.VideoSample=null),u||(u=s.VideoSample=s.createVideoSample(!0,r.pts,r.dts,"")),u.key=!0,u.frame=!0;break;case 6:a=!0,Ae(i.data,1,r.pts,t.samples);break;case 7:var v,p;a=!0,l=!0;var g=i.data,m=new Ui(g).readSPS();if(!e.sps||e.width!==m.width||e.height!==m.height||(null==(v=e.pixelRatio)?void 0:v[0])!==m.pixelRatio[0]||(null==(p=e.pixelRatio)?void 0:p[1])!==m.pixelRatio[1]){e.width=m.width,e.height=m.height,e.pixelRatio=m.pixelRatio,e.sps=[g],e.duration=n;for(var y=g.subarray(1,4),_="avc1.",b=0;b<3;b++){var E=y[b].toString(16);E.length<2&&(E="0"+E),_+=E}e.codec=_}break;case 8:a=!0,e.pps=[i.data];break;case 9:a=!0,e.audFound=!0,u&&s.pushAccessUnit(u,e),u=s.VideoSample=s.createVideoSample(!1,r.pts,r.dts,"");break;case 12:a=!0;break;default:a=!1,u&&(u.debug+="unknown NAL "+i.type+" ")}u&&a&&u.units.push(i)})),i&&u&&(this.pushAccessUnit(u,e),this.VideoSample=null)},r.parseAVCNALu=function(e,t){var r,i,n=t.byteLength,a=e.naluState||0,s=a,o=[],u=0,l=-1,d=0;for(-1===a&&(l=0,d=31&t[0],a=0,u=1);u<n;)if(r=t[u++],a)if(1!==a)if(r)if(1===r){if(i=u-a-1,l>=0){var h={data:t.subarray(l,i),type:d};o.push(h)}else{var c=this.getLastNalUnit(e.samples);c&&(s&&u<=4-s&&c.state&&(c.data=c.data.subarray(0,c.data.byteLength-s)),i>0&&(c.data=ke(c.data,t.subarray(0,i)),c.state=0))}u<n?(l=u,d=31&t[u],a=0):a=-1}else a=0;else a=3;else a=r?0:2;else a=r?0:1;if(l>=0&&a>=0){var f={data:t.subarray(l,n),type:d,state:a};o.push(f)}if(0===o.length){var v=this.getLastNalUnit(e.samples);v&&(v.data=ke(v.data,t))}return e.naluState=a,o},t}(Ni),Vi=function(){function e(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new $r(t,{removePKCS7Padding:!1})}var t=e.prototype;return t.decryptBuffer=function(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)},t.decryptAacSample=function(e,t,r){var i=this,n=e[t].unit;if(!(n.length<=16)){var a=n.subarray(16,n.length-n.length%16),s=a.buffer.slice(a.byteOffset,a.byteOffset+a.length);this.decryptBuffer(s).then((function(a){var s=new Uint8Array(a);n.set(s,16),i.decrypter.isSync()||i.decryptAacSamples(e,t+1,r)}))}},t.decryptAacSamples=function(e,t,r){for(;;t++){if(t>=e.length)return void r();if(!(e[t].unit.length<32||(this.decryptAacSample(e,t,r),this.decrypter.isSync())))return}},t.getAvcEncryptedData=function(e){for(var t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t),i=0,n=32;n<e.length-16;n+=160,i+=16)r.set(e.subarray(n,n+16),i);return r},t.getAvcDecryptedUnit=function(e,t){for(var r=new Uint8Array(t),i=0,n=32;n<e.length-16;n+=160,i+=16)e.set(r.subarray(i,i+16),n);return e},t.decryptAvcSample=function(e,t,r,i,n){var a=this,s=Re(n.data),o=this.getAvcEncryptedData(s);this.decryptBuffer(o.buffer).then((function(o){n.data=a.getAvcDecryptedUnit(s,o),a.decrypter.isSync()||a.decryptAvcSamples(e,t,r+1,i)}))},t.decryptAvcSamples=function(e,t,r,i){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length)return void i();for(var n=e[t].units;!(r>=n.length);r++){var a=n[r];if(!(a.data.length<=48||1!==a.type&&5!==a.type||(this.decryptAvcSample(e,t,r,i,a),this.decrypter.isSync())))return}}},e}(),ji=188,Hi=function(){function e(e,t,r){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=e,this.config=t,this.typeSupported=r,this.videoParser=new Gi}e.probe=function(t){var r=e.syncOffset(t);return r>0&&x.warn("MPEG2-TS detected but first sync word found @ offset "+r),-1!==r},e.syncOffset=function(e){for(var t=e.length,r=Math.min(940,t-ji)+1,i=0;i<r;){for(var n=!1,a=-1,s=0,o=i;o<t;o+=ji){if(71!==e[o]||t-o!==ji&&71!==e[o+ji]){if(s)return-1;break}if(s++,-1===a&&0!==(a=o)&&(r=Math.min(a+18612,e.length-ji)+1),n||(n=0===Ki(e,o)),n&&s>1&&(0===a&&s>2||o+ji>r))return a}i++}return-1},e.createTrack=function(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:le[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}};var t=e.prototype;return t.resetInitSegment=function(t,r,i,n){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=e.createTrack("video"),this._audioTrack=e.createTrack("audio",n),this._id3Track=e.createTrack("id3"),this._txtTrack=e.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=r,this.videoCodec=i,this._duration=n},t.resetTimeStamp=function(){},t.resetContiguity=function(){var e=this._audioTrack,t=this._videoTrack,r=this._id3Track;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.remainderData=null},t.demux=function(t,r,i,n){var a;void 0===i&&(i=!1),void 0===n&&(n=!1),i||(this.sampleAes=null);var s=this._videoTrack,o=this._audioTrack,u=this._id3Track,l=this._txtTrack,d=s.pid,h=s.pesData,c=o.pid,f=u.pid,v=o.pesData,p=u.pesData,g=null,m=this.pmtParsed,y=this._pmtId,_=t.length;if(this.remainderData&&(_=(t=ke(this.remainderData,t)).length,this.remainderData=null),_<ji&&!n)return this.remainderData=t,{audioTrack:o,videoTrack:s,id3Track:u,textTrack:l};var b=Math.max(0,e.syncOffset(t));(_-=(_-b)%ji)<t.byteLength&&!n&&(this.remainderData=new Uint8Array(t.buffer,_,t.buffer.byteLength-_));for(var E=0,T=b;T<_;T+=ji)if(71===t[T]){var S=!!(64&t[T+1]),L=Ki(t,T),k=void 0;if((48&t[T+3])>>4>1){if((k=T+5+t[T+4])===T+ji)continue}else k=T+4;switch(L){case d:S&&(h&&(a=Xi(h))&&this.videoParser.parseAVCPES(s,l,a,!1,this._duration),h={data:[],size:0}),h&&(h.data.push(t.subarray(k,T+ji)),h.size+=T+ji-k);break;case c:if(S){if(v&&(a=Xi(v)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,a);break;case"mp3":this.parseMPEGPES(o,a)}v={data:[],size:0}}v&&(v.data.push(t.subarray(k,T+ji)),v.size+=T+ji-k);break;case f:S&&(p&&(a=Xi(p))&&this.parseID3PES(u,a),p={data:[],size:0}),p&&(p.data.push(t.subarray(k,T+ji)),p.size+=T+ji-k);break;case 0:S&&(k+=t[k]+1),y=this._pmtId=zi(t,k);break;case y:S&&(k+=t[k]+1);var w=Wi(t,k,this.typeSupported,i,this.observer);(d=w.videoPid)>0&&(s.pid=d,s.segmentCodec=w.segmentVideoCodec),(c=w.audioPid)>0&&(o.pid=c,o.segmentCodec=w.segmentAudioCodec),(f=w.id3Pid)>0&&(u.pid=f),null===g||m||(x.warn("MPEG-TS PMT found at "+T+" after unknown PID '"+g+"'. Backtracking to sync byte @"+b+" to parse all TS packets."),g=null,T=b-188),m=this.pmtParsed=!0;break;case 17:case 8191:break;default:g=L}}else E++;E>0&&qi(this.observer,new Error("Found "+E+" TS packet/s that do not start with 0x47")),s.pesData=h,o.pesData=v,u.pesData=p;var A={audioTrack:o,videoTrack:s,id3Track:u,textTrack:l};return n&&this.extractRemainingSamples(A),A},t.flush=function(){var e,t=this.remainderData;return this.remainderData=null,e=t?this.demux(t,-1,!1,!0):{videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e},t.extractRemainingSamples=function(e){var t,r=e.audioTrack,i=e.videoTrack,n=e.id3Track,a=e.textTrack,s=i.pesData,o=r.pesData,u=n.pesData;if(s&&(t=Xi(s))?(this.videoParser.parseAVCPES(i,a,t,!0,this._duration),i.pesData=null):i.pesData=s,o&&(t=Xi(o))){switch(r.segmentCodec){case"aac":this.parseAACPES(r,t);break;case"mp3":this.parseMPEGPES(r,t)}r.pesData=null}else null!=o&&o.size&&x.log("last AAC PES packet truncated,might overlap between fragments"),r.pesData=o;u&&(t=Xi(u))?(this.parseID3PES(n,t),n.pesData=null):n.pesData=u},t.demuxSampleAes=function(e,t,r){var i=this.demux(e,r,!0,!this.config.progressive),n=this.sampleAes=new Vi(this.observer,this.config,t);return this.decrypt(i,n)},t.decrypt=function(e,t){return new Promise((function(r){var i=e.audioTrack,n=e.videoTrack;i.samples&&"aac"===i.segmentCodec?t.decryptAacSamples(i.samples,0,(function(){n.samples?t.decryptAvcSamples(n.samples,0,0,(function(){r(e)})):r(e)})):n.samples&&t.decryptAvcSamples(n.samples,0,0,(function(){r(e)}))}))},t.destroy=function(){this._duration=0},t.parseAACPES=function(e,t){var r,i,n,a=0,s=this.aacOverFlow,o=t.data;if(s){this.aacOverFlow=null;var u=s.missing,l=s.sample.unit.byteLength;if(-1===u)o=ke(s.sample.unit,o);else{var d=l-u;s.sample.unit.set(o.subarray(0,u),d),e.samples.push(s.sample),a=s.missing}}for(r=a,i=o.length;r<i-1&&!bi(o,r);r++);if(r!==a){var h,c=r<i-1;if(h=c?"AAC PES did not start with ADTS header,offset:"+r:"No ADTS header found in AAC PES",qi(this.observer,new Error(h),c),!c)return}if(Ti(e,this.observer,o,r,this.audioCodec),void 0!==t.pts)n=t.pts;else{if(!s)return void x.warn("[tsdemuxer]: AAC PES unknown PTS");var f=Si(e.samplerate);n=s.sample.pts+f}for(var v,p=0;r<i;){if(r+=(v=Li(e,o,r,n,p)).length,v.missing){this.aacOverFlow=v;break}for(p++;r<i-1&&!bi(o,r);r++);}},t.parseMPEGPES=function(e,t){var r=t.data,i=r.length,n=0,a=0,s=t.pts;if(void 0!==s)for(;a<i;)if(Oi(r,a)){var o=Di(e,r,a,s,n);if(!o)break;a+=o.length,n++}else a++;else x.warn("[tsdemuxer]: MPEG PES unknown PTS")},t.parseAC3PES=function(e,t){},t.parseID3PES=function(e,t){if(void 0!==t.pts){var r=o({},t,{type:this._videoTrack?pt:ft,duration:Number.POSITIVE_INFINITY});e.samples.push(r)}else x.warn("[tsdemuxer]: ID3 PES unknown PTS")},e}();function Ki(e,t){return((31&e[t+1])<<8)+e[t+2]}function zi(e,t){return(31&e[t+10])<<8|e[t+11]}function Wi(e,t,r,i,n){var a={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},s=t+3+((15&e[t+1])<<8|e[t+2])-4;for(t+=12+((15&e[t+10])<<8|e[t+11]);t<s;){var o=Ki(e,t),u=(15&e[t+3])<<8|e[t+4];switch(e[t]){case 207:if(!i){Yi("ADTS AAC");break}case 15:-1===a.audioPid&&(a.audioPid=o);break;case 21:-1===a.id3Pid&&(a.id3Pid=o);break;case 219:if(!i){Yi("H.264");break}case 27:-1===a.videoPid&&(a.videoPid=o,a.segmentVideoCodec="avc");break;case 3:case 4:r.mpeg||r.mp3?-1===a.audioPid&&(a.audioPid=o,a.segmentAudioCodec="mp3"):x.log("MPEG audio found, not supported in this browser");break;case 193:if(!i){Yi("AC-3");break}case 129:x.warn("AC-3 in M2TS support not included in build");break;case 6:if(-1===a.audioPid&&u>0)for(var l=t+5,d=u;d>2;){106===e[l]&&x.warn("AC-3 in M2TS support not included in build");var h=e[l+1]+2;l+=h,d-=h}break;case 194:case 135:return qi(n,new Error("Unsupported EC-3 in M2TS found")),a;case 36:return qi(n,new Error("Unsupported HEVC in M2TS found")),a}t+=u+5}return a}function qi(e,t,r){x.warn("parsing error: "+t.message),e.emit(_.ERROR,_.ERROR,{type:b.MEDIA_ERROR,details:E.FRAG_PARSING_ERROR,fatal:!1,levelRetry:r,error:t,reason:t.message})}function Yi(e){x.log(e+" with AES-128-CBC encryption found in unencrypted stream")}function Xi(e){var t,r,i,n,a,s=0,o=e.data;if(!e||0===e.size)return null;for(;o[0].length<19&&o.length>1;)o[0]=ke(o[0],o[1]),o.splice(1,1);if(1===((t=o[0])[0]<<16)+(t[1]<<8)+t[2]){if((r=(t[4]<<8)+t[5])&&r>e.size-6)return null;var u=t[7];192&u&&(n=536870912*(14&t[9])+4194304*(255&t[10])+16384*(254&t[11])+128*(255&t[12])+(254&t[13])/2,64&u?n-(a=536870912*(14&t[14])+4194304*(255&t[15])+16384*(254&t[16])+128*(255&t[17])+(254&t[18])/2)>54e5&&(x.warn(Math.round((n-a)/9e4)+"s delta between PTS and DTS, align them"),n=a):a=n);var l=(i=t[8])+9;if(e.size<=l)return null;e.size-=l;for(var d=new Uint8Array(e.size),h=0,c=o.length;h<c;h++){var f=(t=o[h]).byteLength;if(l){if(l>f){l-=f;continue}t=t.subarray(l),f-=l,l=0}d.set(t,s),s+=f}return r&&(r-=i+3),{data:d,pts:n,dts:a,len:r}}return null}var Qi=function(e){function t(){return e.apply(this,arguments)||this}u(t,e);var r=t.prototype;return r.resetInitSegment=function(t,r,i,n){e.prototype.resetInitSegment.call(this,t,r,i,n),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:r,duration:n,inputTimeScale:9e4,dropped:0}},t.probe=function(e){if(!e)return!1;var t=W(e,0),r=(null==t?void 0:t.length)||0;if(t&&11===e[r]&&119===e[r+1]&&void 0!==X(t)&&function(e,t){var r=0,i=5;t+=i;for(var n=new Uint32Array(1),a=new Uint32Array(1),s=new Uint8Array(1);i>0;){s[0]=e[t];var o=Math.min(i,8),u=8-o;a[0]=4278190080>>>24+u<<u,n[0]=(s[0]&a[0])>>u,r=r?r<<o|n[0]:n[0],t+=1,i-=o}return r}(e,r)<=16)return!1;for(var i=e.length;r<i;r++)if(Ii(e,r))return x.log("MPEG Audio sync word found !"),!0;return!1},r.canParse=function(e,t){return function(e,t){return Pi(e,t)&&4<=e.length-t}(e,t)},r.appendFrame=function(e,t,r){if(null!==this.basePTS)return Di(e,t,r,this.basePTS,this.frameIndex)},t}(pi),Ji=function(){function e(){}return e.getSilentFrame=function(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}},e}(),Zi=Math.pow(2,32)-1,$i=function(){function e(){}return e.init=function(){var t;for(t in e.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},e.types)e.types.hasOwnProperty(t)&&(e.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);var r=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),i=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);e.HDLR_TYPES={video:r,audio:i};var n=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),a=new Uint8Array([0,0,0,0,0,0,0,0]);e.STTS=e.STSC=e.STCO=a,e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),e.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var s=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),u=new Uint8Array([0,0,0,1]);e.FTYP=e.box(e.types.ftyp,s,u,s,o),e.DINF=e.box(e.types.dinf,e.box(e.types.dref,n))},e.box=function(e){for(var t=8,r=arguments.length,i=new Array(r>1?r-1:0),n=1;n<r;n++)i[n-1]=arguments[n];for(var a=i.length,s=a;a--;)t+=i[a].byteLength;var o=new Uint8Array(t);for(o[0]=t>>24&255,o[1]=t>>16&255,o[2]=t>>8&255,o[3]=255&t,o.set(e,4),a=0,t=8;a<s;a++)o.set(i[a],t),t+=i[a].byteLength;return o},e.hdlr=function(t){return e.box(e.types.hdlr,e.HDLR_TYPES[t])},e.mdat=function(t){return e.box(e.types.mdat,t)},e.mdhd=function(t,r){r*=t;var i=Math.floor(r/(Zi+1)),n=Math.floor(r%(Zi+1));return e.box(e.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,i>>24,i>>16&255,i>>8&255,255&i,n>>24,n>>16&255,n>>8&255,255&n,85,196,0,0]))},e.mdia=function(t){return e.box(e.types.mdia,e.mdhd(t.timescale,t.duration),e.hdlr(t.type),e.minf(t))},e.mfhd=function(t){return e.box(e.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))},e.minf=function(t){return"audio"===t.type?e.box(e.types.minf,e.box(e.types.smhd,e.SMHD),e.DINF,e.stbl(t)):e.box(e.types.minf,e.box(e.types.vmhd,e.VMHD),e.DINF,e.stbl(t))},e.moof=function(t,r,i){return e.box(e.types.moof,e.mfhd(t),e.traf(i,r))},e.moov=function(t){for(var r=t.length,i=[];r--;)i[r]=e.trak(t[r]);return e.box.apply(null,[e.types.moov,e.mvhd(t[0].timescale,t[0].duration)].concat(i).concat(e.mvex(t)))},e.mvex=function(t){for(var r=t.length,i=[];r--;)i[r]=e.trex(t[r]);return e.box.apply(null,[e.types.mvex].concat(i))},e.mvhd=function(t,r){r*=t;var i=Math.floor(r/(Zi+1)),n=Math.floor(r%(Zi+1)),a=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,i>>24,i>>16&255,i>>8&255,255&i,n>>24,n>>16&255,n>>8&255,255&n,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return e.box(e.types.mvhd,a)},e.sdtp=function(t){var r,i,n=t.samples||[],a=new Uint8Array(4+n.length);for(r=0;r<n.length;r++)i=n[r].flags,a[r+4]=i.dependsOn<<4|i.isDependedOn<<2|i.hasRedundancy;return e.box(e.types.sdtp,a)},e.stbl=function(t){return e.box(e.types.stbl,e.stsd(t),e.box(e.types.stts,e.STTS),e.box(e.types.stsc,e.STSC),e.box(e.types.stsz,e.STSZ),e.box(e.types.stco,e.STCO))},e.avc1=function(t){var r,i,n,a=[],s=[];for(r=0;r<t.sps.length;r++)n=(i=t.sps[r]).byteLength,a.push(n>>>8&255),a.push(255&n),a=a.concat(Array.prototype.slice.call(i));for(r=0;r<t.pps.length;r++)n=(i=t.pps[r]).byteLength,s.push(n>>>8&255),s.push(255&n),s=s.concat(Array.prototype.slice.call(i));var o=e.box(e.types.avcC,new Uint8Array([1,a[3],a[4],a[5],255,224|t.sps.length].concat(a).concat([t.pps.length]).concat(s))),u=t.width,l=t.height,d=t.pixelRatio[0],h=t.pixelRatio[1];return e.box(e.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,u>>8&255,255&u,l>>8&255,255&l,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),e.box(e.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,255&d,h>>24,h>>16&255,h>>8&255,255&h])))},e.esds=function(e){var t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))},e.audioStsd=function(e){var t=e.samplerate;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,255&t,0,0])},e.mp4a=function(t){return e.box(e.types.mp4a,e.audioStsd(t),e.box(e.types.esds,e.esds(t)))},e.mp3=function(t){return e.box(e.types[".mp3"],e.audioStsd(t))},e.ac3=function(t){return e.box(e.types["ac-3"],e.audioStsd(t),e.box(e.types.dac3,t.config))},e.stsd=function(t){return"audio"===t.type?"mp3"===t.segmentCodec&&"mp3"===t.codec?e.box(e.types.stsd,e.STSD,e.mp3(t)):"ac3"===t.segmentCodec?e.box(e.types.stsd,e.STSD,e.ac3(t)):e.box(e.types.stsd,e.STSD,e.mp4a(t)):e.box(e.types.stsd,e.STSD,e.avc1(t))},e.tkhd=function(t){var r=t.id,i=t.duration*t.timescale,n=t.width,a=t.height,s=Math.floor(i/(Zi+1)),o=Math.floor(i%(Zi+1));return e.box(e.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,o>>24,o>>16&255,o>>8&255,255&o,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,n>>8&255,255&n,0,0,a>>8&255,255&a,0,0]))},e.traf=function(t,r){var i=e.sdtp(t),n=t.id,a=Math.floor(r/(Zi+1)),s=Math.floor(r%(Zi+1));return e.box(e.types.traf,e.box(e.types.tfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,255&n])),e.box(e.types.tfdt,new Uint8Array([1,0,0,0,a>>24,a>>16&255,a>>8&255,255&a,s>>24,s>>16&255,s>>8&255,255&s])),e.trun(t,i.length+16+20+8+16+8+8),i)},e.trak=function(t){return t.duration=t.duration||4294967295,e.box(e.types.trak,e.tkhd(t),e.mdia(t))},e.trex=function(t){var r=t.id;return e.box(e.types.trex,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},e.trun=function(t,r){var i,n,a,s,o,u,l=t.samples||[],d=l.length,h=12+16*d,c=new Uint8Array(h);for(r+=8+h,c.set(["video"===t.type?1:0,0,15,1,d>>>24&255,d>>>16&255,d>>>8&255,255&d,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0),i=0;i<d;i++)a=(n=l[i]).duration,s=n.size,o=n.flags,u=n.cts,c.set([a>>>24&255,a>>>16&255,a>>>8&255,255&a,s>>>24&255,s>>>16&255,s>>>8&255,255&s,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,61440&o.degradPrio,15&o.degradPrio,u>>>24&255,u>>>16&255,u>>>8&255,255&u],12+16*i);return e.box(e.types.trun,c)},e.initSegment=function(t){e.types||e.init();var r=e.moov(t);return ke(e.FTYP,r)},e}();$i.types=void 0,$i.HDLR_TYPES=void 0,$i.STTS=void 0,$i.STSC=void 0,$i.STCO=void 0,$i.STSZ=void 0,$i.VMHD=void 0,$i.SMHD=void 0,$i.STSD=void 0,$i.FTYP=void 0,$i.DINF=void 0;function en(e,t){return void 0===t&&(t=!1),function(e,t,r,i){void 0===r&&(r=1),void 0===i&&(i=!1);var n=e*t*r;return i?Math.round(n):n}(e,1e3,1/9e4,t)}var tn=null,rn=null,nn=function(){function e(e,t,r,i){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=e,this.config=t,this.typeSupported=r,this.ISGenerated=!1,null===tn){var n=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);tn=n?parseInt(n[1]):0}if(null===rn){var a=navigator.userAgent.match(/Safari\/(\d+)/i);rn=a?parseInt(a[1]):0}}var t=e.prototype;return t.destroy=function(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null},t.resetTimeStamp=function(e){x.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e},t.resetNextTimestamp=function(){x.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},t.resetInitSegment=function(){x.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0},t.getVideoStartPts=function(e){var t=!1,r=e.reduce((function(e,r){var i=r.pts-e;return i<-4294967296?(t=!0,an(e,r.pts)):i>0?e:r.pts}),e[0].pts);return t&&x.debug("PTS rollover detected"),r},t.remux=function(e,t,r,i,n,a,s,o){var u,l,d,h,c,f,v=n,p=n,g=e.pid>-1,m=t.pid>-1,y=t.samples.length,_=e.samples.length>0,b=s&&y>0||y>1;if((!g||_)&&(!m||b)||this.ISGenerated||s){if(this.ISGenerated){var E,T,S,L,k=this.videoTrackConfig;!k||t.width===k.width&&t.height===k.height&&(null==(E=t.pixelRatio)?void 0:E[0])===(null==(T=k.pixelRatio)?void 0:T[0])&&(null==(S=t.pixelRatio)?void 0:S[1])===(null==(L=k.pixelRatio)?void 0:L[1])||this.resetInitSegment()}else d=this.generateIS(e,t,n,a);var w,A=this.isVideoContiguous,R=-1;if(b&&(R=function(e){for(var t=0;t<e.length;t++)if(e[t].key)return t;return-1}(t.samples),!A&&this.config.forceKeyFrameOnDiscontinuity))if(f=!0,R>0){x.warn("[mp4-remuxer]: Dropped "+R+" out of "+y+" video samples due to a missing keyframe");var D=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(R),t.dropped+=R,w=p+=(t.samples[0].pts-D)/t.inputTimeScale}else-1===R&&(x.warn("[mp4-remuxer]: No keyframe found out of "+y+" video samples"),f=!1);if(this.ISGenerated){if(_&&b){var C=this.getVideoStartPts(t.samples),P=(an(e.samples[0].pts,C)-C)/t.inputTimeScale;v+=Math.max(0,P),p+=Math.max(0,-P)}if(_){if(e.samplerate||(x.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),d=this.generateIS(e,t,n,a)),l=this.remuxAudio(e,v,this.isAudioContiguous,a,m||b||o===st?p:void 0),b){var O=l?l.endPTS-l.startPTS:0;t.inputTimeScale||(x.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),d=this.generateIS(e,t,n,a)),u=this.remuxVideo(t,p,A,O)}}else b&&(u=this.remuxVideo(t,p,A,0));u&&(u.firstKeyFrame=R,u.independent=-1!==R,u.firstKeyFramePTS=w)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(c=sn(r,n,this._initPTS,this._initDTS)),i.samples.length&&(h=on(i,n,this._initPTS))),{audio:l,video:u,initSegment:d,independent:f,text:h,id3:c}},t.generateIS=function(e,t,r,i){var n,a,s,o=e.samples,u=t.samples,l=this.typeSupported,d={},h=this._initPTS,c=!h||i,f="audio/mp4";if(c&&(n=a=1/0),e.config&&o.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":l.mpeg?(f="audio/mpeg",e.codec=""):l.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3"}d.audio={id:"audio",container:f,codec:e.codec,initSegment:"mp3"===e.segmentCodec&&l.mpeg?new Uint8Array(0):$i.initSegment([e]),metadata:{channelCount:e.channelCount}},c&&(s=e.inputTimeScale,h&&s===h.timescale?c=!1:n=a=o[0].pts-Math.round(s*r))}if(t.sps&&t.pps&&u.length){if(t.timescale=t.inputTimeScale,d.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:$i.initSegment([t]),metadata:{width:t.width,height:t.height}},c)if(s=t.inputTimeScale,h&&s===h.timescale)c=!1;else{var v=this.getVideoStartPts(u),p=Math.round(s*r);a=Math.min(a,an(u[0].dts,v)-p),n=Math.min(n,v-p)}this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(d).length)return this.ISGenerated=!0,c?(this._initPTS={baseTime:n,timescale:s},this._initDTS={baseTime:a,timescale:s}):n=s=void 0,{tracks:d,initPTS:n,timescale:s}},t.remuxVideo=function(e,t,r,i){var n,a,s=e.inputTimeScale,u=e.samples,l=[],d=u.length,h=this._initPTS,c=this.nextAvcDts,f=8,v=this.videoSampleDuration,p=Number.POSITIVE_INFINITY,g=Number.NEGATIVE_INFINITY,m=!1;if(!r||null===c){var y=t*s,T=u[0].pts-an(u[0].dts,u[0].pts);tn&&null!==c&&Math.abs(y-T-c)<15e3?r=!0:c=y-T}for(var S=h.baseTime*s/h.timescale,L=0;L<d;L++){var k=u[L];k.pts=an(k.pts-S,c),k.dts=an(k.dts-S,c),k.dts<u[L>0?L-1:L].dts&&(m=!0)}m&&u.sort((function(e,t){var r=e.dts-t.dts,i=e.pts-t.pts;return r||i})),n=u[0].dts;var w=u[u.length-1].dts-n,A=w?Math.round(w/(d-1)):v||e.inputTimeScale/30;if(r){var R=n-c,D=R>A,C=R<-1;if((D||C)&&(D?x.warn("AVC: "+en(R,!0)+" ms ("+R+"dts) hole between fragments detected at "+t.toFixed(3)):x.warn("AVC: "+en(-R,!0)+" ms ("+R+"dts) overlapping between fragments detected at "+t.toFixed(3)),!C||c>=u[0].pts||tn)){n=c;var P=u[0].pts-R;if(D)u[0].dts=n,u[0].pts=P;else for(var O=0;O<u.length&&!(u[O].dts>P);O++)u[O].dts-=R,u[O].pts-=R;x.log("Video: Initial PTS/DTS adjusted: "+en(P,!0)+"/"+en(n,!0)+", delta: "+en(R,!0)+" ms")}}for(var I=0,F=0,M=n=Math.max(0,n),B=0;B<d;B++){for(var N=u[B],U=N.units,G=U.length,V=0,j=0;j<G;j++)V+=U[j].data.length;F+=V,I+=G,N.length=V,N.dts<M?(N.dts=M,M+=A/4|0||1):M=N.dts,p=Math.min(N.pts,p),g=Math.max(N.pts,g)}a=u[d-1].dts;var H,K=F+4*I+8;try{H=new Uint8Array(K)}catch(e){return void this.observer.emit(_.ERROR,_.ERROR,{type:b.MUX_ERROR,details:E.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:K,reason:"fail allocating video mdat "+K})}var z=new DataView(H.buffer);z.setUint32(0,K),H.set($i.types.mdat,4);for(var W=!1,q=Number.POSITIVE_INFINITY,Y=Number.POSITIVE_INFINITY,X=Number.NEGATIVE_INFINITY,Q=Number.NEGATIVE_INFINITY,J=0;J<d;J++){for(var Z=u[J],$=Z.units,ee=0,te=0,re=$.length;te<re;te++){var ie=$[te],ne=ie.data,ae=ie.data.byteLength;z.setUint32(f,ae),f+=4,H.set(ne,f),f+=ae,ee+=4+ae}var se=void 0;if(J<d-1)v=u[J+1].dts-Z.dts,se=u[J+1].pts-Z.pts;else{var oe=this.config,ue=J>0?Z.dts-u[J-1].dts:A;if(se=J>0?Z.pts-u[J-1].pts:A,oe.stretchShortVideoTrack&&null!==this.nextAudioPts){var le=Math.floor(oe.maxBufferHole*s),de=(i?p+i*s:this.nextAudioPts)-Z.pts;de>le?((v=de-ue)<0?v=ue:W=!0,x.log("[mp4-remuxer]: It is approximately "+de/90+" ms to the next segment; using duration "+v/90+" ms for the last video frame.")):v=ue}else v=ue}var he=Math.round(Z.pts-Z.dts);q=Math.min(q,v),X=Math.max(X,v),Y=Math.min(Y,se),Q=Math.max(Q,se),l.push(new un(Z.key,v,ee,he))}if(l.length)if(tn){if(tn<70){var ce=l[0].flags;ce.dependsOn=2,ce.isNonSync=0}}else if(rn&&Q-Y<X-q&&A/X<.025&&0===l[0].cts){x.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var fe=n,ve=0,pe=l.length;ve<pe;ve++){var ge=fe+l[ve].duration,me=fe+l[ve].cts;if(ve<pe-1){var ye=ge+l[ve+1].cts;l[ve].duration=ye-me}else l[ve].duration=ve?l[ve-1].duration:A;l[ve].cts=0,fe=ge}}v=W||!v?A:v,this.nextAvcDts=c=a+v,this.videoSampleDuration=v,this.isVideoContiguous=!0;var _e={data1:$i.moof(e.sequenceNumber++,n,o({},e,{samples:l})),data2:H,startPTS:p/s,endPTS:(g+v)/s,startDTS:n/s,endDTS:c/s,type:"video",hasAudio:!1,hasVideo:!0,nb:l.length,dropped:e.dropped};return e.samples=[],e.dropped=0,_e},t.getSamplesPerFrame=function(e){switch(e.segmentCodec){case"mp3":return 1152;case"ac3":return 1536;default:return 1024}},t.remuxAudio=function(e,t,r,i,n){var a=e.inputTimeScale,s=a/(e.samplerate?e.samplerate:a),u=this.getSamplesPerFrame(e),l=u*s,d=this._initPTS,h="mp3"===e.segmentCodec&&this.typeSupported.mpeg,c=[],f=void 0!==n,v=e.samples,p=h?0:8,g=this.nextAudioPts||-1,m=t*a,y=d.baseTime*a/d.timescale;if(this.isAudioContiguous=r=r||v.length&&g>0&&(i&&Math.abs(m-g)<9e3||Math.abs(an(v[0].pts-y,m)-g)<20*l),v.forEach((function(e){e.pts=an(e.pts-y,m)})),!r||g<0){if(v=v.filter((function(e){return e.pts>=0})),!v.length)return;g=0===n?0:i&&!f?Math.max(0,m):v[0].pts}if("aac"===e.segmentCodec)for(var T=this.config.maxAudioFramesDrift,S=0,L=g;S<v.length;S++){var k=v[S],w=k.pts,A=w-L,R=Math.abs(1e3*A/a);if(A<=-T*l&&f)0===S&&(x.warn("Audio frame @ "+(w/a).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*A/a)+" ms."),this.nextAudioPts=g=L=w);else if(A>=T*l&&R<1e4&&f){var D=Math.round(A/l);(L=w-D*l)<0&&(D--,L+=l),0===S&&(this.nextAudioPts=g=L),x.warn("[mp4-remuxer]: Injecting "+D+" audio frame @ "+(L/a).toFixed(3)+"s due to "+Math.round(1e3*A/a)+" ms gap.");for(var C=0;C<D;C++){var P=Math.max(L,0),O=Ji.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);O||(x.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),O=k.unit.subarray()),v.splice(S,0,{unit:O,pts:P}),L+=l,S++}}k.pts=L,L+=l}for(var I,F=null,M=null,B=0,N=v.length;N--;)B+=v[N].unit.byteLength;for(var U=0,G=v.length;U<G;U++){var V=v[U],j=V.unit,H=V.pts;if(null!==M)c[U-1].duration=Math.round((H-M)/s);else{if(r&&"aac"===e.segmentCodec&&(H=g),F=H,!(B>0))return;B+=p;try{I=new Uint8Array(B)}catch(e){return void this.observer.emit(_.ERROR,_.ERROR,{type:b.MUX_ERROR,details:E.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:B,reason:"fail allocating audio mdat "+B})}h||(new DataView(I.buffer).setUint32(0,B),I.set($i.types.mdat,4))}I.set(j,p);var K=j.byteLength;p+=K,c.push(new un(!0,u,K,0)),M=H}var z=c.length;if(z){var W=c[c.length-1];this.nextAudioPts=g=M+s*W.duration;var q=h?new Uint8Array(0):$i.moof(e.sequenceNumber++,F/s,o({},e,{samples:c}));e.samples=[];var Y=F/a,X=g/a,Q={data1:q,data2:I,startPTS:Y,endPTS:X,startDTS:Y,endDTS:X,type:"audio",hasAudio:!0,hasVideo:!1,nb:z};return this.isAudioContiguous=!0,Q}},t.remuxEmptyAudio=function(e,t,r,i){var n=e.inputTimeScale,a=n/(e.samplerate?e.samplerate:n),s=this.nextAudioPts,o=this._initDTS,u=9e4*o.baseTime/o.timescale,l=(null!==s?s:i.startDTS*n)+u,d=i.endDTS*n+u,h=1024*a,c=Math.ceil((d-l)/h),f=Ji.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(x.warn("[mp4-remuxer]: remux empty Audio"),f){for(var v=[],p=0;p<c;p++){var g=l+p*h;v.push({unit:f,pts:g,dts:g})}return e.samples=v,this.remuxAudio(e,t,r,!1)}x.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec")},e}();function an(e,t){var r;if(null===t)return e;for(r=t<e?-8589934592:8589934592;Math.abs(e-t)>4294967296;)e+=r;return e}function sn(e,t,r,i){var n=e.samples.length;if(n){for(var a=e.inputTimeScale,s=0;s<n;s++){var o=e.samples[s];o.pts=an(o.pts-r.baseTime*a/r.timescale,t*a)/a,o.dts=an(o.dts-i.baseTime*a/i.timescale,t*a)/a}var u=e.samples;return e.samples=[],{samples:u}}}function on(e,t,r){var i=e.samples.length;if(i){for(var n=e.inputTimeScale,a=0;a<i;a++){var s=e.samples[a];s.pts=an(s.pts-r.baseTime*n/r.timescale,t*n)/n}e.samples.sort((function(e,t){return e.pts-t.pts}));var o=e.samples;return e.samples=[],{samples:o}}}var un=function(e,t,r,i){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=r,this.cts=i,this.flags={isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:e?2:1,isNonSync:e?0:1}},ln=function(){function e(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}var t=e.prototype;return t.destroy=function(){},t.resetTimeStamp=function(e){this.initPTS=e,this.lastEndTime=null},t.resetNextTimestamp=function(){this.lastEndTime=null},t.resetInitSegment=function(e,t,r,i){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(Se(e,i)),this.emitInitSegment=!0},t.generateInitSegment=function(e){var t=this.audioCodec,r=this.videoCodec;if(null==e||!e.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var i=this.initData=ye(e);i.audio&&(t=dn(i.audio,I)),i.video&&(r=dn(i.video,F));var n={};i.audio&&i.video?n.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:e,id:"main"}:i.audio?n.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:i.video?n.video={container:"video/mp4",codec:r,initSegment:e,id:"main"}:x.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=n},t.remux=function(e,t,r,i,n,a){var s,o,u=this.initPTS,l=this.lastEndTime,d={audio:void 0,video:void 0,text:i,id3:r,initSegment:void 0};g(l)||(l=this.lastEndTime=n||0);var h=t.samples;if(null==h||!h.length)return d;var c={initPTS:void 0,timescale:1},f=this.initData;if(null!=(s=f)&&s.length||(this.generateInitSegment(h),f=this.initData),null==(o=f)||!o.length)return x.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),d;this.emitInitSegment&&(c.tracks=this.initTracks,this.emitInitSegment=!1);var v=function(e,t){for(var r=0,i=0,n=0,a=ge(e,["moof","traf"]),s=0;s<a.length;s++){var o=a[s],u=ge(o,["tfhd"])[0],l=t[ce(u,4)];if(l){var d=l.default,h=ce(u,0)|(null==d?void 0:d.flags),c=null==d?void 0:d.duration;8&h&&(c=ce(u,2&h?12:8));for(var f=l.timescale||9e4,v=ge(o,["trun"]),p=0;p<v.length;p++)!(r=Le(v[p]))&&c&&(r=c*ce(v[p],4)),l.type===F?i+=r/f:l.type===I&&(n+=r/f)}}if(0===i&&0===n){for(var m=1/0,y=0,_=0,b=ge(e,["sidx"]),E=0;E<b.length;E++){var T=me(b[E]);if(null!=T&&T.references){m=Math.min(m,T.earliestPresentationTime/T.timescale);var S=T.references.reduce((function(e,t){return e+t.info.duration||0}),0);_=(y=Math.max(y,S+T.earliestPresentationTime/T.timescale))-m}}if(_&&g(_))return _}return i||n}(h,f),p=function(e,t){return ge(t,["moof","traf"]).reduce((function(t,r){var i=ge(r,["tfdt"])[0],n=i[0],a=ge(r,["tfhd"]).reduce((function(t,r){var a=ce(r,4),s=e[a];if(s){var o=ce(i,4);if(1===n){if(o===oe)return x.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),t;o*=oe+1,o+=ce(i,8)}var u=o/(s.timescale||9e4);if(g(u)&&(null===t||u<t))return u}return t}),null);return null!==a&&g(a)&&(null===t||a<t)?a:t}),null)}(f,h),m=null===p?n:p;(function(e,t,r,i){if(null===e)return!0;var n=Math.max(i,1),a=t-e.baseTime/e.timescale;return Math.abs(a-r)>n}(u,m,n,v)||c.timescale!==u.timescale&&a)&&(c.initPTS=m-n,u&&1===u.timescale&&x.warn("Adjusting initPTS by "+(c.initPTS-u.baseTime)),this.initPTS=u={baseTime:c.initPTS,timescale:1});var y=e?m-u.baseTime/u.timescale:l,_=y+v;(function(e,t,r){ge(t,["moof","traf"]).forEach((function(t){ge(t,["tfhd"]).forEach((function(i){var n=ce(i,4),a=e[n];if(a){var s=a.timescale||9e4;ge(t,["tfdt"]).forEach((function(e){var t=e[0],i=r*s;if(i){var n=ce(e,4);if(0===t)n-=i,pe(e,4,n=Math.max(n,0));else{n*=Math.pow(2,32),n+=ce(e,8),n-=i,n=Math.max(n,0);var a=Math.floor(n/(oe+1)),o=Math.floor(n%(oe+1));pe(e,4,a),pe(e,8,o)}}}))}}))}))})(f,h,u.baseTime/u.timescale),v>0?this.lastEndTime=_:(x.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var b=!!f.audio,E=!!f.video,T="";b&&(T+="audio"),E&&(T+="video");var S={data1:h,startPTS:y,startDTS:y,endPTS:_,endDTS:_,type:T,hasAudio:b,hasVideo:E,nb:1,dropped:0};return d.audio="audio"===S.type?S:void 0,d.video="audio"!==S.type?S:void 0,d.initSegment=c,d.id3=sn(r,n,u,u),i.samples.length&&(d.text=on(i,n,u)),d},e}();function dn(e,t){var r=null==e?void 0:e.codec;if(r&&r.length>4)return r;if(t===I){if("ec-3"===r||"ac-3"===r||"alac"===r)return r;if("fLaC"===r||"Opus"===r)return Ge(r,!1);var i="mp4a.40.5";return x.info('Parsed audio codec "'+r+'" or audio object type not handled. Using "'+i+'"'),i}return x.warn('Unhandled video codec "'+r+'"'),"hvc1"===r||"hev1"===r?"hvc1.1.6.L120.90":"av01"===r?"av01.0.04M.08":"avc1.42e01e"}var hn,cn="undefined"!=typeof self?self:void 0;try{hn=self.performance.now.bind(self.performance)}catch(e){x.debug("Unable to use Performance API on this environment"),hn=null==cn?void 0:cn.Date.now}var fn=[{demux:Bi,remux:ln},{demux:Hi,remux:nn},{demux:Fi,remux:nn},{demux:Qi,remux:nn}],vn=function(){function e(e,t,r,i,n){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=r,this.vendor=i,this.id=n}var t=e.prototype;return t.configure=function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()},t.push=function(e,t,r,i){var n=this,a=r.transmuxing;a.executeStart=hn();var s=new Uint8Array(e),o=this.currentTransmuxState,u=this.transmuxConfig;i&&(this.currentTransmuxState=i);var l=i||o,d=l.contiguous,h=l.discontinuity,c=l.trackSwitch,f=l.accurateTimeOffset,v=l.timeOffset,p=l.initSegmentChange,g=u.audioCodec,m=u.videoCodec,y=u.defaultInitPts,T=u.duration,S=u.initSegmentData,L=function(e,t){var r=null;return e.byteLength>0&&null!=(null==t?void 0:t.key)&&null!==t.iv&&null!=t.method&&(r=t),r}(s,t);if(L&&"AES-128"===L.method){var k=this.getDecrypter();if(!k.isSync())return this.decryptionPromise=k.webCryptoDecrypt(s,L.key.buffer,L.iv.buffer).then((function(e){var t=n.push(e,null,r);return n.decryptionPromise=null,t})),this.decryptionPromise;var w=k.softwareDecrypt(s,L.key.buffer,L.iv.buffer);if(r.part>-1&&(w=k.flush()),!w)return a.executeEnd=hn(),pn(r);s=new Uint8Array(w)}var A=this.needsProbing(h,c);if(A){var R=this.configureTransmuxer(s);if(R)return x.warn("[transmuxer] "+R.message),this.observer.emit(_.ERROR,_.ERROR,{type:b.MEDIA_ERROR,details:E.FRAG_PARSING_ERROR,fatal:!1,error:R,reason:R.message}),a.executeEnd=hn(),pn(r)}(h||c||p||A)&&this.resetInitSegment(S,g,m,T,t),(h||p||A)&&this.resetInitialTimestamp(y),d||this.resetContiguity();var D=this.transmux(s,L,v,f,r),C=this.currentTransmuxState;return C.contiguous=!0,C.discontinuity=!1,C.trackSwitch=!1,a.executeEnd=hn(),D},t.flush=function(e){var t=this,r=e.transmuxing;r.executeStart=hn();var i=this.decrypter,n=this.currentTransmuxState,a=this.decryptionPromise;if(a)return a.then((function(){return t.flush(e)}));var s=[],o=n.timeOffset;if(i){var u=i.flush();u&&s.push(this.push(u,null,e))}var l=this.demuxer,d=this.remuxer;if(!l||!d)return r.executeEnd=hn(),[pn(e)];var h=l.flush(o);return gn(h)?h.then((function(r){return t.flushRemux(s,r,e),s})):(this.flushRemux(s,h,e),s)},t.flushRemux=function(e,t,r){var i=t.audioTrack,n=t.videoTrack,a=t.id3Track,s=t.textTrack,o=this.currentTransmuxState,u=o.accurateTimeOffset,l=o.timeOffset;x.log("[transmuxer.ts]: Flushed fragment "+r.sn+(r.part>-1?" p: "+r.part:"")+" of level "+r.level);var d=this.remuxer.remux(i,n,a,s,l,u,!0,this.id);e.push({remuxResult:d,chunkMeta:r}),r.transmuxing.executeEnd=hn()},t.resetInitialTimestamp=function(e){var t=this.demuxer,r=this.remuxer;t&&r&&(t.resetTimeStamp(e),r.resetTimeStamp(e))},t.resetContiguity=function(){var e=this.demuxer,t=this.remuxer;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())},t.resetInitSegment=function(e,t,r,i,n){var a=this.demuxer,s=this.remuxer;a&&s&&(a.resetInitSegment(e,t,r,i),s.resetInitSegment(e,t,r,n))},t.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},t.transmux=function(e,t,r,i,n){return t&&"SAMPLE-AES"===t.method?this.transmuxSampleAes(e,t,r,i,n):this.transmuxUnencrypted(e,r,i,n)},t.transmuxUnencrypted=function(e,t,r,i){var n=this.demuxer.demux(e,t,!1,!this.config.progressive),a=n.audioTrack,s=n.videoTrack,o=n.id3Track,u=n.textTrack;return{remuxResult:this.remuxer.remux(a,s,o,u,t,r,!1,this.id),chunkMeta:i}},t.transmuxSampleAes=function(e,t,r,i,n){var a=this;return this.demuxer.demuxSampleAes(e,t,r).then((function(e){return{remuxResult:a.remuxer.remux(e.audioTrack,e.videoTrack,e.id3Track,e.textTrack,r,i,!1,a.id),chunkMeta:n}}))},t.configureTransmuxer=function(e){for(var t,r=this.config,i=this.observer,n=this.typeSupported,a=this.vendor,s=0,o=fn.length;s<o;s++){var u;if(null!=(u=fn[s].demux)&&u.probe(e)){t=fn[s];break}}if(!t)return new Error("Failed to find demuxer by probing fragment data");var l=this.demuxer,d=this.remuxer,h=t.remux,c=t.demux;d&&d instanceof h||(this.remuxer=new h(i,r,n,a)),l&&l instanceof c||(this.demuxer=new c(i,r,n),this.probe=c.probe)},t.needsProbing=function(e,t){return!this.demuxer||!this.remuxer||e||t},t.getDecrypter=function(){var e=this.decrypter;return e||(e=this.decrypter=new $r(this.config)),e},e}();var pn=function(e){return{remuxResult:{},chunkMeta:e}};function gn(e){return"then"in e&&e.then instanceof Function}var mn=function(e,t,r,i,n){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=r,this.duration=i,this.defaultInitPts=n||null},yn=function(e,t,r,i,n,a){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=e,this.contiguous=t,this.accurateTimeOffset=r,this.trackSwitch=i,this.timeOffset=n,this.initSegmentChange=a},_n={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,r="~";function i(){}function n(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function a(e,t,i,a,s){if("function"!=typeof i)throw new TypeError("The listener must be a function");var o=new n(i,a||e,s),u=r?r+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],o]:e._events[u].push(o):(e._events[u]=o,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new i:delete e._events[t]}function o(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(r=!1)),o.prototype.eventNames=function(){var e,i,n=[];if(0===this._eventsCount)return n;for(i in e=this._events)t.call(e,i)&&n.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},o.prototype.listeners=function(e){var t=r?r+e:e,i=this._events[t];if(!i)return[];if(i.fn)return[i.fn];for(var n=0,a=i.length,s=new Array(a);n<a;n++)s[n]=i[n].fn;return s},o.prototype.listenerCount=function(e){var t=r?r+e:e,i=this._events[t];return i?i.fn?1:i.length:0},o.prototype.emit=function(e,t,i,n,a,s){var o=r?r+e:e;if(!this._events[o])return!1;var u,l,d=this._events[o],h=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),h){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,t),!0;case 3:return d.fn.call(d.context,t,i),!0;case 4:return d.fn.call(d.context,t,i,n),!0;case 5:return d.fn.call(d.context,t,i,n,a),!0;case 6:return d.fn.call(d.context,t,i,n,a,s),!0}for(l=1,u=new Array(h-1);l<h;l++)u[l-1]=arguments[l];d.fn.apply(d.context,u)}else{var c,f=d.length;for(l=0;l<f;l++)switch(d[l].once&&this.removeListener(e,d[l].fn,void 0,!0),h){case 1:d[l].fn.call(d[l].context);break;case 2:d[l].fn.call(d[l].context,t);break;case 3:d[l].fn.call(d[l].context,t,i);break;case 4:d[l].fn.call(d[l].context,t,i,n);break;default:if(!u)for(c=1,u=new Array(h-1);c<h;c++)u[c-1]=arguments[c];d[l].fn.apply(d[l].context,u)}}return!0},o.prototype.on=function(e,t,r){return a(this,e,t,r,!1)},o.prototype.once=function(e,t,r){return a(this,e,t,r,!0)},o.prototype.removeListener=function(e,t,i,n){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn!==t||n&&!o.once||i&&o.context!==i||s(this,a);else{for(var u=0,l=[],d=o.length;u<d;u++)(o[u].fn!==t||n&&!o[u].once||i&&o[u].context!==i)&&l.push(o[u]);l.length?this._events[a]=1===l.length?l[0]:l:s(this,a)}return this},o.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=r,o.EventEmitter=o,e.exports=o}(_n);var bn=f(_n.exports);function En(e,t){if(!((r=t.remuxResult).audio||r.video||r.text||r.id3||r.initSegment))return!1;var r,i=[],n=t.remuxResult,a=n.audio,s=n.video;return a&&Tn(i,a),s&&Tn(i,s),e.postMessage({event:"transmuxComplete",data:t},i),!0}function Tn(e,t){t.data1&&e.push(t.data1.buffer),t.data2&&e.push(t.data2.buffer)}function Sn(e,t,r){t.reduce((function(t,r){return En(e,r)||t}),!1)||e.postMessage({event:"transmuxComplete",data:t[0]}),e.postMessage({event:"flush",data:r})}void 0!==r&&r&&function(e){var t=new bn,r=function(t,r){e.postMessage({event:t,data:r})};t.on(_.FRAG_DECRYPTED,r),t.on(_.ERROR,r),e.addEventListener("message",(function(i){var n=i.data;switch(n.cmd){case"init":var a=JSON.parse(n.config);e.transmuxer=new vn(t,n.typeSupported,a,"",n.id),w(a.debug,n.id),function(){var e=function(e){x[e]=function(t){r("workerLog",{logType:e,message:t})}};for(var t in x)e(t)}(),r("init",null);break;case"configure":e.transmuxer.configure(n.config);break;case"demux":var s=e.transmuxer.push(n.data,n.decryptdata,n.chunkMeta,n.state);gn(s)?(e.transmuxer.async=!0,s.then((function(t){En(e,t)})).catch((function(e){r(_.ERROR,{type:b.MEDIA_ERROR,details:E.FRAG_PARSING_ERROR,chunkMeta:n.chunkMeta,fatal:!1,error:e,err:e,reason:"transmuxer-worker push error"})}))):(e.transmuxer.async=!1,En(e,s));break;case"flush":var o=n.chunkMeta,u=e.transmuxer.flush(o);gn(u)||e.transmuxer.async?(gn(u)||(u=Promise.resolve(u)),u.then((function(t){Sn(e,t,o)})).catch((function(e){r(_.ERROR,{type:b.MEDIA_ERROR,details:E.FRAG_PARSING_ERROR,chunkMeta:n.chunkMeta,fatal:!1,error:e,err:e,reason:"transmuxer-worker flush error"})}))):Sn(e,u,o)}}))}(self);var Ln=function(){function e(e,r,i,n){var a=this;this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;var s=e.config;this.hls=e,this.id=r,this.useWorker=!!s.enableWorker,this.onTransmuxComplete=i,this.onFlush=n;var o=function(e,t){(t=t||{}).frag=a.frag,t.id=a.id,e===_.ERROR&&(a.error=t.error),a.hls.trigger(e,t)};this.observer=new bn,this.observer.on(_.FRAG_DECRYPTED,o),this.observer.on(_.ERROR,o);var u,l,d,h,c=Ce(s.preferManagedMediaSource)||{isTypeSupported:function(){return!1}},f={mpeg:c.isTypeSupported("audio/mpeg"),mp3:c.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:!1};if(this.useWorker&&"undefined"!=typeof Worker&&(s.workerPath,1))try{s.workerPath?(x.log("loading Web Worker "+s.workerPath+' for "'+r+'"'),this.workerContext=(d=s.workerPath,h=new self.URL(d,self.location.href).href,{worker:new self.Worker(h),scriptURL:h})):(x.log('injecting Web Worker for "'+r+'"'),this.workerContext=(u=new self.Blob(["var exports={};var module={exports:exports};function define(f){f()};define.amd=true;("+t.toString()+")(true);"],{type:"text/javascript"}),l=self.URL.createObjectURL(u),{worker:new self.Worker(l),objectURL:l})),this.onwmsg=function(e){return a.onWorkerMessage(e)};var v=this.workerContext.worker;v.addEventListener("message",this.onwmsg),v.onerror=function(e){var t=new Error(e.message+" ("+e.filename+":"+e.lineno+")");s.enableWorker=!1,x.warn('Error in "'+r+'" Web Worker, fallback to inline'),a.hls.trigger(_.ERROR,{type:b.OTHER_ERROR,details:E.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:t})},v.postMessage({cmd:"init",typeSupported:f,vendor:"",id:r,config:JSON.stringify(s)})}catch(e){x.warn('Error setting up "'+r+'" Web Worker, fallback to inline',e),this.resetWorker(),this.error=null,this.transmuxer=new vn(this.observer,f,s,"",r)}else this.transmuxer=new vn(this.observer,f,s,"",r)}var r=e.prototype;return r.resetWorker=function(){if(this.workerContext){var e=this.workerContext,t=e.worker,r=e.objectURL;r&&self.URL.revokeObjectURL(r),t.removeEventListener("message",this.onwmsg),t.onerror=null,t.terminate(),this.workerContext=null}},r.destroy=function(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{var e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}var t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},r.push=function(e,t,r,i,n,a,s,o,u,l){var d,h,c=this;u.transmuxing.start=self.performance.now();var f=this.transmuxer,v=a?a.start:n.start,p=n.decryptdata,g=this.frag,m=!(g&&n.cc===g.cc),y=!(g&&u.level===g.level),_=g?u.sn-g.sn:-1,b=this.part?u.part-this.part.index:-1,E=0===_&&u.id>1&&u.id===(null==g?void 0:g.stats.chunkCount),T=!y&&(1===_||0===_&&(1===b||E&&b<=0)),S=self.performance.now();(y||_||0===n.stats.parsing.start)&&(n.stats.parsing.start=S),!a||!b&&T||(a.stats.parsing.start=S);var L=!(g&&(null==(d=n.initSegment)?void 0:d.url)===(null==(h=g.initSegment)?void 0:h.url)),k=new yn(m,T,o,y,v,L);if(!T||m||L){x.log("[transmuxer-interface, "+n.type+"]: Starting new transmux session for sn: "+u.sn+" p: "+u.part+" level: "+u.level+" id: "+u.id+"\n discontinuity: "+m+"\n trackSwitch: "+y+"\n contiguous: "+T+"\n accurateTimeOffset: "+o+"\n timeOffset: "+v+"\n initSegmentChange: "+L);var w=new mn(r,i,t,s,l);this.configureTransmuxer(w)}if(this.frag=n,this.part=a,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:p,chunkMeta:u,state:k},e instanceof ArrayBuffer?[e]:[]);else if(f){var A=f.push(e,p,u,k);gn(A)?(f.async=!0,A.then((function(e){c.handleTransmuxComplete(e)})).catch((function(e){c.transmuxerError(e,u,"transmuxer-interface push error")}))):(f.async=!1,this.handleTransmuxComplete(A))}},r.flush=function(e){var t=this;e.transmuxing.start=self.performance.now();var r=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(r){var i=r.flush(e);gn(i)||r.async?(gn(i)||(i=Promise.resolve(i)),i.then((function(r){t.handleFlushResult(r,e)})).catch((function(r){t.transmuxerError(r,e,"transmuxer-interface flush error")}))):this.handleFlushResult(i,e)}},r.transmuxerError=function(e,t,r){this.hls&&(this.error=e,this.hls.trigger(_.ERROR,{type:b.MEDIA_ERROR,details:E.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,fatal:!1,error:e,err:e,reason:r}))},r.handleFlushResult=function(e,t){var r=this;e.forEach((function(e){r.handleTransmuxComplete(e)})),this.onFlush(t)},r.onWorkerMessage=function(e){var t=e.data;if(null!=t&&t.event){var r=this.hls;if(this.hls)switch(t.event){case"init":var i,n=null==(i=this.workerContext)?void 0:i.objectURL;n&&self.URL.revokeObjectURL(n);break;case"transmuxComplete":this.handleTransmuxComplete(t.data);break;case"flush":this.onFlush(t.data);break;case"workerLog":x[t.data.logType]&&x[t.data.logType](t.data.message);break;default:t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,r.trigger(t.event,t.data)}}else x.warn("worker message received with no "+(t?"event name":"data"))},r.configureTransmuxer=function(e){var t=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)},r.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},e}(),kn=function(){function e(e,t,r,i){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=e,this.media=t,this.fragmentTracker=r,this.hls=i}var t=e.prototype;return t.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},t.poll=function(e,t){var r=this.config,i=this.media,n=this.stalled;if(null!==i){var a=i.currentTime,s=i.seeking,o=this.seeking&&!s,u=!this.seeking&&s;if(this.seeking=s,a===e)if(u||o)this.stalled=null;else if(i.paused&&!s||i.ended||0===i.playbackRate||!ur.getBuffered(i).length)this.nudgeRetry=0;else{var l=ur.bufferInfo(i,a,0),d=l.nextStart||0;if(s){var h=l.len>2,c=!d||t&&t.start<=a||d-a>2&&!this.fragmentTracker.getPartialFragment(a);if(h||c)return;this.moved=!1}if(!this.moved&&null!==this.stalled){var f;if(!(l.len>0||d))return;var v=Math.max(d,l.start||0)-a,p=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,g=(null==p||null==(f=p.details)?void 0:f.live)?2*p.details.targetduration:2,m=this.fragmentTracker.getPartialFragment(a);if(v>0&&(v<=g||m))return void(i.paused||this._trySkipBufferHole(m))}var y=self.performance.now();if(null!==n){var _=y-n;if(s||!(_>=250)||(this._reportStall(l),this.media)){var b=ur.bufferInfo(i,a,r.maxBufferHole);this._tryFixBufferStall(b,_)}}else this.stalled=y}else if(this.moved=!0,s||(this.nudgeRetry=0),null!==n){if(this.stallReported){var E=self.performance.now()-n;x.warn("playback not stuck anymore @"+a+", after "+Math.round(E)+"ms"),this.stallReported=!1}this.stalled=null}}},t._tryFixBufferStall=function(e,t){var r=this.config,i=this.fragmentTracker,n=this.media;if(null!==n){var a=n.currentTime,s=i.getPartialFragment(a);if(s&&(this._trySkipBufferHole(s)||!this.media))return;(e.len>r.maxBufferHole||e.nextStart&&e.nextStart-a<r.maxBufferHole)&&t>1e3*r.highBufferWatchdogPeriod&&(x.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},t._reportStall=function(e){var t=this.hls,r=this.media;if(!this.stallReported&&r){this.stallReported=!0;var i=new Error("Playback stalling at @"+r.currentTime+" due to low buffer ("+JSON.stringify(e)+")");x.warn(i.message),t.trigger(_.ERROR,{type:b.MEDIA_ERROR,details:E.BUFFER_STALLED_ERROR,fatal:!1,error:i,buffer:e.len})}},t._trySkipBufferHole=function(e){var t=this.config,r=this.hls,i=this.media;if(null===i)return 0;var n=i.currentTime,a=ur.bufferInfo(i,n,0),s=n<a.start?a.start:a.nextStart;if(s){var o=a.len<=t.maxBufferHole,u=a.len>0&&a.len<1&&i.readyState<3,l=s-n;if(l>0&&(o||u)){if(l>t.maxBufferHole){var d=this.fragmentTracker,h=!1;if(0===n){var c=d.getAppendedFrag(0,at);c&&s<c.end&&(h=!0)}if(!h){var f=e||d.getAppendedFrag(n,at);if(f){for(var v=!1,p=f.end;p<s;){var g=d.getPartialFragment(p);if(!g){v=!0;break}p+=g.duration}if(v)return 0}}}var m=Math.max(s+.05,n+.1);if(x.warn("skipping hole, adjusting currentTime from "+n+" to "+m),this.moved=!0,this.stalled=null,i.currentTime=m,e&&!e.gap){var y=new Error("fragment loaded with buffer holes, seeking from "+n+" to "+m);r.trigger(_.ERROR,{type:b.MEDIA_ERROR,details:E.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:y,reason:y.message,frag:e})}return m}}return 0},t._tryNudgeBuffer=function(){var e=this.config,t=this.hls,r=this.media,i=this.nudgeRetry;if(null!==r){var n=r.currentTime;if(this.nudgeRetry++,i<e.nudgeMaxRetry){var a=n+(i+1)*e.nudgeOffset,s=new Error("Nudging 'currentTime' from "+n+" to "+a);x.warn(s.message),r.currentTime=a,t.trigger(_.ERROR,{type:b.MEDIA_ERROR,details:E.BUFFER_NUDGE_ON_STALL,error:s,fatal:!1})}else{var o=new Error("Playhead still not moving while enough data buffered @"+n+" after "+e.nudgeMaxRetry+" nudges");x.error(o.message),t.trigger(_.ERROR,{type:b.MEDIA_ERROR,details:E.BUFFER_STALLED_ERROR,error:o,fatal:!0})}}},e}(),wn=function(e){function t(t,r,i){var n;return(n=e.call(this,t,r,i,"[stream-controller]",at)||this).audioCodecSwap=!1,n.gapController=null,n.level=-1,n._forceStartLoad=!1,n.altAudio=!1,n.audioOnly=!1,n.fragPlaying=null,n.onvplaying=null,n.onvseeked=null,n.fragLastKbps=0,n.couldBacktrack=!1,n.backtrackFragment=null,n.audioCodecSwitch=!1,n.videoBuffer=null,n._registerListeners(),n}u(t,e);var r=t.prototype;return r._registerListeners=function(){var e=this.hls;e.on(_.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.MANIFEST_PARSED,this.onManifestParsed,this),e.on(_.LEVEL_LOADING,this.onLevelLoading,this),e.on(_.LEVEL_LOADED,this.onLevelLoaded,this),e.on(_.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(_.ERROR,this.onError,this),e.on(_.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(_.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(_.BUFFER_CREATED,this.onBufferCreated,this),e.on(_.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(_.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(_.FRAG_BUFFERED,this.onFragBuffered,this)},r._unregisterListeners=function(){var e=this.hls;e.off(_.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.MANIFEST_PARSED,this.onManifestParsed,this),e.off(_.LEVEL_LOADED,this.onLevelLoaded,this),e.off(_.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(_.ERROR,this.onError,this),e.off(_.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(_.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(_.BUFFER_CREATED,this.onBufferCreated,this),e.off(_.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(_.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(_.FRAG_BUFFERED,this.onFragBuffered,this)},r.onHandlerDestroying=function(){this._unregisterListeners(),e.prototype.onHandlerDestroying.call(this)},r.startLoad=function(e){if(this.levels){var t=this.lastCurrentTime,r=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){var i=r.startLevel;-1===i&&(r.config.testBandwidth&&this.levels.length>1?(i=0,this.bitrateTest=!0):i=r.firstAutoLevel),r.nextLoadLevel=i,this.level=r.loadLevel,this.loadedmetadata=!1}t>0&&-1===e&&(this.log("Override startPosition with lastCurrentTime @"+t.toFixed(3)),e=t),this.state=ri,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=ti},r.stopLoad=function(){this._forceStartLoad=!1,e.prototype.stopLoad.call(this)},r.doTick=function(){switch(this.state){case di:var e=this.levels,t=this.level,r=null==e?void 0:e[t],i=null==r?void 0:r.details;if(i&&(!i.live||this.levelLastLoaded===r)){if(this.waitForCdnTuneIn(i))break;this.state=ri;break}if(this.hls.nextLoadLevel!==this.level){this.state=ri;break}break;case ai:var n,a=self.performance.now(),s=this.retryDate;if(!s||a>=s||null!=(n=this.media)&&n.seeking){var o=this.levels,u=this.level,l=null==o?void 0:o[u];this.resetStartWhenNotLoaded(l||null),this.state=ri}}this.state===ri&&this.doTickIdle(),this.onTickEnd()},r.onTickEnd=function(){e.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},r.doTickIdle=function(){var e=this.hls,t=this.levelLastLoaded,r=this.levels,i=this.media;if(null!==t&&(i||!this.startFragRequested&&e.config.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)){var n=e.nextLoadLevel;if(null!=r&&r[n]){var a=r[n],s=this.getMainFwdBufferInfo();if(null!==s){var o=this.getLevelDetails();if(o&&this._streamEnded(s,o)){var u={};return this.altAudio&&(u.type="video"),this.hls.trigger(_.BUFFER_EOS,u),void(this.state=ui)}e.loadLevel!==n&&-1===e.manualLevel&&this.log("Adapting to level "+n+" from level "+this.level),this.level=e.nextLoadLevel=n;var l=a.details;if(!l||this.state===di||l.live&&this.levelLastLoaded!==a)return this.level=n,void(this.state=di);var d=s.len,h=this.getMaxBufferLength(a.maxBitrate);if(!(d>=h)){this.backtrackFragment&&this.backtrackFragment.start>s.end&&(this.backtrackFragment=null);var c=this.backtrackFragment?this.backtrackFragment.start:s.end,f=this.getNextFragment(c,l);if(this.couldBacktrack&&!this.fragPrevious&&f&&"initSegment"!==f.sn&&this.fragmentTracker.getState(f)!==Ir){var v,p=(null!=(v=this.backtrackFragment)?v:f).sn-l.startSN,g=l.fragments[p-1];g&&f.cc===g.cc&&(f=g,this.fragmentTracker.removeFragment(g))}else this.backtrackFragment&&s.len&&(this.backtrackFragment=null);if(f&&this.isLoopLoading(f,c)){if(!f.gap){var m=this.audioOnly&&!this.altAudio?I:F,y=(m===F?this.videoBuffer:this.mediaBuffer)||this.media;y&&this.afterBufferFlushed(y,m,at)}f=this.getNextFragmentLoopLoading(f,l,s,at,h)}f&&(!f.initSegment||f.initSegment.data||this.bitrateTest||(f=f.initSegment),this.loadFragment(f,a,c))}}}}},r.loadFragment=function(t,r,i){var n=this.fragmentTracker.getState(t);this.fragCurrent=t,n===Cr||n===Or?"initSegment"===t.sn?this._loadInitSegment(t,r):this.bitrateTest?(this.log("Fragment "+t.sn+" of level "+t.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(t,r)):(this.startFragRequested=!0,e.prototype.loadFragment.call(this,t,r,i)):this.clearTrackerIfNeeded(t)},r.getBufferedFrag=function(e){return this.fragmentTracker.getBufferedFrag(e,at)},r.followingBufferedFrag=function(e){return e?this.getBufferedFrag(e.end+.5):null},r.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},r.nextLevelSwitch=function(){var e=this.levels,t=this.media;if(null!=t&&t.readyState){var r,i=this.getAppendedFrag(t.currentTime);i&&i.start>1&&this.flushMainBuffer(0,i.start-1);var n=this.getLevelDetails();if(null!=n&&n.live){var a=this.getMainFwdBufferInfo();if(!a||a.len<2*n.targetduration)return}if(!t.paused&&e){var s=e[this.hls.nextLoadLevel],o=this.fragLastKbps;r=o&&this.fragCurrent?this.fragCurrent.duration*s.maxBitrate/(1e3*o)+1:0}else r=0;var u=this.getBufferedFrag(t.currentTime+r);if(u){var l=this.followingBufferedFrag(u);if(l){this.abortCurrentFrag();var d=l.maxStartPTS?l.maxStartPTS:l.start,h=l.duration,c=Math.max(u.end,d+Math.min(Math.max(h-this.config.maxFragLookUpTolerance,h*(this.couldBacktrack?.5:.125)),h*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(c,Number.POSITIVE_INFINITY)}}}},r.abortCurrentFrag=function(){var e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case ii:case ni:case ai:case si:case oi:this.state=ri}this.nextLoadPosition=this.getLoadPosition()},r.flushMainBuffer=function(t,r){e.prototype.flushMainBuffer.call(this,t,r,this.altAudio?"video":null)},r.onMediaAttached=function(t,r){e.prototype.onMediaAttached.call(this,t,r);var i=r.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),i.addEventListener("playing",this.onvplaying),i.addEventListener("seeked",this.onvseeked),this.gapController=new kn(this.config,i,this.fragmentTracker,this.hls)},r.onMediaDetaching=function(){var t=this.media;t&&this.onvplaying&&this.onvseeked&&(t.removeEventListener("playing",this.onvplaying),t.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),e.prototype.onMediaDetaching.call(this)},r.onMediaPlaying=function(){this.tick()},r.onMediaSeeked=function(){var e=this.media,t=e?e.currentTime:null;g(t)&&this.log("Media seeked to "+t.toFixed(3));var r=this.getMainFwdBufferInfo();null!==r&&0!==r.len?this.tick():this.warn('Main forward buffer length on "seeked" event '+(r?r.len:"empty")+")")},r.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(_.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=this.fragLastKbps=0,this.levels=this.fragPlaying=this.backtrackFragment=this.levelLastLoaded=null,this.altAudio=this.audioOnly=this.startFragRequested=!1},r.onManifestParsed=function(e,t){var r,i,n=!1,a=!1;t.levels.forEach((function(e){var t=e.audioCodec;t&&(n=n||-1!==t.indexOf("mp4a.40.2"),a=a||-1!==t.indexOf("mp4a.40.5"))})),this.audioCodecSwitch=n&&a&&!("function"==typeof(null==(i=ci())||null==(r=i.prototype)?void 0:r.changeType)),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1},r.onLevelLoading=function(e,t){var r=this.levels;if(r&&this.state===ri){var i=r[t.level];(!i.details||i.details.live&&this.levelLastLoaded!==i||this.waitForCdnTuneIn(i.details))&&(this.state=di)}},r.onLevelLoaded=function(e,t){var r,i=this.levels,n=t.level,a=t.details,s=a.totalduration;if(i){this.log("Level "+n+" loaded ["+a.startSN+","+a.endSN+"]"+(a.lastPartSn?"[part-"+a.lastPartSn+"-"+a.lastPartIndex+"]":"")+", cc ["+a.startCC+", "+a.endCC+"] duration:"+s);var o=i[n],u=this.fragCurrent;!u||this.state!==ni&&this.state!==ai||u.level!==t.level&&u.loader&&this.abortCurrentFrag();var l=0;if(a.live||null!=(r=o.details)&&r.live){var d;if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;l=this.alignPlaylists(a,o.details,null==(d=this.levelLastLoaded)?void 0:d.details)}if(o.details=a,this.levelLastLoaded=o,this.hls.trigger(_.LEVEL_UPDATED,{details:a,level:n}),this.state===di){if(this.waitForCdnTuneIn(a))return;this.state=ri}this.startFragRequested?a.live&&this.synchronizeToLiveEdge(a):this.setStartPosition(a,l),this.tick()}else this.warn("Levels were reset while loading level "+n)},r._handleFragmentLoadProgress=function(e){var t,r=e.frag,i=e.part,n=e.payload,a=this.levels;if(a){var s=a[r.level],o=s.details;if(!o)return this.warn("Dropping fragment "+r.sn+" of level "+r.level+" after level details were reset"),void this.fragmentTracker.removeFragment(r);var u=s.videoCodec,l=o.PTSKnown||!o.live,d=null==(t=r.initSegment)?void 0:t.data,h=this._getAudioCodec(s),c=this.transmuxer=this.transmuxer||new Ln(this.hls,at,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),f=i?i.index:-1,v=-1!==f,p=new zr(r.level,r.sn,r.stats.chunkCount,n.byteLength,f,v),g=this.initPTS[r.cc];c.push(n,d,h,u,r,i,o.totalduration,l,p,g)}else this.warn("Levels were reset while fragment load was in progress. Fragment "+r.sn+" of level "+r.level+" will not be buffered")},r.onAudioTrackSwitching=function(e,t){var r=this.altAudio;if(!t.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var i=this.fragCurrent;i&&(this.log("Switching to main audio track, cancel main fragment load"),i.abortRequests(),this.fragmentTracker.removeFragment(i)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var n=this.hls;r&&(n.trigger(_.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),n.trigger(_.AUDIO_TRACK_SWITCHED,t)}},r.onAudioTrackSwitched=function(e,t){var r=t.id,i=!!this.hls.audioTracks[r].url;if(i){var n=this.videoBuffer;n&&this.mediaBuffer!==n&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=n)}this.altAudio=i,this.tick()},r.onBufferCreated=function(e,t){var r,i,n=t.tracks,a=!1;for(var s in n){var o=n[s];if("main"===o.id){if(i=s,r=o,"video"===s){var u=n[s];u&&(this.videoBuffer=u.buffer)}}else a=!0}a&&r?(this.log("Alternate track found, use "+i+".buffered to schedule main fragment loading"),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media},r.onFragBuffered=function(e,t){var r=t.frag,i=t.part;if(!r||r.type===at){if(this.fragContextChanged(r))return this.warn("Fragment "+r.sn+(i?" p: "+i.index:"")+" of level "+r.level+" finished buffering, but was aborted. state: "+this.state),void(this.state===oi&&(this.state=ri));var n=i?i.stats:r.stats;this.fragLastKbps=Math.round(8*n.total/(n.buffering.end-n.loading.first)),"initSegment"!==r.sn&&(this.fragPrevious=r),this.fragBufferedComplete(r,i)}},r.onError=function(e,t){var r;if(t.fatal)this.state=li;else switch(t.details){case E.FRAG_GAP:case E.FRAG_PARSING_ERROR:case E.FRAG_DECRYPT_ERROR:case E.FRAG_LOAD_ERROR:case E.FRAG_LOAD_TIMEOUT:case E.KEY_LOAD_ERROR:case E.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(at,t);break;case E.LEVEL_LOAD_ERROR:case E.LEVEL_LOAD_TIMEOUT:case E.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==di||(null==(r=t.context)?void 0:r.type)!==rt||(this.state=ri);break;case E.BUFFER_APPEND_ERROR:case E.BUFFER_FULL_ERROR:if(!t.parent||"main"!==t.parent)return;if(t.details===E.BUFFER_APPEND_ERROR)return void this.resetLoadingState();this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case E.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}},r.checkBuffer=function(){var e=this.media,t=this.gapController;if(e&&t&&e.readyState){if(this.loadedmetadata||!ur.getBuffered(e).length){var r=this.state!==ri?this.fragCurrent:null;t.poll(this.lastCurrentTime,r)}this.lastCurrentTime=e.currentTime}},r.onFragLoadEmergencyAborted=function(){this.state=ri,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},r.onBufferFlushed=function(e,t){var r=t.type;if(r!==I||this.audioOnly&&!this.altAudio){var i=(r===F?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(i,r,at),this.tick()}},r.onLevelsUpdated=function(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level),this.levels=t.levels},r.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},r.seekToStartPos=function(){var e=this.media;if(e){var t=e.currentTime,r=this.startPosition;if(r>=0&&t<r){if(e.seeking)return void this.log("could not seek to "+r+", already seeking at "+t);var i=ur.getBuffered(e),n=(i.length?i.start(0):0)-r;n>0&&(n<this.config.maxBufferHole||n<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+n+" to match buffer start"),r+=n,this.startPosition=r),this.log("seek to target start position "+r+" from current time "+t),e.currentTime=r}}},r._getAudioCodec=function(e){var t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t=-1!==t.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),t},r._loadBitrateTestFrag=function(e,t){var r=this;e.bitrateTest=!0,this._doFragLoad(e,t).then((function(i){var n=r.hls;if(i&&!r.fragContextChanged(e)){t.fragmentError=0,r.state=ri,r.startFragRequested=!1,r.bitrateTest=!1;var a=e.stats;a.parsing.start=a.parsing.end=a.buffering.start=a.buffering.end=self.performance.now(),n.trigger(_.FRAG_LOADED,i),e.bitrateTest=!1}}))},r._handleTransmuxComplete=function(e){var t,r="main",i=this.hls,n=e.remuxResult,a=e.chunkMeta,s=this.getCurrentContext(a);if(s){var o=s.frag,u=s.part,l=s.level,d=n.video,h=n.text,c=n.id3,f=n.initSegment,v=l.details,p=this.altAudio?void 0:n.audio;if(this.fragContextChanged(o))this.fragmentTracker.removeFragment(o);else{if(this.state=si,f){if(null!=f&&f.tracks){var m=o.initSegment||o;this._bufferInitSegment(l,f.tracks,m,a),i.trigger(_.FRAG_PARSING_INIT_SEGMENT,{frag:m,id:r,tracks:f.tracks})}var y=f.initPTS,b=f.timescale;g(y)&&(this.initPTS[o.cc]={baseTime:y,timescale:b},i.trigger(_.INIT_PTS_FOUND,{frag:o,id:r,initPTS:y,timescale:b}))}if(d&&v&&"initSegment"!==o.sn){var E=v.fragments[o.sn-1-v.startSN],T=o.sn===v.startSN,S=!E||o.cc>E.cc;if(!1!==n.independent){var L=d.startPTS,k=d.endPTS,w=d.startDTS,x=d.endDTS;if(u)u.elementaryStreams[d.type]={startPTS:L,endPTS:k,startDTS:w,endDTS:x};else if(d.firstKeyFrame&&d.independent&&1===a.id&&!S&&(this.couldBacktrack=!0),d.dropped&&d.independent){var A=this.getMainFwdBufferInfo(),R=(A?A.end:this.getLoadPosition())+this.config.maxBufferHole,D=d.firstKeyFramePTS?d.firstKeyFramePTS:L;if(!T&&R<D-this.config.maxBufferHole&&!S)return void this.backtrack(o);S&&(o.gap=!0),o.setElementaryStreamInfo(d.type,o.start,k,o.start,x,!0)}else T&&L>2&&(o.gap=!0);o.setElementaryStreamInfo(d.type,L,k,w,x),this.backtrackFragment&&(this.backtrackFragment=o),this.bufferFragmentData(d,o,u,a,T||S)}else{if(!T&&!S)return void this.backtrack(o);o.gap=!0}}if(p){var C=p.startPTS,P=p.endPTS,O=p.startDTS,F=p.endDTS;u&&(u.elementaryStreams[I]={startPTS:C,endPTS:P,startDTS:O,endDTS:F}),o.setElementaryStreamInfo(I,C,P,O,F),this.bufferFragmentData(p,o,u,a)}if(v&&null!=c&&null!=(t=c.samples)&&t.length){var M={id:r,frag:o,details:v,samples:c.samples};i.trigger(_.FRAG_PARSING_METADATA,M)}if(v&&h){var B={id:r,frag:o,details:v,samples:h.samples};i.trigger(_.FRAG_PARSING_USERDATA,B)}}}else this.resetWhenMissingContext(a)},r._bufferInitSegment=function(e,t,r,i){var n=this;if(this.state===si){this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;var a=t.audio,s=t.video,o=t.audiovideo;if(a){var u=e.audioCodec,l=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){u&&(u=-1!==u.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5");var d=a.metadata;d&&"channelCount"in d&&1!==(d.channelCount||1)&&-1===l.indexOf("firefox")&&(u="mp4a.40.5")}u&&-1!==u.indexOf("mp4a.40.5")&&-1!==l.indexOf("android")&&"audio/mpeg"!==a.container&&(u="mp4a.40.2",this.log("Android: force audio codec to "+u)),e.audioCodec&&e.audioCodec!==u&&this.log('Swapping manifest audio codec "'+e.audioCodec+'" for "'+u+'"'),a.levelCodec=u,a.id="main",this.log("Init audio buffer, container:"+a.container+", codecs[selected/level/parsed]=["+(u||"")+"/"+(e.audioCodec||"")+"/"+a.codec+"]")}s&&(s.levelCodec=e.videoCodec,s.id="main",this.log("Init video buffer, container:"+s.container+", codecs[level/parsed]=["+(e.videoCodec||"")+"/"+s.codec+"]")),o&&this.log("Init audiovideo buffer, container:"+o.container+", codecs[level/parsed]=["+e.codecs+"/"+o.codec+"]"),this.hls.trigger(_.BUFFER_CODECS,t),Object.keys(t).forEach((function(e){var a=t[e].initSegment;null!=a&&a.byteLength&&n.hls.trigger(_.BUFFER_APPENDING,{type:e,data:a,frag:r,part:null,chunkMeta:i,parent:r.type})})),this.tickImmediate()}},r.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,at)},r.backtrack=function(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=ri},r.checkFragmentChanged=function(){var e=this.media,t=null;if(e&&e.readyState>1&&!1===e.seeking){var r=e.currentTime;if(ur.isBuffered(e,r)?t=this.getAppendedFrag(r):ur.isBuffered(e,r+.1)&&(t=this.getAppendedFrag(r+.1)),t){this.backtrackFragment=null;var i=this.fragPlaying,n=t.level;i&&t.sn===i.sn&&i.level===n||(this.fragPlaying=t,this.hls.trigger(_.FRAG_CHANGED,{frag:t}),i&&i.level===n||this.hls.trigger(_.LEVEL_SWITCHED,{level:n}))}}},s(t,[{key:"nextLevel",get:function(){var e=this.nextBufferedFrag;return e?e.level:-1}},{key:"currentFrag",get:function(){var e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}},{key:"currentProgramDateTime",get:function(){var e=this.media;if(e){var t=e.currentTime,r=this.currentFrag;if(r&&g(t)&&g(r.programDateTime)){var i=r.programDateTime+1e3*(t-r.start);return new Date(i)}}return null}},{key:"currentLevel",get:function(){var e=this.currentFrag;return e?e.level:-1}},{key:"nextBufferedFrag",get:function(){var e=this.currentFrag;return e?this.followingBufferedFrag(e):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),t}(hi),xn=function(){function e(t){void 0===t&&(t={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this.started=!1,this._emitter=new bn,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,this.triggeringException=void 0,w(t.debug||!1,"Hls instance");var r=this.config=function(e,t){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==t.liveMaxLatencyDurationCount&&(void 0===t.liveSyncDurationCount||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==t.liveMaxLatencyDuration&&(void 0===t.liveSyncDuration||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var r=xr(e),n=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach((function(e){var i=("level"===e?"playlist":e)+"LoadPolicy",a=void 0===t[i],s=[];n.forEach((function(n){var o=e+"Loading"+n,u=t[o];if(void 0!==u&&a){s.push(o);var l=r[i].default;switch(t[i]={default:l},n){case"TimeOut":l.maxLoadTimeMs=u,l.maxTimeToFirstByteMs=u;break;case"MaxRetry":l.errorRetry.maxNumRetry=u,l.timeoutRetry.maxNumRetry=u;break;case"RetryDelay":l.errorRetry.retryDelayMs=u,l.timeoutRetry.retryDelayMs=u;break;case"MaxRetryTimeout":l.errorRetry.maxRetryDelayMs=u,l.timeoutRetry.maxRetryDelayMs=u}}})),s.length&&x.warn('hls.js config: "'+s.join('", "')+'" setting(s) are deprecated, use "'+i+'": '+JSON.stringify(t[i]))})),i(i({},r),t)}(e.DefaultConfig,t);this.userConfig=t,r.progressive&&Ar(r);var n=r.abrController,a=r.bufferController,s=r.capLevelController,o=r.errorController,u=r.fpsController,l=new o(this),d=this.abrController=new n(this),h=this.bufferController=new a(this),c=this.capLevelController=new s(this),f=new u(this),v=new dt(this),p=new bt(this),g=r.contentSteeringController,m=g?new g(this):null,y=this.levelController=new Rr(this,m),b=new Fr(this),E=new Hr(this.config),T=this.streamController=new wn(this,b,E);c.setStreamController(T),f.setStreamController(T);var S=[v,y,T];m&&S.splice(1,0,m),this.networkControllers=S;var L=[d,h,c,f,p,b];this.audioTrackController=this.createController(r.audioTrackController,S);var k=r.audioStreamController;k&&S.push(new k(this,b,E)),this.subtitleTrackController=this.createController(r.subtitleTrackController,S);var A=r.subtitleStreamController;A&&S.push(new A(this,b,E)),this.createController(r.timelineController,L),E.emeController=this.emeController=this.createController(r.emeController,L),this.cmcdController=this.createController(r.cmcdController,L),this.latencyController=this.createController(Et,L),this.coreComponents=L,S.push(l);var R=l.onErrorOut;"function"==typeof R&&this.on(_.ERROR,R,l)}e.isMSESupported=function(){return fi()},e.isSupported=function(){return function(){if(!fi())return!1;var e=Ce();return"function"==typeof(null==e?void 0:e.isTypeSupported)&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some((function(t){return e.isTypeSupported(Fe(t,"video"))}))||["mp4a.40.2","fLaC"].some((function(t){return e.isTypeSupported(Fe(t,"audio"))})))}()},e.getMediaSource=function(){return Ce()};var t=e.prototype;return t.createController=function(e,t){if(e){var r=new e(this);return t&&t.push(r),r}return null},t.on=function(e,t,r){void 0===r&&(r=this),this._emitter.on(e,t,r)},t.once=function(e,t,r){void 0===r&&(r=this),this._emitter.once(e,t,r)},t.removeAllListeners=function(e){this._emitter.removeAllListeners(e)},t.off=function(e,t,r,i){void 0===r&&(r=this),this._emitter.off(e,t,r,i)},t.listeners=function(e){return this._emitter.listeners(e)},t.emit=function(e,t,r){return this._emitter.emit(e,t,r)},t.trigger=function(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(t){if(x.error("An internal error happened while handling event "+e+'. Error message: "'+t.message+'". Here is a stacktrace:',t),!this.triggeringException){this.triggeringException=!0;var r=e===_.ERROR;this.trigger(_.ERROR,{type:b.OTHER_ERROR,details:E.INTERNAL_EXCEPTION,fatal:r,event:e,error:t}),this.triggeringException=!1}}return!1},t.listenerCount=function(e){return this._emitter.listenerCount(e)},t.destroy=function(){x.log("destroy"),this.trigger(_.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach((function(e){return e.destroy()})),this.networkControllers.length=0,this.coreComponents.forEach((function(e){return e.destroy()})),this.coreComponents.length=0;var e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null},t.attachMedia=function(e){x.log("attachMedia"),this._media=e,this.trigger(_.MEDIA_ATTACHING,{media:e})},t.detachMedia=function(){x.log("detachMedia"),this.trigger(_.MEDIA_DETACHING,void 0),this._media=null},t.loadSource=function(e){this.stopLoad();var t=this.media,r=this.url,i=this.url=p.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,x.log("loadSource:"+i),t&&r&&(r!==i||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(_.MANIFEST_LOADING,{url:e})},t.startLoad=function(e){void 0===e&&(e=-1),x.log("startLoad("+e+")"),this.started=!0,this.networkControllers.forEach((function(t){t.startLoad(e)}))},t.stopLoad=function(){x.log("stopLoad"),this.started=!1,this.networkControllers.forEach((function(e){e.stopLoad()}))},t.resumeBuffering=function(){this.started&&this.networkControllers.forEach((function(e){"fragmentLoader"in e&&e.startLoad(-1)}))},t.pauseBuffering=function(){this.networkControllers.forEach((function(e){"fragmentLoader"in e&&e.stopLoad()}))},t.swapAudioCodec=function(){x.log("swapAudioCodec"),this.streamController.swapAudioCodec()},t.recoverMediaError=function(){x.log("recoverMediaError");var e=this._media;this.detachMedia(),e&&this.attachMedia(e)},t.removeLevel=function(e){this.levelController.removeLevel(e)},t.setAudioOption=function(e){var t;return null==(t=this.audioTrackController)?void 0:t.setAudioOption(e)},t.setSubtitleOption=function(e){var t;return null==(t=this.subtitleTrackController)||t.setSubtitleOption(e),null},s(e,[{key:"levels",get:function(){return this.levelController.levels||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(e){x.log("set currentLevel:"+e),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){x.log("set nextLevel:"+e),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){x.log("set loadLevel:"+e),this.levelController.manualLevel=e}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(e){this.levelController.nextLoadLevel=e}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(e){x.log("set firstLevel:"+e),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){var e=this.levelController.startLevel;return-1===e&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e},set:function(e){x.log("set startLevel:"+e),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(e){var t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){this._autoLevelCapping!==e&&(x.log("set autoLevelCapping:"+e),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}},{key:"bandwidthEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimate():NaN},set:function(e){this.abrController.resetEstimator(e)}},{key:"ttfbEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimateTTFB():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(e){(function(e){return Tt.indexOf(e)>-1})(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var e=this.levels,t=this.config.minAutoBitrate;if(!e)return 0;for(var r=e.length,i=0;i<r;i++)if(e[i].maxBitrate>=t)return i;return 0}},{key:"maxAutoLevel",get:function(){var e,t=this.levels,r=this.autoLevelCapping,i=this.maxHdcpLevel;if(e=-1===r&&null!=t&&t.length?t.length-1:r,i)for(var n=e;n--;){var a=t[n].attrs["HDCP-LEVEL"];if(a&&a<=i)return n}return e}},{key:"firstAutoLevel",get:function(){return this.abrController.firstAutoLevel}},{key:"nextAutoLevel",get:function(){return this.abrController.nextAutoLevel},set:function(e){this.abrController.nextAutoLevel=e}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"allAudioTracks",get:function(){var e=this.audioTrackController;return e?e.allAudioTracks:[]}},{key:"audioTracks",get:function(){var e=this.audioTrackController;return e?e.audioTracks:[]}},{key:"audioTrack",get:function(){var e=this.audioTrackController;return e?e.audioTrack:-1},set:function(e){var t=this.audioTrackController;t&&(t.audioTrack=e)}},{key:"allSubtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}},{key:"subtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(e){this.config.lowLatencyMode=e}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.5.17"}},{key:"Events",get:function(){return _}},{key:"ErrorTypes",get:function(){return b}},{key:"ErrorDetails",get:function(){return E}},{key:"DefaultConfig",get:function(){return e.defaultConfig?e.defaultConfig:wr},set:function(t){e.defaultConfig=t}}]),e}();return xn.defaultConfig=void 0,xn}()}(!1)},21:(e,t,r)=>{r.d(t,{c:()=>n.a});var i=r(539),n=r.n(i)}},t={};function r(i){var n=t[i];if(void 0!==n)return n.exports;var a=t[i]={exports:{}};return e[i](a,a.exports,r),a.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var i={};function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function a(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach((function(t){c(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function s(){s=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,i=Object.defineProperty||function(e,t,r){e[t]=r.value},n="function"==typeof Symbol?Symbol:{},a=n.iterator||"@@iterator",o=n.asyncIterator||"@@asyncIterator",u=n.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,r){return e[t]=r}}function d(e,t,r,n){var a=t&&t.prototype instanceof f?t:f,s=Object.create(a.prototype),o=new w(n||[]);return i(s,"_invoke",{value:T(e,r,o)}),s}function h(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=d;var c={};function f(){}function v(){}function p(){}var g={};l(g,a,(function(){return this}));var m=Object.getPrototypeOf,y=m&&m(m(x([])));y&&y!==t&&r.call(y,a)&&(g=y);var _=p.prototype=f.prototype=Object.create(g);function b(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function E(e,t){function n(i,a,s,o){var u=h(e[i],e,a);if("throw"!==u.type){var l=u.arg,d=l.value;return d&&"object"==typeof d&&r.call(d,"__await")?t.resolve(d.__await).then((function(e){n("next",e,s,o)}),(function(e){n("throw",e,s,o)})):t.resolve(d).then((function(e){l.value=e,s(l)}),(function(e){return n("throw",e,s,o)}))}o(u.arg)}var a;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return a=a?a.then(i,i):i()}})}function T(e,t,r){var i="suspendedStart";return function(n,a){if("executing"===i)throw new Error("Generator is already running");if("completed"===i){if("throw"===n)throw a;return{value:void 0,done:!0}}for(r.method=n,r.arg=a;;){var s=r.delegate;if(s){var o=S(s,r);if(o){if(o===c)continue;return o}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===i)throw i="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i="executing";var u=h(e,t,r);if("normal"===u.type){if(i=r.done?"completed":"suspendedYield",u.arg===c)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(i="completed",r.method="throw",r.arg=u.arg)}}}function S(e,t){var r=t.method,i=e.iterator[r];if(void 0===i)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,S(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),c;var n=h(i,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,c;var a=n.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,c):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,c)}function L(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function w(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(L,this),this.reset(!0)}function x(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,n=function t(){for(;++i<e.length;)if(r.call(e,i))return t.value=e[i],t.done=!1,t;return t.value=void 0,t.done=!0,t};return n.next=n}}return{next:A}}function A(){return{value:void 0,done:!0}}return v.prototype=p,i(_,"constructor",{value:p,configurable:!0}),i(p,"constructor",{value:v,configurable:!0}),v.displayName=l(p,u,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,l(e,u,"GeneratorFunction")),e.prototype=Object.create(_),e},e.awrap=function(e){return{__await:e}},b(E.prototype),l(E.prototype,o,(function(){return this})),e.AsyncIterator=E,e.async=function(t,r,i,n,a){void 0===a&&(a=Promise);var s=new E(d(t,r,i,n),a);return e.isGeneratorFunction(r)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},b(_),l(_,u,"Generator"),l(_,a,(function(){return this})),l(_,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var i in t)r.push(i);return r.reverse(),function e(){for(;r.length;){var i=r.pop();if(i in t)return e.value=i,e.done=!1,e}return e.done=!0,e}},e.values=x,w.prototype={constructor:w,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function i(r,i){return s.type="throw",s.arg=e,t.next=r,i&&(t.method="next",t.arg=void 0),!!i}for(var n=this.tryEntries.length-1;n>=0;--n){var a=this.tryEntries[n],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var o=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(o&&u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(o){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var i=this.tryEntries.length-1;i>=0;--i){var n=this.tryEntries[i];if(n.tryLoc<=this.prev&&r.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var a=n;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var s=a?a.completion:{};return s.type=e,s.arg=t,a?(this.method="next",this.next=a.finallyLoc,c):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),c},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),k(r),c}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var i=r.completion;if("throw"===i.type){var n=i.arg;k(r)}return n}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:x(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),c}},e}function o(e,t,r,i,n,a,s){try{var o=e[a](s),u=o.value}catch(e){return void r(e)}o.done?t(u):Promise.resolve(u).then(i,n)}function u(e){return function(){var t=this,r=arguments;return new Promise((function(i,n){var a=e.apply(t,r);function s(e){o(a,i,n,s,u,"next",e)}function u(e){o(a,i,n,s,u,"throw",e)}s(void 0)}))}}function l(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function d(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,g(i.key),i)}}function h(e,t,r){return t&&d(e.prototype,t),r&&d(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function c(e,t,r){return(t=g(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function v(e,t){return(v=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function p(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function g(e){var t=function(e){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}r.d(i,{N:()=>or,c:()=>ur.c});var m=r(228),y=r.n(m);function _(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function b(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?_(Object(r),!0).forEach((function(t){A(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):_(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function E(){E=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,i=Object.defineProperty||function(e,t,r){e[t]=r.value},n="function"==typeof Symbol?Symbol:{},a=n.iterator||"@@iterator",s=n.asyncIterator||"@@asyncIterator",o=n.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var a=t&&t.prototype instanceof c?t:c,s=Object.create(a.prototype),o=new w(n||[]);return i(s,"_invoke",{value:T(e,r,o)}),s}function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var h={};function c(){}function f(){}function v(){}var p={};u(p,a,(function(){return this}));var g=Object.getPrototypeOf,m=g&&g(g(x([])));m&&m!==t&&r.call(m,a)&&(p=m);var y=v.prototype=c.prototype=Object.create(p);function _(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function b(e,t){function n(i,a,s,o){var u=d(e[i],e,a);if("throw"!==u.type){var l=u.arg,h=l.value;return h&&"object"==typeof h&&r.call(h,"__await")?t.resolve(h.__await).then((function(e){n("next",e,s,o)}),(function(e){n("throw",e,s,o)})):t.resolve(h).then((function(e){l.value=e,s(l)}),(function(e){return n("throw",e,s,o)}))}o(u.arg)}var a;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return a=a?a.then(i,i):i()}})}function T(e,t,r){var i="suspendedStart";return function(n,a){if("executing"===i)throw new Error("Generator is already running");if("completed"===i){if("throw"===n)throw a;return{value:void 0,done:!0}}for(r.method=n,r.arg=a;;){var s=r.delegate;if(s){var o=S(s,r);if(o){if(o===h)continue;return o}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===i)throw i="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i="executing";var u=d(e,t,r);if("normal"===u.type){if(i=r.done?"completed":"suspendedYield",u.arg===h)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(i="completed",r.method="throw",r.arg=u.arg)}}}function S(e,t){var r=t.method,i=e.iterator[r];if(void 0===i)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,S(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),h;var n=d(i,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,h;var a=n.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,h):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,h)}function L(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function w(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(L,this),this.reset(!0)}function x(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,n=function t(){for(;++i<e.length;)if(r.call(e,i))return t.value=e[i],t.done=!1,t;return t.value=void 0,t.done=!0,t};return n.next=n}}return{next:A}}function A(){return{value:void 0,done:!0}}return f.prototype=v,i(y,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:f,configurable:!0}),f.displayName=u(v,o,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===f||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,v):(e.__proto__=v,u(e,o,"GeneratorFunction")),e.prototype=Object.create(y),e},e.awrap=function(e){return{__await:e}},_(b.prototype),u(b.prototype,s,(function(){return this})),e.AsyncIterator=b,e.async=function(t,r,i,n,a){void 0===a&&(a=Promise);var s=new b(l(t,r,i,n),a);return e.isGeneratorFunction(r)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},_(y),u(y,o,"Generator"),u(y,a,(function(){return this})),u(y,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var i in t)r.push(i);return r.reverse(),function e(){for(;r.length;){var i=r.pop();if(i in t)return e.value=i,e.done=!1,e}return e.done=!0,e}},e.values=x,w.prototype={constructor:w,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function i(r,i){return s.type="throw",s.arg=e,t.next=r,i&&(t.method="next",t.arg=void 0),!!i}for(var n=this.tryEntries.length-1;n>=0;--n){var a=this.tryEntries[n],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var o=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(o&&u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(o){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var i=this.tryEntries.length-1;i>=0;--i){var n=this.tryEntries[i];if(n.tryLoc<=this.prev&&r.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var a=n;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var s=a?a.completion:{};return s.type=e,s.arg=t,a?(this.method="next",this.next=a.finallyLoc,h):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),h},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),k(r),h}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var i=r.completion;if("throw"===i.type){var n=i.arg;k(r)}return n}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:x(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},e}function T(e){return(T="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function S(e,t,r,i,n,a,s){try{var o=e[a](s),u=o.value}catch(e){return void r(e)}o.done?t(u):Promise.resolve(u).then(i,n)}function L(e){return function(){var t=this,r=arguments;return new Promise((function(i,n){var a=e.apply(t,r);function s(e){S(a,i,n,s,o,"next",e)}function o(e){S(a,i,n,s,o,"throw",e)}s(void 0)}))}}function k(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function w(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,U(i.key),i)}}function x(e,t,r){return t&&w(e.prototype,t),r&&w(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function A(e,t,r){return(t=U(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function R(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&C(e,t)}function D(e){return(D=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function C(e,t){return(C=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function P(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function O(e,t,r){return(O=P()?Reflect.construct.bind():function(e,t,r){var i=[null];i.push.apply(i,t);var n=new(Function.bind.apply(e,i));return r&&C(n,r.prototype),n}).apply(null,arguments)}function I(e){var t="function"==typeof Map?new Map:void 0;return I=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,i)}function i(){return O(e,arguments,D(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),C(i,e)},I(e)}function F(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function M(e){var t=P();return function(){var r,i=D(e);if(t){var n=D(this).constructor;r=Reflect.construct(i,arguments,n)}else r=i.apply(this,arguments);return function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return F(e)}(this,r)}}function B(){return B="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=D(e)););return e}(e,t);if(i){var n=Object.getOwnPropertyDescriptor(i,t);return n.get?n.get.call(arguments.length<3?e:r):n.value}},B.apply(this,arguments)}function N(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function U(e){var t=function(e){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}var G={DEBUG:1,LOG:2,WARN:3,ERROR:4},V=["Boolean","Number","String","Undefined","Null","Date","Object"],j=function(){function e(t,r){k(this,e),this.name=t||"",this._prefix="[".concat(this.name,"]"),this.logCacheLevel=(null==r?void 0:r.logCacheLevel)||3,this.logMaxSize=(null==r?void 0:r.logMaxSize)||204800,this.logSize=0,this.logTextArray=[]}return x(e,[{key:"debug",value:function(){for(var t,r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];this.logCache.apply(this,[G.DEBUG].concat(i)),e.disabled||(t=console).debug.apply(t,["[".concat(H(),"]"),this._prefix].concat(i))}},{key:"log",value:function(){for(var t,r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];this.logCache.apply(this,[G.LOG].concat(i)),e.disabled||(t=console).log.apply(t,["[".concat(H(),"]"),this._prefix].concat(i))}},{key:"warn",value:function(){for(var t,r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];this.logCache.apply(this,[G.WARN].concat(i)),e.disabled||(t=console).warn.apply(t,["[".concat(H(),"]"),this._prefix].concat(i))}},{key:"error",value:function(){for(var t,r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];this.logCache.apply(this,[G.ERROR].concat(i)),e.disabled||(t=console).error.apply(t,["[".concat(H(),"]"),this._prefix].concat(i))}},{key:"logCache",value:function(e){if(!(e<this.logCacheLevel)){var t="";try{for(var r=arguments.length,i=new Array(r>1?r-1:0),n=1;n<r;n++)i[n-1]=arguments[n];var a=i.map((function(e){return z(e)}));t="[".concat(H(),"]")+this._prefix+JSON.stringify(a)}catch(e){return}if(e>=this.logCacheLevel&&(this.logSize+=t.length,this.logTextArray.push(t)),this.logSize>this.logMaxSize){var s=this.logTextArray.shift();this.logSize-=s.length}}}},{key:"getLogCache",value:function(){var e=this.logTextArray.join("\n");return this.reset(),e}},{key:"reset",value:function(){this.logTextArray=[],this.logSize=0}},{key:"table",value:function(){var t;e.disabled||(console.group(this._prefix),(t=console).table.apply(t,arguments),console.groupEnd())}},{key:"setLogLevel",value:function(e){this.logCacheLevel=e}}],[{key:"enable",value:function(){e.disabled=!1}},{key:"disable",value:function(){e.disabled=!0}}]),e}();function H(){return(new Date).toLocaleString()}function K(e){if("object"!==T(e))return e;var t=Object.prototype.toString.call(e).slice(8,-1);switch(t){case"Array":case"Uint8Array":case"ArrayBuffer":return t+"["+e.length+"]";case"Object":return"{}";default:return t}}function z(e,t,r){r||(r=1),t||(t=2);var i={};if(!e||"object"!==T(e))return e;var n=Object.prototype.toString.call(e).slice(8,-1);if(!V.includes(n))return n;if(!(r>t)){for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(r===t?i[a]=K(e[a]):"object"===T(e[a])?i[a]=z(e[a],t,r+1):i[a]=e[a]);return i}}A(j,"disabled",!0);var W,q="core.ttfb",Y="core.metadataparsed",X="core.sei",Q="core.flvscriptdata",J="core.demuxedtrack",Z="core.streamexception",$="real_time_speed",ee="network",te="network_timeout",re="demux",ie="remux",ne="media",ae="other",se="FLV",oe="FMP4",ue="MSE_ADD_SB",le="MSE_APPEND_BUFFER",de="MSE_OTHER",he="MSE_FULL",ce="MSE_CHANGE_TYPE",fe=(A(W={},"manifest",{HLS:1100,DASH:1200}),A(W,ee,2100),A(W,te,2101),A(W,"network_forbidden",2103),A(W,"network_notfound",2104),A(W,"network_range_not_satisfiable",2116),A(W,re,{FLV:3100,HLS:3200,MP4:3300,FMP4:3400,SIDX:3410}),A(W,ie,{FMP4:4100,MP4:4200}),A(W,ne,{MEDIA_ERR_ABORTED:5101,MEDIA_ERR_NETWORK:5102,MEDIA_ERR_DECODE:5103,MEDIA_ERR_SRC_NOT_SUPPORTED:5104,MEDIA_ERR_CODEC_NOT_SUPPORTED:5105,MEDIA_ERR_URL_EMPTY:5106,MSE_ADD_SB:5200,MSE_APPEND_BUFFER:5201,MSE_OTHER:5202,MSE_FULL:5203,MSE_HIJACK:5204,MSE_CHANGE_TYPE:5205,EME_HIJACK:5301}),A(W,"drm",{LICENSE:7100,CUSTOM_LICENSE:7200}),A(W,ae,8e3),A(W,"runtime",{NO_CANPLAY_ERROR:9001,BUFFERBREAK_ERROR:9002,WAITING_TIMEOUT_ERROR:9003}),W),ve=function(){R(t,I(Error));var e=M(t);function t(r,i,n,a,s){var o;return k(this,t),(o=e.call(this,s||(null==n?void 0:n.message))).errorType=r===te?ee:r,o.originError=n,o.ext=a,o.errorCode=fe[r][i]||fe[r],o.errorMessage=o.message,o.errorCode||(o.errorType=ae,o.errorCode=fe[o.errorType]),o}return x(t,null,[{key:"create",value:function(e,r,i,n,a){return e instanceof t?e:(e instanceof Error&&(i=e,e=""),e||(e=ae),new t(e,r,i,n,a))}},{key:"network",value:function(e){var r;return new t(null!=e&&e.isTimeout?te:ee,null,e instanceof Error?e:null,{url:null==e?void 0:e.url,response:null==e?void 0:e.response,httpCode:null==e||null===(r=e.response)||void 0===r?void 0:r.status})}}]),t}(),pe=function(){function e(){k(this,e)}return x(e,null,[{key:"start",value:function(e){return e&&e.length?1===e.length&&e.end(0)-e.start(0)<1e-6||1===e.length&&e.start(0)<0?0:e.start(0):0}},{key:"end",value:function(e){return e&&e.length?1===e.length&&e.end(0)-e.start(0)<1e-6?0:e.end(e.length-1):0}},{key:"get",value:function(e){if(e)try{return e.buffered}catch(e){}}},{key:"buffers",value:function(e,t){if(!e||!e.length)return[];for(var r=[],i=0,n=e.length;i<n;i++){var a=r.length;if(a&&t){var s=r[a-1],o=s[1];if(e.start(i)-o<=t){var u=e.end(i);u>o&&(s[1]=u)}else r.push([e.start(i),e.end(i)])}else r.push([e.start(i),e.end(i)])}return r}},{key:"totalLength",value:function(e){return e&&e.length?e.reduce((function(e,t){return e+(t[1]-t[0])}),0):0}},{key:"info",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(!t||!t.length)return{start:0,end:0,buffers:[]};for(var n=0,a=0,s=0,o=0,u=0,l=0,d=0,h=e.buffers(t,i),c=0,f=h.length;c<f;c++){var v=h[c];if(r+i>=v[0]&&r<=v[1])n=v[0],a=v[1],s=c;else{if(r+i<v[0]){o=v[0],u=v[1];break}r+i>v[1]&&(l=v[0],d=v[1])}}return{start:n,end:a,index:s,buffers:h,nextStart:o,nextEnd:u,prevStart:l,prevEnd:d,currentTime:r,behind:r-n,remaining:a?a-r:0,length:e.totalLength&&e.totalLength(h)}}},{key:"isBuffered",value:function(t,r){if(t){var i=e.get(t);if(null!=i&&i.length)for(var n=0;n<i.length;n++)if(r>=i.start(n)&&r<=i.end(n))return!0}return!1}}]),e}();function ge(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];if((t=t.filter(Boolean)).length<2)return t[0];var i=new Uint8Array(t.reduce((function(e,t){return e+t.byteLength}),0)),n=0;return t.forEach((function(e){i.set(e,n),n+=e.byteLength})),i}function me(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return new Promise((function(t){return setTimeout(t,e)}))}var ye="fetch",_e="arraybuffer",be="text",Ee=function(){R(t,I(Error));var e=M(t);function t(r,i,n,a){var s;return k(this,t),A(F(s=e.call(this,a)),"retryCount",0),A(F(s),"isTimeout",!1),A(F(s),"loaderType",ye),A(F(s),"startTime",0),A(F(s),"endTime",0),A(F(s),"options",{}),s.url=r,s.request=i,s.response=n,s}return x(t)}(),Te=Object.prototype.toString;function Se(e){if("[object Object]"!==Te.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function Le(e){if(e&&null!==e[0]&&void 0!==e[0]&&(0!==e[0]||null!==e[1]&&void 0!==e[1])){var t="bytes="+e[0]+"-";return e[1]&&(t+=e[1]),t}}function ke(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function we(e,t){if(e){if(!t)return e;var r,i=Object.keys(t).map((function(e){if(null!=(r=t[e]))return Array.isArray(r)?e+="[]":r=[r],r.map((function(t){var r;return r=t,"[object Date]"===Te.call(r)?t=t.toISOString():function(e){return null!==e&&"object"===T(e)}(t)&&(t=JSON.stringify(t)),"".concat(ke(e),"=").concat(ke(t))})).join("&")})).filter(Boolean).join("&");if(i){var n=e.indexOf("#");-1!==n&&(e=e.slice(0,n)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}}function xe(e,t,r,i,n,a,s,o,u,l,d){return n=null!=n?parseFloat(n):null,i=parseInt(i||"0",10),Number.isNaN(i)&&(i=0),{data:e,done:t,options:{range:u,vid:l,index:o,contentLength:i,age:n,startTime:a,firstByteTime:s,endTime:Date.now(),priOptions:d},response:r}}function Ae(e,t){return Math.round(8*e*1e3/t/1024)}var Re=2097152,De=function(){R(r,y());var e,t=M(r);function r(){var e;return k(this,r),A(F(e=t.call(this)),"_abortController",null),A(F(e),"_timeoutTimer",null),A(F(e),"_reader",null),A(F(e),"_response",null),A(F(e),"_aborted",!1),A(F(e),"_index",-1),A(F(e),"_range",null),A(F(e),"_receivedLength",0),A(F(e),"_running",!1),A(F(e),"_logger",null),A(F(e),"_vid",""),A(F(e),"_onProcessMinLen",0),A(F(e),"_onCancel",null),A(F(e),"_priOptions",null),e}return x(r,[{key:"load",value:function(e){var t,r=this,i=e.url,n=e.vid,a=e.timeout,s=e.responseType,o=e.onProgress,u=e.index,l=e.onTimeout,d=e.onCancel,h=e.range,c=e.transformResponse,f=e.request,v=e.params,p=e.logger,g=e.method,m=e.headers,y=e.body,_=e.mode,b=e.credentials,T=e.cache,S=e.redirect,k=e.referrer,w=e.referrerPolicy,x=e.onProcessMinLen,A=e.priOptions;this._logger=p,this._aborted=!1,this._onProcessMinLen=x,this._onCancel=d,this._abortController="undefined"!=typeof AbortController&&new AbortController,this._running=!0,this._index=u,this._range=h||[0,0],this._vid=n||i,this._priOptions=A||{};var R={method:g,headers:m,body:y,mode:_,credentials:b,cache:T,redirect:S,referrer:k,referrerPolicy:w,signal:null===(t=this._abortController)||void 0===t?void 0:t.signal},D=!1;clearTimeout(this._timeoutTimer),i=we(i,v);var C=Le(h);C&&(m=f?f.headers:R.headers=R.headers||(Headers?new Headers:{}),Headers&&m instanceof Headers?m.append("Range",C):m.Range=C),a&&(this._timeoutTimer=setTimeout((function(){if(D=!0,r.cancel(),l){var e=new Ee(i,R,null,"timeout");e.isTimeout=!0,l(e,{index:r._index,range:r._range,vid:r._vid,priOptions:r._priOptions})}}),a));var P=Date.now();return this._logger.debug("[fetch load start], index,",u,",range,",h),new Promise((function(e,t){fetch(f||i,f?void 0:R).then(function(){var n=L(E().mark((function n(a){var l,d,f,v;return E().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(clearTimeout(r._timeoutTimer),r._response=a,!r._aborted&&r._running){n.next=4;break}return n.abrupt("return");case 4:if(c&&(a=c(a,i)||a),a.ok){n.next=7;break}throw new Ee(i,R,a,"bad network response");case 7:if(l=Date.now(),s!==be){n.next=15;break}return n.next=11,a.text();case 11:d=n.sent,r._running=!1,n.next=37;break;case 15:if("json"!==s){n.next=22;break}return n.next=18,a.json();case 18:d=n.sent,r._running=!1,n.next=37;break;case 22:if(!o){n.next=29;break}return r.resolve=e,r.reject=t,r._loadChunk(a,o,P,l),n.abrupt("return");case 29:return n.next=31,a.arrayBuffer();case 31:d=n.sent,d=new Uint8Array(d),r._running=!1,f=Date.now()-P,v=Ae(d.byteLength,f),r.emit($,{speed:v,len:d.byteLength,time:f,vid:r._vid,index:r._index,range:r._range,priOptions:r._priOptions});case 37:r._logger.debug("[fetch load end], index,",u,",range,",h),e(xe(d,!0,a,a.headers.get("Content-Length"),a.headers.get("age"),P,l,u,h,r._vid,r._priOptions));case 39:case"end":return n.stop()}}),n)})));return function(e){return n.apply(this,arguments)}}()).catch((function(e){var n;clearTimeout(r._timeoutTimer),r._running=!1,r._aborted&&!D||((e=e instanceof Ee?e:new Ee(i,R,null,null===(n=e)||void 0===n?void 0:n.message)).startTime=P,e.endTime=Date.now(),e.isTimeout=D,e.options={index:r._index,range:r._range,vid:r._vid,priOptions:r._priOptions},t(e))}))}))}},{key:"cancel",value:(e=L(E().mark((function e(){return E().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._aborted){e.next=2;break}return e.abrupt("return");case 2:if(this._aborted=!0,this._running=!1,!this._response){e.next=14;break}if(e.prev=5,!this._reader){e.next=9;break}return e.next=9,this._reader.cancel();case 9:e.next=13;break;case 11:e.prev=11,e.t0=e.catch(5);case 13:this._response=this._reader=null;case 14:if(this._abortController){try{this._abortController.abort()}catch(e){}this._abortController=null}this._onCancel&&this._onCancel({index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions});case 16:case"end":return e.stop()}}),e,this,[[5,11]])}))),function(){return e.apply(this,arguments)})},{key:"_loadChunk",value:function(e,t,r,i){var n=this;if(!e.body||!e.body.getReader){this._running=!1;var a=new Ee(e.url,"",e,"onProgress of bad response.body.getReader");return a.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},void this.reject(a)}this._onProcessMinLen>0&&(this._cache=new Uint8Array(Re),this._writeIdx=0);var s,o,u,l=this._reader=e.body.getReader(),d=function(){var a=L(E().mark((function a(){var h,c,f,v,p,g,m,y;return E().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return o=Date.now(),a.prev=1,a.next=4,l.read();case 4:s=a.sent,u=Date.now(),a.next=13;break;case 8:return a.prev=8,a.t0=a.catch(1),u=Date.now(),n._aborted||(n._running=!1,a.t0.options={index:n._index,range:n._range,vid:n._vid,priOptions:n._priOptions},n.reject(a.t0)),a.abrupt("return");case 13:if(c=(null===(h=n._range)||void 0===h?void 0:h.length)>0?n._range[0]:0,f=c+n._receivedLength,!n._aborted){a.next=19;break}return n._running=!1,t(void 0,!1,{range:[f,f],vid:n._vid,index:n._index,startTime:o,endTime:u,st:r,firstByteTime:i,priOptions:n._priOptions},e),a.abrupt("return");case 19:v=s.value?s.value.byteLength:0,n._receivedLength+=v,n._logger.debug("【fetchLoader,onProgress call】,task,",n._range,", start,",f,", end,",c+n._receivedLength,", done,",s.done),n._onProcessMinLen>0?n._writeIdx+v>=n._onProcessMinLen||s.done?((p=new Uint8Array(n._writeIdx+v)).set(n._cache.slice(0,n._writeIdx),0),v>0&&p.set(s.value,n._writeIdx),n._writeIdx=0,n._logger.debug("【fetchLoader,onProgress enough】,done,",s.done,",len,",p.byteLength,", writeIdx,",n._writeIdx)):v>0&&n._writeIdx+v<Re?(n._cache.set(s.value,n._writeIdx),n._writeIdx+=v,n._logger.debug("【fetchLoader,onProgress cache】,len,",v,", writeIdx,",n._writeIdx)):v>0&&(g=new Uint8Array(n._writeIdx+v+2048),n._logger.debug("【fetchLoader,onProgress extra start】,size,",n._writeIdx+v+2048,", datalen,",v,", writeIdx,",n._writeIdx),g.set(n._cache.slice(0,n._writeIdx),0),v>0&&g.set(s.value,n._writeIdx),n._writeIdx+=v,delete n._cache,n._cache=g,n._logger.debug("【fetchLoader,onProgress extra end】,len,",v,", writeIdx,",n._writeIdx)):p=s.value,(p&&p.byteLength>0||s.done)&&t(p,s.done,{range:[n._range[0]+n._receivedLength-(p?p.byteLength:0),n._range[0]+n._receivedLength],vid:n._vid,index:n._index,startTime:o,endTime:u,st:r,firstByteTime:i,priOptions:n._priOptions},e),s.done?(m=Date.now()-r,y=Ae(n._receivedLength,m),n.emit($,{speed:y,len:n._receivedLength,time:m,vid:n._vid,index:n._index,range:n._range,priOptions:n._priOptions}),n._running=!1,n._logger.debug("[fetchLoader onProgress end],task,",n._range,",done,",s.done),n.resolve(xe(s,!0,e,e.headers.get("Content-Length"),e.headers.get("age"),r,i,n._index,n._range,n._vid,n._priOptions))):d();case 25:case"end":return a.stop()}}),a,null,[[1,8]])})));return function(){return a.apply(this,arguments)}}();d()}},{key:"receiveLen",get:function(){return this._receivedLength}},{key:"running",get:function(){return this._running},set:function(e){this._running=e}}],[{key:"isSupported",value:function(){return!("undefined"==typeof fetch)}}]),r}(),Ce=function(){R(t,y());var e=M(t);function t(){var r;return k(this,t),A(F(r=e.call(this)),"_xhr",null),A(F(r),"_aborted",!1),A(F(r),"_timeoutTimer",null),A(F(r),"_range",null),A(F(r),"_receivedLength",0),A(F(r),"_url",null),A(F(r),"_onProgress",null),A(F(r),"_index",-1),A(F(r),"_headers",null),A(F(r),"_currentChunkSizeKB",384),A(F(r),"_timeout",null),A(F(r),"_xhr",null),A(F(r),"_withCredentials",null),A(F(r),"_startTime",-1),A(F(r),"_loadCompleteResolve",null),A(F(r),"_loadCompleteReject",null),A(F(r),"_runing",!1),A(F(r),"_logger",!1),A(F(r),"_vid",""),A(F(r),"_responseType",void 0),A(F(r),"_credentials",void 0),A(F(r),"_method",void 0),A(F(r),"_transformResponse",void 0),A(F(r),"_firstRtt",void 0),A(F(r),"_onCancel",null),A(F(r),"_priOptions",null),r}return x(t,[{key:"load",value:function(e){var t=this;clearTimeout(this._timeoutTimer),this._logger=e.logger,this._range=e.range,this._onProgress=e.onProgress,this._index=e.index,this._headers=e.headers,this._withCredentials="include"===e.credentials||"same-origin"===e.credentials,this._body=e.body||null,e.method&&(this._method=e.method),this._timeout=e.timeout||null,this._runing=!0,this._vid=e.vid||e.url,this._responseType=e.responseType,this._firstRtt=-1,this._onTimeout=e.onTimeout,this._onCancel=e.onCancel,this._request=e.request,this._priOptions=e.priOptions||{},this._logger.debug("【xhrLoader task】, range",this._range),this._url=we(e.url,e.params);var r=Date.now();return new Promise((function(e,r){t._loadCompleteResolve=e,t._loadCompleteReject=r,t._startLoad()})).catch((function(e){if(clearTimeout(t._timeoutTimer),t._runing=!1,!t._aborted)throw(e=e instanceof Ee?e:new Ee(t._url,t._request)).startTime=r,e.endTime=Date.now(),e.options={index:t._index,vid:t._vid,priOptions:t._priOptions},e}))}},{key:"_startLoad",value:function(){var e=null;if(this._responseType===_e&&this._range&&this._range.length>1)if(this._onProgress){this._firstRtt=-1;var t=1024*this._currentChunkSizeKB,r=this._range[0]+this._receivedLength,i=this._range[1];t<this._range[1]-r&&(i=r+t),e=[r,i],this._logger.debug("[xhr_loader->],tast :",this._range,", SubRange, ",e)}else e=this._range,this._logger.debug("[xhr_loader->],tast :",this._range,", allRange, ",e);this._internalOpen(e)}},{key:"_internalOpen",value:function(e){var t=this;try{this._startTime=Date.now();var r=this._xhr=new XMLHttpRequest;r.open(this._method||"GET",this._url,!0),r.responseType=this._responseType,this._timeout&&(r.timeout=this._timeout),r.withCredentials=this._withCredentials,r.onload=this._onLoad.bind(this),r.onreadystatechange=this._onReadyStatechange.bind(this),r.onerror=function(e){var r,i,n;t._running=!1;var a=new Ee(t._url,t._request,null==e||null===(r=e.currentTarget)||void 0===r?void 0:r.response,"xhr.onerror.status:"+(null==e||null===(i=e.currentTarget)||void 0===i?void 0:i.status)+",statusText,"+(null==e||null===(n=e.currentTarget)||void 0===n?void 0:n.statusText));a.options={index:t._index,range:t._range,vid:t._vid,priOptions:t._priOptions},t._loadCompleteReject(a)},r.ontimeout=function(e){t.cancel();var r=new Ee(t._url,t._request,{status:408},"timeout");t._onTimeout&&(r.isTimeout=!0,t._onTimeout(r,{index:t._index,range:t._range,vid:t._vid,priOptions:t._priOptions})),r.options={index:t._index,range:t._range,vid:t._vid,priOptions:t._priOptions},t._loadCompleteReject(r)};var i=this._headers||{},n=Le(e);n&&(i.Range=n),i&&Object.keys(i).forEach((function(e){r.setRequestHeader(e,i[e])})),this._logger.debug("[xhr.send->] tast,",this._range,",load sub range, ",e),r.send(this._body)}catch(t){t.options={index:this._index,range:e,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(t)}}},{key:"_onReadyStatechange",value:function(e){2===e.target.readyState&&this._firstRtt<0&&(this._firstRtt=Date.now())}},{key:"_onLoad",value:function(e){var t,r=e.target.status;if(r<200||r>299){var i=new Ee(this._url,null,b(b({},e.target.response),{},{status:r}),"bad response,status:"+r);return i.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(i)}var n,a=null,s=!1,o=(null===(t=this._range)||void 0===t?void 0:t.length)>0?this._range[0]:0;if(this._responseType===_e){var u,l=new Uint8Array(e.target.response);if(n=o+this._receivedLength,l&&l.byteLength>0){this._receivedLength+=l.byteLength;var d=Date.now()-this._startTime,h=Ae(this._receivedLength,d);this.emit($,{speed:h,len:this._receivedLength,time:d,vid:this._vid,index:this._index,range:[n,o+this._receivedLength],priOptions:this._priOptions})}a=l,s=!((null===(u=this._range)||void 0===u?void 0:u.length)>1&&this._range[1]&&this._receivedLength<this._range[1]-this._range[0]),this._logger.debug("[xhr load done->], tast :",this._range,", start",n,"end ",o+this._receivedLength,",dataLen,",l?l.byteLength:0,",receivedLength",this._receivedLength,",index,",this._index,", done,",s)}else s=!0,a=e.target.response;var c={ok:r>=200&&r<300,status:r,statusText:this._xhr.statusText,url:this._xhr.responseURL,headers:this._getHeaders(this._xhr),body:this._xhr.response};this._transformResponse&&(c=this._transformResponse(c,this._url)||c),this._onProgress&&this._onProgress(a,s,{index:this._index,vid:this._vid,range:[n,o+this._receivedLength],startTime:this._startTime,endTime:Date.now(),priOptions:this._priOptions},c),s?(this._runing=!1,this._loadCompleteResolve&&this._loadCompleteResolve(xe(this._onProgress?null:a,s,c,c.headers["content-length"],c.headers.age,this._startTime,this._firstRtt,this._index,this._range,this._vid,this._priOptions))):this._startLoad()}},{key:"cancel",value:function(){if(!this._aborted)return this._aborted=!0,this._runing=!1,B(D(t.prototype),"removeAllListeners",this).call(this),this._onCancel&&this._onCancel({index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions}),this._xhr?this._xhr.abort():void 0}},{key:"receiveLen",get:function(){return this._receivedLength}},{key:"running",get:function(){return this._running},set:function(e){this._running=e}},{key:"_getHeaders",value:function(e){var t,r={},i=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return N(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?N(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0,n=function(){};return{s:n,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,o=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==r.return||r.return()}finally{if(o)throw a}}}}(e.getAllResponseHeaders().trim().split("\r\n"));try{for(i.s();!(t=i.n()).done;){var n=t.value.split(": ");r[n[0].toLowerCase()]=n.slice(1).join(": ")}}catch(e){i.e(e)}finally{i.f()}return r}}],[{key:"isSupported",value:function(){return"undefined"!=typeof XMLHttpRequest}}]),t}();function Pe(){var e,t,r=new Promise((function(r,i){e=r,t=i}));return r.used=!1,r.resolve=function(){return r.used=!0,e.apply(void 0,arguments)},r.reject=function(){return r.used=!0,t.apply(void 0,arguments)},r}function Oe(){try{return parseInt(performance.now(),10)}catch(e){return(new Date).getTime()}}var Ie=["retry","retryDelay","onRetryError","transformError"],Fe=function(){function e(t,r){k(this,e),this.promise=Pe(),this.alive=!!r.onProgress,!r.logger&&(r.logger=new j("Loader")),this._loaderType=t,this._loader=t===ye&&"undefined"!=typeof fetch?new De:new Ce,this._config=r,this._retryCount=0,this._retryTimer=null,this._canceled=!1,this._retryCheckFunc=r.retryCheckFunc,this._logger=r.logger}var t;return x(e,[{key:"exec",value:function(){var e=this,t=this._config,r=t.retry,i=t.retryDelay,n=t.onRetryError,a=t.transformError,s=function(e,t){if(null==e)return{};var r,i,n=function(e,t){if(null==e)return{};var r,i,n={},a=Object.keys(e);for(i=0;i<a.length;i++)r=a[i],t.indexOf(r)>=0||(n[r]=e[r]);return n}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}(t,Ie),o=function(){var t=L(E().mark((function t(){var u,l,d;return E().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e._loader.load(s);case 3:u=t.sent,e.promise.resolve(u),t.next=27;break;case 7:if(t.prev=7,t.t0=t.catch(0),e._loader.running=!1,e._logger.debug("[task request catch err]",t.t0),!e._canceled){t.next=13;break}return t.abrupt("return");case 13:if(t.t0.loaderType=e._loaderType,t.t0.retryCount=e._retryCount,l=t.t0,a&&(l=a(l)||l),n&&e._retryCount>0&&n(l,e._retryCount,{index:s.index,vid:s.vid,range:s.range,priOptions:s.priOptions}),e._retryCount++,d=!0,e._retryCheckFunc&&(d=e._retryCheckFunc(t.t0)),!(d&&e._retryCount<=r)){t.next=26;break}return clearTimeout(e._retryTimer),e._logger.debug("[task request setTimeout],retry",e._retryCount,",retry range,",s.range),e._retryTimer=setTimeout(o,i),t.abrupt("return");case 26:e.promise.reject(l);case 27:case"end":return t.stop()}}),t,null,[[0,7]])})));return function(){return t.apply(this,arguments)}}();return o(),this.promise}},{key:"cancel",value:(t=L(E().mark((function e(){return E().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return clearTimeout(this._retryTimer),this._canceled=!0,this._loader.running=!1,e.abrupt("return",this._loader.cancel());case 4:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"running",get:function(){return this._loader&&this._loader.running}},{key:"loader",get:function(){return this._loader}}]),e}(),Me=function(){R(r,y());var e,t=M(r);function r(e){var i;return k(this,r),A(F(i=t.call(this,e)),"type",ye),A(F(i),"_queue",[]),A(F(i),"_alive",[]),A(F(i),"_currentTask",null),A(F(i),"_finnalUrl",""),A(F(i),"_config",void 0),i._config=function(e){return b({loaderType:ye,retry:0,retryDelay:0,timeout:0,request:null,onTimeout:void 0,onProgress:void 0,onRetryError:void 0,transformRequest:void 0,transformResponse:void 0,transformError:void 0,responseType:be,range:void 0,url:"",params:void 0,method:"GET",headers:{},body:void 0,mode:void 0,credentials:void 0,cache:void 0,redirect:void 0,referrer:void 0,referrerPolicy:void 0,integrity:void 0,onProcessMinLen:0},e)}(e),"xhr"!==i._config.loaderType&&De.isSupported()||(i.type="xhr"),i.log=e.logger,i}return x(r,[{key:"isFetch",value:function(){return this.type===ye}},{key:"load",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};"string"!=typeof e&&e?r=e:r.url=e||r.url||this._config.url,(r=Object.assign({},this._config,r)).params&&(r.params=Object.assign({},r.params)),r.headers&&Se(r.headers)&&(r.headers=Object.assign({},r.headers)),r.body&&Se(r.body)&&(r.body=Object.assign({},r.body)),r.transformRequest&&(r=r.transformRequest(r)||r),r.logger=this.log;var i=new Fe(this.type,r);return i.loader.on($,(function(e){t.emit($,e)})),this._queue.push(i),1!==this._queue.length||this._currentTask&&this._currentTask.running||this._processTask(),i.promise}},{key:"cancel",value:(e=L(E().mark((function e(){var t;return E().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this._queue.map((function(e){return e.cancel()})).concat(this._alive.map((function(e){return e.cancel()}))),this._currentTask&&t.push(this._currentTask.cancel()),this._queue=[],this._alive=[],e.next=6,Promise.all(t);case 6:return e.next=8,me();case 8:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})},{key:"_processTask",value:function(){var e=this;if(this._currentTask=this._queue.shift(),this._currentTask){this._currentTask.alive&&this._alive.push(this._currentTask);var t=this._currentTask.exec().catch((function(e){}));t&&"function"==typeof t.finally&&t.finally((function(){var t,r;null!==(t=e._currentTask)&&void 0!==t&&t.alive&&(null===(r=e._alive)||void 0===r?void 0:r.length)>0&&(e._alive=e._alive.filter((function(t){return t&&t!==e._currentTask}))),e._processTask()}))}}}],[{key:"isFetchSupport",value:function(){return De.isSupported()}}]),r}(),Be=function(){function e(t){var r=this;k(this,e),A(this,"_seiSet",new Set),this.emitter=t,t.on(X,(function(e){e&&r._seiSet.add(e)}))}return x(e,[{key:"throw",value:function(e,t){var r=this;if(null!=e&&this._seiSet.size){var i=e-.2,n=e+.2,a=[];this._seiSet.forEach((function(e){e.time>=i&&e.time<=n&&a.push(e)})),a.forEach((function(e){r._seiSet.delete(e),r.emitter.emit("core.seiintime",e)})),t&&this._seiSet.forEach((function(t){t.time<e-5&&r._seiSet.delete(t)}))}}},{key:"reset",value:function(){this._seiSet.clear()}}]),e}(),Ne=function(){function e(t){k(this,e),A(this,"_chunkSpeed",0),A(this,"_chunkCache",[]),A(this,"_speeds",[]),A(this,"_totalSize",0),A(this,"_totalCost",0),this._opts=t||{}}return x(e,[{key:"addRecord",value:function(e,t){e&&t&&(this._speeds.push(8e3*e/t),this._speeds=this._speeds.slice(-3))}},{key:"addChunkRecord",value:function(e,t){var r,i;if(e&&t&&!(e<((null===(r=this._opts)||void 0===r?void 0:r.skipChunkSize)||1e3))){this._totalSize+=e,this._totalCost+=t,this._chunkSpeed=8e3*e/t,this._chunkCache.push({size:e,duration:t,timestamp:performance.now()});var n=(null===(i=this._opts)||void 0===i?void 0:i.chunkCountForSpeed)||50;this._chunkCache.length>n&&(this._chunkCache=this._chunkCache.slice(-n))}}},{key:"getAvgSpeed",value:function(){var e;if(!this._chunkCache.length&&!this._speeds.length)return 0;if(this._speeds.length)return this._speeds.reduce((function(e,t){return e+t}))/this._speeds.length;var t=this._chunkCache[this._chunkCache.length-1],r=performance.now()-t.timestamp;return r>((null===(e=this._opts)||void 0===e?void 0:e.longtimeNoReceived)||3e3)&&this._chunkCache.push({size:0,duration:r,timestamp:performance.now()}),8e3*this._chunkCache.reduce((function(e,t){return e+t.size}),0)/this._chunkCache.reduce((function(e,t){return e+t.duration}),0)}},{key:"getLatestSpeed",value:function(){return this._chunkCache.length||this._speeds.length?this._speeds.length?this._speeds[this._speeds.length-1]:this._chunkSpeed:0}},{key:"getTotalSize",value:function(){return this._totalSize}},{key:"getTotalCost",value:function(){return this._totalCost}},{key:"reset",value:function(){this._chunkCache=[],this._speeds=[],this._totalSize=0,this._totalCost=0}}]),e}(),Ue=function(){function e(t){k(this,e),A(this,"encodeType",""),A(this,"audioCodec",""),A(this,"videoCodec",""),A(this,"domain",""),A(this,"fps",0),A(this,"bitrate",0),A(this,"width",0),A(this,"height",0),A(this,"samplerate",0),A(this,"channelCount",0),A(this,"gop",0),A(this,"_bitsAccumulateSize",0),A(this,"_bitsAccumulateDuration",0),A(this,"_startGopId",-1),this._timescale=t}return x(e,[{key:"getStats",value:function(){return{encodeType:this.encodeType,audioCodec:this.audioCodec,videoCodec:this.videoCodec,domain:this.domain,fps:this.fps,bitrate:this.bitrate,width:this.width,height:this.height,samplerate:this.samplerate,channelCount:this.channelCount,gop:this.gop}}},{key:"setEncodeType",value:function(e){this.encodeType=e}},{key:"setFpsFromScriptData",value:function(e){var t,r=e.data,i=null==r||null===(t=r.onMetaData)||void 0===t?void 0:t.framerate;i&&i>0&&i<100&&(this.fps=i)}},{key:"setVideoMeta",value:function(e){if(this.width=e.width,this.height=e.height,this.videoCodec=e.codec,this.encodeType=e.codecType,e.fpsNum&&e.fpsDen){var t=e.fpsNum/e.fpsDen;t>0&&t<100&&(this.fps=t)}}},{key:"setAudioMeta",value:function(e){this.audioCodec=e.codec,this.samplerate=e.sampleRate,this.channelCount=e.channelCount}},{key:"setDomain",value:function(e){this.domain=e.split("/").slice(2,3)[0]}},{key:"updateBitrate",value:function(e){var t=this;if((!this.fps||this.fps>=100)&&e.length){var r=e.reduce((function(e,t){return e+t.duration}),0)/e.length;this.fps=Math.round(this._timescale/r)}e.forEach((function(e){-1===t._startGopId&&(t._startGopId=e.gopId),e.gopId===t._startGopId&&t.gop++,t._bitsAccumulateDuration+=e.duration/(t._timescale/1e3),t._bitsAccumulateSize+=e.units.reduce((function(e,t){return e+t.length}),0),t._bitsAccumulateDuration>=1e3&&(t.bitrate=8*t._bitsAccumulateSize,t._bitsAccumulateDuration=0,t._bitsAccumulateSize=0)}))}}]),e}(),Ge=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3;k(this,e),A(this,"_core",null),A(this,"_samples",[]),this._core=t,this._timescale=r,this._stats=new Ue(r),this._bindEvents()}return x(e,[{key:"getStats",value:function(){var e,t,r,i,n,a,s,o,u,l,d,h=(null===(e=this._core)||void 0===e?void 0:e.media)||{},c=h.currentTime,f=void 0===c?0:c,v=h.decodeFps,p=void 0===v?0:v;return b(b({},this._stats.getStats()),{},{downloadSpeed:(null===(t=this._core)||void 0===t||null===(r=t.speedInfo)||void 0===r?void 0:r.call(t).speed)||0,avgSpeed:(null===(i=this._core)||void 0===i||null===(n=i.speedInfo)||void 0===n?void 0:n.call(i).avgSpeed)||0,totalReceivedByte:(null===(a=this._core)||void 0===a||null===(s=a.speedInfo)||void 0===s?void 0:s.call(a).totalSize)||0,totalReceivedCost:(null===(o=this._core)||void 0===o||null===(u=o.speedInfo)||void 0===u?void 0:u.call(o).totalCost)||0,currentTime:f,bufferEnd:(null===(l=this._core)||void 0===l||null===(d=l.bufferInfo())||void 0===d?void 0:d.remaining)||0,decodeFps:p})}},{key:"_bindEvents",value:function(){var e=this;this._core.on(J,(function(t){var r=t.videoTrack;return e._stats.updateBitrate(r.samples)})),this._core.on(Q,(function(t){e._stats.setFpsFromScriptData(t)})),this._core.on(Y,(function(t){"video"===t.type?e._stats.setVideoMeta(t.track):e._stats.setAudioMeta(t.track)})),this._core.on(q,(function(t){e._stats.setDomain(t.responseUrl)}))}},{key:"reset",value:function(){this._samples=[],this._stats=new Ue(this._timescale)}}]),e}(),Ve=function(){function e(){k(this,e),A(this,"_prevCurrentTime",0)}return x(e,[{key:"do",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,r=arguments.length>2?arguments[2]:void 0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;if(e){var n=e.currentTime,a=0;if(this._prevCurrentTime===n){var s=pe.info(pe.get(e),n);if(!s.buffers.length)return;r&&s.nextStart||s.nextStart&&s.nextStart-n<t?a=s.nextStart+.1:s.end&&s.end-n>i&&!e.seeking&&(a=n+.1)}this._prevCurrentTime=n,a&&n!==a&&(e.currentTime=a)}}}]),e}(),je="undefined"!=typeof window;function He(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];try{return je?e&&"undefined"!=typeof ManagedMediaSource?ManagedMediaSource:window.MediaSource:null}catch(e){}}function Ke(e){return/ManagedMediaSource/gi.test(Object.prototype.toString.call(e))}var ze="updateDuration",We=function(){function e(t,r){var i=this;k(this,e),A(this,"media",null),A(this,"mediaSource",null),A(this,"_openPromise",Pe()),A(this,"_queue",Object.create(null)),A(this,"_sourceBuffer",Object.create(null)),A(this,"_mseFullFlag",{}),A(this,"_st",0),A(this,"_opst",0),A(this,"_logger",null),A(this,"_config",null),A(this,"_url",null),A(this,"_onStartStreaming",(function(){i._logger.debug("startstreaming")})),A(this,"_onEndStreaming",(function(){i._logger.debug("endstreaming")})),A(this,"_onSBUpdateEnd",(function(e){var t=i._queue[e];if(t){var r=t[0];if((null==r?void 0:r.opName)!==ze&&t.shift(),r){var n,a,s=Oe()-i._opst;i._logger.debug("UpdateEnd(".concat(e,"/").concat(r.opName,")"),function(e){try{return JSON.stringify(e)}catch(e){return""}}(function(e){var t=[];if(e instanceof TimeRanges)for(var r=0;r<e.length;r++)t.push({start:e.start(r),end:e.end(r)});return t}(null===(n=i._sourceBuffer[e])||void 0===n?void 0:n.buffered)),s,r.context),r.promise.resolve({name:r.opName,context:r.context,costtime:s});var o=null===(a=r.context)||void 0===a?void 0:a.callback;o&&"function"==typeof o&&o(r.context),i._startQueue(e)}}})),A(this,"_onSBUpdateError",(function(e,t){var r=i._queue[e];if(r){var n=r[0];n&&(i._logger.error("UpdateError",e,n.opName,n.context),n.promise.reject(new ve(ne,le,t)))}})),this._config=Object.assign(e.getDefaultConfig(),r),t&&this.bindMedia(t),this._logger=new j("MSE"),this._config.openLog&&j.enable()}var t,r,i;return x(e,[{key:"isOpened",get:function(){var e;return"open"===(null===(e=this.mediaSource)||void 0===e?void 0:e.readyState)}},{key:"hasOpTasks",get:function(){var e=this,t=!1;return Object.keys(this._queue).forEach((function(r){var i=e._queue[r];Array.isArray(i)&&(t||(t=i.length>0))})),t}},{key:"url",get:function(){return this._url}},{key:"duration",get:function(){var e;return(null===(e=this.mediaSource)||void 0===e?void 0:e.duration)||-1}},{key:"isEnded",get:function(){return!!this.mediaSource&&"ended"===this.mediaSource.readyState}},{key:"streaming",get:function(){return!Ke(this.mediaSource)||this.mediaSource.streaming}},{key:"isFull",value:function(t){return t?this._mseFullFlag[t]:this._mseFullFlag[e.VIDEO]}},{key:"updateDuration",value:function(e){var t=this,r=this.mediaSource&&this.mediaSource.duration>e;if(this.mediaSource&&this.mediaSource.duration>e){var i=0;if(Object.keys(this._sourceBuffer).forEach((function(e){try{i=Math.max(t.bufferEnd(e)||0,i)}catch(e){}})),e<i)return Promise.resolve()}return this._enqueueBlockingOp((function(){t.isEnded?t._logger.debug("setDuration but ended"):t.mediaSource&&(t.mediaSource.duration=e,t._logger.debug("setDuration",e))}),ze,{isReduceDuration:r})}},{key:"open",value:function(){var e=this;if(this._openPromise.used&&!this.isOpened&&this.mediaSource){var t=this.mediaSource;t.addEventListener("sourceopen",(function r(){var i=Oe()-e._st;e._logger.debug("sourceopen",i),t.removeEventListener("sourceopen",r),e._openPromise.resolve({costtime:i})})),this._openPromise=Pe()}return this._openPromise}},{key:"bindMedia",value:(i=L(E().mark((function e(t){var r,i,n,a,s=this;return E().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.mediaSource&&!this.media){e.next=3;break}return e.next=3,this.unbindMedia();case 3:if(r=He(this._config.preferMMS),t&&r){e.next=6;break}throw new Error("Param media or MediaSource does not exist");case 6:return this.media=t,i=this.mediaSource=new r,n=Ke(i),this._st=Oe(),a=function e(){var r=Oe()-s._st;s._logger.debug("sourceopen"),i.removeEventListener("sourceopen",e),URL.revokeObjectURL(t.src),s._openPromise.resolve({costtime:r})},i.addEventListener("sourceopen",a),n&&(i.addEventListener("startstreaming",this._onStartStreaming),i.addEventListener("endstreaming",this._onEndStreaming)),this._url=URL.createObjectURL(i),t.src=this._url,t.disableRemotePlayback=n,e.abrupt("return",this._openPromise);case 17:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"unbindMedia",value:(r=L(E().mark((function e(){var t,r,i,n=this;return E().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._openPromise.used||this._openPromise.resolve(),t=this.mediaSource){if(Object.keys(this._queue).forEach((function(e){var t=n._queue[e];t&&t.forEach((function(e){var t,r;return null===(t=e.promise)||void 0===t||null===(r=t.resolve)||void 0===r?void 0:r.call(t)}))})),r=!!this.media&&this.media.readyState>=1,i="open"===t.readyState,r&&i)try{t.endOfStream()}catch(e){}Object.keys(this._sourceBuffer).forEach((function(e){try{t.removeSourceBuffer(n._sourceBuffer[e])}catch(e){}})),Ke(t)&&(t.removeEventListener("startstreaming",this._onStartStreaming),t.removeEventListener("endstreaming",this._onEndStreaming))}if(this.media){this.media.disableRemotePlayback=!1,this.media.removeAttribute("src");try{this.media.load()}catch(e){}this.media=null}this.mediaSource=null,this._openPromise=Pe(),this._queue=Object.create(null),this._sourceBuffer=Object.create(null);case 8:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"createSource",value:function(e,t){if(!this._sourceBuffer[e]&&this.mediaSource){var r;try{r=this._sourceBuffer[e]=this.mediaSource.addSourceBuffer(t)}catch(e){throw new ve(ne,ue,e)}r.mimeType=t,r.addEventListener("updateend",this._onSBUpdateEnd.bind(this,e)),r.addEventListener("error",this._onSBUpdateError.bind(this,e))}}},{key:"changeType",value:function(e,t){var r=this,i=this._sourceBuffer[e];return this.mediaSource&&i&&i.mimeType!==t?"function"!=typeof i.changeType?Promise.reject(new ve(ne,ce,new Error("changeType is not a function"))):this._enqueueOp(e,(function(){try{i.changeType(t)}catch(e){throw new ve(ne,ce,e)}i.mimeType=t,r._onSBUpdateEnd(e)}),"changeType",{mimeType:t}):Promise.resolve()}},{key:"createOrChangeSource",value:function(e,t){return this.createSource(e,t),this.changeType(e,t)}},{key:"append",value:function(e,t,r){var i=this;return t&&t.byteLength&&this._sourceBuffer[e]?this._enqueueOp(e,(function(){var n;i.mediaSource&&!i.media.error&&(i._logger.debug("MSE APPEND START",r),i._opst=Oe(),null===(n=i._sourceBuffer[e])||void 0===n||n.appendBuffer(t))}),"appendBuffer",r):Promise.resolve()}},{key:"remove",value:function(e,t,r,i){var n=this,a=!1;return this._mseFullFlag[e]&&(a=!0),this._enqueueOp(e,(function(){if(n.mediaSource&&!n.media.error){var a=n._sourceBuffer[e];t>=r||!a?n._onSBUpdateEnd(e):(n._opst=Oe(),n._logger.debug("MSE REMOVE START",e,t,r,i),a.remove(t,r))}}),"removeBuffer",i,a)}},{key:"clearBuffer",value:function(e,t){var r,i=this;return Object.keys(this._sourceBuffer).forEach((function(n){r=i.remove(n,e,t)})),r||Promise.resolve()}},{key:"clearAllBuffer",value:function(){var e,t=this;return Object.keys(this._sourceBuffer).forEach((function(r){var i=t._sourceBuffer[r];e=t.remove(r,0,pe.end(pe.get(i)))})),e}},{key:"clearOpQueues",value:function(e,t){var r;this._logger.debug("MSE clearOpQueue START");var i=this._queue[e];if(t&&i)this._queue[e]=[];else if(i&&i[e]&&!(i.length<5)){var n=[];i.forEach((function(e){e.context&&e.context.isinit&&n.push(e)})),this._queue[e]=i.slice(0,2),n.length>0&&(r=this._queue[e]).push.apply(r,n)}}},{key:"endOfStream",value:function(e){var t=this;return this.mediaSource&&"open"===this.mediaSource.readyState?this._enqueueBlockingOp((function(){var r=t.mediaSource;r&&"open"===r.readyState&&(t._logger.debug("MSE endOfStream START"),e?r.endOfStream(e):r.endOfStream())}),"endOfStream"):Promise.resolve()}},{key:"setLiveSeekableRange",value:function(e,t){var r=this.mediaSource;e<0||t<e||null==r||!r.setLiveSeekableRange||"open"!==r.readyState||r.setLiveSeekableRange(e,t)}},{key:"getSourceBuffer",value:function(e){return this._sourceBuffer[e]}},{key:"buffered",value:function(e){return pe.get(this._sourceBuffer[e])}},{key:"bufferStart",value:function(e){return pe.start(this.buffered(e))}},{key:"bufferEnd",value:function(e){return pe.end(this.buffered(e))}},{key:"_enqueueOp",value:function(e,t,r,i,n){var a=this;if(!this.mediaSource)return Promise.resolve();var s=this._queue[e]=this._queue[e]||[],o={exec:t,promise:Pe(),opName:r,context:i};return n?(s.splice(0,0,o),this._mseFullFlag[e]=!1,this._startQueue(e)):s.push(o),this.isOpened||this.isEnded?1===s.length&&this._startQueue(e):this._openPromise.then((function(){1===s.length&&a._startQueue(e)})),o.promise}},{key:"_enqueueBlockingOp",value:(t=L(E().mark((function e(t,r,i){var n,a,s=this;return E().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.mediaSource){e.next=2;break}return e.abrupt("return",Promise.resolve());case 2:if((n=Object.keys(this._sourceBuffer)).length){e.next=5;break}return e.abrupt("return",t());case 5:return a=[],n.forEach((function(e){var t=s._queue[e],n=Pe();a.push(n),t.push({exec:function(){n.resolve()},promise:n,opName:r,context:i}),1===t.length&&s._startQueue(e)})),e.abrupt("return",Promise.all(a).then((function(){try{return t()}finally{n.forEach((function(e){var t=s._queue[e],r=s._sourceBuffer[e];null==t||t.shift(),r&&r.updating||s._startQueue(e)}))}})));case 8:case"end":return e.stop()}}),e,this)}))),function(e,r,i){return t.apply(this,arguments)})},{key:"_startQueue",value:function(e){var t=this._queue[e];if(t){var r=t[0];if(r&&!this._mseFullFlag[e])try{r.exec()}catch(i){i&&i.message&&i.message.indexOf("SourceBuffer is full")>=0?(this._mseFullFlag[e]=!0,r.context&&"object"===T(r.context)&&(r.context.isFull=!0),this._logger.error("[MSE error], context,",r.context," ,name,",r.opName,",err,SourceBuffer is full"),r.promise.reject(new ve(ne,he,i))):(this._logger.error(i),r.promise.reject(i.constructor===ve?i:new ve(ne,de,i)),t.shift(),this._startQueue(e))}}}},{key:"setTimeoffset",value:function(e,t,r){var i=this;return this._enqueueOp(e,(function(){t<0&&(t+=.001),i._sourceBuffer[e].timestampOffset=t,i._onSBUpdateEnd(e)}),"setTimeoffset",r)}},{key:"abort",value:function(e,t){var r=this;return this.isOpened?this._enqueueOp(e,(function(){r._sourceBuffer[e].abort(),r._onSBUpdateEnd(e)}),"abort",t):Promise.resolve()}}],[{key:"isSupported",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:'video/mp4; codecs="avc1.42E01E,mp4a.40.2"',t=He();if(!t)return!1;try{return t.isTypeSupported(e)}catch(t){return this._logger.error(e,t),!1}}},{key:"isMMSOnly",value:function(){return"undefined"!=typeof ManagedMediaSource&&"undefined"==typeof MediaSource}},{key:"getDefaultConfig",value:function(){return{openLog:!1,preferMMS:!1}}}]),e}();function qe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Ye(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,nt(i.key),i)}}function Xe(e,t,r){return t&&Ye(e.prototype,t),r&&Ye(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Qe(e,t,r){return(t=nt(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Je(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&$e(e,t)}function Ze(e){return(Ze=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function $e(e,t){return($e=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function et(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,i=Ze(e);if(t){var n=Ze(this).constructor;r=Reflect.construct(i,arguments,n)}else r=i.apply(this,arguments);return function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,r)}}function tt(e){return function(e){if(Array.isArray(e))return it(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||rt(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function rt(e,t){if(e){if("string"==typeof e)return it(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?it(e,t):void 0}}function it(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function nt(e){var t=function(e){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}A(We,"VIDEO","video"),A(We,"AUDIO","audio");var at=function(){function e(t){qe(this,e),this.name=t||"",this._prefix="[".concat(this.name,"]")}return Xe(e,[{key:"warn",value:function(){var t;if(!e.disabled){for(var r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];(t=console).warn.apply(t,[this._prefix].concat(i))}}}],[{key:"enable",value:function(){e.disabled=!1}},{key:"disable",value:function(){e.disabled=!0}}]),e}();Qe(at,"disabled",!0);var st="video",ot="hevc",ut="aac",lt="g7110a",dt="g7110m",ht="opus",ct="LARGE_AV_SHIFT",ft="LARGE_VIDEO_GAP",vt="LARGE_VIDEO_GAP_BETWEEN_CHUNK",pt="LARGE_AUDIO_GAP",gt="AUDIO_FILLED",mt="AUDIO_DROPPED",yt=function(){function e(){qe(this,e),Qe(this,"id",1),Qe(this,"type",st),Qe(this,"codecType","avc"),Qe(this,"pid",-1),Qe(this,"hvcC",void 0),Qe(this,"codec",""),Qe(this,"timescale",0),Qe(this,"formatTimescale",0),Qe(this,"sequenceNumber",0),Qe(this,"baseMediaDecodeTime",0),Qe(this,"baseDts",0),Qe(this,"duration",0),Qe(this,"warnings",[]),Qe(this,"samples",[]),Qe(this,"pps",[]),Qe(this,"sps",[]),Qe(this,"vps",[]),Qe(this,"fpsNum",0),Qe(this,"fpsDen",0),Qe(this,"sarRatio",[]),Qe(this,"width",0),Qe(this,"height",0),Qe(this,"nalUnitSize",4),Qe(this,"present",!1),Qe(this,"isVideoEncryption",!1),Qe(this,"isAudioEncryption",!1),Qe(this,"isVideo",!0),Qe(this,"lastKeyFrameDts",0),Qe(this,"kid",null),Qe(this,"pssh",null),Qe(this,"ext",void 0)}return Xe(e,[{key:"reset",value:function(){this.sequenceNumber=this.width=this.height=this.fpsDen=this.fpsNum=this.duration=this.baseMediaDecodeTime=this.timescale=0,this.codec="",this.present=!1,this.pid=-1,this.pps=[],this.sps=[],this.vps=[],this.sarRatio=[],this.samples=[],this.warnings=[],this.hvcC=null}},{key:"firstDts",get:function(){return this.samples.length?this.samples[0].dts:null}},{key:"firstPts",get:function(){return this.samples.length?this.samples[0].pts:null}},{key:"samplesDuration",get:function(){if(this.samples.length>0){var e=this.samples[0],t=this.samples[this.samples.length-1];return t.dts-e.dts+t.duration}return 0}},{key:"exist",value:function(){return!!/av01/.test(this.codec)||!!(this.pps.length&&this.sps.length&&this.codec)}},{key:"hasSample",value:function(){return!!this.samples.length}},{key:"isEncryption",get:function(){return this.isVideoEncryption}}]),e}(),_t=function(){function e(){qe(this,e),Qe(this,"id",2),Qe(this,"type","audio"),Qe(this,"codecType",ut),Qe(this,"pid",-1),Qe(this,"codec",""),Qe(this,"sequenceNumber",0),Qe(this,"sampleDuration",0),Qe(this,"timescale",0),Qe(this,"formatTimescale",0),Qe(this,"baseMediaDecodeTime",0),Qe(this,"duration",0),Qe(this,"warnings",[]),Qe(this,"samples",[]),Qe(this,"baseDts",0),Qe(this,"sampleSize",16),Qe(this,"sampleRate",0),Qe(this,"channelCount",0),Qe(this,"objectType",0),Qe(this,"sampleRateIndex",0),Qe(this,"config",[]),Qe(this,"present",!1),Qe(this,"isVideoEncryption",!1),Qe(this,"isAudioEncryption",!1),Qe(this,"kid",null),Qe(this,"ext",void 0)}return Xe(e,[{key:"reset",value:function(){this.sequenceNumber=0,this.timescale=0,this.sampleDuration=0,this.sampleRate=0,this.channelCount=0,this.baseMediaDecodeTime=0,this.present=!1,this.pid=-1,this.codec="",this.samples=[],this.config=[],this.warnings=[]}},{key:"exist",value:function(){return!(!(this.sampleRate&&this.channelCount&&this.codec)||this.codecType!==ut&&this.codecType!==lt&&this.codecType!==dt&&this.codecType!==ht)}},{key:"hasSample",value:function(){return!!this.samples.length}},{key:"isEncryption",get:function(){return this.isAudioEncryption}},{key:"firstDts",get:function(){return this.samples.length?this.samples[0].dts:null}},{key:"firstPts",get:function(){return this.samples.length?this.samples[0].pts:null}},{key:"samplesDuration",get:function(){if(this.samples.length>0){var e=this.samples[0],t=this.samples[this.samples.length-1];return t.dts-e.dts+t.duration}return 0}}]),e}(),bt=function(){function e(t,r,i){qe(this,e),Qe(this,"flag",{}),Qe(this,"keyframe",!1),Qe(this,"gopId",0),Qe(this,"duration",0),Qe(this,"size",0),Qe(this,"units",[]),Qe(this,"chromaFormat",420),this.originPts=this.pts=t,this.originDts=this.dts=r,i&&(this.units=i)}return Xe(e,[{key:"cts",get:function(){return this.pts-this.dts}},{key:"setToKeyframe",value:function(){this.keyframe=!0,this.flag.dependsOn=2,this.flag.isNonSyncSample=0}}]),e}(),Et=Xe((function e(t,r,i,n){qe(this,e),Qe(this,"duration",1024),Qe(this,"flag",{dependsOn:2,isNonSyncSample:0}),Qe(this,"keyframe",!0),this.originPts=this.pts=this.dts=t,this.data=r,this.size=r.byteLength,this.sampleOffset=n,i&&(this.duration=i)})),Tt=Xe((function e(t,r){qe(this,e),Qe(this,"time",0),this.data=t,this.originPts=this.pts=r})),St=function(){Je(t,Tt);var e=et(t);function t(){return qe(this,t),e.apply(this,arguments)}return Xe(t)}(),Lt=function(){Je(t,Tt);var e=et(t);function t(){return qe(this,t),e.apply(this,arguments)}return Xe(t)}(),kt=function(){function e(){qe(this,e),Qe(this,"id",3),Qe(this,"type","metadata"),Qe(this,"timescale",0),Qe(this,"flvScriptSamples",[]),Qe(this,"seiSamples",[])}return Xe(e,[{key:"exist",value:function(){return!(!this.flvScriptSamples.length&&!this.seiSamples.length||!this.timescale)}},{key:"reset",value:function(){this.timescale=0,this.flvScriptSamples=[],this.seiSamples=[]}},{key:"hasSample",value:function(){return!(!this.flvScriptSamples.length&&!this.seiSamples.length)}}]),e}(),wt="undefined"!=typeof window,xt=wt&&navigator.userAgent.toLocaleLowerCase(),At=wt&&/^((?!chrome|android).)*safari/.test(xt),Rt=wt&&xt.includes("firefox"),Dt=wt&&xt.includes("android"),Ct=function(){function e(){qe(this,e)}return Xe(e,null,[{key:"getRateIndexByRate",value:function(t){return e.FREQ.indexOf(t)}},{key:"parseADTS",value:function(t,r){for(var i=t.length,n=0;n+2<i&&(255!==t[n]||240!=(246&t[n+1]));)n++;if(!(n>=i)){var a=n,s=[],o=(60&t[n+2])>>>2,u=e.FREQ[o];if(!u)throw new Error("Invalid sampling index: ".concat(o));for(var l,d,h=1+((192&t[n+2])>>>6),c=(1&t[n+2])<<2|(192&t[n+3])>>>6,f=e._getConfig(o,c,h),v=f.config,p=f.codec,g=0,m=e.getFrameDuration(u);n+7<i;)if(255===t[n]&&240==(246&t[n+1])){if(!(d=(3&t[n+3])<<11|t[n+4]<<3|(224&t[n+5])>>5)||i-n<d)break;l=2*(1&~t[n+1]),s.push({pts:r+g*m,data:t.subarray(n+7+l,n+d)}),g++,n+=d}else n++;return{skip:a,remaining:n>=i?void 0:t.subarray(n),frames:s,samplingFrequencyIndex:o,sampleRate:u,objectType:h,channelCount:c,codec:p,config:v,originCodec:"mp4a.40.".concat(h)}}}},{key:"parseAudioSpecificConfig",value:function(t){if(t.length){var r=t[0]>>>3,i=(7&t[0])<<1|t[1]>>>7,n=(120&t[1])>>>3,a=e.FREQ[i];if(a){var s=e._getConfig(i,n,r);return{samplingFrequencyIndex:i,sampleRate:a,objectType:r,channelCount:n,config:s.config,codec:s.codec,originCodec:"mp4a.40.".concat(r)}}}}},{key:"getFrameDuration",value:function(e){return 1024*(arguments.length>1&&void 0!==arguments[1]?arguments[1]:9e4)/e}},{key:"_getConfig",value:function(e,t,r){var i,n,a=[];return Rt?e>=6?(i=5,n=e-3):(i=2,n=e):Dt?(i=2,n=e):(i=2===r||5===r?r:5,n=e,e>=6?n=e-3:1===t&&(i=2,n=e)),a[0]=i<<3,a[0]|=(14&e)>>1,a[1]=(1&e)<<7,a[1]|=t<<3,5===i&&(a[1]|=(14&n)>>1,a[2]=(1&n)<<7,a[2]|=8,a[3]=0),{config:a,codec:"mp4a.40.".concat(i)}}},{key:"getSilentFrame",value:function(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}}}]),e}();Qe(Ct,"FREQ",[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350]);var Pt=function(){function e(){qe(this,e)}return Xe(e,null,[{key:"getFrameDuration",value:function(e){return 20}},{key:"parseHeaderPackets",value:function(e){if(e.length){for(var t=new DataView(e.buffer,e.byteOffset,e.byteLength),r="",i=0;i<8;i++)r+=String.fromCodePoint(e[i]);if("OpusHead"!==r)throw new Error("Invalid Opus MagicSignature");var n=e[9];console.log("Pre-skip",e[10],e[11]);var a=t.getUint32(12,!0),s=t.getInt16(16,!0);if(a)return{outputGain:s,sampleRate:a,channelCount:n,config:new Uint8Array(e.buffer,e.byteOffset+8,e.byteLength-8),codec:"opus",originCodec:"opus"}}}}]),e}(),Ot=5e3,It=function(){function e(t,r,i){qe(this,e),this.videoTrack=t,this.audioTrack=r,this.metadataTrack=i,this._baseDts=-1,this._baseDtsInited=!1,this._audioNextPts=void 0,this._videoNextDts=void 0,this._audioTimestampBreak=0,this._videoTimestampBreak=0,this._lastVideoDuration=0,this._keyFrameInNextChunk=!1,this._lastAudioExceptionGapDot=-1/0,this._lastAudioExceptionOverlapDot=-1/0,this._lastAudioExceptionLargeGapDot=-1/0,this._lastVideoExceptionLargeGapDot=-1/0,this._lastVideoExceptionChunkFirstDtsDot=-1/0}return Xe(e,[{key:"fix",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];t=Math.round(1e3*t);var n=this.videoTrack,a=this.audioTrack;if(!r&&i||(this._videoLastSample=null,this._audioNextPts=void 0,this._videoNextDts=void 0,this._audioTimestampBreak=0,this._videoTimestampBreak=0,this._lastAudioExceptionGapDot=-1/0,this._lastAudioExceptionOverlapDot=-1/0,this._lastAudioExceptionLargeGapDot=-1/0,this._lastVideoExceptionLargeGapDot=-1/0,this._lastVideoExceptionChunkFirstDtsDot=-1/0),r&&!i&&(this._baseDtsInited=!1),this._baseDtsInited||this._calculateBaseDts(a,n),!i&&t&&(this._audioNextPts=this._videoNextDts=t),this._baseDtsInited&&(this._videoTimestampBreak||!this.videoTrack.exist())&&(this._audioTimestampBreak||!this.audioTrack.exist())&&this._resetBaseDtsWhenStreamBreaked(),this._fixAudio(a),this._keyFrameInNextChunk=!1,this._fixVideo(n),this.metadataTrack.exist()){var s=this.metadataTrack.timescale;this.metadataTrack.seiSamples.forEach((function(t){t.pts=t.originPts-e._baseDts,t.time=Math.max(0,t.pts)/s})),this.metadataTrack.flvScriptSamples.forEach((function(t){t.pts=t.originPts-e._baseDts,t.time=Math.max(0,t.pts)/s}))}n.samples.length&&(n.baseMediaDecodeTime=n.samples[0].dts),a.samples.length&&(a.baseMediaDecodeTime=a.samples[0].pts*a.timescale/1e3)}},{key:"_fixVideo",value:function(e){var t=this,r=e.samples;if(r.length){var i;if(r.forEach((function(e){e.dts-=t._baseDts,e.pts-=t._baseDts,e.keyframe&&(t._keyFrameInNextChunk=!0)})),e.fpsNum&&e.fpsDen)i=e.timescale*(e.fpsDen/e.fpsNum);else if(e.length>1){var n=e.samples[0],a=e.samples[r.length-1];i=Math.floor((a.dts-n.dts)/(r.length-1))}else i=this._lastVideoDuration||40;var s=r.pop();if(this._videoLastSample&&r.unshift(this._videoLastSample),this._videoLastSample=s,r.length){if(void 0===this._videoNextDts){var o=r[0];this._videoNextDts=o.dts}var u,l=r.length,d=0,h=r[0],c=this._videoNextDts-h.dts;if(Math.abs(c)>200)Math.abs(h.dts-this._lastVideoExceptionChunkFirstDtsDot)>5e3&&(this._lastVideoExceptionChunkFirstDtsDot=h.dts,e.warnings.push({type:vt,nextDts:this._videoNextDts,firstSampleDts:h.dts,nextSampleDts:null===(u=r[1])||void 0===u?void 0:u.dts,sampleDuration:c})),this._videoTimestampBreak>=5?(this._videoNextDts=h.dts,this._videoTimestampBreak=0):(h.dts+=c,h.pts+=c,this.audioTrack.exist()||(this._videoTimestampBreak=1));for(var f=0;f<l;f++){var v=r[f].dts,p=r[f+1];((d=f<l-1?p.dts-v:s?s.dts-v:i)>1e3||d<0)&&(this._videoTimestampBreak++,Math.abs(v-this._lastVideoExceptionLargeGapDot)>5e3&&(this._lastVideoExceptionLargeGapDot=v,e.warnings.push({type:ft,time:v/e.timescale,dts:v,originDts:r[f].originDts,nextDts:this._videoNextDts,sampleDuration:d,refSampleDuration:i})),d=i),r[f].duration=d,this._videoNextDts+=d,this._lastVideoDuration=d}}}}},{key:"_fixAudio",value:function(e){var t=this,r=e.samples;r.length&&(r.forEach((function(e){e.dts=e.pts-=t._baseDts})),this._doFixAudioInternal(e,r,1e3))}},{key:"_calculateBaseDts",value:function(e,t){var r=e.samples,i=t.samples;if(!r.length&&!i.length)return!1;var n=1/0,a=1/0;r.length&&(e.baseDts=n=r[0].pts),i.length&&(t.baseDts=a=i[0].dts),this._baseDts=Math.min(n,a);var s=a-n;return Number.isFinite(s)&&Math.abs(s)>500&&t.warnings.push({type:ct,videoBaseDts:a,audioBasePts:n,baseDts:this._baseDts,delta:s}),this._baseDtsInited=!0,!0}},{key:"_resetBaseDtsWhenStreamBreaked",value:function(){this._calculateBaseDts(this.audioTrack,this.videoTrack)&&(this.audioTrack.exist()?this.videoTrack.exist()?this._baseDts-=Math.min(this._audioNextPts,this._videoNextDts):this._baseDts-=this._audioNextPts:this._baseDts-=this._videoNextDts,this._videoTimestampBreak=0,this._audioTimestampBreak=0)}},{key:"_doFixAudioInternal",value:function(e,t,r){if(!e.sampleDuration)switch(e.codecType){case ut:e.sampleDuration=Ct.getFrameDuration(e.timescale,r);break;case ht:e.sampleDuration=Pt.getFrameDuration(e.samples,r);break;case lt:case dt:e.sampleDuration=this._getG711Duration(e);break;default:console.error("can't fix audio codecType:",e.codecType)}var i=e.sampleDuration,n=e.codecType===ht?20:e.codecType===ut?1024:i*e.timescale/1e3;if(void 0===this._audioNextPts){var a=t[0];this._audioNextPts=a.pts}for(var s=0;s<t.length;s++){var o=this._audioNextPts,u=t[s],l=u.pts-o;if(0===s&&this._audioTimestampBreak>=5&&this._keyFrameInNextChunk&&(o=this._audioNextPts=u.dts,l=0,this._audioTimestampBreak=0),!this._audioTimestampBreak&&l>=3*i&&l<=1e3&&!At){var d=this._getSilentFrame(e)||t[0].data.subarray(),h=Math.floor(l/i);Math.abs(u.pts-this._lastAudioExceptionGapDot)>Ot&&(this._lastAudioExceptionGapDot=u.pts,e.warnings.push({type:gt,pts:u.pts,originPts:u.originPts,count:h,nextPts:o,refSampleDuration:i}));for(var c=0;c<h;c++){var f=new Et(Math.floor(this._audioNextPts+i)-Math.floor(this._audioNextPts),d,n);f.originPts=Math.floor(this._baseDts+o),t.splice(s,0,f),this._audioNextPts+=i,s++}s--}else if(l<=-3*i&&l>=-1e3)Math.abs(u.pts-this._lastAudioExceptionOverlapDot)>Ot&&(this._lastAudioExceptionOverlapDot=u.pts,e.warnings.push({type:mt,pts:u.pts,originPts:u.originPts,nextPts:o,refSampleDuration:i})),t.splice(s,1),s--;else{if(Math.abs(l)>1e3&&(this._audioTimestampBreak++,Math.abs(u.pts-this._lastAudioExceptionLargeGapDot)>Ot&&(this._lastAudioExceptionLargeGapDot=u.pts,e.warnings.push({type:pt,time:u.pts/1e3,pts:u.pts,originPts:u.originPts,nextPts:o,sampleDuration:l,refSampleDuration:i}))),e.codecType===ht){var v=t[t.length-1];v&&(v.duration=u.pts-v.pts)}else u.dts=u.pts=o,u.duration=n;this._audioNextPts+=i}}}},{key:"_getG711Duration",value:function(e){var t=e.sampleSize,r=e.channelCount,i=e.sampleRate,n=e.samples[0];if(n)return 2*n.data.byteLength/r/(t/8)/i*1e3}},{key:"_getSilentFrame",value:function(e){return e.codecType===ut?Ct.getSilentFrame(e.codec,e.channelCount):new Uint8Array(8*e.sampleDuration*e.channelCount)}}]),e}();function Ft(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];t=t.filter(Boolean);var i=new Uint8Array(t.reduce((function(e,t){return e+t.byteLength}),0)),n=0;return t.forEach((function(e){i.set(e,n),n+=e.byteLength})),i}function Mt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return(e[t]<<24>>>0)+(e[t+1]<<16)+(e[t+2]<<8)+(e[t+3]||0)}function Bt(e){for(var t,r="avc1.",i=0;i<3;i++)(t=e[i].toString(16)).length<2&&(t="0".concat(t)),r+=t;return r}function Nt(e){if(!Array.isArray(e)){for(var t=[],r="",i=0;i<e.length;i++)i%2&&(r=e[i-1]+e[i],t.push(parseInt(r,16)),r="");return t}return e.map((function(e){return parseInt(e,16)}))}Math.pow(2,32);var Ut=function(){function e(){qe(this,e)}return Xe(e,null,[{key:"parseAnnexB",value:function(e){for(var t=e.length,r=2,i=0;null!==e[r]&&void 0!==e[r]&&1!==e[r];)r++;if((i=2+ ++r)>=t)return[];for(var n=[];i<t;)switch(e[i]){case 0:if(0!==e[i-1]){i+=2;break}if(0!==e[i-2]){i++;break}r!==i-2&&n.push(e.subarray(r,i-2));do{i++}while(1!==e[i]&&i<t);i=(r=i+1)+2;break;case 1:if(0!==e[i-1]||0!==e[i-2]){i+=3;break}r!==i-2&&n.push(e.subarray(r,i-2)),i=(r=i+1)+2;break;default:i+=3}return r<t&&n.push(e.subarray(r)),n}},{key:"parseAvcC",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4;if(!(e.length<4)){for(var r,i=e.length,n=[],a=0;a+t<i;)if(r=Mt(e,a),3===t&&(r>>>=8),a+=t,r){if(a+r>i)break;n.push(e.subarray(a,a+r)),a+=r}return n}}},{key:"parseSEI",value:function(e,t){for(var r=e.length,i=t?2:1,n=0,a=0,s="";255===e[i];)n+=255,i++;for(n+=e[i++];255===e[i];)a+=255,i++;if(a+=e[i++],5===n&&r>i+16)for(var o=0;o<16;o++)s+=e[i].toString(16),i++;return{payload:e.subarray(i,i+a),type:n,size:a,uuid:s}}},{key:"removeEPB",value:function(e){for(var t=e.byteLength,r=[],i=1;i<t-2;)0===e[i]&&0===e[i+1]&&3===e[i+2]?(r.push(i+2),i+=2):i++;if(!r.length)return e;var n=t-r.length,a=new Uint8Array(n),s=0;for(i=0;i<n;s++,i++)s===r[0]&&(s++,r.shift()),a[i]=e[s];return a}}]),e}(),Gt=function(){function e(t){if(qe(this,e),Qe(this,"_bytesAvailable",void 0),Qe(this,"_bitsAvailable",0),Qe(this,"_word",0),!t)throw new Error("ExpGolomb data params is required");this._data=t,this._bytesAvailable=t.byteLength,this._bytesAvailable&&this._loadWord()}return Xe(e,[{key:"bitsAvailable",get:function(){return this._bitsAvailable}},{key:"_loadWord",value:function(){var e=this._data.byteLength-this._bytesAvailable,t=Math.min(4,this._bytesAvailable);if(0===t)throw new Error("No bytes available");var r=new Uint8Array(4);r.set(this._data.subarray(e,e+t)),this._word=new DataView(r.buffer).getUint32(0),this._bitsAvailable=8*t,this._bytesAvailable-=t}},{key:"skipBits",value:function(e){if(this._bitsAvailable>e)this._word<<=e,this._bitsAvailable-=e;else{e-=this._bitsAvailable;var t=Math.floor(e/8);e-=8*t,this._bytesAvailable-=t,this._loadWord(),this._word<<=e,this._bitsAvailable-=e}}},{key:"readBits",value:function(e){if(e>32)throw new Error("Cannot read more than 32 bits");var t=Math.min(this._bitsAvailable,e),r=this._word>>>32-t;return this._bitsAvailable-=t,this._bitsAvailable>0?this._word<<=t:this._bytesAvailable>0&&this._loadWord(),(t=e-t)>0&&this._bitsAvailable?r<<t|this.readBits(t):r}},{key:"skipLZ",value:function(){var e;for(e=0;e<this._bitsAvailable;++e)if(this._word&2147483648>>>e)return this._word<<=e,this._bitsAvailable-=e,e;return this._loadWord(),e+this.skipLZ()}},{key:"skipUEG",value:function(){this.skipBits(1+this.skipLZ())}},{key:"readUEG",value:function(){var e=this.skipLZ();return this.readBits(e+1)-1}},{key:"readEG",value:function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}},{key:"readBool",value:function(){return 1===this.readBits(1)}},{key:"readUByte",value:function(){return this.readBits(8)}},{key:"skipScalingList",value:function(e){for(var t=8,r=8,i=0;i<e;i++)0!==r&&(r=(t+this.readEG()+256)%256),t=0===r?t:r}}]),e}(),Vt=function(){function e(){qe(this,e)}return Xe(e,null,[{key:"parseAVCDecoderConfigurationRecord",value:function(t){if(!(t.length<7)){for(var r,i,n=1+(3&t[4]),a=[],s=[],o=6,u=31&t[5],l=0;l<u;l++)if(i=t[o]<<8|t[o+1],o+=2,i){var d=t.subarray(o,o+i);o+=i,a.push(d),r||(r=e.parseSPS(Ut.removeEPB(d)))}var h,c=t[o];o++;for(var f=0;f<c;f++)h=t[o]<<8|t[o+1],o+=2,h&&(s.push(t.subarray(o,o+h)),o+=h);return{sps:r,spsArr:a,ppsArr:s,nalUnitSize:n}}}},{key:"parseSPS",value:function(e){var t=new Gt(e);t.readUByte();var r=t.readUByte(),i=t.readUByte(),n=t.readUByte();t.skipUEG();var a=420;if(100===r||110===r||122===r||244===r||44===r||83===r||86===r||118===r||128===r||138===r||144===r){var s=t.readUEG();if(s<=3&&(a=[0,420,422,444][s]),3===s&&t.skipBits(1),t.skipUEG(),t.skipUEG(),t.skipBits(1),t.readBool())for(var o=3!==s?8:12,u=0;u<o;u++)t.readBool()&&(u<6?t.skipScalingList(16):t.skipScalingList(64))}t.skipUEG();var l=t.readUEG();if(0===l)t.readUEG();else if(1===l){t.skipBits(1),t.skipUEG(),t.skipUEG();for(var d=t.readUEG(),h=0;h<d;h++)t.skipUEG()}t.skipUEG(),t.skipBits(1);var c=t.readUEG(),f=t.readUEG(),v=t.readBits(1);0===v&&t.skipBits(1),t.skipBits(1);var p,g,m,y,_,b=0,E=0,T=0,S=0;if(t.readBool()&&(b=t.readUEG(),E=t.readUEG(),T=t.readUEG(),S=t.readUEG()),t.readBool()){if(t.readBool())switch(t.readUByte()){case 1:p=[1,1];break;case 2:p=[12,11];break;case 3:p=[10,11];break;case 4:p=[16,11];break;case 5:p=[40,33];break;case 6:p=[24,11];break;case 7:p=[20,11];break;case 8:p=[32,11];break;case 9:p=[80,33];break;case 10:p=[18,11];break;case 11:p=[15,11];break;case 12:p=[64,33];break;case 13:p=[160,99];break;case 14:p=[4,3];break;case 15:p=[3,2];break;case 16:p=[2,1];break;case 255:p=[t.readUByte()<<8|t.readUByte(),t.readUByte()<<8|t.readUByte()]}if(t.readBool()&&t.readBool(),t.readBool()&&(t.readBits(4),t.readBool()&&t.readBits(24)),t.readBool()&&(t.readUEG(),t.readUEG()),t.readBool()){var L=t.readBits(32),k=t.readBits(32);g=t.readBool(),_=(m=k)/(y=2*L)}}return{codec:Bt(e.subarray(1,4)),profileIdc:r,profileCompatibility:i,levelIdc:n,chromaFormat:a,width:Math.ceil(16*(c+1)-2*(b+E)),height:(2-v)*(f+1)*16-(v?2:4)*(T+S),sarRatio:p,fpsNum:m,fpsDen:y,fps:_,fixedFrame:g}}}]),e}(),jt=function(){function e(){qe(this,e)}return Xe(e,null,[{key:"parseHEVCDecoderConfigurationRecord",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(t.length<23)){r=r||{};for(var i,n,a,s,o,u=1+(3&t[21]),l=[],d=[],h=[],c=23,f=t[22],v=0;v<f;v++){a=63&t[c],s=t[c+1]<<8|t[c+2],c+=3;for(var p=0;p<s;p++)if(o=t[c]<<8|t[c+1],c+=2,o){switch(a){case 32:var g=t.subarray(c,c+o);i||(i=e.parseVPS(Ut.removeEPB(g),r)),h.push(g);break;case 33:var m=t.subarray(c,c+o);n||(n=e.parseSPS(Ut.removeEPB(m),r)),l.push(m);break;case 34:d.push(t.subarray(c,c+o))}c+=o}}return{hvcC:r,sps:n,spsArr:l,ppsArr:d,vpsArr:h,nalUnitSize:u}}}},{key:"parseVPS",value:function(t,r){r=r||{};var i=new Gt(t);i.readUByte(),i.readUByte(),i.readBits(12);var n=i.readBits(3);return r.numTemporalLayers=Math.max(r.numTemporalLayers||0,n+1),i.readBits(17),e._parseProfileTierLevel(i,n,r),r}},{key:"parseSPS",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};r=r||{};var i=new Gt(t);i.readUByte(),i.readUByte(),i.readBits(4);var n=i.readBits(3);r.numTemporalLayers=Math.max(n+1,r.numTemporalLayers||0),r.temporalIdNested=i.readBits(1),e._parseProfileTierLevel(i,n,r),i.readUEG();var a=r.chromaFormatIdc=i.readUEG(),s=420;a<=3&&(s=[0,420,422,444][a]);var o=0;3===a&&(o=i.readBits(1));var u,l,d,h,c=i.readUEG(),f=i.readUEG(),v=i.readBits(1);return 1===v&&(u=i.readUEG(),l=i.readUEG(),d=i.readUEG(),h=i.readUEG()),r.bitDepthLumaMinus8=i.readUEG(),r.bitDepthChromaMinus8=i.readUEG(),1===v&&(c-=(1!==a&&2!==a||0!==o?1:2)*(l+u),f-=(1===a&&0===o?2:1)*(h+d)),{codec:"hev1.1.6.L93.B0",width:c,height:f,chromaFormat:s,hvcC:r}}},{key:"_parseProfileTierLevel",value:function(e,t,r){var i=r.generalTierFlag||0;r.generalProfileSpace=e.readBits(2),r.generalTierFlag=Math.max(e.readBits(1),i),r.generalProfileIdc=Math.max(e.readBits(5),r.generalProfileIdc||0),r.generalProfileCompatibilityFlags=e.readBits(32),r.generalConstraintIndicatorFlags=[e.readBits(8),e.readBits(8),e.readBits(8),e.readBits(8),e.readBits(8),e.readBits(8)];var n=e.readBits(8);i<r.generalTierFlag?r.generalLevelIdc=n:r.generalLevelIdc=Math.max(n,r.generalLevelIdc||0);var a=[],s=[];if(t>e.bitsAvailable)throw new Error("maxSubLayersMinus inavlid size ".concat(t));for(var o=0;o<t;o++)a[o]=e.readBits(1),s[o]=e.readBits(1);t>0&&e.readBits(2*(8-t));for(var u=0;u<t;u++)0!==a[u]&&(e.readBits(2),e.readBits(1),e.readBits(5),e.readBits(16),e.readBits(16),e.readBits(4),e.readBits(16),e.readBits(16),e.readBits(12)),0!==s[u]&&e.readBits(8)}}]),e}(),Ht=function(){function e(){qe(this,e)}return Xe(e,null,[{key:"decode",value:function(t){for(var r=[],i=t,n=0,a=t.length;n<a;)if(i[n]<128)r.push(String.fromCharCode(i[n])),++n;else{if(i[n]<192);else if(i[n]<224){if(e._checkContinuation(i,n,1)){var s=(31&i[n])<<6|63&i[n+1];if(s>=128){r.push(String.fromCharCode(65535&s)),n+=2;continue}}}else if(i[n]<240){if(e._checkContinuation(i,n,2)){var o=(15&i[n])<<12|(63&i[n+1])<<6|63&i[n+2];if(o>=2048&&55296!=(63488&o)){r.push(String.fromCharCode(65535&o)),n+=3;continue}}}else if(i[n]<248&&e._checkContinuation(i,n,3)){var u=(7&i[n])<<18|(63&i[n+1])<<12|(63&i[n+2])<<6|63&i[n+3];if(u>65536&&u<1114112){u-=65536,r.push(String.fromCharCode(u>>>10|55296)),r.push(String.fromCharCode(1023&u|56320)),n+=4;continue}}r.push(String.fromCharCode(65533)),++n}return r.join("")}},{key:"_checkContinuation",value:function(e,t,r){var i=e;if(t+r<i.length){for(;r--;)if(128!=(192&i[++t]))return!1;return!0}return!1}}]),e}(),Kt=function(){function e(){qe(this,e)}return Xe(e,null,[{key:"parse",value:function(t){if(!(t.length<3)){var r={},i=e._parseValue(new DataView(t.buffer,t.byteOffset,t.byteLength)),n=e._parseValue(new DataView(t.buffer,t.byteOffset+i.size,t.byteLength-i.size));return r[i.data]=n.data,r}}},{key:"_parseValue",value:function(t){var r,i=t.byteLength,n=1,a=!1;switch(t.getUint8(0)){case 0:r=t.getFloat64(1),n+=8;break;case 1:r=!!t.getUint8(1),n+=1;break;case 2:var s=e._parseString(new DataView(t.buffer,t.byteOffset+n,t.byteLength-n));r=s.data,n+=s.size;break;case 3:r={};var o=0;for(9==(16777215&t.getUint32(i-4))&&(o=3);n<i-4;){var u=e._parseObject(new DataView(t.buffer,t.byteOffset+n,t.byteLength-n-o)),l=u.size,d=u.data;if(u.isEnd)break;r[d.name]=d.value,n+=l}n<=i-3&&9==(16777215&t.getUint32(n-1))&&(n+=3);break;case 8:r={},n+=4;var h=0;for(9==(16777215&t.getUint32(i-4))&&(h=3);n<i-8;){var c=e._parseObject(new DataView(t.buffer,t.byteOffset+n,t.byteLength-n-h)),f=c.size,v=c.data;if(c.isEnd)break;r[v.name]=v.value,n+=f}n<=i-3&&9==(16777215&t.getUint32(n-1))&&(n+=3);break;case 9:r=void 0,n=1,a=!0;break;case 10:r=[];var p=t.getUint32(1);n+=4;for(var g=0;g<p;g++){var m=e._parseValue(new DataView(t.buffer,t.byteOffset+n,t.byteLength-n)),y=m.data,_=m.size;r.push(y),n+=_}break;case 11:var b=t.getFloat64(n)+6e4*t.getInt16(n+8);r=new Date(b),n+=10;break;case 12:var E=t.getUint32(1);n+=4,r="",E>0&&(r=Ht.decode(new Uint8Array(t.buffer,t.byteOffset+n,E))),n+=E;break;default:n=i}return{data:r,size:n,isEnd:a}}},{key:"_parseString",value:function(e){var t=e.getUint16(0),r="";return t>0&&(r=Ht.decode(new Uint8Array(e.buffer,e.byteOffset+2,t))),{data:r,size:2+t}}},{key:"_parseObject",value:function(t){if(!(t.byteLength<3)){var r=e._parseString(t),i=e._parseValue(new DataView(t.buffer,t.byteOffset+r.size,t.byteLength-r.size));return{data:{name:r.data,value:i.data},size:r.size+i.size,isEnd:i.isEnd}}}}]),e}(),zt=new at("FlvDemuxer"),Wt=function(){function e(t,r,i){qe(this,e),Qe(this,"_headerParsed",!1),Qe(this,"_remainingData",null),Qe(this,"_gopId",0),Qe(this,"_needAddMetaBeforeKeyFrameNal",!0),this.videoTrack=t||new yt,this.audioTrack=r||new _t,this.metadataTrack=i||new kt,this._fixer=new It(this.videoTrack,this.audioTrack,this.metadataTrack)}return Xe(e,[{key:"demux",value:function(t){var r,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],a=arguments.length>3?arguments[3]:void 0,s=this.audioTrack,o=this.videoTrack,u=this.metadataTrack;if(!i&&n||(this._remainingData=null),i&&(this._headerParsed=!1),i?(o.reset(),s.reset(),u.reset()):(o.samples=[],s.samples=[],u.seiSamples=[],u.flvScriptSamples=[],o.warnings=[],s.warnings=[],this._remainingData&&(t=Ft(this._remainingData,t),this._remainingData=null)),!t.length)return{videoTrack:o,audioTrack:s,metadataTrack:u};var l=0;if(!this._headerParsed){if(!e.probe(t))throw new Error("Invalid flv file");s.present=(4&t[4])>>>2!=0,o.present=!!(1&t[4]),this._headerParsed=!0,l=Mt(t,5)+4}for(var d,h,c,f,v,p=t.length;l+15<p&&(d=t[l],!(l+15+(h=t[l+1]<<16|t[l+2]<<8|t[l+3])>p));)c=(t[l+7]<<24>>>0)+(t[l+4]<<16)+(t[l+5]<<8)+t[l+6],l+=11,f=t.subarray(l,l+h),8===d?this._parseAudio(f,c):9===d?(a&&(this.seamlessLoadingSwitching=!0),this._parseVideo(f,c)):18===d?this._parseScript(f,c):zt.warn("Invalid tag type: ".concat(d)),(v=Mt(t,l+=h))!==11+h&&zt.warn("Invalid PrevTagSize ".concat(v," (").concat(11+h,")")),l+=4;l<p&&(this._remainingData=t.subarray(l)),s.formatTimescale=o.formatTimescale=o.timescale=u.timescale=1e3,s.timescale=s.codecType===ht?1e3:s.sampleRate||0,!s.exist()&&s.hasSample()&&s.reset(),!o.exist()&&o.hasSample()&&o.reset();var g=u.flvScriptSamples[u.flvScriptSamples.length-1],m=null==g||null===(r=g.data)||void 0===r?void 0:r.onMetaData;return m&&(null!=o&&o.exist()&&(m.hasOwnProperty("duration")&&(o.duration=1e3*m.duration),m.hasOwnProperty("width")&&m.hasOwnProperty("height")&&(o.width=m.width,o.height=m.height)),null!=s&&s.exist()&&m.hasOwnProperty("duration")&&(s.duration=1e3*m.duration)),{videoTrack:o,audioTrack:s,metadataTrack:u}}},{key:"fix",value:function(e,t,r){return this._fixer.fix(e,t,r),{videoTrack:this.videoTrack,audioTrack:this.audioTrack,metadataTrack:this.metadataTrack}}},{key:"demuxAndFix",value:function(e,t,r,i,n){return this.demux(e,t,r,n),this.fix(i,t,r)}},{key:"_parseAudio",value:function(t,r){if(t.length){var i=(240&t[0])>>>4,n=this.audioTrack;if(10!==i&&7!==i&&8!==i&&13!==i)return zt.warn("Unsupported sound format: ".concat(i)),void n.reset();if(10!==i&&13!==i){var a=(12&t[0])>>2,s=(2&t[0])>>1,o=1&t[0];n.sampleRate=e.AUDIO_RATE[a],n.sampleSize=s?16:8,n.channelCount=o+1}switch(i){case 7:case 8:this._parseG711(t,r,i);break;case 10:this._parseAac(t,r);break;case 13:this._parseOpus(t,r)}}}},{key:"_parseOpus",value:function(e,t){var r=this.audioTrack,i=e[1];switch(r.codecType=ht,i){case 0:var n=Pt.parseHeaderPackets(e.subarray(2));n?(r.codec=n.codec,r.channelCount=n.channelCount,r.sampleRate=n.sampleRate,r.config=n.config,r.sampleDuration=Pt.getFrameDuration([],r.timescale)):(r.reset(),zt.warn("Cannot parse AudioSpecificConfig",e));break;case 1:if(null==t)return;var a=new Et(t,e.subarray(2),r.sampleDuration);r.samples.push(a);break;default:zt.warn("Unknown OpusPacketType: ".concat(i))}}},{key:"_parseG711",value:function(e,t,r){var i=this.audioTrack;i.codecType=7===r?lt:dt,i.sampleRate=8e3,i.codec=i.codecType,i.samples.push(new Et(t,e.subarray(1)))}},{key:"_parseAac",value:function(e,t){var r=this.audioTrack;if(r.codecType=ut,0===e[1]){var i=Ct.parseAudioSpecificConfig(e.subarray(2));i?(r.codec=i.codec,r.channelCount=i.channelCount,r.sampleRate=i.sampleRate,r.config=i.config,r.objectType=i.objectType,r.sampleRateIndex=i.samplingFrequencyIndex):(r.reset(),zt.warn("Cannot parse AudioSpecificConfig",e))}else if(1===e[1]){if(null==t)return;r.samples.push(new Et(t,e.subarray(2)))}else zt.warn("Unknown AACPacketType: ".concat(e[1]))}},{key:"_parseVideo",value:function(e,t){var r=this;if(!(e.length<6)){var i=(240&e[0])>>>4,n=15&e[0],a=this.videoTrack;if(7!==n&&12!==n)return a.reset(),void zt.warn("Unsupported codecId: ".concat(n));var s=12===n;a.codecType=s?ot:"avc";var o=e[1],u=(e[2]<<16|e[3]<<8|e[4])<<8>>8;if(0===o){var l=e.subarray(5),d=s?jt.parseHEVCDecoderConfigurationRecord(l):Vt.parseAVCDecoderConfigurationRecord(l);if(d){var h=d.hvcC,c=d.sps,f=d.ppsArr,v=d.spsArr,p=d.vpsArr,g=d.nalUnitSize;h&&(a.hvcC=a.hvcC||h),c&&(a.codec=c.codec,a.width=c.width,a.height=c.height,a.sarRatio=c.sarRatio,a.fpsNum=c.fpsNum,a.fpsDen=c.fpsDen),v.length&&(a.sps=v),f.length&&(a.pps=f),p&&p.length&&(a.vps=p),g&&(a.nalUnitSize=g)}else zt.warn("Cannot parse ".concat(s?"HEVC":"AVC","DecoderConfigurationRecord"),e)}else if(1===o){var m=Ut.parseAvcC(e.subarray(5),a.nalUnitSize);if((m=this._checkAddMetaNalToUnits(s,m,a))&&m.length){var y=new bt(t+u,t,m);if(this.seamlessLoadingSwitching&&t<a.lastKeyFrameDts)return;this.seamlessLoadingSwitching=!1,1===i&&(y.setToKeyframe(),a.lastKeyFrameDts=t),a.samples.push(y),m.forEach((function(e){var i=s?e[0]>>>1&63:31&e[0];switch(i){case 5:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:if(!s&&5!==i||s&&5===i)break;y.setToKeyframe();break;case 6:case 39:case 40:if(!s&&6!==i||s&&6===i)break;r.metadataTrack.seiSamples.push(new Lt(Ut.parseSEI(Ut.removeEPB(e),s),t+u))}})),y.keyframe&&this._gopId++,y.gopId=this._gopId}else zt.warn("Cannot parse NALUs",e)}else 2===o||zt.warn("Unknown AVCPacketType: ".concat(o))}}},{key:"_checkAddMetaNalToUnits",value:function(e,t,r){return e&&this._needAddMetaBeforeKeyFrameNal?t.map((function(e){return e[0]>>>1&63})).includes(32)?(this._needAddMetaBeforeKeyFrameNal=!1,t):(t.unshift(r.pps[0]),t.unshift(r.sps[0]),t.unshift(r.vps[0]),t.filter(Boolean)):(this._needAddMetaBeforeKeyFrameNal=!1,t)}},{key:"_parseScript",value:function(e,t){this.metadataTrack.flvScriptSamples.push(new St(Kt.parse(e),t))}}],[{key:"probe",value:function(e){return 70===e[0]&&76===e[1]&&86===e[2]&&1===e[3]&&Mt(e,5)>=9}}]),e}();Qe(Wt,"AUDIO_RATE",[5500,11e3,22e3,44e3]);var qt=function(){function e(){qe(this,e),this.buffer=new Uint8Array(0)}return Xe(e,[{key:"write",value:function(){for(var e=this,t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];r.forEach((function(t){t?e.buffer=function(e){for(var t=0,r=arguments.length,i=new Array(r>1?r-1:0),n=1;n<r;n++)i[n-1]=arguments[n];i.forEach((function(e){t+=e.length}));var a=new e(t),s=0;return i.forEach((function(e){a.set(e,s),s+=e.length})),a}(Uint8Array,e.buffer,t):window.console.warn(t)}))}}],[{key:"writeUint16",value:function(e){return new Uint8Array([e>>8&255,255&e])}},{key:"writeUint32",value:function(e){return new Uint8Array([e>>24,e>>16&255,e>>8&255,255&e])}}]),e}(),Yt=Math.pow(2,32)-1,Xt=function(){function e(){qe(this,e)}return Xe(e,null,[{key:"box",value:function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];var n=8+(r=r.filter(Boolean)).reduce((function(e,t){return e+t.byteLength}),0),a=new Uint8Array(n);a[0]=n>>24&255,a[1]=n>>16&255,a[2]=n>>8&255,a[3]=255&n,a.set(e,4);var s=8;return r.forEach((function(e){a.set(e,s),s+=e.byteLength})),a}},{key:"ftyp",value:function(t){return t.find((function(e){return e.type===st&&e.codecType===ot}))?e.FTYPHEV1:e.FTYPAVC1}},{key:"initSegment",value:function(t){return Ft(e.ftyp(t),e.moov(t))}},{key:"pssh",value:function(t){var r=new Uint8Array([1,0,0,0].concat([16,119,239,236,192,178,77,2,172,227,60,30,82,226,251,75],[0,0,0,1],Nt(t.kid),[0,0,0,0]));return e.box(e.types.pssh,r)}},{key:"moov",value:function(t){if(t[0].useEME&&(t[0].encv||t[0].enca)){t[0].pssh||(t[0].pssh={kid:t[0].kid});var r=this.pssh(t[0].pssh);return e.box.apply(e,[e.types.moov,e.mvhd(t[0].mvhdDurtion||t[0].duration,t[0].mvhdTimecale||t[0].timescale),e.mvex(t)].concat(tt(t.map((function(t){return e.trak(t)}))),[r]))}return e.box.apply(e,[e.types.moov,e.mvhd(t[0].mvhdDurtion||t[0].duration,t[0].mvhdTimecale||t[0].timescale)].concat(tt(t.map((function(t){return e.trak(t)}))),[e.mvex(t)]))}},{key:"mvhd",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9e4;return e.box(e.types.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,255&r,t>>24&255,t>>16&255,t>>8&255,255&t,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]))}},{key:"trak",value:function(t){return e.box(e.types.trak,e.tkhd(t.id,t.tkhdDuration||0,t.width,t.height),e.mdia(t))}},{key:"tkhd",value:function(t,r){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;return e.box(e.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,t>>24&255,t>>16&255,t>>8&255,255&t,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,i>>8&255,255&i,0,0,n>>8&255,255&n,0,0]))}},{key:"mdia",value:function(t){return e.box(e.types.mdia,e.mdhd(t.duration,t.timescale),e.hdlr(t.type),e.minf(t))}},{key:"mdhd",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9e4;return e.box(e.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,255&r,t>>24&255,t>>16&255,t>>8&255,255&t,85,196,0,0]))}},{key:"hdlr",value:function(t){return e.box(e.types.hdlr,e.HDLR_TYPES[t])}},{key:"minf",value:function(t){return e.box(e.types.minf,t.type===st?e.VMHD:e.SMHD,e.DINF,e.stbl(t))}},{key:"stbl",value:function(t){var r=[];return t&&t.ext&&t.ext.stss&&r.push(e.stss(t.ext.stss.entries)),e.box(e.types.stbl,e.stsd(t),e.STTS,r[0],e.STSC,e.STSZ,e.STCO)}},{key:"stsd",value:function(t){var r;return r="audio"===t.type?t.useEME&&t.enca?e.enca(t):t.codecType===ht?e.opus(t):e.mp4a(t):t.useEME&&t.encv?e.encv(t):t.av1C?e.av01(t):e.avc1hev1(t),e.box(e.types.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),r)}},{key:"enca",value:function(t){var r=t.enca.channelCount,i=t.enca.sampleRate,n=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,r,0,16,0,0,0,0,i>>8&255,255&i,0,0]),a=e.esds(t.config),s=e.sinf(t.enca);return e.box(e.types.enca,n,a,s)}},{key:"encv",value:function(t){var r,i,n=t.sps.length>0?t.sps[0]:[],a=t.pps.length>0?t.pps[0]:[],s=t.width,o=t.height,u=t.sarRatio[0],l=t.sarRatio[1],d=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,s>>8&255,255&s,o>>8&255,255&o,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),h=new Uint8Array((r=(i=[1,n[1],n[2],n[3],255,225,n.length>>>8&255,255&n.length]).concat.apply(i,tt(n)).concat([1,a.length>>>8&255,255&a.length])).concat.apply(r,tt(a))),c=new Uint8Array([0,0,88,57,0,15,200,192,0,4,86,72]),f=e.sinf(t.encv),v=new Uint8Array([u>>24,u>>16&255,u>>8&255,255&u,l>>24,l>>16&255,l>>8&255,255&l]);return e.box(e.types.encv,d,e.box(e.types.avcC,h),e.box(e.types.btrt,c),f,e.box(e.types.pasp,v))}},{key:"schi",value:function(t){var r=new Uint8Array([]),i=e.tenc(t);return e.box(e.types.schi,r,i)}},{key:"tenc",value:function(t){var r=new Uint8Array([0,0,0,0,0,0,255&t.default_IsEncrypted,255&t.default_IV_size].concat(Nt(t.default_KID)));return e.box(e.types.tenc,r)}},{key:"sinf",value:function(t){var r=new Uint8Array([]),i=new Uint8Array([t.data_format.charCodeAt(0),t.data_format.charCodeAt(1),t.data_format.charCodeAt(2),t.data_format.charCodeAt(3)]),n=new Uint8Array([0,0,0,0,99,101,110,99,0,1,0,0]),a=e.schi(t);return e.box(e.types.sinf,r,e.box(e.types.frma,i),e.box(e.types.schm,n),a)}},{key:"av01",value:function(t){return e.box(e.types.av01,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,t.width>>8&255,255&t.width,t.height>>8&255,255&t.height,0,72,0,0,0,72,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),t.av1C,t.colr)}},{key:"avc1hev1",value:function(t){var r=t.codecType===ot,i=r?e.types.hvc1:e.types.avc1,n=r?e.hvcC(t):e.avcC(t),a=[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.width>>8&255,255&t.width,t.height>>8&255,255&t.height,0,72,0,0,0,72,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),n];return r?a.push(e.box(e.types.fiel,new Uint8Array([1,0]))):t.sarRatio&&t.sarRatio.length>1&&a.push(e.pasp(t.sarRatio)),e.box.apply(e,[i].concat(a))}},{key:"avcC",value:function(t){var r,i,n,a=[],s=[];return t.sps.forEach((function(e){n=e.byteLength,a.push(n>>>8&255),a.push(255&n),a.push.apply(a,tt(e))})),t.pps.forEach((function(e){n=e.byteLength,s.push(n>>>8&255),s.push(255&n),s.push.apply(s,tt(e))})),e.box(e.types.avcC,new Uint8Array((r=(i=[1,a[3],a[4],a[5],255,224|t.sps.length]).concat.apply(i,a).concat([t.pps.length])).concat.apply(r,s)))}},{key:"hvcC",value:function(t){var r=t.hvcC;if(r instanceof ArrayBuffer||r instanceof Uint8Array)return r;var i,n=t.vps,a=t.sps,s=t.pps;if(r){var o=r.generalProfileCompatibilityFlags,u=r.generalConstraintIndicatorFlags,l=(n.length&&1)+(a.length&&1)+(s.length&&1);i=[1,r.generalProfileSpace<<6|r.generalTierFlag<<5|r.generalProfileIdc,o>>>24,o>>>16,o>>>8,o,u[0],u[1],u[2],u[3],u[4],u[5],r.generalLevelIdc,240,0,252,252|r.chromaFormatIdc,248|r.bitDepthLumaMinus8,248|r.bitDepthChromaMinus8,0,0,r.numTemporalLayers<<3|r.temporalIdNested<<2|3,l];var d=function(e){var t;i.push(e.length>>8,e.length),(t=i).push.apply(t,tt(e))};n.length&&(i.push(160,0,n.length),n.forEach(d)),a.length&&(i.push(161,0,a.length),a.forEach(d)),s.length&&(i.push(162,0,s.length),s.forEach(d))}else i=[1,1,96,0,0,0,144,0,0,0,0,0,93,240,0,252,253,248,248,0,0,15,3,160,0,1,0,24,64,1,12,1,255,255,1,96,0,0,3,0,144,0,0,3,0,0,3,0,93,153,152,9,161,0,1,0,45,66,1,1,1,96,0,0,3,0,144,0,0,3,0,0,3,0,93,160,2,128,128,45,22,89,153,164,147,43,154,128,128,128,130,0,0,3,0,2,0,0,3,0,50,16,162,0,1,0,7,68,1,193,114,180,98,64];return e.box(e.types.hvcC,new Uint8Array(i))}},{key:"pasp",value:function(t){var r,i,n=(i=2,function(e){if(Array.isArray(e))return e}(r=t)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var i,n,a,s,o=[],u=!0,l=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(i=a.call(r)).done)&&(o.push(i.value),o.length!==t);u=!0);}catch(e){l=!0,n=e}finally{try{if(!u&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(l)throw n}}return o}}(r,i)||rt(r,i)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),a=n[0],s=n[1];return e.box(e.types.pasp,new Uint8Array([a>>24,a>>16&255,a>>8&255,255&a,s>>24,s>>16&255,s>>8&255,255&s]))}},{key:"mp4a",value:function(t){return e.box(e.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,t.sampleRate>>8&255,255&t.sampleRate,0,0]),t.config.length?e.esds(t.config):void 0)}},{key:"esds",value:function(t){var r=t.length;return e.box(e.types.esds,new Uint8Array([0,0,0,0,3,23+r,0,0,0,4,15+r,64,21,0,6,0,0,0,218,192,0,0,218,192,5].concat([r]).concat(t).concat([6,1,2])))}},{key:"opus",value:function(t){var r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,t.sampleRate>>8&255,255&t.sampleRate,0,0]),i=t.config.length?e.dOps(t):[];return e.box(e.types.Opus,r,i)}},{key:"dOps",value:function(t){if(t.config)return t.config[4]=t.sampleRate>>>24&255,t.config[5]=t.sampleRate>>>16&255,t.config[6]=t.sampleRate>>>8&255,t.config[7]=255&t.sampleRate,e.box(e.types.dOps,t.config)}},{key:"mvex",value:function(t){return e.box.apply(e,[e.types.mvex].concat(tt(t.map((function(t){return e.trex(t.id)})))))}},{key:"trex",value:function(t){return e.box(e.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}},{key:"trex1",value:function(t){return e.box(e.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,2,0,0,0,0,0,0,1,0,0]))}},{key:"trex2",value:function(t){return e.box(e.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,4,0,0,0,0,0,2,0,0,0]))}},{key:"moof",value:function(t){return e.box.apply(e,[e.types.moof,e.mfhd(t[0].samples?t[0].samples[0].gopId:0)].concat(tt(t.map((function(t){return e.traf(t)})))))}},{key:"mfhd",value:function(t){return e.box(e.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))}},{key:"traf",value:function(t){var r=e.tfhd(t.id),i=e.tfdt(t,t.baseMediaDecodeTime),n=0;if(t.isVideo&&t.videoSenc&&t.videoSenc.forEach((function(e){n+=8,e.subsamples&&e.subsamples.length&&(n+=2,n+=6*e.subsamples.length)})),t.videoSencLength=n,t.useEME&&(t.isVideoEncryption||t.isAudioEncryption)){if(t.isVideoEncryption){if(t.isVideo){var a=e.saiz(t),s=e.saio(t),o=e.trun1(t),u=e.senc(t);return e.box(e.types.traf,r,i,a,s,o,u)}if(t.isAudioEncryption){var l=e.sbgp(),d=e.saiz(t),h=e.saio(t),c=e.senc(t),f=e.trun1(t);return e.box(e.types.traf,r,i,l,d,h,c,f)}var v=e.sbgp(),p=e.trun1(t);return e.box(e.types.traf,r,i,v,p)}if(t.isVideo){var g=e.trun1(t);return e.box(e.types.traf,r,i,g)}var m=e.sbgp(),y=e.saiz(t),_=e.saio(t),b=e.senc(t),E=e.trun1(t);return e.box(e.types.traf,r,i,m,y,_,b,E)}var T=e.sdtp(t);return e.box(e.types.traf,r,i,T,e.trun(t.samples,T.byteLength+76))}},{key:"sdtp",value:function(t){var r=new qt;return t.samples.forEach((function(e){r.write(new Uint8Array(t.isVideo?[e.keyframe?32:16]:[16]))})),e.box(e.types.sdtp,this.extension(0,0),r.buffer)}},{key:"trun1",value:function(t){var r=new qt,i=qt.writeUint32(t.samples.length),n=null;if(t.isVideo){var a=t.videoSencLength;n=qt.writeUint32(16*t.samples.length+a+149),!t.isVideoEncryption&&t.isAudioEncryption&&(n=qt.writeUint32(16*t.samples.length+92))}else{var s=12*t.samples.length+124;t.isAudioEncryption&&(s=12*t.samples.length+8*t.audioSenc.length+177),n=qt.writeUint32(s)}return t.samples.forEach((function(e){r.write(qt.writeUint32(e.duration)),r.write(qt.writeUint32(e.size)),r.write(qt.writeUint32(e.keyframe?33554432:65536)),t.isVideo&&r.write(qt.writeUint32(e.cts?e.cts:0))})),e.box(e.types.trun,this.extension(0,t.flags),i,n,r.buffer)}},{key:"senc",value:function(t){var r=new qt,i=t.samples.length,n=t.isVideo?16:8,a=t.isVideo?2:0,s=[],o=0;return t.isVideo?(s=t.videoSenc,o=t.videoSencLength):s=t.audioSenc,o=o||n*i,r.write(qt.writeUint32(16+o),e.types.senc,this.extension(0,a)),r.write(qt.writeUint32(i)),s.forEach((function(e){for(var t=0;t<e.InitializationVector.length;t++)r.write(new Uint8Array([e.InitializationVector[t]]));e.subsamples&&e.subsamples.length&&(r.write(qt.writeUint16(e.subsamples.length)),e.subsamples.forEach((function(e){r.write(qt.writeUint16(e.BytesOfClearData)),r.write(qt.writeUint32(e.BytesOfProtectedData))})))})),r.buffer}},{key:"saio",value:function(t){var r=12*t.samples.length+141;!t.isVideo&&t.isAudioEncryption&&(r=149);var i=new Uint8Array([1,0,0,0,0,0,0,1,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,255&r]);return e.box(e.types.saio,i)}},{key:"saiz",value:function(t){var r=t.samples.length,i=new Uint8Array([0,0,0,0,16,r>>24&255,r>>16&255,r>>8&255,255&r]);return e.box(e.types.saiz,i)}},{key:"sbgp",value:function(){var t=new Uint8Array([114,111,108,108,0,0,0,1,0,0,1,25,0,0,0,1]);return e.box(e.types.sbgp,this.extension(0,0),t)}},{key:"extension",value:function(e,t){return new Uint8Array([e,t>>16&255,t>>8&255,255&t])}},{key:"tfhd",value:function(t){return e.box(e.types.tfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))}},{key:"tfdt",value:function(t,r){var i=Math.floor(r/(Yt+1)),n=Math.floor(r%(Yt+1));return t.useEME&&(t.isVideoEncryption||t.isAudioEncryption)?e.box(e.types.tfdt,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,255&n])):e.box(e.types.tfdt,new Uint8Array([1,0,0,0,i>>24,i>>16&255,i>>8&255,255&i,n>>24,n>>16&255,n>>8&255,255&n]))}},{key:"trun",value:function(t,r){var i=t.length,n=12+16*i;r+=8+n;var a=new Uint8Array(n);a.set([0,0,15,1,i>>>24&255,i>>>16&255,i>>>8&255,255&i,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0);for(var s=0;s<i;s++){var o=t[s],u=o.duration,l=o.size,d=o.flag,h=void 0===d?{}:d,c=o.cts,f=void 0===c?0:c;a.set([u>>>24&255,u>>>16&255,u>>>8&255,255&u,l>>>24&255,l>>>16&255,l>>>8&255,255&l,h.isLeading<<2|(null===h.dependsOn||void 0===h.dependsOn?1:h.dependsOn),h.isDependedOn<<6|h.hasRedundancy<<4|h.paddingValue<<1|(null===h.isNonSyncSample||void 0===h.isNonSyncSample?1:h.isNonSyncSample),61440&h.degradationPriority,15&h.degradationPriority,f>>>24&255,f>>>16&255,f>>>8&255,255&f],12+16*s)}return e.box(e.types.trun,a)}},{key:"moovMP4",value:function(t){return e.box.apply(e,[e.types.moov,e.mvhd(t[0].duration,t[0].timescale)].concat(tt(t.map((function(t){return e.trackMP4(t)})))))}},{key:"trackMP4",value:function(t){return e.box(e.types.trak,e.tkhd(t.id,t.duration,t.width,t.height),e.mdiaMP4(t))}},{key:"mdiaMP4",value:function(t){return e.box(e.types.mdia,e.mdhd(t.duration,t.timescale),e.hdlr(t.type),e.minfMP4(t))}},{key:"minfMP4",value:function(t){return e.box(e.types.minf,t.type===st?e.VMHD:e.SMHD,e.DINF,e.stblMP4(t))}},{key:"stblMP4",value:function(t){var r=t.ext,i=[e.stsd(t),e.stts(r.stts),e.stsc(r.stsc),e.stsz(r.stsz),e.stco(r.stco)];return r.stss.length&&i.push(e.stss(r.stss)),r.ctts.length&&i.push(e.ctts(r.ctts)),e.box.apply(e,[e.types.stbl].concat(i))}},{key:"stts",value:function(t){var r=t.length,i=new Uint8Array(8*r),n=0;return t.forEach((function(e){var t=e.value,r=e.count;i.set([r>>24,r>>16&255,r>>8&255,255&r,t>>24,t>>16&255,t>>8&255,255&t],n),n+=8})),e.box(e.types.stts,Ft(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),i))}},{key:"stsc",value:function(t){var r=t.length,i=new Uint8Array(12*r),n=0;return t.forEach((function(e){var t=e.firstChunk,r=e.samplesPerChunk,a=e.sampleDescIndex;i.set([t>>24,t>>16&255,t>>8&255,255&t,r>>24,r>>16&255,r>>8&255,255&r,a>>24,a>>16&255,a>>8&255,255&a],n),n+=12})),e.box(e.types.stsc,Ft(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),i))}},{key:"stsz",value:function(t){var r=t.length,i=new Uint8Array(4*r),n=0;return t.forEach((function(e){i.set([e>>24,e>>16&255,e>>8&255,255&e],n),n+=4})),e.box(e.types.stsz,Ft(new Uint8Array([0,0,0,0,0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),i))}},{key:"stco",value:function(t){var r=t.length,i=new Uint8Array(4*r),n=0;return t.forEach((function(e){i.set([e>>24,e>>16&255,e>>8&255,255&e],n),n+=4})),e.box(e.types.stco,Ft(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),i))}},{key:"stss",value:function(t){var r=t.length,i=new Uint8Array(4*r),n=0;return t.forEach((function(e){i.set([e>>24,e>>16&255,e>>8&255,255&e],n),n+=4})),e.box(e.types.stss,Ft(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),i))}},{key:"ctts",value:function(t){var r=t.length,i=new Uint8Array(8*r),n=0;return t.forEach((function(e){var t=e.value,r=e.count;i.set([r>>24,r>>16&255,r>>8&255,255&r,t>>24,t>>16&255,t>>8&255,255&t],n),n+=8})),e.box(e.types.ctts,Ft(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),i))}},{key:"styp",value:function(){return e.box(e.types.styp,new Uint8Array([109,115,100,104,0,0,0,0,109,115,100,104,109,115,105,120]))}},{key:"sidx",value:function(t){var r=t.timescale,i=t.samples[0].duration,n=i*t.samples.length,a=t.samples[0].sampleOffset*i,s=8;t.samples.forEach((function(e){s+=e.size}));var o=0;if(t.isVideo){var u,l=0;t.videoSenc&&(u=t.videoSenc),t.isVideo&&u.forEach((function(e){l+=8,e.subsamples&&e.subsamples.length&&(l+=2,l+=6*e.subsamples.length)})),t.videoSencLength=l,o=s+141+16*t.samples.length+l,t.useEME&&t.isAudioEncryption&&!t.isVideoEncryption&&(o=s+16*t.samples.length+84)}else o=s+116+12*t.samples.length,t.useEME&&t.isAudioEncryption&&(o=s+169+12*t.samples.length+8*t.audioSenc.length);var d=new Uint8Array([0,0,0,0,0,0,0,255&t.id,r>>24&255,r>>16&255,r>>8&255,255&r,a>>24&255,a>>16&255,a>>8&255,255&a,0,0,0,0,0,0,0,1,0,o>>16&255,o>>8&255,255&o,n>>24&255,n>>16&255,n>>8&255,255&n,144,0,0,0]);return e.box(e.types.sidx,d)}},{key:"mdat",value:function(t){return e.box(e.types.mdat,t)}}]),e}();Qe(Xt,"types",["Opus","dOps","av01","av1C","avc1","avcC","hvc1","hvcC","dinf","dref","esds","ftyp","hdlr","mdat","mdhd","mdia","mfhd","minf","moof","moov","mp4a","mvex","mvhd","pasp","stbl","stco","stsc","stsd","stsz","stts","tfdt","tfhd","traf","trak","trex","tkhd","vmhd","smhd","ctts","stss","styp","pssh","sidx","sbgp","saiz","saio","senc","trun","encv","enca","sinf","btrt","frma","tenc","schm","schi","mehd","fiel","sdtp"].reduce((function(e,t){return e[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)],e}),Object.create(null))),Qe(Xt,"HDLR_TYPES",{video:new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),audio:new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0])}),Qe(Xt,"FTYPAVC1",Xt.box(Xt.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]))),Qe(Xt,"FTYPHEV1",Xt.box(Xt.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,104,101,118,49]))),Qe(Xt,"DINF",Xt.box(Xt.types.dinf,Xt.box(Xt.types.dref,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])))),Qe(Xt,"VMHD",Xt.box(Xt.types.vmhd,new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]))),Qe(Xt,"SMHD",Xt.box(Xt.types.smhd,new Uint8Array([0,0,0,0,0,0,0,0]))),Qe(Xt,"StblTable",new Uint8Array([0,0,0,0,0,0,0,0])),Qe(Xt,"STTS",Xt.box(Xt.types.stts,Xt.StblTable)),Qe(Xt,"STSC",Xt.box(Xt.types.stsc,Xt.StblTable)),Qe(Xt,"STSZ",Xt.box(Xt.types.stsz,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]))),Qe(Xt,"STCO",Xt.box(Xt.types.stco,Xt.StblTable));var Qt=function(){function e(t,r){qe(this,e),this.name=t||"",this._prefix="[".concat(this.name,"]"),e.disabled=r}return Xe(e,[{key:"debug",value:function(){var t;if(!e.disabled){for(var r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];(t=console).debug.apply(t,[this._prefix].concat(i))}}},{key:"log",value:function(){var t;if(!e.disabled){for(var r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];(t=console).log.apply(t,[this._prefix].concat(i))}}},{key:"warn",value:function(){var t;if(!e.disabled){for(var r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];(t=console).warn.apply(t,[this._prefix].concat(i))}}},{key:"error",value:function(){var t;if(!e.disabled){for(var r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];(t=console).error.apply(t,[this._prefix].concat(i))}}},{key:"table",value:function(){var t;e.disabled||(console.group(this._prefix),(t=console).table.apply(t,arguments),console.groupEnd())}}],[{key:"enable",value:function(){e.disabled=!1}},{key:"disable",value:function(){e.disabled=!0}}]),e}();Qe(Qt,"disabled",!0);var Jt=function(){function e(t,r,i){qe(this,e),this.videoTrack=t,this.audioTrack=r;var n=/Chrome\/([^.]+)/.exec(navigator.userAgent);this.forceFirstIDR=n&&Number(n[1])<50,this.log=new Qt("FMP4Remuxer",!i||!i.openLog||!i.openLog)}return Xe(e,[{key:"remux",value:function(){var e,t,r,i,n,a=arguments.length>0&&void 0!==arguments[0]&&arguments[0],s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=this.videoTrack,u=this.audioTrack,l=o.exist(),d=u.exist(),h=[];return a&&(s&&s.initMerge?(l&&h.push(this.videoTrack),d&&h.push(this.audioTrack),r=Xt.initSegment(h)):(l&&(e=Xt.initSegment([this.videoTrack])),d&&(t=Xt.initSegment([this.audioTrack])))),l&&o.hasSample()&&(i=this._remuxVideo()),d&&u.hasSample()&&(n=this._remuxAudio()),o.samples=[],u.samples=[],{initSegment:r,videoInitSegment:e,audioInitSegment:t,videoSegment:i,audioSegment:n}}},{key:"_remuxVideo",value:function(){var e=this.videoTrack;this.forceFirstIDR&&(e.samples[0].flag={dependsOn:2,isNonSyncSample:0});var t=e.samples,r=/av01/.test(e.codec),i=0;r?t.forEach((function(e){i+=e.data.byteLength})):t.forEach((function(e){i+=e.units.reduce((function(e,t){return e+t.byteLength}),0),i+=4*e.units.length}));var n=new Uint8Array(i);if(r)for(var a,s=0,o=t.length,u=0;s<o;s++)a=t[s],n.set(a.data,u),a.size=a.data.byteLength,u+=a.size;else for(var l,d=new DataView(n.buffer),h=function(e,r){r=t[c];var i=0;r.units.forEach((function(t){d.setUint32(e,t.byteLength),e+=4,n.set(t,e),e+=t.byteLength,i+=4+t.byteLength})),r.size=i,v=e,l=r},c=0,f=t.length,v=0;c<f;c++)h(v,l);var p=Xt.mdat(n);return Ft(Xt.moof([e]),p)}},{key:"_remuxAudio",value:function(){var e=this.audioTrack,t=new Uint8Array(e.samples.reduce((function(e,t){return e+t.size}),0));e.samples.reduce((function(e,r){return t.set(r.data,e),e+r.size}),0);var r=Xt.mdat(t);return Ft(Xt.moof([e]),r)}},{key:"reset",value:function(){this.videoTrack.reset(),this.audioTrack.reset()}}]),e}(),Zt=function(){function e(){l(this,e),c(this,"_ttfb",0),c(this,"_demuxStart",0),c(this,"_demuxEnd",0),c(this,"_demuxCost",0),c(this,"_remuxStart",0),c(this,"_remuxEnd",0),c(this,"_remuxCost",0),c(this,"_appendStart",0),c(this,"_appendEnd",0),c(this,"_appendCost",0)}return h(e,[{key:"set",value:function(e,t){this["_".concat(e)]=t}},{key:"start",value:function(e){this["_".concat(e,"Start")]=Date.now()}},{key:"end",value:function(e){this["_".concat(e,"End")]=Date.now(),this["_".concat(e,"Cost")]=this["_".concat(e,"Cost")]+(this["_".concat(e,"End")]-this["_".concat(e,"Start")])}},{key:"transferCost",get:function(){return{ttfbCost:this._ttfb,demuxCost:this._demuxCost,remuxCost:this._remuxCost,appendCost:this._appendCost}}}]),e}(),$t="demux",er="remux",tr="append",rr=new j("BufferService"),ir=function(){function e(t,r){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};l(this,e),c(this,"flv",null),c(this,"_demuxer",new Wt),c(this,"_remuxer",null),c(this,"_mse",null),c(this,"_softVideo",null),c(this,"_sourceCreated",!1),c(this,"_needInitSegment",!0),c(this,"_discontinuity",!0),c(this,"_contiguous",!1),c(this,"_initSegmentId",""),c(this,"_cachedBuffer",null),c(this,"_demuxStartTime",0),c(this,"_opts",null),this.flv=t,this._opts=i,r?this._softVideo=r:(this._remuxer=new Jt(this._demuxer.videoTrack,this._demuxer.audioTrack),this._mse=new We(null,{preferMMS:"boolean"==typeof i.preferMMS?i.preferMMS:!!i.perferMMS}),this._mse.bindMedia(t.media))}var t,r,i,n,o,d;return h(e,[{key:"baseDts",get:function(){var e,t;return null===(e=this._demuxer)||void 0===e||null===(t=e._fixer)||void 0===t?void 0:t._baseDts}},{key:"blobUrl",get:function(){var e;return null===(e=this._mse)||void 0===e?void 0:e.url}},{key:"isFull",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:We.VIDEO;return this._mse.isFull(e)}},{key:"seamlessSwitch",value:function(){this._needInitSegment=!0,this._discontinuity=!0,this._contiguous=!0,this._initSegmentId=""}},{key:"unContiguous",value:function(e){this._contiguous=!1,this._demuxStartTime=e}},{key:"reset",value:(d=u(s().mark((function e(){var t,r=arguments;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=r.length>0&&void 0!==r[0]&&r[0],!this._mse||t){e.next=6;break}return e.next=4,this._mse.unbindMedia();case 4:return e.next=6,this._mse.bindMedia(this.flv.media);case 6:this._needInitSegment=!0,this._discontinuity=!0,this._contiguous=!1,this._sourceCreated=!1,this._initSegmentId="",this.resetSeamlessSwitchStats();case 12:case"end":return e.stop()}}),e,this)}))),function(){return d.apply(this,arguments)})},{key:"resetSeamlessSwitchStats",value:function(){this.seamlessLoadingSwitch=null,this.seamlessLoadingSwitching=!1,this._demuxer&&(this._demuxer.seamlessLoadingSwitching=!1)}},{key:"endOfStream",value:(o=u(s().mark((function e(){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._mse){e.next=7;break}if(!this._sourceCreated){e.next=5;break}return e.next=4,this._mse.endOfStream();case 4:this.flv.emit("core.buffereos");case 5:e.next=8;break;case 7:this._softVideo&&this._softVideo.endOfStream();case 8:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"updateDuration",value:(n=u(s().mark((function e(t){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._mse){e.next=7;break}if(this._mse.isOpened){e.next=4;break}return e.next=4,this._mse.open();case 4:return rr.debug("update duration",t),e.next=7,this._mse.updateDuration(t);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"destroy",value:(i=u(s().mark((function e(){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._mse){e.next=3;break}return e.next=3,this._mse.unbindMedia();case 3:this._mse=null,this._softVideo=null,this._demuxer=null,this._remuxer=null;case 7:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"appendBuffer",value:(r=u(s().mark((function e(t){var r,i,n,a,o,u,l,d,h,c,f,v,p,g,m,y,_,b=this;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=!1,this._cachedBuffer&&(t=ge(this._cachedBuffer,t),this._cachedBuffer=null),i=this._demuxer,t&&t.length&&i){e.next=5;break}return e.abrupt("return");case 5:e.prev=5,this.flv._transferCost.start($t),i.demuxAndFix(t,this.seamlessLoadingSwitching||this._discontinuity,this._contiguous,this._demuxStartTime,this.seamlessLoadingSwitching),this.seamlessLoadingSwitching=!1,this.flv._transferCost.end($t),e.next=15;break;case 12:throw e.prev=12,e.t0=e.catch(5),new ve(re,se,e.t0);case 15:if(n=i.videoTrack,a=i.audioTrack,o=i.metadataTrack,!this.seamlessLoadingSwitch){e.next=25;break}if(!((u=n.samples.findIndex((function(e){return e.originDts===n.lastKeyFrameDts})))>=0)){e.next=25;break}return n.samples.splice(u),e.next=22,this.seamlessLoadingSwitch();case 22:this.seamlessLoadingSwitch=null,t=null,r=!0;case 25:if(l=n.exist(),d=a.exist(),this._opts.onlyAudio&&(l=!1,n.present=!1),this._opts.onlyVideo&&(d=!1,a.present=!1),!(!l&&n.present||!d&&a.present)){e.next=42;break}if(h=0,(c=l?n:d?a:void 0)&&c.samples.length&&(h=(c.samples[c.samples.length-1].originPts-c.samples[0].originPts)/c.timescale*1e3),!(h>this._opts.analyzeDuration)){e.next=40;break}rr.warn("analyze duration exceeded, ".concat(h,"ms"),c),n.present=l,a.present=d,this.flv.emit("core.analyzedurationexceeded",{duration:h}),e.next=42;break;case 40:return this._cachedBuffer=t,e.abrupt("return");case 42:if(f=n.type,v=a.type,this._fireEvents(n,a,o),r||(this._discontinuity=!1,this._contiguous=!0,this._demuxStartTime=0),p=this._mse,g=function(){var e,t;null!==(e=b.flv)&&void 0!==e&&e.emit&&(null===(t=b.flv)||void 0===t||t.emit("core.appendbuffer",{}))},this.flv.emit(J,{videoTrack:n}),(m="".concat(n.codec,"/").concat(n.width,"/").concat(n.height,"/").concat(a.codec,"/").concat(a.config))!==this._initSegmentId&&(this._needInitSegment=!0,this._initSegmentId=m,this._emitMetaParsedEvent(n,a)),!p){e.next=81;break}if(this._sourceCreated){e.next=59;break}return e.next=55,p.open();case 55:l&&(rr.log("codec: video/mp4;codecs=".concat(n.codec)),p.createSource(f,"video/mp4;codecs=".concat(n.codec))),d&&(rr.log("codec: audio/mp4;codecs=".concat(a.codec)),p.createSource(v,"audio/mp4;codecs=".concat(a.codec))),this._sourceCreated=!0,this.flv.emit("core.sourcebuffercreated");case 59:e.prev=59,this._needInitSegment&&!this._opts.mseLowLatency&&(n.duration=this._opts.durationForMSELowLatencyOff*n.timescale,a.duration=this._opts.durationForMSELowLatencyOff*d.timescale),this.flv._transferCost.start(er),y=this._remuxer.remux(this._needInitSegment),this.flv._transferCost.end(er),e.next=69;break;case 66:throw e.prev=66,e.t1=e.catch(59),new ve(ie,oe,e.t1);case 69:if(!this._needInitSegment||y.videoInitSegment||y.audioInitSegment){e.next=71;break}return e.abrupt("return");case 71:return this._needInitSegment=!1,_=[],y.videoInitSegment&&_.push(p.append(f,y.videoInitSegment)),y.audioInitSegment&&_.push(p.append(v,y.audioInitSegment)),y.videoSegment&&_.push(p.append(f,y.videoSegment)),y.audioSegment&&_.push(p.append(v,y.audioSegment)),this.flv._transferCost.start(tr),e.abrupt("return",Promise.all(_).then(g).then((function(){b.flv._transferCost.end(tr),g()})));case 81:this._softVideo&&(this._softVideo.appendBuffer(n,a),g());case 82:case"end":return e.stop()}}),e,this,[[5,12],[59,66]])}))),function(e){return r.apply(this,arguments)})},{key:"evictBuffer",value:(t=u(s().mark((function e(t){var r,i,n,a=this;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.flv.media,this._mse&&this._demuxer&&r&&t&&!(t<0)){e.next=3;break}return e.abrupt("return");case 3:if(i=r.currentTime,!((n=i-t)<=0)){e.next=7;break}return e.abrupt("return");case 7:if(!(pe.start(pe.get(r))+1>=n)){e.next=10;break}return e.abrupt("return");case 10:return e.abrupt("return",this._mse.clearBuffer(0,n).then((function(){return a.flv.emit("core.removebuffer",{removeEnd:n})})));case 11:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"_emitMetaParsedEvent",value:function(e,t){e.exist()&&this.flv.emit(Y,{type:"video",track:e,meta:{codec:e.codec,timescale:e.timescale,width:e.width,height:e.height,sarRatio:e.sarRatio,baseDts:e.baseDts}}),t.exist()&&this.flv.emit(Y,{type:"audio",track:t,meta:{codec:t.codec,channelCount:t.channelCount,sampleRate:t.sampleRate,timescale:t.timescale,baseDts:t.baseDts}}),rr.debug("track parsed",e,t)}},{key:"_fireEvents",value:function(e,t,r){var i=this;rr.debug("videoTrack samples count: ".concat(e.samples.length,", audioTrack samples count: ").concat(t.samples.length)),r.flvScriptSamples.forEach((function(e){i.flv.emit(Q,e),rr.debug("flvScriptData",e)})),e.samples.forEach((function(e){e.keyframe&&i.flv.emit("core.keyframe",{pts:e.originPts})})),e.warnings.forEach((function(e){var t;switch(e.type){case ct:t="LARGE_AV_FIRST_FRAME_GAP_DETECT";break;case ft:t="LARGE_VIDEO_DTS_GAP_DETECT";break;case vt:t="MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT"}t&&i.flv.emit(Z,a(a({},e),{},{type:t})),rr.warn("video exception",e)})),t.warnings.forEach((function(e){var t;switch(e.type){case pt:t="LARGE_AUDIO_DTS_GAP_DETECT";break;case gt:t="AUDIO_GAP_DETECT";break;case mt:t="AUDIO_OVERLAP_DETECT"}t&&i.flv.emit(Z,a(a({},e),{},{type:t})),rr.warn("audio exception",e)})),r.seiSamples.forEach((function(e){i.flv.emit(X,a(a({},e),{},{sei:{code:e.data.type,content:e.data.payload,dts:e.pts}}))}))}}]),e}();function nr(e,t){var r=0,i=e.length-1,n=0,a=0,s=i;for(t<e[0]&&(r=0,a=s+1);a<=s;){if((n=a+Math.floor((s-a)/2))===i||t>=e[n]&&t<e[n+1]){r=n;break}e[n]<t?a=n+1:s=n-1}return r}var ar=new j("flv"),sr=.1,or=function(){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&v(e,t)}(b,y());var e,t,r,i,n,o,d,g,m,_=(g=b,m=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=f(g);if(m){var r=f(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return p(e)}(this,e)});function b(e){var t,r;return l(this,b),c(p(t=_.call(this)),"media",null),c(p(t),"_loading",!1),c(p(t),"_opts",null),c(p(t),"_bufferService",null),c(p(t),"_gapService",null),c(p(t),"_stats",null),c(p(t),"_mediaLoader",null),c(p(t),"_maxChunkWaitTimer",null),c(p(t),"_tickTimer",null),c(p(t),"_tickInterval",500),c(p(t),"_urlSwitching",!1),c(p(t),"_seamlessSwitching",!1),c(p(t),"_disconnectRetryCount",0),c(p(t),"_preLoadEndPoint",0),c(p(t),"_keyframes",null),c(p(t),"_acceptRanges",!0),c(p(t),"_onProgress",function(){var e=u(s().mark((function e(r,i,n,a){var o,u,l,d,h,c,f,v,p,g;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=n.startTime,u=n.endTime,l=n.st,d=n.firstByteTime,t._loading=!i,t._firstProgressEmit){e.next=13;break}if(t.media){e.next=6;break}return null===(h=t._mediaLoader)||void 0===h||h.cancel(),e.abrupt("return");case 6:c=a.headers,f=l?d-l:u-o,t.emit(q,{url:t._opts.url,responseUrl:a.url,elapsed:f}),t.emit("core.loadresponseheaders",{headers:c}),t._transferCost.set("ttfb",f),t._acceptRanges=!(null==c||!c.get("Accept-Ranges"))||!(null==c||!c.get("Content-Range")),t._firstProgressEmit=!0;case 13:if(t._bufferService){e.next=15;break}return e.abrupt("return");case 15:return clearTimeout(t._maxChunkWaitTimer),t._bandwidthService.addChunkRecord(null==r?void 0:r.byteLength,u-o),e.prev=17,e.next=20,t._bufferService.appendBuffer(r);case 20:null===(v=t._bufferService)||void 0===v||v.evictBuffer(t._opts.bufferBehind),e.next=33;break;case 23:if(e.prev=23,e.t0=e.catch(17),t.isLive||!t._bufferService.isFull()){e.next=32;break}return e.next=28,t._mediaLoader.cancel();case 28:return t._loading=!1,p=t.bufferInfo().remaining,t._opts.preloadTime=parseInt(p)/2,e.abrupt("return");case 32:return e.abrupt("return",t._emitError(ve.create(e.t0)));case 33:if(t._urlSwitching&&(t._urlSwitching=!1,t.emit("core.switchurlsuccess",{url:t._opts.url})),t._seamlessSwitching&&(t._seamlessSwitching=!1,t._tick()),!i||t.media.seeking){e.next=40;break}return t.emit("core.loadcomplete"),ar.debug("load done"),t.isLive&&t._disconnectRetryCount<=0&&t._end(),e.abrupt("return");case 40:if(t.isLive){e.next=42;break}return e.abrupt("return");case 42:(g=t._opts.maxReaderInterval)&&t._firstProgressEmit&&(clearTimeout(t._maxChunkWaitTimer),t._maxChunkWaitTimer=setTimeout((function(){if(t._disconnectRetryCount)return t._disconnectRetryCount--,void t.load();ar.debug("onMaxChunkWait",g),t._end()}),g));case 44:case"end":return e.stop()}}),e,null,[[17,23]])})));return function(t,r,i,n){return e.apply(this,arguments)}}()),c(p(t),"_onRetryError",(function(e,r){ar.debug("load retry",e,r),t.emit("core.loadretry",{error:ve.network(e),retryTime:r})})),c(p(t),"_end",(function(){t._clear(),t._bufferService&&t._bufferService.endOfStream(),ar.debug("end stream")})),c(p(t),"_resetDisconnectCount",(function(){t._disconnectRetryCount=t._opts.disconnectRetryCount})),c(p(t),"_tick",(function(){clearTimeout(t._tickTimer);var e=p(t).media;if(e){t._tickTimer=setTimeout(t._tick,t._tickInterval);var r=pe.end(pe.get(e));if(!(r<sr)&&e.readyState){var i=t._opts;if(function(e){return e&&!e.paused&&!e.ended&&0!==e.playbackRate&&0!==e.readyState}(e)&&e.currentTime)t._gapService&&t._gapService.do(e,i.maxJumpDistance,t.isLive,3);else{if(!e.currentTime&&t._gapService&&i.enableStartGapJump)return void((t._opts.mseLowLatency||!1===t._opts.mseLowLatency&&t.bufferInfo(.3).nextStart)&&t._gapService.do(e,i.maxJumpDistance,t.isLive,3));i.isLive&&4===e.readyState&&r-e.currentTime>i.disconnectTime&&t.disconnect()}}}})),c(p(t),"_onPlay",(function(){var e,r,i=t._opts.softDecode||(null===(e=t.media)||void 0===e||null===(r=e.buffered)||void 0===r?void 0:r.length);if(t.isLive)!t._loading&&i&&t.replay(void 0,!0);else{var n=t.bufferInfo();(n.start||n.nextStart)>sr&&t._tick()}})),c(p(t),"_onLoadeddata",(function(){t.isLive&&!t._opts.mseLowLatency&&t.media.duration!==1/0&&t._bufferService.updateDuration(1/0).catch((function(e){}))})),c(p(t),"_onSeeking",u(s().mark((function e(){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:!t.isLive&&t.seekable&&(t._preLoadEndPoint=-1,t._checkPreload());case 1:case"end":return e.stop()}}),e)})))),c(p(t),"_onTimeupdate",(function(){if(t.media){var e=t._opts,r=t.media.currentTime;if(e.isLive&&e.maxLatency&&e.targetLatency){var i=pe.end(pe.get(t.media));i-r>=e.maxLatency&&(t.media.currentTime=i-e.targetLatency,t.emit("core.chaseframe",{currentTime:t.media.currentTime,latency:e.targetLatency}))}t._seiService.throw(r,!0),e.isLive||!t.seekable||t._loading||t._checkPreload()}})),c(p(t),"_onWaiting",(function(){t.isLive&&!t._loading&&t._disconnectRetryCount&&(t._disconnectRetryCount--,t.load())})),c(p(t),"_onBufferUpdate",(function(){if(!t._opts.isLive){var e=t.bufferInfo(),r=e.end,i=e.nextEnd;Math.abs((r||i)-t.media.duration)<1&&(t._end(),t.media.readyState<=2&&t._tick())}})),c(p(t),"_checkPreload",u(s().mark((function e(){var r,i,n,a,o,u,l,d,h,c;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.bufferInfo(),i=r.remaining,n=void 0===i?0:i,a=t._opts,o=t._keyframes.filepositions,u=t._keyframes.times,l=t.media.currentTime,!(n<a.preloadTime)){e.next=19;break}if(d=nr(t._keyframes.times,l+n+sr),(h=nr(t._keyframes.times,l+n+t._opts.preloadTime))===d&&(h=d+1),t._preLoadEndPoint!==h){e.next=11;break}return e.abrupt("return");case 11:if(null!=(c=o[d])){e.next=14;break}return e.abrupt("return");case 14:return e.next=16,t._mediaLoader.cancel();case 16:t._loadData(null,[c,o[h]]),t._preLoadEndPoint=h,t._bufferService.unContiguous(u[d]);case 19:case"end":return e.stop()}}),e)})))),c(p(t),"_onFlvScriptData",(function(e){var r,i,n,a,s=null===(r=e.data)||void 0===r||null===(i=r.onMetaData)||void 0===i?void 0:i.keyframes,o=null===(n=e.data)||void 0===n||null===(a=n.onMetaData)||void 0===a?void 0:a.duration;s&&(t._keyframes=s),!t._opts.isLive&&o&&t._bufferService.updateDuration(o)})),t._opts=((r=a({retryCount:3,retryDelay:1e3,disconnectRetryCount:0,loadTimeout:1e4,maxReaderInterval:5e3,preloadTime:5,defaultVodLoadSize:1e7,isLive:!1,softDecode:!1,bufferBehind:10,maxJumpDistance:3,analyzeDuration:2e4,seamlesslyReload:!1,keepStatusAfterSwitch:!0,onlyVideo:!1,onlyAudio:!1,preferMMS:!1,mseLowLatency:!0,durationForMSELowLatencyOff:6,chunkCountForSpeed:50,skipChunkSize:1e3,longtimeNoReceived:3e3,enableStartGapJump:!0},e)).isLive&&r.preloadTime&&(r.maxLatency||(r.maxLatency=2*r.preloadTime),r.targetLatency||(r.targetLatency=r.preloadTime),null!==r.disconnectTime&&void 0!==r.disconnectTime||(r.disconnectTime=r.maxLatency)),r),t.media=t._opts.media||document.createElement("video"),t._opts.media=null,t._firstProgressEmit=!1,t._mediaLoader=new Me(a(a({},t._opts.fetchOptions),{},{retry:t._opts.retryCount,retryDelay:t._opts.retryDelay,timeout:t._opts.loadTimeout,onRetryError:t._onRetryError,onProgress:t._onProgress,responseType:"arraybuffer"})),t._disconnectRetryCount=t._opts.disconnectRetryCount,t._transferCost=new Zt,t._bufferService=new ir(p(t),t._opts.softDecode?t.media:void 0,t._opts),t._seiService=new Be(p(t)),t._bandwidthService=new Ne({chunkCountForSpeed:t._opts.chunkCountForSpeed,skipChunkSize:t._opts.skipChunkSize,longtimeNoReceived:t._opts.longtimeNoReceived}),t._stats=new Ge(p(t)),t._opts.softDecode||(t._gapService=new Ve),t.media.addEventListener("play",t._onPlay),t.media.addEventListener("loadeddata",t._onLoadeddata),t.media.addEventListener("seeking",t._onSeeking),t.media.addEventListener("timeupdate",t._onTimeupdate),t.media.addEventListener("progress",t._onBufferUpdate),t.media.addEventListener("waiting",t._onWaiting),t.on(Q,t._onFlvScriptData),t}return h(b,[{key:"version",get:function(){return"3.0.20"}},{key:"isLive",get:function(){return this._opts.isLive}},{key:"baseDts",get:function(){var e;return null===(e=this._bufferService)||void 0===e?void 0:e.baseDts}},{key:"seekable",get:function(){return!!this._keyframes&&this._acceptRanges}},{key:"loader",get:function(){return this._mediaLoader}},{key:"blobUrl",get:function(){var e;return null===(e=this._bufferService)||void 0===e?void 0:e.blobUrl}},{key:"speedInfo",value:function(){return{speed:this._bandwidthService.getLatestSpeed(),avgSpeed:this._bandwidthService.getAvgSpeed(),totalSize:this._bandwidthService.getTotalSize(),totalCost:this._bandwidthService.getTotalCost()}}},{key:"getStats",value:function(){return this._stats.getStats()}},{key:"bufferInfo",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:sr;return pe.info(pe.get(this.media),null===(e=this.media)||void 0===e?void 0:e.currentTime,t)}},{key:"playbackQuality",value:function(){return function(e){if(!e)return{};if("function"==typeof e.getVideoPlaybackQuality){var t=e.getVideoPlaybackQuality();return{droppedVideoFrames:t.droppedVideoFrames||t.corruptedVideoFrames,totalVideoFrames:t.totalVideoFrames,creationTime:t.creationTime}}return{droppedVideoFrames:e.webkitDroppedFrameCount,totalVideoFrames:e.webkitDecodedFrameCount,creationTime:performance.now()}}(this.media)}},{key:"load",value:(d=u(s().mark((function e(t){var r,i=arguments;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=i.length>1&&void 0!==i[1]&&i[1],this._bufferService){e.next=3;break}return e.abrupt("return");case 3:return e.next=5,this._reset(r);case 5:this._loadData(t,this._opts.isLive?[]:[0,this._opts.defaultVodLoadSize]),clearTimeout(this._tickTimer),this._tickTimer=setTimeout(this._tick,this._tickInterval);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"replay",value:(o=u(s().mark((function e(){var t,r,i=this,n=arguments;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=n.length>0&&void 0!==n[0]?n[0]:this._opts.seamlesslyReload,r=n.length>1?n[1]:void 0,this.media){e.next=4;break}return e.abrupt("return");case 4:if(this._resetDisconnectCount(),!t){e.next=11;break}return e.next=8,this._clear();case 8:setTimeout((function(){i._seamlessSwitching=!0,i._loadData(i._opts.url),i._bufferService.seamlessSwitch()})),e.next=13;break;case 11:return e.next=13,this.load();case 13:return e.abrupt("return",this.media.play(!r).catch((function(){})));case 14:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"disconnect",value:function(){var e;return ar.debug("disconnect!"),null===(e=this._bufferService)||void 0===e||e.resetSeamlessSwitchStats(),this._clear()}},{key:"switchURL",value:(n=u(s().mark((function e(t,r){var i=this;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._bufferService){e.next=2;break}return e.abrupt("return");case 2:if(this._resetDisconnectCount(),!this._loading||!r){e.next=6;break}return this._bufferService.seamlessLoadingSwitch=function(){var e=u(s().mark((function e(r){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i._clear();case 2:i._bufferService.seamlessLoadingSwitching=!0,i._urlSwitching=!0,i._seamlessSwitching=!0,i._bufferService.seamlessSwitch(),i._loadData(t);case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),e.abrupt("return");case 6:if(r&&this._opts.isLive){e.next=11;break}return e.next=9,this.load(t);case 9:return this._urlSwitching=!0,e.abrupt("return",this.media.play(!0).catch((function(){})));case 11:return e.next=13,this._clear();case 13:setTimeout((function(){i._urlSwitching=!0,i._seamlessSwitching=!0,i._loadData(t),i._bufferService.seamlessSwitch()}));case 14:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"destroy",value:(i=u(s().mark((function e(){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.media){e.next=2;break}return e.abrupt("return");case 2:return this.removeAllListeners(),this._seiService.reset(),this.media.removeEventListener("play",this._onPlay),this.media.removeEventListener("loadeddata",this._onLoadeddata),this.media.removeEventListener("seeking",this._onSeeking),this.media.removeEventListener("timeupdate",this._onTimeupdate),this.media.removeEventListener("waiting",this._onWaiting),this.media.removeEventListener("progress",this._onBufferUpdate),e.next=12,Promise.all([this._clear(),this._bufferService.destroy()]);case 12:this.media=null,this._bufferService=null;case 14:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"_emitError",value:function(e){var t,r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];ar.table(e),ar.error(e),ar.error(null===(t=this.media)||void 0===t?void 0:t.error),this._urlSwitching&&(this._urlSwitching=!1,this._seamlessSwitching=!1,this.emit("core.switchurlfailed",e)),this.emit("error",e),r&&(this._seiService.reset(),this._end())}},{key:"_reset",value:(r=u(s().mark((function e(){var t,r=arguments;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.length>0&&void 0!==r[0]&&r[0],this._seiService.reset(),this._bandwidthService.reset(),this._stats.reset(),e.next=6,this._clear();case 6:return e.next=8,this._bufferService.reset(t);case 8:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"_loadData",value:(t=u(s().mark((function e(t,r){var i;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&(this._opts.url=t),i=t=this._opts.url,t){e.next=4;break}throw new Error("Source url is missing");case 4:if(this._opts.preProcessUrl&&(i=this._opts.preProcessUrl(t).url),this._mediaLoader.finnalUrl=i,this.emit("core.loadstart",{url:i,seamlessSwitching:this._seamlessSwitching}),ar.debug("load data, loading:",this._loading,i),!this._loading){e.next=11;break}return e.next=11,this._mediaLoader.cancel();case 11:return this._loading=!0,e.prev=12,e.next=15,this._mediaLoader.load({url:i,range:r});case 15:e.next=21;break;case 17:return e.prev=17,e.t0=e.catch(12),this._loading=!1,e.abrupt("return",this._emitError(ve.network(e.t0),!1));case 21:case"end":return e.stop()}}),e,this,[[12,17]])}))),function(e,r){return t.apply(this,arguments)})},{key:"_clear",value:(e=u(s().mark((function e(){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._mediaLoader){e.next=3;break}return e.next=3,this._mediaLoader.cancel();case 3:clearTimeout(this._maxChunkWaitTimer),clearTimeout(this._tickTimer),this._loading=!1,this._firstProgressEmit=!1;case 7:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})}],[{key:"isSupported",value:function(e){return e&&"video"!==e&&"audio"!==e?"undefined"!=typeof WebAssembly:We.isSupported()}},{key:"enableLogger",value:function(){j.enable(),at.enable()}},{key:"disableLogger",value:function(){j.disable(),at.disable()}}]),b}();try{localStorage.getItem("xgd")?or.enableLogger():or.disableLogger()}catch(e){}var ur=r(21),lr=i.N,dr=i.c;export{lr as Flv,dr as Hls};
1
+ var df=Object.create;var Qa=Object.defineProperty;var cf=Object.getOwnPropertyDescriptor;var vf=Object.getOwnPropertyNames;var pf=Object.getPrototypeOf,mf=Object.prototype.hasOwnProperty;var Ja=(c,g)=>()=>(g||c((g={exports:{}}).exports,g),g.exports);var gf=(c,g,n,l)=>{if(g&&typeof g=="object"||typeof g=="function")for(let f of vf(g))!mf.call(c,f)&&f!==n&&Qa(c,f,{get:()=>g[f],enumerable:!(l=cf(g,f))||l.enumerable});return c};var gr=(c,g,n)=>(n=c!=null?df(pf(c)):{},gf(g||!c||!c.__esModule?Qa(n,"default",{value:c,enumerable:!0}):n,c));var _r=Ja((th,qi)=>{"use strict";var Sf=Object.prototype.hasOwnProperty,pt="~";function Ar(){}Object.create&&(Ar.prototype=Object.create(null),new Ar().__proto__||(pt=!1));function Tf(c,g,n){this.fn=c,this.context=g,this.once=n||!1}function as(c,g,n,l,f){if(typeof n!="function")throw new TypeError("The listener must be a function");var v=new Tf(n,l||c,f),E=pt?pt+g:g;return c._events[E]?c._events[E].fn?c._events[E]=[c._events[E],v]:c._events[E].push(v):(c._events[E]=v,c._eventsCount++),c}function si(c,g){--c._eventsCount===0?c._events=new Ar:delete c._events[g]}function ht(){this._events=new Ar,this._eventsCount=0}ht.prototype.eventNames=function(){var g=[],n,l;if(this._eventsCount===0)return g;for(l in n=this._events)Sf.call(n,l)&&g.push(pt?l.slice(1):l);return Object.getOwnPropertySymbols?g.concat(Object.getOwnPropertySymbols(n)):g};ht.prototype.listeners=function(g){var n=pt?pt+g:g,l=this._events[n];if(!l)return[];if(l.fn)return[l.fn];for(var f=0,v=l.length,E=new Array(v);f<v;f++)E[f]=l[f].fn;return E};ht.prototype.listenerCount=function(g){var n=pt?pt+g:g,l=this._events[n];return l?l.fn?1:l.length:0};ht.prototype.emit=function(g,n,l,f,v,E){var _=pt?pt+g:g;if(!this._events[_])return!1;var S=this._events[_],C=arguments.length,I,P;if(S.fn){switch(S.once&&this.removeListener(g,S.fn,void 0,!0),C){case 1:return S.fn.call(S.context),!0;case 2:return S.fn.call(S.context,n),!0;case 3:return S.fn.call(S.context,n,l),!0;case 4:return S.fn.call(S.context,n,l,f),!0;case 5:return S.fn.call(S.context,n,l,f,v),!0;case 6:return S.fn.call(S.context,n,l,f,v,E),!0}for(P=1,I=new Array(C-1);P<C;P++)I[P-1]=arguments[P];S.fn.apply(S.context,I)}else{var H=S.length,W;for(P=0;P<H;P++)switch(S[P].once&&this.removeListener(g,S[P].fn,void 0,!0),C){case 1:S[P].fn.call(S[P].context);break;case 2:S[P].fn.call(S[P].context,n);break;case 3:S[P].fn.call(S[P].context,n,l);break;case 4:S[P].fn.call(S[P].context,n,l,f);break;default:if(!I)for(W=1,I=new Array(C-1);W<C;W++)I[W-1]=arguments[W];S[P].fn.apply(S[P].context,I)}}return!0};ht.prototype.on=function(g,n,l){return as(this,g,n,l,!1)};ht.prototype.once=function(g,n,l){return as(this,g,n,l,!0)};ht.prototype.removeListener=function(g,n,l,f){var v=pt?pt+g:g;if(!this._events[v])return this;if(!n)return si(this,v),this;var E=this._events[v];if(E.fn)E.fn===n&&(!f||E.once)&&(!l||E.context===l)&&si(this,v);else{for(var _=0,S=[],C=E.length;_<C;_++)(E[_].fn!==n||f&&!E[_].once||l&&E[_].context!==l)&&S.push(E[_]);S.length?this._events[v]=S.length===1?S[0]:S:si(this,v)}return this};ht.prototype.removeAllListeners=function(g){var n;return g?(n=pt?pt+g:g,this._events[n]&&si(this,n)):(this._events=new Ar,this._eventsCount=0),this};ht.prototype.off=ht.prototype.removeListener;ht.prototype.addListener=ht.prototype.on;ht.prefixed=pt;ht.EventEmitter=ht;typeof qi<"u"&&(qi.exports=ht)});var no=Ja((io,En)=>{(function c(g){(function(n,l){typeof io=="object"&&typeof En<"u"?En.exports=l():typeof define=="function"&&define.amd?define(l):(n=typeof globalThis<"u"?globalThis:n||self,n.Hls=l())})(this,function(){"use strict";function n(s,a){var i=Object.keys(s);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(s);a&&(e=e.filter(function(t){return Object.getOwnPropertyDescriptor(s,t).enumerable})),i.push.apply(i,e)}return i}function l(s){for(var a=1;a<arguments.length;a++){var i=arguments[a]!=null?arguments[a]:{};a%2?n(Object(i),!0).forEach(function(e){S(s,e,i[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(i)):n(Object(i)).forEach(function(e){Object.defineProperty(s,e,Object.getOwnPropertyDescriptor(i,e))})}return s}function f(s,a){if(typeof s!="object"||!s)return s;var i=s[Symbol.toPrimitive];if(i!==void 0){var e=i.call(s,a||"default");if(typeof e!="object")return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return(a==="string"?String:Number)(s)}function v(s){var a=f(s,"string");return typeof a=="symbol"?a:String(a)}function E(s,a){for(var i=0;i<a.length;i++){var e=a[i];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(s,v(e.key),e)}}function _(s,a,i){return a&&E(s.prototype,a),i&&E(s,i),Object.defineProperty(s,"prototype",{writable:!1}),s}function S(s,a,i){return a=v(a),a in s?Object.defineProperty(s,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):s[a]=i,s}function C(){return C=Object.assign?Object.assign.bind():function(s){for(var a=1;a<arguments.length;a++){var i=arguments[a];for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&(s[e]=i[e])}return s},C.apply(this,arguments)}function I(s,a){s.prototype=Object.create(a.prototype),s.prototype.constructor=s,H(s,a)}function P(s){return P=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},P(s)}function H(s,a){return H=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},H(s,a)}function W(){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(s,a,i){return W()?Y=Reflect.construct.bind():Y=function(t,r,o){var u=[null];u.push.apply(u,r);var h=Function.bind.apply(t,u),d=new h;return o&&H(d,o.prototype),d},Y.apply(null,arguments)}function ee(s){try{return Function.toString.call(s).indexOf("[native code]")!==-1}catch{return typeof s=="function"}}function J(s){var a=typeof Map=="function"?new Map:void 0;return J=function(e){if(e===null||!ee(e))return e;if(typeof e!="function")throw new TypeError("Super expression must either be null or a function");if(typeof a<"u"){if(a.has(e))return a.get(e);a.set(e,t)}function t(){return Y(e,arguments,P(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),H(t,e)},J(s)}function ae(s){if(s===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s}function se(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var _e={exports:{}};(function(s,a){(function(i){var e=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,t=/^(?=([^\/?#]*))\1([^]*)$/,r=/(?:\/|^)\.(?=\/)/g,o=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,u={buildAbsoluteURL:function(h,d,m){if(m=m||{},h=h.trim(),d=d.trim(),!d){if(!m.alwaysNormalize)return h;var p=u.parseURL(h);if(!p)throw new Error("Error trying to parse base URL.");return p.path=u.normalizePath(p.path),u.buildURLFromParts(p)}var y=u.parseURL(d);if(!y)throw new Error("Error trying to parse relative URL.");if(y.scheme)return m.alwaysNormalize?(y.path=u.normalizePath(y.path),u.buildURLFromParts(y)):d;var T=u.parseURL(h);if(!T)throw new Error("Error trying to parse base URL.");if(!T.netLoc&&T.path&&T.path[0]!=="/"){var x=t.exec(T.path);T.netLoc=x[1],T.path=x[2]}T.netLoc&&!T.path&&(T.path="/");var b={scheme:T.scheme,netLoc:y.netLoc,path:null,params:y.params,query:y.query,fragment:y.fragment};if(!y.netLoc&&(b.netLoc=T.netLoc,y.path[0]!=="/"))if(!y.path)b.path=T.path,y.params||(b.params=T.params,y.query||(b.query=T.query));else{var L=T.path,A=L.substring(0,L.lastIndexOf("/")+1)+y.path;b.path=u.normalizePath(A)}return b.path===null&&(b.path=m.alwaysNormalize?u.normalizePath(y.path):y.path),u.buildURLFromParts(b)},parseURL:function(h){var d=e.exec(h);return d?{scheme:d[1]||"",netLoc:d[2]||"",path:d[3]||"",params:d[4]||"",query:d[5]||"",fragment:d[6]||""}:null},normalizePath:function(h){for(h=h.split("").reverse().join("").replace(r,"");h.length!==(h=h.replace(o,"")).length;);return h.split("").reverse().join("")},buildURLFromParts:function(h){return h.scheme+h.netLoc+h.path+h.params+h.query+h.fragment}};s.exports=u})()})(_e);var oe=_e.exports,j=Number.isFinite||function(s){return typeof s=="number"&&isFinite(s)},ue=Number.isSafeInteger||function(s){return typeof s=="number"&&Math.abs(s)<=Ve},Ve=Number.MAX_SAFE_INTEGER||9007199254740991,R=function(s){return s.MEDIA_ATTACHING="hlsMediaAttaching",s.MEDIA_ATTACHED="hlsMediaAttached",s.MEDIA_DETACHING="hlsMediaDetaching",s.MEDIA_DETACHED="hlsMediaDetached",s.BUFFER_RESET="hlsBufferReset",s.BUFFER_CODECS="hlsBufferCodecs",s.BUFFER_CREATED="hlsBufferCreated",s.BUFFER_APPENDING="hlsBufferAppending",s.BUFFER_APPENDED="hlsBufferAppended",s.BUFFER_EOS="hlsBufferEos",s.BUFFER_FLUSHING="hlsBufferFlushing",s.BUFFER_FLUSHED="hlsBufferFlushed",s.MANIFEST_LOADING="hlsManifestLoading",s.MANIFEST_LOADED="hlsManifestLoaded",s.MANIFEST_PARSED="hlsManifestParsed",s.LEVEL_SWITCHING="hlsLevelSwitching",s.LEVEL_SWITCHED="hlsLevelSwitched",s.LEVEL_LOADING="hlsLevelLoading",s.LEVEL_LOADED="hlsLevelLoaded",s.LEVEL_UPDATED="hlsLevelUpdated",s.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",s.LEVELS_UPDATED="hlsLevelsUpdated",s.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",s.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",s.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",s.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",s.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",s.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",s.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",s.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",s.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",s.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",s.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",s.CUES_PARSED="hlsCuesParsed",s.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",s.INIT_PTS_FOUND="hlsInitPtsFound",s.FRAG_LOADING="hlsFragLoading",s.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",s.FRAG_LOADED="hlsFragLoaded",s.FRAG_DECRYPTED="hlsFragDecrypted",s.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",s.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",s.FRAG_PARSING_METADATA="hlsFragParsingMetadata",s.FRAG_PARSED="hlsFragParsed",s.FRAG_BUFFERED="hlsFragBuffered",s.FRAG_CHANGED="hlsFragChanged",s.FPS_DROP="hlsFpsDrop",s.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",s.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",s.ERROR="hlsError",s.DESTROYING="hlsDestroying",s.KEY_LOADING="hlsKeyLoading",s.KEY_LOADED="hlsKeyLoaded",s.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",s.BACK_BUFFER_REACHED="hlsBackBufferReached",s.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",s}({}),le=function(s){return s.NETWORK_ERROR="networkError",s.MEDIA_ERROR="mediaError",s.KEY_SYSTEM_ERROR="keySystemError",s.MUX_ERROR="muxError",s.OTHER_ERROR="otherError",s}({}),G=function(s){return s.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",s.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",s.KEY_SYSTEM_NO_SESSION="keySystemNoSession",s.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",s.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",s.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",s.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",s.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",s.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",s.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",s.MANIFEST_LOAD_ERROR="manifestLoadError",s.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",s.MANIFEST_PARSING_ERROR="manifestParsingError",s.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",s.LEVEL_EMPTY_ERROR="levelEmptyError",s.LEVEL_LOAD_ERROR="levelLoadError",s.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",s.LEVEL_PARSING_ERROR="levelParsingError",s.LEVEL_SWITCH_ERROR="levelSwitchError",s.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",s.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",s.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",s.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",s.FRAG_LOAD_ERROR="fragLoadError",s.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",s.FRAG_DECRYPT_ERROR="fragDecryptError",s.FRAG_PARSING_ERROR="fragParsingError",s.FRAG_GAP="fragGap",s.REMUX_ALLOC_ERROR="remuxAllocError",s.KEY_LOAD_ERROR="keyLoadError",s.KEY_LOAD_TIMEOUT="keyLoadTimeOut",s.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",s.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",s.BUFFER_APPEND_ERROR="bufferAppendError",s.BUFFER_APPENDING_ERROR="bufferAppendingError",s.BUFFER_STALLED_ERROR="bufferStalledError",s.BUFFER_FULL_ERROR="bufferFullError",s.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",s.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",s.INTERNAL_EXCEPTION="internalException",s.INTERNAL_ABORTED="aborted",s.UNKNOWN="unknown",s}({}),He=function(){},F={trace:He,debug:He,log:He,warn:He,info:He,error:He},O=F;function B(s){var a=self.console[s];return a?a.bind(self.console,"["+s+"] >"):He}function re(s){for(var a=arguments.length,i=new Array(a>1?a-1:0),e=1;e<a;e++)i[e-1]=arguments[e];i.forEach(function(t){O[t]=s[t]?s[t].bind(s):B(t)})}function X(s,a){if(typeof console=="object"&&s===!0||typeof s=="object"){re(s,"debug","log","info","warn","error");try{O.log('Debug logs enabled for "'+a+'" in hls.js version 1.5.17')}catch{O=F}}else O=F}var k=O,ge=/^(\d+)x(\d+)$/,De=/(.+?)=(".*?"|.*?)(?:,|$)/g,pe=function(){function s(i){typeof i=="string"&&(i=s.parseAttrList(i)),C(this,i)}var a=s.prototype;return a.decimalInteger=function(e){var t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t},a.hexadecimalInteger=function(e){if(this[e]){var t=(this[e]||"0x").slice(2);t=(t.length&1?"0":"")+t;for(var r=new Uint8Array(t.length/2),o=0;o<t.length/2;o++)r[o]=parseInt(t.slice(o*2,o*2+2),16);return r}else return null},a.hexadecimalIntegerAsNumber=function(e){var t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t},a.decimalFloatingPoint=function(e){return parseFloat(this[e])},a.optionalFloat=function(e,t){var r=this[e];return r?parseFloat(r):t},a.enumeratedString=function(e){return this[e]},a.bool=function(e){return this[e]==="YES"},a.decimalResolution=function(e){var t=ge.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}},s.parseAttrList=function(e){var t,r={},o='"';for(De.lastIndex=0;(t=De.exec(e))!==null;){var u=t[2];u.indexOf(o)===0&&u.lastIndexOf(o)===u.length-1&&(u=u.slice(1,-1));var h=t[1].trim();r[h]=u}return r},_(s,[{key:"clientAttrs",get:function(){return Object.keys(this).filter(function(e){return e.substring(0,2)==="X-"})}}]),s}();function Ne(s){return s!=="ID"&&s!=="CLASS"&&s!=="START-DATE"&&s!=="DURATION"&&s!=="END-DATE"&&s!=="END-ON-NEXT"}function Qe(s){return s==="SCTE35-OUT"||s==="SCTE35-IN"}var ke=function(){function s(a,i){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,i){var e=i.attr;for(var t in e)if(Object.prototype.hasOwnProperty.call(a,t)&&a[t]!==e[t]){k.warn('DATERANGE tag attribute: "'+t+'" does not match for tags with ID: "'+a.ID+'"'),this._badValueForSameId=t;break}a=C(new pe({}),e,a)}if(this.attr=a,this._startDate=new Date(a["START-DATE"]),"END-DATE"in this.attr){var r=new Date(this.attr["END-DATE"]);j(r.getTime())&&(this._endDate=r)}}return _(s,[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){if(this._endDate)return this._endDate;var i=this.duration;return i!==null?new Date(this._startDate.getTime()+i*1e3):null}},{key:"duration",get:function(){if("DURATION"in this.attr){var i=this.attr.decimalFloatingPoint("DURATION");if(j(i))return i}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}},{key:"endOnNext",get:function(){return this.attr.bool("END-ON-NEXT")}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&j(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),s}(),$t=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}},Pe={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"},hr=function(){function s(i){var e;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(e={},e[Pe.AUDIO]=null,e[Pe.VIDEO]=null,e[Pe.AUDIOVIDEO]=null,e),this.baseurl=i}var a=s.prototype;return a.setByteRange=function(e,t){var r=e.split("@",2),o;r.length===1?o=t?.byteRangeEndOffset||0:o=parseInt(r[1]),this._byteRange=[o,parseInt(r[0])+o]},_(s,[{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=oe.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(e){this._url=e}}]),s}(),dr=function(s){I(a,s);function a(e,t){var r;return r=s.call(this,t)||this,r._decryptdata=null,r.rawProgramDateTime=null,r.programDateTime=null,r.tagList=[],r.duration=0,r.sn=0,r.levelkeys=void 0,r.type=void 0,r.loader=null,r.keyLoader=null,r.level=-1,r.cc=0,r.startPTS=void 0,r.endPTS=void 0,r.startDTS=void 0,r.endDTS=void 0,r.start=0,r.deltaPTS=void 0,r.maxStartPTS=void 0,r.minEndPTS=void 0,r.stats=new $t,r.data=void 0,r.bitrateTest=!1,r.title=null,r.initSegment=null,r.endList=void 0,r.gap=void 0,r.urlId=0,r.type=e,r}var i=a.prototype;return i.setKeyFormat=function(t){if(this.levelkeys){var r=this.levelkeys[t];r&&!this._decryptdata&&(this._decryptdata=r.getDecryptData(this.sn))}},i.abortRequests=function(){var t,r;(t=this.loader)==null||t.abort(),(r=this.keyLoader)==null||r.abort()},i.setElementaryStreamInfo=function(t,r,o,u,h,d){d===void 0&&(d=!1);var m=this.elementaryStreams,p=m[t];if(!p){m[t]={startPTS:r,endPTS:o,startDTS:u,endDTS:h,partial:d};return}p.startPTS=Math.min(p.startPTS,r),p.endPTS=Math.max(p.endPTS,o),p.startDTS=Math.min(p.startDTS,u),p.endDTS=Math.max(p.endDTS,h)},i.clearElementaryStreamInfo=function(){var t=this.elementaryStreams;t[Pe.AUDIO]=null,t[Pe.VIDEO]=null,t[Pe.AUDIOVIDEO]=null},_(a,[{key:"decryptdata",get:function(){var t=this.levelkeys;if(!t&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var r=this.levelkeys.identity;if(r)this._decryptdata=r.getDecryptData(this.sn);else{var o=Object.keys(this.levelkeys);if(o.length===1)return this._decryptdata=this.levelkeys[o[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null||!j(this.programDateTime))return null;var t=j(this.duration)?this.duration:0;return this.programDateTime+t*1e3}},{key:"encrypted",get:function(){var t;if((t=this._decryptdata)!=null&&t.encrypted)return!0;if(this.levelkeys){var r=Object.keys(this.levelkeys),o=r.length;if(o>1||o===1&&this.levelkeys[r[0]].encrypted)return!0}return!1}}]),a}(hr),_n=function(s){I(a,s);function a(i,e,t,r,o){var u;u=s.call(this,t)||this,u.fragOffset=0,u.duration=0,u.gap=!1,u.independent=!1,u.relurl=void 0,u.fragment=void 0,u.index=void 0,u.stats=new $t,u.duration=i.decimalFloatingPoint("DURATION"),u.gap=i.bool("GAP"),u.independent=i.bool("INDEPENDENT"),u.relurl=i.enumeratedString("URI"),u.fragment=e,u.index=r;var h=i.enumeratedString("BYTERANGE");return h&&u.setByteRange(h,o),o&&(u.fragOffset=o.fragOffset+o.duration),u}return _(a,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var e=this.elementaryStreams;return!!(e.audio||e.video||e.audiovideo)}}]),a}(hr),Je=10,so=function(){function s(i){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=i}var a=s.prototype;return a.reloaded=function(e){if(!e){this.advanced=!0,this.updated=!0;return}var t=this.lastPartSn-e.lastPartSn,r=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!r||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||t===0&&r>0,this.updated||this.advanced?this.misses=Math.floor(e.misses*.6):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay},_(s,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?j(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||Je}},{key:"drift",get:function(){var e=this.driftEndTime-this.driftStartTime;if(e>0){var t=this.driftEnd-this.driftStart;return t*1e3/e}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var e;return(e=this.fragments)!=null&&e.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),s}(),oo=void 0,uo=se(oo);function nr(s,a,i){return Uint8Array.prototype.slice?s.slice(a,i):new Uint8Array(Array.prototype.slice.call(s,a,i))}var mi=function(a,i){return i+10<=a.length&&a[i]===73&&a[i+1]===68&&a[i+2]===51&&a[i+3]<255&&a[i+4]<255&&a[i+6]<128&&a[i+7]<128&&a[i+8]<128&&a[i+9]<128},Sn=function(a,i){return i+10<=a.length&&a[i]===51&&a[i+1]===68&&a[i+2]===73&&a[i+3]<255&&a[i+4]<255&&a[i+6]<128&&a[i+7]<128&&a[i+8]<128&&a[i+9]<128},Nr=function(a,i){for(var e=i,t=0;mi(a,i);){t+=10;var r=Ur(a,i+6);t+=r,Sn(a,i+10)&&(t+=10),i+=t}if(t>0)return a.subarray(e,e+t)},Ur=function(a,i){var e=0;return e=(a[i]&127)<<21,e|=(a[i+1]&127)<<14,e|=(a[i+2]&127)<<7,e|=a[i+3]&127,e},lo=function(a,i){return mi(a,i)&&Ur(a,i+6)+10<=a.length-i},Tn=function(a){for(var i=bn(a),e=0;e<i.length;e++){var t=i[e];if(xn(t))return mo(t)}},xn=function(a){return a&&a.key==="PRIV"&&a.info==="com.apple.streaming.transportStreamTimestamp"},fo=function(a){var i=String.fromCharCode(a[0],a[1],a[2],a[3]),e=Ur(a,4),t=10;return{type:i,size:e,data:a.subarray(t,t+e)}},bn=function(a){for(var i=0,e=[];mi(a,i);){var t=Ur(a,i+6);i+=10;for(var r=i+t;i+8<r;){var o=fo(a.subarray(i)),u=ho(o);u&&e.push(u),i+=o.size+10}Sn(a,i)&&(i+=10)}return e},ho=function(a){return a.type==="PRIV"?co(a):a.type[0]==="W"?po(a):vo(a)},co=function(a){if(!(a.size<2)){var i=Qt(a.data,!0),e=new Uint8Array(a.data.subarray(i.length+1));return{key:a.type,info:i,data:e.buffer}}},vo=function(a){if(!(a.size<2)){if(a.type==="TXXX"){var i=1,e=Qt(a.data.subarray(i),!0);i+=e.length+1;var t=Qt(a.data.subarray(i));return{key:a.type,info:e,data:t}}var r=Qt(a.data.subarray(1));return{key:a.type,data:r}}},po=function(a){if(a.type==="WXXX"){if(a.size<2)return;var i=1,e=Qt(a.data.subarray(i),!0);i+=e.length+1;var t=Qt(a.data.subarray(i));return{key:a.type,info:e,data:t}}var r=Qt(a.data);return{key:a.type,data:r}},mo=function(a){if(a.data.byteLength===8){var i=new Uint8Array(a.data),e=i[3]&1,t=(i[4]<<23)+(i[5]<<15)+(i[6]<<7)+i[7];return t/=45,e&&(t+=4772185884e-2),Math.round(t)}},Qt=function(a,i){i===void 0&&(i=!1);var e=go();if(e){var t=e.decode(a);if(i){var r=t.indexOf("\0");return r!==-1?t.substring(0,r):t}return t.replace(/\0/g,"")}for(var o=a.length,u,h,d,m="",p=0;p<o;){if(u=a[p++],u===0&&i)return m;if(u===0||u===3)continue;switch(u>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:m+=String.fromCharCode(u);break;case 12:case 13:h=a[p++],m+=String.fromCharCode((u&31)<<6|h&63);break;case 14:h=a[p++],d=a[p++],m+=String.fromCharCode((u&15)<<12|(h&63)<<6|(d&63)<<0);break}}return m},gi;function go(){if(!navigator.userAgent.includes("PlayStation 4"))return!gi&&typeof self.TextDecoder<"u"&&(gi=new self.TextDecoder("utf-8")),gi}var Ln={hexDump:function(a){for(var i="",e=0;e<a.length;e++){var t=a[e].toString(16);t.length<2&&(t="0"+t),i+=t}return i}},Br=Math.pow(2,32)-1,yo=[].push,An={video:1,audio:2,id3:3,text:4};function nt(s){return String.fromCharCode.apply(null,s)}function Rn(s,a){var i=s[a]<<8|s[a+1];return i<0?65536+i:i}function ve(s,a){var i=Dn(s,a);return i<0?4294967296+i:i}function Cn(s,a){var i=ve(s,a);return i*=Math.pow(2,32),i+=ve(s,a+4),i}function Dn(s,a){return s[a]<<24|s[a+1]<<16|s[a+2]<<8|s[a+3]}function yi(s,a,i){s[a]=i>>24,s[a+1]=i>>16&255,s[a+2]=i>>8&255,s[a+3]=i&255}function Eo(s){for(var a=s.byteLength,i=0;i<a;){var e=ve(s,i);if(e>8&&s[i+4]===109&&s[i+5]===111&&s[i+6]===111&&s[i+7]===102)return!0;i=e>1?i+e:a}return!1}function be(s,a){var i=[];if(!a.length)return i;for(var e=s.byteLength,t=0;t<e;){var r=ve(s,t),o=nt(s.subarray(t+4,t+8)),u=r>1?t+r:e;if(o===a[0])if(a.length===1)i.push(s.subarray(t+8,u));else{var h=be(s.subarray(t+8,u),a.slice(1));h.length&&yo.apply(i,h)}t=u}return i}function _o(s){var a=[],i=s[0],e=8,t=ve(s,e);e+=4;var r=0,o=0;i===0?(r=ve(s,e),o=ve(s,e+4),e+=8):(r=Cn(s,e),o=Cn(s,e+8),e+=16),e+=2;var u=s.length+o,h=Rn(s,e);e+=2;for(var d=0;d<h;d++){var m=e,p=ve(s,m);m+=4;var y=p&2147483647,T=(p&2147483648)>>>31;if(T===1)return k.warn("SIDX has hierarchical references (not supported)"),null;var x=ve(s,m);m+=4,a.push({referenceSize:y,subsegmentDuration:x,info:{duration:x/t,start:u,end:u+y-1}}),u+=y,m+=4,e=m}return{earliestPresentationTime:r,timescale:t,version:i,referencesCount:h,references:a}}function wn(s){for(var a=[],i=be(s,["moov","trak"]),e=0;e<i.length;e++){var t=i[e],r=be(t,["tkhd"])[0];if(r){var o=r[0],u=ve(r,o===0?12:20),h=be(t,["mdia","mdhd"])[0];if(h){o=h[0];var d=ve(h,o===0?12:20),m=be(t,["mdia","hdlr"])[0];if(m){var p=nt(m.subarray(8,12)),y={soun:Pe.AUDIO,vide:Pe.VIDEO}[p];if(y){var T=be(t,["mdia","minf","stbl","stsd"])[0],x=So(T);a[u]={timescale:d,type:y},a[y]=l({timescale:d,id:u},x)}}}}}var b=be(s,["moov","mvex","trex"]);return b.forEach(function(L){var A=ve(L,4),D=a[A];D&&(D.default={duration:ve(L,12),flags:ve(L,20)})}),a}function So(s){var a=s.subarray(8),i=a.subarray(86),e=nt(a.subarray(4,8)),t=e,r=e==="enca"||e==="encv";if(r){var o=be(a,[e])[0],u=o.subarray(e==="enca"?28:78),h=be(u,["sinf"]);h.forEach(function(yt){var ft=be(yt,["schm"])[0];if(ft){var st=nt(ft.subarray(4,8));if(st==="cbcs"||st==="cenc"){var or=be(yt,["frma"])[0];or&&(t=nt(or))}}})}switch(t){case"avc1":case"avc2":case"avc3":case"avc4":{var d=be(i,["avcC"])[0];t+="."+Gr(d[1])+Gr(d[2])+Gr(d[3]);break}case"mp4a":{var m=be(a,[e])[0],p=be(m.subarray(28),["esds"])[0];if(p&&p.length>12){var y=4;if(p[y++]!==3)break;y=Ei(p,y),y+=2;var T=p[y++];if(T&128&&(y+=2),T&64&&(y+=p[y++]),p[y++]!==4)break;y=Ei(p,y);var x=p[y++];if(x===64)t+="."+Gr(x);else break;if(y+=12,p[y++]!==5)break;y=Ei(p,y);var b=p[y++],L=(b&248)>>3;L===31&&(L+=1+((b&7)<<3)+((p[y]&224)>>5)),t+="."+L}break}case"hvc1":case"hev1":{var A=be(i,["hvcC"])[0],D=A[1],w=["","A","B","C"][D>>6],N=D&31,U=ve(A,2),$=(D&32)>>5?"H":"L",V=A[12],M=A.subarray(6,12);t+="."+w+N,t+="."+U.toString(16).toUpperCase(),t+="."+$+V;for(var K="",z=M.length;z--;){var te=M[z];if(te||K){var Z=te.toString(16).toUpperCase();K="."+Z+K}}t+=K;break}case"dvh1":case"dvhe":{var ie=be(i,["dvcC"])[0],he=ie[2]>>1&127,fe=ie[2]<<5&32|ie[3]>>3&31;t+="."+Ut(he)+"."+Ut(fe);break}case"vp09":{var Le=be(i,["vpcC"])[0],Ee=Le[4],we=Le[5],Ae=Le[6]>>4&15;t+="."+Ut(Ee)+"."+Ut(we)+"."+Ut(Ae);break}case"av01":{var ye=be(i,["av1C"])[0],je=ye[1]>>>5,Fe=ye[1]&31,qe=ye[2]>>>7?"H":"M",Xe=(ye[2]&64)>>6,Ze=(ye[2]&32)>>5,ze=je===2&&Xe?Ze?12:10:Xe?10:8,Ue=(ye[2]&16)>>4,jt=(ye[2]&8)>>3,_t=(ye[2]&4)>>2,$e=ye[2]&3,ct=1,vt=1,et=1,Ke=0;t+="."+je+"."+Ut(Fe)+qe+"."+Ut(ze)+"."+Ue+"."+jt+_t+$e+"."+Ut(ct)+"."+Ut(vt)+"."+Ut(et)+"."+Ke;break}}return{codec:t,encrypted:r}}function Ei(s,a){for(var i=a+5;s[a++]&128&&a<i;);return a}function Gr(s){return("0"+s.toString(16).toUpperCase()).slice(-2)}function Ut(s){return(s<10?"0":"")+s}function To(s,a){if(!s||!a)return s;var i=a.keyId;if(i&&a.isCommonEncryption){var e=be(s,["moov","trak"]);e.forEach(function(t){var r=be(t,["mdia","minf","stbl","stsd"])[0],o=r.subarray(8),u=be(o,["enca"]),h=u.length>0;h||(u=be(o,["encv"])),u.forEach(function(d){var m=h?d.subarray(28):d.subarray(78),p=be(m,["sinf"]);p.forEach(function(y){var T=xo(y);if(T){var x=T.subarray(8,24);x.some(function(b){return b!==0})||(k.log("[eme] Patching keyId in 'enc"+(h?"a":"v")+">sinf>>tenc' box: "+Ln.hexDump(x)+" -> "+Ln.hexDump(i)),T.set(i,8))}})})})}return s}function xo(s){var a=be(s,["schm"])[0];if(a){var i=nt(a.subarray(4,8));if(i==="cbcs"||i==="cenc")return be(s,["schi","tenc"])[0]}return null}function bo(s,a){return be(a,["moof","traf"]).reduce(function(i,e){var t=be(e,["tfdt"])[0],r=t[0],o=be(e,["tfhd"]).reduce(function(u,h){var d=ve(h,4),m=s[d];if(m){var p=ve(t,4);if(r===1){if(p===Br)return k.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),u;p*=Br+1,p+=ve(t,8)}var y=m.timescale||9e4,T=p/y;if(j(T)&&(u===null||T<u))return T}return u},null);return o!==null&&j(o)&&(i===null||o<i)?o:i},null)}function Lo(s,a){for(var i=0,e=0,t=0,r=be(s,["moof","traf"]),o=0;o<r.length;o++){var u=r[o],h=be(u,["tfhd"])[0],d=ve(h,4),m=a[d];if(m){var p=m.default,y=ve(h,0)|p?.flags,T=p?.duration;y&8&&(y&2?T=ve(h,12):T=ve(h,8));for(var x=m.timescale||9e4,b=be(u,["trun"]),L=0;L<b.length;L++){if(i=Ao(b[L]),!i&&T){var A=ve(b[L],4);i=T*A}m.type===Pe.VIDEO?e+=i/x:m.type===Pe.AUDIO&&(t+=i/x)}}}if(e===0&&t===0){for(var D=1/0,w=0,N=0,U=be(s,["sidx"]),$=0;$<U.length;$++){var V=_o(U[$]);if(V!=null&&V.references){D=Math.min(D,V.earliestPresentationTime/V.timescale);var M=V.references.reduce(function(K,z){return K+z.info.duration||0},0);w=Math.max(w,M+V.earliestPresentationTime/V.timescale),N=w-D}}if(N&&j(N))return N}return e||t}function Ao(s){var a=ve(s,0),i=8;a&1&&(i+=4),a&4&&(i+=4);for(var e=0,t=ve(s,4),r=0;r<t;r++){if(a&256){var o=ve(s,i);e+=o,i+=4}a&512&&(i+=4),a&1024&&(i+=4),a&2048&&(i+=4)}return e}function Ro(s,a,i){be(a,["moof","traf"]).forEach(function(e){be(e,["tfhd"]).forEach(function(t){var r=ve(t,4),o=s[r];if(o){var u=o.timescale||9e4;be(e,["tfdt"]).forEach(function(h){var d=h[0],m=i*u;if(m){var p=ve(h,4);if(d===0)p-=m,p=Math.max(p,0),yi(h,4,p);else{p*=Math.pow(2,32),p+=ve(h,8),p-=m,p=Math.max(p,0);var y=Math.floor(p/(Br+1)),T=Math.floor(p%(Br+1));yi(h,4,y),yi(h,8,T)}}})}})})}function Co(s){var a={valid:null,remainder:null},i=be(s,["moof"]);if(i.length<2)return a.remainder=s,a;var e=i[i.length-1];return a.valid=nr(s,0,e.byteOffset-8),a.remainder=nr(s,e.byteOffset-8),a}function At(s,a){var i=new Uint8Array(s.length+a.length);return i.set(s),i.set(a,s.length),i}function In(s,a){var i=[],e=a.samples,t=a.timescale,r=a.id,o=!1,u=be(e,["moof"]);return u.map(function(h){var d=h.byteOffset-8,m=be(h,["traf"]);m.map(function(p){var y=be(p,["tfdt"]).map(function(T){var x=T[0],b=ve(T,4);return x===1&&(b*=Math.pow(2,32),b+=ve(T,8)),b/t})[0];return y!==void 0&&(s=y),be(p,["tfhd"]).map(function(T){var x=ve(T,4),b=ve(T,0)&16777215,L=(b&1)!==0,A=(b&2)!==0,D=(b&8)!==0,w=0,N=(b&16)!==0,U=0,$=(b&32)!==0,V=8;x===r&&(L&&(V+=8),A&&(V+=4),D&&(w=ve(T,V),V+=4),N&&(U=ve(T,V),V+=4),$&&(V+=4),a.type==="video"&&(o=Do(a.codec)),be(p,["trun"]).map(function(M){var K=M[0],z=ve(M,0)&16777215,te=(z&1)!==0,Z=0,ie=(z&4)!==0,he=(z&256)!==0,fe=0,Le=(z&512)!==0,Ee=0,we=(z&1024)!==0,Ae=(z&2048)!==0,ye=0,je=ve(M,4),Fe=8;te&&(Z=ve(M,Fe),Fe+=4),ie&&(Fe+=4);for(var qe=Z+d,Xe=0;Xe<je;Xe++){if(he?(fe=ve(M,Fe),Fe+=4):fe=w,Le?(Ee=ve(M,Fe),Fe+=4):Ee=U,we&&(Fe+=4),Ae&&(K===0?ye=ve(M,Fe):ye=Dn(M,Fe),Fe+=4),a.type===Pe.VIDEO)for(var Ze=0;Ze<Ee;){var ze=ve(e,qe);if(qe+=4,wo(o,e[qe])){var Ue=e.subarray(qe,qe+ze);Pn(Ue,o?2:1,s+ye/t,i)}qe+=ze,Ze+=ze+4}s+=fe/t}}))})})}),i}function Do(s){if(!s)return!1;var a=s.indexOf("."),i=a<0?s:s.substring(0,a);return i==="hvc1"||i==="hev1"||i==="dvh1"||i==="dvhe"}function wo(s,a){if(s){var i=a>>1&63;return i===39||i===40}else{var e=a&31;return e===6}}function Pn(s,a,i,e){var t=kn(s),r=0;r+=a;for(var o=0,u=0,h=0;r<t.length;){o=0;do{if(r>=t.length)break;h=t[r++],o+=h}while(h===255);u=0;do{if(r>=t.length)break;h=t[r++],u+=h}while(h===255);var d=t.length-r,m=r;if(u<d)r+=u;else if(u>d){k.error("Malformed SEI payload. "+u+" is too small, only "+d+" bytes left to parse.");break}if(o===4){var p=t[m++];if(p===181){var y=Rn(t,m);if(m+=2,y===49){var T=ve(t,m);if(m+=4,T===1195456820){var x=t[m++];if(x===3){var b=t[m++],L=31&b,A=64&b,D=A?2+L*3:0,w=new Uint8Array(D);if(A){w[0]=b;for(var N=1;N<D;N++)w[N]=t[m++]}e.push({type:x,payloadType:o,pts:i,bytes:w})}}}}}else if(o===5&&u>16){for(var U=[],$=0;$<16;$++){var V=t[m++].toString(16);U.push(V.length==1?"0"+V:V),($===3||$===5||$===7||$===9)&&U.push("-")}for(var M=u-16,K=new Uint8Array(M),z=0;z<M;z++)K[z]=t[m++];e.push({payloadType:o,pts:i,uuid:U.join(""),userData:Qt(K),userDataBytes:K})}}}function kn(s){for(var a=s.byteLength,i=[],e=1;e<a-2;)s[e]===0&&s[e+1]===0&&s[e+2]===3?(i.push(e+2),e+=2):e++;if(i.length===0)return s;var t=a-i.length,r=new Uint8Array(t),o=0;for(e=0;e<t;o++,e++)o===i[0]&&(o++,i.shift()),r[e]=s[o];return r}function Io(s){var a=s[0],i="",e="",t=0,r=0,o=0,u=0,h=0,d=0;if(a===0){for(;nt(s.subarray(d,d+1))!=="\0";)i+=nt(s.subarray(d,d+1)),d+=1;for(i+=nt(s.subarray(d,d+1)),d+=1;nt(s.subarray(d,d+1))!=="\0";)e+=nt(s.subarray(d,d+1)),d+=1;e+=nt(s.subarray(d,d+1)),d+=1,t=ve(s,12),r=ve(s,16),u=ve(s,20),h=ve(s,24),d=28}else if(a===1){d+=4,t=ve(s,d),d+=4;var m=ve(s,d);d+=4;var p=ve(s,d);for(d+=4,o=Math.pow(2,32)*m+p,ue(o)||(o=Number.MAX_SAFE_INTEGER,k.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),u=ve(s,d),d+=4,h=ve(s,d),d+=4;nt(s.subarray(d,d+1))!=="\0";)i+=nt(s.subarray(d,d+1)),d+=1;for(i+=nt(s.subarray(d,d+1)),d+=1;nt(s.subarray(d,d+1))!=="\0";)e+=nt(s.subarray(d,d+1)),d+=1;e+=nt(s.subarray(d,d+1)),d+=1}var y=s.subarray(d,s.byteLength);return{schemeIdUri:i,value:e,timeScale:t,presentationTime:o,presentationTimeDelta:r,eventDuration:u,id:h,payload:y}}var Po=function(){s.clearKeyUriToKeyIdMap=function(){};function s(i,e,t,r,o){r===void 0&&(r=[1]),o===void 0&&(o=null),this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=i,this.uri=e,this.keyFormat=t,this.keyFormatVersions=r,this.iv=o,this.encrypted=i?i!=="NONE":!1,this.isCommonEncryption=this.encrypted&&i!=="AES-128"}var a=s.prototype;return a.isSupported=function(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES"}return!1},a.getDecryptData=function(e){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof e!="number"&&(this.method==="AES-128"&&!this.iv&&k.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),e=0);var t=ko(e),r=new s(this.method,this.uri,"identity",this.keyFormatVersions,t);return r}return this},s}();function ko(s){for(var a=new Uint8Array(16),i=12;i<16;i++)a[i]=s>>8*(15-i)&255;return a}function ar(s){if(s===void 0&&(s=!0),!(typeof self>"u")){var a=(s||!self.MediaSource)&&self.ManagedMediaSource;return a||self.MediaSource||self.WebKitMediaSource}}function Oo(s){return typeof self<"u"&&s===self.ManagedMediaSource}var Vr={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function Mo(s,a){var i=Vr[a];return!!i&&!!i[s.slice(0,4)]}function _i(s,a,i){return i===void 0&&(i=!0),!s.split(",").some(function(e){return!On(e,a,i)})}function On(s,a,i){var e;i===void 0&&(i=!0);var t=ar(i);return(e=t?.isTypeSupported(Si(s,a)))!=null?e:!1}function Si(s,a){return a+'/mp4;codecs="'+s+'"'}function Mn(s){if(s){var a=s.substring(0,4);return Vr.video[a]}return 2}function Hr(s){return s.split(",").reduce(function(a,i){var e=Vr.video[i];return e?(e*2+a)/(a?3:2):(Vr.audio[i]+a)/(a?2:1)},0)}var Ti={};function Fo(s,a){if(a===void 0&&(a=!0),Ti[s])return Ti[s];for(var i={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"]}[s],e=0;e<i.length;e++)if(On(i[e],"audio",a))return Ti[s]=i[e],i[e];return s}var No=/flac|opus/i;function Kr(s,a){return a===void 0&&(a=!0),s.replace(No,function(i){return Fo(i.toLowerCase(),a)})}function Fn(s,a){return s&&s!=="mp4a"?s:a&&a.split(",")[0]}function Uo(s){for(var a=s.split(","),i=0;i<a.length;i++){var e=a[i].split(".");if(e.length>2){var t=e.shift()+".";t+=parseInt(e.shift()).toString(16),t+=("000"+parseInt(e.shift()).toString(16)).slice(-4),a[i]=t}}return a.join(",")}var Nn=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,Un=/#EXT-X-MEDIA:(.*)/g,Bo=/^#EXT(?:INF|-X-TARGETDURATION):/m,Bn=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),Go=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),br=function(){function s(){}return s.findGroup=function(i,e){for(var t=0;t<i.length;t++){var r=i[t];if(r.id===e)return r}},s.resolve=function(i,e){return oe.buildAbsoluteURL(e,i,{alwaysNormalize:!0})},s.isMediaPlaylist=function(i){return Bo.test(i)},s.parseMasterPlaylist=function(i,e){var t=!1,r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:t},o=[];Nn.lastIndex=0;for(var u;(u=Nn.exec(i))!=null;)if(u[1]){var h,d=new pe(u[1]),m=u[2],p={attrs:d,bitrate:d.decimalInteger("BANDWIDTH")||d.decimalInteger("AVERAGE-BANDWIDTH"),name:d.NAME,url:s.resolve(m,e)},y=d.decimalResolution("RESOLUTION");y&&(p.width=y.width,p.height=y.height),Vo(d.CODECS,p),(h=p.unknownCodecs)!=null&&h.length||o.push(p),r.levels.push(p)}else if(u[3]){var T=u[3],x=u[4];switch(T){case"SESSION-DATA":{var b=new pe(x),L=b["DATA-ID"];L&&(r.sessionData===null&&(r.sessionData={}),r.sessionData[L]=b);break}case"SESSION-KEY":{var A=Gn(x,e);A.encrypted&&A.isSupported()?(r.sessionKeys===null&&(r.sessionKeys=[]),r.sessionKeys.push(A)):k.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+x+'"');break}case"DEFINE":break;case"CONTENT-STEERING":{var D=new pe(x);r.contentSteering={uri:s.resolve(D["SERVER-URI"],e),pathwayId:D["PATHWAY-ID"]||"."};break}case"START":{r.startTimeOffset=Vn(x);break}}}var w=o.length>0&&o.length<r.levels.length;return r.levels=w?o:r.levels,r.levels.length===0&&(r.playlistParsingError=new Error("no levels found in manifest")),r},s.parseMasterPlaylistMedia=function(i,e,t){var r,o={},u=t.levels,h={AUDIO:u.map(function(U){return{id:U.attrs.AUDIO,audioCodec:U.audioCodec}}),SUBTITLES:u.map(function(U){return{id:U.attrs.SUBTITLES,textCodec:U.textCodec}}),"CLOSED-CAPTIONS":[]},d=0;for(Un.lastIndex=0;(r=Un.exec(i))!==null;){var m=new pe(r[1]),p=m.TYPE;if(p){var y=h[p],T=o[p]||[];o[p]=T;var x=m.LANGUAGE,b=m["ASSOC-LANGUAGE"],L=m.CHANNELS,A=m.CHARACTERISTICS,D=m["INSTREAM-ID"],w={attrs:m,bitrate:0,id:d++,groupId:m["GROUP-ID"]||"",name:m.NAME||x||"",type:p,default:m.bool("DEFAULT"),autoselect:m.bool("AUTOSELECT"),forced:m.bool("FORCED"),lang:x,url:m.URI?s.resolve(m.URI,e):""};if(b&&(w.assocLang=b),L&&(w.channels=L),A&&(w.characteristics=A),D&&(w.instreamId=D),y!=null&&y.length){var N=s.findGroup(y,w.groupId)||y[0];Hn(w,N,"audioCodec"),Hn(w,N,"textCodec")}T.push(w)}}return o},s.parseLevelPlaylist=function(i,e,t,r,o,u){var h=new so(e),d=h.fragments,m=null,p=0,y=0,T=0,x=0,b=null,L=new dr(r,e),A,D,w,N=-1,U=!1,$=null;for(Bn.lastIndex=0,h.m3u8=i,h.hasVariableRefs=!1;(A=Bn.exec(i))!==null;){U&&(U=!1,L=new dr(r,e),L.start=T,L.sn=p,L.cc=x,L.level=t,m&&(L.initSegment=m,L.rawProgramDateTime=m.rawProgramDateTime,m.rawProgramDateTime=null,$&&(L.setByteRange($),$=null)));var V=A[1];if(V){L.duration=parseFloat(V);var M=(" "+A[2]).slice(1);L.title=M||null,L.tagList.push(M?["INF",V,M]:["INF",V])}else if(A[3]){if(j(L.duration)){L.start=T,w&&jn(L,w,h),L.sn=p,L.level=t,L.cc=x,d.push(L);var K=(" "+A[3]).slice(1);L.relurl=K,Kn(L,b),b=L,T+=L.duration,p++,y=0,U=!0}}else if(A[4]){var z=(" "+A[4]).slice(1);b?L.setByteRange(z,b):L.setByteRange(z)}else if(A[5])L.rawProgramDateTime=(" "+A[5]).slice(1),L.tagList.push(["PROGRAM-DATE-TIME",L.rawProgramDateTime]),N===-1&&(N=d.length);else{if(A=A[0].match(Go),!A){k.warn("No matches on slow regex match for level playlist!");continue}for(D=1;D<A.length&&!(typeof A[D]<"u");D++);var te=(" "+A[D]).slice(1),Z=(" "+A[D+1]).slice(1),ie=A[D+2]?(" "+A[D+2]).slice(1):"";switch(te){case"PLAYLIST-TYPE":h.type=Z.toUpperCase();break;case"MEDIA-SEQUENCE":p=h.startSN=parseInt(Z);break;case"SKIP":{var he=new pe(Z),fe=he.decimalInteger("SKIPPED-SEGMENTS");if(j(fe)){h.skippedSegments=fe;for(var Le=fe;Le--;)d.unshift(null);p+=fe}var Ee=he.enumeratedString("RECENTLY-REMOVED-DATERANGES");Ee&&(h.recentlyRemovedDateranges=Ee.split(" "));break}case"TARGETDURATION":h.targetduration=Math.max(parseInt(Z),1);break;case"VERSION":h.version=parseInt(Z);break;case"INDEPENDENT-SEGMENTS":case"EXTM3U":break;case"ENDLIST":h.live=!1;break;case"#":(Z||ie)&&L.tagList.push(ie?[Z,ie]:[Z]);break;case"DISCONTINUITY":x++,L.tagList.push(["DIS"]);break;case"GAP":L.gap=!0,L.tagList.push([te]);break;case"BITRATE":L.tagList.push([te,Z]);break;case"DATERANGE":{var we=new pe(Z),Ae=new ke(we,h.dateRanges[we.ID]);Ae.isValid||h.skippedSegments?h.dateRanges[Ae.id]=Ae:k.warn('Ignoring invalid DATERANGE tag: "'+Z+'"'),L.tagList.push(["EXT-X-DATERANGE",Z]);break}case"DEFINE":break;case"DISCONTINUITY-SEQUENCE":x=parseInt(Z);break;case"KEY":{var ye=Gn(Z,e);if(ye.isSupported()){if(ye.method==="NONE"){w=void 0;break}w||(w={}),w[ye.keyFormat]&&(w=C({},w)),w[ye.keyFormat]=ye}else k.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+Z+'"');break}case"START":h.startTimeOffset=Vn(Z);break;case"MAP":{var je=new pe(Z);if(L.duration){var Fe=new dr(r,e);Wn(Fe,je,t,w),m=Fe,L.initSegment=m,m.rawProgramDateTime&&!L.rawProgramDateTime&&(L.rawProgramDateTime=m.rawProgramDateTime)}else{var qe=L.byteRangeEndOffset;if(qe){var Xe=L.byteRangeStartOffset;$=qe-Xe+"@"+Xe}else $=null;Wn(L,je,t,w),m=L,U=!0}break}case"SERVER-CONTROL":{var Ze=new pe(Z);h.canBlockReload=Ze.bool("CAN-BLOCK-RELOAD"),h.canSkipUntil=Ze.optionalFloat("CAN-SKIP-UNTIL",0),h.canSkipDateRanges=h.canSkipUntil>0&&Ze.bool("CAN-SKIP-DATERANGES"),h.partHoldBack=Ze.optionalFloat("PART-HOLD-BACK",0),h.holdBack=Ze.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var ze=new pe(Z);h.partTarget=ze.decimalFloatingPoint("PART-TARGET");break}case"PART":{var Ue=h.partList;Ue||(Ue=h.partList=[]);var jt=y>0?Ue[Ue.length-1]:void 0,_t=y++,$e=new pe(Z),ct=new _n($e,L,e,_t,jt);Ue.push(ct),L.duration+=ct.duration;break}case"PRELOAD-HINT":{var vt=new pe(Z);h.preloadHint=vt;break}case"RENDITION-REPORT":{var et=new pe(Z);h.renditionReports=h.renditionReports||[],h.renditionReports.push(et);break}default:k.warn("line parsed but not handled: "+A);break}}}b&&!b.relurl?(d.pop(),T-=b.duration,h.partList&&(h.fragmentHint=b)):h.partList&&(Kn(L,b),L.cc=x,h.fragmentHint=L,w&&jn(L,w,h));var Ke=d.length,yt=d[0],ft=d[Ke-1];if(T+=h.skippedSegments*h.targetduration,T>0&&Ke&&ft){h.averagetargetduration=T/Ke;var st=ft.sn;h.endSN=st!=="initSegment"?st:0,h.live||(ft.endList=!0),yt&&(h.startCC=yt.cc)}else h.endSN=0,h.startCC=0;return h.fragmentHint&&(T+=h.fragmentHint.duration),h.totalduration=T,h.endCC=x,N>0&&Ho(d,N),h},s}();function Gn(s,a,i){var e,t,r=new pe(s),o=(e=r.METHOD)!=null?e:"",u=r.URI,h=r.hexadecimalInteger("IV"),d=r.KEYFORMATVERSIONS,m=(t=r.KEYFORMAT)!=null?t:"identity";u&&r.IV&&!h&&k.error("Invalid IV: "+r.IV);var p=u?br.resolve(u,a):"",y=(d||"1").split("/").map(Number).filter(Number.isFinite);return new Po(o,p,m,y,h)}function Vn(s){var a=new pe(s),i=a.decimalFloatingPoint("TIME-OFFSET");return j(i)?i:null}function Vo(s,a){var i=(s||"").split(/[ ,]+/).filter(function(e){return e});["video","audio","text"].forEach(function(e){var t=i.filter(function(r){return Mo(r,e)});t.length&&(a[e+"Codec"]=t.join(","),i=i.filter(function(r){return t.indexOf(r)===-1}))}),a.unknownCodecs=i}function Hn(s,a,i){var e=a[i];e&&(s[i]=e)}function Ho(s,a){for(var i=s[a],e=a;e--;){var t=s[e];if(!t)return;t.programDateTime=i.programDateTime-t.duration*1e3,i=t}}function Kn(s,a){s.rawProgramDateTime?s.programDateTime=Date.parse(s.rawProgramDateTime):a!=null&&a.programDateTime&&(s.programDateTime=a.endProgramDateTime),j(s.programDateTime)||(s.programDateTime=null,s.rawProgramDateTime=null)}function Wn(s,a,i,e){s.relurl=a.URI,a.BYTERANGE&&s.setByteRange(a.BYTERANGE),s.level=i,s.sn="initSegment",e&&(s.levelkeys=e),s.initSegment=null}function jn(s,a,i){s.levelkeys=a;var e=i.encryptedFragments;(!e.length||e[e.length-1].levelkeys!==a)&&Object.keys(a).some(function(t){return a[t].isCommonEncryption})&&e.push(s)}var Oe={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},Me={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function zn(s){var a=s.type;switch(a){case Oe.AUDIO_TRACK:return Me.AUDIO;case Oe.SUBTITLE_TRACK:return Me.SUBTITLE;default:return Me.MAIN}}function xi(s,a){var i=s.url;return(i===void 0||i.indexOf("data:")===0)&&(i=a.url),i}var Ko=function(){function s(i){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=i,this.registerListeners()}var a=s.prototype;return a.startLoad=function(e){},a.stopLoad=function(){this.destroyInternalLoaders()},a.registerListeners=function(){var e=this.hls;e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.LEVEL_LOADING,this.onLevelLoading,this),e.on(R.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(R.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},a.unregisterListeners=function(){var e=this.hls;e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.LEVEL_LOADING,this.onLevelLoading,this),e.off(R.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(R.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},a.createInternalLoader=function(e){var t=this.hls.config,r=t.pLoader,o=t.loader,u=r||o,h=new u(t);return this.loaders[e.type]=h,h},a.getInternalLoader=function(e){return this.loaders[e.type]},a.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},a.destroyInternalLoaders=function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}},a.destroy=function(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()},a.onManifestLoading=function(e,t){var r=t.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Oe.MANIFEST,url:r,deliveryDirectives:null})},a.onLevelLoading=function(e,t){var r=t.id,o=t.level,u=t.pathwayId,h=t.url,d=t.deliveryDirectives;this.load({id:r,level:o,pathwayId:u,responseType:"text",type:Oe.LEVEL,url:h,deliveryDirectives:d})},a.onAudioTrackLoading=function(e,t){var r=t.id,o=t.groupId,u=t.url,h=t.deliveryDirectives;this.load({id:r,groupId:o,level:null,responseType:"text",type:Oe.AUDIO_TRACK,url:u,deliveryDirectives:h})},a.onSubtitleTrackLoading=function(e,t){var r=t.id,o=t.groupId,u=t.url,h=t.deliveryDirectives;this.load({id:r,groupId:o,level:null,responseType:"text",type:Oe.SUBTITLE_TRACK,url:u,deliveryDirectives:h})},a.load=function(e){var t,r=this,o=this.hls.config,u=this.getInternalLoader(e);if(u){var h=u.context;if(h&&h.url===e.url&&h.level===e.level){k.trace("[playlist-loader]: playlist request ongoing");return}k.log("[playlist-loader]: aborting previous loader for type: "+e.type),u.abort()}var d;if(e.type===Oe.MANIFEST?d=o.manifestLoadPolicy.default:d=C({},o.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),u=this.createInternalLoader(e),j((t=e.deliveryDirectives)==null?void 0:t.part)){var m;if(e.type===Oe.LEVEL&&e.level!==null?m=this.hls.levels[e.level].details:e.type===Oe.AUDIO_TRACK&&e.id!==null?m=this.hls.audioTracks[e.id].details:e.type===Oe.SUBTITLE_TRACK&&e.id!==null&&(m=this.hls.subtitleTracks[e.id].details),m){var p=m.partTarget,y=m.targetduration;if(p&&y){var T=Math.max(p*3,y*.8)*1e3;d=C({},d,{maxTimeToFirstByteMs:Math.min(T,d.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(T,d.maxTimeToFirstByteMs)})}}}var x=d.errorRetry||d.timeoutRetry||{},b={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:x.maxNumRetry||0,retryDelay:x.retryDelayMs||0,maxRetryDelay:x.maxRetryDelayMs||0},L={onSuccess:function(D,w,N,U){var $=r.getInternalLoader(N);r.resetInternalLoader(N.type);var V=D.data;if(V.indexOf("#EXTM3U")!==0){r.handleManifestParsingError(D,N,new Error("no EXTM3U delimiter"),U||null,w);return}w.parsing.start=performance.now(),br.isMediaPlaylist(V)?r.handleTrackOrLevelPlaylist(D,w,N,U||null,$):r.handleMasterPlaylist(D,w,N,U)},onError:function(D,w,N,U){r.handleNetworkError(w,N,!1,D,U)},onTimeout:function(D,w,N){r.handleNetworkError(w,N,!0,void 0,D)}};u.load(e,b,L)},a.handleMasterPlaylist=function(e,t,r,o){var u=this.hls,h=e.data,d=xi(e,r),m=br.parseMasterPlaylist(h,d);if(m.playlistParsingError){this.handleManifestParsingError(e,r,m.playlistParsingError,o,t);return}var p=m.contentSteering,y=m.levels,T=m.sessionData,x=m.sessionKeys,b=m.startTimeOffset,L=m.variableList;this.variableList=L;var A=br.parseMasterPlaylistMedia(h,d,m),D=A.AUDIO,w=D===void 0?[]:D,N=A.SUBTITLES,U=A["CLOSED-CAPTIONS"];if(w.length){var $=w.some(function(V){return!V.url});!$&&y[0].audioCodec&&!y[0].attrs.AUDIO&&(k.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),w.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new pe({}),bitrate:0,url:""}))}u.trigger(R.MANIFEST_LOADED,{levels:y,audioTracks:w,subtitles:N,captions:U,contentSteering:p,url:d,stats:t,networkDetails:o,sessionData:T,sessionKeys:x,startTimeOffset:b,variableList:L})},a.handleTrackOrLevelPlaylist=function(e,t,r,o,u){var h=this.hls,d=r.id,m=r.level,p=r.type,y=xi(e,r),T=0,x=j(m)?m:j(d)?d:0,b=zn(r),L=br.parseLevelPlaylist(e.data,y,x,b,T,this.variableList);if(p===Oe.MANIFEST){var A={attrs:new pe({}),bitrate:0,details:L,name:"",url:y};h.trigger(R.MANIFEST_LOADED,{levels:[A],audioTracks:[],url:y,stats:t,networkDetails:o,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=L,this.handlePlaylistLoaded(L,e,t,r,o,u)},a.handleManifestParsingError=function(e,t,r,o,u){this.hls.trigger(R.ERROR,{type:le.NETWORK_ERROR,details:G.MANIFEST_PARSING_ERROR,fatal:t.type===Oe.MANIFEST,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:o,stats:u})},a.handleNetworkError=function(e,t,r,o,u){r===void 0&&(r=!1);var h="A network "+(r?"timeout":"error"+(o?" (status "+o.code+")":""))+" occurred while loading "+e.type;e.type===Oe.LEVEL?h+=": "+e.level+" id: "+e.id:(e.type===Oe.AUDIO_TRACK||e.type===Oe.SUBTITLE_TRACK)&&(h+=" id: "+e.id+' group-id: "'+e.groupId+'"');var d=new Error(h);k.warn("[playlist-loader]: "+h);var m=G.UNKNOWN,p=!1,y=this.getInternalLoader(e);switch(e.type){case Oe.MANIFEST:m=r?G.MANIFEST_LOAD_TIMEOUT:G.MANIFEST_LOAD_ERROR,p=!0;break;case Oe.LEVEL:m=r?G.LEVEL_LOAD_TIMEOUT:G.LEVEL_LOAD_ERROR,p=!1;break;case Oe.AUDIO_TRACK:m=r?G.AUDIO_TRACK_LOAD_TIMEOUT:G.AUDIO_TRACK_LOAD_ERROR,p=!1;break;case Oe.SUBTITLE_TRACK:m=r?G.SUBTITLE_TRACK_LOAD_TIMEOUT:G.SUBTITLE_LOAD_ERROR,p=!1;break}y&&this.resetInternalLoader(e.type);var T={type:le.NETWORK_ERROR,details:m,fatal:p,url:e.url,loader:y,context:e,error:d,networkDetails:t,stats:u};if(o){var x=t?.url||e.url;T.response=l({url:x,data:void 0},o)}this.hls.trigger(R.ERROR,T)},a.handlePlaylistLoaded=function(e,t,r,o,u,h){var d=this.hls,m=o.type,p=o.level,y=o.id,T=o.groupId,x=o.deliveryDirectives,b=xi(t,o),L=zn(o),A=typeof o.level=="number"&&L===Me.MAIN?p:void 0;if(!e.fragments.length){var D=new Error("No Segments found in Playlist");d.trigger(R.ERROR,{type:le.NETWORK_ERROR,details:G.LEVEL_EMPTY_ERROR,fatal:!1,url:b,error:D,reason:D.message,response:t,context:o,level:A,parent:L,networkDetails:u,stats:r});return}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));var w=e.playlistParsingError;if(w){d.trigger(R.ERROR,{type:le.NETWORK_ERROR,details:G.LEVEL_PARSING_ERROR,fatal:!1,url:b,error:w,reason:w.message,response:t,context:o,level:A,parent:L,networkDetails:u,stats:r});return}switch(e.live&&h&&(h.getCacheAge&&(e.ageHeader=h.getCacheAge()||0),(!h.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),m){case Oe.MANIFEST:case Oe.LEVEL:d.trigger(R.LEVEL_LOADED,{details:e,level:A||0,id:y||0,stats:r,networkDetails:u,deliveryDirectives:x});break;case Oe.AUDIO_TRACK:d.trigger(R.AUDIO_TRACK_LOADED,{details:e,id:y||0,groupId:T||"",stats:r,networkDetails:u,deliveryDirectives:x});break;case Oe.SUBTITLE_TRACK:d.trigger(R.SUBTITLE_TRACK_LOADED,{details:e,id:y||0,groupId:T||"",stats:r,networkDetails:u,deliveryDirectives:x});break}},s}();function Wo(s,a){var i;try{i=new Event("addtrack")}catch{i=document.createEvent("Event"),i.initEvent("addtrack",!1,!1)}i.track=s,a.dispatchEvent(i)}function jo(s){var a=s.mode;if(a==="disabled"&&(s.mode="hidden"),s.cues)for(var i=s.cues.length;i--;)s.removeCue(s.cues[i]);a==="disabled"&&(s.mode=a)}function zo(s,a,i,e){var t=s.mode;if(t==="disabled"&&(s.mode="hidden"),s.cues&&s.cues.length>0)for(var r=qo(s.cues,a,i),o=0;o<r.length;o++)(!e||e(r[o]))&&s.removeCue(r[o]);t==="disabled"&&(s.mode=t)}function Yo(s,a){if(a<s[0].startTime)return 0;var i=s.length-1;if(a>s[i].endTime)return-1;for(var e=0,t=i;e<=t;){var r=Math.floor((t+e)/2);if(a<s[r].startTime)t=r-1;else if(a>s[r].startTime&&e<i)e=r+1;else return r}return s[e].startTime-a<a-s[t].startTime?e:t}function qo(s,a,i){var e=[],t=Yo(s,a);if(t>-1)for(var r=t,o=s.length;r<o;r++){var u=s[r];if(u.startTime>=a&&u.endTime<=i)e.push(u);else if(u.startTime>i)return e}return e}var Rt={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"},Xo=.25;function bi(){if(!(typeof self>"u"))return self.VTTCue||self.TextTrackCue}function Yn(s,a,i,e,t){var r=new s(a,i,"");try{r.value=e,t&&(r.type=t)}catch{r=new s(a,i,JSON.stringify(t?l({type:t},e):e))}return r}var Wr=function(){var s=bi();try{s&&new s(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function Li(s,a){return s.getTime()/1e3-a}function $o(s){return Uint8Array.from(s.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var Qo=function(){function s(i){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=i,this._registerListeners()}var a=s.prototype;return a.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},a._registerListeners=function(){var e=this.hls;e.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(R.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(R.LEVEL_UPDATED,this.onLevelUpdated,this)},a._unregisterListeners=function(){var e=this.hls;e.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(R.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(R.LEVEL_UPDATED,this.onLevelUpdated,this)},a.onMediaAttached=function(e,t){this.media=t.media},a.onMediaDetaching=function(){this.id3Track&&(jo(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},a.onManifestLoading=function(){this.dateRangeCuesAppended={}},a.createTrack=function(e){var t=this.getID3Track(e.textTracks);return t.mode="hidden",t},a.getID3Track=function(e){if(this.media){for(var t=0;t<e.length;t++){var r=e[t];if(r.kind==="metadata"&&r.label==="id3")return Wo(r,this.media),r}return this.media.addTextTrack("metadata","id3")}},a.onFragParsingMetadata=function(e,t){if(this.media){var r=this.hls.config,o=r.enableEmsgMetadataCues,u=r.enableID3MetadataCues;if(!(!o&&!u)){var h=t.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));var d=bi();if(d)for(var m=0;m<h.length;m++){var p=h[m].type;if(!(p===Rt.emsg&&!o||!u)){var y=bn(h[m].data);if(y){var T=h[m].pts,x=T+h[m].duration;x>Wr&&(x=Wr);var b=x-T;b<=0&&(x=T+Xo);for(var L=0;L<y.length;L++){var A=y[L];if(!xn(A)){this.updateId3CueEnds(T,p);var D=Yn(d,T,x,A,p);D&&this.id3Track.addCue(D)}}}}}}}},a.updateId3CueEnds=function(e,t){var r,o=(r=this.id3Track)==null?void 0:r.cues;if(o)for(var u=o.length;u--;){var h=o[u];h.type===t&&h.startTime<e&&h.endTime===Wr&&(h.endTime=e)}},a.onBufferFlushing=function(e,t){var r=t.startOffset,o=t.endOffset,u=t.type,h=this.id3Track,d=this.hls;if(d){var m=d.config,p=m.enableEmsgMetadataCues,y=m.enableID3MetadataCues;if(h&&(p||y)){var T;u==="audio"?T=function(b){return b.type===Rt.audioId3&&y}:u==="video"?T=function(b){return b.type===Rt.emsg&&p}:T=function(b){return b.type===Rt.audioId3&&y||b.type===Rt.emsg&&p},zo(h,r,o,T)}}},a.onLevelUpdated=function(e,t){var r=this,o=t.details;if(!(!this.media||!o.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)){var u=this.dateRangeCuesAppended,h=this.id3Track,d=o.dateRanges,m=Object.keys(d);if(h)for(var p=Object.keys(u).filter(function(w){return!m.includes(w)}),y=function(){var N=p[T];Object.keys(u[N].cues).forEach(function(U){h.removeCue(u[N].cues[U])}),delete u[N]},T=p.length;T--;)y();var x=o.fragments[o.fragments.length-1];if(!(m.length===0||!j(x?.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var b=x.programDateTime/1e3-x.start,L=bi(),A=function(){var N=m[D],U=d[N],$=Li(U.startDate,b),V=u[N],M=V?.cues||{},K=V?.durationKnown||!1,z=Wr,te=U.endDate;if(te)z=Li(te,b),K=!0;else if(U.endOnNext&&!K){var Z=m.reduce(function(Ae,ye){if(ye!==U.id){var je=d[ye];if(je.class===U.class&&je.startDate>U.startDate&&(!Ae||U.startDate<Ae.startDate))return je}return Ae},null);Z&&(z=Li(Z.startDate,b),K=!0)}for(var ie=Object.keys(U.attr),he=0;he<ie.length;he++){var fe=ie[he];if(Ne(fe)){var Le=M[fe];if(Le)K&&!V.durationKnown&&(Le.endTime=z);else if(L){var Ee=U.attr[fe];Qe(fe)&&(Ee=$o(Ee));var we=Yn(L,$,z,{key:fe,data:Ee},Rt.dateRange);we&&(we.id=N,r.id3Track.addCue(we),M[fe]=we)}}}u[N]={cues:M,dateRange:U,durationKnown:K}},D=0;D<m.length;D++)A()}}},s}(),Jo=function(){function s(i){var e=this;this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=function(){return e.timeupdate()},this.hls=i,this.config=i.config,this.registerListeners()}var a=s.prototype;return a.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},a.registerListeners=function(){this.hls.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(R.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(R.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(R.ERROR,this.onError,this)},a.unregisterListeners=function(){this.hls.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(R.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(R.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(R.ERROR,this.onError,this)},a.onMediaAttached=function(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},a.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},a.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},a.onLevelUpdated=function(e,t){var r=t.details;this.levelDetails=r,r.advanced&&this.timeupdate(),!r.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},a.onError=function(e,t){var r;t.details===G.BUFFER_STALLED_ERROR&&(this.stallCount++,(r=this.levelDetails)!=null&&r.live&&k.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},a.timeupdate=function(){var e=this.media,t=this.levelDetails;if(!(!e||!t)){this.currentTime=e.currentTime;var r=this.computeLatency();if(r!==null){this._latency=r;var o=this.config,u=o.lowLatencyMode,h=o.maxLiveSyncPlaybackRate;if(!(!u||h===1||!t.live)){var d=this.targetLatency;if(d!==null){var m=r-d,p=Math.min(this.maxLatency,d+t.targetduration),y=m<p;if(y&&m>.05&&this.forwardBufferLength>1){var T=Math.min(2,Math.max(1,h)),x=Math.round(2/(1+Math.exp(-.75*m-this.edgeStalled))*20)/20;e.playbackRate=Math.min(T,Math.max(1,x))}else e.playbackRate!==1&&e.playbackRate!==0&&(e.playbackRate=1)}}}}},a.estimateLiveEdge=function(){var e=this.levelDetails;return e===null?null:e.edge+e.age},a.computeLatency=function(){var e=this.estimateLiveEdge();return e===null?null:e-this.currentTime},_(s,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var e=this.config,t=this.levelDetails;return e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}},{key:"targetLatency",get:function(){var e=this.levelDetails;if(e===null)return null;var t=e.holdBack,r=e.partHoldBack,o=e.targetduration,u=this.config,h=u.liveSyncDuration,d=u.liveSyncDurationCount,m=u.lowLatencyMode,p=this.hls.userConfig,y=m&&r||t;(p.liveSyncDuration||p.liveSyncDurationCount||y===0)&&(y=h!==void 0?h:d*o);var T=o,x=1;return y+Math.min(this.stallCount*x,T)}},{key:"liveSyncPosition",get:function(){var e=this.estimateLiveEdge(),t=this.targetLatency,r=this.levelDetails;if(e===null||t===null||r===null)return null;var o=r.edge,u=e-t-this.edgeStalled,h=o-r.totalduration,d=o-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(h,u),d)}},{key:"drift",get:function(){var e=this.levelDetails;return e===null?1:e.drift}},{key:"edgeStalled",get:function(){var e=this.levelDetails;if(e===null)return 0;var t=(this.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;return Math.max(e.age-t,0)}},{key:"forwardBufferLength",get:function(){var e=this.media,t=this.levelDetails;if(!e||!t)return 0;var r=e.buffered.length;return(r?e.buffered.end(r-1):t.edge)-this.currentTime}}]),s}(),Ai=["NONE","TYPE-0","TYPE-1",null];function Zo(s){return Ai.indexOf(s)>-1}var jr=["SDR","PQ","HLG"];function eu(s){return!!s&&jr.indexOf(s)>-1}var zr={No:"",Yes:"YES",v2:"v2"};function qn(s){var a=s.canSkipUntil,i=s.canSkipDateRanges,e=s.age,t=e<a/2;return a&&t?i?zr.v2:zr.Yes:zr.No}var Xn=function(){function s(i,e,t){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=i,this.part=e,this.skip=t}var a=s.prototype;return a.addDirectives=function(e){var t=new self.URL(e);return this.msn!==void 0&&t.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href},s}(),Ri=function(){function s(i){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[i.url],this._attrs=[i.attrs],this.bitrate=i.bitrate,i.details&&(this.details=i.details),this.id=i.id||0,this.name=i.name,this.width=i.width||0,this.height=i.height||0,this.frameRate=i.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=i.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=i.audioCodec,this.videoCodec=i.videoCodec,this.codecSet=[i.videoCodec,i.audioCodec].filter(function(e){return!!e}).map(function(e){return e.substring(0,4)}).join(","),this.addGroupId("audio",i.attrs.AUDIO),this.addGroupId("text",i.attrs.SUBTITLES)}var a=s.prototype;return a.hasAudioGroup=function(e){return $n(this._audioGroups,e)},a.hasSubtitleGroup=function(e){return $n(this._subtitleGroups,e)},a.addGroupId=function(e,t){if(t){if(e==="audio"){var r=this._audioGroups;r||(r=this._audioGroups=[]),r.indexOf(t)===-1&&r.push(t)}else if(e==="text"){var o=this._subtitleGroups;o||(o=this._subtitleGroups=[]),o.indexOf(t)===-1&&o.push(t)}}},a.addFallback=function(){},_(s,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"averageBitrate",get:function(){return this._avgBitrate||this.realBitrate||this.bitrate}},{key:"attrs",get:function(){return this._attrs[0]}},{key:"codecs",get:function(){return this.attrs.CODECS||""}},{key:"pathwayId",get:function(){return this.attrs["PATHWAY-ID"]||"."}},{key:"videoRange",get:function(){return this.attrs["VIDEO-RANGE"]||"SDR"}},{key:"score",get:function(){return this.attrs.optionalFloat("SCORE",0)}},{key:"uri",get:function(){return this.url[0]||""}},{key:"audioGroups",get:function(){return this._audioGroups}},{key:"subtitleGroups",get:function(){return this._subtitleGroups}},{key:"urlId",get:function(){return 0},set:function(e){}},{key:"audioGroupIds",get:function(){return this.audioGroups?[this.audioGroupId]:void 0}},{key:"textGroupIds",get:function(){return this.subtitleGroups?[this.textGroupId]:void 0}},{key:"audioGroupId",get:function(){var e;return(e=this.audioGroups)==null?void 0:e[0]}},{key:"textGroupId",get:function(){var e;return(e=this.subtitleGroups)==null?void 0:e[0]}}]),s}();function $n(s,a){return!a||!s?!1:s.indexOf(a)!==-1}function Ci(s,a){var i=a.startPTS;if(j(i)){var e=0,t;a.sn>s.sn?(e=i-s.start,t=s):(e=s.start-i,t=a),t.duration!==e&&(t.duration=e)}else if(a.sn>s.sn){var r=s.cc===a.cc;r&&s.minEndPTS?a.start=s.start+(s.minEndPTS-s.start):a.start=s.start+s.duration}else a.start=Math.max(s.start-a.duration,0)}function Qn(s,a,i,e,t,r){var o=e-i;o<=0&&(k.warn("Fragment should have a positive duration",a),e=i+a.duration,r=t+a.duration);var u=i,h=e,d=a.startPTS,m=a.endPTS;if(j(d)){var p=Math.abs(d-i);j(a.deltaPTS)?a.deltaPTS=Math.max(p,a.deltaPTS):a.deltaPTS=p,u=Math.max(i,d),i=Math.min(i,d),t=Math.min(t,a.startDTS),h=Math.min(e,m),e=Math.max(e,m),r=Math.max(r,a.endDTS)}var y=i-a.start;a.start!==0&&(a.start=i),a.duration=e-a.start,a.startPTS=i,a.maxStartPTS=u,a.startDTS=t,a.endPTS=e,a.minEndPTS=h,a.endDTS=r;var T=a.sn;if(!s||T<s.startSN||T>s.endSN)return 0;var x,b=T-s.startSN,L=s.fragments;for(L[b]=a,x=b;x>0;x--)Ci(L[x],L[x-1]);for(x=b;x<L.length-1;x++)Ci(L[x],L[x+1]);return s.fragmentHint&&Ci(L[L.length-1],s.fragmentHint),s.PTSKnown=s.alignedSliding=!0,y}function tu(s,a){for(var i=null,e=s.fragments,t=e.length-1;t>=0;t--){var r=e[t].initSegment;if(r){i=r;break}}s.fragmentHint&&delete s.fragmentHint.endPTS;var o=0,u;if(nu(s,a,function(x,b){x.relurl&&(o=x.cc-b.cc),j(x.startPTS)&&j(x.endPTS)&&(b.start=b.startPTS=x.startPTS,b.startDTS=x.startDTS,b.maxStartPTS=x.maxStartPTS,b.endPTS=x.endPTS,b.endDTS=x.endDTS,b.minEndPTS=x.minEndPTS,b.duration=x.endPTS-x.startPTS,b.duration&&(u=b),a.PTSKnown=a.alignedSliding=!0),b.elementaryStreams=x.elementaryStreams,b.loader=x.loader,b.stats=x.stats,x.initSegment&&(b.initSegment=x.initSegment,i=x.initSegment)}),i){var h=a.fragmentHint?a.fragments.concat(a.fragmentHint):a.fragments;h.forEach(function(x){var b;x&&(!x.initSegment||x.initSegment.relurl===((b=i)==null?void 0:b.relurl))&&(x.initSegment=i)})}if(a.skippedSegments)if(a.deltaUpdateFailed=a.fragments.some(function(x){return!x}),a.deltaUpdateFailed){k.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var d=a.skippedSegments;d--;)a.fragments.shift();a.startSN=a.fragments[0].sn,a.startCC=a.fragments[0].cc}else a.canSkipDateRanges&&(a.dateRanges=ru(s.dateRanges,a.dateRanges,a.recentlyRemovedDateranges));var m=a.fragments;if(o){k.warn("discontinuity sliding from playlist, take drift into account");for(var p=0;p<m.length;p++)m[p].cc+=o}a.skippedSegments&&(a.startCC=a.fragments[0].cc),iu(s.partList,a.partList,function(x,b){b.elementaryStreams=x.elementaryStreams,b.stats=x.stats}),u?Qn(a,u,u.startPTS,u.endPTS,u.startDTS,u.endDTS):Jn(s,a),m.length&&(a.totalduration=a.edge-m[0].start),a.driftStartTime=s.driftStartTime,a.driftStart=s.driftStart;var y=a.advancedDateTime;if(a.advanced&&y){var T=a.edge;a.driftStart||(a.driftStartTime=y,a.driftStart=T),a.driftEndTime=y,a.driftEnd=T}else a.driftEndTime=s.driftEndTime,a.driftEnd=s.driftEnd,a.advancedDateTime=s.advancedDateTime}function ru(s,a,i){var e=C({},s);return i&&i.forEach(function(t){delete e[t]}),Object.keys(a).forEach(function(t){var r=new ke(a[t].attr,e[t]);r.isValid?e[t]=r:k.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(a[t].attr)+'"')}),e}function iu(s,a,i){if(s&&a)for(var e=0,t=0,r=s.length;t<=r;t++){var o=s[t],u=a[t+e];o&&u&&o.index===u.index&&o.fragment.sn===u.fragment.sn?i(o,u):e--}}function nu(s,a,i){for(var e=a.skippedSegments,t=Math.max(s.startSN,a.startSN)-a.startSN,r=(s.fragmentHint?1:0)+(e?a.endSN:Math.min(s.endSN,a.endSN))-a.startSN,o=a.startSN-s.startSN,u=a.fragmentHint?a.fragments.concat(a.fragmentHint):a.fragments,h=s.fragmentHint?s.fragments.concat(s.fragmentHint):s.fragments,d=t;d<=r;d++){var m=h[o+d],p=u[d];e&&!p&&d<e&&(p=a.fragments[d]=m),m&&p&&i(m,p)}}function Jn(s,a){var i=a.startSN+a.skippedSegments-s.startSN,e=s.fragments;i<0||i>=e.length||au(a,e[i].start)}function au(s,a){if(a){for(var i=s.fragments,e=s.skippedSegments;e<i.length;e++)i[e].start+=a;s.fragmentHint&&(s.fragmentHint.start+=a)}}function su(s,a){a===void 0&&(a=1/0);var i=1e3*s.targetduration;if(s.updated){var e=s.fragments,t=4;if(e.length&&i*t>a){var r=e[e.length-1].duration*1e3;r<i&&(i=r)}}else i/=2;return Math.round(i)}function ou(s,a,i){if(!(s!=null&&s.details))return null;var e=s.details,t=e.fragments[a-e.startSN];return t||(t=e.fragmentHint,t&&t.sn===a)?t:a<e.startSN&&i&&i.sn===a?i:null}function Zn(s,a,i){var e;return s!=null&&s.details?ea((e=s.details)==null?void 0:e.partList,a,i):null}function ea(s,a,i){if(s)for(var e=s.length;e--;){var t=s[e];if(t.index===i&&t.fragment.sn===a)return t}return null}function ta(s){s.forEach(function(a,i){var e=a.details;e!=null&&e.fragments&&e.fragments.forEach(function(t){t.level=i})})}function Yr(s){switch(s.details){case G.FRAG_LOAD_TIMEOUT:case G.KEY_LOAD_TIMEOUT:case G.LEVEL_LOAD_TIMEOUT:case G.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function ra(s,a){var i=Yr(a);return s.default[(i?"timeout":"error")+"Retry"]}function Di(s,a){var i=s.backoff==="linear"?1:Math.pow(2,a);return Math.min(i*s.retryDelayMs,s.maxRetryDelayMs)}function ia(s){return l(l({},s),{errorRetry:null,timeoutRetry:null})}function qr(s,a,i,e){if(!s)return!1;var t=e?.code,r=a<s.maxNumRetry&&(uu(t)||!!i);return s.shouldRetry?s.shouldRetry(s,a,i,e,r):r}function uu(s){return s===0&&navigator.onLine===!1||!!s&&(s<400||s>499)}var na={search:function(a,i){for(var e=0,t=a.length-1,r=null,o=null;e<=t;){r=(e+t)/2|0,o=a[r];var u=i(o);if(u>0)e=r+1;else if(u<0)t=r-1;else return o}return null}};function lu(s,a,i){if(a===null||!Array.isArray(s)||!s.length||!j(a))return null;var e=s[0].programDateTime;if(a<(e||0))return null;var t=s[s.length-1].endProgramDateTime;if(a>=(t||0))return null;i=i||0;for(var r=0;r<s.length;++r){var o=s[r];if(hu(a,i,o))return o}return null}function aa(s,a,i,e,t){i===void 0&&(i=0),e===void 0&&(e=0),t===void 0&&(t=.005);var r=null;if(s){r=a[s.sn-a[0].sn+1]||null;var o=s.endDTS-i;o>0&&o<15e-7&&(i+=15e-7)}else i===0&&a[0].start===0&&(r=a[0]);if(r&&((!s||s.level===r.level)&&sa(i,e,r)===0||fu(r,s,Math.min(t,e))))return r;var u=na.search(a,sa.bind(null,i,e));return u&&(u!==s||!r)?u:r}function fu(s,a,i){if(a&&a.start===0&&a.level<s.level&&(a.endPTS||0)>0){var e=a.tagList.reduce(function(t,r){return r[0]==="INF"&&(t+=parseFloat(r[1])),t},i);return s.start<=e}return!1}function sa(s,a,i){if(s===void 0&&(s=0),a===void 0&&(a=0),i.start<=s&&i.start+i.duration>s)return 0;var e=Math.min(a,i.duration+(i.deltaPTS?i.deltaPTS:0));return i.start+i.duration-e<=s?1:i.start-e>s&&i.start?-1:0}function hu(s,a,i){var e=Math.min(a,i.duration+(i.deltaPTS?i.deltaPTS:0))*1e3,t=i.endProgramDateTime||0;return t-e>s}function du(s,a){return na.search(s,function(i){return i.cc<a?1:i.cc>a?-1:0})}var ot={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},Ct={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4},cu=function(){function s(i){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=i,this.log=k.log.bind(k,"[info]:"),this.warn=k.warn.bind(k,"[warning]:"),this.error=k.error.bind(k,"[error]:"),this.registerListeners()}var a=s.prototype;return a.registerListeners=function(){var e=this.hls;e.on(R.ERROR,this.onError,this),e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.LEVEL_UPDATED,this.onLevelUpdated,this)},a.unregisterListeners=function(){var e=this.hls;e&&(e.off(R.ERROR,this.onError,this),e.off(R.ERROR,this.onErrorOut,this),e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.LEVEL_UPDATED,this.onLevelUpdated,this))},a.destroy=function(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}},a.startLoad=function(e){},a.stopLoad=function(){this.playlistError=0},a.getVariantLevelIndex=function(e){return e?.type===Me.MAIN?e.level:this.hls.loadLevel},a.onManifestLoading=function(){this.playlistError=0,this.penalizedRenditions={}},a.onLevelUpdated=function(){this.playlistError=0},a.onError=function(e,t){var r,o;if(!t.fatal){var u=this.hls,h=t.context;switch(t.details){case G.FRAG_LOAD_ERROR:case G.FRAG_LOAD_TIMEOUT:case G.KEY_LOAD_ERROR:case G.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case G.FRAG_PARSING_ERROR:if((r=t.frag)!=null&&r.gap){t.errorAction={action:ot.DoNothing,flags:Ct.None};return}case G.FRAG_GAP:case G.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=ot.SendAlternateToPenaltyBox;return}case G.LEVEL_EMPTY_ERROR:case G.LEVEL_PARSING_ERROR:{var d,m,p=t.parent===Me.MAIN?t.level:u.loadLevel;t.details===G.LEVEL_EMPTY_ERROR&&((d=t.context)!=null&&(m=d.levelDetails)!=null&&m.live)?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,p):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,p))}return;case G.LEVEL_LOAD_ERROR:case G.LEVEL_LOAD_TIMEOUT:typeof h?.level=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,h.level));return;case G.AUDIO_TRACK_LOAD_ERROR:case G.AUDIO_TRACK_LOAD_TIMEOUT:case G.SUBTITLE_LOAD_ERROR:case G.SUBTITLE_TRACK_LOAD_TIMEOUT:if(h){var y=u.levels[u.loadLevel];if(y&&(h.type===Oe.AUDIO_TRACK&&y.hasAudioGroup(h.groupId)||h.type===Oe.SUBTITLE_TRACK&&y.hasSubtitleGroup(h.groupId))){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,u.loadLevel),t.errorAction.action=ot.SendAlternateToPenaltyBox,t.errorAction.flags=Ct.MoveAllAlternatesMatchingHost;return}}return;case G.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{var T=u.levels[u.loadLevel],x=T?.attrs["HDCP-LEVEL"];x?t.errorAction={action:ot.SendAlternateToPenaltyBox,flags:Ct.MoveAllAlternatesMatchingHDCP,hdcpLevel:x}:this.keySystemError(t)}return;case G.BUFFER_ADD_CODEC_ERROR:case G.REMUX_ALLOC_ERROR:case G.BUFFER_APPEND_ERROR:t.errorAction=this.getLevelSwitchAction(t,(o=t.level)!=null?o:u.loadLevel);return;case G.INTERNAL_EXCEPTION:case G.BUFFER_APPENDING_ERROR:case G.BUFFER_FULL_ERROR:case G.LEVEL_SWITCH_ERROR:case G.BUFFER_STALLED_ERROR:case G.BUFFER_SEEK_OVER_HOLE:case G.BUFFER_NUDGE_ON_STALL:t.errorAction={action:ot.DoNothing,flags:Ct.None};return}t.type===le.KEY_SYSTEM_ERROR&&this.keySystemError(t)}},a.keySystemError=function(e){var t=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,t)},a.getPlaylistRetryOrSwitchAction=function(e,t){var r=this.hls,o=ra(r.config.playlistLoadPolicy,e),u=this.playlistError++,h=qr(o,u,Yr(e),e.response);if(h)return{action:ot.RetryRequest,flags:Ct.None,retryConfig:o,retryCount:u};var d=this.getLevelSwitchAction(e,t);return o&&(d.retryConfig=o,d.retryCount=u),d},a.getFragRetryOrSwitchAction=function(e){var t=this.hls,r=this.getVariantLevelIndex(e.frag),o=t.levels[r],u=t.config,h=u.fragLoadPolicy,d=u.keyLoadPolicy,m=ra(e.details.startsWith("key")?d:h,e),p=t.levels.reduce(function(x,b){return x+b.fragmentError},0);if(o){e.details!==G.FRAG_GAP&&o.fragmentError++;var y=qr(m,p,Yr(e),e.response);if(y)return{action:ot.RetryRequest,flags:Ct.None,retryConfig:m,retryCount:p}}var T=this.getLevelSwitchAction(e,r);return m&&(T.retryConfig=m,T.retryCount=p),T},a.getLevelSwitchAction=function(e,t){var r=this.hls;t==null&&(t=r.loadLevel);var o=this.hls.levels[t];if(o){var u,h,d=e.details;o.loadError++,d===G.BUFFER_APPEND_ERROR&&o.fragmentError++;var m=-1,p=r.levels,y=r.loadLevel,T=r.minAutoLevel,x=r.maxAutoLevel;r.autoLevelEnabled||(r.loadLevel=-1);for(var b=(u=e.frag)==null?void 0:u.type,L=b===Me.AUDIO&&d===G.FRAG_PARSING_ERROR||e.sourceBufferName==="audio"&&(d===G.BUFFER_ADD_CODEC_ERROR||d===G.BUFFER_APPEND_ERROR),A=L&&p.some(function(z){var te=z.audioCodec;return o.audioCodec!==te}),D=e.sourceBufferName==="video"&&(d===G.BUFFER_ADD_CODEC_ERROR||d===G.BUFFER_APPEND_ERROR),w=D&&p.some(function(z){var te=z.codecSet,Z=z.audioCodec;return o.codecSet!==te&&o.audioCodec===Z}),N=(h=e.context)!=null?h:{},U=N.type,$=N.groupId,V=function(){var te=(K+y)%p.length;if(te!==y&&te>=T&&te<=x&&p[te].loadError===0){var Z,ie,he=p[te];if(d===G.FRAG_GAP&&b===Me.MAIN&&e.frag){var fe=p[te].details;if(fe){var Le=aa(e.frag,fe.fragments,e.frag.start);if(Le!=null&&Le.gap)return 0}}else{if(U===Oe.AUDIO_TRACK&&he.hasAudioGroup($)||U===Oe.SUBTITLE_TRACK&&he.hasSubtitleGroup($))return 0;if(b===Me.AUDIO&&(Z=o.audioGroups)!=null&&Z.some(function(Ee){return he.hasAudioGroup(Ee)})||b===Me.SUBTITLE&&(ie=o.subtitleGroups)!=null&&ie.some(function(Ee){return he.hasSubtitleGroup(Ee)})||A&&o.audioCodec===he.audioCodec||!A&&o.audioCodec!==he.audioCodec||w&&o.codecSet===he.codecSet)return 0}return m=te,1}},M,K=p.length;K--&&(M=V(),!(M!==0&&M===1)););if(m>-1&&r.loadLevel!==m)return e.levelRetry=!0,this.playlistError=0,{action:ot.SendAlternateToPenaltyBox,flags:Ct.None,nextAutoLevel:m}}return{action:ot.SendAlternateToPenaltyBox,flags:Ct.MoveAllAlternatesMatchingHost}},a.onErrorOut=function(e,t){var r;switch((r=t.errorAction)==null?void 0:r.action){case ot.DoNothing:break;case ot.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),!t.errorAction.resolved&&t.details!==G.FRAG_GAP?t.fatal=!0:/MediaSource readyState: ended/.test(t.error.message)&&(this.warn('MediaSource ended after "'+t.sourceBufferName+'" sourceBuffer append error. Attempting to recover from media error.'),this.hls.recoverMediaError());break}if(t.fatal){this.hls.stopLoad();return}},a.sendAlternateToPenaltyBox=function(e){var t=this.hls,r=e.errorAction;if(r){var o=r.flags,u=r.hdcpLevel,h=r.nextAutoLevel;switch(o){case Ct.None:this.switchLevel(e,h);break;case Ct.MoveAllAlternatesMatchingHDCP:u&&(t.maxHdcpLevel=Ai[Ai.indexOf(u)-1],r.resolved=!0),this.warn('Restricting playback to HDCP-LEVEL of "'+t.maxHdcpLevel+'" or lower');break}r.resolved||this.switchLevel(e,h)}},a.switchLevel=function(e,t){t!==void 0&&e.errorAction&&(this.warn("switching to level "+t+" after "+e.details),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)},s}(),vu=function(){function s(i,e){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=k.log.bind(k,e+":"),this.warn=k.warn.bind(k,e+":"),this.hls=i}var a=s.prototype;return a.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},a.clearTimer=function(){this.timer!==-1&&(self.clearTimeout(this.timer),this.timer=-1)},a.startLoad=function(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()},a.stopLoad=function(){this.canLoad=!1,this.clearTimer()},a.switchParams=function(e,t,r){var o=t?.renditionReports;if(o){for(var u=-1,h=0;h<o.length;h++){var d=o[h],m=void 0;try{m=new self.URL(d.URI,t.url).href}catch(L){k.warn("Could not construct new URL for Rendition Report: "+L),m=d.URI||""}if(m===e){u=h;break}else m===e.substring(0,m.length)&&(u=h)}if(u!==-1){var p=o[u],y=parseInt(p["LAST-MSN"])||t?.lastPartSn,T=parseInt(p["LAST-PART"])||t?.lastPartIndex;if(this.hls.config.lowLatencyMode){var x=Math.min(t.age-t.partTarget,t.targetduration);T>=0&&x>t.partTarget&&(T+=1)}var b=r&&qn(r);return new Xn(y,T>=0?T:void 0,b)}}},a.loadPlaylist=function(e){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())},a.shouldLoadPlaylist=function(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)},a.shouldReloadPlaylist=function(e){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(e)},a.playlistLoaded=function(e,t,r){var o=this,u=t.details,h=t.stats,d=self.performance.now(),m=h.loading.first?Math.max(0,d-h.loading.first):0;if(u.advancedDateTime=Date.now()-m,u.live||r!=null&&r.live){if(u.reloaded(r),r&&this.log("live playlist "+e+" "+(u.advanced?"REFRESHED "+u.lastPartSn+"-"+u.lastPartIndex:u.updated?"UPDATED":"MISSED")),r&&u.fragments.length>0&&tu(r,u),!this.canLoad||!u.live)return;var p,y=void 0,T=void 0;if(u.canBlockReload&&u.endSN&&u.advanced){var x=this.hls.config.lowLatencyMode,b=u.lastPartSn,L=u.endSN,A=u.lastPartIndex,D=A!==-1,w=b===L,N=x?0:A;D?(y=w?L+1:b,T=w?N:A+1):y=L+1;var U=u.age,$=U+u.ageHeader,V=Math.min($-u.partTarget,u.targetduration*1.5);if(V>0){if(r&&V>r.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+r.tuneInGoal+" to: "+V+" with playlist age: "+u.age),V=0;else{var M=Math.floor(V/u.targetduration);if(y+=M,T!==void 0){var K=Math.round(V%u.targetduration/u.partTarget);T+=K}this.log("CDN Tune-in age: "+u.ageHeader+"s last advanced "+U.toFixed(2)+"s goal: "+V+" skip sn "+M+" to part "+T)}u.tuneInGoal=V}if(p=this.getDeliveryDirectives(u,t.deliveryDirectives,y,T),x||!w){this.loadPlaylist(p);return}}else(u.canBlockReload||u.canSkipUntil)&&(p=this.getDeliveryDirectives(u,t.deliveryDirectives,y,T));var z=this.hls.mainForwardBufferInfo,te=z?z.end-z.len:0,Z=(u.edge-te)*1e3,ie=su(u,Z);u.updated&&d>this.requestScheduled+ie&&(this.requestScheduled=h.loading.start),y!==void 0&&u.canBlockReload?this.requestScheduled=h.loading.first+ie-(u.partTarget*1e3||1e3):this.requestScheduled===-1||this.requestScheduled+ie<d?this.requestScheduled=d:this.requestScheduled-d<=0&&(this.requestScheduled+=ie);var he=this.requestScheduled-d;he=Math.max(0,he),this.log("reload live playlist "+e+" in "+Math.round(he)+" ms"),this.timer=self.setTimeout(function(){return o.loadPlaylist(p)},he)}else this.clearTimer()},a.getDeliveryDirectives=function(e,t,r,o){var u=qn(e);return t!=null&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,o=t.part,u=zr.No),new Xn(r,o,u)},a.checkRetry=function(e){var t=this,r=e.details,o=Yr(e),u=e.errorAction,h=u||{},d=h.action,m=h.retryCount,p=m===void 0?0:m,y=h.retryConfig,T=!!u&&!!y&&(d===ot.RetryRequest||!u.resolved&&d===ot.SendAlternateToPenaltyBox);if(T){var x;if(this.requestScheduled=-1,p>=y.maxNumRetry)return!1;if(o&&(x=e.context)!=null&&x.deliveryDirectives)this.warn("Retrying playlist loading "+(p+1)+"/"+y.maxNumRetry+' after "'+r+'" without delivery-directives'),this.loadPlaylist();else{var b=Di(y,p);this.timer=self.setTimeout(function(){return t.loadPlaylist()},b),this.warn("Retrying playlist loading "+(p+1)+"/"+y.maxNumRetry+' after "'+r+'" in '+b+"ms")}e.levelRetry=!0,u.resolved=!0}return T},s}(),cr=function(){function s(i,e,t){e===void 0&&(e=0),t===void 0&&(t=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=i,this.alpha_=i?Math.exp(Math.log(.5)/i):0,this.estimate_=e,this.totalWeight_=t}var a=s.prototype;return a.sample=function(e,t){var r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e},a.getTotalWeight=function(){return this.totalWeight_},a.getEstimate=function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_},s}(),pu=function(){function s(i,e,t,r){r===void 0&&(r=100),this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=t,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new cr(i),this.fast_=new cr(e),this.defaultTTFB_=r,this.ttfb_=new cr(i)}var a=s.prototype;return a.update=function(e,t){var r=this.slow_,o=this.fast_,u=this.ttfb_;r.halfLife!==e&&(this.slow_=new cr(e,r.getEstimate(),r.getTotalWeight())),o.halfLife!==t&&(this.fast_=new cr(t,o.getEstimate(),o.getTotalWeight())),u.halfLife!==e&&(this.ttfb_=new cr(e,u.getEstimate(),u.getTotalWeight()))},a.sample=function(e,t){e=Math.max(e,this.minDelayMs_);var r=8*t,o=e/1e3,u=r/o;this.fast_.sample(o,u),this.slow_.sample(o,u)},a.sampleTTFB=function(e){var t=e/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(r,Math.max(e,5))},a.canEstimate=function(){return this.fast_.getTotalWeight()>=this.minWeight_},a.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},a.getEstimateTTFB=function(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_},a.destroy=function(){},s}();function mu(){if(typeof matchMedia=="function"){var s=matchMedia("(dynamic-range: high)"),a=matchMedia("bad query");if(s.media!==a.media)return s.matches===!0}return!1}function gu(s,a){var i=!1,e=[];return s&&(i=s!=="SDR",e=[s]),a&&(e=a.allowedVideoRanges||jr.slice(0),i=a.preferHDR!==void 0?a.preferHDR:mu(),i?e=e.filter(function(t){return t!=="SDR"}):e=["SDR"]),{preferHDR:i,allowedVideoRanges:e}}function yu(s,a,i,e,t){for(var r=Object.keys(s),o=e?.channels,u=e?.audioCodec,h=o&&parseInt(o)===2,d=!0,m=!1,p=1/0,y=1/0,T=1/0,x=0,b=[],L=gu(a,t),A=L.preferHDR,D=L.allowedVideoRanges,w=function(){var K=s[r[N]];d=K.channels[2]>0,p=Math.min(p,K.minHeight),y=Math.min(y,K.minFramerate),T=Math.min(T,K.minBitrate);var z=D.filter(function(te){return K.videoRanges[te]>0});z.length>0&&(m=!0,b=z)},N=r.length;N--;)w();p=j(p)?p:0,y=j(y)?y:0;var U=Math.max(1080,p),$=Math.max(30,y);T=j(T)?T:i,i=Math.max(T,i),m||(a=void 0,b=[]);var V=r.reduce(function(M,K){var z=s[K];if(K===M)return M;if(z.minBitrate>i)return Ht(K,"min bitrate of "+z.minBitrate+" > current estimate of "+i),M;if(!z.hasDefaultAudio)return Ht(K,"no renditions with default or auto-select sound found"),M;if(u&&K.indexOf(u.substring(0,4))%5!==0)return Ht(K,'audio codec preference "'+u+'" not found'),M;if(o&&!h){if(!z.channels[o])return Ht(K,"no renditions with "+o+" channel sound found (channels options: "+Object.keys(z.channels)+")"),M}else if((!u||h)&&d&&z.channels[2]===0)return Ht(K,"no renditions with stereo sound found"),M;return z.minHeight>U?(Ht(K,"min resolution of "+z.minHeight+" > maximum of "+U),M):z.minFramerate>$?(Ht(K,"min framerate of "+z.minFramerate+" > maximum of "+$),M):b.some(function(te){return z.videoRanges[te]>0})?z.maxScore<x?(Ht(K,"max score of "+z.maxScore+" < selected max of "+x),M):M&&(Hr(K)>=Hr(M)||z.fragmentError>s[M].fragmentError)?M:(x=z.maxScore,K):(Ht(K,"no variants with VIDEO-RANGE of "+JSON.stringify(b)+" found"),M)},void 0);return{codecSet:V,videoRanges:b,preferHDR:A,minFramerate:y,minBitrate:T}}function Ht(s,a){k.log('[abr] start candidates with "'+s+'" ignored because '+a)}function Eu(s){return s.reduce(function(a,i){var e=a.groups[i.groupId];e||(e=a.groups[i.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),e.tracks.push(i);var t=i.channels||"2";return e.channels[t]=(e.channels[t]||0)+1,e.hasDefault=e.hasDefault||i.default,e.hasAutoSelect=e.hasAutoSelect||i.autoselect,e.hasDefault&&(a.hasDefaultAudio=!0),e.hasAutoSelect&&(a.hasAutoSelectAudio=!0),a},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function _u(s,a,i,e){return s.slice(i,e+1).reduce(function(t,r){if(!r.codecSet)return t;var o=r.audioGroups,u=t[r.codecSet];u||(t[r.codecSet]=u={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!o,fragmentError:0}),u.minBitrate=Math.min(u.minBitrate,r.bitrate);var h=Math.min(r.height,r.width);return u.minHeight=Math.min(u.minHeight,h),u.minFramerate=Math.min(u.minFramerate,r.frameRate),u.maxScore=Math.max(u.maxScore,r.score),u.fragmentError+=r.fragmentError,u.videoRanges[r.videoRange]=(u.videoRanges[r.videoRange]||0)+1,t},{})}var Su=function(){function s(i){var e=this;this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this._abandonRulesCheck=function(){var t=e.fragCurrent,r=e.partCurrent,o=e.hls,u=o.autoLevelEnabled,h=o.media;if(!(!t||!h)){var d=performance.now(),m=r?r.stats:t.stats,p=r?r.duration:t.duration,y=d-m.loading.start,T=o.minAutoLevel;if(m.aborted||m.loaded&&m.loaded===m.total||t.level<=T){e.clearTimer(),e._nextAutoLevel=-1;return}if(!(!u||h.paused||!h.playbackRate||!h.readyState)){var x=o.mainForwardBufferInfo;if(x!==null){var b=e.bwEstimator.getEstimateTTFB(),L=Math.abs(h.playbackRate);if(!(y<=Math.max(b,1e3*(p/(L*2))))){var A=x.len/L,D=m.loading.first?m.loading.first-m.loading.start:-1,w=m.loaded&&D>-1,N=e.getBwEstimate(),U=o.levels,$=U[t.level],V=m.total||Math.max(m.loaded,Math.round(p*$.averageBitrate/8)),M=w?y-D:y;M<1&&w&&(M=Math.min(y,m.loaded*8/N));var K=w?m.loaded*1e3/M:0,z=K?(V-m.loaded)/K:V*8/N+b/1e3;if(!(z<=A)){var te=K?K*8:N,Z=Number.POSITIVE_INFINITY,ie;for(ie=t.level-1;ie>T;ie--){var he=U[ie].maxBitrate;if(Z=e.getTimeToLoadFrag(b/1e3,te,p*he,!U[ie].details),Z<A)break}if(!(Z>=z)&&!(Z>p*10)){o.nextLoadLevel=o.nextAutoLevel=ie,w?e.bwEstimator.sample(y-Math.min(b,D),m.loaded):e.bwEstimator.sampleTTFB(y);var fe=U[ie].maxBitrate;e.getBwEstimate()*e.hls.config.abrBandWidthUpFactor>fe&&e.resetEstimator(fe),e.clearTimer(),k.warn("[abr] Fragment "+t.sn+(r?" part "+r.index:"")+" of level "+t.level+` is loading too slowly;
2
+ Time to underbuffer: `+A.toFixed(3)+` s
3
+ Estimated load time for current fragment: `+z.toFixed(3)+` s
4
+ Estimated load time for down switch fragment: `+Z.toFixed(3)+` s
5
+ TTFB estimate: `+(D|0)+` ms
6
+ Current BW estimate: `+(j(N)?N|0:"Unknown")+` bps
7
+ New BW estimate: `+(e.getBwEstimate()|0)+` bps
8
+ Switching to level `+ie+" @ "+(fe|0)+" bps"),o.trigger(R.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:r,stats:m})}}}}}}},this.hls=i,this.bwEstimator=this.initEstimator(),this.registerListeners()}var a=s.prototype;return a.resetEstimator=function(e){e&&(k.log("setting initial bwe to "+e),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()},a.initEstimator=function(){var e=this.hls.config;return new pu(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)},a.registerListeners=function(){var e=this.hls;e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.FRAG_LOADING,this.onFragLoading,this),e.on(R.FRAG_LOADED,this.onFragLoaded,this),e.on(R.FRAG_BUFFERED,this.onFragBuffered,this),e.on(R.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(R.LEVEL_LOADED,this.onLevelLoaded,this),e.on(R.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(R.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(R.ERROR,this.onError,this)},a.unregisterListeners=function(){var e=this.hls;e&&(e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.FRAG_LOADING,this.onFragLoading,this),e.off(R.FRAG_LOADED,this.onFragLoaded,this),e.off(R.FRAG_BUFFERED,this.onFragBuffered,this),e.off(R.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(R.LEVEL_LOADED,this.onLevelLoaded,this),e.off(R.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(R.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(R.ERROR,this.onError,this))},a.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null},a.onManifestLoading=function(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()},a.onLevelsUpdated=function(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null},a.onMaxAutoLevelUpdated=function(){this.firstSelection=-1,this.nextAutoLevelKey=""},a.onFragLoading=function(e,t){var r=t.frag;if(!this.ignoreFragment(r)){if(!r.bitrateTest){var o;this.fragCurrent=r,this.partCurrent=(o=t.part)!=null?o:null}this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}},a.onLevelSwitching=function(e,t){this.clearTimer()},a.onError=function(e,t){if(!t.fatal)switch(t.details){case G.BUFFER_ADD_CODEC_ERROR:case G.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case G.FRAG_LOAD_TIMEOUT:{var r=t.frag,o=this.fragCurrent,u=this.partCurrent;if(r&&o&&r.sn===o.sn&&r.level===o.level){var h=performance.now(),d=u?u.stats:r.stats,m=h-d.loading.start,p=d.loading.first?d.loading.first-d.loading.start:-1,y=d.loaded&&p>-1;if(y){var T=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(m-Math.min(T,p),d.loaded)}else this.bwEstimator.sampleTTFB(m)}break}}},a.getTimeToLoadFrag=function(e,t,r,o){var u=e+r/t,h=o?this.lastLevelLoadSec:0;return u+h},a.onLevelLoaded=function(e,t){var r=this.hls.config,o=t.stats.loading,u=o.end-o.start;j(u)&&(this.lastLevelLoadSec=u/1e3),t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)},a.onFragLoaded=function(e,t){var r=t.frag,o=t.part,u=o?o.stats:r.stats;if(r.type===Me.MAIN&&this.bwEstimator.sampleTTFB(u.loading.first-u.loading.start),!this.ignoreFragment(r)){if(this.clearTimer(),r.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){var h=o?o.duration:r.duration,d=this.hls.levels[r.level],m=(d.loaded?d.loaded.bytes:0)+u.loaded,p=(d.loaded?d.loaded.duration:0)+h;d.loaded={bytes:m,duration:p},d.realBitrate=Math.round(8*m/p)}if(r.bitrateTest){var y={stats:u,frag:r,part:o,id:r.type};this.onFragBuffered(R.FRAG_BUFFERED,y),r.bitrateTest=!1}else this.lastLoadedFragLevel=r.level}},a.onFragBuffered=function(e,t){var r=t.frag,o=t.part,u=o!=null&&o.stats.loaded?o.stats:r.stats;if(!u.aborted&&!this.ignoreFragment(r)){var h=u.parsing.end-u.loading.start-Math.min(u.loading.first-u.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(h,u.loaded),u.bwEstimate=this.getBwEstimate(),r.bitrateTest?this.bitrateTestDelay=h/1e3:this.bitrateTestDelay=0}},a.ignoreFragment=function(e){return e.type!==Me.MAIN||e.sn==="initSegment"},a.clearTimer=function(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)},a.getAutoLevelKey=function(){return this.getBwEstimate()+"_"+this.getStarvationDelay().toFixed(2)},a.getNextABRAutoLevel=function(){var e=this.fragCurrent,t=this.partCurrent,r=this.hls,o=r.maxAutoLevel,u=r.config,h=r.minAutoLevel,d=t?t.duration:e?e.duration:0,m=this.getBwEstimate(),p=this.getStarvationDelay(),y=u.abrBandWidthFactor,T=u.abrBandWidthUpFactor;if(p){var x=this.findBestLevel(m,h,o,p,0,y,T);if(x>=0)return x}var b=d?Math.min(d,u.maxStarvationDelay):u.maxStarvationDelay;if(!p){var L=this.bitrateTestDelay;if(L){var A=d?Math.min(d,u.maxLoadingDelay):u.maxLoadingDelay;b=A-L,k.info("[abr] bitrate test took "+Math.round(1e3*L)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*b)+" ms"),y=T=1}}var D=this.findBestLevel(m,h,o,p,b,y,T);if(k.info("[abr] "+(p?"rebuffering expected":"buffer is empty")+", optimal quality level "+D),D>-1)return D;var w=r.levels[h],N=r.levels[r.loadLevel];return w?.bitrate<N?.bitrate?h:r.loadLevel},a.getStarvationDelay=function(){var e=this.hls,t=e.media;if(!t)return 1/0;var r=t&&t.playbackRate!==0?Math.abs(t.playbackRate):1,o=e.mainForwardBufferInfo;return(o?o.len:0)/r},a.getBwEstimate=function(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate},a.findBestLevel=function(e,t,r,o,u,h,d){var m,p=this,y=o+u,T=this.lastLoadedFragLevel,x=T===-1?this.hls.firstLevel:T,b=this.fragCurrent,L=this.partCurrent,A=this.hls,D=A.levels,w=A.allAudioTracks,N=A.loadLevel,U=A.config;if(D.length===1)return 0;var $=D[x],V=!!($!=null&&(m=$.details)!=null&&m.live),M=N===-1||T===-1,K,z="SDR",te=$?.frameRate||0,Z=U.audioPreference,ie=U.videoPreference,he=this.audioTracksByGroup||(this.audioTracksByGroup=Eu(w));if(M){if(this.firstSelection!==-1)return this.firstSelection;var fe=this.codecTiers||(this.codecTiers=_u(D,he,t,r)),Le=yu(fe,z,e,Z,ie),Ee=Le.codecSet,we=Le.videoRanges,Ae=Le.minFramerate,ye=Le.minBitrate,je=Le.preferHDR;K=Ee,z=je?we[we.length-1]:we[0],te=Ae,e=Math.max(e,ye),k.log("[abr] picked start tier "+JSON.stringify(Le))}else K=$?.codecSet,z=$?.videoRange;for(var Fe=L?L.duration:b?b.duration:0,qe=this.bwEstimator.getEstimateTTFB()/1e3,Xe=[],Ze=function(){var _t,$e=D[Ue],ct=Ue>x;if(!$e)return 0;if(K&&$e.codecSet!==K||z&&$e.videoRange!==z||ct&&te>$e.frameRate||!ct&&te>0&&te<$e.frameRate||$e.supportedResult&&!((_t=$e.supportedResult.decodingInfoResults)!=null&&_t[0].smooth))return Xe.push(Ue),0;var vt=$e.details,et=(L?vt?.partTarget:vt?.averagetargetduration)||Fe,Ke;ct?Ke=d*e:Ke=h*e;var yt=Fe&&o>=Fe*2&&u===0?D[Ue].averageBitrate:D[Ue].maxBitrate,ft=p.getTimeToLoadFrag(qe,Ke,yt*et,vt===void 0),st=Ke>=yt&&(Ue===T||$e.loadError===0&&$e.fragmentError===0)&&(ft<=qe||!j(ft)||V&&!p.bitrateTestDelay||ft<y);if(st){var or=p.forcedAutoLevel;return Ue!==N&&(or===-1||or!==N)&&(Xe.length&&k.trace("[abr] Skipped level(s) "+Xe.join(",")+" of "+r+' max with CODECS and VIDEO-RANGE:"'+D[Xe[0]].codecs+'" '+D[Xe[0]].videoRange+'; not compatible with "'+$.codecs+'" '+z),k.info("[abr] switch candidate:"+x+"->"+Ue+" adjustedbw("+Math.round(Ke)+")-bitrate="+Math.round(Ke-yt)+" ttfb:"+qe.toFixed(1)+" avgDuration:"+et.toFixed(1)+" maxFetchDuration:"+y.toFixed(1)+" fetchDuration:"+ft.toFixed(1)+" firstSelection:"+M+" codecSet:"+K+" videoRange:"+z+" hls.loadLevel:"+N)),M&&(p.firstSelection=Ue),{v:Ue}}},ze,Ue=r;Ue>=t;Ue--)if(ze=Ze(),ze!==0&&ze)return ze.v;return-1},_(s,[{key:"firstAutoLevel",get:function(){var e=this.hls,t=e.maxAutoLevel,r=e.minAutoLevel,o=this.getBwEstimate(),u=this.hls.config.maxStarvationDelay,h=this.findBestLevel(o,r,t,0,u,1,1);if(h>-1)return h;var d=this.hls.firstLevel,m=Math.min(Math.max(d,r),t);return k.warn("[abr] Could not find best starting auto level. Defaulting to first in playlist "+d+" clamped to "+m),m}},{key:"forcedAutoLevel",get:function(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}},{key:"nextAutoLevel",get:function(){var e=this.forcedAutoLevel,t=this.bwEstimator,r=t.canEstimate(),o=this.lastLoadedFragLevel>-1;if(e!==-1&&(!r||!o||this.nextAutoLevelKey===this.getAutoLevelKey()))return e;var u=r&&o?this.getNextABRAutoLevel():this.firstAutoLevel;if(e!==-1){var h=this.hls.levels;if(h.length>Math.max(e,u)&&h[e].loadError<=h[u].loadError)return e}return this._nextAutoLevel=u,this.nextAutoLevelKey=this.getAutoLevelKey(),u},set:function(e){var t=this.hls,r=t.maxAutoLevel,o=t.minAutoLevel,u=Math.min(Math.max(e,o),r);this._nextAutoLevel!==u&&(this.nextAutoLevelKey="",this._nextAutoLevel=u)}}]),s}(),Tu={length:0,start:function(){return 0},end:function(){return 0}},rt=function(){function s(){}return s.isBuffered=function(i,e){try{if(i){for(var t=s.getBuffered(i),r=0;r<t.length;r++)if(e>=t.start(r)&&e<=t.end(r))return!0}}catch{}return!1},s.bufferInfo=function(i,e,t){try{if(i){var r=s.getBuffered(i),o=[],u;for(u=0;u<r.length;u++)o.push({start:r.start(u),end:r.end(u)});return this.bufferedInfo(o,e,t)}}catch{}return{len:0,start:e,end:e,nextStart:void 0}},s.bufferedInfo=function(i,e,t){e=Math.max(0,e),i.sort(function(L,A){var D=L.start-A.start;return D||A.end-L.end});var r=[];if(t)for(var o=0;o<i.length;o++){var u=r.length;if(u){var h=r[u-1].end;i[o].start-h<t?i[o].end>h&&(r[u-1].end=i[o].end):r.push(i[o])}else r.push(i[o])}else r=i;for(var d=0,m,p=e,y=e,T=0;T<r.length;T++){var x=r[T].start,b=r[T].end;if(e+t>=x&&e<b)p=x,y=b,d=y-e;else if(e+t<x){m=x;break}}return{len:d,start:p||0,end:y||0,nextStart:m}},s.getBuffered=function(i){try{return i.buffered}catch(e){return k.log("failed to get media.buffered",e),Tu}},s}(),xu=function(){function s(i){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=i}var a=s.prototype;return a.append=function(e,t,r){var o=this.queues[t];o.push(e),o.length===1&&!r&&this.executeNext(t)},a.insertAbort=function(e,t){var r=this.queues[t];r.unshift(e),this.executeNext(t)},a.appendBlocker=function(e){var t,r=new Promise(function(u){t=u}),o={execute:t,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(o,e),r},a.executeNext=function(e){var t=this.queues[e];if(t.length){var r=t[0];try{r.execute()}catch(u){k.warn('[buffer-operation-queue]: Exception executing "'+e+'" SourceBuffer operation: '+u),r.onError(u);var o=this.buffers[e];o!=null&&o.updating||this.shiftAndExecuteNext(e)}}},a.shiftAndExecuteNext=function(e){this.queues[e].shift(),this.executeNext(e)},a.current=function(e){return this.queues[e][0]},s}(),oa=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,bu=function(){function s(i){var e=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendSource=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this.log=void 0,this.warn=void 0,this.error=void 0,this._onEndStreaming=function(r){e.hls&&e.hls.pauseBuffering()},this._onStartStreaming=function(r){e.hls&&e.hls.resumeBuffering()},this._onMediaSourceOpen=function(){var r=e.media,o=e.mediaSource;e.log("Media source opened"),r&&(r.removeEventListener("emptied",e._onMediaEmptied),e.updateMediaElementDuration(),e.hls.trigger(R.MEDIA_ATTACHED,{media:r,mediaSource:o})),o&&o.removeEventListener("sourceopen",e._onMediaSourceOpen),e.checkPendingTracks()},this._onMediaSourceClose=function(){e.log("Media source closed")},this._onMediaSourceEnded=function(){e.log("Media source ended")},this._onMediaEmptied=function(){var r=e.mediaSrc,o=e._objectUrl;r!==o&&k.error("Media element src was set while attaching MediaSource ("+o+" > "+r+")")},this.hls=i;var t="[buffer-controller]";this.appendSource=Oo(ar(i.config.preferManagedMediaSource)),this.log=k.log.bind(k,t),this.warn=k.warn.bind(k,t),this.error=k.error.bind(k,t),this._initSourceBuffer(),this.registerListeners()}var a=s.prototype;return a.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},a.destroy=function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null,this.hls=null},a.registerListeners=function(){var e=this.hls;e.on(R.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.MANIFEST_PARSED,this.onManifestParsed,this),e.on(R.BUFFER_RESET,this.onBufferReset,this),e.on(R.BUFFER_APPENDING,this.onBufferAppending,this),e.on(R.BUFFER_CODECS,this.onBufferCodecs,this),e.on(R.BUFFER_EOS,this.onBufferEos,this),e.on(R.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(R.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(R.FRAG_PARSED,this.onFragParsed,this),e.on(R.FRAG_CHANGED,this.onFragChanged,this)},a.unregisterListeners=function(){var e=this.hls;e.off(R.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.MANIFEST_PARSED,this.onManifestParsed,this),e.off(R.BUFFER_RESET,this.onBufferReset,this),e.off(R.BUFFER_APPENDING,this.onBufferAppending,this),e.off(R.BUFFER_CODECS,this.onBufferCodecs,this),e.off(R.BUFFER_EOS,this.onBufferEos,this),e.off(R.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(R.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(R.FRAG_PARSED,this.onFragParsed,this),e.off(R.FRAG_CHANGED,this.onFragChanged,this)},a._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new xu(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.appendErrors={audio:0,video:0,audiovideo:0},this.lastMpegAudioChunk=null},a.onManifestLoading=function(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null},a.onManifestParsed=function(e,t){var r=2;t.audio&&!t.video||t.altAudio,r=1,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,this.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},a.onMediaAttaching=function(e,t){var r=this.media=t.media,o=ar(this.appendSource);if(r&&o){var u,h=this.mediaSource=new o;this.log("created media source: "+((u=h.constructor)==null?void 0:u.name)),h.addEventListener("sourceopen",this._onMediaSourceOpen),h.addEventListener("sourceended",this._onMediaSourceEnded),h.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(h.addEventListener("startstreaming",this._onStartStreaming),h.addEventListener("endstreaming",this._onEndStreaming));var d=this._objectUrl=self.URL.createObjectURL(h);if(this.appendSource)try{r.removeAttribute("src");var m=self.ManagedMediaSource;r.disableRemotePlayback=r.disableRemotePlayback||m&&h instanceof m,ua(r),Lu(r,d),r.load()}catch{r.src=d}else r.src=d;r.addEventListener("emptied",this._onMediaEmptied)}},a.onMediaDetaching=function(){var e=this.media,t=this.mediaSource,r=this._objectUrl;if(t){if(this.log("media source detaching"),t.readyState==="open")try{t.endOfStream()}catch(o){this.warn("onMediaDetaching: "+o.message+" while calling endOfStream")}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(t.removeEventListener("startstreaming",this._onStartStreaming),t.removeEventListener("endstreaming",this._onEndStreaming)),e&&(e.removeEventListener("emptied",this._onMediaEmptied),r&&self.URL.revokeObjectURL(r),this.mediaSrc===r?(e.removeAttribute("src"),this.appendSource&&ua(e),e.load()):this.warn("media|source.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(R.MEDIA_DETACHED,void 0)},a.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach(function(t){e.resetBuffer(t)}),this._initSourceBuffer()},a.resetBuffer=function(e){var t=this.sourceBuffer[e];try{if(t){var r;this.removeBufferListeners(e),this.sourceBuffer[e]=void 0,(r=this.mediaSource)!=null&&r.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(t)}}catch(o){this.warn("onBufferReset "+e,o)}},a.onBufferCodecs=function(e,t){var r=this,o=this.getSourceBufferTypes().length,u=Object.keys(t);if(u.forEach(function(d){if(o){var m=r.tracks[d];if(m&&typeof m.buffer.changeType=="function"){var p,y=t[d],T=y.id,x=y.codec,b=y.levelCodec,L=y.container,A=y.metadata,D=Fn(m.codec,m.levelCodec),w=D?.replace(oa,"$1"),N=Fn(x,b),U=(p=N)==null?void 0:p.replace(oa,"$1");if(N&&w!==U){d.slice(0,5)==="audio"&&(N=Kr(N,r.appendSource));var $=L+";codecs="+N;r.appendChangeType(d,$),r.log("switching codec "+D+" to "+N),r.tracks[d]={buffer:m.buffer,codec:x,container:L,levelCodec:b,metadata:A,id:T}}}}else r.pendingTracks[d]=t[d]}),!o){var h=Math.max(this.bufferCodecEventsExpected-1,0);this.bufferCodecEventsExpected!==h&&(this.log(h+" bufferCodec event(s) expected "+u.join(",")),this.bufferCodecEventsExpected=h),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()}},a.appendChangeType=function(e,t){var r=this,o=this.operationQueue,u={execute:function(){var d=r.sourceBuffer[e];d&&(r.log("changing "+e+" sourceBuffer type to "+t),d.changeType(t)),o.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(d){r.warn("Failed to change "+e+" SourceBuffer type",d)}};o.append(u,e,!!this.pendingTracks[e])},a.onBufferAppending=function(e,t){var r=this,o=this.hls,u=this.operationQueue,h=this.tracks,d=t.data,m=t.type,p=t.frag,y=t.part,T=t.chunkMeta,x=T.buffering[m],b=self.performance.now();x.start=b;var L=p.stats.buffering,A=y?y.stats.buffering:null;L.start===0&&(L.start=b),A&&A.start===0&&(A.start=b);var D=h.audio,w=!1;m==="audio"&&D?.container==="audio/mpeg"&&(w=!this.lastMpegAudioChunk||T.id===1||this.lastMpegAudioChunk.sn!==T.sn,this.lastMpegAudioChunk=T);var N=p.start,U={execute:function(){if(x.executeStart=self.performance.now(),w){var V=r.sourceBuffer[m];if(V){var M=N-V.timestampOffset;Math.abs(M)>=.1&&(r.log("Updating audio SourceBuffer timestampOffset to "+N+" (delta: "+M+") sn: "+p.sn+")"),V.timestampOffset=N)}}r.appendExecutor(d,m)},onStart:function(){},onComplete:function(){var V=self.performance.now();x.executeEnd=x.end=V,L.first===0&&(L.first=V),A&&A.first===0&&(A.first=V);var M=r.sourceBuffer,K={};for(var z in M)K[z]=rt.getBuffered(M[z]);r.appendErrors[m]=0,m==="audio"||m==="video"?r.appendErrors.audiovideo=0:(r.appendErrors.audio=0,r.appendErrors.video=0),r.hls.trigger(R.BUFFER_APPENDED,{type:m,frag:p,part:y,chunkMeta:T,parent:p.type,timeRanges:K})},onError:function(V){var M={type:le.MEDIA_ERROR,parent:p.type,details:G.BUFFER_APPEND_ERROR,sourceBufferName:m,frag:p,part:y,chunkMeta:T,error:V,err:V,fatal:!1};if(V.code===DOMException.QUOTA_EXCEEDED_ERR)M.details=G.BUFFER_FULL_ERROR;else{var K=++r.appendErrors[m];M.details=G.BUFFER_APPEND_ERROR,r.warn("Failed "+K+"/"+o.config.appendErrorMaxRetry+' times to append segment in "'+m+'" sourceBuffer'),K>=o.config.appendErrorMaxRetry&&(M.fatal=!0)}o.trigger(R.ERROR,M)}};u.append(U,m,!!this.pendingTracks[m])},a.onBufferFlushing=function(e,t){var r=this,o=this.operationQueue,u=function(d){return{execute:r.removeExecutor.bind(r,d,t.startOffset,t.endOffset),onStart:function(){},onComplete:function(){r.hls.trigger(R.BUFFER_FLUSHED,{type:d})},onError:function(p){r.warn("Failed to remove from "+d+" SourceBuffer",p)}}};t.type?o.append(u(t.type),t.type):this.getSourceBufferTypes().forEach(function(h){o.append(u(h),h)})},a.onFragParsed=function(e,t){var r=this,o=t.frag,u=t.part,h=[],d=u?u.elementaryStreams:o.elementaryStreams;d[Pe.AUDIOVIDEO]?h.push("audiovideo"):(d[Pe.AUDIO]&&h.push("audio"),d[Pe.VIDEO]&&h.push("video"));var m=function(){var y=self.performance.now();o.stats.buffering.end=y,u&&(u.stats.buffering.end=y);var T=u?u.stats:o.stats;r.hls.trigger(R.FRAG_BUFFERED,{frag:o,part:u,stats:T,id:o.type})};h.length===0&&this.warn("Fragments must have at least one ElementaryStreamType set. type: "+o.type+" level: "+o.level+" sn: "+o.sn),this.blockBuffers(m,h)},a.onFragChanged=function(e,t){this.trimBuffers()},a.onBufferEos=function(e,t){var r=this,o=this.getSourceBufferTypes().reduce(function(u,h){var d=r.sourceBuffer[h];return d&&(!t.type||t.type===h)&&(d.ending=!0,d.ended||(d.ended=!0,r.log(h+" sourceBuffer now EOS"))),u&&!!(!d||d.ended)},!0);o&&(this.log("Queueing mediaSource.endOfStream()"),this.blockBuffers(function(){r.getSourceBufferTypes().forEach(function(h){var d=r.sourceBuffer[h];d&&(d.ending=!1)});var u=r.mediaSource;if(!u||u.readyState!=="open"){u&&r.log("Could not call mediaSource.endOfStream(). mediaSource.readyState: "+u.readyState);return}r.log("Calling mediaSource.endOfStream()"),u.endOfStream()}))},a.onLevelUpdated=function(e,t){var r=t.details;r.fragments.length&&(this.details=r,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},a.trimBuffers=function(){var e=this.hls,t=this.details,r=this.media;if(!(!r||t===null)){var o=this.getSourceBufferTypes();if(o.length){var u=e.config,h=r.currentTime,d=t.levelTargetDuration,m=t.live&&u.liveBackBufferLength!==null?u.liveBackBufferLength:u.backBufferLength;if(j(m)&&m>0){var p=Math.max(m,d),y=Math.floor(h/d)*d-p;this.flushBackBuffer(h,d,y)}if(j(u.frontBufferFlushThreshold)&&u.frontBufferFlushThreshold>0){var T=Math.max(u.maxBufferLength,u.frontBufferFlushThreshold),x=Math.max(T,d),b=Math.floor(h/d)*d+x;this.flushFrontBuffer(h,d,b)}}}},a.flushBackBuffer=function(e,t,r){var o=this,u=this.details,h=this.sourceBuffer,d=this.getSourceBufferTypes();d.forEach(function(m){var p=h[m];if(p){var y=rt.getBuffered(p);if(y.length>0&&r>y.start(0)){if(o.hls.trigger(R.BACK_BUFFER_REACHED,{bufferEnd:r}),u!=null&&u.live)o.hls.trigger(R.LIVE_BACK_BUFFER_REACHED,{bufferEnd:r});else if(p.ended&&y.end(y.length-1)-e<t*2){o.log("Cannot flush "+m+" back buffer while SourceBuffer is in ended state");return}o.hls.trigger(R.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:m})}}})},a.flushFrontBuffer=function(e,t,r){var o=this,u=this.sourceBuffer,h=this.getSourceBufferTypes();h.forEach(function(d){var m=u[d];if(m){var p=rt.getBuffered(m),y=p.length;if(y<2)return;var T=p.start(y-1),x=p.end(y-1);if(r>T||e>=T&&e<=x)return;if(m.ended&&e-x<2*t){o.log("Cannot flush "+d+" front buffer while SourceBuffer is in ended state");return}o.hls.trigger(R.BUFFER_FLUSHING,{startOffset:T,endOffset:1/0,type:d})}})},a.updateMediaElementDuration=function(){if(!(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")){var e=this.details,t=this.hls,r=this.media,o=this.mediaSource,u=e.fragments[0].start+e.totalduration,h=r.duration,d=j(o.duration)?o.duration:0;e.live&&t.config.liveDurationInfinity?(o.duration=1/0,this.updateSeekableRange(e)):(u>d&&u>h||!j(h))&&(this.log("Updating Media Source duration to "+u.toFixed(3)),o.duration=u)}},a.updateSeekableRange=function(e){var t=this.mediaSource,r=e.fragments,o=r.length;if(o&&e.live&&t!=null&&t.setLiveSeekableRange){var u=Math.max(0,r[0].start),h=Math.max(u,u+e.totalduration);this.log("Media Source duration is set to "+t.duration+". Setting seekable range to "+u+"-"+h+"."),t.setLiveSeekableRange(u,h)}},a.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,t=this.operationQueue,r=this.pendingTracks,o=Object.keys(r).length;if(o&&(!e||o===2||"audiovideo"in r)){this.createSourceBuffers(r),this.pendingTracks={};var u=this.getSourceBufferTypes();if(u.length)this.hls.trigger(R.BUFFER_CREATED,{tracks:this.tracks}),u.forEach(function(d){t.executeNext(d)});else{var h=new Error("could not create source buffer for media codec(s)");this.hls.trigger(R.ERROR,{type:le.MEDIA_ERROR,details:G.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:h,reason:h.message})}}},a.createSourceBuffers=function(e){var t=this,r=this.sourceBuffer,o=this.mediaSource;if(!o)throw Error("createSourceBuffers called when mediaSource was null");var u=function(m){if(!r[m]){var p,y=e[m];if(!y)throw Error("source buffer exists for track "+m+", however track does not");var T=((p=y.levelCodec)==null?void 0:p.indexOf(","))===-1?y.levelCodec:y.codec;T&&m.slice(0,5)==="audio"&&(T=Kr(T,t.appendSource));var x=y.container+";codecs="+T;t.log("creating sourceBuffer("+x+")");try{var b=r[m]=o.addSourceBuffer(x),L=m;t.addBufferListener(L,"updatestart",t._onSBUpdateStart),t.addBufferListener(L,"updateend",t._onSBUpdateEnd),t.addBufferListener(L,"error",t._onSBUpdateError),t.appendSource&&t.addBufferListener(L,"bufferedchange",function(A,D){var w=D.removedRanges;w!=null&&w.length&&t.hls.trigger(R.BUFFER_FLUSHED,{type:m})}),t.tracks[m]={buffer:b,codec:T,container:y.container,levelCodec:y.levelCodec,metadata:y.metadata,id:y.id}}catch(A){t.error("error while trying to add sourceBuffer: "+A.message),t.hls.trigger(R.ERROR,{type:le.MEDIA_ERROR,details:G.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:A,sourceBufferName:m,mimeType:x})}}};for(var h in e)u(h)},a._onSBUpdateStart=function(e){var t=this.operationQueue,r=t.current(e);r.onStart()},a._onSBUpdateEnd=function(e){var t;if(((t=this.mediaSource)==null?void 0:t.readyState)==="closed"){this.resetBuffer(e);return}var r=this.operationQueue,o=r.current(e);o.onComplete(),r.shiftAndExecuteNext(e)},a._onSBUpdateError=function(e,t){var r,o=new Error(e+" SourceBuffer error. MediaSource readyState: "+((r=this.mediaSource)==null?void 0:r.readyState));this.error(""+o,t),this.hls.trigger(R.ERROR,{type:le.MEDIA_ERROR,details:G.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:o,fatal:!1});var u=this.operationQueue.current(e);u&&u.onError(o)},a.removeExecutor=function(e,t,r){var o=this.media,u=this.mediaSource,h=this.operationQueue,d=this.sourceBuffer,m=d[e];if(!o||!u||!m){this.warn("Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),h.shiftAndExecuteNext(e);return}var p=j(o.duration)?o.duration:1/0,y=j(u.duration)?u.duration:1/0,T=Math.max(0,t),x=Math.min(r,p,y);x>T&&(!m.ending||m.ended)?(m.ended=!1,this.log("Removing ["+T+","+x+"] from the "+e+" SourceBuffer"),m.remove(T,x)):h.shiftAndExecuteNext(e)},a.appendExecutor=function(e,t){var r=this.sourceBuffer[t];if(!r){if(!this.pendingTracks[t])throw new Error("Attempting to append to the "+t+" SourceBuffer, but it does not exist");return}r.ended=!1,r.appendBuffer(e)},a.blockBuffers=function(e,t){var r=this;if(t===void 0&&(t=this.getSourceBufferTypes()),!t.length){this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}var o=this.operationQueue,u=t.map(function(h){return o.appendBlocker(h)});Promise.all(u).then(function(){e(),t.forEach(function(h){var d=r.sourceBuffer[h];d!=null&&d.updating||o.shiftAndExecuteNext(h)})})},a.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},a.addBufferListener=function(e,t,r){var o=this.sourceBuffer[e];if(o){var u=r.bind(this,e);this.listeners[e].push({event:t,listener:u}),o.addEventListener(t,u)}},a.removeBufferListeners=function(e){var t=this.sourceBuffer[e];t&&this.listeners[e].forEach(function(r){t.removeEventListener(r.event,r.listener)})},_(s,[{key:"mediaSrc",get:function(){var e,t,r=((e=this.media)==null||(t=e.querySelector)==null?void 0:t.call(e,"source"))||this.media;return r?.src}}]),s}();function ua(s){var a=s.querySelectorAll("source");[].slice.call(a).forEach(function(i){s.removeChild(i)})}function Lu(s,a){var i=self.document.createElement("source");i.type="video/mp4",i.src=a,s.appendChild(i)}var Au=function(){function s(i){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=i,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var a=s.prototype;return a.setStreamController=function(e){this.streamController=e},a.destroy=function(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},a.registerListeners=function(){var e=this.hls;e.on(R.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(R.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(R.MANIFEST_PARSED,this.onManifestParsed,this),e.on(R.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(R.BUFFER_CODECS,this.onBufferCodecs,this),e.on(R.MEDIA_DETACHING,this.onMediaDetaching,this)},a.unregisterListener=function(){var e=this.hls;e.off(R.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(R.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(R.MANIFEST_PARSED,this.onManifestParsed,this),e.off(R.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(R.BUFFER_CODECS,this.onBufferCodecs,this),e.off(R.MEDIA_DETACHING,this.onMediaDetaching,this)},a.onFpsDropLevelCapping=function(e,t){var r=this.hls.levels[t.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})},a.onMediaAttaching=function(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()},a.onManifestParsed=function(e,t){var r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()},a.onLevelsUpdated=function(e,t){this.timer&&j(this.autoLevelCapping)&&this.detectPlayerSize()},a.onBufferCodecs=function(e,t){var r=this.hls;r.config.capLevelToPlayerSize&&t.video&&this.startCapping()},a.onMediaDetaching=function(){this.stopCapping()},a.detectPlayerSize=function(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0){this.clientRect=null;return}var e=this.hls.levels;if(e.length){var t=this.hls,r=this.getMaxLevel(e.length-1);r!==this.autoLevelCapping&&k.log("Setting autoLevelCapping to "+r+": "+e[r].height+"p@"+e[r].bitrate+" for media "+this.mediaWidth+"x"+this.mediaHeight),t.autoLevelCapping=r,t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}},a.getMaxLevel=function(e){var t=this,r=this.hls.levels;if(!r.length)return-1;var o=r.filter(function(u,h){return t.isLevelAllowed(u)&&h<=e});return this.clientRect=null,s.getMaxLevelByMediaSize(o,this.mediaWidth,this.mediaHeight)},a.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},a.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},a.getDimensions=function(){if(this.clientRect)return this.clientRect;var e=this.media,t={width:0,height:0};if(e){var r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,!t.width&&!t.height&&(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t},a.isLevelAllowed=function(e){var t=this.restrictedLevels;return!t.some(function(r){return e.bitrate===r.bitrate&&e.width===r.width&&e.height===r.height})},s.getMaxLevelByMediaSize=function(e,t,r){if(!(e!=null&&e.length))return-1;for(var o=function(y,T){return T?y.width!==T.width||y.height!==T.height:!0},u=e.length-1,h=Math.max(t,r),d=0;d<e.length;d+=1){var m=e[d];if((m.width>=h||m.height>=h)&&o(m,e[d+1])){u=d;break}}return u},_(s,[{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch{}return e}}]),s}(),Ru=function(){function s(i){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=i,this.registerListeners()}var a=s.prototype;return a.setStreamController=function(e){this.streamController=e},a.registerListeners=function(){this.hls.on(R.MEDIA_ATTACHING,this.onMediaAttaching,this)},a.unregisterListeners=function(){this.hls.off(R.MEDIA_ATTACHING,this.onMediaAttaching,this)},a.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},a.onMediaAttaching=function(e,t){var r=this.hls.config;if(r.capLevelOnFPSDrop){var o=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=o,o&&typeof o.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}},a.checkFPS=function(e,t,r){var o=performance.now();if(t){if(this.lastTime){var u=o-this.lastTime,h=r-this.lastDroppedFrames,d=t-this.lastDecodedFrames,m=1e3*h/u,p=this.hls;if(p.trigger(R.FPS_DROP,{currentDropped:h,currentDecoded:d,totalDroppedFrames:r}),m>0&&h>p.config.fpsDroppedMonitoringThreshold*d){var y=p.currentLevel;k.warn("drop FPS ratio greater than max allowed value for currentLevel: "+y),y>0&&(p.autoLevelCapping===-1||p.autoLevelCapping>=y)&&(y=y-1,p.trigger(R.FPS_DROP_LEVEL_CAPPING,{level:y,droppedLevel:p.currentLevel}),p.autoLevelCapping=y,this.streamController.nextLevelSwitch())}}this.lastTime=o,this.lastDroppedFrames=r,this.lastDecodedFrames=t}},a.checkFPSInterval=function(){var e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){var t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)},s}(),Cu=3e5,Du=function(){function s(i){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=i,this.log=k.log.bind(k,"[content-steering]:"),this.registerListeners()}var a=s.prototype;return a.registerListeners=function(){var e=this.hls;e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(R.MANIFEST_PARSED,this.onManifestParsed,this),e.on(R.ERROR,this.onError,this)},a.unregisterListeners=function(){var e=this.hls;e&&(e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(R.MANIFEST_PARSED,this.onManifestParsed,this),e.off(R.ERROR,this.onError,this))},a.startLoad=function(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){var e=this.timeToLoad*1e3-(performance.now()-this.updated);if(e>0){this.scheduleRefresh(this.uri,e);return}}this.loadSteeringManifest(this.uri)}},a.stopLoad=function(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()},a.clearTimeout=function(){this.reloadTimer!==-1&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)},a.destroy=function(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null},a.removeLevel=function(e){var t=this.levels;t&&(this.levels=t.filter(function(r){return r!==e}))},a.onManifestLoading=function(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null},a.onManifestLoaded=function(e,t){var r=t.contentSteering;r!==null&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())},a.onManifestParsed=function(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks},a.onError=function(e,t){var r=t.errorAction;if(r?.action===ot.SendAlternateToPenaltyBox&&r.flags===Ct.MoveAllAlternatesMatchingHost){var o=this.levels,u=this.pathwayPriority,h=this.pathwayId;if(t.context){var d=t.context,m=d.groupId,p=d.pathwayId,y=d.type;m&&o?h=this.getPathwayForGroupId(m,y,h):p&&(h=p)}h in this.penalizedPathways||(this.penalizedPathways[h]=performance.now()),!u&&o&&(u=o.reduce(function(T,x){return T.indexOf(x.pathwayId)===-1&&T.push(x.pathwayId),T},[])),u&&u.length>1&&(this.updatePathwayPriority(u),r.resolved=this.pathwayId!==h),r.resolved||k.warn("Could not resolve "+t.details+' ("'+t.error.message+'") with content-steering for Pathway: '+h+" levels: "+(o&&o.length)+" priorities: "+JSON.stringify(u)+" penalized: "+JSON.stringify(this.penalizedPathways))}},a.filterParsedLevels=function(e){this.levels=e;var t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){var r=e[0].pathwayId;this.log("No levels found in Pathway "+this.pathwayId+'. Setting initial Pathway to "'+r+'"'),t=this.getLevelsForPathway(r),this.pathwayId=r}return t.length!==e.length&&this.log("Found "+t.length+"/"+e.length+' levels in Pathway "'+this.pathwayId+'"'),t},a.getLevelsForPathway=function(e){return this.levels===null?[]:this.levels.filter(function(t){return e===t.pathwayId})},a.updatePathwayPriority=function(e){this.pathwayPriority=e;var t,r=this.penalizedPathways,o=performance.now();Object.keys(r).forEach(function(y){o-r[y]>Cu&&delete r[y]});for(var u=0;u<e.length;u++){var h=e[u];if(!(h in r)){if(h===this.pathwayId)return;var d=this.hls.nextLoadLevel,m=this.hls.levels[d];if(t=this.getLevelsForPathway(h),t.length>0){this.log('Setting Pathway to "'+h+'"'),this.pathwayId=h,ta(t),this.hls.trigger(R.LEVELS_UPDATED,{levels:t});var p=this.hls.levels[d];m&&p&&this.levels&&(p.attrs["STABLE-VARIANT-ID"]!==m.attrs["STABLE-VARIANT-ID"]&&p.bitrate!==m.bitrate&&this.log("Unstable Pathways change from bitrate "+m.bitrate+" to "+p.bitrate),this.hls.nextLoadLevel=d);break}}}},a.getPathwayForGroupId=function(e,t,r){for(var o=this.getLevelsForPathway(r).concat(this.levels||[]),u=0;u<o.length;u++)if(t===Oe.AUDIO_TRACK&&o[u].hasAudioGroup(e)||t===Oe.SUBTITLE_TRACK&&o[u].hasSubtitleGroup(e))return o[u].pathwayId;return r},a.clonePathways=function(e){var t=this,r=this.levels;if(r){var o={},u={};e.forEach(function(h){var d=h.ID,m=h["BASE-ID"],p=h["URI-REPLACEMENT"];if(!r.some(function(T){return T.pathwayId===d})){var y=t.getLevelsForPathway(m).map(function(T){var x=new pe(T.attrs);x["PATHWAY-ID"]=d;var b=x.AUDIO&&x.AUDIO+"_clone_"+d,L=x.SUBTITLES&&x.SUBTITLES+"_clone_"+d;b&&(o[x.AUDIO]=b,x.AUDIO=b),L&&(u[x.SUBTITLES]=L,x.SUBTITLES=L);var A=fa(T.uri,x["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",p),D=new Ri({attrs:x,audioCodec:T.audioCodec,bitrate:T.bitrate,height:T.height,name:T.name,url:A,videoCodec:T.videoCodec,width:T.width});if(T.audioGroups)for(var w=1;w<T.audioGroups.length;w++)D.addGroupId("audio",T.audioGroups[w]+"_clone_"+d);if(T.subtitleGroups)for(var N=1;N<T.subtitleGroups.length;N++)D.addGroupId("text",T.subtitleGroups[N]+"_clone_"+d);return D});r.push.apply(r,y),la(t.audioTracks,o,p,d),la(t.subtitleTracks,u,p,d)}})}},a.loadSteeringManifest=function(e){var t=this,r=this.hls.config,o=r.loader;this.loader&&this.loader.destroy(),this.loader=new o(r);var u;try{u=new self.URL(e)}catch{this.enabled=!1,this.log("Failed to parse Steering Manifest URI: "+e);return}if(u.protocol!=="data:"){var h=(this.hls.bandwidthEstimate||r.abrEwmaDefaultEstimate)|0;u.searchParams.set("_HLS_pathway",this.pathwayId),u.searchParams.set("_HLS_throughput",""+h)}var d={responseType:"json",url:u.href},m=r.steeringManifestLoadPolicy.default,p=m.errorRetry||m.timeoutRetry||{},y={loadPolicy:m,timeout:m.maxLoadTimeMs,maxRetry:p.maxNumRetry||0,retryDelay:p.retryDelayMs||0,maxRetryDelay:p.maxRetryDelayMs||0},T={onSuccess:function(b,L,A,D){t.log('Loaded steering manifest: "'+u+'"');var w=b.data;if(w.VERSION!==1){t.log("Steering VERSION "+w.VERSION+" not supported!");return}t.updated=performance.now(),t.timeToLoad=w.TTL;var N=w["RELOAD-URI"],U=w["PATHWAY-CLONES"],$=w["PATHWAY-PRIORITY"];if(N)try{t.uri=new self.URL(N,u).href}catch{t.enabled=!1,t.log("Failed to parse Steering Manifest RELOAD-URI: "+N);return}t.scheduleRefresh(t.uri||A.url),U&&t.clonePathways(U);var V={steeringManifest:w,url:u.toString()};t.hls.trigger(R.STEERING_MANIFEST_LOADED,V),$&&t.updatePathwayPriority($)},onError:function(b,L,A,D){if(t.log("Error loading steering manifest: "+b.code+" "+b.text+" ("+L.url+")"),t.stopLoad(),b.code===410){t.enabled=!1,t.log("Steering manifest "+L.url+" no longer available");return}var w=t.timeToLoad*1e3;if(b.code===429){var N=t.loader;if(typeof N?.getResponseHeader=="function"){var U=N.getResponseHeader("Retry-After");U&&(w=parseFloat(U)*1e3)}t.log("Steering manifest "+L.url+" rate limited");return}t.scheduleRefresh(t.uri||L.url,w)},onTimeout:function(b,L,A){t.log("Timeout loading steering manifest ("+L.url+")"),t.scheduleRefresh(t.uri||L.url)}};this.log("Requesting steering manifest: "+u),this.loader.load(d,y,T)},a.scheduleRefresh=function(e,t){var r=this;t===void 0&&(t=this.timeToLoad*1e3),this.clearTimeout(),this.reloadTimer=self.setTimeout(function(){var o,u=(o=r.hls)==null?void 0:o.media;if(u&&!u.ended){r.loadSteeringManifest(e);return}r.scheduleRefresh(e,r.timeToLoad*1e3)},t)},s}();function la(s,a,i,e){s&&Object.keys(a).forEach(function(t){var r=s.filter(function(o){return o.groupId===t}).map(function(o){var u=C({},o);return u.details=void 0,u.attrs=new pe(u.attrs),u.url=u.attrs.URI=fa(o.url,o.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",i),u.groupId=u.attrs["GROUP-ID"]=a[t],u.attrs["PATHWAY-ID"]=e,u});s.push.apply(s,r)})}function fa(s,a,i,e){var t=e.HOST,r=e.PARAMS,o=e[i],u;a&&(u=o?.[a],u&&(s=u));var h=new self.URL(s);return t&&!u&&(h.host=t),r&&Object.keys(r).sort().forEach(function(d){d&&h.searchParams.set(d,r[d])}),h.href}var wu=/^age:\s*[\d.]+\s*$/im,ha=function(){function s(i){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=i&&i.xhrSetup||null,this.stats=new $t,this.retryDelay=0}var a=s.prototype;return a.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null},a.abortInternal=function(){var e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,e.readyState!==4&&(this.stats.aborted=!0,e.abort()))},a.abort=function(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},a.load=function(e,t,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=r,this.loadInternal()},a.loadInternal=function(){var e=this,t=this.config,r=this.context;if(!(!t||!r)){var o=this.loader=new self.XMLHttpRequest,u=this.stats;u.loading.first=0,u.loaded=0,u.aborted=!1;var h=this.xhrSetup;h?Promise.resolve().then(function(){if(!(e.loader!==o||e.stats.aborted))return h(o,r.url)}).catch(function(d){if(!(e.loader!==o||e.stats.aborted))return o.open("GET",r.url,!0),h(o,r.url)}).then(function(){e.loader!==o||e.stats.aborted||e.openAndSendXhr(o,r,t)}).catch(function(d){e.callbacks.onError({code:o.status,text:d.message},r,o,u)}):this.openAndSendXhr(o,r,t)}},a.openAndSendXhr=function(e,t,r){e.readyState||e.open("GET",t.url,!0);var o=t.headers,u=r.loadPolicy,h=u.maxTimeToFirstByteMs,d=u.maxLoadTimeMs;if(o)for(var m in o)e.setRequestHeader(m,o[m]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),r.timeout=h&&j(h)?h:d,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),e.send()},a.readystatechange=function(){var e=this.context,t=this.loader,r=this.stats;if(!(!e||!t)){var o=t.readyState,u=this.config;if(!r.aborted&&o>=2&&(r.loading.first===0&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),u.timeout!==u.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),u.timeout=u.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),u.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),o===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;var h=t.status,d=t.responseType!=="text";if(h>=200&&h<300&&(d&&t.response||t.responseText!==null)){r.loading.end=Math.max(self.performance.now(),r.loading.first);var m=d?t.response:t.responseText,p=t.responseType==="arraybuffer"?m.byteLength:m.length;if(r.loaded=r.total=p,r.bwEstimate=r.total*8e3/(r.loading.end-r.loading.first),!this.callbacks)return;var y=this.callbacks.onProgress;if(y&&y(r,e,m,t),!this.callbacks)return;var T={url:t.responseURL,data:m,code:h};this.callbacks.onSuccess(T,r,e,t)}else{var x=u.loadPolicy.errorRetry,b=r.retry,L={url:e.url,data:void 0,code:h};qr(x,b,!1,L)?this.retry(x):(k.error(h+" while loading "+e.url),this.callbacks.onError({code:h,text:t.statusText},e,t,r))}}}},a.loadtimeout=function(){if(this.config){var e=this.config.loadPolicy.timeoutRetry,t=this.stats.retry;if(qr(e,t,!0))this.retry(e);else{var r;k.warn("timeout while loading "+((r=this.context)==null?void 0:r.url));var o=this.callbacks;o&&(this.abortInternal(),o.onTimeout(this.stats,this.context,this.loader))}}},a.retry=function(e){var t=this.context,r=this.stats;this.retryDelay=Di(e,r.retry),r.retry++,k.warn((status?"HTTP Status "+status:"Timeout")+" while loading "+t?.url+", retrying "+r.retry+"/"+e.maxNumRetry+" in "+this.retryDelay+"ms"),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)},a.loadprogress=function(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)},a.getCacheAge=function(){var e=null;if(this.loader&&wu.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e},a.getResponseHeader=function(e){return this.loader&&new RegExp("^"+e+":\\s*[\\d.]+\\s*$","im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null},s}(),Iu=function(){function s(){this.chunks=[],this.dataLength=0}var a=s.prototype;return a.push=function(e){this.chunks.push(e),this.dataLength+=e.length},a.flush=function(){var e=this.chunks,t=this.dataLength,r;if(e.length)e.length===1?r=e[0]:r=Pu(e,t);else return new Uint8Array(0);return this.reset(),r},a.reset=function(){this.chunks.length=0,this.dataLength=0},s}();function Pu(s,a){for(var i=new Uint8Array(a),e=0,t=0;t<s.length;t++){var r=s[t];i.set(r,e),e+=r.length}return i}function ku(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var Ou=/(\d+)-(\d+)\/(\d+)/,da=function(){function s(i){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=i.fetchSetup||Uu,this.controller=new self.AbortController,this.stats=new $t}var a=s.prototype;return a.destroy=function(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null},a.abortInternal=function(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())},a.abort=function(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},a.load=function(e,t,r){var o=this,u=this.stats;if(u.loading.start)throw new Error("Loader can only be used once.");u.loading.start=self.performance.now();var h=Mu(e,this.controller.signal),d=r.onProgress,m=e.responseType==="arraybuffer",p=m?"byteLength":"length",y=t.loadPolicy,T=y.maxTimeToFirstByteMs,x=y.maxLoadTimeMs;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,h),self.clearTimeout(this.requestTimeout),t.timeout=T&&j(T)?T:x,this.requestTimeout=self.setTimeout(function(){o.abortInternal(),r.onTimeout(u,e,o.response)},t.timeout),self.fetch(this.request).then(function(b){o.response=o.loader=b;var L=Math.max(self.performance.now(),u.loading.start);if(self.clearTimeout(o.requestTimeout),t.timeout=x,o.requestTimeout=self.setTimeout(function(){o.abortInternal(),r.onTimeout(u,e,o.response)},x-(L-u.loading.start)),!b.ok){var A=b.status,D=b.statusText;throw new Bu(D||"fetch, bad network response",A,b)}return u.loading.first=L,u.total=Nu(b.headers)||u.total,d&&j(t.highWaterMark)?o.loadProgressively(b,u,e,t.highWaterMark,d):m?b.arrayBuffer():e.responseType==="json"?b.json():b.text()}).then(function(b){var L=o.response;if(!L)throw new Error("loader destroyed");self.clearTimeout(o.requestTimeout),u.loading.end=Math.max(self.performance.now(),u.loading.first);var A=b[p];A&&(u.loaded=u.total=A);var D={url:L.url,data:b,code:L.status};d&&!j(t.highWaterMark)&&d(u,e,b,L),r.onSuccess(D,u,e,L)}).catch(function(b){if(self.clearTimeout(o.requestTimeout),!u.aborted){var L=b&&b.code||0,A=b?b.message:null;r.onError({code:L,text:A},e,b?b.details:null,u)}})},a.getCacheAge=function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?parseFloat(t):null}return e},a.getResponseHeader=function(e){return this.response?this.response.headers.get(e):null},a.loadProgressively=function(e,t,r,o,u){o===void 0&&(o=0);var h=new Iu,d=e.body.getReader(),m=function p(){return d.read().then(function(y){if(y.done)return h.dataLength&&u(t,r,h.flush(),e),Promise.resolve(new ArrayBuffer(0));var T=y.value,x=T.length;return t.loaded+=x,x<o||h.dataLength?(h.push(T),h.dataLength>=o&&u(t,r,h.flush(),e)):u(t,r,T,e),p()}).catch(function(){return Promise.reject()})};return m()},s}();function Mu(s,a){var i={method:"GET",mode:"cors",credentials:"same-origin",signal:a,headers:new self.Headers(C({},s.headers))};return s.rangeEnd&&i.headers.set("Range","bytes="+s.rangeStart+"-"+String(s.rangeEnd-1)),i}function Fu(s){var a=Ou.exec(s);if(a)return parseInt(a[2])-parseInt(a[1])+1}function Nu(s){var a=s.get("Content-Range");if(a){var i=Fu(a);if(j(i))return i}var e=s.get("Content-Length");if(e)return parseInt(e)}function Uu(s,a){return new self.Request(s.url,a)}var Bu=function(s){I(a,s);function a(i,e,t){var r;return r=s.call(this,i)||this,r.code=void 0,r.details=void 0,r.code=e,r.details=t,r}return a}(J(Error)),Gu={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},ca=l(l({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,maxBufferSize:60*1e3*1e3,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,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:ha,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:Su,bufferController:bu,capLevelController:Au,errorController:cu,fpsController:Ru,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:null,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,useMediaCapabilities:!1,certLoadPolicy:{default:Gu},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},Vu()),{},{subtitleStreamController:void 0,subtitleTrackController:void 0,timelineController:void 0,audioStreamController:void 0,audioTrackController:void 0,emeController:void 0,cmcdController:void 0,contentSteeringController:Du});function Vu(){return{cueHandler:uo,enableWebVTT:!1,enableIMSC1:!1,enableCEA708Captions:!1,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function Hu(s,a){if((a.liveSyncDurationCount||a.liveMaxLatencyDurationCount)&&(a.liveSyncDuration||a.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(a.liveMaxLatencyDurationCount!==void 0&&(a.liveSyncDurationCount===void 0||a.liveMaxLatencyDurationCount<=a.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(a.liveMaxLatencyDuration!==void 0&&(a.liveSyncDuration===void 0||a.liveMaxLatencyDuration<=a.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var i=wi(s),e=["manifest","level","frag"],t=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return e.forEach(function(r){var o=(r==="level"?"playlist":r)+"LoadPolicy",u=a[o]===void 0,h=[];t.forEach(function(d){var m=r+"Loading"+d,p=a[m];if(p!==void 0&&u){h.push(m);var y=i[o].default;switch(a[o]={default:y},d){case"TimeOut":y.maxLoadTimeMs=p,y.maxTimeToFirstByteMs=p;break;case"MaxRetry":y.errorRetry.maxNumRetry=p,y.timeoutRetry.maxNumRetry=p;break;case"RetryDelay":y.errorRetry.retryDelayMs=p,y.timeoutRetry.retryDelayMs=p;break;case"MaxRetryTimeout":y.errorRetry.maxRetryDelayMs=p,y.timeoutRetry.maxRetryDelayMs=p;break}}}),h.length&&k.warn('hls.js config: "'+h.join('", "')+'" setting(s) are deprecated, use "'+o+'": '+JSON.stringify(a[o]))}),l(l({},i),a)}function wi(s){return s&&typeof s=="object"?Array.isArray(s)?s.map(wi):Object.keys(s).reduce(function(a,i){return a[i]=wi(s[i]),a},{}):s}function Ku(s){var a=s.loader;if(a!==da&&a!==ha)k.log("[config]: Custom loader detected, cannot enable progressive streaming"),s.progressive=!1;else{var i=ku();i&&(s.loader=da,s.progressive=!0,s.enableSoftwareAES=!0,k.log("[config]: Progressive streaming enabled, using FetchLoader"))}}var Ii,Wu=function(s){I(a,s);function a(e,t){var r;return r=s.call(this,e,"[level-controller]")||this,r._levels=[],r._firstLevel=-1,r._maxAutoLevel=-1,r._startLevel=void 0,r.currentLevel=null,r.currentLevelIndex=-1,r.manualLevelIndex=-1,r.steering=void 0,r.onParsedComplete=void 0,r.steering=t,r._registerListeners(),r}var i=a.prototype;return i._registerListeners=function(){var t=this.hls;t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(R.LEVEL_LOADED,this.onLevelLoaded,this),t.on(R.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(R.FRAG_BUFFERED,this.onFragBuffered,this),t.on(R.ERROR,this.onError,this)},i._unregisterListeners=function(){var t=this.hls;t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(R.LEVEL_LOADED,this.onLevelLoaded,this),t.off(R.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(R.FRAG_BUFFERED,this.onFragBuffered,this),t.off(R.ERROR,this.onError,this)},i.destroy=function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),s.prototype.destroy.call(this)},i.stopLoad=function(){var t=this._levels;t.forEach(function(r){r.loadError=0,r.fragmentError=0}),s.prototype.stopLoad.call(this)},i.resetLevels=function(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1},i.onManifestLoading=function(t,r){this.resetLevels()},i.onManifestLoaded=function(t,r){var o=this.hls.config.preferManagedMediaSource,u=[],h={},d={},m=!1,p=!1,y=!1;r.levels.forEach(function(T){var x,b,L=T.attrs,A=T.audioCodec,D=T.videoCodec;((x=A)==null?void 0:x.indexOf("mp4a.40.34"))!==-1&&(Ii||(Ii=/chrome|firefox/i.test(navigator.userAgent)),Ii&&(T.audioCodec=A=void 0)),A&&(T.audioCodec=A=Kr(A,o)),((b=D)==null?void 0:b.indexOf("avc1"))===0&&(D=T.videoCodec=Uo(D));var w=T.width,N=T.height,U=T.unknownCodecs;if(m||(m=!!(w&&N)),p||(p=!!D),y||(y=!!A),!(U!=null&&U.length||A&&!_i(A,"audio",o)||D&&!_i(D,"video",o))){var $=L.CODECS,V=L["FRAME-RATE"],M=L["HDCP-LEVEL"],K=L["PATHWAY-ID"],z=L.RESOLUTION,te=L["VIDEO-RANGE"],Z=(K||".")+"-",ie=""+Z+T.bitrate+"-"+z+"-"+V+"-"+$+"-"+te+"-"+M;if(h[ie])if(h[ie].uri!==T.url&&!T.attrs["PATHWAY-ID"]){var fe=d[ie]+=1;T.attrs["PATHWAY-ID"]=new Array(fe+1).join(".");var Le=new Ri(T);h[ie]=Le,u.push(Le)}else h[ie].addGroupId("audio",L.AUDIO),h[ie].addGroupId("text",L.SUBTITLES);else{var he=new Ri(T);h[ie]=he,d[ie]=1,u.push(he)}}}),this.filterAndSortMediaOptions(u,r,m,p,y)},i.filterAndSortMediaOptions=function(t,r,o,u,h){var d=this,m=[],p=[],y=t;if((o||u)&&h&&(y=y.filter(function(M){var K=M.videoCodec,z=M.videoRange,te=M.width,Z=M.height;return(!!K||!!(te&&Z))&&eu(z)})),y.length===0){Promise.resolve().then(function(){if(d.hls){r.levels.length&&d.warn("One or more CODECS in variant not supported: "+JSON.stringify(r.levels[0].attrs));var M=new Error("no level with compatible codecs found in manifest");d.hls.trigger(R.ERROR,{type:le.MEDIA_ERROR,details:G.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:r.url,error:M,reason:M.message})}});return}if(r.audioTracks){var T=this.hls.config.preferManagedMediaSource;m=r.audioTracks.filter(function(M){return!M.audioCodec||_i(M.audioCodec,"audio",T)}),va(m)}r.subtitles&&(p=r.subtitles,va(p));var x=y.slice(0);y.sort(function(M,K){if(M.attrs["HDCP-LEVEL"]!==K.attrs["HDCP-LEVEL"])return(M.attrs["HDCP-LEVEL"]||"")>(K.attrs["HDCP-LEVEL"]||"")?1:-1;if(o&&M.height!==K.height)return M.height-K.height;if(M.frameRate!==K.frameRate)return M.frameRate-K.frameRate;if(M.videoRange!==K.videoRange)return jr.indexOf(M.videoRange)-jr.indexOf(K.videoRange);if(M.videoCodec!==K.videoCodec){var z=Mn(M.videoCodec),te=Mn(K.videoCodec);if(z!==te)return te-z}if(M.uri===K.uri&&M.codecSet!==K.codecSet){var Z=Hr(M.codecSet),ie=Hr(K.codecSet);if(Z!==ie)return ie-Z}return M.averageBitrate!==K.averageBitrate?M.averageBitrate-K.averageBitrate:0});var b=x[0];if(this.steering&&(y=this.steering.filterParsedLevels(y),y.length!==x.length)){for(var L=0;L<x.length;L++)if(x[L].pathwayId===y[0].pathwayId){b=x[L];break}}this._levels=y;for(var A=0;A<y.length;A++)if(y[A]===b){var D;this._firstLevel=A;var w=b.bitrate,N=this.hls.bandwidthEstimate;if(this.log("manifest loaded, "+y.length+" level(s) found, first bitrate: "+w),((D=this.hls.userConfig)==null?void 0:D.abrEwmaDefaultEstimate)===void 0){var U=Math.min(w,this.hls.config.abrEwmaDefaultEstimateMax);U>N&&N===ca.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=U)}break}var $=h&&!u,V={levels:y,audioTracks:m,subtitleTracks:p,sessionData:r.sessionData,sessionKeys:r.sessionKeys,firstLevel:this._firstLevel,stats:r.stats,audio:h,video:u,altAudio:!$&&m.some(function(M){return!!M.url})};this.hls.trigger(R.MANIFEST_PARSED,V),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)},i.onError=function(t,r){r.fatal||!r.context||r.context.type===Oe.LEVEL&&r.context.level===this.level&&this.checkRetry(r)},i.onFragBuffered=function(t,r){var o=r.frag;if(o!==void 0&&o.type===Me.MAIN){var u=o.elementaryStreams;if(!Object.keys(u).some(function(d){return!!u[d]}))return;var h=this._levels[o.level];h!=null&&h.loadError&&(this.log("Resetting level error count of "+h.loadError+" on frag buffered"),h.loadError=0)}},i.onLevelLoaded=function(t,r){var o,u=r.level,h=r.details,d=this._levels[u];if(!d){var m;this.warn("Invalid level index "+u),(m=r.deliveryDirectives)!=null&&m.skip&&(h.deltaUpdateFailed=!0);return}u===this.currentLevelIndex?(d.fragmentError===0&&(d.loadError=0),this.playlistLoaded(u,r,d.details)):(o=r.deliveryDirectives)!=null&&o.skip&&(h.deltaUpdateFailed=!0)},i.loadPlaylist=function(t){s.prototype.loadPlaylist.call(this);var r=this.currentLevelIndex,o=this.currentLevel;if(o&&this.shouldLoadPlaylist(o)){var u=o.uri;if(t)try{u=t.addDirectives(u)}catch(d){this.warn("Could not construct new URL with HLS Delivery Directives: "+d)}var h=o.attrs["PATHWAY-ID"];this.log("Loading level index "+r+(t?.msn!==void 0?" at sn "+t.msn+" part "+t.part:"")+" with"+(h?" Pathway "+h:"")+" "+u),this.clearTimer(),this.hls.trigger(R.LEVEL_LOADING,{url:u,level:r,pathwayId:o.attrs["PATHWAY-ID"],id:0,deliveryDirectives:t||null})}},i.removeLevel=function(t){var r=this,o,u=this._levels.filter(function(h,d){return d!==t?!0:(r.steering&&r.steering.removeLevel(h),h===r.currentLevel&&(r.currentLevel=null,r.currentLevelIndex=-1,h.details&&h.details.fragments.forEach(function(m){return m.level=-1})),!1)});ta(u),this._levels=u,this.currentLevelIndex>-1&&(o=this.currentLevel)!=null&&o.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.hls.trigger(R.LEVELS_UPDATED,{levels:u})},i.onLevelsUpdated=function(t,r){var o=r.levels;this._levels=o},i.checkMaxAutoUpdated=function(){var t=this.hls,r=t.autoLevelCapping,o=t.maxAutoLevel,u=t.maxHdcpLevel;this._maxAutoLevel!==o&&(this._maxAutoLevel=o,this.hls.trigger(R.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:r,levels:this.levels,maxAutoLevel:o,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:u}))},_(a,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(t){var r=this._levels;if(r.length!==0){if(t<0||t>=r.length){var o=new Error("invalid level idx"),u=t<0;if(this.hls.trigger(R.ERROR,{type:le.OTHER_ERROR,details:G.LEVEL_SWITCH_ERROR,level:t,fatal:u,error:o,reason:o.message}),u)return;t=Math.min(t,r.length-1)}var h=this.currentLevelIndex,d=this.currentLevel,m=d?d.attrs["PATHWAY-ID"]:void 0,p=r[t],y=p.attrs["PATHWAY-ID"];if(this.currentLevelIndex=t,this.currentLevel=p,!(h===t&&p.details&&d&&m===y)){this.log("Switching to level "+t+" ("+(p.height?p.height+"p ":"")+(p.videoRange?p.videoRange+" ":"")+(p.codecSet?p.codecSet+" ":"")+"@"+p.bitrate+")"+(y?" with Pathway "+y:"")+" from level "+h+(m?" with Pathway "+m:""));var T={level:t,attrs:p.attrs,details:p.details,bitrate:p.bitrate,averageBitrate:p.averageBitrate,maxBitrate:p.maxBitrate,realBitrate:p.realBitrate,width:p.width,height:p.height,codecSet:p.codecSet,audioCodec:p.audioCodec,videoCodec:p.videoCodec,audioGroups:p.audioGroups,subtitleGroups:p.subtitleGroups,loaded:p.loaded,loadError:p.loadError,fragmentError:p.fragmentError,name:p.name,id:p.id,uri:p.uri,url:p.url,urlId:0,audioGroupIds:p.audioGroupIds,textGroupIds:p.textGroupIds};this.hls.trigger(R.LEVEL_SWITCHING,T);var x=p.details;if(!x||x.live){var b=this.switchParams(p.uri,d?.details,x);this.loadPlaylist(b)}}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(t){this.manualLevelIndex=t,this._startLevel===void 0&&(this._startLevel=t),t!==-1&&(this.level=t)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(t){this._firstLevel=t}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var t=this.hls.config.startLevel;return t!==void 0?t:this.hls.firstAutoLevel}return this._startLevel},set:function(t){this._startLevel=t}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(t){this.level=t,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=t)}}]),a}(vu);function va(s){var a={};s.forEach(function(i){var e=i.groupId||"";i.id=a[e]=a[e]||0,a[e]++})}var gt={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"},ju=function(){function s(i){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=i,this._registerListeners()}var a=s.prototype;return a._registerListeners=function(){var e=this.hls;e.on(R.BUFFER_APPENDED,this.onBufferAppended,this),e.on(R.FRAG_BUFFERED,this.onFragBuffered,this),e.on(R.FRAG_LOADED,this.onFragLoaded,this)},a._unregisterListeners=function(){var e=this.hls;e.off(R.BUFFER_APPENDED,this.onBufferAppended,this),e.off(R.FRAG_BUFFERED,this.onFragBuffered,this),e.off(R.FRAG_LOADED,this.onFragLoaded,this)},a.destroy=function(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null},a.getAppendedFrag=function(e,t){var r=this.activePartLists[t];if(r)for(var o=r.length;o--;){var u=r[o];if(!u)break;var h=u.end;if(u.start<=e&&h!==null&&e<=h)return u}return this.getBufferedFrag(e,t)},a.getBufferedFrag=function(e,t){for(var r=this.fragments,o=Object.keys(r),u=o.length;u--;){var h=r[o[u]];if(h?.body.type===t&&h.buffered){var d=h.body;if(d.start<=e&&e<=d.end)return d}}return null},a.detectEvictedFragments=function(e,t,r,o){var u=this;this.timeRanges&&(this.timeRanges[e]=t);var h=o?.fragment.sn||-1;Object.keys(this.fragments).forEach(function(d){var m=u.fragments[d];if(m&&!(h>=m.body.sn)){if(!m.buffered&&!m.loaded){m.body.type===r&&u.removeFragment(m.body);return}var p=m.range[e];p&&p.time.some(function(y){var T=!u.isTimeBuffered(y.startPTS,y.endPTS,t);return T&&u.removeFragment(m.body),T})}})},a.detectPartialFragments=function(e){var t=this,r=this.timeRanges,o=e.frag,u=e.part;if(!(!r||o.sn==="initSegment")){var h=vr(o),d=this.fragments[h];if(!(!d||d.buffered&&o.gap)){var m=!o.relurl;if(Object.keys(r).forEach(function(y){var T=o.elementaryStreams[y];if(T){var x=r[y],b=m||T.partial===!0;d.range[y]=t.getBufferedTimes(o,u,b,x)}}),d.loaded=null,Object.keys(d.range).length){d.buffered=!0;var p=d.body.endList=o.endList||d.body.endList;p&&(this.endListFragments[d.body.type]=d),Xr(d)||this.removeParts(o.sn-1,o.type)}else this.removeFragment(d.body)}}},a.removeParts=function(e,t){var r=this.activePartLists[t];r&&(this.activePartLists[t]=r.filter(function(o){return o.fragment.sn>=e}))},a.fragBuffered=function(e,t){var r=vr(e),o=this.fragments[r];!o&&t&&(o=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),o&&(o.loaded=null,o.buffered=!0)},a.getBufferedTimes=function(e,t,r,o){for(var u={time:[],partial:r},h=e.start,d=e.end,m=e.minEndPTS||d,p=e.maxStartPTS||h,y=0;y<o.length;y++){var T=o.start(y)-this.bufferPadding,x=o.end(y)+this.bufferPadding;if(p>=T&&m<=x){u.time.push({startPTS:Math.max(h,o.start(y)),endPTS:Math.min(d,o.end(y))});break}else if(h<x&&d>T){var b=Math.max(h,o.start(y)),L=Math.min(d,o.end(y));L>b&&(u.partial=!0,u.time.push({startPTS:b,endPTS:L}))}else if(d<=T)break}return u},a.getPartialFragment=function(e){var t=null,r,o,u,h=0,d=this.bufferPadding,m=this.fragments;return Object.keys(m).forEach(function(p){var y=m[p];y&&Xr(y)&&(o=y.body.start-d,u=y.body.end+d,e>=o&&e<=u&&(r=Math.min(e-o,u-e),h<=r&&(t=y.body,h=r)))}),t},a.isEndListAppended=function(e){var t=this.endListFragments[e];return t!==void 0&&(t.buffered||Xr(t))},a.getState=function(e){var t=vr(e),r=this.fragments[t];return r?r.buffered?Xr(r)?gt.PARTIAL:gt.OK:gt.APPENDING:gt.NOT_LOADED},a.isTimeBuffered=function(e,t,r){for(var o,u,h=0;h<r.length;h++){if(o=r.start(h)-this.bufferPadding,u=r.end(h)+this.bufferPadding,e>=o&&t<=u)return!0;if(t<=o)return!1}return!1},a.onFragLoaded=function(e,t){var r=t.frag,o=t.part;if(!(r.sn==="initSegment"||r.bitrateTest)){var u=o?null:t,h=vr(r);this.fragments[h]={body:r,appendedPTS:null,loaded:u,buffered:!1,range:Object.create(null)}}},a.onBufferAppended=function(e,t){var r=this,o=t.frag,u=t.part,h=t.timeRanges;if(o.sn!=="initSegment"){var d=o.type;if(u){var m=this.activePartLists[d];m||(this.activePartLists[d]=m=[]),m.push(u)}this.timeRanges=h,Object.keys(h).forEach(function(p){var y=h[p];r.detectEvictedFragments(p,y,d,u)})}},a.onFragBuffered=function(e,t){this.detectPartialFragments(t)},a.hasFragment=function(e){var t=vr(e);return!!this.fragments[t]},a.hasParts=function(e){var t;return!!((t=this.activePartLists[e])!=null&&t.length)},a.removeFragmentsInRange=function(e,t,r,o,u){var h=this;o&&!this.hasGaps||Object.keys(this.fragments).forEach(function(d){var m=h.fragments[d];if(m){var p=m.body;p.type!==r||o&&!p.gap||p.start<t&&p.end>e&&(m.buffered||u)&&h.removeFragment(p)}})},a.removeFragment=function(e){var t=vr(e);e.stats.loaded=0,e.clearElementaryStreamInfo();var r=this.activePartLists[e.type];if(r){var o=e.sn;this.activePartLists[e.type]=r.filter(function(u){return u.fragment.sn!==o})}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]},a.removeAllFragments=function(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1},s}();function Xr(s){var a,i,e;return s.buffered&&(s.body.gap||((a=s.range.video)==null?void 0:a.partial)||((i=s.range.audio)==null?void 0:i.partial)||((e=s.range.audiovideo)==null?void 0:e.partial))}function vr(s){return s.type+"_"+s.level+"_"+s.sn}var pa=Math.pow(2,17),zu=function(){function s(i){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=i}var a=s.prototype;return a.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},a.abort=function(){this.loader&&this.loader.abort()},a.load=function(e,t){var r=this,o=e.url;if(!o)return Promise.reject(new Kt({type:le.NETWORK_ERROR,details:G.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a "+(o?"part list":"url")),networkDetails:null}));this.abort();var u=this.config,h=u.fLoader,d=u.loader;return new Promise(function(m,p){if(r.loader&&r.loader.destroy(),e.gap)if(e.tagList.some(function(L){return L[0]==="GAP"})){p(ga(e));return}else e.gap=!1;var y=r.loader=e.loader=h?new h(u):new d(u),T=ma(e),x=ia(u.fragLoadPolicy.default),b={loadPolicy:x,timeout:x.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:pa};e.stats=y.stats,y.load(T,b,{onSuccess:function(A,D,w,N){r.resetLoader(e,y);var U=A.data;w.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(U.slice(0,16)),U=U.slice(16)),m({frag:e,part:null,payload:U,networkDetails:N})},onError:function(A,D,w,N){r.resetLoader(e,y),p(new Kt({type:le.NETWORK_ERROR,details:G.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:l({url:o,data:void 0},A),error:new Error("HTTP Error "+A.code+" "+A.text),networkDetails:w,stats:N}))},onAbort:function(A,D,w){r.resetLoader(e,y),p(new Kt({type:le.NETWORK_ERROR,details:G.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:w,stats:A}))},onTimeout:function(A,D,w){r.resetLoader(e,y),p(new Kt({type:le.NETWORK_ERROR,details:G.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error("Timeout after "+b.timeout+"ms"),networkDetails:w,stats:A}))},onProgress:function(A,D,w,N){t&&t({frag:e,part:null,payload:w,networkDetails:N})}})})},a.loadPart=function(e,t,r){var o=this;this.abort();var u=this.config,h=u.fLoader,d=u.loader;return new Promise(function(m,p){if(o.loader&&o.loader.destroy(),e.gap||t.gap){p(ga(e,t));return}var y=o.loader=e.loader=h?new h(u):new d(u),T=ma(e,t),x=ia(u.fragLoadPolicy.default),b={loadPolicy:x,timeout:x.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:pa};t.stats=y.stats,y.load(T,b,{onSuccess:function(A,D,w,N){o.resetLoader(e,y),o.updateStatsFromPart(e,t);var U={frag:e,part:t,payload:A.data,networkDetails:N};r(U),m(U)},onError:function(A,D,w,N){o.resetLoader(e,y),p(new Kt({type:le.NETWORK_ERROR,details:G.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:l({url:T.url,data:void 0},A),error:new Error("HTTP Error "+A.code+" "+A.text),networkDetails:w,stats:N}))},onAbort:function(A,D,w){e.stats.aborted=t.stats.aborted,o.resetLoader(e,y),p(new Kt({type:le.NETWORK_ERROR,details:G.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:w,stats:A}))},onTimeout:function(A,D,w){o.resetLoader(e,y),p(new Kt({type:le.NETWORK_ERROR,details:G.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error("Timeout after "+b.timeout+"ms"),networkDetails:w,stats:A}))}})})},a.updateStatsFromPart=function(e,t){var r=e.stats,o=t.stats,u=o.total;if(r.loaded+=o.loaded,u){var h=Math.round(e.duration/t.duration),d=Math.min(Math.round(r.loaded/u),h),m=h-d,p=m*Math.round(r.loaded/d);r.total=r.loaded+p}else r.total=Math.max(r.loaded,r.total);var y=r.loading,T=o.loading;y.start?y.first+=T.first-T.start:(y.start=T.start,y.first=T.first),y.end=T.end},a.resetLoader=function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()},s}();function ma(s,a){a===void 0&&(a=null);var i=a||s,e={frag:s,part:a,responseType:"arraybuffer",url:i.url,headers:{},rangeStart:0,rangeEnd:0},t=i.byteRangeStartOffset,r=i.byteRangeEndOffset;if(j(t)&&j(r)){var o,u=t,h=r;if(s.sn==="initSegment"&&((o=s.decryptdata)==null?void 0:o.method)==="AES-128"){var d=r-t;d%16&&(h=r+(16-d%16)),t!==0&&(e.resetIV=!0,u=t-16)}e.rangeStart=u,e.rangeEnd=h}return e}function ga(s,a){var i=new Error("GAP "+(s.gap?"tag":"attribute")+" found"),e={type:le.MEDIA_ERROR,details:G.FRAG_GAP,fatal:!1,frag:s,error:i,networkDetails:null};return a&&(e.part=a),(a||s).stats.aborted=!0,new Kt(e)}var Kt=function(s){I(a,s);function a(i){var e;return e=s.call(this,i.error.message)||this,e.data=void 0,e.data=i,e}return a}(J(Error)),Yu=function(){function s(i){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=i}var a=s.prototype;return a.abort=function(e){for(var t in this.keyUriToKeyInfo){var r=this.keyUriToKeyInfo[t].loader;if(r){var o;if(e&&e!==((o=r.context)==null?void 0:o.frag.type))return;r.abort()}}},a.detach=function(){for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}},a.destroy=function(){this.detach();for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}},a.createKeyLoadError=function(e,t,r,o,u){return t===void 0&&(t=G.KEY_LOAD_ERROR),new Kt({type:le.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:u,error:r,networkDetails:o})},a.loadClear=function(e,t){var r=this;if(this.emeController&&this.config.emeEnabled)for(var o=e.sn,u=e.cc,h=function(){var p=t[d];if(u<=p.cc&&(o==="initSegment"||p.sn==="initSegment"||o<p.sn))return r.emeController.selectKeySystemFormat(p).then(function(y){p.setKeyFormat(y)}),1},d=0;d<t.length&&!h();d++);},a.load=function(e){var t=this;return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then(function(r){return t.loadInternal(e,r)}):this.loadInternal(e)},a.loadInternal=function(e,t){var r,o;t&&e.setKeyFormat(t);var u=e.decryptdata;if(!u){var h=new Error(t?"Expected frag.decryptdata to be defined after setting format "+t:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,G.KEY_LOAD_ERROR,h))}var d=u.uri;if(!d)return Promise.reject(this.createKeyLoadError(e,G.KEY_LOAD_ERROR,new Error('Invalid key URI: "'+d+'"')));var m=this.keyUriToKeyInfo[d];if((r=m)!=null&&r.decryptdata.key)return u.key=m.decryptdata.key,Promise.resolve({frag:e,keyInfo:m});if((o=m)!=null&&o.keyLoadPromise){var p;switch((p=m.mediaKeySessionContext)==null?void 0:p.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return m.keyLoadPromise.then(function(y){return u.key=y.keyInfo.decryptdata.key,{frag:e,keyInfo:m}})}}switch(m=this.keyUriToKeyInfo[d]={decryptdata:u,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},u.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return u.keyFormat==="identity"?this.loadKeyHTTP(m,e):this.loadKeyEME(m,e);case"AES-128":return this.loadKeyHTTP(m,e);default:return Promise.reject(this.createKeyLoadError(e,G.KEY_LOAD_ERROR,new Error('Key supplied with unsupported METHOD: "'+u.method+'"')))}},a.loadKeyEME=function(e,t){var r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var o=this.emeController.loadKey(r);if(o)return(e.keyLoadPromise=o.then(function(u){return e.mediaKeySessionContext=u,r})).catch(function(u){throw e.keyLoadPromise=null,u})}return Promise.resolve(r)},a.loadKeyHTTP=function(e,t){var r=this,o=this.config,u=o.loader,h=new u(o);return t.keyLoader=e.loader=h,e.keyLoadPromise=new Promise(function(d,m){var p={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},y=o.keyLoadPolicy.default,T={loadPolicy:y,timeout:y.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},x={onSuccess:function(L,A,D,w){var N=D.frag,U=D.keyInfo,$=D.url;if(!N.decryptdata||U!==r.keyUriToKeyInfo[$])return m(r.createKeyLoadError(N,G.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),w));U.decryptdata.key=N.decryptdata.key=new Uint8Array(L.data),N.keyLoader=null,U.loader=null,d({frag:N,keyInfo:U})},onError:function(L,A,D,w){r.resetLoader(A),m(r.createKeyLoadError(t,G.KEY_LOAD_ERROR,new Error("HTTP Error "+L.code+" loading key "+L.text),D,l({url:p.url,data:void 0},L)))},onTimeout:function(L,A,D){r.resetLoader(A),m(r.createKeyLoadError(t,G.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),D))},onAbort:function(L,A,D){r.resetLoader(A),m(r.createKeyLoadError(t,G.INTERNAL_ABORTED,new Error("key loading aborted"),D))}};h.load(p,T,x)})},a.resetLoader=function(e){var t=e.frag,r=e.keyInfo,o=e.url,u=r.loader;t.keyLoader===u&&(t.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[o],u&&u.destroy()},s}(),qu=function(){function s(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var a=s.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(e){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)},a.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},a.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},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(){},s}(),ya=function(a,i,e,t,r,o){t===void 0&&(t=0),r===void 0&&(r=-1),o===void 0&&(o=!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=$r(),this.buffering={audio:$r(),video:$r(),audiovideo:$r()},this.level=a,this.sn=i,this.id=e,this.size=t,this.part=r,this.partial=o};function $r(){return{start:0,executeStart:0,executeEnd:0,end:0}}function Qr(s,a){for(var i=0,e=s.length;i<e;i++){var t;if(((t=s[i])==null?void 0:t.cc)===a)return s[i]}return null}function Xu(s,a,i){return!!(a&&(i.endCC>i.startCC||s&&s.cc<i.startCC))}function $u(s,a){var i=s.fragments,e=a.fragments;if(!e.length||!i.length){k.log("No fragments to align");return}var t=Qr(i,e[0].cc);if(!t||t&&!t.startPTS){k.log("No frag in previous level to align on");return}return t}function Ea(s,a){if(s){var i=s.start+a;s.start=s.startPTS=i,s.endPTS=i+s.duration}}function _a(s,a){for(var i=a.fragments,e=0,t=i.length;e<t;e++)Ea(i[e],s);a.fragmentHint&&Ea(a.fragmentHint,s),a.alignedSliding=!0}function Qu(s,a,i){a&&(Ju(s,i,a),!i.alignedSliding&&a&&Zu(i,a),!i.alignedSliding&&a&&!i.skippedSegments&&Jn(a,i))}function Ju(s,a,i){if(Xu(s,i,a)){var e=$u(i,a);e&&j(e.start)&&(k.log("Adjusting PTS using last level due to CC increase within current level "+a.url),_a(e.start,a))}}function Zu(s,a){if(!(!s.hasProgramDateTime||!a.hasProgramDateTime)){var i=s.fragments,e=a.fragments;if(!(!i.length||!e.length)){var t,r,o=Math.min(a.endCC,s.endCC);a.startCC<o&&s.startCC<o&&(t=Qr(e,o),r=Qr(i,o)),(!t||!r)&&(t=e[Math.floor(e.length/2)],r=Qr(i,t.cc)||i[Math.floor(i.length/2)]);var u=t.programDateTime,h=r.programDateTime;if(!(!u||!h)){var d=(h-u)/1e3-(r.start-t.start);_a(d,s)}}}}var el=function(){function s(i,e){this.subtle=void 0,this.aesIV=void 0,this.subtle=i,this.aesIV=e}var a=s.prototype;return a.decrypt=function(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)},s}(),tl=function(){function s(i,e){this.subtle=void 0,this.key=void 0,this.subtle=i,this.key=e}var a=s.prototype;return a.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},s}();function rl(s){var a=s.byteLength,i=a&&new DataView(s.buffer).getUint8(a-1);return i?nr(s,0,a-i):s}var il=function(){function s(){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 a=s.prototype;return a.uint8ArrayToUint32Array_=function(e){for(var t=new DataView(e),r=new Uint32Array(4),o=0;o<4;o++)r[o]=t.getUint32(o*4);return r},a.initTable=function(){var e=this.sBox,t=this.invSBox,r=this.subMix,o=r[0],u=r[1],h=r[2],d=r[3],m=this.invSubMix,p=m[0],y=m[1],T=m[2],x=m[3],b=new Uint32Array(256),L=0,A=0,D=0;for(D=0;D<256;D++)D<128?b[D]=D<<1:b[D]=D<<1^283;for(D=0;D<256;D++){var w=A^A<<1^A<<2^A<<3^A<<4;w=w>>>8^w&255^99,e[L]=w,t[w]=L;var N=b[L],U=b[N],$=b[U],V=b[w]*257^w*16843008;o[L]=V<<24|V>>>8,u[L]=V<<16|V>>>16,h[L]=V<<8|V>>>24,d[L]=V,V=$*16843009^U*65537^N*257^L*16843008,p[w]=V<<24|V>>>8,y[w]=V<<16|V>>>16,T[w]=V<<8|V>>>24,x[w]=V,L?(L=N^b[b[b[$^N]]],A^=b[b[A]]):L=A=1}},a.expandKey=function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,o=0;o<t.length&&r;)r=t[o]===this.key[o],o++;if(!r){this.key=t;var u=this.keySize=t.length;if(u!==4&&u!==6&&u!==8)throw new Error("Invalid aes key size="+u);var h=this.ksRows=(u+6+1)*4,d,m,p=this.keySchedule=new Uint32Array(h),y=this.invKeySchedule=new Uint32Array(h),T=this.sBox,x=this.rcon,b=this.invSubMix,L=b[0],A=b[1],D=b[2],w=b[3],N,U;for(d=0;d<h;d++){if(d<u){N=p[d]=t[d];continue}U=N,d%u===0?(U=U<<8|U>>>24,U=T[U>>>24]<<24|T[U>>>16&255]<<16|T[U>>>8&255]<<8|T[U&255],U^=x[d/u|0]<<24):u>6&&d%u===4&&(U=T[U>>>24]<<24|T[U>>>16&255]<<16|T[U>>>8&255]<<8|T[U&255]),p[d]=N=(p[d-u]^U)>>>0}for(m=0;m<h;m++)d=h-m,m&3?U=p[d]:U=p[d-4],m<4||d<=4?y[m]=U:y[m]=L[T[U>>>24]]^A[T[U>>>16&255]]^D[T[U>>>8&255]]^w[T[U&255]],y[m]=y[m]>>>0}},a.networkToHostOrderSwap=function(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24},a.decrypt=function(e,t,r){for(var o=this.keySize+6,u=this.invKeySchedule,h=this.invSBox,d=this.invSubMix,m=d[0],p=d[1],y=d[2],T=d[3],x=this.uint8ArrayToUint32Array_(r),b=x[0],L=x[1],A=x[2],D=x[3],w=new Int32Array(e),N=new Int32Array(w.length),U,$,V,M,K,z,te,Z,ie,he,fe,Le,Ee,we,Ae=this.networkToHostOrderSwap;t<w.length;){for(ie=Ae(w[t]),he=Ae(w[t+1]),fe=Ae(w[t+2]),Le=Ae(w[t+3]),K=ie^u[0],z=Le^u[1],te=fe^u[2],Z=he^u[3],Ee=4,we=1;we<o;we++)U=m[K>>>24]^p[z>>16&255]^y[te>>8&255]^T[Z&255]^u[Ee],$=m[z>>>24]^p[te>>16&255]^y[Z>>8&255]^T[K&255]^u[Ee+1],V=m[te>>>24]^p[Z>>16&255]^y[K>>8&255]^T[z&255]^u[Ee+2],M=m[Z>>>24]^p[K>>16&255]^y[z>>8&255]^T[te&255]^u[Ee+3],K=U,z=$,te=V,Z=M,Ee=Ee+4;U=h[K>>>24]<<24^h[z>>16&255]<<16^h[te>>8&255]<<8^h[Z&255]^u[Ee],$=h[z>>>24]<<24^h[te>>16&255]<<16^h[Z>>8&255]<<8^h[K&255]^u[Ee+1],V=h[te>>>24]<<24^h[Z>>16&255]<<16^h[K>>8&255]<<8^h[z&255]^u[Ee+2],M=h[Z>>>24]<<24^h[K>>16&255]<<16^h[z>>8&255]<<8^h[te&255]^u[Ee+3],N[t]=Ae(U^b),N[t+1]=Ae(M^L),N[t+2]=Ae(V^A),N[t+3]=Ae($^D),b=ie,L=he,A=fe,D=Le,t=t+4}return N.buffer},s}(),nl=16,Pi=function(){function s(i,e){var t=e===void 0?{}:e,r=t.removePKCS7Padding,o=r===void 0?!0:r;if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=i.enableSoftwareAES,this.removePKCS7Padding=o,o)try{var u=self.crypto;u&&(this.subtle=u.subtle||u.webkitSubtle)}catch{}this.useSoftware=!this.subtle}var a=s.prototype;return a.destroy=function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},a.isSync=function(){return this.useSoftware},a.flush=function(){var e=this.currentResult,t=this.remainderData;if(!e||t)return this.reset(),null;var r=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?rl(r):r},a.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},a.decrypt=function(e,t,r){var o=this;return this.useSoftware?new Promise(function(u,h){o.softwareDecrypt(new Uint8Array(e),t,r);var d=o.flush();d?u(d.buffer):h(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,r)},a.softwareDecrypt=function(e,t,r){var o=this.currentIV,u=this.currentResult,h=this.remainderData;this.logOnce("JS AES decrypt"),h&&(e=At(h,e),this.remainderData=null);var d=this.getValidChunk(e);if(!d.length)return null;o&&(r=o);var m=this.softwareDecrypter;m||(m=this.softwareDecrypter=new il),m.expandKey(t);var p=u;return this.currentResult=m.decrypt(d.buffer,0,r),this.currentIV=nr(d,-16).buffer,p||null},a.webCryptoDecrypt=function(e,t,r){var o=this;if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,r));this.key=t,this.fastAesKey=new tl(this.subtle,t)}return this.fastAesKey.expandKey().then(function(u){if(!o.subtle)return Promise.reject(new Error("web crypto not initialized"));o.logOnce("WebCrypto AES decrypt");var h=new el(o.subtle,new Uint8Array(r));return h.decrypt(e.buffer,u)}).catch(function(u){return k.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+u.name+": "+u.message),o.onWebCryptoError(e,t,r)})},a.onWebCryptoError=function(e,t,r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r);var o=this.flush();if(o)return o.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")},a.getValidChunk=function(e){var t=e,r=e.length-e.length%nl;return r!==e.length&&(t=nr(e,0,r),this.remainderData=nr(e,r)),t},a.logOnce=function(e){this.logEnabled&&(k.log("[decrypter]: "+e),this.logEnabled=!1)},s}(),al={toString:function(a){for(var i="",e=a.length,t=0;t<e;t++)i+="["+a.start(t).toFixed(3)+"-"+a.end(t).toFixed(3)+"]";return i}},ne={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},sl=function(s){I(a,s);function a(e,t,r,o,u){var h;return h=s.call(this)||this,h.hls=void 0,h.fragPrevious=null,h.fragCurrent=null,h.fragmentTracker=void 0,h.transmuxer=null,h._state=ne.STOPPED,h.playlistType=void 0,h.media=null,h.mediaBuffer=null,h.config=void 0,h.bitrateTest=!1,h.lastCurrentTime=0,h.nextLoadPosition=0,h.startPosition=0,h.startTimeOffset=null,h.loadedmetadata=!1,h.retryDate=0,h.levels=null,h.fragmentLoader=void 0,h.keyLoader=void 0,h.levelLastLoaded=null,h.startFragRequested=!1,h.decrypter=void 0,h.initPTS=[],h.onvseeking=null,h.onvended=null,h.logPrefix="",h.log=void 0,h.warn=void 0,h.playlistType=u,h.logPrefix=o,h.log=k.log.bind(k,o+":"),h.warn=k.warn.bind(k,o+":"),h.hls=e,h.fragmentLoader=new zu(e.config),h.keyLoader=r,h.fragmentTracker=t,h.config=e.config,h.decrypter=new Pi(e.config),e.on(R.MANIFEST_LOADED,h.onManifestLoaded,ae(h)),h}var i=a.prototype;return i.doTick=function(){this.onTickEnd()},i.onTickEnd=function(){},i.startLoad=function(t){},i.stopLoad=function(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);var t=this.fragCurrent;t!=null&&t.loader&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=ne.STOPPED},i._streamEnded=function(t,r){if(r.live||t.nextStart||!t.end||!this.media)return!1;var o=r.partList;if(o!=null&&o.length){var u=o[o.length-1],h=rt.isBuffered(this.media,u.start+u.duration/2);return h}var d=r.fragments[r.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(d)},i.getLevelDetails=function(){if(this.levels&&this.levelLastLoaded!==null){var t;return(t=this.levelLastLoaded)==null?void 0:t.details}},i.onMediaAttached=function(t,r){var o=this.media=this.mediaBuffer=r.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),o.addEventListener("seeking",this.onvseeking),o.addEventListener("ended",this.onvended);var u=this.config;this.levels&&u.autoStartLoad&&this.state===ne.STOPPED&&this.startLoad(u.startPosition)},i.onMediaDetaching=function(){var t=this.media;t!=null&&t.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),t&&this.onvseeking&&this.onvended&&(t.removeEventListener("seeking",this.onvseeking),t.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},i.onMediaSeeking=function(){var t=this.config,r=this.fragCurrent,o=this.media,u=this.mediaBuffer,h=this.state,d=o?o.currentTime:0,m=rt.bufferInfo(u||o,d,t.maxBufferHole);if(this.log("media seeking to "+(j(d)?d.toFixed(3):d)+", state: "+h),this.state===ne.ENDED)this.resetLoadingState();else if(r){var p=t.maxFragLookUpTolerance,y=r.start-p,T=r.start+r.duration+p;if(!m.len||T<m.start||y>m.end){var x=d>T;(d<y||x)&&(x&&r.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),r.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}o&&(this.fragmentTracker.removeFragmentsInRange(d,1/0,this.playlistType,!0),this.lastCurrentTime=d),!this.loadedmetadata&&!m.len&&(this.nextLoadPosition=this.startPosition=d),this.tickImmediate()},i.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},i.onManifestLoaded=function(t,r){this.startTimeOffset=r.startTimeOffset,this.initPTS=[]},i.onHandlerDestroying=function(){this.hls.off(R.MANIFEST_LOADED,this.onManifestLoaded,this),this.stopLoad(),s.prototype.onHandlerDestroying.call(this),this.hls=null},i.onHandlerDestroyed=function(){this.state=ne.STOPPED,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,s.prototype.onHandlerDestroyed.call(this)},i.loadFragment=function(t,r,o){this._loadFragForPlayback(t,r,o)},i._loadFragForPlayback=function(t,r,o){var u=this,h=function(m){if(u.fragContextChanged(t)){u.warn("Fragment "+t.sn+(m.part?" p: "+m.part.index:"")+" of level "+t.level+" was dropped during download."),u.fragmentTracker.removeFragment(t);return}t.stats.chunkCount++,u._handleFragmentLoadProgress(m)};this._doFragLoad(t,r,o,h).then(function(d){if(d){var m=u.state;if(u.fragContextChanged(t)){(m===ne.FRAG_LOADING||!u.fragCurrent&&m===ne.PARSING)&&(u.fragmentTracker.removeFragment(t),u.state=ne.IDLE);return}"payload"in d&&(u.log("Loaded fragment "+t.sn+" of level "+t.level),u.hls.trigger(R.FRAG_LOADED,d)),u._handleFragmentLoadComplete(d)}}).catch(function(d){u.state===ne.STOPPED||u.state===ne.ERROR||(u.warn("Frag error: "+(d?.message||d)),u.resetFragmentLoading(t))})},i.clearTrackerIfNeeded=function(t){var r,o=this.fragmentTracker,u=o.getState(t);if(u===gt.APPENDING){var h=t.type,d=this.getFwdBufferInfo(this.mediaBuffer,h),m=Math.max(t.duration,d?d.len:this.config.maxBufferLength),p=this.backtrackFragment,y=p?t.sn-p.sn:0;(y===1||this.reduceMaxBufferLength(m,t.duration))&&o.removeFragment(t)}else((r=this.mediaBuffer)==null?void 0:r.buffered.length)===0?o.removeAllFragments():o.hasParts(t.type)&&(o.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type}),o.getState(t)===gt.PARTIAL&&o.removeFragment(t))},i.checkLiveUpdate=function(t){if(t.updated&&!t.live){var r=t.fragments[t.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:r,part:null,stats:r.stats,id:r.type})}t.fragments[0]||(t.deltaUpdateFailed=!0)},i.flushMainBuffer=function(t,r,o){if(o===void 0&&(o=null),!!(t-r)){var u={startOffset:t,endOffset:r,type:o};this.hls.trigger(R.BUFFER_FLUSHING,u)}},i._loadInitSegment=function(t,r){var o=this;this._doFragLoad(t,r).then(function(u){if(!u||o.fragContextChanged(t)||!o.levels)throw new Error("init load aborted");return u}).then(function(u){var h=o.hls,d=u.payload,m=t.decryptdata;if(d&&d.byteLength>0&&m!=null&&m.key&&m.iv&&m.method==="AES-128"){var p=self.performance.now();return o.decrypter.decrypt(new Uint8Array(d),m.key.buffer,m.iv.buffer).catch(function(y){throw h.trigger(R.ERROR,{type:le.MEDIA_ERROR,details:G.FRAG_DECRYPT_ERROR,fatal:!1,error:y,reason:y.message,frag:t}),y}).then(function(y){var T=self.performance.now();return h.trigger(R.FRAG_DECRYPTED,{frag:t,payload:y,stats:{tstart:p,tdecrypt:T}}),u.payload=y,o.completeInitSegmentLoad(u)})}return o.completeInitSegmentLoad(u)}).catch(function(u){o.state===ne.STOPPED||o.state===ne.ERROR||(o.warn(u),o.resetFragmentLoading(t))})},i.completeInitSegmentLoad=function(t){var r=this.levels;if(!r)throw new Error("init load aborted, missing levels");var o=t.frag.stats;this.state=ne.IDLE,t.frag.data=new Uint8Array(t.payload),o.parsing.start=o.buffering.start=self.performance.now(),o.parsing.end=o.buffering.end=self.performance.now(),this.tick()},i.fragContextChanged=function(t){var r=this.fragCurrent;return!t||!r||t.sn!==r.sn||t.level!==r.level},i.fragBufferedComplete=function(t,r){var o,u,h,d,m=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log("Buffered "+t.type+" sn: "+t.sn+(r?" part: "+r.index:"")+" of "+(this.playlistType===Me.MAIN?"level":"track")+" "+t.level+" (frag:["+((o=t.startPTS)!=null?o:NaN).toFixed(3)+"-"+((u=t.endPTS)!=null?u:NaN).toFixed(3)+"] > buffer:"+(m?al.toString(rt.getBuffered(m)):"(detached)")+")"),t.sn!=="initSegment"){var p;if(t.type!==Me.SUBTITLE){var y=t.elementaryStreams;if(!Object.keys(y).some(function(x){return!!y[x]})){this.state=ne.IDLE;return}}var T=(p=this.levels)==null?void 0:p[t.level];T!=null&&T.fragmentError&&(this.log("Resetting level fragment error count of "+T.fragmentError+" on frag buffered"),T.fragmentError=0)}this.state=ne.IDLE,m&&(!this.loadedmetadata&&t.type==Me.MAIN&&m.buffered.length&&((h=this.fragCurrent)==null?void 0:h.sn)===((d=this.fragPrevious)==null?void 0:d.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},i.seekToStartPos=function(){},i._handleFragmentLoadComplete=function(t){var r=this.transmuxer;if(r){var o=t.frag,u=t.part,h=t.partsLoaded,d=!h||h.length===0||h.some(function(p){return!p}),m=new ya(o.level,o.sn,o.stats.chunkCount+1,0,u?u.index:-1,!d);r.flush(m)}},i._handleFragmentLoadProgress=function(t){},i._doFragLoad=function(t,r,o,u){var h,d=this;o===void 0&&(o=null);var m=r?.details;if(!this.levels||!m)throw new Error("frag load aborted, missing level"+(m?"":" detail")+"s");var p=null;if(t.encrypted&&!((h=t.decryptdata)!=null&&h.key)?(this.log("Loading key for "+t.sn+" of ["+m.startSN+"-"+m.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+t.level),this.state=ne.KEY_LOADING,this.fragCurrent=t,p=this.keyLoader.load(t).then(function(D){if(!d.fragContextChanged(D.frag))return d.hls.trigger(R.KEY_LOADED,D),d.state===ne.KEY_LOADING&&(d.state=ne.IDLE),D}),this.hls.trigger(R.KEY_LOADING,{frag:t}),this.fragCurrent===null&&(p=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!t.encrypted&&m.encryptedFragments.length&&this.keyLoader.loadClear(t,m.encryptedFragments),o=Math.max(t.start,o||0),this.config.lowLatencyMode&&t.sn!=="initSegment"){var y=m.partList;if(y&&u){o>t.end&&m.fragmentHint&&(t=m.fragmentHint);var T=this.getNextPart(y,t,o);if(T>-1){var x=y[T];this.log("Loading part sn: "+t.sn+" p: "+x.index+" cc: "+t.cc+" of playlist ["+m.startSN+"-"+m.endSN+"] parts [0-"+T+"-"+(y.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+t.level+", target: "+parseFloat(o.toFixed(3))),this.nextLoadPosition=x.start+x.duration,this.state=ne.FRAG_LOADING;var b;return p?b=p.then(function(D){return!D||d.fragContextChanged(D.frag)?null:d.doFragPartsLoad(t,x,r,u)}).catch(function(D){return d.handleFragLoadError(D)}):b=this.doFragPartsLoad(t,x,r,u).catch(function(D){return d.handleFragLoadError(D)}),this.hls.trigger(R.FRAG_LOADING,{frag:t,part:x,targetBufferTime:o}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):b}else if(!t.url||this.loadedEndOfParts(y,o))return Promise.resolve(null)}}this.log("Loading fragment "+t.sn+" cc: "+t.cc+" "+(m?"of ["+m.startSN+"-"+m.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+t.level+", target: "+parseFloat(o.toFixed(3))),j(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=ne.FRAG_LOADING;var L=this.config.progressive,A;return L&&p?A=p.then(function(D){return!D||d.fragContextChanged(D?.frag)?null:d.fragmentLoader.load(t,u)}).catch(function(D){return d.handleFragLoadError(D)}):A=Promise.all([this.fragmentLoader.load(t,L?u:void 0),p]).then(function(D){var w=D[0];return!L&&w&&u&&u(w),w}).catch(function(D){return d.handleFragLoadError(D)}),this.hls.trigger(R.FRAG_LOADING,{frag:t,targetBufferTime:o}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):A},i.doFragPartsLoad=function(t,r,o,u){var h=this;return new Promise(function(d,m){var p,y=[],T=(p=o.details)==null?void 0:p.partList,x=function b(L){h.fragmentLoader.loadPart(t,L,u).then(function(A){y[L.index]=A;var D=A.part;h.hls.trigger(R.FRAG_LOADED,A);var w=Zn(o,t.sn,L.index+1)||ea(T,t.sn,L.index+1);if(w)b(w);else return d({frag:t,part:D,partsLoaded:y})}).catch(m)};x(r)})},i.handleFragLoadError=function(t){if("data"in t){var r=t.data;t.data&&r.details===G.INTERNAL_ABORTED?this.handleFragLoadAborted(r.frag,r.part):this.hls.trigger(R.ERROR,r)}else this.hls.trigger(R.ERROR,{type:le.OTHER_ERROR,details:G.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null},i._handleTransmuxerFlush=function(t){var r=this.getCurrentContext(t);if(!r||this.state!==ne.PARSING){!this.fragCurrent&&this.state!==ne.STOPPED&&this.state!==ne.ERROR&&(this.state=ne.IDLE);return}var o=r.frag,u=r.part,h=r.level,d=self.performance.now();o.stats.parsing.end=d,u&&(u.stats.parsing.end=d),this.updateLevelTiming(o,u,h,t.partial)},i.getCurrentContext=function(t){var r=this.levels,o=this.fragCurrent,u=t.level,h=t.sn,d=t.part;if(!(r!=null&&r[u]))return this.warn("Levels object was unset while buffering fragment "+h+" of level "+u+". The current chunk will not be buffered."),null;var m=r[u],p=d>-1?Zn(m,h,d):null,y=p?p.fragment:ou(m,h,o);return y?(o&&o!==y&&(y.stats=o.stats),{frag:y,part:p,level:m}):null},i.bufferFragmentData=function(t,r,o,u,h){var d;if(!(!t||this.state!==ne.PARSING)){var m=t.data1,p=t.data2,y=m;if(m&&p&&(y=At(m,p)),!!((d=y)!=null&&d.length)){var T={type:t.type,frag:r,part:o,chunkMeta:u,parent:r.type,data:y};if(this.hls.trigger(R.BUFFER_APPENDING,T),t.dropped&&t.independent&&!o){if(h)return;this.flushBufferGap(r)}}}},i.flushBufferGap=function(t){var r=this.media;if(r){if(!rt.isBuffered(r,r.currentTime)){this.flushMainBuffer(0,t.start);return}var o=r.currentTime,u=rt.bufferInfo(r,o,0),h=t.duration,d=Math.min(this.config.maxFragLookUpTolerance*2,h*.25),m=Math.max(Math.min(t.start-d,u.end-d),o+d);t.start-m>d&&this.flushMainBuffer(m,t.start)}},i.getFwdBufferInfo=function(t,r){var o=this.getLoadPosition();return j(o)?this.getFwdBufferInfoAtPos(t,o,r):null},i.getFwdBufferInfoAtPos=function(t,r,o){var u=this.config.maxBufferHole,h=rt.bufferInfo(t,r,u);if(h.len===0&&h.nextStart!==void 0){var d=this.fragmentTracker.getBufferedFrag(r,o);if(d&&h.nextStart<d.end)return rt.bufferInfo(t,r,Math.max(h.nextStart,u))}return h},i.getMaxBufferLength=function(t){var r=this.config,o;return t?o=Math.max(8*r.maxBufferSize/t,r.maxBufferLength):o=r.maxBufferLength,Math.min(o,r.maxMaxBufferLength)},i.reduceMaxBufferLength=function(t,r){var o=this.config,u=Math.max(Math.min(t-r,o.maxBufferLength),r),h=Math.max(t-r*3,o.maxMaxBufferLength/2,u);return h>=u?(o.maxMaxBufferLength=h,this.warn("Reduce max buffer length to "+h+"s"),!0):!1},i.getAppendedFrag=function(t,r){var o=this.fragmentTracker.getAppendedFrag(t,Me.MAIN);return o&&"fragment"in o?o.fragment:o},i.getNextFragment=function(t,r){var o=r.fragments,u=o.length;if(!u)return null;var h=this.config,d=o[0].start,m;if(r.live){var p=h.initialLiveManifestSize;if(u<p)return this.warn("Not enough fragments to start playback (have: "+u+", need: "+p+")"),null;(!r.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||t<d)&&(m=this.getInitialLiveFragment(r,o),this.startPosition=this.nextLoadPosition=m?this.hls.liveSyncPosition||m.start:t)}else t<=d&&(m=o[0]);if(!m){var y=h.lowLatencyMode?r.partEnd:r.fragmentEnd;m=this.getFragmentAtPosition(t,y,r)}return this.mapToInitFragWhenRequired(m)},i.isLoopLoading=function(t,r){var o=this.fragmentTracker.getState(t);return(o===gt.OK||o===gt.PARTIAL&&!!t.gap)&&this.nextLoadPosition>r},i.getNextFragmentLoopLoading=function(t,r,o,u,h){var d=t.gap,m=this.getNextFragment(this.nextLoadPosition,r);if(m===null)return m;if(t=m,d&&t&&!t.gap&&o.nextStart){var p=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,o.nextStart,u);if(p!==null&&o.len+p.len>=h)return this.log('buffer full after gaps in "'+u+'" playlist starting at sn: '+t.sn),null}return t},i.mapToInitFragWhenRequired=function(t){return t!=null&&t.initSegment&&!(t!=null&&t.initSegment.data)&&!this.bitrateTest?t.initSegment:t},i.getNextPart=function(t,r,o){for(var u=-1,h=!1,d=!0,m=0,p=t.length;m<p;m++){var y=t[m];if(d=d&&!y.independent,u>-1&&o<y.start)break;var T=y.loaded;T?u=-1:(h||y.independent||d)&&y.fragment===r&&(u=m),h=T}return u},i.loadedEndOfParts=function(t,r){var o=t[t.length-1];return o&&r>o.start&&o.loaded},i.getInitialLiveFragment=function(t,r){var o=this.fragPrevious,u=null;if(o){if(t.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+o.programDateTime),u=lu(r,o.endProgramDateTime,this.config.maxFragLookUpTolerance)),!u){var h=o.sn+1;if(h>=t.startSN&&h<=t.endSN){var d=r[h-t.startSN];o.cc===d.cc&&(u=d,this.log("Live playlist, switching playlist, load frag with next SN: "+u.sn))}u||(u=du(r,o.cc),u&&this.log("Live playlist, switching playlist, load frag with same CC: "+u.sn))}}else{var m=this.hls.liveSyncPosition;m!==null&&(u=this.getFragmentAtPosition(m,this.bitrateTest?t.fragmentEnd:t.edge,t))}return u},i.getFragmentAtPosition=function(t,r,o){var u=this.config,h=this.fragPrevious,d=o.fragments,m=o.endSN,p=o.fragmentHint,y=u.maxFragLookUpTolerance,T=o.partList,x=!!(u.lowLatencyMode&&T!=null&&T.length&&p);x&&p&&!this.bitrateTest&&(d=d.concat(p),m=p.sn);var b;if(t<r){var L=t>r-y?0:y;b=aa(h,d,t,L)}else b=d[d.length-1];if(b){var A=b.sn-o.startSN,D=this.fragmentTracker.getState(b);if((D===gt.OK||D===gt.PARTIAL&&b.gap)&&(h=b),h&&b.sn===h.sn&&(!x||T[0].fragment.sn>b.sn)){var w=h&&b.level===h.level;if(w){var N=d[A+1];b.sn<m&&this.fragmentTracker.getState(N)!==gt.OK?b=N:b=null}}}return b},i.synchronizeToLiveEdge=function(t){var r=this.config,o=this.media;if(o){var u=this.hls.liveSyncPosition,h=o.currentTime,d=t.fragments[0].start,m=t.edge,p=h>=d-r.maxFragLookUpTolerance&&h<=m;if(u!==null&&o.duration>u&&(h<u||!p)){var y=r.liveMaxLatencyDuration!==void 0?r.liveMaxLatencyDuration:r.liveMaxLatencyDurationCount*t.targetduration;(!p&&o.readyState<4||h<m-y)&&(this.loadedmetadata||(this.nextLoadPosition=u),o.readyState&&(this.warn("Playback: "+h.toFixed(3)+" is located too far from the end of live sliding playlist: "+m+", reset currentTime to : "+u.toFixed(3)),o.currentTime=u))}}},i.alignPlaylists=function(t,r,o){var u=t.fragments.length;if(!u)return this.warn("No fragments in live playlist"),0;var h=t.fragments[0].start,d=!r,m=t.alignedSliding&&j(h);if(d||!m&&!h){var p=this.fragPrevious;Qu(p,o,t);var y=t.fragments[0].start;return this.log("Live playlist sliding: "+y.toFixed(2)+" start-sn: "+(r?r.startSN:"na")+"->"+t.startSN+" prev-sn: "+(p?p.sn:"na")+" fragments: "+u),y}return h},i.waitForCdnTuneIn=function(t){var r=3;return t.live&&t.canBlockReload&&t.partTarget&&t.tuneInGoal>Math.max(t.partHoldBack,t.partTarget*r)},i.setStartPosition=function(t,r){var o=this.startPosition;if(o<r&&(o=-1),o===-1||this.lastCurrentTime===-1){var u=this.startTimeOffset!==null,h=u?this.startTimeOffset:t.startTimeOffset;h!==null&&j(h)?(o=r+h,h<0&&(o+=t.totalduration),o=Math.min(Math.max(r,o),r+t.totalduration),this.log("Start time offset "+h+" found in "+(u?"multivariant":"media")+" playlist, adjust startPosition to "+o),this.startPosition=o):t.live?o=this.hls.liveSyncPosition||r:this.startPosition=o=0,this.lastCurrentTime=o}this.nextLoadPosition=o},i.getLoadPosition=function(){var t=this.media,r=0;return this.loadedmetadata&&t?r=t.currentTime:this.nextLoadPosition&&(r=this.nextLoadPosition),r},i.handleFragLoadAborted=function(t,r){this.transmuxer&&t.sn!=="initSegment"&&t.stats.aborted&&(this.warn("Fragment "+t.sn+(r?" part "+r.index:"")+" of level "+t.level+" was aborted"),this.resetFragmentLoading(t))},i.resetFragmentLoading=function(t){(!this.fragCurrent||!this.fragContextChanged(t)&&this.state!==ne.FRAG_LOADING_WAITING_RETRY)&&(this.state=ne.IDLE)},i.onFragmentOrKeyLoadError=function(t,r){if(r.chunkMeta&&!r.frag){var o=this.getCurrentContext(r.chunkMeta);o&&(r.frag=o.frag)}var u=r.frag;if(!(!u||u.type!==t||!this.levels)){if(this.fragContextChanged(u)){var h;this.warn("Frag load error must match current frag to retry "+u.url+" > "+((h=this.fragCurrent)==null?void 0:h.url));return}var d=r.details===G.FRAG_GAP;d&&this.fragmentTracker.fragBuffered(u,!0);var m=r.errorAction,p=m||{},y=p.action,T=p.retryCount,x=T===void 0?0:T,b=p.retryConfig;if(m&&y===ot.RetryRequest&&b){this.resetStartWhenNotLoaded(this.levelLastLoaded);var L=Di(b,x);this.warn("Fragment "+u.sn+" of "+t+" "+u.level+" errored with "+r.details+", retrying loading "+(x+1)+"/"+b.maxNumRetry+" in "+L+"ms"),m.resolved=!0,this.retryDate=self.performance.now()+L,this.state=ne.FRAG_LOADING_WAITING_RETRY}else if(b&&m)if(this.resetFragmentErrors(t),x<b.maxNumRetry)!d&&y!==ot.RemoveAlternatePermanently&&(m.resolved=!0);else{k.warn(r.details+" reached or exceeded max retry ("+x+")");return}else m?.action===ot.SendAlternateToPenaltyBox?this.state=ne.WAITING_LEVEL:this.state=ne.ERROR;this.tickImmediate()}},i.reduceLengthAndFlushBuffer=function(t){if(this.state===ne.PARSING||this.state===ne.PARSED){var r=t.frag,o=t.parent,u=this.getFwdBufferInfo(this.mediaBuffer,o),h=u&&u.len>.5;h&&this.reduceMaxBufferLength(u.len,r?.duration||10);var d=!h;return d&&this.warn("Buffer full error while media.currentTime is not buffered, flush "+o+" buffer"),r&&(this.fragmentTracker.removeFragment(r),this.nextLoadPosition=r.start),this.resetLoadingState(),d}return!1},i.resetFragmentErrors=function(t){t===Me.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==ne.STOPPED&&(this.state=ne.IDLE)},i.afterBufferFlushed=function(t,r,o){if(t){var u=rt.getBuffered(t);this.fragmentTracker.detectEvictedFragments(r,u,o),this.state===ne.ENDED&&this.resetLoadingState()}},i.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=ne.IDLE},i.resetStartWhenNotLoaded=function(t){if(!this.loadedmetadata){this.startFragRequested=!1;var r=t?t.details:null;r!=null&&r.live?(this.startPosition=-1,this.setStartPosition(r,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},i.resetWhenMissingContext=function(t){this.warn("The loading context changed while buffering fragment "+t.sn+" of level "+t.level+". This chunk will not be buffered."),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()},i.removeUnbufferedFrags=function(t){t===void 0&&(t=0),this.fragmentTracker.removeFragmentsInRange(t,1/0,this.playlistType,!1,!0)},i.updateLevelTiming=function(t,r,o,u){var h=this,d,m=o.details;if(!m){this.warn("level.details undefined");return}var p=Object.keys(t.elementaryStreams).reduce(function(T,x){var b=t.elementaryStreams[x];if(b){var L=b.endPTS-b.startPTS;if(L<=0)return h.warn("Could not parse fragment "+t.sn+" "+x+" duration reliably ("+L+")"),T||!1;var A=u?0:Qn(m,t,b.startPTS,b.endPTS,b.startDTS,b.endDTS);return h.hls.trigger(R.LEVEL_PTS_UPDATED,{details:m,level:o,drift:A,type:x,frag:t,start:b.startPTS,end:b.endPTS}),!0}return T},!1);if(!p&&((d=this.transmuxer)==null?void 0:d.error)===null){var y=new Error("Found no media in fragment "+t.sn+" of level "+t.level+" resetting transmuxer to fallback to playlist timing");if(o.fragmentError===0&&(o.fragmentError++,t.gap=!0,this.fragmentTracker.removeFragment(t),this.fragmentTracker.fragBuffered(t,!0)),this.warn(y.message),this.hls.trigger(R.ERROR,{type:le.MEDIA_ERROR,details:G.FRAG_PARSING_ERROR,fatal:!1,error:y,frag:t,reason:"Found no media in msn "+t.sn+' of level "'+o.url+'"'}),!this.hls)return;this.resetTransmuxer()}this.state=ne.PARSED,this.hls.trigger(R.FRAG_PARSED,{frag:t,part:r})},i.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},i.recoverWorkerError=function(t){t.event==="demuxerWorker"&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())},_(a,[{key:"state",get:function(){return this._state},set:function(t){var r=this._state;r!==t&&(this._state=t,this.log(r+"->"+t))}}]),a}(qu);function Sa(){return self.SourceBuffer||self.WebKitSourceBuffer}function Ta(){var s=ar();if(!s)return!1;var a=Sa();return!a||a.prototype&&typeof a.prototype.appendBuffer=="function"&&typeof a.prototype.remove=="function"}function ol(){if(!Ta())return!1;var s=ar();return typeof s?.isTypeSupported=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(function(a){return s.isTypeSupported(Si(a,"video"))})||["mp4a.40.2","fLaC"].some(function(a){return s.isTypeSupported(Si(a,"audio"))}))}function ul(){var s,a=Sa();return typeof(a==null||(s=a.prototype)==null?void 0:s.changeType)=="function"}function Bt(s,a){return s===void 0&&(s=""),a===void 0&&(a=9e4),{type:s,id:-1,pid:-1,inputTimeScale:a,sequenceNumber:-1,samples:[],dropped:0}}var xa=function(){function s(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var a=s.prototype;return a.resetInitSegment=function(e,t,r,o){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},a.resetTimeStamp=function(e){this.initPTS=e,this.resetContiguity()},a.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},a.canParse=function(e,t){return!1},a.appendFrame=function(e,t,r){},a.demux=function(e,t){this.cachedData&&(e=At(this.cachedData,e),this.cachedData=null);var r=Nr(e,0),o=r?r.length:0,u,h=this._audioTrack,d=this._id3Track,m=r?Tn(r):void 0,p=e.length;for((this.basePTS===null||this.frameIndex===0&&j(m))&&(this.basePTS=ll(m,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),r&&r.length>0&&d.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:Rt.audioId3,duration:Number.POSITIVE_INFINITY});o<p;){if(this.canParse(e,o)){var y=this.appendFrame(h,e,o);y?(this.frameIndex++,this.lastPTS=y.sample.pts,o+=y.length,u=o):o=p}else lo(e,o)?(r=Nr(e,o),d.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:Rt.audioId3,duration:Number.POSITIVE_INFINITY}),o+=r.length,u=o):o++;if(o===p&&u!==p){var T=nr(e,u);this.cachedData?this.cachedData=At(this.cachedData,T):this.cachedData=T}}return{audioTrack:h,videoTrack:Bt(),id3Track:d,textTrack:Bt()}},a.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},a.flush=function(e){var t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:Bt(),id3Track:this._id3Track,textTrack:Bt()}},a.destroy=function(){},s}(),ll=function(a,i,e){if(j(a))return a*90;var t=e?e.baseTime*9e4/e.timescale:0;return i*9e4+t};function fl(s,a,i,e){var t,r,o,u,h=navigator.userAgent.toLowerCase(),d=e,m=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];t=((a[i+2]&192)>>>6)+1;var p=(a[i+2]&60)>>>2;if(p>m.length-1){var y=new Error("invalid ADTS sampling index:"+p);s.emit(R.ERROR,R.ERROR,{type:le.MEDIA_ERROR,details:G.FRAG_PARSING_ERROR,fatal:!0,error:y,reason:y.message});return}return o=(a[i+2]&1)<<2,o|=(a[i+3]&192)>>>6,k.log("manifest codec:"+e+", ADTS type:"+t+", samplingIndex:"+p),/firefox/i.test(h)?p>=6?(t=5,u=new Array(4),r=p-3):(t=2,u=new Array(2),r=p):h.indexOf("android")!==-1?(t=2,u=new Array(2),r=p):(t=5,u=new Array(4),e&&(e.indexOf("mp4a.40.29")!==-1||e.indexOf("mp4a.40.5")!==-1)||!e&&p>=6?r=p-3:((e&&e.indexOf("mp4a.40.2")!==-1&&(p>=6&&o===1||/vivaldi/i.test(h))||!e&&o===1)&&(t=2,u=new Array(2)),r=p)),u[0]=t<<3,u[0]|=(p&14)>>1,u[1]|=(p&1)<<7,u[1]|=o<<3,t===5&&(u[1]|=(r&14)>>1,u[2]=(r&1)<<7,u[2]|=8,u[3]=0),{config:u,samplerate:m[p],channelCount:o,codec:"mp4a.40."+t,manifestCodec:d}}function ba(s,a){return s[a]===255&&(s[a+1]&246)===240}function La(s,a){return s[a+1]&1?7:9}function ki(s,a){return(s[a+3]&3)<<11|s[a+4]<<3|(s[a+5]&224)>>>5}function hl(s,a){return a+5<s.length}function Jr(s,a){return a+1<s.length&&ba(s,a)}function dl(s,a){return hl(s,a)&&ba(s,a)&&ki(s,a)<=s.length-a}function cl(s,a){if(Jr(s,a)){var i=La(s,a);if(a+i>=s.length)return!1;var e=ki(s,a);if(e<=i)return!1;var t=a+e;return t===s.length||Jr(s,t)}return!1}function Aa(s,a,i,e,t){if(!s.samplerate){var r=fl(a,i,e,t);if(!r)return;s.config=r.config,s.samplerate=r.samplerate,s.channelCount=r.channelCount,s.codec=r.codec,s.manifestCodec=r.manifestCodec,k.log("parsed codec:"+s.codec+", rate:"+r.samplerate+", channels:"+r.channelCount)}}function Ra(s){return 1024*9e4/s}function vl(s,a){var i=La(s,a);if(a+i<=s.length){var e=ki(s,a)-i;if(e>0)return{headerLength:i,frameLength:e}}}function Ca(s,a,i,e,t){var r=Ra(s.samplerate),o=e+t*r,u=vl(a,i),h;if(u){var d=u.frameLength,m=u.headerLength,p=m+d,y=Math.max(0,i+p-a.length);y?(h=new Uint8Array(p-m),h.set(a.subarray(i+m,a.length),0)):h=a.subarray(i+m,i+p);var T={unit:h,pts:o};return y||s.samples.push(T),{sample:T,length:p,missing:y}}var x=a.length-i;h=new Uint8Array(x),h.set(a.subarray(i,a.length),0);var b={unit:h,pts:o};return{sample:b,length:x,missing:-1}}var Zr=null,pl=[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],ml=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],gl=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],yl=[0,1,1,4];function Da(s,a,i,e,t){if(!(i+24>a.length)){var r=wa(a,i);if(r&&i+r.frameLength<=a.length){var o=r.samplesPerFrame*9e4/r.sampleRate,u=e+t*o,h={unit:a.subarray(i,i+r.frameLength),pts:u,dts:u};return s.config=[],s.channelCount=r.channelCount,s.samplerate=r.sampleRate,s.samples.push(h),{sample:h,length:r.frameLength,missing:0}}}}function wa(s,a){var i=s[a+1]>>3&3,e=s[a+1]>>1&3,t=s[a+2]>>4&15,r=s[a+2]>>2&3;if(i!==1&&t!==0&&t!==15&&r!==3){var o=s[a+2]>>1&1,u=s[a+3]>>6,h=i===3?3-e:e===3?3:4,d=pl[h*14+t-1]*1e3,m=i===3?0:i===2?1:2,p=ml[m*3+r],y=u===3?1:2,T=gl[i][e],x=yl[e],b=T*8*x,L=Math.floor(T*d/p+o)*x;if(Zr===null){var A=navigator.userAgent||"",D=A.match(/Chrome\/(\d+)/i);Zr=D?parseInt(D[1]):0}var w=!!Zr&&Zr<=87;return w&&e===2&&d>=224e3&&u===0&&(s[a+3]=s[a+3]|128),{sampleRate:p,channelCount:y,frameLength:L,samplesPerFrame:b}}}function Oi(s,a){return s[a]===255&&(s[a+1]&224)===224&&(s[a+1]&6)!==0}function Ia(s,a){return a+1<s.length&&Oi(s,a)}function El(s,a){var i=4;return Oi(s,a)&&i<=s.length-a}function Pa(s,a){if(a+1<s.length&&Oi(s,a)){var i=4,e=wa(s,a),t=i;e!=null&&e.frameLength&&(t=e.frameLength);var r=a+t;return r===s.length||Ia(s,r)}return!1}var _l=function(s){I(a,s);function a(e,t){var r;return r=s.call(this)||this,r.observer=void 0,r.config=void 0,r.observer=e,r.config=t,r}var i=a.prototype;return i.resetInitSegment=function(t,r,o,u){s.prototype.resetInitSegment.call(this,t,r,o,u),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:r,duration:u,inputTimeScale:9e4,dropped:0}},a.probe=function(t){if(!t)return!1;var r=Nr(t,0),o=r?.length||0;if(Pa(t,o))return!1;for(var u=t.length;o<u;o++)if(cl(t,o))return k.log("ADTS sync word found !"),!0;return!1},i.canParse=function(t,r){return dl(t,r)},i.appendFrame=function(t,r,o){Aa(t,this.observer,r,o,t.manifestCodec);var u=Ca(t,r,o,this.basePTS,this.frameIndex);if(u&&u.missing===0)return u},a}(xa),Sl=/\/emsg[-/]ID3/i,Tl=function(){function s(i,e){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=e}var a=s.prototype;return a.resetTimeStamp=function(){},a.resetInitSegment=function(e,t,r,o){var u=this.videoTrack=Bt("video",1),h=this.audioTrack=Bt("audio",1),d=this.txtTrack=Bt("text",1);if(this.id3Track=Bt("id3",1),this.timeOffset=0,!!(e!=null&&e.byteLength)){var m=wn(e);if(m.video){var p=m.video,y=p.id,T=p.timescale,x=p.codec;u.id=y,u.timescale=d.timescale=T,u.codec=x}if(m.audio){var b=m.audio,L=b.id,A=b.timescale,D=b.codec;h.id=L,h.timescale=A,h.codec=D}d.id=An.text,u.sampleDuration=0,u.duration=h.duration=o}},a.resetContiguity=function(){this.remainderData=null},s.probe=function(e){return Eo(e)},a.demux=function(e,t){this.timeOffset=t;var r=e,o=this.videoTrack,u=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=At(this.remainderData,e));var h=Co(r);this.remainderData=h.remainder,o.samples=h.valid||new Uint8Array}else o.samples=r;var d=this.extractID3Track(o,t);return u.samples=In(t,o),{videoTrack:o,audioTrack:this.audioTrack,id3Track:d,textTrack:this.txtTrack}},a.flush=function(){var e=this.timeOffset,t=this.videoTrack,r=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;var o=this.extractID3Track(t,this.timeOffset);return r.samples=In(e,t),{videoTrack:t,audioTrack:Bt(),id3Track:o,textTrack:Bt()}},a.extractID3Track=function(e,t){var r=this.id3Track;if(e.samples.length){var o=be(e.samples,["emsg"]);o&&o.forEach(function(u){var h=Io(u);if(Sl.test(h.schemeIdUri)){var d=j(h.presentationTime)?h.presentationTime/h.timeScale:t+h.presentationTimeDelta/h.timeScale,m=h.eventDuration===4294967295?Number.POSITIVE_INFINITY:h.eventDuration/h.timeScale;m<=.001&&(m=Number.POSITIVE_INFINITY);var p=h.payload;r.samples.push({data:p,len:p.byteLength,dts:d,pts:d,type:Rt.emsg,duration:m})}})}return r},a.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},a.destroy=function(){},s}(),xl=function(a,i){var e=0,t=5;i+=t;for(var r=new Uint32Array(1),o=new Uint32Array(1),u=new Uint8Array(1);t>0;){u[0]=a[i];var h=Math.min(t,8),d=8-h;o[0]=4278190080>>>24+d<<d,r[0]=(u[0]&o[0])>>d,e=e?e<<h|r[0]:r[0],i+=1,t-=h}return e},bl=function(){function s(){this.VideoSample=null}var a=s.prototype;return a.createVideoSample=function(e,t,r,o){return{key:e,frame:!1,pts:t,dts:r,units:[],debug:o,length:0}},a.getLastNalUnit=function(e){var t,r=this.VideoSample,o;if((!r||r.units.length===0)&&(r=e[e.length-1]),(t=r)!=null&&t.units){var u=r.units;o=u[u.length-1]}return o},a.pushAccessUnit=function(e,t){if(e.units.length&&e.frame){if(e.pts===void 0){var r=t.samples,o=r.length;if(o){var u=r[o-1];e.pts=u.pts,e.dts=u.dts}else{t.dropped++;return}}t.samples.push(e)}e.debug.length&&k.log(e.pts+"/"+e.dts+":"+e.debug)},s}(),ka=function(){function s(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 a=s.prototype;return a.loadWord=function(){var e=this.data,t=this.bytesAvailable,r=e.byteLength-t,o=new Uint8Array(4),u=Math.min(4,t);if(u===0)throw new Error("no bytes available");o.set(e.subarray(r,r+u)),this.word=new DataView(o.buffer).getUint32(0),this.bitsAvailable=u*8,this.bytesAvailable-=u},a.skipBits=function(e){var t;e=Math.min(e,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,t=e>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)},a.readBits=function(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;if(e>32&&k.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return t=e-t,t>0&&this.bitsAvailable?r<<t|this.readBits(t):r},a.skipLZ=function(){var e;for(e=0;e<this.bitsAvailable;++e)if(this.word&2147483648>>>e)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()},a.skipUEG=function(){this.skipBits(1+this.skipLZ())},a.skipEG=function(){this.skipBits(1+this.skipLZ())},a.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},a.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},a.readBoolean=function(){return this.readBits(1)===1},a.readUByte=function(){return this.readBits(8)},a.readUShort=function(){return this.readBits(16)},a.readUInt=function(){return this.readBits(32)},a.skipScalingList=function(e){for(var t=8,r=8,o,u=0;u<e;u++)r!==0&&(o=this.readEG(),r=(t+o+256)%256),t=r===0?t:r},a.readSPS=function(){var e=0,t=0,r=0,o=0,u,h,d,m=this.readUByte.bind(this),p=this.readBits.bind(this),y=this.readUEG.bind(this),T=this.readBoolean.bind(this),x=this.skipBits.bind(this),b=this.skipEG.bind(this),L=this.skipUEG.bind(this),A=this.skipScalingList.bind(this);m();var D=m();if(p(5),x(3),m(),L(),D===100||D===110||D===122||D===244||D===44||D===83||D===86||D===118||D===128){var w=y();if(w===3&&x(1),L(),L(),x(1),T())for(h=w!==3?8:12,d=0;d<h;d++)T()&&(d<6?A(16):A(64))}L();var N=y();if(N===0)y();else if(N===1)for(x(1),b(),b(),u=y(),d=0;d<u;d++)b();L(),x(1);var U=y(),$=y(),V=p(1);V===0&&x(1),x(1),T()&&(e=y(),t=y(),r=y(),o=y());var M=[1,1];if(T()&&T()){var K=m();switch(K){case 1:M=[1,1];break;case 2:M=[12,11];break;case 3:M=[10,11];break;case 4:M=[16,11];break;case 5:M=[40,33];break;case 6:M=[24,11];break;case 7:M=[20,11];break;case 8:M=[32,11];break;case 9:M=[80,33];break;case 10:M=[18,11];break;case 11:M=[15,11];break;case 12:M=[64,33];break;case 13:M=[160,99];break;case 14:M=[4,3];break;case 15:M=[3,2];break;case 16:M=[2,1];break;case 255:{M=[m()<<8|m(),m()<<8|m()];break}}}return{width:Math.ceil((U+1)*16-e*2-t*2),height:(2-V)*($+1)*16-(V?2:4)*(r+o),pixelRatio:M}},a.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},s}(),Ll=function(s){I(a,s);function a(){return s.apply(this,arguments)||this}var i=a.prototype;return i.parseAVCPES=function(t,r,o,u,h){var d=this,m=this.parseAVCNALu(t,o.data),p=this.VideoSample,y,T=!1;o.data=null,p&&m.length&&!t.audFound&&(this.pushAccessUnit(p,t),p=this.VideoSample=this.createVideoSample(!1,o.pts,o.dts,"")),m.forEach(function(x){var b;switch(x.type){case 1:{var L=!1;y=!0;var A=x.data;if(T&&A.length>4){var D=new ka(A).readSliceType();(D===2||D===4||D===7||D===9)&&(L=!0)}if(L){var w;(w=p)!=null&&w.frame&&!p.key&&(d.pushAccessUnit(p,t),p=d.VideoSample=null)}p||(p=d.VideoSample=d.createVideoSample(!0,o.pts,o.dts,"")),p.frame=!0,p.key=L;break}case 5:y=!0,(b=p)!=null&&b.frame&&!p.key&&(d.pushAccessUnit(p,t),p=d.VideoSample=null),p||(p=d.VideoSample=d.createVideoSample(!0,o.pts,o.dts,"")),p.key=!0,p.frame=!0;break;case 6:{y=!0,Pn(x.data,1,o.pts,r.samples);break}case 7:{var N,U;y=!0,T=!0;var $=x.data,V=new ka($),M=V.readSPS();if(!t.sps||t.width!==M.width||t.height!==M.height||((N=t.pixelRatio)==null?void 0:N[0])!==M.pixelRatio[0]||((U=t.pixelRatio)==null?void 0:U[1])!==M.pixelRatio[1]){t.width=M.width,t.height=M.height,t.pixelRatio=M.pixelRatio,t.sps=[$],t.duration=h;for(var K=$.subarray(1,4),z="avc1.",te=0;te<3;te++){var Z=K[te].toString(16);Z.length<2&&(Z="0"+Z),z+=Z}t.codec=z}break}case 8:y=!0,t.pps=[x.data];break;case 9:y=!0,t.audFound=!0,p&&d.pushAccessUnit(p,t),p=d.VideoSample=d.createVideoSample(!1,o.pts,o.dts,"");break;case 12:y=!0;break;default:y=!1,p&&(p.debug+="unknown NAL "+x.type+" ");break}if(p&&y){var ie=p.units;ie.push(x)}}),u&&p&&(this.pushAccessUnit(p,t),this.VideoSample=null)},i.parseAVCNALu=function(t,r){var o=r.byteLength,u=t.naluState||0,h=u,d=[],m=0,p,y,T,x=-1,b=0;for(u===-1&&(x=0,b=r[0]&31,u=0,m=1);m<o;){if(p=r[m++],!u){u=p?0:1;continue}if(u===1){u=p?0:2;continue}if(!p)u=3;else if(p===1){if(y=m-u-1,x>=0){var L={data:r.subarray(x,y),type:b};d.push(L)}else{var A=this.getLastNalUnit(t.samples);A&&(h&&m<=4-h&&A.state&&(A.data=A.data.subarray(0,A.data.byteLength-h)),y>0&&(A.data=At(A.data,r.subarray(0,y)),A.state=0))}m<o?(T=r[m]&31,x=m,b=T,u=0):u=-1}else u=0}if(x>=0&&u>=0){var D={data:r.subarray(x,o),type:b,state:u};d.push(D)}if(d.length===0){var w=this.getLastNalUnit(t.samples);w&&(w.data=At(w.data,r))}return t.naluState=u,d},a}(bl),Al=function(){function s(i,e,t){this.keyData=void 0,this.decrypter=void 0,this.keyData=t,this.decrypter=new Pi(e,{removePKCS7Padding:!1})}var a=s.prototype;return a.decryptBuffer=function(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)},a.decryptAacSample=function(e,t,r){var o=this,u=e[t].unit;if(!(u.length<=16)){var h=u.subarray(16,u.length-u.length%16),d=h.buffer.slice(h.byteOffset,h.byteOffset+h.length);this.decryptBuffer(d).then(function(m){var p=new Uint8Array(m);u.set(p,16),o.decrypter.isSync()||o.decryptAacSamples(e,t+1,r)})}},a.decryptAacSamples=function(e,t,r){for(;;t++){if(t>=e.length){r();return}if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,r),!this.decrypter.isSync()))return}},a.getAvcEncryptedData=function(e){for(var t=Math.floor((e.length-48)/160)*16+16,r=new Int8Array(t),o=0,u=32;u<e.length-16;u+=160,o+=16)r.set(e.subarray(u,u+16),o);return r},a.getAvcDecryptedUnit=function(e,t){for(var r=new Uint8Array(t),o=0,u=32;u<e.length-16;u+=160,o+=16)e.set(r.subarray(o,o+16),u);return e},a.decryptAvcSample=function(e,t,r,o,u){var h=this,d=kn(u.data),m=this.getAvcEncryptedData(d);this.decryptBuffer(m.buffer).then(function(p){u.data=h.getAvcDecryptedUnit(d,p),h.decrypter.isSync()||h.decryptAvcSamples(e,t,r+1,o)})},a.decryptAvcSamples=function(e,t,r,o){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length){o();return}for(var u=e[t].units;!(r>=u.length);r++){var h=u[r];if(!(h.data.length<=48||h.type!==1&&h.type!==5)&&(this.decryptAvcSample(e,t,r,o,h),!this.decrypter.isSync()))return}}},s}(),at=188,Rl=function(){function s(i,e,t){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=i,this.config=e,this.typeSupported=t,this.videoParser=new Ll}s.probe=function(e){var t=s.syncOffset(e);return t>0&&k.warn("MPEG2-TS detected but first sync word found @ offset "+t),t!==-1},s.syncOffset=function(e){for(var t=e.length,r=Math.min(at*5,t-at)+1,o=0;o<r;){for(var u=!1,h=-1,d=0,m=o;m<t;m+=at)if(e[m]===71&&(t-m===at||e[m+at]===71)){if(d++,h===-1&&(h=m,h!==0&&(r=Math.min(h+at*99,e.length-at)+1)),u||(u=Mi(e,m)===0),u&&d>1&&(h===0&&d>2||m+at>r))return h}else{if(d)return-1;break}o++}return-1},s.createTrack=function(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:An[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}};var a=s.prototype;return a.resetInitSegment=function(e,t,r,o){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=s.createTrack("video"),this._audioTrack=s.createTrack("audio",o),this._id3Track=s.createTrack("id3"),this._txtTrack=s.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=r,this._duration=o},a.resetTimeStamp=function(){},a.resetContiguity=function(){var e=this._audioTrack,t=this._videoTrack,r=this._id3Track;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.remainderData=null},a.demux=function(e,t,r,o){r===void 0&&(r=!1),o===void 0&&(o=!1),r||(this.sampleAes=null);var u,h=this._videoTrack,d=this._audioTrack,m=this._id3Track,p=this._txtTrack,y=h.pid,T=h.pesData,x=d.pid,b=m.pid,L=d.pesData,A=m.pesData,D=null,w=this.pmtParsed,N=this._pmtId,U=e.length;if(this.remainderData&&(e=At(this.remainderData,e),U=e.length,this.remainderData=null),U<at&&!o)return this.remainderData=e,{audioTrack:d,videoTrack:h,id3Track:m,textTrack:p};var $=Math.max(0,s.syncOffset(e));U-=(U-$)%at,U<e.byteLength&&!o&&(this.remainderData=new Uint8Array(e.buffer,U,e.buffer.byteLength-U));for(var V=0,M=$;M<U;M+=at)if(e[M]===71){var K=!!(e[M+1]&64),z=Mi(e,M),te=(e[M+3]&48)>>4,Z=void 0;if(te>1){if(Z=M+5+e[M+4],Z===M+at)continue}else Z=M+4;switch(z){case y:K&&(T&&(u=pr(T))&&this.videoParser.parseAVCPES(h,p,u,!1,this._duration),T={data:[],size:0}),T&&(T.data.push(e.subarray(Z,M+at)),T.size+=M+at-Z);break;case x:if(K){if(L&&(u=pr(L)))switch(d.segmentCodec){case"aac":this.parseAACPES(d,u);break;case"mp3":this.parseMPEGPES(d,u);break}L={data:[],size:0}}L&&(L.data.push(e.subarray(Z,M+at)),L.size+=M+at-Z);break;case b:K&&(A&&(u=pr(A))&&this.parseID3PES(m,u),A={data:[],size:0}),A&&(A.data.push(e.subarray(Z,M+at)),A.size+=M+at-Z);break;case 0:K&&(Z+=e[Z]+1),N=this._pmtId=Cl(e,Z);break;case N:{K&&(Z+=e[Z]+1);var ie=Dl(e,Z,this.typeSupported,r,this.observer);y=ie.videoPid,y>0&&(h.pid=y,h.segmentCodec=ie.segmentVideoCodec),x=ie.audioPid,x>0&&(d.pid=x,d.segmentCodec=ie.segmentAudioCodec),b=ie.id3Pid,b>0&&(m.pid=b),D!==null&&!w&&(k.warn("MPEG-TS PMT found at "+M+" after unknown PID '"+D+"'. Backtracking to sync byte @"+$+" to parse all TS packets."),D=null,M=$-188),w=this.pmtParsed=!0;break}case 17:case 8191:break;default:D=z;break}}else V++;V>0&&ei(this.observer,new Error("Found "+V+" TS packet/s that do not start with 0x47")),h.pesData=T,d.pesData=L,m.pesData=A;var he={audioTrack:d,videoTrack:h,id3Track:m,textTrack:p};return o&&this.extractRemainingSamples(he),he},a.flush=function(){var e=this.remainderData;this.remainderData=null;var t;return e?t=this.demux(e,-1,!1,!0):t={videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t},a.extractRemainingSamples=function(e){var t=e.audioTrack,r=e.videoTrack,o=e.id3Track,u=e.textTrack,h=r.pesData,d=t.pesData,m=o.pesData,p;if(h&&(p=pr(h))?(this.videoParser.parseAVCPES(r,u,p,!0,this._duration),r.pesData=null):r.pesData=h,d&&(p=pr(d))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,p);break;case"mp3":this.parseMPEGPES(t,p);break}t.pesData=null}else d!=null&&d.size&&k.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=d;m&&(p=pr(m))?(this.parseID3PES(o,p),o.pesData=null):o.pesData=m},a.demuxSampleAes=function(e,t,r){var o=this.demux(e,r,!0,!this.config.progressive),u=this.sampleAes=new Al(this.observer,this.config,t);return this.decrypt(o,u)},a.decrypt=function(e,t){return new Promise(function(r){var o=e.audioTrack,u=e.videoTrack;o.samples&&o.segmentCodec==="aac"?t.decryptAacSamples(o.samples,0,function(){u.samples?t.decryptAvcSamples(u.samples,0,0,function(){r(e)}):r(e)}):u.samples&&t.decryptAvcSamples(u.samples,0,0,function(){r(e)})})},a.destroy=function(){this._duration=0},a.parseAACPES=function(e,t){var r=0,o=this.aacOverFlow,u=t.data;if(o){this.aacOverFlow=null;var h=o.missing,d=o.sample.unit.byteLength;if(h===-1)u=At(o.sample.unit,u);else{var m=d-h;o.sample.unit.set(u.subarray(0,h),m),e.samples.push(o.sample),r=o.missing}}var p,y;for(p=r,y=u.length;p<y-1&&!Jr(u,p);p++);if(p!==r){var T,x=p<y-1;if(x?T="AAC PES did not start with ADTS header,offset:"+p:T="No ADTS header found in AAC PES",ei(this.observer,new Error(T),x),!x)return}Aa(e,this.observer,u,p,this.audioCodec);var b;if(t.pts!==void 0)b=t.pts;else if(o){var L=Ra(e.samplerate);b=o.sample.pts+L}else{k.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var A=0,D;p<y;)if(D=Ca(e,u,p,b,A),p+=D.length,D.missing){this.aacOverFlow=D;break}else for(A++;p<y-1&&!Jr(u,p);p++);},a.parseMPEGPES=function(e,t){var r=t.data,o=r.length,u=0,h=0,d=t.pts;if(d===void 0){k.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;h<o;)if(Ia(r,h)){var m=Da(e,r,h,d,u);if(m)h+=m.length,u++;else break}else h++},a.parseAC3PES=function(e,t){},a.parseID3PES=function(e,t){if(t.pts===void 0){k.warn("[tsdemuxer]: ID3 PES unknown PTS");return}var r=C({},t,{type:this._videoTrack?Rt.emsg:Rt.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(r)},s}();function Mi(s,a){return((s[a+1]&31)<<8)+s[a+2]}function Cl(s,a){return(s[a+10]&31)<<8|s[a+11]}function Dl(s,a,i,e,t){var r={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},o=(s[a+1]&15)<<8|s[a+2],u=a+3+o-4,h=(s[a+10]&15)<<8|s[a+11];for(a+=12+h;a<u;){var d=Mi(s,a),m=(s[a+3]&15)<<8|s[a+4];switch(s[a]){case 207:if(!e){Fi("ADTS AAC");break}case 15:r.audioPid===-1&&(r.audioPid=d);break;case 21:r.id3Pid===-1&&(r.id3Pid=d);break;case 219:if(!e){Fi("H.264");break}case 27:r.videoPid===-1&&(r.videoPid=d,r.segmentVideoCodec="avc");break;case 3:case 4:!i.mpeg&&!i.mp3?k.log("MPEG audio found, not supported in this browser"):r.audioPid===-1&&(r.audioPid=d,r.segmentAudioCodec="mp3");break;case 193:if(!e){Fi("AC-3");break}case 129:k.warn("AC-3 in M2TS support not included in build");break;case 6:if(r.audioPid===-1&&m>0)for(var p=a+5,y=m;y>2;){var T=s[p];switch(T){case 106:k.warn("AC-3 in M2TS support not included in build");break}var x=s[p+1]+2;p+=x,y-=x}break;case 194:case 135:return ei(t,new Error("Unsupported EC-3 in M2TS found")),r;case 36:return ei(t,new Error("Unsupported HEVC in M2TS found")),r}a+=m+5}return r}function ei(s,a,i){k.warn("parsing error: "+a.message),s.emit(R.ERROR,R.ERROR,{type:le.MEDIA_ERROR,details:G.FRAG_PARSING_ERROR,fatal:!1,levelRetry:i,error:a,reason:a.message})}function Fi(s){k.log(s+" with AES-128-CBC encryption found in unencrypted stream")}function pr(s){var a=0,i,e,t,r,o,u=s.data;if(!s||s.size===0)return null;for(;u[0].length<19&&u.length>1;)u[0]=At(u[0],u[1]),u.splice(1,1);i=u[0];var h=(i[0]<<16)+(i[1]<<8)+i[2];if(h===1){if(e=(i[4]<<8)+i[5],e&&e>s.size-6)return null;var d=i[7];d&192&&(r=(i[9]&14)*536870912+(i[10]&255)*4194304+(i[11]&254)*16384+(i[12]&255)*128+(i[13]&254)/2,d&64?(o=(i[14]&14)*536870912+(i[15]&255)*4194304+(i[16]&254)*16384+(i[17]&255)*128+(i[18]&254)/2,r-o>60*9e4&&(k.warn(Math.round((r-o)/9e4)+"s delta between PTS and DTS, align them"),r=o)):o=r),t=i[8];var m=t+9;if(s.size<=m)return null;s.size-=m;for(var p=new Uint8Array(s.size),y=0,T=u.length;y<T;y++){i=u[y];var x=i.byteLength;if(m)if(m>x){m-=x;continue}else i=i.subarray(m),x-=m,m=0;p.set(i,a),a+=x}return e&&(e-=t+3),{data:p,pts:r,dts:o,len:e}}return null}var wl=function(s){I(a,s);function a(){return s.apply(this,arguments)||this}var i=a.prototype;return i.resetInitSegment=function(t,r,o,u){s.prototype.resetInitSegment.call(this,t,r,o,u),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:r,duration:u,inputTimeScale:9e4,dropped:0}},a.probe=function(t){if(!t)return!1;var r=Nr(t,0),o=r?.length||0;if(r&&t[o]===11&&t[o+1]===119&&Tn(r)!==void 0&&xl(t,o)<=16)return!1;for(var u=t.length;o<u;o++)if(Pa(t,o))return k.log("MPEG Audio sync word found !"),!0;return!1},i.canParse=function(t,r){return El(t,r)},i.appendFrame=function(t,r,o){if(this.basePTS!==null)return Da(t,r,o,this.basePTS,this.frameIndex)},a}(xa),Oa=function(){function s(){}return s.getSilentFrame=function(i,e){switch(i){case"mp4a.40.2":if(e===1)return new Uint8Array([0,200,0,128,35,128]);if(e===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(e===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(e===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(e===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(e===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(e===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(e===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(e===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}},s}(),Jt=Math.pow(2,32)-1,ut=function(){function s(){}return s.init=function(){s.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var i;for(i in s.types)s.types.hasOwnProperty(i)&&(s.types[i]=[i.charCodeAt(0),i.charCodeAt(1),i.charCodeAt(2),i.charCodeAt(3)]);var e=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]),t=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]);s.HDLR_TYPES={video:e,audio:t};var r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),o=new Uint8Array([0,0,0,0,0,0,0,0]);s.STTS=s.STSC=s.STCO=o,s.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),s.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),s.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),s.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var u=new Uint8Array([105,115,111,109]),h=new Uint8Array([97,118,99,49]),d=new Uint8Array([0,0,0,1]);s.FTYP=s.box(s.types.ftyp,u,d,u,h),s.DINF=s.box(s.types.dinf,s.box(s.types.dref,r))},s.box=function(i){for(var e=8,t=arguments.length,r=new Array(t>1?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];for(var u=r.length,h=u;u--;)e+=r[u].byteLength;var d=new Uint8Array(e);for(d[0]=e>>24&255,d[1]=e>>16&255,d[2]=e>>8&255,d[3]=e&255,d.set(i,4),u=0,e=8;u<h;u++)d.set(r[u],e),e+=r[u].byteLength;return d},s.hdlr=function(i){return s.box(s.types.hdlr,s.HDLR_TYPES[i])},s.mdat=function(i){return s.box(s.types.mdat,i)},s.mdhd=function(i,e){e*=i;var t=Math.floor(e/(Jt+1)),r=Math.floor(e%(Jt+1));return s.box(s.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,i>>24&255,i>>16&255,i>>8&255,i&255,t>>24,t>>16&255,t>>8&255,t&255,r>>24,r>>16&255,r>>8&255,r&255,85,196,0,0]))},s.mdia=function(i){return s.box(s.types.mdia,s.mdhd(i.timescale,i.duration),s.hdlr(i.type),s.minf(i))},s.mfhd=function(i){return s.box(s.types.mfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,i&255]))},s.minf=function(i){return i.type==="audio"?s.box(s.types.minf,s.box(s.types.smhd,s.SMHD),s.DINF,s.stbl(i)):s.box(s.types.minf,s.box(s.types.vmhd,s.VMHD),s.DINF,s.stbl(i))},s.moof=function(i,e,t){return s.box(s.types.moof,s.mfhd(i),s.traf(t,e))},s.moov=function(i){for(var e=i.length,t=[];e--;)t[e]=s.trak(i[e]);return s.box.apply(null,[s.types.moov,s.mvhd(i[0].timescale,i[0].duration)].concat(t).concat(s.mvex(i)))},s.mvex=function(i){for(var e=i.length,t=[];e--;)t[e]=s.trex(i[e]);return s.box.apply(null,[s.types.mvex].concat(t))},s.mvhd=function(i,e){e*=i;var t=Math.floor(e/(Jt+1)),r=Math.floor(e%(Jt+1)),o=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,i>>24&255,i>>16&255,i>>8&255,i&255,t>>24,t>>16&255,t>>8&255,t&255,r>>24,r>>16&255,r>>8&255,r&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return s.box(s.types.mvhd,o)},s.sdtp=function(i){var e=i.samples||[],t=new Uint8Array(4+e.length),r,o;for(r=0;r<e.length;r++)o=e[r].flags,t[r+4]=o.dependsOn<<4|o.isDependedOn<<2|o.hasRedundancy;return s.box(s.types.sdtp,t)},s.stbl=function(i){return s.box(s.types.stbl,s.stsd(i),s.box(s.types.stts,s.STTS),s.box(s.types.stsc,s.STSC),s.box(s.types.stsz,s.STSZ),s.box(s.types.stco,s.STCO))},s.avc1=function(i){var e=[],t=[],r,o,u;for(r=0;r<i.sps.length;r++)o=i.sps[r],u=o.byteLength,e.push(u>>>8&255),e.push(u&255),e=e.concat(Array.prototype.slice.call(o));for(r=0;r<i.pps.length;r++)o=i.pps[r],u=o.byteLength,t.push(u>>>8&255),t.push(u&255),t=t.concat(Array.prototype.slice.call(o));var h=s.box(s.types.avcC,new Uint8Array([1,e[3],e[4],e[5],255,224|i.sps.length].concat(e).concat([i.pps.length]).concat(t))),d=i.width,m=i.height,p=i.pixelRatio[0],y=i.pixelRatio[1];return s.box(s.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,d>>8&255,d&255,m>>8&255,m&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),h,s.box(s.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),s.box(s.types.pasp,new Uint8Array([p>>24,p>>16&255,p>>8&255,p&255,y>>24,y>>16&255,y>>8&255,y&255])))},s.esds=function(i){var e=i.config.length;return new Uint8Array([0,0,0,0,3,23+e,0,1,0,4,15+e,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([e]).concat(i.config).concat([6,1,2]))},s.audioStsd=function(i){var e=i.samplerate;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,i.channelCount,0,16,0,0,0,0,e>>8&255,e&255,0,0])},s.mp4a=function(i){return s.box(s.types.mp4a,s.audioStsd(i),s.box(s.types.esds,s.esds(i)))},s.mp3=function(i){return s.box(s.types[".mp3"],s.audioStsd(i))},s.ac3=function(i){return s.box(s.types["ac-3"],s.audioStsd(i),s.box(s.types.dac3,i.config))},s.stsd=function(i){return i.type==="audio"?i.segmentCodec==="mp3"&&i.codec==="mp3"?s.box(s.types.stsd,s.STSD,s.mp3(i)):i.segmentCodec==="ac3"?s.box(s.types.stsd,s.STSD,s.ac3(i)):s.box(s.types.stsd,s.STSD,s.mp4a(i)):s.box(s.types.stsd,s.STSD,s.avc1(i))},s.tkhd=function(i){var e=i.id,t=i.duration*i.timescale,r=i.width,o=i.height,u=Math.floor(t/(Jt+1)),h=Math.floor(t%(Jt+1));return s.box(s.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,0,0,0,0,u>>24,u>>16&255,u>>8&255,u&255,h>>24,h>>16&255,h>>8&255,h&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,r>>8&255,r&255,0,0,o>>8&255,o&255,0,0]))},s.traf=function(i,e){var t=s.sdtp(i),r=i.id,o=Math.floor(e/(Jt+1)),u=Math.floor(e%(Jt+1));return s.box(s.types.traf,s.box(s.types.tfhd,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,r&255])),s.box(s.types.tfdt,new Uint8Array([1,0,0,0,o>>24,o>>16&255,o>>8&255,o&255,u>>24,u>>16&255,u>>8&255,u&255])),s.trun(i,t.length+16+20+8+16+8+8),t)},s.trak=function(i){return i.duration=i.duration||4294967295,s.box(s.types.trak,s.tkhd(i),s.mdia(i))},s.trex=function(i){var e=i.id;return s.box(s.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},s.trun=function(i,e){var t=i.samples||[],r=t.length,o=12+16*r,u=new Uint8Array(o),h,d,m,p,y,T;for(e+=8+o,u.set([i.type==="video"?1:0,0,15,1,r>>>24&255,r>>>16&255,r>>>8&255,r&255,e>>>24&255,e>>>16&255,e>>>8&255,e&255],0),h=0;h<r;h++)d=t[h],m=d.duration,p=d.size,y=d.flags,T=d.cts,u.set([m>>>24&255,m>>>16&255,m>>>8&255,m&255,p>>>24&255,p>>>16&255,p>>>8&255,p&255,y.isLeading<<2|y.dependsOn,y.isDependedOn<<6|y.hasRedundancy<<4|y.paddingValue<<1|y.isNonSync,y.degradPrio&61440,y.degradPrio&15,T>>>24&255,T>>>16&255,T>>>8&255,T&255],12+16*h);return s.box(s.types.trun,u)},s.initSegment=function(i){s.types||s.init();var e=s.moov(i),t=At(s.FTYP,e);return t},s}();ut.types=void 0,ut.HDLR_TYPES=void 0,ut.STTS=void 0,ut.STSC=void 0,ut.STCO=void 0,ut.STSZ=void 0,ut.VMHD=void 0,ut.SMHD=void 0,ut.STSD=void 0,ut.FTYP=void 0,ut.DINF=void 0;var Il=9e4;function Pl(s,a,i,e){i===void 0&&(i=1),e===void 0&&(e=!1);var t=s*a*i;return e?Math.round(t):t}function Lr(s,a){return a===void 0&&(a=!1),Pl(s,1e3,1/Il,a)}var kl=10*1e3,Ma=1024,Ol=1152,Ml=1536,mr=null,Ni=null,Ui=function(){function s(i,e,t,r){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=i,this.config=e,this.typeSupported=t,this.ISGenerated=!1,mr===null){var o=navigator.userAgent||"",u=o.match(/Chrome\/(\d+)/i);mr=u?parseInt(u[1]):0}if(Ni===null){var h=navigator.userAgent.match(/Safari\/(\d+)/i);Ni=h?parseInt(h[1]):0}}var a=s.prototype;return a.destroy=function(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null},a.resetTimeStamp=function(e){k.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e},a.resetNextTimestamp=function(){k.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},a.resetInitSegment=function(){k.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0},a.getVideoStartPts=function(e){var t=!1,r=e.reduce(function(o,u){var h=u.pts-o;return h<-4294967296?(t=!0,Dt(o,u.pts)):h>0?o:u.pts},e[0].pts);return t&&k.debug("PTS rollover detected"),r},a.remux=function(e,t,r,o,u,h,d,m){var p,y,T,x,b,L,A=u,D=u,w=e.pid>-1,N=t.pid>-1,U=t.samples.length,$=e.samples.length>0,V=d&&U>0||U>1,M=(!w||$)&&(!N||V)||this.ISGenerated||d;if(M){if(this.ISGenerated){var K,z,te,Z,ie=this.videoTrackConfig;ie&&(t.width!==ie.width||t.height!==ie.height||((K=t.pixelRatio)==null?void 0:K[0])!==((z=ie.pixelRatio)==null?void 0:z[0])||((te=t.pixelRatio)==null?void 0:te[1])!==((Z=ie.pixelRatio)==null?void 0:Z[1]))&&this.resetInitSegment()}else T=this.generateIS(e,t,u,h);var he=this.isVideoContiguous,fe=-1,Le;if(V&&(fe=Fl(t.samples),!he&&this.config.forceKeyFrameOnDiscontinuity))if(L=!0,fe>0){k.warn("[mp4-remuxer]: Dropped "+fe+" out of "+U+" video samples due to a missing keyframe");var Ee=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(fe),t.dropped+=fe,D+=(t.samples[0].pts-Ee)/t.inputTimeScale,Le=D}else fe===-1&&(k.warn("[mp4-remuxer]: No keyframe found out of "+U+" video samples"),L=!1);if(this.ISGenerated){if($&&V){var we=this.getVideoStartPts(t.samples),Ae=Dt(e.samples[0].pts,we)-we,ye=Ae/t.inputTimeScale;A+=Math.max(0,ye),D+=Math.max(0,-ye)}if($){if(e.samplerate||(k.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),T=this.generateIS(e,t,u,h)),y=this.remuxAudio(e,A,this.isAudioContiguous,h,N||V||m===Me.AUDIO?D:void 0),V){var je=y?y.endPTS-y.startPTS:0;t.inputTimeScale||(k.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),T=this.generateIS(e,t,u,h)),p=this.remuxVideo(t,D,he,je)}}else V&&(p=this.remuxVideo(t,D,he,0));p&&(p.firstKeyFrame=fe,p.independent=fe!==-1,p.firstKeyFramePTS=Le)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(b=Fa(r,u,this._initPTS,this._initDTS)),o.samples.length&&(x=Na(o,u,this._initPTS))),{audio:y,video:p,initSegment:T,independent:L,text:x,id3:b}},a.generateIS=function(e,t,r,o){var u=e.samples,h=t.samples,d=this.typeSupported,m={},p=this._initPTS,y=!p||o,T="audio/mp4",x,b,L;if(y&&(x=b=1/0),e.config&&u.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":d.mpeg?(T="audio/mpeg",e.codec=""):d.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3";break}m.audio={id:"audio",container:T,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&d.mpeg?new Uint8Array(0):ut.initSegment([e]),metadata:{channelCount:e.channelCount}},y&&(L=e.inputTimeScale,!p||L!==p.timescale?x=b=u[0].pts-Math.round(L*r):y=!1)}if(t.sps&&t.pps&&h.length){if(t.timescale=t.inputTimeScale,m.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:ut.initSegment([t]),metadata:{width:t.width,height:t.height}},y)if(L=t.inputTimeScale,!p||L!==p.timescale){var A=this.getVideoStartPts(h),D=Math.round(L*r);b=Math.min(b,Dt(h[0].dts,A)-D),x=Math.min(x,A-D)}else y=!1;this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(m).length)return this.ISGenerated=!0,y?(this._initPTS={baseTime:x,timescale:L},this._initDTS={baseTime:b,timescale:L}):x=L=void 0,{tracks:m,initPTS:x,timescale:L}},a.remuxVideo=function(e,t,r,o){var u=e.inputTimeScale,h=e.samples,d=[],m=h.length,p=this._initPTS,y=this.nextAvcDts,T=8,x=this.videoSampleDuration,b,L,A=Number.POSITIVE_INFINITY,D=Number.NEGATIVE_INFINITY,w=!1;if(!r||y===null){var N=t*u,U=h[0].pts-Dt(h[0].dts,h[0].pts);mr&&y!==null&&Math.abs(N-U-y)<15e3?r=!0:y=N-U}for(var $=p.baseTime*u/p.timescale,V=0;V<m;V++){var M=h[V];M.pts=Dt(M.pts-$,y),M.dts=Dt(M.dts-$,y),M.dts<h[V>0?V-1:V].dts&&(w=!0)}w&&h.sort(function(ni,$a){var ff=ni.dts-$a.dts,hf=ni.pts-$a.pts;return ff||hf}),b=h[0].dts,L=h[h.length-1].dts;var K=L-b,z=K?Math.round(K/(m-1)):x||e.inputTimeScale/30;if(r){var te=b-y,Z=te>z,ie=te<-1;if((Z||ie)&&(Z?k.warn("AVC: "+Lr(te,!0)+" ms ("+te+"dts) hole between fragments detected at "+t.toFixed(3)):k.warn("AVC: "+Lr(-te,!0)+" ms ("+te+"dts) overlapping between fragments detected at "+t.toFixed(3)),!ie||y>=h[0].pts||mr)){b=y;var he=h[0].pts-te;if(Z)h[0].dts=b,h[0].pts=he;else for(var fe=0;fe<h.length&&!(h[fe].dts>he);fe++)h[fe].dts-=te,h[fe].pts-=te;k.log("Video: Initial PTS/DTS adjusted: "+Lr(he,!0)+"/"+Lr(b,!0)+", delta: "+Lr(te,!0)+" ms")}}b=Math.max(0,b);for(var Le=0,Ee=0,we=b,Ae=0;Ae<m;Ae++){for(var ye=h[Ae],je=ye.units,Fe=je.length,qe=0,Xe=0;Xe<Fe;Xe++)qe+=je[Xe].data.length;Ee+=qe,Le+=Fe,ye.length=qe,ye.dts<we?(ye.dts=we,we+=z/4|0||1):we=ye.dts,A=Math.min(ye.pts,A),D=Math.max(ye.pts,D)}L=h[m-1].dts;var Ze=Ee+4*Le+8,ze;try{ze=new Uint8Array(Ze)}catch(ni){this.observer.emit(R.ERROR,R.ERROR,{type:le.MUX_ERROR,details:G.REMUX_ALLOC_ERROR,fatal:!1,error:ni,bytes:Ze,reason:"fail allocating video mdat "+Ze});return}var Ue=new DataView(ze.buffer);Ue.setUint32(0,Ze),ze.set(ut.types.mdat,4);for(var jt=!1,_t=Number.POSITIVE_INFINITY,$e=Number.POSITIVE_INFINITY,ct=Number.NEGATIVE_INFINITY,vt=Number.NEGATIVE_INFINITY,et=0;et<m;et++){for(var Ke=h[et],yt=Ke.units,ft=0,st=0,or=yt.length;st<or;st++){var ja=yt[st],tf=ja.data,Wi=ja.data.byteLength;Ue.setUint32(T,Wi),T+=4,ze.set(tf,T),T+=Wi,ft+=4+Wi}var ri=void 0;if(et<m-1)x=h[et+1].dts-Ke.dts,ri=h[et+1].pts-Ke.pts;else{var za=this.config,ii=et>0?Ke.dts-h[et-1].dts:z;if(ri=et>0?Ke.pts-h[et-1].pts:z,za.stretchShortVideoTrack&&this.nextAudioPts!==null){var rf=Math.floor(za.maxBufferHole*u),ji=(o?A+o*u:this.nextAudioPts)-Ke.pts;ji>rf?(x=ji-ii,x<0?x=ii:jt=!0,k.log("[mp4-remuxer]: It is approximately "+ji/90+" ms to the next segment; using duration "+x/90+" ms for the last video frame.")):x=ii}else x=ii}var nf=Math.round(Ke.pts-Ke.dts);_t=Math.min(_t,x),ct=Math.max(ct,x),$e=Math.min($e,ri),vt=Math.max(vt,ri),d.push(new Ua(Ke.key,x,ft,nf))}if(d.length){if(mr){if(mr<70){var Ya=d[0].flags;Ya.dependsOn=2,Ya.isNonSync=0}}else if(Ni&&vt-$e<ct-_t&&z/ct<.025&&d[0].cts===0){k.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var zi=b,wt=0,qa=d.length;wt<qa;wt++){var Xa=zi+d[wt].duration,af=zi+d[wt].cts;if(wt<qa-1){var sf=Xa+d[wt+1].cts;d[wt].duration=sf-af}else d[wt].duration=wt?d[wt-1].duration:z;d[wt].cts=0,zi=Xa}}}x=jt||!x?z:x,this.nextAvcDts=y=L+x,this.videoSampleDuration=x,this.isVideoContiguous=!0;var of=ut.moof(e.sequenceNumber++,b,C({},e,{samples:d})),uf="video",lf={data1:of,data2:ze,startPTS:A/u,endPTS:(D+x)/u,startDTS:b/u,endDTS:y/u,type:uf,hasAudio:!1,hasVideo:!0,nb:d.length,dropped:e.dropped};return e.samples=[],e.dropped=0,lf},a.getSamplesPerFrame=function(e){switch(e.segmentCodec){case"mp3":return Ol;case"ac3":return Ml;default:return Ma}},a.remuxAudio=function(e,t,r,o,u){var h=e.inputTimeScale,d=e.samplerate?e.samplerate:h,m=h/d,p=this.getSamplesPerFrame(e),y=p*m,T=this._initPTS,x=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,b=[],L=u!==void 0,A=e.samples,D=x?0:8,w=this.nextAudioPts||-1,N=t*h,U=T.baseTime*h/T.timescale;if(this.isAudioContiguous=r=r||A.length&&w>0&&(o&&Math.abs(N-w)<9e3||Math.abs(Dt(A[0].pts-U,N)-w)<20*y),A.forEach(function(st){st.pts=Dt(st.pts-U,N)}),!r||w<0){if(A=A.filter(function(st){return st.pts>=0}),!A.length)return;u===0?w=0:o&&!L?w=Math.max(0,N):w=A[0].pts}if(e.segmentCodec==="aac")for(var $=this.config.maxAudioFramesDrift,V=0,M=w;V<A.length;V++){var K=A[V],z=K.pts,te=z-M,Z=Math.abs(1e3*te/h);if(te<=-$*y&&L)V===0&&(k.warn("Audio frame @ "+(z/h).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*te/h)+" ms."),this.nextAudioPts=w=M=z);else if(te>=$*y&&Z<kl&&L){var ie=Math.round(te/y);M=z-ie*y,M<0&&(ie--,M+=y),V===0&&(this.nextAudioPts=w=M),k.warn("[mp4-remuxer]: Injecting "+ie+" audio frame @ "+(M/h).toFixed(3)+"s due to "+Math.round(1e3*te/h)+" ms gap.");for(var he=0;he<ie;he++){var fe=Math.max(M,0),Le=Oa.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);Le||(k.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Le=K.unit.subarray()),A.splice(V,0,{unit:Le,pts:fe}),M+=y,V++}}K.pts=M,M+=y}for(var Ee=null,we=null,Ae,ye=0,je=A.length;je--;)ye+=A[je].unit.byteLength;for(var Fe=0,qe=A.length;Fe<qe;Fe++){var Xe=A[Fe],Ze=Xe.unit,ze=Xe.pts;if(we!==null){var Ue=b[Fe-1];Ue.duration=Math.round((ze-we)/m)}else if(r&&e.segmentCodec==="aac"&&(ze=w),Ee=ze,ye>0){ye+=D;try{Ae=new Uint8Array(ye)}catch(st){this.observer.emit(R.ERROR,R.ERROR,{type:le.MUX_ERROR,details:G.REMUX_ALLOC_ERROR,fatal:!1,error:st,bytes:ye,reason:"fail allocating audio mdat "+ye});return}if(!x){var jt=new DataView(Ae.buffer);jt.setUint32(0,ye),Ae.set(ut.types.mdat,4)}}else return;Ae.set(Ze,D);var _t=Ze.byteLength;D+=_t,b.push(new Ua(!0,p,_t,0)),we=ze}var $e=b.length;if($e){var ct=b[b.length-1];this.nextAudioPts=w=we+m*ct.duration;var vt=x?new Uint8Array(0):ut.moof(e.sequenceNumber++,Ee/m,C({},e,{samples:b}));e.samples=[];var et=Ee/h,Ke=w/h,yt="audio",ft={data1:vt,data2:Ae,startPTS:et,endPTS:Ke,startDTS:et,endDTS:Ke,type:yt,hasAudio:!0,hasVideo:!1,nb:$e};return this.isAudioContiguous=!0,ft}},a.remuxEmptyAudio=function(e,t,r,o){var u=e.inputTimeScale,h=e.samplerate?e.samplerate:u,d=u/h,m=this.nextAudioPts,p=this._initDTS,y=p.baseTime*9e4/p.timescale,T=(m!==null?m:o.startDTS*u)+y,x=o.endDTS*u+y,b=d*Ma,L=Math.ceil((x-T)/b),A=Oa.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(k.warn("[mp4-remuxer]: remux empty Audio"),!A){k.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var D=[],w=0;w<L;w++){var N=T+w*b;D.push({unit:A,pts:N,dts:N})}return e.samples=D,this.remuxAudio(e,t,r,!1)},s}();function Dt(s,a){var i;if(a===null)return s;for(a<s?i=-8589934592:i=8589934592;Math.abs(s-a)>4294967296;)s+=i;return s}function Fl(s){for(var a=0;a<s.length;a++)if(s[a].key)return a;return-1}function Fa(s,a,i,e){var t=s.samples.length;if(t){for(var r=s.inputTimeScale,o=0;o<t;o++){var u=s.samples[o];u.pts=Dt(u.pts-i.baseTime*r/i.timescale,a*r)/r,u.dts=Dt(u.dts-e.baseTime*r/e.timescale,a*r)/r}var h=s.samples;return s.samples=[],{samples:h}}}function Na(s,a,i){var e=s.samples.length;if(e){for(var t=s.inputTimeScale,r=0;r<e;r++){var o=s.samples[r];o.pts=Dt(o.pts-i.baseTime*t/i.timescale,a*t)/t}s.samples.sort(function(h,d){return h.pts-d.pts});var u=s.samples;return s.samples=[],{samples:u}}}var Ua=function(a,i,e,t){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=i,this.size=e,this.cts=t,this.flags={isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:a?2:1,isNonSync:a?0:1}},Nl=function(){function s(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}var a=s.prototype;return a.destroy=function(){},a.resetTimeStamp=function(e){this.initPTS=e,this.lastEndTime=null},a.resetNextTimestamp=function(){this.lastEndTime=null},a.resetInitSegment=function(e,t,r,o){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(To(e,o)),this.emitInitSegment=!0},a.generateInitSegment=function(e){var t=this.audioCodec,r=this.videoCodec;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}var o=this.initData=wn(e);o.audio&&(t=Ba(o.audio,Pe.AUDIO)),o.video&&(r=Ba(o.video,Pe.VIDEO));var u={};o.audio&&o.video?u.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:e,id:"main"}:o.audio?u.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:o.video?u.video={container:"video/mp4",codec:r,initSegment:e,id:"main"}:k.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=u},a.remux=function(e,t,r,o,u,h){var d,m,p=this.initPTS,y=this.lastEndTime,T={audio:void 0,video:void 0,text:o,id3:r,initSegment:void 0};j(y)||(y=this.lastEndTime=u||0);var x=t.samples;if(!(x!=null&&x.length))return T;var b={initPTS:void 0,timescale:1},L=this.initData;if((d=L)!=null&&d.length||(this.generateInitSegment(x),L=this.initData),!((m=L)!=null&&m.length))return k.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),T;this.emitInitSegment&&(b.tracks=this.initTracks,this.emitInitSegment=!1);var A=Lo(x,L),D=bo(L,x),w=D===null?u:D;(Ul(p,w,u,A)||b.timescale!==p.timescale&&h)&&(b.initPTS=w-u,p&&p.timescale===1&&k.warn("Adjusting initPTS by "+(b.initPTS-p.baseTime)),this.initPTS=p={baseTime:b.initPTS,timescale:1});var N=e?w-p.baseTime/p.timescale:y,U=N+A;Ro(L,x,p.baseTime/p.timescale),A>0?this.lastEndTime=U:(k.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var $=!!L.audio,V=!!L.video,M="";$&&(M+="audio"),V&&(M+="video");var K={data1:x,startPTS:N,startDTS:N,endPTS:U,endDTS:U,type:M,hasAudio:$,hasVideo:V,nb:1,dropped:0};return T.audio=K.type==="audio"?K:void 0,T.video=K.type!=="audio"?K:void 0,T.initSegment=b,T.id3=Fa(r,u,p,p),o.samples.length&&(T.text=Na(o,u,p)),T},s}();function Ul(s,a,i,e){if(s===null)return!0;var t=Math.max(e,1),r=a-s.baseTime/s.timescale;return Math.abs(r-i)>t}function Ba(s,a){var i=s?.codec;if(i&&i.length>4)return i;if(a===Pe.AUDIO){if(i==="ec-3"||i==="ac-3"||i==="alac")return i;if(i==="fLaC"||i==="Opus"){var e=!1;return Kr(i,e)}var t="mp4a.40.5";return k.info('Parsed audio codec "'+i+'" or audio object type not handled. Using "'+t+'"'),t}return k.warn('Unhandled video codec "'+i+'"'),i==="hvc1"||i==="hev1"?"hvc1.1.6.L120.90":i==="av01"?"av01.0.04M.08":"avc1.42e01e"}var Ga=typeof self<"u"?self:void 0,Wt;try{Wt=self.performance.now.bind(self.performance)}catch{k.debug("Unable to use Performance API on this environment"),Wt=Ga?.Date.now}var Bi=[{demux:Tl,remux:Nl},{demux:Rl,remux:Ui},{demux:_l,remux:Ui},{demux:wl,remux:Ui}],Gi=function(){function s(i,e,t,r,o){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=i,this.typeSupported=e,this.config=t,this.vendor=r,this.id=o}var a=s.prototype;return a.configure=function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()},a.push=function(e,t,r,o){var u=this,h=r.transmuxing;h.executeStart=Wt();var d=new Uint8Array(e),m=this.currentTransmuxState,p=this.transmuxConfig;o&&(this.currentTransmuxState=o);var y=o||m,T=y.contiguous,x=y.discontinuity,b=y.trackSwitch,L=y.accurateTimeOffset,A=y.timeOffset,D=y.initSegmentChange,w=p.audioCodec,N=p.videoCodec,U=p.defaultInitPts,$=p.duration,V=p.initSegmentData,M=Bl(d,t);if(M&&M.method==="AES-128"){var K=this.getDecrypter();if(K.isSync()){var z=K.softwareDecrypt(d,M.key.buffer,M.iv.buffer),te=r.part>-1;if(te&&(z=K.flush()),!z)return h.executeEnd=Wt(),Vi(r);d=new Uint8Array(z)}else return this.decryptionPromise=K.webCryptoDecrypt(d,M.key.buffer,M.iv.buffer).then(function(Le){var Ee=u.push(Le,null,r);return u.decryptionPromise=null,Ee}),this.decryptionPromise}var Z=this.needsProbing(x,b);if(Z){var ie=this.configureTransmuxer(d);if(ie)return k.warn("[transmuxer] "+ie.message),this.observer.emit(R.ERROR,R.ERROR,{type:le.MEDIA_ERROR,details:G.FRAG_PARSING_ERROR,fatal:!1,error:ie,reason:ie.message}),h.executeEnd=Wt(),Vi(r)}(x||b||D||Z)&&this.resetInitSegment(V,w,N,$,t),(x||D||Z)&&this.resetInitialTimestamp(U),T||this.resetContiguity();var he=this.transmux(d,M,A,L,r),fe=this.currentTransmuxState;return fe.contiguous=!0,fe.discontinuity=!1,fe.trackSwitch=!1,h.executeEnd=Wt(),he},a.flush=function(e){var t=this,r=e.transmuxing;r.executeStart=Wt();var o=this.decrypter,u=this.currentTransmuxState,h=this.decryptionPromise;if(h)return h.then(function(){return t.flush(e)});var d=[],m=u.timeOffset;if(o){var p=o.flush();p&&d.push(this.push(p,null,e))}var y=this.demuxer,T=this.remuxer;if(!y||!T)return r.executeEnd=Wt(),[Vi(e)];var x=y.flush(m);return sr(x)?x.then(function(b){return t.flushRemux(d,b,e),d}):(this.flushRemux(d,x,e),d)},a.flushRemux=function(e,t,r){var o=t.audioTrack,u=t.videoTrack,h=t.id3Track,d=t.textTrack,m=this.currentTransmuxState,p=m.accurateTimeOffset,y=m.timeOffset;k.log("[transmuxer.ts]: Flushed fragment "+r.sn+(r.part>-1?" p: "+r.part:"")+" of level "+r.level);var T=this.remuxer.remux(o,u,h,d,y,p,!0,this.id);e.push({remuxResult:T,chunkMeta:r}),r.transmuxing.executeEnd=Wt()},a.resetInitialTimestamp=function(e){var t=this.demuxer,r=this.remuxer;!t||!r||(t.resetTimeStamp(e),r.resetTimeStamp(e))},a.resetContiguity=function(){var e=this.demuxer,t=this.remuxer;!e||!t||(e.resetContiguity(),t.resetNextTimestamp())},a.resetInitSegment=function(e,t,r,o,u){var h=this.demuxer,d=this.remuxer;!h||!d||(h.resetInitSegment(e,t,r,o),d.resetInitSegment(e,t,r,u))},a.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},a.transmux=function(e,t,r,o,u){var h;return t&&t.method==="SAMPLE-AES"?h=this.transmuxSampleAes(e,t,r,o,u):h=this.transmuxUnencrypted(e,r,o,u),h},a.transmuxUnencrypted=function(e,t,r,o){var u=this.demuxer.demux(e,t,!1,!this.config.progressive),h=u.audioTrack,d=u.videoTrack,m=u.id3Track,p=u.textTrack,y=this.remuxer.remux(h,d,m,p,t,r,!1,this.id);return{remuxResult:y,chunkMeta:o}},a.transmuxSampleAes=function(e,t,r,o,u){var h=this;return this.demuxer.demuxSampleAes(e,t,r).then(function(d){var m=h.remuxer.remux(d.audioTrack,d.videoTrack,d.id3Track,d.textTrack,r,o,!1,h.id);return{remuxResult:m,chunkMeta:u}})},a.configureTransmuxer=function(e){for(var t=this.config,r=this.observer,o=this.typeSupported,u=this.vendor,h,d=0,m=Bi.length;d<m;d++){var p;if((p=Bi[d].demux)!=null&&p.probe(e)){h=Bi[d];break}}if(!h)return new Error("Failed to find demuxer by probing fragment data");var y=this.demuxer,T=this.remuxer,x=h.remux,b=h.demux;(!T||!(T instanceof x))&&(this.remuxer=new x(r,t,o,u)),(!y||!(y instanceof b))&&(this.demuxer=new b(r,t,o),this.probe=b.probe)},a.needsProbing=function(e,t){return!this.demuxer||!this.remuxer||e||t},a.getDecrypter=function(){var e=this.decrypter;return e||(e=this.decrypter=new Pi(this.config)),e},s}();function Bl(s,a){var i=null;return s.byteLength>0&&a?.key!=null&&a.iv!==null&&a.method!=null&&(i=a),i}var Vi=function(a){return{remuxResult:{},chunkMeta:a}};function sr(s){return"then"in s&&s.then instanceof Function}var Gl=function(a,i,e,t,r){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=a,this.videoCodec=i,this.initSegmentData=e,this.duration=t,this.defaultInitPts=r||null},Vl=function(a,i,e,t,r,o){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=a,this.contiguous=i,this.accurateTimeOffset=e,this.trackSwitch=t,this.timeOffset=r,this.initSegmentChange=o},Va={exports:{}};(function(s){var a=Object.prototype.hasOwnProperty,i="~";function e(){}Object.create&&(e.prototype=Object.create(null),new e().__proto__||(i=!1));function t(h,d,m){this.fn=h,this.context=d,this.once=m||!1}function r(h,d,m,p,y){if(typeof m!="function")throw new TypeError("The listener must be a function");var T=new t(m,p||h,y),x=i?i+d:d;return h._events[x]?h._events[x].fn?h._events[x]=[h._events[x],T]:h._events[x].push(T):(h._events[x]=T,h._eventsCount++),h}function o(h,d){--h._eventsCount===0?h._events=new e:delete h._events[d]}function u(){this._events=new e,this._eventsCount=0}u.prototype.eventNames=function(){var d=[],m,p;if(this._eventsCount===0)return d;for(p in m=this._events)a.call(m,p)&&d.push(i?p.slice(1):p);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(m)):d},u.prototype.listeners=function(d){var m=i?i+d:d,p=this._events[m];if(!p)return[];if(p.fn)return[p.fn];for(var y=0,T=p.length,x=new Array(T);y<T;y++)x[y]=p[y].fn;return x},u.prototype.listenerCount=function(d){var m=i?i+d:d,p=this._events[m];return p?p.fn?1:p.length:0},u.prototype.emit=function(d,m,p,y,T,x){var b=i?i+d:d;if(!this._events[b])return!1;var L=this._events[b],A=arguments.length,D,w;if(L.fn){switch(L.once&&this.removeListener(d,L.fn,void 0,!0),A){case 1:return L.fn.call(L.context),!0;case 2:return L.fn.call(L.context,m),!0;case 3:return L.fn.call(L.context,m,p),!0;case 4:return L.fn.call(L.context,m,p,y),!0;case 5:return L.fn.call(L.context,m,p,y,T),!0;case 6:return L.fn.call(L.context,m,p,y,T,x),!0}for(w=1,D=new Array(A-1);w<A;w++)D[w-1]=arguments[w];L.fn.apply(L.context,D)}else{var N=L.length,U;for(w=0;w<N;w++)switch(L[w].once&&this.removeListener(d,L[w].fn,void 0,!0),A){case 1:L[w].fn.call(L[w].context);break;case 2:L[w].fn.call(L[w].context,m);break;case 3:L[w].fn.call(L[w].context,m,p);break;case 4:L[w].fn.call(L[w].context,m,p,y);break;default:if(!D)for(U=1,D=new Array(A-1);U<A;U++)D[U-1]=arguments[U];L[w].fn.apply(L[w].context,D)}}return!0},u.prototype.on=function(d,m,p){return r(this,d,m,p,!1)},u.prototype.once=function(d,m,p){return r(this,d,m,p,!0)},u.prototype.removeListener=function(d,m,p,y){var T=i?i+d:d;if(!this._events[T])return this;if(!m)return o(this,T),this;var x=this._events[T];if(x.fn)x.fn===m&&(!y||x.once)&&(!p||x.context===p)&&o(this,T);else{for(var b=0,L=[],A=x.length;b<A;b++)(x[b].fn!==m||y&&!x[b].once||p&&x[b].context!==p)&&L.push(x[b]);L.length?this._events[T]=L.length===1?L[0]:L:o(this,T)}return this},u.prototype.removeAllListeners=function(d){var m;return d?(m=i?i+d:d,this._events[m]&&o(this,m)):(this._events=new e,this._eventsCount=0),this},u.prototype.off=u.prototype.removeListener,u.prototype.addListener=u.prototype.on,u.prefixed=i,u.EventEmitter=u,s.exports=u})(Va);var Hl=Va.exports,Hi=se(Hl);typeof g<"u"&&g&&Kl(self);function Kl(s){var a=new Hi,i=function(r,o){s.postMessage({event:r,data:o})};a.on(R.FRAG_DECRYPTED,i),a.on(R.ERROR,i);var e=function(){var r=function(h){var d=function(p){i("workerLog",{logType:h,message:p})};k[h]=d};for(var o in k)r(o)};s.addEventListener("message",function(t){var r=t.data;switch(r.cmd){case"init":{var o=JSON.parse(r.config);s.transmuxer=new Gi(a,r.typeSupported,o,"",r.id),X(o.debug,r.id),e(),i("init",null);break}case"configure":{s.transmuxer.configure(r.config);break}case"demux":{var u=s.transmuxer.push(r.data,r.decryptdata,r.chunkMeta,r.state);sr(u)?(s.transmuxer.async=!0,u.then(function(p){Ki(s,p)}).catch(function(p){i(R.ERROR,{type:le.MEDIA_ERROR,details:G.FRAG_PARSING_ERROR,chunkMeta:r.chunkMeta,fatal:!1,error:p,err:p,reason:"transmuxer-worker push error"})})):(s.transmuxer.async=!1,Ki(s,u));break}case"flush":{var h=r.chunkMeta,d=s.transmuxer.flush(h),m=sr(d);m||s.transmuxer.async?(sr(d)||(d=Promise.resolve(d)),d.then(function(p){Ka(s,p,h)}).catch(function(p){i(R.ERROR,{type:le.MEDIA_ERROR,details:G.FRAG_PARSING_ERROR,chunkMeta:r.chunkMeta,fatal:!1,error:p,err:p,reason:"transmuxer-worker flush error"})})):Ka(s,d,h);break}}})}function Ki(s,a){if(Wl(a.remuxResult))return!1;var i=[],e=a.remuxResult,t=e.audio,r=e.video;return t&&Ha(i,t),r&&Ha(i,r),s.postMessage({event:"transmuxComplete",data:a},i),!0}function Ha(s,a){a.data1&&s.push(a.data1.buffer),a.data2&&s.push(a.data2.buffer)}function Ka(s,a,i){var e=a.reduce(function(t,r){return Ki(s,r)||t},!1);e||s.postMessage({event:"transmuxComplete",data:a[0]}),s.postMessage({event:"flush",data:i})}function Wl(s){return!s.audio&&!s.video&&!s.text&&!s.id3&&!s.initSegment}function jl(){return typeof c=="function"}function zl(){var s=new self.Blob(["var exports={};var module={exports:exports};function define(f){f()};define.amd=true;("+c.toString()+")(true);"],{type:"text/javascript"}),a=self.URL.createObjectURL(s),i=new self.Worker(a);return{worker:i,objectURL:a}}function Yl(s){var a=new self.URL(s,self.location.href).href,i=new self.Worker(a);return{worker:i,scriptURL:a}}var ql=function(){function s(i,e,t,r){var o=this;this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;var u=i.config;this.hls=i,this.id=e,this.useWorker=!!u.enableWorker,this.onTransmuxComplete=t,this.onFlush=r;var h=function(x,b){b=b||{},b.frag=o.frag,b.id=o.id,x===R.ERROR&&(o.error=b.error),o.hls.trigger(x,b)};this.observer=new Hi,this.observer.on(R.FRAG_DECRYPTED,h),this.observer.on(R.ERROR,h);var d=ar(u.preferManagedMediaSource)||{isTypeSupported:function(){return!1}},m={mpeg:d.isTypeSupported("audio/mpeg"),mp3:d.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:!1};if(this.useWorker&&typeof Worker<"u"){var p=u.workerPath||jl();if(p){try{u.workerPath?(k.log("loading Web Worker "+u.workerPath+' for "'+e+'"'),this.workerContext=Yl(u.workerPath)):(k.log('injecting Web Worker for "'+e+'"'),this.workerContext=zl()),this.onwmsg=function(T){return o.onWorkerMessage(T)};var y=this.workerContext.worker;y.addEventListener("message",this.onwmsg),y.onerror=function(T){var x=new Error(T.message+" ("+T.filename+":"+T.lineno+")");u.enableWorker=!1,k.warn('Error in "'+e+'" Web Worker, fallback to inline'),o.hls.trigger(R.ERROR,{type:le.OTHER_ERROR,details:G.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:x})},y.postMessage({cmd:"init",typeSupported:m,vendor:"",id:e,config:JSON.stringify(u)})}catch(T){k.warn('Error setting up "'+e+'" Web Worker, fallback to inline',T),this.resetWorker(),this.error=null,this.transmuxer=new Gi(this.observer,m,u,"",e)}return}}this.transmuxer=new Gi(this.observer,m,u,"",e)}var a=s.prototype;return a.resetWorker=function(){if(this.workerContext){var e=this.workerContext,t=e.worker,r=e.objectURL;r&&self.URL.revokeObjectURL(r),t.removeEventListener("message",this.onwmsg),t.onerror=null,t.terminate(),this.workerContext=null}},a.destroy=function(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{var e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}var t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},a.push=function(e,t,r,o,u,h,d,m,p,y){var T,x,b=this;p.transmuxing.start=self.performance.now();var L=this.transmuxer,A=h?h.start:u.start,D=u.decryptdata,w=this.frag,N=!(w&&u.cc===w.cc),U=!(w&&p.level===w.level),$=w?p.sn-w.sn:-1,V=this.part?p.part-this.part.index:-1,M=$===0&&p.id>1&&p.id===w?.stats.chunkCount,K=!U&&($===1||$===0&&(V===1||M&&V<=0)),z=self.performance.now();(U||$||u.stats.parsing.start===0)&&(u.stats.parsing.start=z),h&&(V||!K)&&(h.stats.parsing.start=z);var te=!(w&&((T=u.initSegment)==null?void 0:T.url)===((x=w.initSegment)==null?void 0:x.url)),Z=new Vl(N,K,m,U,A,te);if(!K||N||te){k.log("[transmuxer-interface, "+u.type+"]: Starting new transmux session for sn: "+p.sn+" p: "+p.part+" level: "+p.level+" id: "+p.id+`
9
+ discontinuity: `+N+`
10
+ trackSwitch: `+U+`
11
+ contiguous: `+K+`
12
+ accurateTimeOffset: `+m+`
13
+ timeOffset: `+A+`
14
+ initSegmentChange: `+te);var ie=new Gl(r,o,t,d,y);this.configureTransmuxer(ie)}if(this.frag=u,this.part=h,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:D,chunkMeta:p,state:Z},e instanceof ArrayBuffer?[e]:[]);else if(L){var he=L.push(e,D,p,Z);sr(he)?(L.async=!0,he.then(function(fe){b.handleTransmuxComplete(fe)}).catch(function(fe){b.transmuxerError(fe,p,"transmuxer-interface push error")})):(L.async=!1,this.handleTransmuxComplete(he))}},a.flush=function(e){var t=this;e.transmuxing.start=self.performance.now();var r=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(r){var o=r.flush(e),u=sr(o);u||r.async?(sr(o)||(o=Promise.resolve(o)),o.then(function(h){t.handleFlushResult(h,e)}).catch(function(h){t.transmuxerError(h,e,"transmuxer-interface flush error")})):this.handleFlushResult(o,e)}},a.transmuxerError=function(e,t,r){this.hls&&(this.error=e,this.hls.trigger(R.ERROR,{type:le.MEDIA_ERROR,details:G.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,fatal:!1,error:e,err:e,reason:r}))},a.handleFlushResult=function(e,t){var r=this;e.forEach(function(o){r.handleTransmuxComplete(o)}),this.onFlush(t)},a.onWorkerMessage=function(e){var t=e.data;if(!(t!=null&&t.event)){k.warn("worker message received with no "+(t?"event name":"data"));return}var r=this.hls;if(this.hls)switch(t.event){case"init":{var o,u=(o=this.workerContext)==null?void 0:o.objectURL;u&&self.URL.revokeObjectURL(u);break}case"transmuxComplete":{this.handleTransmuxComplete(t.data);break}case"flush":{this.onFlush(t.data);break}case"workerLog":k[t.data.logType]&&k[t.data.logType](t.data.message);break;default:{t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,r.trigger(t.event,t.data);break}}},a.configureTransmuxer=function(e){var t=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)},a.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},s}(),Xl=250,ti=2,$l=.1,Ql=.05,Jl=function(){function s(i,e,t,r){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=i,this.media=e,this.fragmentTracker=t,this.hls=r}var a=s.prototype;return a.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},a.poll=function(e,t){var r=this.config,o=this.media,u=this.stalled;if(o!==null){var h=o.currentTime,d=o.seeking,m=this.seeking&&!d,p=!this.seeking&&d;if(this.seeking=d,h!==e){if(this.moved=!0,d||(this.nudgeRetry=0),u!==null){if(this.stallReported){var y=self.performance.now()-u;k.warn("playback not stuck anymore @"+h+", after "+Math.round(y)+"ms"),this.stallReported=!1}this.stalled=null}return}if(p||m){this.stalled=null;return}if(o.paused&&!d||o.ended||o.playbackRate===0||!rt.getBuffered(o).length){this.nudgeRetry=0;return}var T=rt.bufferInfo(o,h,0),x=T.nextStart||0;if(d){var b=T.len>ti,L=!x||t&&t.start<=h||x-h>ti&&!this.fragmentTracker.getPartialFragment(h);if(b||L)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var A,D=T.len>0;if(!D&&!x)return;var w=Math.max(x,T.start||0)-h,N=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,U=N==null||(A=N.details)==null?void 0:A.live,$=U?N.details.targetduration*2:ti,V=this.fragmentTracker.getPartialFragment(h);if(w>0&&(w<=$||V)){o.paused||this._trySkipBufferHole(V);return}}var M=self.performance.now();if(u===null){this.stalled=M;return}var K=M-u;if(!(!d&&K>=Xl&&(this._reportStall(T),!this.media))){var z=rt.bufferInfo(o,h,r.maxBufferHole);this._tryFixBufferStall(z,K)}}},a._tryFixBufferStall=function(e,t){var r=this.config,o=this.fragmentTracker,u=this.media;if(u!==null){var h=u.currentTime,d=o.getPartialFragment(h);if(d){var m=this._trySkipBufferHole(d);if(m||!this.media)return}(e.len>r.maxBufferHole||e.nextStart&&e.nextStart-h<r.maxBufferHole)&&t>r.highBufferWatchdogPeriod*1e3&&(k.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},a._reportStall=function(e){var t=this.hls,r=this.media,o=this.stallReported;if(!o&&r){this.stallReported=!0;var u=new Error("Playback stalling at @"+r.currentTime+" due to low buffer ("+JSON.stringify(e)+")");k.warn(u.message),t.trigger(R.ERROR,{type:le.MEDIA_ERROR,details:G.BUFFER_STALLED_ERROR,fatal:!1,error:u,buffer:e.len})}},a._trySkipBufferHole=function(e){var t=this.config,r=this.hls,o=this.media;if(o===null)return 0;var u=o.currentTime,h=rt.bufferInfo(o,u,0),d=u<h.start?h.start:h.nextStart;if(d){var m=h.len<=t.maxBufferHole,p=h.len>0&&h.len<1&&o.readyState<3,y=d-u;if(y>0&&(m||p)){if(y>t.maxBufferHole){var T=this.fragmentTracker,x=!1;if(u===0){var b=T.getAppendedFrag(0,Me.MAIN);b&&d<b.end&&(x=!0)}if(!x){var L=e||T.getAppendedFrag(u,Me.MAIN);if(L){for(var A=!1,D=L.end;D<d;){var w=T.getPartialFragment(D);if(w)D+=w.duration;else{A=!0;break}}if(A)return 0}}}var N=Math.max(d+Ql,u+$l);if(k.warn("skipping hole, adjusting currentTime from "+u+" to "+N),this.moved=!0,this.stalled=null,o.currentTime=N,e&&!e.gap){var U=new Error("fragment loaded with buffer holes, seeking from "+u+" to "+N);r.trigger(R.ERROR,{type:le.MEDIA_ERROR,details:G.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:U,reason:U.message,frag:e})}return N}}return 0},a._tryNudgeBuffer=function(){var e=this.config,t=this.hls,r=this.media,o=this.nudgeRetry;if(r!==null){var u=r.currentTime;if(this.nudgeRetry++,o<e.nudgeMaxRetry){var h=u+(o+1)*e.nudgeOffset,d=new Error("Nudging 'currentTime' from "+u+" to "+h);k.warn(d.message),r.currentTime=h,t.trigger(R.ERROR,{type:le.MEDIA_ERROR,details:G.BUFFER_NUDGE_ON_STALL,error:d,fatal:!1})}else{var m=new Error("Playhead still not moving while enough data buffered @"+u+" after "+e.nudgeMaxRetry+" nudges");k.error(m.message),t.trigger(R.ERROR,{type:le.MEDIA_ERROR,details:G.BUFFER_STALLED_ERROR,error:m,fatal:!0})}}},s}(),Zl=100,ef=function(s){I(a,s);function a(e,t,r){var o;return o=s.call(this,e,t,r,"[stream-controller]",Me.MAIN)||this,o.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.couldBacktrack=!1,o.backtrackFragment=null,o.audioCodecSwitch=!1,o.videoBuffer=null,o._registerListeners(),o}var i=a.prototype;return i._registerListeners=function(){var t=this.hls;t.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.MANIFEST_PARSED,this.onManifestParsed,this),t.on(R.LEVEL_LOADING,this.onLevelLoading,this),t.on(R.LEVEL_LOADED,this.onLevelLoaded,this),t.on(R.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(R.ERROR,this.onError,this),t.on(R.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(R.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(R.BUFFER_CREATED,this.onBufferCreated,this),t.on(R.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(R.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(R.FRAG_BUFFERED,this.onFragBuffered,this)},i._unregisterListeners=function(){var t=this.hls;t.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.MANIFEST_PARSED,this.onManifestParsed,this),t.off(R.LEVEL_LOADED,this.onLevelLoaded,this),t.off(R.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(R.ERROR,this.onError,this),t.off(R.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(R.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(R.BUFFER_CREATED,this.onBufferCreated,this),t.off(R.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(R.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(R.FRAG_BUFFERED,this.onFragBuffered,this)},i.onHandlerDestroying=function(){this._unregisterListeners(),s.prototype.onHandlerDestroying.call(this)},i.startLoad=function(t){if(this.levels){var r=this.lastCurrentTime,o=this.hls;if(this.stopLoad(),this.setInterval(Zl),this.level=-1,!this.startFragRequested){var u=o.startLevel;u===-1&&(o.config.testBandwidth&&this.levels.length>1?(u=0,this.bitrateTest=!0):u=o.firstAutoLevel),o.nextLoadLevel=u,this.level=o.loadLevel,this.loadedmetadata=!1}r>0&&t===-1&&(this.log("Override startPosition with lastCurrentTime @"+r.toFixed(3)),t=r),this.state=ne.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=ne.STOPPED},i.stopLoad=function(){this._forceStartLoad=!1,s.prototype.stopLoad.call(this)},i.doTick=function(){switch(this.state){case ne.WAITING_LEVEL:{var t=this.levels,r=this.level,o=t?.[r],u=o?.details;if(u&&(!u.live||this.levelLastLoaded===o)){if(this.waitForCdnTuneIn(u))break;this.state=ne.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=ne.IDLE;break}break}case ne.FRAG_LOADING_WAITING_RETRY:{var h,d=self.performance.now(),m=this.retryDate;if(!m||d>=m||(h=this.media)!=null&&h.seeking){var p=this.levels,y=this.level,T=p?.[y];this.resetStartWhenNotLoaded(T||null),this.state=ne.IDLE}}break}this.state===ne.IDLE&&this.doTickIdle(),this.onTickEnd()},i.onTickEnd=function(){s.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},i.doTickIdle=function(){var t=this.hls,r=this.levelLastLoaded,o=this.levels,u=this.media;if(!(r===null||!u&&(this.startFragRequested||!t.config.startFragPrefetch))&&!(this.altAudio&&this.audioOnly)){var h=t.nextLoadLevel;if(o!=null&&o[h]){var d=o[h],m=this.getMainFwdBufferInfo();if(m!==null){var p=this.getLevelDetails();if(p&&this._streamEnded(m,p)){var y={};this.altAudio&&(y.type="video"),this.hls.trigger(R.BUFFER_EOS,y),this.state=ne.ENDED;return}t.loadLevel!==h&&t.manualLevel===-1&&this.log("Adapting to level "+h+" from level "+this.level),this.level=t.nextLoadLevel=h;var T=d.details;if(!T||this.state===ne.WAITING_LEVEL||T.live&&this.levelLastLoaded!==d){this.level=h,this.state=ne.WAITING_LEVEL;return}var x=m.len,b=this.getMaxBufferLength(d.maxBitrate);if(!(x>=b)){this.backtrackFragment&&this.backtrackFragment.start>m.end&&(this.backtrackFragment=null);var L=this.backtrackFragment?this.backtrackFragment.start:m.end,A=this.getNextFragment(L,T);if(this.couldBacktrack&&!this.fragPrevious&&A&&A.sn!=="initSegment"&&this.fragmentTracker.getState(A)!==gt.OK){var D,w=((D=this.backtrackFragment)!=null?D:A).sn,N=w-T.startSN,U=T.fragments[N-1];U&&A.cc===U.cc&&(A=U,this.fragmentTracker.removeFragment(U))}else this.backtrackFragment&&m.len&&(this.backtrackFragment=null);if(A&&this.isLoopLoading(A,L)){var $=A.gap;if(!$){var V=this.audioOnly&&!this.altAudio?Pe.AUDIO:Pe.VIDEO,M=(V===Pe.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;M&&this.afterBufferFlushed(M,V,Me.MAIN)}A=this.getNextFragmentLoopLoading(A,T,m,Me.MAIN,b)}A&&(A.initSegment&&!A.initSegment.data&&!this.bitrateTest&&(A=A.initSegment),this.loadFragment(A,d,L))}}}}},i.loadFragment=function(t,r,o){var u=this.fragmentTracker.getState(t);this.fragCurrent=t,u===gt.NOT_LOADED||u===gt.PARTIAL?t.sn==="initSegment"?this._loadInitSegment(t,r):this.bitrateTest?(this.log("Fragment "+t.sn+" of level "+t.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(t,r)):(this.startFragRequested=!0,s.prototype.loadFragment.call(this,t,r,o)):this.clearTrackerIfNeeded(t)},i.getBufferedFrag=function(t){return this.fragmentTracker.getBufferedFrag(t,Me.MAIN)},i.followingBufferedFrag=function(t){return t?this.getBufferedFrag(t.end+.5):null},i.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},i.nextLevelSwitch=function(){var t=this.levels,r=this.media;if(r!=null&&r.readyState){var o,u=this.getAppendedFrag(r.currentTime);u&&u.start>1&&this.flushMainBuffer(0,u.start-1);var h=this.getLevelDetails();if(h!=null&&h.live){var d=this.getMainFwdBufferInfo();if(!d||d.len<h.targetduration*2)return}if(!r.paused&&t){var m=this.hls.nextLoadLevel,p=t[m],y=this.fragLastKbps;y&&this.fragCurrent?o=this.fragCurrent.duration*p.maxBitrate/(1e3*y)+1:o=0}else o=0;var T=this.getBufferedFrag(r.currentTime+o);if(T){var x=this.followingBufferedFrag(T);if(x){this.abortCurrentFrag();var b=x.maxStartPTS?x.maxStartPTS:x.start,L=x.duration,A=Math.max(T.end,b+Math.min(Math.max(L-this.config.maxFragLookUpTolerance,L*(this.couldBacktrack?.5:.125)),L*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(A,Number.POSITIVE_INFINITY)}}}},i.abortCurrentFrag=function(){var t=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,t&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.state){case ne.KEY_LOADING:case ne.FRAG_LOADING:case ne.FRAG_LOADING_WAITING_RETRY:case ne.PARSING:case ne.PARSED:this.state=ne.IDLE;break}this.nextLoadPosition=this.getLoadPosition()},i.flushMainBuffer=function(t,r){s.prototype.flushMainBuffer.call(this,t,r,this.altAudio?"video":null)},i.onMediaAttached=function(t,r){s.prototype.onMediaAttached.call(this,t,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 Jl(this.config,o,this.fragmentTracker,this.hls)},i.onMediaDetaching=function(){var t=this.media;t&&this.onvplaying&&this.onvseeked&&(t.removeEventListener("playing",this.onvplaying),t.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),s.prototype.onMediaDetaching.call(this)},i.onMediaPlaying=function(){this.tick()},i.onMediaSeeked=function(){var t=this.media,r=t?t.currentTime:null;j(r)&&this.log("Media seeked to "+r.toFixed(3));var o=this.getMainFwdBufferInfo();if(o===null||o.len===0){this.warn('Main forward buffer length on "seeked" event '+(o?o.len:"empty")+")");return}this.tick()},i.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(R.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=this.fragLastKbps=0,this.levels=this.fragPlaying=this.backtrackFragment=this.levelLastLoaded=null,this.altAudio=this.audioOnly=this.startFragRequested=!1},i.onManifestParsed=function(t,r){var o=!1,u=!1;r.levels.forEach(function(h){var d=h.audioCodec;d&&(o=o||d.indexOf("mp4a.40.2")!==-1,u=u||d.indexOf("mp4a.40.5")!==-1)}),this.audioCodecSwitch=o&&u&&!ul(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=r.levels,this.startFragRequested=!1},i.onLevelLoading=function(t,r){var o=this.levels;if(!(!o||this.state!==ne.IDLE)){var u=o[r.level];(!u.details||u.details.live&&this.levelLastLoaded!==u||this.waitForCdnTuneIn(u.details))&&(this.state=ne.WAITING_LEVEL)}},i.onLevelLoaded=function(t,r){var o,u=this.levels,h=r.level,d=r.details,m=d.totalduration;if(!u){this.warn("Levels were reset while loading level "+h);return}this.log("Level "+h+" loaded ["+d.startSN+","+d.endSN+"]"+(d.lastPartSn?"[part-"+d.lastPartSn+"-"+d.lastPartIndex+"]":"")+", cc ["+d.startCC+", "+d.endCC+"] duration:"+m);var p=u[h],y=this.fragCurrent;y&&(this.state===ne.FRAG_LOADING||this.state===ne.FRAG_LOADING_WAITING_RETRY)&&y.level!==r.level&&y.loader&&this.abortCurrentFrag();var T=0;if(d.live||(o=p.details)!=null&&o.live){var x;if(this.checkLiveUpdate(d),d.deltaUpdateFailed)return;T=this.alignPlaylists(d,p.details,(x=this.levelLastLoaded)==null?void 0:x.details)}if(p.details=d,this.levelLastLoaded=p,this.hls.trigger(R.LEVEL_UPDATED,{details:d,level:h}),this.state===ne.WAITING_LEVEL){if(this.waitForCdnTuneIn(d))return;this.state=ne.IDLE}this.startFragRequested?d.live&&this.synchronizeToLiveEdge(d):this.setStartPosition(d,T),this.tick()},i._handleFragmentLoadProgress=function(t){var r,o=t.frag,u=t.part,h=t.payload,d=this.levels;if(!d){this.warn("Levels were reset while fragment load was in progress. Fragment "+o.sn+" of level "+o.level+" will not be buffered");return}var m=d[o.level],p=m.details;if(!p){this.warn("Dropping fragment "+o.sn+" of level "+o.level+" after level details were reset"),this.fragmentTracker.removeFragment(o);return}var y=m.videoCodec,T=p.PTSKnown||!p.live,x=(r=o.initSegment)==null?void 0:r.data,b=this._getAudioCodec(m),L=this.transmuxer=this.transmuxer||new ql(this.hls,Me.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),A=u?u.index:-1,D=A!==-1,w=new ya(o.level,o.sn,o.stats.chunkCount,h.byteLength,A,D),N=this.initPTS[o.cc];L.push(h,x,b,y,o,u,p.totalduration,T,w,N)},i.onAudioTrackSwitching=function(t,r){var o=this.altAudio,u=!!r.url;if(!u){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var h=this.fragCurrent;h&&(this.log("Switching to main audio track, cancel main fragment load"),h.abortRequests(),this.fragmentTracker.removeFragment(h)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var d=this.hls;o&&(d.trigger(R.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),d.trigger(R.AUDIO_TRACK_SWITCHED,r)}},i.onAudioTrackSwitched=function(t,r){var o=r.id,u=!!this.hls.audioTracks[o].url;if(u){var h=this.videoBuffer;h&&this.mediaBuffer!==h&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=h)}this.altAudio=u,this.tick()},i.onBufferCreated=function(t,r){var o=r.tracks,u,h,d=!1;for(var m in o){var p=o[m];if(p.id==="main"){if(h=m,u=p,m==="video"){var y=o[m];y&&(this.videoBuffer=y.buffer)}}else d=!0}d&&u?(this.log("Alternate track found, use "+h+".buffered to schedule main fragment loading"),this.mediaBuffer=u.buffer):this.mediaBuffer=this.media},i.onFragBuffered=function(t,r){var o=r.frag,u=r.part;if(!(o&&o.type!==Me.MAIN)){if(this.fragContextChanged(o)){this.warn("Fragment "+o.sn+(u?" p: "+u.index:"")+" of level "+o.level+" finished buffering, but was aborted. state: "+this.state),this.state===ne.PARSED&&(this.state=ne.IDLE);return}var h=u?u.stats:o.stats;this.fragLastKbps=Math.round(8*h.total/(h.buffering.end-h.loading.first)),o.sn!=="initSegment"&&(this.fragPrevious=o),this.fragBufferedComplete(o,u)}},i.onError=function(t,r){var o;if(r.fatal){this.state=ne.ERROR;return}switch(r.details){case G.FRAG_GAP:case G.FRAG_PARSING_ERROR:case G.FRAG_DECRYPT_ERROR:case G.FRAG_LOAD_ERROR:case G.FRAG_LOAD_TIMEOUT:case G.KEY_LOAD_ERROR:case G.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Me.MAIN,r);break;case G.LEVEL_LOAD_ERROR:case G.LEVEL_LOAD_TIMEOUT:case G.LEVEL_PARSING_ERROR:!r.levelRetry&&this.state===ne.WAITING_LEVEL&&((o=r.context)==null?void 0:o.type)===Oe.LEVEL&&(this.state=ne.IDLE);break;case G.BUFFER_APPEND_ERROR:case G.BUFFER_FULL_ERROR:if(!r.parent||r.parent!=="main")return;if(r.details===G.BUFFER_APPEND_ERROR){this.resetLoadingState();return}this.reduceLengthAndFlushBuffer(r)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case G.INTERNAL_EXCEPTION:this.recoverWorkerError(r);break}},i.checkBuffer=function(){var t=this.media,r=this.gapController;if(!(!t||!r||!t.readyState)){if(this.loadedmetadata||!rt.getBuffered(t).length){var o=this.state!==ne.IDLE?this.fragCurrent:null;r.poll(this.lastCurrentTime,o)}this.lastCurrentTime=t.currentTime}},i.onFragLoadEmergencyAborted=function(){this.state=ne.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},i.onBufferFlushed=function(t,r){var o=r.type;if(o!==Pe.AUDIO||this.audioOnly&&!this.altAudio){var u=(o===Pe.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(u,o,Me.MAIN),this.tick()}},i.onLevelsUpdated=function(t,r){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level),this.levels=r.levels},i.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},i.seekToStartPos=function(){var t=this.media;if(t){var r=t.currentTime,o=this.startPosition;if(o>=0&&r<o){if(t.seeking){this.log("could not seek to "+o+", already seeking at "+r);return}var u=rt.getBuffered(t),h=u.length?u.start(0):0,d=h-o;d>0&&(d<this.config.maxBufferHole||d<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+d+" to match buffer start"),o+=d,this.startPosition=o),this.log("seek to target start position "+o+" from current time "+r),t.currentTime=o}}},i._getAudioCodec=function(t){var r=this.config.defaultAudioCodec||t.audioCodec;return this.audioCodecSwap&&r&&(this.log("Swapping audio codec"),r.indexOf("mp4a.40.5")!==-1?r="mp4a.40.2":r="mp4a.40.5"),r},i._loadBitrateTestFrag=function(t,r){var o=this;t.bitrateTest=!0,this._doFragLoad(t,r).then(function(u){var h=o.hls;if(!(!u||o.fragContextChanged(t))){r.fragmentError=0,o.state=ne.IDLE,o.startFragRequested=!1,o.bitrateTest=!1;var d=t.stats;d.parsing.start=d.parsing.end=d.buffering.start=d.buffering.end=self.performance.now(),h.trigger(R.FRAG_LOADED,u),t.bitrateTest=!1}})},i._handleTransmuxComplete=function(t){var r,o="main",u=this.hls,h=t.remuxResult,d=t.chunkMeta,m=this.getCurrentContext(d);if(!m){this.resetWhenMissingContext(d);return}var p=m.frag,y=m.part,T=m.level,x=h.video,b=h.text,L=h.id3,A=h.initSegment,D=T.details,w=this.altAudio?void 0:h.audio;if(this.fragContextChanged(p)){this.fragmentTracker.removeFragment(p);return}if(this.state=ne.PARSING,A){if(A!=null&&A.tracks){var N=p.initSegment||p;this._bufferInitSegment(T,A.tracks,N,d),u.trigger(R.FRAG_PARSING_INIT_SEGMENT,{frag:N,id:o,tracks:A.tracks})}var U=A.initPTS,$=A.timescale;j(U)&&(this.initPTS[p.cc]={baseTime:U,timescale:$},u.trigger(R.INIT_PTS_FOUND,{frag:p,id:o,initPTS:U,timescale:$}))}if(x&&D&&p.sn!=="initSegment"){var V=D.fragments[p.sn-1-D.startSN],M=p.sn===D.startSN,K=!V||p.cc>V.cc;if(h.independent!==!1){var z=x.startPTS,te=x.endPTS,Z=x.startDTS,ie=x.endDTS;if(y)y.elementaryStreams[x.type]={startPTS:z,endPTS:te,startDTS:Z,endDTS:ie};else if(x.firstKeyFrame&&x.independent&&d.id===1&&!K&&(this.couldBacktrack=!0),x.dropped&&x.independent){var he=this.getMainFwdBufferInfo(),fe=(he?he.end:this.getLoadPosition())+this.config.maxBufferHole,Le=x.firstKeyFramePTS?x.firstKeyFramePTS:z;if(!M&&fe<Le-this.config.maxBufferHole&&!K){this.backtrack(p);return}else K&&(p.gap=!0);p.setElementaryStreamInfo(x.type,p.start,te,p.start,ie,!0)}else M&&z>ti&&(p.gap=!0);p.setElementaryStreamInfo(x.type,z,te,Z,ie),this.backtrackFragment&&(this.backtrackFragment=p),this.bufferFragmentData(x,p,y,d,M||K)}else if(M||K)p.gap=!0;else{this.backtrack(p);return}}if(w){var Ee=w.startPTS,we=w.endPTS,Ae=w.startDTS,ye=w.endDTS;y&&(y.elementaryStreams[Pe.AUDIO]={startPTS:Ee,endPTS:we,startDTS:Ae,endDTS:ye}),p.setElementaryStreamInfo(Pe.AUDIO,Ee,we,Ae,ye),this.bufferFragmentData(w,p,y,d)}if(D&&L!=null&&(r=L.samples)!=null&&r.length){var je={id:o,frag:p,details:D,samples:L.samples};u.trigger(R.FRAG_PARSING_METADATA,je)}if(D&&b){var Fe={id:o,frag:p,details:D,samples:b.samples};u.trigger(R.FRAG_PARSING_USERDATA,Fe)}},i._bufferInitSegment=function(t,r,o,u){var h=this;if(this.state===ne.PARSING){this.audioOnly=!!r.audio&&!r.video,this.altAudio&&!this.audioOnly&&delete r.audio;var d=r.audio,m=r.video,p=r.audiovideo;if(d){var y=t.audioCodec,T=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){y&&(y.indexOf("mp4a.40.5")!==-1?y="mp4a.40.2":y="mp4a.40.5");var x=d.metadata;x&&"channelCount"in x&&(x.channelCount||1)!==1&&T.indexOf("firefox")===-1&&(y="mp4a.40.5")}y&&y.indexOf("mp4a.40.5")!==-1&&T.indexOf("android")!==-1&&d.container!=="audio/mpeg"&&(y="mp4a.40.2",this.log("Android: force audio codec to "+y)),t.audioCodec&&t.audioCodec!==y&&this.log('Swapping manifest audio codec "'+t.audioCodec+'" for "'+y+'"'),d.levelCodec=y,d.id="main",this.log("Init audio buffer, container:"+d.container+", codecs[selected/level/parsed]=["+(y||"")+"/"+(t.audioCodec||"")+"/"+d.codec+"]")}m&&(m.levelCodec=t.videoCodec,m.id="main",this.log("Init video buffer, container:"+m.container+", codecs[level/parsed]=["+(t.videoCodec||"")+"/"+m.codec+"]")),p&&this.log("Init audiovideo buffer, container:"+p.container+", codecs[level/parsed]=["+t.codecs+"/"+p.codec+"]"),this.hls.trigger(R.BUFFER_CODECS,r),Object.keys(r).forEach(function(b){var L=r[b],A=L.initSegment;A!=null&&A.byteLength&&h.hls.trigger(R.BUFFER_APPENDING,{type:b,data:A,frag:o,part:null,chunkMeta:u,parent:o.type})}),this.tickImmediate()}},i.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,Me.MAIN)},i.backtrack=function(t){this.couldBacktrack=!0,this.backtrackFragment=t,this.resetTransmuxer(),this.flushBufferGap(t),this.fragmentTracker.removeFragment(t),this.fragPrevious=null,this.nextLoadPosition=t.start,this.state=ne.IDLE},i.checkFragmentChanged=function(){var t=this.media,r=null;if(t&&t.readyState>1&&t.seeking===!1){var o=t.currentTime;if(rt.isBuffered(t,o)?r=this.getAppendedFrag(o):rt.isBuffered(t,o+.1)&&(r=this.getAppendedFrag(o+.1)),r){this.backtrackFragment=null;var u=this.fragPlaying,h=r.level;(!u||r.sn!==u.sn||u.level!==h)&&(this.fragPlaying=r,this.hls.trigger(R.FRAG_CHANGED,{frag:r}),(!u||u.level!==h)&&this.hls.trigger(R.LEVEL_SWITCHED,{level:h}))}}},_(a,[{key:"nextLevel",get:function(){var t=this.nextBufferedFrag;return t?t.level:-1}},{key:"currentFrag",get:function(){var t=this.media;return t?this.fragPlaying||this.getAppendedFrag(t.currentTime):null}},{key:"currentProgramDateTime",get:function(){var t=this.media;if(t){var r=t.currentTime,o=this.currentFrag;if(o&&j(r)&&j(o.programDateTime)){var u=o.programDateTime+(r-o.start)*1e3;return new Date(u)}}return null}},{key:"currentLevel",get:function(){var t=this.currentFrag;return t?t.level:-1}},{key:"nextBufferedFrag",get:function(){var t=this.currentFrag;return t?this.followingBufferedFrag(t):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),a}(sl),Wa=function(){s.isMSESupported=function(){return Ta()},s.isSupported=function(){return ol()},s.getMediaSource=function(){return ar()};function s(i){i===void 0&&(i={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this.started=!1,this._emitter=new Hi,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,this.triggeringException=void 0,X(i.debug||!1,"Hls instance");var e=this.config=Hu(s.DefaultConfig,i);this.userConfig=i,e.progressive&&Ku(e);var t=e.abrController,r=e.bufferController,o=e.capLevelController,u=e.errorController,h=e.fpsController,d=new u(this),m=this.abrController=new t(this),p=this.bufferController=new r(this),y=this.capLevelController=new o(this),T=new h(this),x=new Ko(this),b=new Qo(this),L=e.contentSteeringController,A=L?new L(this):null,D=this.levelController=new Wu(this,A),w=new ju(this),N=new Yu(this.config),U=this.streamController=new ef(this,w,N);y.setStreamController(U),T.setStreamController(U);var $=[x,D,U];A&&$.splice(1,0,A),this.networkControllers=$;var V=[m,p,y,T,b,w];this.audioTrackController=this.createController(e.audioTrackController,$);var M=e.audioStreamController;M&&$.push(new M(this,w,N)),this.subtitleTrackController=this.createController(e.subtitleTrackController,$);var K=e.subtitleStreamController;K&&$.push(new K(this,w,N)),this.createController(e.timelineController,V),N.emeController=this.emeController=this.createController(e.emeController,V),this.cmcdController=this.createController(e.cmcdController,V),this.latencyController=this.createController(Jo,V),this.coreComponents=V,$.push(d);var z=d.onErrorOut;typeof z=="function"&&this.on(R.ERROR,z,d)}var a=s.prototype;return a.createController=function(e,t){if(e){var r=new e(this);return t&&t.push(r),r}return null},a.on=function(e,t,r){r===void 0&&(r=this),this._emitter.on(e,t,r)},a.once=function(e,t,r){r===void 0&&(r=this),this._emitter.once(e,t,r)},a.removeAllListeners=function(e){this._emitter.removeAllListeners(e)},a.off=function(e,t,r,o){r===void 0&&(r=this),this._emitter.off(e,t,r,o)},a.listeners=function(e){return this._emitter.listeners(e)},a.emit=function(e,t,r){return this._emitter.emit(e,t,r)},a.trigger=function(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(o){if(k.error("An internal error happened while handling event "+e+'. Error message: "'+o.message+'". Here is a stacktrace:',o),!this.triggeringException){this.triggeringException=!0;var r=e===R.ERROR;this.trigger(R.ERROR,{type:le.OTHER_ERROR,details:G.INTERNAL_EXCEPTION,fatal:r,event:e,error:o}),this.triggeringException=!1}}return!1},a.listenerCount=function(e){return this._emitter.listenerCount(e)},a.destroy=function(){k.log("destroy"),this.trigger(R.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(t){return t.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(t){return t.destroy()}),this.coreComponents.length=0;var e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null},a.attachMedia=function(e){k.log("attachMedia"),this._media=e,this.trigger(R.MEDIA_ATTACHING,{media:e})},a.detachMedia=function(){k.log("detachMedia"),this.trigger(R.MEDIA_DETACHING,void 0),this._media=null},a.loadSource=function(e){this.stopLoad();var t=this.media,r=this.url,o=this.url=oe.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,k.log("loadSource:"+o),t&&r&&(r!==o||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(R.MANIFEST_LOADING,{url:e})},a.startLoad=function(e){e===void 0&&(e=-1),k.log("startLoad("+e+")"),this.started=!0,this.networkControllers.forEach(function(t){t.startLoad(e)})},a.stopLoad=function(){k.log("stopLoad"),this.started=!1,this.networkControllers.forEach(function(e){e.stopLoad()})},a.resumeBuffering=function(){this.started&&this.networkControllers.forEach(function(e){"fragmentLoader"in e&&e.startLoad(-1)})},a.pauseBuffering=function(){this.networkControllers.forEach(function(e){"fragmentLoader"in e&&e.stopLoad()})},a.swapAudioCodec=function(){k.log("swapAudioCodec"),this.streamController.swapAudioCodec()},a.recoverMediaError=function(){k.log("recoverMediaError");var e=this._media;this.detachMedia(),e&&this.attachMedia(e)},a.removeLevel=function(e){this.levelController.removeLevel(e)},a.setAudioOption=function(e){var t;return(t=this.audioTrackController)==null?void 0:t.setAudioOption(e)},a.setSubtitleOption=function(e){var t;return(t=this.subtitleTrackController)==null||t.setSubtitleOption(e),null},_(s,[{key:"levels",get:function(){var e=this.levelController.levels;return e||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(e){k.log("set currentLevel:"+e),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){k.log("set nextLevel:"+e),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){k.log("set loadLevel:"+e),this.levelController.manualLevel=e}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(e){this.levelController.nextLoadLevel=e}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(e){k.log("set firstLevel:"+e),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){var e=this.levelController.startLevel;return e===-1&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e},set:function(e){k.log("set startLevel:"+e),e!==-1&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(e){var t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){this._autoLevelCapping!==e&&(k.log("set autoLevelCapping:"+e),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}},{key:"bandwidthEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimate():NaN},set:function(e){this.abrController.resetEstimator(e)}},{key:"ttfbEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimateTTFB():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(e){Zo(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var e=this.levels,t=this.config.minAutoBitrate;if(!e)return 0;for(var r=e.length,o=0;o<r;o++)if(e[o].maxBitrate>=t)return o;return 0}},{key:"maxAutoLevel",get:function(){var e=this.levels,t=this.autoLevelCapping,r=this.maxHdcpLevel,o;if(t===-1&&e!=null&&e.length?o=e.length-1:o=t,r)for(var u=o;u--;){var h=e[u].attrs["HDCP-LEVEL"];if(h&&h<=r)return u}return o}},{key:"firstAutoLevel",get:function(){return this.abrController.firstAutoLevel}},{key:"nextAutoLevel",get:function(){return this.abrController.nextAutoLevel},set:function(e){this.abrController.nextAutoLevel=e}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"allAudioTracks",get:function(){var e=this.audioTrackController;return e?e.allAudioTracks:[]}},{key:"audioTracks",get:function(){var e=this.audioTrackController;return e?e.audioTracks:[]}},{key:"audioTrack",get:function(){var e=this.audioTrackController;return e?e.audioTrack:-1},set:function(e){var t=this.audioTrackController;t&&(t.audioTrack=e)}},{key:"allSubtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}},{key:"subtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return e?e.subtitleDisplay:!1},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(e){this.config.lowLatencyMode=e}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.5.17"}},{key:"Events",get:function(){return R}},{key:"ErrorTypes",get:function(){return le}},{key:"ErrorDetails",get:function(){return G}},{key:"DefaultConfig",get:function(){return s.defaultConfig?s.defaultConfig:ca},set:function(e){s.defaultConfig=e}}]),s}();return Wa.defaultConfig=void 0,Wa})})(!1)});function Za(c,g){var n=Object.keys(c);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(c);g&&(l=l.filter(function(f){return Object.getOwnPropertyDescriptor(c,f).enumerable})),n.push.apply(n,l)}return n}function bt(c){for(var g=1;g<arguments.length;g++){var n=arguments[g]!=null?arguments[g]:{};g%2?Za(Object(n),!0).forEach(function(l){ce(c,l,n[l])}):Object.getOwnPropertyDescriptors?Object.defineProperties(c,Object.getOwnPropertyDescriptors(n)):Za(Object(n)).forEach(function(l){Object.defineProperty(c,l,Object.getOwnPropertyDescriptor(n,l))})}return c}function Re(){Re=function(){return c};var c={},g=Object.prototype,n=g.hasOwnProperty,l=Object.defineProperty||function(F,O,B){F[O]=B.value},f=typeof Symbol=="function"?Symbol:{},v=f.iterator||"@@iterator",E=f.asyncIterator||"@@asyncIterator",_=f.toStringTag||"@@toStringTag";function S(F,O,B){return Object.defineProperty(F,O,{value:B,enumerable:!0,configurable:!0,writable:!0}),F[O]}try{S({},"")}catch{S=function(O,B,re){return O[B]=re}}function C(F,O,B,re){var X=O&&O.prototype instanceof H?O:H,k=Object.create(X.prototype),ge=new le(re||[]);return l(k,"_invoke",{value:j(F,B,ge)}),k}function I(F,O,B){try{return{type:"normal",arg:F.call(O,B)}}catch(re){return{type:"throw",arg:re}}}c.wrap=C;var P={};function H(){}function W(){}function Y(){}var ee={};S(ee,v,function(){return this});var J=Object.getPrototypeOf,ae=J&&J(J(G([])));ae&&ae!==g&&n.call(ae,v)&&(ee=ae);var se=Y.prototype=H.prototype=Object.create(ee);function _e(F){["next","throw","return"].forEach(function(O){S(F,O,function(B){return this._invoke(O,B)})})}function oe(F,O){function B(X,k,ge,De){var pe=I(F[X],F,k);if(pe.type!=="throw"){var Ne=pe.arg,Qe=Ne.value;return Qe&&typeof Qe=="object"&&n.call(Qe,"__await")?O.resolve(Qe.__await).then(function(ke){B("next",ke,ge,De)},function(ke){B("throw",ke,ge,De)}):O.resolve(Qe).then(function(ke){Ne.value=ke,ge(Ne)},function(ke){return B("throw",ke,ge,De)})}De(pe.arg)}var re;l(this,"_invoke",{value:function(X,k){function ge(){return new O(function(De,pe){B(X,k,De,pe)})}return re=re?re.then(ge,ge):ge()}})}function j(F,O,B){var re="suspendedStart";return function(X,k){if(re==="executing")throw new Error("Generator is already running");if(re==="completed"){if(X==="throw")throw k;return He()}for(B.method=X,B.arg=k;;){var ge=B.delegate;if(ge){var De=ue(ge,B);if(De){if(De===P)continue;return De}}if(B.method==="next")B.sent=B._sent=B.arg;else if(B.method==="throw"){if(re==="suspendedStart")throw re="completed",B.arg;B.dispatchException(B.arg)}else B.method==="return"&&B.abrupt("return",B.arg);re="executing";var pe=I(F,O,B);if(pe.type==="normal"){if(re=B.done?"completed":"suspendedYield",pe.arg===P)continue;return{value:pe.arg,done:B.done}}pe.type==="throw"&&(re="completed",B.method="throw",B.arg=pe.arg)}}}function ue(F,O){var B=O.method,re=F.iterator[B];if(re===void 0)return O.delegate=null,B==="throw"&&F.iterator.return&&(O.method="return",O.arg=void 0,ue(F,O),O.method==="throw")||B!=="return"&&(O.method="throw",O.arg=new TypeError("The iterator does not provide a '"+B+"' method")),P;var X=I(re,F.iterator,O.arg);if(X.type==="throw")return O.method="throw",O.arg=X.arg,O.delegate=null,P;var k=X.arg;return k?k.done?(O[F.resultName]=k.value,O.next=F.nextLoc,O.method!=="return"&&(O.method="next",O.arg=void 0),O.delegate=null,P):k:(O.method="throw",O.arg=new TypeError("iterator result is not an object"),O.delegate=null,P)}function Ve(F){var O={tryLoc:F[0]};1 in F&&(O.catchLoc=F[1]),2 in F&&(O.finallyLoc=F[2],O.afterLoc=F[3]),this.tryEntries.push(O)}function R(F){var O=F.completion||{};O.type="normal",delete O.arg,F.completion=O}function le(F){this.tryEntries=[{tryLoc:"root"}],F.forEach(Ve,this),this.reset(!0)}function G(F){if(F){var O=F[v];if(O)return O.call(F);if(typeof F.next=="function")return F;if(!isNaN(F.length)){var B=-1,re=function X(){for(;++B<F.length;)if(n.call(F,B))return X.value=F[B],X.done=!1,X;return X.value=void 0,X.done=!0,X};return re.next=re}}return{next:He}}function He(){return{value:void 0,done:!0}}return W.prototype=Y,l(se,"constructor",{value:Y,configurable:!0}),l(Y,"constructor",{value:W,configurable:!0}),W.displayName=S(Y,_,"GeneratorFunction"),c.isGeneratorFunction=function(F){var O=typeof F=="function"&&F.constructor;return!!O&&(O===W||(O.displayName||O.name)==="GeneratorFunction")},c.mark=function(F){return Object.setPrototypeOf?Object.setPrototypeOf(F,Y):(F.__proto__=Y,S(F,_,"GeneratorFunction")),F.prototype=Object.create(se),F},c.awrap=function(F){return{__await:F}},_e(oe.prototype),S(oe.prototype,E,function(){return this}),c.AsyncIterator=oe,c.async=function(F,O,B,re,X){X===void 0&&(X=Promise);var k=new oe(C(F,O,B,re),X);return c.isGeneratorFunction(O)?k:k.next().then(function(ge){return ge.done?ge.value:k.next()})},_e(se),S(se,_,"Generator"),S(se,v,function(){return this}),S(se,"toString",function(){return"[object Generator]"}),c.keys=function(F){var O=Object(F),B=[];for(var re in O)B.push(re);return B.reverse(),function X(){for(;B.length;){var k=B.pop();if(k in O)return X.value=k,X.done=!1,X}return X.done=!0,X}},c.values=G,le.prototype={constructor:le,reset:function(F){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(R),!F)for(var O in this)O.charAt(0)==="t"&&n.call(this,O)&&!isNaN(+O.slice(1))&&(this[O]=void 0)},stop:function(){this.done=!0;var F=this.tryEntries[0].completion;if(F.type==="throw")throw F.arg;return this.rval},dispatchException:function(F){if(this.done)throw F;var O=this;function B(pe,Ne){return k.type="throw",k.arg=F,O.next=pe,Ne&&(O.method="next",O.arg=void 0),!!Ne}for(var re=this.tryEntries.length-1;re>=0;--re){var X=this.tryEntries[re],k=X.completion;if(X.tryLoc==="root")return B("end");if(X.tryLoc<=this.prev){var ge=n.call(X,"catchLoc"),De=n.call(X,"finallyLoc");if(ge&&De){if(this.prev<X.catchLoc)return B(X.catchLoc,!0);if(this.prev<X.finallyLoc)return B(X.finallyLoc)}else if(ge){if(this.prev<X.catchLoc)return B(X.catchLoc,!0)}else{if(!De)throw new Error("try statement without catch or finally");if(this.prev<X.finallyLoc)return B(X.finallyLoc)}}}},abrupt:function(F,O){for(var B=this.tryEntries.length-1;B>=0;--B){var re=this.tryEntries[B];if(re.tryLoc<=this.prev&&n.call(re,"finallyLoc")&&this.prev<re.finallyLoc){var X=re;break}}X&&(F==="break"||F==="continue")&&X.tryLoc<=O&&O<=X.finallyLoc&&(X=null);var k=X?X.completion:{};return k.type=F,k.arg=O,X?(this.method="next",this.next=X.finallyLoc,P):this.complete(k)},complete:function(F,O){if(F.type==="throw")throw F.arg;return F.type==="break"||F.type==="continue"?this.next=F.arg:F.type==="return"?(this.rval=this.arg=F.arg,this.method="return",this.next="end"):F.type==="normal"&&O&&(this.next=O),P},finish:function(F){for(var O=this.tryEntries.length-1;O>=0;--O){var B=this.tryEntries[O];if(B.finallyLoc===F)return this.complete(B.completion,B.afterLoc),R(B),P}},catch:function(F){for(var O=this.tryEntries.length-1;O>=0;--O){var B=this.tryEntries[O];if(B.tryLoc===F){var re=B.completion;if(re.type==="throw"){var X=re.arg;R(B)}return X}}throw new Error("illegal catch attempt")},delegateYield:function(F,O,B){return this.delegate={iterator:G(F),resultName:O,nextLoc:B},this.method==="next"&&(this.arg=void 0),P}},c}function es(c,g,n,l,f,v,E){try{var _=c[v](E),S=_.value}catch(C){n(C);return}_.done?g(S):Promise.resolve(S).then(l,f)}function it(c){return function(){var g=this,n=arguments;return new Promise(function(l,f){var v=c.apply(g,n);function E(S){es(v,l,f,E,_,"next",S)}function _(S){es(v,l,f,E,_,"throw",S)}E(void 0)})}}function yr(c,g){if(!(c instanceof g))throw new TypeError("Cannot call a class as a function")}function ts(c,g){for(var n=0;n<g.length;n++){var l=g[n];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(c,ns(l.key),l)}}function Er(c,g,n){return g&&ts(c.prototype,g),n&&ts(c,n),Object.defineProperty(c,"prototype",{writable:!1}),c}function ce(c,g,n){return g=ns(g),g in c?Object.defineProperty(c,g,{value:n,enumerable:!0,configurable:!0,writable:!0}):c[g]=n,c}function rs(c,g){if(typeof g!="function"&&g!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(g&&g.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),Object.defineProperty(c,"prototype",{writable:!1}),g&&Yi(c,g)}function ai(c){return ai=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},ai(c)}function Yi(c,g){return Yi=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(l,f){return l.__proto__=f,l},Yi(c,g)}function yf(){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 Ie(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function Ef(c,g){if(g&&(typeof g=="object"||typeof g=="function"))return g;if(g!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ie(c)}function is(c){var g=yf();return function(){var l=ai(c),f;if(g){var v=ai(this).constructor;f=Reflect.construct(l,arguments,v)}else f=l.apply(this,arguments);return Ef(this,f)}}function _f(c,g){if(typeof c!="object"||c===null)return c;var n=c[Symbol.toPrimitive];if(n!==void 0){var l=n.call(c,g||"default");if(typeof l!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return(g==="string"?String:Number)(c)}function ns(c){var g=_f(c,"string");return typeof g=="symbol"?g:String(g)}function ss(c,g){var n=Object.keys(c);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(c);g&&(l=l.filter(function(f){return Object.getOwnPropertyDescriptor(c,f).enumerable})),n.push.apply(n,l)}return n}function er(c){for(var g=1;g<arguments.length;g++){var n=arguments[g]!=null?arguments[g]:{};g%2?ss(Object(n),!0).forEach(function(l){q(c,l,n[l])}):Object.getOwnPropertyDescriptors?Object.defineProperties(c,Object.getOwnPropertyDescriptors(n)):ss(Object(n)).forEach(function(l){Object.defineProperty(c,l,Object.getOwnPropertyDescriptor(n,l))})}return c}function Ye(){Ye=function(){return c};var c={},g=Object.prototype,n=g.hasOwnProperty,l=Object.defineProperty||function(F,O,B){F[O]=B.value},f=typeof Symbol=="function"?Symbol:{},v=f.iterator||"@@iterator",E=f.asyncIterator||"@@asyncIterator",_=f.toStringTag||"@@toStringTag";function S(F,O,B){return Object.defineProperty(F,O,{value:B,enumerable:!0,configurable:!0,writable:!0}),F[O]}try{S({},"")}catch{S=function(O,B,re){return O[B]=re}}function C(F,O,B,re){var X=O&&O.prototype instanceof H?O:H,k=Object.create(X.prototype),ge=new le(re||[]);return l(k,"_invoke",{value:j(F,B,ge)}),k}function I(F,O,B){try{return{type:"normal",arg:F.call(O,B)}}catch(re){return{type:"throw",arg:re}}}c.wrap=C;var P={};function H(){}function W(){}function Y(){}var ee={};S(ee,v,function(){return this});var J=Object.getPrototypeOf,ae=J&&J(J(G([])));ae&&ae!==g&&n.call(ae,v)&&(ee=ae);var se=Y.prototype=H.prototype=Object.create(ee);function _e(F){["next","throw","return"].forEach(function(O){S(F,O,function(B){return this._invoke(O,B)})})}function oe(F,O){function B(X,k,ge,De){var pe=I(F[X],F,k);if(pe.type!=="throw"){var Ne=pe.arg,Qe=Ne.value;return Qe&&typeof Qe=="object"&&n.call(Qe,"__await")?O.resolve(Qe.__await).then(function(ke){B("next",ke,ge,De)},function(ke){B("throw",ke,ge,De)}):O.resolve(Qe).then(function(ke){Ne.value=ke,ge(Ne)},function(ke){return B("throw",ke,ge,De)})}De(pe.arg)}var re;l(this,"_invoke",{value:function(X,k){function ge(){return new O(function(De,pe){B(X,k,De,pe)})}return re=re?re.then(ge,ge):ge()}})}function j(F,O,B){var re="suspendedStart";return function(X,k){if(re==="executing")throw new Error("Generator is already running");if(re==="completed"){if(X==="throw")throw k;return He()}for(B.method=X,B.arg=k;;){var ge=B.delegate;if(ge){var De=ue(ge,B);if(De){if(De===P)continue;return De}}if(B.method==="next")B.sent=B._sent=B.arg;else if(B.method==="throw"){if(re==="suspendedStart")throw re="completed",B.arg;B.dispatchException(B.arg)}else B.method==="return"&&B.abrupt("return",B.arg);re="executing";var pe=I(F,O,B);if(pe.type==="normal"){if(re=B.done?"completed":"suspendedYield",pe.arg===P)continue;return{value:pe.arg,done:B.done}}pe.type==="throw"&&(re="completed",B.method="throw",B.arg=pe.arg)}}}function ue(F,O){var B=O.method,re=F.iterator[B];if(re===void 0)return O.delegate=null,B==="throw"&&F.iterator.return&&(O.method="return",O.arg=void 0,ue(F,O),O.method==="throw")||B!=="return"&&(O.method="throw",O.arg=new TypeError("The iterator does not provide a '"+B+"' method")),P;var X=I(re,F.iterator,O.arg);if(X.type==="throw")return O.method="throw",O.arg=X.arg,O.delegate=null,P;var k=X.arg;return k?k.done?(O[F.resultName]=k.value,O.next=F.nextLoc,O.method!=="return"&&(O.method="next",O.arg=void 0),O.delegate=null,P):k:(O.method="throw",O.arg=new TypeError("iterator result is not an object"),O.delegate=null,P)}function Ve(F){var O={tryLoc:F[0]};1 in F&&(O.catchLoc=F[1]),2 in F&&(O.finallyLoc=F[2],O.afterLoc=F[3]),this.tryEntries.push(O)}function R(F){var O=F.completion||{};O.type="normal",delete O.arg,F.completion=O}function le(F){this.tryEntries=[{tryLoc:"root"}],F.forEach(Ve,this),this.reset(!0)}function G(F){if(F){var O=F[v];if(O)return O.call(F);if(typeof F.next=="function")return F;if(!isNaN(F.length)){var B=-1,re=function X(){for(;++B<F.length;)if(n.call(F,B))return X.value=F[B],X.done=!1,X;return X.value=void 0,X.done=!0,X};return re.next=re}}return{next:He}}function He(){return{value:void 0,done:!0}}return W.prototype=Y,l(se,"constructor",{value:Y,configurable:!0}),l(Y,"constructor",{value:W,configurable:!0}),W.displayName=S(Y,_,"GeneratorFunction"),c.isGeneratorFunction=function(F){var O=typeof F=="function"&&F.constructor;return!!O&&(O===W||(O.displayName||O.name)==="GeneratorFunction")},c.mark=function(F){return Object.setPrototypeOf?Object.setPrototypeOf(F,Y):(F.__proto__=Y,S(F,_,"GeneratorFunction")),F.prototype=Object.create(se),F},c.awrap=function(F){return{__await:F}},_e(oe.prototype),S(oe.prototype,E,function(){return this}),c.AsyncIterator=oe,c.async=function(F,O,B,re,X){X===void 0&&(X=Promise);var k=new oe(C(F,O,B,re),X);return c.isGeneratorFunction(O)?k:k.next().then(function(ge){return ge.done?ge.value:k.next()})},_e(se),S(se,_,"Generator"),S(se,v,function(){return this}),S(se,"toString",function(){return"[object Generator]"}),c.keys=function(F){var O=Object(F),B=[];for(var re in O)B.push(re);return B.reverse(),function X(){for(;B.length;){var k=B.pop();if(k in O)return X.value=k,X.done=!1,X}return X.done=!0,X}},c.values=G,le.prototype={constructor:le,reset:function(F){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(R),!F)for(var O in this)O.charAt(0)==="t"&&n.call(this,O)&&!isNaN(+O.slice(1))&&(this[O]=void 0)},stop:function(){this.done=!0;var F=this.tryEntries[0].completion;if(F.type==="throw")throw F.arg;return this.rval},dispatchException:function(F){if(this.done)throw F;var O=this;function B(pe,Ne){return k.type="throw",k.arg=F,O.next=pe,Ne&&(O.method="next",O.arg=void 0),!!Ne}for(var re=this.tryEntries.length-1;re>=0;--re){var X=this.tryEntries[re],k=X.completion;if(X.tryLoc==="root")return B("end");if(X.tryLoc<=this.prev){var ge=n.call(X,"catchLoc"),De=n.call(X,"finallyLoc");if(ge&&De){if(this.prev<X.catchLoc)return B(X.catchLoc,!0);if(this.prev<X.finallyLoc)return B(X.finallyLoc)}else if(ge){if(this.prev<X.catchLoc)return B(X.catchLoc,!0)}else{if(!De)throw new Error("try statement without catch or finally");if(this.prev<X.finallyLoc)return B(X.finallyLoc)}}}},abrupt:function(F,O){for(var B=this.tryEntries.length-1;B>=0;--B){var re=this.tryEntries[B];if(re.tryLoc<=this.prev&&n.call(re,"finallyLoc")&&this.prev<re.finallyLoc){var X=re;break}}X&&(F==="break"||F==="continue")&&X.tryLoc<=O&&O<=X.finallyLoc&&(X=null);var k=X?X.completion:{};return k.type=F,k.arg=O,X?(this.method="next",this.next=X.finallyLoc,P):this.complete(k)},complete:function(F,O){if(F.type==="throw")throw F.arg;return F.type==="break"||F.type==="continue"?this.next=F.arg:F.type==="return"?(this.rval=this.arg=F.arg,this.method="return",this.next="end"):F.type==="normal"&&O&&(this.next=O),P},finish:function(F){for(var O=this.tryEntries.length-1;O>=0;--O){var B=this.tryEntries[O];if(B.finallyLoc===F)return this.complete(B.completion,B.afterLoc),R(B),P}},catch:function(F){for(var O=this.tryEntries.length-1;O>=0;--O){var B=this.tryEntries[O];if(B.tryLoc===F){var re=B.completion;if(re.type==="throw"){var X=re.arg;R(B)}return X}}throw new Error("illegal catch attempt")},delegateYield:function(F,O,B){return this.delegate={iterator:G(F),resultName:O,nextLoc:B},this.method==="next"&&(this.arg=void 0),P}},c}function Gt(c){"@babel/helpers - typeof";return Gt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(g){return typeof g}:function(g){return g&&typeof Symbol=="function"&&g.constructor===Symbol&&g!==Symbol.prototype?"symbol":typeof g},Gt(c)}function os(c,g,n,l,f,v,E){try{var _=c[v](E),S=_.value}catch(C){n(C);return}_.done?g(S):Promise.resolve(S).then(l,f)}function St(c){return function(){var g=this,n=arguments;return new Promise(function(l,f){var v=c.apply(g,n);function E(S){os(v,l,f,E,_,"next",S)}function _(S){os(v,l,f,E,_,"throw",S)}E(void 0)})}}function Be(c,g){if(!(c instanceof g))throw new TypeError("Cannot call a class as a function")}function us(c,g){for(var n=0;n<g.length;n++){var l=g[n];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(c,cs(l.key),l)}}function Ge(c,g,n){return g&&us(c.prototype,g),n&&us(c,n),Object.defineProperty(c,"prototype",{writable:!1}),c}function q(c,g,n){return g=cs(g),g in c?Object.defineProperty(c,g,{value:n,enumerable:!0,configurable:!0,writable:!0}):c[g]=n,c}function It(c,g){if(typeof g!="function"&&g!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(g&&g.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),Object.defineProperty(c,"prototype",{writable:!1}),g&&Cr(c,g)}function Zt(c){return Zt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Zt(c)}function Cr(c,g){return Cr=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(l,f){return l.__proto__=f,l},Cr(c,g)}function fs(){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 oi(c,g,n){return fs()?oi=Reflect.construct.bind():oi=function(f,v,E){var _=[null];_.push.apply(_,v);var S=Function.bind.apply(f,_),C=new S;return E&&Cr(C,E.prototype),C},oi.apply(null,arguments)}function xf(c){return Function.toString.call(c).indexOf("[native code]")!==-1}function ur(c){var g=typeof Map=="function"?new Map:void 0;return ur=function(l){if(l===null||!xf(l))return l;if(typeof l!="function")throw new TypeError("Super expression must either be null or a function");if(typeof g<"u"){if(g.has(l))return g.get(l);g.set(l,f)}function f(){return oi(l,arguments,Zt(this).constructor)}return f.prototype=Object.create(l.prototype,{constructor:{value:f,enumerable:!1,writable:!0,configurable:!0}}),Cr(f,l)},ur(c)}function bf(c,g){if(c==null)return{};var n={},l=Object.keys(c),f,v;for(v=0;v<l.length;v++)f=l[v],!(g.indexOf(f)>=0)&&(n[f]=c[f]);return n}function hs(c,g){if(c==null)return{};var n=bf(c,g),l,f;if(Object.getOwnPropertySymbols){var v=Object.getOwnPropertySymbols(c);for(f=0;f<v.length;f++)l=v[f],!(g.indexOf(l)>=0)&&Object.prototype.propertyIsEnumerable.call(c,l)&&(n[l]=c[l])}return n}function de(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function Lf(c,g){if(g&&(typeof g=="object"||typeof g=="function"))return g;if(g!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return de(c)}function Pt(c){var g=fs();return function(){var l=Zt(c),f;if(g){var v=Zt(this).constructor;f=Reflect.construct(l,arguments,v)}else f=l.apply(this,arguments);return Lf(this,f)}}function Af(c,g){for(;!Object.prototype.hasOwnProperty.call(c,g)&&(c=Zt(c),c!==null););return c}function Rr(){return typeof Reflect<"u"&&Reflect.get?Rr=Reflect.get.bind():Rr=function(g,n,l){var f=Af(g,n);if(f){var v=Object.getOwnPropertyDescriptor(f,n);return v.get?v.get.call(arguments.length<3?g:l):v.value}},Rr.apply(this,arguments)}function Rf(c,g){if(c){if(typeof c=="string")return ls(c,g);var n=Object.prototype.toString.call(c).slice(8,-1);if(n==="Object"&&c.constructor&&(n=c.constructor.name),n==="Map"||n==="Set")return Array.from(c);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ls(c,g)}}function ls(c,g){(g==null||g>c.length)&&(g=c.length);for(var n=0,l=new Array(g);n<g;n++)l[n]=c[n];return l}function ds(c,g){var n=typeof Symbol<"u"&&c[Symbol.iterator]||c["@@iterator"];if(!n){if(Array.isArray(c)||(n=Rf(c))||g&&c&&typeof c.length=="number"){n&&(c=n);var l=0,f=function(){};return{s:f,n:function(){return l>=c.length?{done:!0}:{done:!1,value:c[l++]}},e:function(S){throw S},f}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
15
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var v=!0,E=!1,_;return{s:function(){n=n.call(c)},n:function(){var S=n.next();return v=S.done,S},e:function(S){E=!0,_=S},f:function(){try{!v&&n.return!=null&&n.return()}finally{if(E)throw _}}}}function Cf(c,g){if(typeof c!="object"||c===null)return c;var n=c[Symbol.toPrimitive];if(n!==void 0){var l=n.call(c,g||"default");if(typeof l!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return(g==="string"?String:Number)(c)}function cs(c){var g=Cf(c,"string");return typeof g=="symbol"?g:String(g)}var tt=function(){function c(){Be(this,c)}return Ge(c,null,[{key:"start",value:function(n){return!n||!n.length||n.length===1&&n.end(0)-n.start(0)<1e-6||n.length===1&&n.start(0)<0?0:n.start(0)}},{key:"end",value:function(n){return!n||!n.length||n.length===1&&n.end(0)-n.start(0)<1e-6?0:n.end(n.length-1)}},{key:"get",value:function(n){if(n)try{return n.buffered}catch{}}},{key:"buffers",value:function(n,l){if(!n||!n.length)return[];for(var f=[],v=0,E=n.length;v<E;v++){var _=f.length;if(!_||!l)f.push([n.start(v),n.end(v)]);else{var S=f[_-1],C=S[1],I=n.start(v);if(I-C<=l){var P=n.end(v);P>C&&(S[1]=P)}else f.push([n.start(v),n.end(v)])}}return f}},{key:"totalLength",value:function(n){return!n||!n.length?0:n.reduce(function(l,f){return l+=f[1]-f[0]},0)}},{key:"info",value:function(n){var l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,f=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;if(!n||!n.length)return{start:0,end:0,buffers:[]};for(var v=0,E=0,_=0,S=0,C=0,I=0,P=0,H=c.buffers(n,f),W=0,Y=H.length;W<Y;W++){var ee=H[W];if(l+f>=ee[0]&&l<=ee[1])v=ee[0],E=ee[1],_=W;else if(l+f<ee[0]){S=ee[0],C=ee[1];break}else l+f>ee[1]&&(I=ee[0],P=ee[1])}return{start:v,end:E,index:_,buffers:H,nextStart:S,nextEnd:C,prevStart:I,prevEnd:P,currentTime:l,behind:l-v,remaining:E?E-l:0,length:c.totalLength&&c.totalLength(H)}}},{key:"isBuffered",value:function(n,l){if(n){var f=c.get(n);if(f!=null&&f.length){for(var v=0;v<f.length;v++)if(l>=f.start(v)&&l<=f.end(v))return!0}}return!1}}]),c}();var vs=typeof window<"u";var Et,Ce={MANIFEST:"manifest",NETWORK:"network",NETWORK_TIMEOUT:"network_timeout",NETWORK_FORBIDDEN:"network_forbidden",NETWORK_NOTFOUND:"network_notfound",NETWROK_RANGE_NOT_SATISFIABLE:"network_range_not_satisfiable",DEMUX:"demux",REMUX:"remux",MEDIA:"media",DRM:"drm",OTHER:"other",RUNTIME:"runtime",SUB_TYPES:{FLV:"FLV",HLS:"HLS",MP4:"MP4",FMP4:"FMP4",MSE_ADD_SB:"MSE_ADD_SB",MSE_APPEND_BUFFER:"MSE_APPEND_BUFFER",MSE_OTHER:"MSE_OTHER",MSE_FULL:"MSE_FULL",MSE_CHANGE_TYPE:"MSE_CHANGE_TYPE",OPTION:"OPTION",DASH:"DASH",LICENSE:"LICENSE",CUSTOM_LICENSE:"CUSTOM_LICENSE",MSE_HIJACK:"MSE_HIJACK",EME_HIJACK:"EME_HIJACK",SIDX:"SIDX",NO_CANPLAY_ERROR:"NO_CANPLAY_ERROR",BUFFERBREAK_ERROR:"BUFFERBREAK_ERROR",WAITING_TIMEOUT_ERROR:"WAITING_TIMEOUT_ERROR",MEDIA_ERR_ABORTED:"MEDIA_ERR_ABORTED",MEDIA_ERR_NETWORK:"MEDIA_ERR_NETWORK",MEDIA_ERR_DECODE:"MEDIA_ERR_DECODE",MEDIA_ERR_SRC_NOT_SUPPORTED:"MEDIA_ERR_SRC_NOT_SUPPORTED",MEDIA_ERR_CODEC_NOT_SUPPORTED:"MEDIA_ERR_CODEC_NOT_SUPPORTED",MEDIA_ERR_URL_EMPTY:"MEDIA_ERR_URL_EMPTY"}},ui=(Et={},q(Et,Ce.MANIFEST,{HLS:1100,DASH:1200}),q(Et,Ce.NETWORK,2100),q(Et,Ce.NETWORK_TIMEOUT,2101),q(Et,Ce.NETWORK_FORBIDDEN,2103),q(Et,Ce.NETWORK_NOTFOUND,2104),q(Et,Ce.NETWROK_RANGE_NOT_SATISFIABLE,2116),q(Et,Ce.DEMUX,{FLV:3100,HLS:3200,MP4:3300,FMP4:3400,SIDX:3410}),q(Et,Ce.REMUX,{FMP4:4100,MP4:4200}),q(Et,Ce.MEDIA,{MEDIA_ERR_ABORTED:5101,MEDIA_ERR_NETWORK:5102,MEDIA_ERR_DECODE:5103,MEDIA_ERR_SRC_NOT_SUPPORTED:5104,MEDIA_ERR_CODEC_NOT_SUPPORTED:5105,MEDIA_ERR_URL_EMPTY:5106,MSE_ADD_SB:5200,MSE_APPEND_BUFFER:5201,MSE_OTHER:5202,MSE_FULL:5203,MSE_HIJACK:5204,MSE_CHANGE_TYPE:5205,EME_HIJACK:5301}),q(Et,Ce.DRM,{LICENSE:7100,CUSTOM_LICENSE:7200}),q(Et,Ce.OTHER,8e3),q(Et,Ce.RUNTIME,{NO_CANPLAY_ERROR:9001,BUFFERBREAK_ERROR:9002,WAITING_TIMEOUT_ERROR:9003}),Et),dt=function(c){It(n,c);var g=Pt(n);function n(l,f,v,E,_){var S;return Be(this,n),S=g.call(this,_||v?.message),S.errorType=l===Ce.NETWORK_TIMEOUT?Ce.NETWORK:l,S.originError=v,S.ext=E,S.errorCode=ui[l][f]||ui[l],S.errorMessage=S.message,S.errorCode||(S.errorType=Ce.OTHER,S.errorCode=ui[S.errorType]),S}return Ge(n,null,[{key:"create",value:function(f,v,E,_,S){return f instanceof n?f:(f instanceof Error&&(E=f,f=""),f||(f=Ce.OTHER),new n(f,v,E,_,S))}},{key:"network",value:function(f){var v;return new n(f!=null&&f.isTimeout?Ce.NETWORK_TIMEOUT:Ce.NETWORK,null,f instanceof Error?f:null,{url:f?.url,response:f?.response,httpCode:f==null||(v=f.response)===null||v===void 0?void 0:v.status})}}]),n}(ur(Error));var wr={DEBUG:1,LOG:2,WARN:3,ERROR:4},Df=200*1024,wf=["Boolean","Number","String","Undefined","Null","Date","Object"],Tt=function(){function c(g,n){Be(this,c),this.name=g||"",this._prefix="[".concat(this.name,"]"),this.logCacheLevel=n?.logCacheLevel||3,this.logMaxSize=n?.logMaxSize||Df,this.logSize=0,this.logTextArray=[]}return Ge(c,[{key:"debug",value:function(){for(var n,l=arguments.length,f=new Array(l),v=0;v<l;v++)f[v]=arguments[v];this.logCache.apply(this,[wr.DEBUG].concat(f)),!c.disabled&&(n=console).debug.apply(n,["[".concat(Dr(),"]"),this._prefix].concat(f))}},{key:"log",value:function(){for(var n,l=arguments.length,f=new Array(l),v=0;v<l;v++)f[v]=arguments[v];this.logCache.apply(this,[wr.LOG].concat(f)),!c.disabled&&(n=console).log.apply(n,["[".concat(Dr(),"]"),this._prefix].concat(f))}},{key:"warn",value:function(){for(var n,l=arguments.length,f=new Array(l),v=0;v<l;v++)f[v]=arguments[v];this.logCache.apply(this,[wr.WARN].concat(f)),!c.disabled&&(n=console).warn.apply(n,["[".concat(Dr(),"]"),this._prefix].concat(f))}},{key:"error",value:function(){for(var n,l=arguments.length,f=new Array(l),v=0;v<l;v++)f[v]=arguments[v];this.logCache.apply(this,[wr.ERROR].concat(f)),!c.disabled&&(n=console).error.apply(n,["[".concat(Dr(),"]"),this._prefix].concat(f))}},{key:"logCache",value:function(n){if(!(n<this.logCacheLevel)){var l="";try{for(var f=arguments.length,v=new Array(f>1?f-1:0),E=1;E<f;E++)v[E-1]=arguments[E];var _=v.map(function(C){return ps(C)});l="[".concat(Dr(),"]")+this._prefix+JSON.stringify(_)}catch{return}if(n>=this.logCacheLevel&&(this.logSize+=l.length,this.logTextArray.push(l)),this.logSize>this.logMaxSize){var S=this.logTextArray.shift();this.logSize-=S.length}}}},{key:"getLogCache",value:function(){var n=this.logTextArray.join(`
16
+ `);return this.reset(),n}},{key:"reset",value:function(){this.logTextArray=[],this.logSize=0}},{key:"table",value:function(){var n;c.disabled||(console.group(this._prefix),(n=console).table.apply(n,arguments),console.groupEnd())}},{key:"setLogLevel",value:function(n){this.logCacheLevel=n}}],[{key:"enable",value:function(){c.disabled=!1}},{key:"disable",value:function(){c.disabled=!0}}]),c}();q(Tt,"disabled",!0);function Dr(){return new Date().toLocaleString()}function If(c){if(Gt(c)!=="object")return c;var g=Object.prototype.toString.call(c).slice(8,-1);switch(g){case"Array":case"Uint8Array":case"ArrayBuffer":return g+"["+c.length+"]";case"Object":return"{}";default:return g}}function ps(c,g,n){n||(n=1),g||(g=2);var l={};if(!c||Gt(c)!=="object")return c;var f=Object.prototype.toString.call(c).slice(8,-1);if(!wf.includes(f))return f;if(!(n>g)){for(var v in c)Object.prototype.hasOwnProperty.call(c,v)&&(n===g?l[v]=If(c[v]):Gt(c[v])==="object"?l[v]=ps(c[v],g,n+1):l[v]=c[v]);return l}}function tr(){var c,g,n=new Promise(function(l,f){c=l,g=f});return n.used=!1,n.resolve=function(){return n.used=!0,c.apply(void 0,arguments)},n.reject=function(){return n.used=!0,g.apply(void 0,arguments)},n}function lr(){try{return parseInt(performance.now(),10)}catch{return new Date().getTime()}}var ms={stringify:function(g){try{return JSON.stringify(g)}catch{return""}},parse:function(g){try{return JSON.parse(g)}catch{return}}};function gs(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;try{return vs?c&&typeof ManagedMediaSource<"u"?ManagedMediaSource:window.MediaSource:null}catch{}}function Xi(c){return/ManagedMediaSource/gi.test(Object.prototype.toString.call(c))}function Pf(c){var g=[];if(c instanceof TimeRanges)for(var n=0;n<c.length;n++)g.push({start:c.start(n),end:c.end(n)});return g}var li={APPEND:"appendBuffer",REMOVE:"removeBuffer",UPDATE_DURATION:"updateDuration"};var rr=function(){function c(g,n){var l=this;Be(this,c),q(this,"media",null),q(this,"mediaSource",null),q(this,"_openPromise",tr()),q(this,"_queue",Object.create(null)),q(this,"_sourceBuffer",Object.create(null)),q(this,"_mseFullFlag",{}),q(this,"_st",0),q(this,"_opst",0),q(this,"_logger",null),q(this,"_config",null),q(this,"_url",null),q(this,"_onStartStreaming",function(){l._logger.debug("startstreaming")}),q(this,"_onEndStreaming",function(){l._logger.debug("endstreaming")}),q(this,"_onSBUpdateEnd",function(f){var v=l._queue[f];if(v){var E=v[0];if(E?.opName!==li.UPDATE_DURATION&&v.shift(),E){var _,S,C=lr()-l._opst;l._logger.debug("UpdateEnd(".concat(f,"/").concat(E.opName,")"),ms.stringify(Pf((_=l._sourceBuffer[f])===null||_===void 0?void 0:_.buffered)),C,E.context),E.promise.resolve({name:E.opName,context:E.context,costtime:C});var I=(S=E.context)===null||S===void 0?void 0:S.callback;I&&typeof I=="function"&&I(E.context),l._startQueue(f)}}}),q(this,"_onSBUpdateError",function(f,v){var E=l._queue[f];if(E){var _=E[0];_&&(l._logger.error("UpdateError",f,_.opName,_.context),_.promise.reject(new dt(Ce.MEDIA,Ce.SUB_TYPES.MSE_APPEND_BUFFER,v)))}}),this._config=Object.assign(c.getDefaultConfig(),n),g&&this.bindMedia(g),this._logger=new Tt("MSE"),this._config.openLog&&Tt.enable()}return Ge(c,[{key:"isOpened",get:function(){var n;return((n=this.mediaSource)===null||n===void 0?void 0:n.readyState)==="open"}},{key:"hasOpTasks",get:function(){var n=this,l=!1;return Object.keys(this._queue).forEach(function(f){var v=n._queue[f];Array.isArray(v)&&(l||(l=v.length>0))}),l}},{key:"url",get:function(){return this._url}},{key:"duration",get:function(){var n;return((n=this.mediaSource)===null||n===void 0?void 0:n.duration)||-1}},{key:"isEnded",get:function(){return this.mediaSource?this.mediaSource.readyState==="ended":!1}},{key:"streaming",get:function(){return Xi(this.mediaSource)?this.mediaSource.streaming:!0}},{key:"isFull",value:function(n){return n?this._mseFullFlag[n]:this._mseFullFlag[c.VIDEO]}},{key:"updateDuration",value:function(n){var l=this,f=this.mediaSource&&this.mediaSource.duration>n;if(this.mediaSource&&this.mediaSource.duration>n){var v=0;if(Object.keys(this._sourceBuffer).forEach(function(E){try{v=Math.max(l.bufferEnd(E)||0,v)}catch{}}),n<v)return Promise.resolve()}return this._enqueueBlockingOp(function(){if(l.isEnded){l._logger.debug("setDuration but ended");return}l.mediaSource&&(l.mediaSource.duration=n,l._logger.debug("setDuration",n))},li.UPDATE_DURATION,{isReduceDuration:f})}},{key:"open",value:function(){var n=this;if(this._openPromise.used&&!this.isOpened&&this.mediaSource){var l=this.mediaSource,f=function v(){var E=lr()-n._st;n._logger.debug("sourceopen",E),l.removeEventListener("sourceopen",v),n._openPromise.resolve({costtime:E})};l.addEventListener("sourceopen",f),this._openPromise=tr()}return this._openPromise}},{key:"bindMedia",value:function(){var g=St(Ye().mark(function l(f){var v=this,E,_,S,C;return Ye().wrap(function(P){for(;;)switch(P.prev=P.next){case 0:if(!(this.mediaSource||this.media)){P.next=3;break}return P.next=3,this.unbindMedia();case 3:if(E=gs(this._config.preferMMS),!(!f||!E)){P.next=6;break}throw new Error("Param media or MediaSource does not exist");case 6:return this.media=f,_=this.mediaSource=new E,S=Xi(_),this._st=lr(),C=function H(){var W=lr()-v._st;v._logger.debug("sourceopen"),_.removeEventListener("sourceopen",H),URL.revokeObjectURL(f.src),v._openPromise.resolve({costtime:W})},_.addEventListener("sourceopen",C),S&&(_.addEventListener("startstreaming",this._onStartStreaming),_.addEventListener("endstreaming",this._onEndStreaming)),this._url=URL.createObjectURL(_),f.src=this._url,f.disableRemotePlayback=S,P.abrupt("return",this._openPromise);case 17:case"end":return P.stop()}},l,this)}));function n(l){return g.apply(this,arguments)}return n}()},{key:"unbindMedia",value:function(){var g=St(Ye().mark(function l(){var f=this,v,E,_;return Ye().wrap(function(C){for(;;)switch(C.prev=C.next){case 0:if(this._openPromise.used||this._openPromise.resolve(),v=this.mediaSource,v){if(Object.keys(this._queue).forEach(function(I){var P=f._queue[I];P&&P.forEach(function(H){var W,Y;return(W=H.promise)===null||W===void 0||(Y=W.resolve)===null||Y===void 0?void 0:Y.call(W)})}),E=!!this.media&&this.media.readyState>=1,_=v.readyState==="open",E&&_)try{v.endOfStream()}catch{}Object.keys(this._sourceBuffer).forEach(function(I){try{v.removeSourceBuffer(f._sourceBuffer[I])}catch{}}),Xi(v)&&(v.removeEventListener("startstreaming",this._onStartStreaming),v.removeEventListener("endstreaming",this._onEndStreaming))}if(this.media){this.media.disableRemotePlayback=!1,this.media.removeAttribute("src");try{this.media.load()}catch{}this.media=null}this.mediaSource=null,this._openPromise=tr(),this._queue=Object.create(null),this._sourceBuffer=Object.create(null);case 8:case"end":return C.stop()}},l,this)}));function n(){return g.apply(this,arguments)}return n}()},{key:"createSource",value:function(n,l){if(!(this._sourceBuffer[n]||!this.mediaSource)){var f;try{f=this._sourceBuffer[n]=this.mediaSource.addSourceBuffer(l)}catch(v){throw new dt(Ce.MEDIA,Ce.SUB_TYPES.MSE_ADD_SB,v)}f.mimeType=l,f.addEventListener("updateend",this._onSBUpdateEnd.bind(this,n)),f.addEventListener("error",this._onSBUpdateError.bind(this,n))}}},{key:"changeType",value:function(n,l){var f=this,v=this._sourceBuffer[n];return!this.mediaSource||!v||v.mimeType===l?Promise.resolve():typeof v.changeType!="function"?Promise.reject(new dt(Ce.MEDIA,Ce.SUB_TYPES.MSE_CHANGE_TYPE,new Error("changeType is not a function"))):this._enqueueOp(n,function(){try{v.changeType(l)}catch(E){throw new dt(Ce.MEDIA,Ce.SUB_TYPES.MSE_CHANGE_TYPE,E)}v.mimeType=l,f._onSBUpdateEnd(n)},"changeType",{mimeType:l})}},{key:"createOrChangeSource",value:function(n,l){return this.createSource(n,l),this.changeType(n,l)}},{key:"append",value:function(n,l,f){var v=this;return!l||!l.byteLength||!this._sourceBuffer[n]?Promise.resolve():this._enqueueOp(n,function(){var E;!v.mediaSource||v.media.error||(v._logger.debug("MSE APPEND START",f),v._opst=lr(),(E=v._sourceBuffer[n])===null||E===void 0||E.appendBuffer(l))},li.APPEND,f)}},{key:"remove",value:function(n,l,f,v){var E=this,_=!1;return this._mseFullFlag[n]&&(_=!0),this._enqueueOp(n,function(){if(!(!E.mediaSource||E.media.error)){var S=E._sourceBuffer[n];if(l>=f||!S){E._onSBUpdateEnd(n);return}E._opst=lr(),E._logger.debug("MSE REMOVE START",n,l,f,v),S.remove(l,f)}},li.REMOVE,v,_)}},{key:"clearBuffer",value:function(n,l){var f=this,v;return Object.keys(this._sourceBuffer).forEach(function(E){v=f.remove(E,n,l)}),v||Promise.resolve()}},{key:"clearAllBuffer",value:function(){var n=this,l;return Object.keys(this._sourceBuffer).forEach(function(f){var v=n._sourceBuffer[f];l=n.remove(f,0,tt.end(tt.get(v)))}),l}},{key:"clearOpQueues",value:function(n,l){var f;this._logger.debug("MSE clearOpQueue START");var v=this._queue[n];if(l&&v){this._queue[n]=[];return}if(!(!v||!v[n]||v.length<5)){var E=[];v.forEach(function(_){_.context&&_.context.isinit&&E.push(_)}),this._queue[n]=v.slice(0,2),E.length>0&&(f=this._queue[n]).push.apply(f,E)}}},{key:"endOfStream",value:function(n){var l=this;return!this.mediaSource||this.mediaSource.readyState!=="open"?Promise.resolve():this._enqueueBlockingOp(function(){var f=l.mediaSource;!f||f.readyState!=="open"||(l._logger.debug("MSE endOfStream START"),n?f.endOfStream(n):f.endOfStream())},"endOfStream")}},{key:"setLiveSeekableRange",value:function(n,l){var f=this.mediaSource;n<0||l<n||!(f!=null&&f.setLiveSeekableRange)||f.readyState!=="open"||f.setLiveSeekableRange(n,l)}},{key:"getSourceBuffer",value:function(n){return this._sourceBuffer[n]}},{key:"buffered",value:function(n){return tt.get(this._sourceBuffer[n])}},{key:"bufferStart",value:function(n){return tt.start(this.buffered(n))}},{key:"bufferEnd",value:function(n){return tt.end(this.buffered(n))}},{key:"_enqueueOp",value:function(n,l,f,v,E){var _=this;if(!this.mediaSource)return Promise.resolve();var S=this._queue[n]=this._queue[n]||[],C={exec:l,promise:tr(),opName:f,context:v};return E?(S.splice(0,0,C),this._mseFullFlag[n]=!1,this._startQueue(n)):S.push(C),this.isOpened||this.isEnded?S.length===1&&this._startQueue(n):this._openPromise.then(function(){S.length===1&&_._startQueue(n)}),C.promise}},{key:"_enqueueBlockingOp",value:function(){var g=St(Ye().mark(function l(f,v,E){var _=this,S,C;return Ye().wrap(function(P){for(;;)switch(P.prev=P.next){case 0:if(this.mediaSource){P.next=2;break}return P.abrupt("return",Promise.resolve());case 2:if(S=Object.keys(this._sourceBuffer),S.length){P.next=5;break}return P.abrupt("return",f());case 5:return C=[],S.forEach(function(H){var W=_._queue[H],Y=tr();C.push(Y),W.push({exec:function(){Y.resolve()},promise:Y,opName:v,context:E}),W.length===1&&_._startQueue(H)}),P.abrupt("return",Promise.all(C).then(function(){try{return f()}finally{S.forEach(function(H){var W=_._queue[H],Y=_._sourceBuffer[H];W?.shift(),(!Y||!Y.updating)&&_._startQueue(H)})}}));case 8:case"end":return P.stop()}},l,this)}));function n(l,f,v){return g.apply(this,arguments)}return n}()},{key:"_startQueue",value:function(n){var l=this._queue[n];if(l){var f=l[0];if(f&&!this._mseFullFlag[n])try{f.exec()}catch(v){v&&v.message&&v.message.indexOf("SourceBuffer is full")>=0?(this._mseFullFlag[n]=!0,f.context&&Gt(f.context)==="object"&&(f.context.isFull=!0),this._logger.error("[MSE error], context,",f.context," ,name,",f.opName,",err,SourceBuffer is full"),f.promise.reject(new dt(Ce.MEDIA,Ce.SUB_TYPES.MSE_FULL,v))):(this._logger.error(v),f.promise.reject(v.constructor===dt?v:new dt(Ce.MEDIA,Ce.SUB_TYPES.MSE_OTHER,v)),l.shift(),this._startQueue(n))}}}},{key:"setTimeoffset",value:function(n,l,f){var v=this;return this._enqueueOp(n,function(){l<0&&(l+=.001),v._sourceBuffer[n].timestampOffset=l,v._onSBUpdateEnd(n)},"setTimeoffset",f)}},{key:"abort",value:function(n,l){var f=this;return this.isOpened?this._enqueueOp(n,function(){f._sourceBuffer[n].abort(),f._onSBUpdateEnd(n)},"abort",l):Promise.resolve()}}],[{key:"isSupported",value:function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:'video/mp4; codecs="avc1.42E01E,mp4a.40.2"',l=gs();if(!l)return!1;try{return l.isTypeSupported(n)}catch(f){return this._logger.error(n,f),!1}}},{key:"isMMSOnly",value:function(){return typeof ManagedMediaSource<"u"&&typeof MediaSource>"u"}},{key:"getDefaultConfig",value:function(){return{openLog:!1,preferMMS:!1}}}]),c}();q(rr,"VIDEO","video");q(rr,"AUDIO","audio");var kt={FETCH:"fetch",XHR:"xhr"},ir={ARRAY_BUFFER:"arraybuffer",TEXT:"text",JSON:"json"};var Lt=function(c){It(n,c);var g=Pt(n);function n(l,f,v,E){var _;return Be(this,n),_=g.call(this,E),q(de(_),"retryCount",0),q(de(_),"isTimeout",!1),q(de(_),"loaderType",kt.FETCH),q(de(_),"startTime",0),q(de(_),"endTime",0),q(de(_),"options",{}),_.url=l,_.request=f,_.response=v,_}return Ge(n)}(ur(Error));var ys=Object.prototype.toString;function Es(c){return c!==null&&Gt(c)==="object"}function $i(c){if(ys.call(c)!=="[object Object]")return!1;var g=Object.getPrototypeOf(c);return g===null||g===Object.prototype}function _s(c){return ys.call(c)==="[object Date]"}function fi(c){if(!(!c||c[0]===null||c[0]===void 0||c[0]===0&&(c[1]===null||c[1]===void 0))){var g="bytes="+c[0]+"-";return c[1]&&(g+=c[1]),g}}function Ss(c){return encodeURIComponent(c).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function hi(c,g){if(c){if(!g)return c;var n,l=Object.keys(g).map(function(v){if(n=g[v],n!=null)return Array.isArray(n)?v=v+"[]":n=[n],n.map(function(E){return _s(E)?E=E.toISOString():Es(E)&&(E=JSON.stringify(E)),"".concat(Ss(v),"=").concat(Ss(E))}).join("&")}).filter(Boolean).join("&");if(l){var f=c.indexOf("#");f!==-1&&(c=c.slice(0,f)),c+=(c.indexOf("?")===-1?"?":"&")+l}return c}}function Ir(c,g,n,l,f,v,E,_,S,C,I){f=f!=null?parseFloat(f):null,l=parseInt(l||"0",10),Number.isNaN(l)&&(l=0);var P={range:S,vid:C,index:_,contentLength:l,age:f,startTime:v,firstByteTime:E,endTime:Date.now(),priOptions:I};return{data:c,done:g,options:P,response:n}}function Pr(c,g){return Math.round(c*8*1e3/g/1024)}var me={ERROR:"error",TTFB:"core.ttfb",LOAD_START:"core.loadstart",LOAD_RESPONSE_HEADERS:"core.loadresponseheaders",LOAD_COMPLETE:"core.loadcomplete",LOAD_RETRY:"core.loadretry",SOURCEBUFFER_CREATED:"core.sourcebuffercreated",MEDIASOURCE_OPENED:"core.mediasourceopened",ANALYZE_DURATION_EXCEEDED:"core.analyzedurationexceeded",APPEND_BUFFER:"core.appendbuffer",REMOVE_BUFFER:"core.removebuffer",BUFFEREOS:"core.buffereos",KEYFRAME:"core.keyframe",CHASEFRAME:"core.chaseframe",METADATA_PARSED:"core.metadataparsed",SEI:"core.sei",SEI_IN_TIME:"core.seiintime",FLV_SCRIPT_DATA:"core.flvscriptdata",LOWDECODE:"core.lowdecode",SWITCH_URL_SUCCESS:"core.switchurlsuccess",SWITCH_URL_FAILED:"core.switchurlfailed",SPEED:"core.speed",HLS_MANIFEST_LOADED:"core.hlsmanifestloaded",HLS_LEVEL_LOADED:"core.hlslevelloaded",DEMUXED_TRACK:"core.demuxedtrack",STREAM_EXCEPTION:"core.streamexception",LARGE_AV_FIRST_FRAME_GAP_DETECT:"LARGE_AV_FIRST_FRAME_GAP_DETECT",LARGE_VIDEO_DTS_GAP_DETECT:"LARGE_VIDEO_DTS_GAP_DETECT",LARGE_AUDIO_DTS_GAP_DETECT:"LARGE_AUDIO_DTS_GAP_DETECT",AUDIO_GAP_DETECT:"AUDIO_GAP_DETECT",AUDIO_OVERLAP_DETECT:"AUDIO_OVERLAP_DETECT",MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT:"MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT",REAL_TIME_SPEED:"real_time_speed"};var xs=gr(_r()),Ts=2*1024*1024,kr=function(c){It(n,c);var g=Pt(n);function n(){var l;return Be(this,n),l=g.call(this),q(de(l),"_abortController",null),q(de(l),"_timeoutTimer",null),q(de(l),"_reader",null),q(de(l),"_response",null),q(de(l),"_aborted",!1),q(de(l),"_index",-1),q(de(l),"_range",null),q(de(l),"_receivedLength",0),q(de(l),"_running",!1),q(de(l),"_logger",null),q(de(l),"_vid",""),q(de(l),"_onProcessMinLen",0),q(de(l),"_onCancel",null),q(de(l),"_priOptions",null),l}return Ge(n,[{key:"load",value:function(f){var v,E=this,_=f.url,S=f.vid,C=f.timeout,I=f.responseType,P=f.onProgress,H=f.index,W=f.onTimeout,Y=f.onCancel,ee=f.range,J=f.transformResponse,ae=f.request,se=f.params,_e=f.logger,oe=f.method,j=f.headers,ue=f.body,Ve=f.mode,R=f.credentials,le=f.cache,G=f.redirect,He=f.referrer,F=f.referrerPolicy,O=f.onProcessMinLen,B=f.priOptions;this._logger=_e,this._aborted=!1,this._onProcessMinLen=O,this._onCancel=Y,this._abortController=typeof AbortController<"u"&&new AbortController,this._running=!0,this._index=H,this._range=ee||[0,0],this._vid=S||_,this._priOptions=B||{};var re={method:oe,headers:j,body:ue,mode:Ve,credentials:R,cache:le,redirect:G,referrer:He,referrerPolicy:F,signal:(v=this._abortController)===null||v===void 0?void 0:v.signal},X=!1;clearTimeout(this._timeoutTimer),_=hi(_,se);var k=fi(ee);k&&(ae?j=ae.headers:j=re.headers=re.headers||(Headers?new Headers:{}),Headers&&j instanceof Headers?j.append("Range",k):j.Range=k),C&&(this._timeoutTimer=setTimeout(function(){if(X=!0,E.cancel(),W){var De=new Lt(_,re,null,"timeout");De.isTimeout=!0,W(De,{index:E._index,range:E._range,vid:E._vid,priOptions:E._priOptions})}},C));var ge=Date.now();return this._logger.debug("[fetch load start], index,",H,",range,",ee),new Promise(function(De,pe){fetch(ae||_,ae?void 0:re).then(function(){var Ne=St(Ye().mark(function Qe(ke){var $t,Pe,hr,dr;return Ye().wrap(function(Je){for(;;)switch(Je.prev=Je.next){case 0:if(clearTimeout(E._timeoutTimer),E._response=ke,!(E._aborted||!E._running)){Je.next=4;break}return Je.abrupt("return");case 4:if(J&&(ke=J(ke,_)||ke),ke.ok){Je.next=7;break}throw new Lt(_,re,ke,"bad network response");case 7:if($t=Date.now(),I!==ir.TEXT){Je.next=15;break}return Je.next=11,ke.text();case 11:Pe=Je.sent,E._running=!1,Je.next=37;break;case 15:if(I!==ir.JSON){Je.next=22;break}return Je.next=18,ke.json();case 18:Pe=Je.sent,E._running=!1,Je.next=37;break;case 22:if(!P){Je.next=29;break}return E.resolve=De,E.reject=pe,E._loadChunk(ke,P,ge,$t),Je.abrupt("return");case 29:return Je.next=31,ke.arrayBuffer();case 31:Pe=Je.sent,Pe=new Uint8Array(Pe),E._running=!1,hr=Date.now()-ge,dr=Pr(Pe.byteLength,hr),E.emit(me.REAL_TIME_SPEED,{speed:dr,len:Pe.byteLength,time:hr,vid:E._vid,index:E._index,range:E._range,priOptions:E._priOptions});case 37:E._logger.debug("[fetch load end], index,",H,",range,",ee),De(Ir(Pe,!0,ke,ke.headers.get("Content-Length"),ke.headers.get("age"),ge,$t,H,ee,E._vid,E._priOptions));case 39:case"end":return Je.stop()}},Qe)}));return function(Qe){return Ne.apply(this,arguments)}}()).catch(function(Ne){var Qe;clearTimeout(E._timeoutTimer),E._running=!1,!(E._aborted&&!X)&&(Ne=Ne instanceof Lt?Ne:new Lt(_,re,null,(Qe=Ne)===null||Qe===void 0?void 0:Qe.message),Ne.startTime=ge,Ne.endTime=Date.now(),Ne.isTimeout=X,Ne.options={index:E._index,range:E._range,vid:E._vid,priOptions:E._priOptions},pe(Ne))})})}},{key:"cancel",value:function(){var l=St(Ye().mark(function v(){return Ye().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:if(!this._aborted){_.next=2;break}return _.abrupt("return");case 2:if(this._aborted=!0,this._running=!1,!this._response){_.next=14;break}if(_.prev=5,!this._reader){_.next=9;break}return _.next=9,this._reader.cancel();case 9:_.next=13;break;case 11:_.prev=11,_.t0=_.catch(5);case 13:this._response=this._reader=null;case 14:if(this._abortController){try{this._abortController.abort()}catch{}this._abortController=null}this._onCancel&&this._onCancel({index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions});case 16:case"end":return _.stop()}},v,this,[[5,11]])}));function f(){return l.apply(this,arguments)}return f}()},{key:"_loadChunk",value:function(f,v,E,_){var S=this;if(!f.body||!f.body.getReader){this._running=!1;var C=new Lt(f.url,"",f,"onProgress of bad response.body.getReader");C.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this.reject(C);return}this._onProcessMinLen>0&&(this._cache=new Uint8Array(Ts),this._writeIdx=0);var I=this._reader=f.body.getReader(),P,H,W,Y=function(){var ee=St(Ye().mark(function J(){var ae,se,_e,oe,j,ue,Ve,R;return Ye().wrap(function(G){for(;;)switch(G.prev=G.next){case 0:return H=Date.now(),G.prev=1,G.next=4,I.read();case 4:P=G.sent,W=Date.now(),G.next=13;break;case 8:return G.prev=8,G.t0=G.catch(1),W=Date.now(),S._aborted||(S._running=!1,G.t0.options={index:S._index,range:S._range,vid:S._vid,priOptions:S._priOptions},S.reject(G.t0)),G.abrupt("return");case 13:if(se=((ae=S._range)===null||ae===void 0?void 0:ae.length)>0?S._range[0]:0,_e=se+S._receivedLength,!S._aborted){G.next=19;break}return S._running=!1,v(void 0,!1,{range:[_e,_e],vid:S._vid,index:S._index,startTime:H,endTime:W,st:E,firstByteTime:_,priOptions:S._priOptions},f),G.abrupt("return");case 19:oe=P.value?P.value.byteLength:0,S._receivedLength+=oe,S._logger.debug("\u3010fetchLoader,onProgress call\u3011,task,",S._range,", start,",_e,", end,",se+S._receivedLength,", done,",P.done),S._onProcessMinLen>0?S._writeIdx+oe>=S._onProcessMinLen||P.done?(j=new Uint8Array(S._writeIdx+oe),j.set(S._cache.slice(0,S._writeIdx),0),oe>0&&j.set(P.value,S._writeIdx),S._writeIdx=0,S._logger.debug("\u3010fetchLoader,onProgress enough\u3011,done,",P.done,",len,",j.byteLength,", writeIdx,",S._writeIdx)):oe>0&&S._writeIdx+oe<Ts?(S._cache.set(P.value,S._writeIdx),S._writeIdx+=oe,S._logger.debug("\u3010fetchLoader,onProgress cache\u3011,len,",oe,", writeIdx,",S._writeIdx)):oe>0&&(ue=new Uint8Array(S._writeIdx+oe+2048),S._logger.debug("\u3010fetchLoader,onProgress extra start\u3011,size,",S._writeIdx+oe+2048,", datalen,",oe,", writeIdx,",S._writeIdx),ue.set(S._cache.slice(0,S._writeIdx),0),oe>0&&ue.set(P.value,S._writeIdx),S._writeIdx+=oe,delete S._cache,S._cache=ue,S._logger.debug("\u3010fetchLoader,onProgress extra end\u3011,len,",oe,", writeIdx,",S._writeIdx)):j=P.value,(j&&j.byteLength>0||P.done)&&v(j,P.done,{range:[S._range[0]+S._receivedLength-(j?j.byteLength:0),S._range[0]+S._receivedLength],vid:S._vid,index:S._index,startTime:H,endTime:W,st:E,firstByteTime:_,priOptions:S._priOptions},f),P.done?(Ve=Date.now()-E,R=Pr(S._receivedLength,Ve),S.emit(me.REAL_TIME_SPEED,{speed:R,len:S._receivedLength,time:Ve,vid:S._vid,index:S._index,range:S._range,priOptions:S._priOptions}),S._running=!1,S._logger.debug("[fetchLoader onProgress end],task,",S._range,",done,",P.done),S.resolve(Ir(P,!0,f,f.headers.get("Content-Length"),f.headers.get("age"),E,_,S._index,S._range,S._vid,S._priOptions))):Y();case 25:case"end":return G.stop()}},J,null,[[1,8]])}));return function(){return ee.apply(this,arguments)}}();Y()}},{key:"receiveLen",get:function(){return this._receivedLength}},{key:"running",get:function(){return this._running},set:function(f){this._running=f}}],[{key:"isSupported",value:function(){return typeof fetch<"u"}}]),n}(xs.default);function bs(c){return er({loaderType:kt.FETCH,retry:0,retryDelay:0,timeout:0,request:null,onTimeout:void 0,onProgress:void 0,onRetryError:void 0,transformRequest:void 0,transformResponse:void 0,transformError:void 0,responseType:ir.TEXT,range:void 0,url:"",params:void 0,method:"GET",headers:{},body:void 0,mode:void 0,credentials:void 0,cache:void 0,redirect:void 0,referrer:void 0,referrerPolicy:void 0,integrity:void 0,onProcessMinLen:0},c)}var Ls=gr(_r()),As=function(c){It(n,c);var g=Pt(n);function n(){var l;return Be(this,n),l=g.call(this),q(de(l),"_xhr",null),q(de(l),"_aborted",!1),q(de(l),"_timeoutTimer",null),q(de(l),"_range",null),q(de(l),"_receivedLength",0),q(de(l),"_url",null),q(de(l),"_onProgress",null),q(de(l),"_index",-1),q(de(l),"_headers",null),q(de(l),"_currentChunkSizeKB",384),q(de(l),"_timeout",null),q(de(l),"_xhr",null),q(de(l),"_withCredentials",null),q(de(l),"_startTime",-1),q(de(l),"_loadCompleteResolve",null),q(de(l),"_loadCompleteReject",null),q(de(l),"_runing",!1),q(de(l),"_logger",!1),q(de(l),"_vid",""),q(de(l),"_responseType",void 0),q(de(l),"_credentials",void 0),q(de(l),"_method",void 0),q(de(l),"_transformResponse",void 0),q(de(l),"_firstRtt",void 0),q(de(l),"_onCancel",null),q(de(l),"_priOptions",null),l}return Ge(n,[{key:"load",value:function(f){var v=this;clearTimeout(this._timeoutTimer),this._logger=f.logger,this._range=f.range,this._onProgress=f.onProgress,this._index=f.index,this._headers=f.headers,this._withCredentials=f.credentials==="include"||f.credentials==="same-origin",this._body=f.body||null,f.method&&(this._method=f.method),this._timeout=f.timeout||null,this._runing=!0,this._vid=f.vid||f.url,this._responseType=f.responseType,this._firstRtt=-1,this._onTimeout=f.onTimeout,this._onCancel=f.onCancel,this._request=f.request,this._priOptions=f.priOptions||{},this._logger.debug("\u3010xhrLoader task\u3011, range",this._range),this._url=hi(f.url,f.params);var E=Date.now();return new Promise(function(_,S){v._loadCompleteResolve=_,v._loadCompleteReject=S,v._startLoad()}).catch(function(_){if(clearTimeout(v._timeoutTimer),v._runing=!1,!v._aborted)throw _=_ instanceof Lt?_:new Lt(v._url,v._request),_.startTime=E,_.endTime=Date.now(),_.options={index:v._index,vid:v._vid,priOptions:v._priOptions},_})}},{key:"_startLoad",value:function(){var f=null;if(this._responseType===ir.ARRAY_BUFFER&&this._range&&this._range.length>1)if(this._onProgress){this._firstRtt=-1;var v=this._currentChunkSizeKB*1024,E=this._range[0]+this._receivedLength,_=this._range[1];v<this._range[1]-E&&(_=E+v),f=[E,_],this._logger.debug("[xhr_loader->],tast :",this._range,", SubRange, ",f)}else f=this._range,this._logger.debug("[xhr_loader->],tast :",this._range,", allRange, ",f);this._internalOpen(f)}},{key:"_internalOpen",value:function(f){var v=this;try{this._startTime=Date.now();var E=this._xhr=new XMLHttpRequest;E.open(this._method||"GET",this._url,!0),E.responseType=this._responseType,this._timeout&&(E.timeout=this._timeout),E.withCredentials=this._withCredentials,E.onload=this._onLoad.bind(this),E.onreadystatechange=this._onReadyStatechange.bind(this),E.onerror=function(C){var I,P,H;v._running=!1;var W=new Lt(v._url,v._request,C==null||(I=C.currentTarget)===null||I===void 0?void 0:I.response,"xhr.onerror.status:"+(C==null||(P=C.currentTarget)===null||P===void 0?void 0:P.status)+",statusText,"+(C==null||(H=C.currentTarget)===null||H===void 0?void 0:H.statusText));W.options={index:v._index,range:v._range,vid:v._vid,priOptions:v._priOptions},v._loadCompleteReject(W)},E.ontimeout=function(C){v.cancel();var I=new Lt(v._url,v._request,{status:408},"timeout");v._onTimeout&&(I.isTimeout=!0,v._onTimeout(I,{index:v._index,range:v._range,vid:v._vid,priOptions:v._priOptions})),I.options={index:v._index,range:v._range,vid:v._vid,priOptions:v._priOptions},v._loadCompleteReject(I)};var _=this._headers||{},S=fi(f);S&&(_.Range=S),_&&Object.keys(_).forEach(function(C){E.setRequestHeader(C,_[C])}),this._logger.debug("[xhr.send->] tast,",this._range,",load sub range, ",f),E.send(this._body)}catch(C){C.options={index:this._index,range:f,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(C)}}},{key:"_onReadyStatechange",value:function(f){var v=f.target;v.readyState===2&&this._firstRtt<0&&(this._firstRtt=Date.now())}},{key:"_onLoad",value:function(f){var v,E=f.target.status;if(E<200||E>299){var _=new Lt(this._url,null,er(er({},f.target.response),{},{status:E}),"bad response,status:"+E);return _.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(_)}var S=null,C=!1,I,P=((v=this._range)===null||v===void 0?void 0:v.length)>0?this._range[0]:0;if(this._responseType===ir.ARRAY_BUFFER){var H,W=new Uint8Array(f.target.response);if(I=P+this._receivedLength,W&&W.byteLength>0){this._receivedLength+=W.byteLength;var Y=Date.now()-this._startTime,ee=Pr(this._receivedLength,Y);this.emit(me.REAL_TIME_SPEED,{speed:ee,len:this._receivedLength,time:Y,vid:this._vid,index:this._index,range:[I,P+this._receivedLength],priOptions:this._priOptions})}S=W,((H=this._range)===null||H===void 0?void 0:H.length)>1&&this._range[1]&&this._receivedLength<this._range[1]-this._range[0]?C=!1:C=!0,this._logger.debug("[xhr load done->], tast :",this._range,", start",I,"end ",P+this._receivedLength,",dataLen,",W?W.byteLength:0,",receivedLength",this._receivedLength,",index,",this._index,", done,",C)}else C=!0,S=f.target.response;var J={ok:E>=200&&E<300,status:E,statusText:this._xhr.statusText,url:this._xhr.responseURL,headers:this._getHeaders(this._xhr),body:this._xhr.response};this._transformResponse&&(J=this._transformResponse(J,this._url)||J),this._onProgress&&this._onProgress(S,C,{index:this._index,vid:this._vid,range:[I,P+this._receivedLength],startTime:this._startTime,endTime:Date.now(),priOptions:this._priOptions},J),C?(this._runing=!1,this._loadCompleteResolve&&this._loadCompleteResolve(Ir(this._onProgress?null:S,C,J,J.headers["content-length"],J.headers.age,this._startTime,this._firstRtt,this._index,this._range,this._vid,this._priOptions))):this._startLoad()}},{key:"cancel",value:function(){if(!this._aborted&&(this._aborted=!0,this._runing=!1,Rr(Zt(n.prototype),"removeAllListeners",this).call(this),this._onCancel&&this._onCancel({index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions}),this._xhr))return this._xhr.abort()}},{key:"receiveLen",get:function(){return this._receivedLength}},{key:"running",get:function(){return this._running},set:function(f){this._running=f}},{key:"_getHeaders",value:function(f){var v=f.getAllResponseHeaders().trim().split(`\r
17
+ `),E={},_=ds(v),S;try{for(_.s();!(S=_.n()).done;){var C=S.value,I=C.split(": ");E[I[0].toLowerCase()]=I.slice(1).join(": ")}}catch(P){_.e(P)}finally{_.f()}return E}}],[{key:"isSupported",value:function(){return typeof XMLHttpRequest<"u"}}]),n}(Ls.default);var kf=["retry","retryDelay","onRetryError","transformError"],Rs=function(){function c(g,n){Be(this,c),this.promise=tr(),this.alive=!!n.onProgress,!n.logger&&(n.logger=new Tt("Loader")),this._loaderType=g,this._loader=g===kt.FETCH&&typeof fetch<"u"?new kr:new As,this._config=n,this._retryCount=0,this._retryTimer=null,this._canceled=!1,this._retryCheckFunc=n.retryCheckFunc,this._logger=n.logger}return Ge(c,[{key:"exec",value:function(){var n=this,l=this._config,f=l.retry,v=l.retryDelay,E=l.onRetryError,_=l.transformError,S=hs(l,kf),C=function(){var I=St(Ye().mark(function P(){var H,W,Y;return Ye().wrap(function(J){for(;;)switch(J.prev=J.next){case 0:return J.prev=0,J.next=3,n._loader.load(S);case 3:H=J.sent,n.promise.resolve(H),J.next=27;break;case 7:if(J.prev=7,J.t0=J.catch(0),n._loader.running=!1,n._logger.debug("[task request catch err]",J.t0),!n._canceled){J.next=13;break}return J.abrupt("return");case 13:if(J.t0.loaderType=n._loaderType,J.t0.retryCount=n._retryCount,W=J.t0,_&&(W=_(W)||W),E&&n._retryCount>0&&E(W,n._retryCount,{index:S.index,vid:S.vid,range:S.range,priOptions:S.priOptions}),n._retryCount++,Y=!0,n._retryCheckFunc&&(Y=n._retryCheckFunc(J.t0)),!(Y&&n._retryCount<=f)){J.next=26;break}return clearTimeout(n._retryTimer),n._logger.debug("[task request setTimeout],retry",n._retryCount,",retry range,",S.range),n._retryTimer=setTimeout(C,v),J.abrupt("return");case 26:n.promise.reject(W);case 27:case"end":return J.stop()}},P,null,[[0,7]])}));return function(){return I.apply(this,arguments)}}();return C(),this.promise}},{key:"cancel",value:function(){var g=St(Ye().mark(function l(){return Ye().wrap(function(v){for(;;)switch(v.prev=v.next){case 0:return clearTimeout(this._retryTimer),this._canceled=!0,this._loader.running=!1,v.abrupt("return",this._loader.cancel());case 4:case"end":return v.stop()}},l,this)}));function n(){return g.apply(this,arguments)}return n}()},{key:"running",get:function(){return this._loader&&this._loader.running}},{key:"loader",get:function(){return this._loader}}]),c}();function Qi(c){return c&&!c.paused&&!c.ended&&c.playbackRate!==0&&c.readyState!==0}function Ji(c){if(!c)return{};if(typeof c.getVideoPlaybackQuality=="function"){var g=c.getVideoPlaybackQuality();return{droppedVideoFrames:g.droppedVideoFrames||g.corruptedVideoFrames,totalVideoFrames:g.totalVideoFrames,creationTime:g.creationTime}}return{droppedVideoFrames:c.webkitDroppedFrameCount,totalVideoFrames:c.webkitDecodedFrameCount,creationTime:performance.now()}}function Zi(){for(var c=arguments.length,g=new Array(c),n=0;n<c;n++)g[n]=arguments[n];if(g=g.filter(Boolean),g.length<2)return g[0];var l=new Uint8Array(g.reduce(function(v,E){return v+E.byteLength},0)),f=0;return g.forEach(function(v){l.set(v,f),f+=v.byteLength}),l}function en(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return new Promise(function(g){return setTimeout(g,c)})}var Cs=gr(_r()),tn=function(c){It(n,c);var g=Pt(n);function n(l){var f;return Be(this,n),f=g.call(this,l),q(de(f),"type",kt.FETCH),q(de(f),"_queue",[]),q(de(f),"_alive",[]),q(de(f),"_currentTask",null),q(de(f),"_finnalUrl",""),q(de(f),"_config",void 0),f._config=bs(l),(f._config.loaderType===kt.XHR||!kr.isSupported())&&(f.type=kt.XHR),f.log=l.logger,f}return Ge(n,[{key:"isFetch",value:function(){return this.type===kt.FETCH}},{key:"load",value:function(f){var v=this,E=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};typeof f=="string"||!f?E.url=f||E.url||this._config.url:E=f,E=Object.assign({},this._config,E),E.params&&(E.params=Object.assign({},E.params)),E.headers&&$i(E.headers)&&(E.headers=Object.assign({},E.headers)),E.body&&$i(E.body)&&(E.body=Object.assign({},E.body)),E.transformRequest&&(E=E.transformRequest(E)||E),E.logger=this.log;var _=new Rs(this.type,E);return _.loader.on(me.REAL_TIME_SPEED,function(S){v.emit(me.REAL_TIME_SPEED,S)}),this._queue.push(_),this._queue.length===1&&(!this._currentTask||!this._currentTask.running)&&this._processTask(),_.promise}},{key:"cancel",value:function(){var l=St(Ye().mark(function v(){var E;return Ye().wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return E=this._queue.map(function(C){return C.cancel()}).concat(this._alive.map(function(C){return C.cancel()})),this._currentTask&&E.push(this._currentTask.cancel()),this._queue=[],this._alive=[],S.next=6,Promise.all(E);case 6:return S.next=8,en();case 8:case"end":return S.stop()}},v,this)}));function f(){return l.apply(this,arguments)}return f}()},{key:"_processTask",value:function(){var f=this;if(this._currentTask=this._queue.shift(),!!this._currentTask){this._currentTask.alive&&this._alive.push(this._currentTask);var v=this._currentTask.exec().catch(function(E){});v&&typeof v.finally=="function"&&v.finally(function(){var E,_;(E=f._currentTask)!==null&&E!==void 0&&E.alive&&((_=f._alive)===null||_===void 0?void 0:_.length)>0&&(f._alive=f._alive.filter(function(S){return S&&S!==f._currentTask})),f._processTask()})}}}],[{key:"isFetchSupport",value:function(){return kr.isSupported()}}]),n}(Cs.default);var rn=function(){function c(){Be(this,c),q(this,"_prevCurrentTime",0)}return Ge(c,[{key:"do",value:function(n){var l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:3,f=arguments.length>2?arguments[2]:void 0,v=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1;if(n){var E=n.currentTime,_=0;if(this._prevCurrentTime===E){var S=tt.info(tt.get(n),E);if(!S.buffers.length)return;f&&S.nextStart||S.nextStart&&S.nextStart-E<l?_=S.nextStart+.1:S.end&&S.end-E>v&&!n.seeking&&(_=E+.1)}this._prevCurrentTime=E,_&&E!==_&&(n.currentTime=_)}}}]),c}();var nn=function(){function c(g){var n=this;Be(this,c),q(this,"_seiSet",new Set),this.emitter=g,g.on(me.SEI,function(l){l&&n._seiSet.add(l)})}return Ge(c,[{key:"throw",value:function(n,l){var f=this;if(!(n==null||!this._seiSet.size)){var v=n-.2,E=n+.2,_=[];this._seiSet.forEach(function(S){S.time>=v&&S.time<=E&&_.push(S)}),_.forEach(function(S){f._seiSet.delete(S),f.emitter.emit(me.SEI_IN_TIME,S)}),l&&this._seiSet.forEach(function(S){S.time<n-5&&f._seiSet.delete(S)})}}},{key:"reset",value:function(){this._seiSet.clear()}}]),c}();var Of=1e3,Mf=50,Ff=3,Nf=3e3,an=function(){function c(g){Be(this,c),q(this,"_chunkSpeed",0),q(this,"_chunkCache",[]),q(this,"_speeds",[]),q(this,"_totalSize",0),q(this,"_totalCost",0),this._opts=g||{}}return Ge(c,[{key:"addRecord",value:function(n,l){!n||!l||(this._speeds.push(8e3*n/l),this._speeds=this._speeds.slice(-Ff))}},{key:"addChunkRecord",value:function(n,l){var f,v;if(!(!n||!l||n<(((f=this._opts)===null||f===void 0?void 0:f.skipChunkSize)||Of))){this._totalSize+=n,this._totalCost+=l,this._chunkSpeed=8e3*n/l,this._chunkCache.push({size:n,duration:l,timestamp:performance.now()});var E=((v=this._opts)===null||v===void 0?void 0:v.chunkCountForSpeed)||Mf;this._chunkCache.length>E&&(this._chunkCache=this._chunkCache.slice(-E))}}},{key:"getAvgSpeed",value:function(){var n;if(!this._chunkCache.length&&!this._speeds.length)return 0;if(this._speeds.length)return this._speeds.reduce(function(_,S){return _+=S})/this._speeds.length;var l=this._chunkCache[this._chunkCache.length-1],f=performance.now()-l.timestamp;f>(((n=this._opts)===null||n===void 0?void 0:n.longtimeNoReceived)||Nf)&&this._chunkCache.push({size:0,duration:f,timestamp:performance.now()});var v=this._chunkCache.reduce(function(_,S){return _+=S.size},0),E=this._chunkCache.reduce(function(_,S){return _+=S.duration},0);return 8e3*v/E}},{key:"getLatestSpeed",value:function(){return!this._chunkCache.length&&!this._speeds.length?0:this._speeds.length?this._speeds[this._speeds.length-1]:this._chunkSpeed}},{key:"getTotalSize",value:function(){return this._totalSize}},{key:"getTotalCost",value:function(){return this._totalCost}},{key:"reset",value:function(){this._chunkCache=[],this._speeds=[],this._totalSize=0,this._totalCost=0}}]),c}();var pd=gr(_r());var Ds=function(){function c(g){Be(this,c),q(this,"encodeType",""),q(this,"audioCodec",""),q(this,"videoCodec",""),q(this,"domain",""),q(this,"fps",0),q(this,"bitrate",0),q(this,"width",0),q(this,"height",0),q(this,"samplerate",0),q(this,"channelCount",0),q(this,"gop",0),q(this,"_bitsAccumulateSize",0),q(this,"_bitsAccumulateDuration",0),q(this,"_startGopId",-1),this._timescale=g}return Ge(c,[{key:"getStats",value:function(){return{encodeType:this.encodeType,audioCodec:this.audioCodec,videoCodec:this.videoCodec,domain:this.domain,fps:this.fps,bitrate:this.bitrate,width:this.width,height:this.height,samplerate:this.samplerate,channelCount:this.channelCount,gop:this.gop}}},{key:"setEncodeType",value:function(n){this.encodeType=n}},{key:"setFpsFromScriptData",value:function(n){var l,f=n.data,v=f==null||(l=f.onMetaData)===null||l===void 0?void 0:l.framerate;v&&v>0&&v<100&&(this.fps=v)}},{key:"setVideoMeta",value:function(n){if(this.width=n.width,this.height=n.height,this.videoCodec=n.codec,this.encodeType=n.codecType,n.fpsNum&&n.fpsDen){var l=n.fpsNum/n.fpsDen;l>0&&l<100&&(this.fps=l)}}},{key:"setAudioMeta",value:function(n){this.audioCodec=n.codec,this.samplerate=n.sampleRate,this.channelCount=n.channelCount}},{key:"setDomain",value:function(n){this.domain=n.split("/").slice(2,3)[0]}},{key:"updateBitrate",value:function(n){var l=this;if((!this.fps||this.fps>=100)&&n.length){var f=n.reduce(function(v,E){return v+=E.duration},0)/n.length;this.fps=Math.round(this._timescale/f)}n.forEach(function(v){l._startGopId===-1&&(l._startGopId=v.gopId),v.gopId===l._startGopId&&l.gop++,l._bitsAccumulateDuration+=v.duration/(l._timescale/1e3),l._bitsAccumulateSize+=v.units.reduce(function(E,_){return E+=_.length},0),l._bitsAccumulateDuration>=1e3&&(l.bitrate=l._bitsAccumulateSize*8,l._bitsAccumulateDuration=0,l._bitsAccumulateSize=0)})}}]),c}(),sn=function(){function c(g){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1e3;Be(this,c),q(this,"_core",null),q(this,"_samples",[]),this._core=g,this._timescale=n,this._stats=new Ds(n),this._bindEvents()}return Ge(c,[{key:"getStats",value:function(){var n,l,f,v,E,_,S,C,I,P,H,W=((n=this._core)===null||n===void 0?void 0:n.media)||{},Y=W.currentTime,ee=Y===void 0?0:Y,J=W.decodeFps,ae=J===void 0?0:J;return er(er({},this._stats.getStats()),{},{downloadSpeed:((l=this._core)===null||l===void 0||(f=l.speedInfo)===null||f===void 0?void 0:f.call(l).speed)||0,avgSpeed:((v=this._core)===null||v===void 0||(E=v.speedInfo)===null||E===void 0?void 0:E.call(v).avgSpeed)||0,totalReceivedByte:((_=this._core)===null||_===void 0||(S=_.speedInfo)===null||S===void 0?void 0:S.call(_).totalSize)||0,totalReceivedCost:((C=this._core)===null||C===void 0||(I=C.speedInfo)===null||I===void 0?void 0:I.call(C).totalCost)||0,currentTime:ee,bufferEnd:((P=this._core)===null||P===void 0||(H=P.bufferInfo())===null||H===void 0?void 0:H.remaining)||0,decodeFps:ae})}},{key:"_bindEvents",value:function(){var n=this;this._core.on(me.DEMUXED_TRACK,function(l){var f=l.videoTrack;return n._stats.updateBitrate(f.samples)}),this._core.on(me.FLV_SCRIPT_DATA,function(l){n._stats.setFpsFromScriptData(l)}),this._core.on(me.METADATA_PARSED,function(l){l.type==="video"?n._stats.setVideoMeta(l.track):n._stats.setAudioMeta(l.track)}),this._core.on(me.TTFB,function(l){n._stats.setDomain(l.responseUrl)})}},{key:"reset",value:function(){this._samples=[],this._stats=new Ds(this._timescale)}}]),c}();var ro=gr(_r());function Uf(c,g){var n=c==null?null:typeof Symbol<"u"&&c[Symbol.iterator]||c["@@iterator"];if(n!=null){var l,f,v,E,_=[],S=!0,C=!1;try{if(v=(n=n.call(c)).next,g===0){if(Object(n)!==n)return;S=!1}else for(;!(S=(l=v.call(n)).done)&&(_.push(l.value),_.length!==g);S=!0);}catch(I){C=!0,f=I}finally{try{if(!S&&n.return!=null&&(E=n.return(),Object(E)!==E))return}finally{if(C)throw f}}return _}}function Se(c,g){if(!(c instanceof g))throw new TypeError("Cannot call a class as a function")}function ws(c,g){for(var n=0;n<g.length;n++){var l=g[n];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(c,ks(l.key),l)}}function Te(c,g,n){return g&&ws(c.prototype,g),n&&ws(c,n),Object.defineProperty(c,"prototype",{writable:!1}),c}function Q(c,g,n){return g=ks(g),g in c?Object.defineProperty(c,g,{value:n,enumerable:!0,configurable:!0,writable:!0}):c[g]=n,c}function ln(c,g){if(typeof g!="function"&&g!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(g&&g.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),Object.defineProperty(c,"prototype",{writable:!1}),g&&on(c,g)}function di(c){return di=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},di(c)}function on(c,g){return on=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(l,f){return l.__proto__=f,l},on(c,g)}function Bf(){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 Gf(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function Vf(c,g){if(g&&(typeof g=="object"||typeof g=="function"))return g;if(g!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Gf(c)}function fn(c){var g=Bf();return function(){var l=di(c),f;if(g){var v=di(this).constructor;f=Reflect.construct(l,arguments,v)}else f=l.apply(this,arguments);return Vf(this,f)}}function Is(c,g){return Kf(c)||Uf(c,g)||Ps(c,g)||zf()}function Ot(c){return Hf(c)||Wf(c)||Ps(c)||jf()}function Hf(c){if(Array.isArray(c))return un(c)}function Kf(c){if(Array.isArray(c))return c}function Wf(c){if(typeof Symbol<"u"&&c[Symbol.iterator]!=null||c["@@iterator"]!=null)return Array.from(c)}function Ps(c,g){if(c){if(typeof c=="string")return un(c,g);var n=Object.prototype.toString.call(c).slice(8,-1);if(n==="Object"&&c.constructor&&(n=c.constructor.name),n==="Map"||n==="Set")return Array.from(c);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return un(c,g)}}function un(c,g){(g==null||g>c.length)&&(g=c.length);for(var n=0,l=new Array(g);n<g;n++)l[n]=c[n];return l}function jf(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
18
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function zf(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
19
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Yf(c,g){if(typeof c!="object"||c===null)return c;var n=c[Symbol.toPrimitive];if(n!==void 0){var l=n.call(c,g||"default");if(typeof l!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return(g==="string"?String:Number)(c)}function ks(c){var g=Yf(c,"string");return typeof g=="symbol"?g:String(g)}var Mt={VIDEO:"video",AUDIO:"audio",METADATA:"metadata"},zt={AV1:"av1",AVC:"avc",HEVC:"hevc"},We={AAC:"aac",G711PCMA:"g7110a",G711PCMU:"g7110m",OPUS:"opus"},mt={LARGE_AV_SHIFT:"LARGE_AV_SHIFT",LARGE_VIDEO_GAP:"LARGE_VIDEO_GAP",LARGE_VIDEO_GAP_BETWEEN_CHUNK:"LARGE_VIDEO_GAP_BETWEEN_CHUNK",LARGE_AUDIO_GAP:"LARGE_AUDIO_GAP",AUDIO_FILLED:"AUDIO_FILLED",AUDIO_DROPPED:"AUDIO_DROPPED"};var Os=function(){function c(){Se(this,c),Q(this,"id",1),Q(this,"type",Mt.VIDEO),Q(this,"codecType",zt.AVC),Q(this,"pid",-1),Q(this,"hvcC",void 0),Q(this,"codec",""),Q(this,"timescale",0),Q(this,"formatTimescale",0),Q(this,"sequenceNumber",0),Q(this,"baseMediaDecodeTime",0),Q(this,"baseDts",0),Q(this,"duration",0),Q(this,"warnings",[]),Q(this,"samples",[]),Q(this,"pps",[]),Q(this,"sps",[]),Q(this,"vps",[]),Q(this,"fpsNum",0),Q(this,"fpsDen",0),Q(this,"sarRatio",[]),Q(this,"width",0),Q(this,"height",0),Q(this,"nalUnitSize",4),Q(this,"present",!1),Q(this,"isVideoEncryption",!1),Q(this,"isAudioEncryption",!1),Q(this,"isVideo",!0),Q(this,"lastKeyFrameDts",0),Q(this,"kid",null),Q(this,"pssh",null),Q(this,"ext",void 0)}return Te(c,[{key:"reset",value:function(){this.sequenceNumber=this.width=this.height=this.fpsDen=this.fpsNum=this.duration=this.baseMediaDecodeTime=this.timescale=0,this.codec="",this.present=!1,this.pid=-1,this.pps=[],this.sps=[],this.vps=[],this.sarRatio=[],this.samples=[],this.warnings=[],this.hvcC=null}},{key:"firstDts",get:function(){return this.samples.length?this.samples[0].dts:null}},{key:"firstPts",get:function(){return this.samples.length?this.samples[0].pts:null}},{key:"samplesDuration",get:function(){if(this.samples.length>0){var n=this.samples[0],l=this.samples[this.samples.length-1];return l.dts-n.dts+l.duration}return 0}},{key:"exist",value:function(){return/av01/.test(this.codec)?!0:!!(this.pps.length&&this.sps.length&&this.codec)}},{key:"hasSample",value:function(){return!!this.samples.length}},{key:"isEncryption",get:function(){return this.isVideoEncryption}}]),c}();var Ms=function(){function c(){Se(this,c),Q(this,"id",2),Q(this,"type",Mt.AUDIO),Q(this,"codecType",We.AAC),Q(this,"pid",-1),Q(this,"codec",""),Q(this,"sequenceNumber",0),Q(this,"sampleDuration",0),Q(this,"timescale",0),Q(this,"formatTimescale",0),Q(this,"baseMediaDecodeTime",0),Q(this,"duration",0),Q(this,"warnings",[]),Q(this,"samples",[]),Q(this,"baseDts",0),Q(this,"sampleSize",16),Q(this,"sampleRate",0),Q(this,"channelCount",0),Q(this,"objectType",0),Q(this,"sampleRateIndex",0),Q(this,"config",[]),Q(this,"present",!1),Q(this,"isVideoEncryption",!1),Q(this,"isAudioEncryption",!1),Q(this,"kid",null),Q(this,"ext",void 0)}return Te(c,[{key:"reset",value:function(){this.sequenceNumber=0,this.timescale=0,this.sampleDuration=0,this.sampleRate=0,this.channelCount=0,this.baseMediaDecodeTime=0,this.present=!1,this.pid=-1,this.codec="",this.samples=[],this.config=[],this.warnings=[]}},{key:"exist",value:function(){return!!(this.sampleRate&&this.channelCount&&this.codec&&(this.codecType===We.AAC||this.codecType===We.G711PCMA||this.codecType===We.G711PCMU||this.codecType===We.OPUS))}},{key:"hasSample",value:function(){return!!this.samples.length}},{key:"isEncryption",get:function(){return this.isAudioEncryption}},{key:"firstDts",get:function(){return this.samples.length?this.samples[0].dts:null}},{key:"firstPts",get:function(){return this.samples.length?this.samples[0].pts:null}},{key:"samplesDuration",get:function(){if(this.samples.length>0){var n=this.samples[0],l=this.samples[this.samples.length-1];return l.dts-n.dts+l.duration}return 0}}]),c}();var Fs=function(){function c(g,n,l){Se(this,c),Q(this,"flag",{}),Q(this,"keyframe",!1),Q(this,"gopId",0),Q(this,"duration",0),Q(this,"size",0),Q(this,"units",[]),Q(this,"chromaFormat",420),this.originPts=this.pts=g,this.originDts=this.dts=n,l&&(this.units=l)}return Te(c,[{key:"cts",get:function(){return this.pts-this.dts}},{key:"setToKeyframe",value:function(){this.keyframe=!0,this.flag.dependsOn=2,this.flag.isNonSyncSample=0}}]),c}();var Sr=Te(function c(g,n,l,f){Se(this,c),Q(this,"duration",1024),Q(this,"flag",{dependsOn:2,isNonSyncSample:0}),Q(this,"keyframe",!0),this.originPts=this.pts=this.dts=g,this.data=n,this.size=n.byteLength,this.sampleOffset=f,l&&(this.duration=l)});var Ns=Te(function c(g,n){Se(this,c),Q(this,"time",0),this.data=g,this.originPts=this.pts=n}),Us=function(c){ln(n,c);var g=fn(n);function n(){return Se(this,n),g.apply(this,arguments)}return Te(n)}(Ns),Bs=function(c){ln(n,c);var g=fn(n);function n(){return Se(this,n),g.apply(this,arguments)}return Te(n)}(Ns),Gs=function(){function c(){Se(this,c),Q(this,"id",3),Q(this,"type",Mt.METADATA),Q(this,"timescale",0),Q(this,"flvScriptSamples",[]),Q(this,"seiSamples",[])}return Te(c,[{key:"exist",value:function(){return!!((this.flvScriptSamples.length||this.seiSamples.length)&&this.timescale)}},{key:"reset",value:function(){this.timescale=0,this.flvScriptSamples=[],this.seiSamples=[]}},{key:"hasSample",value:function(){return!!(this.flvScriptSamples.length||this.seiSamples.length)}}]),c}();var fr=function(){function c(g){Se(this,c),this.name=g||"",this._prefix="[".concat(this.name,"]")}return Te(c,[{key:"warn",value:function(){var n;if(!c.disabled){for(var l=arguments.length,f=new Array(l),v=0;v<l;v++)f[v]=arguments[v];(n=console).warn.apply(n,[this._prefix].concat(f))}}}],[{key:"enable",value:function(){c.disabled=!1}},{key:"disable",value:function(){c.disabled=!0}}]),c}();Q(fr,"disabled",!0);var ci=typeof window<"u",hn=ci&&navigator.userAgent.toLocaleLowerCase(),Vs=ci&&/^((?!chrome|android).)*safari/.test(hn),Hs=ci&&hn.includes("firefox"),Ks=ci&&hn.includes("android");var Tr=function(){function c(){Se(this,c)}return Te(c,null,[{key:"getRateIndexByRate",value:function(n){return c.FREQ.indexOf(n)}},{key:"parseADTS",value:function(n,l){for(var f=n.length,v=0;v+2<f&&!(n[v]===255&&(n[v+1]&246)===240);)v++;if(!(v>=f)){var E=v,_=[],S=(n[v+2]&60)>>>2,C=c.FREQ[S];if(!C)throw new Error("Invalid sampling index: ".concat(S));for(var I=((n[v+2]&192)>>>6)+1,P=(n[v+2]&1)<<2|(n[v+3]&192)>>>6,H=c._getConfig(S,P,I),W=H.config,Y=H.codec,ee,J,ae=0,se=c.getFrameDuration(C);v+7<f;){if(n[v]!==255||(n[v+1]&246)!==240){v++;continue}if(J=(n[v+3]&3)<<11|n[v+4]<<3|(n[v+5]&224)>>5,!J||f-v<J)break;ee=(~n[v+1]&1)*2,_.push({pts:l+ae*se,data:n.subarray(v+7+ee,v+J)}),ae++,v+=J}return{skip:E,remaining:v>=f?void 0:n.subarray(v),frames:_,samplingFrequencyIndex:S,sampleRate:C,objectType:I,channelCount:P,codec:Y,config:W,originCodec:"mp4a.40.".concat(I)}}}},{key:"parseAudioSpecificConfig",value:function(n){if(n.length){var l=n[0]>>>3,f=(n[0]&7)<<1|n[1]>>>7,v=(n[1]&120)>>>3,E=c.FREQ[f];if(E){var _=c._getConfig(f,v,l),S=_.config,C=_.codec;return{samplingFrequencyIndex:f,sampleRate:E,objectType:l,channelCount:v,config:S,codec:C,originCodec:"mp4a.40.".concat(l)}}}}},{key:"getFrameDuration",value:function(n){var l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:9e4;return 1024*l/n}},{key:"_getConfig",value:function(n,l,f){var v=[],E,_;return Hs?n>=6?(E=5,_=n-3):(E=2,_=n):Ks?(E=2,_=n):(E=f===2||f===5?f:5,_=n,n>=6?_=n-3:l===1&&(E=2,_=n)),v[0]=E<<3,v[0]|=(n&14)>>1,v[1]=(n&1)<<7,v[1]|=l<<3,E===5&&(v[1]|=(_&14)>>1,v[2]=(_&1)<<7,v[2]|=8,v[3]=0),{config:v,codec:"mp4a.40.".concat(E)}}},{key:"getSilentFrame",value:function(n,l){switch(n){case"mp4a.40.2":if(l===1)return new Uint8Array([0,200,0,128,35,128]);if(l===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(l===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(l===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(l===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(l===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(l===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(l===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(l===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}}}]),c}();Q(Tr,"FREQ",[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350]);var Or=function(){function c(){Se(this,c)}return Te(c,null,[{key:"getFrameDuration",value:function(n){return 20}},{key:"parseHeaderPackets",value:function(n){if(n.length){for(var l=new DataView(n.buffer,n.byteOffset,n.byteLength),f="",v=0;v<8;v++)f+=String.fromCodePoint(n[v]);if(f!=="OpusHead")throw new Error("Invalid Opus MagicSignature");var E=n[9];console.log("Pre-skip",n[10],n[11]);var _=l.getUint32(12,!0),S=l.getInt16(16,!0);if(_){var C="opus",I="opus",P=new Uint8Array(n.buffer,n.byteOffset+8,n.byteLength-8);return{outputGain:S,sampleRate:_,channelCount:E,config:P,codec:C,originCodec:I}}}}}]),c}();var qf=500,Ws=3,dn=1e3,cn=5e3,Xf=1e3,$f=200,js=5e3,zs=5,Ys=function(){function c(g,n,l){Se(this,c),this.videoTrack=g,this.audioTrack=n,this.metadataTrack=l,this._baseDts=-1,this._baseDtsInited=!1,this._audioNextPts=void 0,this._videoNextDts=void 0,this._audioTimestampBreak=0,this._videoTimestampBreak=0,this._lastVideoDuration=0,this._keyFrameInNextChunk=!1,this._lastAudioExceptionGapDot=-1/0,this._lastAudioExceptionOverlapDot=-1/0,this._lastAudioExceptionLargeGapDot=-1/0,this._lastVideoExceptionLargeGapDot=-1/0,this._lastVideoExceptionChunkFirstDtsDot=-1/0}return Te(c,[{key:"fix",value:function(){var n=this,l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,v=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;l=Math.round(l*1e3);var E=this.videoTrack,_=this.audioTrack;(f||!v)&&(this._videoLastSample=null,this._audioNextPts=void 0,this._videoNextDts=void 0,this._audioTimestampBreak=0,this._videoTimestampBreak=0,this._lastAudioExceptionGapDot=-1/0,this._lastAudioExceptionOverlapDot=-1/0,this._lastAudioExceptionLargeGapDot=-1/0,this._lastVideoExceptionLargeGapDot=-1/0,this._lastVideoExceptionChunkFirstDtsDot=-1/0),f&&!v&&(this._baseDtsInited=!1),this._baseDtsInited||this._calculateBaseDts(_,E),!v&&l&&(this._audioNextPts=this._videoNextDts=l);var S=this._baseDtsInited&&(this._videoTimestampBreak||!this.videoTrack.exist())&&(this._audioTimestampBreak||!this.audioTrack.exist());if(S&&this._resetBaseDtsWhenStreamBreaked(),this._fixAudio(_),this._keyFrameInNextChunk=!1,this._fixVideo(E),this.metadataTrack.exist()){var C=this.metadataTrack.timescale;this.metadataTrack.seiSamples.forEach(function(I){I.pts=I.originPts-n._baseDts,I.time=Math.max(0,I.pts)/C}),this.metadataTrack.flvScriptSamples.forEach(function(I){I.pts=I.originPts-n._baseDts,I.time=Math.max(0,I.pts)/C})}E.samples.length&&(E.baseMediaDecodeTime=E.samples[0].dts),_.samples.length&&(_.baseMediaDecodeTime=_.samples[0].pts*_.timescale/1e3)}},{key:"_fixVideo",value:function(n){var l=this,f=n.samples;if(f.length){f.forEach(function(se){se.dts-=l._baseDts,se.pts-=l._baseDts,se.keyframe&&(l._keyFrameInNextChunk=!0)});var v;if(n.fpsNum&&n.fpsDen)v=n.timescale*(n.fpsDen/n.fpsNum);else if(n.length>1){var E=n.samples[0],_=n.samples[f.length-1];v=Math.floor((_.dts-E.dts)/(f.length-1))}else v=this._lastVideoDuration||40;var S=f.pop();if(this._videoLastSample&&f.unshift(this._videoLastSample),this._videoLastSample=S,!!f.length){if(this._videoNextDts===void 0){var C=f[0];this._videoNextDts=C.dts}var I=f.length,P=0,H=f[0],W=this._videoNextDts-H.dts;if(Math.abs(W)>$f){if(Math.abs(H.dts-this._lastVideoExceptionChunkFirstDtsDot)>js){var Y;this._lastVideoExceptionChunkFirstDtsDot=H.dts,n.warnings.push({type:mt.LARGE_VIDEO_GAP_BETWEEN_CHUNK,nextDts:this._videoNextDts,firstSampleDts:H.dts,nextSampleDts:(Y=f[1])===null||Y===void 0?void 0:Y.dts,sampleDuration:W})}this._videoTimestampBreak>=zs?(this._videoNextDts=H.dts,this._videoTimestampBreak=0):(H.dts+=W,H.pts+=W,this.audioTrack.exist()||(this._videoTimestampBreak=1))}for(var ee=0;ee<I;ee++){var J=f[ee].dts,ae=f[ee+1];ee<I-1?P=ae.dts-J:S?P=S.dts-J:P=v,(P>Xf||P<0)&&(this._videoTimestampBreak++,Math.abs(J-this._lastVideoExceptionLargeGapDot)>js&&(this._lastVideoExceptionLargeGapDot=J,n.warnings.push({type:mt.LARGE_VIDEO_GAP,time:J/n.timescale,dts:J,originDts:f[ee].originDts,nextDts:this._videoNextDts,sampleDuration:P,refSampleDuration:v})),P=v),f[ee].duration=P,this._videoNextDts+=P,this._lastVideoDuration=P}}}}},{key:"_fixAudio",value:function(n){var l=this,f=n.samples;f.length&&(f.forEach(function(v){v.dts=v.pts-=l._baseDts}),this._doFixAudioInternal(n,f,1e3))}},{key:"_calculateBaseDts",value:function(n,l){var f=n.samples,v=l.samples;if(!f.length&&!v.length)return!1;var E=1/0,_=1/0;f.length&&(n.baseDts=E=f[0].pts),v.length&&(l.baseDts=_=v[0].dts),this._baseDts=Math.min(E,_);var S=_-E;return Number.isFinite(S)&&Math.abs(S)>qf&&l.warnings.push({type:mt.LARGE_AV_SHIFT,videoBaseDts:_,audioBasePts:E,baseDts:this._baseDts,delta:S}),this._baseDtsInited=!0,!0}},{key:"_resetBaseDtsWhenStreamBreaked",value:function(){var n=this._calculateBaseDts(this.audioTrack,this.videoTrack);n&&(this.audioTrack.exist()?this.videoTrack.exist()?this._baseDts-=Math.min(this._audioNextPts,this._videoNextDts):this._baseDts-=this._audioNextPts:this._baseDts-=this._videoNextDts,this._videoTimestampBreak=0,this._audioTimestampBreak=0)}},{key:"_doFixAudioInternal",value:function(n,l,f){if(!n.sampleDuration)switch(n.codecType){case We.AAC:{n.sampleDuration=Tr.getFrameDuration(n.timescale,f);break}case We.OPUS:{n.sampleDuration=Or.getFrameDuration(n.samples,f);break}case We.G711PCMA:case We.G711PCMU:{n.sampleDuration=this._getG711Duration(n);break}default:console.error("can't fix audio codecType:",n.codecType);break}var v=n.sampleDuration,E=n.codecType===We.OPUS?20:n.codecType===We.AAC?1024:v*n.timescale/1e3;if(this._audioNextPts===void 0){var _=l[0];this._audioNextPts=_.pts}for(var S=0;S<l.length;S++){var C=this._audioNextPts,I=l[S],P=I.pts-C;if(S===0&&this._audioTimestampBreak>=zs&&this._keyFrameInNextChunk&&(C=this._audioNextPts=I.dts,P=0,this._audioTimestampBreak=0),!this._audioTimestampBreak&&P>=Ws*v&&P<=dn&&!Vs){var H=this._getSilentFrame(n)||l[0].data.subarray(),W=Math.floor(P/v);Math.abs(I.pts-this._lastAudioExceptionGapDot)>cn&&(this._lastAudioExceptionGapDot=I.pts,n.warnings.push({type:mt.AUDIO_FILLED,pts:I.pts,originPts:I.originPts,count:W,nextPts:C,refSampleDuration:v}));for(var Y=0;Y<W;Y++){var ee=new Sr(Math.floor(this._audioNextPts+v)-Math.floor(this._audioNextPts),H,E);ee.originPts=Math.floor(this._baseDts+C),l.splice(S,0,ee),this._audioNextPts+=v,S++}S--}else if(P<=-Ws*v&&P>=-1*dn)Math.abs(I.pts-this._lastAudioExceptionOverlapDot)>cn&&(this._lastAudioExceptionOverlapDot=I.pts,n.warnings.push({type:mt.AUDIO_DROPPED,pts:I.pts,originPts:I.originPts,nextPts:C,refSampleDuration:v})),l.splice(S,1),S--;else{if(Math.abs(P)>dn&&(this._audioTimestampBreak++,Math.abs(I.pts-this._lastAudioExceptionLargeGapDot)>cn&&(this._lastAudioExceptionLargeGapDot=I.pts,n.warnings.push({type:mt.LARGE_AUDIO_GAP,time:I.pts/1e3,pts:I.pts,originPts:I.originPts,nextPts:C,sampleDuration:P,refSampleDuration:v}))),n.codecType===We.OPUS){var J=l[l.length-1];J&&(J.duration=I.pts-J.pts)}else I.dts=I.pts=C,I.duration=E;this._audioNextPts+=v}}}},{key:"_getG711Duration",value:function(n){var l=n.sampleSize,f=n.channelCount,v=n.sampleRate,E=n.samples[0];if(E)return E.data.byteLength*2/f/(l/8)/v*1e3}},{key:"_getSilentFrame",value:function(n){return n.codecType===We.AAC?Tr.getSilentFrame(n.codec,n.channelCount):new Uint8Array(8*n.sampleDuration*n.channelCount)}}]),c}();function xt(){for(var c=arguments.length,g=new Array(c),n=0;n<c;n++)g[n]=arguments[n];g=g.filter(Boolean);var l=new Uint8Array(g.reduce(function(v,E){return v+E.byteLength},0)),f=0;return g.forEach(function(v){l.set(v,f),f+=v.byteLength}),l}var oc=Math.pow(2,32);function xr(c){var g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(c[g]<<24>>>0)+(c[g+1]<<16)+(c[g+2]<<8)+(c[g+3]||0)}function qs(c){for(var g="avc1.",n,l=0;l<3;l++)n=c[l].toString(16),n.length<2&&(n="0".concat(n)),g+=n;return g}function vn(c){if(!Array.isArray(c)){for(var g=[],n="",l=0;l<c.length;l++)l%2&&(n=c[l-1]+c[l],g.push(parseInt(n,16)),n="");return g}return c.map(function(f){return parseInt(f,16)})}var Yt=function(){function c(){Se(this,c)}return Te(c,null,[{key:"parseAnnexB",value:function(n){for(var l=n.length,f=2,v=0;n[f]!==null&&n[f]!==void 0&&n[f]!==1;)f++;if(f++,v=f+2,v>=l)return[];for(var E=[];v<l;)switch(n[v]){case 0:if(n[v-1]!==0){v+=2;break}else if(n[v-2]!==0){v++;break}f!==v-2&&E.push(n.subarray(f,v-2));do v++;while(n[v]!==1&&v<l);f=v+1,v=f+2;break;case 1:if(n[v-1]!==0||n[v-2]!==0){v+=3;break}f!==v-2&&E.push(n.subarray(f,v-2)),f=v+1,v=f+2;break;default:v+=3;break}return f<l&&E.push(n.subarray(f)),E}},{key:"parseAvcC",value:function(n){var l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:4;if(!(n.length<4)){for(var f=n.length,v=[],E=0,_;E+l<f;)if(_=xr(n,E),l===3&&(_>>>=8),E+=l,!!_){if(E+_>f)break;v.push(n.subarray(E,E+_)),E+=_}return v}}},{key:"parseSEI",value:function(n,l){for(var f=n.length,v=l?2:1,E=0,_=0,S="";n[v]===255;)E+=255,v++;for(E+=n[v++];n[v]===255;)_+=255,v++;if(_+=n[v++],E===5&&f>v+16)for(var C=0;C<16;C++)S+=n[v].toString(16),v++;return{payload:n.subarray(v,v+_),type:E,size:_,uuid:S}}},{key:"removeEPB",value:function(n){for(var l=n.byteLength,f=[],v=1;v<l-2;)n[v]===0&&n[v+1]===0&&n[v+2]===3?(f.push(v+2),v+=2):v++;if(!f.length)return n;var E=l-f.length,_=new Uint8Array(E),S=0;for(v=0;v<E;S++,v++)S===f[0]&&(S++,f.shift()),_[v]=n[S];return _}}]),c}();var Mr=function(){function c(g){if(Se(this,c),Q(this,"_bytesAvailable",void 0),Q(this,"_bitsAvailable",0),Q(this,"_word",0),!g)throw new Error("ExpGolomb data params is required");this._data=g,this._bytesAvailable=g.byteLength,this._bytesAvailable&&this._loadWord()}return Te(c,[{key:"bitsAvailable",get:function(){return this._bitsAvailable}},{key:"_loadWord",value:function(){var n=this._data.byteLength-this._bytesAvailable,l=Math.min(4,this._bytesAvailable);if(l===0)throw new Error("No bytes available");var f=new Uint8Array(4);f.set(this._data.subarray(n,n+l)),this._word=new DataView(f.buffer).getUint32(0),this._bitsAvailable=l*8,this._bytesAvailable-=l}},{key:"skipBits",value:function(n){if(this._bitsAvailable>n)this._word<<=n,this._bitsAvailable-=n;else{n-=this._bitsAvailable;var l=Math.floor(n/8);n-=l*8,this._bytesAvailable-=l,this._loadWord(),this._word<<=n,this._bitsAvailable-=n}}},{key:"readBits",value:function(n){if(n>32)throw new Error("Cannot read more than 32 bits");var l=Math.min(this._bitsAvailable,n),f=this._word>>>32-l;return this._bitsAvailable-=l,this._bitsAvailable>0?this._word<<=l:this._bytesAvailable>0&&this._loadWord(),l=n-l,l>0&&this._bitsAvailable?f<<l|this.readBits(l):f}},{key:"skipLZ",value:function(){var n;for(n=0;n<this._bitsAvailable;++n)if(this._word&2147483648>>>n)return this._word<<=n,this._bitsAvailable-=n,n;return this._loadWord(),n+this.skipLZ()}},{key:"skipUEG",value:function(){this.skipBits(1+this.skipLZ())}},{key:"readUEG",value:function(){var n=this.skipLZ();return this.readBits(n+1)-1}},{key:"readEG",value:function(){var n=this.readUEG();return 1&n?1+n>>>1:-1*(n>>>1)}},{key:"readBool",value:function(){return this.readBits(1)===1}},{key:"readUByte",value:function(){return this.readBits(8)}},{key:"skipScalingList",value:function(n){for(var l=8,f=8,v,E=0;E<n;E++)f!==0&&(v=this.readEG(),f=(l+v+256)%256),l=f===0?l:f}}]),c}();var Xs=function(){function c(){Se(this,c)}return Te(c,null,[{key:"parseAVCDecoderConfigurationRecord",value:function(n){if(!(n.length<7)){for(var l=(n[4]&3)+1,f,v=[],E=[],_=6,S=n[5]&31,C,I=0;I<S;I++)if(C=n[_]<<8|n[_+1],_+=2,!!C){var P=n.subarray(_,_+C);_+=C,v.push(P),f||(f=c.parseSPS(Yt.removeEPB(P)))}var H=n[_];_++;for(var W,Y=0;Y<H;Y++)W=n[_]<<8|n[_+1],_+=2,W&&(E.push(n.subarray(_,_+W)),_+=W);return{sps:f,spsArr:v,ppsArr:E,nalUnitSize:l}}}},{key:"parseSPS",value:function(n){var l=new Mr(n);l.readUByte();var f=l.readUByte(),v=l.readUByte(),E=l.readUByte();l.skipUEG();var _=420;if(f===100||f===110||f===122||f===244||f===44||f===83||f===86||f===118||f===128||f===138||f===144){var S=l.readUEG();if(S<=3&&(_=[0,420,422,444][S]),S===3&&l.skipBits(1),l.skipUEG(),l.skipUEG(),l.skipBits(1),l.readBool())for(var C=S!==3?8:12,I=0;I<C;I++)l.readBool()&&(I<6?l.skipScalingList(16):l.skipScalingList(64))}l.skipUEG();var P=l.readUEG();if(P===0)l.readUEG();else if(P===1){l.skipBits(1),l.skipUEG(),l.skipUEG();for(var H=l.readUEG(),W=0;W<H;W++)l.skipUEG()}l.skipUEG(),l.skipBits(1);var Y=l.readUEG(),ee=l.readUEG(),J=l.readBits(1);J===0&&l.skipBits(1),l.skipBits(1);var ae=0,se=0,_e=0,oe=0;l.readBool()&&(ae=l.readUEG(),se=l.readUEG(),_e=l.readUEG(),oe=l.readUEG());var j,ue,Ve,R,le;if(l.readBool()){if(l.readBool()){var G=l.readUByte();switch(G){case 1:j=[1,1];break;case 2:j=[12,11];break;case 3:j=[10,11];break;case 4:j=[16,11];break;case 5:j=[40,33];break;case 6:j=[24,11];break;case 7:j=[20,11];break;case 8:j=[32,11];break;case 9:j=[80,33];break;case 10:j=[18,11];break;case 11:j=[15,11];break;case 12:j=[64,33];break;case 13:j=[160,99];break;case 14:j=[4,3];break;case 15:j=[3,2];break;case 16:j=[2,1];break;case 255:{j=[l.readUByte()<<8|l.readUByte(),l.readUByte()<<8|l.readUByte()];break}}}if(l.readBool()&&l.readBool(),l.readBool()&&(l.readBits(4),l.readBool()&&l.readBits(24)),l.readBool()&&(l.readUEG(),l.readUEG()),l.readBool()){var He=l.readBits(32),F=l.readBits(32);ue=l.readBool(),Ve=F,R=He*2,le=Ve/R}}return{codec:qs(n.subarray(1,4)),profileIdc:f,profileCompatibility:v,levelIdc:E,chromaFormat:_,width:Math.ceil((Y+1)*16-2*(ae+se)),height:(2-J)*(ee+1)*16-(J?2:4)*(_e+oe),sarRatio:j,fpsNum:Ve,fpsDen:R,fps:le,fixedFrame:ue}}}]),c}();var $s=function(){function c(){Se(this,c)}return Te(c,null,[{key:"parseHEVCDecoderConfigurationRecord",value:function(n){var l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!(n.length<23)){l=l||{};for(var f=(n[21]&3)+1,v,E,_=[],S=[],C=[],I=23,P=n[22],H,W,Y,ee=0;ee<P;ee++){H=n[I]&63,W=n[I+1]<<8|n[I+2],I+=3;for(var J=0;J<W;J++)if(Y=n[I]<<8|n[I+1],I+=2,!!Y){switch(H){case 32:{var ae=n.subarray(I,I+Y);v||(v=c.parseVPS(Yt.removeEPB(ae),l)),C.push(ae)}break;case 33:{var se=n.subarray(I,I+Y);E||(E=c.parseSPS(Yt.removeEPB(se),l)),_.push(se)}break;case 34:S.push(n.subarray(I,I+Y));break}I+=Y}}return{hvcC:l,sps:E,spsArr:_,ppsArr:S,vpsArr:C,nalUnitSize:f}}}},{key:"parseVPS",value:function(n,l){l=l||{};var f=new Mr(n);f.readUByte(),f.readUByte(),f.readBits(12);var v=f.readBits(3);return l.numTemporalLayers=Math.max(l.numTemporalLayers||0,v+1),f.readBits(17),c._parseProfileTierLevel(f,v,l),l}},{key:"parseSPS",value:function(n){var l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};l=l||{};var f=new Mr(n);f.readUByte(),f.readUByte(),f.readBits(4);var v=f.readBits(3);l.numTemporalLayers=Math.max(v+1,l.numTemporalLayers||0),l.temporalIdNested=f.readBits(1),c._parseProfileTierLevel(f,v,l),f.readUEG();var E=l.chromaFormatIdc=f.readUEG(),_=420;E<=3&&(_=[0,420,422,444][E]);var S=0;E===3&&(S=f.readBits(1));var C=f.readUEG(),I=f.readUEG(),P=f.readBits(1),H,W,Y,ee;if(P===1&&(H=f.readUEG(),W=f.readUEG(),Y=f.readUEG(),ee=f.readUEG()),l.bitDepthLumaMinus8=f.readUEG(),l.bitDepthChromaMinus8=f.readUEG(),P===1){var J=(E===1||E===2)&&S===0?2:1,ae=E===1&&S===0?2:1;C-=J*(W+H),I-=ae*(ee+Y)}return{codec:"hev1.1.6.L93.B0",width:C,height:I,chromaFormat:_,hvcC:l}}},{key:"_parseProfileTierLevel",value:function(n,l,f){var v=f.generalTierFlag||0;f.generalProfileSpace=n.readBits(2),f.generalTierFlag=Math.max(n.readBits(1),v),f.generalProfileIdc=Math.max(n.readBits(5),f.generalProfileIdc||0),f.generalProfileCompatibilityFlags=n.readBits(32),f.generalConstraintIndicatorFlags=[n.readBits(8),n.readBits(8),n.readBits(8),n.readBits(8),n.readBits(8),n.readBits(8)];var E=n.readBits(8);v<f.generalTierFlag?f.generalLevelIdc=E:f.generalLevelIdc=Math.max(E,f.generalLevelIdc||0);var _=[],S=[];if(l>n.bitsAvailable)throw new Error("maxSubLayersMinus inavlid size ".concat(l));for(var C=0;C<l;C++)_[C]=n.readBits(1),S[C]=n.readBits(1);l>0&&n.readBits((8-l)*2);for(var I=0;I<l;I++)_[I]!==0&&(n.readBits(2),n.readBits(1),n.readBits(5),n.readBits(16),n.readBits(16),n.readBits(4),n.readBits(16),n.readBits(16),n.readBits(12)),S[I]!==0&&n.readBits(8)}}]),c}();var pn=function(){function c(){Se(this,c)}return Te(c,null,[{key:"decode",value:function(n){for(var l=[],f=n,v=0,E=n.length;v<E;){if(f[v]<128){l.push(String.fromCharCode(f[v])),++v;continue}else if(!(f[v]<192)){if(f[v]<224){if(c._checkContinuation(f,v,1)){var _=(f[v]&31)<<6|f[v+1]&63;if(_>=128){l.push(String.fromCharCode(_&65535)),v+=2;continue}}}else if(f[v]<240){if(c._checkContinuation(f,v,2)){var S=(f[v]&15)<<12|(f[v+1]&63)<<6|f[v+2]&63;if(S>=2048&&(S&63488)!==55296){l.push(String.fromCharCode(S&65535)),v+=3;continue}}}else if(f[v]<248&&c._checkContinuation(f,v,3)){var C=(f[v]&7)<<18|(f[v+1]&63)<<12|(f[v+2]&63)<<6|f[v+3]&63;if(C>65536&&C<1114112){C-=65536,l.push(String.fromCharCode(C>>>10|55296)),l.push(String.fromCharCode(C&1023|56320)),v+=4;continue}}}l.push("\uFFFD"),++v}return l.join("")}},{key:"_checkContinuation",value:function(n,l,f){var v=n;if(l+f<v.length){for(;f--;)if((v[++l]&192)!==128)return!1;return!0}else return!1}}]),c}();var Qs=function(){function c(){Se(this,c)}return Te(c,null,[{key:"parse",value:function(n){if(!(n.length<3)){var l={},f=c._parseValue(new DataView(n.buffer,n.byteOffset,n.byteLength)),v=c._parseValue(new DataView(n.buffer,n.byteOffset+f.size,n.byteLength-f.size));return l[f.data]=v.data,l}}},{key:"_parseValue",value:function(n){var l=n.byteLength,f=n.getUint8(0),v=1,E=!1,_;switch(f){case 0:_=n.getFloat64(1),v+=8;break;case 1:{_=!!n.getUint8(1),v+=1;break}case 2:{var S=c._parseString(new DataView(n.buffer,n.byteOffset+v,n.byteLength-v)),C=S.data,I=S.size;_=C,v+=I}break;case 3:{_={};var P=0;for((n.getUint32(l-4)&16777215)===9&&(P=3);v<l-4;){var H=c._parseObject(new DataView(n.buffer,n.byteOffset+v,n.byteLength-v-P)),W=H.size,Y=H.data,ee=H.isEnd;if(ee)break;_[Y.name]=Y.value,v+=W}if(v<=l-3){var J=n.getUint32(v-1)&16777215;J===9&&(v+=3)}}break;case 8:{_={},v+=4;var ae=0;for((n.getUint32(l-4)&16777215)===9&&(ae=3);v<l-8;){var se=c._parseObject(new DataView(n.buffer,n.byteOffset+v,n.byteLength-v-ae)),_e=se.size,oe=se.data,j=se.isEnd;if(j)break;_[oe.name]=oe.value,v+=_e}if(v<=l-3){var ue=n.getUint32(v-1)&16777215;ue===9&&(v+=3)}}break;case 9:_=void 0,v=1,E=!0;break;case 10:{_=[];var Ve=n.getUint32(1);v+=4;for(var R=0;R<Ve;R++){var le=c._parseValue(new DataView(n.buffer,n.byteOffset+v,n.byteLength-v)),G=le.data,He=le.size;_.push(G),v+=He}}break;case 11:{var F=n.getFloat64(v)+n.getInt16(v+8)*6e4;_=new Date(F),v+=10}break;case 12:{var O=n.getUint32(1);v+=4,_="",O>0&&(_=pn.decode(new Uint8Array(n.buffer,n.byteOffset+v,O))),v+=O}break;default:v=l;break}return{data:_,size:v,isEnd:E}}},{key:"_parseString",value:function(n){var l=n.getUint16(0),f="";return l>0&&(f=pn.decode(new Uint8Array(n.buffer,n.byteOffset+2,l))),{data:f,size:2+l}}},{key:"_parseObject",value:function(n){if(!(n.byteLength<3)){var l=c._parseString(n),f=c._parseValue(new DataView(n.buffer,n.byteOffset+l.size,n.byteLength-l.size));return{data:{name:l.data,value:f.data},size:l.size+f.size,isEnd:f.isEnd}}}}]),c}();var Ft={MP3:2,G711A:7,G711M:8,AAC:10,OPUS:13};var Nt=new fr("FlvDemuxer"),vi=function(){function c(g,n,l){Se(this,c),Q(this,"_headerParsed",!1),Q(this,"_remainingData",null),Q(this,"_gopId",0),Q(this,"_needAddMetaBeforeKeyFrameNal",!0),this.videoTrack=g||new Os,this.audioTrack=n||new Ms,this.metadataTrack=l||new Gs,this._fixer=new Ys(this.videoTrack,this.audioTrack,this.metadataTrack)}return Te(c,[{key:"demux",value:function(n){var l,f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,v=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,E=arguments.length>3?arguments[3]:void 0,_=this.audioTrack,S=this.videoTrack,C=this.metadataTrack;if((f||!v)&&(this._remainingData=null),f&&(this._headerParsed=!1),f?(S.reset(),_.reset(),C.reset()):(S.samples=[],_.samples=[],C.seiSamples=[],C.flvScriptSamples=[],S.warnings=[],_.warnings=[],this._remainingData&&(n=xt(this._remainingData,n),this._remainingData=null)),!n.length)return{videoTrack:S,audioTrack:_,metadataTrack:C};var I=0;if(!this._headerParsed){if(!c.probe(n))throw new Error("Invalid flv file");_.present=(n[4]&4)>>>2!==0,S.present=(n[4]&1)!==0,this._headerParsed=!0,I=xr(n,5)+4}for(var P=n.length,H,W,Y,ee,J;I+15<P&&(H=n[I],W=n[I+1]<<16|n[I+2]<<8|n[I+3],!(I+15+W>P));)Y=(n[I+7]<<24>>>0)+(n[I+4]<<16)+(n[I+5]<<8)+n[I+6],I+=11,ee=n.subarray(I,I+W),H===8?this._parseAudio(ee,Y):H===9?(E&&(this.seamlessLoadingSwitching=!0),this._parseVideo(ee,Y)):H===18?this._parseScript(ee,Y):Nt.warn("Invalid tag type: ".concat(H)),I+=W,J=xr(n,I),J!==11+W&&Nt.warn("Invalid PrevTagSize ".concat(J," (").concat(11+W,")")),I+=4;I<P&&(this._remainingData=n.subarray(I)),_.formatTimescale=S.formatTimescale=S.timescale=C.timescale=1e3,_.timescale=_.codecType===We.OPUS?1e3:_.sampleRate||0,!_.exist()&&_.hasSample()&&_.reset(),!S.exist()&&S.hasSample()&&S.reset();var ae=C.flvScriptSamples[C.flvScriptSamples.length-1],se=ae==null||(l=ae.data)===null||l===void 0?void 0:l.onMetaData;return se&&(S!=null&&S.exist()&&(se.hasOwnProperty("duration")&&(S.duration=se.duration*1e3),se.hasOwnProperty("width")&&se.hasOwnProperty("height")&&(S.width=se.width,S.height=se.height)),_!=null&&_.exist()&&se.hasOwnProperty("duration")&&(_.duration=se.duration*1e3)),{videoTrack:S,audioTrack:_,metadataTrack:C}}},{key:"fix",value:function(n,l,f){return this._fixer.fix(n,l,f),{videoTrack:this.videoTrack,audioTrack:this.audioTrack,metadataTrack:this.metadataTrack}}},{key:"demuxAndFix",value:function(n,l,f,v,E){return this.demux(n,l,f,E),this.fix(v,l,f)}},{key:"_parseAudio",value:function(n,l){if(n.length){var f=(n[0]&240)>>>4,v=this.audioTrack;if(f!==Ft.AAC&&f!==Ft.G711A&&f!==Ft.G711M&&f!==Ft.OPUS){Nt.warn("Unsupported sound format: ".concat(f)),v.reset();return}if(f!==Ft.AAC&&f!==Ft.OPUS){var E=(n[0]&12)>>2,_=(n[0]&2)>>1,S=n[0]&1;v.sampleRate=c.AUDIO_RATE[E],v.sampleSize=_?16:8,v.channelCount=S+1}switch(f){case Ft.G711A:case Ft.G711M:this._parseG711(n,l,f);break;case Ft.AAC:this._parseAac(n,l);break;case Ft.OPUS:this._parseOpus(n,l);break}}}},{key:"_parseOpus",value:function(n,l){var f=this.audioTrack,v=n[1];switch(f.codecType=We.OPUS,v){case 0:{var E=Or.parseHeaderPackets(n.subarray(2));E?(f.codec=E.codec,f.channelCount=E.channelCount,f.sampleRate=E.sampleRate,f.config=E.config,f.sampleDuration=Or.getFrameDuration([],f.timescale)):(f.reset(),Nt.warn("Cannot parse AudioSpecificConfig",n));break}case 1:{if(l==null)return;var _=new Sr(l,n.subarray(2),f.sampleDuration);f.samples.push(_);break}default:Nt.warn("Unknown OpusPacketType: ".concat(v))}}},{key:"_parseG711",value:function(n,l,f){var v=this.audioTrack;v.codecType=f===7?We.G711PCMA:We.G711PCMU,v.sampleRate=8e3,v.codec=v.codecType,v.samples.push(new Sr(l,n.subarray(1)))}},{key:"_parseAac",value:function(n,l){var f=this.audioTrack;if(f.codecType=We.AAC,n[1]===0){var v=Tr.parseAudioSpecificConfig(n.subarray(2));v?(f.codec=v.codec,f.channelCount=v.channelCount,f.sampleRate=v.sampleRate,f.config=v.config,f.objectType=v.objectType,f.sampleRateIndex=v.samplingFrequencyIndex):(f.reset(),Nt.warn("Cannot parse AudioSpecificConfig",n))}else if(n[1]===1){if(l==null)return;f.samples.push(new Sr(l,n.subarray(2)))}else Nt.warn("Unknown AACPacketType: ".concat(n[1]))}},{key:"_parseVideo",value:function(n,l){var f=this;if(!(n.length<6)){var v=(n[0]&240)>>>4,E=n[0]&15,_=this.videoTrack;if(E!==7&&E!==12){_.reset(),Nt.warn("Unsupported codecId: ".concat(E));return}var S=E===12;_.codecType=S?zt.HEVC:zt.AVC;var C=n[1],I=(n[2]<<16|n[3]<<8|n[4])<<8>>8;if(C===0){var P=n.subarray(5),H=S?$s.parseHEVCDecoderConfigurationRecord(P):Xs.parseAVCDecoderConfigurationRecord(P);if(H){var W=H.hvcC,Y=H.sps,ee=H.ppsArr,J=H.spsArr,ae=H.vpsArr,se=H.nalUnitSize;W&&(_.hvcC=_.hvcC||W),Y&&(_.codec=Y.codec,_.width=Y.width,_.height=Y.height,_.sarRatio=Y.sarRatio,_.fpsNum=Y.fpsNum,_.fpsDen=Y.fpsDen),J.length&&(_.sps=J),ee.length&&(_.pps=ee),ae&&ae.length&&(_.vps=ae),se&&(_.nalUnitSize=se)}else Nt.warn("Cannot parse ".concat(S?"HEVC":"AVC","DecoderConfigurationRecord"),n)}else if(C===1){var _e=Yt.parseAvcC(n.subarray(5),_.nalUnitSize);if(_e=this._checkAddMetaNalToUnits(S,_e,_),_e&&_e.length){var oe=new Fs(l+I,l,_e);if(this.seamlessLoadingSwitching&&l<_.lastKeyFrameDts)return;this.seamlessLoadingSwitching=!1,v===1&&(oe.setToKeyframe(),_.lastKeyFrameDts=l),_.samples.push(oe),_e.forEach(function(j){var ue=S?j[0]>>>1&63:j[0]&31;switch(ue){case 5:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:if(!S&&ue!==5||S&&ue===5)break;oe.setToKeyframe();break;case 6:case 39:case 40:if(!S&&ue!==6||S&&ue===6)break;f.metadataTrack.seiSamples.push(new Bs(Yt.parseSEI(Yt.removeEPB(j),S),l+I));break}}),oe.keyframe&&this._gopId++,oe.gopId=this._gopId}else Nt.warn("Cannot parse NALUs",n)}else C===2||Nt.warn("Unknown AVCPacketType: ".concat(C))}}},{key:"_checkAddMetaNalToUnits",value:function(n,l,f){if(!n||!this._needAddMetaBeforeKeyFrameNal)return this._needAddMetaBeforeKeyFrameNal=!1,l;var v=l.map(function(E){return E[0]>>>1&63});return v.includes(32)?(this._needAddMetaBeforeKeyFrameNal=!1,l):(l.unshift(f.pps[0]),l.unshift(f.sps[0]),l.unshift(f.vps[0]),l.filter(Boolean))}},{key:"_parseScript",value:function(n,l){this.metadataTrack.flvScriptSamples.push(new Us(Qs.parse(n),l))}}],[{key:"probe",value:function(n){return n[0]!==70||n[1]!==76||n[2]!==86||n[3]!==1?!1:xr(n,5)>=9}}]),c}();Q(vi,"AUDIO_RATE",[5500,11e3,22e3,44e3]);function Qf(c){for(var g=0,n=arguments.length,l=new Array(n>1?n-1:0),f=1;f<n;f++)l[f-1]=arguments[f];l.forEach(function(_){g+=_.length});var v=new c(g),E=0;return l.forEach(function(_){v.set(_,E),E+=_.length}),v}var lt=function(){function c(){Se(this,c),this.buffer=new Uint8Array(0)}return Te(c,[{key:"write",value:function(){for(var n=this,l=arguments.length,f=new Array(l),v=0;v<l;v++)f[v]=arguments[v];f.forEach(function(E){E?n.buffer=Qf(Uint8Array,n.buffer,E):window.console.warn(E)})}}],[{key:"writeUint16",value:function(n){return new Uint8Array([n>>8&255,n&255])}},{key:"writeUint32",value:function(n){return new Uint8Array([n>>24,n>>16&255,n>>8&255,n&255])}}]),c}();var Js=Math.pow(2,32)-1,xe=function(){function c(){Se(this,c)}return Te(c,null,[{key:"box",value:function(n){for(var l=arguments.length,f=new Array(l>1?l-1:0),v=1;v<l;v++)f[v-1]=arguments[v];f=f.filter(Boolean);var E=8+f.reduce(function(C,I){return C+I.byteLength},0),_=new Uint8Array(E);_[0]=E>>24&255,_[1]=E>>16&255,_[2]=E>>8&255,_[3]=E&255,_.set(n,4);var S=8;return f.forEach(function(C){_.set(C,S),S+=C.byteLength}),_}},{key:"ftyp",value:function(n){var l=n.find(function(f){return f.type===Mt.VIDEO&&f.codecType===zt.HEVC});return l?c.FTYPHEV1:c.FTYPAVC1}},{key:"initSegment",value:function(n){var l=c.ftyp(n),f=xt(l,c.moov(n));return f}},{key:"pssh",value:function(n){var l=new Uint8Array([1,0,0,0].concat([16,119,239,236,192,178,77,2,172,227,60,30,82,226,251,75],[0,0,0,1],vn(n.kid),[0,0,0,0]));return c.box(c.types.pssh,l)}},{key:"moov",value:function(n){if(n[0].useEME&&(n[0].encv||n[0].enca)){n[0].pssh||(n[0].pssh={kid:n[0].kid});var l=this.pssh(n[0].pssh);return c.box.apply(c,[c.types.moov,c.mvhd(n[0].mvhdDurtion||n[0].duration,n[0].mvhdTimecale||n[0].timescale),c.mvex(n)].concat(Ot(n.map(function(f){return c.trak(f)})),[l]))}else return c.box.apply(c,[c.types.moov,c.mvhd(n[0].mvhdDurtion||n[0].duration,n[0].mvhdTimecale||n[0].timescale)].concat(Ot(n.map(function(f){return c.trak(f)})),[c.mvex(n)]))}},{key:"mvhd",value:function(n){var l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:9e4,f=c.box(c.types.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,l>>24&255,l>>16&255,l>>8&255,l&255,n>>24&255,n>>16&255,n>>8&255,n&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]));return f}},{key:"trak",value:function(n){var l=c.box(c.types.trak,c.tkhd(n.id,n.tkhdDuration||0,n.width,n.height),c.mdia(n));return l}},{key:"tkhd",value:function(n,l){var f=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,v=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,E=c.box(c.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,n>>24&255,n>>16&255,n>>8&255,n&255,0,0,0,0,l>>24&255,l>>16&255,l>>8&255,l&255,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,f>>8&255,f&255,0,0,v>>8&255,v&255,0,0]));return E}},{key:"mdia",value:function(n){var l=c.box(c.types.mdia,c.mdhd(n.duration,n.timescale),c.hdlr(n.type),c.minf(n));return l}},{key:"mdhd",value:function(n){var l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:9e4,f=c.box(c.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,l>>24&255,l>>16&255,l>>8&255,l&255,n>>24&255,n>>16&255,n>>8&255,n&255,85,196,0,0]));return f}},{key:"hdlr",value:function(n){var l=c.box(c.types.hdlr,c.HDLR_TYPES[n]);return l}},{key:"minf",value:function(n){var l=c.box(c.types.minf,n.type===Mt.VIDEO?c.VMHD:c.SMHD,c.DINF,c.stbl(n));return l}},{key:"stbl",value:function(n){var l=[];n&&n.ext&&n.ext.stss&&l.push(c.stss(n.ext.stss.entries));var f=c.box(c.types.stbl,c.stsd(n),c.STTS,l[0],c.STSC,c.STSZ,c.STCO);return f}},{key:"stsd",value:function(n){var l;n.type==="audio"?n.useEME&&n.enca?l=c.enca(n):n.codecType===We.OPUS?l=c.opus(n):l=c.mp4a(n):n.useEME&&n.encv?l=c.encv(n):n.av1C?l=c.av01(n):l=c.avc1hev1(n);var f=c.box(c.types.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),l);return f}},{key:"enca",value:function(n){var l=n.enca.channelCount,f=n.enca.sampleRate,v=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,l,0,16,0,0,0,0,f>>8&255,f&255,0,0]),E=c.esds(n.config),_=c.sinf(n.enca);return c.box(c.types.enca,v,E,_)}},{key:"encv",value:function(n){var l,f,v=n.sps.length>0?n.sps[0]:[],E=n.pps.length>0?n.pps[0]:[],_=n.width,S=n.height,C=n.sarRatio[0],I=n.sarRatio[1],P=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,_>>8&255,_&255,S>>8&255,S&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),H=new Uint8Array((l=(f=[1,v[1],v[2],v[3],255,225,v.length>>>8&255,v.length&255]).concat.apply(f,Ot(v)).concat([1,E.length>>>8&255,E.length&255])).concat.apply(l,Ot(E))),W=new Uint8Array([0,0,88,57,0,15,200,192,0,4,86,72]),Y=c.sinf(n.encv),ee=new Uint8Array([C>>24,C>>16&255,C>>8&255,C&255,I>>24,I>>16&255,I>>8&255,I&255]);return c.box(c.types.encv,P,c.box(c.types.avcC,H),c.box(c.types.btrt,W),Y,c.box(c.types.pasp,ee))}},{key:"schi",value:function(n){var l=new Uint8Array([]),f=c.tenc(n);return c.box(c.types.schi,l,f)}},{key:"tenc",value:function(n){var l=new Uint8Array([0,0,0,0,0,0,n.default_IsEncrypted&255,n.default_IV_size&255].concat(vn(n.default_KID)));return c.box(c.types.tenc,l)}},{key:"sinf",value:function(n){var l=new Uint8Array([]),f=new Uint8Array([n.data_format.charCodeAt(0),n.data_format.charCodeAt(1),n.data_format.charCodeAt(2),n.data_format.charCodeAt(3)]),v=new Uint8Array([0,0,0,0,99,101,110,99,0,1,0,0]),E=c.schi(n);return c.box(c.types.sinf,l,c.box(c.types.frma,f),c.box(c.types.schm,v),E)}},{key:"av01",value:function(n){return c.box(c.types.av01,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,n.width>>8&255,n.width&255,n.height>>8&255,n.height&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),n.av1C,n.colr)}},{key:"avc1hev1",value:function(n){var l=n.codecType===zt.HEVC,f=l?c.types.hvc1:c.types.avc1,v=l?c.hvcC(n):c.avcC(n),E=[new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,n.width>>8&255,n.width&255,n.height>>8&255,n.height&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),v];return l?E.push(c.box(c.types.fiel,new Uint8Array([1,0]))):n.sarRatio&&n.sarRatio.length>1&&E.push(c.pasp(n.sarRatio)),c.box.apply(c,[f].concat(E))}},{key:"avcC",value:function(n){var l,f,v=[],E=[],_;return n.sps.forEach(function(S){_=S.byteLength,v.push(_>>>8&255),v.push(_&255),v.push.apply(v,Ot(S))}),n.pps.forEach(function(S){_=S.byteLength,E.push(_>>>8&255),E.push(_&255),E.push.apply(E,Ot(S))}),c.box(c.types.avcC,new Uint8Array((l=(f=[1,v[3],v[4],v[5],255,224|n.sps.length]).concat.apply(f,v).concat([n.pps.length])).concat.apply(l,E)))}},{key:"hvcC",value:function(n){var l=n.hvcC;if(l instanceof ArrayBuffer||l instanceof Uint8Array)return l;var f=n.vps,v=n.sps,E=n.pps,_;if(l){var S=l.generalProfileCompatibilityFlags,C=l.generalConstraintIndicatorFlags,I=(f.length&&1)+(v.length&&1)+(E.length&&1);_=[1,l.generalProfileSpace<<6|l.generalTierFlag<<5|l.generalProfileIdc,S>>>24,S>>>16,S>>>8,S,C[0],C[1],C[2],C[3],C[4],C[5],l.generalLevelIdc,240,0,252,l.chromaFormatIdc|252,l.bitDepthLumaMinus8|248,l.bitDepthChromaMinus8|248,0,0,l.numTemporalLayers<<3|l.temporalIdNested<<2|3,I];var P=function(W){var Y;_.push(W.length>>8,W.length),(Y=_).push.apply(Y,Ot(W))};f.length&&(_.push(160,0,f.length),f.forEach(P)),v.length&&(_.push(161,0,v.length),v.forEach(P)),E.length&&(_.push(162,0,E.length),E.forEach(P))}else _=[1,1,96,0,0,0,144,0,0,0,0,0,93,240,0,252,253,248,248,0,0,15,3,160,0,1,0,24,64,1,12,1,255,255,1,96,0,0,3,0,144,0,0,3,0,0,3,0,93,153,152,9,161,0,1,0,45,66,1,1,1,96,0,0,3,0,144,0,0,3,0,0,3,0,93,160,2,128,128,45,22,89,153,164,147,43,154,128,128,128,130,0,0,3,0,2,0,0,3,0,50,16,162,0,1,0,7,68,1,193,114,180,98,64];return c.box(c.types.hvcC,new Uint8Array(_))}},{key:"pasp",value:function(n){var l=Is(n,2),f=l[0],v=l[1];return c.box(c.types.pasp,new Uint8Array([f>>24,f>>16&255,f>>8&255,f&255,v>>24,v>>16&255,v>>8&255,v&255]))}},{key:"mp4a",value:function(n){return c.box(c.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,n.channelCount,0,16,0,0,0,0,n.sampleRate>>8&255,n.sampleRate&255,0,0]),n.config.length?c.esds(n.config):void 0)}},{key:"esds",value:function(n){var l=n.length,f=c.box(c.types.esds,new Uint8Array([0,0,0,0,3,23+l,0,0,0,4,15+l,64,21,0,6,0,0,0,218,192,0,0,218,192,5].concat([l]).concat(n).concat([6,1,2])));return f}},{key:"opus",value:function(n){var l=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,n.channelCount,0,16,0,0,0,0,n.sampleRate>>8&255,n.sampleRate&255,0,0]),f=n.config.length?c.dOps(n):[];return c.box(c.types.Opus,l,f)}},{key:"dOps",value:function(n){if(n.config)return n.config[4]=n.sampleRate>>>24&255,n.config[5]=n.sampleRate>>>16&255,n.config[6]=n.sampleRate>>>8&255,n.config[7]=n.sampleRate&255,c.box(c.types.dOps,n.config)}},{key:"mvex",value:function(n){var l=c.box.apply(c,[c.types.mvex].concat(Ot(n.map(function(f){return c.trex(f.id)}))));return l}},{key:"trex",value:function(n){var l=c.box(c.types.trex,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,n&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]));return l}},{key:"trex1",value:function(n){var l=c.box(c.types.trex,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,n&255,0,0,0,1,0,0,2,0,0,0,0,0,0,1,0,0]));return l}},{key:"trex2",value:function(n){var l=c.box(c.types.trex,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,n&255,0,0,0,1,0,0,4,0,0,0,0,0,2,0,0,0]));return l}},{key:"moof",value:function(n){var l=c.box.apply(c,[c.types.moof,c.mfhd(n[0].samples?n[0].samples[0].gopId:0)].concat(Ot(n.map(function(f){return c.traf(f)}))));return l}},{key:"mfhd",value:function(n){var l=c.box(c.types.mfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,n&255]));return l}},{key:"traf",value:function(n){var l=c.tfhd(n.id),f=c.tfdt(n,n.baseMediaDecodeTime),v=0,E;if(n.isVideo&&n.videoSenc&&(E=n.videoSenc,E.forEach(function(O){v=v+8,O.subsamples&&O.subsamples.length&&(v=v+2,v=v+O.subsamples.length*6)})),n.videoSencLength=v,!n.useEME||!n.isVideoEncryption&&!n.isAudioEncryption){var _=c.sdtp(n),S=76;return c.box(c.types.traf,l,f,_,c.trun(n.samples,_.byteLength+S))}else if(n.isVideoEncryption)if(n.isVideo){var C=c.saiz(n),I=c.saio(n),P=c.trun1(n),H=c.senc(n),W=c.box(c.types.traf,l,f,C,I,P,H);return W}else if(n.isAudioEncryption){var J=c.sbgp(),ae=c.saiz(n),se=c.saio(n),_e=c.senc(n),oe=c.trun1(n),j=c.box(c.types.traf,l,f,J,ae,se,_e,oe);return j}else{var Y=c.sbgp(),ee=c.trun1(n);return c.box(c.types.traf,l,f,Y,ee)}else if(n.isVideo){var ue=c.trun1(n);return c.box(c.types.traf,l,f,ue)}else{var Ve=c.sbgp(),R=c.saiz(n),le=c.saio(n),G=c.senc(n),He=c.trun1(n),F=c.box(c.types.traf,l,f,Ve,R,le,G,He);return F}}},{key:"sdtp",value:function(n){var l=new lt;return n.samples.forEach(function(f){l.write(new Uint8Array(n.isVideo?[f.keyframe?32:16]:[16]))}),c.box(c.types.sdtp,this.extension(0,0),l.buffer)}},{key:"trun1",value:function(n){var l=new lt,f=lt.writeUint32(n.samples.length),v=null;if(n.isVideo){var E=n.videoSencLength;v=lt.writeUint32(n.samples.length*16+E+149),!n.isVideoEncryption&&n.isAudioEncryption&&(v=lt.writeUint32(n.samples.length*16+92))}else{var _=n.samples.length*12+124;n.isAudioEncryption&&(_=n.samples.length*12+8*n.audioSenc.length+177),v=lt.writeUint32(_)}return n.samples.forEach(function(S){l.write(lt.writeUint32(S.duration)),l.write(lt.writeUint32(S.size)),l.write(lt.writeUint32(S.keyframe?33554432:65536)),n.isVideo&&l.write(lt.writeUint32(S.cts?S.cts:0))}),c.box(c.types.trun,this.extension(0,n.flags),f,v,l.buffer)}},{key:"senc",value:function(n){var l=new lt,f=n.samples.length,v=n.isVideo?16:8,E=n.isVideo?2:0,_=[],S=0;return n.isVideo?(_=n.videoSenc,S=n.videoSencLength):_=n.audioSenc,S=S||v*f,l.write(lt.writeUint32(16+S),c.types.senc,this.extension(0,E)),l.write(lt.writeUint32(f)),_.forEach(function(C){for(var I=0;I<C.InitializationVector.length;I++)l.write(new Uint8Array([C.InitializationVector[I]]));C.subsamples&&C.subsamples.length&&(l.write(lt.writeUint16(C.subsamples.length)),C.subsamples.forEach(function(P){l.write(lt.writeUint16(P.BytesOfClearData)),l.write(lt.writeUint32(P.BytesOfProtectedData))}))}),l.buffer}},{key:"saio",value:function(n){var l=n.samples.length*12+141;!n.isVideo&&n.isAudioEncryption&&(l=149);var f=new Uint8Array([1,0,0,0,0,0,0,1,0,0,0,0,l>>24&255,l>>16&255,l>>8&255,l&255]);return c.box(c.types.saio,f)}},{key:"saiz",value:function(n){var l=n.samples.length,f=new Uint8Array([0,0,0,0,16,l>>24&255,l>>16&255,l>>8&255,l&255]);return c.box(c.types.saiz,f)}},{key:"sbgp",value:function(){var n=new Uint8Array([114,111,108,108,0,0,0,1,0,0,1,25,0,0,0,1]);return c.box(c.types.sbgp,this.extension(0,0),n)}},{key:"extension",value:function(n,l){return new Uint8Array([n,l>>16&255,l>>8&255,l&255])}},{key:"tfhd",value:function(n){return c.box(c.types.tfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,n&255]))}},{key:"tfdt",value:function(n,l){var f=Math.floor(l/(Js+1)),v=Math.floor(l%(Js+1));return n.useEME&&(n.isVideoEncryption||n.isAudioEncryption)?c.box(c.types.tfdt,new Uint8Array([0,0,0,0,v>>24,v>>16&255,v>>8&255,v&255])):c.box(c.types.tfdt,new Uint8Array([1,0,0,0,f>>24,f>>16&255,f>>8&255,f&255,v>>24,v>>16&255,v>>8&255,v&255]))}},{key:"trun",value:function(n,l){var f=n.length,v=12+16*f;l+=8+v;var E=new Uint8Array(v);E.set([0,0,15,1,f>>>24&255,f>>>16&255,f>>>8&255,f&255,l>>>24&255,l>>>16&255,l>>>8&255,l&255],0);for(var _=0;_<f;_++){var S=n[_],C=S.duration,I=S.size,P=S.flag,H=P===void 0?{}:P,W=S.cts,Y=W===void 0?0:W;E.set([C>>>24&255,C>>>16&255,C>>>8&255,C&255,I>>>24&255,I>>>16&255,I>>>8&255,I&255,H.isLeading<<2|(H.dependsOn===null||H.dependsOn===void 0?1:H.dependsOn),H.isDependedOn<<6|H.hasRedundancy<<4|H.paddingValue<<1|(H.isNonSyncSample===null||H.isNonSyncSample===void 0?1:H.isNonSyncSample),H.degradationPriority&61440,H.degradationPriority&15,Y>>>24&255,Y>>>16&255,Y>>>8&255,Y&255],12+16*_)}return c.box(c.types.trun,E)}},{key:"moovMP4",value:function(n){return c.box.apply(c,[c.types.moov,c.mvhd(n[0].duration,n[0].timescale)].concat(Ot(n.map(function(l){return c.trackMP4(l)}))))}},{key:"trackMP4",value:function(n){return c.box(c.types.trak,c.tkhd(n.id,n.duration,n.width,n.height),c.mdiaMP4(n))}},{key:"mdiaMP4",value:function(n){return c.box(c.types.mdia,c.mdhd(n.duration,n.timescale),c.hdlr(n.type),c.minfMP4(n))}},{key:"minfMP4",value:function(n){return c.box(c.types.minf,n.type===Mt.VIDEO?c.VMHD:c.SMHD,c.DINF,c.stblMP4(n))}},{key:"stblMP4",value:function(n){var l=n.ext,f=[c.stsd(n),c.stts(l.stts),c.stsc(l.stsc),c.stsz(l.stsz),c.stco(l.stco)];return l.stss.length&&f.push(c.stss(l.stss)),l.ctts.length&&f.push(c.ctts(l.ctts)),c.box.apply(c,[c.types.stbl].concat(f))}},{key:"stts",value:function(n){var l=n.length,f=new Uint8Array(8*l),v=0;return n.forEach(function(E){var _=E.value,S=E.count;f.set([S>>24,S>>16&255,S>>8&255,S&255,_>>24,_>>16&255,_>>8&255,_&255],v),v+=8}),c.box(c.types.stts,xt(new Uint8Array([0,0,0,0,l>>24,l>>16&255,l>>8&255,l&255]),f))}},{key:"stsc",value:function(n){var l=n.length,f=new Uint8Array(12*l),v=0;return n.forEach(function(E){var _=E.firstChunk,S=E.samplesPerChunk,C=E.sampleDescIndex;f.set([_>>24,_>>16&255,_>>8&255,_&255,S>>24,S>>16&255,S>>8&255,S&255,C>>24,C>>16&255,C>>8&255,C&255],v),v+=12}),c.box(c.types.stsc,xt(new Uint8Array([0,0,0,0,l>>24,l>>16&255,l>>8&255,l&255]),f))}},{key:"stsz",value:function(n){var l=n.length,f=new Uint8Array(4*l),v=0;return n.forEach(function(E){f.set([E>>24,E>>16&255,E>>8&255,E&255],v),v+=4}),c.box(c.types.stsz,xt(new Uint8Array([0,0,0,0,0,0,0,0,l>>24,l>>16&255,l>>8&255,l&255]),f))}},{key:"stco",value:function(n){var l=n.length,f=new Uint8Array(4*l),v=0;return n.forEach(function(E){f.set([E>>24,E>>16&255,E>>8&255,E&255],v),v+=4}),c.box(c.types.stco,xt(new Uint8Array([0,0,0,0,l>>24,l>>16&255,l>>8&255,l&255]),f))}},{key:"stss",value:function(n){var l=n.length,f=new Uint8Array(4*l),v=0;return n.forEach(function(E){f.set([E>>24,E>>16&255,E>>8&255,E&255],v),v+=4}),c.box(c.types.stss,xt(new Uint8Array([0,0,0,0,l>>24,l>>16&255,l>>8&255,l&255]),f))}},{key:"ctts",value:function(n){var l=n.length,f=new Uint8Array(8*l),v=0;return n.forEach(function(E){var _=E.value,S=E.count;f.set([S>>24,S>>16&255,S>>8&255,S&255,_>>24,_>>16&255,_>>8&255,_&255],v),v+=8}),c.box(c.types.ctts,xt(new Uint8Array([0,0,0,0,l>>24,l>>16&255,l>>8&255,l&255]),f))}},{key:"styp",value:function(){return c.box(c.types.styp,new Uint8Array([109,115,100,104,0,0,0,0,109,115,100,104,109,115,105,120]))}},{key:"sidx",value:function(n){var l=n.timescale,f=n.samples[0].duration,v=f*n.samples.length,E=n.samples[0].sampleOffset*f,_=8;n.samples.forEach(function(H){_+=H.size});var S=0;if(n.isVideo){var C=0,I;n.videoSenc&&(I=n.videoSenc),n.isVideo&&I.forEach(function(H){C=C+8,H.subsamples&&H.subsamples.length&&(C=C+2,C=C+H.subsamples.length*6)}),n.videoSencLength=C,S=_+141+n.samples.length*16+C,n.useEME&&n.isAudioEncryption&&!n.isVideoEncryption&&(S=_+n.samples.length*16+84)}else S=_+116+n.samples.length*12,n.useEME&&n.isAudioEncryption&&(S=_+169+n.samples.length*12+8*n.audioSenc.length);var P=new Uint8Array([0,0,0,0,0,0,0,n.id&255,l>>24&255,l>>16&255,l>>8&255,l&255,E>>24&255,E>>16&255,E>>8&255,E&255,0,0,0,0,0,0,0,1,0,S>>16&255,S>>8&255,S&255,v>>24&255,v>>16&255,v>>8&255,v&255,144,0,0,0]);return c.box(c.types.sidx,P)}},{key:"mdat",value:function(n){var l=c.box(c.types.mdat,n);return l}}]),c}();Q(xe,"types",["Opus","dOps","av01","av1C","avc1","avcC","hvc1","hvcC","dinf","dref","esds","ftyp","hdlr","mdat","mdhd","mdia","mfhd","minf","moof","moov","mp4a","mvex","mvhd","pasp","stbl","stco","stsc","stsd","stsz","stts","tfdt","tfhd","traf","trak","trex","tkhd","vmhd","smhd","ctts","stss","styp","pssh","sidx","sbgp","saiz","saio","senc","trun","encv","enca","sinf","btrt","frma","tenc","schm","schi","mehd","fiel","sdtp"].reduce(function(c,g){return c[g]=[g.charCodeAt(0),g.charCodeAt(1),g.charCodeAt(2),g.charCodeAt(3)],c},Object.create(null)));Q(xe,"HDLR_TYPES",{video:new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),audio:new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0])});Q(xe,"FTYPAVC1",xe.box(xe.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49])));Q(xe,"FTYPHEV1",xe.box(xe.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,104,101,118,49])));Q(xe,"DINF",xe.box(xe.types.dinf,xe.box(xe.types.dref,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]))));Q(xe,"VMHD",xe.box(xe.types.vmhd,new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])));Q(xe,"SMHD",xe.box(xe.types.smhd,new Uint8Array([0,0,0,0,0,0,0,0])));Q(xe,"StblTable",new Uint8Array([0,0,0,0,0,0,0,0]));Q(xe,"STTS",xe.box(xe.types.stts,xe.StblTable));Q(xe,"STSC",xe.box(xe.types.stsc,xe.StblTable));Q(xe,"STSZ",xe.box(xe.types.stsz,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0])));Q(xe,"STCO",xe.box(xe.types.stco,xe.StblTable));var mn=function(){function c(g,n){Se(this,c),this.name=g||"",this._prefix="[".concat(this.name,"]"),c.disabled=n}return Te(c,[{key:"debug",value:function(){var n;if(!c.disabled){for(var l=arguments.length,f=new Array(l),v=0;v<l;v++)f[v]=arguments[v];(n=console).debug.apply(n,[this._prefix].concat(f))}}},{key:"log",value:function(){var n;if(!c.disabled){for(var l=arguments.length,f=new Array(l),v=0;v<l;v++)f[v]=arguments[v];(n=console).log.apply(n,[this._prefix].concat(f))}}},{key:"warn",value:function(){var n;if(!c.disabled){for(var l=arguments.length,f=new Array(l),v=0;v<l;v++)f[v]=arguments[v];(n=console).warn.apply(n,[this._prefix].concat(f))}}},{key:"error",value:function(){var n;if(!c.disabled){for(var l=arguments.length,f=new Array(l),v=0;v<l;v++)f[v]=arguments[v];(n=console).error.apply(n,[this._prefix].concat(f))}}},{key:"table",value:function(){var n;c.disabled||(console.group(this._prefix),(n=console).table.apply(n,arguments),console.groupEnd())}}],[{key:"enable",value:function(){c.disabled=!1}},{key:"disable",value:function(){c.disabled=!0}}]),c}();Q(mn,"disabled",!0);var gn=function(){function c(g,n,l){Se(this,c),this.videoTrack=g,this.audioTrack=n;var f=/Chrome\/([^.]+)/.exec(navigator.userAgent);this.forceFirstIDR=f&&Number(f[1])<50,this.log=new mn("FMP4Remuxer",l&&l.openLog?!l.openLog:!0)}return Te(c,[{key:"remux",value:function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},f=this.videoTrack,v=this.audioTrack,E=f.exist(),_=v.exist(),S,C,I,P=[];n&&(l&&l.initMerge?(E&&P.push(this.videoTrack),_&&P.push(this.audioTrack),I=xe.initSegment(P)):(E&&(S=xe.initSegment([this.videoTrack])),_&&(C=xe.initSegment([this.audioTrack]))));var H,W;return E&&f.hasSample()&&(H=this._remuxVideo()),_&&v.hasSample()&&(W=this._remuxAudio()),f.samples=[],v.samples=[],{initSegment:I,videoInitSegment:S,audioInitSegment:C,videoSegment:H,audioSegment:W}}},{key:"_remuxVideo",value:function(){var n=this.videoTrack;this.forceFirstIDR&&(n.samples[0].flag={dependsOn:2,isNonSyncSample:0});var l=n.samples,f=/av01/.test(n.codec),v=0;f?l.forEach(function(_e){v+=_e.data.byteLength}):l.forEach(function(_e){v+=_e.units.reduce(function(oe,j){return oe+j.byteLength},0),v+=_e.units.length*4});var E=new Uint8Array(v);if(f)for(var _=0,S=l.length,C=0,I;_<S;_++)I=l[_],E.set(I.data,C),I.size=I.data.byteLength,C+=I.size;else for(var P=new DataView(E.buffer),H=function(oe,j){j=l[W];var ue=0;j.units.forEach(function(Ve){P.setUint32(oe,Ve.byteLength),oe+=4,E.set(Ve,oe),oe+=Ve.byteLength,ue+=4+Ve.byteLength}),j.size=ue,ee=oe,J=j},W=0,Y=l.length,ee=0,J;W<Y;W++)H(ee,J);var ae=xe.mdat(E),se=xe.moof([n]);return xt(se,ae)}},{key:"_remuxAudio",value:function(){var n=this.audioTrack,l=new Uint8Array(n.samples.reduce(function(E,_){return E+_.size},0));n.samples.reduce(function(E,_){return l.set(_.data,E),E+_.size},0);var f=xe.mdat(l),v=xe.moof([n]);return xt(v,f)}},{key:"reset",value:function(){this.videoTrack.reset(),this.audioTrack.reset()}}]),c}();var Zs=function(){function c(){yr(this,c),ce(this,"_ttfb",0),ce(this,"_demuxStart",0),ce(this,"_demuxEnd",0),ce(this,"_demuxCost",0),ce(this,"_remuxStart",0),ce(this,"_remuxEnd",0),ce(this,"_remuxCost",0),ce(this,"_appendStart",0),ce(this,"_appendEnd",0),ce(this,"_appendCost",0)}return Er(c,[{key:"set",value:function(n,l){this["_".concat(n)]=l}},{key:"start",value:function(n){this["_".concat(n,"Start")]=Date.now()}},{key:"end",value:function(n){this["_".concat(n,"End")]=Date.now(),this["_".concat(n,"Cost")]=this["_".concat(n,"Cost")]+(this["_".concat(n,"End")]-this["_".concat(n,"Start")])}},{key:"transferCost",get:function(){return{ttfbCost:this._ttfb,demuxCost:this._demuxCost,remuxCost:this._remuxCost,appendCost:this._appendCost}}}]),c}(),qt={TTFB:"ttfb",DEMUX:"demux",REMUX:"remux",APPEND:"append"};var Xt=new Tt("BufferService"),eo=function(){function c(g,n){var l=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};yr(this,c),ce(this,"flv",null),ce(this,"_demuxer",new vi),ce(this,"_remuxer",null),ce(this,"_mse",null),ce(this,"_softVideo",null),ce(this,"_sourceCreated",!1),ce(this,"_needInitSegment",!0),ce(this,"_discontinuity",!0),ce(this,"_contiguous",!1),ce(this,"_initSegmentId",""),ce(this,"_cachedBuffer",null),ce(this,"_demuxStartTime",0),ce(this,"_opts",null),this.flv=g,this._opts=l,n?this._softVideo=n:(this._remuxer=new gn(this._demuxer.videoTrack,this._demuxer.audioTrack),this._mse=new rr(null,{preferMMS:typeof l.preferMMS=="boolean"?l.preferMMS:!!l.perferMMS}),this._mse.bindMedia(g.media))}return Er(c,[{key:"baseDts",get:function(){var n,l;return(n=this._demuxer)===null||n===void 0||(l=n._fixer)===null||l===void 0?void 0:l._baseDts}},{key:"blobUrl",get:function(){var n;return(n=this._mse)===null||n===void 0?void 0:n.url}},{key:"isFull",value:function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:rr.VIDEO;return this._mse.isFull(n)}},{key:"seamlessSwitch",value:function(){this._needInitSegment=!0,this._discontinuity=!0,this._contiguous=!0,this._initSegmentId=""}},{key:"unContiguous",value:function(n){this._contiguous=!1,this._demuxStartTime=n}},{key:"reset",value:function(){var g=it(Re().mark(function l(){var f,v=arguments;return Re().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:if(f=v.length>0&&v[0]!==void 0?v[0]:!1,!(this._mse&&!f)){_.next=6;break}return _.next=4,this._mse.unbindMedia();case 4:return _.next=6,this._mse.bindMedia(this.flv.media);case 6:this._needInitSegment=!0,this._discontinuity=!0,this._contiguous=!1,this._sourceCreated=!1,this._initSegmentId="",this.resetSeamlessSwitchStats();case 12:case"end":return _.stop()}},l,this)}));function n(){return g.apply(this,arguments)}return n}()},{key:"resetSeamlessSwitchStats",value:function(){this.seamlessLoadingSwitch=null,this.seamlessLoadingSwitching=!1,this._demuxer&&(this._demuxer.seamlessLoadingSwitching=!1)}},{key:"endOfStream",value:function(){var g=it(Re().mark(function l(){return Re().wrap(function(v){for(;;)switch(v.prev=v.next){case 0:if(!this._mse){v.next=7;break}if(!this._sourceCreated){v.next=5;break}return v.next=4,this._mse.endOfStream();case 4:this.flv.emit(me.BUFFEREOS);case 5:v.next=8;break;case 7:this._softVideo&&this._softVideo.endOfStream();case 8:case"end":return v.stop()}},l,this)}));function n(){return g.apply(this,arguments)}return n}()},{key:"updateDuration",value:function(){var g=it(Re().mark(function l(f){return Re().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:if(!this._mse){E.next=7;break}if(this._mse.isOpened){E.next=4;break}return E.next=4,this._mse.open();case 4:return Xt.debug("update duration",f),E.next=7,this._mse.updateDuration(f);case 7:case"end":return E.stop()}},l,this)}));function n(l){return g.apply(this,arguments)}return n}()},{key:"destroy",value:function(){var g=it(Re().mark(function l(){return Re().wrap(function(v){for(;;)switch(v.prev=v.next){case 0:if(!this._mse){v.next=3;break}return v.next=3,this._mse.unbindMedia();case 3:this._mse=null,this._softVideo=null,this._demuxer=null,this._remuxer=null;case 7:case"end":return v.stop()}},l,this)}));function n(){return g.apply(this,arguments)}return n}()},{key:"appendBuffer",value:function(){var g=it(Re().mark(function l(f){var v=this,E,_,S,C,I,P,H,W,Y,ee,J,ae,se,_e,oe,j,ue;return Re().wrap(function(R){for(;;)switch(R.prev=R.next){case 0:if(E=!1,this._cachedBuffer&&(f=Zi(this._cachedBuffer,f),this._cachedBuffer=null),_=this._demuxer,!(!f||!f.length||!_)){R.next=5;break}return R.abrupt("return");case 5:R.prev=5,this.flv._transferCost.start(qt.DEMUX),_.demuxAndFix(f,this.seamlessLoadingSwitching||this._discontinuity,this._contiguous,this._demuxStartTime,this.seamlessLoadingSwitching),this.seamlessLoadingSwitching=!1,this.flv._transferCost.end(qt.DEMUX),R.next=15;break;case 12:throw R.prev=12,R.t0=R.catch(5),new dt(Ce.DEMUX,Ce.SUB_TYPES.FLV,R.t0);case 15:if(S=_.videoTrack,C=_.audioTrack,I=_.metadataTrack,!this.seamlessLoadingSwitch){R.next=25;break}if(P=S.samples.findIndex(function(le){return le.originDts===S.lastKeyFrameDts}),!(P>=0)){R.next=25;break}return S.samples.splice(P),R.next=22,this.seamlessLoadingSwitch();case 22:this.seamlessLoadingSwitch=null,f=null,E=!0;case 25:if(H=S.exist(),W=C.exist(),this._opts.onlyAudio&&(H=!1,S.present=!1),this._opts.onlyVideo&&(W=!1,C.present=!1),!(!H&&S.present||!W&&C.present)){R.next=42;break}if(Y=0,ee=H?S:W?C:void 0,ee&&ee.samples.length&&(Y=(ee.samples[ee.samples.length-1].originPts-ee.samples[0].originPts)/ee.timescale*1e3),!(Y>this._opts.analyzeDuration)){R.next=40;break}Xt.warn("analyze duration exceeded, ".concat(Y,"ms"),ee),S.present=H,C.present=W,this.flv.emit(me.ANALYZE_DURATION_EXCEEDED,{duration:Y}),R.next=42;break;case 40:return this._cachedBuffer=f,R.abrupt("return");case 42:if(J=S.type,ae=C.type,this._fireEvents(S,C,I),E||(this._discontinuity=!1,this._contiguous=!0,this._demuxStartTime=0),se=this._mse,_e=function(){var G;if((G=v.flv)!==null&&G!==void 0&&G.emit){var He;(He=v.flv)===null||He===void 0||He.emit(me.APPEND_BUFFER,{})}},this.flv.emit(me.DEMUXED_TRACK,{videoTrack:S}),oe="".concat(S.codec,"/").concat(S.width,"/").concat(S.height,"/").concat(C.codec,"/").concat(C.config),oe!==this._initSegmentId&&(this._needInitSegment=!0,this._initSegmentId=oe,this._emitMetaParsedEvent(S,C)),!se){R.next=81;break}if(this._sourceCreated){R.next=59;break}return R.next=55,se.open();case 55:H&&(Xt.log("codec: video/mp4;codecs=".concat(S.codec)),se.createSource(J,"video/mp4;codecs=".concat(S.codec))),W&&(Xt.log("codec: audio/mp4;codecs=".concat(C.codec)),se.createSource(ae,"audio/mp4;codecs=".concat(C.codec))),this._sourceCreated=!0,this.flv.emit(me.SOURCEBUFFER_CREATED);case 59:R.prev=59,this._needInitSegment&&!this._opts.mseLowLatency&&(S.duration=this._opts.durationForMSELowLatencyOff*S.timescale,C.duration=this._opts.durationForMSELowLatencyOff*W.timescale),this.flv._transferCost.start(qt.REMUX),j=this._remuxer.remux(this._needInitSegment),this.flv._transferCost.end(qt.REMUX),R.next=69;break;case 66:throw R.prev=66,R.t1=R.catch(59),new dt(Ce.REMUX,Ce.SUB_TYPES.FMP4,R.t1);case 69:if(!(this._needInitSegment&&!j.videoInitSegment&&!j.audioInitSegment)){R.next=71;break}return R.abrupt("return");case 71:return this._needInitSegment=!1,ue=[],j.videoInitSegment&&ue.push(se.append(J,j.videoInitSegment)),j.audioInitSegment&&ue.push(se.append(ae,j.audioInitSegment)),j.videoSegment&&ue.push(se.append(J,j.videoSegment)),j.audioSegment&&ue.push(se.append(ae,j.audioSegment)),this.flv._transferCost.start(qt.APPEND),R.abrupt("return",Promise.all(ue).then(_e).then(function(){v.flv._transferCost.end(qt.APPEND),_e()}));case 81:this._softVideo&&(this._softVideo.appendBuffer(S,C),_e());case 82:case"end":return R.stop()}},l,this,[[5,12],[59,66]])}));function n(l){return g.apply(this,arguments)}return n}()},{key:"evictBuffer",value:function(){var g=it(Re().mark(function l(f){var v=this,E,_,S,C;return Re().wrap(function(P){for(;;)switch(P.prev=P.next){case 0:if(E=this.flv.media,!(!this._mse||!this._demuxer||!E||!f||f<0)){P.next=3;break}return P.abrupt("return");case 3:if(_=E.currentTime,S=_-f,!(S<=0)){P.next=7;break}return P.abrupt("return");case 7:if(C=tt.start(tt.get(E)),!(C+1>=S)){P.next=10;break}return P.abrupt("return");case 10:return P.abrupt("return",this._mse.clearBuffer(0,S).then(function(){return v.flv.emit(me.REMOVE_BUFFER,{removeEnd:S})}));case 11:case"end":return P.stop()}},l,this)}));function n(l){return g.apply(this,arguments)}return n}()},{key:"_emitMetaParsedEvent",value:function(n,l){n.exist()&&this.flv.emit(me.METADATA_PARSED,{type:"video",track:n,meta:{codec:n.codec,timescale:n.timescale,width:n.width,height:n.height,sarRatio:n.sarRatio,baseDts:n.baseDts}}),l.exist()&&this.flv.emit(me.METADATA_PARSED,{type:"audio",track:l,meta:{codec:l.codec,channelCount:l.channelCount,sampleRate:l.sampleRate,timescale:l.timescale,baseDts:l.baseDts}}),Xt.debug("track parsed",n,l)}},{key:"_fireEvents",value:function(n,l,f){var v=this;Xt.debug("videoTrack samples count: ".concat(n.samples.length,", audioTrack samples count: ").concat(l.samples.length)),f.flvScriptSamples.forEach(function(E){v.flv.emit(me.FLV_SCRIPT_DATA,E),Xt.debug("flvScriptData",E)}),n.samples.forEach(function(E){E.keyframe&&v.flv.emit(me.KEYFRAME,{pts:E.originPts})}),n.warnings.forEach(function(E){var _;switch(E.type){case mt.LARGE_AV_SHIFT:_=me.LARGE_AV_FIRST_FRAME_GAP_DETECT;break;case mt.LARGE_VIDEO_GAP:_=me.LARGE_VIDEO_DTS_GAP_DETECT;break;case mt.LARGE_VIDEO_GAP_BETWEEN_CHUNK:_=me.MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT;break}_&&v.flv.emit(me.STREAM_EXCEPTION,bt(bt({},E),{},{type:_})),Xt.warn("video exception",E)}),l.warnings.forEach(function(E){var _;switch(E.type){case mt.LARGE_AUDIO_GAP:_=me.LARGE_AUDIO_DTS_GAP_DETECT;break;case mt.AUDIO_FILLED:_=me.AUDIO_GAP_DETECT;break;case mt.AUDIO_DROPPED:_=me.AUDIO_OVERLAP_DETECT;break}_&&v.flv.emit(me.STREAM_EXCEPTION,bt(bt({},E),{},{type:_})),Xt.warn("audio exception",E)}),f.seiSamples.forEach(function(E){v.flv.emit(me.SEI,bt(bt({},E),{},{sei:{code:E.data.type,content:E.data.payload,dts:E.pts}}))})}}]),c}();function to(c){var g=bt({retryCount:3,retryDelay:1e3,disconnectRetryCount:0,loadTimeout:1e4,maxReaderInterval:5e3,preloadTime:5,defaultVodLoadSize:1e7,isLive:!1,softDecode:!1,bufferBehind:10,maxJumpDistance:3,analyzeDuration:2e4,seamlesslyReload:!1,keepStatusAfterSwitch:!0,onlyVideo:!1,onlyAudio:!1,preferMMS:!1,mseLowLatency:!0,durationForMSELowLatencyOff:6,chunkCountForSpeed:50,skipChunkSize:1e3,longtimeNoReceived:3e3,enableStartGapJump:!0},c);return g.isLive&&g.preloadTime&&(g.maxLatency||(g.maxLatency=g.preloadTime*2),g.targetLatency||(g.targetLatency=g.preloadTime),(g.disconnectTime===null||g.disconnectTime===void 0)&&(g.disconnectTime=g.maxLatency)),g}function yn(c,g){var n=0,l=c.length-1,f=0,v=0,E=l;for(g<c[0]&&(n=0,v=E+1);v<=E;)if(f=v+Math.floor((E-v)/2),f===l||g>=c[f]&&g<c[f+1]){n=f;break}else c[f]<g?v=f+1:E=f-1;return n}var Vt=new Tt("flv"),pi=.1,Jf=.3,Fr=function(c){rs(n,c);var g=is(n);function n(l){var f;return yr(this,n),f=g.call(this),ce(Ie(f),"media",null),ce(Ie(f),"_loading",!1),ce(Ie(f),"_opts",null),ce(Ie(f),"_bufferService",null),ce(Ie(f),"_gapService",null),ce(Ie(f),"_stats",null),ce(Ie(f),"_mediaLoader",null),ce(Ie(f),"_maxChunkWaitTimer",null),ce(Ie(f),"_tickTimer",null),ce(Ie(f),"_tickInterval",500),ce(Ie(f),"_urlSwitching",!1),ce(Ie(f),"_seamlessSwitching",!1),ce(Ie(f),"_disconnectRetryCount",0),ce(Ie(f),"_preLoadEndPoint",0),ce(Ie(f),"_keyframes",null),ce(Ie(f),"_acceptRanges",!0),ce(Ie(f),"_onProgress",function(){var v=it(Re().mark(function E(_,S,C,I){var P,H,W,Y,ee,J,ae,se,_e,oe;return Re().wrap(function(ue){for(;;)switch(ue.prev=ue.next){case 0:if(P=C.startTime,H=C.endTime,W=C.st,Y=C.firstByteTime,f._loading=!S,f._firstProgressEmit){ue.next=13;break}if(f.media){ue.next=6;break}return(ee=f._mediaLoader)===null||ee===void 0||ee.cancel(),ue.abrupt("return");case 6:J=I.headers,ae=W?Y-W:H-P,f.emit(me.TTFB,{url:f._opts.url,responseUrl:I.url,elapsed:ae}),f.emit(me.LOAD_RESPONSE_HEADERS,{headers:J}),f._transferCost.set(qt.TTFB,ae),f._acceptRanges=!!(J!=null&&J.get("Accept-Ranges"))||!!(J!=null&&J.get("Content-Range")),f._firstProgressEmit=!0;case 13:if(f._bufferService){ue.next=15;break}return ue.abrupt("return");case 15:return clearTimeout(f._maxChunkWaitTimer),f._bandwidthService.addChunkRecord(_?.byteLength,H-P),ue.prev=17,ue.next=20,f._bufferService.appendBuffer(_);case 20:(se=f._bufferService)===null||se===void 0||se.evictBuffer(f._opts.bufferBehind),ue.next=33;break;case 23:if(ue.prev=23,ue.t0=ue.catch(17),!(!f.isLive&&f._bufferService.isFull())){ue.next=32;break}return ue.next=28,f._mediaLoader.cancel();case 28:return f._loading=!1,_e=f.bufferInfo().remaining,f._opts.preloadTime=parseInt(_e)/2,ue.abrupt("return");case 32:return ue.abrupt("return",f._emitError(dt.create(ue.t0)));case 33:if(f._urlSwitching&&(f._urlSwitching=!1,f.emit(me.SWITCH_URL_SUCCESS,{url:f._opts.url})),f._seamlessSwitching&&(f._seamlessSwitching=!1,f._tick()),!(S&&!f.media.seeking)){ue.next=40;break}return f.emit(me.LOAD_COMPLETE),Vt.debug("load done"),f.isLive&&f._disconnectRetryCount<=0&&f._end(),ue.abrupt("return");case 40:if(f.isLive){ue.next=42;break}return ue.abrupt("return");case 42:oe=f._opts.maxReaderInterval,oe&&f._firstProgressEmit&&(clearTimeout(f._maxChunkWaitTimer),f._maxChunkWaitTimer=setTimeout(function(){if(f._disconnectRetryCount){f._disconnectRetryCount--,f.load();return}Vt.debug("onMaxChunkWait",oe),f._end()},oe));case 44:case"end":return ue.stop()}},E,null,[[17,23]])}));return function(E,_,S,C){return v.apply(this,arguments)}}()),ce(Ie(f),"_onRetryError",function(v,E){Vt.debug("load retry",v,E),f.emit(me.LOAD_RETRY,{error:dt.network(v),retryTime:E})}),ce(Ie(f),"_end",function(){f._clear(),f._bufferService&&f._bufferService.endOfStream(),Vt.debug("end stream")}),ce(Ie(f),"_resetDisconnectCount",function(){f._disconnectRetryCount=f._opts.disconnectRetryCount}),ce(Ie(f),"_tick",function(){clearTimeout(f._tickTimer);var v=Ie(f),E=v.media;if(E){f._tickTimer=setTimeout(f._tick,f._tickInterval);var _=tt.end(tt.get(E));if(!(_<pi||!E.readyState)){var S=f._opts;if(Qi(E)&&E.currentTime)f._gapService&&f._gapService.do(E,S.maxJumpDistance,f.isLive,3);else{if(!E.currentTime&&f._gapService&&S.enableStartGapJump){var C=f._opts.mseLowLatency||f._opts.mseLowLatency===!1&&f.bufferInfo(Jf).nextStart;C&&f._gapService.do(E,S.maxJumpDistance,f.isLive,3);return}S.isLive&&E.readyState===4&&_-E.currentTime>S.disconnectTime&&f.disconnect()}}}}),ce(Ie(f),"_onPlay",function(){var v,E,_=f._opts.softDecode||((v=f.media)===null||v===void 0||(E=v.buffered)===null||E===void 0?void 0:E.length);if(f.isLive){!f._loading&&_&&f.replay(void 0,!0);return}var S=f.bufferInfo();(S.start||S.nextStart)>pi&&f._tick()}),ce(Ie(f),"_onLoadeddata",function(){f.isLive&&!f._opts.mseLowLatency&&f.media.duration!==1/0&&f._bufferService.updateDuration(1/0).catch(function(v){})}),ce(Ie(f),"_onSeeking",it(Re().mark(function v(){return Re().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:!f.isLive&&f.seekable&&(f._preLoadEndPoint=-1,f._checkPreload());case 1:case"end":return _.stop()}},v)}))),ce(Ie(f),"_onTimeupdate",function(){if(f.media){var v=f._opts,E=f.media.currentTime;if(v.isLive&&v.maxLatency&&v.targetLatency){var _=tt.end(tt.get(f.media)),S=_-E;S>=v.maxLatency&&(f.media.currentTime=_-v.targetLatency,f.emit(me.CHASEFRAME,{currentTime:f.media.currentTime,latency:v.targetLatency}))}f._seiService.throw(E,!0),!(v.isLive||!f.seekable||f._loading)&&f._checkPreload()}}),ce(Ie(f),"_onWaiting",function(){f.isLive&&!f._loading&&f._disconnectRetryCount&&(f._disconnectRetryCount--,f.load())}),ce(Ie(f),"_onBufferUpdate",function(){if(!f._opts.isLive){var v=f.bufferInfo(),E=v.end,_=v.nextEnd;Math.abs((E||_)-f.media.duration)<1&&(f._end(),f.media.readyState<=2&&f._tick())}}),ce(Ie(f),"_checkPreload",it(Re().mark(function v(){var E,_,S,C,I,P,H,W,Y,ee;return Re().wrap(function(ae){for(;;)switch(ae.prev=ae.next){case 0:if(E=f.bufferInfo(),_=E.remaining,S=_===void 0?0:_,C=f._opts,I=f._keyframes.filepositions,P=f._keyframes.times,H=f.media.currentTime,!(S<C.preloadTime)){ae.next=19;break}if(W=yn(f._keyframes.times,H+S+pi),Y=yn(f._keyframes.times,H+S+f._opts.preloadTime),Y===W&&(Y=W+1),f._preLoadEndPoint!==Y){ae.next=11;break}return ae.abrupt("return");case 11:if(ee=I[W],ee!=null){ae.next=14;break}return ae.abrupt("return");case 14:return ae.next=16,f._mediaLoader.cancel();case 16:f._loadData(null,[ee,I[Y]]),f._preLoadEndPoint=Y,f._bufferService.unContiguous(P[W]);case 19:case"end":return ae.stop()}},v)}))),ce(Ie(f),"_onFlvScriptData",function(v){var E,_,S,C,I=(E=v.data)===null||E===void 0||(_=E.onMetaData)===null||_===void 0?void 0:_.keyframes,P=(S=v.data)===null||S===void 0||(C=S.onMetaData)===null||C===void 0?void 0:C.duration;I&&(f._keyframes=I),!f._opts.isLive&&P&&f._bufferService.updateDuration(P)}),f._opts=to(l),f.media=f._opts.media||document.createElement("video"),f._opts.media=null,f._firstProgressEmit=!1,f._mediaLoader=new tn(bt(bt({},f._opts.fetchOptions),{},{retry:f._opts.retryCount,retryDelay:f._opts.retryDelay,timeout:f._opts.loadTimeout,onRetryError:f._onRetryError,onProgress:f._onProgress,responseType:"arraybuffer"})),f._disconnectRetryCount=f._opts.disconnectRetryCount,f._transferCost=new Zs,f._bufferService=new eo(Ie(f),f._opts.softDecode?f.media:void 0,f._opts),f._seiService=new nn(Ie(f)),f._bandwidthService=new an({chunkCountForSpeed:f._opts.chunkCountForSpeed,skipChunkSize:f._opts.skipChunkSize,longtimeNoReceived:f._opts.longtimeNoReceived}),f._stats=new sn(Ie(f)),f._opts.softDecode||(f._gapService=new rn),f.media.addEventListener("play",f._onPlay),f.media.addEventListener("loadeddata",f._onLoadeddata),f.media.addEventListener("seeking",f._onSeeking),f.media.addEventListener("timeupdate",f._onTimeupdate),f.media.addEventListener("progress",f._onBufferUpdate),f.media.addEventListener("waiting",f._onWaiting),f.on(me.FLV_SCRIPT_DATA,f._onFlvScriptData),f}return Er(n,[{key:"version",get:function(){return"3.0.20"}},{key:"isLive",get:function(){return this._opts.isLive}},{key:"baseDts",get:function(){var f;return(f=this._bufferService)===null||f===void 0?void 0:f.baseDts}},{key:"seekable",get:function(){return!!this._keyframes&&this._acceptRanges}},{key:"loader",get:function(){return this._mediaLoader}},{key:"blobUrl",get:function(){var f;return(f=this._bufferService)===null||f===void 0?void 0:f.blobUrl}},{key:"speedInfo",value:function(){return{speed:this._bandwidthService.getLatestSpeed(),avgSpeed:this._bandwidthService.getAvgSpeed(),totalSize:this._bandwidthService.getTotalSize(),totalCost:this._bandwidthService.getTotalCost()}}},{key:"getStats",value:function(){return this._stats.getStats()}},{key:"bufferInfo",value:function(){var f,v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:pi;return tt.info(tt.get(this.media),(f=this.media)===null||f===void 0?void 0:f.currentTime,v)}},{key:"playbackQuality",value:function(){return Ji(this.media)}},{key:"load",value:function(){var l=it(Re().mark(function v(E){var _,S=arguments;return Re().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:if(_=S.length>1&&S[1]!==void 0?S[1]:!1,this._bufferService){I.next=3;break}return I.abrupt("return");case 3:return I.next=5,this._reset(_);case 5:this._loadData(E,this._opts.isLive?[]:[0,this._opts.defaultVodLoadSize]),clearTimeout(this._tickTimer),this._tickTimer=setTimeout(this._tick,this._tickInterval);case 8:case"end":return I.stop()}},v,this)}));function f(v){return l.apply(this,arguments)}return f}()},{key:"replay",value:function(){var l=it(Re().mark(function v(){var E=this,_,S,C=arguments;return Re().wrap(function(P){for(;;)switch(P.prev=P.next){case 0:if(_=C.length>0&&C[0]!==void 0?C[0]:this._opts.seamlesslyReload,S=C.length>1?C[1]:void 0,this.media){P.next=4;break}return P.abrupt("return");case 4:if(this._resetDisconnectCount(),!_){P.next=11;break}return P.next=8,this._clear();case 8:setTimeout(function(){E._seamlessSwitching=!0,E._loadData(E._opts.url),E._bufferService.seamlessSwitch()}),P.next=13;break;case 11:return P.next=13,this.load();case 13:return P.abrupt("return",this.media.play(!S).catch(function(){}));case 14:case"end":return P.stop()}},v,this)}));function f(){return l.apply(this,arguments)}return f}()},{key:"disconnect",value:function(){var f;return Vt.debug("disconnect!"),(f=this._bufferService)===null||f===void 0||f.resetSeamlessSwitchStats(),this._clear()}},{key:"switchURL",value:function(){var l=it(Re().mark(function v(E,_){var S=this;return Re().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:if(this._bufferService){I.next=2;break}return I.abrupt("return");case 2:if(this._resetDisconnectCount(),!(this._loading&&_)){I.next=6;break}return this._bufferService.seamlessLoadingSwitch=function(){var P=it(Re().mark(function H(W){return Re().wrap(function(ee){for(;;)switch(ee.prev=ee.next){case 0:return ee.next=2,S._clear();case 2:S._bufferService.seamlessLoadingSwitching=!0,S._urlSwitching=!0,S._seamlessSwitching=!0,S._bufferService.seamlessSwitch(),S._loadData(E);case 7:case"end":return ee.stop()}},H)}));return function(H){return P.apply(this,arguments)}}(),I.abrupt("return");case 6:if(!(!_||!this._opts.isLive)){I.next=11;break}return I.next=9,this.load(E);case 9:return this._urlSwitching=!0,I.abrupt("return",this.media.play(!0).catch(function(){}));case 11:return I.next=13,this._clear();case 13:setTimeout(function(){S._urlSwitching=!0,S._seamlessSwitching=!0,S._loadData(E),S._bufferService.seamlessSwitch()});case 14:case"end":return I.stop()}},v,this)}));function f(v,E){return l.apply(this,arguments)}return f}()},{key:"destroy",value:function(){var l=it(Re().mark(function v(){return Re().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:if(this.media){_.next=2;break}return _.abrupt("return");case 2:return this.removeAllListeners(),this._seiService.reset(),this.media.removeEventListener("play",this._onPlay),this.media.removeEventListener("loadeddata",this._onLoadeddata),this.media.removeEventListener("seeking",this._onSeeking),this.media.removeEventListener("timeupdate",this._onTimeupdate),this.media.removeEventListener("waiting",this._onWaiting),this.media.removeEventListener("progress",this._onBufferUpdate),_.next=12,Promise.all([this._clear(),this._bufferService.destroy()]);case 12:this.media=null,this._bufferService=null;case 14:case"end":return _.stop()}},v,this)}));function f(){return l.apply(this,arguments)}return f}()},{key:"_emitError",value:function(f){var v,E=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;Vt.table(f),Vt.error(f),Vt.error((v=this.media)===null||v===void 0?void 0:v.error),this._urlSwitching&&(this._urlSwitching=!1,this._seamlessSwitching=!1,this.emit(me.SWITCH_URL_FAILED,f)),this.emit(me.ERROR,f),E&&(this._seiService.reset(),this._end())}},{key:"_reset",value:function(){var l=it(Re().mark(function v(){var E,_=arguments;return Re().wrap(function(C){for(;;)switch(C.prev=C.next){case 0:return E=_.length>0&&_[0]!==void 0?_[0]:!1,this._seiService.reset(),this._bandwidthService.reset(),this._stats.reset(),C.next=6,this._clear();case 6:return C.next=8,this._bufferService.reset(E);case 8:case"end":return C.stop()}},v,this)}));function f(){return l.apply(this,arguments)}return f}()},{key:"_loadData",value:function(){var l=it(Re().mark(function v(E,_){var S;return Re().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:if(E&&(this._opts.url=E),S=E=this._opts.url,E){I.next=4;break}throw new Error("Source url is missing");case 4:if(this._opts.preProcessUrl&&(S=this._opts.preProcessUrl(E).url),this._mediaLoader.finnalUrl=S,this.emit(me.LOAD_START,{url:S,seamlessSwitching:this._seamlessSwitching}),Vt.debug("load data, loading:",this._loading,S),!this._loading){I.next=11;break}return I.next=11,this._mediaLoader.cancel();case 11:return this._loading=!0,I.prev=12,I.next=15,this._mediaLoader.load({url:S,range:_});case 15:I.next=21;break;case 17:return I.prev=17,I.t0=I.catch(12),this._loading=!1,I.abrupt("return",this._emitError(dt.network(I.t0),!1));case 21:case"end":return I.stop()}},v,this,[[12,17]])}));function f(v,E){return l.apply(this,arguments)}return f}()},{key:"_clear",value:function(){var l=it(Re().mark(function v(){return Re().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:if(!this._mediaLoader){_.next=3;break}return _.next=3,this._mediaLoader.cancel();case 3:clearTimeout(this._maxChunkWaitTimer),clearTimeout(this._tickTimer),this._loading=!1,this._firstProgressEmit=!1;case 7:case"end":return _.stop()}},v,this)}));function f(){return l.apply(this,arguments)}return f}()}],[{key:"isSupported",value:function(f){return!f||f==="video"||f==="audio"?rr.isSupported():typeof WebAssembly<"u"}},{key:"enableLogger",value:function(){Tt.enable(),fr.enable()}},{key:"disableLogger",value:function(){Tt.disable(),fr.disable()}}]),n}(ro.default);try{localStorage.getItem("xgd")?Fr.enableLogger():Fr.disableLogger()}catch{}var ao=gr(no(),1);var export_Hls=ao.default;export{Fr as Flv,export_Hls as Hls};