Zorn/src/Features/HLS.astro

21 lines
No EOL
408 KiB
Text

<script is:inline>
// Original Source: https://hlsjs.video-dev.org/dist/hls.js
// @license magnet:?xt=urn:btih:8e4f440f4c65981c5bf93c76d35135ba5064d8b7&dn=apache-2.0.txt Apache-2.0
// @license-end
!function t(e){var i,r;i=this,r=function(){"use strict";function i(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),i.push.apply(i,r)}return i}function r(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?i(Object(r),!0).forEach(function(e){o(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function n(t){var e=function t(e,i){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,i||"default");if("object"!=typeof n)return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===i?String:Number)(e)}(t,"string");return"symbol"==typeof e?e:String(e)}function a(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,n(r.key),r)}}function s(t,e,i){return e&&a(t.prototype,e),i&&a(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t}function o(t,e,i){return(e=n(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function l(){return(l=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t}).apply(this,arguments)}function u(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,h(t,e)}function d(t){return(d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function t(e){return e.__proto__||Object.getPrototypeOf(e)})(t)}function h(t,e){return(h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function t(e,i){return e.__proto__=i,e})(t,e)}function f(t,e,i){return(f=!function t(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}()?function t(e,i,r){var n=[null];n.push.apply(n,i);var a=new(Function.bind.apply(e,n));return r&&h(a,r.prototype),a}:Reflect.construct.bind()).apply(null,arguments)}function c(t){var e="function"==typeof Map?new Map:void 0;return(c=function t(i){if(null===i||!function t(e){try{return -1!==Function.toString.call(e).indexOf("[native code]")}catch(i){return"function"==typeof e}}(i))return i;if("function"!=typeof i)throw TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(i))return e.get(i);e.set(i,r)}function r(){return f(i,arguments,d(this).constructor)}return r.prototype=Object.create(i.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),h(r,i)})(t)}function $(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,r=Array(e);i<e;i++)r[i]=t[i];return r}var g,v,m,p,y,T,x,E,S,L,A,R,_,D={exports:{}};E=D,S=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,L=/^(?=([^\/?#]*))\1([^]*)$/,A=/(?:\/|^)\.(?=\/)/g,R=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,_={buildAbsoluteURL:function(t,e,i){if(i=i||{},t=t.trim(),!(e=e.trim())){if(!i.alwaysNormalize)return t;var r=_.parseURL(t);if(!r)throw Error("Error trying to parse base URL.");return r.path=_.normalizePath(r.path),_.buildURLFromParts(r)}var n=_.parseURL(e);if(!n)throw Error("Error trying to parse relative URL.");if(n.scheme)return i.alwaysNormalize?(n.path=_.normalizePath(n.path),_.buildURLFromParts(n)):e;var a=_.parseURL(t);if(!a)throw Error("Error trying to parse base URL.");if(!a.netLoc&&a.path&&"/"!==a.path[0]){var s=L.exec(a.path);a.netLoc=s[1],a.path=s[2]}a.netLoc&&!a.path&&(a.path="/");var o={scheme:a.scheme,netLoc:n.netLoc,path:null,params:n.params,query:n.query,fragment:n.fragment};if(!n.netLoc&&(o.netLoc=a.netLoc,"/"!==n.path[0])){if(n.path){var l=a.path,u=l.substring(0,l.lastIndexOf("/")+1)+n.path;o.path=_.normalizePath(u)}else o.path=a.path,n.params||(o.params=a.params,n.query||(o.query=a.query))}return null===o.path&&(o.path=i.alwaysNormalize?_.normalizePath(n.path):n.path),_.buildURLFromParts(o)},parseURL:function(t){var e=S.exec(t);return e?{scheme:e[1]||"",netLoc:e[2]||"",path:e[3]||"",params:e[4]||"",query:e[5]||"",fragment:e[6]||""}:null},normalizePath:function(t){for(t=t.split("").reverse().join("").replace(A,"");t.length!==(t=t.replace(R,"")).length;);return t.split("").reverse().join("")},buildURLFromParts:function(t){return t.scheme+t.netLoc+t.path+t.params+t.query+t.fragment}},E.exports=_;var k,I,b,C=D.exports,w=Number.isFinite||function(t){return"number"==typeof t&&isFinite(t)},P=Number.isSafeInteger||function(t){return"number"==typeof t&&Math.abs(t)<=F},F=Number.MAX_SAFE_INTEGER||9007199254740991,O=((k={}).MEDIA_ATTACHING="hlsMediaAttaching",k.MEDIA_ATTACHED="hlsMediaAttached",k.MEDIA_DETACHING="hlsMediaDetaching",k.MEDIA_DETACHED="hlsMediaDetached",k.BUFFER_RESET="hlsBufferReset",k.BUFFER_CODECS="hlsBufferCodecs",k.BUFFER_CREATED="hlsBufferCreated",k.BUFFER_APPENDING="hlsBufferAppending",k.BUFFER_APPENDED="hlsBufferAppended",k.BUFFER_EOS="hlsBufferEos",k.BUFFER_FLUSHING="hlsBufferFlushing",k.BUFFER_FLUSHED="hlsBufferFlushed",k.MANIFEST_LOADING="hlsManifestLoading",k.MANIFEST_LOADED="hlsManifestLoaded",k.MANIFEST_PARSED="hlsManifestParsed",k.LEVEL_SWITCHING="hlsLevelSwitching",k.LEVEL_SWITCHED="hlsLevelSwitched",k.LEVEL_LOADING="hlsLevelLoading",k.LEVEL_LOADED="hlsLevelLoaded",k.LEVEL_UPDATED="hlsLevelUpdated",k.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",k.LEVELS_UPDATED="hlsLevelsUpdated",k.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",k.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",k.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",k.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",k.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",k.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",k.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",k.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",k.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",k.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",k.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",k.CUES_PARSED="hlsCuesParsed",k.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",k.INIT_PTS_FOUND="hlsInitPtsFound",k.FRAG_LOADING="hlsFragLoading",k.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",k.FRAG_LOADED="hlsFragLoaded",k.FRAG_DECRYPTED="hlsFragDecrypted",k.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",k.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",k.FRAG_PARSING_METADATA="hlsFragParsingMetadata",k.FRAG_PARSED="hlsFragParsed",k.FRAG_BUFFERED="hlsFragBuffered",k.FRAG_CHANGED="hlsFragChanged",k.FPS_DROP="hlsFpsDrop",k.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",k.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",k.ERROR="hlsError",k.DESTROYING="hlsDestroying",k.KEY_LOADING="hlsKeyLoading",k.KEY_LOADED="hlsKeyLoaded",k.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",k.BACK_BUFFER_REACHED="hlsBackBufferReached",k.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",k),N=((I={}).NETWORK_ERROR="networkError",I.MEDIA_ERROR="mediaError",I.KEY_SYSTEM_ERROR="keySystemError",I.MUX_ERROR="muxError",I.OTHER_ERROR="otherError",I),M=((b={}).KEY_SYSTEM_NO_KEYS="keySystemNoKeys",b.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",b.KEY_SYSTEM_NO_SESSION="keySystemNoSession",b.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",b.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",b.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",b.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",b.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",b.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",b.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",b.MANIFEST_LOAD_ERROR="manifestLoadError",b.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",b.MANIFEST_PARSING_ERROR="manifestParsingError",b.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",b.LEVEL_EMPTY_ERROR="levelEmptyError",b.LEVEL_LOAD_ERROR="levelLoadError",b.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",b.LEVEL_PARSING_ERROR="levelParsingError",b.LEVEL_SWITCH_ERROR="levelSwitchError",b.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",b.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",b.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",b.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",b.FRAG_LOAD_ERROR="fragLoadError",b.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",b.FRAG_DECRYPT_ERROR="fragDecryptError",b.FRAG_PARSING_ERROR="fragParsingError",b.FRAG_GAP="fragGap",b.REMUX_ALLOC_ERROR="remuxAllocError",b.KEY_LOAD_ERROR="keyLoadError",b.KEY_LOAD_TIMEOUT="keyLoadTimeOut",b.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",b.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",b.BUFFER_APPEND_ERROR="bufferAppendError",b.BUFFER_APPENDING_ERROR="bufferAppendingError",b.BUFFER_STALLED_ERROR="bufferStalledError",b.BUFFER_FULL_ERROR="bufferFullError",b.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",b.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",b.INTERNAL_EXCEPTION="internalException",b.INTERNAL_ABORTED="aborted",b.UNKNOWN="unknown",b),B=function t(){},U={trace:B,debug:B,log:B,warn:B,info:B,error:B},G=U;function K(t,e){if("object"==typeof console&&!0===t||"object"==typeof t){!function t(e){for(var i=arguments.length,r=Array(i>1?i-1:0),n=1;n<i;n++)r[n-1]=arguments[n];r.forEach(function(t){var i,r;G[t]=e[t]?e[t].bind(e):(i=t,(r=self.console[i])?r.bind(self.console,"["+i+"] >"):B)})}(t,"debug","log","info","warn","error");try{G.log('Debug logs enabled for "'+e+'" in hls.js version 1.5.14')}catch(i){G=U}}else G=U}var H=G,V=/^(\d+)x(\d+)$/,Y=/(.+?)=(".*?"|.*?)(?:,|$)/g,W=function(){function t(e){"string"==typeof e&&(e=t.parseAttrList(e)),l(this,e)}var e=t.prototype;return e.decimalInteger=function t(e){var i=parseInt(this[e],10);return i>Number.MAX_SAFE_INTEGER?1/0:i},e.hexadecimalInteger=function t(e){if(!this[e])return null;var i=(this[e]||"0x").slice(2);i=(1&i.length?"0":"")+i;for(var r=new Uint8Array(i.length/2),n=0;n<i.length/2;n++)r[n]=parseInt(i.slice(2*n,2*n+2),16);return r},e.hexadecimalIntegerAsNumber=function t(e){var i=parseInt(this[e],16);return i>Number.MAX_SAFE_INTEGER?1/0:i},e.decimalFloatingPoint=function t(e){return parseFloat(this[e])},e.optionalFloat=function t(e,i){var r=this[e];return r?parseFloat(r):i},e.enumeratedString=function t(e){return this[e]},e.bool=function t(e){return"YES"===this[e]},e.decimalResolution=function t(e){var i=V.exec(this[e]);if(null!==i)return{width:parseInt(i[1],10),height:parseInt(i[2],10)}},t.parseAttrList=function t(e){var i,r={};for(Y.lastIndex=0;null!==(i=Y.exec(e));){var n=i[2];0===n.indexOf('"')&&n.lastIndexOf('"')===n.length-1&&(n=n.slice(1,-1)),r[i[1].trim()]=n}return r},s(t,[{key:"clientAttrs",get:function t(){return Object.keys(this).filter(function(t){return"X-"===t.substring(0,2)})}}]),t}();function q(t){return"ID"!==t&&"CLASS"!==t&&"START-DATE"!==t&&"DURATION"!==t&&"END-DATE"!==t&&"END-ON-NEXT"!==t}function X(t){return"SCTE35-OUT"===t||"SCTE35-IN"===t}var z=function(){function t(t,e){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,e){var i=e.attr;for(var r in i)if(Object.prototype.hasOwnProperty.call(t,r)&&t[r]!==i[r]){H.warn('DATERANGE tag attribute: "'+r+'" does not match for tags with ID: "'+t.ID+'"'),this._badValueForSameId=r;break}t=l(new W({}),i,t)}if(this.attr=t,this._startDate=new Date(t["START-DATE"]),"END-DATE"in this.attr){var n=new Date(this.attr["END-DATE"]);w(n.getTime())&&(this._endDate=n)}}return s(t,[{key:"id",get:function t(){return this.attr.ID}},{key:"class",get:function t(){return this.attr.CLASS}},{key:"startDate",get:function t(){return this._startDate}},{key:"endDate",get:function t(){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 t(){if("DURATION"in this.attr){var e=this.attr.decimalFloatingPoint("DURATION");if(w(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function t(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}},{key:"endOnNext",get:function t(){return this.attr.bool("END-ON-NEXT")}},{key:"isValid",get:function t(){return!!this.id&&!this._badValueForSameId&&w(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),t}(),j=function t(){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}},Q={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"},Z=function(){function t(t){var e;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((e={})[Q.AUDIO]=null,e[Q.VIDEO]=null,e[Q.AUDIOVIDEO]=null,e),this.baseurl=t}return t.prototype.setByteRange=function t(e,i){var r,n=e.split("@",2);r=1===n.length?(null==i?void 0:i.byteRangeEndOffset)||0:parseInt(n[1]),this._byteRange=[r,parseInt(n[0])+r]},s(t,[{key:"byteRange",get:function t(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function t(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function t(){return this.byteRange[1]}},{key:"url",get:function t(){return!this._url&&this.baseurl&&this.relurl&&(this._url=C.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function t(e){this._url=e}}]),t}(),J=function(t){function e(e,i){var r;return(r=t.call(this,i)||this)._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 j,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}u(e,t);var i=e.prototype;return i.setKeyFormat=function t(e){if(this.levelkeys){var i=this.levelkeys[e];i&&!this._decryptdata&&(this._decryptdata=i.getDecryptData(this.sn))}},i.abortRequests=function t(){var e,i;null==(e=this.loader)||e.abort(),null==(i=this.keyLoader)||i.abort()},i.setElementaryStreamInfo=function t(e,i,r,n,a,s){void 0===s&&(s=!1);var o=this.elementaryStreams,l=o[e];if(!l){o[e]={startPTS:i,endPTS:r,startDTS:n,endDTS:a,partial:s};return}l.startPTS=Math.min(l.startPTS,i),l.endPTS=Math.max(l.endPTS,r),l.startDTS=Math.min(l.startDTS,n),l.endDTS=Math.max(l.endDTS,a)},i.clearElementaryStreamInfo=function t(){var e=this.elementaryStreams;e[Q.AUDIO]=null,e[Q.VIDEO]=null,e[Q.AUDIOVIDEO]=null},s(e,[{key:"decryptdata",get:function t(){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 i=Object.keys(this.levelkeys);if(1===i.length)return this._decryptdata=this.levelkeys[i[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function t(){return this.start+this.duration}},{key:"endProgramDateTime",get:function t(){if(null===this.programDateTime||!w(this.programDateTime))return null;var e=w(this.duration)?this.duration:0;return this.programDateTime+1e3*e}},{key:"encrypted",get:function t(){var e;if(null!=(e=this._decryptdata)&&e.encrypted)return!0;if(this.levelkeys){var i=Object.keys(this.levelkeys),r=i.length;if(r>1||1===r&&this.levelkeys[i[0]].encrypted)return!0}return!1}}]),e}(Z),tt=function(t){function e(e,i,r,n,a){(s=t.call(this,r)||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 j,s.duration=e.decimalFloatingPoint("DURATION"),s.gap=e.bool("GAP"),s.independent=e.bool("INDEPENDENT"),s.relurl=e.enumeratedString("URI"),s.fragment=i,s.index=n;var s,o=e.enumeratedString("BYTERANGE");return o&&s.setByteRange(o,a),a&&(s.fragOffset=a.fragOffset+a.duration),s}return u(e,t),s(e,[{key:"start",get:function t(){return this.fragment.start+this.fragOffset}},{key:"end",get:function t(){return this.start+this.duration}},{key:"loaded",get:function t(){var e=this.elementaryStreams;return!!(e.audio||e.video||e.audiovideo)}}]),e}(Z),te=function(){function t(t){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=t}return t.prototype.reloaded=function t(e){if(!e){this.advanced=!0,this.updated=!0;return}var i=this.lastPartSn-e.lastPartSn,r=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!r||!!i||!this.live,this.advanced=this.endSN>e.endSN||i>0||0===i&&r>0,this.updated||this.advanced?this.misses=Math.floor(.6*e.misses):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay},s(t,[{key:"hasProgramDateTime",get:function t(){return!!this.fragments.length&&w(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function t(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function t(){var e=this.driftEndTime-this.driftStartTime;return e>0?1e3*(this.driftEnd-this.driftStart)/e:1}},{key:"edge",get:function t(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function t(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function t(){var e;return null!=(e=this.fragments)&&e.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function t(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function t(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function t(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),t}();function ti(t){return Uint8Array.from(atob(t),function(t){return t.charCodeAt(0)})}function tr(t){return Uint8Array.from(unescape(encodeURIComponent(t)),function(t){return t.charCodeAt(0)})}var tn="undefined"!=typeof self?self:void 0,ta={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},ts={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function to(t){switch(t){case ts.FAIRPLAY:return ta.FAIRPLAY;case ts.PLAYREADY:return ta.PLAYREADY;case ts.WIDEVINE:return ta.WIDEVINE;case ts.CLEARKEY:return ta.CLEARKEY}}var tl={WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function tu(t){switch(t){case ta.FAIRPLAY:return ts.FAIRPLAY;case ta.PLAYREADY:return ts.PLAYREADY;case ta.WIDEVINE:return ts.WIDEVINE;case ta.CLEARKEY:return ts.CLEARKEY}}function td(t){var e=t.drmSystems,i=t.widevineLicenseUrl,r=e?[ta.FAIRPLAY,ta.WIDEVINE,ta.PLAYREADY,ta.CLEARKEY].filter(function(t){return!!e[t]}):[];return!r[ta.WIDEVINE]&&i&&r.push(ta.WIDEVINE),r}var th,tf=null!=tn&&null!=(th=tn.navigator)&&th.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function tc(t,e,i){return Uint8Array.prototype.slice?t.slice(e,i):new Uint8Array(Array.prototype.slice.call(t,e,i))}var t$=function t(e,i){return!!(i+10<=e.length)&&73===e[i]&&68===e[i+1]&&51===e[i+2]&&!!(e[i+3]<255)&&!!(e[i+4]<255)&&!!(e[i+6]<128)&&!!(e[i+7]<128)&&!!(e[i+8]<128)&&!!(e[i+9]<128)},tg=function t(e,i){return!!(i+10<=e.length)&&51===e[i]&&68===e[i+1]&&73===e[i+2]&&!!(e[i+3]<255)&&!!(e[i+4]<255)&&!!(e[i+6]<128)&&!!(e[i+7]<128)&&!!(e[i+8]<128)&&!!(e[i+9]<128)},tv=function t(e,i){for(var r=i,n=0;t$(e,i);){n+=10;var a=tm(e,i+6);n+=a,tg(e,i+10)&&(n+=10),i+=n}if(n>0)return e.subarray(r,r+n)},tm=function t(e,i){var r=0;return r=(127&e[i])<<21,r|=(127&e[i+1])<<14,r|=(127&e[i+2])<<7,r|=127&e[i+3]},tp=function t(e){for(var i=tx(e),r=0;r<i.length;r++){var n=i[r];if(ty(n))return tR(n)}},ty=function t(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info},tT=function t(e){var i=String.fromCharCode(e[0],e[1],e[2],e[3]),r=tm(e,4);return{type:i,size:r,data:e.subarray(10,10+r)}},tx=function t(e){for(var i=0,r=[];t$(e,i);){for(var n=tm(e,i+6),a=(i+=10)+n;i+8<a;){var s=tT(e.subarray(i)),o=tE(s);o&&r.push(o),i+=s.size+10}tg(e,i)&&(i+=10)}return r},tE=function t(e){return"PRIV"===e.type?tS(e):"W"===e.type[0]?tA(e):tL(e)},tS=function t(e){if(!(e.size<2)){var i=t_(e.data,!0),r=new Uint8Array(e.data.subarray(i.length+1));return{key:e.type,info:i,data:r.buffer}}},tL=function t(e){if(!(e.size<2)){if("TXXX"===e.type){var i=1,r=t_(e.data.subarray(i),!0);i+=r.length+1;var n=t_(e.data.subarray(i));return{key:e.type,info:r,data:n}}var a=t_(e.data.subarray(1));return{key:e.type,data:a}}},tA=function t(e){if("WXXX"===e.type){if(e.size<2)return;var i=1,r=t_(e.data.subarray(i),!0);i+=r.length+1;var n=t_(e.data.subarray(i));return{key:e.type,info:r,data:n}}var a=t_(e.data);return{key:e.type,data:a}},tR=function t(e){if(8===e.data.byteLength){var i=new Uint8Array(e.data),r=1&i[3],n=(i[4]<<23)+(i[5]<<15)+(i[6]<<7)+i[7];return n/=45,r&&(n+=47721858.84),Math.round(n)}},t_=function t(e,i){void 0===i&&(i=!1);var r,n,a,s=function t(){if(!navigator.userAgent.includes("PlayStation 4"))return g||void 0===self.TextDecoder||(g=new self.TextDecoder("utf-8")),g}();if(s){var o=s.decode(e);if(i){var l=o.indexOf("\0");return -1!==l?o.substring(0,l):o}return o.replace(/\0/g,"")}for(var u=e.length,d="",h=0;h<u&&(0!==(r=e[h++])||!i);)if(0!==r&&3!==r)switch(r>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:d+=String.fromCharCode(r);break;case 12:case 13:d+=String.fromCharCode((31&r)<<6|63&(n=e[h++]));break;case 14:d+=String.fromCharCode((15&r)<<12|(63&(n=e[h++]))<<6|(63&(a=e[h++]))<<0)}return d},tD={hexDump:function t(e){for(var i="",r=0;r<e.length;r++){var n=e[r].toString(16);n.length<2&&(n="0"+n),i+=n}return i}},tk=[].push,tI={video:1,audio:2,id3:3,text:4};function tb(t){return String.fromCharCode.apply(null,t)}function tC(t,e){var i=t[e]<<8|t[e+1];return i<0?65536+i:i}function t8(t,e){var i=tP(t,e);return i<0?4294967296+i:i}function tw(t,e){var i=t8(t,e);return i*=4294967296,i+=t8(t,e+4)}function tP(t,e){return t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]}function tF(t,e,i){t[e]=i>>24,t[e+1]=i>>16&255,t[e+2]=i>>8&255,t[e+3]=255&i}function tO(t,e){var i=[];if(!e.length)return i;for(var r=t.byteLength,n=0;n<r;){var a=t8(t,n),s=tb(t.subarray(n+4,n+8)),o=a>1?n+a:r;if(s===e[0]){if(1===e.length)i.push(t.subarray(n+8,o));else{var l=tO(t.subarray(n+8,o),e.slice(1));l.length&&tk.apply(i,l)}}n=o}return i}function tN(t){var e=[],i=t[0],r=8,n=t8(t,r);r+=4;var a=0,s=0;0===i?(a=t8(t,r),s=t8(t,r+4),r+=8):(a=tw(t,r),s=tw(t,r+8),r+=16),r+=2;var o=t.length+s,l=tC(t,r);r+=2;for(var u=0;u<l;u++){var d=r,h=t8(t,d);d+=4;var f=2147483647&h;if(1==(2147483648&h)>>>31)return H.warn("SIDX has hierarchical references (not supported)"),null;var c=t8(t,d);d+=4,e.push({referenceSize:f,subsegmentDuration:c,info:{duration:c/n,start:o,end:o+f-1}}),o+=f,d+=4,r=d}return{earliestPresentationTime:a,timescale:n,version:i,referencesCount:l,references:e}}function tM(t){for(var e=[],i=tO(t,["moov","trak"]),n=0;n<i.length;n++){var a=i[n],s=tO(a,["tkhd"])[0];if(s){var o=s[0],l=t8(s,0===o?12:20),u=tO(a,["mdia","mdhd"])[0];if(u){o=u[0];var d=t8(u,0===o?12:20),h=tO(a,["mdia","hdlr"])[0];if(h){var f=tb(h.subarray(8,12)),c={soun:Q.AUDIO,vide:Q.VIDEO}[f];if(c){var $=tO(a,["mdia","minf","stbl","stsd"])[0],g=tB($);e[l]={timescale:d,type:c},e[c]=r({timescale:d,id:l},g)}}}}}return tO(t,["moov","mvex","trex"]).forEach(function(t){var i=e[t8(t,4)];i&&(i.default={duration:t8(t,12),flags:t8(t,20)})}),e}function tB(t){var e=t.subarray(8),i=e.subarray(86),r=tb(e.subarray(4,8)),n=r,a="enca"===r||"encv"===r;if(a){var s=tO(e,[r])[0].subarray("enca"===r?28:78);tO(s,["sinf"]).forEach(function(t){var e=tO(t,["schm"])[0];if(e){var i=tb(e.subarray(4,8));if("cbcs"===i||"cenc"===i){var r=tO(t,["frma"])[0];r&&(n=tb(r))}}})}switch(n){case"avc1":case"avc2":case"avc3":case"avc4":var o=tO(i,["avcC"])[0];n+="."+t0(o[1])+t0(o[2])+t0(o[3]);break;case"mp4a":var l=tO(e,[r])[0],u=tO(l.subarray(28),["esds"])[0];if(u&&u.length>12){var d=4;if(3!==u[d++])break;d=tU(u,d),d+=2;var h=u[d++];if(128&h&&(d+=2),64&h&&(d+=u[d++]),4!==u[d++])break;d=tU(u,d);var f=u[d++];if(64===f)n+="."+t0(f);else break;if(d+=12,5!==u[d++])break;d=tU(u,d);var c=u[d++],$=(248&c)>>3;31===$&&($+=1+((7&c)<<3)+((224&u[d])>>5)),n+="."+$}break;case"hvc1":case"hev1":var g=tO(i,["hvcC"])[0],v=g[1],m=["","A","B","C"][v>>6],p=t8(g,2),y=g[12],T=g.subarray(6,12);n+="."+m+(31&v),n+="."+p.toString(16).toUpperCase(),n+="."+((32&v)>>5?"H":"L")+y;for(var x="",E=T.length;E--;){var S=T[E];(S||x)&&(x="."+S.toString(16).toUpperCase()+x)}n+=x;break;case"dvh1":case"dvhe":var L=tO(i,["dvcC"])[0],A=L[2]>>1&127,R=L[2]<<5&32|L[3]>>3&31;n+="."+tG(A)+"."+tG(R);break;case"vp09":var _=tO(i,["vpcC"])[0],D=_[4],k=_[5],I=_[6]>>4&15;n+="."+tG(D)+"."+tG(k)+"."+tG(I);break;case"av01":var b=tO(i,["av1C"])[0],C=b[1]>>>5,w=31&b[1],P=b[2]>>>7?"H":"M",F=(64&b[2])>>6,O=(32&b[2])>>5,N=(16&b[2])>>4,M=(8&b[2])>>3,B=(4&b[2])>>2,U=3&b[2];n+="."+C+"."+tG(w)+P+"."+tG(2===C&&F?O?12:10:F?10:8)+"."+N+"."+M+B+U+"."+tG(1)+"."+tG(1)+"."+tG(1)+".0"}return{codec:n,encrypted:a}}function tU(t,e){for(var i=e+5;128&t[e++]&&e<i;);return e}function t0(t){return("0"+t.toString(16).toUpperCase()).slice(-2)}function tG(t){return(t<10?"0":"")+t}function t2(t){var e=tO(t,["schm"])[0];if(e){var i=tb(e.subarray(4,8));if("cbcs"===i||"cenc"===i)return tO(t,["schi","tenc"])[0]}return H.error("[eme] missing 'schm' box"),null}function t1(t){var e=t8(t,0),i=8;1&e&&(i+=4),4&e&&(i+=4);for(var r=0,n=t8(t,4),a=0;a<n;a++){if(256&e){var s=t8(t,i);r+=s,i+=4}512&e&&(i+=4),1024&e&&(i+=4),2048&e&&(i+=4)}return r}function t6(t,e){var i=new Uint8Array(t.length+e.length);return i.set(t),i.set(e,t.length),i}function tK(t,e){var i=[],r=e.samples,n=e.timescale,a=e.id,s=!1;return tO(r,["moof"]).map(function(o){var l=o.byteOffset-8;tO(o,["traf"]).map(function(o){var u=tO(o,["tfdt"]).map(function(t){var e=t[0],i=t8(t,4);return 1===e&&(i*=4294967296,i+=t8(t,8)),i/n})[0];return void 0!==u&&(t=u),tO(o,["tfhd"]).map(function(u){var d=t8(u,4),h=16777215&t8(u,0),f=0,c=0,$=8;d===a&&((1&h)!=0&&($+=8),(2&h)!=0&&($+=4),(8&h)!=0&&(f=t8(u,$),$+=4),(16&h)!=0&&(c=t8(u,$),$+=4),(32&h)!=0&&($+=4),"video"===e.type&&(s=function t(e){if(!e)return!1;var i=e.indexOf("."),r=i<0?e:e.substring(0,i);return"hvc1"===r||"hev1"===r||"dvh1"===r||"dvhe"===r}(e.codec)),tO(o,["trun"]).map(function(a){var o=a[0],u=16777215&t8(a,0),d=0,h=(256&u)!=0,$=0,g=(512&u)!=0,v=0,m=(1024&u)!=0,p=(2048&u)!=0,y=0,T=t8(a,4),x=8;(1&u)!=0&&(d=t8(a,x),x+=4),(4&u)!=0&&(x+=4);for(var E=d+l,S=0;S<T;S++){if(h?($=t8(a,x),x+=4):$=f,g?(v=t8(a,x),x+=4):v=c,m&&(x+=4),p&&(y=0===o?t8(a,x):tP(a,x),x+=4),e.type===Q.VIDEO)for(var L=0;L<v;){var A=t8(r,E);if(t4(s,r[E+=4])){var R=r.subarray(E,E+A);t3(R,s?2:1,t+y/n,i)}E+=A,L+=A+4}t+=$/n}}))})})}),i}function t4(t,e){if(!t)return 6==(31&e);var i=e>>1&63;return 39===i||40===i}function t3(t,e,i,r){var n=tH(t),a=0;a+=e;for(var s=0,o=0,l=0;a<n.length;){s=0;do{if(a>=n.length)break;s+=l=n[a++]}while(255===l);o=0;do{if(a>=n.length)break;o+=l=n[a++]}while(255===l);var u=n.length-a,d=a;if(o<u)a+=o;else if(o>u){H.error("Malformed SEI payload. "+o+" is too small, only "+u+" bytes left to parse.");break}if(4===s){if(181===n[d++]){var h=tC(n,d);if(d+=2,49===h){var f=t8(n,d);if(d+=4,1195456820===f){var c=n[d++];if(3===c){var $=n[d++],g=31&$,v=64&$,m=v?2+3*g:0,p=new Uint8Array(m);if(v){p[0]=$;for(var y=1;y<m;y++)p[y]=n[d++]}r.push({type:c,payloadType:s,pts:i,bytes:p})}}}}}else if(5===s&&o>16){for(var T=[],x=0;x<16;x++){var E=n[d++].toString(16);T.push(1==E.length?"0"+E:E),(3===x||5===x||7===x||9===x)&&T.push("-")}for(var S=o-16,L=new Uint8Array(S),A=0;A<S;A++)L[A]=n[d++];r.push({payloadType:s,pts:i,uuid:T.join(""),userData:t_(L),userDataBytes:L})}}}function tH(t){for(var e=t.byteLength,i=[],r=1;r<e-2;)0===t[r]&&0===t[r+1]&&3===t[r+2]?(i.push(r+2),r+=2):r++;if(0===i.length)return t;var n=e-i.length,a=new Uint8Array(n),s=0;for(r=0;r<n;s++,r++)s===i[0]&&(s++,i.shift()),a[r]=t[s];return a}var tV={},t7=function(){function t(t,e,i,r,n){void 0===r&&(r=[1]),void 0===n&&(n=null),this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=t,this.uri=e,this.keyFormat=i,this.keyFormatVersions=r,this.iv=n,this.encrypted=!!t&&"NONE"!==t,this.isCommonEncryption=this.encrypted&&"AES-128"!==t}t.clearKeyUriToKeyIdMap=function t(){tV={}};var e=t.prototype;return e.isSupported=function t(){if(this.method){if("AES-128"===this.method||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case ts.FAIRPLAY:case ts.WIDEVINE:case ts.PLAYREADY:case ts.CLEARKEY:return -1!==["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)}}return!1},e.getDecryptData=function e(i){if(!this.encrypted||!this.uri)return null;if("AES-128"===this.method&&this.uri&&!this.iv){"number"!=typeof i&&("AES-128"!==this.method||this.iv||H.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),i=0);var r=function t(e){for(var i=new Uint8Array(16),r=12;r<16;r++)i[r]=e>>8*(15-r)&255;return i}(i);return new t(this.method,this.uri,"identity",this.keyFormatVersions,r)}var n=function t(e){var i=e.split(":"),r=null;if("data"===i[0]&&2===i.length){var n=i[1].split(";"),a=n[n.length-1].split(",");if(2===a.length){var s,o,l,u="base64"===a[0],d=a[1];u?(n.splice(-1,1),r=ti(d)):r=(o=tr(s=d).subarray(0,16),(l=new Uint8Array(16)).set(o,16-o.length),l)}}return r}(this.uri);if(n)switch(this.keyFormat){case ts.WIDEVINE:this.pssh=n,n.length>=22&&(this.keyId=n.subarray(n.length-22,n.length-6));break;case ts.PLAYREADY:var a=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=function t(e,i,r){if(16!==e.byteLength)throw RangeError("Invalid system id");if(i){n=1,a=new Uint8Array(16*i.length);for(var n,a,s,o=0;o<i.length;o++){var l=i[o];if(16!==l.byteLength)throw RangeError("Invalid key");a.set(l,16*o)}}else n=0,a=new Uint8Array;n>0?(s=new Uint8Array(4),i.length>0&&new DataView(s.buffer).setUint32(0,i.length,!1)):s=new Uint8Array;var u=new Uint8Array(4);return r&&r.byteLength>0&&new DataView(u.buffer).setUint32(0,r.byteLength,!1),function t(e){for(var i=arguments.length,r=Array(i>1?i-1:0),n=1;n<i;n++)r[n-1]=arguments[n];for(var a=r.length,s=8,o=a;o--;)s+=r[o].byteLength;var l=new Uint8Array(s);for(l[0]=s>>24&255,l[1]=s>>16&255,l[2]=s>>8&255,l[3]=255&s,l.set(e,4),o=0,s=8;o<a;o++)l.set(r[o],s),s+=r[o].byteLength;return l}([112,115,115,104],new Uint8Array([n,0,0,0]),e,s,a,u,r||new Uint8Array)}(a,null,n);var s=new Uint16Array(n.buffer,n.byteOffset,n.byteLength/2),o=String.fromCharCode.apply(null,Array.from(s)),l=o.substring(o.indexOf("<"),o.length),u=new DOMParser().parseFromString(l,"text/xml").getElementsByTagName("KID")[0];if(u){var d=u.childNodes[0]?u.childNodes[0].nodeValue:u.getAttribute("VALUE");if(d){var h,f,c=ti(d).subarray(0,16);h=c,(f=function t(e,i,r){var n=e[i];e[i]=e[r],e[r]=n})(h,0,3),f(h,1,2),f(h,4,5),f(h,6,7),this.keyId=c}}break;default:var $=n.subarray(0,16);if(16!==$.length){var g=new Uint8Array(16);g.set($,16-$.length),$=g}this.keyId=$}if(!this.keyId||16!==this.keyId.byteLength){var v=tV[this.uri];if(!v){var m=Object.keys(tV).length%Number.MAX_SAFE_INTEGER;v=new Uint8Array(16),new DataView(v.buffer,12,4).setUint32(0,m),tV[this.uri]=v}this.keyId=v}return this},t}(),tY=/\{\$([a-zA-Z0-9-_]+)\}/g;function tW(t){return tY.test(t)}function t5(t,e,i){if(null!==t.variableList||t.hasVariableRefs)for(var r=i.length;r--;){var n=i[r],a=e[n];a&&(e[n]=tq(t,a))}}function tq(t,e){if(null!==t.variableList||t.hasVariableRefs){var i=t.variableList;return e.replace(tY,function(e){var r=e.substring(2,e.length-1),n=null==i?void 0:i[r];return void 0===n?(t.playlistParsingError||(t.playlistParsingError=Error('Missing preceding EXT-X-DEFINE tag for Variable Reference: "'+r+'"')),e):n})}return e}function tX(t,e,i){var r,n,a=t.variableList;if(a||(t.variableList=a={}),"QUERYPARAM"in e){r=e.QUERYPARAM;try{var s=new self.URL(i).searchParams;if(s.has(r))n=s.get(r);else throw Error('"'+r+'" does not match any query parameter in URI: "'+i+'"')}catch(o){t.playlistParsingError||(t.playlistParsingError=Error("EXT-X-DEFINE QUERYPARAM: "+o.message))}}else r=e.NAME,n=e.VALUE;r in a?t.playlistParsingError||(t.playlistParsingError=Error('EXT-X-DEFINE duplicate Variable Name declarations: "'+r+'"')):a[r]=n||""}function tz(t,e,i){var r=e.IMPORT;if(i&&r in i){var n=t.variableList;n||(t.variableList=n={}),n[r]=i[r]}else t.playlistParsingError||(t.playlistParsingError=Error('EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "'+r+'"'))}function tj(t){if(void 0===t&&(t=!0),"undefined"!=typeof self)return(t||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}var tQ={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 t9(t,e,i){return void 0===i&&(i=!0),!t.split(",").some(function(t){return!tZ(t,e,i)})}function tZ(t,e,i){void 0===i&&(i=!0);var r,n=tj(i);return null!=(r=null==n?void 0:n.isTypeSupported(tJ(t,e)))&&r}function tJ(t,e){return e+'/mp4;codecs="'+t+'"'}function et(t){if(t){var e=t.substring(0,4);return tQ.video[e]}return 2}function ee(t){return t.split(",").reduce(function(t,e){var i=tQ.video[e];return i?(2*i+t)/(t?3:2):(tQ.audio[e]+t)/(t?2:1)},0)}var ei={},er=/flac|opus/i;function en(t,e){return void 0===e&&(e=!0),t.replace(er,function(t){return function t(e,i){if(void 0===i&&(i=!0),ei[e])return ei[e];for(var r={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"]}[e],n=0;n<r.length;n++)if(tZ(r[n],"audio",i))return ei[e]=r[n],r[n];return e}(t.toLowerCase(),e)})}function ea(t,e){return t&&"mp4a"!==t?t:e?e.split(",")[0]:e}var es=/#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,eo=/#EXT-X-MEDIA:(.*)/g,el=/^#EXT(?:INF|-X-TARGETDURATION):/m,eu=RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),ed=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("|")),eh=function(){function t(){}return t.findGroup=function t(e,i){for(var r=0;r<e.length;r++){var n=e[r];if(n.id===i)return n}},t.resolve=function t(e,i){return C.buildAbsoluteURL(i,e,{alwaysNormalize:!0})},t.isMediaPlaylist=function t(e){return el.test(e)},t.parseMasterPlaylist=function e(i,r){var n={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:tW(i)},a=[];for(es.lastIndex=0;null!=(s=es.exec(i));)if(s[1]){var s,o,l=new W(s[1]);t5(n,l,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);var u=tq(n,s[2]),d={attrs:l,bitrate:l.decimalInteger("BANDWIDTH")||l.decimalInteger("AVERAGE-BANDWIDTH"),name:l.NAME,url:t.resolve(u,r)},h=l.decimalResolution("RESOLUTION");h&&(d.width=h.width,d.height=h.height),e$(l.CODECS,d),null!=(o=d.unknownCodecs)&&o.length||a.push(d),n.levels.push(d)}else if(s[3]){var f=s[3],c=s[4];switch(f){case"SESSION-DATA":var $=new W(c);t5(n,$,["DATA-ID","LANGUAGE","VALUE","URI"]);var g=$["DATA-ID"];g&&(null===n.sessionData&&(n.sessionData={}),n.sessionData[g]=$);break;case"SESSION-KEY":var v=ef(c,r,n);v.encrypted&&v.isSupported()?(null===n.sessionKeys&&(n.sessionKeys=[]),n.sessionKeys.push(v)):H.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+c+'"');break;case"DEFINE":var m=new W(c);t5(n,m,["NAME","VALUE","QUERYPARAM"]),tX(n,m,r);break;case"CONTENT-STEERING":var p=new W(c);t5(n,p,["SERVER-URI","PATHWAY-ID"]),n.contentSteering={uri:t.resolve(p["SERVER-URI"],r),pathwayId:p["PATHWAY-ID"]||"."};break;case"START":n.startTimeOffset=ec(c)}}var y=a.length>0&&a.length<n.levels.length;return n.levels=y?a:n.levels,0===n.levels.length&&(n.playlistParsingError=Error("no levels found in manifest")),n},t.parseMasterPlaylistMedia=function e(i,r,n){var a,s={},o=n.levels,l={AUDIO:o.map(function(t){return{id:t.attrs.AUDIO,audioCodec:t.audioCodec}}),SUBTITLES:o.map(function(t){return{id:t.attrs.SUBTITLES,textCodec:t.textCodec}}),"CLOSED-CAPTIONS":[]},u=0;for(eo.lastIndex=0;null!==(a=eo.exec(i));){var d=new W(a[1]),h=d.TYPE;if(h){var f=l[h],c=s[h]||[];s[h]=c,t5(n,d,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);var $=d.LANGUAGE,g=d["ASSOC-LANGUAGE"],v=d.CHANNELS,m=d.CHARACTERISTICS,p=d["INSTREAM-ID"],y={attrs:d,bitrate:0,id:u++,groupId:d["GROUP-ID"]||"",name:d.NAME||$||"",type:h,default:d.bool("DEFAULT"),autoselect:d.bool("AUTOSELECT"),forced:d.bool("FORCED"),lang:$,url:d.URI?t.resolve(d.URI,r):""};if(g&&(y.assocLang=g),v&&(y.channels=v),m&&(y.characteristics=m),p&&(y.instreamId=p),null!=f&&f.length){var T=t.findGroup(f,y.groupId)||f[0];eg(y,T,"audioCodec"),eg(y,T,"textCodec")}c.push(y)}}return s},t.parseLevelPlaylist=function t(e,i,r,n,a,s){var o,u,d,h=new te(i),f=h.fragments,c=null,$=0,g=0,v=0,m=0,p=null,y=new J(n,i),T=-1,x=!1,E=null;for(eu.lastIndex=0,h.m3u8=e,h.hasVariableRefs=tW(e);null!==(o=eu.exec(e));){x&&(x=!1,(y=new J(n,i)).start=v,y.sn=$,y.cc=m,y.level=r,c&&(y.initSegment=c,y.rawProgramDateTime=c.rawProgramDateTime,c.rawProgramDateTime=null,E&&(y.setByteRange(E),E=null)));var S=o[1];if(S){y.duration=parseFloat(S);var L=(" "+o[2]).slice(1);y.title=L||null,y.tagList.push(L?["INF",S,L]:["INF",S])}else if(o[3]){if(w(y.duration)){y.start=v,d&&ep(y,d,h),y.sn=$,y.level=r,y.cc=m,f.push(y);var A=(" "+o[3]).slice(1);y.relurl=tq(h,A),ev(y,p),p=y,v+=y.duration,$++,g=0,x=!0}}else if(o[4]){var R=(" "+o[4]).slice(1);p?y.setByteRange(R,p):y.setByteRange(R)}else if(o[5])y.rawProgramDateTime=(" "+o[5]).slice(1),y.tagList.push(["PROGRAM-DATE-TIME",y.rawProgramDateTime]),-1===T&&(T=f.length);else{if(!(o=o[0].match(ed))){H.warn("No matches on slow regex match for level playlist!");continue}for(u=1;u<o.length&&void 0===o[u];u++);var _=(" "+o[u]).slice(1),D=(" "+o[u+1]).slice(1),k=o[u+2]?(" "+o[u+2]).slice(1):"";switch(_){case"PLAYLIST-TYPE":h.type=D.toUpperCase();break;case"MEDIA-SEQUENCE":$=h.startSN=parseInt(D);break;case"SKIP":var I=new W(D);t5(h,I,["RECENTLY-REMOVED-DATERANGES"]);var b=I.decimalInteger("SKIPPED-SEGMENTS");if(w(b)){h.skippedSegments=b;for(var C=b;C--;)f.unshift(null);$+=b}var P=I.enumeratedString("RECENTLY-REMOVED-DATERANGES");P&&(h.recentlyRemovedDateranges=P.split(" "));break;case"TARGETDURATION":h.targetduration=Math.max(parseInt(D),1);break;case"VERSION":h.version=parseInt(D);break;case"INDEPENDENT-SEGMENTS":case"EXTM3U":break;case"ENDLIST":h.live=!1;break;case"#":(D||k)&&y.tagList.push(k?[D,k]:[D]);break;case"DISCONTINUITY":m++,y.tagList.push(["DIS"]);break;case"GAP":y.gap=!0,y.tagList.push([_]);break;case"BITRATE":y.tagList.push([_,D]);break;case"DATERANGE":var F=new W(D);t5(h,F,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),t5(h,F,F.clientAttrs);var O=new z(F,h.dateRanges[F.ID]);O.isValid||h.skippedSegments?h.dateRanges[O.id]=O:H.warn('Ignoring invalid DATERANGE tag: "'+D+'"'),y.tagList.push(["EXT-X-DATERANGE",D]);break;case"DEFINE":var N=new W(D);t5(h,N,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in N?tz(h,N,s):tX(h,N,i);break;case"DISCONTINUITY-SEQUENCE":m=parseInt(D);break;case"KEY":var M=ef(D,i,h);if(M.isSupported()){if("NONE"===M.method){d=void 0;break}d||(d={}),d[M.keyFormat]&&(d=l({},d)),d[M.keyFormat]=M}else H.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+D+'"');break;case"START":h.startTimeOffset=ec(D);break;case"MAP":var B=new W(D);if(t5(h,B,["BYTERANGE","URI"]),y.duration){var U=new J(n,i);em(U,B,r,d),c=U,y.initSegment=c,c.rawProgramDateTime&&!y.rawProgramDateTime&&(y.rawProgramDateTime=c.rawProgramDateTime)}else{var G=y.byteRangeEndOffset;if(G){var K=y.byteRangeStartOffset;E=G-K+"@"+K}else E=null;em(y,B,r,d),c=y,x=!0}break;case"SERVER-CONTROL":var V=new W(D);h.canBlockReload=V.bool("CAN-BLOCK-RELOAD"),h.canSkipUntil=V.optionalFloat("CAN-SKIP-UNTIL",0),h.canSkipDateRanges=h.canSkipUntil>0&&V.bool("CAN-SKIP-DATERANGES"),h.partHoldBack=V.optionalFloat("PART-HOLD-BACK",0),h.holdBack=V.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var Y=new W(D);h.partTarget=Y.decimalFloatingPoint("PART-TARGET");break;case"PART":var q=h.partList;q||(q=h.partList=[]);var X=g>0?q[q.length-1]:void 0,j=g++,Q=new W(D);t5(h,Q,["BYTERANGE","URI"]);var Z=new tt(Q,y,i,j,X);q.push(Z),y.duration+=Z.duration;break;case"PRELOAD-HINT":var ti=new W(D);t5(h,ti,["URI"]),h.preloadHint=ti;break;case"RENDITION-REPORT":var tr=new W(D);t5(h,tr,["URI"]),h.renditionReports=h.renditionReports||[],h.renditionReports.push(tr);break;default:H.warn("line parsed but not handled: "+o)}}}p&&!p.relurl?(f.pop(),v-=p.duration,h.partList&&(h.fragmentHint=p)):h.partList&&(ev(y,p),y.cc=m,h.fragmentHint=y,d&&ep(y,d,h));var tn=f.length,ta=f[0],ts=f[tn-1];if((v+=h.skippedSegments*h.targetduration)>0&&tn&&ts){h.averagetargetduration=v/tn;var to=ts.sn;h.endSN="initSegment"!==to?to:0,h.live||(ts.endList=!0),ta&&(h.startCC=ta.cc)}else h.endSN=0,h.startCC=0;return h.fragmentHint&&(v+=h.fragmentHint.duration),h.totalduration=v,h.endCC=m,T>0&&function t(e,i){for(var r=e[i],n=i;n--;){var a=e[n];if(!a)return;a.programDateTime=r.programDateTime-1e3*a.duration,r=a}}(f,T),h},t}();function ef(t,e,i){var r,n,a=new W(t);t5(i,a,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);var s=null!=(r=a.METHOD)?r:"",o=a.URI,l=a.hexadecimalInteger("IV"),u=a.KEYFORMATVERSIONS,d=null!=(n=a.KEYFORMAT)?n:"identity";o&&a.IV&&!l&&H.error("Invalid IV: "+a.IV);var h=o?eh.resolve(o,e):"",f=(u||"1").split("/").map(Number).filter(Number.isFinite);return new t7(s,h,d,f,l)}function ec(t){var e=new W(t).decimalFloatingPoint("TIME-OFFSET");return w(e)?e:null}function e$(t,e){var i=(t||"").split(/[ ,]+/).filter(function(t){return t});["video","audio","text"].forEach(function(t){var r=i.filter(function(e){var i,r,n;return i=e,!!(n=tQ[r=t])&&!!n[i.slice(0,4)]});r.length&&(e[t+"Codec"]=r.join(","),i=i.filter(function(t){return -1===r.indexOf(t)}))}),e.unknownCodecs=i}function eg(t,e,i){var r=e[i];r&&(t[i]=r)}function ev(t,e){t.rawProgramDateTime?t.programDateTime=Date.parse(t.rawProgramDateTime):null!=e&&e.programDateTime&&(t.programDateTime=e.endProgramDateTime),w(t.programDateTime)||(t.programDateTime=null,t.rawProgramDateTime=null)}function em(t,e,i,r){t.relurl=e.URI,e.BYTERANGE&&t.setByteRange(e.BYTERANGE),t.level=i,t.sn="initSegment",r&&(t.levelkeys=r),t.initSegment=null}function ep(t,e,i){t.levelkeys=e;var r=i.encryptedFragments;(!r.length||r[r.length-1].levelkeys!==e)&&Object.keys(e).some(function(t){return e[t].isCommonEncryption})&&r.push(t)}var ey={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},eT={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function ex(t){var e=t.type;switch(e){case ey.AUDIO_TRACK:return eT.AUDIO;case ey.SUBTITLE_TRACK:return eT.SUBTITLE;default:return eT.MAIN}}function eE(t,e){var i=t.url;return(void 0===i||0===i.indexOf("data:"))&&(i=e.url),i}var eS=function(){function t(t){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=t,this.registerListeners()}var e=t.prototype;return e.startLoad=function t(e){},e.stopLoad=function t(){this.destroyInternalLoaders()},e.registerListeners=function t(){var e=this.hls;e.on(O.MANIFEST_LOADING,this.onManifestLoading,this),e.on(O.LEVEL_LOADING,this.onLevelLoading,this),e.on(O.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(O.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},e.unregisterListeners=function t(){var e=this.hls;e.off(O.MANIFEST_LOADING,this.onManifestLoading,this),e.off(O.LEVEL_LOADING,this.onLevelLoading,this),e.off(O.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(O.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},e.createInternalLoader=function t(e){var i=this.hls.config,r=i.pLoader,n=i.loader,a=new(r||n)(i);return this.loaders[e.type]=a,a},e.getInternalLoader=function t(e){return this.loaders[e.type]},e.resetInternalLoader=function t(e){this.loaders[e]&&delete this.loaders[e]},e.destroyInternalLoaders=function t(){for(var e in this.loaders){var i=this.loaders[e];i&&i.destroy(),this.resetInternalLoader(e)}},e.destroy=function t(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()},e.onManifestLoading=function t(e,i){var r=i.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:ey.MANIFEST,url:r,deliveryDirectives:null})},e.onLevelLoading=function t(e,i){var r=i.id,n=i.level,a=i.pathwayId,s=i.url,o=i.deliveryDirectives;this.load({id:r,level:n,pathwayId:a,responseType:"text",type:ey.LEVEL,url:s,deliveryDirectives:o})},e.onAudioTrackLoading=function t(e,i){var r=i.id,n=i.groupId,a=i.url,s=i.deliveryDirectives;this.load({id:r,groupId:n,level:null,responseType:"text",type:ey.AUDIO_TRACK,url:a,deliveryDirectives:s})},e.onSubtitleTrackLoading=function t(e,i){var r=i.id,n=i.groupId,a=i.url,s=i.deliveryDirectives;this.load({id:r,groupId:n,level:null,responseType:"text",type:ey.SUBTITLE_TRACK,url:a,deliveryDirectives:s})},e.load=function t(e){var i,r,n,a=this,s=this.hls.config,o=this.getInternalLoader(e);if(o){var u=o.context;if(u&&u.url===e.url&&u.level===e.level){H.trace("[playlist-loader]: playlist request ongoing");return}H.log("[playlist-loader]: aborting previous loader for type: "+e.type),o.abort()}if(i=e.type===ey.MANIFEST?s.manifestLoadPolicy.default:l({},s.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),o=this.createInternalLoader(e),w(null==(n=e.deliveryDirectives)?void 0:n.part)&&(e.type===ey.LEVEL&&null!==e.level?r=this.hls.levels[e.level].details:e.type===ey.AUDIO_TRACK&&null!==e.id?r=this.hls.audioTracks[e.id].details:e.type===ey.SUBTITLE_TRACK&&null!==e.id&&(r=this.hls.subtitleTracks[e.id].details),r)){var d=r.partTarget,h=r.targetduration;if(d&&h){var f=1e3*Math.max(3*d,.8*h);i=l({},i,{maxTimeToFirstByteMs:Math.min(f,i.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(f,i.maxTimeToFirstByteMs)})}}var c=i.errorRetry||i.timeoutRetry||{},$={loadPolicy:i,timeout:i.maxLoadTimeMs,maxRetry:c.maxNumRetry||0,retryDelay:c.retryDelayMs||0,maxRetryDelay:c.maxRetryDelayMs||0};o.load(e,$,{onSuccess:function t(e,i,r,n){var s=a.getInternalLoader(r);a.resetInternalLoader(r.type);var o=e.data;if(0!==o.indexOf("#EXTM3U")){a.handleManifestParsingError(e,r,Error("no EXTM3U delimiter"),n||null,i);return}i.parsing.start=performance.now(),eh.isMediaPlaylist(o)?a.handleTrackOrLevelPlaylist(e,i,r,n||null,s):a.handleMasterPlaylist(e,i,r,n)},onError:function t(e,i,r,n){a.handleNetworkError(i,r,!1,e,n)},onTimeout:function t(e,i,r){a.handleNetworkError(i,r,!0,void 0,e)}})},e.handleMasterPlaylist=function t(e,i,r,n){var a=this.hls,s=e.data,o=eE(e,r),l=eh.parseMasterPlaylist(s,o);if(l.playlistParsingError){this.handleManifestParsingError(e,r,l.playlistParsingError,n,i);return}var u=l.contentSteering,d=l.levels,h=l.sessionData,f=l.sessionKeys,c=l.startTimeOffset,$=l.variableList;this.variableList=$;var g=eh.parseMasterPlaylistMedia(s,o,l),v=g.AUDIO,m=void 0===v?[]:v,p=g.SUBTITLES,y=g["CLOSED-CAPTIONS"];m.length&&(m.some(function(t){return!t.url})||!d[0].audioCodec||d[0].attrs.AUDIO||(H.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),m.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new W({}),bitrate:0,url:""}))),a.trigger(O.MANIFEST_LOADED,{levels:d,audioTracks:m,subtitles:p,captions:y,contentSteering:u,url:o,stats:i,networkDetails:n,sessionData:h,sessionKeys:f,startTimeOffset:c,variableList:$})},e.handleTrackOrLevelPlaylist=function t(e,i,r,n,a){var s=this.hls,o=r.id,l=r.level,u=r.type,d=eE(e,r),h=w(l)?l:w(o)?o:0,f=ex(r),c=eh.parseLevelPlaylist(e.data,d,h,f,0,this.variableList);if(u===ey.MANIFEST){var $={attrs:new W({}),bitrate:0,details:c,name:"",url:d};s.trigger(O.MANIFEST_LOADED,{levels:[$],audioTracks:[],url:d,stats:i,networkDetails:n,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}i.parsing.end=performance.now(),r.levelDetails=c,this.handlePlaylistLoaded(c,e,i,r,n,a)},e.handleManifestParsingError=function t(e,i,r,n,a){this.hls.trigger(O.ERROR,{type:N.NETWORK_ERROR,details:M.MANIFEST_PARSING_ERROR,fatal:i.type===ey.MANIFEST,url:e.url,err:r,error:r,reason:r.message,response:e,context:i,networkDetails:n,stats:a})},e.handleNetworkError=function t(e,i,n,a,s){void 0===n&&(n=!1);var o="A network "+(n?"timeout":"error"+(a?" (status "+a.code+")":""))+" occurred while loading "+e.type;e.type===ey.LEVEL?o+=": "+e.level+" id: "+e.id:(e.type===ey.AUDIO_TRACK||e.type===ey.SUBTITLE_TRACK)&&(o+=" id: "+e.id+' group-id: "'+e.groupId+'"');var l=Error(o);H.warn("[playlist-loader]: "+o);var u=M.UNKNOWN,d=!1,h=this.getInternalLoader(e);switch(e.type){case ey.MANIFEST:u=n?M.MANIFEST_LOAD_TIMEOUT:M.MANIFEST_LOAD_ERROR,d=!0;break;case ey.LEVEL:u=n?M.LEVEL_LOAD_TIMEOUT:M.LEVEL_LOAD_ERROR,d=!1;break;case ey.AUDIO_TRACK:u=n?M.AUDIO_TRACK_LOAD_TIMEOUT:M.AUDIO_TRACK_LOAD_ERROR,d=!1;break;case ey.SUBTITLE_TRACK:u=n?M.SUBTITLE_TRACK_LOAD_TIMEOUT:M.SUBTITLE_LOAD_ERROR,d=!1}h&&this.resetInternalLoader(e.type);var f={type:N.NETWORK_ERROR,details:u,fatal:d,url:e.url,loader:h,context:e,error:l,networkDetails:i,stats:s};if(a){var c=(null==i?void 0:i.url)||e.url;f.response=r({url:c,data:void 0},a)}this.hls.trigger(O.ERROR,f)},e.handlePlaylistLoaded=function t(e,i,r,n,a,s){var o=this.hls,l=n.type,u=n.level,d=n.id,h=n.groupId,f=n.deliveryDirectives,c=eE(i,n),$=ex(n),g="number"==typeof n.level&&$===eT.MAIN?u:void 0;if(!e.fragments.length){var v=Error("No Segments found in Playlist");o.trigger(O.ERROR,{type:N.NETWORK_ERROR,details:M.LEVEL_EMPTY_ERROR,fatal:!1,url:c,error:v,reason:v.message,response:i,context:n,level:g,parent:$,networkDetails:a,stats:r});return}e.targetduration||(e.playlistParsingError=Error("Missing Target Duration"));var m=e.playlistParsingError;if(m){o.trigger(O.ERROR,{type:N.NETWORK_ERROR,details:M.LEVEL_PARSING_ERROR,fatal:!1,url:c,error:m,reason:m.message,response:i,context:n,level:g,parent:$,networkDetails:a,stats:r});return}switch(e.live&&s&&(s.getCacheAge&&(e.ageHeader=s.getCacheAge()||0),(!s.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),l){case ey.MANIFEST:case ey.LEVEL:o.trigger(O.LEVEL_LOADED,{details:e,level:g||0,id:d||0,stats:r,networkDetails:a,deliveryDirectives:f});break;case ey.AUDIO_TRACK:o.trigger(O.AUDIO_TRACK_LOADED,{details:e,id:d||0,groupId:h||"",stats:r,networkDetails:a,deliveryDirectives:f});break;case ey.SUBTITLE_TRACK:o.trigger(O.SUBTITLE_TRACK_LOADED,{details:e,id:d||0,groupId:h||"",stats:r,networkDetails:a,deliveryDirectives:f})}},t}();function eL(t,e){var i;try{i=new Event("addtrack")}catch(r){(i=document.createEvent("Event")).initEvent("addtrack",!1,!1)}i.track=t,e.dispatchEvent(i)}function eA(t,e){var i=t.mode;if("disabled"===i&&(t.mode="hidden"),t.cues&&!t.cues.getCueById(e.id))try{if(t.addCue(e),!t.cues.getCueById(e.id))throw Error("addCue is failed for: "+e)}catch(r){H.debug("[texttrack-utils]: "+r);try{var n=new self.TextTrackCue(e.startTime,e.endTime,e.text);n.id=e.id,t.addCue(n)}catch(a){H.debug("[texttrack-utils]: Legacy TextTrackCue fallback failed: "+a)}}"disabled"===i&&(t.mode=i)}function eR(t){var e=t.mode;if("disabled"===e&&(t.mode="hidden"),t.cues)for(var i=t.cues.length;i--;)t.removeCue(t.cues[i]);"disabled"===e&&(t.mode=e)}function e_(t,e,i,r){var n=t.mode;if("disabled"===n&&(t.mode="hidden"),t.cues&&t.cues.length>0)for(var a=function t(e,i,r){var n=[],a=function t(e,i){if(i<e[0].startTime)return 0;var r=e.length-1;if(i>e[r].endTime)return -1;for(var n=0,a=r;n<=a;){var s=Math.floor((a+n)/2);if(i<e[s].startTime)a=s-1;else{if(!(i>e[s].startTime)||!(n<r))return s;n=s+1}}return e[n].startTime-i<i-e[a].startTime?n:a}(e,i);if(a>-1)for(var s=a,o=e.length;s<o;s++){var l=e[s];if(l.startTime>=i&&l.endTime<=r)n.push(l);else if(l.startTime>r)break}return n}(t.cues,e,i),s=0;s<a.length;s++)(!r||r(a[s]))&&t.removeCue(a[s]);"disabled"===n&&(t.mode=n)}function eD(t){for(var e=[],i=0;i<t.length;i++){var r=t[i];("subtitles"===r.kind||"captions"===r.kind)&&r.label&&e.push(t[i])}return e}var ek={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"};function eI(){if("undefined"!=typeof self)return self.VTTCue||self.TextTrackCue}function eb(t,e,i,n,a){var s=new t(e,i,"");try{s.value=n,a&&(s.type=a)}catch(o){s=new t(e,i,JSON.stringify(a?r({type:a},n):n))}return s}var eC=function(){var t=eI();try{t&&new t(0,Number.POSITIVE_INFINITY,"")}catch(e){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function e8(t,e){return t.getTime()/1e3-e}function ew(t){return Uint8Array.from(t.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var eP=function(){function t(t){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=t,this._registerListeners()}var e=t.prototype;return e.destroy=function t(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},e._registerListeners=function t(){var e=this.hls;e.on(O.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(O.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(O.MANIFEST_LOADING,this.onManifestLoading,this),e.on(O.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(O.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(O.LEVEL_UPDATED,this.onLevelUpdated,this)},e._unregisterListeners=function t(){var e=this.hls;e.off(O.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(O.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(O.MANIFEST_LOADING,this.onManifestLoading,this),e.off(O.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(O.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(O.LEVEL_UPDATED,this.onLevelUpdated,this)},e.onMediaAttached=function t(e,i){this.media=i.media},e.onMediaDetaching=function t(){this.id3Track&&(eR(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},e.onManifestLoading=function t(){this.dateRangeCuesAppended={}},e.createTrack=function t(e){var i=this.getID3Track(e.textTracks);return i.mode="hidden",i},e.getID3Track=function t(e){if(this.media){for(var i=0;i<e.length;i++){var r=e[i];if("metadata"===r.kind&&"id3"===r.label)return eL(r,this.media),r}return this.media.addTextTrack("metadata","id3")}},e.onFragParsingMetadata=function t(e,i){if(this.media){var r=this.hls.config,n=r.enableEmsgMetadataCues,a=r.enableID3MetadataCues;if(n||a){var s=i.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));var o=eI();if(o)for(var l=0;l<s.length;l++){var u=s[l].type;if((u!==ek.emsg||n)&&a){var d=tx(s[l].data);if(d){var h=s[l].pts,f=h+s[l].duration;f>eC&&(f=eC),f-h<=0&&(f=h+.25);for(var c=0;c<d.length;c++){var $=d[c];if(!ty($)){this.updateId3CueEnds(h,u);var g=eb(o,h,f,$,u);g&&this.id3Track.addCue(g)}}}}}}}},e.updateId3CueEnds=function t(e,i){var r,n=null==(r=this.id3Track)?void 0:r.cues;if(n)for(var a=n.length;a--;){var s=n[a];s.type===i&&s.startTime<e&&s.endTime===eC&&(s.endTime=e)}},e.onBufferFlushing=function t(e,i){var r,n=i.startOffset,a=i.endOffset,s=i.type,o=this.id3Track,l=this.hls;if(l){var u=l.config,d=u.enableEmsgMetadataCues,h=u.enableID3MetadataCues;o&&(d||h)&&(r="audio"===s?function t(e){return e.type===ek.audioId3&&h}:"video"===s?function t(e){return e.type===ek.emsg&&d}:function t(e){return e.type===ek.audioId3&&h||e.type===ek.emsg&&d},e_(o,n,a,r))}},e.onLevelUpdated=function t(e,i){var r=this,n=i.details;if(this.media&&n.hasProgramDateTime&&this.hls.config.enableDateRangeMetadataCues){var a=this.dateRangeCuesAppended,s=this.id3Track,o=n.dateRanges,l=Object.keys(o);if(s)for(var u=Object.keys(a).filter(function(t){return!l.includes(t)}),d=u.length;d--;)!function t(){var e=u[d];Object.keys(a[e].cues).forEach(function(t){s.removeCue(a[e].cues[t])}),delete a[e]}();var h=n.fragments[n.fragments.length-1];if(0!==l.length&&w(null==h?void 0:h.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var f=h.programDateTime/1e3-h.start,c=eI(),$=0;$<l.length;$++)!function t(){var e=l[$],i=o[e],n=e8(i.startDate,f),s=a[e],u=(null==s?void 0:s.cues)||{},d=(null==s?void 0:s.durationKnown)||!1,h=eC,g=i.endDate;if(g)h=e8(g,f),d=!0;else if(i.endOnNext&&!d){var v=l.reduce(function(t,e){if(e!==i.id){var r=o[e];if(r.class===i.class&&r.startDate>i.startDate&&(!t||i.startDate<t.startDate))return r}return t},null);v&&(h=e8(v.startDate,f),d=!0)}for(var m=Object.keys(i.attr),p=0;p<m.length;p++){var y=m[p];if(q(y)){var T=u[y];if(T)d&&!s.durationKnown&&(T.endTime=h);else if(c){var x=i.attr[y];X(y)&&(x=ew(x));var E=eb(c,n,h,{key:y,data:x},ek.dateRange);E&&(E.id=e,r.id3Track.addCue(E),u[y]=E)}}}a[e]={cues:u,dateRange:i,durationKnown:d}}()}}},t}(),eF=function(){function t(t){var e=this;this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=function(){return e.timeupdate()},this.hls=t,this.config=t.config,this.registerListeners()}var e=t.prototype;return e.destroy=function t(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},e.registerListeners=function t(){this.hls.on(O.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(O.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(O.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(O.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(O.ERROR,this.onError,this)},e.unregisterListeners=function t(){this.hls.off(O.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(O.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(O.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(O.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(O.ERROR,this.onError,this)},e.onMediaAttached=function t(e,i){this.media=i.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},e.onMediaDetaching=function t(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},e.onManifestLoading=function t(){this.levelDetails=null,this._latency=null,this.stallCount=0},e.onLevelUpdated=function t(e,i){var r=i.details;this.levelDetails=r,r.advanced&&this.timeupdate(),!r.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},e.onError=function t(e,i){var r;i.details===M.BUFFER_STALLED_ERROR&&(this.stallCount++,null!=(r=this.levelDetails)&&r.live&&H.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},e.timeupdate=function t(){var e=this.media,i=this.levelDetails;if(e&&i){this.currentTime=e.currentTime;var r=this.computeLatency();if(null!==r){this._latency=r;var n=this.config,a=n.lowLatencyMode,s=n.maxLiveSyncPlaybackRate;if(a&&1!==s&&i.live){var o=this.targetLatency;if(null!==o){var l,u=r-o;if(u<Math.min(this.maxLatency,o+i.targetduration)&&u>.05&&this.forwardBufferLength>1){var d=Math.round(2/(1+Math.exp(-.75*u-this.edgeStalled))*20)/20;e.playbackRate=Math.min(Math.min(2,Math.max(1,s)),Math.max(1,d))}else 1!==e.playbackRate&&0!==e.playbackRate&&(e.playbackRate=1)}}}}},e.estimateLiveEdge=function t(){var e=this.levelDetails;return null===e?null:e.edge+e.age},e.computeLatency=function t(){var e=this.estimateLiveEdge();return null===e?null:e-this.currentTime},s(t,[{key:"latency",get:function t(){return this._latency||0}},{key:"maxLatency",get:function t(){var e=this.config,i=this.levelDetails;return void 0!==e.liveMaxLatencyDuration?e.liveMaxLatencyDuration:i?e.liveMaxLatencyDurationCount*i.targetduration:0}},{key:"targetLatency",get:function t(){var e=this.levelDetails;if(null===e)return null;var i=e.holdBack,r=e.partHoldBack,n=e.targetduration,a=this.config,s=a.liveSyncDuration,o=a.liveSyncDurationCount,l=a.lowLatencyMode,u=this.hls.userConfig,d=l&&r||i;return(u.liveSyncDuration||u.liveSyncDurationCount||0===d)&&(d=void 0!==s?s:o*n),d+Math.min(1*this.stallCount,n)}},{key:"liveSyncPosition",get:function t(){var e=this.estimateLiveEdge(),i=this.targetLatency,r=this.levelDetails;if(null===e||null===i||null===r)return null;var n,a=r.edge,s=e-i-this.edgeStalled;return Math.min(Math.max(a-r.totalduration,s),a-(this.config.lowLatencyMode&&r.partTarget||r.targetduration))}},{key:"drift",get:function t(){var e=this.levelDetails;return null===e?1:e.drift}},{key:"edgeStalled",get:function t(){var e=this.levelDetails;if(null===e)return 0;var i=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-i,0)}},{key:"forwardBufferLength",get:function t(){var e=this.media,i=this.levelDetails;if(!e||!i)return 0;var r=e.buffered.length;return(r?e.buffered.end(r-1):i.edge)-this.currentTime}}]),t}(),eO=["NONE","TYPE-0","TYPE-1",null],eN=["SDR","PQ","HLG"],eM={No:"",Yes:"YES",v2:"v2"};function eB(t){var e=t.canSkipUntil,i=t.canSkipDateRanges,r=t.age;return e&&r<e/2?i?eM.v2:eM.Yes:(0,eM.No)}var eU=function(){function t(t,e,i){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=t,this.part=e,this.skip=i}return t.prototype.addDirectives=function t(e){var i=new self.URL(e);return void 0!==this.msn&&i.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&i.searchParams.set("_HLS_part",this.part.toString()),this.skip&&i.searchParams.set("_HLS_skip",this.skip),i.href},t}(),e0=function(){function t(t){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=[t.url],this._attrs=[t.attrs],this.bitrate=t.bitrate,t.details&&(this.details=t.details),this.id=t.id||0,this.name=t.name,this.width=t.width||0,this.height=t.height||0,this.frameRate=t.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=t.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=t.audioCodec,this.videoCodec=t.videoCodec,this.codecSet=[t.videoCodec,t.audioCodec].filter(function(t){return!!t}).map(function(t){return t.substring(0,4)}).join(","),this.addGroupId("audio",t.attrs.AUDIO),this.addGroupId("text",t.attrs.SUBTITLES)}var e=t.prototype;return e.hasAudioGroup=function t(e){return eG(this._audioGroups,e)},e.hasSubtitleGroup=function t(e){return eG(this._subtitleGroups,e)},e.addGroupId=function t(e,i){if(i){if("audio"===e){var r=this._audioGroups;r||(r=this._audioGroups=[]),-1===r.indexOf(i)&&r.push(i)}else if("text"===e){var n=this._subtitleGroups;n||(n=this._subtitleGroups=[]),-1===n.indexOf(i)&&n.push(i)}}},e.addFallback=function t(){},s(t,[{key:"maxBitrate",get:function t(){return Math.max(this.realBitrate,this.bitrate)}},{key:"averageBitrate",get:function t(){return this._avgBitrate||this.realBitrate||this.bitrate}},{key:"attrs",get:function t(){return this._attrs[0]}},{key:"codecs",get:function t(){return this.attrs.CODECS||""}},{key:"pathwayId",get:function t(){return this.attrs["PATHWAY-ID"]||"."}},{key:"videoRange",get:function t(){return this.attrs["VIDEO-RANGE"]||"SDR"}},{key:"score",get:function t(){return this.attrs.optionalFloat("SCORE",0)}},{key:"uri",get:function t(){return this.url[0]||""}},{key:"audioGroups",get:function t(){return this._audioGroups}},{key:"subtitleGroups",get:function t(){return this._subtitleGroups}},{key:"urlId",get:function t(){return 0},set:function t(e){}},{key:"audioGroupIds",get:function t(){return this.audioGroups?[this.audioGroupId]:void 0}},{key:"textGroupIds",get:function t(){return this.subtitleGroups?[this.textGroupId]:void 0}},{key:"audioGroupId",get:function t(){var e;return null==(e=this.audioGroups)?void 0:e[0]}},{key:"textGroupId",get:function t(){var e;return null==(e=this.subtitleGroups)?void 0:e[0]}}]),t}();function eG(t,e){return!!e&&!!t&&-1!==t.indexOf(e)}function e2(t,e){var i=e.startPTS;if(w(i)){var r,n=0;e.sn>t.sn?(n=i-t.start,r=t):(n=t.start-i,r=e),r.duration!==n&&(r.duration=n)}else e.sn>t.sn?t.cc===e.cc&&t.minEndPTS?e.start=t.start+(t.minEndPTS-t.start):e.start=t.start+t.duration:e.start=Math.max(t.start-e.duration,0)}function e1(t,e,i,r,n,a){r-i<=0&&(H.warn("Fragment should have a positive duration",e),r=i+e.duration,a=n+e.duration);var s,o=i,l=r,u=e.startPTS,d=e.endPTS;if(w(u)){var h=Math.abs(u-i);w(e.deltaPTS)?e.deltaPTS=Math.max(h,e.deltaPTS):e.deltaPTS=h,o=Math.max(i,u),i=Math.min(i,u),n=Math.min(n,e.startDTS),l=Math.min(r,d),r=Math.max(r,d),a=Math.max(a,e.endDTS)}var f=i-e.start;0!==e.start&&(e.start=i),e.duration=r-e.start,e.startPTS=i,e.maxStartPTS=o,e.startDTS=n,e.endPTS=r,e.minEndPTS=l,e.endDTS=a;var c=e.sn;if(!t||c<t.startSN||c>t.endSN)return 0;var $=c-t.startSN,g=t.fragments;for(g[$]=e,s=$;s>0;s--)e2(g[s],g[s-1]);for(s=$;s<g.length-1;s++)e2(g[s],g[s+1]);return t.fragmentHint&&e2(g[g.length-1],t.fragmentHint),t.PTSKnown=t.alignedSliding=!0,f}function e6(t,e){var i=e.startSN+e.skippedSegments-t.startSN,r=t.fragments;!(i<0)&&!(i>=r.length)&&eK(e,r[i].start)}function eK(t,e){if(e){for(var i=t.fragments,r=t.skippedSegments;r<i.length;r++)i[r].start+=e;t.fragmentHint&&(t.fragmentHint.start+=e)}}function e4(t,e,i){var r;return null!=t&&t.details?e3(null==(r=t.details)?void 0:r.partList,e,i):null}function e3(t,e,i){if(t)for(var r=t.length;r--;){var n=t[r];if(n.index===i&&n.fragment.sn===e)return n}return null}function eH(t){t.forEach(function(t,e){var i=t.details;null!=i&&i.fragments&&i.fragments.forEach(function(t){t.level=e})})}function eV(t){switch(t.details){case M.FRAG_LOAD_TIMEOUT:case M.KEY_LOAD_TIMEOUT:case M.LEVEL_LOAD_TIMEOUT:case M.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function e7(t,e){var i=eV(e);return t.default[(i?"timeout":"error")+"Retry"]}function eY(t,e){return Math.min(("linear"===t.backoff?1:Math.pow(2,e))*t.retryDelayMs,t.maxRetryDelayMs)}function eW(t){return r(r({},t),{errorRetry:null,timeoutRetry:null})}function e5(t,e,i,r){if(!t)return!1;var n,a=null==r?void 0:r.code,s=e<t.maxNumRetry&&(n=a,0===n&&!1===navigator.onLine||!!n&&(n<400||n>499)||!!i);return t.shouldRetry?t.shouldRetry(t,e,i,r,s):s}var eq={search:function t(e,i){for(var r=0,n=e.length-1,a=null,s=null;r<=n;){var o=i(s=e[a=(r+n)/2|0]);if(o>0)r=a+1;else{if(!(o<0))return s;n=a-1}}return null}};function eX(t,e,i,r,n){void 0===i&&(i=0),void 0===r&&(r=0),void 0===n&&(n=.005);var a=null;if(t){a=e[t.sn-e[0].sn+1]||null;var s=t.endDTS-i;s>0&&s<15e-7&&(i+=15e-7)}else 0===i&&0===e[0].start&&(a=e[0]);if(a&&((!t||t.level===a.level)&&0===ez(i,r,a)||function t(e,i,r){if(i&&0===i.start&&i.level<e.level&&(i.endPTS||0)>0){var n=i.tagList.reduce(function(t,e){return"INF"===e[0]&&(t+=parseFloat(e[1])),t},r);return e.start<=n}return!1}(a,t,Math.min(n,r))))return a;var o=eq.search(e,ez.bind(null,i,r));return o&&(o!==t||!a)?o:a}function ez(t,e,i){if(void 0===t&&(t=0),void 0===e&&(e=0),i.start<=t&&i.start+i.duration>t)return 0;var r=Math.min(e,i.duration+(i.deltaPTS?i.deltaPTS:0));return i.start+i.duration-r<=t?1:i.start-r>t&&i.start?-1:0}function ej(t,e,i){var r=1e3*Math.min(e,i.duration+(i.deltaPTS?i.deltaPTS:0));return(i.endProgramDateTime||0)-r>t}var eQ={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},e9={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4},eZ=function(){function t(t){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=t,this.log=H.log.bind(H,"[info]:"),this.warn=H.warn.bind(H,"[warning]:"),this.error=H.error.bind(H,"[error]:"),this.registerListeners()}var e=t.prototype;return e.registerListeners=function t(){var e=this.hls;e.on(O.ERROR,this.onError,this),e.on(O.MANIFEST_LOADING,this.onManifestLoading,this),e.on(O.LEVEL_UPDATED,this.onLevelUpdated,this)},e.unregisterListeners=function t(){var e=this.hls;e&&(e.off(O.ERROR,this.onError,this),e.off(O.ERROR,this.onErrorOut,this),e.off(O.MANIFEST_LOADING,this.onManifestLoading,this),e.off(O.LEVEL_UPDATED,this.onLevelUpdated,this))},e.destroy=function t(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}},e.startLoad=function t(e){},e.stopLoad=function t(){this.playlistError=0},e.getVariantLevelIndex=function t(e){return(null==e?void 0:e.type)===eT.MAIN?e.level:this.hls.loadLevel},e.onManifestLoading=function t(){this.playlistError=0,this.penalizedRenditions={}},e.onLevelUpdated=function t(){this.playlistError=0},e.onError=function t(e,i){if(!i.fatal){var r=this.hls,n=i.context;switch(i.details){case M.FRAG_LOAD_ERROR:case M.FRAG_LOAD_TIMEOUT:case M.KEY_LOAD_ERROR:case M.KEY_LOAD_TIMEOUT:i.errorAction=this.getFragRetryOrSwitchAction(i);return;case M.FRAG_PARSING_ERROR:if(null!=(a=i.frag)&&a.gap){i.errorAction={action:eQ.DoNothing,flags:e9.None};return}case M.FRAG_GAP:case M.FRAG_DECRYPT_ERROR:i.errorAction=this.getFragRetryOrSwitchAction(i),i.errorAction.action=eQ.SendAlternateToPenaltyBox;return;case M.LEVEL_EMPTY_ERROR:case M.LEVEL_PARSING_ERROR:var a,s,o,l,u=i.parent===eT.MAIN?i.level:r.loadLevel;i.details===M.LEVEL_EMPTY_ERROR&&null!=(o=i.context)&&null!=(l=o.levelDetails)&&l.live?i.errorAction=this.getPlaylistRetryOrSwitchAction(i,u):(i.levelRetry=!1,i.errorAction=this.getLevelSwitchAction(i,u));return;case M.LEVEL_LOAD_ERROR:case M.LEVEL_LOAD_TIMEOUT:"number"==typeof(null==n?void 0:n.level)&&(i.errorAction=this.getPlaylistRetryOrSwitchAction(i,n.level));return;case M.AUDIO_TRACK_LOAD_ERROR:case M.AUDIO_TRACK_LOAD_TIMEOUT:case M.SUBTITLE_LOAD_ERROR:case M.SUBTITLE_TRACK_LOAD_TIMEOUT:if(n){var d=r.levels[r.loadLevel];d&&(n.type===ey.AUDIO_TRACK&&d.hasAudioGroup(n.groupId)||n.type===ey.SUBTITLE_TRACK&&d.hasSubtitleGroup(n.groupId))&&(i.errorAction=this.getPlaylistRetryOrSwitchAction(i,r.loadLevel),i.errorAction.action=eQ.SendAlternateToPenaltyBox,i.errorAction.flags=e9.MoveAllAlternatesMatchingHost)}return;case M.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:var h=r.levels[r.loadLevel],f=null==h?void 0:h.attrs["HDCP-LEVEL"];f?i.errorAction={action:eQ.SendAlternateToPenaltyBox,flags:e9.MoveAllAlternatesMatchingHDCP,hdcpLevel:f}:this.keySystemError(i);return;case M.BUFFER_ADD_CODEC_ERROR:case M.REMUX_ALLOC_ERROR:case M.BUFFER_APPEND_ERROR:i.errorAction=this.getLevelSwitchAction(i,null!=(s=i.level)?s:r.loadLevel);return;case M.INTERNAL_EXCEPTION:case M.BUFFER_APPENDING_ERROR:case M.BUFFER_FULL_ERROR:case M.LEVEL_SWITCH_ERROR:case M.BUFFER_STALLED_ERROR:case M.BUFFER_SEEK_OVER_HOLE:case M.BUFFER_NUDGE_ON_STALL:i.errorAction={action:eQ.DoNothing,flags:e9.None};return}i.type===N.KEY_SYSTEM_ERROR&&this.keySystemError(i)}},e.keySystemError=function t(e){var i=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,i)},e.getPlaylistRetryOrSwitchAction=function t(e,i){var r=e7(this.hls.config.playlistLoadPolicy,e),n=this.playlistError++;if(e5(r,n,eV(e),e.response))return{action:eQ.RetryRequest,flags:e9.None,retryConfig:r,retryCount:n};var a=this.getLevelSwitchAction(e,i);return r&&(a.retryConfig=r,a.retryCount=n),a},e.getFragRetryOrSwitchAction=function t(e){var i=this.hls,r=this.getVariantLevelIndex(e.frag),n=i.levels[r],a=i.config,s=a.fragLoadPolicy,o=a.keyLoadPolicy,l=e7(e.details.startsWith("key")?o:s,e),u=i.levels.reduce(function(t,e){return t+e.fragmentError},0);if(n&&(e.details!==M.FRAG_GAP&&n.fragmentError++,e5(l,u,eV(e),e.response)))return{action:eQ.RetryRequest,flags:e9.None,retryConfig:l,retryCount:u};var d=this.getLevelSwitchAction(e,r);return l&&(d.retryConfig=l,d.retryCount=u),d},e.getLevelSwitchAction=function t(e,i){var r=this.hls;null==i&&(i=r.loadLevel);var n=this.hls.levels[i];if(n){var a=e.details;n.loadError++,a===M.BUFFER_APPEND_ERROR&&n.fragmentError++;var s=-1,o=r.levels,l=r.loadLevel,u=r.minAutoLevel,d=r.maxAutoLevel;r.autoLevelEnabled||(r.loadLevel=-1);for(var h,f,c,$=null==(h=e.frag)?void 0:h.type,g=($===eT.AUDIO&&a===M.FRAG_PARSING_ERROR||"audio"===e.sourceBufferName&&(a===M.BUFFER_ADD_CODEC_ERROR||a===M.BUFFER_APPEND_ERROR))&&o.some(function(t){var e=t.audioCodec;return n.audioCodec!==e}),v="video"===e.sourceBufferName&&(a===M.BUFFER_ADD_CODEC_ERROR||a===M.BUFFER_APPEND_ERROR)&&o.some(function(t){var e=t.codecSet,i=t.audioCodec;return n.codecSet!==e&&n.audioCodec===i}),m=null!=(f=e.context)?f:{},p=m.type,y=m.groupId,T=o.length;T--&&(0===(c=function t(){var i=(T+l)%o.length;if(i!==l&&i>=u&&i<=d&&0===o[i].loadError){var r,h,f=o[i];if(a===M.FRAG_GAP&&$===eT.MAIN&&e.frag){var c=o[i].details;if(c){var m=eX(e.frag,c.fragments,e.frag.start);if(null!=m&&m.gap)return 0}}else if(p===ey.AUDIO_TRACK&&f.hasAudioGroup(y)||p===ey.SUBTITLE_TRACK&&f.hasSubtitleGroup(y))return 0;else if($===eT.AUDIO&&null!=(r=n.audioGroups)&&r.some(function(t){return f.hasAudioGroup(t)})||$===eT.SUBTITLE&&null!=(h=n.subtitleGroups)&&h.some(function(t){return f.hasSubtitleGroup(t)})||g&&n.audioCodec===f.audioCodec||!g&&n.audioCodec!==f.audioCodec||v&&n.codecSet===f.codecSet)return 0;return s=i,1}}())||1!==c););if(s>-1&&r.loadLevel!==s)return e.levelRetry=!0,this.playlistError=0,{action:eQ.SendAlternateToPenaltyBox,flags:e9.None,nextAutoLevel:s}}return{action:eQ.SendAlternateToPenaltyBox,flags:e9.MoveAllAlternatesMatchingHost}},e.onErrorOut=function t(e,i){var r;switch(null==(r=i.errorAction)?void 0:r.action){case eQ.DoNothing:break;case eQ.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(i),i.errorAction.resolved||i.details===M.FRAG_GAP?/MediaSource readyState: ended/.test(i.error.message)&&(this.warn('MediaSource ended after "'+i.sourceBufferName+'" sourceBuffer append error. Attempting to recover from media error.'),this.hls.recoverMediaError()):i.fatal=!0}if(i.fatal){this.hls.stopLoad();return}},e.sendAlternateToPenaltyBox=function t(e){var i=this.hls,r=e.errorAction;if(r){var n=r.flags,a=r.hdcpLevel,s=r.nextAutoLevel;switch(n){case e9.None:this.switchLevel(e,s);break;case e9.MoveAllAlternatesMatchingHDCP:a&&(i.maxHdcpLevel=eO[eO.indexOf(a)-1],r.resolved=!0),this.warn('Restricting playback to HDCP-LEVEL of "'+i.maxHdcpLevel+'" or lower')}r.resolved||this.switchLevel(e,s)}},e.switchLevel=function t(e,i){void 0!==i&&e.errorAction&&(this.warn("switching to level "+i+" after "+e.details),this.hls.nextAutoLevel=i,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)},t}(),eJ=function(){function t(t,e){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=H.log.bind(H,e+":"),this.warn=H.warn.bind(H,e+":"),this.hls=t}var e=t.prototype;return e.destroy=function t(){this.clearTimer(),this.hls=this.log=this.warn=null},e.clearTimer=function t(){-1!==this.timer&&(self.clearTimeout(this.timer),this.timer=-1)},e.startLoad=function t(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()},e.stopLoad=function t(){this.canLoad=!1,this.clearTimer()},e.switchParams=function t(e,i,r){var n=null==i?void 0:i.renditionReports;if(n){for(var a=-1,s=0;s<n.length;s++){var o=n[s],l=void 0;try{l=new self.URL(o.URI,i.url).href}catch(u){H.warn("Could not construct new URL for Rendition Report: "+u),l=o.URI||""}if(l===e){a=s;break}l===e.substring(0,l.length)&&(a=s)}if(-1!==a){var d=n[a],h=parseInt(d["LAST-MSN"])||(null==i?void 0:i.lastPartSn),f=parseInt(d["LAST-PART"])||(null==i?void 0:i.lastPartIndex);if(this.hls.config.lowLatencyMode){var c=Math.min(i.age-i.partTarget,i.targetduration);f>=0&&c>i.partTarget&&(f+=1)}var $=r&&eB(r);return new eU(h,f>=0?f:void 0,$)}}},e.loadPlaylist=function t(e){-1===this.requestScheduled&&(this.requestScheduled=self.performance.now())},e.shouldLoadPlaylist=function t(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)},e.shouldReloadPlaylist=function t(e){return -1===this.timer&&-1===this.requestScheduled&&this.shouldLoadPlaylist(e)},e.playlistLoaded=function t(e,i,r){var n=this,a=i.details,s=i.stats,o=self.performance.now(),u=s.loading.first?Math.max(0,o-s.loading.first):0;if(a.advancedDateTime=Date.now()-u,a.live||null!=r&&r.live){if(a.reloaded(r),r&&this.log("live playlist "+e+" "+(a.advanced?"REFRESHED "+a.lastPartSn+"-"+a.lastPartIndex:a.updated?"UPDATED":"MISSED")),r&&a.fragments.length>0&&function t(e,i){for(var r,n=null,a=e.fragments,s=a.length-1;s>=0;s--){var o=a[s].initSegment;if(o){n=o;break}}e.fragmentHint&&delete e.fragmentHint.endPTS;var u=0;if(function t(e,i,r){for(var n=i.skippedSegments,a=Math.max(e.startSN,i.startSN)-i.startSN,s=(e.fragmentHint?1:0)+(n?i.endSN:Math.min(e.endSN,i.endSN))-i.startSN,o=i.startSN-e.startSN,l=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments,u=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,d=a;d<=s;d++){var h=u[o+d],f=l[d];n&&!f&&d<n&&(f=i.fragments[d]=h),h&&f&&r(h,f)}}(e,i,function(t,e){t.relurl&&(u=t.cc-e.cc),w(t.startPTS)&&w(t.endPTS)&&(e.start=e.startPTS=t.startPTS,e.startDTS=t.startDTS,e.maxStartPTS=t.maxStartPTS,e.endPTS=t.endPTS,e.endDTS=t.endDTS,e.minEndPTS=t.minEndPTS,e.duration=t.endPTS-t.startPTS,e.duration&&(r=e),i.PTSKnown=i.alignedSliding=!0),e.elementaryStreams=t.elementaryStreams,e.loader=t.loader,e.stats=t.stats,t.initSegment&&(e.initSegment=t.initSegment,n=t.initSegment)}),n&&(i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments).forEach(function(t){var e;t&&(!t.initSegment||t.initSegment.relurl===(null==(e=n)?void 0:e.relurl))&&(t.initSegment=n)}),i.skippedSegments){if(i.deltaUpdateFailed=i.fragments.some(function(t){return!t}),i.deltaUpdateFailed){H.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var d,h,f,c,$=i.skippedSegments;$--;)i.fragments.shift();i.startSN=i.fragments[0].sn,i.startCC=i.fragments[0].cc}else{i.canSkipDateRanges&&(i.dateRanges=(d=e.dateRanges,h=i.dateRanges,f=i.recentlyRemovedDateranges,c=l({},d),f&&f.forEach(function(t){delete c[t]}),Object.keys(h).forEach(function(t){var e=new z(h[t].attr,c[t]);e.isValid?c[t]=e:H.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(h[t].attr)+'"')}),c))}}var g=i.fragments;if(u){H.warn("discontinuity sliding from playlist, take drift into account");for(var v=0;v<g.length;v++)g[v].cc+=u}i.skippedSegments&&(i.startCC=i.fragments[0].cc),function t(e,i,r){if(e&&i)for(var n=0,a=0,s=e.length;a<=s;a++){var o=e[a],l=i[a+n];o&&l&&o.index===l.index&&o.fragment.sn===l.fragment.sn?r(o,l):n--}}(e.partList,i.partList,function(t,e){e.elementaryStreams=t.elementaryStreams,e.stats=t.stats}),r?e1(i,r,r.startPTS,r.endPTS,r.startDTS,r.endDTS):e6(e,i),g.length&&(i.totalduration=i.edge-g[0].start),i.driftStartTime=e.driftStartTime,i.driftStart=e.driftStart;var m=i.advancedDateTime;if(i.advanced&&m){var p=i.edge;i.driftStart||(i.driftStartTime=m,i.driftStart=p),i.driftEndTime=m,i.driftEnd=p}else i.driftEndTime=e.driftEndTime,i.driftEnd=e.driftEnd,i.advancedDateTime=e.advancedDateTime}(r,a),!this.canLoad||!a.live)return;var d,h=void 0,f=void 0;if(a.canBlockReload&&a.endSN&&a.advanced){var c=this.hls.config.lowLatencyMode,$=a.lastPartSn,g=a.endSN,v=a.lastPartIndex,m=$===g;-1!==v?(h=m?g+1:$,f=m?c?0:v:v+1):h=g+1;var p=a.age,y=Math.min(p+a.ageHeader-a.partTarget,1.5*a.targetduration);if(y>0){if(r&&y>r.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+r.tuneInGoal+" to: "+y+" with playlist age: "+a.age),y=0;else{var T=Math.floor(y/a.targetduration);h+=T,void 0!==f&&(f+=Math.round(y%a.targetduration/a.partTarget)),this.log("CDN Tune-in age: "+a.ageHeader+"s last advanced "+p.toFixed(2)+"s goal: "+y+" skip sn "+T+" to part "+f)}a.tuneInGoal=y}if(d=this.getDeliveryDirectives(a,i.deliveryDirectives,h,f),c||!m){this.loadPlaylist(d);return}}else(a.canBlockReload||a.canSkipUntil)&&(d=this.getDeliveryDirectives(a,i.deliveryDirectives,h,f));var x=this.hls.mainForwardBufferInfo,E=x?x.end-x.len:0,S=(a.edge-E)*1e3,L=function t(e,i){void 0===i&&(i=1/0);var r=1e3*e.targetduration;if(e.updated){var n=e.fragments;if(n.length&&4*r>i){var a=1e3*n[n.length-1].duration;a<r&&(r=a)}}else r/=2;return Math.round(r)}(a,S);a.updated&&o>this.requestScheduled+L&&(this.requestScheduled=s.loading.start),void 0!==h&&a.canBlockReload?this.requestScheduled=s.loading.first+L-(1e3*a.partTarget||1e3):-1===this.requestScheduled||this.requestScheduled+L<o?this.requestScheduled=o:this.requestScheduled-o<=0&&(this.requestScheduled+=L);var A=this.requestScheduled-o;A=Math.max(0,A),this.log("reload live playlist "+e+" in "+Math.round(A)+" ms"),this.timer=self.setTimeout(function(){return n.loadPlaylist(d)},A)}else this.clearTimer()},e.getDeliveryDirectives=function t(e,i,r,n){var a=eB(e);return null!=i&&i.skip&&e.deltaUpdateFailed&&(r=i.msn,n=i.part,a=eM.No),new eU(r,n,a)},e.checkRetry=function t(e){var i,r=this,n=e.details,a=eV(e),s=e.errorAction,o=s||{},l=o.action,u=o.retryCount,d=void 0===u?0:u,h=o.retryConfig,f=!!s&&!!h&&(l===eQ.RetryRequest||!s.resolved&&l===eQ.SendAlternateToPenaltyBox);if(f){if(this.requestScheduled=-1,d>=h.maxNumRetry)return!1;if(a&&null!=(i=e.context)&&i.deliveryDirectives)this.warn("Retrying playlist loading "+(d+1)+"/"+h.maxNumRetry+' after "'+n+'" without delivery-directives'),this.loadPlaylist();else{var c=eY(h,d);this.timer=self.setTimeout(function(){return r.loadPlaylist()},c),this.warn("Retrying playlist loading "+(d+1)+"/"+h.maxNumRetry+' after "'+n+'" in '+c+"ms")}e.levelRetry=!0,s.resolved=!0}return f},t}(),it=function(){function t(t,e,i){void 0===e&&(e=0),void 0===i&&(i=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=t,this.alpha_=t?Math.exp(Math.log(.5)/t):0,this.estimate_=e,this.totalWeight_=i}var e=t.prototype;return e.sample=function t(e,i){var r=Math.pow(this.alpha_,e);this.estimate_=i*(1-r)+r*this.estimate_,this.totalWeight_+=e},e.getTotalWeight=function t(){return this.totalWeight_},e.getEstimate=function t(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_},t}(),ie=function(){function t(t,e,i,r){void 0===r&&(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_=i,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new it(t),this.fast_=new it(e),this.defaultTTFB_=r,this.ttfb_=new it(t)}var e=t.prototype;return e.update=function t(e,i){var r=this.slow_,n=this.fast_,a=this.ttfb_;r.halfLife!==e&&(this.slow_=new it(e,r.getEstimate(),r.getTotalWeight())),n.halfLife!==i&&(this.fast_=new it(i,n.getEstimate(),n.getTotalWeight())),a.halfLife!==e&&(this.ttfb_=new it(e,a.getEstimate(),a.getTotalWeight()))},e.sample=function t(e,i){var r=(e=Math.max(e,this.minDelayMs_))/1e3,n=8*i/r;this.fast_.sample(r,n),this.slow_.sample(r,n)},e.sampleTTFB=function t(e){this.ttfb_.sample(Math.sqrt(2)*Math.exp(-Math.pow(e/1e3,2)/2),Math.max(e,5))},e.canEstimate=function t(){return this.fast_.getTotalWeight()>=this.minWeight_},e.getEstimate=function t(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},e.getEstimateTTFB=function t(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_},e.destroy=function t(){},t}(),ii={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]},ir={};function ia(t,e,i,r,n,a){var s=t.audioCodec?t.audioGroups:null,o=null==a?void 0:a.audioCodec,l=null==a?void 0:a.channels,u=l?parseInt(l):o?1/0:2,d=null;if(null!=s&&s.length)try{d=1===s.length&&s[0]?e.groups[s[0]].channels:s.reduce(function(t,i){if(i){var r=e.groups[i];if(!r)throw Error("Audio track group "+i+" not found");Object.keys(r.channels).forEach(function(e){t[e]=(t[e]||0)+r.channels[e]})}return t},{2:0})}catch(h){return!0}return void 0!==t.videoCodec&&(t.width>1920&&t.height>1088||t.height>1920&&t.width>1088||t.frameRate>Math.max(r,30)||"SDR"!==t.videoRange&&t.videoRange!==i||t.bitrate>Math.max(n,8e6))||!!d&&w(u)&&Object.keys(d).some(function(t){return parseInt(t)>u})}function is(t,e,i){var n=t.videoCodec,a=t.audioCodec;if(!n||!a||!i)return Promise.resolve(ii);var s={width:t.width,height:t.height,bitrate:Math.ceil(Math.max(.9*t.bitrate,t.averageBitrate)),framerate:t.frameRate||30},o=t.videoRange;"SDR"!==o&&(s.transferFunction=o.toLowerCase());var l=n.split(",").map(function(t){return{type:"media-source",video:r(r({},s),{},{contentType:tJ(t,"video")})}});return a&&t.audioGroups&&t.audioGroups.forEach(function(t){var i;t&&(null==(i=e.groups[t])||i.tracks.forEach(function(e){if(e.groupId===t){var i=parseFloat(e.channels||"");w(i)&&i>2&&l.push.apply(l,a.split(",").map(function(t){return{type:"media-source",audio:{contentType:tJ(t,"audio"),channels:""+i}}}))}}))}),Promise.all(l.map(function(t){var e=function t(e){var i=e.audio,r=e.video,n=r||i;if(n){var a=n.contentType.split('"')[1];if(r)return"r"+r.height+"x"+r.width+"f"+Math.ceil(r.framerate)+(r.transferFunction||"sd")+"_"+a+"_"+Math.ceil(r.bitrate/1e5);if(i)return"c"+i.channels+(i.spatialRendering?"s":"n")+"_"+a}return""}(t);return ir[e]||(ir[e]=i.decodingInfo(t))})).then(function(t){return{supported:!t.some(function(t){return!t.supported}),configurations:l,decodingInfoResults:t}}).catch(function(t){return{supported:!1,configurations:l,decodingInfoResults:[],error:t}})}function io(t,e,i,r,n){for(var a,s,o,l,u=Object.keys(t),d=null==r?void 0:r.channels,h=null==r?void 0:r.audioCodec,f=d&&2===parseInt(d),c=!0,$=!1,g=1/0,v=1/0,m=1/0,p=0,y=[],T=(a=e,s=n,o=!1,l=[],a&&(o="SDR"!==a,l=[a]),s&&(l=s.allowedVideoRanges||eN.slice(0),l=(o=void 0!==s.preferHDR?s.preferHDR:function t(){if("function"==typeof matchMedia){var e=matchMedia("(dynamic-range: high)"),i=matchMedia("bad query");if(e.media!==i.media)return!0===e.matches}return!1}())?l.filter(function(t){return"SDR"!==t}):["SDR"]),{preferHDR:o,allowedVideoRanges:l}),x=T.preferHDR,E=T.allowedVideoRanges,S=function e(){var i=t[u[L]];c=i.channels[2]>0,g=Math.min(g,i.minHeight),v=Math.min(v,i.minFramerate),m=Math.min(m,i.minBitrate);var r=E.filter(function(t){return i.videoRanges[t]>0});r.length>0&&($=!0,y=r)},L=u.length;L--;)S();g=w(g)?g:0;var A=Math.max(1080,g),R=Math.max(30,v=w(v)?v:0);return i=Math.max(m=w(m)?m:i,i),$||(e=void 0,y=[]),{codecSet:u.reduce(function(e,r){var n=t[r];if(r===e)return e;if(n.minBitrate>i)return il(r,"min bitrate of "+n.minBitrate+" > current estimate of "+i),e;if(!n.hasDefaultAudio)return il(r,"no renditions with default or auto-select sound found"),e;if(h&&r.indexOf(h.substring(0,4))%5!=0)return il(r,'audio codec preference "'+h+'" not found'),e;if(d&&!f){if(!n.channels[d])return il(r,"no renditions with "+d+" channel sound found (channels options: "+Object.keys(n.channels)+")"),e}else if((!h||f)&&c&&0===n.channels["2"])return il(r,"no renditions with stereo sound found"),e;return n.minHeight>A?(il(r,"min resolution of "+n.minHeight+" > maximum of "+A),e):n.minFramerate>R?(il(r,"min framerate of "+n.minFramerate+" > maximum of "+R),e):y.some(function(t){return n.videoRanges[t]>0})?n.maxScore<p?(il(r,"max score of "+n.maxScore+" < selected max of "+p),e):e&&(ee(r)>=ee(e)||n.fragmentError>t[e].fragmentError)?e:(p=n.maxScore,r):(il(r,"no variants with VIDEO-RANGE of "+JSON.stringify(y)+" found"),e)},void 0),videoRanges:y,preferHDR:x,minFramerate:v,minBitrate:m}}function il(t,e){H.log('[abr] start candidates with "'+t+'" ignored because '+e)}function iu(t){return t.reduce(function(t,e){var i=t.groups[e.groupId];i||(i=t.groups[e.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),i.tracks.push(e);var r=e.channels||"2";return i.channels[r]=(i.channels[r]||0)+1,i.hasDefault=i.hasDefault||e.default,i.hasAutoSelect=i.hasAutoSelect||e.autoselect,i.hasDefault&&(t.hasDefaultAudio=!0),i.hasAutoSelect&&(t.hasAutoSelectAudio=!0),t},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function id(t,e,i,r){return t.slice(i,r+1).reduce(function(t,i){if(!i.codecSet)return t;var r=i.audioGroups,n=t[i.codecSet];n||(t[i.codecSet]=n={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!r,fragmentError:0}),n.minBitrate=Math.min(n.minBitrate,i.bitrate);var a=Math.min(i.height,i.width);return n.minHeight=Math.min(n.minHeight,a),n.minFramerate=Math.min(n.minFramerate,i.frameRate),n.maxScore=Math.max(n.maxScore,i.score),n.fragmentError+=i.fragmentError,n.videoRanges[i.videoRange]=(n.videoRanges[i.videoRange]||0)+1,r&&r.forEach(function(t){if(t){var i=e.groups[t];i&&(n.hasDefaultAudio=n.hasDefaultAudio||e.hasDefaultAudio?i.hasDefault:i.hasAutoSelect||!e.hasDefaultAudio&&!e.hasAutoSelectAudio,Object.keys(i.channels).forEach(function(t){n.channels[t]=(n.channels[t]||0)+i.channels[t]}))}}),t},{})}function ih(t,e,i){if("attrs"in t){var r=e.indexOf(t);if(-1!==r)return r}for(var n=0;n<e.length;n++)if(ic(t,e[n],i))return n;return -1}function ic(t,e,i){var r,n,a,s,o=t.groupId,l=t.name,u=t.lang,d=t.assocLang,h=t.characteristics,f=t.default,c=t.forced;return(void 0===o||e.groupId===o)&&(void 0===l||e.name===l)&&(void 0===u||e.lang===u)&&(void 0===u||e.assocLang===d)&&(void 0===f||e.default===f)&&(void 0===c||e.forced===c)&&(void 0===h||(r=h,n=e.characteristics,void 0===n&&(n=""),a=r.split(","),s=n.split(","),a.length===s.length&&!a.some(function(t){return -1===s.indexOf(t)})))&&(void 0===i||i(t,e))}function i$(t,e){var i=t.audioCodec,r=t.channels;return(void 0===i||(e.audioCodec||"").substring(0,4)===i.substring(0,4))&&(void 0===r||r===(e.channels||"2"))}function ig(t,e,i){for(var r=e;r;r--)if(i(t[r]))return r;for(var n=e+1;n<t.length;n++)if(i(t[n]))return n;return -1}var iv=function(){function t(t){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,i=e.fragCurrent,r=e.partCurrent,n=e.hls,a=n.autoLevelEnabled,s=n.media;if(i&&s){var o=performance.now(),l=r?r.stats:i.stats,u=r?r.duration:i.duration,d=o-l.loading.start,h=n.minAutoLevel;if(l.aborted||l.loaded&&l.loaded===l.total||i.level<=h){e.clearTimer(),e._nextAutoLevel=-1;return}if(a&&!s.paused&&s.playbackRate&&s.readyState){var f=n.mainForwardBufferInfo;if(null!==f){var c=e.bwEstimator.getEstimateTTFB(),$=Math.abs(s.playbackRate);if(!(d<=Math.max(c,1e3*(u/(2*$))))){var g=f.len/$,v=l.loading.first?l.loading.first-l.loading.start:-1,m=l.loaded&&v>-1,p=e.getBwEstimate(),y=n.levels,T=y[i.level],x=l.total||Math.max(l.loaded,Math.round(u*T.averageBitrate/8)),E=m?d-v:d;E<1&&m&&(E=Math.min(d,8*l.loaded/p));var S=m?1e3*l.loaded/E:0,L=S?(x-l.loaded)/S:8*x/p+c/1e3;if(!(L<=g)){var A=S?8*S:p,R=Number.POSITIVE_INFINITY;for(t=i.level-1;t>h;t--){var _=y[t].maxBitrate;if((R=e.getTimeToLoadFrag(c/1e3,A,u*_,!y[t].details))<g)break}if(!(R>=L)&&!(R>10*u)){n.nextLoadLevel=n.nextAutoLevel=t,m?e.bwEstimator.sample(d-Math.min(c,v),l.loaded):e.bwEstimator.sampleTTFB(d);var D=y[t].maxBitrate;e.getBwEstimate()*e.hls.config.abrBandWidthUpFactor>D&&e.resetEstimator(D),e.clearTimer(),H.warn("[abr] Fragment "+i.sn+(r?" part "+r.index:"")+" of level "+i.level+" is loading too slowly;\n Time to underbuffer: "+g.toFixed(3)+" s\n Estimated load time for current fragment: "+L.toFixed(3)+" s\n Estimated load time for down switch fragment: "+R.toFixed(3)+" s\n TTFB estimate: "+(0|v)+" ms\n Current BW estimate: "+(w(p)?0|p:"Unknown")+" bps\n New BW estimate: "+(0|e.getBwEstimate())+" bps\n Switching to level "+t+" @ "+(0|D)+" bps"),n.trigger(O.FRAG_LOAD_EMERGENCY_ABORTED,{frag:i,part:r,stats:l})}}}}}}},this.hls=t,this.bwEstimator=this.initEstimator(),this.registerListeners()}var e=t.prototype;return e.resetEstimator=function t(e){e&&(H.log("setting initial bwe to "+e),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()},e.initEstimator=function t(){var e=this.hls.config;return new ie(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)},e.registerListeners=function t(){var e=this.hls;e.on(O.MANIFEST_LOADING,this.onManifestLoading,this),e.on(O.FRAG_LOADING,this.onFragLoading,this),e.on(O.FRAG_LOADED,this.onFragLoaded,this),e.on(O.FRAG_BUFFERED,this.onFragBuffered,this),e.on(O.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(O.LEVEL_LOADED,this.onLevelLoaded,this),e.on(O.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(O.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(O.ERROR,this.onError,this)},e.unregisterListeners=function t(){var e=this.hls;e&&(e.off(O.MANIFEST_LOADING,this.onManifestLoading,this),e.off(O.FRAG_LOADING,this.onFragLoading,this),e.off(O.FRAG_LOADED,this.onFragLoaded,this),e.off(O.FRAG_BUFFERED,this.onFragBuffered,this),e.off(O.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(O.LEVEL_LOADED,this.onLevelLoaded,this),e.off(O.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(O.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(O.ERROR,this.onError,this))},e.destroy=function t(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null},e.onManifestLoading=function t(e,i){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()},e.onLevelsUpdated=function t(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null},e.onMaxAutoLevelUpdated=function t(){this.firstSelection=-1,this.nextAutoLevelKey=""},e.onFragLoading=function t(e,i){var r,n=i.frag;!this.ignoreFragment(n)&&(n.bitrateTest||(this.fragCurrent=n,this.partCurrent=null!=(r=i.part)?r:null),this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100))},e.onLevelSwitching=function t(e,i){this.clearTimer()},e.onError=function t(e,i){if(!i.fatal)switch(i.details){case M.BUFFER_ADD_CODEC_ERROR:case M.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case M.FRAG_LOAD_TIMEOUT:var r=i.frag,n=this.fragCurrent,a=this.partCurrent;if(r&&n&&r.sn===n.sn&&r.level===n.level){var s=performance.now(),o=a?a.stats:r.stats,l=s-o.loading.start,u=o.loading.first?o.loading.first-o.loading.start:-1;if(o.loaded&&u>-1){var d=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(l-Math.min(d,u),o.loaded)}else this.bwEstimator.sampleTTFB(l)}}},e.getTimeToLoadFrag=function t(e,i,r,n){return e+r/i+(n?this.lastLevelLoadSec:0)},e.onLevelLoaded=function t(e,i){var r=this.hls.config,n=i.stats.loading,a=n.end-n.start;w(a)&&(this.lastLevelLoadSec=a/1e3),i.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)},e.onFragLoaded=function t(e,i){var r=i.frag,n=i.part,a=n?n.stats:r.stats;if(r.type===eT.MAIN&&this.bwEstimator.sampleTTFB(a.loading.first-a.loading.start),!this.ignoreFragment(r)){if(this.clearTimer(),r.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){var s=n?n.duration:r.duration,o=this.hls.levels[r.level],l=(o.loaded?o.loaded.bytes:0)+a.loaded,u=(o.loaded?o.loaded.duration:0)+s;o.loaded={bytes:l,duration:u},o.realBitrate=Math.round(8*l/u)}if(r.bitrateTest){var d={stats:a,frag:r,part:n,id:r.type};this.onFragBuffered(O.FRAG_BUFFERED,d),r.bitrateTest=!1}else this.lastLoadedFragLevel=r.level}},e.onFragBuffered=function t(e,i){var r=i.frag,n=i.part,a=null!=n&&n.stats.loaded?n.stats:r.stats;if(!(a.aborted||this.ignoreFragment(r))){var s=a.parsing.end-a.loading.start-Math.min(a.loading.first-a.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(s,a.loaded),a.bwEstimate=this.getBwEstimate(),r.bitrateTest?this.bitrateTestDelay=s/1e3:this.bitrateTestDelay=0}},e.ignoreFragment=function t(e){return e.type!==eT.MAIN||"initSegment"===e.sn},e.clearTimer=function t(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)},e.getAutoLevelKey=function t(){return this.getBwEstimate()+"_"+this.getStarvationDelay().toFixed(2)},e.getNextABRAutoLevel=function t(){var e=this.fragCurrent,i=this.partCurrent,r=this.hls,n=r.maxAutoLevel,a=r.config,s=r.minAutoLevel,o=i?i.duration:e?e.duration:0,l=this.getBwEstimate(),u=this.getStarvationDelay(),d=a.abrBandWidthFactor,h=a.abrBandWidthUpFactor;if(u){var f=this.findBestLevel(l,s,n,u,0,d,h);if(f>=0)return f}var c=o?Math.min(o,a.maxStarvationDelay):a.maxStarvationDelay;if(!u){var $=this.bitrateTestDelay;$&&(c=(o?Math.min(o,a.maxLoadingDelay):a.maxLoadingDelay)-$,H.info("[abr] bitrate test took "+Math.round(1e3*$)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*c)+" ms"),d=h=1)}var g=this.findBestLevel(l,s,n,u,c,d,h);if(H.info("[abr] "+(u?"rebuffering expected":"buffer is empty")+", optimal quality level "+g),g>-1)return g;var v=r.levels[s],m=r.levels[r.loadLevel];return(null==v?void 0:v.bitrate)<(null==m?void 0:m.bitrate)?s:r.loadLevel},e.getStarvationDelay=function t(){var e=this.hls,i=e.media;if(!i)return 1/0;var r=i&&0!==i.playbackRate?Math.abs(i.playbackRate):1,n=e.mainForwardBufferInfo;return(n?n.len:0)/r},e.getBwEstimate=function t(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate},e.findBestLevel=function t(e,i,r,n,a,s,o){var l,u=this,d=n+a,h=this.lastLoadedFragLevel,f=-1===h?this.hls.firstLevel:h,c=this.fragCurrent,$=this.partCurrent,g=this.hls,v=g.levels,m=g.allAudioTracks,p=g.loadLevel,y=g.config;if(1===v.length)return 0;var T=v[f],x=!!(null!=T&&null!=(l=T.details)&&l.live),E=-1===p||-1===h,S="SDR",L=(null==T?void 0:T.frameRate)||0,A=y.audioPreference,R=y.videoPreference,_=this.audioTracksByGroup||(this.audioTracksByGroup=iu(m));if(E){if(-1!==this.firstSelection)return this.firstSelection;var D=this.codecTiers||(this.codecTiers=id(v,_,i,r)),k=io(D,S,e,A,R),I=k.codecSet,b=k.videoRanges,C=k.minFramerate,P=k.minBitrate,F=k.preferHDR;O=I,S=F?b[b.length-1]:b[0],L=C,e=Math.max(e,P),H.log("[abr] picked start tier "+JSON.stringify(k))}else O=null==T?void 0:T.codecSet,S=null==T?void 0:T.videoRange;for(var O,N,M=$?$.duration:c?c.duration:0,B=this.bwEstimator.getEstimateTTFB()/1e3,U=[],G=function t(){var i,l,c=v[K],g=K>f;if(!c)return 0;if(y.useMediaCapabilities&&!c.supportedResult&&!c.supportedPromise){var m=navigator.mediaCapabilities;"function"==typeof(null==m?void 0:m.decodingInfo)&&ia(c,_,S,L,e,A)?(c.supportedPromise=is(c,_,m),c.supportedPromise.then(function(t){if(u.hls){c.supportedResult=t;var e=u.hls.levels,i=e.indexOf(c);t.error?H.warn('[abr] MediaCapabilities decodingInfo error: "'+t.error+'" for level '+i+" "+JSON.stringify(t)):!t.supported&&(H.warn("[abr] Unsupported MediaCapabilities decodingInfo result for level "+i+" "+JSON.stringify(t)),i>-1&&e.length>1&&(H.log("[abr] Removing unsupported level "+i),u.hls.removeLevel(i)))}})):c.supportedResult=ii}if(O&&c.codecSet!==O||S&&c.videoRange!==S||g&&L>c.frameRate||!g&&L>0&&L<c.frameRate||c.supportedResult&&!(null!=(i=c.supportedResult.decodingInfoResults)&&i[0].smooth))return U.push(K),0;var R=c.details,D=($?null==R?void 0:R.partTarget:null==R?void 0:R.averagetargetduration)||M;l=g?o*e:s*e;var k=M&&n>=2*M&&0===a?v[K].averageBitrate:v[K].maxBitrate,I=u.getTimeToLoadFrag(B,l,k*D,void 0===R);if(l>=k&&(K===h||0===c.loadError&&0===c.fragmentError)&&(I<=B||!w(I)||x&&!u.bitrateTestDelay||I<d)){var b=u.forcedAutoLevel;return K!==p&&(-1===b||b!==p)&&(U.length&&H.trace("[abr] Skipped level(s) "+U.join(",")+" of "+r+' max with CODECS and VIDEO-RANGE:"'+v[U[0]].codecs+'" '+v[U[0]].videoRange+'; not compatible with "'+T.codecs+'" '+S),H.info("[abr] switch candidate:"+f+"->"+K+" adjustedbw("+Math.round(l)+")-bitrate="+Math.round(l-k)+" ttfb:"+B.toFixed(1)+" avgDuration:"+D.toFixed(1)+" maxFetchDuration:"+d.toFixed(1)+" fetchDuration:"+I.toFixed(1)+" firstSelection:"+E+" codecSet:"+O+" videoRange:"+S+" hls.loadLevel:"+p)),E&&(u.firstSelection=K),{v:K}}},K=r;K>=i;K--)if(0!==(N=G())&&N)return N.v;return -1},s(t,[{key:"firstAutoLevel",get:function t(){var e=this.hls,i=e.maxAutoLevel,r=e.minAutoLevel,n=this.getBwEstimate(),a=this.hls.config.maxStarvationDelay,s=this.findBestLevel(n,r,i,0,a,1,1);if(s>-1)return s;var o=this.hls.firstLevel,l=Math.min(Math.max(o,r),i);return H.warn("[abr] Could not find best starting auto level. Defaulting to first in playlist "+o+" clamped to "+l),l}},{key:"forcedAutoLevel",get:function t(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}},{key:"nextAutoLevel",get:function t(){var e=this.forcedAutoLevel,i=this.bwEstimator.canEstimate(),r=this.lastLoadedFragLevel>-1;if(-1!==e&&(!i||!r||this.nextAutoLevelKey===this.getAutoLevelKey()))return e;var n=i&&r?this.getNextABRAutoLevel():this.firstAutoLevel;if(-1!==e){var a=this.hls.levels;if(a.length>Math.max(e,n)&&a[e].loadError<=a[n].loadError)return e}return this._nextAutoLevel=n,this.nextAutoLevelKey=this.getAutoLevelKey(),n},set:function t(e){var i=this.hls,r=i.maxAutoLevel,n=Math.min(Math.max(e,i.minAutoLevel),r);this._nextAutoLevel!==n&&(this.nextAutoLevelKey="",this._nextAutoLevel=n)}}]),t}(),im=function(){function t(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var e=t.prototype;return e.destroy=function t(){this.onHandlerDestroying(),this.onHandlerDestroyed()},e.onHandlerDestroying=function t(){this.clearNextTick(),this.clearInterval()},e.onHandlerDestroyed=function t(){},e.hasInterval=function t(){return!!this._tickInterval},e.hasNextTick=function t(){return!!this._tickTimer},e.setInterval=function t(e){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)},e.clearInterval=function t(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)},e.clearNextTick=function t(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)},e.tick=function t(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},e.tickImmediate=function t(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},e.doTick=function t(){},t}(),ip={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"},iy=function(){function t(t){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=t,this._registerListeners()}var e=t.prototype;return e._registerListeners=function t(){var e=this.hls;e.on(O.BUFFER_APPENDED,this.onBufferAppended,this),e.on(O.FRAG_BUFFERED,this.onFragBuffered,this),e.on(O.FRAG_LOADED,this.onFragLoaded,this)},e._unregisterListeners=function t(){var e=this.hls;e.off(O.BUFFER_APPENDED,this.onBufferAppended,this),e.off(O.FRAG_BUFFERED,this.onFragBuffered,this),e.off(O.FRAG_LOADED,this.onFragLoaded,this)},e.destroy=function t(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null},e.getAppendedFrag=function t(e,i){var r=this.activePartLists[i];if(r)for(var n=r.length;n--;){var a=r[n];if(!a)break;var s=a.end;if(a.start<=e&&null!==s&&e<=s)return a}return this.getBufferedFrag(e,i)},e.getBufferedFrag=function t(e,i){for(var r=this.fragments,n=Object.keys(r),a=n.length;a--;){var s=r[n[a]];if((null==s?void 0:s.body.type)===i&&s.buffered){var o=s.body;if(o.start<=e&&e<=o.end)return o}}return null},e.detectEvictedFragments=function t(e,i,r,n){var a=this;this.timeRanges&&(this.timeRanges[e]=i);var s=(null==n?void 0:n.fragment.sn)||-1;Object.keys(this.fragments).forEach(function(t){var n=a.fragments[t];if(n&&!(s>=n.body.sn)){if(!n.buffered&&!n.loaded){n.body.type===r&&a.removeFragment(n.body);return}var o=n.range[e];o&&o.time.some(function(t){var e=!a.isTimeBuffered(t.startPTS,t.endPTS,i);return e&&a.removeFragment(n.body),e})}})},e.detectPartialFragments=function t(e){var i=this,r=this.timeRanges,n=e.frag,a=e.part;if(r&&"initSegment"!==n.sn){var s=ix(n),o=this.fragments[s];if(o&&(!o.buffered||!n.gap)){var l=!n.relurl;(Object.keys(r).forEach(function(t){var e=n.elementaryStreams[t];if(e){var s=r[t],u=l||!0===e.partial;o.range[t]=i.getBufferedTimes(n,a,u,s)}}),o.loaded=null,Object.keys(o.range).length)?(o.buffered=!0,(o.body.endList=n.endList||o.body.endList)&&(this.endListFragments[o.body.type]=o),iT(o)||this.removeParts(n.sn-1,n.type)):this.removeFragment(o.body)}}},e.removeParts=function t(e,i){var r=this.activePartLists[i];r&&(this.activePartLists[i]=r.filter(function(t){return t.fragment.sn>=e}))},e.fragBuffered=function t(e,i){var r=ix(e),n=this.fragments[r];!n&&i&&(n=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),n&&(n.loaded=null,n.buffered=!0)},e.getBufferedTimes=function t(e,i,r,n){for(var a={time:[],partial:r},s=e.start,o=e.end,l=e.minEndPTS||o,u=e.maxStartPTS||s,d=0;d<n.length;d++){var h=n.start(d)-this.bufferPadding,f=n.end(d)+this.bufferPadding;if(u>=h&&l<=f){a.time.push({startPTS:Math.max(s,n.start(d)),endPTS:Math.min(o,n.end(d))});break}if(s<f&&o>h){var c=Math.max(s,n.start(d)),$=Math.min(o,n.end(d));$>c&&(a.partial=!0,a.time.push({startPTS:c,endPTS:$}))}else if(o<=h)break}return a},e.getPartialFragment=function t(e){var i,r,n,a=null,s=0,o=this.bufferPadding,l=this.fragments;return Object.keys(l).forEach(function(t){var u=l[t];u&&iT(u)&&(r=u.body.start-o,n=u.body.end+o,e>=r&&e<=n&&s<=(i=Math.min(e-r,n-e))&&(a=u.body,s=i))}),a},e.isEndListAppended=function t(e){var i=this.endListFragments[e];return void 0!==i&&(i.buffered||iT(i))},e.getState=function t(e){var i=ix(e),r=this.fragments[i];return r?r.buffered?iT(r)?ip.PARTIAL:ip.OK:ip.APPENDING:(0,ip.NOT_LOADED)},e.isTimeBuffered=function t(e,i,r){for(var n,a,s=0;s<r.length;s++){if(n=r.start(s)-this.bufferPadding,a=r.end(s)+this.bufferPadding,e>=n&&i<=a)return!0;if(i<=n)break}return!1},e.onFragLoaded=function t(e,i){var r=i.frag,n=i.part;if("initSegment"!==r.sn&&!r.bitrateTest){var a=ix(r);this.fragments[a]={body:r,appendedPTS:null,loaded:n?null:i,buffered:!1,range:Object.create(null)}}},e.onBufferAppended=function t(e,i){var r=this,n=i.frag,a=i.part,s=i.timeRanges;if("initSegment"!==n.sn){var o=n.type;if(a){var l=this.activePartLists[o];l||(this.activePartLists[o]=l=[]),l.push(a)}this.timeRanges=s,Object.keys(s).forEach(function(t){var e=s[t];r.detectEvictedFragments(t,e,o,a)})}},e.onFragBuffered=function t(e,i){this.detectPartialFragments(i)},e.hasFragment=function t(e){var i=ix(e);return!!this.fragments[i]},e.hasParts=function t(e){var i;return!!(null!=(i=this.activePartLists[e])&&i.length)},e.removeFragmentsInRange=function t(e,i,r,n,a){var s=this;(!n||this.hasGaps)&&Object.keys(this.fragments).forEach(function(t){var o=s.fragments[t];if(o){var l=o.body;l.type===r&&(!n||l.gap)&&l.start<i&&l.end>e&&(o.buffered||a)&&s.removeFragment(l)}})},e.removeFragment=function t(e){var i=ix(e);e.stats.loaded=0,e.clearElementaryStreamInfo();var r=this.activePartLists[e.type];if(r){var n=e.sn;this.activePartLists[e.type]=r.filter(function(t){return t.fragment.sn!==n})}delete this.fragments[i],e.endList&&delete this.endListFragments[e.type]},e.removeAllFragments=function t(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1},t}();function iT(t){var e,i,r;return t.buffered&&(t.body.gap||(null==(e=t.range.video)?void 0:e.partial)||(null==(i=t.range.audio)?void 0:i.partial)||(null==(r=t.range.audiovideo)?void 0:r.partial))}function ix(t){return t.type+"_"+t.level+"_"+t.sn}var iE={length:0,start:function t(){return 0},end:function t(){return 0}},iS=function(){function t(){}return t.isBuffered=function e(i,r){try{if(i){for(var n=t.getBuffered(i),a=0;a<n.length;a++)if(r>=n.start(a)&&r<=n.end(a))return!0}}catch(s){}return!1},t.bufferInfo=function e(i,r,n){try{if(i){var a,s=t.getBuffered(i),o=[];for(a=0;a<s.length;a++)o.push({start:s.start(a),end:s.end(a)});return this.bufferedInfo(o,r,n)}}catch(l){}return{len:0,start:r,end:r,nextStart:void 0}},t.bufferedInfo=function t(e,i,r){i=Math.max(0,i),e.sort(function(t,e){var i=t.start-e.start;return i||e.end-t.end});var n,a=[];if(r)for(var s=0;s<e.length;s++){var o=a.length;if(o){var l=a[o-1].end;e[s].start-l<r?e[s].end>l&&(a[o-1].end=e[s].end):a.push(e[s])}else a.push(e[s])}else a=e;for(var u=0,d=i,h=i,f=0;f<a.length;f++){var c=a[f].start,$=a[f].end;if(i+r>=c&&i<$)d=c,u=(h=$)-i;else if(i+r<c){n=c;break}}return{len:u,start:d||0,end:h||0,nextStart:n}},t.getBuffered=function t(e){try{return e.buffered}catch(i){return H.log("failed to get media.buffered",i),iE}},t}(),iL=function t(e,i,r,n,a,s){void 0===n&&(n=0),void 0===a&&(a=-1),void 0===s&&(s=!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=iA(),this.buffering={audio:iA(),video:iA(),audiovideo:iA()},this.level=e,this.sn=i,this.id=r,this.size=n,this.part=a,this.partial=s};function iA(){return{start:0,executeStart:0,executeEnd:0,end:0}}function iR(t,e){for(var i,r=0,n=t.length;r<n;r++)if((null==(i=t[r])?void 0:i.cc)===e)return t[r];return null}function i_(t,e){if(t){var i=t.start+e;t.start=t.startPTS=i,t.endPTS=i+t.duration}}function iD(t,e){for(var i=e.fragments,r=0,n=i.length;r<n;r++)i_(i[r],t);e.fragmentHint&&i_(e.fragmentHint,t),e.alignedSliding=!0}function ik(t,e){if(t.hasProgramDateTime&&e.hasProgramDateTime){var i,r,n=t.fragments,a=e.fragments;if(n.length&&a.length){var s=Math.min(e.endCC,t.endCC);e.startCC<s&&t.startCC<s&&(i=iR(a,s),r=iR(n,s)),i&&r||(r=iR(n,(i=a[Math.floor(a.length/2)]).cc)||n[Math.floor(n.length/2)]);var o=i.programDateTime,l=r.programDateTime;o&&l&&iD((l-o)/1e3-(r.start-i.start),t)}}}var iI=function(){function t(t){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t}var e=t.prototype;return e.destroy=function t(){this.loader&&(this.loader.destroy(),this.loader=null)},e.abort=function t(){this.loader&&this.loader.abort()},e.load=function t(e,i){var n=this,a=e.url;if(!a)return Promise.reject(new i8({type:N.NETWORK_ERROR,details:M.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:Error("Fragment does not have a "+(a?"part list":"url")),networkDetails:null}));this.abort();var s=this.config,o=s.fLoader,l=s.loader;return new Promise(function(t,u){if(n.loader&&n.loader.destroy(),e.gap){if(e.tagList.some(function(t){return"GAP"===t[0]})){u(iC(e));return}e.gap=!1}var d=n.loader=e.loader=o?new o(s):new l(s),h=ib(e),f=eW(s.fragLoadPolicy.default),c={loadPolicy:f,timeout:f.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===e.sn?1/0:131072};e.stats=d.stats,d.load(h,c,{onSuccess:function i(r,a,s,o){n.resetLoader(e,d);var l=r.data;s.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(l.slice(0,16)),l=l.slice(16)),t({frag:e,part:null,payload:l,networkDetails:o})},onError:function t(i,s,o,l){n.resetLoader(e,d),u(new i8({type:N.NETWORK_ERROR,details:M.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:r({url:a,data:void 0},i),error:Error("HTTP Error "+i.code+" "+i.text),networkDetails:o,stats:l}))},onAbort:function t(i,r,a){n.resetLoader(e,d),u(new i8({type:N.NETWORK_ERROR,details:M.INTERNAL_ABORTED,fatal:!1,frag:e,error:Error("Aborted"),networkDetails:a,stats:i}))},onTimeout:function t(i,r,a){n.resetLoader(e,d),u(new i8({type:N.NETWORK_ERROR,details:M.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:Error("Timeout after "+c.timeout+"ms"),networkDetails:a,stats:i}))},onProgress:function t(r,n,a,s){i&&i({frag:e,part:null,payload:a,networkDetails:s})}})})},e.loadPart=function t(e,i,n){var a=this;this.abort();var s=this.config,o=s.fLoader,l=s.loader;return new Promise(function(t,u){if(a.loader&&a.loader.destroy(),e.gap||i.gap){u(iC(e,i));return}var d=a.loader=e.loader=o?new o(s):new l(s),h=ib(e,i),f=eW(s.fragLoadPolicy.default),c={loadPolicy:f,timeout:f.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:131072};i.stats=d.stats,d.load(h,c,{onSuccess:function r(s,o,l,u){a.resetLoader(e,d),a.updateStatsFromPart(e,i);var h={frag:e,part:i,payload:s.data,networkDetails:u};n(h),t(h)},onError:function t(n,s,o,l){a.resetLoader(e,d),u(new i8({type:N.NETWORK_ERROR,details:M.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:i,response:r({url:h.url,data:void 0},n),error:Error("HTTP Error "+n.code+" "+n.text),networkDetails:o,stats:l}))},onAbort:function t(r,n,s){e.stats.aborted=i.stats.aborted,a.resetLoader(e,d),u(new i8({type:N.NETWORK_ERROR,details:M.INTERNAL_ABORTED,fatal:!1,frag:e,part:i,error:Error("Aborted"),networkDetails:s,stats:r}))},onTimeout:function t(r,n,s){a.resetLoader(e,d),u(new i8({type:N.NETWORK_ERROR,details:M.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:i,error:Error("Timeout after "+c.timeout+"ms"),networkDetails:s,stats:r}))}})})},e.updateStatsFromPart=function t(e,i){var r=e.stats,n=i.stats,a=n.total;if(r.loaded+=n.loaded,a){var s=Math.round(e.duration/i.duration),o=Math.min(Math.round(r.loaded/a),s),l=(s-o)*Math.round(r.loaded/o);r.total=r.loaded+l}else r.total=Math.max(r.loaded,r.total);var u=r.loading,d=n.loading;u.start?u.first+=d.first-d.start:(u.start=d.start,u.first=d.first),u.end=d.end},e.resetLoader=function t(e,i){e.loader=null,this.loader===i&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),i.destroy()},t}();function ib(t,e){void 0===e&&(e=null);var i=e||t,r={frag:t,part:e,responseType:"arraybuffer",url:i.url,headers:{},rangeStart:0,rangeEnd:0},n=i.byteRangeStartOffset,a=i.byteRangeEndOffset;if(w(n)&&w(a)){var s,o=n,l=a;if("initSegment"===t.sn&&(null==(s=t.decryptdata)?void 0:s.method)==="AES-128"){var u=a-n;u%16&&(l=a+(16-u%16)),0!==n&&(r.resetIV=!0,o=n-16)}r.rangeStart=o,r.rangeEnd=l}return r}function iC(t,e){var i=Error("GAP "+(t.gap?"tag":"attribute")+" found"),r={type:N.MEDIA_ERROR,details:M.FRAG_GAP,fatal:!1,frag:t,error:i,networkDetails:null};return e&&(r.part=e),(e||t).stats.aborted=!0,new i8(r)}var i8=function(t){function e(e){var i;return(i=t.call(this,e.error.message)||this).data=void 0,i.data=e,i}return u(e,t),e}(c(Error)),iw=function(){function t(t,e){this.subtle=void 0,this.aesIV=void 0,this.subtle=t,this.aesIV=e}return t.prototype.decrypt=function t(e,i){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},i,e)},t}(),iP=function(){function t(t,e){this.subtle=void 0,this.key=void 0,this.subtle=t,this.key=e}return t.prototype.expandKey=function t(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},t}(),iF=function(){function t(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var e=t.prototype;return e.uint8ArrayToUint32Array_=function t(e){for(var i=new DataView(e),r=new Uint32Array(4),n=0;n<4;n++)r[n]=i.getUint32(4*n);return r},e.initTable=function t(){var e=this.sBox,i=this.invSBox,r=this.subMix,n=r[0],a=r[1],s=r[2],o=r[3],l=this.invSubMix,u=l[0],d=l[1],h=l[2],f=l[3],c=new Uint32Array(256),$=0,g=0,v=0;for(v=0;v<256;v++)v<128?c[v]=v<<1:c[v]=v<<1^283;for(v=0;v<256;v++){var m=g^g<<1^g<<2^g<<3^g<<4;m=m>>>8^255&m^99,e[$]=m,i[m]=$;var p=c[$],y=c[p],T=c[y],x=257*c[m]^16843008*m;n[$]=x<<24|x>>>8,a[$]=x<<16|x>>>16,s[$]=x<<8|x>>>24,o[$]=x,x=16843009*T^65537*y^257*p^16843008*$,u[m]=x<<24|x>>>8,d[m]=x<<16|x>>>16,h[m]=x<<8|x>>>24,f[m]=x,$?($=p^c[c[c[T^p]]],g^=c[c[g]]):$=g=1}},e.expandKey=function t(e){for(var i,r,n,a,s=this.uint8ArrayToUint32Array_(e),o=!0,l=0;l<s.length&&o;)o=s[l]===this.key[l],l++;if(!o){this.key=s;var u=this.keySize=s.length;if(4!==u&&6!==u&&8!==u)throw Error("Invalid aes key size="+u);var d=this.ksRows=(u+6+1)*4,h=this.keySchedule=new Uint32Array(d),f=this.invKeySchedule=new Uint32Array(d),c=this.sBox,$=this.rcon,g=this.invSubMix,v=g[0],m=g[1],p=g[2],y=g[3];for(i=0;i<d;i++){if(i<u){n=h[i]=s[i];continue}a=n,i%u==0?(a=c[(a=a<<8|a>>>24)>>>24]<<24|c[a>>>16&255]<<16|c[a>>>8&255]<<8|c[255&a],a^=$[i/u|0]<<24):u>6&&i%u==4&&(a=c[a>>>24]<<24|c[a>>>16&255]<<16|c[a>>>8&255]<<8|c[255&a]),h[i]=n=(h[i-u]^a)>>>0}for(r=0;r<d;r++)i=d-r,a=3&r?h[i]:h[i-4],r<4||i<=4?f[r]=a:f[r]=v[c[a>>>24]]^m[c[a>>>16&255]]^p[c[a>>>8&255]]^y[c[255&a]],f[r]=f[r]>>>0}},e.networkToHostOrderSwap=function t(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24},e.decrypt=function t(e,i,r){for(var n,a,s,o,l,u,d,h,f,c,$,g,v,m,p=this.keySize+6,y=this.invKeySchedule,T=this.invSBox,x=this.invSubMix,E=x[0],S=x[1],L=x[2],A=x[3],R=this.uint8ArrayToUint32Array_(r),_=R[0],D=R[1],k=R[2],I=R[3],b=new Int32Array(e),C=new Int32Array(b.length),w=this.networkToHostOrderSwap;i<b.length;){for(m=1,f=w(b[i]),c=w(b[i+1]),$=w(b[i+2]),g=w(b[i+3]),l=f^y[0],u=g^y[1],d=$^y[2],h=c^y[3],v=4;m<p;m++)n=E[l>>>24]^S[u>>16&255]^L[d>>8&255]^A[255&h]^y[v],a=E[u>>>24]^S[d>>16&255]^L[h>>8&255]^A[255&l]^y[v+1],s=E[d>>>24]^S[h>>16&255]^L[l>>8&255]^A[255&u]^y[v+2],o=E[h>>>24]^S[l>>16&255]^L[u>>8&255]^A[255&d]^y[v+3],l=n,u=a,d=s,h=o,v+=4;n=T[l>>>24]<<24^T[u>>16&255]<<16^T[d>>8&255]<<8^T[255&h]^y[v],a=T[u>>>24]<<24^T[d>>16&255]<<16^T[h>>8&255]<<8^T[255&l]^y[v+1],s=T[d>>>24]<<24^T[h>>16&255]<<16^T[l>>8&255]<<8^T[255&u]^y[v+2],o=T[h>>>24]<<24^T[l>>16&255]<<16^T[u>>8&255]<<8^T[255&d]^y[v+3],C[i]=w(n^_),C[i+1]=w(o^D),C[i+2]=w(s^k),C[i+3]=w(a^I),_=f,D=c,k=$,I=g,i+=4}return C.buffer},t}(),iO=function(){function t(t,e){var i=(void 0===e?{}:e).removePKCS7Padding,r=void 0===i||i;if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=t.enableSoftwareAES,this.removePKCS7Padding=r,r)try{var n=self.crypto;n&&(this.subtle=n.subtle||n.webkitSubtle)}catch(a){}this.useSoftware=!this.subtle}var e=t.prototype;return e.destroy=function t(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},e.isSync=function t(){return this.useSoftware},e.flush=function t(){var e,i,r,n=this.currentResult,a=this.remainderData;if(!n||a)return this.reset(),null;var s=new Uint8Array(n);return(this.reset(),this.removePKCS7Padding)?(r=(i=(e=s).byteLength)&&new DataView(e.buffer).getUint8(i-1))?tc(e,0,i-r):e:s},e.reset=function t(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},e.decrypt=function t(e,i,r){var n=this;return this.useSoftware?new Promise(function(t,a){n.softwareDecrypt(new Uint8Array(e),i,r);var s=n.flush();s?t(s.buffer):a(Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),i,r)},e.softwareDecrypt=function t(e,i,r){var n=this.currentIV,a=this.currentResult,s=this.remainderData;this.logOnce("JS AES decrypt"),s&&(e=t6(s,e),this.remainderData=null);var o=this.getValidChunk(e);if(!o.length)return null;n&&(r=n);var l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new iF),l.expandKey(i);var u=a;return(this.currentResult=l.decrypt(o.buffer,0,r),this.currentIV=tc(o,-16).buffer,u)?u:null},e.webCryptoDecrypt=function t(e,i,r){var n=this;if(this.key!==i||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,i,r));this.key=i,this.fastAesKey=new iP(this.subtle,i)}return this.fastAesKey.expandKey().then(function(t){return n.subtle?(n.logOnce("WebCrypto AES decrypt"),new iw(n.subtle,new Uint8Array(r)).decrypt(e.buffer,t)):Promise.reject(Error("web crypto not initialized"))}).catch(function(t){return H.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+t.name+": "+t.message),n.onWebCryptoError(e,i,r)})},e.onWebCryptoError=function t(e,i,r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,i,r);var n=this.flush();if(n)return n.buffer;throw Error("WebCrypto and softwareDecrypt: failed to decrypt data")},e.getValidChunk=function t(e){var i=e,r=e.length-e.length%16;return r!==e.length&&(i=tc(e,0,r),this.remainderData=tc(e,r)),i},e.logOnce=function t(e){this.logEnabled&&(H.log("[decrypter]: "+e),this.logEnabled=!1)},t}(),iN={toString:function t(e){for(var i="",r=e.length,n=0;n<r;n++)i+="["+e.start(n).toFixed(3)+"-"+e.end(n).toFixed(3)+"]";return i}},iM={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"},iB=function(t){function e(e,i,r,n,a){var s;return(s=t.call(this)||this).hls=void 0,s.fragPrevious=null,s.fragCurrent=null,s.fragmentTracker=void 0,s.transmuxer=null,s._state=iM.STOPPED,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=H.log.bind(H,n+":"),s.warn=H.warn.bind(H,n+":"),s.hls=e,s.fragmentLoader=new iI(e.config),s.keyLoader=r,s.fragmentTracker=i,s.config=e.config,s.decrypter=new iO(e.config),e.on(O.MANIFEST_LOADED,s.onManifestLoaded,function t(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(s)),s}u(e,t);var i=e.prototype;return i.doTick=function t(){this.onTickEnd()},i.onTickEnd=function t(){},i.startLoad=function t(e){},i.stopLoad=function t(){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=iM.STOPPED},i._streamEnded=function t(e,i){if(i.live||e.nextStart||!e.end||!this.media)return!1;var r=i.partList;if(null!=r&&r.length){var n=r[r.length-1];return iS.isBuffered(this.media,n.start+n.duration/2)}var a=i.fragments[i.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(a)},i.getLevelDetails=function t(){if(this.levels&&null!==this.levelLastLoaded){var e;return null==(e=this.levelLastLoaded)?void 0:e.details}},i.onMediaAttached=function t(e,i){var r=this.media=this.mediaBuffer=i.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),r.addEventListener("seeking",this.onvseeking),r.addEventListener("ended",this.onvended);var n=this.config;this.levels&&n.autoStartLoad&&this.state===iM.STOPPED&&this.startLoad(n.startPosition)},i.onMediaDetaching=function t(){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()},i.onMediaSeeking=function t(){var e=this.config,i=this.fragCurrent,r=this.media,n=this.mediaBuffer,a=this.state,s=r?r.currentTime:0,o=iS.bufferInfo(n||r,s,e.maxBufferHole);if(this.log("media seeking to "+(w(s)?s.toFixed(3):s)+", state: "+a),this.state===iM.ENDED)this.resetLoadingState();else if(i){var l=e.maxFragLookUpTolerance,u=i.start-l,d=i.start+i.duration+l;if(!o.len||d<o.start||u>o.end){var h=s>d;(s<u||h)&&(h&&i.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),i.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}r&&(this.fragmentTracker.removeFragmentsInRange(s,1/0,this.playlistType,!0),this.lastCurrentTime=s),this.loadedmetadata||o.len||(this.nextLoadPosition=this.startPosition=s),this.tickImmediate()},i.onMediaEnded=function t(){this.startPosition=this.lastCurrentTime=0},i.onManifestLoaded=function t(e,i){this.startTimeOffset=i.startTimeOffset,this.initPTS=[]},i.onHandlerDestroying=function e(){this.hls.off(O.MANIFEST_LOADED,this.onManifestLoaded,this),this.stopLoad(),t.prototype.onHandlerDestroying.call(this),this.hls=null},i.onHandlerDestroyed=function e(){this.state=iM.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,t.prototype.onHandlerDestroyed.call(this)},i.loadFragment=function t(e,i,r){this._loadFragForPlayback(e,i,r)},i._loadFragForPlayback=function t(e,i,r){var n=this,a=function t(i){if(n.fragContextChanged(e)){n.warn("Fragment "+e.sn+(i.part?" p: "+i.part.index:"")+" of level "+e.level+" was dropped during download."),n.fragmentTracker.removeFragment(e);return}e.stats.chunkCount++,n._handleFragmentLoadProgress(i)};this._doFragLoad(e,i,r,a).then(function(t){if(t){var i=n.state;if(n.fragContextChanged(e)){i!==iM.FRAG_LOADING&&(n.fragCurrent||i!==iM.PARSING)||(n.fragmentTracker.removeFragment(e),n.state=iM.IDLE);return}"payload"in t&&(n.log("Loaded fragment "+e.sn+" of level "+e.level),n.hls.trigger(O.FRAG_LOADED,t)),n._handleFragmentLoadComplete(t)}}).catch(function(t){n.state!==iM.STOPPED&&n.state!==iM.ERROR&&(n.warn("Frag error: "+((null==t?void 0:t.message)||t)),n.resetFragmentLoading(e))})},i.clearTrackerIfNeeded=function t(e){var i,r=this.fragmentTracker;if(r.getState(e)===ip.APPENDING){var n=e.type,a=this.getFwdBufferInfo(this.mediaBuffer,n),s=Math.max(e.duration,a?a.len:this.config.maxBufferLength),o=this.backtrackFragment;(1==(o?e.sn-o.sn:0)||this.reduceMaxBufferLength(s,e.duration))&&r.removeFragment(e)}else(null==(i=this.mediaBuffer)?void 0:i.buffered.length)===0?r.removeAllFragments():r.hasParts(e.type)&&(r.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),r.getState(e)===ip.PARTIAL&&r.removeFragment(e))},i.checkLiveUpdate=function t(e){if(e.updated&&!e.live){var i=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:i,part:null,stats:i.stats,id:i.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)},i.flushMainBuffer=function t(e,i,r){if(void 0===r&&(r=null),e-i){var n={startOffset:e,endOffset:i,type:r};this.hls.trigger(O.BUFFER_FLUSHING,n)}},i._loadInitSegment=function t(e,i){var r=this;this._doFragLoad(e,i).then(function(t){if(!t||r.fragContextChanged(e)||!r.levels)throw 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(O.ERROR,{type:N.MEDIA_ERROR,details:M.FRAG_DECRYPT_ERROR,fatal:!1,error:t,reason:t.message,frag:e}),t}).then(function(n){var a=self.performance.now();return i.trigger(O.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!==iM.STOPPED&&r.state!==iM.ERROR&&(r.warn(t),r.resetFragmentLoading(e))})},i.completeInitSegmentLoad=function t(e){if(!this.levels)throw Error("init load aborted, missing levels");var i=e.frag.stats;this.state=iM.IDLE,e.frag.data=new Uint8Array(e.payload),i.parsing.start=i.buffering.start=self.performance.now(),i.parsing.end=i.buffering.end=self.performance.now(),this.tick()},i.fragContextChanged=function t(e){var i=this.fragCurrent;return!e||!i||e.sn!==i.sn||e.level!==i.level},i.fragBufferedComplete=function t(e,i){var r=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log("Buffered "+e.type+" sn: "+e.sn+(i?" part: "+i.index:"")+" of "+(this.playlistType===eT.MAIN?"level":"track")+" "+e.level+" (frag:["+(null!=(n=e.startPTS)?n:NaN).toFixed(3)+"-"+(null!=(a=e.endPTS)?a:NaN).toFixed(3)+"] > buffer:"+(r?iN.toString(iS.getBuffered(r)):"(detached)")+")"),"initSegment"!==e.sn){if(e.type!==eT.SUBTITLE){var n,a,s,o,l,u=e.elementaryStreams;if(!Object.keys(u).some(function(t){return!!u[t]})){this.state=iM.IDLE;return}}var d=null==(l=this.levels)?void 0:l[e.level];null!=d&&d.fragmentError&&(this.log("Resetting level fragment error count of "+d.fragmentError+" on frag buffered"),d.fragmentError=0)}this.state=iM.IDLE,r&&(!this.loadedmetadata&&e.type==eT.MAIN&&r.buffered.length&&(null==(s=this.fragCurrent)?void 0:s.sn)===(null==(o=this.fragPrevious)?void 0:o.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},i.seekToStartPos=function t(){},i._handleFragmentLoadComplete=function t(e){var i=this.transmuxer;if(i){var r=e.frag,n=e.part,a=e.partsLoaded,s=!a||0===a.length||a.some(function(t){return!t}),o=new iL(r.level,r.sn,r.stats.chunkCount+1,0,n?n.index:-1,!s);i.flush(o)}},i._handleFragmentLoadProgress=function t(e){},i._doFragLoad=function t(e,i,r,n){var a,s,o=this;void 0===r&&(r=null);var l=null==i?void 0:i.details;if(!this.levels||!l)throw Error("frag load aborted, missing level"+(l?"":" detail")+"s");var u=null;if(e.encrypted&&!(null!=(s=e.decryptdata)&&s.key)?(this.log("Loading key for "+e.sn+" of ["+l.startSN+"-"+l.endSN+"], "+("[stream-controller]"===this.logPrefix?"level":"track")+" "+e.level),this.state=iM.KEY_LOADING,this.fragCurrent=e,u=this.keyLoader.load(e).then(function(t){if(!o.fragContextChanged(t.frag))return o.hls.trigger(O.KEY_LOADED,t),o.state===iM.KEY_LOADING&&(o.state=iM.IDLE),t}),this.hls.trigger(O.KEY_LOADING,{frag:e}),null===this.fragCurrent&&(u=Promise.reject(Error("frag load aborted, context changed in KEY_LOADING")))):!e.encrypted&&l.encryptedFragments.length&&this.keyLoader.loadClear(e,l.encryptedFragments),r=Math.max(e.start,r||0),this.config.lowLatencyMode&&"initSegment"!==e.sn){var d=l.partList;if(d&&n){r>e.end&&l.fragmentHint&&(e=l.fragmentHint);var h=this.getNextPart(d,e,r);if(h>-1){var f,c=d[h];return(this.log("Loading part sn: "+e.sn+" p: "+c.index+" cc: "+e.cc+" of playlist ["+l.startSN+"-"+l.endSN+"] parts [0-"+h+"-"+(d.length-1)+"] "+("[stream-controller]"===this.logPrefix?"level":"track")+": "+e.level+", target: "+parseFloat(r.toFixed(3))),this.nextLoadPosition=c.start+c.duration,this.state=iM.FRAG_LOADING,f=u?u.then(function(t){return!t||o.fragContextChanged(t.frag)?null:o.doFragPartsLoad(e,c,i,n)}).catch(function(t){return o.handleFragLoadError(t)}):this.doFragPartsLoad(e,c,i,n).catch(function(t){return o.handleFragLoadError(t)}),this.hls.trigger(O.FRAG_LOADING,{frag:e,part:c,targetBufferTime:r}),null===this.fragCurrent)?Promise.reject(Error("frag load aborted, context changed in FRAG_LOADING parts")):f}if(!e.url||this.loadedEndOfParts(d,r))return Promise.resolve(null)}}this.log("Loading fragment "+e.sn+" cc: "+e.cc+" "+(l?"of ["+l.startSN+"-"+l.endSN+"] ":"")+("[stream-controller]"===this.logPrefix?"level":"track")+": "+e.level+", target: "+parseFloat(r.toFixed(3))),w(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=iM.FRAG_LOADING;var $=this.config.progressive;return(a=$&&u?u.then(function(t){return!t||o.fragContextChanged(null==t?void 0:t.frag)?null:o.fragmentLoader.load(e,n)}).catch(function(t){return o.handleFragLoadError(t)}):Promise.all([this.fragmentLoader.load(e,$?n:void 0),u]).then(function(t){var e=t[0];return!$&&e&&n&&n(e),e}).catch(function(t){return o.handleFragLoadError(t)}),this.hls.trigger(O.FRAG_LOADING,{frag:e,targetBufferTime:r}),null===this.fragCurrent)?Promise.reject(Error("frag load aborted, context changed in FRAG_LOADING")):a},i.doFragPartsLoad=function t(e,i,r,n){var a=this;return new Promise(function(t,s){var o,l=[],u=null==(o=r.details)?void 0:o.partList;!function i(o){a.fragmentLoader.loadPart(e,o,n).then(function(n){l[o.index]=n;var s=n.part;a.hls.trigger(O.FRAG_LOADED,n);var d=e4(r,e.sn,o.index+1)||e3(u,e.sn,o.index+1);if(!d)return t({frag:e,part:s,partsLoaded:l});i(d)}).catch(s)}(i)})},i.handleFragLoadError=function t(e){if("data"in e){var i=e.data;e.data&&i.details===M.INTERNAL_ABORTED?this.handleFragLoadAborted(i.frag,i.part):this.hls.trigger(O.ERROR,i)}else this.hls.trigger(O.ERROR,{type:N.OTHER_ERROR,details:M.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null},i._handleTransmuxerFlush=function t(e){var i=this.getCurrentContext(e);if(!i||this.state!==iM.PARSING){this.fragCurrent||this.state===iM.STOPPED||this.state===iM.ERROR||(this.state=iM.IDLE);return}var r=i.frag,n=i.part,a=i.level,s=self.performance.now();r.stats.parsing.end=s,n&&(n.stats.parsing.end=s),this.updateLevelTiming(r,n,a,e.partial)},i.getCurrentContext=function t(e){var i=this.levels,r=this.fragCurrent,n=e.level,a=e.sn,s=e.part;if(!(null!=i&&i[n]))return this.warn("Levels object was unset while buffering fragment "+a+" of level "+n+". The current chunk will not be buffered."),null;var o=i[n],l=s>-1?e4(o,a,s):null,u=l?l.fragment:function t(e,i,r){if(!(null!=e&&e.details))return null;var n=e.details,a=n.fragments[i-n.startSN];return a||(a=n.fragmentHint)&&a.sn===i?a:i<n.startSN&&r&&r.sn===i?r:null}(o,a,r);return u?(r&&r!==u&&(u.stats=r.stats),{frag:u,part:l,level:o}):null},i.bufferFragmentData=function t(e,i,r,n,a){if(e&&this.state===iM.PARSING){var s,o=e.data1,l=e.data2,u=o;if(o&&l&&(u=t6(o,l)),null!=(s=u)&&s.length){var d={type:e.type,frag:i,part:r,chunkMeta:n,parent:i.type,data:u};if(this.hls.trigger(O.BUFFER_APPENDING,d),e.dropped&&e.independent&&!r){if(a)return;this.flushBufferGap(i)}}}},i.flushBufferGap=function t(e){var i=this.media;if(i){if(!iS.isBuffered(i,i.currentTime)){this.flushMainBuffer(0,e.start);return}var r=i.currentTime,n=iS.bufferInfo(i,r,0),a=e.duration,s=Math.min(2*this.config.maxFragLookUpTolerance,.25*a),o=Math.max(Math.min(e.start-s,n.end-s),r+s);e.start-o>s&&this.flushMainBuffer(o,e.start)}},i.getFwdBufferInfo=function t(e,i){var r=this.getLoadPosition();return w(r)?this.getFwdBufferInfoAtPos(e,r,i):null},i.getFwdBufferInfoAtPos=function t(e,i,r){var n=this.config.maxBufferHole,a=iS.bufferInfo(e,i,n);if(0===a.len&&void 0!==a.nextStart){var s=this.fragmentTracker.getBufferedFrag(i,r);if(s&&a.nextStart<s.end)return iS.bufferInfo(e,i,Math.max(a.nextStart,n))}return a},i.getMaxBufferLength=function t(e){var i,r=this.config;return Math.min(i=e?Math.max(8*r.maxBufferSize/e,r.maxBufferLength):r.maxBufferLength,r.maxMaxBufferLength)},i.reduceMaxBufferLength=function t(e,i){var r=this.config,n=Math.max(Math.min(e-i,r.maxBufferLength),i),a=Math.max(e-3*i,r.maxMaxBufferLength/2,n);return a>=n&&(r.maxMaxBufferLength=a,this.warn("Reduce max buffer length to "+a+"s"),!0)},i.getAppendedFrag=function t(e,i){var r=this.fragmentTracker.getAppendedFrag(e,eT.MAIN);return r&&"fragment"in r?r.fragment:r},i.getNextFragment=function t(e,i){var r,n=i.fragments,a=n.length;if(!a)return null;var s=this.config,o=n[0].start;if(i.live){var l=s.initialLiveManifestSize;if(a<l)return this.warn("Not enough fragments to start playback (have: "+a+", need: "+l+")"),null;(i.PTSKnown||this.startFragRequested||-1!==this.startPosition)&&!(e<o)||(r=this.getInitialLiveFragment(i,n),this.startPosition=this.nextLoadPosition=r?this.hls.liveSyncPosition||r.start:e)}else e<=o&&(r=n[0]);if(!r){var u=s.lowLatencyMode?i.partEnd:i.fragmentEnd;r=this.getFragmentAtPosition(e,u,i)}return this.mapToInitFragWhenRequired(r)},i.isLoopLoading=function t(e,i){var r=this.fragmentTracker.getState(e);return(r===ip.OK||r===ip.PARTIAL&&!!e.gap)&&this.nextLoadPosition>i},i.getNextFragmentLoopLoading=function t(e,i,r,n,a){var s=e.gap,o=this.getNextFragment(this.nextLoadPosition,i);if(null===o)return o;if(e=o,s&&e&&!e.gap&&r.nextStart){var l=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,n);if(null!==l&&r.len+l.len>=a)return this.log('buffer full after gaps in "'+n+'" playlist starting at sn: '+e.sn),null}return e},i.mapToInitFragWhenRequired=function t(e){return null==e||!e.initSegment||null!=e&&e.initSegment.data||this.bitrateTest?e:e.initSegment},i.getNextPart=function t(e,i,r){for(var n=-1,a=!1,s=!0,o=0,l=e.length;o<l;o++){var u=e[o];if(s=s&&!u.independent,n>-1&&r<u.start)break;var d=u.loaded;d?n=-1:(a||u.independent||s)&&u.fragment===i&&(n=o),a=d}return n},i.loadedEndOfParts=function t(e,i){var r=e[e.length-1];return r&&i>r.start&&r.loaded},i.getInitialLiveFragment=function t(e,i){var r=this.fragPrevious,n=null;if(r){if(e.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+r.programDateTime),n=function t(e,i,r){if(null===i||!Array.isArray(e)||!e.length||!w(i)||i<(e[0].programDateTime||0)||i>=(e[e.length-1].endProgramDateTime||0))return null;r=r||0;for(var n=0;n<e.length;++n){var a=e[n];if(ej(i,r,a))return a}return null}(i,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!n){var a,s,o=r.sn+1;if(o>=e.startSN&&o<=e.endSN){var l=i[o-e.startSN];r.cc===l.cc&&(n=l,this.log("Live playlist, switching playlist, load frag with next SN: "+n.sn))}!n&&(n=(a=i,s=r.cc,eq.search(a,function(t){return t.cc<s?1:t.cc>s?-1:0})))&&this.log("Live playlist, switching playlist, load frag with same CC: "+n.sn)}}else{var u=this.hls.liveSyncPosition;null!==u&&(n=this.getFragmentAtPosition(u,this.bitrateTest?e.fragmentEnd:e.edge,e))}return n},i.getFragmentAtPosition=function t(e,i,r){var n,a=this.config,s=this.fragPrevious,o=r.fragments,l=r.endSN,u=r.fragmentHint,d=a.maxFragLookUpTolerance,h=r.partList,f=!!(a.lowLatencyMode&&null!=h&&h.length&&u);if(f&&u&&!this.bitrateTest&&(o=o.concat(u),l=u.sn),n=e<i?eX(s,o,e,e>i-d?0:d):o[o.length-1]){var c=n.sn-r.startSN,$=this.fragmentTracker.getState(n);if(($===ip.OK||$===ip.PARTIAL&&n.gap)&&(s=n),s&&n.sn===s.sn&&(!f||h[0].fragment.sn>n.sn)&&s&&n.level===s.level){var g=o[c+1];n=n.sn<l&&this.fragmentTracker.getState(g)!==ip.OK?g:null}}return n},i.synchronizeToLiveEdge=function t(e){var i=this.config,r=this.media;if(r){var n=this.hls.liveSyncPosition,a=r.currentTime,s=e.fragments[0].start,o=e.edge,l=a>=s-i.maxFragLookUpTolerance&&a<=o;if(null!==n&&r.duration>n&&(a<n||!l)){var u=void 0!==i.liveMaxLatencyDuration?i.liveMaxLatencyDuration:i.liveMaxLatencyDurationCount*e.targetduration;(!l&&r.readyState<4||a<o-u)&&(this.loadedmetadata||(this.nextLoadPosition=n),r.readyState&&(this.warn("Playback: "+a.toFixed(3)+" is located too far from the end of live sliding playlist: "+o+", reset currentTime to : "+n.toFixed(3)),r.currentTime=n))}}},i.alignPlaylists=function t(e,i,r){var n=e.fragments.length;if(!n)return this.warn("No fragments in live playlist"),0;var a=e.fragments[0].start,s=e.alignedSliding&&w(a);if(!i||!s&&!a){var o,l,u,d=this.fragPrevious;o=d,l=r,u=e,l&&(function t(e,i,r){var n,a,s;if(n=e,a=r,s=i,a&&(s.endCC>s.startCC||n&&n.cc<s.startCC)){var o=function t(e,i){var r=e.fragments,n=i.fragments;if(!n.length||!r.length){H.log("No fragments to align");return}var a=iR(r,n[0].cc);if(!a||a&&!a.startPTS){H.log("No frag in previous level to align on");return}return a}(r,i);o&&w(o.start)&&(H.log("Adjusting PTS using last level due to CC increase within current level "+i.url),iD(o.start,i))}}(o,u,l),!u.alignedSliding&&l&&ik(u,l),u.alignedSliding||!l||u.skippedSegments||e6(l,u));var h=e.fragments[0].start;return this.log("Live playlist sliding: "+h.toFixed(2)+" start-sn: "+(i?i.startSN:"na")+"->"+e.startSN+" prev-sn: "+(d?d.sn:"na")+" fragments: "+n),h}return a},i.waitForCdnTuneIn=function t(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)},i.setStartPosition=function t(e,i){var r=this.startPosition;if(r<i&&(r=-1),-1===r||-1===this.lastCurrentTime){var n=null!==this.startTimeOffset,a=n?this.startTimeOffset:e.startTimeOffset;null!==a&&w(a)?(r=i+a,a<0&&(r+=e.totalduration),r=Math.min(Math.max(i,r),i+e.totalduration),this.log("Start time offset "+a+" found in "+(n?"multivariant":"media")+" playlist, adjust startPosition to "+r),this.startPosition=r):e.live?r=this.hls.liveSyncPosition||i:this.startPosition=r=0,this.lastCurrentTime=r}this.nextLoadPosition=r},i.getLoadPosition=function t(){var e=this.media,i=0;return this.loadedmetadata&&e?i=e.currentTime:this.nextLoadPosition&&(i=this.nextLoadPosition),i},i.handleFragLoadAborted=function t(e,i){this.transmuxer&&"initSegment"!==e.sn&&e.stats.aborted&&(this.warn("Fragment "+e.sn+(i?" part "+i.index:"")+" of level "+e.level+" was aborted"),this.resetFragmentLoading(e))},i.resetFragmentLoading=function t(e){this.fragCurrent&&(this.fragContextChanged(e)||this.state===iM.FRAG_LOADING_WAITING_RETRY)||(this.state=iM.IDLE)},i.onFragmentOrKeyLoadError=function t(e,i){if(i.chunkMeta&&!i.frag){var r,n=this.getCurrentContext(i.chunkMeta);n&&(i.frag=n.frag)}var a=i.frag;if(a&&a.type===e&&this.levels){if(this.fragContextChanged(a)){this.warn("Frag load error must match current frag to retry "+a.url+" > "+(null==(r=this.fragCurrent)?void 0:r.url));return}var s=i.details===M.FRAG_GAP;s&&this.fragmentTracker.fragBuffered(a,!0);var o=i.errorAction,l=o||{},u=l.action,d=l.retryCount,h=void 0===d?0:d,f=l.retryConfig;if(o&&u===eQ.RetryRequest&&f){this.resetStartWhenNotLoaded(this.levelLastLoaded);var c=eY(f,h);this.warn("Fragment "+a.sn+" of "+e+" "+a.level+" errored with "+i.details+", retrying loading "+(h+1)+"/"+f.maxNumRetry+" in "+c+"ms"),o.resolved=!0,this.retryDate=self.performance.now()+c,this.state=iM.FRAG_LOADING_WAITING_RETRY}else if(f&&o){if(this.resetFragmentErrors(e),h<f.maxNumRetry)s||u===eQ.RemoveAlternatePermanently||(o.resolved=!0);else{H.warn(i.details+" reached or exceeded max retry ("+h+")");return}}else(null==o?void 0:o.action)===eQ.SendAlternateToPenaltyBox?this.state=iM.WAITING_LEVEL:this.state=iM.ERROR;this.tickImmediate()}},i.reduceLengthAndFlushBuffer=function t(e){if(this.state===iM.PARSING||this.state===iM.PARSED){var i=e.frag,r=e.parent,n=this.getFwdBufferInfo(this.mediaBuffer,r),a=n&&n.len>.5;a&&this.reduceMaxBufferLength(n.len,(null==i?void 0:i.duration)||10);var s=!a;return s&&this.warn("Buffer full error while media.currentTime is not buffered, flush "+r+" buffer"),i&&(this.fragmentTracker.removeFragment(i),this.nextLoadPosition=i.start),this.resetLoadingState(),s}return!1},i.resetFragmentErrors=function t(e){e===eT.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==iM.STOPPED&&(this.state=iM.IDLE)},i.afterBufferFlushed=function t(e,i,r){if(e){var n=iS.getBuffered(e);this.fragmentTracker.detectEvictedFragments(i,n,r),this.state===iM.ENDED&&this.resetLoadingState()}},i.resetLoadingState=function t(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=iM.IDLE},i.resetStartWhenNotLoaded=function t(e){if(!this.loadedmetadata){this.startFragRequested=!1;var i=e?e.details:null;null!=i&&i.live?(this.startPosition=-1,this.setStartPosition(i,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},i.resetWhenMissingContext=function t(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()},i.removeUnbufferedFrags=function t(e){void 0===e&&(e=0),this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)},i.updateLevelTiming=function t(e,i,r,n){var a,s=this,o=r.details;if(!o){this.warn("level.details undefined");return}if(!Object.keys(e.elementaryStreams).reduce(function(t,i){var a=e.elementaryStreams[i];if(a){var l=a.endPTS-a.startPTS;if(l<=0)return s.warn("Could not parse fragment "+e.sn+" "+i+" duration reliably ("+l+")"),t||!1;var u=n?0:e1(o,e,a.startPTS,a.endPTS,a.startDTS,a.endDTS);return s.hls.trigger(O.LEVEL_PTS_UPDATED,{details:o,level:r,drift:u,type:i,frag:e,start:a.startPTS,end:a.endPTS}),!0}return t},!1)&&(null==(a=this.transmuxer)?void 0:a.error)===null){var l=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(l.message),this.hls.trigger(O.ERROR,{type:N.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,fatal:!1,error:l,frag:e,reason:"Found no media in msn "+e.sn+' of level "'+r.url+'"'}),!this.hls)return;this.resetTransmuxer()}this.state=iM.PARSED,this.hls.trigger(O.FRAG_PARSED,{frag:e,part:i})},i.resetTransmuxer=function t(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},i.recoverWorkerError=function t(e){"demuxerWorker"===e.event&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())},s(e,[{key:"state",get:function t(){return this._state},set:function t(e){var i=this._state;i!==e&&(this._state=e,this.log(i+"->"+e))}}]),e}(im),iU=function(){function t(){this.chunks=[],this.dataLength=0}var e=t.prototype;return e.push=function t(e){this.chunks.push(e),this.dataLength+=e.length},e.flush=function t(){var e,i=this.chunks,r=this.dataLength;return i.length?(e=1===i.length?i[0]:function t(e,i){for(var r=new Uint8Array(i),n=0,a=0;a<e.length;a++){var s=e[a];r.set(s,n),n+=s.length}return r}(i,r),this.reset(),e):new Uint8Array(0)},e.reset=function t(){this.chunks.length=0,this.dataLength=0},t}();function i0(t,e){return void 0===t&&(t=""),void 0===e&&(e=9e4),{type:t,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}var iG=function(){function t(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var e=t.prototype;return e.resetInitSegment=function t(e,i,r,n){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},e.resetTimeStamp=function t(e){this.initPTS=e,this.resetContiguity()},e.resetContiguity=function t(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},e.canParse=function t(e,i){return!1},e.appendFrame=function t(e,i,r){},e.demux=function t(e,i){this.cachedData&&(e=t6(this.cachedData,e),this.cachedData=null);var r,n=tv(e,0),a=n?n.length:0,s=this._audioTrack,o=this._id3Track,l=n?tp(n):void 0,u=e.length;for((null===this.basePTS||0===this.frameIndex&&w(l))&&(this.basePTS=i2(l,i,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),n&&n.length>0&&o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:n,type:ek.audioId3,duration:Number.POSITIVE_INFINITY});a<u;){if(this.canParse(e,a)){var d,h,f=this.appendFrame(s,e,a);f?(this.frameIndex++,this.lastPTS=f.sample.pts,a+=f.length,r=a):a=u}else(d=e,h=a,t$(d,h)&&tm(d,h+6)+10<=d.length-h)?(n=tv(e,a),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:n,type:ek.audioId3,duration:Number.POSITIVE_INFINITY}),a+=n.length,r=a):a++;if(a===u&&r!==u){var c=tc(e,r);this.cachedData?this.cachedData=t6(this.cachedData,c):this.cachedData=c}}return{audioTrack:s,videoTrack:i0(),id3Track:o,textTrack:i0()}},e.demuxSampleAes=function t(e,i,r){return Promise.reject(Error("["+this+"] This demuxer does not support Sample-AES decryption"))},e.flush=function t(e){var i=this.cachedData;return i&&(this.cachedData=null,this.demux(i,0)),{audioTrack:this._audioTrack,videoTrack:i0(),id3Track:this._id3Track,textTrack:i0()}},e.destroy=function t(){},t}(),i2=function t(e,i,r){return w(e)?90*e:9e4*i+(r?9e4*r.baseTime/r.timescale:0)};function i1(t,e){return 255===t[e]&&(246&t[e+1])==240}function i6(t,e){return 1&t[e+1]?7:9}function iK(t,e){return(3&t[e+3])<<11|t[e+4]<<3|(224&t[e+5])>>>5}function i4(t,e){return e+1<t.length&&i1(t,e)}function i3(t,e){if(i4(t,e)){var i=i6(t,e);if(e+i>=t.length)return!1;var r=iK(t,e);if(r<=i)return!1;var n=e+r;return n===t.length||i4(t,n)}return!1}function iH(t,e,i,r,n){if(!t.samplerate){var a=function t(e,i,r,n){var a,s,o,l,u=navigator.userAgent.toLowerCase(),d=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];a=((192&i[r+2])>>>6)+1;var h=(60&i[r+2])>>>2;if(h>d.length-1){var f=Error("invalid ADTS sampling index:"+h);e.emit(O.ERROR,O.ERROR,{type:N.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,fatal:!0,error:f,reason:f.message});return}return o=(1&i[r+2])<<2,o|=(192&i[r+3])>>>6,H.log("manifest codec:"+n+", ADTS type:"+a+", samplingIndex:"+h),/firefox/i.test(u)?h>=6?(a=5,l=[,,,,],s=h-3):(a=2,l=[,,],s=h):-1!==u.indexOf("android")?(a=2,l=[,,],s=h):(a=5,l=[,,,,],n&&(-1!==n.indexOf("mp4a.40.29")||-1!==n.indexOf("mp4a.40.5"))||!n&&h>=6?s=h-3:((n&&-1!==n.indexOf("mp4a.40.2")&&(h>=6&&1===o||/vivaldi/i.test(u))||!n&&1===o)&&(a=2,l=[,,]),s=h)),l[0]=a<<3,l[0]|=(14&h)>>1,l[1]|=(1&h)<<7,l[1]|=o<<3,5===a&&(l[1]|=(14&s)>>1,l[2]=(1&s)<<7,l[2]|=8,l[3]=0),{config:l,samplerate:d[h],channelCount:o,codec:"mp4a.40."+a,manifestCodec:n}}(e,i,r,n);a&&(t.config=a.config,t.samplerate=a.samplerate,t.channelCount=a.channelCount,t.codec=a.codec,t.manifestCodec=a.manifestCodec,H.log("parsed codec:"+t.codec+", rate:"+a.samplerate+", channels:"+a.channelCount))}}function iV(t){return 9216e4/t}function i7(t,e,i,r,n){var a,s=iV(t.samplerate),o=r+n*s,l=function t(e,i){var r=i6(e,i);if(i+r<=e.length){var n=iK(e,i)-r;if(n>0)return{headerLength:r,frameLength:n}}}(e,i);if(l){var u=l.frameLength,d=l.headerLength,h=d+u,f=Math.max(0,i+h-e.length);f?(a=new Uint8Array(h-d)).set(e.subarray(i+d,e.length),0):a=e.subarray(i+d,i+h);var c={unit:a,pts:o};return f||t.samples.push(c),{sample:c,length:h,missing:f}}var $=e.length-i;return(a=new Uint8Array($)).set(e.subarray(i,e.length),0),{sample:{unit:a,pts:o},length:$,missing:-1}}var iY=null,iW=[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],i5=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],iq=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],iX=[0,1,1,4];function iz(t,e,i,r,n){if(!(i+24>e.length)){var a=ij(e,i);if(a&&i+a.frameLength<=e.length){var s=r+n*(9e4*a.samplesPerFrame/a.sampleRate),o={unit:e.subarray(i,i+a.frameLength),pts:s,dts:s};return t.config=[],t.channelCount=a.channelCount,t.samplerate=a.sampleRate,t.samples.push(o),{sample:o,length:a.frameLength,missing:0}}}}function ij(t,e){var i=t[e+1]>>3&3,r=t[e+1]>>1&3,n=t[e+2]>>4&15,a=t[e+2]>>2&3;if(1!==i&&0!==n&&15!==n&&3!==a){var s=t[e+2]>>1&1,o=t[e+3]>>6,l=1e3*iW[14*(3===i?3-r:3===r?3:4)+n-1],u=i5[3*(3===i?0:2===i?1:2)+a],d=iq[i][r],h=iX[r];if(null===iY){var f=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);iY=f?parseInt(f[1]):0}return iY&&iY<=87&&2===r&&l>=224e3&&0===o&&(t[e+3]=128|t[e+3]),{sampleRate:u,channelCount:3===o?1:2,frameLength:Math.floor(d*l/u+s)*h,samplesPerFrame:8*d*h}}}function iQ(t,e){return 255===t[e]&&(224&t[e+1])==224&&(6&t[e+1])!=0}function i9(t,e){return e+1<t.length&&iQ(t,e)}function iZ(t,e){if(e+1<t.length&&iQ(t,e)){var i=ij(t,e),r=4;null!=i&&i.frameLength&&(r=i.frameLength);var n=e+r;return n===t.length||i9(t,n)}return!1}var iJ=function(t){function e(e,i){var r;return(r=t.call(this)||this).observer=void 0,r.config=void 0,r.observer=e,r.config=i,r}u(e,t);var i=e.prototype;return i.resetInitSegment=function e(i,r,n,a){t.prototype.resetInitSegment.call(this,i,r,n,a),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:r,duration:a,inputTimeScale:9e4,dropped:0}},e.probe=function t(e){if(!e)return!1;var i=tv(e,0),r=(null==i?void 0:i.length)||0;if(iZ(e,r))return!1;for(var n=e.length;r<n;r++)if(i3(e,r))return H.log("ADTS sync word found !"),!0;return!1},i.canParse=function t(e,i){var r,n,a,s;return r=e,n=i,a=r,(s=n)+5<a.length&&i1(r,n)&&iK(r,n)<=r.length-n},i.appendFrame=function t(e,i,r){iH(e,this.observer,i,r,e.manifestCodec);var n=i7(e,i,r,this.basePTS,this.frameIndex);if(n&&0===n.missing)return n},e}(iG),rt=/\/emsg[-/]ID3/i,re=function(){function t(t,e){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=e}var e=t.prototype;return e.resetTimeStamp=function t(){},e.resetInitSegment=function t(e,i,r,n){var a=this.videoTrack=i0("video",1),s=this.audioTrack=i0("audio",1),o=this.txtTrack=i0("text",1);if(this.id3Track=i0("id3",1),this.timeOffset=0,null!=e&&e.byteLength){var l=tM(e);if(l.video){var u=l.video,d=u.id,h=u.timescale,f=u.codec;a.id=d,a.timescale=o.timescale=h,a.codec=f}if(l.audio){var c=l.audio,$=c.id,g=c.timescale,v=c.codec;s.id=$,s.timescale=g,s.codec=v}o.id=tI.text,a.sampleDuration=0,a.duration=s.duration=n}},e.resetContiguity=function t(){this.remainderData=null},t.probe=function t(e){return function t(e){for(var i=e.byteLength,r=0;r<i;){var n=t8(e,r);if(n>8&&109===e[r+4]&&111===e[r+5]&&111===e[r+6]&&102===e[r+7])return!0;r=n>1?r+n:i}return!1}(e)},e.demux=function t(e,i){this.timeOffset=i;var r=e,n=this.videoTrack,a=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=t6(this.remainderData,e));var s=function t(e){var i={valid:null,remainder:null},r=tO(e,["moof"]);if(r.length<2)return i.remainder=e,i;var n=r[r.length-1];return i.valid=tc(e,0,n.byteOffset-8),i.remainder=tc(e,n.byteOffset-8),i}(r);this.remainderData=s.remainder,n.samples=s.valid||new Uint8Array}else n.samples=r;var o=this.extractID3Track(n,i);return a.samples=tK(i,n),{videoTrack:n,audioTrack:this.audioTrack,id3Track:o,textTrack:this.txtTrack}},e.flush=function t(){var e=this.timeOffset,i=this.videoTrack,r=this.txtTrack;i.samples=this.remainderData||new Uint8Array,this.remainderData=null;var n=this.extractID3Track(i,this.timeOffset);return r.samples=tK(e,i),{videoTrack:i,audioTrack:i0(),id3Track:n,textTrack:i0()}},e.extractID3Track=function t(e,i){var r=this.id3Track;if(e.samples.length){var n=tO(e.samples,["emsg"]);n&&n.forEach(function(t){var e=function t(e){var i=e[0],r="",n="",a=0,s=0,o=0,l=0,u=0,d=0;if(0===i){for(;"\0"!==tb(e.subarray(d,d+1));)r+=tb(e.subarray(d,d+1)),d+=1;for(r+=tb(e.subarray(d,d+1)),d+=1;"\0"!==tb(e.subarray(d,d+1));)n+=tb(e.subarray(d,d+1)),d+=1;n+=tb(e.subarray(d,d+1)),d+=1,a=t8(e,12),s=t8(e,16),l=t8(e,20),u=t8(e,24),d=28}else if(1===i){d+=4,a=t8(e,d);var h=t8(e,d+=4),f=t8(e,d+=4);for(d+=4,P(o=4294967296*h+f)||(o=Number.MAX_SAFE_INTEGER,H.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),l=t8(e,d),d+=4,u=t8(e,d),d+=4;"\0"!==tb(e.subarray(d,d+1));)r+=tb(e.subarray(d,d+1)),d+=1;for(r+=tb(e.subarray(d,d+1)),d+=1;"\0"!==tb(e.subarray(d,d+1));)n+=tb(e.subarray(d,d+1)),d+=1;n+=tb(e.subarray(d,d+1)),d+=1}var c=e.subarray(d,e.byteLength);return{schemeIdUri:r,value:n,timeScale:a,presentationTime:o,presentationTimeDelta:s,eventDuration:l,id:u,payload:c}}(t);if(rt.test(e.schemeIdUri)){var n=w(e.presentationTime)?e.presentationTime/e.timeScale:i+e.presentationTimeDelta/e.timeScale,a=4294967295===e.eventDuration?Number.POSITIVE_INFINITY:e.eventDuration/e.timeScale;a<=.001&&(a=Number.POSITIVE_INFINITY);var s=e.payload;r.samples.push({data:s,len:s.byteLength,dts:n,pts:n,type:ek.emsg,duration:a})}})}return r},e.demuxSampleAes=function t(e,i,r){return Promise.reject(Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},e.destroy=function t(){},t}(),ri=function t(e,i){var r=0,n=5;i+=n;for(var a=new Uint32Array(1),s=new Uint32Array(1),o=new Uint8Array(1);n>0;){o[0]=e[i];var l=Math.min(n,8),u=8-l;s[0]=4278190080>>>24+u<<u,a[0]=(o[0]&s[0])>>u,r=r?r<<l|a[0]:a[0],i+=1,n-=l}return r},rr=function(t){function e(e){var i;return(i=t.call(this)||this).observer=void 0,i.observer=e,i}u(e,t);var i=e.prototype;return i.resetInitSegment=function e(i,r,n,a){t.prototype.resetInitSegment.call(this,i,r,n,a),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:r,duration:a,inputTimeScale:9e4,dropped:0}},i.canParse=function t(e,i){return i+64<e.length},i.appendFrame=function t(e,i,r){var n=rn(e,i,r,this.basePTS,this.frameIndex);if(-1!==n)return{sample:e.samples[e.samples.length-1],length:n,missing:0}},e.probe=function t(e){if(!e)return!1;var i=tv(e,0);if(!i)return!1;var r=i.length;return!!(11===e[r]&&119===e[r+1]&&void 0!==tp(i)&&16>ri(e,r))},e}(iG);function rn(t,e,i,r,n){if(i+8>e.length||11!==e[i]||119!==e[i+1])return -1;var a=e[i+4]>>6;if(a>=3)return -1;var s=[48e3,44100,32e3][a],o=63&e[i+4],l=2*[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][3*o+a];if(i+l>e.length)return -1;var u=e[i+6]>>5,d=0;2===u?d+=2:(1&u&&1!==u&&(d+=2),4&u&&(d+=2));var h=(e[i+6]<<8|e[i+7])>>12-d&1,f=[2,1,2,3,3,4,4,5][u]+h,c=e[i+5]>>3,$=7&e[i+5],g=new Uint8Array([a<<6|c<<1|$>>2,(3&$)<<6|u<<3|h<<2|o>>4,o<<4&224]),v=e.subarray(i,i+l);return t.config=g,t.channelCount=f,t.samplerate=s,t.samples.push({unit:v,pts:r+n*(1536/s*9e4)}),l}var ra=function(){function t(){this.VideoSample=null}var e=t.prototype;return e.createVideoSample=function t(e,i,r,n){return{key:e,frame:!1,pts:i,dts:r,units:[],debug:n,length:0}},e.getLastNalUnit=function t(e){var i,r,n=this.VideoSample;if(n&&0!==n.units.length||(n=e[e.length-1]),null!=(i=n)&&i.units){var a=n.units;r=a[a.length-1]}return r},e.pushAccessUnit=function t(e,i){if(e.units.length&&e.frame){if(void 0===e.pts){var r=i.samples,n=r.length;if(n){var a=r[n-1];e.pts=a.pts,e.dts=a.dts}else{i.dropped++;return}}i.samples.push(e)}e.debug.length&&H.log(e.pts+"/"+e.dts+":"+e.debug)},t}(),rs=function(){function t(t){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=t,this.bytesAvailable=t.byteLength,this.word=0,this.bitsAvailable=0}var e=t.prototype;return e.loadWord=function t(){var e=this.data,i=this.bytesAvailable,r=e.byteLength-i,n=new Uint8Array(4),a=Math.min(4,i);if(0===a)throw Error("no bytes available");n.set(e.subarray(r,r+a)),this.word=new DataView(n.buffer).getUint32(0),this.bitsAvailable=8*a,this.bytesAvailable-=a},e.skipBits=function t(e){var i;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,i=e>>3,e-=i<<3,this.bytesAvailable-=i,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)},e.readBits=function t(e){var i=Math.min(this.bitsAvailable,e),r=this.word>>>32-i;if(e>32&&H.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=i,this.bitsAvailable>0)this.word<<=i;else if(this.bytesAvailable>0)this.loadWord();else throw Error("no bits available");return(i=e-i)>0&&this.bitsAvailable?r<<i|this.readBits(i):r},e.skipLZ=function t(){var e;for(e=0;e<this.bitsAvailable;++e)if((this.word&2147483648>>>e)!=0)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()},e.skipUEG=function t(){this.skipBits(1+this.skipLZ())},e.skipEG=function t(){this.skipBits(1+this.skipLZ())},e.readUEG=function t(){var e=this.skipLZ();return this.readBits(e+1)-1},e.readEG=function t(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},e.readBoolean=function t(){return 1===this.readBits(1)},e.readUByte=function t(){return this.readBits(8)},e.readUShort=function t(){return this.readBits(16)},e.readUInt=function t(){return this.readBits(32)},e.skipScalingList=function t(e){for(var i,r=8,n=8,a=0;a<e;a++)0!==n&&(n=(r+(i=this.readEG())+256)%256),r=0===n?r:n},e.readSPS=function t(){var e,i,r,n=0,a=0,s=0,o=0,l=this.readUByte.bind(this),u=this.readBits.bind(this),d=this.readUEG.bind(this),h=this.readBoolean.bind(this),f=this.skipBits.bind(this),c=this.skipEG.bind(this),$=this.skipUEG.bind(this),g=this.skipScalingList.bind(this);l();var v=l();if(u(5),f(3),l(),$(),100===v||110===v||122===v||244===v||44===v||83===v||86===v||118===v||128===v){var m=d();if(3===m&&f(1),$(),$(),f(1),h())for(r=0,i=3!==m?8:12;r<i;r++)h()&&g(r<6?16:64)}$();var p=d();if(0===p)d();else if(1===p)for(f(1),c(),c(),e=d(),r=0;r<e;r++)c();$(),f(1);var y=d(),T=d(),x=u(1);0===x&&f(1),f(1),h()&&(n=d(),a=d(),s=d(),o=d());var E=[1,1];if(h()&&h()){var S=l();switch(S){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=[l()<<8|l(),l()<<8|l()]}}return{width:Math.ceil((y+1)*16-2*n-2*a),height:(2-x)*(T+1)*16-(x?2:4)*(s+o),pixelRatio:E}},e.readSliceType=function t(){return this.readUByte(),this.readUEG(),this.readUEG()},t}(),ro=function(t){function e(){return t.apply(this,arguments)||this}u(e,t);var i=e.prototype;return i.parseAVCPES=function t(e,i,r,n,a){var s,o=this,l=this.parseAVCNALu(e,r.data),u=this.VideoSample,d=!1;r.data=null,u&&l.length&&!e.audFound&&(this.pushAccessUnit(u,e),u=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts,"")),l.forEach(function(t){switch(t.type){case 1:var n,l,h=!1;s=!0;var f=t.data;if(d&&f.length>4){var c=new rs(f).readSliceType();(2===c||4===c||7===c||9===c)&&(h=!0)}h&&null!=(l=u)&&l.frame&&!u.key&&(o.pushAccessUnit(u,e),u=o.VideoSample=null),u||(u=o.VideoSample=o.createVideoSample(!0,r.pts,r.dts,"")),u.frame=!0,u.key=h;break;case 5:s=!0,null!=(n=u)&&n.frame&&!u.key&&(o.pushAccessUnit(u,e),u=o.VideoSample=null),u||(u=o.VideoSample=o.createVideoSample(!0,r.pts,r.dts,"")),u.key=!0,u.frame=!0;break;case 6:s=!0,t3(t.data,1,r.pts,i.samples);break;case 7:s=!0,d=!0;var $,g,v=t.data,m=new rs(v).readSPS();if(!e.sps||e.width!==m.width||e.height!==m.height||(null==($=e.pixelRatio)?void 0:$[0])!==m.pixelRatio[0]||(null==(g=e.pixelRatio)?void 0:g[1])!==m.pixelRatio[1]){e.width=m.width,e.height=m.height,e.pixelRatio=m.pixelRatio,e.sps=[v],e.duration=a;for(var p=v.subarray(1,4),y="avc1.",T=0;T<3;T++){var x=p[T].toString(16);x.length<2&&(x="0"+x),y+=x}e.codec=y}break;case 8:s=!0,e.pps=[t.data];break;case 9:s=!0,e.audFound=!0,u&&o.pushAccessUnit(u,e),u=o.VideoSample=o.createVideoSample(!1,r.pts,r.dts,"");break;case 12:s=!0;break;default:s=!1,u&&(u.debug+="unknown NAL "+t.type+" ")}u&&s&&u.units.push(t)}),n&&u&&(this.pushAccessUnit(u,e),this.VideoSample=null)},i.parseAVCNALu=function t(e,i){var r,n,a,s=i.byteLength,o=e.naluState||0,l=o,u=[],d=0,h=-1,f=0;for(-1===o&&(h=0,f=31&i[0],o=0,d=1);d<s;){if(r=i[d++],!o){o=r?0:1;continue}if(1===o){o=r?0:2;continue}if(r){if(1===r){if(n=d-o-1,h>=0){var c={data:i.subarray(h,n),type:f};u.push(c)}else{var $=this.getLastNalUnit(e.samples);$&&(l&&d<=4-l&&$.state&&($.data=$.data.subarray(0,$.data.byteLength-l)),n>0&&($.data=t6($.data,i.subarray(0,n)),$.state=0))}d<s?(a=31&i[d],h=d,f=a,o=0):o=-1}else o=0}else o=3}if(h>=0&&o>=0){var g={data:i.subarray(h,s),type:f,state:o};u.push(g)}if(0===u.length){var v=this.getLastNalUnit(e.samples);v&&(v.data=t6(v.data,i))}return e.naluState=o,u},e}(ra),rl=function(){function t(t,e,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new iO(e,{removePKCS7Padding:!1})}var e=t.prototype;return e.decryptBuffer=function t(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)},e.decryptAacSample=function t(e,i,r){var n=this,a=e[i].unit;if(!(a.length<=16)){var s=a.subarray(16,a.length-a.length%16),o=s.buffer.slice(s.byteOffset,s.byteOffset+s.length);this.decryptBuffer(o).then(function(t){var s=new Uint8Array(t);a.set(s,16),n.decrypter.isSync()||n.decryptAacSamples(e,i+1,r)})}},e.decryptAacSamples=function t(e,i,r){for(;;i++){if(i>=e.length){r();return}if(!(e[i].unit.length<32)&&(this.decryptAacSample(e,i,r),!this.decrypter.isSync()))return}},e.getAvcEncryptedData=function t(e){for(var i=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(i),n=0,a=32;a<e.length-16;a+=160,n+=16)r.set(e.subarray(a,a+16),n);return r},e.getAvcDecryptedUnit=function t(e,i){for(var r=new Uint8Array(i),n=0,a=32;a<e.length-16;a+=160,n+=16)e.set(r.subarray(n,n+16),a);return e},e.decryptAvcSample=function t(e,i,r,n,a){var s=this,o=tH(a.data),l=this.getAvcEncryptedData(o);this.decryptBuffer(l.buffer).then(function(t){a.data=s.getAvcDecryptedUnit(o,t),s.decrypter.isSync()||s.decryptAvcSamples(e,i,r+1,n)})},e.decryptAvcSamples=function t(e,i,r,n){if(e instanceof Uint8Array)throw Error("Cannot decrypt samples of type Uint8Array");for(;;i++,r=0){if(i>=e.length){n();return}for(var a=e[i].units;!(r>=a.length);r++){var s=a[r];if(!(s.data.length<=48)&&(1===s.type||5===s.type)&&(this.decryptAvcSample(e,i,r,n,s),!this.decrypter.isSync()))return}}},t}(),ru=function(){function t(t,e,i){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=t,this.config=e,this.typeSupported=i,this.videoParser=new ro}t.probe=function e(i){var r=t.syncOffset(i);return r>0&&H.warn("MPEG2-TS detected but first sync word found @ offset "+r),-1!==r},t.syncOffset=function t(e){for(var i=e.length,r=Math.min(940,i-188)+1,n=0;n<r;){for(var a=!1,s=-1,o=0,l=n;l<i;l+=188)if(71===e[l]&&(i-l==188||71===e[l+188])){if(o++,-1===s&&0!==(s=l)&&(r=Math.min(s+18612,e.length-188)+1),a||(a=0===rd(e,l)),a&&o>1&&(0===s&&o>2||l+188>r))return s}else if(o)return -1;else break;n++}return -1},t.createTrack=function t(e,i){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:tI[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?i:void 0}};var e=t.prototype;return e.resetInitSegment=function e(i,r,n,a){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=t.createTrack("video"),this._audioTrack=t.createTrack("audio",a),this._id3Track=t.createTrack("id3"),this._txtTrack=t.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=r,this.videoCodec=n,this._duration=a},e.resetTimeStamp=function t(){},e.resetContiguity=function t(){var e=this._audioTrack,i=this._videoTrack,r=this._id3Track;e&&(e.pesData=null),i&&(i.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.remainderData=null},e.demux=function e(i,r,n,a){void 0===n&&(n=!1),void 0===a&&(a=!1),n||(this.sampleAes=null);var s,o=this._videoTrack,l=this._audioTrack,u=this._id3Track,d=this._txtTrack,h=o.pid,f=o.pesData,c=l.pid,$=u.pid,g=l.pesData,v=u.pesData,m=null,p=this.pmtParsed,y=this._pmtId,T=i.length;if(this.remainderData&&(T=(i=t6(this.remainderData,i)).length,this.remainderData=null),T<188&&!a)return this.remainderData=i,{audioTrack:l,videoTrack:o,id3Track:u,textTrack:d};var x=Math.max(0,t.syncOffset(i));(T-=(T-x)%188)<i.byteLength&&!a&&(this.remainderData=new Uint8Array(i.buffer,T,i.buffer.byteLength-T));for(var E=0,S=x;S<T;S+=188)if(71===i[S]){var L=!!(64&i[S+1]),A=rd(i,S),R=(48&i[S+3])>>4,_=void 0;if(R>1){if((_=S+5+i[S+4])===S+188)continue}else _=S+4;switch(A){case h:L&&(f&&(s=rg(f))&&this.videoParser.parseAVCPES(o,d,s,!1,this._duration),f={data:[],size:0}),f&&(f.data.push(i.subarray(_,S+188)),f.size+=S+188-_);break;case c:if(L){if(g&&(s=rg(g)))switch(l.segmentCodec){case"aac":this.parseAACPES(l,s);break;case"mp3":this.parseMPEGPES(l,s);break;case"ac3":this.parseAC3PES(l,s)}g={data:[],size:0}}g&&(g.data.push(i.subarray(_,S+188)),g.size+=S+188-_);break;case $:L&&(v&&(s=rg(v))&&this.parseID3PES(u,s),v={data:[],size:0}),v&&(v.data.push(i.subarray(_,S+188)),v.size+=S+188-_);break;case 0:L&&(_+=i[_]+1),y=this._pmtId=rh(i,_);break;case y:L&&(_+=i[_]+1);var D=rf(i,_,this.typeSupported,n,this.observer);(h=D.videoPid)>0&&(o.pid=h,o.segmentCodec=D.segmentVideoCodec),(c=D.audioPid)>0&&(l.pid=c,l.segmentCodec=D.segmentAudioCodec),($=D.id3Pid)>0&&(u.pid=$),null===m||p||(H.warn("MPEG-TS PMT found at "+S+" after unknown PID '"+m+"'. Backtracking to sync byte @"+x+" to parse all TS packets."),m=null,S=x-188),p=this.pmtParsed=!0;break;case 17:case 8191:break;default:m=A}}else E++;E>0&&rc(this.observer,Error("Found "+E+" TS packet/s that do not start with 0x47")),o.pesData=f,l.pesData=g,u.pesData=v;var k={audioTrack:l,videoTrack:o,id3Track:u,textTrack:d};return a&&this.extractRemainingSamples(k),k},e.flush=function t(){var e,i=this.remainderData;return(this.remainderData=null,e=i?this.demux(i,-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},e.extractRemainingSamples=function t(e){var i,r=e.audioTrack,n=e.videoTrack,a=e.id3Track,s=e.textTrack,o=n.pesData,l=r.pesData,u=a.pesData;if(o&&(i=rg(o))?(this.videoParser.parseAVCPES(n,s,i,!0,this._duration),n.pesData=null):n.pesData=o,l&&(i=rg(l))){switch(r.segmentCodec){case"aac":this.parseAACPES(r,i);break;case"mp3":this.parseMPEGPES(r,i);break;case"ac3":this.parseAC3PES(r,i)}r.pesData=null}else null!=l&&l.size&&H.log("last AAC PES packet truncated,might overlap between fragments"),r.pesData=l;u&&(i=rg(u))?(this.parseID3PES(a,i),a.pesData=null):a.pesData=u},e.demuxSampleAes=function t(e,i,r){var n=this.demux(e,r,!0,!this.config.progressive),a=this.sampleAes=new rl(this.observer,this.config,i);return this.decrypt(n,a)},e.decrypt=function t(e,i){return new Promise(function(t){var r=e.audioTrack,n=e.videoTrack;r.samples&&"aac"===r.segmentCodec?i.decryptAacSamples(r.samples,0,function(){n.samples?i.decryptAvcSamples(n.samples,0,0,function(){t(e)}):t(e)}):n.samples&&i.decryptAvcSamples(n.samples,0,0,function(){t(e)})})},e.destroy=function t(){this._duration=0},e.parseAACPES=function t(e,i){var r,n,a=0,s=this.aacOverFlow,o=i.data;if(s){this.aacOverFlow=null;var l=s.missing,u=s.sample.unit.byteLength;-1===l?o=t6(s.sample.unit,o):(s.sample.unit.set(o.subarray(0,l),u-l),e.samples.push(s.sample),a=s.missing)}for(d=a,h=o.length;d<h-1&&!i4(o,d);d++);if(d!==a){var d,h,f,c=d<h-1;if(f=c?"AAC PES did not start with ADTS header,offset:"+d:"No ADTS header found in AAC PES",rc(this.observer,Error(f),c),!c)return}if(iH(e,this.observer,o,d,this.audioCodec),void 0!==i.pts)r=i.pts;else if(s){var $=iV(e.samplerate);r=s.sample.pts+$}else{H.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var g=0;d<h;){if(n=i7(e,o,d,r,g),d+=n.length,n.missing){this.aacOverFlow=n;break}for(g++;d<h-1&&!i4(o,d);d++);}},e.parseMPEGPES=function t(e,i){var r=i.data,n=r.length,a=0,s=0,o=i.pts;if(void 0===o){H.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;s<n;)if(i9(r,s)){var l=iz(e,r,s,o,a);if(l)s+=l.length,a++;else break}else s++},e.parseAC3PES=function t(e,i){var r,n=i.data,a=i.pts;if(void 0===a){H.warn("[tsdemuxer]: AC3 PES unknown PTS");return}for(var s=n.length,o=0,l=0;l<s&&(r=rn(e,n,l,a,o++))>0;)l+=r},e.parseID3PES=function t(e,i){if(void 0===i.pts){H.warn("[tsdemuxer]: ID3 PES unknown PTS");return}var r=l({},i,{type:this._videoTrack?ek.emsg:ek.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(r)},t}();function rd(t,e){return((31&t[e+1])<<8)+t[e+2]}function rh(t,e){return(31&t[e+10])<<8|t[e+11]}function rf(t,e,i,r,n){var a={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},s=(15&t[e+1])<<8|t[e+2],o=e+3+s-4,l=(15&t[e+10])<<8|t[e+11];for(e+=12+l;e<o;){var u=rd(t,e),d=(15&t[e+3])<<8|t[e+4];switch(t[e]){case 207:if(!r){r$("ADTS AAC");break}case 15:-1===a.audioPid&&(a.audioPid=u);break;case 21:-1===a.id3Pid&&(a.id3Pid=u);break;case 219:if(!r){r$("H.264");break}case 27:-1===a.videoPid&&(a.videoPid=u,a.segmentVideoCodec="avc");break;case 3:case 4:i.mpeg||i.mp3?-1===a.audioPid&&(a.audioPid=u,a.segmentAudioCodec="mp3"):H.log("MPEG audio found, not supported in this browser");break;case 193:if(!r){r$("AC-3");break}case 129:i.ac3?-1===a.audioPid&&(a.audioPid=u,a.segmentAudioCodec="ac3"):H.log("AC-3 audio found, not supported in this browser");break;case 6:if(-1===a.audioPid&&d>0)for(var h=e+5,f=d;f>2;){106===t[h]&&(!0!==i.ac3?H.log("AC-3 audio found, not supported in this browser for now"):(a.audioPid=u,a.segmentAudioCodec="ac3"));var c=t[h+1]+2;h+=c,f-=c}break;case 194:case 135:return rc(n,Error("Unsupported EC-3 in M2TS found")),a;case 36:return rc(n,Error("Unsupported HEVC in M2TS found")),a}e+=d+5}return a}function rc(t,e,i){H.warn("parsing error: "+e.message),t.emit(O.ERROR,O.ERROR,{type:N.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,fatal:!1,levelRetry:i,error:e,reason:e.message})}function r$(t){H.log(t+" with AES-128-CBC encryption found in unencrypted stream")}function rg(t){var e,i,r,n,a,s=0,o=t.data;if(!t||0===t.size)return null;for(;o[0].length<19&&o.length>1;)o[0]=t6(o[0],o[1]),o.splice(1,1);if(1===((e=o[0])[0]<<16)+(e[1]<<8)+e[2]){if((i=(e[4]<<8)+e[5])&&i>t.size-6)return null;var l=e[7];192&l&&(n=(14&e[9])*536870912+(255&e[10])*4194304+(254&e[11])*16384+(255&e[12])*128+(254&e[13])/2,64&l?n-(a=(14&e[14])*536870912+(255&e[15])*4194304+(254&e[16])*16384+(255&e[17])*128+(254&e[18])/2)>54e5&&(H.warn(Math.round((n-a)/9e4)+"s delta between PTS and DTS, align them"),n=a):a=n);var u=(r=e[8])+9;if(t.size<=u)return null;t.size-=u;for(var d=new Uint8Array(t.size),h=0,f=o.length;h<f;h++){var c=(e=o[h]).byteLength;if(u){if(u>c){u-=c;continue}e=e.subarray(u),c-=u,u=0}d.set(e,s),s+=c}return i&&(i-=r+3),{data:d,pts:n,dts:a,len:i}}return null}var rv=function(t){function e(){return t.apply(this,arguments)||this}u(e,t);var i=e.prototype;return i.resetInitSegment=function e(i,r,n,a){t.prototype.resetInitSegment.call(this,i,r,n,a),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:r,duration:a,inputTimeScale:9e4,dropped:0}},e.probe=function t(e){if(!e)return!1;var i=tv(e,0),r=(null==i?void 0:i.length)||0;if(i&&11===e[r]&&119===e[r+1]&&void 0!==tp(i)&&16>=ri(e,r))return!1;for(var n=e.length;r<n;r++)if(iZ(e,r))return H.log("MPEG Audio sync word found !"),!0;return!1},i.canParse=function t(e,i){var r,n;return r=e,iQ(r,n=i)&&4<=r.length-n},i.appendFrame=function t(e,i,r){if(null!==this.basePTS)return iz(e,i,r,this.basePTS,this.frameIndex)},e}(iG),rm=function(){function t(){}return t.getSilentFrame=function t(e,i){if("mp4a.40.2"===e){if(1===i)return new Uint8Array([0,200,0,128,35,128]);if(2===i)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===i)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);else if(4===i)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);else if(5===i)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);else if(6===i)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===i)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===i)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===i)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}},t}(),rp=function(){function t(){}return t.init=function e(){for(i in t.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:[]},t.types)t.types.hasOwnProperty(i)&&(t.types[i]=[i.charCodeAt(0),i.charCodeAt(1),i.charCodeAt(2),i.charCodeAt(3)]);var i,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]),n=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);t.HDLR_TYPES={video:r,audio:n};var a=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),s=new Uint8Array([0,0,0,0,0,0,0,0]);t.STTS=t.STSC=t.STCO=s,t.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),t.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),t.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),t.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var o=new Uint8Array([105,115,111,109]),l=new Uint8Array([97,118,99,49]),u=new Uint8Array([0,0,0,1]);t.FTYP=t.box(t.types.ftyp,o,u,o,l),t.DINF=t.box(t.types.dinf,t.box(t.types.dref,a))},t.box=function t(e){for(var i=8,r=arguments.length,n=Array(r>1?r-1:0),a=1;a<r;a++)n[a-1]=arguments[a];for(var s=n.length,o=s;s--;)i+=n[s].byteLength;var l=new Uint8Array(i);for(l[0]=i>>24&255,l[1]=i>>16&255,l[2]=i>>8&255,l[3]=255&i,l.set(e,4),s=0,i=8;s<o;s++)l.set(n[s],i),i+=n[s].byteLength;return l},t.hdlr=function e(i){return t.box(t.types.hdlr,t.HDLR_TYPES[i])},t.mdat=function e(i){return t.box(t.types.mdat,i)},t.mdhd=function e(i,r){var n=Math.floor((r*=i)/4294967296),a=Math.floor(r%4294967296);return t.box(t.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,i>>24&255,i>>16&255,i>>8&255,255&i,n>>24,n>>16&255,n>>8&255,255&n,a>>24,a>>16&255,a>>8&255,255&a,85,196,0,0]))},t.mdia=function e(i){return t.box(t.types.mdia,t.mdhd(i.timescale,i.duration),t.hdlr(i.type),t.minf(i))},t.mfhd=function e(i){return t.box(t.types.mfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i]))},t.minf=function e(i){return"audio"===i.type?t.box(t.types.minf,t.box(t.types.smhd,t.SMHD),t.DINF,t.stbl(i)):t.box(t.types.minf,t.box(t.types.vmhd,t.VMHD),t.DINF,t.stbl(i))},t.moof=function e(i,r,n){return t.box(t.types.moof,t.mfhd(i),t.traf(n,r))},t.moov=function e(i){for(var r=i.length,n=[];r--;)n[r]=t.trak(i[r]);return t.box.apply(null,[t.types.moov,t.mvhd(i[0].timescale,i[0].duration)].concat(n).concat(t.mvex(i)))},t.mvex=function e(i){for(var r=i.length,n=[];r--;)n[r]=t.trex(i[r]);return t.box.apply(null,[t.types.mvex].concat(n))},t.mvhd=function e(i,r){var n=Math.floor((r*=i)/4294967296),a=Math.floor(r%4294967296),s=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,i>>24&255,i>>16&255,i>>8&255,255&i,n>>24,n>>16&255,n>>8&255,255&n,a>>24,a>>16&255,a>>8&255,255&a,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return t.box(t.types.mvhd,s)},t.sdtp=function e(i){var r,n,a=i.samples||[],s=new Uint8Array(4+a.length);for(r=0;r<a.length;r++)n=a[r].flags,s[r+4]=n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy;return t.box(t.types.sdtp,s)},t.stbl=function e(i){return t.box(t.types.stbl,t.stsd(i),t.box(t.types.stts,t.STTS),t.box(t.types.stsc,t.STSC),t.box(t.types.stsz,t.STSZ),t.box(t.types.stco,t.STCO))},t.avc1=function e(i){var r,n,a,s=[],o=[];for(r=0;r<i.sps.length;r++)a=(n=i.sps[r]).byteLength,s.push(a>>>8&255),s.push(255&a),s=s.concat(Array.prototype.slice.call(n));for(r=0;r<i.pps.length;r++)a=(n=i.pps[r]).byteLength,o.push(a>>>8&255),o.push(255&a),o=o.concat(Array.prototype.slice.call(n));var l=t.box(t.types.avcC,new Uint8Array([1,s[3],s[4],s[5],255,224|i.sps.length].concat(s).concat([i.pps.length]).concat(o))),u=i.width,d=i.height,h=i.pixelRatio[0],f=i.pixelRatio[1];return t.box(t.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,u>>8&255,255&u,d>>8&255,255&d,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),l,t.box(t.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),t.box(t.types.pasp,new Uint8Array([h>>24,h>>16&255,h>>8&255,255&h,f>>24,f>>16&255,f>>8&255,255&f])))},t.esds=function t(e){var i=e.config.length;return new Uint8Array([0,0,0,0,3,23+i,0,1,0,4,15+i,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([i]).concat(e.config).concat([6,1,2]))},t.audioStsd=function t(e){var i=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,i>>8&255,255&i,0,0])},t.mp4a=function e(i){return t.box(t.types.mp4a,t.audioStsd(i),t.box(t.types.esds,t.esds(i)))},t.mp3=function e(i){return t.box(t.types[".mp3"],t.audioStsd(i))},t.ac3=function e(i){return t.box(t.types["ac-3"],t.audioStsd(i),t.box(t.types.dac3,i.config))},t.stsd=function e(i){return"audio"!==i.type?t.box(t.types.stsd,t.STSD,t.avc1(i)):"mp3"===i.segmentCodec&&"mp3"===i.codec?t.box(t.types.stsd,t.STSD,t.mp3(i)):"ac3"===i.segmentCodec?t.box(t.types.stsd,t.STSD,t.ac3(i)):t.box(t.types.stsd,t.STSD,t.mp4a(i))},t.tkhd=function e(i){var r=i.id,n=i.duration*i.timescale,a=i.width,s=i.height,o=Math.floor(n/4294967296),l=Math.floor(n%4294967296);return t.box(t.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,o>>24,o>>16&255,o>>8&255,255&o,l>>24,l>>16&255,l>>8&255,255&l,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,a>>8&255,255&a,0,0,s>>8&255,255&s,0,0]))},t.traf=function e(i,r){var n=t.sdtp(i),a=i.id,s=Math.floor(r/4294967296),o=Math.floor(r%4294967296);return t.box(t.types.traf,t.box(t.types.tfhd,new Uint8Array([0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a])),t.box(t.types.tfdt,new Uint8Array([1,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,o>>24,o>>16&255,o>>8&255,255&o])),t.trun(i,n.length+16+20+8+16+8+8),n)},t.trak=function e(i){return i.duration=i.duration||4294967295,t.box(t.types.trak,t.tkhd(i),t.mdia(i))},t.trex=function e(i){var r=i.id;return t.box(t.types.trex,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},t.trun=function e(i,r){var n,a,s,o,l,u,d=i.samples||[],h=d.length,f=12+16*h,c=new Uint8Array(f);for(r+=8+f,c.set(["video"===i.type?1:0,0,15,1,h>>>24&255,h>>>16&255,h>>>8&255,255&h,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0),n=0;n<h;n++)s=(a=d[n]).duration,o=a.size,l=a.flags,u=a.cts,c.set([s>>>24&255,s>>>16&255,s>>>8&255,255&s,o>>>24&255,o>>>16&255,o>>>8&255,255&o,l.isLeading<<2|l.dependsOn,l.isDependedOn<<6|l.hasRedundancy<<4|l.paddingValue<<1|l.isNonSync,61440&l.degradPrio,15&l.degradPrio,u>>>24&255,u>>>16&255,u>>>8&255,255&u],12+16*n);return t.box(t.types.trun,c)},t.initSegment=function e(i){t.types||t.init();var r=t.moov(i);return t6(t.FTYP,r)},t}();function ry(t,e,i,r){void 0===i&&(i=1),void 0===r&&(r=!1);var n=t*e*i;return r?Math.round(n):n}function rT(t,e){return void 0===e&&(e=!1),ry(t,1e3,11111111111111112e-21,e)}rp.types=void 0,rp.HDLR_TYPES=void 0,rp.STTS=void 0,rp.STSC=void 0,rp.STCO=void 0,rp.STSZ=void 0,rp.VMHD=void 0,rp.SMHD=void 0,rp.STSD=void 0,rp.FTYP=void 0,rp.DINF=void 0;var rx=null,rE=null,rS=function(){function t(t,e,i,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=t,this.config=e,this.typeSupported=i,this.ISGenerated=!1,null===rx){var n=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);rx=n?parseInt(n[1]):0}if(null===rE){var a=navigator.userAgent.match(/Safari\/(\d+)/i);rE=a?parseInt(a[1]):0}}var e=t.prototype;return e.destroy=function t(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null},e.resetTimeStamp=function t(e){H.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e},e.resetNextTimestamp=function t(){H.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},e.resetInitSegment=function t(){H.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0},e.getVideoStartPts=function t(e){var i=!1,r=e.reduce(function(t,e){var r=e.pts-t;return r<-4294967296?(i=!0,rL(t,e.pts)):r>0?t:e.pts},e[0].pts);return i&&H.debug("PTS rollover detected"),r},e.remux=function t(e,i,r,n,a,s,o,l){var u=a,d=a,h=e.pid>-1,f=i.pid>-1,c=i.samples.length,$=e.samples.length>0,g=o&&c>0||c>1;if((!h||$)&&(!f||g)||this.ISGenerated||o){if(this.ISGenerated){var v,m,p,y,T,x,E,S,L,A,R,_=this.videoTrackConfig;_&&(i.width!==_.width||i.height!==_.height||(null==(S=i.pixelRatio)?void 0:S[0])!==(null==(L=_.pixelRatio)?void 0:L[0])||(null==(A=i.pixelRatio)?void 0:A[1])!==(null==(R=_.pixelRatio)?void 0:R[1]))&&this.resetInitSegment()}else p=this.generateIS(e,i,a,s);var D=this.isVideoContiguous,k=-1;if(g&&(k=function t(e){for(var i=0;i<e.length;i++)if(e[i].key)return i;return -1}(i.samples),!D&&this.config.forceKeyFrameOnDiscontinuity)){if(x=!0,k>0){H.warn("[mp4-remuxer]: Dropped "+k+" out of "+c+" video samples due to a missing keyframe");var I=this.getVideoStartPts(i.samples);i.samples=i.samples.slice(k),i.dropped+=k,d+=(i.samples[0].pts-I)/i.inputTimeScale,E=d}else -1===k&&(H.warn("[mp4-remuxer]: No keyframe found out of "+c+" video samples"),x=!1)}if(this.ISGenerated){if($&&g){var b=this.getVideoStartPts(i.samples),C=(rL(e.samples[0].pts,b)-b)/i.inputTimeScale;u+=Math.max(0,C),d+=Math.max(0,-C)}if($){if(e.samplerate||(H.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),p=this.generateIS(e,i,a,s)),m=this.remuxAudio(e,u,this.isAudioContiguous,s,f||g||l===eT.AUDIO?d:void 0),g){var w=m?m.endPTS-m.startPTS:0;i.inputTimeScale||(H.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),p=this.generateIS(e,i,a,s)),v=this.remuxVideo(i,d,D,w)}}else g&&(v=this.remuxVideo(i,d,D,0));v&&(v.firstKeyFrame=k,v.independent=-1!==k,v.firstKeyFramePTS=E)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(T=rA(r,a,this._initPTS,this._initDTS)),n.samples.length&&(y=rR(n,a,this._initPTS))),{audio:m,video:v,initSegment:p,independent:x,text:y,id3:T}},e.generateIS=function t(e,i,r,n){var a,s,o,l=e.samples,u=i.samples,d=this.typeSupported,h={},f=this._initPTS,c=!f||n,$="audio/mp4";if(c&&(a=s=1/0),e.config&&l.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":d.mpeg?($="audio/mpeg",e.codec=""):d.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3"}h.audio={id:"audio",container:$,codec:e.codec,initSegment:"mp3"===e.segmentCodec&&d.mpeg?new Uint8Array(0):rp.initSegment([e]),metadata:{channelCount:e.channelCount}},c&&(o=e.inputTimeScale,f&&o===f.timescale?c=!1:a=s=l[0].pts-Math.round(o*r))}if(i.sps&&i.pps&&u.length){if(i.timescale=i.inputTimeScale,h.video={id:"main",container:"video/mp4",codec:i.codec,initSegment:rp.initSegment([i]),metadata:{width:i.width,height:i.height}},c){if(o=i.inputTimeScale,f&&o===f.timescale)c=!1;else{var g=this.getVideoStartPts(u),v=Math.round(o*r);s=Math.min(s,rL(u[0].dts,g)-v),a=Math.min(a,g-v)}}this.videoTrackConfig={width:i.width,height:i.height,pixelRatio:i.pixelRatio}}if(Object.keys(h).length)return this.ISGenerated=!0,c?(this._initPTS={baseTime:a,timescale:o},this._initDTS={baseTime:s,timescale:o}):a=o=void 0,{tracks:h,initPTS:a,timescale:o}},e.remuxVideo=function t(e,i,r,n){var a,s,o,u=e.inputTimeScale,d=e.samples,h=[],f=d.length,c=this._initPTS,$=this.nextAvcDts,g=8,v=this.videoSampleDuration,m=Number.POSITIVE_INFINITY,p=Number.NEGATIVE_INFINITY,y=!1;if(!r||null===$){var T=i*u,x=d[0].pts-rL(d[0].dts,d[0].pts);rx&&null!==$&&15e3>Math.abs(T-x-$)?r=!0:$=T-x}for(var E=c.baseTime*u/c.timescale,S=0;S<f;S++){var L=d[S];L.pts=rL(L.pts-E,$),L.dts=rL(L.dts-E,$),L.dts<d[S>0?S-1:S].dts&&(y=!0)}y&&d.sort(function(t,e){var i=t.dts-e.dts,r=t.pts-e.pts;return i||r}),a=d[0].dts;var A=(s=d[d.length-1].dts)-a,R=A?Math.round(A/(f-1)):v||e.inputTimeScale/30;if(r){var _=a-$,D=_>R,k=_<-1;if((D||k)&&(D?H.warn("AVC: "+rT(_,!0)+" ms ("+_+"dts) hole between fragments detected at "+i.toFixed(3)):H.warn("AVC: "+rT(-_,!0)+" ms ("+_+"dts) overlapping between fragments detected at "+i.toFixed(3)),!k||$>=d[0].pts||rx)){a=$;var I=d[0].pts-_;if(D)d[0].dts=a,d[0].pts=I;else for(var b=0;b<d.length&&!(d[b].dts>I);b++)d[b].dts-=_,d[b].pts-=_;H.log("Video: Initial PTS/DTS adjusted: "+rT(I,!0)+"/"+rT(a,!0)+", delta: "+rT(_,!0)+" ms")}}for(var C=0,w=0,P=a=Math.max(0,a),F=0;F<f;F++){for(var B=d[F],U=B.units,G=U.length,K=0,V=0;V<G;V++)K+=U[V].data.length;w+=K,C+=G,B.length=K,B.dts<P?(B.dts=P,P+=R/4|0||1):P=B.dts,m=Math.min(B.pts,m),p=Math.max(B.pts,p)}s=d[f-1].dts;var Y=w+4*C+8;try{o=new Uint8Array(Y)}catch(W){this.observer.emit(O.ERROR,O.ERROR,{type:N.MUX_ERROR,details:M.REMUX_ALLOC_ERROR,fatal:!1,error:W,bytes:Y,reason:"fail allocating video mdat "+Y});return}var q=new DataView(o.buffer);q.setUint32(0,Y),o.set(rp.types.mdat,4);for(var X=!1,z=Number.POSITIVE_INFINITY,j=Number.POSITIVE_INFINITY,Q=Number.NEGATIVE_INFINITY,Z=Number.NEGATIVE_INFINITY,J=0;J<f;J++){for(var tt=d[J],te=tt.units,ti=0,tr=0,tn=te.length;tr<tn;tr++){var ta=te[tr],ts=ta.data,to=ta.data.byteLength;q.setUint32(g,to),g+=4,o.set(ts,g),g+=to,ti+=4+to}var tl=void 0;if(J<f-1)v=d[J+1].dts-tt.dts,tl=d[J+1].pts-tt.pts;else{var tu=this.config,td=J>0?tt.dts-d[J-1].dts:R;if(tl=J>0?tt.pts-d[J-1].pts:R,tu.stretchShortVideoTrack&&null!==this.nextAudioPts){var th=Math.floor(tu.maxBufferHole*u),tf=(n?m+n*u:this.nextAudioPts)-tt.pts;tf>th?((v=tf-td)<0?v=td:X=!0,H.log("[mp4-remuxer]: It is approximately "+tf/90+" ms to the next segment; using duration "+v/90+" ms for the last video frame.")):v=td}else v=td}var tc=Math.round(tt.pts-tt.dts);z=Math.min(z,v),Q=Math.max(Q,v),j=Math.min(j,tl),Z=Math.max(Z,tl),h.push(new r_(tt.key,v,ti,tc))}if(h.length){if(rx){if(rx<70){var t$=h[0].flags;t$.dependsOn=2,t$.isNonSync=0}}else if(rE&&Z-j<Q-z&&R/Q<.025&&0===h[0].cts){H.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var tg=a,tv=0,tm=h.length;tv<tm;tv++){var tp=tg+h[tv].duration,ty=tg+h[tv].cts;if(tv<tm-1){var tT=tp+h[tv+1].cts;h[tv].duration=tT-ty}else h[tv].duration=tv?h[tv-1].duration:R;h[tv].cts=0,tg=tp}}}v=X||!v?R:v,this.nextAvcDts=$=s+v,this.videoSampleDuration=v,this.isVideoContiguous=!0;var tx,tE={data1:rp.moof(e.sequenceNumber++,a,l({},e,{samples:h})),data2:o,startPTS:m/u,endPTS:(p+v)/u,startDTS:a/u,endDTS:$/u,type:"video",hasAudio:!1,hasVideo:!0,nb:h.length,dropped:e.dropped};return e.samples=[],e.dropped=0,tE},e.getSamplesPerFrame=function t(e){switch(e.segmentCodec){case"mp3":return 1152;case"ac3":return 1536;default:return 1024}},e.remuxAudio=function t(e,i,r,n,a){var s,o=e.inputTimeScale,u=e.samplerate?e.samplerate:o,d=o/u,h=this.getSamplesPerFrame(e),f=h*d,c=this._initPTS,$="mp3"===e.segmentCodec&&this.typeSupported.mpeg,g=[],v=void 0!==a,m=e.samples,p=$?0:8,y=this.nextAudioPts||-1,T=i*o,x=c.baseTime*o/c.timescale;if(this.isAudioContiguous=r=r||m.length&&y>0&&(n&&9e3>Math.abs(T-y)||Math.abs(rL(m[0].pts-x,T)-y)<20*f),m.forEach(function(t){t.pts=rL(t.pts-x,T)}),!r||y<0){if(!(m=m.filter(function(t){return t.pts>=0})).length)return;y=0===a?0:n&&!v?Math.max(0,T):m[0].pts}if("aac"===e.segmentCodec)for(var E=this.config.maxAudioFramesDrift,S=0,L=y;S<m.length;S++){var A=m[S],R=A.pts,_=R-L,D=Math.abs(1e3*_/o);if(_<=-E*f&&v)0===S&&(H.warn("Audio frame @ "+(R/o).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*_/o)+" ms."),this.nextAudioPts=y=L=R);else if(_>=E*f&&D<1e4&&v){var k=Math.round(_/f);(L=R-k*f)<0&&(k--,L+=f),0===S&&(this.nextAudioPts=y=L),H.warn("[mp4-remuxer]: Injecting "+k+" audio frame @ "+(L/o).toFixed(3)+"s due to "+Math.round(1e3*_/o)+" ms gap.");for(var I=0;I<k;I++){var b=Math.max(L,0),C=rm.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);C||(H.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),C=A.unit.subarray()),m.splice(S,0,{unit:C,pts:b}),L+=f,S++}}A.pts=L,L+=f}for(var w=null,P=null,F=0,B=m.length;B--;)F+=m[B].unit.byteLength;for(var U=0,G=m.length;U<G;U++){var K=m[U],V=K.unit,Y=K.pts;if(null!==P)g[U-1].duration=Math.round((Y-P)/d);else{if(r&&"aac"===e.segmentCodec&&(Y=y),w=Y,!(F>0))return;F+=p;try{s=new Uint8Array(F)}catch(W){this.observer.emit(O.ERROR,O.ERROR,{type:N.MUX_ERROR,details:M.REMUX_ALLOC_ERROR,fatal:!1,error:W,bytes:F,reason:"fail allocating audio mdat "+F});return}!$&&(new DataView(s.buffer).setUint32(0,F),s.set(rp.types.mdat,4))}s.set(V,p);var q=V.byteLength;p+=q,g.push(new r_(!0,h,q,0)),P=Y}var X=g.length;if(X){var z=g[g.length-1];this.nextAudioPts=y=P+d*z.duration;var j=$?new Uint8Array(0):rp.moof(e.sequenceNumber++,w/d,l({},e,{samples:g}));e.samples=[];var Q=w/o,Z=y/o,J={data1:j,data2:s,startPTS:Q,endPTS:Z,startDTS:Q,endDTS:Z,type:"audio",hasAudio:!0,hasVideo:!1,nb:X};return this.isAudioContiguous=!0,J}},e.remuxEmptyAudio=function t(e,i,r,n){var a=e.inputTimeScale,s=e.samplerate?e.samplerate:a,o=this.nextAudioPts,l=this._initDTS,u=9e4*l.baseTime/l.timescale,d=(null!==o?o:n.startDTS*a)+u,h=n.endDTS*a+u,f=a/s*1024,c=Math.ceil((h-d)/f),$=rm.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(H.warn("[mp4-remuxer]: remux empty Audio"),!$){H.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var g=[],v=0;v<c;v++){var m=d+v*f;g.push({unit:$,pts:m,dts:m})}return e.samples=g,this.remuxAudio(e,i,r,!1)},t}();function rL(t,e){var i;if(null===e)return t;for(i=e<t?-8589934592:8589934592;Math.abs(t-e)>4294967296;)t+=i;return t}function rA(t,e,i,r){var n=t.samples.length;if(n){for(var a=t.inputTimeScale,s=0;s<n;s++){var o=t.samples[s];o.pts=rL(o.pts-i.baseTime*a/i.timescale,e*a)/a,o.dts=rL(o.dts-r.baseTime*a/r.timescale,e*a)/a}var l=t.samples;return t.samples=[],{samples:l}}}function rR(t,e,i){var r=t.samples.length;if(r){for(var n=t.inputTimeScale,a=0;a<r;a++){var s=t.samples[a];s.pts=rL(s.pts-i.baseTime*n/i.timescale,e*n)/n}t.samples.sort(function(t,e){return t.pts-e.pts});var o=t.samples;return t.samples=[],{samples:o}}}var r_=function t(e,i,r,n){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=i,this.size=r,this.cts=n,this.flags={isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:e?2:1,isNonSync:e?0:1}},rD=function(){function t(){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 e=t.prototype;return e.destroy=function t(){},e.resetTimeStamp=function t(e){this.initPTS=e,this.lastEndTime=null},e.resetNextTimestamp=function t(){this.lastEndTime=null},e.resetInitSegment=function t(e,i,r,n){this.audioCodec=i,this.videoCodec=r,this.generateInitSegment(function t(e,i){if(!e||!i)return e;var r=i.keyId;return r&&i.isCommonEncryption&&tO(e,["moov","trak"]).forEach(function(t){var e=tO(t,["mdia","minf","stbl","stsd"])[0].subarray(8),i=tO(e,["enca"]),n=i.length>0;n||(i=tO(e,["encv"])),i.forEach(function(t){tO(n?t.subarray(28):t.subarray(78),["sinf"]).forEach(function(t){var e=t2(t);if(e){var i=e.subarray(8,24);i.some(function(t){return 0!==t})||(H.log("[eme] Patching keyId in 'enc"+(n?"a":"v")+">sinf>>tenc' box: "+tD.hexDump(i)+" -> "+tD.hexDump(r)),e.set(r,8))}})})}),e}(e,n)),this.emitInitSegment=!0},e.generateInitSegment=function t(e){var i=this.audioCodec,r=this.videoCodec;if(!(null!=e&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}var n=this.initData=tM(e);n.audio&&(i=rk(n.audio,Q.AUDIO)),n.video&&(r=rk(n.video,Q.VIDEO));var a={};n.audio&&n.video?a.audiovideo={container:"video/mp4",codec:i+","+r,initSegment:e,id:"main"}:n.audio?a.audio={container:"audio/mp4",codec:i,initSegment:e,id:"audio"}:n.video?a.video={container:"video/mp4",codec:r,initSegment:e,id:"main"}:H.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=a},e.remux=function t(e,i,r,n,a,s){var o,l,u=this.initPTS,d=this.lastEndTime,h={audio:void 0,video:void 0,text:n,id3:r,initSegment:void 0};w(d)||(d=this.lastEndTime=a||0);var f=i.samples;if(!(null!=f&&f.length))return h;var c={initPTS:void 0,timescale:1},$=this.initData;if(null!=(o=$)&&o.length||(this.generateInitSegment(f),$=this.initData),!(null!=(l=$)&&l.length))return H.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),h;this.emitInitSegment&&(c.tracks=this.initTracks,this.emitInitSegment=!1);var g,v,m,p,y,T,x=function t(e,i){for(var r=0,n=0,a=0,s=tO(e,["moof","traf"]),o=0;o<s.length;o++){var l=s[o],u=tO(l,["tfhd"])[0],d=i[t8(u,4)];if(d){var h=d.default,f=t8(u,0)|(null==h?void 0:h.flags),c=null==h?void 0:h.duration;8&f&&(c=2&f?t8(u,12):t8(u,8));for(var $=d.timescale||9e4,g=tO(l,["trun"]),v=0;v<g.length;v++){if(!(r=t1(g[v]))&&c){var m=t8(g[v],4);r=c*m}d.type===Q.VIDEO?n+=r/$:d.type===Q.AUDIO&&(a+=r/$)}}}if(0===n&&0===a){for(var p=1/0,y=0,T=0,x=tO(e,["sidx"]),E=0;E<x.length;E++){var S=tN(x[E]);null!=S&&S.references&&(p=Math.min(p,S.earliestPresentationTime/S.timescale),T=(y=Math.max(y,S.references.reduce(function(t,e){return t+e.info.duration||0},0)+S.earliestPresentationTime/S.timescale))-p)}if(T&&w(T))return T}return n||a}(f,$),E=(g=$,v=f,tO(v,["moof","traf"]).reduce(function(t,e){var i=tO(e,["tfdt"])[0],r=i[0],n=tO(e,["tfhd"]).reduce(function(t,e){var n=g[t8(e,4)];if(n){var a=t8(i,4);if(1===r){if(4294967295===a)return H.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),t;a*=4294967296,a+=t8(i,8)}var s=a/(n.timescale||9e4);if(w(s)&&(null===t||s<t))return s}return t},null);return null!==n&&w(n)&&(null===t||n<t)?n:t},null)),S=null===E?a:E;m=u,p=S,y=a,T=x,(null===m||Math.abs(p-m.baseTime/m.timescale-y)>Math.max(T,1)||c.timescale!==u.timescale&&s)&&(c.initPTS=S-a,u&&1===u.timescale&&H.warn("Adjusting initPTS by "+(c.initPTS-u.baseTime)),this.initPTS=u={baseTime:c.initPTS,timescale:1});var L=e?S-u.baseTime/u.timescale:d,A=L+x;(function t(e,i,r){tO(i,["moof","traf"]).forEach(function(t){tO(t,["tfhd"]).forEach(function(i){var n=e[t8(i,4)];if(n){var a=n.timescale||9e4;tO(t,["tfdt"]).forEach(function(t){var e=t[0],i=r*a;if(i){var n=t8(t,4);if(0===e)n-=i,n=Math.max(n,0),tF(t,4,n);else{n*=4294967296,n+=t8(t,8),n-=i;var s=Math.floor((n=Math.max(n,0))/4294967296),o=Math.floor(n%4294967296);tF(t,4,s),tF(t,8,o)}}})}})})})($,f,u.baseTime/u.timescale),x>0?this.lastEndTime=A:(H.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var R=!!$.audio,_=!!$.video,D="";R&&(D+="audio"),_&&(D+="video");var k={data1:f,startPTS:L,startDTS:L,endPTS:A,endDTS:A,type:D,hasAudio:R,hasVideo:_,nb:1,dropped:0};return h.audio="audio"===k.type?k:void 0,h.video="audio"!==k.type?k:void 0,h.initSegment=c,h.id3=rA(r,a,u,u),n.samples.length&&(h.text=rR(n,a,u)),h},t}();function rk(t,e){var i=null==t?void 0:t.codec;if(i&&i.length>4)return i;if(e===Q.AUDIO){if("ec-3"===i||"ac-3"===i||"alac"===i)return i;if("fLaC"===i||"Opus"===i)return en(i,!1);var r="mp4a.40.5";return H.info('Parsed audio codec "'+i+'" or audio object type not handled. Using "'+r+'"'),r}return(H.warn('Unhandled video codec "'+i+'"'),"hvc1"===i||"hev1"===i)?"hvc1.1.6.L120.90":"av01"===i?"av01.0.04M.08":"avc1.42e01e"}try{v=self.performance.now.bind(self.performance)}catch(rI){H.debug("Unable to use Performance API on this environment"),v=null==tn?void 0:tn.Date.now}var rb=[{demux:re,remux:rD},{demux:ru,remux:rS},{demux:iJ,remux:rS},{demux:rv,remux:rS}];rb.splice(2,0,{demux:rr,remux:rS});var rC=function(){function t(t,e,i,r,n){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=t,this.typeSupported=e,this.config=i,this.vendor=r,this.id=n}var e=t.prototype;return e.configure=function t(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()},e.push=function t(e,i,r,n){var a=this,s=r.transmuxing;s.executeStart=v();var o,l,u,d=new Uint8Array(e),h=this.currentTransmuxState,f=this.transmuxConfig;n&&(this.currentTransmuxState=n);var c=n||h,$=c.contiguous,g=c.discontinuity,m=c.trackSwitch,p=c.accurateTimeOffset,y=c.timeOffset,T=c.initSegmentChange,x=f.audioCodec,E=f.videoCodec,S=f.defaultInitPts,L=f.duration,A=f.initSegmentData,R=(o=d,l=i,u=null,o.byteLength>0&&(null==l?void 0:l.key)!=null&&null!==l.iv&&null!=l.method&&(u=l),u);if(R&&"AES-128"===R.method){var _=this.getDecrypter();if(!_.isSync())return this.decryptionPromise=_.webCryptoDecrypt(d,R.key.buffer,R.iv.buffer).then(function(t){var e=a.push(t,null,r);return a.decryptionPromise=null,e}),this.decryptionPromise;var D=_.softwareDecrypt(d,R.key.buffer,R.iv.buffer);if(r.part>-1&&(D=_.flush()),!D)return s.executeEnd=v(),r8(r);d=new Uint8Array(D)}var k=this.needsProbing(g,m);if(k){var I=this.configureTransmuxer(d);if(I)return H.warn("[transmuxer] "+I.message),this.observer.emit(O.ERROR,O.ERROR,{type:N.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,fatal:!1,error:I,reason:I.message}),s.executeEnd=v(),r8(r)}(g||m||T||k)&&this.resetInitSegment(A,x,E,L,i),(g||T||k)&&this.resetInitialTimestamp(S),$||this.resetContiguity();var b=this.transmux(d,R,y,p,r),C=this.currentTransmuxState;return C.contiguous=!0,C.discontinuity=!1,C.trackSwitch=!1,s.executeEnd=v(),b},e.flush=function t(e){var i=this,r=e.transmuxing;r.executeStart=v();var n=this.decrypter,a=this.currentTransmuxState,s=this.decryptionPromise;if(s)return s.then(function(){return i.flush(e)});var o=[],l=a.timeOffset;if(n){var u=n.flush();u&&o.push(this.push(u,null,e))}var d=this.demuxer,h=this.remuxer;if(!d||!h)return r.executeEnd=v(),[r8(e)];var f=d.flush(l);return rw(f)?f.then(function(t){return i.flushRemux(o,t,e),o}):(this.flushRemux(o,f,e),o)},e.flushRemux=function t(e,i,r){var n=i.audioTrack,a=i.videoTrack,s=i.id3Track,o=i.textTrack,l=this.currentTransmuxState,u=l.accurateTimeOffset,d=l.timeOffset;H.log("[transmuxer.ts]: Flushed fragment "+r.sn+(r.part>-1?" p: "+r.part:"")+" of level "+r.level);var h=this.remuxer.remux(n,a,s,o,d,u,!0,this.id);e.push({remuxResult:h,chunkMeta:r}),r.transmuxing.executeEnd=v()},e.resetInitialTimestamp=function t(e){var i=this.demuxer,r=this.remuxer;i&&r&&(i.resetTimeStamp(e),r.resetTimeStamp(e))},e.resetContiguity=function t(){var e=this.demuxer,i=this.remuxer;e&&i&&(e.resetContiguity(),i.resetNextTimestamp())},e.resetInitSegment=function t(e,i,r,n,a){var s=this.demuxer,o=this.remuxer;s&&o&&(s.resetInitSegment(e,i,r,n),o.resetInitSegment(e,i,r,a))},e.destroy=function t(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},e.transmux=function t(e,i,r,n,a){var s;return i&&"SAMPLE-AES"===i.method?this.transmuxSampleAes(e,i,r,n,a):this.transmuxUnencrypted(e,r,n,a)},e.transmuxUnencrypted=function t(e,i,r,n){var a=this.demuxer.demux(e,i,!1,!this.config.progressive),s=a.audioTrack,o=a.videoTrack,l=a.id3Track,u=a.textTrack;return{remuxResult:this.remuxer.remux(s,o,l,u,i,r,!1,this.id),chunkMeta:n}},e.transmuxSampleAes=function t(e,i,r,n,a){var s=this;return this.demuxer.demuxSampleAes(e,i,r).then(function(t){return{remuxResult:s.remuxer.remux(t.audioTrack,t.videoTrack,t.id3Track,t.textTrack,r,n,!1,s.id),chunkMeta:a}})},e.configureTransmuxer=function t(e){for(var i,r,n=this.config,a=this.observer,s=this.typeSupported,o=this.vendor,l=0,u=rb.length;l<u;l++)if(null!=(r=rb[l].demux)&&r.probe(e)){i=rb[l];break}if(!i)return Error("Failed to find demuxer by probing fragment data");var d=this.demuxer,h=this.remuxer,f=i.remux,c=i.demux;h&&h instanceof f||(this.remuxer=new f(a,n,s,o)),d&&d instanceof c||(this.demuxer=new c(a,n,s),this.probe=c.probe)},e.needsProbing=function t(e,i){return!this.demuxer||!this.remuxer||e||i},e.getDecrypter=function t(){var e=this.decrypter;return e||(e=this.decrypter=new iO(this.config)),e},t}(),r8=function t(e){return{remuxResult:{},chunkMeta:e}};function rw(t){return"then"in t&&t.then instanceof Function}var rP,rF=function t(e,i,r,n,a){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=i,this.initSegmentData=r,this.duration=n,this.defaultInitPts=a||null},rO=function t(e,i,r,n,a,s){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=e,this.contiguous=i,this.accurateTimeOffset=r,this.trackSwitch=n,this.timeOffset=a,this.initSegmentChange=s},rN={exports:{}};!function(t){var e=Object.prototype.hasOwnProperty,i="~";function r(){}function n(t,e,i){this.fn=t,this.context=e,this.once=i||!1}function a(t,e,r,a,s){if("function"!=typeof r)throw TypeError("The listener must be a function");var o=new n(r,a||t,s),l=i?i+e:e;return t._events[l]?t._events[l].fn?t._events[l]=[t._events[l],o]:t._events[l].push(o):(t._events[l]=o,t._eventsCount++),t}function s(t,e){0==--t._eventsCount?t._events=new r:delete t._events[e]}function o(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(i=!1)),o.prototype.eventNames=function t(){var r,n,a=[];if(0===this._eventsCount)return a;for(n in r=this._events)e.call(r,n)&&a.push(i?n.slice(1):n);return Object.getOwnPropertySymbols?a.concat(Object.getOwnPropertySymbols(r)):a},o.prototype.listeners=function t(e){var r=i?i+e:e,n=this._events[r];if(!n)return[];if(n.fn)return[n.fn];for(var a=0,s=n.length,o=Array(s);a<s;a++)o[a]=n[a].fn;return o},o.prototype.listenerCount=function t(e){var r=i?i+e:e,n=this._events[r];return n?n.fn?1:n.length:0},o.prototype.emit=function t(e,r,n,a,s,o){var l=i?i+e:e;if(!this._events[l])return!1;var u,d,h=this._events[l],f=arguments.length;if(h.fn){switch(h.once&&this.removeListener(e,h.fn,void 0,!0),f){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,r),!0;case 3:return h.fn.call(h.context,r,n),!0;case 4:return h.fn.call(h.context,r,n,a),!0;case 5:return h.fn.call(h.context,r,n,a,s),!0;case 6:return h.fn.call(h.context,r,n,a,s,o),!0}for(d=1,u=Array(f-1);d<f;d++)u[d-1]=arguments[d];h.fn.apply(h.context,u)}else{var c,$=h.length;for(d=0;d<$;d++)switch(h[d].once&&this.removeListener(e,h[d].fn,void 0,!0),f){case 1:h[d].fn.call(h[d].context);break;case 2:h[d].fn.call(h[d].context,r);break;case 3:h[d].fn.call(h[d].context,r,n);break;case 4:h[d].fn.call(h[d].context,r,n,a);break;default:if(!u)for(c=1,u=Array(f-1);c<f;c++)u[c-1]=arguments[c];h[d].fn.apply(h[d].context,u)}}return!0},o.prototype.on=function t(e,i,r){return a(this,e,i,r,!1)},o.prototype.once=function t(e,i,r){return a(this,e,i,r,!0)},o.prototype.removeListener=function t(e,r,n,a){var o=i?i+e:e;if(!this._events[o])return this;if(!r)return s(this,o),this;var l=this._events[o];if(l.fn)l.fn!==r||a&&!l.once||n&&l.context!==n||s(this,o);else{for(var u=0,d=[],h=l.length;u<h;u++)(l[u].fn!==r||a&&!l[u].once||n&&l[u].context!==n)&&d.push(l[u]);d.length?this._events[o]=1===d.length?d[0]:d:s(this,o)}return this},o.prototype.removeAllListeners=function t(e){var n;return e?(n=i?i+e:e,this._events[n]&&s(this,n)):(this._events=new r,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=i,o.EventEmitter=o,t.exports=o}(rN);var rM=(rP=rN.exports)&&rP.__esModule&&Object.prototype.hasOwnProperty.call(rP,"default")?rP.default:rP;function rB(t,e){if(i=e.remuxResult,!i.audio&&!i.video&&!i.text&&!i.id3&&!i.initSegment)return!1;var i,r=[],n=e.remuxResult,a=n.audio,s=n.video;return a&&rU(r,a),s&&rU(r,s),t.postMessage({event:"transmuxComplete",data:e},r),!0}function rU(t,e){e.data1&&t.push(e.data1.buffer),e.data2&&t.push(e.data2.buffer)}function r0(t,e,i){e.reduce(function(e,i){return rB(t,i)||e},!1)||t.postMessage({event:"transmuxComplete",data:e[0]}),t.postMessage({event:"flush",data:i})}void 0!==e&&e&&function t(e){var i=new rM,r=function t(i,r){e.postMessage({event:i,data:r})};i.on(O.FRAG_DECRYPTED,r),i.on(O.ERROR,r);var n=function t(){var e=function t(e){var i=function t(i){r("workerLog",{logType:e,message:i})};H[e]=i};for(var i in H)e(i)};e.addEventListener("message",function(t){var a=t.data;switch(a.cmd){case"init":var s=JSON.parse(a.config);e.transmuxer=new rC(i,a.typeSupported,s,"",a.id),K(s.debug,a.id),n(),r("init",null);break;case"configure":e.transmuxer.configure(a.config);break;case"demux":var o=e.transmuxer.push(a.data,a.decryptdata,a.chunkMeta,a.state);rw(o)?(e.transmuxer.async=!0,o.then(function(t){rB(e,t)}).catch(function(t){r(O.ERROR,{type:N.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,chunkMeta:a.chunkMeta,fatal:!1,error:t,err:t,reason:"transmuxer-worker push error"})})):(e.transmuxer.async=!1,rB(e,o));break;case"flush":var l=a.chunkMeta,u=e.transmuxer.flush(l);rw(u)||e.transmuxer.async?(rw(u)||(u=Promise.resolve(u)),u.then(function(t){r0(e,t,l)}).catch(function(t){r(O.ERROR,{type:N.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,chunkMeta:a.chunkMeta,fatal:!1,error:t,err:t,reason:"transmuxer-worker flush error"})})):r0(e,u,l)}})}(self);var rG=function(){function e(e,i,r,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=i,this.useWorker=!!s.enableWorker,this.onTransmuxComplete=r,this.onFlush=n;var o=function t(e,i){(i=i||{}).frag=a.frag,i.id=a.id,e===O.ERROR&&(a.error=i.error),a.hls.trigger(e,i)};this.observer=new rM,this.observer.on(O.FRAG_DECRYPTED,o),this.observer.on(O.ERROR,o);var l=tj(s.preferManagedMediaSource)||{isTypeSupported:function t(){return!1}},u={mpeg:l.isTypeSupported("audio/mpeg"),mp3:l.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:l.isTypeSupported('audio/mp4; codecs="ac-3"')};if(this.useWorker&&"undefined"!=typeof Worker&&(s.workerPath||"function"==typeof t)){try{s.workerPath?(H.log("loading Web Worker "+s.workerPath+' for "'+i+'"'),this.workerContext=(d=s.workerPath,h=new self.URL(d,self.location.href).href,{worker:new self.Worker(h),scriptURL:h})):(H.log('injecting Web Worker for "'+i+'"'),this.workerContext=(f=new self.Blob(["var exports={};var module={exports:exports};function define(f){f()};define.amd=true;("+t.toString()+")(true);"],{type:"text/javascript"}),c=self.URL.createObjectURL(f),{worker:new self.Worker(c),objectURL:c})),this.onwmsg=function(t){return a.onWorkerMessage(t)};var d,h,f,c,$=this.workerContext.worker;$.addEventListener("message",this.onwmsg),$.onerror=function(t){var e=Error(t.message+" ("+t.filename+":"+t.lineno+")");s.enableWorker=!1,H.warn('Error in "'+i+'" Web Worker, fallback to inline'),a.hls.trigger(O.ERROR,{type:N.OTHER_ERROR,details:M.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:e})},$.postMessage({cmd:"init",typeSupported:u,vendor:"",id:i,config:JSON.stringify(s)})}catch(g){H.warn('Error setting up "'+i+'" Web Worker, fallback to inline',g),this.resetWorker(),this.error=null,this.transmuxer=new rC(this.observer,u,s,"",i)}return}this.transmuxer=new rC(this.observer,u,s,"",i)}var i=e.prototype;return i.resetWorker=function t(){if(this.workerContext){var e=this.workerContext,i=e.worker,r=e.objectURL;r&&self.URL.revokeObjectURL(r),i.removeEventListener("message",this.onwmsg),i.onerror=null,i.terminate(),this.workerContext=null}},i.destroy=function t(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{var e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}var i=this.observer;i&&i.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},i.push=function t(e,i,r,n,a,s,o,l,u,d){var h,f,c=this;u.transmuxing.start=self.performance.now();var $=this.transmuxer,g=s?s.start:a.start,v=a.decryptdata,m=this.frag,p=!(m&&a.cc===m.cc),y=!(m&&u.level===m.level),T=m?u.sn-m.sn:-1,x=this.part?u.part-this.part.index:-1,E=0===T&&u.id>1&&u.id===(null==m?void 0:m.stats.chunkCount),S=!y&&(1===T||0===T&&(1===x||E&&x<=0)),L=self.performance.now();(y||T||0===a.stats.parsing.start)&&(a.stats.parsing.start=L),s&&(x||!S)&&(s.stats.parsing.start=L);var A=!(m&&(null==(h=a.initSegment)?void 0:h.url)===(null==(f=m.initSegment)?void 0:f.url)),R=new rO(p,S,l,y,g,A);if(!S||p||A){H.log("[transmuxer-interface, "+a.type+"]: Starting new transmux session for sn: "+u.sn+" p: "+u.part+" level: "+u.level+" id: "+u.id+"\n discontinuity: "+p+"\n trackSwitch: "+y+"\n contiguous: "+S+"\n accurateTimeOffset: "+l+"\n timeOffset: "+g+"\n initSegmentChange: "+A);var _=new rF(r,n,i,o,d);this.configureTransmuxer(_)}if(this.frag=a,this.part=s,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:v,chunkMeta:u,state:R},e instanceof ArrayBuffer?[e]:[]);else if($){var D=$.push(e,v,u,R);rw(D)?($.async=!0,D.then(function(t){c.handleTransmuxComplete(t)}).catch(function(t){c.transmuxerError(t,u,"transmuxer-interface push error")})):($.async=!1,this.handleTransmuxComplete(D))}},i.flush=function t(e){var i=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 n=r.flush(e);rw(n)||r.async?(rw(n)||(n=Promise.resolve(n)),n.then(function(t){i.handleFlushResult(t,e)}).catch(function(t){i.transmuxerError(t,e,"transmuxer-interface flush error")})):this.handleFlushResult(n,e)}},i.transmuxerError=function t(e,i,r){this.hls&&(this.error=e,this.hls.trigger(O.ERROR,{type:N.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,chunkMeta:i,frag:this.frag||void 0,fatal:!1,error:e,err:e,reason:r}))},i.handleFlushResult=function t(e,i){var r=this;e.forEach(function(t){r.handleTransmuxComplete(t)}),this.onFlush(i)},i.onWorkerMessage=function t(e){var i=e.data;if(!(null!=i&&i.event)){H.warn("worker message received with no "+(i?"event name":"data"));return}var r=this.hls;if(this.hls)switch(i.event){case"init":var n,a=null==(n=this.workerContext)?void 0:n.objectURL;a&&self.URL.revokeObjectURL(a);break;case"transmuxComplete":this.handleTransmuxComplete(i.data);break;case"flush":this.onFlush(i.data);break;case"workerLog":H[i.data.logType]&&H[i.data.logType](i.data.message);break;default:i.data=i.data||{},i.data.frag=this.frag,i.data.id=this.id,r.trigger(i.event,i.data)}},i.configureTransmuxer=function t(e){var i=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):i&&i.configure(e)},i.handleTransmuxComplete=function t(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},e}();function r2(t,e){if(t.length!==e.length)return!1;for(var i=0;i<t.length;i++)if(!r1(t[i].attrs,e[i].attrs))return!1;return!0}function r1(t,e,i){var r=t["STABLE-RENDITION-ID"];return r&&!i?r===e["STABLE-RENDITION-ID"]:!(i||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some(function(i){return t[i]!==e[i]})}function r6(t,e){return e.label.toLowerCase()===t.name.toLowerCase()&&(!e.language||e.language.toLowerCase()===(t.lang||"").toLowerCase())}var rK=function(t){function e(e,i,r){var n;return(n=t.call(this,e,i,r,"[audio-stream-controller]",eT.AUDIO)||this).videoBuffer=null,n.videoTrackCC=-1,n.waitingVideoCC=-1,n.bufferedTrack=null,n.switchingTrack=null,n.trackId=-1,n.waitingData=null,n.mainDetails=null,n.flushing=!1,n.bufferFlushed=!1,n.cachedTrackLoadedData=null,n._registerListeners(),n}u(e,t);var i=e.prototype;return i.onHandlerDestroying=function e(){this._unregisterListeners(),t.prototype.onHandlerDestroying.call(this),this.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null},i._registerListeners=function t(){var e=this.hls;e.on(O.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(O.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(O.MANIFEST_LOADING,this.onManifestLoading,this),e.on(O.LEVEL_LOADED,this.onLevelLoaded,this),e.on(O.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(O.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(O.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(O.ERROR,this.onError,this),e.on(O.BUFFER_RESET,this.onBufferReset,this),e.on(O.BUFFER_CREATED,this.onBufferCreated,this),e.on(O.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(O.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(O.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(O.FRAG_BUFFERED,this.onFragBuffered,this)},i._unregisterListeners=function t(){var e=this.hls;e.off(O.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(O.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(O.MANIFEST_LOADING,this.onManifestLoading,this),e.off(O.LEVEL_LOADED,this.onLevelLoaded,this),e.off(O.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(O.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(O.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(O.ERROR,this.onError,this),e.off(O.BUFFER_RESET,this.onBufferReset,this),e.off(O.BUFFER_CREATED,this.onBufferCreated,this),e.off(O.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(O.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(O.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(O.FRAG_BUFFERED,this.onFragBuffered,this)},i.onInitPtsFound=function t(e,i){var r=i.frag,n=i.id,a=i.initPTS,s=i.timescale;if("main"===n){var o=r.cc;this.initPTS[r.cc]={baseTime:a,timescale:s},this.log("InitPTS for cc: "+o+" found from main: "+a),this.videoTrackCC=o,this.state===iM.WAITING_INIT_PTS&&this.tick()}},i.startLoad=function t(e){if(!this.levels){this.startPosition=e,this.state=iM.STOPPED;return}var i=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),i>0&&-1===e?(this.log("Override startPosition with lastCurrentTime @"+i.toFixed(3)),e=i,this.state=iM.IDLE):(this.loadedmetadata=!1,this.state=iM.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()},i.doTick=function e(){switch(this.state){case iM.IDLE:this.doTickIdle();break;case iM.WAITING_TRACK:var i,r=this.levels,n=this.trackId,a=null==r?void 0:null==(i=r[n])?void 0:i.details;if(a){if(this.waitForCdnTuneIn(a))break;this.state=iM.WAITING_INIT_PTS}break;case iM.FRAG_LOADING_WAITING_RETRY:var s,o=performance.now(),l=this.retryDate;if(!l||o>=l||null!=(s=this.media)&&s.seeking){var u=this.levels,d=this.trackId;this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded((null==u?void 0:u[d])||null),this.state=iM.IDLE}break;case iM.WAITING_INIT_PTS:var h=this.waitingData;if(h){var f=h.frag,c=h.part,$=h.cache,g=h.complete;if(void 0!==this.initPTS[f.cc]){this.waitingData=null,this.waitingVideoCC=-1,this.state=iM.FRAG_LOADING;var v={frag:f,part:c,payload:$.flush(),networkDetails:null};this._handleFragmentLoadProgress(v),g&&t.prototype._handleFragmentLoadComplete.call(this,v)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log("Waiting fragment cc ("+f.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var m=this.getLoadPosition(),p=iS.bufferInfo(this.mediaBuffer,m,this.config.maxBufferHole);0>ez(p.end,this.config.maxFragLookUpTolerance,f)&&(this.log("Waiting fragment cc ("+f.cc+") @ "+f.start+" cancelled because another fragment at "+p.end+" is needed"),this.clearWaitingFragment())}}else this.state=iM.IDLE}this.onTickEnd()},i.clearWaitingFragment=function t(){var e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=iM.IDLE)},i.resetLoadingState=function e(){this.clearWaitingFragment(),t.prototype.resetLoadingState.call(this)},i.onTickEnd=function t(){var e=this.media;null!=e&&e.readyState&&(this.lastCurrentTime=e.currentTime)},i.doTickIdle=function t(){var e=this.hls,i=this.levels,r=this.media,n=this.trackId,a=e.config;if((r||!this.startFragRequested&&a.startFragPrefetch)&&null!=i&&i[n]){var s=i[n],o=s.details;if(!o||o.live&&this.levelLastLoaded!==s||this.waitForCdnTuneIn(o)){this.state=iM.WAITING_TRACK;return}var l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,Q.AUDIO,eT.AUDIO));var u=this.getFwdBufferInfo(l,eT.AUDIO);if(null!==u){var d=this.bufferedTrack,h=this.switchingTrack;if(!h&&this._streamEnded(u,o)){e.trigger(O.BUFFER_EOS,{type:"audio"}),this.state=iM.ENDED;return}var f=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,eT.MAIN),c=u.len,$=this.getMaxBufferLength(null==f?void 0:f.len),g=o.fragments,v=g[0].start,m=this.flushing?this.getLoadPosition():u.end;if(h&&r){var p=this.getLoadPosition();d&&!r1(h.attrs,d.attrs)&&(m=p),o.PTSKnown&&p<v&&(u.end>v||u.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),r.currentTime=v+.05)}if(!(c>=$)||h||!(m<g[g.length-1].start)){var y=this.getNextFragment(m,o),T=!1;if(y&&this.isLoopLoading(y,m)&&(T=!!y.gap,y=this.getNextFragmentLoopLoading(y,o,u,eT.MAIN,$)),!y){this.bufferFlushed=!0;return}var x=f&&y.start>f.end+o.targetduration;if(x||!(null!=f&&f.len)&&u.len){var E=this.getAppendedFrag(y.start,eT.MAIN);if(null===E||(T||(T=!!E.gap||!!x&&0===f.len),x&&!T||T&&u.nextStart&&u.nextStart<E.end))return}this.loadFragment(y,s,m)}}}},i.getMaxBufferLength=function e(i){var r=t.prototype.getMaxBufferLength.call(this);return i?Math.min(Math.max(r,i),this.config.maxMaxBufferLength):r},i.onMediaDetaching=function e(){this.videoBuffer=null,this.bufferFlushed=this.flushing=!1,t.prototype.onMediaDetaching.call(this)},i.onAudioTracksUpdated=function t(e,i){var r=i.audioTracks;this.resetTransmuxer(),this.levels=r.map(function(t){return new e0(t)})},i.onAudioTrackSwitching=function t(e,i){var r=!!i.url;this.trackId=i.id;var n=this.fragCurrent;n&&(n.abortRequests(),this.removeUnbufferedFrags(n.start)),this.resetLoadingState(),r?this.setInterval(100):this.resetTransmuxer(),r?(this.switchingTrack=i,this.state=iM.IDLE,this.flushAudioIfNeeded(i)):(this.switchingTrack=null,this.bufferedTrack=i,this.state=iM.STOPPED),this.tick()},i.onManifestLoading=function t(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=this.flushing=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1},i.onLevelLoaded=function t(e,i){this.mainDetails=i.details,null!==this.cachedTrackLoadedData&&(this.hls.trigger(O.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)},i.onAudioTrackLoaded=function t(e,i){if(null==this.mainDetails){this.cachedTrackLoadedData=i;return}var r=this.levels,n=i.details,a=i.id;if(!r){this.warn("Audio tracks were reset while loading level "+a);return}this.log("Audio track "+a+" loaded ["+n.startSN+","+n.endSN+"]"+(n.lastPartSn?"[part-"+n.lastPartSn+"-"+n.lastPartIndex+"]":"")+",duration:"+n.totalduration);var s=r[a],o=0;if(n.live||null!=(l=s.details)&&l.live){this.checkLiveUpdate(n);var l,u,d=this.mainDetails;if(n.deltaUpdateFailed||!d)return;!s.details&&n.hasProgramDateTime&&d.hasProgramDateTime?(ik(n,d),o=n.fragments[0].start):o=this.alignPlaylists(n,s.details,null==(u=this.levelLastLoaded)?void 0:u.details)}s.details=n,this.levelLastLoaded=s,this.startFragRequested||!this.mainDetails&&n.live||this.setStartPosition(this.mainDetails||n,o),this.state!==iM.WAITING_TRACK||this.waitForCdnTuneIn(n)||(this.state=iM.IDLE),this.tick()},i._handleFragmentLoadProgress=function t(e){var i,r=e.frag,n=e.part,a=e.payload,s=this.config,o=this.trackId,l=this.levels;if(!l){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+r.sn+" of level "+r.level+" will not be buffered");return}var u=l[o];if(!u){this.warn("Audio track is undefined on fragment load progress");return}var d=u.details;if(!d){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(r.start);return}var h=s.defaultAudioCodec||u.audioCodec||"mp4a.40.2",f=this.transmuxer;f||(f=this.transmuxer=new rG(this.hls,eT.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var c=this.initPTS[r.cc],$=null==(i=r.initSegment)?void 0:i.data;if(void 0!==c){var g=n?n.index:-1,v=new iL(r.level,r.sn,r.stats.chunkCount,a.byteLength,g,-1!==g);f.push(a,$,h,"",r,n,d.totalduration,!1,v,c)}else this.log("Unknown video PTS for cc "+r.cc+", waiting for video PTS before demuxing audio frag "+r.sn+" of ["+d.startSN+" ,"+d.endSN+"],track "+o),(this.waitingData=this.waitingData||{frag:r,part:n,cache:new iU,complete:!1}).cache.push(new Uint8Array(a)),this.waitingVideoCC=this.videoTrackCC,this.state=iM.WAITING_INIT_PTS},i._handleFragmentLoadComplete=function e(i){if(this.waitingData){this.waitingData.complete=!0;return}t.prototype._handleFragmentLoadComplete.call(this,i)},i.onBufferReset=function t(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},i.onBufferCreated=function t(e,i){var r=i.tracks.audio;r&&(this.mediaBuffer=r.buffer||null),i.tracks.video&&(this.videoBuffer=i.tracks.video.buffer||null)},i.onFragBuffered=function t(e,i){var n=i.frag,a=i.part;if(n.type!==eT.AUDIO){if(!this.loadedmetadata&&n.type===eT.MAIN){var s=this.videoBuffer||this.media;s&&iS.getBuffered(s).length&&(this.loadedmetadata=!0)}return}if(this.fragContextChanged(n)){this.warn("Fragment "+n.sn+(a?" p: "+a.index:"")+" of level "+n.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+(this.switchingTrack?this.switchingTrack.name:"false"));return}if("initSegment"!==n.sn){this.fragPrevious=n;var o=this.switchingTrack;o&&(this.bufferedTrack=o,this.switchingTrack=null,this.hls.trigger(O.AUDIO_TRACK_SWITCHED,r({},o)))}this.fragBufferedComplete(n,a)},i.onError=function e(i,r){var n;if(r.fatal){this.state=iM.ERROR;return}switch(r.details){case M.FRAG_GAP:case M.FRAG_PARSING_ERROR:case M.FRAG_DECRYPT_ERROR:case M.FRAG_LOAD_ERROR:case M.FRAG_LOAD_TIMEOUT:case M.KEY_LOAD_ERROR:case M.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(eT.AUDIO,r);break;case M.AUDIO_TRACK_LOAD_ERROR:case M.AUDIO_TRACK_LOAD_TIMEOUT:case M.LEVEL_PARSING_ERROR:r.levelRetry||this.state!==iM.WAITING_TRACK||(null==(n=r.context)?void 0:n.type)!==ey.AUDIO_TRACK||(this.state=iM.IDLE);break;case M.BUFFER_APPEND_ERROR:case M.BUFFER_FULL_ERROR:if(!r.parent||"audio"!==r.parent)return;if(r.details===M.BUFFER_APPEND_ERROR){this.resetLoadingState();return}this.reduceLengthAndFlushBuffer(r)&&(this.bufferedTrack=null,t.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio"));break;case M.INTERNAL_EXCEPTION:this.recoverWorkerError(r)}},i.onBufferFlushing=function t(e,i){i.type!==Q.VIDEO&&(this.flushing=!0)},i.onBufferFlushed=function t(e,i){var r=i.type;if(r!==Q.VIDEO){this.flushing=!1,this.bufferFlushed=!0,this.state===iM.ENDED&&(this.state=iM.IDLE);var n=this.mediaBuffer||this.media;n&&(this.afterBufferFlushed(n,r,eT.AUDIO),this.tick())}},i._handleTransmuxComplete=function t(e){var i,r="audio",n=this.hls,a=e.remuxResult,s=e.chunkMeta,o=this.getCurrentContext(s);if(!o){this.resetWhenMissingContext(s);return}var u=o.frag,d=o.part,h=o.level,f=h.details,c=a.audio,$=a.text,g=a.id3,v=a.initSegment;if(this.fragContextChanged(u)||!f){this.fragmentTracker.removeFragment(u);return}if(this.state=iM.PARSING,this.switchingTrack&&c&&this.completeAudioSwitch(this.switchingTrack),null!=v&&v.tracks){var m=u.initSegment||u;this._bufferInitSegment(h,v.tracks,m,s),n.trigger(O.FRAG_PARSING_INIT_SEGMENT,{frag:m,id:r,tracks:v.tracks})}if(c){var p=c.startPTS,y=c.endPTS,T=c.startDTS,x=c.endDTS;d&&(d.elementaryStreams[Q.AUDIO]={startPTS:p,endPTS:y,startDTS:T,endDTS:x}),u.setElementaryStreamInfo(Q.AUDIO,p,y,T,x),this.bufferFragmentData(c,u,d,s)}if(null!=g&&null!=(i=g.samples)&&i.length){var E=l({id:r,frag:u,details:f},g);n.trigger(O.FRAG_PARSING_METADATA,E)}if($){var S=l({id:r,frag:u,details:f},$);n.trigger(O.FRAG_PARSING_USERDATA,S)}},i._bufferInitSegment=function t(e,i,r,n){if(this.state===iM.PARSING){i.video&&delete i.video;var a=i.audio;if(a){a.id="audio";var s=e.audioCodec;this.log("Init audio buffer, container:"+a.container+", codecs[level/parsed]=["+s+"/"+a.codec+"]"),s&&1===s.split(",").length&&(a.levelCodec=s),this.hls.trigger(O.BUFFER_CODECS,i);var o=a.initSegment;if(null!=o&&o.byteLength){var l={type:"audio",frag:r,part:null,chunkMeta:n,parent:r.type,data:o};this.hls.trigger(O.BUFFER_APPENDING,l)}this.tickImmediate()}}},i.loadFragment=function e(i,r,n){var a,s=this.fragmentTracker.getState(i);if(this.fragCurrent=i,this.switchingTrack||s===ip.NOT_LOADED||s===ip.PARTIAL){if("initSegment"===i.sn)this._loadInitSegment(i,r);else if(null!=(a=r.details)&&a.live&&!this.initPTS[i.cc]){this.log("Waiting for video PTS in continuity counter "+i.cc+" of live stream before loading audio fragment "+i.sn+" of level "+this.trackId),this.state=iM.WAITING_INIT_PTS;var o=this.mainDetails;o&&o.fragments[0].start!==r.details.fragments[0].start&&ik(r.details,o)}else this.startFragRequested=!0,t.prototype.loadFragment.call(this,i,r,n)}else this.clearTrackerIfNeeded(i)},i.flushAudioIfNeeded=function e(i){var r=this.media,n=this.bufferedTrack,a=null==n?void 0:n.attrs,s=i.attrs;r&&a&&(a.CHANNELS!==s.CHANNELS||n.name!==i.name||n.lang!==i.lang)&&(this.log("Switching audio track : flushing all audio"),t.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null)},i.completeAudioSwitch=function t(e){var i=this.hls;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,i.trigger(O.AUDIO_TRACK_SWITCHED,r({},e))},e}(iB),r4=function(t){function e(e){var i;return(i=t.call(this,e,"[audio-track-controller]")||this).tracks=[],i.groupIds=null,i.tracksInGroup=[],i.trackId=-1,i.currentTrack=null,i.selectDefaultTrack=!0,i.registerListeners(),i}u(e,t);var i=e.prototype;return i.registerListeners=function t(){var e=this.hls;e.on(O.MANIFEST_LOADING,this.onManifestLoading,this),e.on(O.MANIFEST_PARSED,this.onManifestParsed,this),e.on(O.LEVEL_LOADING,this.onLevelLoading,this),e.on(O.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(O.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(O.ERROR,this.onError,this)},i.unregisterListeners=function t(){var e=this.hls;e.off(O.MANIFEST_LOADING,this.onManifestLoading,this),e.off(O.MANIFEST_PARSED,this.onManifestParsed,this),e.off(O.LEVEL_LOADING,this.onLevelLoading,this),e.off(O.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(O.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(O.ERROR,this.onError,this)},i.destroy=function e(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,t.prototype.destroy.call(this)},i.onManifestLoading=function t(){this.tracks=[],this.tracksInGroup=[],this.groupIds=null,this.currentTrack=null,this.trackId=-1,this.selectDefaultTrack=!0},i.onManifestParsed=function t(e,i){this.tracks=i.audioTracks||[]},i.onAudioTrackLoaded=function t(e,i){var r=i.id,n=i.groupId,a=i.details,s=this.tracksInGroup[r];if(!s||s.groupId!==n){this.warn("Audio track with id:"+r+" and group:"+n+" not found in active group "+(null==s?void 0:s.groupId));return}var o=s.details;s.details=i.details,this.log("Audio track "+r+' "'+s.name+'" lang:'+s.lang+" group:"+n+" loaded ["+a.startSN+"-"+a.endSN+"]"),r===this.trackId&&this.playlistLoaded(r,i,o)},i.onLevelLoading=function t(e,i){this.switchLevel(i.level)},i.onLevelSwitching=function t(e,i){this.switchLevel(i.level)},i.switchLevel=function t(e){var i=this.hls.levels[e];if(i){var r=i.audioGroups||null,n=this.groupIds,a=this.currentTrack;if(!r||(null==n?void 0:n.length)!==(null==r?void 0:r.length)||null!=r&&r.some(function(t){return(null==n?void 0:n.indexOf(t))===-1})){this.groupIds=r,this.trackId=-1,this.currentTrack=null;var s=this.tracks.filter(function(t){return!r||-1!==r.indexOf(t.groupId)});if(s.length)this.selectDefaultTrack&&!s.some(function(t){return t.default})&&(this.selectDefaultTrack=!1),s.forEach(function(t,e){t.id=e});else if(!a&&!this.tracksInGroup.length)return;this.tracksInGroup=s;var o=this.hls.config.audioPreference;if(!a&&o){var l=ih(o,s,i$);if(l>-1)a=s[l];else{var u=ih(o,this.tracks);a=this.tracks[u]}}var d=this.findTrackId(a);-1===d&&a&&(d=this.findTrackId(null)),this.log("Updating audio tracks, "+s.length+" track(s) found in group(s): "+(null==r?void 0:r.join(","))),this.hls.trigger(O.AUDIO_TRACKS_UPDATED,{audioTracks:s});var h=this.trackId;if(-1!==d&&-1===h)this.setAudioTrack(d);else if(s.length&&-1===h){var f,c=Error("No audio track selected for current audio group-ID(s): "+(null==(f=this.groupIds)?void 0:f.join(","))+" track count: "+s.length);this.warn(c.message),this.hls.trigger(O.ERROR,{type:N.MEDIA_ERROR,details:M.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:c})}}else this.shouldReloadPlaylist(a)&&this.setAudioTrack(this.trackId)}},i.onError=function t(e,i){!i.fatal&&i.context&&(i.context.type!==ey.AUDIO_TRACK||i.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(i.context.groupId)||(this.requestScheduled=-1,this.checkRetry(i)))},i.setAudioOption=function t(e){var i=this.hls;if(i.config.audioPreference=e,e){var r=this.allAudioTracks;if(this.selectDefaultTrack=!1,r.length){var n=this.currentTrack;if(n&&ic(e,n,i$))return n;var a=ih(e,this.tracksInGroup,i$);if(a>-1){var s=this.tracksInGroup[a];return this.setAudioTrack(a),s}if(n){var o,l,u,d,h,f,c,$,g,v,m,p=i.loadLevel;-1===p&&(p=i.firstAutoLevel);var y=(o=e,l=i.levels,u=r,d=p,h=i$,f=l[d],(c=l.reduce(function(t,e,i){var r=e.uri;return(t[r]||(t[r]=[])).push(i),t},{})[f.uri]).length>1&&(d=Math.max.apply(Math,c)),$=f.videoRange,g=f.frameRate,v=f.codecSet.substring(0,4),(m=ig(l,d,function(t){if(t.videoRange!==$||t.frameRate!==g||t.codecSet.substring(0,4)!==v)return!1;var e=t.audioGroups;return ih(o,u.filter(function(t){return!e||-1!==e.indexOf(t.groupId)}),h)>-1}))>-1?m:ig(l,d,function(t){var e=t.audioGroups;return ih(o,u.filter(function(t){return!e||-1!==e.indexOf(t.groupId)}),h)>-1}));if(-1===y)return null;i.nextLoadLevel=y}if(e.channels||e.audioCodec){var T=ih(e,r);if(T>-1)return r[T]}}}return null},i.setAudioTrack=function t(e){var i=this.tracksInGroup;if(e<0||e>=i.length){this.warn("Invalid audio track id: "+e);return}this.clearTimer(),this.selectDefaultTrack=!1;var n=this.currentTrack,a=i[e],s=a.details&&!a.details.live;if(e!==this.trackId||a!==n||!s){if(this.log("Switching to audio-track "+e+' "'+a.name+'" lang:'+a.lang+" group:"+a.groupId+" channels:"+a.channels),this.trackId=e,this.currentTrack=a,this.hls.trigger(O.AUDIO_TRACK_SWITCHING,r({},a)),!s){var o=this.switchParams(a.url,null==n?void 0:n.details,a.details);this.loadPlaylist(o)}}},i.findTrackId=function t(e){for(var i=this.tracksInGroup,r=0;r<i.length;r++){var n=i[r];if((!this.selectDefaultTrack||n.default)&&(!e||ic(e,n,i$)))return r}if(e){for(var a=e.name,s=e.lang,o=e.assocLang,l=e.characteristics,u=e.audioCodec,d=e.channels,h=0;h<i.length;h++)if(ic({name:a,lang:s,assocLang:o,characteristics:l,audioCodec:u,channels:d},i[h],i$))return h;for(var f=0;f<i.length;f++){var c=i[f];if(r1(e.attrs,c.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return f}for(var $=0;$<i.length;$++){var g=i[$];if(r1(e.attrs,g.attrs,["LANGUAGE"]))return $}}return -1},i.loadPlaylist=function e(i){var r=this.currentTrack;if(this.shouldLoadPlaylist(r)&&r){t.prototype.loadPlaylist.call(this);var n=r.id,a=r.groupId,s=r.url;if(i)try{s=i.addDirectives(s)}catch(o){this.warn("Could not construct new URL with HLS Delivery Directives: "+o)}this.log("loading audio-track playlist "+n+' "'+r.name+'" lang:'+r.lang+" group:"+a),this.clearTimer(),this.hls.trigger(O.AUDIO_TRACK_LOADING,{url:s,id:n,groupId:a,deliveryDirectives:i||null})}},s(e,[{key:"allAudioTracks",get:function t(){return this.tracks}},{key:"audioTracks",get:function t(){return this.tracksInGroup}},{key:"audioTrack",get:function t(){return this.trackId},set:function t(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}}]),e}(eJ),r3=function(t){function e(e,i,r){var n;return(n=t.call(this,e,i,r,"[subtitle-stream-controller]",eT.SUBTITLE)||this).currentTrackId=-1,n.tracksBuffered=[],n.mainDetails=null,n._registerListeners(),n}u(e,t);var i=e.prototype;return i.onHandlerDestroying=function e(){this._unregisterListeners(),t.prototype.onHandlerDestroying.call(this),this.mainDetails=null},i._registerListeners=function t(){var e=this.hls;e.on(O.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(O.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(O.MANIFEST_LOADING,this.onManifestLoading,this),e.on(O.LEVEL_LOADED,this.onLevelLoaded,this),e.on(O.ERROR,this.onError,this),e.on(O.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(O.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(O.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(O.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(O.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(O.FRAG_BUFFERED,this.onFragBuffered,this)},i._unregisterListeners=function t(){var e=this.hls;e.off(O.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(O.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(O.MANIFEST_LOADING,this.onManifestLoading,this),e.off(O.LEVEL_LOADED,this.onLevelLoaded,this),e.off(O.ERROR,this.onError,this),e.off(O.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(O.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(O.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(O.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(O.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(O.FRAG_BUFFERED,this.onFragBuffered,this)},i.startLoad=function t(e){this.stopLoad(),this.state=iM.IDLE,this.setInterval(500),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()},i.onManifestLoading=function t(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},i.onMediaDetaching=function e(){this.tracksBuffered=[],t.prototype.onMediaDetaching.call(this)},i.onLevelLoaded=function t(e,i){this.mainDetails=i.details},i.onSubtitleFragProcessed=function t(e,i){var r,n=i.frag,a=i.success;if(this.fragPrevious=n,this.state=iM.IDLE,a){var s=this.tracksBuffered[this.currentTrackId];if(s){for(var o=n.start,l=0;l<s.length;l++)if(o>=s[l].start&&o<=s[l].end){r=s[l];break}var u=n.start+n.duration;r?r.end=u:(r={start:o,end:u},s.push(r)),this.fragmentTracker.fragBuffered(n),this.fragBufferedComplete(n,null)}}},i.onBufferFlushing=function t(e,i){var r=i.startOffset,n=i.endOffset;if(0===r&&n!==Number.POSITIVE_INFINITY){var a=n-1;if(a<=0)return;i.endOffsetSubtitles=Math.max(0,a),this.tracksBuffered.forEach(function(t){for(var e=0;e<t.length;){if(t[e].end<=a){t.shift();continue}if(t[e].start<a)t[e].start=a;else break;e++}}),this.fragmentTracker.removeFragmentsInRange(r,a,eT.SUBTITLE)}},i.onFragBuffered=function t(e,i){if(!this.loadedmetadata&&i.frag.type===eT.MAIN){var r;null!=(r=this.media)&&r.buffered.length&&(this.loadedmetadata=!0)}},i.onError=function t(e,i){var r=i.frag;(null==r?void 0:r.type)===eT.SUBTITLE&&(i.details===M.FRAG_GAP&&this.fragmentTracker.fragBuffered(r,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==iM.STOPPED&&(this.state=iM.IDLE))},i.onSubtitleTracksUpdated=function t(e,i){var r=this,n=i.subtitleTracks;if(this.levels&&r2(this.levels,n)){this.levels=n.map(function(t){return new e0(t)});return}this.tracksBuffered=[],this.levels=n.map(function(t){var e=new e0(t);return r.tracksBuffered[e.id]=[],e}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,eT.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null},i.onSubtitleTrackSwitch=function t(e,i){if(this.currentTrackId=i.id,!(null!=(r=this.levels)&&r.length)||-1===this.currentTrackId){this.clearInterval();return}var r,n=this.levels[this.currentTrackId];null!=n&&n.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,n&&this.setInterval(500)},i.onSubtitleTrackLoaded=function t(e,i){var r=this.currentTrackId,n=this.levels,a=i.details,s=i.id;if(!n){this.warn("Subtitle tracks were reset while loading level "+s);return}var o=n[s];if(!(s>=n.length)&&o){this.log("Subtitle track "+s+" loaded ["+a.startSN+","+a.endSN+"]"+(a.lastPartSn?"[part-"+a.lastPartSn+"-"+a.lastPartIndex+"]":"")+",duration:"+a.totalduration),this.mediaBuffer=this.mediaBufferTimeRanges;var l=0;if(a.live||null!=(u=o.details)&&u.live){var u,d,h=this.mainDetails;if(a.deltaUpdateFailed||!h)return;var f=h.fragments[0];o.details?0===(l=this.alignPlaylists(a,o.details,null==(d=this.levelLastLoaded)?void 0:d.details))&&f&&eK(a,l=f.start):a.hasProgramDateTime&&h.hasProgramDateTime?(ik(a,h),l=a.fragments[0].start):f&&eK(a,l=f.start)}o.details=a,this.levelLastLoaded=o,s===r&&(this.startFragRequested||!this.mainDetails&&a.live||this.setStartPosition(this.mainDetails||a,l),this.tick(),a.live&&!this.fragCurrent&&this.media&&this.state===iM.IDLE&&(eX(null,a.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),o.details=void 0)))}},i._handleFragmentLoadComplete=function t(e){var i=this,r=e.frag,n=e.payload,a=r.decryptdata,s=this.hls;if(!this.fragContextChanged(r)&&n&&n.byteLength>0&&null!=a&&a.key&&a.iv&&"AES-128"===a.method){var o=performance.now();this.decrypter.decrypt(new Uint8Array(n),a.key.buffer,a.iv.buffer).catch(function(t){throw s.trigger(O.ERROR,{type:N.MEDIA_ERROR,details:M.FRAG_DECRYPT_ERROR,fatal:!1,error:t,reason:t.message,frag:r}),t}).then(function(t){var e=performance.now();s.trigger(O.FRAG_DECRYPTED,{frag:r,payload:t,stats:{tstart:o,tdecrypt:e}})}).catch(function(t){i.warn(t.name+": "+t.message),i.state=iM.IDLE})}},i.doTick=function t(){if(!this.media){this.state=iM.IDLE;return}if(this.state===iM.IDLE){var e=this.currentTrackId,i=this.levels,r=null==i?void 0:i[e];if(!r||!i.length||!r.details)return;var n=this.config,a=this.getLoadPosition(),s=iS.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],a,n.maxBufferHole),o=s.end,l=s.len,u=this.getFwdBufferInfo(this.media,eT.MAIN),d=r.details;if(l>this.getMaxBufferLength(null==u?void 0:u.len)+d.levelTargetDuration)return;var h=d.fragments,f=h.length,c=d.edge,$=null,g=this.fragPrevious;if(o<c){var v=n.maxFragLookUpTolerance;($=eX(g,h,Math.max(h[0].start,o),o>c-v?0:v))||!g||!(g.start<h[0].start)||($=h[0])}else $=h[f-1];if(!$)return;if("initSegment"!==($=this.mapToInitFragWhenRequired($)).sn){var m=h[$.sn-d.startSN-1];m&&m.cc===$.cc&&this.fragmentTracker.getState(m)===ip.NOT_LOADED&&($=m)}this.fragmentTracker.getState($)===ip.NOT_LOADED&&this.loadFragment($,r,o)}},i.getMaxBufferLength=function e(i){var r=t.prototype.getMaxBufferLength.call(this);return i?Math.max(r,i):r},i.loadFragment=function e(i,r,n){this.fragCurrent=i,"initSegment"===i.sn?this._loadInitSegment(i,r):(this.startFragRequested=!0,t.prototype.loadFragment.call(this,i,r,n))},s(e,[{key:"mediaBufferTimeRanges",get:function t(){return new rH(this.tracksBuffered[this.currentTrackId]||[])}}]),e}(iB),rH=function t(e){this.buffered=void 0;var i=function t(i,r,n){if((r>>>=0)>n-1)throw new DOMException("Failed to execute '"+i+"' on 'TimeRanges': The index provided ("+r+") is greater than the maximum bound ("+n+")");return e[r][i]};this.buffered={get length(){return e.length},end:function t(r){return i("end",r,e.length)},start:function t(r){return i("start",r,e.length)}}},rV=function(t){function e(e){var i;return(i=t.call(this,e,"[subtitle-track-controller]")||this).media=null,i.tracks=[],i.groupIds=null,i.tracksInGroup=[],i.trackId=-1,i.currentTrack=null,i.selectDefaultTrack=!0,i.queuedDefaultTrack=-1,i.asyncPollTrackChange=function(){return i.pollTrackChange(0)},i.useTextTrackPolling=!1,i.subtitlePollingInterval=-1,i._subtitleDisplay=!0,i.onTextTracksChanged=function(){if(i.useTextTrackPolling||self.clearInterval(i.subtitlePollingInterval),i.media&&i.hls.config.renderTextTracksNatively){for(var t=null,e=eD(i.media.textTracks),r=0;r<e.length;r++)if("hidden"===e[r].mode)t=e[r];else if("showing"===e[r].mode){t=e[r];break}var n=i.findTrackForTextTrack(t);i.subtitleTrack!==n&&i.setSubtitleTrack(n)}},i.registerListeners(),i}u(e,t);var i=e.prototype;return i.destroy=function e(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,t.prototype.destroy.call(this)},i.registerListeners=function t(){var e=this.hls;e.on(O.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(O.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(O.MANIFEST_LOADING,this.onManifestLoading,this),e.on(O.MANIFEST_PARSED,this.onManifestParsed,this),e.on(O.LEVEL_LOADING,this.onLevelLoading,this),e.on(O.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(O.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(O.ERROR,this.onError,this)},i.unregisterListeners=function t(){var e=this.hls;e.off(O.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(O.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(O.MANIFEST_LOADING,this.onManifestLoading,this),e.off(O.MANIFEST_PARSED,this.onManifestParsed,this),e.off(O.LEVEL_LOADING,this.onLevelLoading,this),e.off(O.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(O.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(O.ERROR,this.onError,this)},i.onMediaAttached=function t(e,i){this.media=i.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))},i.pollTrackChange=function t(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.onTextTracksChanged,e)},i.onMediaDetaching=function t(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),eD(this.media.textTracks).forEach(function(t){eR(t)}),this.subtitleTrack=-1,this.media=null)},i.onManifestLoading=function t(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0},i.onManifestParsed=function t(e,i){this.tracks=i.subtitleTracks},i.onSubtitleTrackLoaded=function t(e,i){var r=i.id,n=i.groupId,a=i.details,s=this.tracksInGroup[r];if(!s||s.groupId!==n){this.warn("Subtitle track with id:"+r+" and group:"+n+" not found in active group "+(null==s?void 0:s.groupId));return}var o=s.details;s.details=i.details,this.log("Subtitle track "+r+' "'+s.name+'" lang:'+s.lang+" group:"+n+" loaded ["+a.startSN+"-"+a.endSN+"]"),r===this.trackId&&this.playlistLoaded(r,i,o)},i.onLevelLoading=function t(e,i){this.switchLevel(i.level)},i.onLevelSwitching=function t(e,i){this.switchLevel(i.level)},i.switchLevel=function t(e){var i=this.hls.levels[e];if(i){var r=i.subtitleGroups||null,n=this.groupIds,a=this.currentTrack;if(!r||(null==n?void 0:n.length)!==(null==r?void 0:r.length)||null!=r&&r.some(function(t){return(null==n?void 0:n.indexOf(t))===-1})){this.groupIds=r,this.trackId=-1,this.currentTrack=null;var s=this.tracks.filter(function(t){return!r||-1!==r.indexOf(t.groupId)});if(s.length)this.selectDefaultTrack&&!s.some(function(t){return t.default})&&(this.selectDefaultTrack=!1),s.forEach(function(t,e){t.id=e});else if(!a&&!this.tracksInGroup.length)return;this.tracksInGroup=s;var o=this.hls.config.subtitlePreference;if(!a&&o){this.selectDefaultTrack=!1;var l=ih(o,s);if(l>-1)a=s[l];else{var u=ih(o,this.tracks);a=this.tracks[u]}}var d=this.findTrackId(a);-1===d&&a&&(d=this.findTrackId(null)),this.log("Updating subtitle tracks, "+s.length+' track(s) found in "'+(null==r?void 0:r.join(","))+'" group-id'),this.hls.trigger(O.SUBTITLE_TRACKS_UPDATED,{subtitleTracks:s}),-1!==d&&-1===this.trackId&&this.setSubtitleTrack(d)}else this.shouldReloadPlaylist(a)&&this.setSubtitleTrack(this.trackId)}},i.findTrackId=function t(e){for(var i=this.tracksInGroup,r=this.selectDefaultTrack,n=0;n<i.length;n++){var a=i[n];if((!r||a.default)&&(r||e)&&(!e||ic(a,e)))return n}if(e){for(var s=0;s<i.length;s++){var o=i[s];if(r1(e.attrs,o.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return s}for(var l=0;l<i.length;l++){var u=i[l];if(r1(e.attrs,u.attrs,["LANGUAGE"]))return l}}return -1},i.findTrackForTextTrack=function t(e){if(e){for(var i=this.tracksInGroup,r=0;r<i.length;r++)if(r6(i[r],e))return r}return -1},i.onError=function t(e,i){!i.fatal&&i.context&&(i.context.type!==ey.SUBTITLE_TRACK||i.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(i.context.groupId)||this.checkRetry(i))},i.setSubtitleOption=function t(e){if(this.hls.config.subtitlePreference=e,e){var i=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,i.length){var r=this.currentTrack;if(r&&ic(e,r))return r;var n=ih(e,this.tracksInGroup);if(n>-1){var a=this.tracksInGroup[n];return this.setSubtitleTrack(n),a}if(r);else{var s=ih(e,i);if(s>-1)return i[s]}}}return null},i.loadPlaylist=function e(i){t.prototype.loadPlaylist.call(this);var r=this.currentTrack;if(this.shouldLoadPlaylist(r)&&r){var n=r.id,a=r.groupId,s=r.url;if(i)try{s=i.addDirectives(s)}catch(o){this.warn("Could not construct new URL with HLS Delivery Directives: "+o)}this.log("Loading subtitle playlist for id "+n),this.hls.trigger(O.SUBTITLE_TRACK_LOADING,{url:s,id:n,groupId:a,deliveryDirectives:i||null})}},i.toggleTrackModes=function t(){var e,i=this.media;if(i){var r=eD(i.textTracks),n=this.currentTrack;if(!n||(e=r.filter(function(t){return r6(n,t)})[0])||this.warn('Unable to find subtitle TextTrack with name "'+n.name+'" and language "'+n.lang+'"'),[].slice.call(r).forEach(function(t){"disabled"!==t.mode&&t!==e&&(t.mode="disabled")}),e){var a=this.subtitleDisplay?"showing":"hidden";e.mode!==a&&(e.mode=a)}}},i.setSubtitleTrack=function t(e){var i=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(e<-1||e>=i.length||!w(e)){this.warn("Invalid subtitle track id: "+e);return}this.clearTimer(),this.selectDefaultTrack=!1;var r=this.currentTrack,n=i[e]||null;if(this.trackId=e,this.currentTrack=n,this.toggleTrackModes(),!n){this.hls.trigger(O.SUBTITLE_TRACK_SWITCH,{id:e});return}var a=!!n.details&&!n.details.live;if(e!==this.trackId||n!==r||!a){this.log("Switching to subtitle-track "+e+(n?' "'+n.name+'" lang:'+n.lang+" group:"+n.groupId:""));var s=n.id,o=n.groupId,l=n.name,u=n.type,d=n.url;this.hls.trigger(O.SUBTITLE_TRACK_SWITCH,{id:s,groupId:void 0===o?"":o,name:l,type:u,url:d});var h=this.switchParams(n.url,null==r?void 0:r.details,n.details);this.loadPlaylist(h)}},s(e,[{key:"subtitleDisplay",get:function t(){return this._subtitleDisplay},set:function t(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes()}},{key:"allSubtitleTracks",get:function t(){return this.tracks}},{key:"subtitleTracks",get:function t(){return this.tracksInGroup}},{key:"subtitleTrack",get:function t(){return this.trackId},set:function t(e){this.selectDefaultTrack=!1,this.setSubtitleTrack(e)}}]),e}(eJ),r7=function(){function t(t){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=t}var e=t.prototype;return e.append=function t(e,i,r){var n=this.queues[i];n.push(e),1!==n.length||r||this.executeNext(i)},e.insertAbort=function t(e,i){this.queues[i].unshift(e),this.executeNext(i)},e.appendBlocker=function t(e){var i,r=new Promise(function(t){i=t}),n={execute:i,onStart:function t(){},onComplete:function t(){},onError:function t(){}};return this.append(n,e),r},e.executeNext=function t(e){var i=this.queues[e];if(i.length){var r=i[0];try{r.execute()}catch(n){H.warn('[buffer-operation-queue]: Exception executing "'+e+'" SourceBuffer operation: '+n),r.onError(n);var a=this.buffers[e];null!=a&&a.updating||this.shiftAndExecuteNext(e)}}},e.shiftAndExecuteNext=function t(e){this.queues[e].shift(),this.executeNext(e)},e.current=function t(e){return this.queues[e][0]},t}(),rY=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,rW=function(){function t(t){var e=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.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(t){e.hls&&e.hls.pauseBuffering()},this._onStartStreaming=function(t){e.hls&&e.hls.resumeBuffering()},this._onMediaSourceOpen=function(){var t=e.media,i=e.mediaSource;e.log("Media source opened"),t&&(t.removeEventListener("emptied",e._onMediaEmptied),e.updateMediaElementDuration(),e.hls.trigger(O.MEDIA_ATTACHED,{media:t,mediaSource:i})),i&&i.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 t=e.mediaSrc,i=e._objectUrl;t!==i&&H.error("Media element src was set while attaching MediaSource ("+i+" > "+t+")")},this.hls=t;var i,r="[buffer-controller]";this.appendSource=(i=tj(t.config.preferManagedMediaSource),"undefined"!=typeof self&&i===self.ManagedMediaSource),this.log=H.log.bind(H,r),this.warn=H.warn.bind(H,r),this.error=H.error.bind(H,r),this._initSourceBuffer(),this.registerListeners()}var e=t.prototype;return e.hasSourceTypes=function t(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},e.destroy=function t(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null,this.hls=null},e.registerListeners=function t(){var e=this.hls;e.on(O.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(O.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(O.MANIFEST_LOADING,this.onManifestLoading,this),e.on(O.MANIFEST_PARSED,this.onManifestParsed,this),e.on(O.BUFFER_RESET,this.onBufferReset,this),e.on(O.BUFFER_APPENDING,this.onBufferAppending,this),e.on(O.BUFFER_CODECS,this.onBufferCodecs,this),e.on(O.BUFFER_EOS,this.onBufferEos,this),e.on(O.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(O.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(O.FRAG_PARSED,this.onFragParsed,this),e.on(O.FRAG_CHANGED,this.onFragChanged,this)},e.unregisterListeners=function t(){var e=this.hls;e.off(O.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(O.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(O.MANIFEST_LOADING,this.onManifestLoading,this),e.off(O.MANIFEST_PARSED,this.onManifestParsed,this),e.off(O.BUFFER_RESET,this.onBufferReset,this),e.off(O.BUFFER_APPENDING,this.onBufferAppending,this),e.off(O.BUFFER_CODECS,this.onBufferCodecs,this),e.off(O.BUFFER_EOS,this.onBufferEos,this),e.off(O.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(O.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(O.FRAG_PARSED,this.onFragParsed,this),e.off(O.FRAG_CHANGED,this.onFragChanged,this)},e._initSourceBuffer=function t(){this.sourceBuffer={},this.operationQueue=new r7(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.appendErrors={audio:0,video:0,audiovideo:0},this.lastMpegAudioChunk=null},e.onManifestLoading=function t(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null},e.onManifestParsed=function t(e,i){var r=2;(!i.audio||i.video)&&i.altAudio||(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,this.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},e.onMediaAttaching=function t(e,i){var r=this.media=i.media,n=tj(this.appendSource);if(r&&n){var a,s=this.mediaSource=new n;this.log("created media source: "+(null==(a=s.constructor)?void 0:a.name)),s.addEventListener("sourceopen",this._onMediaSourceOpen),s.addEventListener("sourceended",this._onMediaSourceEnded),s.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(s.addEventListener("startstreaming",this._onStartStreaming),s.addEventListener("endstreaming",this._onEndStreaming));var o=this._objectUrl=self.URL.createObjectURL(s);if(this.appendSource)try{r.removeAttribute("src");var l,u,d,h=self.ManagedMediaSource;r.disableRemotePlayback=r.disableRemotePlayback||h&&s instanceof h,r5(r),l=r,u=o,(d=self.document.createElement("source")).type="video/mp4",d.src=u,l.appendChild(d),r.load()}catch(f){r.src=o}else r.src=o;r.addEventListener("emptied",this._onMediaEmptied)}},e.onMediaDetaching=function t(){var e=this.media,i=this.mediaSource,r=this._objectUrl;if(i){if(this.log("media source detaching"),"open"===i.readyState)try{i.endOfStream()}catch(n){this.warn("onMediaDetaching: "+n.message+" while calling endOfStream")}this.onBufferReset(),i.removeEventListener("sourceopen",this._onMediaSourceOpen),i.removeEventListener("sourceended",this._onMediaSourceEnded),i.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(i.removeEventListener("startstreaming",this._onStartStreaming),i.removeEventListener("endstreaming",this._onEndStreaming)),e&&(e.removeEventListener("emptied",this._onMediaEmptied),r&&self.URL.revokeObjectURL(r),this.mediaSrc===r?(e.removeAttribute("src"),this.appendSource&&r5(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(O.MEDIA_DETACHED,void 0)},e.onBufferReset=function t(){var e=this;this.getSourceBufferTypes().forEach(function(t){e.resetBuffer(t)}),this._initSourceBuffer()},e.resetBuffer=function t(e){var i,r=this.sourceBuffer[e];try{r&&(this.removeBufferListeners(e),this.sourceBuffer[e]=void 0,null!=(i=this.mediaSource)&&i.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(r))}catch(n){this.warn("onBufferReset "+e,n)}},e.onBufferCodecs=function t(e,i){var r=this,n=this.getSourceBufferTypes().length,a=Object.keys(i);if(a.forEach(function(t){if(n){var e=r.tracks[t];if(e&&"function"==typeof e.buffer.changeType){var a,s=i[t],o=s.id,l=s.codec,u=s.levelCodec,d=s.container,h=s.metadata,f=ea(e.codec,e.levelCodec),c=null==f?void 0:f.replace(rY,"$1"),$=ea(l,u),g=null==(a=$)?void 0:a.replace(rY,"$1");if($&&c!==g){"audio"===t.slice(0,5)&&($=en($,r.appendSource));var v=d+";codecs="+$;r.appendChangeType(t,v),r.log("switching codec "+f+" to "+$),r.tracks[t]={buffer:e.buffer,codec:l,container:d,levelCodec:u,metadata:h,id:o}}}}else r.pendingTracks[t]=i[t]}),!n){var s=Math.max(this.bufferCodecEventsExpected-1,0);this.bufferCodecEventsExpected!==s&&(this.log(s+" bufferCodec event(s) expected "+a.join(",")),this.bufferCodecEventsExpected=s),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks()}},e.appendChangeType=function t(e,i){var r=this,n=this.operationQueue;n.append({execute:function t(){var a=r.sourceBuffer[e];a&&(r.log("changing "+e+" sourceBuffer type to "+i),a.changeType(i)),n.shiftAndExecuteNext(e)},onStart:function t(){},onComplete:function t(){},onError:function t(i){r.warn("Failed to change "+e+" SourceBuffer type",i)}},e,!!this.pendingTracks[e])},e.onBufferAppending=function t(e,i){var r=this,n=this.hls,a=this.operationQueue,s=this.tracks,o=i.data,l=i.type,u=i.frag,d=i.part,h=i.chunkMeta,f=h.buffering[l],c=self.performance.now();f.start=c;var $=u.stats.buffering,g=d?d.stats.buffering:null;0===$.start&&($.start=c),g&&0===g.start&&(g.start=c);var v=s.audio,m=!1;"audio"===l&&(null==v?void 0:v.container)==="audio/mpeg"&&(m=!this.lastMpegAudioChunk||1===h.id||this.lastMpegAudioChunk.sn!==h.sn,this.lastMpegAudioChunk=h);var p=u.start;a.append({execute:function t(){if(f.executeStart=self.performance.now(),m){var e=r.sourceBuffer[l];if(e){var i=p-e.timestampOffset;Math.abs(i)>=.1&&(r.log("Updating audio SourceBuffer timestampOffset to "+p+" (delta: "+i+") sn: "+u.sn+")"),e.timestampOffset=p)}}r.appendExecutor(o,l)},onStart:function t(){},onComplete:function t(){var e=self.performance.now();f.executeEnd=f.end=e,0===$.first&&($.first=e),g&&0===g.first&&(g.first=e);var i=r.sourceBuffer,n={};for(var a in i)n[a]=iS.getBuffered(i[a]);r.appendErrors[l]=0,"audio"===l||"video"===l?r.appendErrors.audiovideo=0:(r.appendErrors.audio=0,r.appendErrors.video=0),r.hls.trigger(O.BUFFER_APPENDED,{type:l,frag:u,part:d,chunkMeta:h,parent:u.type,timeRanges:n})},onError:function t(e){var i={type:N.MEDIA_ERROR,parent:u.type,details:M.BUFFER_APPEND_ERROR,sourceBufferName:l,frag:u,part:d,chunkMeta:h,error:e,err:e,fatal:!1};if(e.code===DOMException.QUOTA_EXCEEDED_ERR)i.details=M.BUFFER_FULL_ERROR;else{var a=++r.appendErrors[l];i.details=M.BUFFER_APPEND_ERROR,r.warn("Failed "+a+"/"+n.config.appendErrorMaxRetry+' times to append segment in "'+l+'" sourceBuffer'),a>=n.config.appendErrorMaxRetry&&(i.fatal=!0)}n.trigger(O.ERROR,i)}},l,!!this.pendingTracks[l])},e.onBufferFlushing=function t(e,i){var r=this,n=this.operationQueue,a=function t(e){return{execute:r.removeExecutor.bind(r,e,i.startOffset,i.endOffset),onStart:function t(){},onComplete:function t(){r.hls.trigger(O.BUFFER_FLUSHED,{type:e})},onError:function t(i){r.warn("Failed to remove from "+e+" SourceBuffer",i)}}};i.type?n.append(a(i.type),i.type):this.getSourceBufferTypes().forEach(function(t){n.append(a(t),t)})},e.onFragParsed=function t(e,i){var r=this,n=i.frag,a=i.part,s=[],o=a?a.elementaryStreams:n.elementaryStreams;o[Q.AUDIOVIDEO]?s.push("audiovideo"):(o[Q.AUDIO]&&s.push("audio"),o[Q.VIDEO]&&s.push("video"));var l=function t(){var e=self.performance.now();n.stats.buffering.end=e,a&&(a.stats.buffering.end=e);var i=a?a.stats:n.stats;r.hls.trigger(O.FRAG_BUFFERED,{frag:n,part:a,stats:i,id:n.type})};0===s.length&&this.warn("Fragments must have at least one ElementaryStreamType set. type: "+n.type+" level: "+n.level+" sn: "+n.sn),this.blockBuffers(l,s)},e.onFragChanged=function t(e,i){this.trimBuffers()},e.onBufferEos=function t(e,i){var r=this;this.getSourceBufferTypes().reduce(function(t,e){var n=r.sourceBuffer[e];return!n||i.type&&i.type!==e||(n.ending=!0,n.ended||(n.ended=!0,r.log(e+" sourceBuffer now EOS"))),t&&!!(!n||n.ended)},!0)&&(this.log("Queueing mediaSource.endOfStream()"),this.blockBuffers(function(){r.getSourceBufferTypes().forEach(function(t){var e=r.sourceBuffer[t];e&&(e.ending=!1)});var t=r.mediaSource;if(!t||"open"!==t.readyState){t&&r.log("Could not call mediaSource.endOfStream(). mediaSource.readyState: "+t.readyState);return}r.log("Calling mediaSource.endOfStream()"),t.endOfStream()}))},e.onLevelUpdated=function t(e,i){var r=i.details;r.fragments.length&&(this.details=r,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},e.trimBuffers=function t(){var e=this.hls,i=this.details,r=this.media;if(r&&null!==i){if(this.getSourceBufferTypes().length){var n=e.config,a=r.currentTime,s=i.levelTargetDuration,o=i.live&&null!==n.liveBackBufferLength?n.liveBackBufferLength:n.backBufferLength;if(w(o)&&o>0&&this.flushBackBuffer(a,s,Math.floor(a/s)*s-Math.max(o,s)),w(n.frontBufferFlushThreshold)&&n.frontBufferFlushThreshold>0){var l=Math.max(n.maxBufferLength,n.frontBufferFlushThreshold);this.flushFrontBuffer(a,s,Math.floor(a/s)*s+Math.max(l,s))}}}},e.flushBackBuffer=function t(e,i,r){var n=this,a=this.details,s=this.sourceBuffer;this.getSourceBufferTypes().forEach(function(t){var o=s[t];if(o){var l=iS.getBuffered(o);if(l.length>0&&r>l.start(0)){if(n.hls.trigger(O.BACK_BUFFER_REACHED,{bufferEnd:r}),null!=a&&a.live)n.hls.trigger(O.LIVE_BACK_BUFFER_REACHED,{bufferEnd:r});else if(o.ended&&l.end(l.length-1)-e<2*i){n.log("Cannot flush "+t+" back buffer while SourceBuffer is in ended state");return}n.hls.trigger(O.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:t})}}})},e.flushFrontBuffer=function t(e,i,r){var n=this,a=this.sourceBuffer;this.getSourceBufferTypes().forEach(function(t){var s=a[t];if(s){var o=iS.getBuffered(s),l=o.length;if(l<2)return;var u=o.start(l-1),d=o.end(l-1);if(r>u||e>=u&&e<=d)return;if(s.ended&&e-d<2*i){n.log("Cannot flush "+t+" front buffer while SourceBuffer is in ended state");return}n.hls.trigger(O.BUFFER_FLUSHING,{startOffset:u,endOffset:1/0,type:t})}})},e.updateMediaElementDuration=function t(){if(this.details&&this.media&&this.mediaSource&&"open"===this.mediaSource.readyState){var e=this.details,i=this.hls,r=this.media,n=this.mediaSource,a=e.fragments[0].start+e.totalduration,s=r.duration,o=w(n.duration)?n.duration:0;e.live&&i.config.liveDurationInfinity?(n.duration=1/0,this.updateSeekableRange(e)):(a>o&&a>s||!w(s))&&(this.log("Updating Media Source duration to "+a.toFixed(3)),n.duration=a)}},e.updateSeekableRange=function t(e){var i=this.mediaSource,r=e.fragments;if(r.length&&e.live&&null!=i&&i.setLiveSeekableRange){var n=Math.max(0,r[0].start),a=Math.max(n,n+e.totalduration);this.log("Media Source duration is set to "+i.duration+". Setting seekable range to "+n+"-"+a+"."),i.setLiveSeekableRange(n,a)}},e.checkPendingTracks=function t(){var e=this.bufferCodecEventsExpected,i=this.operationQueue,r=this.pendingTracks,n=Object.keys(r).length;if(n&&(!e||2===n||"audiovideo"in r)){this.createSourceBuffers(r),this.pendingTracks={};var a=this.getSourceBufferTypes();if(a.length)this.hls.trigger(O.BUFFER_CREATED,{tracks:this.tracks}),a.forEach(function(t){i.executeNext(t)});else{var s=Error("could not create source buffer for media codec(s)");this.hls.trigger(O.ERROR,{type:N.MEDIA_ERROR,details:M.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:s,reason:s.message})}}},e.createSourceBuffers=function t(e){var i=this,r=this.sourceBuffer,n=this.mediaSource;if(!n)throw Error("createSourceBuffers called when mediaSource was null");var a=function t(a){if(!r[a]){var s,o=e[a];if(!o)throw Error("source buffer exists for track "+a+", however track does not");var l=(null==(s=o.levelCodec)?void 0:s.indexOf(","))===-1?o.levelCodec:o.codec;l&&"audio"===a.slice(0,5)&&(l=en(l,i.appendSource));var u=o.container+";codecs="+l;i.log("creating sourceBuffer("+u+")");try{var d=r[a]=n.addSourceBuffer(u),h=a;i.addBufferListener(h,"updatestart",i._onSBUpdateStart),i.addBufferListener(h,"updateend",i._onSBUpdateEnd),i.addBufferListener(h,"error",i._onSBUpdateError),i.appendSource&&i.addBufferListener(h,"bufferedchange",function(t,e){var r=e.removedRanges;null!=r&&r.length&&i.hls.trigger(O.BUFFER_FLUSHED,{type:a})}),i.tracks[a]={buffer:d,codec:l,container:o.container,levelCodec:o.levelCodec,metadata:o.metadata,id:o.id}}catch(f){i.error("error while trying to add sourceBuffer: "+f.message),i.hls.trigger(O.ERROR,{type:N.MEDIA_ERROR,details:M.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:f,sourceBufferName:a,mimeType:u})}}};for(var s in e)a(s)},e._onSBUpdateStart=function t(e){this.operationQueue.current(e).onStart()},e._onSBUpdateEnd=function t(e){if((null==(i=this.mediaSource)?void 0:i.readyState)==="closed"){this.resetBuffer(e);return}var i,r=this.operationQueue;r.current(e).onComplete(),r.shiftAndExecuteNext(e)},e._onSBUpdateError=function t(e,i){var r,n=Error(e+" SourceBuffer error. MediaSource readyState: "+(null==(r=this.mediaSource)?void 0:r.readyState));this.error(""+n,i),this.hls.trigger(O.ERROR,{type:N.MEDIA_ERROR,details:M.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:n,fatal:!1});var a=this.operationQueue.current(e);a&&a.onError(n)},e.removeExecutor=function t(e,i,r){var n=this.media,a=this.mediaSource,s=this.operationQueue,o=this.sourceBuffer[e];if(!n||!a||!o){this.warn("Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),s.shiftAndExecuteNext(e);return}var l=w(n.duration)?n.duration:1/0,u=w(a.duration)?a.duration:1/0,d=Math.max(0,i),h=Math.min(r,l,u);h>d&&(!o.ending||o.ended)?(o.ended=!1,this.log("Removing ["+d+","+h+"] from the "+e+" SourceBuffer"),o.remove(d,h)):s.shiftAndExecuteNext(e)},e.appendExecutor=function t(e,i){var r=this.sourceBuffer[i];if(!r){if(!this.pendingTracks[i])throw Error("Attempting to append to the "+i+" SourceBuffer, but it does not exist");return}r.ended=!1,r.appendBuffer(e)},e.blockBuffers=function t(e,i){var r=this;if(void 0===i&&(i=this.getSourceBufferTypes()),!i.length){this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}var n=this.operationQueue;Promise.all(i.map(function(t){return n.appendBlocker(t)})).then(function(){e(),i.forEach(function(t){var e=r.sourceBuffer[t];null!=e&&e.updating||n.shiftAndExecuteNext(t)})})},e.getSourceBufferTypes=function t(){return Object.keys(this.sourceBuffer)},e.addBufferListener=function t(e,i,r){var n=this.sourceBuffer[e];if(n){var a=r.bind(this,e);this.listeners[e].push({event:i,listener:a}),n.addEventListener(i,a)}},e.removeBufferListeners=function t(e){var i=this.sourceBuffer[e];i&&this.listeners[e].forEach(function(t){i.removeEventListener(t.event,t.listener)})},s(t,[{key:"mediaSrc",get:function t(){var e,i,r=(null==(e=this.media)?void 0:null==(i=e.querySelector)?void 0:i.call(e,"source"))||this.media;return null==r?void 0:r.src}}]),t}();function r5(t){var e=t.querySelectorAll("source");[].slice.call(e).forEach(function(e){t.removeChild(e)})}var rq={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},rX=function t(e){return String.fromCharCode(rq[e]||e)},rz={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},rj={17:2,18:4,21:6,22:8,23:10,19:13,20:15},rQ={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},r9={25:2,26:4,29:6,30:8,31:10,27:13,28:15},rZ=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],rJ=function(){function t(){this.time=null,this.verboseLevel=0}return t.prototype.log=function t(e,i){if(this.verboseLevel>=e){var r="function"==typeof i?i():i;H.log(this.time+" ["+e+"] "+r)}},t}(),nt=function t(e){for(var i=[],r=0;r<e.length;r++)i.push(e[r].toString(16));return i},ne=function(){function t(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}var e=t.prototype;return e.reset=function t(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},e.setStyles=function t(e){for(var i=["foreground","underline","italics","background","flash"],r=0;r<i.length;r++){var n=i[r];e.hasOwnProperty(n)&&(this[n]=e[n])}},e.isDefault=function t(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash},e.equals=function t(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash},e.copy=function t(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash},e.toString=function t(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},t}(),ni=function(){function t(){this.uchar=" ",this.penState=new ne}var e=t.prototype;return e.reset=function t(){this.uchar=" ",this.penState.reset()},e.setChar=function t(e,i){this.uchar=e,this.penState.copy(i)},e.setPenState=function t(e){this.penState.copy(e)},e.equals=function t(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)},e.copy=function t(e){this.uchar=e.uchar,this.penState.copy(e.penState)},e.isEmpty=function t(){return" "===this.uchar&&this.penState.isDefault()},t}(),nr=function(){function t(t){this.chars=[],this.pos=0,this.currPenState=new ne,this.cueStartTime=null,this.logger=void 0;for(var e=0;e<100;e++)this.chars.push(new ni);this.logger=t}var e=t.prototype;return e.equals=function t(e){for(var i=0;i<100;i++)if(!this.chars[i].equals(e.chars[i]))return!1;return!0},e.copy=function t(e){for(var i=0;i<100;i++)this.chars[i].copy(e.chars[i])},e.isEmpty=function t(){for(var e=!0,i=0;i<100;i++)if(!this.chars[i].isEmpty()){e=!1;break}return e},e.setCursor=function t(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>100&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=100)},e.moveCursor=function t(e){var i=this.pos+e;if(e>1)for(var r=this.pos+1;r<i+1;r++)this.chars[r].setPenState(this.currPenState);this.setCursor(i)},e.backSpace=function t(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},e.insertChar=function t(e){var i=this;e>=144&&this.backSpace();var r=rX(e);if(this.pos>=100){this.logger.log(0,function(){return"Cannot insert "+e.toString(16)+" ("+r+") at position "+i.pos+". Skipping it!"});return}this.chars[this.pos].setChar(r,this.currPenState),this.moveCursor(1)},e.clearFromPos=function t(e){var i;for(i=e;i<100;i++)this.chars[i].reset()},e.clear=function t(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},e.clearToEndOfRow=function t(){this.clearFromPos(this.pos)},e.getTextString=function t(){for(var e=[],i=!0,r=0;r<100;r++){var n=this.chars[r].uchar;" "!==n&&(i=!1),e.push(n)}return i?"":e.join("")},e.setPenStyles=function t(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)},t}(),nn=function(){function t(t){this.rows=[],this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(var e=0;e<15;e++)this.rows.push(new nr(t));this.logger=t}var e=t.prototype;return e.reset=function t(){for(var e=0;e<15;e++)this.rows[e].clear();this.currRow=14},e.equals=function t(e){for(var i=!0,r=0;r<15;r++)if(!this.rows[r].equals(e.rows[r])){i=!1;break}return i},e.copy=function t(e){for(var i=0;i<15;i++)this.rows[i].copy(e.rows[i])},e.isEmpty=function t(){for(var e=!0,i=0;i<15;i++)if(!this.rows[i].isEmpty()){e=!1;break}return e},e.backSpace=function t(){this.rows[this.currRow].backSpace()},e.clearToEndOfRow=function t(){this.rows[this.currRow].clearToEndOfRow()},e.insertChar=function t(e){this.rows[this.currRow].insertChar(e)},e.setPen=function t(e){this.rows[this.currRow].setPenStyles(e)},e.moveCursor=function t(e){this.rows[this.currRow].moveCursor(e)},e.setCursor=function t(e){this.logger.log(2,"setCursor: "+e),this.rows[this.currRow].setCursor(e)},e.setPAC=function t(e){this.logger.log(2,function(){return"pacData = "+JSON.stringify(e)});var i=e.row-1;if(this.nrRollUpRows&&i<this.nrRollUpRows-1&&(i=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==i){for(var r=0;r<15;r++)this.rows[r].clear();var n=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){var s=a.rows[n].cueStartTime,o=this.logger.time;if(null!==s&&null!==o&&s<o)for(var l=0;l<this.nrRollUpRows;l++)this.rows[i-this.nrRollUpRows+l+1].copy(a.rows[n+l])}}this.currRow=i;var u=this.rows[this.currRow];if(null!==e.indent){var d=e.indent;u.setCursor(e.indent),e.color=u.chars[Math.max(d-1,0)].penState.foreground}var h={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(h)},e.setBkgData=function t(e){this.logger.log(2,function(){return"bkgData = "+JSON.stringify(e)}),this.backSpace(),this.setPen(e),this.insertChar(32)},e.setRollUpRows=function t(e){this.nrRollUpRows=e},e.rollUp=function t(){var e=this;if(null===this.nrRollUpRows){this.logger.log(3,"roll_up but nrRollUpRows not set yet");return}this.logger.log(1,function(){return e.getDisplayText()});var i=this.currRow+1-this.nrRollUpRows,r=this.rows.splice(i,1)[0];r.clear(),this.rows.splice(this.currRow,0,r),this.logger.log(2,"Rolling up")},e.getDisplayText=function t(e){e=e||!1;for(var i=[],r="",n=-1,a=0;a<15;a++){var s=this.rows[a].getTextString();s&&(n=a+1,e?i.push("Row "+n+": '"+s+"'"):i.push(s.trim()))}return i.length>0&&(r=e?"["+i.join(" | ")+"]":i.join("\n")),r},e.getTextAndFormat=function t(){return this.rows},t}(),na=function(){function t(t,e,i){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=t,this.outputFilter=e,this.mode=null,this.verbose=0,this.displayedMemory=new nn(i),this.nonDisplayedMemory=new nn(i),this.lastOutputScreen=new nn(i),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=i}var e=t.prototype;return e.reset=function t(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},e.getHandler=function t(){return this.outputFilter},e.setHandler=function t(e){this.outputFilter=e},e.setPAC=function t(e){this.writeScreen.setPAC(e)},e.setBkgData=function t(e){this.writeScreen.setBkgData(e)},e.setMode=function t(e){e!==this.mode&&(this.mode=e,this.logger.log(2,function(){return"MODE="+e}),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)},e.insertChars=function t(e){for(var i=this,r=0;r<e.length;r++)this.writeScreen.insertChar(e[r]);var n=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,function(){return n+": "+i.writeScreen.getDisplayText(!0)}),("MODE_PAINT-ON"===this.mode||"MODE_ROLL-UP"===this.mode)&&(this.logger.log(1,function(){return"DISPLAYED: "+i.displayedMemory.getDisplayText(!0)}),this.outputDataUpdate())},e.ccRCL=function t(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},e.ccBS=function t(){this.logger.log(2,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},e.ccAOF=function t(){},e.ccAON=function t(){},e.ccDER=function t(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},e.ccRU=function t(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)},e.ccFON=function t(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},e.ccRDC=function t(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},e.ccTR=function t(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")},e.ccRTD=function t(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")},e.ccEDM=function t(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},e.ccCR=function t(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},e.ccENM=function t(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},e.ccEOC=function t(){var e=this;if(this.logger.log(2,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){var i=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=i,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,function(){return"DISP: "+e.displayedMemory.getDisplayText()})}this.outputDataUpdate(!0)},e.ccTO=function t(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)},e.ccMIDROW=function t(e){var i={flash:!1};i.underline=e%2==1,i.italics=e>=46,i.italics?i.foreground="white":i.foreground=["white","green","blue","cyan","red","yellow","magenta"][Math.floor(e/2)-16],this.logger.log(2,"MIDROW: "+JSON.stringify(i)),this.writeScreen.setPen(i)},e.outputDataUpdate=function t(e){void 0===e&&(e=!1);var i=this.logger.time;null!==i&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,i,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:i):this.cueStartTime=i,this.lastOutputScreen.copy(this.displayedMemory))},e.cueSplitAtTime=function t(e){this.outputFilter&&!this.displayedMemory.isEmpty()&&(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e)},t}(),ns=function(){function t(t,e,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory={a:null,b:null},this.logger=void 0;var r=this.logger=new rJ;this.channels=[null,new na(t,e,r),new na(t+1,i,r)]}var e=t.prototype;return e.getHandler=function t(e){return this.channels[e].getHandler()},e.setHandler=function t(e,i){this.channels[e].setHandler(i)},e.addData=function t(e,i){var r=this;this.logger.time=e;for(var n,a=function t(e){var n,a,s,o=127&i[e],l=127&i[e+1],u=!1,d=null;if(0===o&&0===l)return 0;r.logger.log(3,function(){return"["+nt([i[e],i[e+1]])+"] -> ("+nt([o,l])+")"});var h=r.cmdHistory;if(o>=16&&o<=31){if(n=o,a=l,s=h,s.a===n&&s.b===a)return no(null,null,h),r.logger.log(3,function(){return"Repeated command ("+nt([o,l])+") is dropped"}),0;no(o,l,r.cmdHistory),(u=r.parseCmd(o,l))||(u=r.parseMidrow(o,l)),u||(u=r.parsePAC(o,l)),u||(u=r.parseBackgroundAttributes(o,l))}else no(null,null,h);if(!u&&(d=r.parseChars(o,l))){var f=r.currentChannel;f&&f>0?r.channels[f].insertChars(d):r.logger.log(2,"No channel found yet. TEXT-MODE?")}u||d||r.logger.log(2,function(){return"Couldn't parse cleaned data "+nt([o,l])+" orig: "+nt([i[e],i[e+1]])})},s=0;s<i.length;s+=2)if(0===(n=a(s)))continue},e.parseCmd=function t(e,i){if(!((20===e||28===e||21===e||29===e)&&i>=32&&i<=47||(23===e||31===e)&&i>=33&&i<=35))return!1;var r=20===e||21===e||23===e?1:2,n=this.channels[r];return 20===e||21===e||28===e||29===e?32===i?n.ccRCL():33===i?n.ccBS():34===i?n.ccAOF():35===i?n.ccAON():36===i?n.ccDER():37===i?n.ccRU(2):38===i?n.ccRU(3):39===i?n.ccRU(4):40===i?n.ccFON():41===i?n.ccRDC():42===i?n.ccTR():43===i?n.ccRTD():44===i?n.ccEDM():45===i?n.ccCR():46===i?n.ccENM():47===i&&n.ccEOC():n.ccTO(i-32),this.currentChannel=r,!0},e.parseMidrow=function t(e,i){var r=0;if((17===e||25===e)&&i>=32&&i<=47){if((r=17===e?1:2)!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;var n=this.channels[r];return!!n&&(n.ccMIDROW(i),this.logger.log(3,function(){return"MIDROW ("+nt([e,i])+")"}),!0)}return!1},e.parsePAC=function t(e,i){if(!((e>=17&&e<=23||e>=25&&e<=31)&&i>=64&&i<=127||(16===e||24===e)&&i>=64&&i<=95))return!1;var r,n=e<=23?1:2;r=i>=64&&i<=95?1===n?rz[e]:rQ[e]:1===n?rj[e]:r9[e];var a=this.channels[n];return!!a&&(a.setPAC(this.interpretPAC(r,i)),this.currentChannel=n,!0)},e.interpretPAC=function t(e,i){var r,n={color:null,italics:!1,indent:null,underline:!1,row:e};return r=i>95?i-96:i-64,n.underline=(1&r)==1,r<=13?n.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(n.italics=!0,n.color="white"):n.indent=4*Math.floor((r-16)/2),n},e.parseChars=function t(e,i){var r,n,a=null,s=null;return e>=25?(r=2,s=e-8):(r=1,s=e),s>=17&&s<=19?(n=17===s?i+80:18===s?i+112:i+144,this.logger.log(2,function(){return"Special char '"+rX(n)+"' in channel "+r}),a=[n]):e>=32&&e<=127&&(a=0===i?[e]:[e,i]),a&&this.logger.log(3,function(){return"Char codes = "+nt(a).join(",")}),a},e.parseBackgroundAttributes=function t(e,i){if(!((16===e||24===e)&&i>=32&&i<=47||(23===e||31===e)&&i>=45&&i<=47))return!1;var r,n={};return 16===e||24===e?(r=Math.floor((i-32)/2),n.background=rZ[r],i%2==1&&(n.background=n.background+"_semi")):45===i?n.background="transparent":(n.foreground="black",47===i&&(n.underline=!0)),this.channels[e<=23?1:2].setBkgData(n),!0},e.reset=function t(){for(var e=0;e<Object.keys(this.channels).length;e++){var i=this.channels[e];i&&i.reset()}no(null,null,this.cmdHistory)},e.cueSplitAtTime=function t(e){for(var i=0;i<this.channels.length;i++){var r=this.channels[i];r&&r.cueSplitAtTime(e)}},t}();function no(t,e,i){i.a=t,i.b=e}var nl=function(){function t(t,e){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=t,this.trackName=e}var e=t.prototype;return e.dispatchCue=function t(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},e.newCue=function t(e,i,r){(null===this.startTime||this.startTime>e)&&(this.startTime=e),this.endTime=i,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)},e.reset=function t(){this.cueRanges=[],this.startTime=null},t}(),nu=function(){if(null!=tn&&tn.VTTCue)return self.VTTCue;var t=["","lr","rl"],e=["start","middle","end","left","right"];function i(t,e){if("string"!=typeof e||!Array.isArray(t))return!1;var i=e.toLowerCase();return!!~t.indexOf(i)&&i}function r(t){return i(e,t)}function n(t){for(var e=arguments.length,i=Array(e>1?e-1:0),r=1;r<e;r++)i[r-1]=arguments[r];for(var n=1;n<arguments.length;n++){var a=arguments[n];for(var s in a)t[s]=a[s]}return t}function a(e,a,s){var o=this,l={enumerable:!0};o.hasBeenReset=!1;var u="",d=!1,h=e,f=a,c=s,$=null,g="",v=!0,m="auto",p="start",y=50,T="middle",x=50,E="middle";Object.defineProperty(o,"id",n({},l,{get:function t(){return u},set:function t(e){u=""+e}})),Object.defineProperty(o,"pauseOnExit",n({},l,{get:function t(){return d},set:function t(e){d=!!e}})),Object.defineProperty(o,"startTime",n({},l,{get:function t(){return h},set:function t(e){if("number"!=typeof e)throw TypeError("Start time must be set to a number.");h=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"endTime",n({},l,{get:function t(){return f},set:function t(e){if("number"!=typeof e)throw TypeError("End time must be set to a number.");f=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"text",n({},l,{get:function t(){return c},set:function t(e){c=""+e,this.hasBeenReset=!0}})),Object.defineProperty(o,"region",n({},l,{get:function t(){return $},set:function t(e){$=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"vertical",n({},l,{get:function t(){return g},set:function e(r){var n,a=(n=r,i(t,n));if(!1===a)throw SyntaxError("An invalid or illegal string was specified.");g=a,this.hasBeenReset=!0}})),Object.defineProperty(o,"snapToLines",n({},l,{get:function t(){return v},set:function t(e){v=!!e,this.hasBeenReset=!0}})),Object.defineProperty(o,"line",n({},l,{get:function t(){return m},set:function t(e){if("number"!=typeof e&&"auto"!==e)throw SyntaxError("An invalid number or illegal string was specified.");m=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"lineAlign",n({},l,{get:function t(){return p},set:function t(e){var i=r(e);if(!i)throw SyntaxError("An invalid or illegal string was specified.");p=i,this.hasBeenReset=!0}})),Object.defineProperty(o,"position",n({},l,{get:function t(){return y},set:function t(e){if(e<0||e>100)throw Error("Position must be between 0 and 100.");y=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"positionAlign",n({},l,{get:function t(){return T},set:function t(e){var i=r(e);if(!i)throw SyntaxError("An invalid or illegal string was specified.");T=i,this.hasBeenReset=!0}})),Object.defineProperty(o,"size",n({},l,{get:function t(){return x},set:function t(e){if(e<0||e>100)throw Error("Size must be between 0 and 100.");x=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"align",n({},l,{get:function t(){return E},set:function t(e){var i=r(e);if(!i)throw SyntaxError("An invalid or illegal string was specified.");E=i,this.hasBeenReset=!0}})),o.displayState=void 0}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a}(),nd=function(){function t(){}return t.prototype.decode=function t(e,i){if(!e)return"";if("string"!=typeof e)throw Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))},t}();function nh(t){function e(t,e,i,r){return(0|t)*3600+(0|e)*60+(0|i)+parseFloat(r||0)}var i=t.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return i?parseFloat(i[2])>59?e(i[2],i[3],0,i[4]):e(i[1],i[2],i[3],i[4]):null}var nf=function(){function t(){this.values=Object.create(null)}var e=t.prototype;return e.set=function t(e,i){this.get(e)||""===i||(this.values[e]=i)},e.get=function t(e,i,r){return r?this.has(e)?this.values[e]:i[r]:this.has(e)?this.values[e]:i},e.has=function t(e){return e in this.values},e.alt=function t(e,i,r){for(var n=0;n<r.length;++n)if(i===r[n]){this.set(e,i);break}},e.integer=function t(e,i){/^-?\d+$/.test(i)&&this.set(e,parseInt(i,10))},e.percent=function t(e,i){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(i)){var t=parseFloat(i);if(t>=0&&t<=100)return this.set(e,t),!0}return!1},t}();function nc(t,e,i,r){var n=r?t.split(r):[t];for(var a in n){if("string"==typeof n[a]){var s,o=n[a].split(i);if(2===o.length){e(o[0],o[1])}}}}var n$=new nu(0,0,""),ng="middle"===n$.align?"middle":"center";function nv(t,e,i){var r,n,a,s,o,l=t;function u(){var e=nh(t);if(null===e)throw Error("Malformed timestamp: "+l);return t=t.replace(/^[^\sa-zA-Z-]+/,""),e}function d(){t=t.replace(/^\s+/,"")}if(d(),e.startTime=u(),d(),"-->"!==t.slice(0,3))throw Error("Malformed time stamp (time stamps must be separated by '-->'): "+l);t=t.slice(3),d(),e.endTime=u(),d(),r=t,n=e,a=new nf,nc(r,function(t,e){var r;switch(t){case"region":for(var n=i.length-1;n>=0;n--)if(i[n].id===e){a.set(t,i[n].region);break}break;case"vertical":a.alt(t,e,["rl","lr"]);break;case"line":r=e.split(","),a.integer(t,r[0]),a.percent(t,r[0])&&a.set("snapToLines",!1),a.alt(t,r[0],["auto"]),2===r.length&&a.alt("lineAlign",r[1],["start",ng,"end"]);break;case"position":r=e.split(","),a.percent(t,r[0]),2===r.length&&a.alt("positionAlign",r[1],["start",ng,"end","line-left","line-right","auto"]);break;case"size":a.percent(t,e);break;case"align":a.alt(t,e,["start",ng,"end","left","right"])}},/:/,/\s/),n.region=a.get("region",null),n.vertical=a.get("vertical",""),"auto"===(s=a.get("line","auto"))&&-1===n$.line&&(s=-1),n.line=s,n.lineAlign=a.get("lineAlign","start"),n.snapToLines=a.get("snapToLines",!0),n.size=a.get("size",100),n.align=a.get("align",ng),"auto"===(o=a.get("position","auto"))&&50===n$.position&&(o="start"===n.align||"left"===n.align?0:"end"===n.align||"right"===n.align?100:50),n.position=o}function nm(t){return t.replace(/<br(?: \/)?>/gi,"\n")}var np=function(){function t(){this.state="INITIAL",this.buffer="",this.decoder=new nd,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var e=t.prototype;return e.parse=function t(e){var i=this;function r(){var t=i.buffer,e=0;for(t=nm(t);e<t.length&&"\r"!==t[e]&&"\n"!==t[e];)++e;var r=t.slice(0,e);return"\r"===t[e]&&++e,"\n"===t[e]&&++e,i.buffer=t.slice(e),r}function n(t){nc(t,function(t,e){},/:/)}e&&(i.buffer+=i.decoder.decode(e,{stream:!0}));try{var a="";if("INITIAL"===i.state){if(!/\r\n|\n/.test(i.buffer))return this;var s=(a=r()).match(/^()?WEBVTT([ \t].*)?$/);if(!(null!=s&&s[0]))throw Error("Malformed WebVTT signature.");i.state="HEADER"}for(var o=!1;i.buffer&&/\r\n|\n/.test(i.buffer);)switch(o?o=!1:a=r(),i.state){case"HEADER":/:/.test(a)?n(a):a||(i.state="ID");continue;case"NOTE":a||(i.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(a)){i.state="NOTE";break}if(!a)continue;if(i.cue=new nu(0,0,""),i.state="CUE",-1===a.indexOf("-->")){i.cue.id=a;continue}case"CUE":if(!i.cue){i.state="BADCUE";continue}try{nv(a,i.cue,i.regionList)}catch(l){i.cue=null,i.state="BADCUE";continue}i.state="CUETEXT";continue;case"CUETEXT":var u=-1!==a.indexOf("-->");if(!a||u&&(o=!0)){i.oncue&&i.cue&&i.oncue(i.cue),i.cue=null,i.state="ID";continue}if(null===i.cue)continue;i.cue.text&&(i.cue.text+="\n"),i.cue.text+=a;continue;case"BADCUE":a||(i.state="ID")}}catch(d){"CUETEXT"===i.state&&i.cue&&i.oncue&&i.oncue(i.cue),i.cue=null,i.state="INITIAL"===i.state?"BADWEBVTT":"BADCUE"}return this},e.flush=function t(){var e=this;try{if((e.cue||"HEADER"===e.state)&&(e.buffer+="\n\n",e.parse()),"INITIAL"===e.state||"BADWEBVTT"===e.state)throw Error("Malformed WebVTT signature.")}catch(i){e.onparsingerror&&e.onparsingerror(i)}return e.onflush&&e.onflush(),this},t}(),ny=/\r\n|\n\r|\n|\r/g,nT=function t(e,i,r){return void 0===r&&(r=0),e.slice(r,r+i.length)===i},nx=function t(e){var i=parseInt(e.slice(-3)),r=parseInt(e.slice(-6,-4)),n=parseInt(e.slice(-9,-7)),a=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!w(i)||!w(r)||!w(n)||!w(a))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+e);return i+=1e3*r,i+=6e4*n,i+=36e5*a},nE=function t(e){for(var t=5381,i=e.length;i;)t=33*t^e.charCodeAt(--i);return(t>>>0).toString()};function nS(t,e,i){return nE(t.toString())+nE(e.toString())+nE(i)}var nL=function t(e,i,r){var n,a=e[i],s=e[a.prevCC];if(!s||!s.new&&a.new){e.ccOffset=e.presentationOffset=a.start,a.new=!1;return}for(;null!=(n=s)&&n.new;)e.ccOffset+=a.start-s.start,a.new=!1,s=e[(a=s).prevCC];e.presentationOffset=r},nA="stpp.ttml.im1t",nR=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,n_=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,nD={left:"start",center:"center",right:"end",start:"start",end:"end"};function nk(t,e,i,r){var n=tO(new Uint8Array(t),["mdat"]);if(0===n.length){r(Error("Could not parse IMSC1 mdat"));return}var a,s,o,u=n.map(function(t){return t_(t)}),d=(a=e.baseTime,void 0===(s=e.timescale)&&(s=1),void 0===o&&(o=!1),ry(a,1,1/s,o));try{u.forEach(function(t){return i(function t(e,i){var r=new DOMParser().parseFromString(e,"text/xml").getElementsByTagName("tt")[0];if(!r)throw Error("Invalid ttml");var n={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},a=Object.keys(n).reduce(function(t,e){return t[e]=r.getAttribute("ttp:"+e)||n[e],t},{}),s="preserve"!==r.getAttribute("xml:space"),o=nb(nI(r,"styling","style")),u=nb(nI(r,"layout","region")),d=nI(r,"body","[begin]");return[].map.call(d,function(t){var e=function t(e,i){return[].slice.call(e.childNodes).reduce(function(e,r,n){var a;return"br"===r.nodeName&&n?e+"\n":null!=(a=r.childNodes)&&a.length?t(r,i):i?e+r.textContent.trim().replace(/\s+/g," "):e+r.textContent},"")}(t,s);if(!e||!t.hasAttribute("begin"))return null;var r=nw(t.getAttribute("begin"),a),n=nw(t.getAttribute("dur"),a),d=nw(t.getAttribute("end"),a);if(null===r)throw n8(t);if(null===d){if(null===n)throw n8(t);d=r+n}var h,f,c,$,g,v,m=new nu(r-i,d-i,e);m.id=nS(m.startTime,m.endTime,m.text);var p,y=(h=u[t.getAttribute("region")],f=o[t.getAttribute("style")],c=o,$="http://www.w3.org/ns/ttml#styling",g=null,v=null!=h&&h.hasAttribute("style")?h.getAttribute("style"):null,v&&c.hasOwnProperty(v)&&(g=c[v]),["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"].reduce(function(t,e){var i=nC(f,$,e)||nC(h,$,e)||nC(g,$,e);return i&&(t[e]=i),t},{})),T=y.textAlign;if(T){var x=nD[T];x&&(m.lineAlign=x),m.align=T}return l(m,y),m}).filter(function(t){return null!==t})}(t,d))})}catch(h){r(h)}}function nI(t,e,i){var r=t.getElementsByTagName(e)[0];return r?[].slice.call(r.querySelectorAll(i)):[]}function nb(t){return t.reduce(function(t,e){var i=e.getAttribute("xml:id");return i&&(t[i]=e),t},{})}function nC(t,e,i){return t&&t.hasAttributeNS(e,i)?t.getAttributeNS(e,i):null}function n8(t){return Error("Could not parse ttml timestamp "+t)}function nw(t,e){if(!t)return null;var i,r,n,a,s=nh(t);return null===s&&(nR.test(t)?s=(i=t,r=e,n=nR.exec(i),a=(0|n[4])+(0|n[5])/r.subFrameRate,(0|n[1])*3600+(0|n[2])*60+(0|n[3])+a/r.frameRate):n_.test(t)&&(s=function t(e,i){var r=n_.exec(e),n=Number(r[1]),a=r[2];switch(a){case"h":return 3600*n;case"m":return 60*n;case"ms":return 1e3*n;case"f":return n/i.frameRate;case"t":return n/i.tickRate}return n}(t,e))),s}var nP=function(){function t(t){this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=nM(),this.captionsProperties=void 0,this.hls=t,this.config=t.config,this.Cues=t.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},t.on(O.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(O.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(O.MANIFEST_LOADING,this.onManifestLoading,this),t.on(O.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(O.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(O.FRAG_LOADING,this.onFragLoading,this),t.on(O.FRAG_LOADED,this.onFragLoaded,this),t.on(O.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.on(O.FRAG_DECRYPTED,this.onFragDecrypted,this),t.on(O.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(O.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.on(O.BUFFER_FLUSHING,this.onBufferFlushing,this)}var e=t.prototype;return e.destroy=function t(){var e=this.hls;e.off(O.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(O.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(O.MANIFEST_LOADING,this.onManifestLoading,this),e.off(O.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(O.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(O.FRAG_LOADING,this.onFragLoading,this),e.off(O.FRAG_LOADED,this.onFragLoaded,this),e.off(O.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(O.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(O.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(O.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(O.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=null,this.cea608Parser1=this.cea608Parser2=void 0},e.initCea608Parsers=function t(){if(this.config.enableCEA708Captions&&(!this.cea608Parser1||!this.cea608Parser2)){var e=new nl(this,"textTrack1"),i=new nl(this,"textTrack2"),r=new nl(this,"textTrack3"),n=new nl(this,"textTrack4");this.cea608Parser1=new ns(1,e,i),this.cea608Parser2=new ns(3,r,n)}},e.addCues=function t(e,i,r,n,a){for(var s=!1,o=a.length;o--;){var l=a[o],u=nN(l[0],l[1],i,r);if(u>=0&&(l[0]=Math.min(l[0],i),l[1]=Math.max(l[1],r),s=!0,u/(r-i)>.5))return}if(s||a.push([i,r]),this.config.renderTextTracksNatively){var d=this.captionsTracks[e];this.Cues.newCue(d,i,r,n)}else{var h=this.Cues.newCue(null,i,r,n);this.hls.trigger(O.CUES_PARSED,{type:"captions",cues:h,track:e})}},e.onInitPtsFound=function t(e,i){var r=this,n=i.frag,a=i.id,s=i.initPTS,o=i.timescale,l=this.unparsedVttFrags;"main"===a&&(this.initPTS[n.cc]={baseTime:s,timescale:o}),l.length&&(this.unparsedVttFrags=[],l.forEach(function(t){r.onFragLoaded(O.FRAG_LOADED,t)}))},e.getExistingTrack=function t(e,i){var r=this.media;if(r)for(var n=0;n<r.textTracks.length;n++){var a=r.textTracks[n];if(nO(a,{name:e,lang:i,attrs:{}}))return a}return null},e.createCaptionsTrack=function t(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)},e.createNativeTrack=function t(e){if(!this.captionsTracks[e]){var i=this.captionsProperties,r=this.captionsTracks,n=this.media,a=i[e],s=a.label,o=a.languageCode,l=this.getExistingTrack(s,o);if(l)r[e]=l,eR(r[e]),eL(r[e],n);else{var u=this.createTextTrack("captions",s,o);u&&(u[e]=!0,r[e]=u)}}},e.createNonNativeTrack=function t(e){if(!this.nonNativeCaptionsTracks[e]){var i=this.captionsProperties[e];if(i){var r={_id:e,label:i.label,kind:"captions",default:!!i.media&&!!i.media.default,closedCaptions:i.media};this.nonNativeCaptionsTracks[e]=r,this.hls.trigger(O.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[r]})}}},e.createTextTrack=function t(e,i,r){var n=this.media;if(n)return n.addTextTrack(e,i,r)},e.onMediaAttaching=function t(e,i){this.media=i.media,this._cleanTracks()},e.onMediaDetaching=function t(){var e=this.captionsTracks;Object.keys(e).forEach(function(t){eR(e[t]),delete e[t]}),this.nonNativeCaptionsTracks={}},e.onManifestLoading=function t(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=nM(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},e._cleanTracks=function t(){var e=this.media;if(e){var i=e.textTracks;if(i)for(var r=0;r<i.length;r++)eR(i[r])}},e.onSubtitleTracksUpdated=function t(e,i){var r=this,n=i.subtitleTracks||[],a=n.some(function(t){return t.textCodec===nA});if(this.config.enableWebVTT||a&&this.config.enableIMSC1){if(r2(this.tracks,n)){this.tracks=n;return}if(this.textTracks=[],this.tracks=n,this.config.renderTextTracksNatively){var s=this.media,o=s?eD(s.textTracks):null;if(this.tracks.forEach(function(t,e){var i;if(o){for(var n=null,a=0;a<o.length;a++)if(o[a]&&nO(o[a],t)){n=o[a],o[a]=null;break}n&&(i=n)}if(i)eR(i);else{var s=nF(t);(i=r.createTextTrack(s,t.name,t.lang))&&(i.mode="disabled")}i&&r.textTracks.push(i)}),null!=o&&o.length){var l=o.filter(function(t){return null!==t}).map(function(t){return t.label});l.length&&H.warn("Media element contains unused subtitle tracks: "+l.join(", ")+". Replace media element for each source to clear TextTracks and captions menu.")}}else if(this.tracks.length){var u=this.tracks.map(function(t){return{label:t.name,kind:t.type.toLowerCase(),default:t.default,subtitleTrack:t}});this.hls.trigger(O.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:u})}}},e.onManifestLoaded=function t(e,i){var r=this;this.config.enableCEA708Captions&&i.captions&&i.captions.forEach(function(t){var e=/(?:CC|SERVICE)([1-4])/.exec(t.instreamId);if(e){var i="textTrack"+e[1],n=r.captionsProperties[i];n&&(n.label=t.name,t.lang&&(n.languageCode=t.lang),n.media=t)}})},e.closedCaptionsForLevel=function t(e){var i=this.hls.levels[e.level];return null==i?void 0:i.attrs["CLOSED-CAPTIONS"]},e.onFragLoading=function t(e,i){if(this.enabled&&i.frag.type===eT.MAIN){var r,n,a=this.cea608Parser1,s=this.cea608Parser2,o=this.lastSn,l=i.frag,u=l.cc,d=l.sn,h=null!=(r=null==(n=i.part)?void 0:n.index)?r:-1;a&&s&&(d!==o+1||d===o&&h!==this.lastPartIndex+1||u!==this.lastCc)&&(a.reset(),s.reset()),this.lastCc=u,this.lastSn=d,this.lastPartIndex=h}},e.onFragLoaded=function t(e,i){var r=i.frag,n=i.payload;if(r.type===eT.SUBTITLE){if(n.byteLength){var a=r.decryptdata;if(null==a||!a.encrypted||"stats"in i){var s=this.tracks[r.level],o=this.vttCCs;o[r.cc]||(o[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),s&&s.textCodec===nA?this._parseIMSC1(r,n):this._parseVTTs(i)}}else this.hls.trigger(O.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:Error("Empty subtitle payload")})}},e._parseIMSC1=function t(e,i){var r=this,n=this.hls;nk(i,this.initPTS[e.cc],function(t){r._appendCues(t,e.level),n.trigger(O.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},function(t){H.log("Failed to parse IMSC1: "+t),n.trigger(O.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:t})})},e._parseVTTs=function t(e){var i,r=this,n=e.frag,a=e.payload,s=this.initPTS,o=this.unparsedVttFrags,l=s.length-1;if(!s[n.cc]&&-1===l){o.push(e);return}var u,d,h,f,c,$,g,v,m,p,y,T,x,E,S,L,A,R,_=this.hls;u=null!=(i=n.initSegment)&&i.data?t6(n.initSegment.data,new Uint8Array(a)):a,d=this.initPTS[n.cc],h=this.vttCCs,f=n.cc,c=n.start,$=function(t){r._appendCues(t,n.level),_.trigger(O.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:n})},g=function(t){var i="Missing initPTS for VTT MPEGTS"===t.message;i?o.push(e):r._fallbackToIMSC1(n,a),H.log("Failed to parse VTT cue: "+t),(!i||!(l>n.cc))&&_.trigger(O.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:n,error:t})},m=new np,p=t_(new Uint8Array(u)).trim().replace(ny,"\n").split("\n"),y=[],E=d?(T=d.baseTime,void 0===(x=d.timescale)&&(x=1),ry(T,9e4,1/x)):0,S="00:00.000",L=0,A=0,R=!0,m.oncue=function(t){var e=h[f],i=h.ccOffset,r=(L-E)/9e4;if(null!=e&&e.new&&(void 0!==A?i=h.ccOffset=e.start:nL(h,f,r)),r){if(!d){v=Error("Missing initPTS for VTT MPEGTS");return}i=r-h.presentationOffset}var n=t.endTime-t.startTime,a=rL((t.startTime+i-A)*9e4,9e4*c)/9e4;t.startTime=Math.max(a,0),t.endTime=Math.max(a+n,0);var s=t.text.trim();t.text=decodeURIComponent(encodeURIComponent(s)),t.id||(t.id=nS(t.startTime,t.endTime,s)),t.endTime>0&&y.push(t)},m.onparsingerror=function(t){v=t},m.onflush=function(){if(v){g(v);return}$(y)},p.forEach(function(t){if(R){if(nT(t,"X-TIMESTAMP-MAP=")){R=!1,t.slice(16).split(",").forEach(function(t){nT(t,"LOCAL:")?S=t.slice(6):nT(t,"MPEGTS:")&&(L=parseInt(t.slice(7)))});try{A=nx(S)/1e3}catch(e){v=e}return}""===t&&(R=!1)}m.parse(t+"\n")}),m.flush()},e._fallbackToIMSC1=function t(e,i){var r=this,n=this.tracks[e.level];n.textCodec||nk(i,this.initPTS[e.cc],function(){n.textCodec=nA,r._parseIMSC1(e,i)},function(){n.textCodec="wvtt"})},e._appendCues=function t(e,i){var r=this.hls;if(this.config.renderTextTracksNatively){var n=this.textTracks[i];if(!n||"disabled"===n.mode)return;e.forEach(function(t){return eA(n,t)})}else{var a=this.tracks[i];if(!a)return;var s=a.default?"default":"subtitles"+i;r.trigger(O.CUES_PARSED,{type:"subtitles",cues:e,track:s})}},e.onFragDecrypted=function t(e,i){i.frag.type===eT.SUBTITLE&&this.onFragLoaded(O.FRAG_LOADED,i)},e.onSubtitleTracksCleared=function t(){this.tracks=[],this.captionsTracks={}},e.onFragParsingUserdata=function t(e,i){this.initCea608Parsers();var r=this.cea608Parser1,n=this.cea608Parser2;if(this.enabled&&r&&n){var a=i.frag,s=i.samples;if(a.type!==eT.MAIN||"NONE"!==this.closedCaptionsForLevel(a))for(var o=0;o<s.length;o++){var l=s[o].bytes;if(l){var u=this.extractCea608Data(l);r.addData(s[o].pts,u[0]),n.addData(s[o].pts,u[1])}}}},e.onBufferFlushing=function t(e,i){var r=i.startOffset,n=i.endOffset,a=i.endOffsetSubtitles,s=i.type,o=this.media;if(o&&!(o.currentTime<n)){if(!s||"video"===s){var l=this.captionsTracks;Object.keys(l).forEach(function(t){return e_(l[t],r,n)})}if(this.config.renderTextTracksNatively&&0===r&&void 0!==a){var u=this.textTracks;Object.keys(u).forEach(function(t){return e_(u[t],r,a)})}}},e.extractCea608Data=function t(e){for(var i=[[],[]],r=31&e[0],n=2,a=0;a<r;a++){var s=e[n++],o=127&e[n++],l=127&e[n++];if((0!==o||0!==l)&&(4&s)!=0){var u=3&s;(0===u||1===u)&&(i[u].push(o),i[u].push(l))}}return i},t}();function nF(t){return t.characteristics&&/transcribes-spoken-dialog/gi.test(t.characteristics)&&/describes-music-and-sound/gi.test(t.characteristics)?"captions":"subtitles"}function nO(t,e){return!!t&&t.kind===nF(e)&&r6(e,t)}function nN(t,e,i,r){return Math.min(e,r)-Math.max(t,i)}function nM(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}var nB=function(){function t(t){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=t,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var e=t.prototype;return e.setStreamController=function t(e){this.streamController=e},e.destroy=function t(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},e.registerListeners=function t(){var e=this.hls;e.on(O.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(O.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(O.MANIFEST_PARSED,this.onManifestParsed,this),e.on(O.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(O.BUFFER_CODECS,this.onBufferCodecs,this),e.on(O.MEDIA_DETACHING,this.onMediaDetaching,this)},e.unregisterListener=function t(){var e=this.hls;e.off(O.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(O.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(O.MANIFEST_PARSED,this.onManifestParsed,this),e.off(O.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(O.BUFFER_CODECS,this.onBufferCodecs,this),e.off(O.MEDIA_DETACHING,this.onMediaDetaching,this)},e.onFpsDropLevelCapping=function t(e,i){var r=this.hls.levels[i.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})},e.onMediaAttaching=function t(e,i){this.media=i.media instanceof HTMLVideoElement?i.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()},e.onManifestParsed=function t(e,i){var r=this.hls;this.restrictedLevels=[],this.firstLevel=i.firstLevel,r.config.capLevelToPlayerSize&&i.video&&this.startCapping()},e.onLevelsUpdated=function t(e,i){this.timer&&w(this.autoLevelCapping)&&this.detectPlayerSize()},e.onBufferCodecs=function t(e,i){this.hls.config.capLevelToPlayerSize&&i.video&&this.startCapping()},e.onMediaDetaching=function t(){this.stopCapping()},e.detectPlayerSize=function t(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0){this.clientRect=null;return}var e=this.hls.levels;if(e.length){var i=this.hls,r=this.getMaxLevel(e.length-1);r!==this.autoLevelCapping&&H.log("Setting autoLevelCapping to "+r+": "+e[r].height+"p@"+e[r].bitrate+" for media "+this.mediaWidth+"x"+this.mediaHeight),i.autoLevelCapping=r,i.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=i.autoLevelCapping}}},e.getMaxLevel=function e(i){var r=this,n=this.hls.levels;if(!n.length)return -1;var a=n.filter(function(t,e){return r.isLevelAllowed(t)&&e<=i});return this.clientRect=null,t.getMaxLevelByMediaSize(a,this.mediaWidth,this.mediaHeight)},e.startCapping=function t(){!this.timer&&(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},e.stopCapping=function t(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},e.getDimensions=function t(){if(this.clientRect)return this.clientRect;var e=this.media,i={width:0,height:0};if(e){var r=e.getBoundingClientRect();i.width=r.width,i.height=r.height,i.width||i.height||(i.width=r.right-r.left||e.width||0,i.height=r.bottom-r.top||e.height||0)}return this.clientRect=i,i},e.isLevelAllowed=function t(e){return!this.restrictedLevels.some(function(t){return e.bitrate===t.bitrate&&e.width===t.width&&e.height===t.height})},t.getMaxLevelByMediaSize=function t(e,i,r){if(!(null!=e&&e.length))return -1;for(var n=e.length-1,a=Math.max(i,r),s=0;s<e.length;s+=1){var o,l,u=e[s];if((u.width>=a||u.height>=a)&&(o=u,!(l=e[s+1])||o.width!==l.width||o.height!==l.height)){n=s;break}}return n},s(t,[{key:"mediaWidth",get:function t(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function t(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function t(){var e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch(i){}return e}}]),t}(),nU=function(){function t(t){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=t,this.registerListeners()}var e=t.prototype;return e.setStreamController=function t(e){this.streamController=e},e.registerListeners=function t(){this.hls.on(O.MEDIA_ATTACHING,this.onMediaAttaching,this)},e.unregisterListeners=function t(){this.hls.off(O.MEDIA_ATTACHING,this.onMediaAttaching,this)},e.destroy=function t(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},e.onMediaAttaching=function t(e,i){var r=this.hls.config;if(r.capLevelOnFPSDrop){var n=i.media instanceof self.HTMLVideoElement?i.media:null;this.media=n,n&&"function"==typeof n.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}},e.checkFPS=function t(e,i,r){var n=performance.now();if(i){if(this.lastTime){var a=n-this.lastTime,s=r-this.lastDroppedFrames,o=i-this.lastDecodedFrames,l=this.hls;if(l.trigger(O.FPS_DROP,{currentDropped:s,currentDecoded:o,totalDroppedFrames:r}),1e3*s/a>0&&s>l.config.fpsDroppedMonitoringThreshold*o){var u=l.currentLevel;H.warn("drop FPS ratio greater than max allowed value for currentLevel: "+u),u>0&&(-1===l.autoLevelCapping||l.autoLevelCapping>=u)&&(u-=1,l.trigger(O.FPS_DROP_LEVEL_CAPPING,{level:u,droppedLevel:l.currentLevel}),l.autoLevelCapping=u,this.streamController.nextLevelSwitch())}}this.lastTime=n,this.lastDroppedFrames=r,this.lastDecodedFrames=i}},e.checkFPSInterval=function t(){var e=this.media;if(e){if(this.isVideoPlaybackQualityAvailable){var i=e.getVideoPlaybackQuality();this.checkFPS(e,i.totalVideoFrames,i.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}},t}(),n0="[eme]",nG=function(){function t(e){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=t.CDMCleanupPromise?[t.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=H.debug.bind(H,n0),this.log=H.log.bind(H,n0),this.warn=H.warn.bind(H,n0),this.error=H.error.bind(H,n0),this.hls=e,this.config=e.config,this.registerListeners()}var e=t.prototype;return e.destroy=function t(){this.unregisterListeners(),this.onMediaDetached();var e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null},e.registerListeners=function t(){this.hls.on(O.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(O.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(O.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(O.MANIFEST_LOADED,this.onManifestLoaded,this)},e.unregisterListeners=function t(){this.hls.off(O.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(O.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(O.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(O.MANIFEST_LOADED,this.onManifestLoaded,this)},e.getLicenseServerUrl=function t(e){var i=this.config,r=i.drmSystems,n=i.widevineLicenseUrl,a=r[e];if(a)return a.licenseUrl;if(e===ta.WIDEVINE&&n)return n;throw Error('no license server URL configured for key-system "'+e+'"')},e.getServerCertificateUrl=function t(e){var i=this.config.drmSystems[e];if(i)return i.serverCertificateUrl;this.log('No Server Certificate in config.drmSystems["'+e+'"]')},e.attemptKeySystemAccess=function t(e){var i=this,r=this.hls.levels,n=function t(e,i,r){return!!e&&r.indexOf(e)===i},a=r.map(function(t){return t.audioCodec}).filter(n),s=r.map(function(t){return t.videoCodec}).filter(n);return a.length+s.length===0&&s.push("avc1.42e01e"),new Promise(function(t,r){!function e(n){var o=n.shift();i.getMediaKeysPromise(o,a,s).then(function(e){return t({keySystem:o,mediaKeys:e})}).catch(function(t){n.length?e(n):t instanceof nK?r(t):r(new nK({type:N.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_NO_ACCESS,error:t,fatal:!0},t.message))})}(e)})},e.requestMediaKeySystemAccess=function t(e,i){var r=this.config.requestMediaKeySystemAccessFunc;if("function"!=typeof r){var n="Configured requestMediaKeySystemAccess is not a function "+r;return null===tf&&"http:"===self.location.protocol&&(n="navigator.requestMediaKeySystemAccess is not available over insecure protocol "+location.protocol),Promise.reject(Error(n))}return r(e,i)},e.getMediaKeysPromise=function t(e,i,r){var n=this,a=function t(e,i,r,n){var a,s,o,l,u;switch(e){case ta.FAIRPLAY:a=["cenc","sinf"];break;case ta.WIDEVINE:case ta.PLAYREADY:a=["cenc"];break;case ta.CLEARKEY:a=["cenc","keyids"];break;default:throw Error("Unknown key-system: "+e)}return s=a,o=i,l=r,u=n,[{initDataTypes:s,persistentState:u.persistentState||"optional",distinctiveIdentifier:u.distinctiveIdentifier||"optional",sessionTypes:u.sessionTypes||[u.sessionType||"temporary"],audioCapabilities:o.map(function(t){return{contentType:'audio/mp4; codecs="'+t+'"',robustness:u.audioRobustness||"",encryptionScheme:u.audioEncryptionScheme||null}}),videoCapabilities:l.map(function(t){return{contentType:'video/mp4; codecs="'+t+'"',robustness:u.videoRobustness||"",encryptionScheme:u.videoEncryptionScheme||null}})}]}(e,i,r,this.config.drmSystemOptions),s=this.keySystemAccessPromises[e],o=null==s?void 0:s.keySystemAccess;if(!o){this.log('Requesting encrypted media "'+e+'" key-system access with config: '+JSON.stringify(a)),o=this.requestMediaKeySystemAccess(e,a);var l=this.keySystemAccessPromises[e]={keySystemAccess:o};return o.catch(function(t){n.log('Failed to obtain access to key-system "'+e+'": '+t)}),o.then(function(t){n.log('Access for key-system "'+t.keySystem+'" obtained');var i=n.fetchServerCertificate(e);return n.log('Create media-keys for "'+e+'"'),l.mediaKeys=t.createMediaKeys().then(function(t){return n.log('Media-keys created for "'+e+'"'),i.then(function(i){return i?n.setMediaKeysServerCertificate(t,e,i):t})}),l.mediaKeys.catch(function(t){n.error('Failed to create media-keys for "'+e+'"}: '+t)}),l.mediaKeys})}return o.then(function(){return s.mediaKeys})},e.createMediaKeySessionContext=function t(e){var i=e.decryptdata,r=e.keySystem,n=e.mediaKeys;this.log('Creating key-system session "'+r+'" keyId: '+tD.hexDump(i.keyId||[]));var a=n.createSession(),s={decryptdata:i,keySystem:r,mediaKeys:n,mediaKeysSession:a,keyStatus:"status-pending"};return this.mediaKeySessions.push(s),s},e.renewKeySession=function t(e){var i=e.decryptdata;if(i.pssh){var r=this.createMediaKeySessionContext(e),n=this.getKeyIdString(i);this.keyIdToKeySessionPromise[n]=this.generateRequestWithPreferredKeySession(r,"cenc",i.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)},e.getKeyIdString=function t(e){if(!e)throw Error("Could not read keyId of undefined decryptdata");if(null===e.keyId)throw Error("keyId is null");return tD.hexDump(e.keyId)},e.updateKeySession=function t(e,i){var r,n=e.mediaKeysSession;return this.log('Updating key-session "'+n.sessionId+'" for keyID '+tD.hexDump((null==(r=e.decryptdata)?void 0:r.keyId)||[])+"\n } (data length: "+(i?i.byteLength:i)+")"),n.update(i)},e.selectKeySystemFormat=function t(e){var i=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log("Selecting key-system from fragment (sn: "+e.sn+" "+e.type+": "+e.level+") key formats "+i.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(i)),this.keyFormatPromise},e.getKeyFormatPromise=function t(e){var i=this;return new Promise(function(t,r){var n=td(i.config),a=e.map(to).filter(function(t){return!!t&&-1!==n.indexOf(t)});return i.getKeySystemSelectionPromise(a).then(function(e){var i=e.keySystem,n=tu(i);n?t(n):r(Error('Unable to find format for key-system "'+i+'"'))}).catch(r)})},e.loadKey=function t(e){var i=this,r=e.keyInfo.decryptdata,n=this.getKeyIdString(r),a="(keyId: "+n+' format: "'+r.keyFormat+'" method: '+r.method+" uri: "+r.uri+")";this.log("Starting session for key "+a);var s=this.keyIdToKeySessionPromise[n];return s||(s=this.keyIdToKeySessionPromise[n]=this.getKeySystemForKeyPromise(r).then(function(t){var n=t.keySystem,s=t.mediaKeys;return i.throwIfDestroyed(),i.log("Handle encrypted media sn: "+e.frag.sn+" "+e.frag.type+": "+e.frag.level+" using key "+a),i.attemptSetMediaKeys(n,s).then(function(){i.throwIfDestroyed();var t=i.createMediaKeySessionContext({keySystem:n,mediaKeys:s,decryptdata:r});return i.generateRequestWithPreferredKeySession(t,"cenc",r.pssh,"playlist-key")})})).catch(function(t){return i.handleError(t)}),s},e.throwIfDestroyed=function t(e){if(!this.hls)throw Error("invalid state")},e.handleError=function t(e){this.hls&&(this.error(e.message),e instanceof nK?this.hls.trigger(O.ERROR,e.data):this.hls.trigger(O.ERROR,{type:N.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))},e.getKeySystemForKeyPromise=function t(e){var i=this.getKeyIdString(e),r=this.keyIdToKeySessionPromise[i];if(!r){var n=to(e.keyFormat),a=n?[n]:td(this.config);return this.attemptKeySystemAccess(a)}return r},e.getKeySystemSelectionPromise=function t(e){if(e.length||(e=td(this.config)),0===e.length)throw new nK({type:N.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},"Missing key-system license configuration options "+JSON.stringify({drmSystems:this.config.drmSystems}));return this.attemptKeySystemAccess(e)},e._onMediaEncrypted=function t(e){var i=this,r=e.initDataType,n=e.initData;if(this.debug('"'+e.type+'" event: init data type: "'+r+'"'),null!==n){if("sinf"===r&&this.config.drmSystems[ta.FAIRPLAY]){var a=tb(new Uint8Array(n));try{var s=ti(JSON.parse(a).sinf),o=t2(new Uint8Array(s));if(!o)return;d=o.subarray(8,24),h=ta.FAIRPLAY}catch(l){this.warn('Failed to parse sinf "encrypted" event message initData');return}}else{var u=function t(e){if(!(e instanceof ArrayBuffer)||e.byteLength<32)return null;var i={version:0,systemId:"",kids:null,data:null},r=new DataView(e),n=r.getUint32(0);if(e.byteLength!==n&&n>44||1886614376!==r.getUint32(4)||(i.version=r.getUint32(8)>>>24,i.version>1))return null;i.systemId=tD.hexDump(new Uint8Array(e,12,16));var a=r.getUint32(28);if(0===i.version){if(n-32<a)return null;i.data=new Uint8Array(e,32,a)}else if(1===i.version){i.kids=[];for(var s=0;s<a;s++)i.kids.push(new Uint8Array(e,32+16*s,16))}return i}(n);if(null===u)return;0===u.version&&u.systemId===tl.WIDEVINE&&u.data&&(d=u.data.subarray(8,24)),h=function t(e){if(e===tl.WIDEVINE)return ta.WIDEVINE}(u.systemId)}if(h&&d){for(var d,h,f,c=tD.hexDump(d),$=this.keyIdToKeySessionPromise,g=this.mediaKeySessions,v=$[c],m=0;m<g.length&&(0===(f=function t(){var e=g[m],a=e.decryptdata;if(a.pssh||!a.keyId)return 0;var s=tD.hexDump(a.keyId);if(c===s||-1!==a.uri.replace(/-/g,"").indexOf(c))return v=$[s],delete $[s],a.pssh=new Uint8Array(n),a.keyId=d,v=$[c]=v.then(function(){return i.generateRequestWithPreferredKeySession(e,r,n,"encrypted-event-key-match")}),1}())||1!==f);m++);v||(v=$[c]=this.getKeySystemSelectionPromise([h]).then(function(t){var e,a=t.keySystem,s=t.mediaKeys;i.throwIfDestroyed();var o=new t7("ISO-23001-7",c,null!=(e=tu(a))?e:"");return o.pssh=new Uint8Array(n),o.keyId=d,i.attemptSetMediaKeys(a,s).then(function(){i.throwIfDestroyed();var t=i.createMediaKeySessionContext({decryptdata:o,keySystem:a,mediaKeys:s});return i.generateRequestWithPreferredKeySession(t,r,n,"encrypted-event-no-match")})})),v.catch(function(t){return i.handleError(t)})}}},e._onWaitingForKey=function t(e){this.log('"'+e.type+'" event')},e.attemptSetMediaKeys=function t(e,i){var r=this,n=this.setMediaKeysQueue.slice();this.log('Setting media-keys for "'+e+'"');var a=Promise.all(n).then(function(){if(!r.media)throw Error("Attempted to set mediaKeys without media element attached");return r.media.setMediaKeys(i)});return this.setMediaKeysQueue.push(a),a.then(function(){r.log('Media-keys set for "'+e+'"'),n.push(a),r.setMediaKeysQueue=r.setMediaKeysQueue.filter(function(t){return -1===n.indexOf(t)})})},e.generateRequestWithPreferredKeySession=function t(e,i,r,n){var a,s,o=this,l=null==(a=this.config.drmSystems)?void 0:null==(s=a[e.keySystem])?void 0:s.generateRequest;if(l)try{var u,d=l.call(this.hls,i,r,e);if(!d)throw Error("Invalid response from configured generateRequest filter");i=d.initDataType,r=e.decryptdata.pssh=d.initData?new Uint8Array(d.initData):null}catch(h){if(this.warn(h.message),null!=(u=this.hls)&&u.config.debug)throw h}if(null===r)return this.log('Skipping key-session request for "'+n+'" (no initData)'),Promise.resolve(e);var f=this.getKeyIdString(e.decryptdata);this.log('Generating key-session request for "'+n+'": '+f+" (init data type: "+i+" length: "+(r?r.byteLength:null)+")");var c=new rM,$=e._onmessage=function(t){var i=e.mediaKeysSession;if(!i){c.emit("error",Error("invalid state"));return}var r=t.messageType,n=t.message;o.log('"'+r+'" message event for session "'+i.sessionId+'" message size: '+n.byteLength),"license-request"===r||"license-renewal"===r?o.renewLicense(e,n).catch(function(t){o.handleError(t),c.emit("error",t)}):"license-release"===r?e.keySystem===ta.FAIRPLAY&&(o.updateKeySession(e,tr("acknowledged")),o.removeSession(e)):o.warn('unhandled media key message type "'+r+'"')},g=e._onkeystatuseschange=function(t){if(!e.mediaKeysSession){c.emit("error",Error("invalid state"));return}o.onKeyStatusChange(e);var i=e.keyStatus;c.emit("keyStatus",i),"expired"===i&&(o.warn(e.keySystem+" expired for key "+f),o.renewKeySession(e))};e.mediaKeysSession.addEventListener("message",$),e.mediaKeysSession.addEventListener("keystatuseschange",g);var v=new Promise(function(t,e){c.on("error",e),c.on("keyStatus",function(i){i.startsWith("usable")?t():"output-restricted"===i?e(new nK({type:N.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):"internal-error"===i?e(new nK({type:N.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},'key status changed to "'+i+'"')):"expired"===i?e(Error("key expired while generating request")):o.warn('unhandled key status change "'+i+'"')})});return e.mediaKeysSession.generateRequest(i,r).then(function(){var t;o.log('Request generated for key-session "'+(null==(t=e.mediaKeysSession)?void 0:t.sessionId)+'" keyId: '+f)}).catch(function(t){throw new nK({type:N.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_NO_SESSION,error:t,fatal:!1},"Error generating key-session request: "+t)}).then(function(){return v}).catch(function(t){throw c.removeAllListeners(),o.removeSession(e),t}).then(function(){return c.removeAllListeners(),e})},e.onKeyStatusChange=function t(e){var i=this;e.mediaKeysSession.keyStatuses.forEach(function(t,r){i.log('key status change "'+t+'" for keyStatuses keyId: '+tD.hexDump("buffer"in r?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):new Uint8Array(r))+" session keyId: "+tD.hexDump(new Uint8Array(e.decryptdata.keyId||[]))+" uri: "+e.decryptdata.uri),e.keyStatus=t})},e.fetchServerCertificate=function t(e){var i=this.config,n=new i.loader(i),a=this.getServerCertificateUrl(e);return a?(this.log('Fetching server certificate for "'+e+'"'),new Promise(function(t,s){var o={responseType:"arraybuffer",url:a},l=i.certLoadPolicy.default,u={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0};n.load(o,u,{onSuccess:function e(i,r,n,a){t(i.data)},onError:function t(i,n,l,u){s(new nK({type:N.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:l,response:r({url:o.url,data:void 0},i)},'"'+e+'" certificate request failed ('+a+"). Status: "+i.code+" ("+i.text+")"))},onTimeout:function t(i,r,n){s(new nK({type:N.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:n,response:{url:o.url,data:void 0}},'"'+e+'" certificate request timed out ('+a+")"))},onAbort:function t(e,i,r){s(Error("aborted"))}})})):Promise.resolve()},e.setMediaKeysServerCertificate=function t(e,i,r){var n=this;return new Promise(function(t,a){e.setServerCertificate(r).then(function(a){n.log("setServerCertificate "+(a?"success":"not supported by CDM")+" ("+(null==r?void 0:r.byteLength)+') on "'+i+'"'),t(e)}).catch(function(t){a(new nK({type:N.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:t,fatal:!0},t.message))})})},e.renewLicense=function t(e,i){var r=this;return this.requestLicense(e,new Uint8Array(i)).then(function(t){return r.updateKeySession(e,new Uint8Array(t)).catch(function(t){throw new nK({type:N.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:t,fatal:!0},t.message)})})},e.unpackPlayReadyKeyMessage=function t(e,i){var r=String.fromCharCode.apply(null,new Uint16Array(i.buffer));if(!r.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),i;var n=new DOMParser().parseFromString(r,"application/xml"),a=n.querySelectorAll("HttpHeader");if(a.length>0)for(var s=0,o=a.length;s<o;s++){var l,u,d,h=null==(u=(l=a[s]).querySelector("name"))?void 0:u.textContent,f=null==(d=l.querySelector("value"))?void 0:d.textContent;h&&f&&e.setRequestHeader(h,f)}var c=n.querySelector("Challenge"),$=null==c?void 0:c.textContent;if(!$)throw Error("Cannot find <Challenge> in key message");return tr(atob($))},e.setupLicenseXHR=function t(e,i,r,n){var a=this,s=this.config.licenseXhrSetup;return s?Promise.resolve().then(function(){if(!r.decryptdata)throw Error("Key removed");return s.call(a.hls,e,i,r,n)}).catch(function(t){if(!r.decryptdata)throw t;return e.open("POST",i,!0),s.call(a.hls,e,i,r,n)}).then(function(t){return e.readyState||e.open("POST",i,!0),{xhr:e,licenseChallenge:t||n}}):(e.open("POST",i,!0),Promise.resolve({xhr:e,licenseChallenge:n}))},e.requestLicense=function t(e,i){var r=this,n=this.config.keyLoadPolicy.default;return new Promise(function(t,a){var s=r.getLicenseServerUrl(e.keySystem);r.log("Sending license request to URL: "+s);var o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=function(){if(!r.hls||!e.mediaKeysSession)return a(Error("invalid state"));if(4===o.readyState){if(200===o.status){r._requestLicenseFailureCount=0;var l=o.response;r.log("License received "+(l instanceof ArrayBuffer?l.byteLength:l));var u=r.config.licenseResponseCallback;if(u)try{l=u.call(r.hls,o,s,e)}catch(d){r.error(d)}t(l)}else{var h=n.errorRetry,f=h?h.maxNumRetry:0;if(r._requestLicenseFailureCount++,r._requestLicenseFailureCount>f||o.status>=400&&o.status<500)a(new nK({type:N.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:o,response:{url:s,data:void 0,code:o.status,text:o.statusText}},"License Request XHR failed ("+s+"). Status: "+o.status+" ("+o.statusText+")"));else{var c=f-r._requestLicenseFailureCount+1;r.warn("Retrying license request, "+c+" attempts left"),r.requestLicense(e,i).then(t,a)}}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,r.setupLicenseXHR(o,s,e,i).then(function(t){var i=t.xhr,n=t.licenseChallenge;e.keySystem==ta.PLAYREADY&&(n=r.unpackPlayReadyKeyMessage(i,n)),i.send(n)})})},e.onMediaAttached=function t(e,i){if(this.config.emeEnabled){var r=i.media;this.media=r,r.addEventListener("encrypted",this.onMediaEncrypted),r.addEventListener("waitingforkey",this.onWaitingForKey)}},e.onMediaDetached=function e(){var i=this,r=this.media,n=this.mediaKeySessions;r&&(r.removeEventListener("encrypted",this.onMediaEncrypted),r.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},t7.clearKeyUriToKeyIdMap();var a=n.length;t.CDMCleanupPromise=Promise.all(n.map(function(t){return i.removeSession(t)}).concat(null==r?void 0:r.setMediaKeys(null).catch(function(t){i.log("Could not clear media keys: "+t)}))).then(function(){a&&(i.log("finished closing key sessions and clearing media keys"),n.length=0)}).catch(function(t){i.log("Could not close sessions and clear media keys: "+t)})},e.onManifestLoading=function t(){this.keyFormatPromise=null},e.onManifestLoaded=function t(e,i){var r=i.sessionKeys;if(r&&this.config.emeEnabled&&!this.keyFormatPromise){var n=r.reduce(function(t,e){return -1===t.indexOf(e.keyFormat)&&t.push(e.keyFormat),t},[]);this.log("Selecting key-system from session-keys "+n.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(n)}},e.removeSession=function t(e){var i=this,r=e.mediaKeysSession,n=e.licenseXhr;if(r){this.log("Remove licenses and keys and close session "+r.sessionId),e._onmessage&&(r.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(r.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),n&&n.readyState!==XMLHttpRequest.DONE&&n.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;var a=this.mediaKeySessions.indexOf(e);return a>-1&&this.mediaKeySessions.splice(a,1),r.remove().catch(function(t){i.log("Could not remove session: "+t)}).then(function(){return r.close()}).catch(function(t){i.log("Could not close session: "+t)})}},t}();nG.CDMCleanupPromise=void 0;var n2,n1,n6,nK=function(t){function e(e,i){var r;return(r=t.call(this,i)||this).data=void 0,e.error||(e.error=Error(i)),r.data=e,e.err=e.error,r}return u(e,t),e}(c(Error));(n2=m||(m={})).MANIFEST="m",n2.AUDIO="a",n2.VIDEO="v",n2.MUXED="av",n2.INIT="i",n2.CAPTION="c",n2.TIMED_TEXT="tt",n2.KEY="k",n2.OTHER="o",(n1=p||(p={})).DASH="d",n1.HLS="h",n1.SMOOTH="s",n1.OTHER="o",(n6=y||(y={})).OBJECT="CMCD-Object",n6.REQUEST="CMCD-Request",n6.SESSION="CMCD-Session",n6.STATUS="CMCD-Status";var n4=((T={})[y.OBJECT]=["br","d","ot","tb"],T[y.REQUEST]=["bl","dl","mtp","nor","nrr","su"],T[y.SESSION]=["cid","pr","sf","sid","st","v"],T[y.STATUS]=["bs","rtp"],T),n3=function t(e,i){this.value=void 0,this.params=void 0,Array.isArray(e)&&(e=e.map(function(e){return e instanceof t?e:new t(e)})),this.value=e,this.params=i},nH=function t(e){this.description=void 0,this.description=e},nV="Bare Item",n7=/[\x00-\x1f\x7f]+/;function nY(t,e,i){var r,n,a,s;return r=t,n=e,a=i,Error('failed to serialize "'+(Array.isArray(s=r)?JSON.stringify(s):s instanceof Map?"Map{}":s instanceof Set?"Set{}":"object"==typeof s?JSON.stringify(s):String(s))+'" as '+n,{cause:a})}function nW(t){var e;if((e=t)<-999999999999999||999999999999999<e)throw nY(t,"Integer");return t.toString()}function n5(t){var e,i=(e=t).description||e.toString().slice(7,-1);if(!1===/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(i))throw nY(i,"Token");return i}function nq(t){switch(typeof t){case"number":if(!w(t))throw nY(t,nV);if(Number.isInteger(t))return nW(t);return function t(e){var i=function t(e,i){if(e<0)return-t(-e,i);var r=Math.pow(10,i);if(!(Math.abs(e*r%1-.5)<Number.EPSILON))return Math.round(e*r)/r;var n=Math.floor(e*r);return(n%2==0?n:n+1)/r}(e,3);if(Math.floor(Math.abs(i)).toString().length>12)throw nY(e,"Decimal");var r=i.toString();return r.includes(".")?r:r+".0"}(t);case"string":return function t(e){if(n7.test(e))throw nY(e,"String");return'"'+e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')+'"'}(t);case"symbol":return n5(t);case"boolean":return function t(e){if("boolean"!=typeof e)throw nY(e,"Boolean");return e?"?1":"?0"}(t);case"object":if(t instanceof Date){var e;return"@"+nW((e=t).getTime()/1e3)}if(t instanceof Uint8Array)return function t(e){var i;if(!1===ArrayBuffer.isView(e))throw nY(e,"Byte Sequence");return":"+(i=e,btoa(String.fromCharCode.apply(String,i)))+":"}(t);if(t instanceof nH)return n5(t);default:throw nY(t,nV)}}function nX(t){if(!1===/^[a-z*][a-z0-9\-_.*]*$/.test(t))throw nY(t,"Key");return t}function nz(t){return null==t?"":Object.entries(t).map(function(t){var e=t[0],i=t[1];return!0===i?";"+nX(e):";"+nX(e)+"="+nq(i)}).join("")}function nj(t){return t instanceof n3?""+nq(t.value)+nz(t.params):nq(t)}var nQ=function t(e){return Math.round(e)},n9=function t(e){return 100*nQ(e/100)},nZ={br:nQ,d:nQ,bl:n9,dl:n9,mtp:n9,nor:function t(e,i){return null!=i&&i.baseUrl&&(e=function t(e,i){var r=new URL(e),n=new URL(i);if(r.origin!==n.origin)return e;for(var a=r.pathname.split("/").slice(1),s=n.pathname.split("/").slice(1,-1);a[0]===s[0];)a.shift(),s.shift();for(;s.length;)s.shift(),a.unshift("..");return a.join("/")}(e,i.baseUrl)),encodeURIComponent(e)},rtp:n9,tb:nQ};function nJ(t,e){var i,r;return(void 0===e&&(e={}),t)?(i=function t(e,i){var r={};if(null==e||"object"!=typeof e)return r;var n=Object.keys(e).sort(),a=l({},nZ,null==i?void 0:i.formatters),s=null==i?void 0:i.filter;return n.forEach(function(t){if(!(null!=s&&s(t))){var n,o,l=e[t],u=a[t];if(u&&(l=u(l,i)),("v"!==t||1!==l)&&("pr"!=t||1!==l))("number"==typeof(n=l)?!!w(n):null!=n&&""!==n&&!1!==n)&&(("ot"===(o=t)||"sf"===o||"st"===o)&&"string"==typeof l&&(l=new nH(l)),r[t]=l)}}),r}(t,e),r=l({whitespace:!1},e),function t(e,i){if(void 0===i&&(i={whitespace:!0}),"object"!=typeof e)throw nY(e,"Dict");var r,n=e instanceof Map?e.entries():Object.entries(e),a=null!=(r=i)&&r.whitespace?" ":"";return Array.from(n).map(function(t){var e,i=t[0],r=t[1];r instanceof n3==!1&&(r=new n3(r));var n=nX(i);return!0===r.value?n+=nz(r.params):(n+="=",Array.isArray(r.value))?n+="("+(e=r).value.map(nj).join(" ")+")"+nz(e.params):n+=nj(r),n}).join(","+a)}(i,r)):""}var at=/CMCD=[^&#]+/,ae=function(){function t(t){var e=this;this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.includeKeys=void 0,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){e.initialized&&(e.starved=!0),e.buffering=!0},this.onPlaying=function(){e.initialized||(e.initialized=!0),e.buffering=!1},this.applyPlaylistData=function(t){try{e.apply(t,{ot:m.MANIFEST,su:!e.initialized})}catch(i){H.warn("Could not generate manifest CMCD data.",i)}},this.applyFragmentData=function(t){try{var i=t.frag,r=e.hls.levels[i.level],n=e.getObjectType(i),a={d:1e3*i.duration,ot:n};(n===m.VIDEO||n===m.AUDIO||n==m.MUXED)&&(a.br=r.bitrate/1e3,a.tb=e.getTopBandwidth(n)/1e3,a.bl=e.getBufferLength(n)),e.apply(t,a)}catch(s){H.warn("Could not generate segment CMCD data.",s)}},this.hls=t;var i=this.config=t.config,r=i.cmcd;null!=r&&(i.pLoader=this.createPlaylistLoader(),i.fLoader=this.createFragmentLoader(),this.sid=r.sessionId||function t(){try{return crypto.randomUUID()}catch(e){try{var i=URL.createObjectURL(new Blob),r=i.toString();return URL.revokeObjectURL(i),r.slice(r.lastIndexOf("/")+1)}catch(n){var a=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=(a+16*Math.random())%16|0;return a=Math.floor(a/16),("x"==t?e:3&e|8).toString(16)})}}}(),this.cid=r.contentId,this.useHeaders=!0===r.useHeaders,this.includeKeys=r.includeKeys,this.registerListeners())}var e=t.prototype;return e.registerListeners=function t(){var e=this.hls;e.on(O.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(O.MEDIA_DETACHED,this.onMediaDetached,this),e.on(O.BUFFER_CREATED,this.onBufferCreated,this)},e.unregisterListeners=function t(){var e=this.hls;e.off(O.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(O.MEDIA_DETACHED,this.onMediaDetached,this),e.off(O.BUFFER_CREATED,this.onBufferCreated,this)},e.destroy=function t(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=null},e.onMediaAttached=function t(e,i){this.media=i.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},e.onMediaDetached=function t(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},e.onBufferCreated=function t(e,i){var r,n;this.audioBuffer=null==(r=i.tracks.audio)?void 0:r.buffer,this.videoBuffer=null==(n=i.tracks.video)?void 0:n.buffer},e.createData=function t(){var e;return{v:1,sf:p.HLS,sid:this.sid,cid:this.cid,pr:null==(e=this.media)?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},e.apply=function t(e,i){void 0===i&&(i={}),l(i,this.createData());var r,n,a=i.ot===m.INIT||i.ot===m.VIDEO||i.ot===m.MUXED;this.starved&&a&&(i.bs=!0,i.su=!0,this.starved=!1),null==i.su&&(i.su=this.buffering);var s=this.includeKeys;(s&&(i=Object.keys(i).reduce(function(t,e){return s.includes(e)&&(t[e]=i[e]),t},{})),this.useHeaders)?(e.headers||(e.headers={}),r=e.headers,l(r,function t(e,i){if(void 0===i&&(i={}),!e)return{};var r,n=Object.entries(e),a=Object.entries(n4).concat(Object.entries((null==(r=i)?void 0:r.customHeaderMap)||{}));return Object.entries(n.reduce(function(t,e){var i,r,n=e[0],s=e[1],o=(null==(i=a.find(function(t){return t[1].includes(n)}))?void 0:i[0])||y.REQUEST;return null!=(r=t[o])||(t[o]={}),t[o][n]=s,t},{})).reduce(function(t,e){var r=e[0],n=e[1];return t[r]=nJ(n,i),t},{})}(n=i,void 0))):e.url=function t(e,i,r){var n=function t(e,i){if(void 0===i&&(i={}),!e)return"";var r=nJ(e,i);return"CMCD="+encodeURIComponent(r)}(i,void 0);if(!n)return e;if(at.test(e))return e.replace(at,n);var a=e.includes("?")?"&":"?";return""+e+a+n}(e.url,i)},e.getObjectType=function t(e){var i=e.type;return"subtitle"===i?m.TIMED_TEXT:"initSegment"===e.sn?m.INIT:"audio"===i?m.AUDIO:"main"===i?this.hls.audioTracks.length?m.VIDEO:m.MUXED:void 0},e.getTopBandwidth=function t(e){var i=0,r=this.hls;if(e===m.AUDIO)s=r.audioTracks;else{var n=r.maxAutoLevel,a=n>-1?n+1:r.levels.length;s=r.levels.slice(0,a)}for(var s,o,l=function t(e,i){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function t(e,i){if(e){if("string"==typeof e)return $(e,i);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return $(e,i)}}(e))){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(s);!(o=l()).done;){var u=o.value;u.bitrate>i&&(i=u.bitrate)}return i>0?i:NaN},e.getBufferLength=function t(e){var i=this.hls.media,r=e===m.AUDIO?this.audioBuffer:this.videoBuffer;return r&&i?1e3*iS.bufferInfo(r,i.currentTime,this.config.maxBufferHole).len:NaN},e.createPlaylistLoader=function t(){var e=this.config.pLoader,i=this.applyPlaylistData,r=e||this.config.loader;return function(){function t(t){this.loader=void 0,this.loader=new r(t)}var e=t.prototype;return e.destroy=function t(){this.loader.destroy()},e.abort=function t(){this.loader.abort()},e.load=function t(e,r,n){i(e),this.loader.load(e,r,n)},s(t,[{key:"stats",get:function t(){return this.loader.stats}},{key:"context",get:function t(){return this.loader.context}}]),t}()},e.createFragmentLoader=function t(){var e=this.config.fLoader,i=this.applyFragmentData,r=e||this.config.loader;return function(){function t(t){this.loader=void 0,this.loader=new r(t)}var e=t.prototype;return e.destroy=function t(){this.loader.destroy()},e.abort=function t(){this.loader.abort()},e.load=function t(e,r,n){i(e),this.loader.load(e,r,n)},s(t,[{key:"stats",get:function t(){return this.loader.stats}},{key:"context",get:function t(){return this.loader.context}}]),t}()},t}(),ai=function(){function t(t){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=t,this.log=H.log.bind(H,"[content-steering]:"),this.registerListeners()}var e=t.prototype;return e.registerListeners=function t(){var e=this.hls;e.on(O.MANIFEST_LOADING,this.onManifestLoading,this),e.on(O.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(O.MANIFEST_PARSED,this.onManifestParsed,this),e.on(O.ERROR,this.onError,this)},e.unregisterListeners=function t(){var e=this.hls;e&&(e.off(O.MANIFEST_LOADING,this.onManifestLoading,this),e.off(O.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(O.MANIFEST_PARSED,this.onManifestParsed,this),e.off(O.ERROR,this.onError,this))},e.startLoad=function t(){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){this.scheduleRefresh(this.uri,e);return}}this.loadSteeringManifest(this.uri)}},e.stopLoad=function t(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()},e.clearTimeout=function t(){-1!==this.reloadTimer&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)},e.destroy=function t(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null},e.removeLevel=function t(e){var i=this.levels;i&&(this.levels=i.filter(function(t){return t!==e}))},e.onManifestLoading=function t(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null},e.onManifestLoaded=function t(e,i){var r=i.contentSteering;null!==r&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())},e.onManifestParsed=function t(e,i){this.audioTracks=i.audioTracks,this.subtitleTracks=i.subtitleTracks},e.onError=function t(e,i){var r=i.errorAction;if((null==r?void 0:r.action)===eQ.SendAlternateToPenaltyBox&&r.flags===e9.MoveAllAlternatesMatchingHost){var n=this.levels,a=this.pathwayPriority,s=this.pathwayId;if(i.context){var o=i.context,l=o.groupId,u=o.pathwayId,d=o.type;l&&n?s=this.getPathwayForGroupId(l,d,s):u&&(s=u)}s in this.penalizedPathways||(this.penalizedPathways[s]=performance.now()),!a&&n&&(a=n.reduce(function(t,e){return -1===t.indexOf(e.pathwayId)&&t.push(e.pathwayId),t},[])),a&&a.length>1&&(this.updatePathwayPriority(a),r.resolved=this.pathwayId!==s),r.resolved||H.warn("Could not resolve "+i.details+' ("'+i.error.message+'") with content-steering for Pathway: '+s+" levels: "+(n?n.length:n)+" priorities: "+JSON.stringify(a)+" penalized: "+JSON.stringify(this.penalizedPathways))}},e.filterParsedLevels=function t(e){this.levels=e;var i=this.getLevelsForPathway(this.pathwayId);if(0===i.length){var r=e[0].pathwayId;this.log("No levels found in Pathway "+this.pathwayId+'. Setting initial Pathway to "'+r+'"'),i=this.getLevelsForPathway(r),this.pathwayId=r}return i.length!==e.length?(this.log("Found "+i.length+"/"+e.length+' levels in Pathway "'+this.pathwayId+'"'),i):e},e.getLevelsForPathway=function t(e){return null===this.levels?[]:this.levels.filter(function(t){return e===t.pathwayId})},e.updatePathwayPriority=function t(e){this.pathwayPriority=e;var i,r=this.penalizedPathways,n=performance.now();Object.keys(r).forEach(function(t){n-r[t]>3e5&&delete r[t]});for(var a=0;a<e.length;a++){var s=e[a];if(!(s in r)){if(s===this.pathwayId)return;var o=this.hls.nextLoadLevel,l=this.hls.levels[o];if((i=this.getLevelsForPathway(s)).length>0){this.log('Setting Pathway to "'+s+'"'),this.pathwayId=s,eH(i),this.hls.trigger(O.LEVELS_UPDATED,{levels:i});var u=this.hls.levels[o];l&&u&&this.levels&&(u.attrs["STABLE-VARIANT-ID"]!==l.attrs["STABLE-VARIANT-ID"]&&u.bitrate!==l.bitrate&&this.log("Unstable Pathways change from bitrate "+l.bitrate+" to "+u.bitrate),this.hls.nextLoadLevel=o);break}}}},e.getPathwayForGroupId=function t(e,i,r){for(var n=this.getLevelsForPathway(r).concat(this.levels||[]),a=0;a<n.length;a++)if(i===ey.AUDIO_TRACK&&n[a].hasAudioGroup(e)||i===ey.SUBTITLE_TRACK&&n[a].hasSubtitleGroup(e))return n[a].pathwayId;return r},e.clonePathways=function t(e){var i=this,r=this.levels;if(r){var n={},a={};e.forEach(function(t){var e=t.ID,s=t["BASE-ID"],o=t["URI-REPLACEMENT"];if(!r.some(function(t){return t.pathwayId===e})){var l=i.getLevelsForPathway(s).map(function(t){var i=new W(t.attrs);i["PATHWAY-ID"]=e;var r=i.AUDIO&&i.AUDIO+"_clone_"+e,s=i.SUBTITLES&&i.SUBTITLES+"_clone_"+e;r&&(n[i.AUDIO]=r,i.AUDIO=r),s&&(a[i.SUBTITLES]=s,i.SUBTITLES=s);var l=an(t.uri,i["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",o),u=new e0({attrs:i,audioCodec:t.audioCodec,bitrate:t.bitrate,height:t.height,name:t.name,url:l,videoCodec:t.videoCodec,width:t.width});if(t.audioGroups)for(var d=1;d<t.audioGroups.length;d++)u.addGroupId("audio",t.audioGroups[d]+"_clone_"+e);if(t.subtitleGroups)for(var h=1;h<t.subtitleGroups.length;h++)u.addGroupId("text",t.subtitleGroups[h]+"_clone_"+e);return u});r.push.apply(r,l),ar(i.audioTracks,n,o,e),ar(i.subtitleTracks,a,o,e)}})}},e.loadSteeringManifest=function t(e){var i,r=this,n=this.hls.config,a=n.loader;this.loader&&this.loader.destroy(),this.loader=new a(n);try{i=new self.URL(e)}catch(s){this.enabled=!1,this.log("Failed to parse Steering Manifest URI: "+e);return}if("data:"!==i.protocol){var o=0|(this.hls.bandwidthEstimate||n.abrEwmaDefaultEstimate);i.searchParams.set("_HLS_pathway",this.pathwayId),i.searchParams.set("_HLS_throughput",""+o)}var l={responseType:"json",url:i.href},u=n.steeringManifestLoadPolicy.default,d=u.errorRetry||u.timeoutRetry||{},h={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:d.maxNumRetry||0,retryDelay:d.retryDelayMs||0,maxRetryDelay:d.maxRetryDelayMs||0};this.log("Requesting steering manifest: "+i),this.loader.load(l,h,{onSuccess:function t(e,n,a,s){r.log('Loaded steering manifest: "'+i+'"');var o=e.data;if(1!==o.VERSION){r.log("Steering VERSION "+o.VERSION+" not supported!");return}r.updated=performance.now(),r.timeToLoad=o.TTL;var l=o["RELOAD-URI"],u=o["PATHWAY-CLONES"],d=o["PATHWAY-PRIORITY"];if(l)try{r.uri=new self.URL(l,i).href}catch(h){r.enabled=!1,r.log("Failed to parse Steering Manifest RELOAD-URI: "+l);return}r.scheduleRefresh(r.uri||a.url),u&&r.clonePathways(u);var f={steeringManifest:o,url:i.toString()};r.hls.trigger(O.STEERING_MANIFEST_LOADED,f),d&&r.updatePathwayPriority(d)},onError:function t(e,i,n,a){if(r.log("Error loading steering manifest: "+e.code+" "+e.text+" ("+i.url+")"),r.stopLoad(),410===e.code){r.enabled=!1,r.log("Steering manifest "+i.url+" no longer available");return}var s=1e3*r.timeToLoad;if(429===e.code){var o=r.loader;if("function"==typeof(null==o?void 0:o.getResponseHeader)){var l=o.getResponseHeader("Retry-After");l&&(s=1e3*parseFloat(l))}r.log("Steering manifest "+i.url+" rate limited");return}r.scheduleRefresh(r.uri||i.url,s)},onTimeout:function t(e,i,n){r.log("Timeout loading steering manifest ("+i.url+")"),r.scheduleRefresh(r.uri||i.url)}})},e.scheduleRefresh=function t(e,i){var r=this;void 0===i&&(i=1e3*this.timeToLoad),this.clearTimeout(),this.reloadTimer=self.setTimeout(function(){var t,i=null==(t=r.hls)?void 0:t.media;if(i&&!i.ended){r.loadSteeringManifest(e);return}r.scheduleRefresh(e,1e3*r.timeToLoad)},i)},t}();function ar(t,e,i,r){t&&Object.keys(e).forEach(function(n){var a=t.filter(function(t){return t.groupId===n}).map(function(t){var a=l({},t);return a.details=void 0,a.attrs=new W(a.attrs),a.url=a.attrs.URI=an(t.url,t.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",i),a.groupId=a.attrs["GROUP-ID"]=e[n],a.attrs["PATHWAY-ID"]=r,a});t.push.apply(t,a)})}function an(t,e,i,r){var n,a=r.HOST,s=r.PARAMS,o=r[i];e&&(n=null==o?void 0:o[e])&&(t=n);var l=new self.URL(t);return a&&!n&&(l.host=a),s&&Object.keys(s).sort().forEach(function(t){t&&l.searchParams.set(t,s[t])}),l.href}var aa=/^age:\s*[\d.]+\s*$/im,as=function(){function t(t){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=t&&t.xhrSetup||null,this.stats=new j,this.retryDelay=0}var e=t.prototype;return e.destroy=function t(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null},e.abortInternal=function t(){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()))},e.abort=function t(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},e.load=function t(e,i,r){if(this.stats.loading.start)throw Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=i,this.callbacks=r,this.loadInternal()},e.loadInternal=function t(){var e=this,i=this.config,r=this.context;if(i&&r){var n=this.loader=new self.XMLHttpRequest,a=this.stats;a.loading.first=0,a.loaded=0,a.aborted=!1;var s=this.xhrSetup;s?Promise.resolve().then(function(){if(e.loader===n&&!e.stats.aborted)return s(n,r.url)}).catch(function(t){if(e.loader===n&&!e.stats.aborted)return n.open("GET",r.url,!0),s(n,r.url)}).then(function(){e.loader!==n||e.stats.aborted||e.openAndSendXhr(n,r,i)}).catch(function(t){e.callbacks.onError({code:n.status,text:t.message},r,n,a)}):this.openAndSendXhr(n,r,i)}},e.openAndSendXhr=function t(e,i,r){e.readyState||e.open("GET",i.url,!0);var n=i.headers,a=r.loadPolicy,s=a.maxTimeToFirstByteMs,o=a.maxLoadTimeMs;if(n)for(var l in n)e.setRequestHeader(l,n[l]);i.rangeEnd&&e.setRequestHeader("Range","bytes="+i.rangeStart+"-"+(i.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=i.responseType,self.clearTimeout(this.requestTimeout),r.timeout=s&&w(s)?s:o,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),e.send()},e.readystatechange=function t(){var e=this.context,i=this.loader,r=this.stats;if(e&&i){var n=i.readyState,a=this.config;if(!r.aborted&&n>=2&&(0===r.loading.first&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),a.timeout!==a.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),a.timeout=a.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),a.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),4===n)){self.clearTimeout(this.requestTimeout),i.onreadystatechange=null,i.onprogress=null;var s=i.status,o="text"!==i.responseType;if(s>=200&&s<300&&(o&&i.response||null!==i.responseText)){r.loading.end=Math.max(self.performance.now(),r.loading.first);var l=o?i.response:i.responseText,u="arraybuffer"===i.responseType?l.byteLength:l.length;if(r.loaded=r.total=u,r.bwEstimate=8e3*r.total/(r.loading.end-r.loading.first),!this.callbacks)return;var d=this.callbacks.onProgress;if(d&&d(r,e,l,i),!this.callbacks)return;var h={url:i.responseURL,data:l,code:s};this.callbacks.onSuccess(h,r,e,i)}else{var f,c=a.loadPolicy.errorRetry,$=r.retry;e5(c,$,!1,{url:e.url,data:void 0,code:s})?this.retry(c):(H.error(s+" while loading "+e.url),this.callbacks.onError({code:s,text:i.statusText},e,i,r))}}}},e.loadtimeout=function t(){if(this.config){var e=this.config.loadPolicy.timeoutRetry;if(e5(e,this.stats.retry,!0))this.retry(e);else{H.warn("timeout while loading "+(null==(i=this.context)?void 0:i.url));var i,r=this.callbacks;r&&(this.abortInternal(),r.onTimeout(this.stats,this.context,this.loader))}}},e.retry=function t(e){var i=this.context,r=this.stats;this.retryDelay=eY(e,r.retry),r.retry++,H.warn((status?"HTTP Status "+status:"Timeout")+" while loading "+(null==i?void 0:i.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)},e.loadprogress=function t(e){var i=this.stats;i.loaded=e.loaded,e.lengthComputable&&(i.total=e.total)},e.getCacheAge=function t(){var e=null;if(this.loader&&aa.test(this.loader.getAllResponseHeaders())){var i=this.loader.getResponseHeader("age");e=i?parseFloat(i):null}return e},e.getResponseHeader=function t(e){return this.loader&&RegExp("^"+e+":\\s*[\\d.]+\\s*$","im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null},t}(),ao=/(\d+)-(\d+)\/(\d+)/,al=function(){function t(t){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=t.fetchSetup||au,this.controller=new self.AbortController,this.stats=new j}var e=t.prototype;return e.destroy=function t(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null},e.abortInternal=function t(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())},e.abort=function t(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},e.load=function t(e,i,r){var n,a,s,o=this,u=this.stats;if(u.loading.start)throw Error("Loader can only be used once.");u.loading.start=self.performance.now();var d=(n=e,a=this.controller.signal,s={method:"GET",mode:"cors",credentials:"same-origin",signal:a,headers:new self.Headers(l({},n.headers))},n.rangeEnd&&s.headers.set("Range","bytes="+n.rangeStart+"-"+String(n.rangeEnd-1)),s),h=r.onProgress,f="arraybuffer"===e.responseType,c=f?"byteLength":"length",$=i.loadPolicy,g=$.maxTimeToFirstByteMs,v=$.maxLoadTimeMs;this.context=e,this.config=i,this.callbacks=r,this.request=this.fetchSetup(e,d),self.clearTimeout(this.requestTimeout),i.timeout=g&&w(g)?g:v,this.requestTimeout=self.setTimeout(function(){o.abortInternal(),r.onTimeout(u,e,o.response)},i.timeout),self.fetch(this.request).then(function(t){o.response=o.loader=t;var n=Math.max(self.performance.now(),u.loading.start);if(self.clearTimeout(o.requestTimeout),i.timeout=v,o.requestTimeout=self.setTimeout(function(){o.abortInternal(),r.onTimeout(u,e,o.response)},v-(n-u.loading.start)),!t.ok){var a=t.status,s=t.statusText;throw new ad(s||"fetch, bad network response",a,t)}return(u.loading.first=n,u.total=function t(e){var i=e.get("Content-Range");if(i){var r=function t(e){var i=ao.exec(e);if(i)return parseInt(i[2])-parseInt(i[1])+1}(i);if(w(r))return r}var n=e.get("Content-Length");if(n)return parseInt(n)}(t.headers)||u.total,h&&w(i.highWaterMark))?o.loadProgressively(t,u,e,i.highWaterMark,h):f?t.arrayBuffer():"json"===e.responseType?t.json():t.text()}).then(function(t){var n=o.response;if(!n)throw Error("loader destroyed");self.clearTimeout(o.requestTimeout),u.loading.end=Math.max(self.performance.now(),u.loading.first);var a=t[c];a&&(u.loaded=u.total=a);var s={url:n.url,data:t,code:n.status};h&&!w(i.highWaterMark)&&h(u,e,t,n),r.onSuccess(s,u,e,n)}).catch(function(t){if(self.clearTimeout(o.requestTimeout),!u.aborted){var i=t&&t.code||0,n=t?t.message:null;r.onError({code:i,text:n},e,t?t.details:null,u)}})},e.getCacheAge=function t(){var e=null;if(this.response){var i=this.response.headers.get("age");e=i?parseFloat(i):null}return e},e.getResponseHeader=function t(e){return this.response?this.response.headers.get(e):null},e.loadProgressively=function t(e,i,r,n,a){void 0===n&&(n=0);var s=new iU,o=e.body.getReader();return function t(){return o.read().then(function(o){if(o.done)return s.dataLength&&a(i,r,s.flush(),e),Promise.resolve(new ArrayBuffer(0));var l=o.value,u=l.length;return i.loaded+=u,u<n||s.dataLength?(s.push(l),s.dataLength>=n&&a(i,r,s.flush(),e)):a(i,r,l,e),t()}).catch(function(){return Promise.reject()})}()},t}();function au(t,e){return new self.Request(t.url,e)}var ad=function(t){function e(e,i,r){var n;return(n=t.call(this,e)||this).code=void 0,n.details=void 0,n.code=i,n.details=r,n}return u(e,t),e}(c(Error)),ah=/\s/,af={newCue:function t(e,i,r,n){for(var a=[],s=self.VTTCue||self.TextTrackCue,o=0;o<n.rows.length;o++)if(l=n.rows[o],d=!0,h=0,f="",!l.isEmpty()){for(var l,u,d,h,f,c,$=0;$<l.chars.length;$++)ah.test(l.chars[$].uchar)&&d?h++:(f+=l.chars[$].uchar,d=!1);l.cueStartTime=i,i===r&&(r+=1e-4),h>=16?h--:h++;var g=nm(f.trim()),v=nS(i,r,g);null!=e&&null!=(c=e.cues)&&c.getCueById(v)||((u=new s(i,r,g)).id=v,u.line=o+1,u.align="left",u.position=10+Math.min(80,10*Math.floor(8*h/32)),a.push(u))}return e&&a.length&&(a.sort(function(t,e){return"auto"===t.line||"auto"===e.line?0:t.line>8&&e.line>8?e.line-t.line:t.line-e.line}),a.forEach(function(t){return eA(e,t)})),a}},ac=r(r({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:as,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:iv,bufferController:rW,capLevelController:nB,errorController:eZ,fpsController:nU,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:tf,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,useMediaCapabilities:!0,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:af,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:r3,subtitleTrackController:rV,timelineController:nP,audioStreamController:rK,audioTrackController:r4,emeController:nG,cmcdController:ae,contentSteeringController:ai}),a$=function(t){function e(e,i){var r;return(r=t.call(this,e,"[level-controller]")||this)._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=i,r._registerListeners(),r}u(e,t);var i=e.prototype;return i._registerListeners=function t(){var e=this.hls;e.on(O.MANIFEST_LOADING,this.onManifestLoading,this),e.on(O.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(O.LEVEL_LOADED,this.onLevelLoaded,this),e.on(O.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(O.FRAG_BUFFERED,this.onFragBuffered,this),e.on(O.ERROR,this.onError,this)},i._unregisterListeners=function t(){var e=this.hls;e.off(O.MANIFEST_LOADING,this.onManifestLoading,this),e.off(O.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(O.LEVEL_LOADED,this.onLevelLoaded,this),e.off(O.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(O.FRAG_BUFFERED,this.onFragBuffered,this),e.off(O.ERROR,this.onError,this)},i.destroy=function e(){this._unregisterListeners(),this.steering=null,this.resetLevels(),t.prototype.destroy.call(this)},i.stopLoad=function e(){this._levels.forEach(function(t){t.loadError=0,t.fragmentError=0}),t.prototype.stopLoad.call(this)},i.resetLevels=function t(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1},i.onManifestLoading=function t(e,i){this.resetLevels()},i.onManifestLoaded=function t(e,i){var r=this.hls.config.preferManagedMediaSource,n=[],a={},s={},o=!1,l=!1,u=!1;i.levels.forEach(function(t){var e,i,d=t.attrs,h=t.audioCodec,f=t.videoCodec;(null==(e=h)?void 0:e.indexOf("mp4a.40.34"))!==-1&&(x||(x=/chrome|firefox/i.test(navigator.userAgent)),x&&(t.audioCodec=h=void 0)),h&&(t.audioCodec=h=en(h,r)),(null==(i=f)?void 0:i.indexOf("avc1"))===0&&(f=t.videoCodec=function t(e){for(var i=e.split(","),r=0;r<i.length;r++){var n=i[r].split(".");if(n.length>2){var a=n.shift()+".";a+=parseInt(n.shift()).toString(16),a+=("000"+parseInt(n.shift()).toString(16)).slice(-4),i[r]=a}}return i.join(",")}(f));var c=t.width,$=t.height,g=t.unknownCodecs;if(o||(o=!!(c&&$)),l||(l=!!f),u||(u=!!h),(null==g||!g.length)&&(!h||t9(h,"audio",r))&&(!f||t9(f,"video",r))){var v=d.CODECS,m=d["FRAME-RATE"],p=d["HDCP-LEVEL"],y=d["PATHWAY-ID"],T=d.RESOLUTION,E=d["VIDEO-RANGE"],S=""+(y||".")+"-"+t.bitrate+"-"+T+"-"+m+"-"+v+"-"+E+"-"+p;if(a[S]){if(a[S].uri===t.url||t.attrs["PATHWAY-ID"])a[S].addGroupId("audio",d.AUDIO),a[S].addGroupId("text",d.SUBTITLES);else{var L=s[S]+=1;t.attrs["PATHWAY-ID"]=Array(L+1).join(".");var A=new e0(t);a[S]=A,n.push(A)}}else{var R=new e0(t);a[S]=R,s[S]=1,n.push(R)}}}),this.filterAndSortMediaOptions(n,i,o,l,u)},i.filterAndSortMediaOptions=function t(e,i,r,n,a){var s=this,o=[],l=[],u=e;if((r||n)&&a&&(u=u.filter(function(t){var e,i=t.videoCodec,r=t.videoRange,n=t.width,a=t.height;return(!!i||!!(n&&a))&&!!(e=r)&&eN.indexOf(e)>-1})),0===u.length){Promise.resolve().then(function(){if(s.hls){i.levels.length&&s.warn("One or more CODECS in variant not supported: "+JSON.stringify(i.levels[0].attrs));var t=Error("no level with compatible codecs found in manifest");s.hls.trigger(O.ERROR,{type:N.MEDIA_ERROR,details:M.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:i.url,error:t,reason:t.message})}});return}if(i.audioTracks){var d=this.hls.config.preferManagedMediaSource;o=i.audioTracks.filter(function(t){return!t.audioCodec||t9(t.audioCodec,"audio",d)}),ag(o)}i.subtitles&&ag(l=i.subtitles);var h=u.slice(0);u.sort(function(t,e){if(t.attrs["HDCP-LEVEL"]!==e.attrs["HDCP-LEVEL"])return(t.attrs["HDCP-LEVEL"]||"")>(e.attrs["HDCP-LEVEL"]||"")?1:-1;if(r&&t.height!==e.height)return t.height-e.height;if(t.frameRate!==e.frameRate)return t.frameRate-e.frameRate;if(t.videoRange!==e.videoRange)return eN.indexOf(t.videoRange)-eN.indexOf(e.videoRange);if(t.videoCodec!==e.videoCodec){var i=et(t.videoCodec),n=et(e.videoCodec);if(i!==n)return n-i}if(t.uri===e.uri&&t.codecSet!==e.codecSet){var a=ee(t.codecSet),s=ee(e.codecSet);if(a!==s)return s-a}return t.averageBitrate!==e.averageBitrate?t.averageBitrate-e.averageBitrate:0});var f=h[0];if(this.steering&&(u=this.steering.filterParsedLevels(u)).length!==h.length){for(var c=0;c<h.length;c++)if(h[c].pathwayId===u[0].pathwayId){f=h[c];break}}this._levels=u;for(var $=0;$<u.length;$++)if(u[$]===f){this._firstLevel=$;var g,v=f.bitrate,m=this.hls.bandwidthEstimate;if(this.log("manifest loaded, "+u.length+" level(s) found, first bitrate: "+v),(null==(g=this.hls.userConfig)?void 0:g.abrEwmaDefaultEstimate)===void 0){var p=Math.min(v,this.hls.config.abrEwmaDefaultEstimateMax);p>m&&m===ac.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=p)}break}var y={levels:u,audioTracks:o,subtitleTracks:l,sessionData:i.sessionData,sessionKeys:i.sessionKeys,firstLevel:this._firstLevel,stats:i.stats,audio:a,video:n,altAudio:!(a&&!n)&&o.some(function(t){return!!t.url})};this.hls.trigger(O.MANIFEST_PARSED,y),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)},i.onError=function t(e,i){!i.fatal&&i.context&&i.context.type===ey.LEVEL&&i.context.level===this.level&&this.checkRetry(i)},i.onFragBuffered=function t(e,i){var r=i.frag;if(void 0!==r&&r.type===eT.MAIN){var n=r.elementaryStreams;if(!Object.keys(n).some(function(t){return!!n[t]}))return;var a=this._levels[r.level];null!=a&&a.loadError&&(this.log("Resetting level error count of "+a.loadError+" on frag buffered"),a.loadError=0)}},i.onLevelLoaded=function t(e,i){var r,n,a=i.level,s=i.details,o=this._levels[a];if(!o){this.warn("Invalid level index "+a),null!=(n=i.deliveryDirectives)&&n.skip&&(s.deltaUpdateFailed=!0);return}a===this.currentLevelIndex?(0===o.fragmentError&&(o.loadError=0),this.playlistLoaded(a,i,o.details)):null!=(r=i.deliveryDirectives)&&r.skip&&(s.deltaUpdateFailed=!0)},i.loadPlaylist=function e(i){t.prototype.loadPlaylist.call(this);var r=this.currentLevelIndex,n=this.currentLevel;if(n&&this.shouldLoadPlaylist(n)){var a=n.uri;if(i)try{a=i.addDirectives(a)}catch(s){this.warn("Could not construct new URL with HLS Delivery Directives: "+s)}var o=n.attrs["PATHWAY-ID"];this.log("Loading level index "+r+((null==i?void 0:i.msn)!==void 0?" at sn "+i.msn+" part "+i.part:"")+" with"+(o?" Pathway "+o:"")+" "+a),this.clearTimer(),this.hls.trigger(O.LEVEL_LOADING,{url:a,level:r,pathwayId:n.attrs["PATHWAY-ID"],id:0,deliveryDirectives:i||null})}},i.removeLevel=function t(e){var i,r=this,n=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(t){return t.level=-1})),!1)});eH(n),this._levels=n,this.currentLevelIndex>-1&&null!=(i=this.currentLevel)&&i.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.hls.trigger(O.LEVELS_UPDATED,{levels:n})},i.onLevelsUpdated=function t(e,i){var r=i.levels;this._levels=r},i.checkMaxAutoUpdated=function t(){var e=this.hls,i=e.autoLevelCapping,r=e.maxAutoLevel,n=e.maxHdcpLevel;this._maxAutoLevel!==r&&(this._maxAutoLevel=r,this.hls.trigger(O.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:i,levels:this.levels,maxAutoLevel:r,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:n}))},s(e,[{key:"levels",get:function t(){return 0===this._levels.length?null:this._levels}},{key:"level",get:function t(){return this.currentLevelIndex},set:function t(e){var i=this._levels;if(0!==i.length){if(e<0||e>=i.length){var r=Error("invalid level idx"),n=e<0;if(this.hls.trigger(O.ERROR,{type:N.OTHER_ERROR,details:M.LEVEL_SWITCH_ERROR,level:e,fatal:n,error:r,reason:r.message}),n)return;e=Math.min(e,i.length-1)}var a=this.currentLevelIndex,s=this.currentLevel,o=s?s.attrs["PATHWAY-ID"]:void 0,l=i[e],u=l.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=l,a!==e||!l.details||!s||o!==u){this.log("Switching to level "+e+" ("+(l.height?l.height+"p ":"")+(l.videoRange?l.videoRange+" ":"")+(l.codecSet?l.codecSet+" ":"")+"@"+l.bitrate+")"+(u?" with Pathway "+u:"")+" from level "+a+(o?" with Pathway "+o:""));var d={level:e,attrs:l.attrs,details:l.details,bitrate:l.bitrate,averageBitrate:l.averageBitrate,maxBitrate:l.maxBitrate,realBitrate:l.realBitrate,width:l.width,height:l.height,codecSet:l.codecSet,audioCodec:l.audioCodec,videoCodec:l.videoCodec,audioGroups:l.audioGroups,subtitleGroups:l.subtitleGroups,loaded:l.loaded,loadError:l.loadError,fragmentError:l.fragmentError,name:l.name,id:l.id,uri:l.uri,url:l.url,urlId:0,audioGroupIds:l.audioGroupIds,textGroupIds:l.textGroupIds};this.hls.trigger(O.LEVEL_SWITCHING,d);var h=l.details;if(!h||h.live){var f=this.switchParams(l.uri,null==s?void 0:s.details,h);this.loadPlaylist(f)}}}}},{key:"manualLevel",get:function t(){return this.manualLevelIndex},set:function t(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}},{key:"firstLevel",get:function t(){return this._firstLevel},set:function t(e){this._firstLevel=e}},{key:"startLevel",get:function t(){if(void 0===this._startLevel){var e=this.hls.config.startLevel;return void 0!==e?e:this.hls.firstAutoLevel}return this._startLevel},set:function t(e){this._startLevel=e}},{key:"nextLoadLevel",get:function t(){return -1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function t(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}}]),e}(eJ);function ag(t){var e={};t.forEach(function(t){var i=t.groupId||"";t.id=e[i]=e[i]||0,e[i]++})}var av=function(){function t(t){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=t}var e=t.prototype;return e.abort=function t(e){for(var i in this.keyUriToKeyInfo){var r,n=this.keyUriToKeyInfo[i].loader;if(n){if(e&&e!==(null==(r=n.context)?void 0:r.frag.type))return;n.abort()}}},e.detach=function t(){for(var e in this.keyUriToKeyInfo){var i=this.keyUriToKeyInfo[e];(i.mediaKeySessionContext||i.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}},e.destroy=function t(){for(var e in this.detach(),this.keyUriToKeyInfo){var i=this.keyUriToKeyInfo[e].loader;i&&i.destroy()}this.keyUriToKeyInfo={}},e.createKeyLoadError=function t(e,i,r,n,a){return void 0===i&&(i=M.KEY_LOAD_ERROR),new i8({type:N.NETWORK_ERROR,details:i,fatal:!1,frag:e,response:a,error:r,networkDetails:n})},e.loadClear=function t(e,i){var r=this;if(this.emeController&&this.config.emeEnabled)for(var n=e.sn,a=e.cc,s=0;s<i.length&&!function t(){var e=i[s];if(a<=e.cc&&("initSegment"===n||"initSegment"===e.sn||n<e.sn))return r.emeController.selectKeySystemFormat(e).then(function(t){e.setKeyFormat(t)}),1}();s++);},e.load=function t(e){var i=this;return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then(function(t){return i.loadInternal(e,t)}):this.loadInternal(e)},e.loadInternal=function t(e,i){i&&e.setKeyFormat(i);var r,n,a,s=e.decryptdata;if(!s){var o=Error(i?"Expected frag.decryptdata to be defined after setting format "+i:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,M.KEY_LOAD_ERROR,o))}var l=s.uri;if(!l)return Promise.reject(this.createKeyLoadError(e,M.KEY_LOAD_ERROR,Error('Invalid key URI: "'+l+'"')));var u=this.keyUriToKeyInfo[l];if(null!=(r=u)&&r.decryptdata.key)return s.key=u.decryptdata.key,Promise.resolve({frag:e,keyInfo:u});if(null!=(n=u)&&n.keyLoadPromise)switch(null==(a=u.mediaKeySessionContext)?void 0:a.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return u.keyLoadPromise.then(function(t){return s.key=t.keyInfo.decryptdata.key,{frag:e,keyInfo:u}})}switch(u=this.keyUriToKeyInfo[l]={decryptdata:s,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},s.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":if("identity"===s.keyFormat)return this.loadKeyHTTP(u,e);return this.loadKeyEME(u,e);case"AES-128":return this.loadKeyHTTP(u,e);default:return Promise.reject(this.createKeyLoadError(e,M.KEY_LOAD_ERROR,Error('Key supplied with unsupported METHOD: "'+s.method+'"')))}},e.loadKeyEME=function t(e,i){var r={frag:i,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var n=this.emeController.loadKey(r);if(n)return(e.keyLoadPromise=n.then(function(t){return e.mediaKeySessionContext=t,r})).catch(function(t){throw e.keyLoadPromise=null,t})}return Promise.resolve(r)},e.loadKeyHTTP=function t(e,i){var n=this,a=this.config,s=new a.loader(a);return i.keyLoader=e.loader=s,e.keyLoadPromise=new Promise(function(t,o){var l={keyInfo:e,frag:i,responseType:"arraybuffer",url:e.decryptdata.uri},u=a.keyLoadPolicy.default,d={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0};s.load(l,d,{onSuccess:function e(i,r,a,s){var l=a.frag,u=a.keyInfo,d=a.url;if(!l.decryptdata||u!==n.keyUriToKeyInfo[d])return o(n.createKeyLoadError(l,M.KEY_LOAD_ERROR,Error("after key load, decryptdata unset or changed"),s));u.decryptdata.key=l.decryptdata.key=new Uint8Array(i.data),l.keyLoader=null,u.loader=null,t({frag:l,keyInfo:u})},onError:function t(e,a,s,u){n.resetLoader(a),o(n.createKeyLoadError(i,M.KEY_LOAD_ERROR,Error("HTTP Error "+e.code+" loading key "+e.text),s,r({url:l.url,data:void 0},e)))},onTimeout:function t(e,r,a){n.resetLoader(r),o(n.createKeyLoadError(i,M.KEY_LOAD_TIMEOUT,Error("key loading timed out"),a))},onAbort:function t(e,r,a){n.resetLoader(r),o(n.createKeyLoadError(i,M.INTERNAL_ABORTED,Error("key loading aborted"),a))}})})},e.resetLoader=function t(e){var i=e.frag,r=e.keyInfo,n=e.url,a=r.loader;i.keyLoader===a&&(i.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[n],a&&a.destroy()},t}();function am(){return self.SourceBuffer||self.WebKitSourceBuffer}function ap(){if(!tj())return!1;var t=am();return!t||t.prototype&&"function"==typeof t.prototype.appendBuffer&&"function"==typeof t.prototype.remove}var ay=function(){function t(t,e,i,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=t,this.media=e,this.fragmentTracker=i,this.hls=r}var e=t.prototype;return e.destroy=function t(){this.media=null,this.hls=this.fragmentTracker=null},e.poll=function t(e,i){var r=this.config,n=this.media,a=this.stalled;if(null!==n){var s=n.currentTime,o=n.seeking,l=this.seeking&&!o,u=!this.seeking&&o;if(this.seeking=o,s!==e){if(this.moved=!0,o||(this.nudgeRetry=0),null!==a){if(this.stallReported){var d=self.performance.now()-a;H.warn("playback not stuck anymore @"+s+", after "+Math.round(d)+"ms"),this.stallReported=!1}this.stalled=null}return}if(u||l){this.stalled=null;return}if(n.paused&&!o||n.ended||0===n.playbackRate||!iS.getBuffered(n).length){this.nudgeRetry=0;return}var h=iS.bufferInfo(n,s,0),f=h.nextStart||0;if(o){var c=h.len>2,$=!f||i&&i.start<=s||f-s>2&&!this.fragmentTracker.getPartialFragment(s);if(c||$)return;this.moved=!1}if(!this.moved&&null!==this.stalled){if(!(h.len>0)&&!f)return;var g,v=Math.max(f,h.start||0)-s,m=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,p=(null==m?void 0:null==(g=m.details)?void 0:g.live)?2*m.details.targetduration:2,y=this.fragmentTracker.getPartialFragment(s);if(v>0&&(v<=p||y)){n.paused||this._trySkipBufferHole(y);return}}var T=self.performance.now();if(null===a){this.stalled=T;return}var x=T-a;if(o||!(x>=250)||(this._reportStall(h),this.media)){var E=iS.bufferInfo(n,s,r.maxBufferHole);this._tryFixBufferStall(E,x)}}},e._tryFixBufferStall=function t(e,i){var r=this.config,n=this.fragmentTracker,a=this.media;if(null!==a){var s=a.currentTime,o=n.getPartialFragment(s);if(o&&(this._trySkipBufferHole(o)||!this.media))return;(e.len>r.maxBufferHole||e.nextStart&&e.nextStart-s<r.maxBufferHole)&&i>1e3*r.highBufferWatchdogPeriod&&(H.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},e._reportStall=function t(e){var i=this.hls,r=this.media;if(!this.stallReported&&r){this.stallReported=!0;var n=Error("Playback stalling at @"+r.currentTime+" due to low buffer ("+JSON.stringify(e)+")");H.warn(n.message),i.trigger(O.ERROR,{type:N.MEDIA_ERROR,details:M.BUFFER_STALLED_ERROR,fatal:!1,error:n,buffer:e.len})}},e._trySkipBufferHole=function t(e){var i=this.config,r=this.hls,n=this.media;if(null===n)return 0;var a=n.currentTime,s=iS.bufferInfo(n,a,0),o=a<s.start?s.start:s.nextStart;if(o){var l=s.len<=i.maxBufferHole,u=s.len>0&&s.len<1&&n.readyState<3,d=o-a;if(d>0&&(l||u)){if(d>i.maxBufferHole){var h=this.fragmentTracker,f=!1;if(0===a){var c=h.getAppendedFrag(0,eT.MAIN);c&&o<c.end&&(f=!0)}if(!f){var $=e||h.getAppendedFrag(a,eT.MAIN);if($){for(var g=!1,v=$.end;v<o;){var m=h.getPartialFragment(v);if(m)v+=m.duration;else{g=!0;break}}if(g)return 0}}}var p=Math.max(o+.05,a+.1);if(H.warn("skipping hole, adjusting currentTime from "+a+" to "+p),this.moved=!0,this.stalled=null,n.currentTime=p,e&&!e.gap){var y=Error("fragment loaded with buffer holes, seeking from "+a+" to "+p);r.trigger(O.ERROR,{type:N.MEDIA_ERROR,details:M.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:y,reason:y.message,frag:e})}return p}}return 0},e._tryNudgeBuffer=function t(){var e=this.config,i=this.hls,r=this.media,n=this.nudgeRetry;if(null!==r){var a=r.currentTime;if(this.nudgeRetry++,n<e.nudgeMaxRetry){var s=a+(n+1)*e.nudgeOffset,o=Error("Nudging 'currentTime' from "+a+" to "+s);H.warn(o.message),r.currentTime=s,i.trigger(O.ERROR,{type:N.MEDIA_ERROR,details:M.BUFFER_NUDGE_ON_STALL,error:o,fatal:!1})}else{var l=Error("Playhead still not moving while enough data buffered @"+a+" after "+e.nudgeMaxRetry+" nudges");H.error(l.message),i.trigger(O.ERROR,{type:N.MEDIA_ERROR,details:M.BUFFER_STALLED_ERROR,error:l,fatal:!0})}}},t}(),aT=function(t){function e(e,i,r){var n;return(n=t.call(this,e,i,r,"[stream-controller]",eT.MAIN)||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(e,t);var i=e.prototype;return i._registerListeners=function t(){var e=this.hls;e.on(O.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(O.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(O.MANIFEST_LOADING,this.onManifestLoading,this),e.on(O.MANIFEST_PARSED,this.onManifestParsed,this),e.on(O.LEVEL_LOADING,this.onLevelLoading,this),e.on(O.LEVEL_LOADED,this.onLevelLoaded,this),e.on(O.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(O.ERROR,this.onError,this),e.on(O.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(O.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(O.BUFFER_CREATED,this.onBufferCreated,this),e.on(O.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(O.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(O.FRAG_BUFFERED,this.onFragBuffered,this)},i._unregisterListeners=function t(){var e=this.hls;e.off(O.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(O.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(O.MANIFEST_LOADING,this.onManifestLoading,this),e.off(O.MANIFEST_PARSED,this.onManifestParsed,this),e.off(O.LEVEL_LOADED,this.onLevelLoaded,this),e.off(O.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(O.ERROR,this.onError,this),e.off(O.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(O.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(O.BUFFER_CREATED,this.onBufferCreated,this),e.off(O.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(O.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(O.FRAG_BUFFERED,this.onFragBuffered,this)},i.onHandlerDestroying=function e(){this._unregisterListeners(),t.prototype.onHandlerDestroying.call(this)},i.startLoad=function t(e){if(this.levels){var i=this.lastCurrentTime,r=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){var n=r.startLevel;-1===n&&(r.config.testBandwidth&&this.levels.length>1?(n=0,this.bitrateTest=!0):n=r.firstAutoLevel),r.nextLoadLevel=n,this.level=r.loadLevel,this.loadedmetadata=!1}i>0&&-1===e&&(this.log("Override startPosition with lastCurrentTime @"+i.toFixed(3)),e=i),this.state=iM.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=iM.STOPPED},i.stopLoad=function e(){this._forceStartLoad=!1,t.prototype.stopLoad.call(this)},i.doTick=function t(){switch(this.state){case iM.WAITING_LEVEL:var e=this.levels,i=this.level,r=null==e?void 0:e[i],n=null==r?void 0:r.details;if(n&&(!n.live||this.levelLastLoaded===r)){if(this.waitForCdnTuneIn(n))break;this.state=iM.IDLE}else this.hls.nextLoadLevel!==this.level&&(this.state=iM.IDLE);break;case iM.FRAG_LOADING_WAITING_RETRY:var a,s=self.performance.now(),o=this.retryDate;if(!o||s>=o||null!=(a=this.media)&&a.seeking){var l=this.levels,u=this.level,d=null==l?void 0:l[u];this.resetStartWhenNotLoaded(d||null),this.state=iM.IDLE}}this.state===iM.IDLE&&this.doTickIdle(),this.onTickEnd()},i.onTickEnd=function e(){t.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},i.doTickIdle=function t(){var e=this.hls,i=this.levelLastLoaded,r=this.levels,n=this.media;if(null!==i&&(n||!this.startFragRequested&&e.config.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)){var a=e.nextLoadLevel;if(null!=r&&r[a]){var s=r[a],o=this.getMainFwdBufferInfo();if(null!==o){var l=this.getLevelDetails();if(l&&this._streamEnded(o,l)){var u={};this.altAudio&&(u.type="video"),this.hls.trigger(O.BUFFER_EOS,u),this.state=iM.ENDED;return}e.loadLevel!==a&&-1===e.manualLevel&&this.log("Adapting to level "+a+" from level "+this.level),this.level=e.nextLoadLevel=a;var d=s.details;if(!d||this.state===iM.WAITING_LEVEL||d.live&&this.levelLastLoaded!==s){this.level=a,this.state=iM.WAITING_LEVEL;return}var h=o.len,f=this.getMaxBufferLength(s.maxBitrate);if(!(h>=f)){this.backtrackFragment&&this.backtrackFragment.start>o.end&&(this.backtrackFragment=null);var c=this.backtrackFragment?this.backtrackFragment.start:o.end,$=this.getNextFragment(c,d);if(this.couldBacktrack&&!this.fragPrevious&&$&&"initSegment"!==$.sn&&this.fragmentTracker.getState($)!==ip.OK){var g,v=(null!=(g=this.backtrackFragment)?g:$).sn-d.startSN,m=d.fragments[v-1];m&&$.cc===m.cc&&($=m,this.fragmentTracker.removeFragment(m))}else this.backtrackFragment&&o.len&&(this.backtrackFragment=null);if($&&this.isLoopLoading($,c)){if(!$.gap){var p=this.audioOnly&&!this.altAudio?Q.AUDIO:Q.VIDEO,y=(p===Q.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;y&&this.afterBufferFlushed(y,p,eT.MAIN)}$=this.getNextFragmentLoopLoading($,d,o,eT.MAIN,f)}$&&(!$.initSegment||$.initSegment.data||this.bitrateTest||($=$.initSegment),this.loadFragment($,s,c))}}}}},i.loadFragment=function e(i,r,n){var a=this.fragmentTracker.getState(i);this.fragCurrent=i,a===ip.NOT_LOADED||a===ip.PARTIAL?"initSegment"===i.sn?this._loadInitSegment(i,r):this.bitrateTest?(this.log("Fragment "+i.sn+" of level "+i.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(i,r)):(this.startFragRequested=!0,t.prototype.loadFragment.call(this,i,r,n)):this.clearTrackerIfNeeded(i)},i.getBufferedFrag=function t(e){return this.fragmentTracker.getBufferedFrag(e,eT.MAIN)},i.followingBufferedFrag=function t(e){return e?this.getBufferedFrag(e.end+.5):null},i.immediateLevelSwitch=function t(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},i.nextLevelSwitch=function t(){var e=this.levels,i=this.media;if(null!=i&&i.readyState){var r,n=this.getAppendedFrag(i.currentTime);n&&n.start>1&&this.flushMainBuffer(0,n.start-1);var a=this.getLevelDetails();if(null!=a&&a.live){var s=this.getMainFwdBufferInfo();if(!s||s.len<2*a.targetduration)return}if(!i.paused&&e){var o=e[this.hls.nextLoadLevel],l=this.fragLastKbps;r=l&&this.fragCurrent?this.fragCurrent.duration*o.maxBitrate/(1e3*l)+1:0}else r=0;var u=this.getBufferedFrag(i.currentTime+r);if(u){var d=this.followingBufferedFrag(u);if(d){this.abortCurrentFrag();var h=d.maxStartPTS?d.maxStartPTS:d.start,f=d.duration,c=Math.max(u.end,h+Math.min(Math.max(f-this.config.maxFragLookUpTolerance,f*(this.couldBacktrack?.5:.125)),f*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(c,Number.POSITIVE_INFINITY)}}}},i.abortCurrentFrag=function t(){var e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case iM.KEY_LOADING:case iM.FRAG_LOADING:case iM.FRAG_LOADING_WAITING_RETRY:case iM.PARSING:case iM.PARSED:this.state=iM.IDLE}this.nextLoadPosition=this.getLoadPosition()},i.flushMainBuffer=function e(i,r){t.prototype.flushMainBuffer.call(this,i,r,this.altAudio?"video":null)},i.onMediaAttached=function e(i,r){t.prototype.onMediaAttached.call(this,i,r);var n=r.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),n.addEventListener("playing",this.onvplaying),n.addEventListener("seeked",this.onvseeked),this.gapController=new ay(this.config,n,this.fragmentTracker,this.hls)},i.onMediaDetaching=function e(){var i=this.media;i&&this.onvplaying&&this.onvseeked&&(i.removeEventListener("playing",this.onvplaying),i.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),t.prototype.onMediaDetaching.call(this)},i.onMediaPlaying=function t(){this.tick()},i.onMediaSeeked=function t(){var e=this.media,i=e?e.currentTime:null;w(i)&&this.log("Media seeked to "+i.toFixed(3));var r=this.getMainFwdBufferInfo();if(null===r||0===r.len){this.warn('Main forward buffer length on "seeked" event '+(r?r.len:"empty")+")");return}this.tick()},i.onManifestLoading=function t(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(O.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(e,i){var r,n,a=!1,s=!1;i.levels.forEach(function(t){var e=t.audioCodec;e&&(a=a||-1!==e.indexOf("mp4a.40.2"),s=s||-1!==e.indexOf("mp4a.40.5"))}),this.audioCodecSwitch=a&&s&&"function"!=typeof(null==(n=am())?void 0:null==(r=n.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=i.levels,this.startFragRequested=!1},i.onLevelLoading=function t(e,i){var r=this.levels;if(r&&this.state===iM.IDLE){var n=r[i.level];(!n.details||n.details.live&&this.levelLastLoaded!==n||this.waitForCdnTuneIn(n.details))&&(this.state=iM.WAITING_LEVEL)}},i.onLevelLoaded=function t(e,i){var r,n,a=this.levels,s=i.level,o=i.details,l=o.totalduration;if(!a){this.warn("Levels were reset while loading level "+s);return}this.log("Level "+s+" loaded ["+o.startSN+","+o.endSN+"]"+(o.lastPartSn?"[part-"+o.lastPartSn+"-"+o.lastPartIndex+"]":"")+", cc ["+o.startCC+", "+o.endCC+"] duration:"+l);var u=a[s],d=this.fragCurrent;d&&(this.state===iM.FRAG_LOADING||this.state===iM.FRAG_LOADING_WAITING_RETRY)&&d.level!==i.level&&d.loader&&this.abortCurrentFrag();var h=0;if(o.live||null!=(r=u.details)&&r.live){if(this.checkLiveUpdate(o),o.deltaUpdateFailed)return;h=this.alignPlaylists(o,u.details,null==(n=this.levelLastLoaded)?void 0:n.details)}if(u.details=o,this.levelLastLoaded=u,this.hls.trigger(O.LEVEL_UPDATED,{details:o,level:s}),this.state===iM.WAITING_LEVEL){if(this.waitForCdnTuneIn(o))return;this.state=iM.IDLE}this.startFragRequested?o.live&&this.synchronizeToLiveEdge(o):this.setStartPosition(o,h),this.tick()},i._handleFragmentLoadProgress=function t(e){var i,r=e.frag,n=e.part,a=e.payload,s=this.levels;if(!s){this.warn("Levels were reset while fragment load was in progress. Fragment "+r.sn+" of level "+r.level+" will not be buffered");return}var o=s[r.level],l=o.details;if(!l){this.warn("Dropping fragment "+r.sn+" of level "+r.level+" after level details were reset"),this.fragmentTracker.removeFragment(r);return}var u=o.videoCodec,d=l.PTSKnown||!l.live,h=null==(i=r.initSegment)?void 0:i.data,f=this._getAudioCodec(o),c=this.transmuxer=this.transmuxer||new rG(this.hls,eT.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),$=n?n.index:-1,g=new iL(r.level,r.sn,r.stats.chunkCount,a.byteLength,$,-1!==$),v=this.initPTS[r.cc];c.push(a,h,f,u,r,n,l.totalduration,d,g,v)},i.onAudioTrackSwitching=function t(e,i){var r=this.altAudio;if(!i.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 n=this.fragCurrent;n&&(this.log("Switching to main audio track, cancel main fragment load"),n.abortRequests(),this.fragmentTracker.removeFragment(n)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var a=this.hls;r&&(a.trigger(O.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),a.trigger(O.AUDIO_TRACK_SWITCHED,i)}},i.onAudioTrackSwitched=function t(e,i){var r=i.id,n=!!this.hls.audioTracks[r].url;if(n){var a=this.videoBuffer;a&&this.mediaBuffer!==a&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=a)}this.altAudio=n,this.tick()},i.onBufferCreated=function t(e,i){var r,n,a=i.tracks,s=!1;for(var o in a){var l=a[o];if("main"===l.id){if(n=o,r=l,"video"===o){var u=a[o];u&&(this.videoBuffer=u.buffer)}}else s=!0}s&&r?(this.log("Alternate track found, use "+n+".buffered to schedule main fragment loading"),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media},i.onFragBuffered=function t(e,i){var r=i.frag,n=i.part;if(!r||r.type===eT.MAIN){if(this.fragContextChanged(r)){this.warn("Fragment "+r.sn+(n?" p: "+n.index:"")+" of level "+r.level+" finished buffering, but was aborted. state: "+this.state),this.state===iM.PARSED&&(this.state=iM.IDLE);return}var a=n?n.stats:r.stats;this.fragLastKbps=Math.round(8*a.total/(a.buffering.end-a.loading.first)),"initSegment"!==r.sn&&(this.fragPrevious=r),this.fragBufferedComplete(r,n)}},i.onError=function t(e,i){var r;if(i.fatal){this.state=iM.ERROR;return}switch(i.details){case M.FRAG_GAP:case M.FRAG_PARSING_ERROR:case M.FRAG_DECRYPT_ERROR:case M.FRAG_LOAD_ERROR:case M.FRAG_LOAD_TIMEOUT:case M.KEY_LOAD_ERROR:case M.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(eT.MAIN,i);break;case M.LEVEL_LOAD_ERROR:case M.LEVEL_LOAD_TIMEOUT:case M.LEVEL_PARSING_ERROR:i.levelRetry||this.state!==iM.WAITING_LEVEL||(null==(r=i.context)?void 0:r.type)!==ey.LEVEL||(this.state=iM.IDLE);break;case M.BUFFER_APPEND_ERROR:case M.BUFFER_FULL_ERROR:if(!i.parent||"main"!==i.parent)return;if(i.details===M.BUFFER_APPEND_ERROR){this.resetLoadingState();return}this.reduceLengthAndFlushBuffer(i)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case M.INTERNAL_EXCEPTION:this.recoverWorkerError(i)}},i.checkBuffer=function t(){var e=this.media,i=this.gapController;if(e&&i&&e.readyState){if(this.loadedmetadata||!iS.getBuffered(e).length){var r=this.state!==iM.IDLE?this.fragCurrent:null;i.poll(this.lastCurrentTime,r)}this.lastCurrentTime=e.currentTime}},i.onFragLoadEmergencyAborted=function t(){this.state=iM.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},i.onBufferFlushed=function t(e,i){var r=i.type;if(r!==Q.AUDIO||this.audioOnly&&!this.altAudio){var n=(r===Q.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(n,r,eT.MAIN),this.tick()}},i.onLevelsUpdated=function t(e,i){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level),this.levels=i.levels},i.swapAudioCodec=function t(){this.audioCodecSwap=!this.audioCodecSwap},i.seekToStartPos=function t(){var e=this.media;if(e){var i=e.currentTime,r=this.startPosition;if(r>=0&&i<r){if(e.seeking){this.log("could not seek to "+r+", already seeking at "+i);return}var n=iS.getBuffered(e),a=(n.length?n.start(0):0)-r;a>0&&(a<this.config.maxBufferHole||a<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+a+" to match buffer start"),r+=a,this.startPosition=r),this.log("seek to target start position "+r+" from current time "+i),e.currentTime=r}}},i._getAudioCodec=function t(e){var i=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&i&&(this.log("Swapping audio codec"),i=-1!==i.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),i},i._loadBitrateTestFrag=function t(e,i){var r=this;e.bitrateTest=!0,this._doFragLoad(e,i).then(function(t){var n=r.hls;if(!(!t||r.fragContextChanged(e))){i.fragmentError=0,r.state=iM.IDLE,r.startFragRequested=!1,r.bitrateTest=!1;var a=e.stats;a.parsing.start=a.parsing.end=a.buffering.start=a.buffering.end=self.performance.now(),n.trigger(O.FRAG_LOADED,t),e.bitrateTest=!1}})},i._handleTransmuxComplete=function t(e){var i,r="main",n=this.hls,a=e.remuxResult,s=e.chunkMeta,o=this.getCurrentContext(s);if(!o){this.resetWhenMissingContext(s);return}var l=o.frag,u=o.part,d=o.level,h=a.video,f=a.text,c=a.id3,$=a.initSegment,g=d.details,v=this.altAudio?void 0:a.audio;if(this.fragContextChanged(l)){this.fragmentTracker.removeFragment(l);return}if(this.state=iM.PARSING,$){if(null!=$&&$.tracks){var m=l.initSegment||l;this._bufferInitSegment(d,$.tracks,m,s),n.trigger(O.FRAG_PARSING_INIT_SEGMENT,{frag:m,id:r,tracks:$.tracks})}var p=$.initPTS,y=$.timescale;w(p)&&(this.initPTS[l.cc]={baseTime:p,timescale:y},n.trigger(O.INIT_PTS_FOUND,{frag:l,id:r,initPTS:p,timescale:y}))}if(h&&g&&"initSegment"!==l.sn){var T=g.fragments[l.sn-1-g.startSN],x=l.sn===g.startSN,E=!T||l.cc>T.cc;if(!1!==a.independent){var S=h.startPTS,L=h.endPTS,A=h.startDTS,R=h.endDTS;if(u)u.elementaryStreams[h.type]={startPTS:S,endPTS:L,startDTS:A,endDTS:R};else if(h.firstKeyFrame&&h.independent&&1===s.id&&!E&&(this.couldBacktrack=!0),h.dropped&&h.independent){var _=this.getMainFwdBufferInfo(),D=(_?_.end:this.getLoadPosition())+this.config.maxBufferHole,k=h.firstKeyFramePTS?h.firstKeyFramePTS:S;if(x||!(D<k-this.config.maxBufferHole)||E)E&&(l.gap=!0);else{this.backtrack(l);return}l.setElementaryStreamInfo(h.type,l.start,L,l.start,R,!0)}else x&&S>2&&(l.gap=!0);l.setElementaryStreamInfo(h.type,S,L,A,R),this.backtrackFragment&&(this.backtrackFragment=l),this.bufferFragmentData(h,l,u,s,x||E)}else if(x||E)l.gap=!0;else{this.backtrack(l);return}}if(v){var I=v.startPTS,b=v.endPTS,C=v.startDTS,P=v.endDTS;u&&(u.elementaryStreams[Q.AUDIO]={startPTS:I,endPTS:b,startDTS:C,endDTS:P}),l.setElementaryStreamInfo(Q.AUDIO,I,b,C,P),this.bufferFragmentData(v,l,u,s)}if(g&&null!=c&&null!=(i=c.samples)&&i.length){var F={id:r,frag:l,details:g,samples:c.samples};n.trigger(O.FRAG_PARSING_METADATA,F)}if(g&&f){var N={id:r,frag:l,details:g,samples:f.samples};n.trigger(O.FRAG_PARSING_USERDATA,N)}},i._bufferInitSegment=function t(e,i,r,n){var a=this;if(this.state===iM.PARSING){this.audioOnly=!!i.audio&&!i.video,this.altAudio&&!this.audioOnly&&delete i.audio;var s=i.audio,o=i.video,l=i.audiovideo;if(s){var u=e.audioCodec,d=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){u&&(u=-1!==u.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5");var h=s.metadata;h&&"channelCount"in h&&1!==(h.channelCount||1)&&-1===d.indexOf("firefox")&&(u="mp4a.40.5")}u&&-1!==u.indexOf("mp4a.40.5")&&-1!==d.indexOf("android")&&"audio/mpeg"!==s.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+'"'),s.levelCodec=u,s.id="main",this.log("Init audio buffer, container:"+s.container+", codecs[selected/level/parsed]=["+(u||"")+"/"+(e.audioCodec||"")+"/"+s.codec+"]")}o&&(o.levelCodec=e.videoCodec,o.id="main",this.log("Init video buffer, container:"+o.container+", codecs[level/parsed]=["+(e.videoCodec||"")+"/"+o.codec+"]")),l&&this.log("Init audiovideo buffer, container:"+l.container+", codecs[level/parsed]=["+e.codecs+"/"+l.codec+"]"),this.hls.trigger(O.BUFFER_CODECS,i),Object.keys(i).forEach(function(t){var e=i[t].initSegment;null!=e&&e.byteLength&&a.hls.trigger(O.BUFFER_APPENDING,{type:t,data:e,frag:r,part:null,chunkMeta:n,parent:r.type})}),this.tickImmediate()}},i.getMainFwdBufferInfo=function t(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,eT.MAIN)},i.backtrack=function t(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=iM.IDLE},i.checkFragmentChanged=function t(){var e=this.media,i=null;if(e&&e.readyState>1&&!1===e.seeking){var r=e.currentTime;if(iS.isBuffered(e,r)?i=this.getAppendedFrag(r):iS.isBuffered(e,r+.1)&&(i=this.getAppendedFrag(r+.1)),i){this.backtrackFragment=null;var n=this.fragPlaying,a=i.level;n&&i.sn===n.sn&&n.level===a||(this.fragPlaying=i,this.hls.trigger(O.FRAG_CHANGED,{frag:i}),n&&n.level===a||this.hls.trigger(O.LEVEL_SWITCHED,{level:a}))}}},s(e,[{key:"nextLevel",get:function t(){var e=this.nextBufferedFrag;return e?e.level:-1}},{key:"currentFrag",get:function t(){var e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}},{key:"currentProgramDateTime",get:function t(){var e=this.media;if(e){var i=e.currentTime,r=this.currentFrag;if(r&&w(i)&&w(r.programDateTime)){var n=r.programDateTime+(i-r.start)*1e3;return new Date(n)}}return null}},{key:"currentLevel",get:function t(){var e=this.currentFrag;return e?e.level:-1}},{key:"nextBufferedFrag",get:function t(){var e=this.currentFrag;return e?this.followingBufferedFrag(e):null}},{key:"forceStartLoad",get:function t(){return this._forceStartLoad}}]),e}(iB),ax=function(){function t(e){void 0===e&&(e={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this.started=!1,this._emitter=new rM,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,K(e.debug||!1,"Hls instance");var i,n,a=this.config=function t(e,i){if((i.liveSyncDurationCount||i.liveMaxLatencyDurationCount)&&(i.liveSyncDuration||i.liveMaxLatencyDuration))throw Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==i.liveMaxLatencyDurationCount&&(void 0===i.liveSyncDurationCount||i.liveMaxLatencyDurationCount<=i.liveSyncDurationCount))throw Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==i.liveMaxLatencyDuration&&(void 0===i.liveSyncDuration||i.liveMaxLatencyDuration<=i.liveSyncDuration))throw Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var n=function t(e){return e&&"object"==typeof e?Array.isArray(e)?e.map(t):Object.keys(e).reduce(function(i,r){return i[r]=t(e[r]),i},{}):e}(e),a=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach(function(t){var e=("level"===t?"playlist":t)+"LoadPolicy",r=void 0===i[e],s=[];a.forEach(function(a){var o=t+"Loading"+a,l=i[o];if(void 0!==l&&r){s.push(o);var u=n[e].default;switch(i[e]={default:u},a){case"TimeOut":u.maxLoadTimeMs=l,u.maxTimeToFirstByteMs=l;break;case"MaxRetry":u.errorRetry.maxNumRetry=l,u.timeoutRetry.maxNumRetry=l;break;case"RetryDelay":u.errorRetry.retryDelayMs=l,u.timeoutRetry.retryDelayMs=l;break;case"MaxRetryTimeout":u.errorRetry.maxRetryDelayMs=l,u.timeoutRetry.maxRetryDelayMs=l}}}),s.length&&H.warn('hls.js config: "'+s.join('", "')+'" setting(s) are deprecated, use "'+e+'": '+JSON.stringify(i[e]))}),r(r({},n),i)}(t.DefaultConfig,e);this.userConfig=e,a.progressive&&(i=a,n=i.loader,n!==al&&n!==as?(H.log("[config]: Custom loader detected, cannot enable progressive streaming"),i.progressive=!1):function t(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(e){}return!1}()&&(i.loader=al,i.progressive=!0,i.enableSoftwareAES=!0,H.log("[config]: Progressive streaming enabled, using FetchLoader")));var s=a.abrController,o=a.bufferController,l=a.capLevelController,u=a.errorController,d=a.fpsController,h=new u(this),f=this.abrController=new s(this),c=this.bufferController=new o(this),$=this.capLevelController=new l(this),g=new d(this),v=new eS(this),m=new eP(this),p=a.contentSteeringController,y=p?new p(this):null,T=this.levelController=new a$(this,y),x=new iy(this),E=new av(this.config),S=this.streamController=new aT(this,x,E);$.setStreamController(S),g.setStreamController(S);var L=[v,T,S];y&&L.splice(1,0,y),this.networkControllers=L;var A=[f,c,$,g,m,x];this.audioTrackController=this.createController(a.audioTrackController,L);var R=a.audioStreamController;R&&L.push(new R(this,x,E)),this.subtitleTrackController=this.createController(a.subtitleTrackController,L);var _=a.subtitleStreamController;_&&L.push(new _(this,x,E)),this.createController(a.timelineController,A),E.emeController=this.emeController=this.createController(a.emeController,A),this.cmcdController=this.createController(a.cmcdController,A),this.latencyController=this.createController(eF,A),this.coreComponents=A,L.push(h);var D=h.onErrorOut;"function"==typeof D&&this.on(O.ERROR,D,h)}t.isMSESupported=function t(){return ap()},t.isSupported=function t(){return function t(){if(!ap())return!1;var e=tj();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(tJ(t,"video"))})||["mp4a.40.2","fLaC"].some(function(t){return e.isTypeSupported(tJ(t,"audio"))}))}()},t.getMediaSource=function t(){return tj()};var e=t.prototype;return e.createController=function t(e,i){if(e){var r=new e(this);return i&&i.push(r),r}return null},e.on=function t(e,i,r){void 0===r&&(r=this),this._emitter.on(e,i,r)},e.once=function t(e,i,r){void 0===r&&(r=this),this._emitter.once(e,i,r)},e.removeAllListeners=function t(e){this._emitter.removeAllListeners(e)},e.off=function t(e,i,r,n){void 0===r&&(r=this),this._emitter.off(e,i,r,n)},e.listeners=function t(e){return this._emitter.listeners(e)},e.emit=function t(e,i,r){return this._emitter.emit(e,i,r)},e.trigger=function t(e,i){if(this.config.debug)return this.emit(e,e,i);try{return this.emit(e,e,i)}catch(r){if(H.error("An internal error happened while handling event "+e+'. Error message: "'+r.message+'". Here is a stacktrace:',r),!this.triggeringException){this.triggeringException=!0;var n=e===O.ERROR;this.trigger(O.ERROR,{type:N.OTHER_ERROR,details:M.INTERNAL_EXCEPTION,fatal:n,event:e,error:r}),this.triggeringException=!1}}return!1},e.listenerCount=function t(e){return this._emitter.listenerCount(e)},e.destroy=function t(){H.log("destroy"),this.trigger(O.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},e.attachMedia=function t(e){H.log("attachMedia"),this._media=e,this.trigger(O.MEDIA_ATTACHING,{media:e})},e.detachMedia=function t(){H.log("detachMedia"),this.trigger(O.MEDIA_DETACHING,void 0),this._media=null},e.loadSource=function t(e){this.stopLoad();var i=this.media,r=this.url,n=this.url=C.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,H.log("loadSource:"+n),i&&r&&(r!==n||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(i)),this.trigger(O.MANIFEST_LOADING,{url:e})},e.startLoad=function t(e){void 0===e&&(e=-1),H.log("startLoad("+e+")"),this.started=!0,this.networkControllers.forEach(function(t){t.startLoad(e)})},e.stopLoad=function t(){H.log("stopLoad"),this.started=!1,this.networkControllers.forEach(function(t){t.stopLoad()})},e.resumeBuffering=function t(){this.started&&this.networkControllers.forEach(function(t){"fragmentLoader"in t&&t.startLoad(-1)})},e.pauseBuffering=function t(){this.networkControllers.forEach(function(t){"fragmentLoader"in t&&t.stopLoad()})},e.swapAudioCodec=function t(){H.log("swapAudioCodec"),this.streamController.swapAudioCodec()},e.recoverMediaError=function t(){H.log("recoverMediaError");var e=this._media;this.detachMedia(),e&&this.attachMedia(e)},e.removeLevel=function t(e){this.levelController.removeLevel(e)},e.setAudioOption=function t(e){var i;return null==(i=this.audioTrackController)?void 0:i.setAudioOption(e)},e.setSubtitleOption=function t(e){var i;return null==(i=this.subtitleTrackController)||i.setSubtitleOption(e),null},s(t,[{key:"levels",get:function t(){var e;return this.levelController.levels||[]}},{key:"currentLevel",get:function t(){return this.streamController.currentLevel},set:function t(e){H.log("set currentLevel:"+e),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function t(){return this.streamController.nextLevel},set:function t(e){H.log("set nextLevel:"+e),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function t(){return this.levelController.level},set:function t(e){H.log("set loadLevel:"+e),this.levelController.manualLevel=e}},{key:"nextLoadLevel",get:function t(){return this.levelController.nextLoadLevel},set:function t(e){this.levelController.nextLoadLevel=e}},{key:"firstLevel",get:function t(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function t(e){H.log("set firstLevel:"+e),this.levelController.firstLevel=e}},{key:"startLevel",get:function t(){var e=this.levelController.startLevel;return -1===e&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e},set:function t(e){H.log("set startLevel:"+e),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}},{key:"capLevelToPlayerSize",get:function t(){return this.config.capLevelToPlayerSize},set:function t(e){var i=!!e;i!==this.config.capLevelToPlayerSize&&(i?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=i)}},{key:"autoLevelCapping",get:function t(){return this._autoLevelCapping},set:function t(e){this._autoLevelCapping!==e&&(H.log("set autoLevelCapping:"+e),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}},{key:"bandwidthEstimate",get:function t(){var e=this.abrController.bwEstimator;return e?e.getEstimate():NaN},set:function t(e){this.abrController.resetEstimator(e)}},{key:"ttfbEstimate",get:function t(){var e=this.abrController.bwEstimator;return e?e.getEstimateTTFB():NaN}},{key:"maxHdcpLevel",get:function t(){return this._maxHdcpLevel},set:function t(e){var i;i=e,eO.indexOf(i)>-1&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}},{key:"autoLevelEnabled",get:function t(){return -1===this.levelController.manualLevel}},{key:"manualLevel",get:function t(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function t(){var e=this.levels,i=this.config.minAutoBitrate;if(!e)return 0;for(var r=e.length,n=0;n<r;n++)if(e[n].maxBitrate>=i)return n;return 0}},{key:"maxAutoLevel",get:function t(){var e,i=this.levels,r=this.autoLevelCapping,n=this.maxHdcpLevel;if(e=-1===r&&null!=i&&i.length?i.length-1:r,n)for(var a=e;a--;){var s=i[a].attrs["HDCP-LEVEL"];if(s&&s<=n)return a}return e}},{key:"firstAutoLevel",get:function t(){return this.abrController.firstAutoLevel}},{key:"nextAutoLevel",get:function t(){return this.abrController.nextAutoLevel},set:function t(e){this.abrController.nextAutoLevel=e}},{key:"playingDate",get:function t(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function t(){return this.streamController.getMainFwdBufferInfo()}},{key:"allAudioTracks",get:function t(){var e=this.audioTrackController;return e?e.allAudioTracks:[]}},{key:"audioTracks",get:function t(){var e=this.audioTrackController;return e?e.audioTracks:[]}},{key:"audioTrack",get:function t(){var e=this.audioTrackController;return e?e.audioTrack:-1},set:function t(e){var i=this.audioTrackController;i&&(i.audioTrack=e)}},{key:"allSubtitleTracks",get:function t(){var e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}},{key:"subtitleTracks",get:function t(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]}},{key:"subtitleTrack",get:function t(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1},set:function t(e){var i=this.subtitleTrackController;i&&(i.subtitleTrack=e)}},{key:"media",get:function t(){return this._media}},{key:"subtitleDisplay",get:function t(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay},set:function t(e){var i=this.subtitleTrackController;i&&(i.subtitleDisplay=e)}},{key:"lowLatencyMode",get:function t(){return this.config.lowLatencyMode},set:function t(e){this.config.lowLatencyMode=e}},{key:"liveSyncPosition",get:function t(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function t(){return this.latencyController.latency}},{key:"maxLatency",get:function t(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function t(){return this.latencyController.targetLatency}},{key:"drift",get:function t(){return this.latencyController.drift}},{key:"forceStartLoad",get:function t(){return this.streamController.forceStartLoad}}],[{key:"version",get:function t(){return"1.5.14"}},{key:"Events",get:function t(){return O}},{key:"ErrorTypes",get:function t(){return N}},{key:"ErrorDetails",get:function t(){return M}},{key:"DefaultConfig",get:function e(){return t.defaultConfig?t.defaultConfig:ac},set:function e(i){t.defaultConfig=i}}]),t}();return ax.defaultConfig=void 0,ax},"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(i="undefined"!=typeof globalThis?globalThis:i||self).Hls=r()}(!1);
// Original Source: https://github.com/video-dev/hls.js/blob/master/demo/basic-usage.html#L14-L36
var StreamPlayer = document.querySelector('.video-container > video')
var StreamSource = document.querySelector('.video-container > video').src
if (Hls.isSupported()) {
var hls = new Hls({
debug: false,
})
hls.loadSource(StreamSource)
hls.attachMedia(StreamPlayer)
hls.on(Hls.Events.MEDIA_ATTACHED, function () {
StreamPlayer.muted = false
StreamPlayer.play()
})
}
</script>