lemon-mse 0.3.7 → 0.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/hls.js CHANGED
@@ -1,32 +1,27 @@
1
- (function (g, f) {var hasExports = typeof exports === 'object';if (typeof define === "function" && define.amd) {define([], f);} else if (typeof module === "object" && module.exports) {module.exports = f();} else {var m = hasExports ? f() : f();var root = hasExports ? exports : g;for(var i in m) root[i] = m[i];}}(typeof self !== 'undefined' ? self : typeof globalThis !== 'undefined' ? globalThis : this, () => {var exports = {};var module = { exports };
2
- "use strict";var ho=Object.create;var St=Object.defineProperty;var co=Object.getOwnPropertyDescriptor;var vo=Object.getOwnPropertyNames;var go=Object.getPrototypeOf,mo=Object.prototype.hasOwnProperty;var po=(ne,ae)=>()=>(ae||ne((ae={exports:{}}).exports,ae),ae.exports),yo=(ne,ae)=>{for(var ge in ae)St(ne,ge,{get:ae[ge],enumerable:!0})},Ki=(ne,ae,ge,se)=>{if(ae&&typeof ae=="object"||typeof ae=="function")for(let Ne of vo(ae))!mo.call(ne,Ne)&&Ne!==ge&&St(ne,Ne,{get:()=>ae[Ne],enumerable:!(se=co(ae,Ne))||se.enumerable});return ne};var Eo=(ne,ae,ge)=>(ge=ne!=null?ho(go(ne)):{},Ki(ae||!ne||!ne.__esModule?St(ge,"default",{value:ne,enumerable:!0}):ge,ne)),xo=ne=>Ki(St({},"__esModule",{value:!0}),ne);var Yi=po((Wi,nr)=>{(function ne(ae){(function(ge,se){typeof Wi=="object"&&typeof nr<"u"?nr.exports=se():typeof define=="function"&&define.amd?define(se):(ge=typeof globalThis<"u"?globalThis:ge||self,ge.Hls=se())})(this,function(){"use strict";function ge(a,n){var i=Object.keys(a);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(a);n&&(e=e.filter(function(t){return Object.getOwnPropertyDescriptor(a,t).enumerable})),i.push.apply(i,e)}return i}function se(a){for(var n=1;n<arguments.length;n++){var i=arguments[n]!=null?arguments[n]:{};n%2?ge(Object(i),!0).forEach(function(e){ji(a,e,i[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(i)):ge(Object(i)).forEach(function(e){Object.defineProperty(a,e,Object.getOwnPropertyDescriptor(i,e))})}return a}function Ne(a,n){if(typeof a!="object"||!a)return a;var i=a[Symbol.toPrimitive];if(i!==void 0){var e=i.call(a,n||"default");if(typeof e!="object")return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(a)}function ar(a){var n=Ne(a,"string");return typeof n=="symbol"?n:String(n)}function sr(a,n){for(var i=0;i<n.length;i++){var e=n[i];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(a,ar(e.key),e)}}function me(a,n,i){return n&&sr(a.prototype,n),i&&sr(a,i),Object.defineProperty(a,"prototype",{writable:!1}),a}function ji(a,n,i){return n=ar(n),n in a?Object.defineProperty(a,n,{value:i,enumerable:!0,configurable:!0,writable:!0}):a[n]=i,a}function Te(){return Te=Object.assign?Object.assign.bind():function(a){for(var n=1;n<arguments.length;n++){var i=arguments[n];for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&(a[e]=i[e])}return a},Te.apply(this,arguments)}function _e(a,n){a.prototype=Object.create(n.prototype),a.prototype.constructor=a,je(a,n)}function Lt(a){return Lt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},Lt(a)}function je(a,n){return je=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},je(a,n)}function Xi(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Qe(a,n,i){return Xi()?Qe=Reflect.construct.bind():Qe=function(t,r,s){var o=[null];o.push.apply(o,r);var l=Function.bind.apply(t,o),u=new l;return s&&je(u,s.prototype),u},Qe.apply(null,arguments)}function zi(a){try{return Function.toString.call(a).indexOf("[native code]")!==-1}catch{return typeof a=="function"}}function Ze(a){var n=typeof Map=="function"?new Map:void 0;return Ze=function(e){if(e===null||!zi(e))return e;if(typeof e!="function")throw new TypeError("Super expression must either be null or a function");if(typeof n<"u"){if(n.has(e))return n.get(e);n.set(e,t)}function t(){return Qe(e,arguments,Lt(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),je(t,e)},Ze(a)}function $i(a){if(a===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function or(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var lr={exports:{}};(function(a,n){(function(i){var e=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,t=/^(?=([^\/?#]*))\1([^]*)$/,r=/(?:\/|^)\.(?=\/)/g,s=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(l,u,d){if(d=d||{},l=l.trim(),u=u.trim(),!u){if(!d.alwaysNormalize)return l;var f=o.parseURL(l);if(!f)throw new Error("Error trying to parse base URL.");return f.path=o.normalizePath(f.path),o.buildURLFromParts(f)}var h=o.parseURL(u);if(!h)throw new Error("Error trying to parse relative URL.");if(h.scheme)return d.alwaysNormalize?(h.path=o.normalizePath(h.path),o.buildURLFromParts(h)):u;var c=o.parseURL(l);if(!c)throw new Error("Error trying to parse base URL.");if(!c.netLoc&&c.path&&c.path[0]!=="/"){var v=t.exec(c.path);c.netLoc=v[1],c.path=v[2]}c.netLoc&&!c.path&&(c.path="/");var g={scheme:c.scheme,netLoc:h.netLoc,path:null,params:h.params,query:h.query,fragment:h.fragment};if(!h.netLoc&&(g.netLoc=c.netLoc,h.path[0]!=="/"))if(!h.path)g.path=c.path,h.params||(g.params=c.params,h.query||(g.query=c.query));else{var m=c.path,p=m.substring(0,m.lastIndexOf("/")+1)+h.path;g.path=o.normalizePath(p)}return g.path===null&&(g.path=d.alwaysNormalize?o.normalizePath(h.path):h.path),o.buildURLFromParts(g)},parseURL:function(l){var u=e.exec(l);return u?{scheme:u[1]||"",netLoc:u[2]||"",path:u[3]||"",params:u[4]||"",query:u[5]||"",fragment:u[6]||""}:null},normalizePath:function(l){for(l=l.split("").reverse().join("").replace(r,"");l.length!==(l=l.replace(s,"")).length;);return l.split("").reverse().join("")},buildURLFromParts:function(l){return l.scheme+l.netLoc+l.path+l.params+l.query+l.fragment}};a.exports=o})()})(lr);var At=lr.exports,M=Number.isFinite||function(a){return typeof a=="number"&&isFinite(a)},Qi=Number.isSafeInteger||function(a){return typeof a=="number"&&Math.abs(a)<=Zi},Zi=Number.MAX_SAFE_INTEGER||9007199254740991,x=function(a){return a.MEDIA_ATTACHING="hlsMediaAttaching",a.MEDIA_ATTACHED="hlsMediaAttached",a.MEDIA_DETACHING="hlsMediaDetaching",a.MEDIA_DETACHED="hlsMediaDetached",a.BUFFER_RESET="hlsBufferReset",a.BUFFER_CODECS="hlsBufferCodecs",a.BUFFER_CREATED="hlsBufferCreated",a.BUFFER_APPENDING="hlsBufferAppending",a.BUFFER_APPENDED="hlsBufferAppended",a.BUFFER_EOS="hlsBufferEos",a.BUFFER_FLUSHING="hlsBufferFlushing",a.BUFFER_FLUSHED="hlsBufferFlushed",a.MANIFEST_LOADING="hlsManifestLoading",a.MANIFEST_LOADED="hlsManifestLoaded",a.MANIFEST_PARSED="hlsManifestParsed",a.LEVEL_SWITCHING="hlsLevelSwitching",a.LEVEL_SWITCHED="hlsLevelSwitched",a.LEVEL_LOADING="hlsLevelLoading",a.LEVEL_LOADED="hlsLevelLoaded",a.LEVEL_UPDATED="hlsLevelUpdated",a.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",a.LEVELS_UPDATED="hlsLevelsUpdated",a.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",a.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",a.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",a.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",a.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",a.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",a.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",a.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",a.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",a.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",a.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",a.CUES_PARSED="hlsCuesParsed",a.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",a.INIT_PTS_FOUND="hlsInitPtsFound",a.FRAG_LOADING="hlsFragLoading",a.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",a.FRAG_LOADED="hlsFragLoaded",a.FRAG_DECRYPTED="hlsFragDecrypted",a.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",a.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",a.FRAG_PARSING_METADATA="hlsFragParsingMetadata",a.FRAG_PARSED="hlsFragParsed",a.FRAG_BUFFERED="hlsFragBuffered",a.FRAG_CHANGED="hlsFragChanged",a.FPS_DROP="hlsFpsDrop",a.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",a.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",a.ERROR="hlsError",a.DESTROYING="hlsDestroying",a.KEY_LOADING="hlsKeyLoading",a.KEY_LOADED="hlsKeyLoaded",a.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",a.BACK_BUFFER_REACHED="hlsBackBufferReached",a.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",a}({}),V=function(a){return a.NETWORK_ERROR="networkError",a.MEDIA_ERROR="mediaError",a.KEY_SYSTEM_ERROR="keySystemError",a.MUX_ERROR="muxError",a.OTHER_ERROR="otherError",a}({}),D=function(a){return a.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",a.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",a.KEY_SYSTEM_NO_SESSION="keySystemNoSession",a.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",a.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",a.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",a.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",a.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",a.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",a.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",a.MANIFEST_LOAD_ERROR="manifestLoadError",a.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",a.MANIFEST_PARSING_ERROR="manifestParsingError",a.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",a.LEVEL_EMPTY_ERROR="levelEmptyError",a.LEVEL_LOAD_ERROR="levelLoadError",a.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",a.LEVEL_PARSING_ERROR="levelParsingError",a.LEVEL_SWITCH_ERROR="levelSwitchError",a.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",a.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",a.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",a.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",a.FRAG_LOAD_ERROR="fragLoadError",a.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",a.FRAG_DECRYPT_ERROR="fragDecryptError",a.FRAG_PARSING_ERROR="fragParsingError",a.FRAG_GAP="fragGap",a.REMUX_ALLOC_ERROR="remuxAllocError",a.KEY_LOAD_ERROR="keyLoadError",a.KEY_LOAD_TIMEOUT="keyLoadTimeOut",a.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",a.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",a.BUFFER_APPEND_ERROR="bufferAppendError",a.BUFFER_APPENDING_ERROR="bufferAppendingError",a.BUFFER_STALLED_ERROR="bufferStalledError",a.BUFFER_FULL_ERROR="bufferFullError",a.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",a.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",a.INTERNAL_EXCEPTION="internalException",a.INTERNAL_ABORTED="aborted",a.UNKNOWN="unknown",a}({}),Be=function(){},Rt={trace:Be,debug:Be,log:Be,warn:Be,info:Be,error:Be},Xe=Rt;function Ji(a){var n=self.console[a];return n?n.bind(self.console,"["+a+"] >"):Be}function en(a){for(var n=arguments.length,i=new Array(n>1?n-1:0),e=1;e<n;e++)i[e-1]=arguments[e];i.forEach(function(t){Xe[t]=a[t]?a[t].bind(a):Ji(t)})}function ur(a,n){if(typeof console=="object"&&a===!0||typeof a=="object"){en(a,"debug","log","info","warn","error");try{Xe.log('Debug logs enabled for "'+n+'" in hls.js version 1.5.17')}catch{Xe=Rt}}else Xe=Rt}var R=Xe,tn=/^(\d+)x(\d+)$/,fr=/(.+?)=(".*?"|.*?)(?:,|$)/g,oe=function(){function a(i){typeof i=="string"&&(i=a.parseAttrList(i)),Te(this,i)}var n=a.prototype;return n.decimalInteger=function(e){var t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t},n.hexadecimalInteger=function(e){if(this[e]){var t=(this[e]||"0x").slice(2);t=(t.length&1?"0":"")+t;for(var r=new Uint8Array(t.length/2),s=0;s<t.length/2;s++)r[s]=parseInt(t.slice(s*2,s*2+2),16);return r}else return null},n.hexadecimalIntegerAsNumber=function(e){var t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t},n.decimalFloatingPoint=function(e){return parseFloat(this[e])},n.optionalFloat=function(e,t){var r=this[e];return r?parseFloat(r):t},n.enumeratedString=function(e){return this[e]},n.bool=function(e){return this[e]==="YES"},n.decimalResolution=function(e){var t=tn.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}},a.parseAttrList=function(e){var t,r={},s='"';for(fr.lastIndex=0;(t=fr.exec(e))!==null;){var o=t[2];o.indexOf(s)===0&&o.lastIndexOf(s)===o.length-1&&(o=o.slice(1,-1));var l=t[1].trim();r[l]=o}return r},me(a,[{key:"clientAttrs",get:function(){return Object.keys(this).filter(function(e){return e.substring(0,2)==="X-"})}}]),a}();function rn(a){return a!=="ID"&&a!=="CLASS"&&a!=="START-DATE"&&a!=="DURATION"&&a!=="END-DATE"&&a!=="END-ON-NEXT"}function nn(a){return a==="SCTE35-OUT"||a==="SCTE35-IN"}var dr=function(){function a(n,i){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,i){var e=i.attr;for(var t in e)if(Object.prototype.hasOwnProperty.call(n,t)&&n[t]!==e[t]){R.warn('DATERANGE tag attribute: "'+t+'" does not match for tags with ID: "'+n.ID+'"'),this._badValueForSameId=t;break}n=Te(new oe({}),e,n)}if(this.attr=n,this._startDate=new Date(n["START-DATE"]),"END-DATE"in this.attr){var r=new Date(this.attr["END-DATE"]);M(r.getTime())&&(this._endDate=r)}}return me(a,[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){if(this._endDate)return this._endDate;var i=this.duration;return i!==null?new Date(this._startDate.getTime()+i*1e3):null}},{key:"duration",get:function(){if("DURATION"in this.attr){var i=this.attr.decimalFloatingPoint("DURATION");if(M(i))return i}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}},{key:"endOnNext",get:function(){return this.attr.bool("END-ON-NEXT")}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&M(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),a}(),Je=function(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}},$={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"},hr=function(){function a(i){var e;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(e={},e[$.AUDIO]=null,e[$.VIDEO]=null,e[$.AUDIOVIDEO]=null,e),this.baseurl=i}var n=a.prototype;return n.setByteRange=function(e,t){var r=e.split("@",2),s;r.length===1?s=t?.byteRangeEndOffset||0:s=parseInt(r[1]),this._byteRange=[s,parseInt(r[0])+s]},me(a,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=At.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(e){this._url=e}}]),a}(),bt=function(a){_e(n,a);function n(e,t){var r;return r=a.call(this,t)||this,r._decryptdata=null,r.rawProgramDateTime=null,r.programDateTime=null,r.tagList=[],r.duration=0,r.sn=0,r.levelkeys=void 0,r.type=void 0,r.loader=null,r.keyLoader=null,r.level=-1,r.cc=0,r.startPTS=void 0,r.endPTS=void 0,r.startDTS=void 0,r.endDTS=void 0,r.start=0,r.deltaPTS=void 0,r.maxStartPTS=void 0,r.minEndPTS=void 0,r.stats=new Je,r.data=void 0,r.bitrateTest=!1,r.title=null,r.initSegment=null,r.endList=void 0,r.gap=void 0,r.urlId=0,r.type=e,r}var i=n.prototype;return i.setKeyFormat=function(t){if(this.levelkeys){var r=this.levelkeys[t];r&&!this._decryptdata&&(this._decryptdata=r.getDecryptData(this.sn))}},i.abortRequests=function(){var t,r;(t=this.loader)==null||t.abort(),(r=this.keyLoader)==null||r.abort()},i.setElementaryStreamInfo=function(t,r,s,o,l,u){u===void 0&&(u=!1);var d=this.elementaryStreams,f=d[t];if(!f){d[t]={startPTS:r,endPTS:s,startDTS:o,endDTS:l,partial:u};return}f.startPTS=Math.min(f.startPTS,r),f.endPTS=Math.max(f.endPTS,s),f.startDTS=Math.min(f.startDTS,o),f.endDTS=Math.max(f.endDTS,l)},i.clearElementaryStreamInfo=function(){var t=this.elementaryStreams;t[$.AUDIO]=null,t[$.VIDEO]=null,t[$.AUDIOVIDEO]=null},me(n,[{key:"decryptdata",get:function(){var t=this.levelkeys;if(!t&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var r=this.levelkeys.identity;if(r)this._decryptdata=r.getDecryptData(this.sn);else{var s=Object.keys(this.levelkeys);if(s.length===1)return this._decryptdata=this.levelkeys[s[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null||!M(this.programDateTime))return null;var t=M(this.duration)?this.duration:0;return this.programDateTime+t*1e3}},{key:"encrypted",get:function(){var t;if((t=this._decryptdata)!=null&&t.encrypted)return!0;if(this.levelkeys){var r=Object.keys(this.levelkeys),s=r.length;if(s>1||s===1&&this.levelkeys[r[0]].encrypted)return!0}return!1}}]),n}(hr),an=function(a){_e(n,a);function n(i,e,t,r,s){var o;o=a.call(this,t)||this,o.fragOffset=0,o.duration=0,o.gap=!1,o.independent=!1,o.relurl=void 0,o.fragment=void 0,o.index=void 0,o.stats=new Je,o.duration=i.decimalFloatingPoint("DURATION"),o.gap=i.bool("GAP"),o.independent=i.bool("INDEPENDENT"),o.relurl=i.enumeratedString("URI"),o.fragment=e,o.index=r;var l=i.enumeratedString("BYTERANGE");return l&&o.setByteRange(l,s),s&&(o.fragOffset=s.fragOffset+s.duration),o}return me(n,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var e=this.elementaryStreams;return!!(e.audio||e.video||e.audiovideo)}}]),n}(hr),sn=10,on=function(){function a(i){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=i}var n=a.prototype;return n.reloaded=function(e){if(!e){this.advanced=!0,this.updated=!0;return}var t=this.lastPartSn-e.lastPartSn,r=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!r||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||t===0&&r>0,this.updated||this.advanced?this.misses=Math.floor(e.misses*.6):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay},me(a,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?M(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||sn}},{key:"drift",get:function(){var e=this.driftEndTime-this.driftStartTime;if(e>0){var t=this.driftEnd-this.driftStart;return t*1e3/e}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var e;return(e=this.fragments)!=null&&e.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),a}(),ln=void 0,un=or(ln);function Ue(a,n,i){return Uint8Array.prototype.slice?a.slice(n,i):new Uint8Array(Array.prototype.slice.call(a,n,i))}var It=function(n,i){return i+10<=n.length&&n[i]===73&&n[i+1]===68&&n[i+2]===51&&n[i+3]<255&&n[i+4]<255&&n[i+6]<128&&n[i+7]<128&&n[i+8]<128&&n[i+9]<128},cr=function(n,i){return i+10<=n.length&&n[i]===51&&n[i+1]===68&&n[i+2]===73&&n[i+3]<255&&n[i+4]<255&&n[i+6]<128&&n[i+7]<128&&n[i+8]<128&&n[i+9]<128},et=function(n,i){for(var e=i,t=0;It(n,i);){t+=10;var r=tt(n,i+6);t+=r,cr(n,i+10)&&(t+=10),i+=t}if(t>0)return n.subarray(e,e+t)},tt=function(n,i){var e=0;return e=(n[i]&127)<<21,e|=(n[i+1]&127)<<14,e|=(n[i+2]&127)<<7,e|=n[i+3]&127,e},fn=function(n,i){return It(n,i)&&tt(n,i+6)+10<=n.length-i},vr=function(n){for(var i=mr(n),e=0;e<i.length;e++){var t=i[e];if(gr(t))return mn(t)}},gr=function(n){return n&&n.key==="PRIV"&&n.info==="com.apple.streaming.transportStreamTimestamp"},dn=function(n){var i=String.fromCharCode(n[0],n[1],n[2],n[3]),e=tt(n,4),t=10;return{type:i,size:e,data:n.subarray(t,t+e)}},mr=function(n){for(var i=0,e=[];It(n,i);){var t=tt(n,i+6);i+=10;for(var r=i+t;i+8<r;){var s=dn(n.subarray(i)),o=hn(s);o&&e.push(o),i+=s.size+10}cr(n,i)&&(i+=10)}return e},hn=function(n){return n.type==="PRIV"?cn(n):n.type[0]==="W"?gn(n):vn(n)},cn=function(n){if(!(n.size<2)){var i=Me(n.data,!0),e=new Uint8Array(n.data.subarray(i.length+1));return{key:n.type,info:i,data:e.buffer}}},vn=function(n){if(!(n.size<2)){if(n.type==="TXXX"){var i=1,e=Me(n.data.subarray(i),!0);i+=e.length+1;var t=Me(n.data.subarray(i));return{key:n.type,info:e,data:t}}var r=Me(n.data.subarray(1));return{key:n.type,data:r}}},gn=function(n){if(n.type==="WXXX"){if(n.size<2)return;var i=1,e=Me(n.data.subarray(i),!0);i+=e.length+1;var t=Me(n.data.subarray(i));return{key:n.type,info:e,data:t}}var r=Me(n.data);return{key:n.type,data:r}},mn=function(n){if(n.data.byteLength===8){var i=new Uint8Array(n.data),e=i[3]&1,t=(i[4]<<23)+(i[5]<<15)+(i[6]<<7)+i[7];return t/=45,e&&(t+=4772185884e-2),Math.round(t)}},Me=function(n,i){i===void 0&&(i=!1);var e=pn();if(e){var t=e.decode(n);if(i){var r=t.indexOf("\0");return r!==-1?t.substring(0,r):t}return t.replace(/\0/g,"")}for(var s=n.length,o,l,u,d="",f=0;f<s;){if(o=n[f++],o===0&&i)return d;if(o===0||o===3)continue;switch(o>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:d+=String.fromCharCode(o);break;case 12:case 13:l=n[f++],d+=String.fromCharCode((o&31)<<6|l&63);break;case 14:l=n[f++],u=n[f++],d+=String.fromCharCode((o&15)<<12|(l&63)<<6|(u&63)<<0);break}}return d},_t;function pn(){if(!navigator.userAgent.includes("PlayStation 4"))return!_t&&typeof self.TextDecoder<"u"&&(_t=new self.TextDecoder("utf-8")),_t}var pr={hexDump:function(n){for(var i="",e=0;e<n.length;e++){var t=n[e].toString(16);t.length<2&&(t="0"+t),i+=t}return i}},rt=Math.pow(2,32)-1,yn=[].push,yr={video:1,audio:2,id3:3,text:4};function ue(a){return String.fromCharCode.apply(null,a)}function Er(a,n){var i=a[n]<<8|a[n+1];return i<0?65536+i:i}function N(a,n){var i=Tr(a,n);return i<0?4294967296+i:i}function xr(a,n){var i=N(a,n);return i*=Math.pow(2,32),i+=N(a,n+4),i}function Tr(a,n){return a[n]<<24|a[n+1]<<16|a[n+2]<<8|a[n+3]}function Dt(a,n,i){a[n]=i>>24,a[n+1]=i>>16&255,a[n+2]=i>>8&255,a[n+3]=i&255}function En(a){for(var n=a.byteLength,i=0;i<n;){var e=N(a,i);if(e>8&&a[i+4]===109&&a[i+5]===111&&a[i+6]===111&&a[i+7]===102)return!0;i=e>1?i+e:n}return!1}function G(a,n){var i=[];if(!n.length)return i;for(var e=a.byteLength,t=0;t<e;){var r=N(a,t),s=ue(a.subarray(t+4,t+8)),o=r>1?t+r:e;if(s===n[0])if(n.length===1)i.push(a.subarray(t+8,o));else{var l=G(a.subarray(t+8,o),n.slice(1));l.length&&yn.apply(i,l)}t=o}return i}function xn(a){var n=[],i=a[0],e=8,t=N(a,e);e+=4;var r=0,s=0;i===0?(r=N(a,e),s=N(a,e+4),e+=8):(r=xr(a,e),s=xr(a,e+8),e+=16),e+=2;var o=a.length+s,l=Er(a,e);e+=2;for(var u=0;u<l;u++){var d=e,f=N(a,d);d+=4;var h=f&2147483647,c=(f&2147483648)>>>31;if(c===1)return R.warn("SIDX has hierarchical references (not supported)"),null;var v=N(a,d);d+=4,n.push({referenceSize:h,subsegmentDuration:v,info:{duration:v/t,start:o,end:o+h-1}}),o+=h,d+=4,e=d}return{earliestPresentationTime:r,timescale:t,version:i,referencesCount:l,references:n}}function Sr(a){for(var n=[],i=G(a,["moov","trak"]),e=0;e<i.length;e++){var t=i[e],r=G(t,["tkhd"])[0];if(r){var s=r[0],o=N(r,s===0?12:20),l=G(t,["mdia","mdhd"])[0];if(l){s=l[0];var u=N(l,s===0?12:20),d=G(t,["mdia","hdlr"])[0];if(d){var f=ue(d.subarray(8,12)),h={soun:$.AUDIO,vide:$.VIDEO}[f];if(h){var c=G(t,["mdia","minf","stbl","stsd"])[0],v=Tn(c);n[o]={timescale:u,type:h},n[h]=se({timescale:u,id:o},v)}}}}}var g=G(a,["moov","mvex","trex"]);return g.forEach(function(m){var p=N(m,4),y=n[p];y&&(y.default={duration:N(m,12),flags:N(m,20)})}),n}function Tn(a){var n=a.subarray(8),i=n.subarray(86),e=ue(n.subarray(4,8)),t=e,r=e==="enca"||e==="encv";if(r){var s=G(n,[e])[0],o=s.subarray(e==="enca"?28:78),l=G(o,["sinf"]);l.forEach(function(xe){var ve=G(xe,["schm"])[0];if(ve){var de=ue(ve.subarray(4,8));if(de==="cbcs"||de==="cenc"){var Ve=G(xe,["frma"])[0];Ve&&(t=ue(Ve))}}})}switch(t){case"avc1":case"avc2":case"avc3":case"avc4":{var u=G(i,["avcC"])[0];t+="."+it(u[1])+it(u[2])+it(u[3]);break}case"mp4a":{var d=G(n,[e])[0],f=G(d.subarray(28),["esds"])[0];if(f&&f.length>12){var h=4;if(f[h++]!==3)break;h=Ct(f,h),h+=2;var c=f[h++];if(c&128&&(h+=2),c&64&&(h+=f[h++]),f[h++]!==4)break;h=Ct(f,h);var v=f[h++];if(v===64)t+="."+it(v);else break;if(h+=12,f[h++]!==5)break;h=Ct(f,h);var g=f[h++],m=(g&248)>>3;m===31&&(m+=1+((g&7)<<3)+((f[h]&224)>>5)),t+="."+m}break}case"hvc1":case"hev1":{var p=G(i,["hvcC"])[0],y=p[1],E=["","A","B","C"][y>>6],S=y&31,L=N(p,2),_=(y&32)>>5?"H":"L",A=p[12],T=p.subarray(6,12);t+="."+E+S,t+="."+L.toString(16).toUpperCase(),t+="."+_+A;for(var b="",I=T.length;I--;){var P=T[I];if(P||b){var C=P.toString(16).toUpperCase();b="."+C+b}}t+=b;break}case"dvh1":case"dvhe":{var w=G(i,["dvcC"])[0],O=w[2]>>1&127,F=w[2]<<5&32|w[3]>>3&31;t+="."+De(O)+"."+De(F);break}case"vp09":{var H=G(i,["vpcC"])[0],U=H[4],W=H[5],K=H[6]>>4&15;t+="."+De(U)+"."+De(W)+"."+De(K);break}case"av01":{var B=G(i,["av1C"])[0],Q=B[1]>>>5,j=B[1]&31,J=B[2]>>>7?"H":"M",ee=(B[2]&64)>>6,re=(B[2]&32)>>5,Z=Q===2&&ee?re?12:10:ee?10:8,X=(B[2]&16)>>4,Fe=(B[2]&8)>>3,Se=(B[2]&4)>>2,te=B[2]&3,pe=1,ye=1,ie=1,z=0;t+="."+Q+"."+De(j)+J+"."+De(Z)+"."+X+"."+Fe+Se+te+"."+De(pe)+"."+De(ye)+"."+De(ie)+"."+z;break}}return{codec:t,encrypted:r}}function Ct(a,n){for(var i=n+5;a[n++]&128&&n<i;);return n}function it(a){return("0"+a.toString(16).toUpperCase()).slice(-2)}function De(a){return(a<10?"0":"")+a}function Sn(a,n){if(!a||!n)return a;var i=n.keyId;if(i&&n.isCommonEncryption){var e=G(a,["moov","trak"]);e.forEach(function(t){var r=G(t,["mdia","minf","stbl","stsd"])[0],s=r.subarray(8),o=G(s,["enca"]),l=o.length>0;l||(o=G(s,["encv"])),o.forEach(function(u){var d=l?u.subarray(28):u.subarray(78),f=G(d,["sinf"]);f.forEach(function(h){var c=Ln(h);if(c){var v=c.subarray(8,24);v.some(function(g){return g!==0})||(R.log("[eme] Patching keyId in 'enc"+(l?"a":"v")+">sinf>>tenc' box: "+pr.hexDump(v)+" -> "+pr.hexDump(i)),c.set(i,8))}})})})}return a}function Ln(a){var n=G(a,["schm"])[0];if(n){var i=ue(n.subarray(4,8));if(i==="cbcs"||i==="cenc")return G(a,["schi","tenc"])[0]}return null}function An(a,n){return G(n,["moof","traf"]).reduce(function(i,e){var t=G(e,["tfdt"])[0],r=t[0],s=G(e,["tfhd"]).reduce(function(o,l){var u=N(l,4),d=a[u];if(d){var f=N(t,4);if(r===1){if(f===rt)return R.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),o;f*=rt+1,f+=N(t,8)}var h=d.timescale||9e4,c=f/h;if(M(c)&&(o===null||c<o))return c}return o},null);return s!==null&&M(s)&&(i===null||s<i)?s:i},null)}function Rn(a,n){for(var i=0,e=0,t=0,r=G(a,["moof","traf"]),s=0;s<r.length;s++){var o=r[s],l=G(o,["tfhd"])[0],u=N(l,4),d=n[u];if(d){var f=d.default,h=N(l,0)|f?.flags,c=f?.duration;h&8&&(h&2?c=N(l,12):c=N(l,8));for(var v=d.timescale||9e4,g=G(o,["trun"]),m=0;m<g.length;m++){if(i=bn(g[m]),!i&&c){var p=N(g[m],4);i=c*p}d.type===$.VIDEO?e+=i/v:d.type===$.AUDIO&&(t+=i/v)}}}if(e===0&&t===0){for(var y=1/0,E=0,S=0,L=G(a,["sidx"]),_=0;_<L.length;_++){var A=xn(L[_]);if(A!=null&&A.references){y=Math.min(y,A.earliestPresentationTime/A.timescale);var T=A.references.reduce(function(b,I){return b+I.info.duration||0},0);E=Math.max(E,T+A.earliestPresentationTime/A.timescale),S=E-y}}if(S&&M(S))return S}return e||t}function bn(a){var n=N(a,0),i=8;n&1&&(i+=4),n&4&&(i+=4);for(var e=0,t=N(a,4),r=0;r<t;r++){if(n&256){var s=N(a,i);e+=s,i+=4}n&512&&(i+=4),n&1024&&(i+=4),n&2048&&(i+=4)}return e}function In(a,n,i){G(n,["moof","traf"]).forEach(function(e){G(e,["tfhd"]).forEach(function(t){var r=N(t,4),s=a[r];if(s){var o=s.timescale||9e4;G(e,["tfdt"]).forEach(function(l){var u=l[0],d=i*o;if(d){var f=N(l,4);if(u===0)f-=d,f=Math.max(f,0),Dt(l,4,f);else{f*=Math.pow(2,32),f+=N(l,8),f-=d,f=Math.max(f,0);var h=Math.floor(f/(rt+1)),c=Math.floor(f%(rt+1));Dt(l,4,h),Dt(l,8,c)}}})}})})}function _n(a){var n={valid:null,remainder:null},i=G(a,["moof"]);if(i.length<2)return n.remainder=a,n;var e=i[i.length-1];return n.valid=Ue(a,0,e.byteOffset-8),n.remainder=Ue(a,e.byteOffset-8),n}function Le(a,n){var i=new Uint8Array(a.length+n.length);return i.set(a),i.set(n,a.length),i}function Lr(a,n){var i=[],e=n.samples,t=n.timescale,r=n.id,s=!1,o=G(e,["moof"]);return o.map(function(l){var u=l.byteOffset-8,d=G(l,["traf"]);d.map(function(f){var h=G(f,["tfdt"]).map(function(c){var v=c[0],g=N(c,4);return v===1&&(g*=Math.pow(2,32),g+=N(c,8)),g/t})[0];return h!==void 0&&(a=h),G(f,["tfhd"]).map(function(c){var v=N(c,4),g=N(c,0)&16777215,m=(g&1)!==0,p=(g&2)!==0,y=(g&8)!==0,E=0,S=(g&16)!==0,L=0,_=(g&32)!==0,A=8;v===r&&(m&&(A+=8),p&&(A+=4),y&&(E=N(c,A),A+=4),S&&(L=N(c,A),A+=4),_&&(A+=4),n.type==="video"&&(s=Dn(n.codec)),G(f,["trun"]).map(function(T){var b=T[0],I=N(T,0)&16777215,P=(I&1)!==0,C=0,w=(I&4)!==0,O=(I&256)!==0,F=0,H=(I&512)!==0,U=0,W=(I&1024)!==0,K=(I&2048)!==0,B=0,Q=N(T,4),j=8;P&&(C=N(T,j),j+=4),w&&(j+=4);for(var J=C+u,ee=0;ee<Q;ee++){if(O?(F=N(T,j),j+=4):F=E,H?(U=N(T,j),j+=4):U=L,W&&(j+=4),K&&(b===0?B=N(T,j):B=Tr(T,j),j+=4),n.type===$.VIDEO)for(var re=0;re<U;){var Z=N(e,J);if(J+=4,Cn(s,e[J])){var X=e.subarray(J,J+Z);Ar(X,s?2:1,a+B/t,i)}J+=Z,re+=Z+4}a+=F/t}}))})})}),i}function Dn(a){if(!a)return!1;var n=a.indexOf("."),i=n<0?a:a.substring(0,n);return i==="hvc1"||i==="hev1"||i==="dvh1"||i==="dvhe"}function Cn(a,n){if(a){var i=n>>1&63;return i===39||i===40}else{var e=n&31;return e===6}}function Ar(a,n,i,e){var t=Rr(a),r=0;r+=n;for(var s=0,o=0,l=0;r<t.length;){s=0;do{if(r>=t.length)break;l=t[r++],s+=l}while(l===255);o=0;do{if(r>=t.length)break;l=t[r++],o+=l}while(l===255);var u=t.length-r,d=r;if(o<u)r+=o;else if(o>u){R.error("Malformed SEI payload. "+o+" is too small, only "+u+" bytes left to parse.");break}if(s===4){var f=t[d++];if(f===181){var h=Er(t,d);if(d+=2,h===49){var c=N(t,d);if(d+=4,c===1195456820){var v=t[d++];if(v===3){var g=t[d++],m=31&g,p=64&g,y=p?2+m*3:0,E=new Uint8Array(y);if(p){E[0]=g;for(var S=1;S<y;S++)E[S]=t[d++]}e.push({type:v,payloadType:s,pts:i,bytes:E})}}}}}else if(s===5&&o>16){for(var L=[],_=0;_<16;_++){var A=t[d++].toString(16);L.push(A.length==1?"0"+A:A),(_===3||_===5||_===7||_===9)&&L.push("-")}for(var T=o-16,b=new Uint8Array(T),I=0;I<T;I++)b[I]=t[d++];e.push({payloadType:s,pts:i,uuid:L.join(""),userData:Me(b),userDataBytes:b})}}}function Rr(a){for(var n=a.byteLength,i=[],e=1;e<n-2;)a[e]===0&&a[e+1]===0&&a[e+2]===3?(i.push(e+2),e+=2):e++;if(i.length===0)return a;var t=n-i.length,r=new Uint8Array(t),s=0;for(e=0;e<t;s++,e++)s===i[0]&&(s++,i.shift()),r[e]=a[s];return r}function Pn(a){var n=a[0],i="",e="",t=0,r=0,s=0,o=0,l=0,u=0;if(n===0){for(;ue(a.subarray(u,u+1))!=="\0";)i+=ue(a.subarray(u,u+1)),u+=1;for(i+=ue(a.subarray(u,u+1)),u+=1;ue(a.subarray(u,u+1))!=="\0";)e+=ue(a.subarray(u,u+1)),u+=1;e+=ue(a.subarray(u,u+1)),u+=1,t=N(a,12),r=N(a,16),o=N(a,20),l=N(a,24),u=28}else if(n===1){u+=4,t=N(a,u),u+=4;var d=N(a,u);u+=4;var f=N(a,u);for(u+=4,s=Math.pow(2,32)*d+f,Qi(s)||(s=Number.MAX_SAFE_INTEGER,R.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=N(a,u),u+=4,l=N(a,u),u+=4;ue(a.subarray(u,u+1))!=="\0";)i+=ue(a.subarray(u,u+1)),u+=1;for(i+=ue(a.subarray(u,u+1)),u+=1;ue(a.subarray(u,u+1))!=="\0";)e+=ue(a.subarray(u,u+1)),u+=1;e+=ue(a.subarray(u,u+1)),u+=1}var h=a.subarray(u,a.byteLength);return{schemeIdUri:i,value:e,timeScale:t,presentationTime:s,presentationTimeDelta:r,eventDuration:o,id:l,payload:h}}var wn=function(){a.clearKeyUriToKeyIdMap=function(){};function a(i,e,t,r,s){r===void 0&&(r=[1]),s===void 0&&(s=null),this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=i,this.uri=e,this.keyFormat=t,this.keyFormatVersions=r,this.iv=s,this.encrypted=i?i!=="NONE":!1,this.isCommonEncryption=this.encrypted&&i!=="AES-128"}var n=a.prototype;return n.isSupported=function(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES"}return!1},n.getDecryptData=function(e){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof e!="number"&&(this.method==="AES-128"&&!this.iv&&R.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),e=0);var t=kn(e),r=new a(this.method,this.uri,"identity",this.keyFormatVersions,t);return r}return this},a}();function kn(a){for(var n=new Uint8Array(16),i=12;i<16;i++)n[i]=a>>8*(15-i)&255;return n}function Ge(a){if(a===void 0&&(a=!0),!(typeof self>"u")){var n=(a||!self.MediaSource)&&self.ManagedMediaSource;return n||self.MediaSource||self.WebKitMediaSource}}function Fn(a){return typeof self<"u"&&a===self.ManagedMediaSource}var nt={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 Mn(a,n){var i=nt[n];return!!i&&!!i[a.slice(0,4)]}function Pt(a,n,i){return i===void 0&&(i=!0),!a.split(",").some(function(e){return!br(e,n,i)})}function br(a,n,i){var e;i===void 0&&(i=!0);var t=Ge(i);return(e=t?.isTypeSupported(wt(a,n)))!=null?e:!1}function wt(a,n){return n+'/mp4;codecs="'+a+'"'}function Ir(a){if(a){var n=a.substring(0,4);return nt.video[n]}return 2}function at(a){return a.split(",").reduce(function(n,i){var e=nt.video[i];return e?(e*2+n)/(n?3:2):(nt.audio[i]+n)/(n?2:1)},0)}var kt={};function On(a,n){if(n===void 0&&(n=!0),kt[a])return kt[a];for(var i={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"]}[a],e=0;e<i.length;e++)if(br(i[e],"audio",n))return kt[a]=i[e],i[e];return a}var Nn=/flac|opus/i;function st(a,n){return n===void 0&&(n=!0),a.replace(Nn,function(i){return On(i.toLowerCase(),n)})}function _r(a,n){return a&&a!=="mp4a"?a:n&&n.split(",")[0]}function Bn(a){for(var n=a.split(","),i=0;i<n.length;i++){var e=n[i].split(".");if(e.length>2){var t=e.shift()+".";t+=parseInt(e.shift()).toString(16),t+=("000"+parseInt(e.shift()).toString(16)).slice(-4),n[i]=t}}return n.join(",")}var Dr=/#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,Cr=/#EXT-X-MEDIA:(.*)/g,Un=/^#EXT(?:INF|-X-TARGETDURATION):/m,Pr=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),Gn=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),ze=function(){function a(){}return a.findGroup=function(i,e){for(var t=0;t<i.length;t++){var r=i[t];if(r.id===e)return r}},a.resolve=function(i,e){return At.buildAbsoluteURL(e,i,{alwaysNormalize:!0})},a.isMediaPlaylist=function(i){return Un.test(i)},a.parseMasterPlaylist=function(i,e){var t=!1,r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:t},s=[];Dr.lastIndex=0;for(var o;(o=Dr.exec(i))!=null;)if(o[1]){var l,u=new oe(o[1]),d=o[2],f={attrs:u,bitrate:u.decimalInteger("BANDWIDTH")||u.decimalInteger("AVERAGE-BANDWIDTH"),name:u.NAME,url:a.resolve(d,e)},h=u.decimalResolution("RESOLUTION");h&&(f.width=h.width,f.height=h.height),Hn(u.CODECS,f),(l=f.unknownCodecs)!=null&&l.length||s.push(f),r.levels.push(f)}else if(o[3]){var c=o[3],v=o[4];switch(c){case"SESSION-DATA":{var g=new oe(v),m=g["DATA-ID"];m&&(r.sessionData===null&&(r.sessionData={}),r.sessionData[m]=g);break}case"SESSION-KEY":{var p=wr(v,e);p.encrypted&&p.isSupported()?(r.sessionKeys===null&&(r.sessionKeys=[]),r.sessionKeys.push(p)):R.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+v+'"');break}case"DEFINE":break;case"CONTENT-STEERING":{var y=new oe(v);r.contentSteering={uri:a.resolve(y["SERVER-URI"],e),pathwayId:y["PATHWAY-ID"]||"."};break}case"START":{r.startTimeOffset=kr(v);break}}}var E=s.length>0&&s.length<r.levels.length;return r.levels=E?s:r.levels,r.levels.length===0&&(r.playlistParsingError=new Error("no levels found in manifest")),r},a.parseMasterPlaylistMedia=function(i,e,t){var r,s={},o=t.levels,l={AUDIO:o.map(function(L){return{id:L.attrs.AUDIO,audioCodec:L.audioCodec}}),SUBTITLES:o.map(function(L){return{id:L.attrs.SUBTITLES,textCodec:L.textCodec}}),"CLOSED-CAPTIONS":[]},u=0;for(Cr.lastIndex=0;(r=Cr.exec(i))!==null;){var d=new oe(r[1]),f=d.TYPE;if(f){var h=l[f],c=s[f]||[];s[f]=c;var v=d.LANGUAGE,g=d["ASSOC-LANGUAGE"],m=d.CHANNELS,p=d.CHARACTERISTICS,y=d["INSTREAM-ID"],E={attrs:d,bitrate:0,id:u++,groupId:d["GROUP-ID"]||"",name:d.NAME||v||"",type:f,default:d.bool("DEFAULT"),autoselect:d.bool("AUTOSELECT"),forced:d.bool("FORCED"),lang:v,url:d.URI?a.resolve(d.URI,e):""};if(g&&(E.assocLang=g),m&&(E.channels=m),p&&(E.characteristics=p),y&&(E.instreamId=y),h!=null&&h.length){var S=a.findGroup(h,E.groupId)||h[0];Fr(E,S,"audioCodec"),Fr(E,S,"textCodec")}c.push(E)}}return s},a.parseLevelPlaylist=function(i,e,t,r,s,o){var l=new on(e),u=l.fragments,d=null,f=0,h=0,c=0,v=0,g=null,m=new bt(r,e),p,y,E,S=-1,L=!1,_=null;for(Pr.lastIndex=0,l.m3u8=i,l.hasVariableRefs=!1;(p=Pr.exec(i))!==null;){L&&(L=!1,m=new bt(r,e),m.start=c,m.sn=f,m.cc=v,m.level=t,d&&(m.initSegment=d,m.rawProgramDateTime=d.rawProgramDateTime,d.rawProgramDateTime=null,_&&(m.setByteRange(_),_=null)));var A=p[1];if(A){m.duration=parseFloat(A);var T=(" "+p[2]).slice(1);m.title=T||null,m.tagList.push(T?["INF",A,T]:["INF",A])}else if(p[3]){if(M(m.duration)){m.start=c,E&&Nr(m,E,l),m.sn=f,m.level=t,m.cc=v,u.push(m);var b=(" "+p[3]).slice(1);m.relurl=b,Mr(m,g),g=m,c+=m.duration,f++,h=0,L=!0}}else if(p[4]){var I=(" "+p[4]).slice(1);g?m.setByteRange(I,g):m.setByteRange(I)}else if(p[5])m.rawProgramDateTime=(" "+p[5]).slice(1),m.tagList.push(["PROGRAM-DATE-TIME",m.rawProgramDateTime]),S===-1&&(S=u.length);else{if(p=p[0].match(Gn),!p){R.warn("No matches on slow regex match for level playlist!");continue}for(y=1;y<p.length&&!(typeof p[y]<"u");y++);var P=(" "+p[y]).slice(1),C=(" "+p[y+1]).slice(1),w=p[y+2]?(" "+p[y+2]).slice(1):"";switch(P){case"PLAYLIST-TYPE":l.type=C.toUpperCase();break;case"MEDIA-SEQUENCE":f=l.startSN=parseInt(C);break;case"SKIP":{var O=new oe(C),F=O.decimalInteger("SKIPPED-SEGMENTS");if(M(F)){l.skippedSegments=F;for(var H=F;H--;)u.unshift(null);f+=F}var U=O.enumeratedString("RECENTLY-REMOVED-DATERANGES");U&&(l.recentlyRemovedDateranges=U.split(" "));break}case"TARGETDURATION":l.targetduration=Math.max(parseInt(C),1);break;case"VERSION":l.version=parseInt(C);break;case"INDEPENDENT-SEGMENTS":case"EXTM3U":break;case"ENDLIST":l.live=!1;break;case"#":(C||w)&&m.tagList.push(w?[C,w]:[C]);break;case"DISCONTINUITY":v++,m.tagList.push(["DIS"]);break;case"GAP":m.gap=!0,m.tagList.push([P]);break;case"BITRATE":m.tagList.push([P,C]);break;case"DATERANGE":{var W=new oe(C),K=new dr(W,l.dateRanges[W.ID]);K.isValid||l.skippedSegments?l.dateRanges[K.id]=K:R.warn('Ignoring invalid DATERANGE tag: "'+C+'"'),m.tagList.push(["EXT-X-DATERANGE",C]);break}case"DEFINE":break;case"DISCONTINUITY-SEQUENCE":v=parseInt(C);break;case"KEY":{var B=wr(C,e);if(B.isSupported()){if(B.method==="NONE"){E=void 0;break}E||(E={}),E[B.keyFormat]&&(E=Te({},E)),E[B.keyFormat]=B}else R.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+C+'"');break}case"START":l.startTimeOffset=kr(C);break;case"MAP":{var Q=new oe(C);if(m.duration){var j=new bt(r,e);Or(j,Q,t,E),d=j,m.initSegment=d,d.rawProgramDateTime&&!m.rawProgramDateTime&&(m.rawProgramDateTime=d.rawProgramDateTime)}else{var J=m.byteRangeEndOffset;if(J){var ee=m.byteRangeStartOffset;_=J-ee+"@"+ee}else _=null;Or(m,Q,t,E),d=m,L=!0}break}case"SERVER-CONTROL":{var re=new oe(C);l.canBlockReload=re.bool("CAN-BLOCK-RELOAD"),l.canSkipUntil=re.optionalFloat("CAN-SKIP-UNTIL",0),l.canSkipDateRanges=l.canSkipUntil>0&&re.bool("CAN-SKIP-DATERANGES"),l.partHoldBack=re.optionalFloat("PART-HOLD-BACK",0),l.holdBack=re.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var Z=new oe(C);l.partTarget=Z.decimalFloatingPoint("PART-TARGET");break}case"PART":{var X=l.partList;X||(X=l.partList=[]);var Fe=h>0?X[X.length-1]:void 0,Se=h++,te=new oe(C),pe=new an(te,m,e,Se,Fe);X.push(pe),m.duration+=pe.duration;break}case"PRELOAD-HINT":{var ye=new oe(C);l.preloadHint=ye;break}case"RENDITION-REPORT":{var ie=new oe(C);l.renditionReports=l.renditionReports||[],l.renditionReports.push(ie);break}default:R.warn("line parsed but not handled: "+p);break}}}g&&!g.relurl?(u.pop(),c-=g.duration,l.partList&&(l.fragmentHint=g)):l.partList&&(Mr(m,g),m.cc=v,l.fragmentHint=m,E&&Nr(m,E,l));var z=u.length,xe=u[0],ve=u[z-1];if(c+=l.skippedSegments*l.targetduration,c>0&&z&&ve){l.averagetargetduration=c/z;var de=ve.sn;l.endSN=de!=="initSegment"?de:0,l.live||(ve.endList=!0),xe&&(l.startCC=xe.cc)}else l.endSN=0,l.startCC=0;return l.fragmentHint&&(c+=l.fragmentHint.duration),l.totalduration=c,l.endCC=v,S>0&&Vn(u,S),l},a}();function wr(a,n,i){var e,t,r=new oe(a),s=(e=r.METHOD)!=null?e:"",o=r.URI,l=r.hexadecimalInteger("IV"),u=r.KEYFORMATVERSIONS,d=(t=r.KEYFORMAT)!=null?t:"identity";o&&r.IV&&!l&&R.error("Invalid IV: "+r.IV);var f=o?ze.resolve(o,n):"",h=(u||"1").split("/").map(Number).filter(Number.isFinite);return new wn(s,f,d,h,l)}function kr(a){var n=new oe(a),i=n.decimalFloatingPoint("TIME-OFFSET");return M(i)?i:null}function Hn(a,n){var i=(a||"").split(/[ ,]+/).filter(function(e){return e});["video","audio","text"].forEach(function(e){var t=i.filter(function(r){return Mn(r,e)});t.length&&(n[e+"Codec"]=t.join(","),i=i.filter(function(r){return t.indexOf(r)===-1}))}),n.unknownCodecs=i}function Fr(a,n,i){var e=n[i];e&&(a[i]=e)}function Vn(a,n){for(var i=a[n],e=n;e--;){var t=a[e];if(!t)return;t.programDateTime=i.programDateTime-t.duration*1e3,i=t}}function Mr(a,n){a.rawProgramDateTime?a.programDateTime=Date.parse(a.rawProgramDateTime):n!=null&&n.programDateTime&&(a.programDateTime=n.endProgramDateTime),M(a.programDateTime)||(a.programDateTime=null,a.rawProgramDateTime=null)}function Or(a,n,i,e){a.relurl=n.URI,n.BYTERANGE&&a.setByteRange(n.BYTERANGE),a.level=i,a.sn="initSegment",e&&(a.levelkeys=e),a.initSegment=null}function Nr(a,n,i){a.levelkeys=n;var e=i.encryptedFragments;(!e.length||e[e.length-1].levelkeys!==n)&&Object.keys(n).some(function(t){return n[t].isCommonEncryption})&&e.push(a)}var Y={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},q={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function Br(a){var n=a.type;switch(n){case Y.AUDIO_TRACK:return q.AUDIO;case Y.SUBTITLE_TRACK:return q.SUBTITLE;default:return q.MAIN}}function Ft(a,n){var i=a.url;return(i===void 0||i.indexOf("data:")===0)&&(i=n.url),i}var Kn=function(){function a(i){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=i,this.registerListeners()}var n=a.prototype;return n.startLoad=function(e){},n.stopLoad=function(){this.destroyInternalLoaders()},n.registerListeners=function(){var e=this.hls;e.on(x.MANIFEST_LOADING,this.onManifestLoading,this),e.on(x.LEVEL_LOADING,this.onLevelLoading,this),e.on(x.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(x.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},n.unregisterListeners=function(){var e=this.hls;e.off(x.MANIFEST_LOADING,this.onManifestLoading,this),e.off(x.LEVEL_LOADING,this.onLevelLoading,this),e.off(x.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(x.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},n.createInternalLoader=function(e){var t=this.hls.config,r=t.pLoader,s=t.loader,o=r||s,l=new o(t);return this.loaders[e.type]=l,l},n.getInternalLoader=function(e){return this.loaders[e.type]},n.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},n.destroyInternalLoaders=function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}},n.destroy=function(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()},n.onManifestLoading=function(e,t){var r=t.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Y.MANIFEST,url:r,deliveryDirectives:null})},n.onLevelLoading=function(e,t){var r=t.id,s=t.level,o=t.pathwayId,l=t.url,u=t.deliveryDirectives;this.load({id:r,level:s,pathwayId:o,responseType:"text",type:Y.LEVEL,url:l,deliveryDirectives:u})},n.onAudioTrackLoading=function(e,t){var r=t.id,s=t.groupId,o=t.url,l=t.deliveryDirectives;this.load({id:r,groupId:s,level:null,responseType:"text",type:Y.AUDIO_TRACK,url:o,deliveryDirectives:l})},n.onSubtitleTrackLoading=function(e,t){var r=t.id,s=t.groupId,o=t.url,l=t.deliveryDirectives;this.load({id:r,groupId:s,level:null,responseType:"text",type:Y.SUBTITLE_TRACK,url:o,deliveryDirectives:l})},n.load=function(e){var t,r=this,s=this.hls.config,o=this.getInternalLoader(e);if(o){var l=o.context;if(l&&l.url===e.url&&l.level===e.level){R.trace("[playlist-loader]: playlist request ongoing");return}R.log("[playlist-loader]: aborting previous loader for type: "+e.type),o.abort()}var u;if(e.type===Y.MANIFEST?u=s.manifestLoadPolicy.default:u=Te({},s.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),o=this.createInternalLoader(e),M((t=e.deliveryDirectives)==null?void 0:t.part)){var d;if(e.type===Y.LEVEL&&e.level!==null?d=this.hls.levels[e.level].details:e.type===Y.AUDIO_TRACK&&e.id!==null?d=this.hls.audioTracks[e.id].details:e.type===Y.SUBTITLE_TRACK&&e.id!==null&&(d=this.hls.subtitleTracks[e.id].details),d){var f=d.partTarget,h=d.targetduration;if(f&&h){var c=Math.max(f*3,h*.8)*1e3;u=Te({},u,{maxTimeToFirstByteMs:Math.min(c,u.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(c,u.maxTimeToFirstByteMs)})}}}var v=u.errorRetry||u.timeoutRetry||{},g={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:v.maxNumRetry||0,retryDelay:v.retryDelayMs||0,maxRetryDelay:v.maxRetryDelayMs||0},m={onSuccess:function(y,E,S,L){var _=r.getInternalLoader(S);r.resetInternalLoader(S.type);var A=y.data;if(A.indexOf("#EXTM3U")!==0){r.handleManifestParsingError(y,S,new Error("no EXTM3U delimiter"),L||null,E);return}E.parsing.start=performance.now(),ze.isMediaPlaylist(A)?r.handleTrackOrLevelPlaylist(y,E,S,L||null,_):r.handleMasterPlaylist(y,E,S,L)},onError:function(y,E,S,L){r.handleNetworkError(E,S,!1,y,L)},onTimeout:function(y,E,S){r.handleNetworkError(E,S,!0,void 0,y)}};o.load(e,g,m)},n.handleMasterPlaylist=function(e,t,r,s){var o=this.hls,l=e.data,u=Ft(e,r),d=ze.parseMasterPlaylist(l,u);if(d.playlistParsingError){this.handleManifestParsingError(e,r,d.playlistParsingError,s,t);return}var f=d.contentSteering,h=d.levels,c=d.sessionData,v=d.sessionKeys,g=d.startTimeOffset,m=d.variableList;this.variableList=m;var p=ze.parseMasterPlaylistMedia(l,u,d),y=p.AUDIO,E=y===void 0?[]:y,S=p.SUBTITLES,L=p["CLOSED-CAPTIONS"];if(E.length){var _=E.some(function(A){return!A.url});!_&&h[0].audioCodec&&!h[0].attrs.AUDIO&&(R.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),E.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new oe({}),bitrate:0,url:""}))}o.trigger(x.MANIFEST_LOADED,{levels:h,audioTracks:E,subtitles:S,captions:L,contentSteering:f,url:u,stats:t,networkDetails:s,sessionData:c,sessionKeys:v,startTimeOffset:g,variableList:m})},n.handleTrackOrLevelPlaylist=function(e,t,r,s,o){var l=this.hls,u=r.id,d=r.level,f=r.type,h=Ft(e,r),c=0,v=M(d)?d:M(u)?u:0,g=Br(r),m=ze.parseLevelPlaylist(e.data,h,v,g,c,this.variableList);if(f===Y.MANIFEST){var p={attrs:new oe({}),bitrate:0,details:m,name:"",url:h};l.trigger(x.MANIFEST_LOADED,{levels:[p],audioTracks:[],url:h,stats:t,networkDetails:s,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=m,this.handlePlaylistLoaded(m,e,t,r,s,o)},n.handleManifestParsingError=function(e,t,r,s,o){this.hls.trigger(x.ERROR,{type:V.NETWORK_ERROR,details:D.MANIFEST_PARSING_ERROR,fatal:t.type===Y.MANIFEST,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:s,stats:o})},n.handleNetworkError=function(e,t,r,s,o){r===void 0&&(r=!1);var l="A network "+(r?"timeout":"error"+(s?" (status "+s.code+")":""))+" occurred while loading "+e.type;e.type===Y.LEVEL?l+=": "+e.level+" id: "+e.id:(e.type===Y.AUDIO_TRACK||e.type===Y.SUBTITLE_TRACK)&&(l+=" id: "+e.id+' group-id: "'+e.groupId+'"');var u=new Error(l);R.warn("[playlist-loader]: "+l);var d=D.UNKNOWN,f=!1,h=this.getInternalLoader(e);switch(e.type){case Y.MANIFEST:d=r?D.MANIFEST_LOAD_TIMEOUT:D.MANIFEST_LOAD_ERROR,f=!0;break;case Y.LEVEL:d=r?D.LEVEL_LOAD_TIMEOUT:D.LEVEL_LOAD_ERROR,f=!1;break;case Y.AUDIO_TRACK:d=r?D.AUDIO_TRACK_LOAD_TIMEOUT:D.AUDIO_TRACK_LOAD_ERROR,f=!1;break;case Y.SUBTITLE_TRACK:d=r?D.SUBTITLE_TRACK_LOAD_TIMEOUT:D.SUBTITLE_LOAD_ERROR,f=!1;break}h&&this.resetInternalLoader(e.type);var c={type:V.NETWORK_ERROR,details:d,fatal:f,url:e.url,loader:h,context:e,error:u,networkDetails:t,stats:o};if(s){var v=t?.url||e.url;c.response=se({url:v,data:void 0},s)}this.hls.trigger(x.ERROR,c)},n.handlePlaylistLoaded=function(e,t,r,s,o,l){var u=this.hls,d=s.type,f=s.level,h=s.id,c=s.groupId,v=s.deliveryDirectives,g=Ft(t,s),m=Br(s),p=typeof s.level=="number"&&m===q.MAIN?f:void 0;if(!e.fragments.length){var y=new Error("No Segments found in Playlist");u.trigger(x.ERROR,{type:V.NETWORK_ERROR,details:D.LEVEL_EMPTY_ERROR,fatal:!1,url:g,error:y,reason:y.message,response:t,context:s,level:p,parent:m,networkDetails:o,stats:r});return}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));var E=e.playlistParsingError;if(E){u.trigger(x.ERROR,{type:V.NETWORK_ERROR,details:D.LEVEL_PARSING_ERROR,fatal:!1,url:g,error:E,reason:E.message,response:t,context:s,level:p,parent:m,networkDetails:o,stats:r});return}switch(e.live&&l&&(l.getCacheAge&&(e.ageHeader=l.getCacheAge()||0),(!l.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),d){case Y.MANIFEST:case Y.LEVEL:u.trigger(x.LEVEL_LOADED,{details:e,level:p||0,id:h||0,stats:r,networkDetails:o,deliveryDirectives:v});break;case Y.AUDIO_TRACK:u.trigger(x.AUDIO_TRACK_LOADED,{details:e,id:h||0,groupId:c||"",stats:r,networkDetails:o,deliveryDirectives:v});break;case Y.SUBTITLE_TRACK:u.trigger(x.SUBTITLE_TRACK_LOADED,{details:e,id:h||0,groupId:c||"",stats:r,networkDetails:o,deliveryDirectives:v});break}},a}();function Wn(a,n){var i;try{i=new Event("addtrack")}catch{i=document.createEvent("Event"),i.initEvent("addtrack",!1,!1)}i.track=a,n.dispatchEvent(i)}function Yn(a){var n=a.mode;if(n==="disabled"&&(a.mode="hidden"),a.cues)for(var i=a.cues.length;i--;)a.removeCue(a.cues[i]);n==="disabled"&&(a.mode=n)}function qn(a,n,i,e){var t=a.mode;if(t==="disabled"&&(a.mode="hidden"),a.cues&&a.cues.length>0)for(var r=Xn(a.cues,n,i),s=0;s<r.length;s++)(!e||e(r[s]))&&a.removeCue(r[s]);t==="disabled"&&(a.mode=t)}function jn(a,n){if(n<a[0].startTime)return 0;var i=a.length-1;if(n>a[i].endTime)return-1;for(var e=0,t=i;e<=t;){var r=Math.floor((t+e)/2);if(n<a[r].startTime)t=r-1;else if(n>a[r].startTime&&e<i)e=r+1;else return r}return a[e].startTime-n<n-a[t].startTime?e:t}function Xn(a,n,i){var e=[],t=jn(a,n);if(t>-1)for(var r=t,s=a.length;r<s;r++){var o=a[r];if(o.startTime>=n&&o.endTime<=i)e.push(o);else if(o.startTime>i)return e}return e}var Ae={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"},zn=.25;function Mt(){if(!(typeof self>"u"))return self.VTTCue||self.TextTrackCue}function Ur(a,n,i,e,t){var r=new a(n,i,"");try{r.value=e,t&&(r.type=t)}catch{r=new a(n,i,JSON.stringify(t?se({type:t},e):e))}return r}var ot=function(){var a=Mt();try{a&&new a(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function Ot(a,n){return a.getTime()/1e3-n}function $n(a){return Uint8Array.from(a.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var Qn=function(){function a(i){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=i,this._registerListeners()}var n=a.prototype;return n.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},n._registerListeners=function(){var e=this.hls;e.on(x.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(x.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(x.MANIFEST_LOADING,this.onManifestLoading,this),e.on(x.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(x.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(x.LEVEL_UPDATED,this.onLevelUpdated,this)},n._unregisterListeners=function(){var e=this.hls;e.off(x.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(x.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(x.MANIFEST_LOADING,this.onManifestLoading,this),e.off(x.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(x.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(x.LEVEL_UPDATED,this.onLevelUpdated,this)},n.onMediaAttached=function(e,t){this.media=t.media},n.onMediaDetaching=function(){this.id3Track&&(Yn(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},n.onManifestLoading=function(){this.dateRangeCuesAppended={}},n.createTrack=function(e){var t=this.getID3Track(e.textTracks);return t.mode="hidden",t},n.getID3Track=function(e){if(this.media){for(var t=0;t<e.length;t++){var r=e[t];if(r.kind==="metadata"&&r.label==="id3")return Wn(r,this.media),r}return this.media.addTextTrack("metadata","id3")}},n.onFragParsingMetadata=function(e,t){if(this.media){var r=this.hls.config,s=r.enableEmsgMetadataCues,o=r.enableID3MetadataCues;if(!(!s&&!o)){var l=t.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));var u=Mt();if(u)for(var d=0;d<l.length;d++){var f=l[d].type;if(!(f===Ae.emsg&&!s||!o)){var h=mr(l[d].data);if(h){var c=l[d].pts,v=c+l[d].duration;v>ot&&(v=ot);var g=v-c;g<=0&&(v=c+zn);for(var m=0;m<h.length;m++){var p=h[m];if(!gr(p)){this.updateId3CueEnds(c,f);var y=Ur(u,c,v,p,f);y&&this.id3Track.addCue(y)}}}}}}}},n.updateId3CueEnds=function(e,t){var r,s=(r=this.id3Track)==null?void 0:r.cues;if(s)for(var o=s.length;o--;){var l=s[o];l.type===t&&l.startTime<e&&l.endTime===ot&&(l.endTime=e)}},n.onBufferFlushing=function(e,t){var r=t.startOffset,s=t.endOffset,o=t.type,l=this.id3Track,u=this.hls;if(u){var d=u.config,f=d.enableEmsgMetadataCues,h=d.enableID3MetadataCues;if(l&&(f||h)){var c;o==="audio"?c=function(g){return g.type===Ae.audioId3&&h}:o==="video"?c=function(g){return g.type===Ae.emsg&&f}:c=function(g){return g.type===Ae.audioId3&&h||g.type===Ae.emsg&&f},qn(l,r,s,c)}}},n.onLevelUpdated=function(e,t){var r=this,s=t.details;if(!(!this.media||!s.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)){var o=this.dateRangeCuesAppended,l=this.id3Track,u=s.dateRanges,d=Object.keys(u);if(l)for(var f=Object.keys(o).filter(function(E){return!d.includes(E)}),h=function(){var S=f[c];Object.keys(o[S].cues).forEach(function(L){l.removeCue(o[S].cues[L])}),delete o[S]},c=f.length;c--;)h();var v=s.fragments[s.fragments.length-1];if(!(d.length===0||!M(v?.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var g=v.programDateTime/1e3-v.start,m=Mt(),p=function(){var S=d[y],L=u[S],_=Ot(L.startDate,g),A=o[S],T=A?.cues||{},b=A?.durationKnown||!1,I=ot,P=L.endDate;if(P)I=Ot(P,g),b=!0;else if(L.endOnNext&&!b){var C=d.reduce(function(K,B){if(B!==L.id){var Q=u[B];if(Q.class===L.class&&Q.startDate>L.startDate&&(!K||L.startDate<K.startDate))return Q}return K},null);C&&(I=Ot(C.startDate,g),b=!0)}for(var w=Object.keys(L.attr),O=0;O<w.length;O++){var F=w[O];if(rn(F)){var H=T[F];if(H)b&&!A.durationKnown&&(H.endTime=I);else if(m){var U=L.attr[F];nn(F)&&(U=$n(U));var W=Ur(m,_,I,{key:F,data:U},Ae.dateRange);W&&(W.id=S,r.id3Track.addCue(W),T[F]=W)}}}o[S]={cues:T,dateRange:L,durationKnown:b}},y=0;y<d.length;y++)p()}}},a}(),Zn=function(){function a(i){var e=this;this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=function(){return e.timeupdate()},this.hls=i,this.config=i.config,this.registerListeners()}var n=a.prototype;return n.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},n.registerListeners=function(){this.hls.on(x.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(x.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(x.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(x.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(x.ERROR,this.onError,this)},n.unregisterListeners=function(){this.hls.off(x.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(x.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(x.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(x.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(x.ERROR,this.onError,this)},n.onMediaAttached=function(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},n.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},n.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},n.onLevelUpdated=function(e,t){var r=t.details;this.levelDetails=r,r.advanced&&this.timeupdate(),!r.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},n.onError=function(e,t){var r;t.details===D.BUFFER_STALLED_ERROR&&(this.stallCount++,(r=this.levelDetails)!=null&&r.live&&R.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},n.timeupdate=function(){var e=this.media,t=this.levelDetails;if(!(!e||!t)){this.currentTime=e.currentTime;var r=this.computeLatency();if(r!==null){this._latency=r;var s=this.config,o=s.lowLatencyMode,l=s.maxLiveSyncPlaybackRate;if(!(!o||l===1||!t.live)){var u=this.targetLatency;if(u!==null){var d=r-u,f=Math.min(this.maxLatency,u+t.targetduration),h=d<f;if(h&&d>.05&&this.forwardBufferLength>1){var c=Math.min(2,Math.max(1,l)),v=Math.round(2/(1+Math.exp(-.75*d-this.edgeStalled))*20)/20;e.playbackRate=Math.min(c,Math.max(1,v))}else e.playbackRate!==1&&e.playbackRate!==0&&(e.playbackRate=1)}}}}},n.estimateLiveEdge=function(){var e=this.levelDetails;return e===null?null:e.edge+e.age},n.computeLatency=function(){var e=this.estimateLiveEdge();return e===null?null:e-this.currentTime},me(a,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var e=this.config,t=this.levelDetails;return e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}},{key:"targetLatency",get:function(){var e=this.levelDetails;if(e===null)return null;var t=e.holdBack,r=e.partHoldBack,s=e.targetduration,o=this.config,l=o.liveSyncDuration,u=o.liveSyncDurationCount,d=o.lowLatencyMode,f=this.hls.userConfig,h=d&&r||t;(f.liveSyncDuration||f.liveSyncDurationCount||h===0)&&(h=l!==void 0?l:u*s);var c=s,v=1;return h+Math.min(this.stallCount*v,c)}},{key:"liveSyncPosition",get:function(){var e=this.estimateLiveEdge(),t=this.targetLatency,r=this.levelDetails;if(e===null||t===null||r===null)return null;var s=r.edge,o=e-t-this.edgeStalled,l=s-r.totalduration,u=s-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(l,o),u)}},{key:"drift",get:function(){var e=this.levelDetails;return e===null?1:e.drift}},{key:"edgeStalled",get:function(){var e=this.levelDetails;if(e===null)return 0;var t=(this.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;return Math.max(e.age-t,0)}},{key:"forwardBufferLength",get:function(){var e=this.media,t=this.levelDetails;if(!e||!t)return 0;var r=e.buffered.length;return(r?e.buffered.end(r-1):t.edge)-this.currentTime}}]),a}(),Nt=["NONE","TYPE-0","TYPE-1",null];function Jn(a){return Nt.indexOf(a)>-1}var lt=["SDR","PQ","HLG"];function ea(a){return!!a&&lt.indexOf(a)>-1}var ut={No:"",Yes:"YES",v2:"v2"};function Gr(a){var n=a.canSkipUntil,i=a.canSkipDateRanges,e=a.age,t=e<n/2;return n&&t?i?ut.v2:ut.Yes:ut.No}var Hr=function(){function a(i,e,t){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=i,this.part=e,this.skip=t}var n=a.prototype;return n.addDirectives=function(e){var t=new self.URL(e);return this.msn!==void 0&&t.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href},a}(),Bt=function(){function a(i){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[i.url],this._attrs=[i.attrs],this.bitrate=i.bitrate,i.details&&(this.details=i.details),this.id=i.id||0,this.name=i.name,this.width=i.width||0,this.height=i.height||0,this.frameRate=i.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=i.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=i.audioCodec,this.videoCodec=i.videoCodec,this.codecSet=[i.videoCodec,i.audioCodec].filter(function(e){return!!e}).map(function(e){return e.substring(0,4)}).join(","),this.addGroupId("audio",i.attrs.AUDIO),this.addGroupId("text",i.attrs.SUBTITLES)}var n=a.prototype;return n.hasAudioGroup=function(e){return Vr(this._audioGroups,e)},n.hasSubtitleGroup=function(e){return Vr(this._subtitleGroups,e)},n.addGroupId=function(e,t){if(t){if(e==="audio"){var r=this._audioGroups;r||(r=this._audioGroups=[]),r.indexOf(t)===-1&&r.push(t)}else if(e==="text"){var s=this._subtitleGroups;s||(s=this._subtitleGroups=[]),s.indexOf(t)===-1&&s.push(t)}}},n.addFallback=function(){},me(a,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"averageBitrate",get:function(){return this._avgBitrate||this.realBitrate||this.bitrate}},{key:"attrs",get:function(){return this._attrs[0]}},{key:"codecs",get:function(){return this.attrs.CODECS||""}},{key:"pathwayId",get:function(){return this.attrs["PATHWAY-ID"]||"."}},{key:"videoRange",get:function(){return this.attrs["VIDEO-RANGE"]||"SDR"}},{key:"score",get:function(){return this.attrs.optionalFloat("SCORE",0)}},{key:"uri",get:function(){return this.url[0]||""}},{key:"audioGroups",get:function(){return this._audioGroups}},{key:"subtitleGroups",get:function(){return this._subtitleGroups}},{key:"urlId",get:function(){return 0},set:function(e){}},{key:"audioGroupIds",get:function(){return this.audioGroups?[this.audioGroupId]:void 0}},{key:"textGroupIds",get:function(){return this.subtitleGroups?[this.textGroupId]:void 0}},{key:"audioGroupId",get:function(){var e;return(e=this.audioGroups)==null?void 0:e[0]}},{key:"textGroupId",get:function(){var e;return(e=this.subtitleGroups)==null?void 0:e[0]}}]),a}();function Vr(a,n){return!n||!a?!1:a.indexOf(n)!==-1}function Ut(a,n){var i=n.startPTS;if(M(i)){var e=0,t;n.sn>a.sn?(e=i-a.start,t=a):(e=a.start-i,t=n),t.duration!==e&&(t.duration=e)}else if(n.sn>a.sn){var r=a.cc===n.cc;r&&a.minEndPTS?n.start=a.start+(a.minEndPTS-a.start):n.start=a.start+a.duration}else n.start=Math.max(a.start-n.duration,0)}function Kr(a,n,i,e,t,r){var s=e-i;s<=0&&(R.warn("Fragment should have a positive duration",n),e=i+n.duration,r=t+n.duration);var o=i,l=e,u=n.startPTS,d=n.endPTS;if(M(u)){var f=Math.abs(u-i);M(n.deltaPTS)?n.deltaPTS=Math.max(f,n.deltaPTS):n.deltaPTS=f,o=Math.max(i,u),i=Math.min(i,u),t=Math.min(t,n.startDTS),l=Math.min(e,d),e=Math.max(e,d),r=Math.max(r,n.endDTS)}var h=i-n.start;n.start!==0&&(n.start=i),n.duration=e-n.start,n.startPTS=i,n.maxStartPTS=o,n.startDTS=t,n.endPTS=e,n.minEndPTS=l,n.endDTS=r;var c=n.sn;if(!a||c<a.startSN||c>a.endSN)return 0;var v,g=c-a.startSN,m=a.fragments;for(m[g]=n,v=g;v>0;v--)Ut(m[v],m[v-1]);for(v=g;v<m.length-1;v++)Ut(m[v],m[v+1]);return a.fragmentHint&&Ut(m[m.length-1],a.fragmentHint),a.PTSKnown=a.alignedSliding=!0,h}function ta(a,n){for(var i=null,e=a.fragments,t=e.length-1;t>=0;t--){var r=e[t].initSegment;if(r){i=r;break}}a.fragmentHint&&delete a.fragmentHint.endPTS;var s=0,o;if(na(a,n,function(v,g){v.relurl&&(s=v.cc-g.cc),M(v.startPTS)&&M(v.endPTS)&&(g.start=g.startPTS=v.startPTS,g.startDTS=v.startDTS,g.maxStartPTS=v.maxStartPTS,g.endPTS=v.endPTS,g.endDTS=v.endDTS,g.minEndPTS=v.minEndPTS,g.duration=v.endPTS-v.startPTS,g.duration&&(o=g),n.PTSKnown=n.alignedSliding=!0),g.elementaryStreams=v.elementaryStreams,g.loader=v.loader,g.stats=v.stats,v.initSegment&&(g.initSegment=v.initSegment,i=v.initSegment)}),i){var l=n.fragmentHint?n.fragments.concat(n.fragmentHint):n.fragments;l.forEach(function(v){var g;v&&(!v.initSegment||v.initSegment.relurl===((g=i)==null?void 0:g.relurl))&&(v.initSegment=i)})}if(n.skippedSegments)if(n.deltaUpdateFailed=n.fragments.some(function(v){return!v}),n.deltaUpdateFailed){R.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var u=n.skippedSegments;u--;)n.fragments.shift();n.startSN=n.fragments[0].sn,n.startCC=n.fragments[0].cc}else n.canSkipDateRanges&&(n.dateRanges=ra(a.dateRanges,n.dateRanges,n.recentlyRemovedDateranges));var d=n.fragments;if(s){R.warn("discontinuity sliding from playlist, take drift into account");for(var f=0;f<d.length;f++)d[f].cc+=s}n.skippedSegments&&(n.startCC=n.fragments[0].cc),ia(a.partList,n.partList,function(v,g){g.elementaryStreams=v.elementaryStreams,g.stats=v.stats}),o?Kr(n,o,o.startPTS,o.endPTS,o.startDTS,o.endDTS):Wr(a,n),d.length&&(n.totalduration=n.edge-d[0].start),n.driftStartTime=a.driftStartTime,n.driftStart=a.driftStart;var h=n.advancedDateTime;if(n.advanced&&h){var c=n.edge;n.driftStart||(n.driftStartTime=h,n.driftStart=c),n.driftEndTime=h,n.driftEnd=c}else n.driftEndTime=a.driftEndTime,n.driftEnd=a.driftEnd,n.advancedDateTime=a.advancedDateTime}function ra(a,n,i){var e=Te({},a);return i&&i.forEach(function(t){delete e[t]}),Object.keys(n).forEach(function(t){var r=new dr(n[t].attr,e[t]);r.isValid?e[t]=r:R.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(n[t].attr)+'"')}),e}function ia(a,n,i){if(a&&n)for(var e=0,t=0,r=a.length;t<=r;t++){var s=a[t],o=n[t+e];s&&o&&s.index===o.index&&s.fragment.sn===o.fragment.sn?i(s,o):e--}}function na(a,n,i){for(var e=n.skippedSegments,t=Math.max(a.startSN,n.startSN)-n.startSN,r=(a.fragmentHint?1:0)+(e?n.endSN:Math.min(a.endSN,n.endSN))-n.startSN,s=n.startSN-a.startSN,o=n.fragmentHint?n.fragments.concat(n.fragmentHint):n.fragments,l=a.fragmentHint?a.fragments.concat(a.fragmentHint):a.fragments,u=t;u<=r;u++){var d=l[s+u],f=o[u];e&&!f&&u<e&&(f=n.fragments[u]=d),d&&f&&i(d,f)}}function Wr(a,n){var i=n.startSN+n.skippedSegments-a.startSN,e=a.fragments;i<0||i>=e.length||aa(n,e[i].start)}function aa(a,n){if(n){for(var i=a.fragments,e=a.skippedSegments;e<i.length;e++)i[e].start+=n;a.fragmentHint&&(a.fragmentHint.start+=n)}}function sa(a,n){n===void 0&&(n=1/0);var i=1e3*a.targetduration;if(a.updated){var e=a.fragments,t=4;if(e.length&&i*t>n){var r=e[e.length-1].duration*1e3;r<i&&(i=r)}}else i/=2;return Math.round(i)}function oa(a,n,i){if(!(a!=null&&a.details))return null;var e=a.details,t=e.fragments[n-e.startSN];return t||(t=e.fragmentHint,t&&t.sn===n)?t:n<e.startSN&&i&&i.sn===n?i:null}function Yr(a,n,i){var e;return a!=null&&a.details?qr((e=a.details)==null?void 0:e.partList,n,i):null}function qr(a,n,i){if(a)for(var e=a.length;e--;){var t=a[e];if(t.index===i&&t.fragment.sn===n)return t}return null}function jr(a){a.forEach(function(n,i){var e=n.details;e!=null&&e.fragments&&e.fragments.forEach(function(t){t.level=i})})}function ft(a){switch(a.details){case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_TIMEOUT:case D.LEVEL_LOAD_TIMEOUT:case D.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function Xr(a,n){var i=ft(n);return a.default[(i?"timeout":"error")+"Retry"]}function Gt(a,n){var i=a.backoff==="linear"?1:Math.pow(2,n);return Math.min(i*a.retryDelayMs,a.maxRetryDelayMs)}function zr(a){return se(se({},a),{errorRetry:null,timeoutRetry:null})}function dt(a,n,i,e){if(!a)return!1;var t=e?.code,r=n<a.maxNumRetry&&(la(t)||!!i);return a.shouldRetry?a.shouldRetry(a,n,i,e,r):r}function la(a){return a===0&&navigator.onLine===!1||!!a&&(a<400||a>499)}var $r={search:function(n,i){for(var e=0,t=n.length-1,r=null,s=null;e<=t;){r=(e+t)/2|0,s=n[r];var o=i(s);if(o>0)e=r+1;else if(o<0)t=r-1;else return s}return null}};function ua(a,n,i){if(n===null||!Array.isArray(a)||!a.length||!M(n))return null;var e=a[0].programDateTime;if(n<(e||0))return null;var t=a[a.length-1].endProgramDateTime;if(n>=(t||0))return null;i=i||0;for(var r=0;r<a.length;++r){var s=a[r];if(da(n,i,s))return s}return null}function Qr(a,n,i,e,t){i===void 0&&(i=0),e===void 0&&(e=0),t===void 0&&(t=.005);var r=null;if(a){r=n[a.sn-n[0].sn+1]||null;var s=a.endDTS-i;s>0&&s<15e-7&&(i+=15e-7)}else i===0&&n[0].start===0&&(r=n[0]);if(r&&((!a||a.level===r.level)&&Zr(i,e,r)===0||fa(r,a,Math.min(t,e))))return r;var o=$r.search(n,Zr.bind(null,i,e));return o&&(o!==a||!r)?o:r}function fa(a,n,i){if(n&&n.start===0&&n.level<a.level&&(n.endPTS||0)>0){var e=n.tagList.reduce(function(t,r){return r[0]==="INF"&&(t+=parseFloat(r[1])),t},i);return a.start<=e}return!1}function Zr(a,n,i){if(a===void 0&&(a=0),n===void 0&&(n=0),i.start<=a&&i.start+i.duration>a)return 0;var e=Math.min(n,i.duration+(i.deltaPTS?i.deltaPTS:0));return i.start+i.duration-e<=a?1:i.start-e>a&&i.start?-1:0}function da(a,n,i){var e=Math.min(n,i.duration+(i.deltaPTS?i.deltaPTS:0))*1e3,t=i.endProgramDateTime||0;return t-e>a}function ha(a,n){return $r.search(a,function(i){return i.cc<n?1:i.cc>n?-1:0})}var he={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},Re={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4},ca=function(){function a(i){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=i,this.log=R.log.bind(R,"[info]:"),this.warn=R.warn.bind(R,"[warning]:"),this.error=R.error.bind(R,"[error]:"),this.registerListeners()}var n=a.prototype;return n.registerListeners=function(){var e=this.hls;e.on(x.ERROR,this.onError,this),e.on(x.MANIFEST_LOADING,this.onManifestLoading,this),e.on(x.LEVEL_UPDATED,this.onLevelUpdated,this)},n.unregisterListeners=function(){var e=this.hls;e&&(e.off(x.ERROR,this.onError,this),e.off(x.ERROR,this.onErrorOut,this),e.off(x.MANIFEST_LOADING,this.onManifestLoading,this),e.off(x.LEVEL_UPDATED,this.onLevelUpdated,this))},n.destroy=function(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}},n.startLoad=function(e){},n.stopLoad=function(){this.playlistError=0},n.getVariantLevelIndex=function(e){return e?.type===q.MAIN?e.level:this.hls.loadLevel},n.onManifestLoading=function(){this.playlistError=0,this.penalizedRenditions={}},n.onLevelUpdated=function(){this.playlistError=0},n.onError=function(e,t){var r,s;if(!t.fatal){var o=this.hls,l=t.context;switch(t.details){case D.FRAG_LOAD_ERROR:case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_ERROR:case D.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case D.FRAG_PARSING_ERROR:if((r=t.frag)!=null&&r.gap){t.errorAction={action:he.DoNothing,flags:Re.None};return}case D.FRAG_GAP:case D.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=he.SendAlternateToPenaltyBox;return}case D.LEVEL_EMPTY_ERROR:case D.LEVEL_PARSING_ERROR:{var u,d,f=t.parent===q.MAIN?t.level:o.loadLevel;t.details===D.LEVEL_EMPTY_ERROR&&((u=t.context)!=null&&(d=u.levelDetails)!=null&&d.live)?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,f):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,f))}return;case D.LEVEL_LOAD_ERROR:case D.LEVEL_LOAD_TIMEOUT:typeof l?.level=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,l.level));return;case D.AUDIO_TRACK_LOAD_ERROR:case D.AUDIO_TRACK_LOAD_TIMEOUT:case D.SUBTITLE_LOAD_ERROR:case D.SUBTITLE_TRACK_LOAD_TIMEOUT:if(l){var h=o.levels[o.loadLevel];if(h&&(l.type===Y.AUDIO_TRACK&&h.hasAudioGroup(l.groupId)||l.type===Y.SUBTITLE_TRACK&&h.hasSubtitleGroup(l.groupId))){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,o.loadLevel),t.errorAction.action=he.SendAlternateToPenaltyBox,t.errorAction.flags=Re.MoveAllAlternatesMatchingHost;return}}return;case D.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{var c=o.levels[o.loadLevel],v=c?.attrs["HDCP-LEVEL"];v?t.errorAction={action:he.SendAlternateToPenaltyBox,flags:Re.MoveAllAlternatesMatchingHDCP,hdcpLevel:v}:this.keySystemError(t)}return;case D.BUFFER_ADD_CODEC_ERROR:case D.REMUX_ALLOC_ERROR:case D.BUFFER_APPEND_ERROR:t.errorAction=this.getLevelSwitchAction(t,(s=t.level)!=null?s:o.loadLevel);return;case D.INTERNAL_EXCEPTION:case D.BUFFER_APPENDING_ERROR:case D.BUFFER_FULL_ERROR:case D.LEVEL_SWITCH_ERROR:case D.BUFFER_STALLED_ERROR:case D.BUFFER_SEEK_OVER_HOLE:case D.BUFFER_NUDGE_ON_STALL:t.errorAction={action:he.DoNothing,flags:Re.None};return}t.type===V.KEY_SYSTEM_ERROR&&this.keySystemError(t)}},n.keySystemError=function(e){var t=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,t)},n.getPlaylistRetryOrSwitchAction=function(e,t){var r=this.hls,s=Xr(r.config.playlistLoadPolicy,e),o=this.playlistError++,l=dt(s,o,ft(e),e.response);if(l)return{action:he.RetryRequest,flags:Re.None,retryConfig:s,retryCount:o};var u=this.getLevelSwitchAction(e,t);return s&&(u.retryConfig=s,u.retryCount=o),u},n.getFragRetryOrSwitchAction=function(e){var t=this.hls,r=this.getVariantLevelIndex(e.frag),s=t.levels[r],o=t.config,l=o.fragLoadPolicy,u=o.keyLoadPolicy,d=Xr(e.details.startsWith("key")?u:l,e),f=t.levels.reduce(function(v,g){return v+g.fragmentError},0);if(s){e.details!==D.FRAG_GAP&&s.fragmentError++;var h=dt(d,f,ft(e),e.response);if(h)return{action:he.RetryRequest,flags:Re.None,retryConfig:d,retryCount:f}}var c=this.getLevelSwitchAction(e,r);return d&&(c.retryConfig=d,c.retryCount=f),c},n.getLevelSwitchAction=function(e,t){var r=this.hls;t==null&&(t=r.loadLevel);var s=this.hls.levels[t];if(s){var o,l,u=e.details;s.loadError++,u===D.BUFFER_APPEND_ERROR&&s.fragmentError++;var d=-1,f=r.levels,h=r.loadLevel,c=r.minAutoLevel,v=r.maxAutoLevel;r.autoLevelEnabled||(r.loadLevel=-1);for(var g=(o=e.frag)==null?void 0:o.type,m=g===q.AUDIO&&u===D.FRAG_PARSING_ERROR||e.sourceBufferName==="audio"&&(u===D.BUFFER_ADD_CODEC_ERROR||u===D.BUFFER_APPEND_ERROR),p=m&&f.some(function(I){var P=I.audioCodec;return s.audioCodec!==P}),y=e.sourceBufferName==="video"&&(u===D.BUFFER_ADD_CODEC_ERROR||u===D.BUFFER_APPEND_ERROR),E=y&&f.some(function(I){var P=I.codecSet,C=I.audioCodec;return s.codecSet!==P&&s.audioCodec===C}),S=(l=e.context)!=null?l:{},L=S.type,_=S.groupId,A=function(){var P=(b+h)%f.length;if(P!==h&&P>=c&&P<=v&&f[P].loadError===0){var C,w,O=f[P];if(u===D.FRAG_GAP&&g===q.MAIN&&e.frag){var F=f[P].details;if(F){var H=Qr(e.frag,F.fragments,e.frag.start);if(H!=null&&H.gap)return 0}}else{if(L===Y.AUDIO_TRACK&&O.hasAudioGroup(_)||L===Y.SUBTITLE_TRACK&&O.hasSubtitleGroup(_))return 0;if(g===q.AUDIO&&(C=s.audioGroups)!=null&&C.some(function(U){return O.hasAudioGroup(U)})||g===q.SUBTITLE&&(w=s.subtitleGroups)!=null&&w.some(function(U){return O.hasSubtitleGroup(U)})||p&&s.audioCodec===O.audioCodec||!p&&s.audioCodec!==O.audioCodec||E&&s.codecSet===O.codecSet)return 0}return d=P,1}},T,b=f.length;b--&&(T=A(),!(T!==0&&T===1)););if(d>-1&&r.loadLevel!==d)return e.levelRetry=!0,this.playlistError=0,{action:he.SendAlternateToPenaltyBox,flags:Re.None,nextAutoLevel:d}}return{action:he.SendAlternateToPenaltyBox,flags:Re.MoveAllAlternatesMatchingHost}},n.onErrorOut=function(e,t){var r;switch((r=t.errorAction)==null?void 0:r.action){case he.DoNothing:break;case he.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),!t.errorAction.resolved&&t.details!==D.FRAG_GAP?t.fatal=!0:/MediaSource readyState: ended/.test(t.error.message)&&(this.warn('MediaSource ended after "'+t.sourceBufferName+'" sourceBuffer append error. Attempting to recover from media error.'),this.hls.recoverMediaError());break}if(t.fatal){this.hls.stopLoad();return}},n.sendAlternateToPenaltyBox=function(e){var t=this.hls,r=e.errorAction;if(r){var s=r.flags,o=r.hdcpLevel,l=r.nextAutoLevel;switch(s){case Re.None:this.switchLevel(e,l);break;case Re.MoveAllAlternatesMatchingHDCP:o&&(t.maxHdcpLevel=Nt[Nt.indexOf(o)-1],r.resolved=!0),this.warn('Restricting playback to HDCP-LEVEL of "'+t.maxHdcpLevel+'" or lower');break}r.resolved||this.switchLevel(e,l)}},n.switchLevel=function(e,t){t!==void 0&&e.errorAction&&(this.warn("switching to level "+t+" after "+e.details),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)},a}(),va=function(){function a(i,e){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=R.log.bind(R,e+":"),this.warn=R.warn.bind(R,e+":"),this.hls=i}var n=a.prototype;return n.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},n.clearTimer=function(){this.timer!==-1&&(self.clearTimeout(this.timer),this.timer=-1)},n.startLoad=function(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()},n.stopLoad=function(){this.canLoad=!1,this.clearTimer()},n.switchParams=function(e,t,r){var s=t?.renditionReports;if(s){for(var o=-1,l=0;l<s.length;l++){var u=s[l],d=void 0;try{d=new self.URL(u.URI,t.url).href}catch(m){R.warn("Could not construct new URL for Rendition Report: "+m),d=u.URI||""}if(d===e){o=l;break}else d===e.substring(0,d.length)&&(o=l)}if(o!==-1){var f=s[o],h=parseInt(f["LAST-MSN"])||t?.lastPartSn,c=parseInt(f["LAST-PART"])||t?.lastPartIndex;if(this.hls.config.lowLatencyMode){var v=Math.min(t.age-t.partTarget,t.targetduration);c>=0&&v>t.partTarget&&(c+=1)}var g=r&&Gr(r);return new Hr(h,c>=0?c:void 0,g)}}},n.loadPlaylist=function(e){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())},n.shouldLoadPlaylist=function(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)},n.shouldReloadPlaylist=function(e){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(e)},n.playlistLoaded=function(e,t,r){var s=this,o=t.details,l=t.stats,u=self.performance.now(),d=l.loading.first?Math.max(0,u-l.loading.first):0;if(o.advancedDateTime=Date.now()-d,o.live||r!=null&&r.live){if(o.reloaded(r),r&&this.log("live playlist "+e+" "+(o.advanced?"REFRESHED "+o.lastPartSn+"-"+o.lastPartIndex:o.updated?"UPDATED":"MISSED")),r&&o.fragments.length>0&&ta(r,o),!this.canLoad||!o.live)return;var f,h=void 0,c=void 0;if(o.canBlockReload&&o.endSN&&o.advanced){var v=this.hls.config.lowLatencyMode,g=o.lastPartSn,m=o.endSN,p=o.lastPartIndex,y=p!==-1,E=g===m,S=v?0:p;y?(h=E?m+1:g,c=E?S:p+1):h=m+1;var L=o.age,_=L+o.ageHeader,A=Math.min(_-o.partTarget,o.targetduration*1.5);if(A>0){if(r&&A>r.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+r.tuneInGoal+" to: "+A+" with playlist age: "+o.age),A=0;else{var T=Math.floor(A/o.targetduration);if(h+=T,c!==void 0){var b=Math.round(A%o.targetduration/o.partTarget);c+=b}this.log("CDN Tune-in age: "+o.ageHeader+"s last advanced "+L.toFixed(2)+"s goal: "+A+" skip sn "+T+" to part "+c)}o.tuneInGoal=A}if(f=this.getDeliveryDirectives(o,t.deliveryDirectives,h,c),v||!E){this.loadPlaylist(f);return}}else(o.canBlockReload||o.canSkipUntil)&&(f=this.getDeliveryDirectives(o,t.deliveryDirectives,h,c));var I=this.hls.mainForwardBufferInfo,P=I?I.end-I.len:0,C=(o.edge-P)*1e3,w=sa(o,C);o.updated&&u>this.requestScheduled+w&&(this.requestScheduled=l.loading.start),h!==void 0&&o.canBlockReload?this.requestScheduled=l.loading.first+w-(o.partTarget*1e3||1e3):this.requestScheduled===-1||this.requestScheduled+w<u?this.requestScheduled=u:this.requestScheduled-u<=0&&(this.requestScheduled+=w);var O=this.requestScheduled-u;O=Math.max(0,O),this.log("reload live playlist "+e+" in "+Math.round(O)+" ms"),this.timer=self.setTimeout(function(){return s.loadPlaylist(f)},O)}else this.clearTimer()},n.getDeliveryDirectives=function(e,t,r,s){var o=Gr(e);return t!=null&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,s=t.part,o=ut.No),new Hr(r,s,o)},n.checkRetry=function(e){var t=this,r=e.details,s=ft(e),o=e.errorAction,l=o||{},u=l.action,d=l.retryCount,f=d===void 0?0:d,h=l.retryConfig,c=!!o&&!!h&&(u===he.RetryRequest||!o.resolved&&u===he.SendAlternateToPenaltyBox);if(c){var v;if(this.requestScheduled=-1,f>=h.maxNumRetry)return!1;if(s&&(v=e.context)!=null&&v.deliveryDirectives)this.warn("Retrying playlist loading "+(f+1)+"/"+h.maxNumRetry+' after "'+r+'" without delivery-directives'),this.loadPlaylist();else{var g=Gt(h,f);this.timer=self.setTimeout(function(){return t.loadPlaylist()},g),this.warn("Retrying playlist loading "+(f+1)+"/"+h.maxNumRetry+' after "'+r+'" in '+g+"ms")}e.levelRetry=!0,o.resolved=!0}return c},a}(),Ke=function(){function a(i,e,t){e===void 0&&(e=0),t===void 0&&(t=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=i,this.alpha_=i?Math.exp(Math.log(.5)/i):0,this.estimate_=e,this.totalWeight_=t}var n=a.prototype;return n.sample=function(e,t){var r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e},n.getTotalWeight=function(){return this.totalWeight_},n.getEstimate=function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_},a}(),ga=function(){function a(i,e,t,r){r===void 0&&(r=100),this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=t,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new Ke(i),this.fast_=new Ke(e),this.defaultTTFB_=r,this.ttfb_=new Ke(i)}var n=a.prototype;return n.update=function(e,t){var r=this.slow_,s=this.fast_,o=this.ttfb_;r.halfLife!==e&&(this.slow_=new Ke(e,r.getEstimate(),r.getTotalWeight())),s.halfLife!==t&&(this.fast_=new Ke(t,s.getEstimate(),s.getTotalWeight())),o.halfLife!==e&&(this.ttfb_=new Ke(e,o.getEstimate(),o.getTotalWeight()))},n.sample=function(e,t){e=Math.max(e,this.minDelayMs_);var r=8*t,s=e/1e3,o=r/s;this.fast_.sample(s,o),this.slow_.sample(s,o)},n.sampleTTFB=function(e){var t=e/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(r,Math.max(e,5))},n.canEstimate=function(){return this.fast_.getTotalWeight()>=this.minWeight_},n.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},n.getEstimateTTFB=function(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_},n.destroy=function(){},a}();function ma(){if(typeof matchMedia=="function"){var a=matchMedia("(dynamic-range: high)"),n=matchMedia("bad query");if(a.media!==n.media)return a.matches===!0}return!1}function pa(a,n){var i=!1,e=[];return a&&(i=a!=="SDR",e=[a]),n&&(e=n.allowedVideoRanges||lt.slice(0),i=n.preferHDR!==void 0?n.preferHDR:ma(),i?e=e.filter(function(t){return t!=="SDR"}):e=["SDR"]),{preferHDR:i,allowedVideoRanges:e}}function ya(a,n,i,e,t){for(var r=Object.keys(a),s=e?.channels,o=e?.audioCodec,l=s&&parseInt(s)===2,u=!0,d=!1,f=1/0,h=1/0,c=1/0,v=0,g=[],m=pa(n,t),p=m.preferHDR,y=m.allowedVideoRanges,E=function(){var b=a[r[S]];u=b.channels[2]>0,f=Math.min(f,b.minHeight),h=Math.min(h,b.minFramerate),c=Math.min(c,b.minBitrate);var I=y.filter(function(P){return b.videoRanges[P]>0});I.length>0&&(d=!0,g=I)},S=r.length;S--;)E();f=M(f)?f:0,h=M(h)?h:0;var L=Math.max(1080,f),_=Math.max(30,h);c=M(c)?c:i,i=Math.max(c,i),d||(n=void 0,g=[]);var A=r.reduce(function(T,b){var I=a[b];if(b===T)return T;if(I.minBitrate>i)return Pe(b,"min bitrate of "+I.minBitrate+" > current estimate of "+i),T;if(!I.hasDefaultAudio)return Pe(b,"no renditions with default or auto-select sound found"),T;if(o&&b.indexOf(o.substring(0,4))%5!==0)return Pe(b,'audio codec preference "'+o+'" not found'),T;if(s&&!l){if(!I.channels[s])return Pe(b,"no renditions with "+s+" channel sound found (channels options: "+Object.keys(I.channels)+")"),T}else if((!o||l)&&u&&I.channels[2]===0)return Pe(b,"no renditions with stereo sound found"),T;return I.minHeight>L?(Pe(b,"min resolution of "+I.minHeight+" > maximum of "+L),T):I.minFramerate>_?(Pe(b,"min framerate of "+I.minFramerate+" > maximum of "+_),T):g.some(function(P){return I.videoRanges[P]>0})?I.maxScore<v?(Pe(b,"max score of "+I.maxScore+" < selected max of "+v),T):T&&(at(b)>=at(T)||I.fragmentError>a[T].fragmentError)?T:(v=I.maxScore,b):(Pe(b,"no variants with VIDEO-RANGE of "+JSON.stringify(g)+" found"),T)},void 0);return{codecSet:A,videoRanges:g,preferHDR:p,minFramerate:h,minBitrate:c}}function Pe(a,n){R.log('[abr] start candidates with "'+a+'" ignored because '+n)}function Ea(a){return a.reduce(function(n,i){var e=n.groups[i.groupId];e||(e=n.groups[i.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),e.tracks.push(i);var t=i.channels||"2";return e.channels[t]=(e.channels[t]||0)+1,e.hasDefault=e.hasDefault||i.default,e.hasAutoSelect=e.hasAutoSelect||i.autoselect,e.hasDefault&&(n.hasDefaultAudio=!0),e.hasAutoSelect&&(n.hasAutoSelectAudio=!0),n},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function xa(a,n,i,e){return a.slice(i,e+1).reduce(function(t,r){if(!r.codecSet)return t;var s=r.audioGroups,o=t[r.codecSet];o||(t[r.codecSet]=o={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!s,fragmentError:0}),o.minBitrate=Math.min(o.minBitrate,r.bitrate);var l=Math.min(r.height,r.width);return o.minHeight=Math.min(o.minHeight,l),o.minFramerate=Math.min(o.minFramerate,r.frameRate),o.maxScore=Math.max(o.maxScore,r.score),o.fragmentError+=r.fragmentError,o.videoRanges[r.videoRange]=(o.videoRanges[r.videoRange]||0)+1,t},{})}var Ta=function(){function a(i){var e=this;this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this._abandonRulesCheck=function(){var t=e.fragCurrent,r=e.partCurrent,s=e.hls,o=s.autoLevelEnabled,l=s.media;if(!(!t||!l)){var u=performance.now(),d=r?r.stats:t.stats,f=r?r.duration:t.duration,h=u-d.loading.start,c=s.minAutoLevel;if(d.aborted||d.loaded&&d.loaded===d.total||t.level<=c){e.clearTimer(),e._nextAutoLevel=-1;return}if(!(!o||l.paused||!l.playbackRate||!l.readyState)){var v=s.mainForwardBufferInfo;if(v!==null){var g=e.bwEstimator.getEstimateTTFB(),m=Math.abs(l.playbackRate);if(!(h<=Math.max(g,1e3*(f/(m*2))))){var p=v.len/m,y=d.loading.first?d.loading.first-d.loading.start:-1,E=d.loaded&&y>-1,S=e.getBwEstimate(),L=s.levels,_=L[t.level],A=d.total||Math.max(d.loaded,Math.round(f*_.averageBitrate/8)),T=E?h-y:h;T<1&&E&&(T=Math.min(h,d.loaded*8/S));var b=E?d.loaded*1e3/T:0,I=b?(A-d.loaded)/b:A*8/S+g/1e3;if(!(I<=p)){var P=b?b*8:S,C=Number.POSITIVE_INFINITY,w;for(w=t.level-1;w>c;w--){var O=L[w].maxBitrate;if(C=e.getTimeToLoadFrag(g/1e3,P,f*O,!L[w].details),C<p)break}if(!(C>=I)&&!(C>f*10)){s.nextLoadLevel=s.nextAutoLevel=w,E?e.bwEstimator.sample(h-Math.min(g,y),d.loaded):e.bwEstimator.sampleTTFB(h);var F=L[w].maxBitrate;e.getBwEstimate()*e.hls.config.abrBandWidthUpFactor>F&&e.resetEstimator(F),e.clearTimer(),R.warn("[abr] Fragment "+t.sn+(r?" part "+r.index:"")+" of level "+t.level+` is loading too slowly;
3
- Time to underbuffer: `+p.toFixed(3)+` s
4
- Estimated load time for current fragment: `+I.toFixed(3)+` s
5
- Estimated load time for down switch fragment: `+C.toFixed(3)+` s
6
- TTFB estimate: `+(y|0)+` ms
7
- Current BW estimate: `+(M(S)?S|0:"Unknown")+` bps
8
- New BW estimate: `+(e.getBwEstimate()|0)+` bps
9
- Switching to level `+w+" @ "+(F|0)+" bps"),s.trigger(x.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:r,stats:d})}}}}}}},this.hls=i,this.bwEstimator=this.initEstimator(),this.registerListeners()}var n=a.prototype;return n.resetEstimator=function(e){e&&(R.log("setting initial bwe to "+e),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()},n.initEstimator=function(){var e=this.hls.config;return new ga(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)},n.registerListeners=function(){var e=this.hls;e.on(x.MANIFEST_LOADING,this.onManifestLoading,this),e.on(x.FRAG_LOADING,this.onFragLoading,this),e.on(x.FRAG_LOADED,this.onFragLoaded,this),e.on(x.FRAG_BUFFERED,this.onFragBuffered,this),e.on(x.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(x.LEVEL_LOADED,this.onLevelLoaded,this),e.on(x.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(x.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(x.ERROR,this.onError,this)},n.unregisterListeners=function(){var e=this.hls;e&&(e.off(x.MANIFEST_LOADING,this.onManifestLoading,this),e.off(x.FRAG_LOADING,this.onFragLoading,this),e.off(x.FRAG_LOADED,this.onFragLoaded,this),e.off(x.FRAG_BUFFERED,this.onFragBuffered,this),e.off(x.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(x.LEVEL_LOADED,this.onLevelLoaded,this),e.off(x.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(x.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(x.ERROR,this.onError,this))},n.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null},n.onManifestLoading=function(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()},n.onLevelsUpdated=function(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null},n.onMaxAutoLevelUpdated=function(){this.firstSelection=-1,this.nextAutoLevelKey=""},n.onFragLoading=function(e,t){var r=t.frag;if(!this.ignoreFragment(r)){if(!r.bitrateTest){var s;this.fragCurrent=r,this.partCurrent=(s=t.part)!=null?s:null}this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}},n.onLevelSwitching=function(e,t){this.clearTimer()},n.onError=function(e,t){if(!t.fatal)switch(t.details){case D.BUFFER_ADD_CODEC_ERROR:case D.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case D.FRAG_LOAD_TIMEOUT:{var r=t.frag,s=this.fragCurrent,o=this.partCurrent;if(r&&s&&r.sn===s.sn&&r.level===s.level){var l=performance.now(),u=o?o.stats:r.stats,d=l-u.loading.start,f=u.loading.first?u.loading.first-u.loading.start:-1,h=u.loaded&&f>-1;if(h){var c=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(d-Math.min(c,f),u.loaded)}else this.bwEstimator.sampleTTFB(d)}break}}},n.getTimeToLoadFrag=function(e,t,r,s){var o=e+r/t,l=s?this.lastLevelLoadSec:0;return o+l},n.onLevelLoaded=function(e,t){var r=this.hls.config,s=t.stats.loading,o=s.end-s.start;M(o)&&(this.lastLevelLoadSec=o/1e3),t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)},n.onFragLoaded=function(e,t){var r=t.frag,s=t.part,o=s?s.stats:r.stats;if(r.type===q.MAIN&&this.bwEstimator.sampleTTFB(o.loading.first-o.loading.start),!this.ignoreFragment(r)){if(this.clearTimer(),r.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){var l=s?s.duration:r.duration,u=this.hls.levels[r.level],d=(u.loaded?u.loaded.bytes:0)+o.loaded,f=(u.loaded?u.loaded.duration:0)+l;u.loaded={bytes:d,duration:f},u.realBitrate=Math.round(8*d/f)}if(r.bitrateTest){var h={stats:o,frag:r,part:s,id:r.type};this.onFragBuffered(x.FRAG_BUFFERED,h),r.bitrateTest=!1}else this.lastLoadedFragLevel=r.level}},n.onFragBuffered=function(e,t){var r=t.frag,s=t.part,o=s!=null&&s.stats.loaded?s.stats:r.stats;if(!o.aborted&&!this.ignoreFragment(r)){var l=o.parsing.end-o.loading.start-Math.min(o.loading.first-o.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(l,o.loaded),o.bwEstimate=this.getBwEstimate(),r.bitrateTest?this.bitrateTestDelay=l/1e3:this.bitrateTestDelay=0}},n.ignoreFragment=function(e){return e.type!==q.MAIN||e.sn==="initSegment"},n.clearTimer=function(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)},n.getAutoLevelKey=function(){return this.getBwEstimate()+"_"+this.getStarvationDelay().toFixed(2)},n.getNextABRAutoLevel=function(){var e=this.fragCurrent,t=this.partCurrent,r=this.hls,s=r.maxAutoLevel,o=r.config,l=r.minAutoLevel,u=t?t.duration:e?e.duration:0,d=this.getBwEstimate(),f=this.getStarvationDelay(),h=o.abrBandWidthFactor,c=o.abrBandWidthUpFactor;if(f){var v=this.findBestLevel(d,l,s,f,0,h,c);if(v>=0)return v}var g=u?Math.min(u,o.maxStarvationDelay):o.maxStarvationDelay;if(!f){var m=this.bitrateTestDelay;if(m){var p=u?Math.min(u,o.maxLoadingDelay):o.maxLoadingDelay;g=p-m,R.info("[abr] bitrate test took "+Math.round(1e3*m)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*g)+" ms"),h=c=1}}var y=this.findBestLevel(d,l,s,f,g,h,c);if(R.info("[abr] "+(f?"rebuffering expected":"buffer is empty")+", optimal quality level "+y),y>-1)return y;var E=r.levels[l],S=r.levels[r.loadLevel];return E?.bitrate<S?.bitrate?l:r.loadLevel},n.getStarvationDelay=function(){var e=this.hls,t=e.media;if(!t)return 1/0;var r=t&&t.playbackRate!==0?Math.abs(t.playbackRate):1,s=e.mainForwardBufferInfo;return(s?s.len:0)/r},n.getBwEstimate=function(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate},n.findBestLevel=function(e,t,r,s,o,l,u){var d,f=this,h=s+o,c=this.lastLoadedFragLevel,v=c===-1?this.hls.firstLevel:c,g=this.fragCurrent,m=this.partCurrent,p=this.hls,y=p.levels,E=p.allAudioTracks,S=p.loadLevel,L=p.config;if(y.length===1)return 0;var _=y[v],A=!!(_!=null&&(d=_.details)!=null&&d.live),T=S===-1||c===-1,b,I="SDR",P=_?.frameRate||0,C=L.audioPreference,w=L.videoPreference,O=this.audioTracksByGroup||(this.audioTracksByGroup=Ea(E));if(T){if(this.firstSelection!==-1)return this.firstSelection;var F=this.codecTiers||(this.codecTiers=xa(y,O,t,r)),H=ya(F,I,e,C,w),U=H.codecSet,W=H.videoRanges,K=H.minFramerate,B=H.minBitrate,Q=H.preferHDR;b=U,I=Q?W[W.length-1]:W[0],P=K,e=Math.max(e,B),R.log("[abr] picked start tier "+JSON.stringify(H))}else b=_?.codecSet,I=_?.videoRange;for(var j=m?m.duration:g?g.duration:0,J=this.bwEstimator.getEstimateTTFB()/1e3,ee=[],re=function(){var Se,te=y[X],pe=X>v;if(!te)return 0;if(b&&te.codecSet!==b||I&&te.videoRange!==I||pe&&P>te.frameRate||!pe&&P>0&&P<te.frameRate||te.supportedResult&&!((Se=te.supportedResult.decodingInfoResults)!=null&&Se[0].smooth))return ee.push(X),0;var ye=te.details,ie=(m?ye?.partTarget:ye?.averagetargetduration)||j,z;pe?z=u*e:z=l*e;var xe=j&&s>=j*2&&o===0?y[X].averageBitrate:y[X].maxBitrate,ve=f.getTimeToLoadFrag(J,z,xe*ie,ye===void 0),de=z>=xe&&(X===c||te.loadError===0&&te.fragmentError===0)&&(ve<=J||!M(ve)||A&&!f.bitrateTestDelay||ve<h);if(de){var Ve=f.forcedAutoLevel;return X!==S&&(Ve===-1||Ve!==S)&&(ee.length&&R.trace("[abr] Skipped level(s) "+ee.join(",")+" of "+r+' max with CODECS and VIDEO-RANGE:"'+y[ee[0]].codecs+'" '+y[ee[0]].videoRange+'; not compatible with "'+_.codecs+'" '+I),R.info("[abr] switch candidate:"+v+"->"+X+" adjustedbw("+Math.round(z)+")-bitrate="+Math.round(z-xe)+" ttfb:"+J.toFixed(1)+" avgDuration:"+ie.toFixed(1)+" maxFetchDuration:"+h.toFixed(1)+" fetchDuration:"+ve.toFixed(1)+" firstSelection:"+T+" codecSet:"+b+" videoRange:"+I+" hls.loadLevel:"+S)),T&&(f.firstSelection=X),{v:X}}},Z,X=r;X>=t;X--)if(Z=re(),Z!==0&&Z)return Z.v;return-1},me(a,[{key:"firstAutoLevel",get:function(){var e=this.hls,t=e.maxAutoLevel,r=e.minAutoLevel,s=this.getBwEstimate(),o=this.hls.config.maxStarvationDelay,l=this.findBestLevel(s,r,t,0,o,1,1);if(l>-1)return l;var u=this.hls.firstLevel,d=Math.min(Math.max(u,r),t);return R.warn("[abr] Could not find best starting auto level. Defaulting to first in playlist "+u+" clamped to "+d),d}},{key:"forcedAutoLevel",get:function(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}},{key:"nextAutoLevel",get:function(){var e=this.forcedAutoLevel,t=this.bwEstimator,r=t.canEstimate(),s=this.lastLoadedFragLevel>-1;if(e!==-1&&(!r||!s||this.nextAutoLevelKey===this.getAutoLevelKey()))return e;var o=r&&s?this.getNextABRAutoLevel():this.firstAutoLevel;if(e!==-1){var l=this.hls.levels;if(l.length>Math.max(e,o)&&l[e].loadError<=l[o].loadError)return e}return this._nextAutoLevel=o,this.nextAutoLevelKey=this.getAutoLevelKey(),o},set:function(e){var t=this.hls,r=t.maxAutoLevel,s=t.minAutoLevel,o=Math.min(Math.max(e,s),r);this._nextAutoLevel!==o&&(this.nextAutoLevelKey="",this._nextAutoLevel=o)}}]),a}(),Sa={length:0,start:function(){return 0},end:function(){return 0}},le=function(){function a(){}return a.isBuffered=function(i,e){try{if(i){for(var t=a.getBuffered(i),r=0;r<t.length;r++)if(e>=t.start(r)&&e<=t.end(r))return!0}}catch{}return!1},a.bufferInfo=function(i,e,t){try{if(i){var r=a.getBuffered(i),s=[],o;for(o=0;o<r.length;o++)s.push({start:r.start(o),end:r.end(o)});return this.bufferedInfo(s,e,t)}}catch{}return{len:0,start:e,end:e,nextStart:void 0}},a.bufferedInfo=function(i,e,t){e=Math.max(0,e),i.sort(function(m,p){var y=m.start-p.start;return y||p.end-m.end});var r=[];if(t)for(var s=0;s<i.length;s++){var o=r.length;if(o){var l=r[o-1].end;i[s].start-l<t?i[s].end>l&&(r[o-1].end=i[s].end):r.push(i[s])}else r.push(i[s])}else r=i;for(var u=0,d,f=e,h=e,c=0;c<r.length;c++){var v=r[c].start,g=r[c].end;if(e+t>=v&&e<g)f=v,h=g,u=h-e;else if(e+t<v){d=v;break}}return{len:u,start:f||0,end:h||0,nextStart:d}},a.getBuffered=function(i){try{return i.buffered}catch(e){return R.log("failed to get media.buffered",e),Sa}},a}(),La=function(){function a(i){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=i}var n=a.prototype;return n.append=function(e,t,r){var s=this.queues[t];s.push(e),s.length===1&&!r&&this.executeNext(t)},n.insertAbort=function(e,t){var r=this.queues[t];r.unshift(e),this.executeNext(t)},n.appendBlocker=function(e){var t,r=new Promise(function(o){t=o}),s={execute:t,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(s,e),r},n.executeNext=function(e){var t=this.queues[e];if(t.length){var r=t[0];try{r.execute()}catch(o){R.warn('[buffer-operation-queue]: Exception executing "'+e+'" SourceBuffer operation: '+o),r.onError(o);var s=this.buffers[e];s!=null&&s.updating||this.shiftAndExecuteNext(e)}}},n.shiftAndExecuteNext=function(e){this.queues[e].shift(),this.executeNext(e)},n.current=function(e){return this.queues[e][0]},a}(),Jr=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,Aa=function(){function a(i){var e=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendSource=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this.log=void 0,this.warn=void 0,this.error=void 0,this._onEndStreaming=function(r){e.hls&&e.hls.pauseBuffering()},this._onStartStreaming=function(r){e.hls&&e.hls.resumeBuffering()},this._onMediaSourceOpen=function(){var r=e.media,s=e.mediaSource;e.log("Media source opened"),r&&(r.removeEventListener("emptied",e._onMediaEmptied),e.updateMediaElementDuration(),e.hls.trigger(x.MEDIA_ATTACHED,{media:r,mediaSource:s})),s&&s.removeEventListener("sourceopen",e._onMediaSourceOpen),e.checkPendingTracks()},this._onMediaSourceClose=function(){e.log("Media source closed")},this._onMediaSourceEnded=function(){e.log("Media source ended")},this._onMediaEmptied=function(){var r=e.mediaSrc,s=e._objectUrl;r!==s&&R.error("Media element src was set while attaching MediaSource ("+s+" > "+r+")")},this.hls=i;var t="[buffer-controller]";this.appendSource=Fn(Ge(i.config.preferManagedMediaSource)),this.log=R.log.bind(R,t),this.warn=R.warn.bind(R,t),this.error=R.error.bind(R,t),this._initSourceBuffer(),this.registerListeners()}var n=a.prototype;return n.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},n.destroy=function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null,this.hls=null},n.registerListeners=function(){var e=this.hls;e.on(x.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(x.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(x.MANIFEST_LOADING,this.onManifestLoading,this),e.on(x.MANIFEST_PARSED,this.onManifestParsed,this),e.on(x.BUFFER_RESET,this.onBufferReset,this),e.on(x.BUFFER_APPENDING,this.onBufferAppending,this),e.on(x.BUFFER_CODECS,this.onBufferCodecs,this),e.on(x.BUFFER_EOS,this.onBufferEos,this),e.on(x.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(x.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(x.FRAG_PARSED,this.onFragParsed,this),e.on(x.FRAG_CHANGED,this.onFragChanged,this)},n.unregisterListeners=function(){var e=this.hls;e.off(x.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(x.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(x.MANIFEST_LOADING,this.onManifestLoading,this),e.off(x.MANIFEST_PARSED,this.onManifestParsed,this),e.off(x.BUFFER_RESET,this.onBufferReset,this),e.off(x.BUFFER_APPENDING,this.onBufferAppending,this),e.off(x.BUFFER_CODECS,this.onBufferCodecs,this),e.off(x.BUFFER_EOS,this.onBufferEos,this),e.off(x.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(x.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(x.FRAG_PARSED,this.onFragParsed,this),e.off(x.FRAG_CHANGED,this.onFragChanged,this)},n._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new La(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.appendErrors={audio:0,video:0,audiovideo:0},this.lastMpegAudioChunk=null},n.onManifestLoading=function(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null},n.onManifestParsed=function(e,t){var r=2;t.audio&&!t.video||t.altAudio,r=1,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,this.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},n.onMediaAttaching=function(e,t){var r=this.media=t.media,s=Ge(this.appendSource);if(r&&s){var o,l=this.mediaSource=new s;this.log("created media source: "+((o=l.constructor)==null?void 0:o.name)),l.addEventListener("sourceopen",this._onMediaSourceOpen),l.addEventListener("sourceended",this._onMediaSourceEnded),l.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(l.addEventListener("startstreaming",this._onStartStreaming),l.addEventListener("endstreaming",this._onEndStreaming));var u=this._objectUrl=self.URL.createObjectURL(l);if(this.appendSource)try{r.removeAttribute("src");var d=self.ManagedMediaSource;r.disableRemotePlayback=r.disableRemotePlayback||d&&l instanceof d,ei(r),Ra(r,u),r.load()}catch{r.src=u}else r.src=u;r.addEventListener("emptied",this._onMediaEmptied)}},n.onMediaDetaching=function(){var e=this.media,t=this.mediaSource,r=this._objectUrl;if(t){if(this.log("media source detaching"),t.readyState==="open")try{t.endOfStream()}catch(s){this.warn("onMediaDetaching: "+s.message+" while calling endOfStream")}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(t.removeEventListener("startstreaming",this._onStartStreaming),t.removeEventListener("endstreaming",this._onEndStreaming)),e&&(e.removeEventListener("emptied",this._onMediaEmptied),r&&self.URL.revokeObjectURL(r),this.mediaSrc===r?(e.removeAttribute("src"),this.appendSource&&ei(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(x.MEDIA_DETACHED,void 0)},n.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach(function(t){e.resetBuffer(t)}),this._initSourceBuffer()},n.resetBuffer=function(e){var t=this.sourceBuffer[e];try{if(t){var r;this.removeBufferListeners(e),this.sourceBuffer[e]=void 0,(r=this.mediaSource)!=null&&r.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(t)}}catch(s){this.warn("onBufferReset "+e,s)}},n.onBufferCodecs=function(e,t){var r=this,s=this.getSourceBufferTypes().length,o=Object.keys(t);if(o.forEach(function(u){if(s){var d=r.tracks[u];if(d&&typeof d.buffer.changeType=="function"){var f,h=t[u],c=h.id,v=h.codec,g=h.levelCodec,m=h.container,p=h.metadata,y=_r(d.codec,d.levelCodec),E=y?.replace(Jr,"$1"),S=_r(v,g),L=(f=S)==null?void 0:f.replace(Jr,"$1");if(S&&E!==L){u.slice(0,5)==="audio"&&(S=st(S,r.appendSource));var _=m+";codecs="+S;r.appendChangeType(u,_),r.log("switching codec "+y+" to "+S),r.tracks[u]={buffer:d.buffer,codec:v,container:m,levelCodec:g,metadata:p,id:c}}}}else r.pendingTracks[u]=t[u]}),!s){var l=Math.max(this.bufferCodecEventsExpected-1,0);this.bufferCodecEventsExpected!==l&&(this.log(l+" bufferCodec event(s) expected "+o.join(",")),this.bufferCodecEventsExpected=l),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()}},n.appendChangeType=function(e,t){var r=this,s=this.operationQueue,o={execute:function(){var u=r.sourceBuffer[e];u&&(r.log("changing "+e+" sourceBuffer type to "+t),u.changeType(t)),s.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(u){r.warn("Failed to change "+e+" SourceBuffer type",u)}};s.append(o,e,!!this.pendingTracks[e])},n.onBufferAppending=function(e,t){var r=this,s=this.hls,o=this.operationQueue,l=this.tracks,u=t.data,d=t.type,f=t.frag,h=t.part,c=t.chunkMeta,v=c.buffering[d],g=self.performance.now();v.start=g;var m=f.stats.buffering,p=h?h.stats.buffering:null;m.start===0&&(m.start=g),p&&p.start===0&&(p.start=g);var y=l.audio,E=!1;d==="audio"&&y?.container==="audio/mpeg"&&(E=!this.lastMpegAudioChunk||c.id===1||this.lastMpegAudioChunk.sn!==c.sn,this.lastMpegAudioChunk=c);var S=f.start,L={execute:function(){if(v.executeStart=self.performance.now(),E){var A=r.sourceBuffer[d];if(A){var T=S-A.timestampOffset;Math.abs(T)>=.1&&(r.log("Updating audio SourceBuffer timestampOffset to "+S+" (delta: "+T+") sn: "+f.sn+")"),A.timestampOffset=S)}}r.appendExecutor(u,d)},onStart:function(){},onComplete:function(){var A=self.performance.now();v.executeEnd=v.end=A,m.first===0&&(m.first=A),p&&p.first===0&&(p.first=A);var T=r.sourceBuffer,b={};for(var I in T)b[I]=le.getBuffered(T[I]);r.appendErrors[d]=0,d==="audio"||d==="video"?r.appendErrors.audiovideo=0:(r.appendErrors.audio=0,r.appendErrors.video=0),r.hls.trigger(x.BUFFER_APPENDED,{type:d,frag:f,part:h,chunkMeta:c,parent:f.type,timeRanges:b})},onError:function(A){var T={type:V.MEDIA_ERROR,parent:f.type,details:D.BUFFER_APPEND_ERROR,sourceBufferName:d,frag:f,part:h,chunkMeta:c,error:A,err:A,fatal:!1};if(A.code===DOMException.QUOTA_EXCEEDED_ERR)T.details=D.BUFFER_FULL_ERROR;else{var b=++r.appendErrors[d];T.details=D.BUFFER_APPEND_ERROR,r.warn("Failed "+b+"/"+s.config.appendErrorMaxRetry+' times to append segment in "'+d+'" sourceBuffer'),b>=s.config.appendErrorMaxRetry&&(T.fatal=!0)}s.trigger(x.ERROR,T)}};o.append(L,d,!!this.pendingTracks[d])},n.onBufferFlushing=function(e,t){var r=this,s=this.operationQueue,o=function(u){return{execute:r.removeExecutor.bind(r,u,t.startOffset,t.endOffset),onStart:function(){},onComplete:function(){r.hls.trigger(x.BUFFER_FLUSHED,{type:u})},onError:function(f){r.warn("Failed to remove from "+u+" SourceBuffer",f)}}};t.type?s.append(o(t.type),t.type):this.getSourceBufferTypes().forEach(function(l){s.append(o(l),l)})},n.onFragParsed=function(e,t){var r=this,s=t.frag,o=t.part,l=[],u=o?o.elementaryStreams:s.elementaryStreams;u[$.AUDIOVIDEO]?l.push("audiovideo"):(u[$.AUDIO]&&l.push("audio"),u[$.VIDEO]&&l.push("video"));var d=function(){var h=self.performance.now();s.stats.buffering.end=h,o&&(o.stats.buffering.end=h);var c=o?o.stats:s.stats;r.hls.trigger(x.FRAG_BUFFERED,{frag:s,part:o,stats:c,id:s.type})};l.length===0&&this.warn("Fragments must have at least one ElementaryStreamType set. type: "+s.type+" level: "+s.level+" sn: "+s.sn),this.blockBuffers(d,l)},n.onFragChanged=function(e,t){this.trimBuffers()},n.onBufferEos=function(e,t){var r=this,s=this.getSourceBufferTypes().reduce(function(o,l){var u=r.sourceBuffer[l];return u&&(!t.type||t.type===l)&&(u.ending=!0,u.ended||(u.ended=!0,r.log(l+" sourceBuffer now EOS"))),o&&!!(!u||u.ended)},!0);s&&(this.log("Queueing mediaSource.endOfStream()"),this.blockBuffers(function(){r.getSourceBufferTypes().forEach(function(l){var u=r.sourceBuffer[l];u&&(u.ending=!1)});var o=r.mediaSource;if(!o||o.readyState!=="open"){o&&r.log("Could not call mediaSource.endOfStream(). mediaSource.readyState: "+o.readyState);return}r.log("Calling mediaSource.endOfStream()"),o.endOfStream()}))},n.onLevelUpdated=function(e,t){var r=t.details;r.fragments.length&&(this.details=r,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},n.trimBuffers=function(){var e=this.hls,t=this.details,r=this.media;if(!(!r||t===null)){var s=this.getSourceBufferTypes();if(s.length){var o=e.config,l=r.currentTime,u=t.levelTargetDuration,d=t.live&&o.liveBackBufferLength!==null?o.liveBackBufferLength:o.backBufferLength;if(M(d)&&d>0){var f=Math.max(d,u),h=Math.floor(l/u)*u-f;this.flushBackBuffer(l,u,h)}if(M(o.frontBufferFlushThreshold)&&o.frontBufferFlushThreshold>0){var c=Math.max(o.maxBufferLength,o.frontBufferFlushThreshold),v=Math.max(c,u),g=Math.floor(l/u)*u+v;this.flushFrontBuffer(l,u,g)}}}},n.flushBackBuffer=function(e,t,r){var s=this,o=this.details,l=this.sourceBuffer,u=this.getSourceBufferTypes();u.forEach(function(d){var f=l[d];if(f){var h=le.getBuffered(f);if(h.length>0&&r>h.start(0)){if(s.hls.trigger(x.BACK_BUFFER_REACHED,{bufferEnd:r}),o!=null&&o.live)s.hls.trigger(x.LIVE_BACK_BUFFER_REACHED,{bufferEnd:r});else if(f.ended&&h.end(h.length-1)-e<t*2){s.log("Cannot flush "+d+" back buffer while SourceBuffer is in ended state");return}s.hls.trigger(x.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:d})}}})},n.flushFrontBuffer=function(e,t,r){var s=this,o=this.sourceBuffer,l=this.getSourceBufferTypes();l.forEach(function(u){var d=o[u];if(d){var f=le.getBuffered(d),h=f.length;if(h<2)return;var c=f.start(h-1),v=f.end(h-1);if(r>c||e>=c&&e<=v)return;if(d.ended&&e-v<2*t){s.log("Cannot flush "+u+" front buffer while SourceBuffer is in ended state");return}s.hls.trigger(x.BUFFER_FLUSHING,{startOffset:c,endOffset:1/0,type:u})}})},n.updateMediaElementDuration=function(){if(!(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")){var e=this.details,t=this.hls,r=this.media,s=this.mediaSource,o=e.fragments[0].start+e.totalduration,l=r.duration,u=M(s.duration)?s.duration:0;e.live&&t.config.liveDurationInfinity?(s.duration=1/0,this.updateSeekableRange(e)):(o>u&&o>l||!M(l))&&(this.log("Updating Media Source duration to "+o.toFixed(3)),s.duration=o)}},n.updateSeekableRange=function(e){var t=this.mediaSource,r=e.fragments,s=r.length;if(s&&e.live&&t!=null&&t.setLiveSeekableRange){var o=Math.max(0,r[0].start),l=Math.max(o,o+e.totalduration);this.log("Media Source duration is set to "+t.duration+". Setting seekable range to "+o+"-"+l+"."),t.setLiveSeekableRange(o,l)}},n.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,t=this.operationQueue,r=this.pendingTracks,s=Object.keys(r).length;if(s&&(!e||s===2||"audiovideo"in r)){this.createSourceBuffers(r),this.pendingTracks={};var o=this.getSourceBufferTypes();if(o.length)this.hls.trigger(x.BUFFER_CREATED,{tracks:this.tracks}),o.forEach(function(u){t.executeNext(u)});else{var l=new Error("could not create source buffer for media codec(s)");this.hls.trigger(x.ERROR,{type:V.MEDIA_ERROR,details:D.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:l,reason:l.message})}}},n.createSourceBuffers=function(e){var t=this,r=this.sourceBuffer,s=this.mediaSource;if(!s)throw Error("createSourceBuffers called when mediaSource was null");var o=function(d){if(!r[d]){var f,h=e[d];if(!h)throw Error("source buffer exists for track "+d+", however track does not");var c=((f=h.levelCodec)==null?void 0:f.indexOf(","))===-1?h.levelCodec:h.codec;c&&d.slice(0,5)==="audio"&&(c=st(c,t.appendSource));var v=h.container+";codecs="+c;t.log("creating sourceBuffer("+v+")");try{var g=r[d]=s.addSourceBuffer(v),m=d;t.addBufferListener(m,"updatestart",t._onSBUpdateStart),t.addBufferListener(m,"updateend",t._onSBUpdateEnd),t.addBufferListener(m,"error",t._onSBUpdateError),t.appendSource&&t.addBufferListener(m,"bufferedchange",function(p,y){var E=y.removedRanges;E!=null&&E.length&&t.hls.trigger(x.BUFFER_FLUSHED,{type:d})}),t.tracks[d]={buffer:g,codec:c,container:h.container,levelCodec:h.levelCodec,metadata:h.metadata,id:h.id}}catch(p){t.error("error while trying to add sourceBuffer: "+p.message),t.hls.trigger(x.ERROR,{type:V.MEDIA_ERROR,details:D.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:p,sourceBufferName:d,mimeType:v})}}};for(var l in e)o(l)},n._onSBUpdateStart=function(e){var t=this.operationQueue,r=t.current(e);r.onStart()},n._onSBUpdateEnd=function(e){var t;if(((t=this.mediaSource)==null?void 0:t.readyState)==="closed"){this.resetBuffer(e);return}var r=this.operationQueue,s=r.current(e);s.onComplete(),r.shiftAndExecuteNext(e)},n._onSBUpdateError=function(e,t){var r,s=new Error(e+" SourceBuffer error. MediaSource readyState: "+((r=this.mediaSource)==null?void 0:r.readyState));this.error(""+s,t),this.hls.trigger(x.ERROR,{type:V.MEDIA_ERROR,details:D.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:s,fatal:!1});var o=this.operationQueue.current(e);o&&o.onError(s)},n.removeExecutor=function(e,t,r){var s=this.media,o=this.mediaSource,l=this.operationQueue,u=this.sourceBuffer,d=u[e];if(!s||!o||!d){this.warn("Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),l.shiftAndExecuteNext(e);return}var f=M(s.duration)?s.duration:1/0,h=M(o.duration)?o.duration:1/0,c=Math.max(0,t),v=Math.min(r,f,h);v>c&&(!d.ending||d.ended)?(d.ended=!1,this.log("Removing ["+c+","+v+"] from the "+e+" SourceBuffer"),d.remove(c,v)):l.shiftAndExecuteNext(e)},n.appendExecutor=function(e,t){var r=this.sourceBuffer[t];if(!r){if(!this.pendingTracks[t])throw new Error("Attempting to append to the "+t+" SourceBuffer, but it does not exist");return}r.ended=!1,r.appendBuffer(e)},n.blockBuffers=function(e,t){var r=this;if(t===void 0&&(t=this.getSourceBufferTypes()),!t.length){this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}var s=this.operationQueue,o=t.map(function(l){return s.appendBlocker(l)});Promise.all(o).then(function(){e(),t.forEach(function(l){var u=r.sourceBuffer[l];u!=null&&u.updating||s.shiftAndExecuteNext(l)})})},n.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},n.addBufferListener=function(e,t,r){var s=this.sourceBuffer[e];if(s){var o=r.bind(this,e);this.listeners[e].push({event:t,listener:o}),s.addEventListener(t,o)}},n.removeBufferListeners=function(e){var t=this.sourceBuffer[e];t&&this.listeners[e].forEach(function(r){t.removeEventListener(r.event,r.listener)})},me(a,[{key:"mediaSrc",get:function(){var e,t,r=((e=this.media)==null||(t=e.querySelector)==null?void 0:t.call(e,"source"))||this.media;return r?.src}}]),a}();function ei(a){var n=a.querySelectorAll("source");[].slice.call(n).forEach(function(i){a.removeChild(i)})}function Ra(a,n){var i=self.document.createElement("source");i.type="video/mp4",i.src=n,a.appendChild(i)}var ba=function(){function a(i){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=i,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var n=a.prototype;return n.setStreamController=function(e){this.streamController=e},n.destroy=function(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},n.registerListeners=function(){var e=this.hls;e.on(x.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(x.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(x.MANIFEST_PARSED,this.onManifestParsed,this),e.on(x.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(x.BUFFER_CODECS,this.onBufferCodecs,this),e.on(x.MEDIA_DETACHING,this.onMediaDetaching,this)},n.unregisterListener=function(){var e=this.hls;e.off(x.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(x.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(x.MANIFEST_PARSED,this.onManifestParsed,this),e.off(x.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(x.BUFFER_CODECS,this.onBufferCodecs,this),e.off(x.MEDIA_DETACHING,this.onMediaDetaching,this)},n.onFpsDropLevelCapping=function(e,t){var r=this.hls.levels[t.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})},n.onMediaAttaching=function(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()},n.onManifestParsed=function(e,t){var r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()},n.onLevelsUpdated=function(e,t){this.timer&&M(this.autoLevelCapping)&&this.detectPlayerSize()},n.onBufferCodecs=function(e,t){var r=this.hls;r.config.capLevelToPlayerSize&&t.video&&this.startCapping()},n.onMediaDetaching=function(){this.stopCapping()},n.detectPlayerSize=function(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0){this.clientRect=null;return}var e=this.hls.levels;if(e.length){var t=this.hls,r=this.getMaxLevel(e.length-1);r!==this.autoLevelCapping&&R.log("Setting autoLevelCapping to "+r+": "+e[r].height+"p@"+e[r].bitrate+" for media "+this.mediaWidth+"x"+this.mediaHeight),t.autoLevelCapping=r,t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}},n.getMaxLevel=function(e){var t=this,r=this.hls.levels;if(!r.length)return-1;var s=r.filter(function(o,l){return t.isLevelAllowed(o)&&l<=e});return this.clientRect=null,a.getMaxLevelByMediaSize(s,this.mediaWidth,this.mediaHeight)},n.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},n.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},n.getDimensions=function(){if(this.clientRect)return this.clientRect;var e=this.media,t={width:0,height:0};if(e){var r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,!t.width&&!t.height&&(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t},n.isLevelAllowed=function(e){var t=this.restrictedLevels;return!t.some(function(r){return e.bitrate===r.bitrate&&e.width===r.width&&e.height===r.height})},a.getMaxLevelByMediaSize=function(e,t,r){if(!(e!=null&&e.length))return-1;for(var s=function(h,c){return c?h.width!==c.width||h.height!==c.height:!0},o=e.length-1,l=Math.max(t,r),u=0;u<e.length;u+=1){var d=e[u];if((d.width>=l||d.height>=l)&&s(d,e[u+1])){o=u;break}}return o},me(a,[{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch{}return e}}]),a}(),Ia=function(){function a(i){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=i,this.registerListeners()}var n=a.prototype;return n.setStreamController=function(e){this.streamController=e},n.registerListeners=function(){this.hls.on(x.MEDIA_ATTACHING,this.onMediaAttaching,this)},n.unregisterListeners=function(){this.hls.off(x.MEDIA_ATTACHING,this.onMediaAttaching,this)},n.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},n.onMediaAttaching=function(e,t){var r=this.hls.config;if(r.capLevelOnFPSDrop){var s=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=s,s&&typeof s.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}},n.checkFPS=function(e,t,r){var s=performance.now();if(t){if(this.lastTime){var o=s-this.lastTime,l=r-this.lastDroppedFrames,u=t-this.lastDecodedFrames,d=1e3*l/o,f=this.hls;if(f.trigger(x.FPS_DROP,{currentDropped:l,currentDecoded:u,totalDroppedFrames:r}),d>0&&l>f.config.fpsDroppedMonitoringThreshold*u){var h=f.currentLevel;R.warn("drop FPS ratio greater than max allowed value for currentLevel: "+h),h>0&&(f.autoLevelCapping===-1||f.autoLevelCapping>=h)&&(h=h-1,f.trigger(x.FPS_DROP_LEVEL_CAPPING,{level:h,droppedLevel:f.currentLevel}),f.autoLevelCapping=h,this.streamController.nextLevelSwitch())}}this.lastTime=s,this.lastDroppedFrames=r,this.lastDecodedFrames=t}},n.checkFPSInterval=function(){var e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){var t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)},a}(),_a=3e5,Da=function(){function a(i){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=i,this.log=R.log.bind(R,"[content-steering]:"),this.registerListeners()}var n=a.prototype;return n.registerListeners=function(){var e=this.hls;e.on(x.MANIFEST_LOADING,this.onManifestLoading,this),e.on(x.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(x.MANIFEST_PARSED,this.onManifestParsed,this),e.on(x.ERROR,this.onError,this)},n.unregisterListeners=function(){var e=this.hls;e&&(e.off(x.MANIFEST_LOADING,this.onManifestLoading,this),e.off(x.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(x.MANIFEST_PARSED,this.onManifestParsed,this),e.off(x.ERROR,this.onError,this))},n.startLoad=function(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){var e=this.timeToLoad*1e3-(performance.now()-this.updated);if(e>0){this.scheduleRefresh(this.uri,e);return}}this.loadSteeringManifest(this.uri)}},n.stopLoad=function(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()},n.clearTimeout=function(){this.reloadTimer!==-1&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)},n.destroy=function(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null},n.removeLevel=function(e){var t=this.levels;t&&(this.levels=t.filter(function(r){return r!==e}))},n.onManifestLoading=function(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null},n.onManifestLoaded=function(e,t){var r=t.contentSteering;r!==null&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())},n.onManifestParsed=function(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks},n.onError=function(e,t){var r=t.errorAction;if(r?.action===he.SendAlternateToPenaltyBox&&r.flags===Re.MoveAllAlternatesMatchingHost){var s=this.levels,o=this.pathwayPriority,l=this.pathwayId;if(t.context){var u=t.context,d=u.groupId,f=u.pathwayId,h=u.type;d&&s?l=this.getPathwayForGroupId(d,h,l):f&&(l=f)}l in this.penalizedPathways||(this.penalizedPathways[l]=performance.now()),!o&&s&&(o=s.reduce(function(c,v){return c.indexOf(v.pathwayId)===-1&&c.push(v.pathwayId),c},[])),o&&o.length>1&&(this.updatePathwayPriority(o),r.resolved=this.pathwayId!==l),r.resolved||R.warn("Could not resolve "+t.details+' ("'+t.error.message+'") with content-steering for Pathway: '+l+" levels: "+(s&&s.length)+" priorities: "+JSON.stringify(o)+" penalized: "+JSON.stringify(this.penalizedPathways))}},n.filterParsedLevels=function(e){this.levels=e;var t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){var r=e[0].pathwayId;this.log("No levels found in Pathway "+this.pathwayId+'. Setting initial Pathway to "'+r+'"'),t=this.getLevelsForPathway(r),this.pathwayId=r}return t.length!==e.length&&this.log("Found "+t.length+"/"+e.length+' levels in Pathway "'+this.pathwayId+'"'),t},n.getLevelsForPathway=function(e){return this.levels===null?[]:this.levels.filter(function(t){return e===t.pathwayId})},n.updatePathwayPriority=function(e){this.pathwayPriority=e;var t,r=this.penalizedPathways,s=performance.now();Object.keys(r).forEach(function(h){s-r[h]>_a&&delete r[h]});for(var o=0;o<e.length;o++){var l=e[o];if(!(l in r)){if(l===this.pathwayId)return;var u=this.hls.nextLoadLevel,d=this.hls.levels[u];if(t=this.getLevelsForPathway(l),t.length>0){this.log('Setting Pathway to "'+l+'"'),this.pathwayId=l,jr(t),this.hls.trigger(x.LEVELS_UPDATED,{levels:t});var f=this.hls.levels[u];d&&f&&this.levels&&(f.attrs["STABLE-VARIANT-ID"]!==d.attrs["STABLE-VARIANT-ID"]&&f.bitrate!==d.bitrate&&this.log("Unstable Pathways change from bitrate "+d.bitrate+" to "+f.bitrate),this.hls.nextLoadLevel=u);break}}}},n.getPathwayForGroupId=function(e,t,r){for(var s=this.getLevelsForPathway(r).concat(this.levels||[]),o=0;o<s.length;o++)if(t===Y.AUDIO_TRACK&&s[o].hasAudioGroup(e)||t===Y.SUBTITLE_TRACK&&s[o].hasSubtitleGroup(e))return s[o].pathwayId;return r},n.clonePathways=function(e){var t=this,r=this.levels;if(r){var s={},o={};e.forEach(function(l){var u=l.ID,d=l["BASE-ID"],f=l["URI-REPLACEMENT"];if(!r.some(function(c){return c.pathwayId===u})){var h=t.getLevelsForPathway(d).map(function(c){var v=new oe(c.attrs);v["PATHWAY-ID"]=u;var g=v.AUDIO&&v.AUDIO+"_clone_"+u,m=v.SUBTITLES&&v.SUBTITLES+"_clone_"+u;g&&(s[v.AUDIO]=g,v.AUDIO=g),m&&(o[v.SUBTITLES]=m,v.SUBTITLES=m);var p=ri(c.uri,v["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",f),y=new Bt({attrs:v,audioCodec:c.audioCodec,bitrate:c.bitrate,height:c.height,name:c.name,url:p,videoCodec:c.videoCodec,width:c.width});if(c.audioGroups)for(var E=1;E<c.audioGroups.length;E++)y.addGroupId("audio",c.audioGroups[E]+"_clone_"+u);if(c.subtitleGroups)for(var S=1;S<c.subtitleGroups.length;S++)y.addGroupId("text",c.subtitleGroups[S]+"_clone_"+u);return y});r.push.apply(r,h),ti(t.audioTracks,s,f,u),ti(t.subtitleTracks,o,f,u)}})}},n.loadSteeringManifest=function(e){var t=this,r=this.hls.config,s=r.loader;this.loader&&this.loader.destroy(),this.loader=new s(r);var o;try{o=new self.URL(e)}catch{this.enabled=!1,this.log("Failed to parse Steering Manifest URI: "+e);return}if(o.protocol!=="data:"){var l=(this.hls.bandwidthEstimate||r.abrEwmaDefaultEstimate)|0;o.searchParams.set("_HLS_pathway",this.pathwayId),o.searchParams.set("_HLS_throughput",""+l)}var u={responseType:"json",url:o.href},d=r.steeringManifestLoadPolicy.default,f=d.errorRetry||d.timeoutRetry||{},h={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:f.maxNumRetry||0,retryDelay:f.retryDelayMs||0,maxRetryDelay:f.maxRetryDelayMs||0},c={onSuccess:function(g,m,p,y){t.log('Loaded steering manifest: "'+o+'"');var E=g.data;if(E.VERSION!==1){t.log("Steering VERSION "+E.VERSION+" not supported!");return}t.updated=performance.now(),t.timeToLoad=E.TTL;var S=E["RELOAD-URI"],L=E["PATHWAY-CLONES"],_=E["PATHWAY-PRIORITY"];if(S)try{t.uri=new self.URL(S,o).href}catch{t.enabled=!1,t.log("Failed to parse Steering Manifest RELOAD-URI: "+S);return}t.scheduleRefresh(t.uri||p.url),L&&t.clonePathways(L);var A={steeringManifest:E,url:o.toString()};t.hls.trigger(x.STEERING_MANIFEST_LOADED,A),_&&t.updatePathwayPriority(_)},onError:function(g,m,p,y){if(t.log("Error loading steering manifest: "+g.code+" "+g.text+" ("+m.url+")"),t.stopLoad(),g.code===410){t.enabled=!1,t.log("Steering manifest "+m.url+" no longer available");return}var E=t.timeToLoad*1e3;if(g.code===429){var S=t.loader;if(typeof S?.getResponseHeader=="function"){var L=S.getResponseHeader("Retry-After");L&&(E=parseFloat(L)*1e3)}t.log("Steering manifest "+m.url+" rate limited");return}t.scheduleRefresh(t.uri||m.url,E)},onTimeout:function(g,m,p){t.log("Timeout loading steering manifest ("+m.url+")"),t.scheduleRefresh(t.uri||m.url)}};this.log("Requesting steering manifest: "+o),this.loader.load(u,h,c)},n.scheduleRefresh=function(e,t){var r=this;t===void 0&&(t=this.timeToLoad*1e3),this.clearTimeout(),this.reloadTimer=self.setTimeout(function(){var s,o=(s=r.hls)==null?void 0:s.media;if(o&&!o.ended){r.loadSteeringManifest(e);return}r.scheduleRefresh(e,r.timeToLoad*1e3)},t)},a}();function ti(a,n,i,e){a&&Object.keys(n).forEach(function(t){var r=a.filter(function(s){return s.groupId===t}).map(function(s){var o=Te({},s);return o.details=void 0,o.attrs=new oe(o.attrs),o.url=o.attrs.URI=ri(s.url,s.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",i),o.groupId=o.attrs["GROUP-ID"]=n[t],o.attrs["PATHWAY-ID"]=e,o});a.push.apply(a,r)})}function ri(a,n,i,e){var t=e.HOST,r=e.PARAMS,s=e[i],o;n&&(o=s?.[n],o&&(a=o));var l=new self.URL(a);return t&&!o&&(l.host=t),r&&Object.keys(r).sort().forEach(function(u){u&&l.searchParams.set(u,r[u])}),l.href}var Ca=/^age:\s*[\d.]+\s*$/im,ii=function(){function a(i){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=i&&i.xhrSetup||null,this.stats=new Je,this.retryDelay=0}var n=a.prototype;return n.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null},n.abortInternal=function(){var e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,e.readyState!==4&&(this.stats.aborted=!0,e.abort()))},n.abort=function(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},n.load=function(e,t,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=r,this.loadInternal()},n.loadInternal=function(){var e=this,t=this.config,r=this.context;if(!(!t||!r)){var s=this.loader=new self.XMLHttpRequest,o=this.stats;o.loading.first=0,o.loaded=0,o.aborted=!1;var l=this.xhrSetup;l?Promise.resolve().then(function(){if(!(e.loader!==s||e.stats.aborted))return l(s,r.url)}).catch(function(u){if(!(e.loader!==s||e.stats.aborted))return s.open("GET",r.url,!0),l(s,r.url)}).then(function(){e.loader!==s||e.stats.aborted||e.openAndSendXhr(s,r,t)}).catch(function(u){e.callbacks.onError({code:s.status,text:u.message},r,s,o)}):this.openAndSendXhr(s,r,t)}},n.openAndSendXhr=function(e,t,r){e.readyState||e.open("GET",t.url,!0);var s=t.headers,o=r.loadPolicy,l=o.maxTimeToFirstByteMs,u=o.maxLoadTimeMs;if(s)for(var d in s)e.setRequestHeader(d,s[d]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),r.timeout=l&&M(l)?l:u,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),e.send()},n.readystatechange=function(){var e=this.context,t=this.loader,r=this.stats;if(!(!e||!t)){var s=t.readyState,o=this.config;if(!r.aborted&&s>=2&&(r.loading.first===0&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),o.timeout!==o.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),o.timeout=o.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),o.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),s===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;var l=t.status,u=t.responseType!=="text";if(l>=200&&l<300&&(u&&t.response||t.responseText!==null)){r.loading.end=Math.max(self.performance.now(),r.loading.first);var d=u?t.response:t.responseText,f=t.responseType==="arraybuffer"?d.byteLength:d.length;if(r.loaded=r.total=f,r.bwEstimate=r.total*8e3/(r.loading.end-r.loading.first),!this.callbacks)return;var h=this.callbacks.onProgress;if(h&&h(r,e,d,t),!this.callbacks)return;var c={url:t.responseURL,data:d,code:l};this.callbacks.onSuccess(c,r,e,t)}else{var v=o.loadPolicy.errorRetry,g=r.retry,m={url:e.url,data:void 0,code:l};dt(v,g,!1,m)?this.retry(v):(R.error(l+" while loading "+e.url),this.callbacks.onError({code:l,text:t.statusText},e,t,r))}}}},n.loadtimeout=function(){if(this.config){var e=this.config.loadPolicy.timeoutRetry,t=this.stats.retry;if(dt(e,t,!0))this.retry(e);else{var r;R.warn("timeout while loading "+((r=this.context)==null?void 0:r.url));var s=this.callbacks;s&&(this.abortInternal(),s.onTimeout(this.stats,this.context,this.loader))}}},n.retry=function(e){var t=this.context,r=this.stats;this.retryDelay=Gt(e,r.retry),r.retry++,R.warn((status?"HTTP Status "+status:"Timeout")+" while loading "+t?.url+", retrying "+r.retry+"/"+e.maxNumRetry+" in "+this.retryDelay+"ms"),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)},n.loadprogress=function(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)},n.getCacheAge=function(){var e=null;if(this.loader&&Ca.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e},n.getResponseHeader=function(e){return this.loader&&new RegExp("^"+e+":\\s*[\\d.]+\\s*$","im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null},a}(),Pa=function(){function a(){this.chunks=[],this.dataLength=0}var n=a.prototype;return n.push=function(e){this.chunks.push(e),this.dataLength+=e.length},n.flush=function(){var e=this.chunks,t=this.dataLength,r;if(e.length)e.length===1?r=e[0]:r=wa(e,t);else return new Uint8Array(0);return this.reset(),r},n.reset=function(){this.chunks.length=0,this.dataLength=0},a}();function wa(a,n){for(var i=new Uint8Array(n),e=0,t=0;t<a.length;t++){var r=a[t];i.set(r,e),e+=r.length}return i}function ka(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var Fa=/(\d+)-(\d+)\/(\d+)/,ni=function(){function a(i){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=i.fetchSetup||Ba,this.controller=new self.AbortController,this.stats=new Je}var n=a.prototype;return n.destroy=function(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null},n.abortInternal=function(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())},n.abort=function(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},n.load=function(e,t,r){var s=this,o=this.stats;if(o.loading.start)throw new Error("Loader can only be used once.");o.loading.start=self.performance.now();var l=Ma(e,this.controller.signal),u=r.onProgress,d=e.responseType==="arraybuffer",f=d?"byteLength":"length",h=t.loadPolicy,c=h.maxTimeToFirstByteMs,v=h.maxLoadTimeMs;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,l),self.clearTimeout(this.requestTimeout),t.timeout=c&&M(c)?c:v,this.requestTimeout=self.setTimeout(function(){s.abortInternal(),r.onTimeout(o,e,s.response)},t.timeout),self.fetch(this.request).then(function(g){s.response=s.loader=g;var m=Math.max(self.performance.now(),o.loading.start);if(self.clearTimeout(s.requestTimeout),t.timeout=v,s.requestTimeout=self.setTimeout(function(){s.abortInternal(),r.onTimeout(o,e,s.response)},v-(m-o.loading.start)),!g.ok){var p=g.status,y=g.statusText;throw new Ua(y||"fetch, bad network response",p,g)}return o.loading.first=m,o.total=Na(g.headers)||o.total,u&&M(t.highWaterMark)?s.loadProgressively(g,o,e,t.highWaterMark,u):d?g.arrayBuffer():e.responseType==="json"?g.json():g.text()}).then(function(g){var m=s.response;if(!m)throw new Error("loader destroyed");self.clearTimeout(s.requestTimeout),o.loading.end=Math.max(self.performance.now(),o.loading.first);var p=g[f];p&&(o.loaded=o.total=p);var y={url:m.url,data:g,code:m.status};u&&!M(t.highWaterMark)&&u(o,e,g,m),r.onSuccess(y,o,e,m)}).catch(function(g){if(self.clearTimeout(s.requestTimeout),!o.aborted){var m=g&&g.code||0,p=g?g.message:null;r.onError({code:m,text:p},e,g?g.details:null,o)}})},n.getCacheAge=function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?parseFloat(t):null}return e},n.getResponseHeader=function(e){return this.response?this.response.headers.get(e):null},n.loadProgressively=function(e,t,r,s,o){s===void 0&&(s=0);var l=new Pa,u=e.body.getReader(),d=function f(){return u.read().then(function(h){if(h.done)return l.dataLength&&o(t,r,l.flush(),e),Promise.resolve(new ArrayBuffer(0));var c=h.value,v=c.length;return t.loaded+=v,v<s||l.dataLength?(l.push(c),l.dataLength>=s&&o(t,r,l.flush(),e)):o(t,r,c,e),f()}).catch(function(){return Promise.reject()})};return d()},a}();function Ma(a,n){var i={method:"GET",mode:"cors",credentials:"same-origin",signal:n,headers:new self.Headers(Te({},a.headers))};return a.rangeEnd&&i.headers.set("Range","bytes="+a.rangeStart+"-"+String(a.rangeEnd-1)),i}function Oa(a){var n=Fa.exec(a);if(n)return parseInt(n[2])-parseInt(n[1])+1}function Na(a){var n=a.get("Content-Range");if(n){var i=Oa(n);if(M(i))return i}var e=a.get("Content-Length");if(e)return parseInt(e)}function Ba(a,n){return new self.Request(a.url,n)}var Ua=function(a){_e(n,a);function n(i,e,t){var r;return r=a.call(this,i)||this,r.code=void 0,r.details=void 0,r.code=e,r.details=t,r}return n}(Ze(Error)),Ga={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},ai=se(se({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:ii,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:Ta,bufferController:Aa,capLevelController:ba,errorController:ca,fpsController:Ia,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:null,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,useMediaCapabilities:!1,certLoadPolicy:{default:Ga},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},Ha()),{},{subtitleStreamController:void 0,subtitleTrackController:void 0,timelineController:void 0,audioStreamController:void 0,audioTrackController:void 0,emeController:void 0,cmcdController:void 0,contentSteeringController:Da});function Ha(){return{cueHandler:un,enableWebVTT:!1,enableIMSC1:!1,enableCEA708Captions:!1,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function Va(a,n){if((n.liveSyncDurationCount||n.liveMaxLatencyDurationCount)&&(n.liveSyncDuration||n.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(n.liveMaxLatencyDurationCount!==void 0&&(n.liveSyncDurationCount===void 0||n.liveMaxLatencyDurationCount<=n.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(n.liveMaxLatencyDuration!==void 0&&(n.liveSyncDuration===void 0||n.liveMaxLatencyDuration<=n.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var i=Ht(a),e=["manifest","level","frag"],t=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return e.forEach(function(r){var s=(r==="level"?"playlist":r)+"LoadPolicy",o=n[s]===void 0,l=[];t.forEach(function(u){var d=r+"Loading"+u,f=n[d];if(f!==void 0&&o){l.push(d);var h=i[s].default;switch(n[s]={default:h},u){case"TimeOut":h.maxLoadTimeMs=f,h.maxTimeToFirstByteMs=f;break;case"MaxRetry":h.errorRetry.maxNumRetry=f,h.timeoutRetry.maxNumRetry=f;break;case"RetryDelay":h.errorRetry.retryDelayMs=f,h.timeoutRetry.retryDelayMs=f;break;case"MaxRetryTimeout":h.errorRetry.maxRetryDelayMs=f,h.timeoutRetry.maxRetryDelayMs=f;break}}}),l.length&&R.warn('hls.js config: "'+l.join('", "')+'" setting(s) are deprecated, use "'+s+'": '+JSON.stringify(n[s]))}),se(se({},i),n)}function Ht(a){return a&&typeof a=="object"?Array.isArray(a)?a.map(Ht):Object.keys(a).reduce(function(n,i){return n[i]=Ht(a[i]),n},{}):a}function Ka(a){var n=a.loader;if(n!==ni&&n!==ii)R.log("[config]: Custom loader detected, cannot enable progressive streaming"),a.progressive=!1;else{var i=ka();i&&(a.loader=ni,a.progressive=!0,a.enableSoftwareAES=!0,R.log("[config]: Progressive streaming enabled, using FetchLoader"))}}var Vt,Wa=function(a){_e(n,a);function n(e,t){var r;return r=a.call(this,e,"[level-controller]")||this,r._levels=[],r._firstLevel=-1,r._maxAutoLevel=-1,r._startLevel=void 0,r.currentLevel=null,r.currentLevelIndex=-1,r.manualLevelIndex=-1,r.steering=void 0,r.onParsedComplete=void 0,r.steering=t,r._registerListeners(),r}var i=n.prototype;return i._registerListeners=function(){var t=this.hls;t.on(x.MANIFEST_LOADING,this.onManifestLoading,this),t.on(x.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(x.LEVEL_LOADED,this.onLevelLoaded,this),t.on(x.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(x.FRAG_BUFFERED,this.onFragBuffered,this),t.on(x.ERROR,this.onError,this)},i._unregisterListeners=function(){var t=this.hls;t.off(x.MANIFEST_LOADING,this.onManifestLoading,this),t.off(x.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(x.LEVEL_LOADED,this.onLevelLoaded,this),t.off(x.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(x.FRAG_BUFFERED,this.onFragBuffered,this),t.off(x.ERROR,this.onError,this)},i.destroy=function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),a.prototype.destroy.call(this)},i.stopLoad=function(){var t=this._levels;t.forEach(function(r){r.loadError=0,r.fragmentError=0}),a.prototype.stopLoad.call(this)},i.resetLevels=function(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1},i.onManifestLoading=function(t,r){this.resetLevels()},i.onManifestLoaded=function(t,r){var s=this.hls.config.preferManagedMediaSource,o=[],l={},u={},d=!1,f=!1,h=!1;r.levels.forEach(function(c){var v,g,m=c.attrs,p=c.audioCodec,y=c.videoCodec;((v=p)==null?void 0:v.indexOf("mp4a.40.34"))!==-1&&(Vt||(Vt=/chrome|firefox/i.test(navigator.userAgent)),Vt&&(c.audioCodec=p=void 0)),p&&(c.audioCodec=p=st(p,s)),((g=y)==null?void 0:g.indexOf("avc1"))===0&&(y=c.videoCodec=Bn(y));var E=c.width,S=c.height,L=c.unknownCodecs;if(d||(d=!!(E&&S)),f||(f=!!y),h||(h=!!p),!(L!=null&&L.length||p&&!Pt(p,"audio",s)||y&&!Pt(y,"video",s))){var _=m.CODECS,A=m["FRAME-RATE"],T=m["HDCP-LEVEL"],b=m["PATHWAY-ID"],I=m.RESOLUTION,P=m["VIDEO-RANGE"],C=(b||".")+"-",w=""+C+c.bitrate+"-"+I+"-"+A+"-"+_+"-"+P+"-"+T;if(l[w])if(l[w].uri!==c.url&&!c.attrs["PATHWAY-ID"]){var F=u[w]+=1;c.attrs["PATHWAY-ID"]=new Array(F+1).join(".");var H=new Bt(c);l[w]=H,o.push(H)}else l[w].addGroupId("audio",m.AUDIO),l[w].addGroupId("text",m.SUBTITLES);else{var O=new Bt(c);l[w]=O,u[w]=1,o.push(O)}}}),this.filterAndSortMediaOptions(o,r,d,f,h)},i.filterAndSortMediaOptions=function(t,r,s,o,l){var u=this,d=[],f=[],h=t;if((s||o)&&l&&(h=h.filter(function(T){var b=T.videoCodec,I=T.videoRange,P=T.width,C=T.height;return(!!b||!!(P&&C))&&ea(I)})),h.length===0){Promise.resolve().then(function(){if(u.hls){r.levels.length&&u.warn("One or more CODECS in variant not supported: "+JSON.stringify(r.levels[0].attrs));var T=new Error("no level with compatible codecs found in manifest");u.hls.trigger(x.ERROR,{type:V.MEDIA_ERROR,details:D.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:r.url,error:T,reason:T.message})}});return}if(r.audioTracks){var c=this.hls.config.preferManagedMediaSource;d=r.audioTracks.filter(function(T){return!T.audioCodec||Pt(T.audioCodec,"audio",c)}),si(d)}r.subtitles&&(f=r.subtitles,si(f));var v=h.slice(0);h.sort(function(T,b){if(T.attrs["HDCP-LEVEL"]!==b.attrs["HDCP-LEVEL"])return(T.attrs["HDCP-LEVEL"]||"")>(b.attrs["HDCP-LEVEL"]||"")?1:-1;if(s&&T.height!==b.height)return T.height-b.height;if(T.frameRate!==b.frameRate)return T.frameRate-b.frameRate;if(T.videoRange!==b.videoRange)return lt.indexOf(T.videoRange)-lt.indexOf(b.videoRange);if(T.videoCodec!==b.videoCodec){var I=Ir(T.videoCodec),P=Ir(b.videoCodec);if(I!==P)return P-I}if(T.uri===b.uri&&T.codecSet!==b.codecSet){var C=at(T.codecSet),w=at(b.codecSet);if(C!==w)return w-C}return T.averageBitrate!==b.averageBitrate?T.averageBitrate-b.averageBitrate:0});var g=v[0];if(this.steering&&(h=this.steering.filterParsedLevels(h),h.length!==v.length)){for(var m=0;m<v.length;m++)if(v[m].pathwayId===h[0].pathwayId){g=v[m];break}}this._levels=h;for(var p=0;p<h.length;p++)if(h[p]===g){var y;this._firstLevel=p;var E=g.bitrate,S=this.hls.bandwidthEstimate;if(this.log("manifest loaded, "+h.length+" level(s) found, first bitrate: "+E),((y=this.hls.userConfig)==null?void 0:y.abrEwmaDefaultEstimate)===void 0){var L=Math.min(E,this.hls.config.abrEwmaDefaultEstimateMax);L>S&&S===ai.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=L)}break}var _=l&&!o,A={levels:h,audioTracks:d,subtitleTracks:f,sessionData:r.sessionData,sessionKeys:r.sessionKeys,firstLevel:this._firstLevel,stats:r.stats,audio:l,video:o,altAudio:!_&&d.some(function(T){return!!T.url})};this.hls.trigger(x.MANIFEST_PARSED,A),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)},i.onError=function(t,r){r.fatal||!r.context||r.context.type===Y.LEVEL&&r.context.level===this.level&&this.checkRetry(r)},i.onFragBuffered=function(t,r){var s=r.frag;if(s!==void 0&&s.type===q.MAIN){var o=s.elementaryStreams;if(!Object.keys(o).some(function(u){return!!o[u]}))return;var l=this._levels[s.level];l!=null&&l.loadError&&(this.log("Resetting level error count of "+l.loadError+" on frag buffered"),l.loadError=0)}},i.onLevelLoaded=function(t,r){var s,o=r.level,l=r.details,u=this._levels[o];if(!u){var d;this.warn("Invalid level index "+o),(d=r.deliveryDirectives)!=null&&d.skip&&(l.deltaUpdateFailed=!0);return}o===this.currentLevelIndex?(u.fragmentError===0&&(u.loadError=0),this.playlistLoaded(o,r,u.details)):(s=r.deliveryDirectives)!=null&&s.skip&&(l.deltaUpdateFailed=!0)},i.loadPlaylist=function(t){a.prototype.loadPlaylist.call(this);var r=this.currentLevelIndex,s=this.currentLevel;if(s&&this.shouldLoadPlaylist(s)){var o=s.uri;if(t)try{o=t.addDirectives(o)}catch(u){this.warn("Could not construct new URL with HLS Delivery Directives: "+u)}var l=s.attrs["PATHWAY-ID"];this.log("Loading level index "+r+(t?.msn!==void 0?" at sn "+t.msn+" part "+t.part:"")+" with"+(l?" Pathway "+l:"")+" "+o),this.clearTimer(),this.hls.trigger(x.LEVEL_LOADING,{url:o,level:r,pathwayId:s.attrs["PATHWAY-ID"],id:0,deliveryDirectives:t||null})}},i.removeLevel=function(t){var r=this,s,o=this._levels.filter(function(l,u){return u!==t?!0:(r.steering&&r.steering.removeLevel(l),l===r.currentLevel&&(r.currentLevel=null,r.currentLevelIndex=-1,l.details&&l.details.fragments.forEach(function(d){return d.level=-1})),!1)});jr(o),this._levels=o,this.currentLevelIndex>-1&&(s=this.currentLevel)!=null&&s.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.hls.trigger(x.LEVELS_UPDATED,{levels:o})},i.onLevelsUpdated=function(t,r){var s=r.levels;this._levels=s},i.checkMaxAutoUpdated=function(){var t=this.hls,r=t.autoLevelCapping,s=t.maxAutoLevel,o=t.maxHdcpLevel;this._maxAutoLevel!==s&&(this._maxAutoLevel=s,this.hls.trigger(x.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:r,levels:this.levels,maxAutoLevel:s,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:o}))},me(n,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(t){var r=this._levels;if(r.length!==0){if(t<0||t>=r.length){var s=new Error("invalid level idx"),o=t<0;if(this.hls.trigger(x.ERROR,{type:V.OTHER_ERROR,details:D.LEVEL_SWITCH_ERROR,level:t,fatal:o,error:s,reason:s.message}),o)return;t=Math.min(t,r.length-1)}var l=this.currentLevelIndex,u=this.currentLevel,d=u?u.attrs["PATHWAY-ID"]:void 0,f=r[t],h=f.attrs["PATHWAY-ID"];if(this.currentLevelIndex=t,this.currentLevel=f,!(l===t&&f.details&&u&&d===h)){this.log("Switching to level "+t+" ("+(f.height?f.height+"p ":"")+(f.videoRange?f.videoRange+" ":"")+(f.codecSet?f.codecSet+" ":"")+"@"+f.bitrate+")"+(h?" with Pathway "+h:"")+" from level "+l+(d?" with Pathway "+d:""));var c={level:t,attrs:f.attrs,details:f.details,bitrate:f.bitrate,averageBitrate:f.averageBitrate,maxBitrate:f.maxBitrate,realBitrate:f.realBitrate,width:f.width,height:f.height,codecSet:f.codecSet,audioCodec:f.audioCodec,videoCodec:f.videoCodec,audioGroups:f.audioGroups,subtitleGroups:f.subtitleGroups,loaded:f.loaded,loadError:f.loadError,fragmentError:f.fragmentError,name:f.name,id:f.id,uri:f.uri,url:f.url,urlId:0,audioGroupIds:f.audioGroupIds,textGroupIds:f.textGroupIds};this.hls.trigger(x.LEVEL_SWITCHING,c);var v=f.details;if(!v||v.live){var g=this.switchParams(f.uri,u?.details,v);this.loadPlaylist(g)}}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(t){this.manualLevelIndex=t,this._startLevel===void 0&&(this._startLevel=t),t!==-1&&(this.level=t)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(t){this._firstLevel=t}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var t=this.hls.config.startLevel;return t!==void 0?t:this.hls.firstAutoLevel}return this._startLevel},set:function(t){this._startLevel=t}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(t){this.level=t,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=t)}}]),n}(va);function si(a){var n={};a.forEach(function(i){var e=i.groupId||"";i.id=n[e]=n[e]||0,n[e]++})}var Ee={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"},Ya=function(){function a(i){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=i,this._registerListeners()}var n=a.prototype;return n._registerListeners=function(){var e=this.hls;e.on(x.BUFFER_APPENDED,this.onBufferAppended,this),e.on(x.FRAG_BUFFERED,this.onFragBuffered,this),e.on(x.FRAG_LOADED,this.onFragLoaded,this)},n._unregisterListeners=function(){var e=this.hls;e.off(x.BUFFER_APPENDED,this.onBufferAppended,this),e.off(x.FRAG_BUFFERED,this.onFragBuffered,this),e.off(x.FRAG_LOADED,this.onFragLoaded,this)},n.destroy=function(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null},n.getAppendedFrag=function(e,t){var r=this.activePartLists[t];if(r)for(var s=r.length;s--;){var o=r[s];if(!o)break;var l=o.end;if(o.start<=e&&l!==null&&e<=l)return o}return this.getBufferedFrag(e,t)},n.getBufferedFrag=function(e,t){for(var r=this.fragments,s=Object.keys(r),o=s.length;o--;){var l=r[s[o]];if(l?.body.type===t&&l.buffered){var u=l.body;if(u.start<=e&&e<=u.end)return u}}return null},n.detectEvictedFragments=function(e,t,r,s){var o=this;this.timeRanges&&(this.timeRanges[e]=t);var l=s?.fragment.sn||-1;Object.keys(this.fragments).forEach(function(u){var d=o.fragments[u];if(d&&!(l>=d.body.sn)){if(!d.buffered&&!d.loaded){d.body.type===r&&o.removeFragment(d.body);return}var f=d.range[e];f&&f.time.some(function(h){var c=!o.isTimeBuffered(h.startPTS,h.endPTS,t);return c&&o.removeFragment(d.body),c})}})},n.detectPartialFragments=function(e){var t=this,r=this.timeRanges,s=e.frag,o=e.part;if(!(!r||s.sn==="initSegment")){var l=We(s),u=this.fragments[l];if(!(!u||u.buffered&&s.gap)){var d=!s.relurl;if(Object.keys(r).forEach(function(h){var c=s.elementaryStreams[h];if(c){var v=r[h],g=d||c.partial===!0;u.range[h]=t.getBufferedTimes(s,o,g,v)}}),u.loaded=null,Object.keys(u.range).length){u.buffered=!0;var f=u.body.endList=s.endList||u.body.endList;f&&(this.endListFragments[u.body.type]=u),ht(u)||this.removeParts(s.sn-1,s.type)}else this.removeFragment(u.body)}}},n.removeParts=function(e,t){var r=this.activePartLists[t];r&&(this.activePartLists[t]=r.filter(function(s){return s.fragment.sn>=e}))},n.fragBuffered=function(e,t){var r=We(e),s=this.fragments[r];!s&&t&&(s=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),s&&(s.loaded=null,s.buffered=!0)},n.getBufferedTimes=function(e,t,r,s){for(var o={time:[],partial:r},l=e.start,u=e.end,d=e.minEndPTS||u,f=e.maxStartPTS||l,h=0;h<s.length;h++){var c=s.start(h)-this.bufferPadding,v=s.end(h)+this.bufferPadding;if(f>=c&&d<=v){o.time.push({startPTS:Math.max(l,s.start(h)),endPTS:Math.min(u,s.end(h))});break}else if(l<v&&u>c){var g=Math.max(l,s.start(h)),m=Math.min(u,s.end(h));m>g&&(o.partial=!0,o.time.push({startPTS:g,endPTS:m}))}else if(u<=c)break}return o},n.getPartialFragment=function(e){var t=null,r,s,o,l=0,u=this.bufferPadding,d=this.fragments;return Object.keys(d).forEach(function(f){var h=d[f];h&&ht(h)&&(s=h.body.start-u,o=h.body.end+u,e>=s&&e<=o&&(r=Math.min(e-s,o-e),l<=r&&(t=h.body,l=r)))}),t},n.isEndListAppended=function(e){var t=this.endListFragments[e];return t!==void 0&&(t.buffered||ht(t))},n.getState=function(e){var t=We(e),r=this.fragments[t];return r?r.buffered?ht(r)?Ee.PARTIAL:Ee.OK:Ee.APPENDING:Ee.NOT_LOADED},n.isTimeBuffered=function(e,t,r){for(var s,o,l=0;l<r.length;l++){if(s=r.start(l)-this.bufferPadding,o=r.end(l)+this.bufferPadding,e>=s&&t<=o)return!0;if(t<=s)return!1}return!1},n.onFragLoaded=function(e,t){var r=t.frag,s=t.part;if(!(r.sn==="initSegment"||r.bitrateTest)){var o=s?null:t,l=We(r);this.fragments[l]={body:r,appendedPTS:null,loaded:o,buffered:!1,range:Object.create(null)}}},n.onBufferAppended=function(e,t){var r=this,s=t.frag,o=t.part,l=t.timeRanges;if(s.sn!=="initSegment"){var u=s.type;if(o){var d=this.activePartLists[u];d||(this.activePartLists[u]=d=[]),d.push(o)}this.timeRanges=l,Object.keys(l).forEach(function(f){var h=l[f];r.detectEvictedFragments(f,h,u,o)})}},n.onFragBuffered=function(e,t){this.detectPartialFragments(t)},n.hasFragment=function(e){var t=We(e);return!!this.fragments[t]},n.hasParts=function(e){var t;return!!((t=this.activePartLists[e])!=null&&t.length)},n.removeFragmentsInRange=function(e,t,r,s,o){var l=this;s&&!this.hasGaps||Object.keys(this.fragments).forEach(function(u){var d=l.fragments[u];if(d){var f=d.body;f.type!==r||s&&!f.gap||f.start<t&&f.end>e&&(d.buffered||o)&&l.removeFragment(f)}})},n.removeFragment=function(e){var t=We(e);e.stats.loaded=0,e.clearElementaryStreamInfo();var r=this.activePartLists[e.type];if(r){var s=e.sn;this.activePartLists[e.type]=r.filter(function(o){return o.fragment.sn!==s})}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]},n.removeAllFragments=function(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1},a}();function ht(a){var n,i,e;return a.buffered&&(a.body.gap||((n=a.range.video)==null?void 0:n.partial)||((i=a.range.audio)==null?void 0:i.partial)||((e=a.range.audiovideo)==null?void 0:e.partial))}function We(a){return a.type+"_"+a.level+"_"+a.sn}var oi=Math.pow(2,17),qa=function(){function a(i){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=i}var n=a.prototype;return n.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},n.abort=function(){this.loader&&this.loader.abort()},n.load=function(e,t){var r=this,s=e.url;if(!s)return Promise.reject(new we({type:V.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a "+(s?"part list":"url")),networkDetails:null}));this.abort();var o=this.config,l=o.fLoader,u=o.loader;return new Promise(function(d,f){if(r.loader&&r.loader.destroy(),e.gap)if(e.tagList.some(function(m){return m[0]==="GAP"})){f(ui(e));return}else e.gap=!1;var h=r.loader=e.loader=l?new l(o):new u(o),c=li(e),v=zr(o.fragLoadPolicy.default),g={loadPolicy:v,timeout:v.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:oi};e.stats=h.stats,h.load(c,g,{onSuccess:function(p,y,E,S){r.resetLoader(e,h);var L=p.data;E.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(L.slice(0,16)),L=L.slice(16)),d({frag:e,part:null,payload:L,networkDetails:S})},onError:function(p,y,E,S){r.resetLoader(e,h),f(new we({type:V.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:se({url:s,data:void 0},p),error:new Error("HTTP Error "+p.code+" "+p.text),networkDetails:E,stats:S}))},onAbort:function(p,y,E){r.resetLoader(e,h),f(new we({type:V.NETWORK_ERROR,details:D.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:E,stats:p}))},onTimeout:function(p,y,E){r.resetLoader(e,h),f(new we({type:V.NETWORK_ERROR,details:D.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error("Timeout after "+g.timeout+"ms"),networkDetails:E,stats:p}))},onProgress:function(p,y,E,S){t&&t({frag:e,part:null,payload:E,networkDetails:S})}})})},n.loadPart=function(e,t,r){var s=this;this.abort();var o=this.config,l=o.fLoader,u=o.loader;return new Promise(function(d,f){if(s.loader&&s.loader.destroy(),e.gap||t.gap){f(ui(e,t));return}var h=s.loader=e.loader=l?new l(o):new u(o),c=li(e,t),v=zr(o.fragLoadPolicy.default),g={loadPolicy:v,timeout:v.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:oi};t.stats=h.stats,h.load(c,g,{onSuccess:function(p,y,E,S){s.resetLoader(e,h),s.updateStatsFromPart(e,t);var L={frag:e,part:t,payload:p.data,networkDetails:S};r(L),d(L)},onError:function(p,y,E,S){s.resetLoader(e,h),f(new we({type:V.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:se({url:c.url,data:void 0},p),error:new Error("HTTP Error "+p.code+" "+p.text),networkDetails:E,stats:S}))},onAbort:function(p,y,E){e.stats.aborted=t.stats.aborted,s.resetLoader(e,h),f(new we({type:V.NETWORK_ERROR,details:D.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:E,stats:p}))},onTimeout:function(p,y,E){s.resetLoader(e,h),f(new we({type:V.NETWORK_ERROR,details:D.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error("Timeout after "+g.timeout+"ms"),networkDetails:E,stats:p}))}})})},n.updateStatsFromPart=function(e,t){var r=e.stats,s=t.stats,o=s.total;if(r.loaded+=s.loaded,o){var l=Math.round(e.duration/t.duration),u=Math.min(Math.round(r.loaded/o),l),d=l-u,f=d*Math.round(r.loaded/u);r.total=r.loaded+f}else r.total=Math.max(r.loaded,r.total);var h=r.loading,c=s.loading;h.start?h.first+=c.first-c.start:(h.start=c.start,h.first=c.first),h.end=c.end},n.resetLoader=function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()},a}();function li(a,n){n===void 0&&(n=null);var i=n||a,e={frag:a,part:n,responseType:"arraybuffer",url:i.url,headers:{},rangeStart:0,rangeEnd:0},t=i.byteRangeStartOffset,r=i.byteRangeEndOffset;if(M(t)&&M(r)){var s,o=t,l=r;if(a.sn==="initSegment"&&((s=a.decryptdata)==null?void 0:s.method)==="AES-128"){var u=r-t;u%16&&(l=r+(16-u%16)),t!==0&&(e.resetIV=!0,o=t-16)}e.rangeStart=o,e.rangeEnd=l}return e}function ui(a,n){var i=new Error("GAP "+(a.gap?"tag":"attribute")+" found"),e={type:V.MEDIA_ERROR,details:D.FRAG_GAP,fatal:!1,frag:a,error:i,networkDetails:null};return n&&(e.part=n),(n||a).stats.aborted=!0,new we(e)}var we=function(a){_e(n,a);function n(i){var e;return e=a.call(this,i.error.message)||this,e.data=void 0,e.data=i,e}return n}(Ze(Error)),ja=function(){function a(i){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=i}var n=a.prototype;return n.abort=function(e){for(var t in this.keyUriToKeyInfo){var r=this.keyUriToKeyInfo[t].loader;if(r){var s;if(e&&e!==((s=r.context)==null?void 0:s.frag.type))return;r.abort()}}},n.detach=function(){for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}},n.destroy=function(){this.detach();for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}},n.createKeyLoadError=function(e,t,r,s,o){return t===void 0&&(t=D.KEY_LOAD_ERROR),new we({type:V.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:o,error:r,networkDetails:s})},n.loadClear=function(e,t){var r=this;if(this.emeController&&this.config.emeEnabled)for(var s=e.sn,o=e.cc,l=function(){var f=t[u];if(o<=f.cc&&(s==="initSegment"||f.sn==="initSegment"||s<f.sn))return r.emeController.selectKeySystemFormat(f).then(function(h){f.setKeyFormat(h)}),1},u=0;u<t.length&&!l();u++);},n.load=function(e){var t=this;return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then(function(r){return t.loadInternal(e,r)}):this.loadInternal(e)},n.loadInternal=function(e,t){var r,s;t&&e.setKeyFormat(t);var o=e.decryptdata;if(!o){var l=new Error(t?"Expected frag.decryptdata to be defined after setting format "+t:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,D.KEY_LOAD_ERROR,l))}var u=o.uri;if(!u)return Promise.reject(this.createKeyLoadError(e,D.KEY_LOAD_ERROR,new Error('Invalid key URI: "'+u+'"')));var d=this.keyUriToKeyInfo[u];if((r=d)!=null&&r.decryptdata.key)return o.key=d.decryptdata.key,Promise.resolve({frag:e,keyInfo:d});if((s=d)!=null&&s.keyLoadPromise){var f;switch((f=d.mediaKeySessionContext)==null?void 0:f.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return d.keyLoadPromise.then(function(h){return o.key=h.keyInfo.decryptdata.key,{frag:e,keyInfo:d}})}}switch(d=this.keyUriToKeyInfo[u]={decryptdata:o,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},o.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return o.keyFormat==="identity"?this.loadKeyHTTP(d,e):this.loadKeyEME(d,e);case"AES-128":return this.loadKeyHTTP(d,e);default:return Promise.reject(this.createKeyLoadError(e,D.KEY_LOAD_ERROR,new Error('Key supplied with unsupported METHOD: "'+o.method+'"')))}},n.loadKeyEME=function(e,t){var r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var s=this.emeController.loadKey(r);if(s)return(e.keyLoadPromise=s.then(function(o){return e.mediaKeySessionContext=o,r})).catch(function(o){throw e.keyLoadPromise=null,o})}return Promise.resolve(r)},n.loadKeyHTTP=function(e,t){var r=this,s=this.config,o=s.loader,l=new o(s);return t.keyLoader=e.loader=l,e.keyLoadPromise=new Promise(function(u,d){var f={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},h=s.keyLoadPolicy.default,c={loadPolicy:h,timeout:h.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},v={onSuccess:function(m,p,y,E){var S=y.frag,L=y.keyInfo,_=y.url;if(!S.decryptdata||L!==r.keyUriToKeyInfo[_])return d(r.createKeyLoadError(S,D.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),E));L.decryptdata.key=S.decryptdata.key=new Uint8Array(m.data),S.keyLoader=null,L.loader=null,u({frag:S,keyInfo:L})},onError:function(m,p,y,E){r.resetLoader(p),d(r.createKeyLoadError(t,D.KEY_LOAD_ERROR,new Error("HTTP Error "+m.code+" loading key "+m.text),y,se({url:f.url,data:void 0},m)))},onTimeout:function(m,p,y){r.resetLoader(p),d(r.createKeyLoadError(t,D.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),y))},onAbort:function(m,p,y){r.resetLoader(p),d(r.createKeyLoadError(t,D.INTERNAL_ABORTED,new Error("key loading aborted"),y))}};l.load(f,c,v)})},n.resetLoader=function(e){var t=e.frag,r=e.keyInfo,s=e.url,o=r.loader;t.keyLoader===o&&(t.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[s],o&&o.destroy()},a}(),Xa=function(){function a(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var n=a.prototype;return n.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},n.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},n.onHandlerDestroyed=function(){},n.hasInterval=function(){return!!this._tickInterval},n.hasNextTick=function(){return!!this._tickTimer},n.setInterval=function(e){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)},n.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},n.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},n.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},n.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},n.doTick=function(){},a}(),fi=function(n,i,e,t,r,s){t===void 0&&(t=0),r===void 0&&(r=-1),s===void 0&&(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=ct(),this.buffering={audio:ct(),video:ct(),audiovideo:ct()},this.level=n,this.sn=i,this.id=e,this.size=t,this.part=r,this.partial=s};function ct(){return{start:0,executeStart:0,executeEnd:0,end:0}}function vt(a,n){for(var i=0,e=a.length;i<e;i++){var t;if(((t=a[i])==null?void 0:t.cc)===n)return a[i]}return null}function za(a,n,i){return!!(n&&(i.endCC>i.startCC||a&&a.cc<i.startCC))}function $a(a,n){var i=a.fragments,e=n.fragments;if(!e.length||!i.length){R.log("No fragments to align");return}var t=vt(i,e[0].cc);if(!t||t&&!t.startPTS){R.log("No frag in previous level to align on");return}return t}function di(a,n){if(a){var i=a.start+n;a.start=a.startPTS=i,a.endPTS=i+a.duration}}function hi(a,n){for(var i=n.fragments,e=0,t=i.length;e<t;e++)di(i[e],a);n.fragmentHint&&di(n.fragmentHint,a),n.alignedSliding=!0}function Qa(a,n,i){n&&(Za(a,i,n),!i.alignedSliding&&n&&Ja(i,n),!i.alignedSliding&&n&&!i.skippedSegments&&Wr(n,i))}function Za(a,n,i){if(za(a,i,n)){var e=$a(i,n);e&&M(e.start)&&(R.log("Adjusting PTS using last level due to CC increase within current level "+n.url),hi(e.start,n))}}function Ja(a,n){if(!(!a.hasProgramDateTime||!n.hasProgramDateTime)){var i=a.fragments,e=n.fragments;if(!(!i.length||!e.length)){var t,r,s=Math.min(n.endCC,a.endCC);n.startCC<s&&a.startCC<s&&(t=vt(e,s),r=vt(i,s)),(!t||!r)&&(t=e[Math.floor(e.length/2)],r=vt(i,t.cc)||i[Math.floor(i.length/2)]);var o=t.programDateTime,l=r.programDateTime;if(!(!o||!l)){var u=(l-o)/1e3-(r.start-t.start);hi(u,a)}}}}var es=function(){function a(i,e){this.subtle=void 0,this.aesIV=void 0,this.subtle=i,this.aesIV=e}var n=a.prototype;return n.decrypt=function(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)},a}(),ts=function(){function a(i,e){this.subtle=void 0,this.key=void 0,this.subtle=i,this.key=e}var n=a.prototype;return n.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},a}();function rs(a){var n=a.byteLength,i=n&&new DataView(a.buffer).getUint8(n-1);return i?Ue(a,0,n-i):a}var is=function(){function a(){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 n=a.prototype;return n.uint8ArrayToUint32Array_=function(e){for(var t=new DataView(e),r=new Uint32Array(4),s=0;s<4;s++)r[s]=t.getUint32(s*4);return r},n.initTable=function(){var e=this.sBox,t=this.invSBox,r=this.subMix,s=r[0],o=r[1],l=r[2],u=r[3],d=this.invSubMix,f=d[0],h=d[1],c=d[2],v=d[3],g=new Uint32Array(256),m=0,p=0,y=0;for(y=0;y<256;y++)y<128?g[y]=y<<1:g[y]=y<<1^283;for(y=0;y<256;y++){var E=p^p<<1^p<<2^p<<3^p<<4;E=E>>>8^E&255^99,e[m]=E,t[E]=m;var S=g[m],L=g[S],_=g[L],A=g[E]*257^E*16843008;s[m]=A<<24|A>>>8,o[m]=A<<16|A>>>16,l[m]=A<<8|A>>>24,u[m]=A,A=_*16843009^L*65537^S*257^m*16843008,f[E]=A<<24|A>>>8,h[E]=A<<16|A>>>16,c[E]=A<<8|A>>>24,v[E]=A,m?(m=S^g[g[g[_^S]]],p^=g[g[p]]):m=p=1}},n.expandKey=function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,s=0;s<t.length&&r;)r=t[s]===this.key[s],s++;if(!r){this.key=t;var o=this.keySize=t.length;if(o!==4&&o!==6&&o!==8)throw new Error("Invalid aes key size="+o);var l=this.ksRows=(o+6+1)*4,u,d,f=this.keySchedule=new Uint32Array(l),h=this.invKeySchedule=new Uint32Array(l),c=this.sBox,v=this.rcon,g=this.invSubMix,m=g[0],p=g[1],y=g[2],E=g[3],S,L;for(u=0;u<l;u++){if(u<o){S=f[u]=t[u];continue}L=S,u%o===0?(L=L<<8|L>>>24,L=c[L>>>24]<<24|c[L>>>16&255]<<16|c[L>>>8&255]<<8|c[L&255],L^=v[u/o|0]<<24):o>6&&u%o===4&&(L=c[L>>>24]<<24|c[L>>>16&255]<<16|c[L>>>8&255]<<8|c[L&255]),f[u]=S=(f[u-o]^L)>>>0}for(d=0;d<l;d++)u=l-d,d&3?L=f[u]:L=f[u-4],d<4||u<=4?h[d]=L:h[d]=m[c[L>>>24]]^p[c[L>>>16&255]]^y[c[L>>>8&255]]^E[c[L&255]],h[d]=h[d]>>>0}},n.networkToHostOrderSwap=function(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24},n.decrypt=function(e,t,r){for(var s=this.keySize+6,o=this.invKeySchedule,l=this.invSBox,u=this.invSubMix,d=u[0],f=u[1],h=u[2],c=u[3],v=this.uint8ArrayToUint32Array_(r),g=v[0],m=v[1],p=v[2],y=v[3],E=new Int32Array(e),S=new Int32Array(E.length),L,_,A,T,b,I,P,C,w,O,F,H,U,W,K=this.networkToHostOrderSwap;t<E.length;){for(w=K(E[t]),O=K(E[t+1]),F=K(E[t+2]),H=K(E[t+3]),b=w^o[0],I=H^o[1],P=F^o[2],C=O^o[3],U=4,W=1;W<s;W++)L=d[b>>>24]^f[I>>16&255]^h[P>>8&255]^c[C&255]^o[U],_=d[I>>>24]^f[P>>16&255]^h[C>>8&255]^c[b&255]^o[U+1],A=d[P>>>24]^f[C>>16&255]^h[b>>8&255]^c[I&255]^o[U+2],T=d[C>>>24]^f[b>>16&255]^h[I>>8&255]^c[P&255]^o[U+3],b=L,I=_,P=A,C=T,U=U+4;L=l[b>>>24]<<24^l[I>>16&255]<<16^l[P>>8&255]<<8^l[C&255]^o[U],_=l[I>>>24]<<24^l[P>>16&255]<<16^l[C>>8&255]<<8^l[b&255]^o[U+1],A=l[P>>>24]<<24^l[C>>16&255]<<16^l[b>>8&255]<<8^l[I&255]^o[U+2],T=l[C>>>24]<<24^l[b>>16&255]<<16^l[I>>8&255]<<8^l[P&255]^o[U+3],S[t]=K(L^g),S[t+1]=K(T^m),S[t+2]=K(A^p),S[t+3]=K(_^y),g=w,m=O,p=F,y=H,t=t+4}return S.buffer},a}(),ns=16,Kt=function(){function a(i,e){var t=e===void 0?{}:e,r=t.removePKCS7Padding,s=r===void 0?!0:r;if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=i.enableSoftwareAES,this.removePKCS7Padding=s,s)try{var o=self.crypto;o&&(this.subtle=o.subtle||o.webkitSubtle)}catch{}this.useSoftware=!this.subtle}var n=a.prototype;return n.destroy=function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},n.isSync=function(){return this.useSoftware},n.flush=function(){var e=this.currentResult,t=this.remainderData;if(!e||t)return this.reset(),null;var r=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?rs(r):r},n.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},n.decrypt=function(e,t,r){var s=this;return this.useSoftware?new Promise(function(o,l){s.softwareDecrypt(new Uint8Array(e),t,r);var u=s.flush();u?o(u.buffer):l(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,r)},n.softwareDecrypt=function(e,t,r){var s=this.currentIV,o=this.currentResult,l=this.remainderData;this.logOnce("JS AES decrypt"),l&&(e=Le(l,e),this.remainderData=null);var u=this.getValidChunk(e);if(!u.length)return null;s&&(r=s);var d=this.softwareDecrypter;d||(d=this.softwareDecrypter=new is),d.expandKey(t);var f=o;return this.currentResult=d.decrypt(u.buffer,0,r),this.currentIV=Ue(u,-16).buffer,f||null},n.webCryptoDecrypt=function(e,t,r){var s=this;if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,r));this.key=t,this.fastAesKey=new ts(this.subtle,t)}return this.fastAesKey.expandKey().then(function(o){if(!s.subtle)return Promise.reject(new Error("web crypto not initialized"));s.logOnce("WebCrypto AES decrypt");var l=new es(s.subtle,new Uint8Array(r));return l.decrypt(e.buffer,o)}).catch(function(o){return R.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+o.name+": "+o.message),s.onWebCryptoError(e,t,r)})},n.onWebCryptoError=function(e,t,r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r);var s=this.flush();if(s)return s.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")},n.getValidChunk=function(e){var t=e,r=e.length-e.length%ns;return r!==e.length&&(t=Ue(e,0,r),this.remainderData=Ue(e,r)),t},n.logOnce=function(e){this.logEnabled&&(R.log("[decrypter]: "+e),this.logEnabled=!1)},a}(),as={toString:function(n){for(var i="",e=n.length,t=0;t<e;t++)i+="["+n.start(t).toFixed(3)+"-"+n.end(t).toFixed(3)+"]";return i}},k={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"},ss=function(a){_e(n,a);function n(e,t,r,s,o){var l;return l=a.call(this)||this,l.hls=void 0,l.fragPrevious=null,l.fragCurrent=null,l.fragmentTracker=void 0,l.transmuxer=null,l._state=k.STOPPED,l.playlistType=void 0,l.media=null,l.mediaBuffer=null,l.config=void 0,l.bitrateTest=!1,l.lastCurrentTime=0,l.nextLoadPosition=0,l.startPosition=0,l.startTimeOffset=null,l.loadedmetadata=!1,l.retryDate=0,l.levels=null,l.fragmentLoader=void 0,l.keyLoader=void 0,l.levelLastLoaded=null,l.startFragRequested=!1,l.decrypter=void 0,l.initPTS=[],l.onvseeking=null,l.onvended=null,l.logPrefix="",l.log=void 0,l.warn=void 0,l.playlistType=o,l.logPrefix=s,l.log=R.log.bind(R,s+":"),l.warn=R.warn.bind(R,s+":"),l.hls=e,l.fragmentLoader=new qa(e.config),l.keyLoader=r,l.fragmentTracker=t,l.config=e.config,l.decrypter=new Kt(e.config),e.on(x.MANIFEST_LOADED,l.onManifestLoaded,$i(l)),l}var i=n.prototype;return i.doTick=function(){this.onTickEnd()},i.onTickEnd=function(){},i.startLoad=function(t){},i.stopLoad=function(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);var t=this.fragCurrent;t!=null&&t.loader&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=k.STOPPED},i._streamEnded=function(t,r){if(r.live||t.nextStart||!t.end||!this.media)return!1;var s=r.partList;if(s!=null&&s.length){var o=s[s.length-1],l=le.isBuffered(this.media,o.start+o.duration/2);return l}var u=r.fragments[r.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(u)},i.getLevelDetails=function(){if(this.levels&&this.levelLastLoaded!==null){var t;return(t=this.levelLastLoaded)==null?void 0:t.details}},i.onMediaAttached=function(t,r){var s=this.media=this.mediaBuffer=r.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),s.addEventListener("seeking",this.onvseeking),s.addEventListener("ended",this.onvended);var o=this.config;this.levels&&o.autoStartLoad&&this.state===k.STOPPED&&this.startLoad(o.startPosition)},i.onMediaDetaching=function(){var t=this.media;t!=null&&t.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),t&&this.onvseeking&&this.onvended&&(t.removeEventListener("seeking",this.onvseeking),t.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},i.onMediaSeeking=function(){var t=this.config,r=this.fragCurrent,s=this.media,o=this.mediaBuffer,l=this.state,u=s?s.currentTime:0,d=le.bufferInfo(o||s,u,t.maxBufferHole);if(this.log("media seeking to "+(M(u)?u.toFixed(3):u)+", state: "+l),this.state===k.ENDED)this.resetLoadingState();else if(r){var f=t.maxFragLookUpTolerance,h=r.start-f,c=r.start+r.duration+f;if(!d.len||c<d.start||h>d.end){var v=u>c;(u<h||v)&&(v&&r.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),r.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}s&&(this.fragmentTracker.removeFragmentsInRange(u,1/0,this.playlistType,!0),this.lastCurrentTime=u),!this.loadedmetadata&&!d.len&&(this.nextLoadPosition=this.startPosition=u),this.tickImmediate()},i.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},i.onManifestLoaded=function(t,r){this.startTimeOffset=r.startTimeOffset,this.initPTS=[]},i.onHandlerDestroying=function(){this.hls.off(x.MANIFEST_LOADED,this.onManifestLoaded,this),this.stopLoad(),a.prototype.onHandlerDestroying.call(this),this.hls=null},i.onHandlerDestroyed=function(){this.state=k.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,a.prototype.onHandlerDestroyed.call(this)},i.loadFragment=function(t,r,s){this._loadFragForPlayback(t,r,s)},i._loadFragForPlayback=function(t,r,s){var o=this,l=function(d){if(o.fragContextChanged(t)){o.warn("Fragment "+t.sn+(d.part?" p: "+d.part.index:"")+" of level "+t.level+" was dropped during download."),o.fragmentTracker.removeFragment(t);return}t.stats.chunkCount++,o._handleFragmentLoadProgress(d)};this._doFragLoad(t,r,s,l).then(function(u){if(u){var d=o.state;if(o.fragContextChanged(t)){(d===k.FRAG_LOADING||!o.fragCurrent&&d===k.PARSING)&&(o.fragmentTracker.removeFragment(t),o.state=k.IDLE);return}"payload"in u&&(o.log("Loaded fragment "+t.sn+" of level "+t.level),o.hls.trigger(x.FRAG_LOADED,u)),o._handleFragmentLoadComplete(u)}}).catch(function(u){o.state===k.STOPPED||o.state===k.ERROR||(o.warn("Frag error: "+(u?.message||u)),o.resetFragmentLoading(t))})},i.clearTrackerIfNeeded=function(t){var r,s=this.fragmentTracker,o=s.getState(t);if(o===Ee.APPENDING){var l=t.type,u=this.getFwdBufferInfo(this.mediaBuffer,l),d=Math.max(t.duration,u?u.len:this.config.maxBufferLength),f=this.backtrackFragment,h=f?t.sn-f.sn:0;(h===1||this.reduceMaxBufferLength(d,t.duration))&&s.removeFragment(t)}else((r=this.mediaBuffer)==null?void 0:r.buffered.length)===0?s.removeAllFragments():s.hasParts(t.type)&&(s.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type}),s.getState(t)===Ee.PARTIAL&&s.removeFragment(t))},i.checkLiveUpdate=function(t){if(t.updated&&!t.live){var r=t.fragments[t.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:r,part:null,stats:r.stats,id:r.type})}t.fragments[0]||(t.deltaUpdateFailed=!0)},i.flushMainBuffer=function(t,r,s){if(s===void 0&&(s=null),!!(t-r)){var o={startOffset:t,endOffset:r,type:s};this.hls.trigger(x.BUFFER_FLUSHING,o)}},i._loadInitSegment=function(t,r){var s=this;this._doFragLoad(t,r).then(function(o){if(!o||s.fragContextChanged(t)||!s.levels)throw new Error("init load aborted");return o}).then(function(o){var l=s.hls,u=o.payload,d=t.decryptdata;if(u&&u.byteLength>0&&d!=null&&d.key&&d.iv&&d.method==="AES-128"){var f=self.performance.now();return s.decrypter.decrypt(new Uint8Array(u),d.key.buffer,d.iv.buffer).catch(function(h){throw l.trigger(x.ERROR,{type:V.MEDIA_ERROR,details:D.FRAG_DECRYPT_ERROR,fatal:!1,error:h,reason:h.message,frag:t}),h}).then(function(h){var c=self.performance.now();return l.trigger(x.FRAG_DECRYPTED,{frag:t,payload:h,stats:{tstart:f,tdecrypt:c}}),o.payload=h,s.completeInitSegmentLoad(o)})}return s.completeInitSegmentLoad(o)}).catch(function(o){s.state===k.STOPPED||s.state===k.ERROR||(s.warn(o),s.resetFragmentLoading(t))})},i.completeInitSegmentLoad=function(t){var r=this.levels;if(!r)throw new Error("init load aborted, missing levels");var s=t.frag.stats;this.state=k.IDLE,t.frag.data=new Uint8Array(t.payload),s.parsing.start=s.buffering.start=self.performance.now(),s.parsing.end=s.buffering.end=self.performance.now(),this.tick()},i.fragContextChanged=function(t){var r=this.fragCurrent;return!t||!r||t.sn!==r.sn||t.level!==r.level},i.fragBufferedComplete=function(t,r){var s,o,l,u,d=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log("Buffered "+t.type+" sn: "+t.sn+(r?" part: "+r.index:"")+" of "+(this.playlistType===q.MAIN?"level":"track")+" "+t.level+" (frag:["+((s=t.startPTS)!=null?s:NaN).toFixed(3)+"-"+((o=t.endPTS)!=null?o:NaN).toFixed(3)+"] > buffer:"+(d?as.toString(le.getBuffered(d)):"(detached)")+")"),t.sn!=="initSegment"){var f;if(t.type!==q.SUBTITLE){var h=t.elementaryStreams;if(!Object.keys(h).some(function(v){return!!h[v]})){this.state=k.IDLE;return}}var c=(f=this.levels)==null?void 0:f[t.level];c!=null&&c.fragmentError&&(this.log("Resetting level fragment error count of "+c.fragmentError+" on frag buffered"),c.fragmentError=0)}this.state=k.IDLE,d&&(!this.loadedmetadata&&t.type==q.MAIN&&d.buffered.length&&((l=this.fragCurrent)==null?void 0:l.sn)===((u=this.fragPrevious)==null?void 0:u.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},i.seekToStartPos=function(){},i._handleFragmentLoadComplete=function(t){var r=this.transmuxer;if(r){var s=t.frag,o=t.part,l=t.partsLoaded,u=!l||l.length===0||l.some(function(f){return!f}),d=new fi(s.level,s.sn,s.stats.chunkCount+1,0,o?o.index:-1,!u);r.flush(d)}},i._handleFragmentLoadProgress=function(t){},i._doFragLoad=function(t,r,s,o){var l,u=this;s===void 0&&(s=null);var d=r?.details;if(!this.levels||!d)throw new Error("frag load aborted, missing level"+(d?"":" detail")+"s");var f=null;if(t.encrypted&&!((l=t.decryptdata)!=null&&l.key)?(this.log("Loading key for "+t.sn+" of ["+d.startSN+"-"+d.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+t.level),this.state=k.KEY_LOADING,this.fragCurrent=t,f=this.keyLoader.load(t).then(function(y){if(!u.fragContextChanged(y.frag))return u.hls.trigger(x.KEY_LOADED,y),u.state===k.KEY_LOADING&&(u.state=k.IDLE),y}),this.hls.trigger(x.KEY_LOADING,{frag:t}),this.fragCurrent===null&&(f=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!t.encrypted&&d.encryptedFragments.length&&this.keyLoader.loadClear(t,d.encryptedFragments),s=Math.max(t.start,s||0),this.config.lowLatencyMode&&t.sn!=="initSegment"){var h=d.partList;if(h&&o){s>t.end&&d.fragmentHint&&(t=d.fragmentHint);var c=this.getNextPart(h,t,s);if(c>-1){var v=h[c];this.log("Loading part sn: "+t.sn+" p: "+v.index+" cc: "+t.cc+" of playlist ["+d.startSN+"-"+d.endSN+"] parts [0-"+c+"-"+(h.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+t.level+", target: "+parseFloat(s.toFixed(3))),this.nextLoadPosition=v.start+v.duration,this.state=k.FRAG_LOADING;var g;return f?g=f.then(function(y){return!y||u.fragContextChanged(y.frag)?null:u.doFragPartsLoad(t,v,r,o)}).catch(function(y){return u.handleFragLoadError(y)}):g=this.doFragPartsLoad(t,v,r,o).catch(function(y){return u.handleFragLoadError(y)}),this.hls.trigger(x.FRAG_LOADING,{frag:t,part:v,targetBufferTime:s}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):g}else if(!t.url||this.loadedEndOfParts(h,s))return Promise.resolve(null)}}this.log("Loading fragment "+t.sn+" cc: "+t.cc+" "+(d?"of ["+d.startSN+"-"+d.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+t.level+", target: "+parseFloat(s.toFixed(3))),M(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=k.FRAG_LOADING;var m=this.config.progressive,p;return m&&f?p=f.then(function(y){return!y||u.fragContextChanged(y?.frag)?null:u.fragmentLoader.load(t,o)}).catch(function(y){return u.handleFragLoadError(y)}):p=Promise.all([this.fragmentLoader.load(t,m?o:void 0),f]).then(function(y){var E=y[0];return!m&&E&&o&&o(E),E}).catch(function(y){return u.handleFragLoadError(y)}),this.hls.trigger(x.FRAG_LOADING,{frag:t,targetBufferTime:s}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):p},i.doFragPartsLoad=function(t,r,s,o){var l=this;return new Promise(function(u,d){var f,h=[],c=(f=s.details)==null?void 0:f.partList,v=function g(m){l.fragmentLoader.loadPart(t,m,o).then(function(p){h[m.index]=p;var y=p.part;l.hls.trigger(x.FRAG_LOADED,p);var E=Yr(s,t.sn,m.index+1)||qr(c,t.sn,m.index+1);if(E)g(E);else return u({frag:t,part:y,partsLoaded:h})}).catch(d)};v(r)})},i.handleFragLoadError=function(t){if("data"in t){var r=t.data;t.data&&r.details===D.INTERNAL_ABORTED?this.handleFragLoadAborted(r.frag,r.part):this.hls.trigger(x.ERROR,r)}else this.hls.trigger(x.ERROR,{type:V.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null},i._handleTransmuxerFlush=function(t){var r=this.getCurrentContext(t);if(!r||this.state!==k.PARSING){!this.fragCurrent&&this.state!==k.STOPPED&&this.state!==k.ERROR&&(this.state=k.IDLE);return}var s=r.frag,o=r.part,l=r.level,u=self.performance.now();s.stats.parsing.end=u,o&&(o.stats.parsing.end=u),this.updateLevelTiming(s,o,l,t.partial)},i.getCurrentContext=function(t){var r=this.levels,s=this.fragCurrent,o=t.level,l=t.sn,u=t.part;if(!(r!=null&&r[o]))return this.warn("Levels object was unset while buffering fragment "+l+" of level "+o+". The current chunk will not be buffered."),null;var d=r[o],f=u>-1?Yr(d,l,u):null,h=f?f.fragment:oa(d,l,s);return h?(s&&s!==h&&(h.stats=s.stats),{frag:h,part:f,level:d}):null},i.bufferFragmentData=function(t,r,s,o,l){var u;if(!(!t||this.state!==k.PARSING)){var d=t.data1,f=t.data2,h=d;if(d&&f&&(h=Le(d,f)),!!((u=h)!=null&&u.length)){var c={type:t.type,frag:r,part:s,chunkMeta:o,parent:r.type,data:h};if(this.hls.trigger(x.BUFFER_APPENDING,c),t.dropped&&t.independent&&!s){if(l)return;this.flushBufferGap(r)}}}},i.flushBufferGap=function(t){var r=this.media;if(r){if(!le.isBuffered(r,r.currentTime)){this.flushMainBuffer(0,t.start);return}var s=r.currentTime,o=le.bufferInfo(r,s,0),l=t.duration,u=Math.min(this.config.maxFragLookUpTolerance*2,l*.25),d=Math.max(Math.min(t.start-u,o.end-u),s+u);t.start-d>u&&this.flushMainBuffer(d,t.start)}},i.getFwdBufferInfo=function(t,r){var s=this.getLoadPosition();return M(s)?this.getFwdBufferInfoAtPos(t,s,r):null},i.getFwdBufferInfoAtPos=function(t,r,s){var o=this.config.maxBufferHole,l=le.bufferInfo(t,r,o);if(l.len===0&&l.nextStart!==void 0){var u=this.fragmentTracker.getBufferedFrag(r,s);if(u&&l.nextStart<u.end)return le.bufferInfo(t,r,Math.max(l.nextStart,o))}return l},i.getMaxBufferLength=function(t){var r=this.config,s;return t?s=Math.max(8*r.maxBufferSize/t,r.maxBufferLength):s=r.maxBufferLength,Math.min(s,r.maxMaxBufferLength)},i.reduceMaxBufferLength=function(t,r){var s=this.config,o=Math.max(Math.min(t-r,s.maxBufferLength),r),l=Math.max(t-r*3,s.maxMaxBufferLength/2,o);return l>=o?(s.maxMaxBufferLength=l,this.warn("Reduce max buffer length to "+l+"s"),!0):!1},i.getAppendedFrag=function(t,r){var s=this.fragmentTracker.getAppendedFrag(t,q.MAIN);return s&&"fragment"in s?s.fragment:s},i.getNextFragment=function(t,r){var s=r.fragments,o=s.length;if(!o)return null;var l=this.config,u=s[0].start,d;if(r.live){var f=l.initialLiveManifestSize;if(o<f)return this.warn("Not enough fragments to start playback (have: "+o+", need: "+f+")"),null;(!r.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||t<u)&&(d=this.getInitialLiveFragment(r,s),this.startPosition=this.nextLoadPosition=d?this.hls.liveSyncPosition||d.start:t)}else t<=u&&(d=s[0]);if(!d){var h=l.lowLatencyMode?r.partEnd:r.fragmentEnd;d=this.getFragmentAtPosition(t,h,r)}return this.mapToInitFragWhenRequired(d)},i.isLoopLoading=function(t,r){var s=this.fragmentTracker.getState(t);return(s===Ee.OK||s===Ee.PARTIAL&&!!t.gap)&&this.nextLoadPosition>r},i.getNextFragmentLoopLoading=function(t,r,s,o,l){var u=t.gap,d=this.getNextFragment(this.nextLoadPosition,r);if(d===null)return d;if(t=d,u&&t&&!t.gap&&s.nextStart){var f=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,s.nextStart,o);if(f!==null&&s.len+f.len>=l)return this.log('buffer full after gaps in "'+o+'" playlist starting at sn: '+t.sn),null}return t},i.mapToInitFragWhenRequired=function(t){return t!=null&&t.initSegment&&!(t!=null&&t.initSegment.data)&&!this.bitrateTest?t.initSegment:t},i.getNextPart=function(t,r,s){for(var o=-1,l=!1,u=!0,d=0,f=t.length;d<f;d++){var h=t[d];if(u=u&&!h.independent,o>-1&&s<h.start)break;var c=h.loaded;c?o=-1:(l||h.independent||u)&&h.fragment===r&&(o=d),l=c}return o},i.loadedEndOfParts=function(t,r){var s=t[t.length-1];return s&&r>s.start&&s.loaded},i.getInitialLiveFragment=function(t,r){var s=this.fragPrevious,o=null;if(s){if(t.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+s.programDateTime),o=ua(r,s.endProgramDateTime,this.config.maxFragLookUpTolerance)),!o){var l=s.sn+1;if(l>=t.startSN&&l<=t.endSN){var u=r[l-t.startSN];s.cc===u.cc&&(o=u,this.log("Live playlist, switching playlist, load frag with next SN: "+o.sn))}o||(o=ha(r,s.cc),o&&this.log("Live playlist, switching playlist, load frag with same CC: "+o.sn))}}else{var d=this.hls.liveSyncPosition;d!==null&&(o=this.getFragmentAtPosition(d,this.bitrateTest?t.fragmentEnd:t.edge,t))}return o},i.getFragmentAtPosition=function(t,r,s){var o=this.config,l=this.fragPrevious,u=s.fragments,d=s.endSN,f=s.fragmentHint,h=o.maxFragLookUpTolerance,c=s.partList,v=!!(o.lowLatencyMode&&c!=null&&c.length&&f);v&&f&&!this.bitrateTest&&(u=u.concat(f),d=f.sn);var g;if(t<r){var m=t>r-h?0:h;g=Qr(l,u,t,m)}else g=u[u.length-1];if(g){var p=g.sn-s.startSN,y=this.fragmentTracker.getState(g);if((y===Ee.OK||y===Ee.PARTIAL&&g.gap)&&(l=g),l&&g.sn===l.sn&&(!v||c[0].fragment.sn>g.sn)){var E=l&&g.level===l.level;if(E){var S=u[p+1];g.sn<d&&this.fragmentTracker.getState(S)!==Ee.OK?g=S:g=null}}}return g},i.synchronizeToLiveEdge=function(t){var r=this.config,s=this.media;if(s){var o=this.hls.liveSyncPosition,l=s.currentTime,u=t.fragments[0].start,d=t.edge,f=l>=u-r.maxFragLookUpTolerance&&l<=d;if(o!==null&&s.duration>o&&(l<o||!f)){var h=r.liveMaxLatencyDuration!==void 0?r.liveMaxLatencyDuration:r.liveMaxLatencyDurationCount*t.targetduration;(!f&&s.readyState<4||l<d-h)&&(this.loadedmetadata||(this.nextLoadPosition=o),s.readyState&&(this.warn("Playback: "+l.toFixed(3)+" is located too far from the end of live sliding playlist: "+d+", reset currentTime to : "+o.toFixed(3)),s.currentTime=o))}}},i.alignPlaylists=function(t,r,s){var o=t.fragments.length;if(!o)return this.warn("No fragments in live playlist"),0;var l=t.fragments[0].start,u=!r,d=t.alignedSliding&&M(l);if(u||!d&&!l){var f=this.fragPrevious;Qa(f,s,t);var h=t.fragments[0].start;return this.log("Live playlist sliding: "+h.toFixed(2)+" start-sn: "+(r?r.startSN:"na")+"->"+t.startSN+" prev-sn: "+(f?f.sn:"na")+" fragments: "+o),h}return l},i.waitForCdnTuneIn=function(t){var r=3;return t.live&&t.canBlockReload&&t.partTarget&&t.tuneInGoal>Math.max(t.partHoldBack,t.partTarget*r)},i.setStartPosition=function(t,r){var s=this.startPosition;if(s<r&&(s=-1),s===-1||this.lastCurrentTime===-1){var o=this.startTimeOffset!==null,l=o?this.startTimeOffset:t.startTimeOffset;l!==null&&M(l)?(s=r+l,l<0&&(s+=t.totalduration),s=Math.min(Math.max(r,s),r+t.totalduration),this.log("Start time offset "+l+" found in "+(o?"multivariant":"media")+" playlist, adjust startPosition to "+s),this.startPosition=s):t.live?s=this.hls.liveSyncPosition||r:this.startPosition=s=0,this.lastCurrentTime=s}this.nextLoadPosition=s},i.getLoadPosition=function(){var t=this.media,r=0;return this.loadedmetadata&&t?r=t.currentTime:this.nextLoadPosition&&(r=this.nextLoadPosition),r},i.handleFragLoadAborted=function(t,r){this.transmuxer&&t.sn!=="initSegment"&&t.stats.aborted&&(this.warn("Fragment "+t.sn+(r?" part "+r.index:"")+" of level "+t.level+" was aborted"),this.resetFragmentLoading(t))},i.resetFragmentLoading=function(t){(!this.fragCurrent||!this.fragContextChanged(t)&&this.state!==k.FRAG_LOADING_WAITING_RETRY)&&(this.state=k.IDLE)},i.onFragmentOrKeyLoadError=function(t,r){if(r.chunkMeta&&!r.frag){var s=this.getCurrentContext(r.chunkMeta);s&&(r.frag=s.frag)}var o=r.frag;if(!(!o||o.type!==t||!this.levels)){if(this.fragContextChanged(o)){var l;this.warn("Frag load error must match current frag to retry "+o.url+" > "+((l=this.fragCurrent)==null?void 0:l.url));return}var u=r.details===D.FRAG_GAP;u&&this.fragmentTracker.fragBuffered(o,!0);var d=r.errorAction,f=d||{},h=f.action,c=f.retryCount,v=c===void 0?0:c,g=f.retryConfig;if(d&&h===he.RetryRequest&&g){this.resetStartWhenNotLoaded(this.levelLastLoaded);var m=Gt(g,v);this.warn("Fragment "+o.sn+" of "+t+" "+o.level+" errored with "+r.details+", retrying loading "+(v+1)+"/"+g.maxNumRetry+" in "+m+"ms"),d.resolved=!0,this.retryDate=self.performance.now()+m,this.state=k.FRAG_LOADING_WAITING_RETRY}else if(g&&d)if(this.resetFragmentErrors(t),v<g.maxNumRetry)!u&&h!==he.RemoveAlternatePermanently&&(d.resolved=!0);else{R.warn(r.details+" reached or exceeded max retry ("+v+")");return}else d?.action===he.SendAlternateToPenaltyBox?this.state=k.WAITING_LEVEL:this.state=k.ERROR;this.tickImmediate()}},i.reduceLengthAndFlushBuffer=function(t){if(this.state===k.PARSING||this.state===k.PARSED){var r=t.frag,s=t.parent,o=this.getFwdBufferInfo(this.mediaBuffer,s),l=o&&o.len>.5;l&&this.reduceMaxBufferLength(o.len,r?.duration||10);var u=!l;return u&&this.warn("Buffer full error while media.currentTime is not buffered, flush "+s+" buffer"),r&&(this.fragmentTracker.removeFragment(r),this.nextLoadPosition=r.start),this.resetLoadingState(),u}return!1},i.resetFragmentErrors=function(t){t===q.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==k.STOPPED&&(this.state=k.IDLE)},i.afterBufferFlushed=function(t,r,s){if(t){var o=le.getBuffered(t);this.fragmentTracker.detectEvictedFragments(r,o,s),this.state===k.ENDED&&this.resetLoadingState()}},i.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=k.IDLE},i.resetStartWhenNotLoaded=function(t){if(!this.loadedmetadata){this.startFragRequested=!1;var r=t?t.details:null;r!=null&&r.live?(this.startPosition=-1,this.setStartPosition(r,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},i.resetWhenMissingContext=function(t){this.warn("The loading context changed while buffering fragment "+t.sn+" of level "+t.level+". This chunk will not be buffered."),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()},i.removeUnbufferedFrags=function(t){t===void 0&&(t=0),this.fragmentTracker.removeFragmentsInRange(t,1/0,this.playlistType,!1,!0)},i.updateLevelTiming=function(t,r,s,o){var l=this,u,d=s.details;if(!d){this.warn("level.details undefined");return}var f=Object.keys(t.elementaryStreams).reduce(function(c,v){var g=t.elementaryStreams[v];if(g){var m=g.endPTS-g.startPTS;if(m<=0)return l.warn("Could not parse fragment "+t.sn+" "+v+" duration reliably ("+m+")"),c||!1;var p=o?0:Kr(d,t,g.startPTS,g.endPTS,g.startDTS,g.endDTS);return l.hls.trigger(x.LEVEL_PTS_UPDATED,{details:d,level:s,drift:p,type:v,frag:t,start:g.startPTS,end:g.endPTS}),!0}return c},!1);if(!f&&((u=this.transmuxer)==null?void 0:u.error)===null){var h=new Error("Found no media in fragment "+t.sn+" of level "+t.level+" resetting transmuxer to fallback to playlist timing");if(s.fragmentError===0&&(s.fragmentError++,t.gap=!0,this.fragmentTracker.removeFragment(t),this.fragmentTracker.fragBuffered(t,!0)),this.warn(h.message),this.hls.trigger(x.ERROR,{type:V.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,error:h,frag:t,reason:"Found no media in msn "+t.sn+' of level "'+s.url+'"'}),!this.hls)return;this.resetTransmuxer()}this.state=k.PARSED,this.hls.trigger(x.FRAG_PARSED,{frag:t,part:r})},i.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},i.recoverWorkerError=function(t){t.event==="demuxerWorker"&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())},me(n,[{key:"state",get:function(){return this._state},set:function(t){var r=this._state;r!==t&&(this._state=t,this.log(r+"->"+t))}}]),n}(Xa);function ci(){return self.SourceBuffer||self.WebKitSourceBuffer}function vi(){var a=Ge();if(!a)return!1;var n=ci();return!n||n.prototype&&typeof n.prototype.appendBuffer=="function"&&typeof n.prototype.remove=="function"}function os(){if(!vi())return!1;var a=Ge();return typeof a?.isTypeSupported=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(function(n){return a.isTypeSupported(wt(n,"video"))})||["mp4a.40.2","fLaC"].some(function(n){return a.isTypeSupported(wt(n,"audio"))}))}function ls(){var a,n=ci();return typeof(n==null||(a=n.prototype)==null?void 0:a.changeType)=="function"}function Ce(a,n){return a===void 0&&(a=""),n===void 0&&(n=9e4),{type:a,id:-1,pid:-1,inputTimeScale:n,sequenceNumber:-1,samples:[],dropped:0}}var gi=function(){function a(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var n=a.prototype;return n.resetInitSegment=function(e,t,r,s){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},n.resetTimeStamp=function(e){this.initPTS=e,this.resetContiguity()},n.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},n.canParse=function(e,t){return!1},n.appendFrame=function(e,t,r){},n.demux=function(e,t){this.cachedData&&(e=Le(this.cachedData,e),this.cachedData=null);var r=et(e,0),s=r?r.length:0,o,l=this._audioTrack,u=this._id3Track,d=r?vr(r):void 0,f=e.length;for((this.basePTS===null||this.frameIndex===0&&M(d))&&(this.basePTS=us(d,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),r&&r.length>0&&u.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:Ae.audioId3,duration:Number.POSITIVE_INFINITY});s<f;){if(this.canParse(e,s)){var h=this.appendFrame(l,e,s);h?(this.frameIndex++,this.lastPTS=h.sample.pts,s+=h.length,o=s):s=f}else fn(e,s)?(r=et(e,s),u.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:Ae.audioId3,duration:Number.POSITIVE_INFINITY}),s+=r.length,o=s):s++;if(s===f&&o!==f){var c=Ue(e,o);this.cachedData?this.cachedData=Le(this.cachedData,c):this.cachedData=c}}return{audioTrack:l,videoTrack:Ce(),id3Track:u,textTrack:Ce()}},n.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},n.flush=function(e){var t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:Ce(),id3Track:this._id3Track,textTrack:Ce()}},n.destroy=function(){},a}(),us=function(n,i,e){if(M(n))return n*90;var t=e?e.baseTime*9e4/e.timescale:0;return i*9e4+t};function fs(a,n,i,e){var t,r,s,o,l=navigator.userAgent.toLowerCase(),u=e,d=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];t=((n[i+2]&192)>>>6)+1;var f=(n[i+2]&60)>>>2;if(f>d.length-1){var h=new Error("invalid ADTS sampling index:"+f);a.emit(x.ERROR,x.ERROR,{type:V.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!0,error:h,reason:h.message});return}return s=(n[i+2]&1)<<2,s|=(n[i+3]&192)>>>6,R.log("manifest codec:"+e+", ADTS type:"+t+", samplingIndex:"+f),/firefox/i.test(l)?f>=6?(t=5,o=new Array(4),r=f-3):(t=2,o=new Array(2),r=f):l.indexOf("android")!==-1?(t=2,o=new Array(2),r=f):(t=5,o=new Array(4),e&&(e.indexOf("mp4a.40.29")!==-1||e.indexOf("mp4a.40.5")!==-1)||!e&&f>=6?r=f-3:((e&&e.indexOf("mp4a.40.2")!==-1&&(f>=6&&s===1||/vivaldi/i.test(l))||!e&&s===1)&&(t=2,o=new Array(2)),r=f)),o[0]=t<<3,o[0]|=(f&14)>>1,o[1]|=(f&1)<<7,o[1]|=s<<3,t===5&&(o[1]|=(r&14)>>1,o[2]=(r&1)<<7,o[2]|=8,o[3]=0),{config:o,samplerate:d[f],channelCount:s,codec:"mp4a.40."+t,manifestCodec:u}}function mi(a,n){return a[n]===255&&(a[n+1]&246)===240}function pi(a,n){return a[n+1]&1?7:9}function Wt(a,n){return(a[n+3]&3)<<11|a[n+4]<<3|(a[n+5]&224)>>>5}function ds(a,n){return n+5<a.length}function gt(a,n){return n+1<a.length&&mi(a,n)}function hs(a,n){return ds(a,n)&&mi(a,n)&&Wt(a,n)<=a.length-n}function cs(a,n){if(gt(a,n)){var i=pi(a,n);if(n+i>=a.length)return!1;var e=Wt(a,n);if(e<=i)return!1;var t=n+e;return t===a.length||gt(a,t)}return!1}function yi(a,n,i,e,t){if(!a.samplerate){var r=fs(n,i,e,t);if(!r)return;a.config=r.config,a.samplerate=r.samplerate,a.channelCount=r.channelCount,a.codec=r.codec,a.manifestCodec=r.manifestCodec,R.log("parsed codec:"+a.codec+", rate:"+r.samplerate+", channels:"+r.channelCount)}}function Ei(a){return 1024*9e4/a}function vs(a,n){var i=pi(a,n);if(n+i<=a.length){var e=Wt(a,n)-i;if(e>0)return{headerLength:i,frameLength:e}}}function xi(a,n,i,e,t){var r=Ei(a.samplerate),s=e+t*r,o=vs(n,i),l;if(o){var u=o.frameLength,d=o.headerLength,f=d+u,h=Math.max(0,i+f-n.length);h?(l=new Uint8Array(f-d),l.set(n.subarray(i+d,n.length),0)):l=n.subarray(i+d,i+f);var c={unit:l,pts:s};return h||a.samples.push(c),{sample:c,length:f,missing:h}}var v=n.length-i;l=new Uint8Array(v),l.set(n.subarray(i,n.length),0);var g={unit:l,pts:s};return{sample:g,length:v,missing:-1}}var mt=null,gs=[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],ms=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],ps=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],ys=[0,1,1,4];function Ti(a,n,i,e,t){if(!(i+24>n.length)){var r=Si(n,i);if(r&&i+r.frameLength<=n.length){var s=r.samplesPerFrame*9e4/r.sampleRate,o=e+t*s,l={unit:n.subarray(i,i+r.frameLength),pts:o,dts:o};return a.config=[],a.channelCount=r.channelCount,a.samplerate=r.sampleRate,a.samples.push(l),{sample:l,length:r.frameLength,missing:0}}}}function Si(a,n){var i=a[n+1]>>3&3,e=a[n+1]>>1&3,t=a[n+2]>>4&15,r=a[n+2]>>2&3;if(i!==1&&t!==0&&t!==15&&r!==3){var s=a[n+2]>>1&1,o=a[n+3]>>6,l=i===3?3-e:e===3?3:4,u=gs[l*14+t-1]*1e3,d=i===3?0:i===2?1:2,f=ms[d*3+r],h=o===3?1:2,c=ps[i][e],v=ys[e],g=c*8*v,m=Math.floor(c*u/f+s)*v;if(mt===null){var p=navigator.userAgent||"",y=p.match(/Chrome\/(\d+)/i);mt=y?parseInt(y[1]):0}var E=!!mt&&mt<=87;return E&&e===2&&u>=224e3&&o===0&&(a[n+3]=a[n+3]|128),{sampleRate:f,channelCount:h,frameLength:m,samplesPerFrame:g}}}function Yt(a,n){return a[n]===255&&(a[n+1]&224)===224&&(a[n+1]&6)!==0}function Li(a,n){return n+1<a.length&&Yt(a,n)}function Es(a,n){var i=4;return Yt(a,n)&&i<=a.length-n}function Ai(a,n){if(n+1<a.length&&Yt(a,n)){var i=4,e=Si(a,n),t=i;e!=null&&e.frameLength&&(t=e.frameLength);var r=n+t;return r===a.length||Li(a,r)}return!1}var xs=function(a){_e(n,a);function n(e,t){var r;return r=a.call(this)||this,r.observer=void 0,r.config=void 0,r.observer=e,r.config=t,r}var i=n.prototype;return i.resetInitSegment=function(t,r,s,o){a.prototype.resetInitSegment.call(this,t,r,s,o),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:r,duration:o,inputTimeScale:9e4,dropped:0}},n.probe=function(t){if(!t)return!1;var r=et(t,0),s=r?.length||0;if(Ai(t,s))return!1;for(var o=t.length;s<o;s++)if(cs(t,s))return R.log("ADTS sync word found !"),!0;return!1},i.canParse=function(t,r){return hs(t,r)},i.appendFrame=function(t,r,s){yi(t,this.observer,r,s,t.manifestCodec);var o=xi(t,r,s,this.basePTS,this.frameIndex);if(o&&o.missing===0)return o},n}(gi),Ts=/\/emsg[-/]ID3/i,Ss=function(){function a(i,e){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=e}var n=a.prototype;return n.resetTimeStamp=function(){},n.resetInitSegment=function(e,t,r,s){var o=this.videoTrack=Ce("video",1),l=this.audioTrack=Ce("audio",1),u=this.txtTrack=Ce("text",1);if(this.id3Track=Ce("id3",1),this.timeOffset=0,!!(e!=null&&e.byteLength)){var d=Sr(e);if(d.video){var f=d.video,h=f.id,c=f.timescale,v=f.codec;o.id=h,o.timescale=u.timescale=c,o.codec=v}if(d.audio){var g=d.audio,m=g.id,p=g.timescale,y=g.codec;l.id=m,l.timescale=p,l.codec=y}u.id=yr.text,o.sampleDuration=0,o.duration=l.duration=s}},n.resetContiguity=function(){this.remainderData=null},a.probe=function(e){return En(e)},n.demux=function(e,t){this.timeOffset=t;var r=e,s=this.videoTrack,o=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=Le(this.remainderData,e));var l=_n(r);this.remainderData=l.remainder,s.samples=l.valid||new Uint8Array}else s.samples=r;var u=this.extractID3Track(s,t);return o.samples=Lr(t,s),{videoTrack:s,audioTrack:this.audioTrack,id3Track:u,textTrack:this.txtTrack}},n.flush=function(){var e=this.timeOffset,t=this.videoTrack,r=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;var s=this.extractID3Track(t,this.timeOffset);return r.samples=Lr(e,t),{videoTrack:t,audioTrack:Ce(),id3Track:s,textTrack:Ce()}},n.extractID3Track=function(e,t){var r=this.id3Track;if(e.samples.length){var s=G(e.samples,["emsg"]);s&&s.forEach(function(o){var l=Pn(o);if(Ts.test(l.schemeIdUri)){var u=M(l.presentationTime)?l.presentationTime/l.timeScale:t+l.presentationTimeDelta/l.timeScale,d=l.eventDuration===4294967295?Number.POSITIVE_INFINITY:l.eventDuration/l.timeScale;d<=.001&&(d=Number.POSITIVE_INFINITY);var f=l.payload;r.samples.push({data:f,len:f.byteLength,dts:u,pts:u,type:Ae.emsg,duration:d})}})}return r},n.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},n.destroy=function(){},a}(),Ls=function(n,i){var e=0,t=5;i+=t;for(var r=new Uint32Array(1),s=new Uint32Array(1),o=new Uint8Array(1);t>0;){o[0]=n[i];var l=Math.min(t,8),u=8-l;s[0]=4278190080>>>24+u<<u,r[0]=(o[0]&s[0])>>u,e=e?e<<l|r[0]:r[0],i+=1,t-=l}return e},As=function(){function a(){this.VideoSample=null}var n=a.prototype;return n.createVideoSample=function(e,t,r,s){return{key:e,frame:!1,pts:t,dts:r,units:[],debug:s,length:0}},n.getLastNalUnit=function(e){var t,r=this.VideoSample,s;if((!r||r.units.length===0)&&(r=e[e.length-1]),(t=r)!=null&&t.units){var o=r.units;s=o[o.length-1]}return s},n.pushAccessUnit=function(e,t){if(e.units.length&&e.frame){if(e.pts===void 0){var r=t.samples,s=r.length;if(s){var o=r[s-1];e.pts=o.pts,e.dts=o.dts}else{t.dropped++;return}}t.samples.push(e)}e.debug.length&&R.log(e.pts+"/"+e.dts+":"+e.debug)},a}(),Ri=function(){function a(i){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=i,this.bytesAvailable=i.byteLength,this.word=0,this.bitsAvailable=0}var n=a.prototype;return n.loadWord=function(){var e=this.data,t=this.bytesAvailable,r=e.byteLength-t,s=new Uint8Array(4),o=Math.min(4,t);if(o===0)throw new Error("no bytes available");s.set(e.subarray(r,r+o)),this.word=new DataView(s.buffer).getUint32(0),this.bitsAvailable=o*8,this.bytesAvailable-=o},n.skipBits=function(e){var t;e=Math.min(e,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,t=e>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)},n.readBits=function(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;if(e>32&&R.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return t=e-t,t>0&&this.bitsAvailable?r<<t|this.readBits(t):r},n.skipLZ=function(){var e;for(e=0;e<this.bitsAvailable;++e)if(this.word&2147483648>>>e)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()},n.skipUEG=function(){this.skipBits(1+this.skipLZ())},n.skipEG=function(){this.skipBits(1+this.skipLZ())},n.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},n.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},n.readBoolean=function(){return this.readBits(1)===1},n.readUByte=function(){return this.readBits(8)},n.readUShort=function(){return this.readBits(16)},n.readUInt=function(){return this.readBits(32)},n.skipScalingList=function(e){for(var t=8,r=8,s,o=0;o<e;o++)r!==0&&(s=this.readEG(),r=(t+s+256)%256),t=r===0?t:r},n.readSPS=function(){var e=0,t=0,r=0,s=0,o,l,u,d=this.readUByte.bind(this),f=this.readBits.bind(this),h=this.readUEG.bind(this),c=this.readBoolean.bind(this),v=this.skipBits.bind(this),g=this.skipEG.bind(this),m=this.skipUEG.bind(this),p=this.skipScalingList.bind(this);d();var y=d();if(f(5),v(3),d(),m(),y===100||y===110||y===122||y===244||y===44||y===83||y===86||y===118||y===128){var E=h();if(E===3&&v(1),m(),m(),v(1),c())for(l=E!==3?8:12,u=0;u<l;u++)c()&&(u<6?p(16):p(64))}m();var S=h();if(S===0)h();else if(S===1)for(v(1),g(),g(),o=h(),u=0;u<o;u++)g();m(),v(1);var L=h(),_=h(),A=f(1);A===0&&v(1),v(1),c()&&(e=h(),t=h(),r=h(),s=h());var T=[1,1];if(c()&&c()){var b=d();switch(b){case 1:T=[1,1];break;case 2:T=[12,11];break;case 3:T=[10,11];break;case 4:T=[16,11];break;case 5:T=[40,33];break;case 6:T=[24,11];break;case 7:T=[20,11];break;case 8:T=[32,11];break;case 9:T=[80,33];break;case 10:T=[18,11];break;case 11:T=[15,11];break;case 12:T=[64,33];break;case 13:T=[160,99];break;case 14:T=[4,3];break;case 15:T=[3,2];break;case 16:T=[2,1];break;case 255:{T=[d()<<8|d(),d()<<8|d()];break}}}return{width:Math.ceil((L+1)*16-e*2-t*2),height:(2-A)*(_+1)*16-(A?2:4)*(r+s),pixelRatio:T}},n.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},a}(),Rs=function(a){_e(n,a);function n(){return a.apply(this,arguments)||this}var i=n.prototype;return i.parseAVCPES=function(t,r,s,o,l){var u=this,d=this.parseAVCNALu(t,s.data),f=this.VideoSample,h,c=!1;s.data=null,f&&d.length&&!t.audFound&&(this.pushAccessUnit(f,t),f=this.VideoSample=this.createVideoSample(!1,s.pts,s.dts,"")),d.forEach(function(v){var g;switch(v.type){case 1:{var m=!1;h=!0;var p=v.data;if(c&&p.length>4){var y=new Ri(p).readSliceType();(y===2||y===4||y===7||y===9)&&(m=!0)}if(m){var E;(E=f)!=null&&E.frame&&!f.key&&(u.pushAccessUnit(f,t),f=u.VideoSample=null)}f||(f=u.VideoSample=u.createVideoSample(!0,s.pts,s.dts,"")),f.frame=!0,f.key=m;break}case 5:h=!0,(g=f)!=null&&g.frame&&!f.key&&(u.pushAccessUnit(f,t),f=u.VideoSample=null),f||(f=u.VideoSample=u.createVideoSample(!0,s.pts,s.dts,"")),f.key=!0,f.frame=!0;break;case 6:{h=!0,Ar(v.data,1,s.pts,r.samples);break}case 7:{var S,L;h=!0,c=!0;var _=v.data,A=new Ri(_),T=A.readSPS();if(!t.sps||t.width!==T.width||t.height!==T.height||((S=t.pixelRatio)==null?void 0:S[0])!==T.pixelRatio[0]||((L=t.pixelRatio)==null?void 0:L[1])!==T.pixelRatio[1]){t.width=T.width,t.height=T.height,t.pixelRatio=T.pixelRatio,t.sps=[_],t.duration=l;for(var b=_.subarray(1,4),I="avc1.",P=0;P<3;P++){var C=b[P].toString(16);C.length<2&&(C="0"+C),I+=C}t.codec=I}break}case 8:h=!0,t.pps=[v.data];break;case 9:h=!0,t.audFound=!0,f&&u.pushAccessUnit(f,t),f=u.VideoSample=u.createVideoSample(!1,s.pts,s.dts,"");break;case 12:h=!0;break;default:h=!1,f&&(f.debug+="unknown NAL "+v.type+" ");break}if(f&&h){var w=f.units;w.push(v)}}),o&&f&&(this.pushAccessUnit(f,t),this.VideoSample=null)},i.parseAVCNALu=function(t,r){var s=r.byteLength,o=t.naluState||0,l=o,u=[],d=0,f,h,c,v=-1,g=0;for(o===-1&&(v=0,g=r[0]&31,o=0,d=1);d<s;){if(f=r[d++],!o){o=f?0:1;continue}if(o===1){o=f?0:2;continue}if(!f)o=3;else if(f===1){if(h=d-o-1,v>=0){var m={data:r.subarray(v,h),type:g};u.push(m)}else{var p=this.getLastNalUnit(t.samples);p&&(l&&d<=4-l&&p.state&&(p.data=p.data.subarray(0,p.data.byteLength-l)),h>0&&(p.data=Le(p.data,r.subarray(0,h)),p.state=0))}d<s?(c=r[d]&31,v=d,g=c,o=0):o=-1}else o=0}if(v>=0&&o>=0){var y={data:r.subarray(v,s),type:g,state:o};u.push(y)}if(u.length===0){var E=this.getLastNalUnit(t.samples);E&&(E.data=Le(E.data,r))}return t.naluState=o,u},n}(As),bs=function(){function a(i,e,t){this.keyData=void 0,this.decrypter=void 0,this.keyData=t,this.decrypter=new Kt(e,{removePKCS7Padding:!1})}var n=a.prototype;return n.decryptBuffer=function(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)},n.decryptAacSample=function(e,t,r){var s=this,o=e[t].unit;if(!(o.length<=16)){var l=o.subarray(16,o.length-o.length%16),u=l.buffer.slice(l.byteOffset,l.byteOffset+l.length);this.decryptBuffer(u).then(function(d){var f=new Uint8Array(d);o.set(f,16),s.decrypter.isSync()||s.decryptAacSamples(e,t+1,r)})}},n.decryptAacSamples=function(e,t,r){for(;;t++){if(t>=e.length){r();return}if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,r),!this.decrypter.isSync()))return}},n.getAvcEncryptedData=function(e){for(var t=Math.floor((e.length-48)/160)*16+16,r=new Int8Array(t),s=0,o=32;o<e.length-16;o+=160,s+=16)r.set(e.subarray(o,o+16),s);return r},n.getAvcDecryptedUnit=function(e,t){for(var r=new Uint8Array(t),s=0,o=32;o<e.length-16;o+=160,s+=16)e.set(r.subarray(s,s+16),o);return e},n.decryptAvcSample=function(e,t,r,s,o){var l=this,u=Rr(o.data),d=this.getAvcEncryptedData(u);this.decryptBuffer(d.buffer).then(function(f){o.data=l.getAvcDecryptedUnit(u,f),l.decrypter.isSync()||l.decryptAvcSamples(e,t,r+1,s)})},n.decryptAvcSamples=function(e,t,r,s){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length){s();return}for(var o=e[t].units;!(r>=o.length);r++){var l=o[r];if(!(l.data.length<=48||l.type!==1&&l.type!==5)&&(this.decryptAvcSample(e,t,r,s,l),!this.decrypter.isSync()))return}}},a}(),fe=188,Is=function(){function a(i,e,t){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=i,this.config=e,this.typeSupported=t,this.videoParser=new Rs}a.probe=function(e){var t=a.syncOffset(e);return t>0&&R.warn("MPEG2-TS detected but first sync word found @ offset "+t),t!==-1},a.syncOffset=function(e){for(var t=e.length,r=Math.min(fe*5,t-fe)+1,s=0;s<r;){for(var o=!1,l=-1,u=0,d=s;d<t;d+=fe)if(e[d]===71&&(t-d===fe||e[d+fe]===71)){if(u++,l===-1&&(l=d,l!==0&&(r=Math.min(l+fe*99,e.length-fe)+1)),o||(o=qt(e,d)===0),o&&u>1&&(l===0&&u>2||d+fe>r))return l}else{if(u)return-1;break}s++}return-1},a.createTrack=function(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:yr[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}};var n=a.prototype;return n.resetInitSegment=function(e,t,r,s){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=a.createTrack("video"),this._audioTrack=a.createTrack("audio",s),this._id3Track=a.createTrack("id3"),this._txtTrack=a.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=r,this._duration=s},n.resetTimeStamp=function(){},n.resetContiguity=function(){var e=this._audioTrack,t=this._videoTrack,r=this._id3Track;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.remainderData=null},n.demux=function(e,t,r,s){r===void 0&&(r=!1),s===void 0&&(s=!1),r||(this.sampleAes=null);var o,l=this._videoTrack,u=this._audioTrack,d=this._id3Track,f=this._txtTrack,h=l.pid,c=l.pesData,v=u.pid,g=d.pid,m=u.pesData,p=d.pesData,y=null,E=this.pmtParsed,S=this._pmtId,L=e.length;if(this.remainderData&&(e=Le(this.remainderData,e),L=e.length,this.remainderData=null),L<fe&&!s)return this.remainderData=e,{audioTrack:u,videoTrack:l,id3Track:d,textTrack:f};var _=Math.max(0,a.syncOffset(e));L-=(L-_)%fe,L<e.byteLength&&!s&&(this.remainderData=new Uint8Array(e.buffer,L,e.buffer.byteLength-L));for(var A=0,T=_;T<L;T+=fe)if(e[T]===71){var b=!!(e[T+1]&64),I=qt(e,T),P=(e[T+3]&48)>>4,C=void 0;if(P>1){if(C=T+5+e[T+4],C===T+fe)continue}else C=T+4;switch(I){case h:b&&(c&&(o=Ye(c))&&this.videoParser.parseAVCPES(l,f,o,!1,this._duration),c={data:[],size:0}),c&&(c.data.push(e.subarray(C,T+fe)),c.size+=T+fe-C);break;case v:if(b){if(m&&(o=Ye(m)))switch(u.segmentCodec){case"aac":this.parseAACPES(u,o);break;case"mp3":this.parseMPEGPES(u,o);break}m={data:[],size:0}}m&&(m.data.push(e.subarray(C,T+fe)),m.size+=T+fe-C);break;case g:b&&(p&&(o=Ye(p))&&this.parseID3PES(d,o),p={data:[],size:0}),p&&(p.data.push(e.subarray(C,T+fe)),p.size+=T+fe-C);break;case 0:b&&(C+=e[C]+1),S=this._pmtId=_s(e,C);break;case S:{b&&(C+=e[C]+1);var w=Ds(e,C,this.typeSupported,r,this.observer);h=w.videoPid,h>0&&(l.pid=h,l.segmentCodec=w.segmentVideoCodec),v=w.audioPid,v>0&&(u.pid=v,u.segmentCodec=w.segmentAudioCodec),g=w.id3Pid,g>0&&(d.pid=g),y!==null&&!E&&(R.warn("MPEG-TS PMT found at "+T+" after unknown PID '"+y+"'. Backtracking to sync byte @"+_+" to parse all TS packets."),y=null,T=_-188),E=this.pmtParsed=!0;break}case 17:case 8191:break;default:y=I;break}}else A++;A>0&&pt(this.observer,new Error("Found "+A+" TS packet/s that do not start with 0x47")),l.pesData=c,u.pesData=m,d.pesData=p;var O={audioTrack:u,videoTrack:l,id3Track:d,textTrack:f};return s&&this.extractRemainingSamples(O),O},n.flush=function(){var e=this.remainderData;this.remainderData=null;var t;return e?t=this.demux(e,-1,!1,!0):t={videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t},n.extractRemainingSamples=function(e){var t=e.audioTrack,r=e.videoTrack,s=e.id3Track,o=e.textTrack,l=r.pesData,u=t.pesData,d=s.pesData,f;if(l&&(f=Ye(l))?(this.videoParser.parseAVCPES(r,o,f,!0,this._duration),r.pesData=null):r.pesData=l,u&&(f=Ye(u))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,f);break;case"mp3":this.parseMPEGPES(t,f);break}t.pesData=null}else u!=null&&u.size&&R.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=u;d&&(f=Ye(d))?(this.parseID3PES(s,f),s.pesData=null):s.pesData=d},n.demuxSampleAes=function(e,t,r){var s=this.demux(e,r,!0,!this.config.progressive),o=this.sampleAes=new bs(this.observer,this.config,t);return this.decrypt(s,o)},n.decrypt=function(e,t){return new Promise(function(r){var s=e.audioTrack,o=e.videoTrack;s.samples&&s.segmentCodec==="aac"?t.decryptAacSamples(s.samples,0,function(){o.samples?t.decryptAvcSamples(o.samples,0,0,function(){r(e)}):r(e)}):o.samples&&t.decryptAvcSamples(o.samples,0,0,function(){r(e)})})},n.destroy=function(){this._duration=0},n.parseAACPES=function(e,t){var r=0,s=this.aacOverFlow,o=t.data;if(s){this.aacOverFlow=null;var l=s.missing,u=s.sample.unit.byteLength;if(l===-1)o=Le(s.sample.unit,o);else{var d=u-l;s.sample.unit.set(o.subarray(0,l),d),e.samples.push(s.sample),r=s.missing}}var f,h;for(f=r,h=o.length;f<h-1&&!gt(o,f);f++);if(f!==r){var c,v=f<h-1;if(v?c="AAC PES did not start with ADTS header,offset:"+f:c="No ADTS header found in AAC PES",pt(this.observer,new Error(c),v),!v)return}yi(e,this.observer,o,f,this.audioCodec);var g;if(t.pts!==void 0)g=t.pts;else if(s){var m=Ei(e.samplerate);g=s.sample.pts+m}else{R.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var p=0,y;f<h;)if(y=xi(e,o,f,g,p),f+=y.length,y.missing){this.aacOverFlow=y;break}else for(p++;f<h-1&&!gt(o,f);f++);},n.parseMPEGPES=function(e,t){var r=t.data,s=r.length,o=0,l=0,u=t.pts;if(u===void 0){R.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;l<s;)if(Li(r,l)){var d=Ti(e,r,l,u,o);if(d)l+=d.length,o++;else break}else l++},n.parseAC3PES=function(e,t){},n.parseID3PES=function(e,t){if(t.pts===void 0){R.warn("[tsdemuxer]: ID3 PES unknown PTS");return}var r=Te({},t,{type:this._videoTrack?Ae.emsg:Ae.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(r)},a}();function qt(a,n){return((a[n+1]&31)<<8)+a[n+2]}function _s(a,n){return(a[n+10]&31)<<8|a[n+11]}function Ds(a,n,i,e,t){var r={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},s=(a[n+1]&15)<<8|a[n+2],o=n+3+s-4,l=(a[n+10]&15)<<8|a[n+11];for(n+=12+l;n<o;){var u=qt(a,n),d=(a[n+3]&15)<<8|a[n+4];switch(a[n]){case 207:if(!e){jt("ADTS AAC");break}case 15:r.audioPid===-1&&(r.audioPid=u);break;case 21:r.id3Pid===-1&&(r.id3Pid=u);break;case 219:if(!e){jt("H.264");break}case 27:r.videoPid===-1&&(r.videoPid=u,r.segmentVideoCodec="avc");break;case 3:case 4:!i.mpeg&&!i.mp3?R.log("MPEG audio found, not supported in this browser"):r.audioPid===-1&&(r.audioPid=u,r.segmentAudioCodec="mp3");break;case 193:if(!e){jt("AC-3");break}case 129:R.warn("AC-3 in M2TS support not included in build");break;case 6:if(r.audioPid===-1&&d>0)for(var f=n+5,h=d;h>2;){var c=a[f];switch(c){case 106:R.warn("AC-3 in M2TS support not included in build");break}var v=a[f+1]+2;f+=v,h-=v}break;case 194:case 135:return pt(t,new Error("Unsupported EC-3 in M2TS found")),r;case 36:return pt(t,new Error("Unsupported HEVC in M2TS found")),r}n+=d+5}return r}function pt(a,n,i){R.warn("parsing error: "+n.message),a.emit(x.ERROR,x.ERROR,{type:V.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,levelRetry:i,error:n,reason:n.message})}function jt(a){R.log(a+" with AES-128-CBC encryption found in unencrypted stream")}function Ye(a){var n=0,i,e,t,r,s,o=a.data;if(!a||a.size===0)return null;for(;o[0].length<19&&o.length>1;)o[0]=Le(o[0],o[1]),o.splice(1,1);i=o[0];var l=(i[0]<<16)+(i[1]<<8)+i[2];if(l===1){if(e=(i[4]<<8)+i[5],e&&e>a.size-6)return null;var u=i[7];u&192&&(r=(i[9]&14)*536870912+(i[10]&255)*4194304+(i[11]&254)*16384+(i[12]&255)*128+(i[13]&254)/2,u&64?(s=(i[14]&14)*536870912+(i[15]&255)*4194304+(i[16]&254)*16384+(i[17]&255)*128+(i[18]&254)/2,r-s>60*9e4&&(R.warn(Math.round((r-s)/9e4)+"s delta between PTS and DTS, align them"),r=s)):s=r),t=i[8];var d=t+9;if(a.size<=d)return null;a.size-=d;for(var f=new Uint8Array(a.size),h=0,c=o.length;h<c;h++){i=o[h];var v=i.byteLength;if(d)if(d>v){d-=v;continue}else i=i.subarray(d),v-=d,d=0;f.set(i,n),n+=v}return e&&(e-=t+3),{data:f,pts:r,dts:s,len:e}}return null}var Cs=function(a){_e(n,a);function n(){return a.apply(this,arguments)||this}var i=n.prototype;return i.resetInitSegment=function(t,r,s,o){a.prototype.resetInitSegment.call(this,t,r,s,o),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:r,duration:o,inputTimeScale:9e4,dropped:0}},n.probe=function(t){if(!t)return!1;var r=et(t,0),s=r?.length||0;if(r&&t[s]===11&&t[s+1]===119&&vr(r)!==void 0&&Ls(t,s)<=16)return!1;for(var o=t.length;s<o;s++)if(Ai(t,s))return R.log("MPEG Audio sync word found !"),!0;return!1},i.canParse=function(t,r){return Es(t,r)},i.appendFrame=function(t,r,s){if(this.basePTS!==null)return Ti(t,r,s,this.basePTS,this.frameIndex)},n}(gi),bi=function(){function a(){}return a.getSilentFrame=function(i,e){switch(i){case"mp4a.40.2":if(e===1)return new Uint8Array([0,200,0,128,35,128]);if(e===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(e===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(e===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(e===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(e===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(e===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(e===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(e===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}},a}(),Oe=Math.pow(2,32)-1,ce=function(){function a(){}return a.init=function(){a.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var i;for(i in a.types)a.types.hasOwnProperty(i)&&(a.types[i]=[i.charCodeAt(0),i.charCodeAt(1),i.charCodeAt(2),i.charCodeAt(3)]);var e=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),t=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);a.HDLR_TYPES={video:e,audio:t};var r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),s=new Uint8Array([0,0,0,0,0,0,0,0]);a.STTS=a.STSC=a.STCO=s,a.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),a.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),a.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),a.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var o=new Uint8Array([105,115,111,109]),l=new Uint8Array([97,118,99,49]),u=new Uint8Array([0,0,0,1]);a.FTYP=a.box(a.types.ftyp,o,u,o,l),a.DINF=a.box(a.types.dinf,a.box(a.types.dref,r))},a.box=function(i){for(var e=8,t=arguments.length,r=new Array(t>1?t-1:0),s=1;s<t;s++)r[s-1]=arguments[s];for(var o=r.length,l=o;o--;)e+=r[o].byteLength;var u=new Uint8Array(e);for(u[0]=e>>24&255,u[1]=e>>16&255,u[2]=e>>8&255,u[3]=e&255,u.set(i,4),o=0,e=8;o<l;o++)u.set(r[o],e),e+=r[o].byteLength;return u},a.hdlr=function(i){return a.box(a.types.hdlr,a.HDLR_TYPES[i])},a.mdat=function(i){return a.box(a.types.mdat,i)},a.mdhd=function(i,e){e*=i;var t=Math.floor(e/(Oe+1)),r=Math.floor(e%(Oe+1));return a.box(a.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,i>>24&255,i>>16&255,i>>8&255,i&255,t>>24,t>>16&255,t>>8&255,t&255,r>>24,r>>16&255,r>>8&255,r&255,85,196,0,0]))},a.mdia=function(i){return a.box(a.types.mdia,a.mdhd(i.timescale,i.duration),a.hdlr(i.type),a.minf(i))},a.mfhd=function(i){return a.box(a.types.mfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,i&255]))},a.minf=function(i){return i.type==="audio"?a.box(a.types.minf,a.box(a.types.smhd,a.SMHD),a.DINF,a.stbl(i)):a.box(a.types.minf,a.box(a.types.vmhd,a.VMHD),a.DINF,a.stbl(i))},a.moof=function(i,e,t){return a.box(a.types.moof,a.mfhd(i),a.traf(t,e))},a.moov=function(i){for(var e=i.length,t=[];e--;)t[e]=a.trak(i[e]);return a.box.apply(null,[a.types.moov,a.mvhd(i[0].timescale,i[0].duration)].concat(t).concat(a.mvex(i)))},a.mvex=function(i){for(var e=i.length,t=[];e--;)t[e]=a.trex(i[e]);return a.box.apply(null,[a.types.mvex].concat(t))},a.mvhd=function(i,e){e*=i;var t=Math.floor(e/(Oe+1)),r=Math.floor(e%(Oe+1)),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,i&255,t>>24,t>>16&255,t>>8&255,t&255,r>>24,r>>16&255,r>>8&255,r&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return a.box(a.types.mvhd,s)},a.sdtp=function(i){var e=i.samples||[],t=new Uint8Array(4+e.length),r,s;for(r=0;r<e.length;r++)s=e[r].flags,t[r+4]=s.dependsOn<<4|s.isDependedOn<<2|s.hasRedundancy;return a.box(a.types.sdtp,t)},a.stbl=function(i){return a.box(a.types.stbl,a.stsd(i),a.box(a.types.stts,a.STTS),a.box(a.types.stsc,a.STSC),a.box(a.types.stsz,a.STSZ),a.box(a.types.stco,a.STCO))},a.avc1=function(i){var e=[],t=[],r,s,o;for(r=0;r<i.sps.length;r++)s=i.sps[r],o=s.byteLength,e.push(o>>>8&255),e.push(o&255),e=e.concat(Array.prototype.slice.call(s));for(r=0;r<i.pps.length;r++)s=i.pps[r],o=s.byteLength,t.push(o>>>8&255),t.push(o&255),t=t.concat(Array.prototype.slice.call(s));var l=a.box(a.types.avcC,new Uint8Array([1,e[3],e[4],e[5],255,224|i.sps.length].concat(e).concat([i.pps.length]).concat(t))),u=i.width,d=i.height,f=i.pixelRatio[0],h=i.pixelRatio[1];return a.box(a.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,u>>8&255,u&255,d>>8&255,d&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),l,a.box(a.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),a.box(a.types.pasp,new Uint8Array([f>>24,f>>16&255,f>>8&255,f&255,h>>24,h>>16&255,h>>8&255,h&255])))},a.esds=function(i){var e=i.config.length;return new Uint8Array([0,0,0,0,3,23+e,0,1,0,4,15+e,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([e]).concat(i.config).concat([6,1,2]))},a.audioStsd=function(i){var e=i.samplerate;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,i.channelCount,0,16,0,0,0,0,e>>8&255,e&255,0,0])},a.mp4a=function(i){return a.box(a.types.mp4a,a.audioStsd(i),a.box(a.types.esds,a.esds(i)))},a.mp3=function(i){return a.box(a.types[".mp3"],a.audioStsd(i))},a.ac3=function(i){return a.box(a.types["ac-3"],a.audioStsd(i),a.box(a.types.dac3,i.config))},a.stsd=function(i){return i.type==="audio"?i.segmentCodec==="mp3"&&i.codec==="mp3"?a.box(a.types.stsd,a.STSD,a.mp3(i)):i.segmentCodec==="ac3"?a.box(a.types.stsd,a.STSD,a.ac3(i)):a.box(a.types.stsd,a.STSD,a.mp4a(i)):a.box(a.types.stsd,a.STSD,a.avc1(i))},a.tkhd=function(i){var e=i.id,t=i.duration*i.timescale,r=i.width,s=i.height,o=Math.floor(t/(Oe+1)),l=Math.floor(t%(Oe+1));return a.box(a.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,0,0,0,0,o>>24,o>>16&255,o>>8&255,o&255,l>>24,l>>16&255,l>>8&255,l&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,r>>8&255,r&255,0,0,s>>8&255,s&255,0,0]))},a.traf=function(i,e){var t=a.sdtp(i),r=i.id,s=Math.floor(e/(Oe+1)),o=Math.floor(e%(Oe+1));return a.box(a.types.traf,a.box(a.types.tfhd,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,r&255])),a.box(a.types.tfdt,new Uint8Array([1,0,0,0,s>>24,s>>16&255,s>>8&255,s&255,o>>24,o>>16&255,o>>8&255,o&255])),a.trun(i,t.length+16+20+8+16+8+8),t)},a.trak=function(i){return i.duration=i.duration||4294967295,a.box(a.types.trak,a.tkhd(i),a.mdia(i))},a.trex=function(i){var e=i.id;return a.box(a.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},a.trun=function(i,e){var t=i.samples||[],r=t.length,s=12+16*r,o=new Uint8Array(s),l,u,d,f,h,c;for(e+=8+s,o.set([i.type==="video"?1:0,0,15,1,r>>>24&255,r>>>16&255,r>>>8&255,r&255,e>>>24&255,e>>>16&255,e>>>8&255,e&255],0),l=0;l<r;l++)u=t[l],d=u.duration,f=u.size,h=u.flags,c=u.cts,o.set([d>>>24&255,d>>>16&255,d>>>8&255,d&255,f>>>24&255,f>>>16&255,f>>>8&255,f&255,h.isLeading<<2|h.dependsOn,h.isDependedOn<<6|h.hasRedundancy<<4|h.paddingValue<<1|h.isNonSync,h.degradPrio&61440,h.degradPrio&15,c>>>24&255,c>>>16&255,c>>>8&255,c&255],12+16*l);return a.box(a.types.trun,o)},a.initSegment=function(i){a.types||a.init();var e=a.moov(i),t=Le(a.FTYP,e);return t},a}();ce.types=void 0,ce.HDLR_TYPES=void 0,ce.STTS=void 0,ce.STSC=void 0,ce.STCO=void 0,ce.STSZ=void 0,ce.VMHD=void 0,ce.SMHD=void 0,ce.STSD=void 0,ce.FTYP=void 0,ce.DINF=void 0;var Ps=9e4;function ws(a,n,i,e){i===void 0&&(i=1),e===void 0&&(e=!1);var t=a*n*i;return e?Math.round(t):t}function $e(a,n){return n===void 0&&(n=!1),ws(a,1e3,1/Ps,n)}var ks=10*1e3,Ii=1024,Fs=1152,Ms=1536,qe=null,Xt=null,zt=function(){function a(i,e,t,r){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=i,this.config=e,this.typeSupported=t,this.ISGenerated=!1,qe===null){var s=navigator.userAgent||"",o=s.match(/Chrome\/(\d+)/i);qe=o?parseInt(o[1]):0}if(Xt===null){var l=navigator.userAgent.match(/Safari\/(\d+)/i);Xt=l?parseInt(l[1]):0}}var n=a.prototype;return n.destroy=function(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null},n.resetTimeStamp=function(e){R.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e},n.resetNextTimestamp=function(){R.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},n.resetInitSegment=function(){R.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0},n.getVideoStartPts=function(e){var t=!1,r=e.reduce(function(s,o){var l=o.pts-s;return l<-4294967296?(t=!0,be(s,o.pts)):l>0?s:o.pts},e[0].pts);return t&&R.debug("PTS rollover detected"),r},n.remux=function(e,t,r,s,o,l,u,d){var f,h,c,v,g,m,p=o,y=o,E=e.pid>-1,S=t.pid>-1,L=t.samples.length,_=e.samples.length>0,A=u&&L>0||L>1,T=(!E||_)&&(!S||A)||this.ISGenerated||u;if(T){if(this.ISGenerated){var b,I,P,C,w=this.videoTrackConfig;w&&(t.width!==w.width||t.height!==w.height||((b=t.pixelRatio)==null?void 0:b[0])!==((I=w.pixelRatio)==null?void 0:I[0])||((P=t.pixelRatio)==null?void 0:P[1])!==((C=w.pixelRatio)==null?void 0:C[1]))&&this.resetInitSegment()}else c=this.generateIS(e,t,o,l);var O=this.isVideoContiguous,F=-1,H;if(A&&(F=Os(t.samples),!O&&this.config.forceKeyFrameOnDiscontinuity))if(m=!0,F>0){R.warn("[mp4-remuxer]: Dropped "+F+" out of "+L+" video samples due to a missing keyframe");var U=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(F),t.dropped+=F,y+=(t.samples[0].pts-U)/t.inputTimeScale,H=y}else F===-1&&(R.warn("[mp4-remuxer]: No keyframe found out of "+L+" video samples"),m=!1);if(this.ISGenerated){if(_&&A){var W=this.getVideoStartPts(t.samples),K=be(e.samples[0].pts,W)-W,B=K/t.inputTimeScale;p+=Math.max(0,B),y+=Math.max(0,-B)}if(_){if(e.samplerate||(R.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),c=this.generateIS(e,t,o,l)),h=this.remuxAudio(e,p,this.isAudioContiguous,l,S||A||d===q.AUDIO?y:void 0),A){var Q=h?h.endPTS-h.startPTS:0;t.inputTimeScale||(R.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),c=this.generateIS(e,t,o,l)),f=this.remuxVideo(t,y,O,Q)}}else A&&(f=this.remuxVideo(t,y,O,0));f&&(f.firstKeyFrame=F,f.independent=F!==-1,f.firstKeyFramePTS=H)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(g=_i(r,o,this._initPTS,this._initDTS)),s.samples.length&&(v=Di(s,o,this._initPTS))),{audio:h,video:f,initSegment:c,independent:m,text:v,id3:g}},n.generateIS=function(e,t,r,s){var o=e.samples,l=t.samples,u=this.typeSupported,d={},f=this._initPTS,h=!f||s,c="audio/mp4",v,g,m;if(h&&(v=g=1/0),e.config&&o.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":u.mpeg?(c="audio/mpeg",e.codec=""):u.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3";break}d.audio={id:"audio",container:c,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&u.mpeg?new Uint8Array(0):ce.initSegment([e]),metadata:{channelCount:e.channelCount}},h&&(m=e.inputTimeScale,!f||m!==f.timescale?v=g=o[0].pts-Math.round(m*r):h=!1)}if(t.sps&&t.pps&&l.length){if(t.timescale=t.inputTimeScale,d.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:ce.initSegment([t]),metadata:{width:t.width,height:t.height}},h)if(m=t.inputTimeScale,!f||m!==f.timescale){var p=this.getVideoStartPts(l),y=Math.round(m*r);g=Math.min(g,be(l[0].dts,p)-y),v=Math.min(v,p-y)}else h=!1;this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(d).length)return this.ISGenerated=!0,h?(this._initPTS={baseTime:v,timescale:m},this._initDTS={baseTime:g,timescale:m}):v=m=void 0,{tracks:d,initPTS:v,timescale:m}},n.remuxVideo=function(e,t,r,s){var o=e.inputTimeScale,l=e.samples,u=[],d=l.length,f=this._initPTS,h=this.nextAvcDts,c=8,v=this.videoSampleDuration,g,m,p=Number.POSITIVE_INFINITY,y=Number.NEGATIVE_INFINITY,E=!1;if(!r||h===null){var S=t*o,L=l[0].pts-be(l[0].dts,l[0].pts);qe&&h!==null&&Math.abs(S-L-h)<15e3?r=!0:h=S-L}for(var _=f.baseTime*o/f.timescale,A=0;A<d;A++){var T=l[A];T.pts=be(T.pts-_,h),T.dts=be(T.dts-_,h),T.dts<l[A>0?A-1:A].dts&&(E=!0)}E&&l.sort(function(Tt,Vi){var uo=Tt.dts-Vi.dts,fo=Tt.pts-Vi.pts;return uo||fo}),g=l[0].dts,m=l[l.length-1].dts;var b=m-g,I=b?Math.round(b/(d-1)):v||e.inputTimeScale/30;if(r){var P=g-h,C=P>I,w=P<-1;if((C||w)&&(C?R.warn("AVC: "+$e(P,!0)+" ms ("+P+"dts) hole between fragments detected at "+t.toFixed(3)):R.warn("AVC: "+$e(-P,!0)+" ms ("+P+"dts) overlapping between fragments detected at "+t.toFixed(3)),!w||h>=l[0].pts||qe)){g=h;var O=l[0].pts-P;if(C)l[0].dts=g,l[0].pts=O;else for(var F=0;F<l.length&&!(l[F].dts>O);F++)l[F].dts-=P,l[F].pts-=P;R.log("Video: Initial PTS/DTS adjusted: "+$e(O,!0)+"/"+$e(g,!0)+", delta: "+$e(P,!0)+" ms")}}g=Math.max(0,g);for(var H=0,U=0,W=g,K=0;K<d;K++){for(var B=l[K],Q=B.units,j=Q.length,J=0,ee=0;ee<j;ee++)J+=Q[ee].data.length;U+=J,H+=j,B.length=J,B.dts<W?(B.dts=W,W+=I/4|0||1):W=B.dts,p=Math.min(B.pts,p),y=Math.max(B.pts,y)}m=l[d-1].dts;var re=U+4*H+8,Z;try{Z=new Uint8Array(re)}catch(Tt){this.observer.emit(x.ERROR,x.ERROR,{type:V.MUX_ERROR,details:D.REMUX_ALLOC_ERROR,fatal:!1,error:Tt,bytes:re,reason:"fail allocating video mdat "+re});return}var X=new DataView(Z.buffer);X.setUint32(0,re),Z.set(ce.types.mdat,4);for(var Fe=!1,Se=Number.POSITIVE_INFINITY,te=Number.POSITIVE_INFINITY,pe=Number.NEGATIVE_INFINITY,ye=Number.NEGATIVE_INFINITY,ie=0;ie<d;ie++){for(var z=l[ie],xe=z.units,ve=0,de=0,Ve=xe.length;de<Ve;de++){var Ni=xe[de],to=Ni.data,tr=Ni.data.byteLength;X.setUint32(c,tr),c+=4,Z.set(to,c),c+=tr,ve+=4+tr}var Et=void 0;if(ie<d-1)v=l[ie+1].dts-z.dts,Et=l[ie+1].pts-z.pts;else{var Bi=this.config,xt=ie>0?z.dts-l[ie-1].dts:I;if(Et=ie>0?z.pts-l[ie-1].pts:I,Bi.stretchShortVideoTrack&&this.nextAudioPts!==null){var ro=Math.floor(Bi.maxBufferHole*o),rr=(s?p+s*o:this.nextAudioPts)-z.pts;rr>ro?(v=rr-xt,v<0?v=xt:Fe=!0,R.log("[mp4-remuxer]: It is approximately "+rr/90+" ms to the next segment; using duration "+v/90+" ms for the last video frame.")):v=xt}else v=xt}var io=Math.round(z.pts-z.dts);Se=Math.min(Se,v),pe=Math.max(pe,v),te=Math.min(te,Et),ye=Math.max(ye,Et),u.push(new Ci(z.key,v,ve,io))}if(u.length){if(qe){if(qe<70){var Ui=u[0].flags;Ui.dependsOn=2,Ui.isNonSync=0}}else if(Xt&&ye-te<pe-Se&&I/pe<.025&&u[0].cts===0){R.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var ir=g,Ie=0,Gi=u.length;Ie<Gi;Ie++){var Hi=ir+u[Ie].duration,no=ir+u[Ie].cts;if(Ie<Gi-1){var ao=Hi+u[Ie+1].cts;u[Ie].duration=ao-no}else u[Ie].duration=Ie?u[Ie-1].duration:I;u[Ie].cts=0,ir=Hi}}}v=Fe||!v?I:v,this.nextAvcDts=h=m+v,this.videoSampleDuration=v,this.isVideoContiguous=!0;var so=ce.moof(e.sequenceNumber++,g,Te({},e,{samples:u})),oo="video",lo={data1:so,data2:Z,startPTS:p/o,endPTS:(y+v)/o,startDTS:g/o,endDTS:h/o,type:oo,hasAudio:!1,hasVideo:!0,nb:u.length,dropped:e.dropped};return e.samples=[],e.dropped=0,lo},n.getSamplesPerFrame=function(e){switch(e.segmentCodec){case"mp3":return Fs;case"ac3":return Ms;default:return Ii}},n.remuxAudio=function(e,t,r,s,o){var l=e.inputTimeScale,u=e.samplerate?e.samplerate:l,d=l/u,f=this.getSamplesPerFrame(e),h=f*d,c=this._initPTS,v=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,g=[],m=o!==void 0,p=e.samples,y=v?0:8,E=this.nextAudioPts||-1,S=t*l,L=c.baseTime*l/c.timescale;if(this.isAudioContiguous=r=r||p.length&&E>0&&(s&&Math.abs(S-E)<9e3||Math.abs(be(p[0].pts-L,S)-E)<20*h),p.forEach(function(de){de.pts=be(de.pts-L,S)}),!r||E<0){if(p=p.filter(function(de){return de.pts>=0}),!p.length)return;o===0?E=0:s&&!m?E=Math.max(0,S):E=p[0].pts}if(e.segmentCodec==="aac")for(var _=this.config.maxAudioFramesDrift,A=0,T=E;A<p.length;A++){var b=p[A],I=b.pts,P=I-T,C=Math.abs(1e3*P/l);if(P<=-_*h&&m)A===0&&(R.warn("Audio frame @ "+(I/l).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*P/l)+" ms."),this.nextAudioPts=E=T=I);else if(P>=_*h&&C<ks&&m){var w=Math.round(P/h);T=I-w*h,T<0&&(w--,T+=h),A===0&&(this.nextAudioPts=E=T),R.warn("[mp4-remuxer]: Injecting "+w+" audio frame @ "+(T/l).toFixed(3)+"s due to "+Math.round(1e3*P/l)+" ms gap.");for(var O=0;O<w;O++){var F=Math.max(T,0),H=bi.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);H||(R.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),H=b.unit.subarray()),p.splice(A,0,{unit:H,pts:F}),T+=h,A++}}b.pts=T,T+=h}for(var U=null,W=null,K,B=0,Q=p.length;Q--;)B+=p[Q].unit.byteLength;for(var j=0,J=p.length;j<J;j++){var ee=p[j],re=ee.unit,Z=ee.pts;if(W!==null){var X=g[j-1];X.duration=Math.round((Z-W)/d)}else if(r&&e.segmentCodec==="aac"&&(Z=E),U=Z,B>0){B+=y;try{K=new Uint8Array(B)}catch(de){this.observer.emit(x.ERROR,x.ERROR,{type:V.MUX_ERROR,details:D.REMUX_ALLOC_ERROR,fatal:!1,error:de,bytes:B,reason:"fail allocating audio mdat "+B});return}if(!v){var Fe=new DataView(K.buffer);Fe.setUint32(0,B),K.set(ce.types.mdat,4)}}else return;K.set(re,y);var Se=re.byteLength;y+=Se,g.push(new Ci(!0,f,Se,0)),W=Z}var te=g.length;if(te){var pe=g[g.length-1];this.nextAudioPts=E=W+d*pe.duration;var ye=v?new Uint8Array(0):ce.moof(e.sequenceNumber++,U/d,Te({},e,{samples:g}));e.samples=[];var ie=U/l,z=E/l,xe="audio",ve={data1:ye,data2:K,startPTS:ie,endPTS:z,startDTS:ie,endDTS:z,type:xe,hasAudio:!0,hasVideo:!1,nb:te};return this.isAudioContiguous=!0,ve}},n.remuxEmptyAudio=function(e,t,r,s){var o=e.inputTimeScale,l=e.samplerate?e.samplerate:o,u=o/l,d=this.nextAudioPts,f=this._initDTS,h=f.baseTime*9e4/f.timescale,c=(d!==null?d:s.startDTS*o)+h,v=s.endDTS*o+h,g=u*Ii,m=Math.ceil((v-c)/g),p=bi.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(R.warn("[mp4-remuxer]: remux empty Audio"),!p){R.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var y=[],E=0;E<m;E++){var S=c+E*g;y.push({unit:p,pts:S,dts:S})}return e.samples=y,this.remuxAudio(e,t,r,!1)},a}();function be(a,n){var i;if(n===null)return a;for(n<a?i=-8589934592:i=8589934592;Math.abs(a-n)>4294967296;)a+=i;return a}function Os(a){for(var n=0;n<a.length;n++)if(a[n].key)return n;return-1}function _i(a,n,i,e){var t=a.samples.length;if(t){for(var r=a.inputTimeScale,s=0;s<t;s++){var o=a.samples[s];o.pts=be(o.pts-i.baseTime*r/i.timescale,n*r)/r,o.dts=be(o.dts-e.baseTime*r/e.timescale,n*r)/r}var l=a.samples;return a.samples=[],{samples:l}}}function Di(a,n,i){var e=a.samples.length;if(e){for(var t=a.inputTimeScale,r=0;r<e;r++){var s=a.samples[r];s.pts=be(s.pts-i.baseTime*t/i.timescale,n*t)/t}a.samples.sort(function(l,u){return l.pts-u.pts});var o=a.samples;return a.samples=[],{samples:o}}}var Ci=function(n,i,e,t){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=i,this.size=e,this.cts=t,this.flags={isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:n?2:1,isNonSync:n?0:1}},Ns=function(){function a(){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 n=a.prototype;return n.destroy=function(){},n.resetTimeStamp=function(e){this.initPTS=e,this.lastEndTime=null},n.resetNextTimestamp=function(){this.lastEndTime=null},n.resetInitSegment=function(e,t,r,s){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(Sn(e,s)),this.emitInitSegment=!0},n.generateInitSegment=function(e){var t=this.audioCodec,r=this.videoCodec;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}var s=this.initData=Sr(e);s.audio&&(t=Pi(s.audio,$.AUDIO)),s.video&&(r=Pi(s.video,$.VIDEO));var o={};s.audio&&s.video?o.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:e,id:"main"}:s.audio?o.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:s.video?o.video={container:"video/mp4",codec:r,initSegment:e,id:"main"}:R.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=o},n.remux=function(e,t,r,s,o,l){var u,d,f=this.initPTS,h=this.lastEndTime,c={audio:void 0,video:void 0,text:s,id3:r,initSegment:void 0};M(h)||(h=this.lastEndTime=o||0);var v=t.samples;if(!(v!=null&&v.length))return c;var g={initPTS:void 0,timescale:1},m=this.initData;if((u=m)!=null&&u.length||(this.generateInitSegment(v),m=this.initData),!((d=m)!=null&&d.length))return R.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),c;this.emitInitSegment&&(g.tracks=this.initTracks,this.emitInitSegment=!1);var p=Rn(v,m),y=An(m,v),E=y===null?o:y;(Bs(f,E,o,p)||g.timescale!==f.timescale&&l)&&(g.initPTS=E-o,f&&f.timescale===1&&R.warn("Adjusting initPTS by "+(g.initPTS-f.baseTime)),this.initPTS=f={baseTime:g.initPTS,timescale:1});var S=e?E-f.baseTime/f.timescale:h,L=S+p;In(m,v,f.baseTime/f.timescale),p>0?this.lastEndTime=L:(R.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var _=!!m.audio,A=!!m.video,T="";_&&(T+="audio"),A&&(T+="video");var b={data1:v,startPTS:S,startDTS:S,endPTS:L,endDTS:L,type:T,hasAudio:_,hasVideo:A,nb:1,dropped:0};return c.audio=b.type==="audio"?b:void 0,c.video=b.type!=="audio"?b:void 0,c.initSegment=g,c.id3=_i(r,o,f,f),s.samples.length&&(c.text=Di(s,o,f)),c},a}();function Bs(a,n,i,e){if(a===null)return!0;var t=Math.max(e,1),r=n-a.baseTime/a.timescale;return Math.abs(r-i)>t}function Pi(a,n){var i=a?.codec;if(i&&i.length>4)return i;if(n===$.AUDIO){if(i==="ec-3"||i==="ac-3"||i==="alac")return i;if(i==="fLaC"||i==="Opus"){var e=!1;return st(i,e)}var t="mp4a.40.5";return R.info('Parsed audio codec "'+i+'" or audio object type not handled. Using "'+t+'"'),t}return R.warn('Unhandled video codec "'+i+'"'),i==="hvc1"||i==="hev1"?"hvc1.1.6.L120.90":i==="av01"?"av01.0.04M.08":"avc1.42e01e"}var wi=typeof self<"u"?self:void 0,ke;try{ke=self.performance.now.bind(self.performance)}catch{R.debug("Unable to use Performance API on this environment"),ke=wi?.Date.now}var $t=[{demux:Ss,remux:Ns},{demux:Is,remux:zt},{demux:xs,remux:zt},{demux:Cs,remux:zt}],Qt=function(){function a(i,e,t,r,s){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=i,this.typeSupported=e,this.config=t,this.vendor=r,this.id=s}var n=a.prototype;return n.configure=function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()},n.push=function(e,t,r,s){var o=this,l=r.transmuxing;l.executeStart=ke();var u=new Uint8Array(e),d=this.currentTransmuxState,f=this.transmuxConfig;s&&(this.currentTransmuxState=s);var h=s||d,c=h.contiguous,v=h.discontinuity,g=h.trackSwitch,m=h.accurateTimeOffset,p=h.timeOffset,y=h.initSegmentChange,E=f.audioCodec,S=f.videoCodec,L=f.defaultInitPts,_=f.duration,A=f.initSegmentData,T=Us(u,t);if(T&&T.method==="AES-128"){var b=this.getDecrypter();if(b.isSync()){var I=b.softwareDecrypt(u,T.key.buffer,T.iv.buffer),P=r.part>-1;if(P&&(I=b.flush()),!I)return l.executeEnd=ke(),Zt(r);u=new Uint8Array(I)}else return this.decryptionPromise=b.webCryptoDecrypt(u,T.key.buffer,T.iv.buffer).then(function(H){var U=o.push(H,null,r);return o.decryptionPromise=null,U}),this.decryptionPromise}var C=this.needsProbing(v,g);if(C){var w=this.configureTransmuxer(u);if(w)return R.warn("[transmuxer] "+w.message),this.observer.emit(x.ERROR,x.ERROR,{type:V.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,error:w,reason:w.message}),l.executeEnd=ke(),Zt(r)}(v||g||y||C)&&this.resetInitSegment(A,E,S,_,t),(v||y||C)&&this.resetInitialTimestamp(L),c||this.resetContiguity();var O=this.transmux(u,T,p,m,r),F=this.currentTransmuxState;return F.contiguous=!0,F.discontinuity=!1,F.trackSwitch=!1,l.executeEnd=ke(),O},n.flush=function(e){var t=this,r=e.transmuxing;r.executeStart=ke();var s=this.decrypter,o=this.currentTransmuxState,l=this.decryptionPromise;if(l)return l.then(function(){return t.flush(e)});var u=[],d=o.timeOffset;if(s){var f=s.flush();f&&u.push(this.push(f,null,e))}var h=this.demuxer,c=this.remuxer;if(!h||!c)return r.executeEnd=ke(),[Zt(e)];var v=h.flush(d);return He(v)?v.then(function(g){return t.flushRemux(u,g,e),u}):(this.flushRemux(u,v,e),u)},n.flushRemux=function(e,t,r){var s=t.audioTrack,o=t.videoTrack,l=t.id3Track,u=t.textTrack,d=this.currentTransmuxState,f=d.accurateTimeOffset,h=d.timeOffset;R.log("[transmuxer.ts]: Flushed fragment "+r.sn+(r.part>-1?" p: "+r.part:"")+" of level "+r.level);var c=this.remuxer.remux(s,o,l,u,h,f,!0,this.id);e.push({remuxResult:c,chunkMeta:r}),r.transmuxing.executeEnd=ke()},n.resetInitialTimestamp=function(e){var t=this.demuxer,r=this.remuxer;!t||!r||(t.resetTimeStamp(e),r.resetTimeStamp(e))},n.resetContiguity=function(){var e=this.demuxer,t=this.remuxer;!e||!t||(e.resetContiguity(),t.resetNextTimestamp())},n.resetInitSegment=function(e,t,r,s,o){var l=this.demuxer,u=this.remuxer;!l||!u||(l.resetInitSegment(e,t,r,s),u.resetInitSegment(e,t,r,o))},n.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},n.transmux=function(e,t,r,s,o){var l;return t&&t.method==="SAMPLE-AES"?l=this.transmuxSampleAes(e,t,r,s,o):l=this.transmuxUnencrypted(e,r,s,o),l},n.transmuxUnencrypted=function(e,t,r,s){var o=this.demuxer.demux(e,t,!1,!this.config.progressive),l=o.audioTrack,u=o.videoTrack,d=o.id3Track,f=o.textTrack,h=this.remuxer.remux(l,u,d,f,t,r,!1,this.id);return{remuxResult:h,chunkMeta:s}},n.transmuxSampleAes=function(e,t,r,s,o){var l=this;return this.demuxer.demuxSampleAes(e,t,r).then(function(u){var d=l.remuxer.remux(u.audioTrack,u.videoTrack,u.id3Track,u.textTrack,r,s,!1,l.id);return{remuxResult:d,chunkMeta:o}})},n.configureTransmuxer=function(e){for(var t=this.config,r=this.observer,s=this.typeSupported,o=this.vendor,l,u=0,d=$t.length;u<d;u++){var f;if((f=$t[u].demux)!=null&&f.probe(e)){l=$t[u];break}}if(!l)return new Error("Failed to find demuxer by probing fragment data");var h=this.demuxer,c=this.remuxer,v=l.remux,g=l.demux;(!c||!(c instanceof v))&&(this.remuxer=new v(r,t,s,o)),(!h||!(h instanceof g))&&(this.demuxer=new g(r,t,s),this.probe=g.probe)},n.needsProbing=function(e,t){return!this.demuxer||!this.remuxer||e||t},n.getDecrypter=function(){var e=this.decrypter;return e||(e=this.decrypter=new Kt(this.config)),e},a}();function Us(a,n){var i=null;return a.byteLength>0&&n?.key!=null&&n.iv!==null&&n.method!=null&&(i=n),i}var Zt=function(n){return{remuxResult:{},chunkMeta:n}};function He(a){return"then"in a&&a.then instanceof Function}var Gs=function(n,i,e,t,r){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=n,this.videoCodec=i,this.initSegmentData=e,this.duration=t,this.defaultInitPts=r||null},Hs=function(n,i,e,t,r,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=n,this.contiguous=i,this.accurateTimeOffset=e,this.trackSwitch=t,this.timeOffset=r,this.initSegmentChange=s},ki={exports:{}};(function(a){var n=Object.prototype.hasOwnProperty,i="~";function e(){}Object.create&&(e.prototype=Object.create(null),new e().__proto__||(i=!1));function t(l,u,d){this.fn=l,this.context=u,this.once=d||!1}function r(l,u,d,f,h){if(typeof d!="function")throw new TypeError("The listener must be a function");var c=new t(d,f||l,h),v=i?i+u:u;return l._events[v]?l._events[v].fn?l._events[v]=[l._events[v],c]:l._events[v].push(c):(l._events[v]=c,l._eventsCount++),l}function s(l,u){--l._eventsCount===0?l._events=new e:delete l._events[u]}function o(){this._events=new e,this._eventsCount=0}o.prototype.eventNames=function(){var u=[],d,f;if(this._eventsCount===0)return u;for(f in d=this._events)n.call(d,f)&&u.push(i?f.slice(1):f);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(d)):u},o.prototype.listeners=function(u){var d=i?i+u:u,f=this._events[d];if(!f)return[];if(f.fn)return[f.fn];for(var h=0,c=f.length,v=new Array(c);h<c;h++)v[h]=f[h].fn;return v},o.prototype.listenerCount=function(u){var d=i?i+u:u,f=this._events[d];return f?f.fn?1:f.length:0},o.prototype.emit=function(u,d,f,h,c,v){var g=i?i+u:u;if(!this._events[g])return!1;var m=this._events[g],p=arguments.length,y,E;if(m.fn){switch(m.once&&this.removeListener(u,m.fn,void 0,!0),p){case 1:return m.fn.call(m.context),!0;case 2:return m.fn.call(m.context,d),!0;case 3:return m.fn.call(m.context,d,f),!0;case 4:return m.fn.call(m.context,d,f,h),!0;case 5:return m.fn.call(m.context,d,f,h,c),!0;case 6:return m.fn.call(m.context,d,f,h,c,v),!0}for(E=1,y=new Array(p-1);E<p;E++)y[E-1]=arguments[E];m.fn.apply(m.context,y)}else{var S=m.length,L;for(E=0;E<S;E++)switch(m[E].once&&this.removeListener(u,m[E].fn,void 0,!0),p){case 1:m[E].fn.call(m[E].context);break;case 2:m[E].fn.call(m[E].context,d);break;case 3:m[E].fn.call(m[E].context,d,f);break;case 4:m[E].fn.call(m[E].context,d,f,h);break;default:if(!y)for(L=1,y=new Array(p-1);L<p;L++)y[L-1]=arguments[L];m[E].fn.apply(m[E].context,y)}}return!0},o.prototype.on=function(u,d,f){return r(this,u,d,f,!1)},o.prototype.once=function(u,d,f){return r(this,u,d,f,!0)},o.prototype.removeListener=function(u,d,f,h){var c=i?i+u:u;if(!this._events[c])return this;if(!d)return s(this,c),this;var v=this._events[c];if(v.fn)v.fn===d&&(!h||v.once)&&(!f||v.context===f)&&s(this,c);else{for(var g=0,m=[],p=v.length;g<p;g++)(v[g].fn!==d||h&&!v[g].once||f&&v[g].context!==f)&&m.push(v[g]);m.length?this._events[c]=m.length===1?m[0]:m:s(this,c)}return this},o.prototype.removeAllListeners=function(u){var d;return u?(d=i?i+u:u,this._events[d]&&s(this,d)):(this._events=new e,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=i,o.EventEmitter=o,a.exports=o})(ki);var Vs=ki.exports,Jt=or(Vs);typeof ae<"u"&&ae&&Ks(self);function Ks(a){var n=new Jt,i=function(r,s){a.postMessage({event:r,data:s})};n.on(x.FRAG_DECRYPTED,i),n.on(x.ERROR,i);var e=function(){var r=function(l){var u=function(f){i("workerLog",{logType:l,message:f})};R[l]=u};for(var s in R)r(s)};a.addEventListener("message",function(t){var r=t.data;switch(r.cmd){case"init":{var s=JSON.parse(r.config);a.transmuxer=new Qt(n,r.typeSupported,s,"",r.id),ur(s.debug,r.id),e(),i("init",null);break}case"configure":{a.transmuxer.configure(r.config);break}case"demux":{var o=a.transmuxer.push(r.data,r.decryptdata,r.chunkMeta,r.state);He(o)?(a.transmuxer.async=!0,o.then(function(f){er(a,f)}).catch(function(f){i(x.ERROR,{type:V.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,chunkMeta:r.chunkMeta,fatal:!1,error:f,err:f,reason:"transmuxer-worker push error"})})):(a.transmuxer.async=!1,er(a,o));break}case"flush":{var l=r.chunkMeta,u=a.transmuxer.flush(l),d=He(u);d||a.transmuxer.async?(He(u)||(u=Promise.resolve(u)),u.then(function(f){Mi(a,f,l)}).catch(function(f){i(x.ERROR,{type:V.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,chunkMeta:r.chunkMeta,fatal:!1,error:f,err:f,reason:"transmuxer-worker flush error"})})):Mi(a,u,l);break}}})}function er(a,n){if(Ws(n.remuxResult))return!1;var i=[],e=n.remuxResult,t=e.audio,r=e.video;return t&&Fi(i,t),r&&Fi(i,r),a.postMessage({event:"transmuxComplete",data:n},i),!0}function Fi(a,n){n.data1&&a.push(n.data1.buffer),n.data2&&a.push(n.data2.buffer)}function Mi(a,n,i){var e=n.reduce(function(t,r){return er(a,r)||t},!1);e||a.postMessage({event:"transmuxComplete",data:n[0]}),a.postMessage({event:"flush",data:i})}function Ws(a){return!a.audio&&!a.video&&!a.text&&!a.id3&&!a.initSegment}function Ys(){return typeof ne=="function"}function qs(){var a=new self.Blob(["var exports={};var module={exports:exports};function define(f){f()};define.amd=true;("+ne.toString()+")(true);"],{type:"text/javascript"}),n=self.URL.createObjectURL(a),i=new self.Worker(n);return{worker:i,objectURL:n}}function js(a){var n=new self.URL(a,self.location.href).href,i=new self.Worker(n);return{worker:i,scriptURL:n}}var Xs=function(){function a(i,e,t,r){var s=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 o=i.config;this.hls=i,this.id=e,this.useWorker=!!o.enableWorker,this.onTransmuxComplete=t,this.onFlush=r;var l=function(v,g){g=g||{},g.frag=s.frag,g.id=s.id,v===x.ERROR&&(s.error=g.error),s.hls.trigger(v,g)};this.observer=new Jt,this.observer.on(x.FRAG_DECRYPTED,l),this.observer.on(x.ERROR,l);var u=Ge(o.preferManagedMediaSource)||{isTypeSupported:function(){return!1}},d={mpeg:u.isTypeSupported("audio/mpeg"),mp3:u.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:!1};if(this.useWorker&&typeof Worker<"u"){var f=o.workerPath||Ys();if(f){try{o.workerPath?(R.log("loading Web Worker "+o.workerPath+' for "'+e+'"'),this.workerContext=js(o.workerPath)):(R.log('injecting Web Worker for "'+e+'"'),this.workerContext=qs()),this.onwmsg=function(c){return s.onWorkerMessage(c)};var h=this.workerContext.worker;h.addEventListener("message",this.onwmsg),h.onerror=function(c){var v=new Error(c.message+" ("+c.filename+":"+c.lineno+")");o.enableWorker=!1,R.warn('Error in "'+e+'" Web Worker, fallback to inline'),s.hls.trigger(x.ERROR,{type:V.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:v})},h.postMessage({cmd:"init",typeSupported:d,vendor:"",id:e,config:JSON.stringify(o)})}catch(c){R.warn('Error setting up "'+e+'" Web Worker, fallback to inline',c),this.resetWorker(),this.error=null,this.transmuxer=new Qt(this.observer,d,o,"",e)}return}}this.transmuxer=new Qt(this.observer,d,o,"",e)}var n=a.prototype;return n.resetWorker=function(){if(this.workerContext){var e=this.workerContext,t=e.worker,r=e.objectURL;r&&self.URL.revokeObjectURL(r),t.removeEventListener("message",this.onwmsg),t.onerror=null,t.terminate(),this.workerContext=null}},n.destroy=function(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{var e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}var t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},n.push=function(e,t,r,s,o,l,u,d,f,h){var c,v,g=this;f.transmuxing.start=self.performance.now();var m=this.transmuxer,p=l?l.start:o.start,y=o.decryptdata,E=this.frag,S=!(E&&o.cc===E.cc),L=!(E&&f.level===E.level),_=E?f.sn-E.sn:-1,A=this.part?f.part-this.part.index:-1,T=_===0&&f.id>1&&f.id===E?.stats.chunkCount,b=!L&&(_===1||_===0&&(A===1||T&&A<=0)),I=self.performance.now();(L||_||o.stats.parsing.start===0)&&(o.stats.parsing.start=I),l&&(A||!b)&&(l.stats.parsing.start=I);var P=!(E&&((c=o.initSegment)==null?void 0:c.url)===((v=E.initSegment)==null?void 0:v.url)),C=new Hs(S,b,d,L,p,P);if(!b||S||P){R.log("[transmuxer-interface, "+o.type+"]: Starting new transmux session for sn: "+f.sn+" p: "+f.part+" level: "+f.level+" id: "+f.id+`
10
- discontinuity: `+S+`
1
+ var Eq=Object.create;var{getPrototypeOf:Bq,defineProperty:yJ,getOwnPropertyNames:$q}=Object;var Fq=Object.prototype.hasOwnProperty;var Oq=(C0,g0,m0)=>{m0=C0!=null?Eq(Bq(C0)):{};let y0=g0||!C0||!C0.__esModule?yJ(m0,"default",{value:C0,enumerable:!0}):m0;for(let Z0 of $q(C0))if(!Fq.call(y0,Z0))yJ(y0,Z0,{get:()=>C0[Z0],enumerable:!0});return y0};var Rq=(C0,g0)=>()=>(g0||C0((g0={exports:{}}).exports,g0),g0.exports);var _J=Rq((kJ,b7)=>{(function C0(g0){(function(m0,y0){typeof kJ==="object"&&typeof b7!=="undefined"?b7.exports=y0():typeof define==="function"&&define.amd?define(y0):(m0=typeof globalThis!=="undefined"?globalThis:m0||self,m0.Hls=y0())})(this,function(){function m0(q,H,Z){if(C7())return Reflect.construct.apply(null,arguments);var Q=[null];Q.push.apply(Q,H);var Y=new(q.bind.apply(q,Q));return Z&&ZY(Y,Z.prototype),Y}function y0(q,H){for(var Z=0;Z<H.length;Z++){var Q=H[Z];Q.enumerable=Q.enumerable||!1,Q.configurable=!0,"value"in Q&&(Q.writable=!0),Object.defineProperty(q,D7(Q.key),Q)}}function Z0(q,H,Z){return H&&y0(q.prototype,H),Z&&y0(q,Z),Object.defineProperty(q,"prototype",{writable:!1}),q}function hJ(q,H,Z){return(H=D7(H))in q?Object.defineProperty(q,H,{value:Z,enumerable:!0,configurable:!0,writable:!0}):q[H]=Z,q}function W0(){return W0=Object.assign?Object.assign.bind():function(q){for(var H=1;H<arguments.length;H++){var Z=arguments[H];for(var Q in Z)({}).hasOwnProperty.call(Z,Q)&&(q[Q]=Z[Q])}return q},W0.apply(null,arguments)}function vY(q){return vY=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(H){return H.__proto__||Object.getPrototypeOf(H)},vY(q)}function G0(q,H){q.prototype=Object.create(H.prototype),q.prototype.constructor=q,ZY(q,H)}function vJ(q){try{return Function.toString.call(q).indexOf("[native code]")!==-1}catch(H){return typeof q=="function"}}function C7(){try{var q=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(H){}return(C7=function(){return!!q})()}function P7(q,H){var Z=Object.keys(q);if(Object.getOwnPropertySymbols){var Q=Object.getOwnPropertySymbols(q);H&&(Q=Q.filter(function(Y){return Object.getOwnPropertyDescriptor(q,Y).enumerable})),Z.push.apply(Z,Q)}return Z}function F0(q){for(var H=1;H<arguments.length;H++){var Z=arguments[H]!=null?arguments[H]:{};H%2?P7(Object(Z),!0).forEach(function(Q){hJ(q,Q,Z[Q])}):Object.getOwnPropertyDescriptors?Object.defineProperties(q,Object.getOwnPropertyDescriptors(Z)):P7(Object(Z)).forEach(function(Q){Object.defineProperty(q,Q,Object.getOwnPropertyDescriptor(Z,Q))})}return q}function ZY(q,H){return ZY=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(Z,Q){return Z.__proto__=Q,Z},ZY(q,H)}function gJ(q,H){if(typeof q!="object"||!q)return q;var Z=q[Symbol.toPrimitive];if(Z!==void 0){var Q=Z.call(q,H);if(typeof Q!="object")return Q;throw new TypeError("@@toPrimitive must return a primitive value.")}return(H==="string"?String:Number)(q)}function D7(q){var H=gJ(q,"string");return typeof H=="symbol"?H:H+""}function qY(q){var H=typeof Map=="function"?new Map:void 0;return qY=function(Z){if(Z===null||!vJ(Z))return Z;if(typeof Z!="function")throw new TypeError("Super expression must either be null or a function");if(H!==void 0){if(H.has(Z))return H.get(Z);H.set(Z,Q)}function Q(){return m0(Z,arguments,vY(this).constructor)}return Q.prototype=Object.create(Z.prototype,{constructor:{value:Q,enumerable:!1,writable:!0,configurable:!0}}),ZY(Q,Z)},qY(q)}function mJ(){try{return crypto.randomUUID()}catch(Y){try{var q=URL.createObjectURL(new Blob),H=q.toString();return URL.revokeObjectURL(q),H.slice(H.lastIndexOf("/")+1)}catch(J){var Z=new Date().getTime(),Q="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(X){var z=(Z+Math.random()*16)%16|0;return Z=Math.floor(Z/16),(X=="x"?z:z&3|8).toString(16)});return Q}}}function S7(q){return q&&q.__esModule&&Object.prototype.hasOwnProperty.call(q,"default")?q.default:q}var gY={exports:{}},x7;function pJ(){if(x7)return gY.exports;return x7=1,function(q){var H=Object.prototype.hasOwnProperty,Z="~";function Q(){}if(Object.create){if(Q.prototype=Object.create(null),!new Q().__proto__)Z=!1}function Y(N,W,G){this.fn=N,this.context=W,this.once=G||!1}function J(N,W,G,K,j){if(typeof G!=="function")throw new TypeError("The listener must be a function");var V=new Y(G,K||N,j),U=Z?Z+W:W;if(!N._events[U])N._events[U]=V,N._eventsCount++;else if(!N._events[U].fn)N._events[U].push(V);else N._events[U]=[N._events[U],V];return N}function X(N,W){if(--N._eventsCount===0)N._events=new Q;else delete N._events[W]}function z(){this._events=new Q,this._eventsCount=0}z.prototype.eventNames=function N(){var W=[],G,K;if(this._eventsCount===0)return W;for(K in G=this._events)if(H.call(G,K))W.push(Z?K.slice(1):K);if(Object.getOwnPropertySymbols)return W.concat(Object.getOwnPropertySymbols(G));return W},z.prototype.listeners=function N(W){var G=Z?Z+W:W,K=this._events[G];if(!K)return[];if(K.fn)return[K.fn];for(var j=0,V=K.length,U=new Array(V);j<V;j++)U[j]=K[j].fn;return U},z.prototype.listenerCount=function N(W){var G=Z?Z+W:W,K=this._events[G];if(!K)return 0;if(K.fn)return 1;return K.length},z.prototype.emit=function N(W,G,K,j,V,U){var A=Z?Z+W:W;if(!this._events[A])return!1;var E=this._events[A],B=arguments.length,F,R;if(E.fn){if(E.once)this.removeListener(W,E.fn,void 0,!0);switch(B){case 1:return E.fn.call(E.context),!0;case 2:return E.fn.call(E.context,G),!0;case 3:return E.fn.call(E.context,G,K),!0;case 4:return E.fn.call(E.context,G,K,j),!0;case 5:return E.fn.call(E.context,G,K,j,V),!0;case 6:return E.fn.call(E.context,G,K,j,V,U),!0}for(R=1,F=new Array(B-1);R<B;R++)F[R-1]=arguments[R];E.fn.apply(E.context,F)}else{var O=E.length,M;for(R=0;R<O;R++){if(E[R].once)this.removeListener(W,E[R].fn,void 0,!0);switch(B){case 1:E[R].fn.call(E[R].context);break;case 2:E[R].fn.call(E[R].context,G);break;case 3:E[R].fn.call(E[R].context,G,K);break;case 4:E[R].fn.call(E[R].context,G,K,j);break;default:if(!F)for(M=1,F=new Array(B-1);M<B;M++)F[M-1]=arguments[M];E[R].fn.apply(E[R].context,F)}}}return!0},z.prototype.on=function N(W,G,K){return J(this,W,G,K,!1)},z.prototype.once=function N(W,G,K){return J(this,W,G,K,!0)},z.prototype.removeListener=function N(W,G,K,j){var V=Z?Z+W:W;if(!this._events[V])return this;if(!G)return X(this,V),this;var U=this._events[V];if(U.fn){if(U.fn===G&&(!j||U.once)&&(!K||U.context===K))X(this,V)}else{for(var A=0,E=[],B=U.length;A<B;A++)if(U[A].fn!==G||j&&!U[A].once||K&&U[A].context!==K)E.push(U[A]);if(E.length)this._events[V]=E.length===1?E[0]:E;else X(this,V)}return this},z.prototype.removeAllListeners=function N(W){var G;if(W){if(G=Z?Z+W:W,this._events[G])X(this,G)}else this._events=new Q,this._eventsCount=0;return this},z.prototype.off=z.prototype.removeListener,z.prototype.addListener=z.prototype.on,z.prefixed=Z,z.EventEmitter=z,q.exports=z}(gY),gY.exports}var uJ=pJ(),mY=S7(uJ),pY={exports:{}},T7;function cJ(){if(T7)return pY.exports;return T7=1,function(q,H){(function(Z){var Q=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,Y=/^(?=([^\/?#]*))\1([^]*)$/,J=/(?:\/|^)\.(?=\/)/g,X=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,z={buildAbsoluteURL:function(N,W,G){if(G=G||{},N=N.trim(),W=W.trim(),!W){if(!G.alwaysNormalize)return N;var K=z.parseURL(N);if(!K)throw new Error("Error trying to parse base URL.");return K.path=z.normalizePath(K.path),z.buildURLFromParts(K)}var j=z.parseURL(W);if(!j)throw new Error("Error trying to parse relative URL.");if(j.scheme){if(!G.alwaysNormalize)return W;return j.path=z.normalizePath(j.path),z.buildURLFromParts(j)}var V=z.parseURL(N);if(!V)throw new Error("Error trying to parse base URL.");if(!V.netLoc&&V.path&&V.path[0]!=="/"){var U=Y.exec(V.path);V.netLoc=U[1],V.path=U[2]}if(V.netLoc&&!V.path)V.path="/";var A={scheme:V.scheme,netLoc:j.netLoc,path:null,params:j.params,query:j.query,fragment:j.fragment};if(!j.netLoc){if(A.netLoc=V.netLoc,j.path[0]!=="/")if(!j.path){if(A.path=V.path,!j.params){if(A.params=V.params,!j.query)A.query=V.query}}else{var E=V.path,B=E.substring(0,E.lastIndexOf("/")+1)+j.path;A.path=z.normalizePath(B)}}if(A.path===null)A.path=G.alwaysNormalize?z.normalizePath(j.path):j.path;return z.buildURLFromParts(A)},parseURL:function(N){var W=Q.exec(N);if(!W)return null;return{scheme:W[1]||"",netLoc:W[2]||"",path:W[3]||"",params:W[4]||"",query:W[5]||"",fragment:W[6]||""}},normalizePath:function(N){N=N.split("").reverse().join("").replace(J,"");while(N.length!==(N=N.replace(X,"")).length);return N.split("").reverse().join("")},buildURLFromParts:function(N){return N.scheme+N.netLoc+N.path+N.params+N.query+N.fragment}};q.exports=z})()}(pY),pY.exports}var uY=cJ(),v=Number.isFinite||function(q){return typeof q==="number"&&isFinite(q)},fJ=Number.isSafeInteger||function(q){return typeof q==="number"&&Math.abs(q)<=dJ},dJ=Number.MAX_SAFE_INTEGER||9007199254740991,f=function(q){return q.NETWORK_ERROR="networkError",q.MEDIA_ERROR="mediaError",q.KEY_SYSTEM_ERROR="keySystemError",q.MUX_ERROR="muxError",q.OTHER_ERROR="otherError",q}({}),D=function(q){return q.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",q.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",q.KEY_SYSTEM_NO_SESSION="keySystemNoSession",q.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",q.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",q.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",q.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",q.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",q.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",q.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",q.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",q.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",q.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",q.MANIFEST_LOAD_ERROR="manifestLoadError",q.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",q.MANIFEST_PARSING_ERROR="manifestParsingError",q.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",q.LEVEL_EMPTY_ERROR="levelEmptyError",q.LEVEL_LOAD_ERROR="levelLoadError",q.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",q.LEVEL_PARSING_ERROR="levelParsingError",q.LEVEL_SWITCH_ERROR="levelSwitchError",q.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",q.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",q.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",q.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",q.FRAG_LOAD_ERROR="fragLoadError",q.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",q.FRAG_DECRYPT_ERROR="fragDecryptError",q.FRAG_PARSING_ERROR="fragParsingError",q.FRAG_GAP="fragGap",q.REMUX_ALLOC_ERROR="remuxAllocError",q.KEY_LOAD_ERROR="keyLoadError",q.KEY_LOAD_TIMEOUT="keyLoadTimeOut",q.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",q.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",q.BUFFER_APPEND_ERROR="bufferAppendError",q.BUFFER_APPENDING_ERROR="bufferAppendingError",q.BUFFER_STALLED_ERROR="bufferStalledError",q.BUFFER_FULL_ERROR="bufferFullError",q.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",q.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",q.ASSET_LIST_LOAD_ERROR="assetListLoadError",q.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",q.ASSET_LIST_PARSING_ERROR="assetListParsingError",q.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",q.INTERNAL_EXCEPTION="internalException",q.INTERNAL_ABORTED="aborted",q.ATTACH_MEDIA_ERROR="attachMediaError",q.UNKNOWN="unknown",q}({}),$=function(q){return q.MEDIA_ATTACHING="hlsMediaAttaching",q.MEDIA_ATTACHED="hlsMediaAttached",q.MEDIA_DETACHING="hlsMediaDetaching",q.MEDIA_DETACHED="hlsMediaDetached",q.MEDIA_ENDED="hlsMediaEnded",q.STALL_RESOLVED="hlsStallResolved",q.BUFFER_RESET="hlsBufferReset",q.BUFFER_CODECS="hlsBufferCodecs",q.BUFFER_CREATED="hlsBufferCreated",q.BUFFER_APPENDING="hlsBufferAppending",q.BUFFER_APPENDED="hlsBufferAppended",q.BUFFER_EOS="hlsBufferEos",q.BUFFERED_TO_END="hlsBufferedToEnd",q.BUFFER_FLUSHING="hlsBufferFlushing",q.BUFFER_FLUSHED="hlsBufferFlushed",q.MANIFEST_LOADING="hlsManifestLoading",q.MANIFEST_LOADED="hlsManifestLoaded",q.MANIFEST_PARSED="hlsManifestParsed",q.LEVEL_SWITCHING="hlsLevelSwitching",q.LEVEL_SWITCHED="hlsLevelSwitched",q.LEVEL_LOADING="hlsLevelLoading",q.LEVEL_LOADED="hlsLevelLoaded",q.LEVEL_UPDATED="hlsLevelUpdated",q.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",q.LEVELS_UPDATED="hlsLevelsUpdated",q.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",q.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",q.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",q.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",q.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",q.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",q.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",q.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",q.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",q.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",q.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",q.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",q.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",q.CUES_PARSED="hlsCuesParsed",q.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",q.INIT_PTS_FOUND="hlsInitPtsFound",q.FRAG_LOADING="hlsFragLoading",q.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",q.FRAG_LOADED="hlsFragLoaded",q.FRAG_DECRYPTED="hlsFragDecrypted",q.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",q.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",q.FRAG_PARSING_METADATA="hlsFragParsingMetadata",q.FRAG_PARSED="hlsFragParsed",q.FRAG_BUFFERED="hlsFragBuffered",q.FRAG_CHANGED="hlsFragChanged",q.FPS_DROP="hlsFpsDrop",q.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",q.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",q.ERROR="hlsError",q.DESTROYING="hlsDestroying",q.KEY_LOADING="hlsKeyLoading",q.KEY_LOADED="hlsKeyLoaded",q.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",q.BACK_BUFFER_REACHED="hlsBackBufferReached",q.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",q.ASSET_LIST_LOADING="hlsAssetListLoading",q.ASSET_LIST_LOADED="hlsAssetListLoaded",q.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",q.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",q.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",q.INTERSTITIAL_STARTED="hlsInterstitialStarted",q.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",q.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",q.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",q.INTERSTITIAL_ENDED="hlsInterstitialEnded",q.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",q.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",q.EVENT_CUE_ENTER="hlsEventCueEnter",q}({}),o={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},d={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"},s0=function(){function q(Z,Q,Y){if(Q===void 0)Q=0;if(Y===void 0)Y=0;this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=Z,this.alpha_=Z?Math.exp(Math.log(0.5)/Z):0,this.estimate_=Q,this.totalWeight_=Y}var H=q.prototype;return H.sample=function Z(Q,Y){var J=Math.pow(this.alpha_,Q);this.estimate_=Y*(1-J)+J*this.estimate_,this.totalWeight_+=Q},H.getTotalWeight=function Z(){return this.totalWeight_},H.getEstimate=function Z(){if(this.alpha_){var Q=1-Math.pow(this.alpha_,this.totalWeight_);if(Q)return this.estimate_/Q}return this.estimate_},q}(),lJ=function(){function q(Z,Q,Y,J){if(J===void 0)J=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_=Y,this.minWeight_=0.001,this.minDelayMs_=50,this.slow_=new s0(Z),this.fast_=new s0(Q),this.defaultTTFB_=J,this.ttfb_=new s0(Z)}var H=q.prototype;return H.update=function Z(Q,Y){var J=this.slow_,X=this.fast_,z=this.ttfb_;if(J.halfLife!==Q)this.slow_=new s0(Q,J.getEstimate(),J.getTotalWeight());if(X.halfLife!==Y)this.fast_=new s0(Y,X.getEstimate(),X.getTotalWeight());if(z.halfLife!==Q)this.ttfb_=new s0(Q,z.getEstimate(),z.getTotalWeight())},H.sample=function Z(Q,Y){Q=Math.max(Q,this.minDelayMs_);var J=8*Y,X=Q/1000,z=J/X;this.fast_.sample(X,z),this.slow_.sample(X,z)},H.sampleTTFB=function Z(Q){var Y=Q/1000,J=Math.sqrt(2)*Math.exp(-Math.pow(Y,2)/2);this.ttfb_.sample(J,Math.max(Q,5))},H.canEstimate=function Z(){return this.fast_.getTotalWeight()>=this.minWeight_},H.getEstimate=function Z(){if(this.canEstimate())return Math.min(this.fast_.getEstimate(),this.slow_.getEstimate());else return this.defaultEstimate_},H.getEstimateTTFB=function Z(){if(this.ttfb_.getTotalWeight()>=this.minWeight_)return this.ttfb_.getEstimate();else return this.defaultTTFB_},H.destroy=function Z(){},Z0(q,[{key:"defaultEstimate",get:function Z(){return this.defaultEstimate_}}])}(),i0=function q(H,Z){this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;var Q="["+H+"]:";this.trace=f0,this.debug=Z.debug.bind(null,Q),this.log=Z.log.bind(null,Q),this.warn=Z.warn.bind(null,Q),this.info=Z.info.bind(null,Q),this.error=Z.error.bind(null,Q)},f0=function q(){},nJ={trace:f0,debug:f0,log:f0,warn:f0,info:f0,error:f0};function cY(){return W0({},nJ)}function oJ(q,H){var Z=self.console[q];return Z?Z.bind(self.console,(H?"["+H+"] ":"")+"["+q+"] >"):f0}function y7(q,H,Z){return H[q]?H[q].bind(H):oJ(q,Z)}var fY=cY();function k7(q,H,Z){var Q=cY();if(typeof console==="object"&&q===!0||typeof q==="object"){var Y=["debug","log","info","warn","error"];Y.forEach(function(J){Q[J]=y7(J,q,Z)});try{Q.log('Debug logs enabled for "'+H+'" in hls.js version 1.6.0')}catch(J){return cY()}Y.forEach(function(J){fY[J]=y7(J,q)})}else W0(fY,Q);return Q}var s=fY,dY,_7;function sJ(){if(_7)return dY;return _7=1,dY=void 0,dY}var h7=sJ(),iJ=S7(h7);function P0(q,H){if(H===void 0)H=!1;if(typeof TextDecoder!=="undefined"){var Z=new TextDecoder("utf-8"),Q=Z.decode(q);if(H){var Y=Q.indexOf("\x00");return Y!==-1?Q.substring(0,Y):Q}return Q.replace(/\0/g,"")}var J=q.length,X,z,N,W="",G=0;while(G<J){if(X=q[G++],X===0&&H)return W;else if(X===0||X===3)continue;switch(X>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:W+=String.fromCharCode(X);break;case 12:case 13:z=q[G++],W+=String.fromCharCode((X&31)<<6|z&63);break;case 14:z=q[G++],N=q[G++],W+=String.fromCharCode((X&15)<<12|(z&63)<<6|(N&63)<<0);break}}return W}var v7={hexDump:function q(H){var Z="";for(var Q=0;Q<H.length;Q++){var Y=H[Q].toString(16);if(Y.length<2)Y="0"+Y;Z+=Y}return Z}},lY=function q(){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}},Q0={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"},g7=function(){function q(Z){if(this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,typeof Z==="string")Z={url:Z};this.base=Z,aJ(this,"stats")}var H=q.prototype;return H.setByteRange=function Z(Q,Y){var J=Q.split("@",2),X;if(J.length===1)X=(Y==null?void 0:Y.byteRangeEndOffset)||0;else X=parseInt(J[1]);this._byteRange=[X,parseInt(J[0])+X]},H.clearElementaryStreamInfo=function Z(){var Q=this.elementaryStreams;Q[Q0.AUDIO]=null,Q[Q0.VIDEO]=null,Q[Q0.AUDIOVIDEO]=null},Z0(q,[{key:"baseurl",get:function Z(){return this.base.url}},{key:"byteRange",get:function Z(){if(this._byteRange===null)return[];return this._byteRange}},{key:"byteRangeStartOffset",get:function Z(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function Z(){return this.byteRange[1]}},{key:"elementaryStreams",get:function Z(){if(this._streams===null){var Q;this._streams=(Q={},Q[Q0.AUDIO]=null,Q[Q0.VIDEO]=null,Q[Q0.AUDIOVIDEO]=null,Q)}return this._streams},set:function Z(Q){this._streams=Q}},{key:"hasStats",get:function Z(){return this._stats!==null}},{key:"hasStreams",get:function Z(){return this._streams!==null}},{key:"stats",get:function Z(){if(this._stats===null)this._stats=new lY;return this._stats},set:function Z(Q){this._stats=Q}},{key:"url",get:function Z(){if(!this._url&&this.baseurl&&this.relurl)this._url=uY.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0});return this._url||""},set:function Z(Q){this._url=Q}}])}();function k0(q){return q.sn!=="initSegment"}var nY=function(q){function H(Q,Y){var J=q.call(this,Y)||this;return J._decryptdata=null,J._programDateTime=null,J._ref=null,J._bitrate=void 0,J.rawProgramDateTime=null,J.tagList=[],J.duration=0,J.sn=0,J.levelkeys=void 0,J.type=void 0,J.loader=null,J.keyLoader=null,J.level=-1,J.cc=0,J.startPTS=void 0,J.endPTS=void 0,J.startDTS=void 0,J.endDTS=void 0,J.start=0,J.playlistOffset=0,J.deltaPTS=void 0,J.maxStartPTS=void 0,J.minEndPTS=void 0,J.data=void 0,J.bitrateTest=!1,J.title=null,J.initSegment=null,J.endList=void 0,J.gap=void 0,J.urlId=0,J.type=Q,J}G0(H,q);var Z=H.prototype;return Z.addStart=function Q(Y){this.setStart(this.start+Y)},Z.setStart=function Q(Y){if(this.start=Y,this._ref)this._ref.start=Y},Z.setDuration=function Q(Y){if(this.duration=Y,this._ref)this._ref.duration=Y},Z.setKeyFormat=function Q(Y){if(this.levelkeys){var J=this.levelkeys[Y];if(J&&!this._decryptdata)this._decryptdata=J.getDecryptData(this.sn)}},Z.abortRequests=function Q(){var Y,J;(Y=this.loader)==null||Y.abort(),(J=this.keyLoader)==null||J.abort()},Z.setElementaryStreamInfo=function Q(Y,J,X,z,N,W){if(W===void 0)W=!1;var G=this.elementaryStreams,K=G[Y];if(!K){G[Y]={startPTS:J,endPTS:X,startDTS:z,endDTS:N,partial:W};return}K.startPTS=Math.min(K.startPTS,J),K.endPTS=Math.max(K.endPTS,X),K.startDTS=Math.min(K.startDTS,z),K.endDTS=Math.max(K.endDTS,N)},Z0(H,[{key:"byteLength",get:function Q(){if(this.hasStats){var Y=this.stats.total;if(Y)return Y}if(this.byteRange){var J=this.byteRange[0],X=this.byteRange[1];if(v(J)&&v(X))return X-J}return null}},{key:"bitrate",get:function Q(){if(this.byteLength)return this.byteLength*8/this.duration;if(this._bitrate)return this._bitrate;return null},set:function Q(Y){this._bitrate=Y}},{key:"decryptdata",get:function Q(){var Y=this.levelkeys;if(!Y&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var J=this.levelkeys.identity;if(J)this._decryptdata=J.getDecryptData(this.sn);else{var X=Object.keys(this.levelkeys);if(X.length===1)return this._decryptdata=this.levelkeys[X[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function Q(){return this.start+this.duration}},{key:"endProgramDateTime",get:function Q(){if(this.programDateTime===null)return null;var Y=!v(this.duration)?0:this.duration;return this.programDateTime+Y*1000}},{key:"encrypted",get:function Q(){var Y;if((Y=this._decryptdata)!=null&&Y.encrypted)return!0;else if(this.levelkeys){var J=Object.keys(this.levelkeys),X=J.length;if(X>1||X===1&&this.levelkeys[J[0]].encrypted)return!0}return!1}},{key:"programDateTime",get:function Q(){if(this._programDateTime===null&&this.rawProgramDateTime)this.programDateTime=Date.parse(this.rawProgramDateTime);return this._programDateTime},set:function Q(Y){if(!v(Y)){this._programDateTime=this.rawProgramDateTime=null;return}this._programDateTime=Y}},{key:"ref",get:function Q(){if(!k0(this))return null;if(!this._ref)this._ref={base:this.base,start:this.start,duration:this.duration,sn:this.sn,programDateTime:this.programDateTime};return this._ref}}])}(g7),rJ=function(q){function H(Z,Q,Y,J,X){var z=q.call(this,Y)||this;z.fragOffset=0,z.duration=0,z.gap=!1,z.independent=!1,z.relurl=void 0,z.fragment=void 0,z.index=void 0,z.duration=Z.decimalFloatingPoint("DURATION"),z.gap=Z.bool("GAP"),z.independent=Z.bool("INDEPENDENT"),z.relurl=Z.enumeratedString("URI"),z.fragment=Q,z.index=J;var N=Z.enumeratedString("BYTERANGE");if(N)z.setByteRange(N,X);if(X)z.fragOffset=X.fragOffset+X.duration;return z}return G0(H,q),Z0(H,[{key:"start",get:function Z(){return this.fragment.start+this.fragOffset}},{key:"end",get:function Z(){return this.start+this.duration}},{key:"loaded",get:function Z(){var Q=this.elementaryStreams;return!!(Q.audio||Q.video||Q.audiovideo)}}])}(g7);function m7(q,H){var Z=Object.getPrototypeOf(q);if(Z){var Q=Object.getOwnPropertyDescriptor(Z,H);if(Q)return Q;return m7(Z,H)}}function aJ(q,H){var Z=m7(q,H);if(Z)Z.enumerable=!0,Object.defineProperty(q,H,Z)}var UY=Math.pow(2,32)-1,tJ=[].push,p7={video:1,audio:2,id3:3,text:4};function K0(q){return String.fromCharCode.apply(null,q)}function u7(q,H){var Z=q[H]<<8|q[H+1];return Z<0?65536+Z:Z}function u(q,H){var Z=f7(q,H);return Z<0?4294967296+Z:Z}function c7(q,H){var Z=u(q,H);return Z*=Math.pow(2,32),Z+=u(q,H+4),Z}function f7(q,H){return q[H]<<24|q[H+1]<<16|q[H+2]<<8|q[H+3]}function oY(q,H,Z){q[H]=Z>>24,q[H+1]=Z>>16&255,q[H+2]=Z>>8&255,q[H+3]=Z&255}function eJ(q){var H=q.byteLength;for(var Z=0;Z<H;){var Q=u(q,Z);if(Q>8&&q[Z+4]===109&&q[Z+5]===111&&q[Z+6]===111&&q[Z+7]===102)return!0;Z=Q>1?Z+Q:H}return!1}function c(q,H){var Z=[];if(!H.length)return Z;var Q=q.byteLength;for(var Y=0;Y<Q;){var J=u(q,Y),X=K0(q.subarray(Y+4,Y+8)),z=J>1?Y+J:Q;if(X===H[0])if(H.length===1)Z.push(q.subarray(Y+8,z));else{var N=c(q.subarray(Y+8,z),H.slice(1));if(N.length)tJ.apply(Z,N)}Y=z}return Z}function Y8(q){var H=[],Z=q[0],Q=8,Y=u(q,Q);Q+=4;var J=0,X=0;if(Z===0)J=u(q,Q),X=u(q,Q+4),Q+=8;else J=c7(q,Q),X=c7(q,Q+8),Q+=16;Q+=2;var z=q.length+X,N=u7(q,Q);Q+=2;for(var W=0;W<N;W++){var G=Q,K=u(q,G);G+=4;var j=K&2147483647,V=(K&2147483648)>>>31;if(V===1)return s.warn("SIDX has hierarchical references (not supported)"),null;var U=u(q,G);G+=4,H.push({referenceSize:j,subsegmentDuration:U,info:{duration:U/Y,start:z,end:z+j-1}}),z+=j,G+=4,Q=G}return{earliestPresentationTime:J,timescale:Y,version:Z,referencesCount:N,references:H}}function d7(q){var H=[],Z=c(q,["moov","trak"]);for(var Q=0;Q<Z.length;Q++){var Y=Z[Q],J=c(Y,["tkhd"])[0];if(J){var X=J[0],z=u(J,X===0?12:20),N=c(Y,["mdia","mdhd"])[0];if(N){X=N[0];var W=u(N,X===0?12:20),G=c(Y,["mdia","hdlr"])[0];if(G){var K=K0(G.subarray(8,12)),j={soun:Q0.AUDIO,vide:Q0.VIDEO}[K],V=c(Y,["mdia","minf","stbl","stsd"])[0],U=Q8(V);if(j)H[z]={timescale:W,type:j,stsd:U},H[j]=F0({timescale:W,id:z},U);else H[z]={timescale:W,type:K,stsd:U}}}}}var A=c(q,["moov","mvex","trex"]);return A.forEach(function(E){var B=u(E,4),F=H[B];if(F)F.default={duration:u(E,12),flags:u(E,20)}}),H}function Q8(q){var H=q.subarray(8),Z=H.subarray(86),Q=K0(H.subarray(4,8)),Y=Q,J,X=Q==="enca"||Q==="encv";if(X){var z=c(H,[Q])[0],N=z.subarray(Q==="enca"?28:78),W=c(N,["sinf"]);W.forEach(function(E0){var b0=c(E0,["schm"])[0];if(b0){var Y0=K0(b0.subarray(4,8));if(Y0==="cbcs"||Y0==="cenc"){var B0=c(E0,["frma"])[0];if(B0)Y=K0(B0)}}})}var G=Y;switch(Y){case"avc1":case"avc2":case"avc3":case"avc4":{var K=c(Z,["avcC"])[0];Y+="."+AY(K[1])+AY(K[2])+AY(K[3]),J=VY(G==="avc1"?"dva1":"dvav",Z);break}case"mp4a":{var j=c(H,[Q])[0],V=c(j.subarray(28),["esds"])[0];if(V&&V.length>7){var U=4;if(V[U++]!==3)break;U=sY(V,U),U+=2;var A=V[U++];if(A&128)U+=2;if(A&64)U+=V[U++];if(V[U++]!==4)break;U=sY(V,U);var E=V[U++];if(E===64)Y+="."+AY(E);else break;if(U+=12,V[U++]!==5)break;U=sY(V,U);var B=V[U++],F=(B&248)>>3;if(F===31)F+=1+((B&7)<<3)+((V[U]&224)>>5);Y+="."+F}break}case"hvc1":case"hev1":{var R=c(Z,["hvcC"]);if(R){var O=R[0],M=O[1],L=["","A","B","C"][M>>6],I=M&31,w=u(O,2),S=(M&32)>>5?"H":"L",P=O[12],b=O.subarray(6,12);Y+="."+L+I,Y+="."+w.toString(16).toUpperCase(),Y+="."+S+P;var C="";for(var x=b.length;x--;){var _=b[x];if(_||C){var y=_.toString(16).toUpperCase();C="."+y+C}}Y+=C}J=VY(G=="hev1"?"dvhe":"dvh1",Z);break}case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":{Y=VY(Y,Z)||Y;break}case"vp09":{var T=c(Z,["vpcC"])[0],h=T[4],g=T[5],m=T[6]>>4&15;Y+="."+_0(h)+"."+_0(g)+"."+_0(m);break}case"av01":{var p=c(Z,["av1C"])[0],r=p[1]>>>5,n=p[1]&31,a=p[2]>>>7?"H":"M",l=(p[2]&64)>>6,X0=(p[2]&32)>>5,t=r===2&&l?X0?12:10:l?10:8,q0=(p[2]&16)>>4,R0=(p[2]&8)>>3,U0=(p[2]&4)>>2,e=p[2]&3,M0=1,z0=1,J0=1,I0=0;Y+="."+r+"."+_0(n)+a+"."+_0(t)+"."+q0+"."+R0+U0+e+"."+_0(M0)+"."+_0(z0)+"."+_0(J0)+"."+I0,J=VY("dav1",Z);break}}return{codec:Y,encrypted:X,supplemental:J}}function VY(q,H){var Z=c(H,["dvvC"]),Q=Z.length?Z[0]:c(H,["dvcC"])[0];if(Q){var Y=Q[2]>>1&127,J=Q[2]<<5&32|Q[3]>>3&31;return q+"."+_0(Y)+"."+_0(J)}}function sY(q,H){var Z=H+5;while(q[H++]&128&&H<Z);return H}function AY(q){return("0"+q.toString(16).toUpperCase()).slice(-2)}function _0(q){return(q<10?"0":"")+q}function J8(q,H){if(!q||!H)return q;var Z=H.keyId;if(Z&&H.isCommonEncryption){var Q=c(q,["moov","trak"]);Q.forEach(function(Y){var J=c(Y,["mdia","minf","stbl","stsd"])[0],X=J.subarray(8),z=c(X,["enca"]),N=z.length>0;if(!N)z=c(X,["encv"]);z.forEach(function(W){var G=N?W.subarray(28):W.subarray(78),K=c(G,["sinf"]);K.forEach(function(j){var V=Z8(j);if(V){var U=V.subarray(8,24);if(!U.some(function(A){return A!==0}))s.log("[eme] Patching keyId in 'enc"+(N?"a":"v")+">sinf>>tenc' box: "+v7.hexDump(U)+" -> "+v7.hexDump(Z)),V.set(Z,8)}})})})}return q}function Z8(q){var H=c(q,["schm"])[0];if(H){var Z=K0(H.subarray(4,8));if(Z==="cbcs"||Z==="cenc")return c(q,["schi","tenc"])[0]}return null}function q8(q,H){return c(H,["moof","traf"]).reduce(function(Z,Q){var Y=c(Q,["tfdt"])[0],J=Y[0],X=c(Q,["tfhd"]).reduce(function(z,N){var W=u(N,4),G=q[W];if(G){var K=u(Y,4);if(J===1){if(K===UY)return s.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),z;K*=UY+1,K+=u(Y,8)}var j=G.timescale||90000,V=K/j;if(v(V)&&(z===null||V<z))return V}return z},null);if(X!==null&&v(X)&&(Z===null||X<Z))return X;return Z},null)}function X8(q,H){var Z=0,Q=0,Y=0,J=c(q,["moof","traf"]);for(var X=0;X<J.length;X++){var z=J[X],N=c(z,["tfhd"])[0],W=u(N,4),G=H[W];if(!G)continue;var K=G.default,j=u(N,0)|(K==null?void 0:K.flags),V=K==null?void 0:K.duration;if(j&8)if(j&2)V=u(N,12);else V=u(N,8);var U=G.timescale||90000,A=c(z,["trun"]);for(var E=0;E<A.length;E++){if(Z=H8(A[E]),!Z&&V){var B=u(A[E],4);Z=V*B}if(G.type===Q0.VIDEO)Q+=Z/U;else if(G.type===Q0.AUDIO)Y+=Z/U}}if(Q===0&&Y===0){var F=1/0,R=0,O=0,M=c(q,["sidx"]);for(var L=0;L<M.length;L++){var I=Y8(M[L]);if(I!=null&&I.references){F=Math.min(F,I.earliestPresentationTime/I.timescale);var w=I.references.reduce(function(S,P){return S+P.info.duration||0},0);R=Math.max(R,w+I.earliestPresentationTime/I.timescale),O=R-F}}if(O&&v(O))return O}if(Q)return Q;return Y}function H8(q){var H=u(q,0),Z=8;if(H&1)Z+=4;if(H&4)Z+=4;var Q=0,Y=u(q,4);for(var J=0;J<Y;J++){if(H&256){var X=u(q,Z);Q+=X,Z+=4}if(H&512)Z+=4;if(H&1024)Z+=4;if(H&2048)Z+=4}return Q}function z8(q,H,Z){c(H,["moof","traf"]).forEach(function(Q){c(Q,["tfhd"]).forEach(function(Y){var J=u(Y,4),X=q[J];if(!X)return;var z=X.timescale||90000;c(Q,["tfdt"]).forEach(function(N){var W=N[0],G=Z*z;if(G){var K=u(N,4);if(W===0)K-=G,K=Math.max(K,0),oY(N,4,K);else{K*=Math.pow(2,32),K+=u(N,8),K-=G,K=Math.max(K,0);var j=Math.floor(K/(UY+1)),V=Math.floor(K%(UY+1));oY(N,4,j),oY(N,8,V)}}})})})}function N8(q){var H={valid:null,remainder:null},Z=c(q,["moof"]);if(Z.length<2)return H.remainder=q,H;var Q=Z[Z.length-1];return H.valid=q.slice(0,Q.byteOffset-8),H.remainder=q.slice(Q.byteOffset-8),H}function D0(q,H){var Z=new Uint8Array(q.length+H.length);return Z.set(q),Z.set(H,q.length),Z}function l7(q,H){var Z=[],Q=H.samples,Y=H.timescale,J=H.id,X=!1,z=c(Q,["moof"]);return z.map(function(N){var W=N.byteOffset-8,G=c(N,["traf"]);G.map(function(K){var j=c(K,["tfdt"]).map(function(V){var U=V[0],A=u(V,4);if(U===1)A*=Math.pow(2,32),A+=u(V,8);return A/Y})[0];if(j!==void 0)q=j;return c(K,["tfhd"]).map(function(V){var U=u(V,4),A=u(V,0)&16777215,E=(A&1)!==0,B=(A&2)!==0,F=(A&8)!==0,R=0,O=(A&16)!==0,M=0,L=(A&32)!==0,I=8;if(U===J){if(E)I+=8;if(B)I+=4;if(F)R=u(V,I),I+=4;if(O)M=u(V,I),I+=4;if(L)I+=4;if(H.type==="video")X=iY(H.codec);c(K,["trun"]).map(function(w){var S=w[0],P=u(w,0)&16777215,b=(P&1)!==0,C=0,x=(P&4)!==0,_=(P&256)!==0,y=0,T=(P&512)!==0,h=0,g=(P&1024)!==0,m=(P&2048)!==0,p=0,r=u(w,4),n=8;if(b)C=u(w,n),n+=4;if(x)n+=4;var a=C+W;for(var l=0;l<r;l++){if(_)y=u(w,n),n+=4;else y=R;if(T)h=u(w,n),n+=4;else h=M;if(g)n+=4;if(m){if(S===0)p=u(w,n);else p=f7(w,n);n+=4}if(H.type===Q0.VIDEO){var X0=0;while(X0<h){var t=u(Q,a);if(a+=4,W8(X,Q[a])){var q0=Q.subarray(a,a+t);n7(q0,X?2:1,q+p/Y,Z)}a+=t,X0+=t+4}}q+=y/Y}})}})})}),Z}function iY(q){if(!q)return!1;var H=q.substring(0,4);return H==="hvc1"||H==="hev1"||H==="dvh1"||H==="dvhe"}function W8(q,H){if(q){var Z=H>>1&63;return Z===39||Z===40}else{var Q=H&31;return Q===6}}function n7(q,H,Z,Q){var Y=o7(q),J=0;J+=H;var X=0,z=0,N=0;while(J<Y.length){X=0;do{if(J>=Y.length)break;N=Y[J++],X+=N}while(N===255);z=0;do{if(J>=Y.length)break;N=Y[J++],z+=N}while(N===255);var W=Y.length-J,G=J;if(z<W)J+=z;else if(z>W){s.error("Malformed SEI payload. "+z+" is too small, only "+W+" bytes left to parse.");break}if(X===4){var K=Y[G++];if(K===181){var j=u7(Y,G);if(G+=2,j===49){var V=u(Y,G);if(G+=4,V===1195456820){var U=Y[G++];if(U===3){var A=Y[G++],E=31&A,B=64&A,F=B?2+E*3:0,R=new Uint8Array(F);if(B){R[0]=A;for(var O=1;O<F;O++)R[O]=Y[G++]}Q.push({type:U,payloadType:X,pts:Z,bytes:R})}}}}}else if(X===5){if(z>16){var M=[];for(var L=0;L<16;L++){var I=Y[G++].toString(16);if(M.push(I.length==1?"0"+I:I),L===3||L===5||L===7||L===9)M.push("-")}var w=z-16,S=new Uint8Array(w);for(var P=0;P<w;P++)S[P]=Y[G++];Q.push({payloadType:X,pts:Z,uuid:M.join(""),userData:P0(S),userDataBytes:S})}}}}function o7(q){var H=q.byteLength,Z=[],Q=1;while(Q<H-2)if(q[Q]===0&&q[Q+1]===0&&q[Q+2]===3)Z.push(Q+2),Q+=2;else Q++;if(Z.length===0)return q;var Y=H-Z.length,J=new Uint8Array(Y),X=0;for(Q=0;Q<Y;X++,Q++){if(X===Z[0])X++,Z.shift();J[Q]=q[X]}return J}function G8(q){var H=q[0],Z="",Q="",Y=0,J=0,X=0,z=0,N=0,W=0;if(H===0){while(K0(q.subarray(W,W+1))!=="\x00")Z+=K0(q.subarray(W,W+1)),W+=1;Z+=K0(q.subarray(W,W+1)),W+=1;while(K0(q.subarray(W,W+1))!=="\x00")Q+=K0(q.subarray(W,W+1)),W+=1;Q+=K0(q.subarray(W,W+1)),W+=1,Y=u(q,12),J=u(q,16),z=u(q,20),N=u(q,24),W=28}else if(H===1){W+=4,Y=u(q,W),W+=4;var G=u(q,W);W+=4;var K=u(q,W);if(W+=4,X=Math.pow(2,32)*G+K,!fJ(X))X=Number.MAX_SAFE_INTEGER,s.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box");z=u(q,W),W+=4,N=u(q,W),W+=4;while(K0(q.subarray(W,W+1))!=="\x00")Z+=K0(q.subarray(W,W+1)),W+=1;Z+=K0(q.subarray(W,W+1)),W+=1;while(K0(q.subarray(W,W+1))!=="\x00")Q+=K0(q.subarray(W,W+1)),W+=1;Q+=K0(q.subarray(W,W+1)),W+=1}var j=q.subarray(W,q.byteLength);return{schemeIdUri:Z,value:Q,timeScale:Y,presentationTime:X,presentationTimeDelta:J,eventDuration:z,id:N,payload:j}}function d0(q){if(q===void 0)q=!0;if(typeof self==="undefined")return;var H=(q||!self.MediaSource)&&self.ManagedMediaSource;return H||self.MediaSource||self.WebKitMediaSource}function K8(q){return typeof self!=="undefined"&&q===self.ManagedMediaSource}function j8(q,H){var Z=Object.keys(q),Q=Object.keys(H),Y=Z.length,J=Q.length;return!Y||!J||Y===J&&!Z.some(function(X){return Q.indexOf(X)===-1})}var s7=function q(){return/\(Windows.+Firefox\//i.test(navigator.userAgent)},r0={audio:{a3ds:1,"ac-3":0.95,"ac-4":1,alac:0.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":0.9,enca:1,fLaC:0.9,flac:0.9,FLAC:0.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:0.8,dav1:0.8,drac:1,dva1:1,dvav:1,dvh1:0.7,dvhe:0.7,encv:1,hev1:0.75,hvc1:0.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:0.9},text:{stpp:1,wvtt:1}};function i7(q,H){var Z=r0[H];return!!Z&&!!Z[q.slice(0,4)]}function rY(q,H,Z){if(Z===void 0)Z=!0;return!q.split(",").some(function(Q){return!r7(Q,H,Z)})}function r7(q,H,Z){var Q;if(Z===void 0)Z=!0;var Y=d0(Z);return(Q=Y==null?void 0:Y.isTypeSupported(XY(q,H)))!=null?Q:!1}function XY(q,H){return H+"/mp4;codecs="+q}function a7(q){if(q){var H=q.substring(0,4);return r0.video[H]}return 2}function EY(q){var H=s7();return q.split(",").reduce(function(Z,Q){var Y=H&&iY(Q),J=Y?9:r0.video[Q];if(J)return(J*2+Z)/(Z?3:2);return(r0.audio[Q]+Z)/(Z?2:1)},0)}var aY={};function U8(q,H){if(H===void 0)H=!0;if(aY[q])return aY[q];var Z={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[q];for(var Q=0;Q<Z.length;Q++){var Y;if(r7(Z[Q],"audio",H))return aY[q]=Z[Q],Z[Q];else if(Z[Q]==="mp3"&&(Y=d0(H))!=null&&Y.isTypeSupported("audio/mpeg"))return""}return q}var V8=/flac|opus|mp4a\.40\.34/i;function BY(q,H){if(H===void 0)H=!0;return q.replace(V8,function(Z){return U8(Z.toLowerCase(),H)})}function A8(q,H){var Z=[];if(q){var Q=q.split(",");for(var Y=0;Y<Q.length;Y++)if(!i7(Q[Y],"video"))Z.push(Q[Y])}if(H)Z.push(H);return Z.join(",")}function $Y(q,H){if(q&&(q.length>4||["ac-3","ec-3","alac","fLaC","Opus"].indexOf(q)!==-1))return q;if(H){var Z=H.split(",");if(Z.length>1){if(q){for(var Q=Z.length;Q--;)if(Z[Q].substring(0,4)===q.substring(0,4))return Z[Q]}return Z[0]}}return H||q}function E8(q){var H=q.split(",");for(var Z=0;Z<H.length;Z++){var Q=H[Z].split(".");if(Q.length>2){var Y=Q.shift()+".";Y+=parseInt(Q.shift()).toString(16),Y+=("000"+parseInt(Q.shift()).toString(16)).slice(-4),H[Z]=Y}}return H.join(",")}function B8(q){if(q.startsWith("av01.")){var H=q.split("."),Z=["0","111","01","01","01","0"];for(var Q=H.length;Q>4&&Q<10;Q++)H[Q]=Z[Q-4];return H.join(".")}return q}function t7(q){var H=d0(q)||{isTypeSupported:function Z(){return!1}};return{mpeg:H.isTypeSupported("audio/mpeg"),mp3:H.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:!1}}function e7(q){return q.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}var tY=["NONE","TYPE-0","TYPE-1",null];function $8(q){return tY.indexOf(q)>-1}var FY=["SDR","PQ","HLG"];function F8(q){return!!q&&FY.indexOf(q)>-1}var OY={No:"",Yes:"YES",v2:"v2"};function YQ(q){var{canSkipUntil:H,canSkipDateRanges:Z,age:Q}=q,Y=Q<H/2;if(H&&Y){if(Z)return OY.v2;return OY.Yes}return OY.No}var QQ=function(){function q(Z,Q,Y){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=Z,this.part=Q,this.skip=Y}var H=q.prototype;return H.addDirectives=function Z(Q){var Y=new self.URL(Q);if(this.msn!==void 0)Y.searchParams.set("_HLS_msn",this.msn.toString());if(this.part!==void 0)Y.searchParams.set("_HLS_part",this.part.toString());if(this.skip)Y.searchParams.set("_HLS_skip",this.skip);return Y.href},q}(),JQ=function(){function q(Z){if(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.supplemental=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=[Z.url],this._attrs=[Z.attrs],this.bitrate=Z.bitrate,Z.details)this.details=Z.details;if(this.id=Z.id||0,this.name=Z.name,this.width=Z.width||0,this.height=Z.height||0,this.frameRate=Z.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=Z.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=Z.audioCodec,this.videoCodec=Z.videoCodec,this.codecSet=[Z.videoCodec,Z.audioCodec].filter(function(J){return!!J}).map(function(J){return J.substring(0,4)}).join(","),"supplemental"in Z){var Q;this.supplemental=Z.supplemental;var Y=(Q=Z.supplemental)==null?void 0:Q.videoCodec;if(Y&&Y!==Z.videoCodec)this.codecSet+=","+Y.substring(0,4)}this.addGroupId("audio",Z.attrs.AUDIO),this.addGroupId("text",Z.attrs.SUBTITLES)}var H=q.prototype;return H.hasAudioGroup=function Z(Q){return ZQ(this._audioGroups,Q)},H.hasSubtitleGroup=function Z(Q){return ZQ(this._subtitleGroups,Q)},H.addGroupId=function Z(Q,Y){if(!Y)return;if(Q==="audio"){var J=this._audioGroups;if(!J)J=this._audioGroups=[];if(J.indexOf(Y)===-1)J.push(Y)}else if(Q==="text"){var X=this._subtitleGroups;if(!X)X=this._subtitleGroups=[];if(X.indexOf(Y)===-1)X.push(Y)}},H.addFallback=function Z(){},Z0(q,[{key:"maxBitrate",get:function Z(){return Math.max(this.realBitrate,this.bitrate)}},{key:"averageBitrate",get:function Z(){return this._avgBitrate||this.realBitrate||this.bitrate}},{key:"attrs",get:function Z(){return this._attrs[0]}},{key:"codecs",get:function Z(){return this.attrs.CODECS||""}},{key:"pathwayId",get:function Z(){return this.attrs["PATHWAY-ID"]||"."}},{key:"videoRange",get:function Z(){return this.attrs["VIDEO-RANGE"]||"SDR"}},{key:"score",get:function Z(){return this.attrs.optionalFloat("SCORE",0)}},{key:"uri",get:function Z(){return this.url[0]||""}},{key:"audioGroups",get:function Z(){return this._audioGroups}},{key:"subtitleGroups",get:function Z(){return this._subtitleGroups}},{key:"urlId",get:function Z(){return 0},set:function Z(Q){}},{key:"audioGroupIds",get:function Z(){return this.audioGroups?[this.audioGroupId]:void 0}},{key:"textGroupIds",get:function Z(){return this.subtitleGroups?[this.textGroupId]:void 0}},{key:"audioGroupId",get:function Z(){var Q;return(Q=this.audioGroups)==null?void 0:Q[0]}},{key:"textGroupId",get:function Z(){var Q;return(Q=this.subtitleGroups)==null?void 0:Q[0]}}])}();function ZQ(q,H){if(!H||!q)return!1;return q.indexOf(H)!==-1}function O8(){if(typeof matchMedia==="function"){var q=matchMedia("(dynamic-range: high)"),H=matchMedia("bad query");if(q.media!==H.media)return q.matches===!0}return!1}function R8(q,H){var Z=!1,Q=[];if(q)Z=q!=="SDR",Q=[q];if(H){Q=H.allowedVideoRanges||FY.slice(0);var Y=Q.join("")!=="SDR"&&!H.videoCodec;if(Z=H.preferHDR!==void 0?H.preferHDR:Y&&O8(),!Z)Q=["SDR"]}return{preferHDR:Z,allowedVideoRanges:Q}}var M8=function q(H){var Z=new WeakSet;return function(Q,Y){if(H)Y=H(Q,Y);if(typeof Y==="object"&&Y!==null){if(Z.has(Y))return;Z.add(Y)}return Y}},$0=function q(H,Z){return JSON.stringify(H,M8(Z))};function I8(q,H,Z,Q,Y){var J=Object.keys(q),X=Q==null?void 0:Q.channels,z=Q==null?void 0:Q.audioCodec,N=Y==null?void 0:Y.videoCodec,W=X&&parseInt(X)===2,G=!1,K=!1,j=1/0,V=1/0,U=1/0,A=1/0,E=0,B=[],F=R8(H,Y),R=F.preferHDR,O=F.allowedVideoRanges,M=function b(){var C=q[J[L]];G||(G=C.channels[2]>0),j=Math.min(j,C.minHeight),V=Math.min(V,C.minFramerate),U=Math.min(U,C.minBitrate);var x=O.filter(function(_){return C.videoRanges[_]>0});if(x.length>0)K=!0};for(var L=J.length;L--;)M();j=v(j)?j:0,V=v(V)?V:0;var I=Math.max(1080,j),w=Math.max(30,V);if(U=v(U)?U:Z,Z=Math.max(U,Z),!K)H=void 0;var S=J.length>1,P=J.reduce(function(b,C){var x=q[C];if(C===b)return b;if(B=K?O.filter(function(_){return x.videoRanges[_]>0}):[],S){if(x.minBitrate>Z)return h0(C,"min bitrate of "+x.minBitrate+" > current estimate of "+Z),b;if(!x.hasDefaultAudio)return h0(C,"no renditions with default or auto-select sound found"),b;if(z&&C.indexOf(z.substring(0,4))%5!==0)return h0(C,'audio codec preference "'+z+'" not found'),b;if(X&&!W){if(!x.channels[X])return h0(C,"no renditions with "+X+" channel sound found (channels options: "+Object.keys(x.channels)+")"),b}else if((!z||W)&&G&&x.channels["2"]===0)return h0(C,"no renditions with stereo sound found"),b;if(x.minHeight>I)return h0(C,"min resolution of "+x.minHeight+" > maximum of "+I),b;if(x.minFramerate>w)return h0(C,"min framerate of "+x.minFramerate+" > maximum of "+w),b;if(!B.some(function(_){return x.videoRanges[_]>0}))return h0(C,"no variants with VIDEO-RANGE of "+$0(B)+" found"),b;if(N&&C.indexOf(N.substring(0,4))%5!==0)return h0(C,'video codec preference "'+N+'" not found'),b;if(x.maxScore<E)return h0(C,"max score of "+x.maxScore+" < selected max of "+E),b}if(b&&(EY(C)>=EY(b)||x.fragmentError>q[b].fragmentError))return b;return A=x.minIndex,E=x.maxScore,C},void 0);return{codecSet:P,videoRanges:B,preferHDR:R,minFramerate:V,minBitrate:U,minIndex:A}}function h0(q,H){s.log('[abr] start candidates with "'+q+'" ignored because '+H)}function qQ(q){return q.reduce(function(H,Z){var Q=H.groups[Z.groupId];if(!Q)Q=H.groups[Z.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1};Q.tracks.push(Z);var Y=Z.channels||"2";if(Q.channels[Y]=(Q.channels[Y]||0)+1,Q.hasDefault=Q.hasDefault||Z.default,Q.hasAutoSelect=Q.hasAutoSelect||Z.autoselect,Q.hasDefault)H.hasDefaultAudio=!0;if(Q.hasAutoSelect)H.hasAutoSelectAudio=!0;return H},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function w8(q,H,Z,Q){return q.slice(Z,Q+1).reduce(function(Y,J,X){if(!J.codecSet)return Y;var z=J.audioGroups,N=Y[J.codecSet];if(!N)Y[J.codecSet]=N={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:X,maxScore:0,videoRanges:{SDR:0},channels:{"2":0},hasDefaultAudio:!z,fragmentError:0};N.minBitrate=Math.min(N.minBitrate,J.bitrate);var W=Math.min(J.height,J.width);return N.minHeight=Math.min(N.minHeight,W),N.minFramerate=Math.min(N.minFramerate,J.frameRate),N.minIndex=Math.min(N.minIndex,X),N.maxScore=Math.max(N.maxScore,J.score),N.fragmentError+=J.fragmentError,N.videoRanges[J.videoRange]=(N.videoRanges[J.videoRange]||0)+1,Y},{})}function XQ(q,H){var Z;return!!q&&q!==((Z=H.loadLevelObj)==null?void 0:Z.uri)}var L8=function(q){function H(Q){var Y=q.call(this,"abr",Q.logger)||this;return Y.hls=void 0,Y.lastLevelLoadSec=0,Y.lastLoadedFragLevel=-1,Y.firstSelection=-1,Y._nextAutoLevel=-1,Y.nextAutoLevelKey="",Y.audioTracksByGroup=null,Y.codecTiers=null,Y.timer=-1,Y.fragCurrent=null,Y.partCurrent=null,Y.bitrateTestDelay=0,Y.rebufferNotice=-1,Y.bwEstimator=void 0,Y._abandonRulesCheck=function(J){var X,z=Y,N=z.fragCurrent,W=z.partCurrent,G=z.hls,K=G.autoLevelEnabled,j=G.media;if(!N||!j)return;var V=performance.now(),U=W?W.stats:N.stats,A=W?W.duration:N.duration,E=V-U.loading.start,B=G.minAutoLevel,F=N.level,R=Y._nextAutoLevel;if(U.aborted||U.loaded&&U.loaded===U.total||F<=B){Y.clearTimer(),Y._nextAutoLevel=-1;return}if(!K)return;var O=R>-1&&R!==F,M=!!J||O;if(!M&&(j.paused||!j.playbackRate||!j.readyState))return;var L=G.mainForwardBufferInfo;if(!M&&L===null)return;var I=Y.bwEstimator.getEstimateTTFB(),w=Math.abs(j.playbackRate);if(E<=Math.max(I,1000*(A/(w*2))))return;var S=L?L.len/w:0,P=U.loading.first?U.loading.first-U.loading.start:-1,b=U.loaded&&P>-1,C=Y.getBwEstimate(),x=G.levels,_=x[F],y=Math.max(U.loaded,Math.round(A*(N.bitrate||_.averageBitrate)/8)),T=b?E-P:E;if(T<1&&b)T=Math.min(E,U.loaded*8/C);var h=b?U.loaded*1000/T:0,g=I/1000,m=h?(y-U.loaded)/h:y*8/C+g;if(m<=S)return;var p=h?h*8:C,r=((X=(J==null?void 0:J.details)||Y.hls.latestLevelDetails)==null?void 0:X.live)===!0,n=Y.hls.config.abrBandWidthUpFactor,a=Number.POSITIVE_INFINITY,l;for(l=F-1;l>B;l--){var X0=x[l].maxBitrate,t=!x[l].details||r;if(a=Y.getTimeToLoadFrag(g,p,A*X0,t),a<Math.min(S,A+g))break}if(a>=m)return;if(a>A*10)return;if(b)Y.bwEstimator.sample(E-Math.min(I,P),U.loaded);else Y.bwEstimator.sampleTTFB(E);var q0=x[l].maxBitrate;if(Y.getBwEstimate()*n>q0)Y.resetEstimator(q0);var R0=Y.findBestLevel(q0,B,l,0,S,1,1);if(R0>-1)l=R0;Y.warn("Fragment "+N.sn+(W?" part "+W.index:"")+" of level "+F+` is loading too slowly;
2
+ Fragment duration: `+N.duration.toFixed(3)+`
3
+ Time to underbuffer: `+S.toFixed(3)+` s
4
+ Estimated load time for current fragment: `+m.toFixed(3)+` s
5
+ Estimated load time for down switch fragment: `+a.toFixed(3)+` s
6
+ TTFB estimate: `+(P|0)+` ms
7
+ Current BW estimate: `+(v(C)?C|0:"Unknown")+` bps
8
+ New BW estimate: `+(Y.getBwEstimate()|0)+` bps
9
+ Switching to level `+l+" @ "+(q0|0)+" bps"),G.nextLoadLevel=G.nextAutoLevel=l,Y.clearTimer();var U0=function e(){if(Y.clearTimer(),Y.fragCurrent===N&&Y.hls.loadLevel===l&&l>0){var M0=Y.getStarvationDelay();if(Y.warn("Aborting inflight request "+(l>0?"and switching down":"")+`
10
+ Fragment duration: `+N.duration.toFixed(3)+` s
11
+ Time to underbuffer: `+M0.toFixed(3)+" s"),N.abortRequests(),Y.fragCurrent=Y.partCurrent=null,l>B){var z0=Y.findBestLevel(Y.hls.levels[B].bitrate,B,l,0,M0,1,1);if(z0===-1)z0=B;Y.hls.nextLoadLevel=Y.hls.nextAutoLevel=z0,Y.resetEstimator(Y.hls.levels[z0].bitrate)}}};if(O||m>a*2)U0();else Y.timer=self.setInterval(U0,a*1000);G.trigger($.FRAG_LOAD_EMERGENCY_ABORTED,{frag:N,part:W,stats:U})},Y.hls=Q,Y.bwEstimator=Y.initEstimator(),Y.registerListeners(),Y}G0(H,q);var Z=H.prototype;return Z.resetEstimator=function Q(Y){if(Y)this.log("setting initial bwe to "+Y),this.hls.config.abrEwmaDefaultEstimate=Y;this.firstSelection=-1,this.bwEstimator=this.initEstimator()},Z.initEstimator=function Q(){var Y=this.hls.config;return new lJ(Y.abrEwmaSlowVoD,Y.abrEwmaFastVoD,Y.abrEwmaDefaultEstimate)},Z.registerListeners=function Q(){var Y=this.hls;Y.on($.MANIFEST_LOADING,this.onManifestLoading,this),Y.on($.FRAG_LOADING,this.onFragLoading,this),Y.on($.FRAG_LOADED,this.onFragLoaded,this),Y.on($.FRAG_BUFFERED,this.onFragBuffered,this),Y.on($.LEVEL_SWITCHING,this.onLevelSwitching,this),Y.on($.LEVEL_LOADED,this.onLevelLoaded,this),Y.on($.LEVELS_UPDATED,this.onLevelsUpdated,this),Y.on($.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),Y.on($.ERROR,this.onError,this)},Z.unregisterListeners=function Q(){var Y=this.hls;if(!Y)return;Y.off($.MANIFEST_LOADING,this.onManifestLoading,this),Y.off($.FRAG_LOADING,this.onFragLoading,this),Y.off($.FRAG_LOADED,this.onFragLoaded,this),Y.off($.FRAG_BUFFERED,this.onFragBuffered,this),Y.off($.LEVEL_SWITCHING,this.onLevelSwitching,this),Y.off($.LEVEL_LOADED,this.onLevelLoaded,this),Y.off($.LEVELS_UPDATED,this.onLevelsUpdated,this),Y.off($.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),Y.off($.ERROR,this.onError,this)},Z.destroy=function Q(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null},Z.onManifestLoading=function Q(Y,J){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()},Z.onLevelsUpdated=function Q(){if(this.lastLoadedFragLevel>-1&&this.fragCurrent)this.lastLoadedFragLevel=this.fragCurrent.level;this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null},Z.onMaxAutoLevelUpdated=function Q(){this.firstSelection=-1,this.nextAutoLevelKey=""},Z.onFragLoading=function Q(Y,J){var X=J.frag;if(this.ignoreFragment(X))return;if(!X.bitrateTest){var z;this.fragCurrent=X,this.partCurrent=(z=J.part)!=null?z:null}this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)},Z.onLevelSwitching=function Q(Y,J){this.clearTimer()},Z.onError=function Q(Y,J){if(J.fatal)return;switch(J.details){case D.BUFFER_ADD_CODEC_ERROR:case D.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case D.FRAG_LOAD_TIMEOUT:{var X=J.frag,z=this.fragCurrent,N=this.partCurrent;if(X&&z&&X.sn===z.sn&&X.level===z.level){var W=performance.now(),G=N?N.stats:X.stats,K=W-G.loading.start,j=G.loading.first?G.loading.first-G.loading.start:-1,V=G.loaded&&j>-1;if(V){var U=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(K-Math.min(U,j),G.loaded)}else this.bwEstimator.sampleTTFB(K)}break}}},Z.getTimeToLoadFrag=function Q(Y,J,X,z){var N=Y+X/J,W=z?Y+this.lastLevelLoadSec:0;return N+W},Z.onLevelLoaded=function Q(Y,J){var X=this.hls.config,z=J.stats.loading,N=z.end-z.first;if(v(N))this.lastLevelLoadSec=N/1000;if(J.details.live)this.bwEstimator.update(X.abrEwmaSlowLive,X.abrEwmaFastLive);else this.bwEstimator.update(X.abrEwmaSlowVoD,X.abrEwmaFastVoD);if(this.timer>-1)this._abandonRulesCheck(J.levelInfo)},Z.onFragLoaded=function Q(Y,J){var{frag:X,part:z}=J,N=z?z.stats:X.stats;if(X.type===d.MAIN)this.bwEstimator.sampleTTFB(N.loading.first-N.loading.start);if(this.ignoreFragment(X))return;if(this.clearTimer(),X.level===this._nextAutoLevel)this._nextAutoLevel=-1;if(this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){var W=z?z.duration:X.duration,G=this.hls.levels[X.level],K=(G.loaded?G.loaded.bytes:0)+N.loaded,j=(G.loaded?G.loaded.duration:0)+W;G.loaded={bytes:K,duration:j},G.realBitrate=Math.round(8*K/j)}if(X.bitrateTest){var V={stats:N,frag:X,part:z,id:X.type};this.onFragBuffered($.FRAG_BUFFERED,V),X.bitrateTest=!1}else this.lastLoadedFragLevel=X.level},Z.onFragBuffered=function Q(Y,J){var{frag:X,part:z}=J,N=z!=null&&z.stats.loaded?z.stats:X.stats;if(N.aborted)return;if(this.ignoreFragment(X))return;var W=N.parsing.end-N.loading.start-Math.min(N.loading.first-N.loading.start,this.bwEstimator.getEstimateTTFB());if(this.bwEstimator.sample(W,N.loaded),N.bwEstimate=this.getBwEstimate(),X.bitrateTest)this.bitrateTestDelay=W/1000;else this.bitrateTestDelay=0},Z.ignoreFragment=function Q(Y){return Y.type!==d.MAIN||Y.sn==="initSegment"},Z.clearTimer=function Q(){if(this.timer>-1)self.clearInterval(this.timer),this.timer=-1},Z.getAutoLevelKey=function Q(){return this.getBwEstimate()+"_"+this.getStarvationDelay().toFixed(2)},Z.getNextABRAutoLevel=function Q(){var Y=this.fragCurrent,J=this.partCurrent,X=this.hls;if(X.levels.length<=1)return X.loadLevel;var{maxAutoLevel:z,config:N,minAutoLevel:W}=X,G=J?J.duration:Y?Y.duration:0,K=this.getBwEstimate(),j=this.getStarvationDelay(),V=N.abrBandWidthFactor,U=N.abrBandWidthUpFactor;if(j){var A=this.findBestLevel(K,W,z,j,0,V,U);if(A>=0)return this.rebufferNotice=-1,A}var E=G?Math.min(G,N.maxStarvationDelay):N.maxStarvationDelay;if(!j){var B=this.bitrateTestDelay;if(B){var F=G?Math.min(G,N.maxLoadingDelay):N.maxLoadingDelay;E=F-B,this.info("bitrate test took "+Math.round(1000*B)+"ms, set first fragment max fetchDuration to "+Math.round(1000*E)+" ms"),V=U=1}}var R=this.findBestLevel(K,W,z,j,E,V,U);if(this.rebufferNotice!==R)this.rebufferNotice=R,this.info((j?"rebuffering expected":"buffer is empty")+", optimal quality level "+R);if(R>-1)return R;var O=X.levels[W],M=X.loadLevelObj;if(M&&(O==null?void 0:O.bitrate)<M.bitrate)return W;return X.loadLevel},Z.getStarvationDelay=function Q(){var Y=this.hls,J=Y.media;if(!J)return 1/0;var X=J&&J.playbackRate!==0?Math.abs(J.playbackRate):1,z=Y.mainForwardBufferInfo;return(z?z.len:0)/X},Z.getBwEstimate=function Q(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate},Z.findBestLevel=function Q(Y,J,X,z,N,W,G){var K,j=this,V=z+N,U=this.lastLoadedFragLevel,A=U===-1?this.hls.firstLevel:U,E=this.fragCurrent,B=this.partCurrent,F=this.hls,R=F.levels,O=F.allAudioTracks,M=F.loadLevel,L=F.config;if(R.length===1)return 0;var I=R[A],w=!!((K=this.hls.latestLevelDetails)!=null&&K.live),S=M===-1||U===-1,P,b="SDR",C=(I==null?void 0:I.frameRate)||0,x=L.audioPreference,_=L.videoPreference,y=this.audioTracksByGroup||(this.audioTracksByGroup=qQ(O)),T=-1;if(S){if(this.firstSelection!==-1)return this.firstSelection;var h=this.codecTiers||(this.codecTiers=w8(R,y,J,X)),g=I8(h,b,Y,x,_),m=g.codecSet,p=g.videoRanges,r=g.minFramerate,n=g.minBitrate,a=g.minIndex,l=g.preferHDR;T=a,P=m,b=l?p[p.length-1]:p[0],C=r,Y=Math.max(Y,n),this.log("picked start tier "+$0(g))}else P=I==null?void 0:I.codecSet,b=I==null?void 0:I.videoRange;var X0=B?B.duration:E?E.duration:0,t=this.bwEstimator.getEstimateTTFB()/1000,q0=[],R0=function M0(){var z0,J0=R[e],I0=e>A;if(!J0)return 0;if(P&&J0.codecSet!==P||b&&J0.videoRange!==b||I0&&C>J0.frameRate||!I0&&C>0&&C<J0.frameRate||J0.supportedResult&&!((z0=J0.supportedResult.decodingInfoResults)!=null&&z0[0].smooth)){if(!S||e!==T)return q0.push(e),0}var E0=J0.details,b0=(B?E0==null?void 0:E0.partTarget:E0==null?void 0:E0.averagetargetduration)||X0,Y0;if(!I0)Y0=W*Y;else Y0=G*Y;var B0=X0&&z>=X0*2&&N===0?J0.averageBitrate:J0.maxBitrate,N0=j.getTimeToLoadFrag(t,Y0,B0*b0,E0===void 0),w0=Y0>=B0&&(e===U||J0.loadError===0&&J0.fragmentError===0)&&(N0<=t||!v(N0)||w&&!j.bitrateTestDelay||N0<V);if(w0){var jY=j.forcedAutoLevel;if(e!==M&&(jY===-1||jY!==M)){if(q0.length)j.trace("Skipped level(s) "+q0.join(",")+" of "+X+' max with CODECS and VIDEO-RANGE:"'+R[q0[0]].codecs+'" '+R[q0[0]].videoRange+'; not compatible with "'+P+'" '+b);j.info("switch candidate:"+A+"->"+e+" adjustedbw("+Math.round(Y0)+")-bitrate="+Math.round(Y0-B0)+" ttfb:"+t.toFixed(1)+" avgDuration:"+b0.toFixed(1)+" maxFetchDuration:"+V.toFixed(1)+" fetchDuration:"+N0.toFixed(1)+" firstSelection:"+S+" codecSet:"+J0.codecSet+" videoRange:"+J0.videoRange+" hls.loadLevel:"+M)}if(S)j.firstSelection=e;return{v:e}}},U0;for(var e=X;e>=J;e--){if(U0=R0(),U0===0)continue;if(U0)return U0.v}return-1},Z.deriveNextAutoLevel=function Q(Y){var J=this.hls,X=J.maxAutoLevel,z=J.minAutoLevel;return Math.min(Math.max(Y,z),X)},Z0(H,[{key:"firstAutoLevel",get:function Q(){var Y=this.hls,J=Y.maxAutoLevel,X=Y.minAutoLevel,z=this.getBwEstimate(),N=this.hls.config.maxStarvationDelay,W=this.findBestLevel(z,X,J,0,N,1,1);if(W>-1)return W;var G=this.hls.firstLevel,K=Math.min(Math.max(G,X),J);return this.warn("Could not find best starting auto level. Defaulting to first in playlist "+G+" clamped to "+K),K}},{key:"forcedAutoLevel",get:function Q(){if(this.nextAutoLevelKey)return-1;return this._nextAutoLevel}},{key:"nextAutoLevel",get:function Q(){var Y=this.forcedAutoLevel,J=this.bwEstimator,X=J.canEstimate(),z=this.lastLoadedFragLevel>-1;if(Y!==-1&&(!X||!z||this.nextAutoLevelKey===this.getAutoLevelKey()))return Y;var N=X&&z?this.getNextABRAutoLevel():this.firstAutoLevel;if(Y!==-1){var W=this.hls.levels;if(W.length>Math.max(Y,N)&&W[Y].loadError<=W[N].loadError)return Y}return this._nextAutoLevel=N,this.nextAutoLevelKey=this.getAutoLevelKey(),N},set:function Q(Y){var J=this.deriveNextAutoLevel(Y);if(this._nextAutoLevel!==J)this.nextAutoLevelKey="",this._nextAutoLevel=J}}])}(i0),b8=function(){function q(Z){this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=Z}var H=q.prototype;return H.destroy=function Z(){this.tracks=this.queues=null},H.append=function Z(Q,Y,J){if(this.queues===null||this.tracks===null)return;var X=this.queues[Y];if(X.push(Q),X.length===1&&!J)this.executeNext(Y)},H.appendBlocker=function Z(Q){var Y=this;return new Promise(function(J){var X={label:"async-blocker",execute:J,onStart:function z(){},onComplete:function z(){},onError:function z(){}};Y.append(X,Q)})},H.prependBlocker=function Z(Q){var Y=this;return new Promise(function(J){if(Y.queues){var X={label:"async-blocker-prepend",execute:J,onStart:function z(){},onComplete:function z(){},onError:function z(){}};Y.queues[Q].unshift(X)}})},H.removeBlockers=function Z(){if(this.queues===null)return;[this.queues.video,this.queues.audio,this.queues.audiovideo].forEach(function(Q){var Y,J=(Y=Q[0])==null?void 0:Y.label;if(J==="async-blocker"||J==="async-blocker-prepend")Q[0].execute(),Q.splice(0,1)})},H.unblockAudio=function Z(Q){if(this.queues===null)return;var Y=this.queues.audio;if(Y[0]===Q)this.shiftAndExecuteNext("audio")},H.executeNext=function Z(Q){if(this.queues===null||this.tracks===null)return;var Y=this.queues[Q];if(Y.length){var J=Y[0];try{J.execute()}catch(N){var X;if(J.onError(N),this.queues===null||this.tracks===null)return;var z=(X=this.tracks[Q])==null?void 0:X.buffer;if(!(z!=null&&z.updating))this.shiftAndExecuteNext(Q)}}},H.shiftAndExecuteNext=function Z(Q){if(this.queues===null)return;this.queues[Q].shift(),this.executeNext(Q)},H.current=function Z(Q){var Y;return((Y=this.queues)==null?void 0:Y[Q][0])||null},H.toString=function Z(){var Q=this.queues,Y=this.tracks;if(Q===null||Y===null)return"<destroyed>";return`
12
+ `+this.list("video")+`
13
+ `+this.list("audio")+`
14
+ `+this.list("audiovideo")+"}"},H.list=function Z(Q){var Y,J;return(Y=this.queues)!=null&&Y[Q]||(J=this.tracks)!=null&&J[Q]?Q+": ("+this.listSbInfo(Q)+") "+this.listOps(Q):""},H.listSbInfo=function Z(Q){var Y,J=(Y=this.tracks)==null?void 0:Y[Q],X=J==null?void 0:J.buffer;if(!X)return"none";return"SourceBuffer"+(X.updating?" updating":"")+(J.ended?" ended":"")+(J.ending?" ending":"")},H.listOps=function Z(Q){var Y;return((Y=this.queues)==null?void 0:Y[Q].map(function(J){return J.label}).join(", "))||""},q}(),HQ={search:function q(H,Z){var Q=0,Y=H.length-1,J=null,X=null;while(Q<=Y){J=(Q+Y)/2|0,X=H[J];var z=Z(X);if(z>0)Q=J+1;else if(z<0)Y=J-1;else return X}return null}};function C8(q,H,Z){if(H===null||!Array.isArray(q)||!q.length||!v(H))return null;var Q=q[0].programDateTime;if(H<(Q||0))return null;var Y=q[q.length-1].endProgramDateTime;if(H>=(Y||0))return null;Z=Z||0;for(var J=0;J<q.length;++J){var X=q[J];if(D8(H,Z,X))return X}return null}function eY(q,H,Z,Q,Y){if(Z===void 0)Z=0;if(Q===void 0)Q=0;if(Y===void 0)Y=0.005;var J=null;if(q){J=H[1+q.sn-H[0].sn]||null;var X=q.endDTS-Z;if(X>0&&X<0.0000015)Z+=0.0000015;if(J&&q.level!==J.level&&J.end<=q.end)J=H[2+q.sn-H[0].sn]||null}else if(Z===0&&H[0].start===0)J=H[0];if(J&&((!q||q.level===J.level)&&zQ(Z,Q,J)===0||P8(J,q,Math.min(Y,Q))))return J;var z=HQ.search(H,zQ.bind(null,Z,Q));if(z&&(z!==q||!J))return z;return J}function P8(q,H,Z){if(H&&H.start===0&&H.level<q.level&&(H.endPTS||0)>0){var Q=H.tagList.reduce(function(Y,J){if(J[0]==="INF")Y+=parseFloat(J[1]);return Y},Z);return q.start<=Q}return!1}function zQ(q,H,Z){if(q===void 0)q=0;if(H===void 0)H=0;if(Z.start<=q&&Z.start+Z.duration>q)return 0;var Q=Math.min(H,Z.duration+(Z.deltaPTS?Z.deltaPTS:0));if(Z.start+Z.duration-Q<=q)return 1;else if(Z.start-Q>q&&Z.start)return-1;return 0}function D8(q,H,Z){var Q=Math.min(H,Z.duration+(Z.deltaPTS?Z.deltaPTS:0))*1000,Y=Z.endProgramDateTime||0;return Y-Q>q}function S8(q,H){return HQ.search(q,function(Z){if(Z.cc<H)return 1;else if(Z.cc>H)return-1;else return 0})}function RY(q){switch(q.details){case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_TIMEOUT:case D.LEVEL_LOAD_TIMEOUT:case D.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function NQ(q,H){var Z=RY(H);return q.default[(Z?"timeout":"error")+"Retry"]}function Y7(q,H){var Z=q.backoff==="linear"?1:Math.pow(2,H);return Math.min(Z*q.retryDelayMs,q.maxRetryDelayMs)}function WQ(q){return F0(F0({},q),{errorRetry:null,timeoutRetry:null})}function MY(q,H,Z,Q){if(!q)return!1;var Y=Q==null?void 0:Q.code,J=H<q.maxNumRetry&&(x8(Y)||!!Z);return q.shouldRetry?q.shouldRetry(q,H,Z,Q,J):J}function x8(q){return q===0&&navigator.onLine===!1||!!q&&(q<400||q>499)}var A0={DoNothing:0,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,RetryRequest:5},S0={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2},T8=function(q){function H(Q){var Y=q.call(this,"error-controller",Q.logger)||this;return Y.hls=void 0,Y.playlistError=0,Y.penalizedRenditions={},Y.hls=Q,Y.registerListeners(),Y}G0(H,q);var Z=H.prototype;return Z.registerListeners=function Q(){var Y=this.hls;Y.on($.ERROR,this.onError,this),Y.on($.MANIFEST_LOADING,this.onManifestLoading,this),Y.on($.LEVEL_UPDATED,this.onLevelUpdated,this)},Z.unregisterListeners=function Q(){var Y=this.hls;if(!Y)return;Y.off($.ERROR,this.onError,this),Y.off($.ERROR,this.onErrorOut,this),Y.off($.MANIFEST_LOADING,this.onManifestLoading,this),Y.off($.LEVEL_UPDATED,this.onLevelUpdated,this)},Z.destroy=function Q(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}},Z.startLoad=function Q(Y){},Z.stopLoad=function Q(){this.playlistError=0},Z.getVariantLevelIndex=function Q(Y){return(Y==null?void 0:Y.type)===d.MAIN?Y.level:this.hls.loadLevel},Z.onManifestLoading=function Q(){this.playlistError=0,this.penalizedRenditions={}},Z.onLevelUpdated=function Q(){this.playlistError=0},Z.onError=function Q(Y,J){var X;if(J.fatal)return;var z=this.hls,N=J.context;switch(J.details){case D.FRAG_LOAD_ERROR:case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_ERROR:case D.KEY_LOAD_TIMEOUT:J.errorAction=this.getFragRetryOrSwitchAction(J);return;case D.FRAG_PARSING_ERROR:if((X=J.frag)!=null&&X.gap){J.errorAction=IY();return}case D.FRAG_GAP:case D.FRAG_DECRYPT_ERROR:{J.errorAction=this.getFragRetryOrSwitchAction(J),J.errorAction.action=A0.SendAlternateToPenaltyBox;return}case D.LEVEL_EMPTY_ERROR:case D.LEVEL_PARSING_ERROR:{var W,G,K=J.parent===d.MAIN?J.level:z.loadLevel;if(J.details===D.LEVEL_EMPTY_ERROR&&!!((W=J.context)!=null&&(G=W.levelDetails)!=null&&G.live))J.errorAction=this.getPlaylistRetryOrSwitchAction(J,K);else J.levelRetry=!1,J.errorAction=this.getLevelSwitchAction(J,K)}return;case D.LEVEL_LOAD_ERROR:case D.LEVEL_LOAD_TIMEOUT:if(typeof(N==null?void 0:N.level)==="number")J.errorAction=this.getPlaylistRetryOrSwitchAction(J,N.level);return;case D.AUDIO_TRACK_LOAD_ERROR:case D.AUDIO_TRACK_LOAD_TIMEOUT:case D.SUBTITLE_LOAD_ERROR:case D.SUBTITLE_TRACK_LOAD_TIMEOUT:if(N){var j=z.loadLevelObj;if(j&&(N.type===o.AUDIO_TRACK&&j.hasAudioGroup(N.groupId)||N.type===o.SUBTITLE_TRACK&&j.hasSubtitleGroup(N.groupId))){J.errorAction=this.getPlaylistRetryOrSwitchAction(J,z.loadLevel),J.errorAction.action=A0.SendAlternateToPenaltyBox,J.errorAction.flags=S0.MoveAllAlternatesMatchingHost;return}}return;case D.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{var V=z.loadLevelObj,U=V==null?void 0:V.attrs["HDCP-LEVEL"];if(U)J.errorAction={action:A0.SendAlternateToPenaltyBox,flags:S0.MoveAllAlternatesMatchingHDCP,hdcpLevel:U};else this.keySystemError(J)}return;case D.BUFFER_ADD_CODEC_ERROR:case D.REMUX_ALLOC_ERROR:case D.BUFFER_APPEND_ERROR:if(!J.errorAction){var A;J.errorAction=this.getLevelSwitchAction(J,(A=J.level)!=null?A:z.loadLevel)}return;case D.INTERNAL_EXCEPTION:case D.BUFFER_APPENDING_ERROR:case D.BUFFER_FULL_ERROR:case D.LEVEL_SWITCH_ERROR:case D.BUFFER_STALLED_ERROR:case D.BUFFER_SEEK_OVER_HOLE:case D.BUFFER_NUDGE_ON_STALL:J.errorAction=IY();return}if(J.type===f.KEY_SYSTEM_ERROR)this.keySystemError(J)},Z.keySystemError=function Q(Y){var J=this.getVariantLevelIndex(Y.frag);Y.levelRetry=!1,Y.errorAction=this.getLevelSwitchAction(Y,J)},Z.getPlaylistRetryOrSwitchAction=function Q(Y,J){var X=this.hls,z=NQ(X.config.playlistLoadPolicy,Y),N=this.playlistError++,W=MY(z,N,RY(Y),Y.response);if(W)return{action:A0.RetryRequest,flags:S0.None,retryConfig:z,retryCount:N};var G=this.getLevelSwitchAction(Y,J);if(z)G.retryConfig=z,G.retryCount=N;return G},Z.getFragRetryOrSwitchAction=function Q(Y){var J=this.hls,X=this.getVariantLevelIndex(Y.frag),z=J.levels[X],N=J.config,W=N.fragLoadPolicy,G=N.keyLoadPolicy,K=NQ(Y.details.startsWith("key")?G:W,Y),j=J.levels.reduce(function(A,E){return A+E.fragmentError},0);if(z){if(Y.details!==D.FRAG_GAP)z.fragmentError++;var V=MY(K,j,RY(Y),Y.response);if(V)return{action:A0.RetryRequest,flags:S0.None,retryConfig:K,retryCount:j}}var U=this.getLevelSwitchAction(Y,X);if(K)U.retryConfig=K,U.retryCount=j;return U},Z.getLevelSwitchAction=function Q(Y,J){var X=this.hls;if(J===null||J===void 0)J=X.loadLevel;var z=this.hls.levels[J];if(z){var N,W,G=Y.details;if(z.loadError++,G===D.BUFFER_APPEND_ERROR)z.fragmentError++;var K=-1,j=X.levels,V=X.loadLevel,U=X.minAutoLevel,A=X.maxAutoLevel;if(!X.autoLevelEnabled)X.loadLevel=-1;var E=(N=Y.frag)==null?void 0:N.type,B=E===d.AUDIO&&G===D.FRAG_PARSING_ERROR||Y.sourceBufferName==="audio"&&(G===D.BUFFER_ADD_CODEC_ERROR||G===D.BUFFER_APPEND_ERROR),F=B&&j.some(function(b){var C=b.audioCodec;return z.audioCodec!==C}),R=Y.sourceBufferName==="video"&&(G===D.BUFFER_ADD_CODEC_ERROR||G===D.BUFFER_APPEND_ERROR),O=R&&j.some(function(b){var{codecSet:C,audioCodec:x}=b;return z.codecSet!==C&&z.audioCodec===x}),M=(W=Y.context)!=null?W:{},L=M.type,I=M.groupId,w=function b(){var C=(P+V)%j.length;if(C!==V&&C>=U&&C<=A&&j[C].loadError===0){var x,_,y=j[C];if(G===D.FRAG_GAP&&E===d.MAIN&&Y.frag){var T=j[C].details;if(T){var h=eY(Y.frag,T.fragments,Y.frag.start);if(h!=null&&h.gap)return 0}}else if(L===o.AUDIO_TRACK&&y.hasAudioGroup(I)||L===o.SUBTITLE_TRACK&&y.hasSubtitleGroup(I))return 0;else if(E===d.AUDIO&&(x=z.audioGroups)!=null&&x.some(function(g){return y.hasAudioGroup(g)})||E===d.SUBTITLE&&(_=z.subtitleGroups)!=null&&_.some(function(g){return y.hasSubtitleGroup(g)})||F&&z.audioCodec===y.audioCodec||!F&&z.audioCodec!==y.audioCodec||O&&z.codecSet===y.codecSet)return 0;return K=C,1}},S;for(var P=j.length;P--;){if(S=w(),S===0)continue;if(S===1)break}if(K>-1&&X.loadLevel!==K)return Y.levelRetry=!0,this.playlistError=0,{action:A0.SendAlternateToPenaltyBox,flags:S0.None,nextAutoLevel:K}}return{action:A0.SendAlternateToPenaltyBox,flags:S0.MoveAllAlternatesMatchingHost}},Z.onErrorOut=function Q(Y,J){var X;switch((X=J.errorAction)==null?void 0:X.action){case A0.DoNothing:break;case A0.SendAlternateToPenaltyBox:if(this.sendAlternateToPenaltyBox(J),!J.errorAction.resolved&&J.details!==D.FRAG_GAP)J.fatal=!0;else if(/MediaSource readyState: ended/.test(J.error.message))this.warn('MediaSource ended after "'+J.sourceBufferName+'" sourceBuffer append error. Attempting to recover from media error.'),this.hls.recoverMediaError();break}if(J.fatal){this.hls.stopLoad();return}},Z.sendAlternateToPenaltyBox=function Q(Y){var J=this.hls,X=Y.errorAction;if(!X)return;var{flags:z,hdcpLevel:N,nextAutoLevel:W}=X;switch(z){case S0.None:this.switchLevel(Y,W);break;case S0.MoveAllAlternatesMatchingHDCP:if(N)J.maxHdcpLevel=tY[tY.indexOf(N)-1],X.resolved=!0;this.warn('Restricting playback to HDCP-LEVEL of "'+J.maxHdcpLevel+'" or lower');break}if(!X.resolved)this.switchLevel(Y,W)},Z.switchLevel=function Q(Y,J){if(J!==void 0&&Y.errorAction){if(this.warn("switching to level "+J+" after "+Y.details),this.hls.nextAutoLevel=J,Y.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel,Y.details===D.BUFFER_ADD_CODEC_ERROR&&Y.mimeType&&Y.sourceBufferName!=="audiovideo"){var X=e7(Y.mimeType),z=this.hls.levels;for(var N=z.length;N--;)if(z[N][Y.sourceBufferName+"Codec"]===X)this.hls.removeLevel(N)}}},H}(i0);function IY(q){var H={action:A0.DoNothing,flags:S0.None};if(q)H.resolved=!0;return H}var GQ={length:0,start:function q(){return 0},end:function q(){return 0}},i=function(){function q(){}return q.isBuffered=function H(Z,Q){if(Z){var Y=q.getBuffered(Z);for(var J=Y.length;J--;)if(Q>=Y.start(J)&&Q<=Y.end(J))return!0}return!1},q.bufferedRanges=function H(Z){if(Z){var Q=q.getBuffered(Z);return q.timeRangesToArray(Q)}return[]},q.timeRangesToArray=function H(Z){var Q=[];for(var Y=0;Y<Z.length;Y++)Q.push({start:Z.start(Y),end:Z.end(Y)});return Q},q.bufferInfo=function H(Z,Q,Y){if(Z){var J=q.bufferedRanges(Z);if(J.length)return q.bufferedInfo(J,Q,Y)}return{len:0,start:Q,end:Q,bufferedIndex:-1}},q.bufferedInfo=function H(Z,Q,Y){if(Q=Math.max(0,Q),Z.length>1)Z.sort(function(B,F){return B.start-F.start||F.end-B.end});var J=-1,X=[];if(Y)for(var z=0;z<Z.length;z++){if(Q>=Z[z].start&&Q<=Z[z].end)J=z;var N=X.length;if(N){var W=X[N-1].end;if(Z[z].start-W<Y){if(Z[z].end>W)X[N-1].end=Z[z].end}else X.push(Z[z])}else X.push(Z[z])}else X=Z;var G=0,K,j=Q,V=Q;for(var U=0;U<X.length;U++){var A=X[U].start,E=X[U].end;if(J===-1&&Q>=A&&Q<=E)J=U;if(Q+Y>=A&&Q<E)j=A,V=E,G=V-Q;else if(Q+Y<A){K=A;break}}return{len:G,start:j||0,end:V||0,nextStart:K,buffered:Z,bufferedIndex:J}},q.getBuffered=function H(Z){try{return Z.buffered||GQ}catch(Q){return s.log("failed to get media.buffered",Q),GQ}},q}(),KQ=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,jQ="HlsJsTrackRemovedError",y8=function(q){function H(Z){var Q=q.call(this,Z)||this;return Q.name=jQ,Q}return G0(H,q),H}(qY(Error)),k8=function(q){function H(Q,Y){var J=q.call(this,"buffer-controller",Q.logger)||this;return J.hls=void 0,J.fragmentTracker=void 0,J.details=null,J._objectUrl=null,J.operationQueue=null,J.bufferCodecEventsTotal=0,J.media=null,J.mediaSource=null,J.lastMpegAudioChunk=null,J.blockedAudioAppend=null,J.lastVideoAppendEnd=0,J.appendSource=void 0,J.transferData=void 0,J.overrides=void 0,J.appendErrors={audio:0,video:0,audiovideo:0},J.tracks={},J.sourceBuffers=[[null,null],[null,null]],J._onEndStreaming=function(X){var z;if(!J.hls)return;if(((z=J.mediaSource)==null?void 0:z.readyState)!=="open")return;J.hls.pauseBuffering()},J._onStartStreaming=function(X){if(!J.hls)return;J.hls.resumeBuffering()},J._onMediaSourceOpen=function(X){var z=J,N=z.media,W=z.mediaSource;if(X)J.log("Media source opened");if(!N||!W)return;if(W.removeEventListener("sourceopen",J._onMediaSourceOpen),N.removeEventListener("emptied",J._onMediaEmptied),J.updateDuration(),J.hls.trigger($.MEDIA_ATTACHED,{media:N,mediaSource:W}),J.mediaSource!==null)J.checkPendingTracks()},J._onMediaSourceClose=function(){J.log("Media source closed")},J._onMediaSourceEnded=function(){J.log("Media source ended")},J._onMediaEmptied=function(){var X=J,z=X.mediaSrc,N=X._objectUrl;if(z!==N)J.error("Media element src was set while attaching MediaSource ("+N+" > "+z+")")},J.hls=Q,J.fragmentTracker=Y,J.appendSource=K8(d0(Q.config.preferManagedMediaSource)),J.initTracks(),J.registerListeners(),J}G0(H,q);var Z=H.prototype;return Z.hasSourceTypes=function Q(){return Object.keys(this.tracks).length>0},Z.destroy=function Q(){if(this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.transferData=this.overrides=void 0,this.operationQueue)this.operationQueue.destroy(),this.operationQueue=null;this.hls=this.fragmentTracker=null,this._onMediaSourceOpen=this._onMediaSourceClose=null,this._onMediaSourceEnded=null,this._onStartStreaming=this._onEndStreaming=null},Z.registerListeners=function Q(){var Y=this.hls;Y.on($.MEDIA_ATTACHING,this.onMediaAttaching,this),Y.on($.MEDIA_DETACHING,this.onMediaDetaching,this),Y.on($.MANIFEST_LOADING,this.onManifestLoading,this),Y.on($.MANIFEST_PARSED,this.onManifestParsed,this),Y.on($.BUFFER_RESET,this.onBufferReset,this),Y.on($.BUFFER_APPENDING,this.onBufferAppending,this),Y.on($.BUFFER_CODECS,this.onBufferCodecs,this),Y.on($.BUFFER_EOS,this.onBufferEos,this),Y.on($.BUFFER_FLUSHING,this.onBufferFlushing,this),Y.on($.LEVEL_UPDATED,this.onLevelUpdated,this),Y.on($.FRAG_PARSED,this.onFragParsed,this),Y.on($.FRAG_CHANGED,this.onFragChanged,this),Y.on($.ERROR,this.onError,this)},Z.unregisterListeners=function Q(){var Y=this.hls;Y.off($.MEDIA_ATTACHING,this.onMediaAttaching,this),Y.off($.MEDIA_DETACHING,this.onMediaDetaching,this),Y.off($.MANIFEST_LOADING,this.onManifestLoading,this),Y.off($.MANIFEST_PARSED,this.onManifestParsed,this),Y.off($.BUFFER_RESET,this.onBufferReset,this),Y.off($.BUFFER_APPENDING,this.onBufferAppending,this),Y.off($.BUFFER_CODECS,this.onBufferCodecs,this),Y.off($.BUFFER_EOS,this.onBufferEos,this),Y.off($.BUFFER_FLUSHING,this.onBufferFlushing,this),Y.off($.LEVEL_UPDATED,this.onLevelUpdated,this),Y.off($.FRAG_PARSED,this.onFragParsed,this),Y.off($.FRAG_CHANGED,this.onFragChanged,this),Y.off($.ERROR,this.onError,this)},Z.transferMedia=function Q(){var Y=this,J=this.media,X=this.mediaSource;if(!J)return null;var z={};if(this.operationQueue){var N=this.isUpdating();if(!N)this.operationQueue.removeBlockers();var W=this.isQueued();if(N||W)this.warn("Transfering MediaSource with"+(W?" operations in queue":"")+(N?" updating SourceBuffer(s)":"")+" "+this.operationQueue);this.operationQueue.destroy()}var G=this.transferData;if(!this.sourceBufferCount&&G&&G.mediaSource===X)W0(z,G.tracks);else this.sourceBuffers.forEach(function(K){var j=K[0];if(j)z[j]=W0({},Y.tracks[j]),Y.removeBuffer(j);K[0]=K[1]=null});return{media:J,mediaSource:X,tracks:z}},Z.initTracks=function Q(){var Y={};this.sourceBuffers=[[null,null],[null,null]],this.tracks=Y,this.resetQueue(),this.resetAppendErrors(),this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.lastVideoAppendEnd=0},Z.onManifestLoading=function Q(){this.bufferCodecEventsTotal=0,this.details=null},Z.onManifestParsed=function Q(Y,J){var X,z=2;if(J.audio&&!J.video||J.altAudio,z=1,this.bufferCodecEventsTotal=z,this.log(z+" bufferCodec event(s) expected."),(X=this.transferData)!=null&&X.mediaSource&&this.sourceBufferCount&&z)this.bufferCreated()},Z.onMediaAttaching=function Q(Y,J){var X=this.media=J.media,z=d0(this.appendSource);if(this.transferData=this.overrides=void 0,X&&z){var N=!!J.mediaSource;if(N||J.overrides)this.transferData=J,this.overrides=J.overrides;var W=this.mediaSource=J.mediaSource||new z;if(this.assignMediaSource(W),N)this._objectUrl=X.src,this.attachTransferred();else{var G=this._objectUrl=self.URL.createObjectURL(W);if(this.appendSource)try{X.removeAttribute("src");var K=self.ManagedMediaSource;X.disableRemotePlayback=X.disableRemotePlayback||K&&W instanceof K,UQ(X),_8(X,G),X.load()}catch(j){X.src=G}else X.src=G}X.addEventListener("emptied",this._onMediaEmptied)}},Z.assignMediaSource=function Q(Y){var J,X;if(this.log((((J=this.transferData)==null?void 0:J.mediaSource)===Y?"transferred":"created")+" media source: "+((X=Y.constructor)==null?void 0:X.name)),Y.addEventListener("sourceopen",this._onMediaSourceOpen),Y.addEventListener("sourceended",this._onMediaSourceEnded),Y.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource)Y.addEventListener("startstreaming",this._onStartStreaming),Y.addEventListener("endstreaming",this._onEndStreaming)},Z.attachTransferred=function Q(){var Y=this,J=this.media,X=this.transferData;if(!X||!J)return;var z=this.tracks,N=X.tracks,W=N?Object.keys(N):null,G=W?W.length:0,K=function A(){if(Y.media&&Y.mediaSourceOpenOrEnded)Y._onMediaSourceOpen()};if(N&&W&&G){if(!this.tracksReady){this.hls.config.startFragPrefetch=!0,this.log("attachTransferred: waiting for SourceBuffer track info");return}if(this.log("attachTransferred: (bufferCodecEventsTotal "+this.bufferCodecEventsTotal+`)
15
+ required tracks: `+$0(z,function(A,E){return A==="initSegment"?void 0:E})+`;
16
+ transfer tracks: `+$0(N,function(A,E){return A==="initSegment"?void 0:E})+"}"),!j8(N,z)){X.mediaSource=null,X.tracks=void 0;var j=J.currentTime,V=this.details,U=Math.max(j,(V==null?void 0:V.fragments[0].start)||0);if(U-j>1){this.log("attachTransferred: waiting for playback to reach new tracks start time "+j+" -> "+U);return}this.warn('attachTransferred: resetting MediaSource for incompatible tracks ("'+Object.keys(N)+'"->"'+Object.keys(z)+'") start time: '+U+" currentTime: "+j),this.onMediaDetaching($.MEDIA_DETACHING,{}),this.onMediaAttaching($.MEDIA_ATTACHING,X),J.currentTime=U;return}this.transferData=void 0,W.forEach(function(A){var E=A,B=N[E];if(B){var F=B.buffer;if(F){var R=Y.fragmentTracker,O=B.id;if(R.hasFragments(O)||R.hasParts(O)){var M=i.getBuffered(F);R.detectEvictedFragments(E,M,O,null,!0)}var L=Q7(E),I=[E,F];if(Y.sourceBuffers[L]=I,F.updating&&Y.operationQueue)Y.operationQueue.prependBlocker(E);Y.trackSourceBuffer(E,B)}}}),K(),this.bufferCreated()}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),K()},Z.onMediaDetaching=function Q(Y,J){var X=this,z=!!J.transferMedia;this.transferData=this.overrides=void 0;var N=this.media,W=this.mediaSource,G=this._objectUrl;if(W){if(this.log("media source "+(z?"transferring":"detaching")),z)this.sourceBuffers.forEach(function(U){var A=U[0];if(A)X.removeBuffer(A)}),this.resetQueue();else{if(this.mediaSourceOpenOrEnded){var K=W.readyState==="open";try{var j=W.sourceBuffers;for(var V=j.length;V--;){if(K)j[V].abort();W.removeSourceBuffer(j[V])}if(K)W.endOfStream()}catch(U){this.warn("onMediaDetaching: "+U.message+" while calling endOfStream")}}if(this.sourceBufferCount)this.onBufferReset()}if(W.removeEventListener("sourceopen",this._onMediaSourceOpen),W.removeEventListener("sourceended",this._onMediaSourceEnded),W.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource)W.removeEventListener("startstreaming",this._onStartStreaming),W.removeEventListener("endstreaming",this._onEndStreaming);this.mediaSource=null,this._objectUrl=null}if(N){if(N.removeEventListener("emptied",this._onMediaEmptied),!z){if(G)self.URL.revokeObjectURL(G);if(this.mediaSrc===G){if(N.removeAttribute("src"),this.appendSource)UQ(N);N.load()}else this.warn("media|source.src was changed by a third party - skip cleanup")}this.media=null}this.hls.trigger($.MEDIA_DETACHED,J)},Z.onBufferReset=function Q(){var Y=this;this.sourceBuffers.forEach(function(J){var X=J[0];if(X)Y.resetBuffer(X)}),this.initTracks()},Z.resetBuffer=function Q(Y){var J,X=(J=this.tracks[Y])==null?void 0:J.buffer;if(this.removeBuffer(Y),X)try{var z;if((z=this.mediaSource)!=null&&z.sourceBuffers.length)this.mediaSource.removeSourceBuffer(X)}catch(N){this.warn("onBufferReset "+Y,N)}delete this.tracks[Y]},Z.removeBuffer=function Q(Y){this.removeBufferListeners(Y),this.sourceBuffers[Q7(Y)]=[null,null];var J=this.tracks[Y];if(J)J.buffer=void 0},Z.resetQueue=function Q(){if(this.operationQueue)this.operationQueue.destroy();this.operationQueue=new b8(this.tracks)},Z.onBufferCodecs=function Q(Y,J){var X=this,z=this.tracks,N=Object.keys(J);this.log('BUFFER_CODECS: "'+N+'" (current SB count '+this.sourceBufferCount+")");var W="audiovideo"in J&&(z.audio||z.video)||z.audiovideo&&(("audio"in J)||("video"in J)),G=!W&&this.sourceBufferCount&&this.media&&N.some(function(K){return!z[K]});if(W||G){this.warn('Unsupported transition between "'+Object.keys(z)+'" and "'+N+'" SourceBuffers');return}if(N.forEach(function(K){var j,V,U,A=J[K],E=A.id,B=A.codec,F=A.levelCodec,R=A.container,O=A.metadata,M=A.supplemental,L=z[K],I=(j=X.transferData)==null?void 0:(V=j.tracks)==null?void 0:V[K],w=I!=null&&I.buffer?I:L,S=(w==null?void 0:w.pendingCodec)||(w==null?void 0:w.codec),P=w==null?void 0:w.levelCodec;if(!L)L=z[K]={buffer:void 0,listeners:[],codec:B,supplemental:M,container:R,levelCodec:F,metadata:O,id:E};var b=$Y(S,P),C=b==null?void 0:b.replace(KQ,"$1"),x=$Y(B,F),_=(U=x)==null?void 0:U.replace(KQ,"$1");if(x&&b&&C!==_){if(K.slice(0,5)==="audio")x=BY(x,X.appendSource);if(X.log("switching codec "+S+" to "+x),x!==(L.pendingCodec||L.codec))L.pendingCodec=x;L.container=R,X.appendChangeType(K,R,x)}}),this.tracksReady||this.sourceBufferCount)J.tracks=this.sourceBufferTracks;if(this.sourceBufferCount)return;if(this.mediaSourceOpenOrEnded)this.checkPendingTracks()},Z.appendChangeType=function Q(Y,J,X){var z=this,N=J+";codecs="+X,W={label:"change-type="+N,execute:function G(){var K=z.tracks[Y];if(K){var j=K.buffer;if(j!=null&&j.changeType)z.log("changing "+Y+" sourceBuffer type to "+N),j.changeType(N),K.codec=X,K.container=J}z.shiftAndExecuteNext(Y)},onStart:function G(){},onComplete:function G(){},onError:function G(K){z.warn("Failed to change "+Y+" SourceBuffer type",K)}};this.append(W,Y,this.isPending(this.tracks[Y]))},Z.blockAudio=function Q(Y){var J,X=this,z=Y.start,N=z+Y.duration*0.05,W=((J=this.fragmentTracker.getAppendedFrag(z,d.MAIN))==null?void 0:J.gap)===!0;if(W)return;var G={label:"block-audio",execute:function K(){var j,V=X.tracks.video;if(X.lastVideoAppendEnd>N||V!=null&&V.buffer&&i.isBuffered(V.buffer,N)||((j=X.fragmentTracker.getAppendedFrag(N,d.MAIN))==null?void 0:j.gap)===!0)X.blockedAudioAppend=null,X.shiftAndExecuteNext("audio")},onStart:function K(){},onComplete:function K(){},onError:function K(j){X.warn("Error executing block-audio operation",j)}};this.blockedAudioAppend={op:G,frag:Y},this.append(G,"audio",!0)},Z.unblockAudio=function Q(){var Y=this.blockedAudioAppend,J=this.operationQueue;if(Y&&J)this.blockedAudioAppend=null,J.unblockAudio(Y.op)},Z.onBufferAppending=function Q(Y,J){var X=this,z=this.tracks,N=J.data,W=J.type,G=J.parent,K=J.frag,j=J.part,V=J.chunkMeta,U=V.buffering[W],A=K.sn,E=self.performance.now();U.start=E;var B=K.stats.buffering,F=j?j.stats.buffering:null;if(B.start===0)B.start=E;if(F&&F.start===0)F.start=E;var R=z.audio,O=!1;if(W==="audio"&&(R==null?void 0:R.container)==="audio/mpeg")O=!this.lastMpegAudioChunk||V.id===1||this.lastMpegAudioChunk.sn!==V.sn,this.lastMpegAudioChunk=V;var M=this.tracks.video,L=M==null?void 0:M.buffer;if(L&&A!=="initSegment"){var I=j||K,w=this.blockedAudioAppend;if(W==="audio"&&G!=="main"&&!this.blockedAudioAppend){var S=I.start,P=S+I.duration*0.05,b=L.buffered,C=this.currentOp("video");if(!b.length&&!C)this.blockAudio(I);else if(!C&&!i.isBuffered(L,P)&&this.lastVideoAppendEnd<P)this.blockAudio(I)}else if(W==="video"){var x=I.end;if(w){var _=w.frag.start;if(x>_||x<this.lastVideoAppendEnd||i.isBuffered(L,_))this.unblockAudio()}this.lastVideoAppendEnd=x}}var y=(j||K).start,T={label:"append-"+W,execute:function h(){if(U.executeStart=self.performance.now(),O){var g=X.tracks[W];if(g){var m=g.buffer;if(m){var p=y-m.timestampOffset;if(Math.abs(p)>=0.1)X.log("Updating audio SourceBuffer timestampOffset to "+y+" (delta: "+p+") sn: "+A+")"),m.timestampOffset=y}}}X.appendExecutor(N,W)},onStart:function h(){},onComplete:function h(){var g=self.performance.now();if(U.executeEnd=U.end=g,B.first===0)B.first=g;if(F&&F.first===0)F.first=g;var m={};if(X.sourceBuffers.forEach(function(p){var r=p[0],n=p[1];if(r)m[r]=i.getBuffered(n)}),X.appendErrors[W]=0,W==="audio"||W==="video")X.appendErrors.audiovideo=0;else X.appendErrors.audio=0,X.appendErrors.video=0;X.hls.trigger($.BUFFER_APPENDED,{type:W,frag:K,part:j,chunkMeta:V,parent:K.type,timeRanges:m})},onError:function h(g){var m,p={type:f.MEDIA_ERROR,parent:K.type,details:D.BUFFER_APPEND_ERROR,sourceBufferName:W,frag:K,part:j,chunkMeta:V,error:g,err:g,fatal:!1};if(g.code===DOMException.QUOTA_EXCEEDED_ERR)p.details=D.BUFFER_FULL_ERROR;else if(g.code===DOMException.INVALID_STATE_ERR&&X.mediaSourceOpenOrEnded&&!((m=X.media)!=null&&m.error))p.errorAction=IY(!0);else if(g.name===jQ)if(X.sourceBufferCount===0)p.errorAction=IY(!0);else++X.appendErrors[W];else{var r=++X.appendErrors[W];if(X.warn("Failed "+r+"/"+X.hls.config.appendErrorMaxRetry+' times to append segment in "'+W+'" sourceBuffer'),r>=X.hls.config.appendErrorMaxRetry)p.fatal=!0}X.hls.trigger($.ERROR,p)}};this.append(T,W,this.isPending(this.tracks[W]))},Z.getFlushOp=function Q(Y,J,X){var z=this;return this.log('queuing "'+Y+'" remove '+J+"-"+X),{label:"remove",execute:function N(){z.removeExecutor(Y,J,X)},onStart:function N(){},onComplete:function N(){z.hls.trigger($.BUFFER_FLUSHED,{type:Y})},onError:function N(W){z.warn("Failed to remove "+J+"-"+X+' from "'+Y+'" SourceBuffer',W)}}},Z.onBufferFlushing=function Q(Y,J){var X=this,z=J.type,N=J.startOffset,W=J.endOffset;if(z)this.append(this.getFlushOp(z,N,W),z);else this.sourceBuffers.forEach(function(G){var K=G[0];if(K)X.append(X.getFlushOp(K,N,W),K)})},Z.onFragParsed=function Q(Y,J){var X=this,z=J.frag,N=J.part,W=[],G=N?N.elementaryStreams:z.elementaryStreams;if(G[Q0.AUDIOVIDEO])W.push("audiovideo");else{if(G[Q0.AUDIO])W.push("audio");if(G[Q0.VIDEO])W.push("video")}var K=function j(){var V=self.performance.now();if(z.stats.buffering.end=V,N)N.stats.buffering.end=V;var U=N?N.stats:z.stats;X.hls.trigger($.FRAG_BUFFERED,{frag:z,part:N,stats:U,id:z.type})};if(W.length===0)this.warn("Fragments must have at least one ElementaryStreamType set. type: "+z.type+" level: "+z.level+" sn: "+z.sn);this.blockBuffers(K,W)},Z.onFragChanged=function Q(Y,J){this.trimBuffers()},Z.onBufferEos=function Q(Y,J){var X=this,z;this.sourceBuffers.forEach(function(G){var K=G[0];if(K){var j=X.tracks[K];if(!J.type||J.type===K){if(j.ending=!0,!j.ended)j.ended=!0,X.log(K+" buffer reached EOS")}}});var N=((z=this.overrides)==null?void 0:z.endOfStream)!==!1,W=this.sourceBufferCount>0&&!this.sourceBuffers.some(function(G){var K,j=G[0];return j&&!((K=X.tracks[j])!=null&&K.ended)});if(W)if(N)this.log("Queueing EOS"),this.blockUntilOpen(function(){X.tracksEnded();var G=X.mediaSource;if(!G||G.readyState!=="open"){if(G)X.log("Could not call mediaSource.endOfStream(). mediaSource.readyState: "+G.readyState);return}X.log("Calling mediaSource.endOfStream()"),G.endOfStream(),X.hls.trigger($.BUFFERED_TO_END,void 0)});else this.tracksEnded(),this.hls.trigger($.BUFFERED_TO_END,void 0)},Z.tracksEnded=function Q(){var Y=this;this.sourceBuffers.forEach(function(J){var X=J[0];if(X!==null){var z=Y.tracks[X];if(z)z.ending=!1}})},Z.onLevelUpdated=function Q(Y,J){var X=J.details;if(!X.fragments.length)return;this.details=X,this.updateDuration()},Z.updateDuration=function Q(){var Y=this,J=this.getDurationAndRange();if(!J)return;this.blockUntilOpen(function(){return Y.updateMediaSource(J)})},Z.onError=function Q(Y,J){if(J.details===D.BUFFER_APPEND_ERROR&&J.frag){var X,z=(X=J.errorAction)==null?void 0:X.nextAutoLevel;if(v(z)&&z!==J.frag.level)this.resetAppendErrors()}},Z.resetAppendErrors=function Q(){this.appendErrors={audio:0,video:0,audiovideo:0}},Z.trimBuffers=function Q(){var Y=this.hls,J=this.details,X=this.media;if(!X||J===null)return;if(!this.sourceBufferCount)return;var z=Y.config,N=X.currentTime,W=J.levelTargetDuration,G=J.live&&z.liveBackBufferLength!==null?z.liveBackBufferLength:z.backBufferLength;if(v(G)&&G>=0){var K=Math.max(G,W),j=Math.floor(N/W)*W-K;this.flushBackBuffer(N,W,j)}if(v(z.frontBufferFlushThreshold)&&z.frontBufferFlushThreshold>0){var V=Math.max(z.maxBufferLength,z.frontBufferFlushThreshold),U=Math.max(V,W),A=Math.floor(N/W)*W+U;this.flushFrontBuffer(N,W,A)}},Z.flushBackBuffer=function Q(Y,J,X){var z=this;this.sourceBuffers.forEach(function(N){var W=N[0],G=N[1];if(G){var K=i.getBuffered(G);if(K.length>0&&X>K.start(0)){var j;z.hls.trigger($.BACK_BUFFER_REACHED,{bufferEnd:X});var V=z.tracks[W];if((j=z.details)!=null&&j.live)z.hls.trigger($.LIVE_BACK_BUFFER_REACHED,{bufferEnd:X});else if(V!=null&&V.ended){z.log("Cannot flush "+W+" back buffer while SourceBuffer is in ended state");return}z.hls.trigger($.BUFFER_FLUSHING,{startOffset:0,endOffset:X,type:W})}}})},Z.flushFrontBuffer=function Q(Y,J,X){var z=this;this.sourceBuffers.forEach(function(N){var W=N[0],G=N[1];if(G){var K=i.getBuffered(G),j=K.length;if(j<2)return;var V=K.start(j-1),U=K.end(j-1);if(X>V||Y>=V&&Y<=U)return;z.hls.trigger($.BUFFER_FLUSHING,{startOffset:V,endOffset:1/0,type:W})}})},Z.getDurationAndRange=function Q(){var Y,J=this.details,X=this.mediaSource;if(!J||!this.media||(X==null?void 0:X.readyState)!=="open")return null;var z=J.edge;if(J.live&&this.hls.config.liveDurationInfinity){var N=J.fragments.length;if(N&&J.live&&!!X.setLiveSeekableRange){var W=Math.max(0,J.fragmentStart),G=Math.max(W,z);return{duration:1/0,start:W,end:G}}return{duration:1/0}}var K=(Y=this.overrides)==null?void 0:Y.duration;if(K){if(!v(K))return null;return{duration:K}}var j=this.media.duration,V=v(X.duration)?X.duration:0;if(z>V&&z>j||!v(j))return{duration:z};return null},Z.updateMediaSource=function Q(Y){var{duration:J,start:X,end:z}=Y,N=this.mediaSource;if(!this.media||!N||N.readyState!=="open")return;if(N.duration!==J){if(v(J))this.log("Updating MediaSource duration to "+J.toFixed(3));N.duration=J}if(X!==void 0&&z!==void 0)this.log("MediaSource duration is set to "+N.duration+". Setting seekable range to "+X+"-"+z+"."),N.setLiveSeekableRange(X,z)},Z.checkPendingTracks=function Q(){var Y=this.bufferCodecEventsTotal,J=this.pendingTrackCount,X=this.tracks;if(this.log("checkPendingTracks (pending: "+J+" codec events expected: "+Y+") "+$0(X)),this.tracksReady){var z,N=(z=this.transferData)==null?void 0:z.tracks;if(N&&Object.keys(N).length)this.attachTransferred();else this.createSourceBuffers()}},Z.bufferCreated=function Q(){var Y=this;if(this.sourceBufferCount){var J={};this.sourceBuffers.forEach(function(z){var N=z[0],W=z[1];if(N){var G=Y.tracks[N];J[N]={buffer:W,container:G.container,codec:G.codec,supplemental:G.supplemental,levelCodec:G.levelCodec,id:G.id,metadata:G.metadata}}}),this.hls.trigger($.BUFFER_CREATED,{tracks:J}),this.log("SourceBuffers created. Running queue: "+this.operationQueue),this.sourceBuffers.forEach(function(z){var N=z[0];Y.executeNext(N)})}else{var X=new Error("could not create source buffer for media codec(s)");this.hls.trigger($.ERROR,{type:f.MEDIA_ERROR,details:D.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:X,reason:X.message})}},Z.createSourceBuffers=function Q(){var Y=this.tracks,J=this.sourceBuffers,X=this.mediaSource;if(!X)throw new Error("createSourceBuffers called when mediaSource was null");for(var z in Y){var N=z,W=Y[N];if(this.isPending(W)){var G=this.getTrackCodec(W,N),K=W.container+";codecs="+G;W.codec=G,this.log("creating sourceBuffer("+K+")"+(this.currentOp(N)?" Queued":"")+" "+$0(W));try{var j=X.addSourceBuffer(K),V=Q7(N),U=[N,j];J[V]=U,W.buffer=j}catch(E){var A;this.error("error while trying to add sourceBuffer: "+E.message),this.shiftAndExecuteNext(N),(A=this.operationQueue)==null||A.removeBlockers(),delete this.tracks[N],this.hls.trigger($.ERROR,{type:f.MEDIA_ERROR,details:D.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:E,sourceBufferName:N,mimeType:K,parent:W.id});return}this.trackSourceBuffer(N,W)}}this.bufferCreated()},Z.getTrackCodec=function Q(Y,J){var{supplemental:X,codec:z}=Y;if(X&&(J==="video"||J==="audiovideo")&&rY(X,"video"))z=A8(z,X);var N=$Y(z,Y.levelCodec);if(N){if(J.slice(0,5)==="audio")return BY(N,this.appendSource);return N}return""},Z.trackSourceBuffer=function Q(Y,J){var X=this,z=J.buffer;if(!z)return;var N=this.getTrackCodec(J,Y);if(this.tracks[Y]={buffer:z,codec:N,container:J.container,levelCodec:J.levelCodec,supplemental:J.supplemental,metadata:J.metadata,id:J.id,listeners:[]},this.removeBufferListeners(Y),this.addBufferListener(Y,"updatestart",this.onSBUpdateStart),this.addBufferListener(Y,"updateend",this.onSBUpdateEnd),this.addBufferListener(Y,"error",this.onSBUpdateError),this.appendSource)this.addBufferListener(Y,"bufferedchange",function(W,G){var K=G.removedRanges;if(K!=null&&K.length)X.hls.trigger($.BUFFER_FLUSHED,{type:W})})},Z.onSBUpdateStart=function Q(Y){var J=this.currentOp(Y);if(!J)return;J.onStart()},Z.onSBUpdateEnd=function Q(Y){var J;if(((J=this.mediaSource)==null?void 0:J.readyState)==="closed"){this.resetBuffer(Y);return}var X=this.currentOp(Y);if(!X)return;X.onComplete(),this.shiftAndExecuteNext(Y)},Z.onSBUpdateError=function Q(Y,J){var X,z=new Error(Y+" SourceBuffer error. MediaSource readyState: "+((X=this.mediaSource)==null?void 0:X.readyState));this.error(""+z,J),this.hls.trigger($.ERROR,{type:f.MEDIA_ERROR,details:D.BUFFER_APPENDING_ERROR,sourceBufferName:Y,error:z,fatal:!1});var N=this.currentOp(Y);if(N)N.onError(z)},Z.removeExecutor=function Q(Y,J,X){var z=this.media,N=this.mediaSource,W=this.tracks[Y],G=W==null?void 0:W.buffer;if(!z||!N||!G){this.warn("Attempting to remove from the "+Y+" SourceBuffer, but it does not exist"),this.shiftAndExecuteNext(Y);return}var K=v(z.duration)?z.duration:1/0,j=v(N.duration)?N.duration:1/0,V=Math.max(0,J),U=Math.min(X,K,j);if(U>V&&(!W.ending||W.ended))W.ended=!1,this.log("Removing ["+V+","+U+"] from the "+Y+" SourceBuffer"),G.remove(V,U);else this.shiftAndExecuteNext(Y)},Z.appendExecutor=function Q(Y,J){var X=this.tracks[J],z=X==null?void 0:X.buffer;if(!z)throw new y8("Attempting to append to the "+J+" SourceBuffer, but it does not exist");X.ending=!1,X.ended=!1,z.appendBuffer(Y)},Z.blockUntilOpen=function Q(Y){if(this.isUpdating()||this.isQueued())this.blockBuffers(Y);else Y()},Z.isUpdating=function Q(){return this.sourceBuffers.some(function(Y){var J=Y[0],X=Y[1];return J&&X.updating})},Z.isQueued=function Q(){var Y=this;return this.sourceBuffers.some(function(J){var X=J[0];return X&&!!Y.currentOp(X)})},Z.isPending=function Q(Y){return!!Y&&!Y.buffer},Z.blockBuffers=function Q(Y,J){var X=this;if(J===void 0)J=this.sourceBufferTypes;if(!J.length){this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(Y);return}var z=this.operationQueue,N=J.map(function(G){return X.appendBlocker(G)}),W=J.length>1&&!!this.blockedAudioAppend;if(W)this.unblockAudio();Promise.all(N).then(function(G){if(z!==X.operationQueue)return;Y(),X.stepOperationQueue(J)})},Z.stepOperationQueue=function Q(Y){var J=this;Y.forEach(function(X){var z,N=(z=J.tracks[X])==null?void 0:z.buffer;if(!N||N.updating)return;J.shiftAndExecuteNext(X)})},Z.append=function Q(Y,J,X){if(this.operationQueue)this.operationQueue.append(Y,J,X)},Z.appendBlocker=function Q(Y){if(this.operationQueue)return this.operationQueue.appendBlocker(Y)},Z.currentOp=function Q(Y){if(this.operationQueue)return this.operationQueue.current(Y);return null},Z.executeNext=function Q(Y){if(Y&&this.operationQueue)this.operationQueue.executeNext(Y)},Z.shiftAndExecuteNext=function Q(Y){if(this.operationQueue)this.operationQueue.shiftAndExecuteNext(Y)},Z.addBufferListener=function Q(Y,J,X){var z=this.tracks[Y];if(!z)return;var N=z.buffer;if(!N)return;var W=X.bind(this,Y);z.listeners.push({event:J,listener:W}),N.addEventListener(J,W)},Z.removeBufferListeners=function Q(Y){var J=this.tracks[Y];if(!J)return;var X=J.buffer;if(!X)return;J.listeners.forEach(function(z){X.removeEventListener(z.event,z.listener)}),J.listeners.length=0},Z0(H,[{key:"mediaSourceOpenOrEnded",get:function Q(){var Y,J=(Y=this.mediaSource)==null?void 0:Y.readyState;return J==="open"||J==="ended"}},{key:"sourceBufferTracks",get:function Q(){var Y=this;return Object.keys(this.tracks).reduce(function(J,X){var z=Y.tracks[X];return J[X]={id:z.id,container:z.container,codec:z.codec,levelCodec:z.levelCodec},J},{})}},{key:"bufferedToEnd",get:function Q(){var Y=this;return this.sourceBufferCount>0&&!this.sourceBuffers.some(function(J){var X,z,N=J[0];return N&&(!((X=Y.tracks[N])!=null&&X.ended)||((z=Y.tracks[N])==null?void 0:z.ending))})}},{key:"tracksReady",get:function Q(){var Y=this.pendingTrackCount;return Y>0&&(Y>=this.bufferCodecEventsTotal||this.isPending(this.tracks.audiovideo))}},{key:"mediaSrc",get:function Q(){var Y,J,X=((Y=this.media)==null?void 0:(J=Y.querySelector)==null?void 0:J.call(Y,"source"))||this.media;return X==null?void 0:X.src}},{key:"pendingTrackCount",get:function Q(){var Y=this;return Object.keys(this.tracks).reduce(function(J,X){return J+(Y.isPending(Y.tracks[X])?1:0)},0)}},{key:"sourceBufferCount",get:function Q(){return this.sourceBuffers.reduce(function(Y,J){var X=J[0];return Y+(X?1:0)},0)}},{key:"sourceBufferTypes",get:function Q(){return this.sourceBuffers.map(function(Y){var J=Y[0];return J}).filter(function(Y){return!!Y})}}])}(i0);function UQ(q){var H=q.querySelectorAll("source");[].slice.call(H).forEach(function(Z){q.removeChild(Z)})}function _8(q,H){var Z=self.document.createElement("source");Z.type="video/mp4",Z.src=H,q.appendChild(Z)}function Q7(q){return q==="audio"?1:0}var h8=function(){function q(Z){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=Z,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var H=q.prototype;return H.setStreamController=function Z(Q){this.streamController=Q},H.destroy=function Z(){if(this.hls)this.unregisterListener();if(this.timer)this.stopCapping();this.media=null,this.clientRect=null,this.hls=this.streamController=null},H.registerListeners=function Z(){var Q=this.hls;Q.on($.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),Q.on($.MEDIA_ATTACHING,this.onMediaAttaching,this),Q.on($.MANIFEST_PARSED,this.onManifestParsed,this),Q.on($.LEVELS_UPDATED,this.onLevelsUpdated,this),Q.on($.BUFFER_CODECS,this.onBufferCodecs,this),Q.on($.MEDIA_DETACHING,this.onMediaDetaching,this)},H.unregisterListener=function Z(){var Q=this.hls;Q.off($.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),Q.off($.MEDIA_ATTACHING,this.onMediaAttaching,this),Q.off($.MANIFEST_PARSED,this.onManifestParsed,this),Q.off($.LEVELS_UPDATED,this.onLevelsUpdated,this),Q.off($.BUFFER_CODECS,this.onBufferCodecs,this),Q.off($.MEDIA_DETACHING,this.onMediaDetaching,this)},H.onFpsDropLevelCapping=function Z(Q,Y){var J=this.hls.levels[Y.droppedLevel];if(this.isLevelAllowed(J))this.restrictedLevels.push({bitrate:J.bitrate,height:J.height,width:J.width})},H.onMediaAttaching=function Z(Q,Y){if(this.media=Y.media instanceof HTMLVideoElement?Y.media:null,this.clientRect=null,this.timer&&this.hls.levels.length)this.detectPlayerSize()},H.onManifestParsed=function Z(Q,Y){var J=this.hls;if(this.restrictedLevels=[],this.firstLevel=Y.firstLevel,J.config.capLevelToPlayerSize&&Y.video)this.startCapping()},H.onLevelsUpdated=function Z(Q,Y){if(this.timer&&v(this.autoLevelCapping))this.detectPlayerSize()},H.onBufferCodecs=function Z(Q,Y){var J=this.hls;if(J.config.capLevelToPlayerSize&&Y.video)this.startCapping()},H.onMediaDetaching=function Z(){this.stopCapping(),this.media=null},H.detectPlayerSize=function Z(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0){this.clientRect=null;return}var Q=this.hls.levels;if(Q.length){var Y=this.hls,J=this.getMaxLevel(Q.length-1);if(J!==this.autoLevelCapping)Y.logger.log("Setting autoLevelCapping to "+J+": "+Q[J].height+"p@"+Q[J].bitrate+" for media "+this.mediaWidth+"x"+this.mediaHeight);if(Y.autoLevelCapping=J,Y.autoLevelEnabled&&Y.autoLevelCapping>this.autoLevelCapping&&this.streamController)this.streamController.nextLevelSwitch();this.autoLevelCapping=Y.autoLevelCapping}}},H.getMaxLevel=function Z(Q){var Y=this,J=this.hls.levels;if(!J.length)return-1;var X=J.filter(function(z,N){return Y.isLevelAllowed(z)&&N<=Q});return this.clientRect=null,q.getMaxLevelByMediaSize(X,this.mediaWidth,this.mediaHeight)},H.startCapping=function Z(){if(this.timer)return;this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1000),this.detectPlayerSize()},H.stopCapping=function Z(){if(this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer)self.clearInterval(this.timer),this.timer=void 0},H.getDimensions=function Z(){if(this.clientRect)return this.clientRect;var Q=this.media,Y={width:0,height:0};if(Q){var J=Q.getBoundingClientRect();if(Y.width=J.width,Y.height=J.height,!Y.width&&!Y.height)Y.width=J.right-J.left||Q.width||0,Y.height=J.bottom-J.top||Q.height||0}return this.clientRect=Y,Y},H.isLevelAllowed=function Z(Q){var Y=this.restrictedLevels;return!Y.some(function(J){return Q.bitrate===J.bitrate&&Q.width===J.width&&Q.height===J.height})},q.getMaxLevelByMediaSize=function Z(Q,Y,J){if(!(Q!=null&&Q.length))return-1;var X=function K(j,V){if(!V)return!0;return j.width!==V.width||j.height!==V.height},z=Q.length-1,N=Math.max(Y,J);for(var W=0;W<Q.length;W+=1){var G=Q[W];if((G.width>=N||G.height>=N)&&X(G,Q[W+1])){z=W;break}}return z},Z0(q,[{key:"mediaWidth",get:function Z(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function Z(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function Z(){var Q=1;if(!this.hls.config.ignoreDevicePixelRatio)try{Q=self.devicePixelRatio}catch(Y){}return Math.min(Q,this.hls.config.maxDevicePixelRatio)}}])}(),v8=/^(\d+)x(\d+)$/,VQ=/(.+?)=(".*?"|.*?)(?:,|$)/g,H0=function(){function q(Z,Q){if(typeof Z==="string")Z=q.parseAttrList(Z,Q);W0(this,Z)}var H=q.prototype;return H.decimalInteger=function Z(Q){var Y=parseInt(this[Q],10);if(Y>Number.MAX_SAFE_INTEGER)return 1/0;return Y},H.hexadecimalInteger=function Z(Q){if(this[Q]){var Y=(this[Q]||"0x").slice(2);Y=(Y.length&1?"0":"")+Y;var J=new Uint8Array(Y.length/2);for(var X=0;X<Y.length/2;X++)J[X]=parseInt(Y.slice(X*2,X*2+2),16);return J}return null},H.hexadecimalIntegerAsNumber=function Z(Q){var Y=parseInt(this[Q],16);if(Y>Number.MAX_SAFE_INTEGER)return 1/0;return Y},H.decimalFloatingPoint=function Z(Q){return parseFloat(this[Q])},H.optionalFloat=function Z(Q,Y){var J=this[Q];return J?parseFloat(J):Y},H.enumeratedString=function Z(Q){return this[Q]},H.enumeratedStringList=function Z(Q,Y){var J=this[Q];return(J?J.split(/[ ,]+/):[]).reduce(function(X,z){return X[z.toLowerCase()]=!0,X},Y)},H.bool=function Z(Q){return this[Q]==="YES"},H.decimalResolution=function Z(Q){var Y=v8.exec(this[Q]);if(Y===null)return;return{width:parseInt(Y[1],10),height:parseInt(Y[2],10)}},q.parseAttrList=function Z(Q,Y){var J,X={},z='"';VQ.lastIndex=0;while((J=VQ.exec(Q))!==null){var N=J[1].trim(),W=J[2],G=W.indexOf(z)===0&&W.lastIndexOf(z)===W.length-1,K=!1;if(G)W=W.slice(1,-1);else switch(N){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":K=!0}if(Y&&(G||K));else if(!K&&!G)switch(N){case"CLOSED-CAPTIONS":if(W==="NONE")break;case"ALLOWED-CPC":case"CLASS":case"ASSOC-LANGUAGE":case"AUDIO":case"BYTERANGE":case"CHANNELS":case"CHARACTERISTICS":case"CODECS":case"DATA-ID":case"END-DATE":case"GROUP-ID":case"ID":case"IMPORT":case"INSTREAM-ID":case"KEYFORMAT":case"KEYFORMATVERSIONS":case"LANGUAGE":case"NAME":case"PATHWAY-ID":case"QUERYPARAM":case"RECENTLY-REMOVED-DATERANGES":case"SERVER-URI":case"STABLE-RENDITION-ID":case"STABLE-VARIANT-ID":case"START-DATE":case"SUBTITLES":case"SUPPLEMENTAL-CODECS":case"URI":case"VALUE":case"VIDEO":case"X-ASSET-LIST":case"X-ASSET-URI":s.warn(Q+": attribute "+N+" is missing quotes")}X[N]=W}return X},Z0(q,[{key:"clientAttrs",get:function Z(){return Object.keys(this).filter(function(Q){return Q.substring(0,2)==="X-"})}}])}(),g8="com.apple.hls.interstitial";function m8(q){return q!=="ID"&&q!=="CLASS"&&q!=="CUE"&&q!=="START-DATE"&&q!=="DURATION"&&q!=="END-DATE"&&q!=="END-ON-NEXT"}function p8(q){return q==="SCTE35-OUT"||q==="SCTE35-IN"||q==="SCTE35-CMD"}var AQ=function(){function q(H,Z,Q){var Y;if(Q===void 0)Q=0;if(this.attr=void 0,this.tagAnchor=void 0,this.tagOrder=void 0,this._startDate=void 0,this._endDate=void 0,this._dateAtEnd=void 0,this._cue=void 0,this._badValueForSameId=void 0,this.tagAnchor=(Z==null?void 0:Z.tagAnchor)||null,this.tagOrder=(Y=Z==null?void 0:Z.tagOrder)!=null?Y:Q,Z){var J=Z.attr;for(var X in J)if(Object.prototype.hasOwnProperty.call(H,X)&&H[X]!==J[X]){s.warn('DATERANGE tag attribute: "'+X+'" does not match for tags with ID: "'+H.ID+'"'),this._badValueForSameId=X;break}H=W0(new H0({}),J,H)}if(this.attr=H,Z)this._startDate=Z._startDate,this._cue=Z._cue,this._endDate=Z._endDate,this._dateAtEnd=Z._dateAtEnd;else this._startDate=new Date(H["START-DATE"]);if("END-DATE"in this.attr){var z=(Z==null?void 0:Z.endDate)||new Date(this.attr["END-DATE"]);if(v(z.getTime()))this._endDate=z}}return Z0(q,[{key:"id",get:function H(){return this.attr.ID}},{key:"class",get:function H(){return this.attr.CLASS}},{key:"cue",get:function H(){var Z=this._cue;if(Z===void 0)return this._cue=this.attr.enumeratedStringList(this.attr.CUE?"CUE":"X-CUE",{pre:!1,post:!1,once:!1});return Z}},{key:"startTime",get:function H(){var Z=this.tagAnchor;if(Z===null||Z.programDateTime===null)return s.warn('Expected tagAnchor Fragment with PDT set for DateRange "'+this.id+'": '+Z),NaN;return Z.start+(this.startDate.getTime()-Z.programDateTime)/1000}},{key:"startDate",get:function H(){return this._startDate}},{key:"endDate",get:function H(){var Z=this._endDate||this._dateAtEnd;if(Z)return Z;var Q=this.duration;if(Q!==null)return this._dateAtEnd=new Date(this._startDate.getTime()+Q*1000);return null}},{key:"duration",get:function H(){if("DURATION"in this.attr){var Z=this.attr.decimalFloatingPoint("DURATION");if(v(Z))return Z}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1000;return null}},{key:"plannedDuration",get:function H(){if("PLANNED-DURATION"in this.attr)return this.attr.decimalFloatingPoint("PLANNED-DURATION");return null}},{key:"endOnNext",get:function H(){return this.attr.bool("END-ON-NEXT")}},{key:"isInterstitial",get:function H(){return this.class===g8}},{key:"isValid",get:function H(){return!!this.id&&!this._badValueForSameId&&v(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)&&(!this.attr.CUE||!this.cue.pre&&!this.cue.post||this.cue.pre!==this.cue.post)&&(!this.isInterstitial||("X-ASSET-URI"in this.attr)||("X-ASSET-LIST"in this.attr))}}])}(),u8=10,c8=function(){function q(Z){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.dateRangeTagCount=0,this.live=!0,this.requestScheduled=-1,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!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.appliedTimelineOffset=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=Z}var H=q.prototype;return H.reloaded=function Z(Q){if(!Q){this.advanced=!0,this.updated=!0;return}var Y=this.lastPartSn-Q.lastPartSn,J=this.lastPartIndex-Q.lastPartIndex;if(this.updated=this.endSN!==Q.endSN||!!J||!!Y||!this.live,this.advanced=this.endSN>Q.endSN||Y>0||Y===0&&J>0,this.updated||this.advanced)this.misses=Math.floor(Q.misses*0.6);else this.misses=Q.misses+1},Z0(q,[{key:"hasProgramDateTime",get:function Z(){if(this.fragments.length)return v(this.fragments[this.fragments.length-1].programDateTime);return!1}},{key:"levelTargetDuration",get:function Z(){return this.averagetargetduration||this.targetduration||u8}},{key:"drift",get:function Z(){var Q=this.driftEndTime-this.driftStartTime;if(Q>0){var Y=this.driftEnd-this.driftStart;return Y*1000/Q}return 1}},{key:"edge",get:function Z(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function Z(){var Q;if((Q=this.partList)!=null&&Q.length)return this.partList[this.partList.length-1].end;return this.fragmentEnd}},{key:"fragmentEnd",get:function Z(){var Q;if((Q=this.fragments)!=null&&Q.length)return this.fragments[this.fragments.length-1].end;return 0}},{key:"fragmentStart",get:function Z(){var Q;if((Q=this.fragments)!=null&&Q.length)return this.fragments[0].start;return 0}},{key:"age",get:function Z(){if(this.advancedDateTime)return Math.max(Date.now()-this.advancedDateTime,0)/1000;return 0}},{key:"lastPartIndex",get:function Z(){var Q;if((Q=this.partList)!=null&&Q.length)return this.partList[this.partList.length-1].index;return-1}},{key:"maxPartIndex",get:function Z(){var Q=this.partList;if(Q){var Y=this.lastPartIndex;if(Y!==-1){for(var J=Q.length;J--;)if(Q[J].index>Y)return Q[J].index;return Y}}return 0}},{key:"lastPartSn",get:function Z(){var Q;if((Q=this.partList)!=null&&Q.length)return this.partList[this.partList.length-1].fragment.sn;return this.endSN}},{key:"expired",get:function Z(){if(this.live&&this.age&&this.misses<3){var Q=this.partEnd-this.fragmentStart;return this.age>Math.max(Q,this.totalduration)+this.levelTargetDuration}return!1}}])}(),l0={cbc:0,ctr:1};function HY(q){return q==="AES-128"||q==="AES-256"||q==="AES-256-CTR"}function EQ(q){switch(q){case"AES-128":case"AES-256":return l0.cbc;case"AES-256-CTR":return l0.ctr;default:throw new Error("invalid full segment method "+q)}}var f8=function(){function q(Z,Q,Y,J,X){if(J===void 0)J=[1];if(X===void 0)X=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=Z,this.uri=Q,this.keyFormat=Y,this.keyFormatVersions=J,this.iv=X,this.encrypted=Z?Z!=="NONE":!1,this.isCommonEncryption=this.encrypted&&!HY(Z)}q.clearKeyUriToKeyIdMap=function Z(){};var H=q.prototype;return H.isSupported=function Z(){if(this.method){if(HY(this.method)||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES"}return!1},H.getDecryptData=function Z(Q){if(!this.encrypted||!this.uri)return null;if(HY(this.method)&&this.uri&&!this.iv){if(typeof Q!=="number")s.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),Q=0;var Y=d8(Q),J=new q(this.method,this.uri,"identity",this.keyFormatVersions,Y);return J}return this},q}();function d8(q){var H=new Uint8Array(16);for(var Z=12;Z<16;Z++)H[Z]=q>>8*(15-Z)&255;return H}var BQ=/#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,$Q=/#EXT-X-MEDIA:(.*)/g,l8=/^#EXT(?:INF|-X-TARGETDURATION):/m,J7=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),n8=new RegExp([/#EXT-X-(PROGRAM-DATE-TIME|BYTERANGE|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("|")),zY=function(){function q(){}return q.findGroup=function H(Z,Q){for(var Y=0;Y<Z.length;Y++){var J=Z[Y];if(J.id===Q)return J}},q.resolve=function H(Z,Q){return uY.buildAbsoluteURL(Q,Z,{alwaysNormalize:!0})},q.isMediaPlaylist=function H(Z){return l8.test(Z)},q.parseMasterPlaylist=function H(Z,Q){var Y=!1,J={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:Y},X=[];BQ.lastIndex=0;var z;while((z=BQ.exec(Z))!=null)if(z[1]){var N,W=new H0(z[1],J),G=z[2],K={attrs:W,bitrate:W.decimalInteger("BANDWIDTH")||W.decimalInteger("AVERAGE-BANDWIDTH"),name:W.NAME,url:q.resolve(G,Q)},j=W.decimalResolution("RESOLUTION");if(j)K.width=j.width,K.height=j.height;MQ(W.CODECS,K);var V=W["SUPPLEMENTAL-CODECS"];if(V)K.supplemental={},MQ(V,K.supplemental);if(!((N=K.unknownCodecs)!=null&&N.length))X.push(K);J.levels.push(K)}else if(z[3]){var U=z[3],A=z[4];switch(U){case"SESSION-DATA":{var E=new H0(A,J),B=E["DATA-ID"];if(B){if(J.sessionData===null)J.sessionData={};J.sessionData[B]=E}break}case"SESSION-KEY":{var F=OQ(A,Q,J);if(F.encrypted&&F.isSupported()){if(J.sessionKeys===null)J.sessionKeys=[];J.sessionKeys.push(F)}else s.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+A+'"');break}case"DEFINE":break;case"CONTENT-STEERING":{var R=new H0(A,J);J.contentSteering={uri:q.resolve(R["SERVER-URI"],Q),pathwayId:R["PATHWAY-ID"]||"."};break}case"START":{J.startTimeOffset=RQ(A);break}}}var O=X.length>0&&X.length<J.levels.length;if(J.levels=O?X:J.levels,J.levels.length===0)J.playlistParsingError=new Error("no levels found in manifest");return J},q.parseMasterPlaylistMedia=function H(Z,Q,Y){var J,X={},z=Y.levels,N={AUDIO:z.map(function(M){return{id:M.attrs.AUDIO,audioCodec:M.audioCodec}}),SUBTITLES:z.map(function(M){return{id:M.attrs.SUBTITLES,textCodec:M.textCodec}}),"CLOSED-CAPTIONS":[]},W=0;$Q.lastIndex=0;while((J=$Q.exec(Z))!==null){var G=new H0(J[1],Y),K=G.TYPE;if(K){var j=N[K],V=X[K]||[];X[K]=V;var U=G.LANGUAGE,A=G["ASSOC-LANGUAGE"],E=G.CHANNELS,B=G.CHARACTERISTICS,F=G["INSTREAM-ID"],R={attrs:G,bitrate:0,id:W++,groupId:G["GROUP-ID"]||"",name:G.NAME||U||"",type:K,default:G.bool("DEFAULT"),autoselect:G.bool("AUTOSELECT"),forced:G.bool("FORCED"),lang:U,url:G.URI?q.resolve(G.URI,Q):""};if(A)R.assocLang=A;if(E)R.channels=E;if(B)R.characteristics=B;if(F)R.instreamId=F;if(j!=null&&j.length){var O=q.findGroup(j,R.groupId)||j[0];IQ(R,O,"audioCodec"),IQ(R,O,"textCodec")}V.push(R)}}return X},q.parseLevelPlaylist=function H(Z,Q,Y,J,X,z){var N,W={url:Q},G=new c8(Q),K=G.fragments,j=[],V=null,U=0,A=0,E=0,B=0,F=0,R=null,O=new nY(J,W),M,L,I,w=-1,S=!1,P=null,b;if(J7.lastIndex=0,G.m3u8=Z,G.hasVariableRefs=!1,((N=J7.exec(Z))==null?void 0:N[0])!=="#EXTM3U")return G.playlistParsingError=new Error("Missing format identifier #EXTM3U"),G;while((M=J7.exec(Z))!==null){if(S){if(S=!1,O=new nY(J,W),O.playlistOffset=E,O.start=E,O.sn=U,O.cc=B,F)O.bitrate=F;if(O.level=Y,V){if(O.initSegment=V,V.rawProgramDateTime)O.rawProgramDateTime=V.rawProgramDateTime,V.rawProgramDateTime=null;if(P)O.setByteRange(P),P=null}}var C=M[1];if(C){O.duration=parseFloat(C);var x=(" "+M[2]).slice(1);O.title=x||null,O.tagList.push(x?["INF",C,x]:["INF",C])}else if(M[3]){if(v(O.duration)){if(O.playlistOffset=E,O.start=E,I)LQ(O,I,G);O.sn=U,O.level=Y,O.cc=B,K.push(O);var _=(" "+M[3]).slice(1);O.relurl=_,Z7(O,R,j),R=O,E+=O.duration,U++,A=0,S=!0}}else{if(M=M[0].match(n8),!M){s.warn("No matches on slow regex match for level playlist!");continue}for(L=1;L<M.length;L++)if(M[L]!==void 0)break;var y=(" "+M[L]).slice(1),T=(" "+M[L+1]).slice(1),h=M[L+2]?(" "+M[L+2]).slice(1):null;switch(y){case"BYTERANGE":if(R)O.setByteRange(T,R);else O.setByteRange(T);break;case"PROGRAM-DATE-TIME":if(O.rawProgramDateTime=T,O.tagList.push(["PROGRAM-DATE-TIME",T]),w===-1)w=K.length;break;case"PLAYLIST-TYPE":if(G.type)p0(G,y,M);G.type=T.toUpperCase();break;case"MEDIA-SEQUENCE":if(G.startSN!==0)p0(G,y,M);else if(K.length>0)bQ(G,y,M);U=G.startSN=parseInt(T);break;case"SKIP":{if(G.skippedSegments)p0(G,y,M);var g=new H0(T,G),m=g.decimalInteger("SKIPPED-SEGMENTS");if(v(m)){G.skippedSegments+=m;for(var p=m;p--;)K.push(null);U+=m}var r=g.enumeratedString("RECENTLY-REMOVED-DATERANGES");if(r)G.recentlyRemovedDateranges=(G.recentlyRemovedDateranges||[]).concat(r.split("\t"));break}case"TARGETDURATION":if(G.targetduration!==0)p0(G,y,M);G.targetduration=Math.max(parseInt(T),1);break;case"VERSION":if(G.version!==null)p0(G,y,M);G.version=parseInt(T);break;case"INDEPENDENT-SEGMENTS":break;case"ENDLIST":if(!G.live)p0(G,y,M);G.live=!1;break;case"#":if(T||h)O.tagList.push(h?[T,h]:[T]);break;case"DISCONTINUITY":B++,O.tagList.push(["DIS"]);break;case"GAP":O.gap=!0,O.tagList.push([y]);break;case"BITRATE":if(O.tagList.push([y,T]),F=parseInt(T)*1000,v(F))O.bitrate=F;else F=0;break;case"DATERANGE":{var n=new H0(T,G),a=new AQ(n,G.dateRanges[n.ID],G.dateRangeTagCount);if(G.dateRangeTagCount++,a.isValid||G.skippedSegments)G.dateRanges[a.id]=a;else s.warn('Ignoring invalid DATERANGE tag: "'+T+'"');O.tagList.push(["EXT-X-DATERANGE",T]);break}case"DEFINE":break;case"DISCONTINUITY-SEQUENCE":if(G.startCC!==0)p0(G,y,M);else if(K.length>0)bQ(G,y,M);G.startCC=B=parseInt(T);break;case"KEY":{var l=OQ(T,Q,G);if(l.isSupported()){if(l.method==="NONE"){I=void 0;break}if(!I)I={};if(I[l.keyFormat])I=W0({},I);I[l.keyFormat]=l}else s.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+T+'"');break}case"START":G.startTimeOffset=RQ(T);break;case"MAP":{var X0=new H0(T,G);if(O.duration){var t=new nY(J,W);if(wQ(t,X0,Y,I),V=t,O.initSegment=V,V.rawProgramDateTime&&!O.rawProgramDateTime)O.rawProgramDateTime=V.rawProgramDateTime}else{var q0=O.byteRangeEndOffset;if(q0){var R0=O.byteRangeStartOffset;P=q0-R0+"@"+R0}else P=null;wQ(O,X0,Y,I),V=O,S=!0}V.cc=B;break}case"SERVER-CONTROL":{if(b)p0(G,y,M);b=new H0(T),G.canBlockReload=b.bool("CAN-BLOCK-RELOAD"),G.canSkipUntil=b.optionalFloat("CAN-SKIP-UNTIL",0),G.canSkipDateRanges=G.canSkipUntil>0&&b.bool("CAN-SKIP-DATERANGES"),G.partHoldBack=b.optionalFloat("PART-HOLD-BACK",0),G.holdBack=b.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{if(G.partTarget)p0(G,y,M);var U0=new H0(T);G.partTarget=U0.decimalFloatingPoint("PART-TARGET");break}case"PART":{var e=G.partList;if(!e)e=G.partList=[];var M0=A>0?e[e.length-1]:void 0,z0=A++,J0=new H0(T,G),I0=new rJ(J0,O,W,z0,M0);e.push(I0),O.duration+=I0.duration;break}case"PRELOAD-HINT":{var E0=new H0(T,G);G.preloadHint=E0;break}case"RENDITION-REPORT":{var b0=new H0(T,G);G.renditionReports=G.renditionReports||[],G.renditionReports.push(b0);break}default:s.warn("line parsed but not handled: "+M);break}}}if(R&&!R.relurl){if(K.pop(),E-=R.duration,G.partList)G.fragmentHint=R}else if(G.partList){if(Z7(O,R,j),O.cc=B,G.fragmentHint=O,I)LQ(O,I,G)}if(!G.targetduration)G.playlistParsingError=new Error("#EXT-X-TARGETDURATION is required");var Y0=K.length,B0=K[0],N0=K[Y0-1];if(E+=G.skippedSegments*G.targetduration,E>0&&Y0&&N0){G.averagetargetduration=E/Y0;var w0=N0.sn;if(G.endSN=w0!=="initSegment"?w0:0,!G.live)N0.endList=!0;if(B0&&G.startCC===void 0)G.startCC=B0.cc;if(w>0){if(s8(K,w),B0)j.unshift(B0)}}else G.endSN=0,G.startCC=0;if(G.fragmentHint)E+=G.fragmentHint.duration;if(G.totalduration=E,j.length&&G.dateRangeTagCount&&B0)FQ(j,G);return G.endCC=B,G},q}();function FQ(q,H){var Z=q.length,Q=q[Z-1],Y=H.live?1/0:H.totalduration,J=Object.keys(H.dateRanges);for(var X=J.length;X--;){var z=H.dateRanges[J[X]],N=z.startDate.getTime();z.tagAnchor=Q.ref;for(var W=Z;W--;){var G=o8(H,N,q,W,Y);if(G!==-1){z.tagAnchor=H.fragments[G].ref;break}}}}function o8(q,H,Z,Q,Y){var J=Z[Q];if(J){var X=J.programDateTime;if(H>=X||Q===0){var z,N=(((z=Z[Q+1])==null?void 0:z.start)||Y)-J.start;if(H<=X+N*1000){var W=Z[Q].sn-q.startSN,G=q.fragments;if(G.length>Z.length){var K=Z[Q+1]||G[G.length-1],j=K.sn-q.startSN;for(var V=j;V>W;V--){var U=G[V].programDateTime;if(H>=U&&H<U+G[V].duration*1000)return V}}return W}}}return-1}function OQ(q,H,Z){var Q,Y,J=new H0(q,Z),X=(Q=J.METHOD)!=null?Q:"",z=J.URI,N=J.hexadecimalInteger("IV"),W=J.KEYFORMATVERSIONS,G=(Y=J.KEYFORMAT)!=null?Y:"identity";if(z&&J.IV&&!N)s.error("Invalid IV: "+J.IV);var K=z?zY.resolve(z,H):"",j=(W?W:"1").split("/").map(Number).filter(Number.isFinite);return new f8(X,K,G,j,N)}function RQ(q){var H=new H0(q),Z=H.decimalFloatingPoint("TIME-OFFSET");if(v(Z))return Z;return null}function MQ(q,H){var Z=(q||"").split(/[ ,]+/).filter(function(Q){return Q});["video","audio","text"].forEach(function(Q){var Y=Z.filter(function(J){return i7(J,Q)});if(Y.length)H[Q+"Codec"]=Y.map(function(J){return J.split("/")[0]}).join(","),Z=Z.filter(function(J){return Y.indexOf(J)===-1})}),H.unknownCodecs=Z}function IQ(q,H,Z){var Q=H[Z];if(Q)q[Z]=Q}function s8(q,H){var Z=q[H];for(var Q=H;Q--;){var Y=q[Q];if(!Y)return;Y.programDateTime=Z.programDateTime-Y.duration*1000,Z=Y}}function Z7(q,H,Z){if(q.rawProgramDateTime)Z.push(q);else if(H!=null&&H.programDateTime)q.programDateTime=H.endProgramDateTime}function wQ(q,H,Z,Q){if(q.relurl=H.URI,H.BYTERANGE)q.setByteRange(H.BYTERANGE);if(q.level=Z,q.sn="initSegment",Q)q.levelkeys=Q;q.initSegment=null}function LQ(q,H,Z){q.levelkeys=H;var Q=Z.encryptedFragments;if((!Q.length||Q[Q.length-1].levelkeys!==H)&&Object.keys(H).some(function(Y){return H[Y].isCommonEncryption}))Q.push(q)}function p0(q,H,Z){q.playlistParsingError=new Error("#EXT-X-"+H+" must not appear more than once ("+Z[0]+")")}function bQ(q,H,Z){q.playlistParsingError=new Error("#EXT-X-"+H+" must appear before the first Media Segment ("+Z[0]+")")}function q7(q,H){var Z=H.startPTS;if(v(Z)){var Q=0,Y;if(H.sn>q.sn)Q=Z-q.start,Y=q;else Q=q.start-Z,Y=H;if(Y.duration!==Q)Y.setDuration(Q)}else if(H.sn>q.sn){var J=q.cc===H.cc;if(J&&q.minEndPTS)H.setStart(q.start+(q.minEndPTS-q.start));else H.setStart(q.start+q.duration)}else H.setStart(Math.max(q.start-H.duration,0))}function CQ(q,H,Z,Q,Y,J){var X=Q-Z;if(X<=0)s.warn("Fragment should have a positive duration",H),Q=Z+H.duration,J=Y+H.duration;var z=Z,N=Q,W=H.startPTS,G=H.endPTS;if(v(W)){var K=Math.abs(W-Z);if(!v(H.deltaPTS))H.deltaPTS=K;else H.deltaPTS=Math.max(K,H.deltaPTS);z=Math.max(Z,W),Z=Math.min(Z,W),Y=Math.min(Y,H.startDTS),N=Math.min(Q,G),Q=Math.max(Q,G),J=Math.max(J,H.endDTS)}var j=Z-H.start;if(H.start!==0)H.setStart(Z);H.setDuration(Q-H.start),H.startPTS=Z,H.maxStartPTS=z,H.startDTS=Y,H.endPTS=Q,H.minEndPTS=N,H.endDTS=J;var V=H.sn;if(!q||V<q.startSN||V>q.endSN)return 0;var U,A=V-q.startSN,E=q.fragments;E[A]=H;for(U=A;U>0;U--)q7(E[U],E[U-1]);for(U=A;U<E.length-1;U++)q7(E[U],E[U+1]);if(q.fragmentHint)q7(E[E.length-1],q.fragmentHint);return q.PTSKnown=q.alignedSliding=!0,j}function i8(q,H){if(q===H)return;var Z=null,Q=q.fragments;for(var Y=Q.length-1;Y>=0;Y--){var J=Q[Y].initSegment;if(J){Z=J;break}}if(q.fragmentHint)delete q.fragmentHint.endPTS;var X;t8(q,H,function(U,A,E,B){if(H.skippedSegments){if(A.cc!==U.cc){var F=U.cc-A.cc;for(var R=E;R<B.length;R++)B[R].cc+=F}}if(v(U.startPTS)&&v(U.endPTS)){if(A.setStart(A.startPTS=U.startPTS),A.startDTS=U.startDTS,A.maxStartPTS=U.maxStartPTS,A.endPTS=U.endPTS,A.endDTS=U.endDTS,A.minEndPTS=U.minEndPTS,A.setDuration(U.endPTS-U.startPTS),A.duration)X=A;H.PTSKnown=H.alignedSliding=!0}if(U.hasStreams)A.elementaryStreams=U.elementaryStreams;if(A.loader=U.loader,U.hasStats)A.stats=U.stats;if(U.initSegment)A.initSegment=U.initSegment,Z=U.initSegment});var z=H.fragments,N=H.fragmentHint?z.concat(H.fragmentHint):z;if(Z)N.forEach(function(U){var A;if(U&&(!U.initSegment||U.initSegment.relurl===((A=Z)==null?void 0:A.relurl)))U.initSegment=Z});if(H.skippedSegments)if(H.deltaUpdateFailed=z.some(function(U){return!U}),H.deltaUpdateFailed){s.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var W=H.skippedSegments;W--;)z.shift();H.startSN=z[0].sn}else{if(H.endCC=z[z.length-1].cc,H.canSkipDateRanges)H.dateRanges=r8(q.dateRanges,H);var G=q.fragments.filter(function(U){return U.rawProgramDateTime});if(q.hasProgramDateTime&&!H.hasProgramDateTime){for(var K=1;K<N.length;K++)if(N[K].programDateTime===null)Z7(N[K],N[K-1],G)}FQ(G,H)}if(a8(q.partList,H.partList,function(U,A){A.elementaryStreams=U.elementaryStreams,A.stats=U.stats}),X)CQ(H,X,X.startPTS,X.endPTS,X.startDTS,X.endDTS);else DQ(q,H);if(z.length)H.totalduration=H.edge-z[0].start;H.driftStartTime=q.driftStartTime,H.driftStart=q.driftStart;var j=H.advancedDateTime;if(H.advanced&&j){var V=H.edge;if(!H.driftStart)H.driftStartTime=j,H.driftStart=V;H.driftEndTime=j,H.driftEnd=V}else H.driftEndTime=q.driftEndTime,H.driftEnd=q.driftEnd,H.advancedDateTime=q.advancedDateTime;if(H.requestScheduled===-1)H.requestScheduled=q.requestScheduled}function r8(q,H){var{dateRanges:Z,recentlyRemovedDateranges:Q}=H,Y=W0({},q);if(Q)Q.forEach(function(z){delete Y[z]});var J=Object.keys(Y),X=J.length;if(X)Object.keys(Z).forEach(function(z){var N=Y[z],W=new AQ(Z[z].attr,N);if(W.isValid){if(Y[z]=W,!N)W.tagOrder+=X}else s.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+$0(Z[z].attr)+'"')});return Y}function a8(q,H,Z){if(q&&H){var Q=0;for(var Y=0,J=q.length;Y<=J;Y++){var X=q[Y],z=H[Y+Q];if(X&&z&&X.index===z.index&&X.fragment.sn===z.fragment.sn)Z(X,z);else Q--}}}function t8(q,H,Z){var Q=H.skippedSegments,Y=Math.max(q.startSN,H.startSN)-H.startSN,J=(q.fragmentHint?1:0)+(Q?H.endSN:Math.min(q.endSN,H.endSN))-H.startSN,X=H.startSN-q.startSN,z=H.fragmentHint?H.fragments.concat(H.fragmentHint):H.fragments,N=q.fragmentHint?q.fragments.concat(q.fragmentHint):q.fragments;for(var W=Y;W<=J;W++){var G=N[X+W],K=z[W];if(Q&&!K&&G)K=H.fragments[W]=G;if(G&&K){if(Z(G,K,W,z),G.url&&G.url!==K.url){H.playlistParsingError=PQ("media sequence mismatch "+K.sn+":",q,H,G,K);return}else if(G.cc!==K.cc){H.playlistParsingError=PQ("discontinuity sequence mismatch ("+G.cc+"!="+K.cc+")",q,H,G,K);return}}}}function PQ(q,H,Z,Q,Y){return new Error(q+" "+Y.url+`
17
+ Playlist starting @`+H.startSN+`
18
+ `+H.m3u8+`
19
+
20
+ Playlist starting @`+Z.startSN+`
21
+ `+Z.m3u8)}function DQ(q,H,Z){if(Z===void 0)Z=!0;var Q=H.startSN+H.skippedSegments-q.startSN,Y=q.fragments,J=Q>=0,X=0;if(J&&Q<Y.length)X=Y[Q].start;else if(J&&H.startSN===q.endSN+1)X=q.fragmentEnd;else if(J&&Z)X=q.fragmentStart+Q*H.levelTargetDuration;else if(!H.skippedSegments&&H.fragmentStart===0)X=q.fragmentStart;else return;e8(H,X)}function e8(q,H){if(H){var Z=q.fragments;for(var Q=q.skippedSegments;Q<Z.length;Q++)Z[Q].addStart(H);if(q.fragmentHint)q.fragmentHint.addStart(H)}}function SQ(q,H){if(H===void 0)H=1/0;var Z=1000*q.targetduration;if(q.updated){var Q=q.fragments,Y=4;if(Q.length&&Z*Y>H){var J=Q[Q.length-1].duration*1000;if(J<Z)Z=J}}else Z/=2;return Math.round(Z)}function YZ(q,H,Z){if(!q)return null;var Q=q.fragments[H-q.startSN];if(Q)return Q;if(Q=q.fragmentHint,Q&&Q.sn===H)return Q;if(H<q.startSN&&Z&&Z.sn===H)return Z;return null}function xQ(q,H,Z){if(!q)return null;return TQ(q.partList,H,Z)}function TQ(q,H,Z){if(q)for(var Q=q.length;Q--;){var Y=q[Q];if(Y.index===Z&&Y.fragment.sn===H)return Y}return null}function yQ(q){q.forEach(function(H,Z){var Q;(Q=H.details)==null||Q.fragments.forEach(function(Y){if(Y.level=Z,Y.initSegment)Y.initSegment.level=Z})})}var QZ=300000,JZ=function(q){function H(Q){var Y=q.call(this,"content-steering",Q.logger)||this;return Y.hls=void 0,Y.loader=null,Y.uri=null,Y.pathwayId=".",Y._pathwayPriority=null,Y.timeToLoad=300,Y.reloadTimer=-1,Y.updated=0,Y.started=!1,Y.enabled=!0,Y.levels=null,Y.audioTracks=null,Y.subtitleTracks=null,Y.penalizedPathways={},Y.hls=Q,Y.registerListeners(),Y}G0(H,q);var Z=H.prototype;return Z.registerListeners=function Q(){var Y=this.hls;Y.on($.MANIFEST_LOADING,this.onManifestLoading,this),Y.on($.MANIFEST_LOADED,this.onManifestLoaded,this),Y.on($.MANIFEST_PARSED,this.onManifestParsed,this),Y.on($.ERROR,this.onError,this)},Z.unregisterListeners=function Q(){var Y=this.hls;if(!Y)return;Y.off($.MANIFEST_LOADING,this.onManifestLoading,this),Y.off($.MANIFEST_LOADED,this.onManifestLoaded,this),Y.off($.MANIFEST_PARSED,this.onManifestParsed,this),Y.off($.ERROR,this.onError,this)},Z.pathways=function Q(){return(this.levels||[]).reduce(function(Y,J){if(Y.indexOf(J.pathwayId)===-1)Y.push(J.pathwayId);return Y},[])},Z.startLoad=function Q(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){var Y=this.timeToLoad*1000-(performance.now()-this.updated);if(Y>0){this.scheduleRefresh(this.uri,Y);return}}this.loadSteeringManifest(this.uri)}},Z.stopLoad=function Q(){if(this.started=!1,this.loader)this.loader.destroy(),this.loader=null;this.clearTimeout()},Z.clearTimeout=function Q(){if(this.reloadTimer!==-1)self.clearTimeout(this.reloadTimer),this.reloadTimer=-1},Z.destroy=function Q(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null},Z.removeLevel=function Q(Y){var J=this.levels;if(J)this.levels=J.filter(function(X){return X!==Y})},Z.onManifestLoading=function Q(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null},Z.onManifestLoaded=function Q(Y,J){var X=J.contentSteering;if(X===null)return;if(this.pathwayId=X.pathwayId,this.uri=X.uri,this.started)this.startLoad()},Z.onManifestParsed=function Q(Y,J){this.audioTracks=J.audioTracks,this.subtitleTracks=J.subtitleTracks},Z.onError=function Q(Y,J){var X=J.errorAction;if((X==null?void 0:X.action)===A0.SendAlternateToPenaltyBox&&X.flags===S0.MoveAllAlternatesMatchingHost){var z=this.levels,N=this._pathwayPriority,W=this.pathwayId;if(J.context){var G=J.context,K=G.groupId,j=G.pathwayId,V=G.type;if(K&&z)W=this.getPathwayForGroupId(K,V,W);else if(j)W=j}if(!(W in this.penalizedPathways))this.penalizedPathways[W]=performance.now();if(!N&&z)N=this.pathways();if(N&&N.length>1)this.updatePathwayPriority(N),X.resolved=this.pathwayId!==W;if(!X.resolved)this.warn("Could not resolve "+J.details+' ("'+J.error.message+'") with content-steering for Pathway: '+W+" levels: "+(z?z.length:z)+" priorities: "+$0(N)+" penalized: "+$0(this.penalizedPathways))}},Z.filterParsedLevels=function Q(Y){this.levels=Y;var J=this.getLevelsForPathway(this.pathwayId);if(J.length===0){var X=Y[0].pathwayId;this.log("No levels found in Pathway "+this.pathwayId+'. Setting initial Pathway to "'+X+'"'),J=this.getLevelsForPathway(X),this.pathwayId=X}if(J.length!==Y.length)this.log("Found "+J.length+"/"+Y.length+' levels in Pathway "'+this.pathwayId+'"');return J},Z.getLevelsForPathway=function Q(Y){if(this.levels===null)return[];return this.levels.filter(function(J){return Y===J.pathwayId})},Z.updatePathwayPriority=function Q(Y){this._pathwayPriority=Y;var J,X=this.penalizedPathways,z=performance.now();Object.keys(X).forEach(function(V){if(z-X[V]>QZ)delete X[V]});for(var N=0;N<Y.length;N++){var W=Y[N];if(W in X)continue;if(W===this.pathwayId)return;var G=this.hls.nextLoadLevel,K=this.hls.levels[G];if(J=this.getLevelsForPathway(W),J.length>0){this.log('Setting Pathway to "'+W+'"'),this.pathwayId=W,yQ(J),this.hls.trigger($.LEVELS_UPDATED,{levels:J});var j=this.hls.levels[G];if(K&&j&&this.levels){if(j.attrs["STABLE-VARIANT-ID"]!==K.attrs["STABLE-VARIANT-ID"]&&j.bitrate!==K.bitrate)this.log("Unstable Pathways change from bitrate "+K.bitrate+" to "+j.bitrate);this.hls.nextLoadLevel=G}break}}},Z.getPathwayForGroupId=function Q(Y,J,X){var z=this.getLevelsForPathway(X).concat(this.levels||[]);for(var N=0;N<z.length;N++)if(J===o.AUDIO_TRACK&&z[N].hasAudioGroup(Y)||J===o.SUBTITLE_TRACK&&z[N].hasSubtitleGroup(Y))return z[N].pathwayId;return X},Z.clonePathways=function Q(Y){var J=this,X=this.levels;if(!X)return;var z={},N={};Y.forEach(function(W){var G=W.ID,K=W["BASE-ID"],j=W["URI-REPLACEMENT"];if(X.some(function(U){return U.pathwayId===G}))return;var V=J.getLevelsForPathway(K).map(function(U){var A=new H0(U.attrs);A["PATHWAY-ID"]=G;var E=A.AUDIO&&A.AUDIO+"_clone_"+G,B=A.SUBTITLES&&A.SUBTITLES+"_clone_"+G;if(E)z[A.AUDIO]=E,A.AUDIO=E;if(B)N[A.SUBTITLES]=B,A.SUBTITLES=B;var F=_Q(U.uri,A["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",j),R=new JQ({attrs:A,audioCodec:U.audioCodec,bitrate:U.bitrate,height:U.height,name:U.name,url:F,videoCodec:U.videoCodec,width:U.width});if(U.audioGroups)for(var O=1;O<U.audioGroups.length;O++)R.addGroupId("audio",U.audioGroups[O]+"_clone_"+G);if(U.subtitleGroups)for(var M=1;M<U.subtitleGroups.length;M++)R.addGroupId("text",U.subtitleGroups[M]+"_clone_"+G);return R});X.push.apply(X,V),kQ(J.audioTracks,z,j,G),kQ(J.subtitleTracks,N,j,G)})},Z.loadSteeringManifest=function Q(Y){var J=this,X=this.hls.config,z=X.loader;if(this.loader)this.loader.destroy();this.loader=new z(X);var N;try{N=new self.URL(Y)}catch(A){this.enabled=!1,this.log("Failed to parse Steering Manifest URI: "+Y);return}if(N.protocol!=="data:"){var W=(this.hls.bandwidthEstimate||X.abrEwmaDefaultEstimate)|0;N.searchParams.set("_HLS_pathway",this.pathwayId),N.searchParams.set("_HLS_throughput",""+W)}var G={responseType:"json",url:N.href},K=X.steeringManifestLoadPolicy.default,j=K.errorRetry||K.timeoutRetry||{},V={loadPolicy:K,timeout:K.maxLoadTimeMs,maxRetry:j.maxNumRetry||0,retryDelay:j.retryDelayMs||0,maxRetryDelay:j.maxRetryDelayMs||0},U={onSuccess:function A(E,B,F,R){J.log('Loaded steering manifest: "'+N+'"');var O=E.data;if((O==null?void 0:O.VERSION)!==1){J.log("Steering VERSION "+O.VERSION+" not supported!");return}J.updated=performance.now(),J.timeToLoad=O.TTL;var M=O["RELOAD-URI"],L=O["PATHWAY-CLONES"],I=O["PATHWAY-PRIORITY"];if(M)try{J.uri=new self.URL(M,N).href}catch(S){J.enabled=!1,J.log("Failed to parse Steering Manifest RELOAD-URI: "+M);return}if(J.scheduleRefresh(J.uri||F.url),L)J.clonePathways(L);var w={steeringManifest:O,url:N.toString()};if(J.hls.trigger($.STEERING_MANIFEST_LOADED,w),I)J.updatePathwayPriority(I)},onError:function A(E,B,F,R){if(J.log("Error loading steering manifest: "+E.code+" "+E.text+" ("+B.url+")"),J.stopLoad(),E.code===410){J.enabled=!1,J.log("Steering manifest "+B.url+" no longer available");return}var O=J.timeToLoad*1000;if(E.code===429){var M=J.loader;if(typeof(M==null?void 0:M.getResponseHeader)==="function"){var L=M.getResponseHeader("Retry-After");if(L)O=parseFloat(L)*1000}J.log("Steering manifest "+B.url+" rate limited");return}J.scheduleRefresh(J.uri||B.url,O)},onTimeout:function A(E,B,F){J.log("Timeout loading steering manifest ("+B.url+")"),J.scheduleRefresh(J.uri||B.url)}};this.log("Requesting steering manifest: "+N),this.loader.load(G,V,U)},Z.scheduleRefresh=function Q(Y,J){var X=this;if(J===void 0)J=this.timeToLoad*1000;this.clearTimeout(),this.reloadTimer=self.setTimeout(function(){var z,N=(z=X.hls)==null?void 0:z.media;if(N&&!N.ended){X.loadSteeringManifest(Y);return}X.scheduleRefresh(Y,X.timeToLoad*1000)},J)},Z0(H,[{key:"pathwayPriority",get:function Q(){return this._pathwayPriority},set:function Q(Y){this.updatePathwayPriority(Y)}}])}(i0);function kQ(q,H,Z,Q){if(!q)return;Object.keys(H).forEach(function(Y){var J=q.filter(function(X){return X.groupId===Y}).map(function(X){var z=W0({},X);return z.details=void 0,z.attrs=new H0(z.attrs),z.url=z.attrs.URI=_Q(X.url,X.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",Z),z.groupId=z.attrs["GROUP-ID"]=H[Y],z.attrs["PATHWAY-ID"]=Q,z});q.push.apply(q,J)})}function _Q(q,H,Z,Q){var{HOST:Y,PARAMS:J}=Q,X=Q[Z],z;if(H){if(z=X==null?void 0:X[H],z)q=z}var N=new self.URL(q);if(Y&&!z)N.host=Y;if(J)Object.keys(J).sort().forEach(function(W){if(W)N.searchParams.set(W,J[W])});return N.href}var ZZ=function(){function q(Z){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=Z,this.registerListeners()}var H=q.prototype;return H.setStreamController=function Z(Q){this.streamController=Q},H.registerListeners=function Z(){this.hls.on($.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on($.MEDIA_DETACHING,this.onMediaDetaching,this)},H.unregisterListeners=function Z(){this.hls.off($.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off($.MEDIA_DETACHING,this.onMediaDetaching,this)},H.destroy=function Z(){if(this.timer)clearInterval(this.timer);this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},H.onMediaAttaching=function Z(Q,Y){var J=this.hls.config;if(J.capLevelOnFPSDrop){var X=Y.media instanceof self.HTMLVideoElement?Y.media:null;if(this.media=X,X&&typeof X.getVideoPlaybackQuality==="function")this.isVideoPlaybackQualityAvailable=!0;self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),J.fpsDroppedMonitoringPeriod)}},H.onMediaDetaching=function Z(){this.media=null},H.checkFPS=function Z(Q,Y,J){var X=performance.now();if(Y){if(this.lastTime){var z=X-this.lastTime,N=J-this.lastDroppedFrames,W=Y-this.lastDecodedFrames,G=1000*N/z,K=this.hls;if(K.trigger($.FPS_DROP,{currentDropped:N,currentDecoded:W,totalDroppedFrames:J}),G>0){if(N>K.config.fpsDroppedMonitoringThreshold*W){var j=K.currentLevel;if(K.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+j),j>0&&(K.autoLevelCapping===-1||K.autoLevelCapping>=j))j=j-1,K.trigger($.FPS_DROP_LEVEL_CAPPING,{level:j,droppedLevel:K.currentLevel}),K.autoLevelCapping=j,this.streamController.nextLevelSwitch()}}}this.lastTime=X,this.lastDroppedFrames=J,this.lastDecodedFrames=Y}},H.checkFPSInterval=function Z(){var Q=this.media;if(Q)if(this.isVideoPlaybackQualityAvailable){var Y=Q.getVideoPlaybackQuality();this.checkFPS(Q,Y.totalVideoFrames,Y.droppedVideoFrames)}else this.checkFPS(Q,Q.webkitDecodedFrameCount,Q.webkitDroppedFrameCount)},q}(),qZ=function(){function q(){this.chunks=[],this.dataLength=0}var H=q.prototype;return H.push=function Z(Q){this.chunks.push(Q),this.dataLength+=Q.length},H.flush=function Z(){var Q=this.chunks,Y=this.dataLength,J;if(!Q.length)return new Uint8Array(0);else if(Q.length===1)J=Q[0];else J=XZ(Q,Y);return this.reset(),J},H.reset=function Z(){this.chunks.length=0,this.dataLength=0},q}();function XZ(q,H){var Z=new Uint8Array(H),Q=0;for(var Y=0;Y<q.length;Y++){var J=q[Y];Z.set(J,Q),Q+=J.length}return Z}function hQ(q,H){if(H+10<=q.length){if(q[H]===51&&q[H+1]===68&&q[H+2]===73){if(q[H+3]<255&&q[H+4]<255){if(q[H+6]<128&&q[H+7]<128&&q[H+8]<128&&q[H+9]<128)return!0}}}return!1}function X7(q,H){if(H+10<=q.length){if(q[H]===73&&q[H+1]===68&&q[H+2]===51){if(q[H+3]<255&&q[H+4]<255){if(q[H+6]<128&&q[H+7]<128&&q[H+8]<128&&q[H+9]<128)return!0}}}return!1}function wY(q,H){var Z=0;return Z=(q[H]&127)<<21,Z|=(q[H+1]&127)<<14,Z|=(q[H+2]&127)<<7,Z|=q[H+3]&127,Z}function LY(q,H){var Z=H,Q=0;while(X7(q,H)){Q+=10;var Y=wY(q,H+6);if(Q+=Y,hQ(q,H+10))Q+=10;H+=Q}if(Q>0)return q.subarray(Z,Z+Q);return}function HZ(q,H,Z,Q){var Y=[96000,88200,64000,48000,44100,32000,24000,22050,16000,12000,11025,8000,7350],J=H[Z+2],X=J>>2&15;if(X>12){var z=new Error("invalid ADTS sampling index:"+X);q.emit($.ERROR,$.ERROR,{type:f.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!0,error:z,reason:z.message});return}var N=(J>>6&3)+1,W=H[Z+3]>>6&3|(J&1)<<2,G="mp4a.40."+N,K=Y[X],j=X;if(N===5||N===29)j-=3;var V=[N<<3|(j&14)>>1,(j&1)<<7|W<<3];return s.log("manifest codec:"+Q+", parsed codec:"+G+", channels:"+W+", rate:"+K+" (ADTS object type:"+N+" sampling index:"+X+")"),{config:V,samplerate:K,channelCount:W,codec:G,parsedCodec:G,manifestCodec:Q}}function vQ(q,H){return q[H]===255&&(q[H+1]&246)===240}function gQ(q,H){return q[H+1]&1?7:9}function H7(q,H){return(q[H+3]&3)<<11|q[H+4]<<3|(q[H+5]&224)>>>5}function zZ(q,H){return H+5<q.length}function bY(q,H){return H+1<q.length&&vQ(q,H)}function NZ(q,H){return zZ(q,H)&&vQ(q,H)&&H7(q,H)<=q.length-H}function WZ(q,H){if(bY(q,H)){var Z=gQ(q,H);if(H+Z>=q.length)return!1;var Q=H7(q,H);if(Q<=Z)return!1;var Y=H+Q;return Y===q.length||bY(q,Y)}return!1}function mQ(q,H,Z,Q,Y){if(!q.samplerate){var J=HZ(H,Z,Q,Y);if(!J)return;W0(q,J)}}function pQ(q){return 92160000/q}function GZ(q,H){var Z=gQ(q,H);if(H+Z<=q.length){var Q=H7(q,H)-Z;if(Q>0)return{headerLength:Z,frameLength:Q}}}function uQ(q,H,Z,Q,Y){var J=pQ(q.samplerate),X=Q+Y*J,z=GZ(H,Z),N;if(z){var{frameLength:W,headerLength:G}=z,K=G+W,j=Math.max(0,Z+K-H.length);if(j)N=new Uint8Array(K-G),N.set(H.subarray(Z+G,H.length),0);else N=H.subarray(Z+G,Z+K);var V={unit:N,pts:X};if(!j)q.samples.push(V);return{sample:V,length:K,missing:j}}var U=H.length-Z;N=new Uint8Array(U),N.set(H.subarray(Z,H.length),0);var A={unit:N,pts:X};return{sample:A,length:U,missing:-1}}function KZ(q,H){return X7(q,H)&&wY(q,H+6)+10<=q.length-H}function jZ(q){if(q.size<2)return;var H=P0(q.data,!0),Z=new Uint8Array(q.data.subarray(H.length+1));return{key:q.type,info:H,data:Z.buffer}}function UZ(q){if(q.size<2)return;if(q.type==="TXXX"){var H=1,Z=P0(q.data.subarray(H),!0);H+=Z.length+1;var Q=P0(q.data.subarray(H));return{key:q.type,info:Z,data:Q}}var Y=P0(q.data.subarray(1));return{key:q.type,info:"",data:Y}}function VZ(q){if(q.type==="WXXX"){if(q.size<2)return;var H=1,Z=P0(q.data.subarray(H),!0);H+=Z.length+1;var Q=P0(q.data.subarray(H));return{key:q.type,info:Z,data:Q}}var Y=P0(q.data);return{key:q.type,info:"",data:Y}}function AZ(q){if(q instanceof ArrayBuffer)return q;else{if(q.byteOffset==0&&q.byteLength==q.buffer.byteLength)return q.buffer;return new Uint8Array(q).buffer}}function z7(q,H,Z){if(H===void 0)H=0;if(Z===void 0)Z=1/0;return EZ(q,H,Z,Uint8Array)}function EZ(q,H,Z,Q){var Y=BZ(q),J=1;if("BYTES_PER_ELEMENT"in Q)J=Q.BYTES_PER_ELEMENT;var X=$Z(q)?q.byteOffset:0,z=(X+q.byteLength)/J,N=(X+H)/J,W=Math.floor(Math.max(0,Math.min(N,z))),G=Math.floor(Math.min(W+Math.max(Z,0),z));return new Q(Y,W,G-W)}function BZ(q){if(q instanceof ArrayBuffer)return q;else return q.buffer}function $Z(q){return q&&q.buffer instanceof ArrayBuffer&&q.byteLength!==void 0&&q.byteOffset!==void 0}function FZ(q){var H={key:q.type,description:"",data:"",mimeType:null,pictureType:null},Z=3;if(q.size<2)return;if(q.data[0]!==Z){console.log("Ignore frame with unrecognized character encoding");return}var Q=q.data.subarray(1).indexOf(0);if(Q===-1)return;var Y=P0(z7(q.data,1,Q)),J=q.data[2+Q],X=q.data.subarray(3+Q).indexOf(0);if(X===-1)return;var z=P0(z7(q.data,3+Q,X)),N;if(Y==="-->")N=P0(z7(q.data,4+Q+X));else N=AZ(q.data.subarray(4+Q+X));return H.mimeType=Y,H.pictureType=J,H.description=z,H.data=N,H}function OZ(q){if(q.type==="PRIV")return jZ(q);else if(q.type[0]==="W")return VZ(q);else if(q.type==="APIC")return FZ(q);return UZ(q)}function RZ(q){var H=String.fromCharCode(q[0],q[1],q[2],q[3]),Z=wY(q,4),Q=10;return{type:H,size:Z,data:q.subarray(Q,Q+Z)}}var CY=10,MZ=10;function cQ(q){var H=0,Z=[];while(X7(q,H)){var Q=wY(q,H+6);if(q[H+5]>>6&1)H+=CY;H+=CY;var Y=H+Q;while(H+MZ<Y){var J=RZ(q.subarray(H)),X=OZ(J);if(X)Z.push(X);H+=J.size+CY}if(hQ(q,H))H+=CY}return Z}function fQ(q){return q&&q.key==="PRIV"&&q.info==="com.apple.streaming.transportStreamTimestamp"}function IZ(q){if(q.data.byteLength===8){var H=new Uint8Array(q.data),Z=H[3]&1,Q=(H[4]<<23)+(H[5]<<15)+(H[6]<<7)+H[7];if(Q/=45,Z)Q+=47721858.84;return Math.round(Q)}return}function dQ(q){var H=cQ(q);for(var Z=0;Z<H.length;Z++){var Q=H[Z];if(fQ(Q))return IZ(Q)}return}var L0=function(q){return q.audioId3="org.id3",q.dateRange="com.apple.quicktime.HLS",q.emsg="https://aomedia.org/emsg/ID3",q.misbklv="urn:misb:KLV:bin:1910.1",q}({});function v0(q,H){if(q===void 0)q="";if(H===void 0)H=90000;return{type:q,id:-1,pid:-1,inputTimeScale:H,sequenceNumber:-1,samples:[],dropped:0}}var lQ=function(){function q(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var H=q.prototype;return H.resetInitSegment=function Z(Q,Y,J,X){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:90000,sequenceNumber:0,samples:[],dropped:0}},H.resetTimeStamp=function Z(Q){this.initPTS=Q,this.resetContiguity()},H.resetContiguity=function Z(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},H.canParse=function Z(Q,Y){return!1},H.appendFrame=function Z(Q,Y,J){},H.demux=function Z(Q,Y){if(this.cachedData)Q=D0(this.cachedData,Q),this.cachedData=null;var J=LY(Q,0),X=J?J.length:0,z,N=this._audioTrack,W=this._id3Track,G=J?dQ(J):void 0,K=Q.length;if(this.basePTS===null||this.frameIndex===0&&v(G))this.basePTS=wZ(G,Y,this.initPTS),this.lastPTS=this.basePTS;if(this.lastPTS===null)this.lastPTS=this.basePTS;if(J&&J.length>0)W.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:J,type:L0.audioId3,duration:Number.POSITIVE_INFINITY});while(X<K){if(this.canParse(Q,X)){var j=this.appendFrame(N,Q,X);if(j)this.frameIndex++,this.lastPTS=j.sample.pts,X+=j.length,z=X;else X=K}else if(KZ(Q,X))J=LY(Q,X),W.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:J,type:L0.audioId3,duration:Number.POSITIVE_INFINITY}),X+=J.length,z=X;else X++;if(X===K&&z!==K){var V=Q.slice(z);if(this.cachedData)this.cachedData=D0(this.cachedData,V);else this.cachedData=V}}return{audioTrack:N,videoTrack:v0(),id3Track:W,textTrack:v0()}},H.demuxSampleAes=function Z(Q,Y,J){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},H.flush=function Z(Q){var Y=this.cachedData;if(Y)this.cachedData=null,this.demux(Y,0);return{audioTrack:this._audioTrack,videoTrack:v0(),id3Track:this._id3Track,textTrack:v0()}},H.destroy=function Z(){this.cachedData=null,this._audioTrack=this._id3Track=void 0},q}(),wZ=function q(H,Z,Q){if(v(H))return H*90;var Y=Q?Q.baseTime*90000/Q.timescale:0;return Z*90000+Y},PY=null,LZ=[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],bZ=[44100,48000,32000,22050,24000,16000,11025,12000,8000],CZ=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],PZ=[0,1,1,4];function nQ(q,H,Z,Q,Y){if(Z+24>H.length)return;var J=oQ(H,Z);if(J&&Z+J.frameLength<=H.length){var X=J.samplesPerFrame*90000/J.sampleRate,z=Q+Y*X,N={unit:H.subarray(Z,Z+J.frameLength),pts:z,dts:z};return q.config=[],q.channelCount=J.channelCount,q.samplerate=J.sampleRate,q.samples.push(N),{sample:N,length:J.frameLength,missing:0}}}function oQ(q,H){var Z=q[H+1]>>3&3,Q=q[H+1]>>1&3,Y=q[H+2]>>4&15,J=q[H+2]>>2&3;if(Z!==1&&Y!==0&&Y!==15&&J!==3){var X=q[H+2]>>1&1,z=q[H+3]>>6,N=Z===3?3-Q:Q===3?3:4,W=LZ[N*14+Y-1]*1000,G=Z===3?0:Z===2?1:2,K=bZ[G*3+J],j=z===3?1:2,V=CZ[Z][Q],U=PZ[Q],A=V*8*U,E=Math.floor(V*W/K+X)*U;if(PY===null){var B=navigator.userAgent||"",F=B.match(/Chrome\/(\d+)/i);PY=F?parseInt(F[1]):0}var R=!!PY&&PY<=87;if(R&&Q===2&&W>=224000&&z===0)q[H+3]=q[H+3]|128;return{sampleRate:K,channelCount:j,frameLength:E,samplesPerFrame:A}}}function N7(q,H){return q[H]===255&&(q[H+1]&224)===224&&(q[H+1]&6)!==0}function sQ(q,H){return H+1<q.length&&N7(q,H)}function DZ(q,H){var Z=4;return N7(q,H)&&Z<=q.length-H}function iQ(q,H){if(H+1<q.length&&N7(q,H)){var Z=4,Q=oQ(q,H),Y=Z;if(Q!=null&&Q.frameLength)Y=Q.frameLength;var J=H+Y;return J===q.length||sQ(q,J)}return!1}var SZ=function(q){function H(Q,Y){var J=q.call(this)||this;return J.observer=void 0,J.config=void 0,J.observer=Q,J.config=Y,J}G0(H,q);var Z=H.prototype;return Z.resetInitSegment=function Q(Y,J,X,z){q.prototype.resetInitSegment.call(this,Y,J,X,z),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:J,duration:z,inputTimeScale:90000,dropped:0}},H.probe=function Q(Y,J){if(!Y)return!1;var X=LY(Y,0),z=(X==null?void 0:X.length)||0;if(iQ(Y,z))return!1;for(var N=Y.length;z<N;z++)if(WZ(Y,z))return J.log("ADTS sync word found !"),!0;return!1},Z.canParse=function Q(Y,J){return NZ(Y,J)},Z.appendFrame=function Q(Y,J,X){mQ(Y,this.observer,J,X,Y.manifestCodec);var z=uQ(Y,J,X,this.basePTS,this.frameIndex);if(z&&z.missing===0)return z},H}(lQ),xZ=function q(H,Z){var Q=0,Y=5;Z+=Y;var J=new Uint32Array(1),X=new Uint32Array(1),z=new Uint8Array(1);while(Y>0){z[0]=H[Z];var N=Math.min(Y,8),W=8-N;X[0]=4278190080>>>24+W<<W,J[0]=(z[0]&X[0])>>W,Q=!Q?J[0]:Q<<N|J[0],Z+=1,Y-=N}return Q},TZ=function(q){function H(){return q.apply(this,arguments)||this}G0(H,q);var Z=H.prototype;return Z.resetInitSegment=function Q(Y,J,X,z){q.prototype.resetInitSegment.call(this,Y,J,X,z),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:J,duration:z,inputTimeScale:90000,dropped:0}},H.probe=function Q(Y){if(!Y)return!1;var J=LY(Y,0),X=(J==null?void 0:J.length)||0;if(J&&Y[X]===11&&Y[X+1]===119&&dQ(J)!==void 0&&xZ(Y,X)<=16)return!1;for(var z=Y.length;X<z;X++)if(iQ(Y,X))return s.log("MPEG Audio sync word found !"),!0;return!1},Z.canParse=function Q(Y,J){return DZ(Y,J)},Z.appendFrame=function Q(Y,J,X){if(this.basePTS===null)return;return nQ(Y,J,X,this.basePTS,this.frameIndex)},H}(lQ),yZ=function(){function q(Z,Q,Y){this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=Z,this.aesIV=Q,this.aesMode=Y}var H=q.prototype;return H.decrypt=function Z(Q,Y){switch(this.aesMode){case l0.cbc:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},Y,Q);case l0.ctr:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},Y,Q);default:throw new Error("[AESCrypto] invalid aes mode "+this.aesMode)}},q}();function kZ(q){var H=q.byteLength,Z=H&&new DataView(q.buffer).getUint8(H-1);if(Z)return q.slice(0,H-Z);return q}var _Z=function(){function q(){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 H=q.prototype;return H.uint8ArrayToUint32Array_=function Z(Q){var Y=new DataView(Q),J=new Uint32Array(4);for(var X=0;X<4;X++)J[X]=Y.getUint32(X*4);return J},H.initTable=function Z(){var Q=this.sBox,Y=this.invSBox,J=this.subMix,X=J[0],z=J[1],N=J[2],W=J[3],G=this.invSubMix,K=G[0],j=G[1],V=G[2],U=G[3],A=new Uint32Array(256),E=0,B=0,F=0;for(F=0;F<256;F++)if(F<128)A[F]=F<<1;else A[F]=F<<1^283;for(F=0;F<256;F++){var R=B^B<<1^B<<2^B<<3^B<<4;R=R>>>8^R&255^99,Q[E]=R,Y[R]=E;var O=A[E],M=A[O],L=A[M],I=A[R]*257^R*16843008;if(X[E]=I<<24|I>>>8,z[E]=I<<16|I>>>16,N[E]=I<<8|I>>>24,W[E]=I,I=L*16843009^M*65537^O*257^E*16843008,K[R]=I<<24|I>>>8,j[R]=I<<16|I>>>16,V[R]=I<<8|I>>>24,U[R]=I,!E)E=B=1;else E=O^A[A[A[L^O]]],B^=A[A[B]]}},H.expandKey=function Z(Q){var Y=this.uint8ArrayToUint32Array_(Q),J=!0,X=0;while(X<Y.length&&J)J=Y[X]===this.key[X],X++;if(J)return;this.key=Y;var z=this.keySize=Y.length;if(z!==4&&z!==6&&z!==8)throw new Error("Invalid aes key size="+z);var N=this.ksRows=(z+6+1)*4,W,G,K=this.keySchedule=new Uint32Array(N),j=this.invKeySchedule=new Uint32Array(N),V=this.sBox,U=this.rcon,A=this.invSubMix,E=A[0],B=A[1],F=A[2],R=A[3],O,M;for(W=0;W<N;W++){if(W<z){O=K[W]=Y[W];continue}if(M=O,W%z===0)M=M<<8|M>>>24,M=V[M>>>24]<<24|V[M>>>16&255]<<16|V[M>>>8&255]<<8|V[M&255],M^=U[W/z|0]<<24;else if(z>6&&W%z===4)M=V[M>>>24]<<24|V[M>>>16&255]<<16|V[M>>>8&255]<<8|V[M&255];K[W]=O=(K[W-z]^M)>>>0}for(G=0;G<N;G++){if(W=N-G,G&3)M=K[W];else M=K[W-4];if(G<4||W<=4)j[G]=M;else j[G]=E[V[M>>>24]]^B[V[M>>>16&255]]^F[V[M>>>8&255]]^R[V[M&255]];j[G]=j[G]>>>0}},H.networkToHostOrderSwap=function Z(Q){return Q<<24|(Q&65280)<<8|(Q&16711680)>>8|Q>>>24},H.decrypt=function Z(Q,Y,J){var X=this.keySize+6,z=this.invKeySchedule,N=this.invSBox,W=this.invSubMix,G=W[0],K=W[1],j=W[2],V=W[3],U=this.uint8ArrayToUint32Array_(J),A=U[0],E=U[1],B=U[2],F=U[3],R=new Int32Array(Q),O=new Int32Array(R.length),M,L,I,w,S,P,b,C,x,_,y,T,h,g,m=this.networkToHostOrderSwap;while(Y<R.length){x=m(R[Y]),_=m(R[Y+1]),y=m(R[Y+2]),T=m(R[Y+3]),S=x^z[0],P=T^z[1],b=y^z[2],C=_^z[3],h=4;for(g=1;g<X;g++)M=G[S>>>24]^K[P>>16&255]^j[b>>8&255]^V[C&255]^z[h],L=G[P>>>24]^K[b>>16&255]^j[C>>8&255]^V[S&255]^z[h+1],I=G[b>>>24]^K[C>>16&255]^j[S>>8&255]^V[P&255]^z[h+2],w=G[C>>>24]^K[S>>16&255]^j[P>>8&255]^V[b&255]^z[h+3],S=M,P=L,b=I,C=w,h=h+4;M=N[S>>>24]<<24^N[P>>16&255]<<16^N[b>>8&255]<<8^N[C&255]^z[h],L=N[P>>>24]<<24^N[b>>16&255]<<16^N[C>>8&255]<<8^N[S&255]^z[h+1],I=N[b>>>24]<<24^N[C>>16&255]<<16^N[S>>8&255]<<8^N[P&255]^z[h+2],w=N[C>>>24]<<24^N[S>>16&255]<<16^N[P>>8&255]<<8^N[b&255]^z[h+3],O[Y]=m(M^A),O[Y+1]=m(w^E),O[Y+2]=m(I^B),O[Y+3]=m(L^F),A=x,E=_,B=y,F=T,Y=Y+4}return O.buffer},q}(),hZ=function(){function q(Z,Q,Y){this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=Z,this.key=Q,this.aesMode=Y}var H=q.prototype;return H.expandKey=function Z(){var Q=vZ(this.aesMode);return this.subtle.importKey("raw",this.key,{name:Q},!1,["encrypt","decrypt"])},q}();function vZ(q){switch(q){case l0.cbc:return"AES-CBC";case l0.ctr:return"AES-CTR";default:throw new Error("[FastAESKey] invalid aes mode "+q)}}var gZ=16,W7=function(){function q(Z,Q){var Y=Q===void 0?{}:Q,J=Y.removePKCS7Padding,X=J===void 0?!0:J;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.enableSoftwareAES=void 0,this.enableSoftwareAES=Z.enableSoftwareAES,this.removePKCS7Padding=X,X)try{var z=self.crypto;if(z)this.subtle=z.subtle||z.webkitSubtle}catch(N){}this.useSoftware=!this.subtle}var H=q.prototype;return H.destroy=function Z(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},H.isSync=function Z(){return this.useSoftware},H.flush=function Z(){var Q=this.currentResult,Y=this.remainderData;if(!Q||Y)return this.reset(),null;var J=new Uint8Array(Q);if(this.reset(),this.removePKCS7Padding)return kZ(J);return J},H.reset=function Z(){if(this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter)this.softwareDecrypter=null},H.decrypt=function Z(Q,Y,J,X){var z=this;if(this.useSoftware)return new Promise(function(N,W){var G=ArrayBuffer.isView(Q)?Q:new Uint8Array(Q);z.softwareDecrypt(G,Y,J,X);var K=z.flush();if(K)N(K.buffer);else W(new Error("[softwareDecrypt] Failed to decrypt data"))});return this.webCryptoDecrypt(new Uint8Array(Q),Y,J,X)},H.softwareDecrypt=function Z(Q,Y,J,X){var z=this.currentIV,N=this.currentResult,W=this.remainderData;if(X!==l0.cbc||Y.byteLength!==16)return s.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;if(this.logOnce("JS AES decrypt"),W)Q=D0(W,Q),this.remainderData=null;var G=this.getValidChunk(Q);if(!G.length)return null;if(z)J=z;var K=this.softwareDecrypter;if(!K)K=this.softwareDecrypter=new _Z;K.expandKey(Y);var j=N;if(this.currentResult=K.decrypt(G.buffer,0,J),this.currentIV=G.slice(-16).buffer,!j)return null;return j},H.webCryptoDecrypt=function Z(Q,Y,J,X){var z=this;if(this.key!==Y||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(Q,Y,J,X));this.key=Y,this.fastAesKey=new hZ(this.subtle,Y,X)}return this.fastAesKey.expandKey().then(function(N){if(!z.subtle)return Promise.reject(new Error("web crypto not initialized"));z.logOnce("WebCrypto AES decrypt");var W=new yZ(z.subtle,new Uint8Array(J),X);return W.decrypt(Q.buffer,N)}).catch(function(N){return s.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+N.name+": "+N.message),z.onWebCryptoError(Q,Y,J,X)})},H.onWebCryptoError=function Z(Q,Y,J,X){var z=this.enableSoftwareAES;if(z){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(Q,Y,J,X);var N=this.flush();if(N)return N.buffer}throw new Error("WebCrypto"+(z?" and softwareDecrypt":"")+": failed to decrypt data")},H.getValidChunk=function Z(Q){var Y=Q,J=Q.length-Q.length%gZ;if(J!==Q.length)Y=Q.slice(0,J),this.remainderData=Q.slice(J);return Y},H.logOnce=function Z(Q){if(!this.logEnabled)return;s.log("[decrypter]: "+Q),this.logEnabled=!1},q}(),mZ=/\/emsg[-/]ID3/i,pZ=function(){function q(Z,Q){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=Q}var H=q.prototype;return H.resetTimeStamp=function Z(){},H.resetInitSegment=function Z(Q,Y,J,X){var z=this.videoTrack=v0("video",1),N=this.audioTrack=v0("audio",1),W=this.txtTrack=v0("text",1);if(this.id3Track=v0("id3",1),this.timeOffset=0,!(Q!=null&&Q.byteLength))return;var G=d7(Q);if(G.video){var K=G.video,j=K.id,V=K.timescale,U=K.codec,A=K.supplemental;z.id=j,z.timescale=W.timescale=V,z.codec=U,z.supplemental=A}if(G.audio){var E=G.audio,B=E.id,F=E.timescale,R=E.codec;N.id=B,N.timescale=F,N.codec=R}W.id=p7.text,z.sampleDuration=0,z.duration=N.duration=X},H.resetContiguity=function Z(){this.remainderData=null},q.probe=function Z(Q){return eJ(Q)},H.demux=function Z(Q,Y){this.timeOffset=Y;var J=Q,X=this.videoTrack,z=this.txtTrack;if(this.config.progressive){if(this.remainderData)J=D0(this.remainderData,Q);var N=N8(J);this.remainderData=N.remainder,X.samples=N.valid||new Uint8Array}else X.samples=J;var W=this.extractID3Track(X,Y);return z.samples=l7(Y,X),{videoTrack:X,audioTrack:this.audioTrack,id3Track:W,textTrack:this.txtTrack}},H.flush=function Z(){var Q=this.timeOffset,Y=this.videoTrack,J=this.txtTrack;Y.samples=this.remainderData||new Uint8Array,this.remainderData=null;var X=this.extractID3Track(Y,this.timeOffset);return J.samples=l7(Q,Y),{videoTrack:Y,audioTrack:v0(),id3Track:X,textTrack:v0()}},H.extractID3Track=function Z(Q,Y){var J=this,X=this.id3Track;if(Q.samples.length){var z=c(Q.samples,["emsg"]);if(z)z.forEach(function(N){var W=G8(N);if(mZ.test(W.schemeIdUri)){var G=rQ(W,Y),K=W.eventDuration===4294967295?Number.POSITIVE_INFINITY:W.eventDuration/W.timeScale;if(K<=0.001)K=Number.POSITIVE_INFINITY;var j=W.payload;X.samples.push({data:j,len:j.byteLength,dts:G,pts:G,type:L0.emsg,duration:K})}else if(J.config.enableEmsgKLVMetadata&&W.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){var V=rQ(W,Y);X.samples.push({data:W.payload,len:W.payload.byteLength,dts:V,pts:V,type:L0.misbklv,duration:Number.POSITIVE_INFINITY})}})}return X},H.demuxSampleAes=function Z(Q,Y,J){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},H.destroy=function Z(){this.config=null,this.remainderData=null,this.videoTrack=this.audioTrack=this.id3Track=this.txtTrack=void 0},q}();function rQ(q,H){return v(q.presentationTime)?q.presentationTime/q.timeScale:H+q.presentationTimeDelta/q.timeScale}var uZ=function(){function q(Z,Q,Y){this.keyData=void 0,this.decrypter=void 0,this.keyData=Y,this.decrypter=new W7(Q,{removePKCS7Padding:!1})}var H=q.prototype;return H.decryptBuffer=function Z(Q){return this.decrypter.decrypt(Q,this.keyData.key.buffer,this.keyData.iv.buffer,l0.cbc)},H.decryptAacSample=function Z(Q,Y,J){var X=this,z=Q[Y].unit;if(z.length<=16)return;var N=z.subarray(16,z.length-z.length%16),W=N.buffer.slice(N.byteOffset,N.byteOffset+N.length);this.decryptBuffer(W).then(function(G){var K=new Uint8Array(G);if(z.set(K,16),!X.decrypter.isSync())X.decryptAacSamples(Q,Y+1,J)})},H.decryptAacSamples=function Z(Q,Y,J){for(;;Y++){if(Y>=Q.length){J();return}if(Q[Y].unit.length<32)continue;if(this.decryptAacSample(Q,Y,J),!this.decrypter.isSync())return}},H.getAvcEncryptedData=function Z(Q){var Y=Math.floor((Q.length-48)/160)*16+16,J=new Int8Array(Y),X=0;for(var z=32;z<Q.length-16;z+=160,X+=16)J.set(Q.subarray(z,z+16),X);return J},H.getAvcDecryptedUnit=function Z(Q,Y){var J=new Uint8Array(Y),X=0;for(var z=32;z<Q.length-16;z+=160,X+=16)Q.set(J.subarray(X,X+16),z);return Q},H.decryptAvcSample=function Z(Q,Y,J,X,z){var N=this,W=o7(z.data),G=this.getAvcEncryptedData(W);this.decryptBuffer(G.buffer).then(function(K){if(z.data=N.getAvcDecryptedUnit(W,K),!N.decrypter.isSync())N.decryptAvcSamples(Q,Y,J+1,X)})},H.decryptAvcSamples=function Z(Q,Y,J,X){if(Q instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;Y++,J=0){if(Y>=Q.length){X();return}var z=Q[Y].units;for(;;J++){if(J>=z.length)break;var N=z[J];if(N.data.length<=48||N.type!==1&&N.type!==5)continue;if(this.decryptAvcSample(Q,Y,J,X,N),!this.decrypter.isSync())return}}},q}(),cZ=function(){function q(){this.VideoSample=null}var H=q.prototype;return H.createVideoSample=function Z(Q,Y,J){return{key:Q,frame:!1,pts:Y,dts:J,units:[],length:0}},H.getLastNalUnit=function Z(Q){var Y,J=this.VideoSample,X;if(!J||J.units.length===0)J=Q[Q.length-1];if((Y=J)!=null&&Y.units){var z=J.units;X=z[z.length-1]}return X},H.pushAccessUnit=function Z(Q,Y){if(Q.units.length&&Q.frame){if(Q.pts===void 0){var J=Y.samples,X=J.length;if(X){var z=J[X-1];Q.pts=z.pts,Q.dts=z.dts}else{Y.dropped++;return}}Y.samples.push(Q)}},H.parseNALu=function Z(Q,Y,J){var X=Y.byteLength,z=Q.naluState||0,N=z,W=[],G=0,K,j,V,U=-1,A=0;if(z===-1)U=0,A=this.getNALuType(Y,0),z=0,G=1;while(G<X){if(K=Y[G++],!z){z=K?0:1;continue}if(z===1){z=K?0:2;continue}if(!K)z=3;else if(K===1){if(j=G-z-1,U>=0){var E={data:Y.subarray(U,j),type:A};W.push(E)}else{var B=this.getLastNalUnit(Q.samples);if(B){if(N&&G<=4-N){if(B.state)B.data=B.data.subarray(0,B.data.byteLength-N)}if(j>0)B.data=D0(B.data,Y.subarray(0,j)),B.state=0}}if(G<X)V=this.getNALuType(Y,G),U=G,A=V,z=0;else z=-1}else z=0}if(U>=0&&z>=0){var F={data:Y.subarray(U,X),type:A,state:z};W.push(F)}if(W.length===0){var R=this.getLastNalUnit(Q.samples);if(R)R.data=D0(R.data,Y)}return Q.naluState=z,W},q}(),aQ=function(){function q(Z){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=Z,this.bytesAvailable=Z.byteLength,this.word=0,this.bitsAvailable=0}var H=q.prototype;return H.loadWord=function Z(){var Q=this.data,Y=this.bytesAvailable,J=Q.byteLength-Y,X=new Uint8Array(4),z=Math.min(4,Y);if(z===0)throw new Error("no bytes available");X.set(Q.subarray(J,J+z)),this.word=new DataView(X.buffer).getUint32(0),this.bitsAvailable=z*8,this.bytesAvailable-=z},H.skipBits=function Z(Q){var Y;if(Q=Math.min(Q,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>Q)this.word<<=Q,this.bitsAvailable-=Q;else Q-=this.bitsAvailable,Y=Q>>3,Q-=Y<<3,this.bytesAvailable-=Y,this.loadWord(),this.word<<=Q,this.bitsAvailable-=Q},H.readBits=function Z(Q){var Y=Math.min(this.bitsAvailable,Q),J=this.word>>>32-Y;if(Q>32)s.error("Cannot read more than 32 bits at a time");if(this.bitsAvailable-=Y,this.bitsAvailable>0)this.word<<=Y;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");if(Y=Q-Y,Y>0&&this.bitsAvailable)return J<<Y|this.readBits(Y);else return J},H.skipLZ=function Z(){var Q;for(Q=0;Q<this.bitsAvailable;++Q)if((this.word&2147483648>>>Q)!==0)return this.word<<=Q,this.bitsAvailable-=Q,Q;return this.loadWord(),Q+this.skipLZ()},H.skipUEG=function Z(){this.skipBits(1+this.skipLZ())},H.skipEG=function Z(){this.skipBits(1+this.skipLZ())},H.readUEG=function Z(){var Q=this.skipLZ();return this.readBits(Q+1)-1},H.readEG=function Z(){var Q=this.readUEG();if(1&Q)return 1+Q>>>1;else return-1*(Q>>>1)},H.readBoolean=function Z(){return this.readBits(1)===1},H.readUByte=function Z(){return this.readBits(8)},H.readUShort=function Z(){return this.readBits(16)},H.readUInt=function Z(){return this.readBits(32)},q}(),tQ=function(q){function H(){return q.apply(this,arguments)||this}G0(H,q);var Z=H.prototype;return Z.parsePES=function Q(Y,J,X,z){var N=this,W=this.parseNALu(Y,X.data,z),G=this.VideoSample,K,j=!1;if(X.data=null,G&&W.length&&!Y.audFound)this.pushAccessUnit(G,Y),G=this.VideoSample=this.createVideoSample(!1,X.pts,X.dts);if(W.forEach(function(V){var U,A;switch(V.type){case 1:{var E=!1;K=!0;var B=V.data;if(j&&B.length>4){var F=N.readSliceType(B);if(F===2||F===4||F===7||F===9)E=!0}if(E){var R;if((R=G)!=null&&R.frame&&!G.key)N.pushAccessUnit(G,Y),G=N.VideoSample=null}if(!G)G=N.VideoSample=N.createVideoSample(!0,X.pts,X.dts);G.frame=!0,G.key=E;break}case 5:if(K=!0,(U=G)!=null&&U.frame&&!G.key)N.pushAccessUnit(G,Y),G=N.VideoSample=null;if(!G)G=N.VideoSample=N.createVideoSample(!0,X.pts,X.dts);G.key=!0,G.frame=!0;break;case 6:{K=!0,n7(V.data,1,X.pts,J.samples);break}case 7:{var O,M;K=!0,j=!0;var L=V.data,I=N.readSPS(L);if(!Y.sps||Y.width!==I.width||Y.height!==I.height||((O=Y.pixelRatio)==null?void 0:O[0])!==I.pixelRatio[0]||((M=Y.pixelRatio)==null?void 0:M[1])!==I.pixelRatio[1]){Y.width=I.width,Y.height=I.height,Y.pixelRatio=I.pixelRatio,Y.sps=[L];var w=L.subarray(1,4),S="avc1.";for(var P=0;P<3;P++){var b=w[P].toString(16);if(b.length<2)b="0"+b;S+=b}Y.codec=S}break}case 8:K=!0,Y.pps=[V.data];break;case 9:if(K=!0,Y.audFound=!0,(A=G)!=null&&A.frame)N.pushAccessUnit(G,Y),G=null;if(!G)G=N.VideoSample=N.createVideoSample(!1,X.pts,X.dts);break;case 12:K=!0;break;default:K=!1;break}if(G&&K){var C=G.units;C.push(V)}}),z&&G)this.pushAccessUnit(G,Y),this.VideoSample=null},Z.getNALuType=function Q(Y,J){return Y[J]&31},Z.readSliceType=function Q(Y){var J=new aQ(Y);return J.readUByte(),J.readUEG(),J.readUEG()},Z.skipScalingList=function Q(Y,J){var X=8,z=8,N;for(var W=0;W<Y;W++){if(z!==0)N=J.readEG(),z=(X+N+256)%256;X=z===0?X:z}},Z.readSPS=function Q(Y){var J=new aQ(Y),X=0,z=0,N=0,W=0,G,K,j,V=J.readUByte.bind(J),U=J.readBits.bind(J),A=J.readUEG.bind(J),E=J.readBoolean.bind(J),B=J.skipBits.bind(J),F=J.skipEG.bind(J),R=J.skipUEG.bind(J),O=this.skipScalingList.bind(this);V();var M=V();if(U(5),B(3),V(),R(),M===100||M===110||M===122||M===244||M===44||M===83||M===86||M===118||M===128){var L=A();if(L===3)B(1);if(R(),R(),B(1),E()){K=L!==3?8:12;for(j=0;j<K;j++)if(E())if(j<6)O(16,J);else O(64,J)}}R();var I=A();if(I===0)A();else if(I===1){B(1),F(),F(),G=A();for(j=0;j<G;j++)F()}R(),B(1);var w=A(),S=A(),P=U(1);if(P===0)B(1);if(B(1),E())X=A(),z=A(),N=A(),W=A();var b=[1,1];if(E()){if(E()){var C=V();switch(C){case 1:b=[1,1];break;case 2:b=[12,11];break;case 3:b=[10,11];break;case 4:b=[16,11];break;case 5:b=[40,33];break;case 6:b=[24,11];break;case 7:b=[20,11];break;case 8:b=[32,11];break;case 9:b=[80,33];break;case 10:b=[18,11];break;case 11:b=[15,11];break;case 12:b=[64,33];break;case 13:b=[160,99];break;case 14:b=[4,3];break;case 15:b=[3,2];break;case 16:b=[2,1];break;case 255:{b=[V()<<8|V(),V()<<8|V()];break}}}}return{width:Math.ceil((w+1)*16-X*2-z*2),height:(2-P)*(S+1)*16-(P?2:4)*(N+W),pixelRatio:b}},H}(cZ),j0=188,fZ=function(){function q(Z,Q,Y,J){this.logger=void 0,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._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=Z,this.config=Q,this.typeSupported=Y,this.logger=J,this.videoParser=null}q.probe=function Z(Q,Y){var J=q.syncOffset(Q);if(J>0)Y.warn("MPEG2-TS detected but first sync word found @ offset "+J);return J!==-1},q.syncOffset=function Z(Q){var Y=Q.length,J=Math.min(j0*5,Y-j0)+1,X=0;while(X<J){var z=!1,N=-1,W=0;for(var G=X;G<Y;G+=j0)if(Q[G]===71&&(Y-G===j0||Q[G+j0]===71)){if(W++,N===-1){if(N=G,N!==0)J=Math.min(N+j0*99,Q.length-j0)+1}if(!z)z=G7(Q,G)===0;if(z&&W>1&&(N===0&&W>2||G+j0>J))return N}else if(W)return-1;else break;X++}return-1},q.createTrack=function Z(Q,Y){return{container:Q==="video"||Q==="audio"?"video/mp2t":void 0,type:Q,id:p7[Q],pid:-1,inputTimeScale:90000,sequenceNumber:0,samples:[],dropped:0,duration:Q==="audio"?Y:void 0}};var H=q.prototype;return H.resetInitSegment=function Z(Q,Y,J,X){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=q.createTrack("video"),this._videoTrack.duration=X,this._audioTrack=q.createTrack("audio",X),this._id3Track=q.createTrack("id3"),this._txtTrack=q.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=Y,this.videoCodec=J},H.resetTimeStamp=function Z(){},H.resetContiguity=function Z(){var Q=this._audioTrack,Y=this._videoTrack,J=this._id3Track;if(Q)Q.pesData=null;if(Y)Y.pesData=null;if(J)J.pesData=null;this.aacOverFlow=null,this.remainderData=null},H.demux=function Z(Q,Y,J,X){if(J===void 0)J=!1;if(X===void 0)X=!1;if(!J)this.sampleAes=null;var z,N=this._videoTrack,W=this._audioTrack,G=this._id3Track,K=this._txtTrack,j=N.pid,V=N.pesData,U=W.pid,A=G.pid,E=W.pesData,B=G.pesData,F=null,R=this.pmtParsed,O=this._pmtId,M=Q.length;if(this.remainderData)Q=D0(this.remainderData,Q),M=Q.length,this.remainderData=null;if(M<j0&&!X)return this.remainderData=Q,{audioTrack:W,videoTrack:N,id3Track:G,textTrack:K};var L=Math.max(0,q.syncOffset(Q));if(M-=(M-L)%j0,M<Q.byteLength&&!X)this.remainderData=new Uint8Array(Q.buffer,M,Q.buffer.byteLength-M);var I=0;for(var w=L;w<M;w+=j0)if(Q[w]===71){var S=!!(Q[w+1]&64),P=G7(Q,w),b=(Q[w+3]&48)>>4,C=void 0;if(b>1){if(C=w+5+Q[w+4],C===w+j0)continue}else C=w+4;switch(P){case j:if(S){if(V&&(z=a0(V,this.logger))){if(this.videoParser===null)switch(N.segmentCodec){case"avc":this.videoParser=new tQ;break}if(this.videoParser!==null)this.videoParser.parsePES(N,K,z,!1)}V={data:[],size:0}}if(V)V.data.push(Q.subarray(C,w+j0)),V.size+=w+j0-C;break;case U:if(S){if(E&&(z=a0(E,this.logger)))switch(W.segmentCodec){case"aac":this.parseAACPES(W,z);break;case"mp3":this.parseMPEGPES(W,z);break}E={data:[],size:0}}if(E)E.data.push(Q.subarray(C,w+j0)),E.size+=w+j0-C;break;case A:if(S){if(B&&(z=a0(B,this.logger)))this.parseID3PES(G,z);B={data:[],size:0}}if(B)B.data.push(Q.subarray(C,w+j0)),B.size+=w+j0-C;break;case 0:if(S)C+=Q[C]+1;O=this._pmtId=dZ(Q,C);break;case O:{if(S)C+=Q[C]+1;var x=lZ(Q,C,this.typeSupported,J,this.observer,this.logger);if(j=x.videoPid,j>0)N.pid=j,N.segmentCodec=x.segmentVideoCodec;if(U=x.audioPid,U>0)W.pid=U,W.segmentCodec=x.segmentAudioCodec;if(A=x.id3Pid,A>0)G.pid=A;if(F!==null&&!R)this.logger.warn("MPEG-TS PMT found at "+w+" after unknown PID '"+F+"'. Backtracking to sync byte @"+L+" to parse all TS packets."),F=null,w=L-188;R=this.pmtParsed=!0;break}case 17:case 8191:break;default:F=P;break}}else I++;if(I>0)DY(this.observer,new Error("Found "+I+" TS packet/s that do not start with 0x47"),void 0,this.logger);N.pesData=V,W.pesData=E,G.pesData=B;var _={audioTrack:W,videoTrack:N,id3Track:G,textTrack:K};if(X)this.extractRemainingSamples(_);return _},H.flush=function Z(){var Q=this.remainderData;this.remainderData=null;var Y;if(Q)Y=this.demux(Q,-1,!1,!0);else Y={videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack};if(this.extractRemainingSamples(Y),this.sampleAes)return this.decrypt(Y,this.sampleAes);return Y},H.extractRemainingSamples=function Z(Q){var{audioTrack:Y,videoTrack:J,id3Track:X,textTrack:z}=Q,N=J.pesData,W=Y.pesData,G=X.pesData,K;if(N&&(K=a0(N,this.logger))){if(this.videoParser===null)switch(J.segmentCodec){case"avc":this.videoParser=new tQ;break}if(this.videoParser!==null)this.videoParser.parsePES(J,z,K,!0),J.pesData=null}else J.pesData=N;if(W&&(K=a0(W,this.logger))){switch(Y.segmentCodec){case"aac":this.parseAACPES(Y,K);break;case"mp3":this.parseMPEGPES(Y,K);break}Y.pesData=null}else{if(W!=null&&W.size)this.logger.log("last AAC PES packet truncated,might overlap between fragments");Y.pesData=W}if(G&&(K=a0(G,this.logger)))this.parseID3PES(X,K),X.pesData=null;else X.pesData=G},H.demuxSampleAes=function Z(Q,Y,J){var X=this.demux(Q,J,!0,!this.config.progressive),z=this.sampleAes=new uZ(this.observer,this.config,Y);return this.decrypt(X,z)},H.decrypt=function Z(Q,Y){return new Promise(function(J){var{audioTrack:X,videoTrack:z}=Q;if(X.samples&&X.segmentCodec==="aac")Y.decryptAacSamples(X.samples,0,function(){if(z.samples)Y.decryptAvcSamples(z.samples,0,0,function(){J(Q)});else J(Q)});else if(z.samples)Y.decryptAvcSamples(z.samples,0,0,function(){J(Q)})})},H.destroy=function Z(){if(this.observer)this.observer.removeAllListeners();this.config=this.logger=this.observer=null,this.aacOverFlow=this.videoParser=this.remainderData=this.sampleAes=null,this._videoTrack=this._audioTrack=this._id3Track=this._txtTrack=void 0},H.parseAACPES=function Z(Q,Y){var J=0,X=this.aacOverFlow,z=Y.data;if(X){this.aacOverFlow=null;var N=X.missing,W=X.sample.unit.byteLength;if(N===-1)z=D0(X.sample.unit,z);else{var G=W-N;X.sample.unit.set(z.subarray(0,N),G),Q.samples.push(X.sample),J=X.missing}}var K,j;for(K=J,j=z.length;K<j-1;K++)if(bY(z,K))break;if(K!==J){var V,U=K<j-1;if(U)V="AAC PES did not start with ADTS header,offset:"+K;else V="No ADTS header found in AAC PES";if(DY(this.observer,new Error(V),U,this.logger),!U)return}mQ(Q,this.observer,z,K,this.audioCodec);var A;if(Y.pts!==void 0)A=Y.pts;else if(X){var E=pQ(Q.samplerate);A=X.sample.pts+E}else{this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}var B=0,F;while(K<j)if(F=uQ(Q,z,K,A,B),K+=F.length,!F.missing){B++;for(;K<j-1;K++)if(bY(z,K))break}else{this.aacOverFlow=F;break}},H.parseMPEGPES=function Z(Q,Y){var J=Y.data,X=J.length,z=0,N=0,W=Y.pts;if(W===void 0){this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}while(N<X)if(sQ(J,N)){var G=nQ(Q,J,N,W,z);if(G)N+=G.length,z++;else break}else N++},H.parseAC3PES=function Z(Q,Y){},H.parseID3PES=function Z(Q,Y){if(Y.pts===void 0){this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}var J=W0({},Y,{type:this._videoTrack?L0.emsg:L0.audioId3,duration:Number.POSITIVE_INFINITY});Q.samples.push(J)},q}();function G7(q,H){return((q[H+1]&31)<<8)+q[H+2]}function dZ(q,H){return(q[H+10]&31)<<8|q[H+11]}function lZ(q,H,Z,Q,Y,J){var X={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},z=(q[H+1]&15)<<8|q[H+2],N=H+3+z-4,W=(q[H+10]&15)<<8|q[H+11];H+=12+W;while(H<N){var G=G7(q,H),K=(q[H+3]&15)<<8|q[H+4];switch(q[H]){case 207:if(!Q){K7("ADTS AAC",J);break}case 15:if(X.audioPid===-1)X.audioPid=G;break;case 21:if(X.id3Pid===-1)X.id3Pid=G;break;case 219:if(!Q){K7("H.264",J);break}case 27:if(X.videoPid===-1)X.videoPid=G;break;case 3:case 4:if(!Z.mpeg&&!Z.mp3)J.log("MPEG audio found, not supported in this browser");else if(X.audioPid===-1)X.audioPid=G,X.segmentAudioCodec="mp3";break;case 193:if(!Q){K7("AC-3",J);break}case 129:J.warn("AC-3 in M2TS support not included in build");break;case 6:if(X.audioPid===-1&&K>0){var j=H+5,V=K;while(V>2){var U=q[j];switch(U){case 106:J.warn("AC-3 in M2TS support not included in build");break}var A=q[j+1]+2;j+=A,V-=A}}break;case 194:case 135:return DY(Y,new Error("Unsupported EC-3 in M2TS found"),void 0,J),X;case 36:return DY(Y,new Error("Unsupported HEVC in M2TS found"),void 0,J),X}H+=K+5}return X}function DY(q,H,Z,Q){Q.warn("parsing error: "+H.message),q.emit($.ERROR,$.ERROR,{type:f.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,levelRetry:Z,error:H,reason:H.message})}function K7(q,H){H.log(q+" with AES-128-CBC encryption found in unencrypted stream")}function a0(q,H){var Z=0,Q,Y,J,X,z,N=q.data;if(!q||q.size===0)return null;while(N[0].length<19&&N.length>1)N[0]=D0(N[0],N[1]),N.splice(1,1);Q=N[0];var W=(Q[0]<<16)+(Q[1]<<8)+Q[2];if(W===1){if(Y=(Q[4]<<8)+Q[5],Y&&Y>q.size-6)return null;var G=Q[7];if(G&192)if(X=(Q[9]&14)*536870912+(Q[10]&255)*4194304+(Q[11]&254)*16384+(Q[12]&255)*128+(Q[13]&254)/2,G&64){if(z=(Q[14]&14)*536870912+(Q[15]&255)*4194304+(Q[16]&254)*16384+(Q[17]&255)*128+(Q[18]&254)/2,X-z>5400000)H.warn(Math.round((X-z)/90000)+"s delta between PTS and DTS, align them"),X=z}else z=X;J=Q[8];var K=J+9;if(q.size<=K)return null;q.size-=K;var j=new Uint8Array(q.size);for(var V=0,U=N.length;V<U;V++){Q=N[V];var A=Q.byteLength;if(K)if(K>A){K-=A;continue}else Q=Q.subarray(K),A-=K,K=0;j.set(Q,Z),Z+=A}if(Y)Y-=J+3;return{data:j,pts:X,dts:z,len:Y}}return null}var nZ=function(){function q(){}return q.getSilentFrame=function H(Z,Q){switch(Z){case"mp4a.40.2":if(Q===1)return new Uint8Array([0,200,0,128,35,128]);else if(Q===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);else if(Q===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);else if(Q===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);else if(Q===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);else if(Q===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(Q===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);else if(Q===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);else if(Q===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}return},q}(),n0=Math.pow(2,32)-1,V0=function(){function q(){}return q.init=function H(){q.types={avc1:[],avcC:[],hvc1:[],hvcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var Z;for(Z in q.types)if(q.types.hasOwnProperty(Z))q.types[Z]=[Z.charCodeAt(0),Z.charCodeAt(1),Z.charCodeAt(2),Z.charCodeAt(3)];var Q=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]),Y=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);q.HDLR_TYPES={video:Q,audio:Y};var J=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),X=new Uint8Array([0,0,0,0,0,0,0,0]);q.STTS=q.STSC=q.STCO=X,q.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),q.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),q.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),q.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var z=new Uint8Array([105,115,111,109]),N=new Uint8Array([97,118,99,49]),W=new Uint8Array([0,0,0,1]);q.FTYP=q.box(q.types.ftyp,z,W,z,N),q.DINF=q.box(q.types.dinf,q.box(q.types.dref,J))},q.box=function H(Z){var Q=8;for(var Y=arguments.length,J=new Array(Y>1?Y-1:0),X=1;X<Y;X++)J[X-1]=arguments[X];var z=J.length,N=z;while(z--)Q+=J[z].byteLength;var W=new Uint8Array(Q);W[0]=Q>>24&255,W[1]=Q>>16&255,W[2]=Q>>8&255,W[3]=Q&255,W.set(Z,4);for(z=0,Q=8;z<N;z++)W.set(J[z],Q),Q+=J[z].byteLength;return W},q.hdlr=function H(Z){return q.box(q.types.hdlr,q.HDLR_TYPES[Z])},q.mdat=function H(Z){return q.box(q.types.mdat,Z)},q.mdhd=function H(Z,Q){Q*=Z;var Y=Math.floor(Q/(n0+1)),J=Math.floor(Q%(n0+1));return q.box(q.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,Z>>24&255,Z>>16&255,Z>>8&255,Z&255,Y>>24,Y>>16&255,Y>>8&255,Y&255,J>>24,J>>16&255,J>>8&255,J&255,85,196,0,0]))},q.mdia=function H(Z){return q.box(q.types.mdia,q.mdhd(Z.timescale||0,Z.duration||0),q.hdlr(Z.type),q.minf(Z))},q.mfhd=function H(Z){return q.box(q.types.mfhd,new Uint8Array([0,0,0,0,Z>>24,Z>>16&255,Z>>8&255,Z&255]))},q.minf=function H(Z){if(Z.type==="audio")return q.box(q.types.minf,q.box(q.types.smhd,q.SMHD),q.DINF,q.stbl(Z));else return q.box(q.types.minf,q.box(q.types.vmhd,q.VMHD),q.DINF,q.stbl(Z))},q.moof=function H(Z,Q,Y){return q.box(q.types.moof,q.mfhd(Z),q.traf(Y,Q))},q.moov=function H(Z){var Q=Z.length,Y=[];while(Q--)Y[Q]=q.trak(Z[Q]);return q.box.apply(null,[q.types.moov,q.mvhd(Z[0].timescale||0,Z[0].duration||0)].concat(Y).concat(q.mvex(Z)))},q.mvex=function H(Z){var Q=Z.length,Y=[];while(Q--)Y[Q]=q.trex(Z[Q]);return q.box.apply(null,[q.types.mvex].concat(Y))},q.mvhd=function H(Z,Q){Q*=Z;var Y=Math.floor(Q/(n0+1)),J=Math.floor(Q%(n0+1)),X=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,Z>>24&255,Z>>16&255,Z>>8&255,Z&255,Y>>24,Y>>16&255,Y>>8&255,Y&255,J>>24,J>>16&255,J>>8&255,J&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return q.box(q.types.mvhd,X)},q.sdtp=function H(Z){var Q=Z.samples||[],Y=new Uint8Array(4+Q.length),J,X;for(J=0;J<Q.length;J++)X=Q[J].flags,Y[J+4]=X.dependsOn<<4|X.isDependedOn<<2|X.hasRedundancy;return q.box(q.types.sdtp,Y)},q.stbl=function H(Z){return q.box(q.types.stbl,q.stsd(Z),q.box(q.types.stts,q.STTS),q.box(q.types.stsc,q.STSC),q.box(q.types.stsz,q.STSZ),q.box(q.types.stco,q.STCO))},q.avc1=function H(Z){var Q=[],Y=[],J,X,z;for(J=0;J<Z.sps.length;J++)X=Z.sps[J],z=X.byteLength,Q.push(z>>>8&255),Q.push(z&255),Q=Q.concat(Array.prototype.slice.call(X));for(J=0;J<Z.pps.length;J++)X=Z.pps[J],z=X.byteLength,Y.push(z>>>8&255),Y.push(z&255),Y=Y.concat(Array.prototype.slice.call(X));var N=q.box(q.types.avcC,new Uint8Array([1,Q[3],Q[4],Q[5],255,224|Z.sps.length].concat(Q).concat([Z.pps.length]).concat(Y))),W=Z.width,G=Z.height,K=Z.pixelRatio[0],j=Z.pixelRatio[1];return q.box(q.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,W>>8&255,W&255,G>>8&255,G&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),N,q.box(q.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),q.box(q.types.pasp,new Uint8Array([K>>24,K>>16&255,K>>8&255,K&255,j>>24,j>>16&255,j>>8&255,j&255])))},q.esds=function H(Z){var Q=Z.config;return new Uint8Array([0,0,0,0,3,25,0,1,0,4,17,64,21,0,0,0,0,0,0,0,0,0,0,0,5,2].concat(Q,[6,1,2]))},q.audioStsd=function H(Z){var Q=Z.samplerate||0;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,Z.channelCount||0,0,16,0,0,0,0,Q>>8&255,Q&255,0,0])},q.mp4a=function H(Z){return q.box(q.types.mp4a,q.audioStsd(Z),q.box(q.types.esds,q.esds(Z)))},q.mp3=function H(Z){return q.box(q.types[".mp3"],q.audioStsd(Z))},q.ac3=function H(Z){return q.box(q.types["ac-3"],q.audioStsd(Z),q.box(q.types.dac3,Z.config))},q.stsd=function H(Z){var Q=Z.segmentCodec;if(Z.type==="audio"){if(Q==="aac")return q.box(q.types.stsd,q.STSD,q.mp4a(Z));if(Q==="mp3"&&Z.codec==="mp3")return q.box(q.types.stsd,q.STSD,q.mp3(Z))}else if(Z.pps&&Z.sps){if(Q==="avc")return q.box(q.types.stsd,q.STSD,q.avc1(Z))}else throw new Error("video track missing pps or sps");throw new Error("unsupported "+Z.type+" segment codec ("+Q+"/"+Z.codec+")")},q.tkhd=function H(Z){var Q=Z.id,Y=(Z.duration||0)*(Z.timescale||0),J=Z.width||0,X=Z.height||0,z=Math.floor(Y/(n0+1)),N=Math.floor(Y%(n0+1));return q.box(q.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,Q>>24&255,Q>>16&255,Q>>8&255,Q&255,0,0,0,0,z>>24,z>>16&255,z>>8&255,z&255,N>>24,N>>16&255,N>>8&255,N&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,J>>8&255,J&255,0,0,X>>8&255,X&255,0,0]))},q.traf=function H(Z,Q){var Y=q.sdtp(Z),J=Z.id,X=Math.floor(Q/(n0+1)),z=Math.floor(Q%(n0+1));return q.box(q.types.traf,q.box(q.types.tfhd,new Uint8Array([0,0,0,0,J>>24,J>>16&255,J>>8&255,J&255])),q.box(q.types.tfdt,new Uint8Array([1,0,0,0,X>>24,X>>16&255,X>>8&255,X&255,z>>24,z>>16&255,z>>8&255,z&255])),q.trun(Z,Y.length+16+20+8+16+8+8),Y)},q.trak=function H(Z){return Z.duration=Z.duration||4294967295,q.box(q.types.trak,q.tkhd(Z),q.mdia(Z))},q.trex=function H(Z){var Q=Z.id;return q.box(q.types.trex,new Uint8Array([0,0,0,0,Q>>24,Q>>16&255,Q>>8&255,Q&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},q.trun=function H(Z,Q){var Y=Z.samples||[],J=Y.length,X=12+16*J,z=new Uint8Array(X),N,W,G,K,j,V;Q+=8+X,z.set([Z.type==="video"?1:0,0,15,1,J>>>24&255,J>>>16&255,J>>>8&255,J&255,Q>>>24&255,Q>>>16&255,Q>>>8&255,Q&255],0);for(N=0;N<J;N++)W=Y[N],G=W.duration,K=W.size,j=W.flags,V=W.cts,z.set([G>>>24&255,G>>>16&255,G>>>8&255,G&255,K>>>24&255,K>>>16&255,K>>>8&255,K&255,j.isLeading<<2|j.dependsOn,j.isDependedOn<<6|j.hasRedundancy<<4|j.paddingValue<<1|j.isNonSync,j.degradPrio&61440,j.degradPrio&15,V>>>24&255,V>>>16&255,V>>>8&255,V&255],12+16*N);return q.box(q.types.trun,z)},q.initSegment=function H(Z){if(!q.types)q.init();var Q=q.moov(Z),Y=D0(q.FTYP,Q);return Y},q.hvc1=function H(Z){return new Uint8Array},q}();V0.types=void 0,V0.HDLR_TYPES=void 0,V0.STTS=void 0,V0.STSC=void 0,V0.STCO=void 0,V0.STSZ=void 0,V0.VMHD=void 0,V0.SMHD=void 0,V0.STSD=void 0,V0.FTYP=void 0,V0.DINF=void 0;var oZ=90000;function sZ(q,H,Z,Q){var Y=q*H*Z;return Math.round(Y)}function NY(q,H){return sZ(q,1000,1/oZ)}var iZ=1e4,rZ=1024,aZ=1152,tZ=1536,t0=null,j7=null;function eQ(q,H,Z,Q){return{duration:H,size:Z,cts:Q,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:q?2:1,isNonSync:q?0:1}}}var U7=function(){function q(Z,Q,Y,J){if(this.logger=void 0,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=Z,this.config=Q,this.typeSupported=Y,this.logger=J,this.ISGenerated=!1,t0===null){var X=navigator.userAgent||"",z=X.match(/Chrome\/(\d+)/i);t0=z?parseInt(z[1]):0}if(j7===null){var N=navigator.userAgent.match(/Safari\/(\d+)/i);j7=N?parseInt(N[1]):0}}var H=q.prototype;return H.destroy=function Z(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null},H.resetTimeStamp=function Z(Q){this.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=Q},H.resetNextTimestamp=function Z(){this.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},H.resetInitSegment=function Z(){this.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0},H.getVideoStartPts=function Z(Q){var Y=!1,J=Q[0].pts,X=Q.reduce(function(z,N){var W=N.pts,G=W-z;if(G<-4294967296)Y=!0,W=x0(W,J),G=W-z;if(G>0)return z;return W},J);if(Y)this.logger.debug("PTS rollover detected");return X},H.remux=function Z(Q,Y,J,X,z,N,W,G){var K,j,V,U,A,E,B=z,F=z,R=Q.pid>-1,O=Y.pid>-1,M=Y.samples.length,L=Q.samples.length>0,I=W&&M>0||M>1,w=(!R||L)&&(!O||I)||this.ISGenerated||W;if(w){if(this.ISGenerated){var S,P,b,C,x=this.videoTrackConfig;if(x&&(Y.width!==x.width||Y.height!==x.height||((S=Y.pixelRatio)==null?void 0:S[0])!==((P=x.pixelRatio)==null?void 0:P[0])||((b=Y.pixelRatio)==null?void 0:b[1])!==((C=x.pixelRatio)==null?void 0:C[1]))||!x&&I||this.nextAudioPts===null&&L)this.resetInitSegment()}if(!this.ISGenerated)V=this.generateIS(Q,Y,z,N);var _=this.isVideoContiguous,y=-1,T;if(I){if(y=eZ(Y.samples),!_&&this.config.forceKeyFrameOnDiscontinuity){if(E=!0,y>0){this.logger.warn("[mp4-remuxer]: Dropped "+y+" out of "+M+" video samples due to a missing keyframe");var h=this.getVideoStartPts(Y.samples);Y.samples=Y.samples.slice(y),Y.dropped+=y,F+=(Y.samples[0].pts-h)/Y.inputTimeScale,T=F}else if(y===-1)this.logger.warn("[mp4-remuxer]: No keyframe found out of "+M+" video samples"),E=!1}}if(this.ISGenerated){if(L&&I){var g=this.getVideoStartPts(Y.samples),m=x0(Q.samples[0].pts,g)-g,p=m/Y.inputTimeScale;B+=Math.max(0,p),F+=Math.max(0,-p)}if(L){if(!Q.samplerate)this.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),V=this.generateIS(Q,Y,z,N);if(j=this.remuxAudio(Q,B,this.isAudioContiguous,N,O||I||G===d.AUDIO?F:void 0),I){var r=j?j.endPTS-j.startPTS:0;if(!Y.inputTimeScale)this.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),V=this.generateIS(Q,Y,z,N);K=this.remuxVideo(Y,F,_,r)}}else if(I)K=this.remuxVideo(Y,F,_,0);if(K)K.firstKeyFrame=y,K.independent=y!==-1,K.firstKeyFramePTS=T}}if(this.ISGenerated&&this._initPTS&&this._initDTS){if(J.samples.length)A=YJ(J,z,this._initPTS,this._initDTS);if(X.samples.length)U=QJ(X,z,this._initPTS)}return{audio:j,video:K,initSegment:V,independent:E,text:U,id3:A}},H.generateIS=function Z(Q,Y,J,X){var z=Q.samples,N=Y.samples,W=this.typeSupported,G={},K=this._initPTS,j=!K||X,V="audio/mp4",U,A,E;if(j)U=A=1/0;if(Q.config&&z.length){switch(Q.timescale=Q.samplerate,Q.segmentCodec){case"mp3":if(W.mpeg)V="audio/mpeg",Q.codec="";else if(W.mp3)Q.codec="mp3";break;case"ac3":Q.codec="ac-3";break}if(G.audio={id:"audio",container:V,codec:Q.codec,initSegment:Q.segmentCodec==="mp3"&&W.mpeg?new Uint8Array(0):V0.initSegment([Q]),metadata:{channelCount:Q.channelCount}},j)if(E=Q.inputTimeScale,!K||E!==K.timescale)U=A=z[0].pts-Math.round(E*J);else j=!1}if(Y.sps&&Y.pps&&N.length){if(Y.timescale=Y.inputTimeScale,G.video={id:"main",container:"video/mp4",codec:Y.codec,initSegment:V0.initSegment([Y]),metadata:{width:Y.width,height:Y.height}},j)if(E=Y.inputTimeScale,!K||E!==K.timescale){var B=this.getVideoStartPts(N),F=Math.round(E*J);A=Math.min(A,x0(N[0].dts,B)-F),U=Math.min(U,B-F)}else j=!1;this.videoTrackConfig={width:Y.width,height:Y.height,pixelRatio:Y.pixelRatio}}if(Object.keys(G).length){if(this.ISGenerated=!0,j)this._initPTS={baseTime:U,timescale:E},this._initDTS={baseTime:A,timescale:E};else U=E=void 0;return{tracks:G,initPTS:U,timescale:E}}},H.remuxVideo=function Z(Q,Y,J,X){var{inputTimeScale:z,samples:N}=Q,W=[],G=N.length,K=this._initPTS,j=this.nextAvcDts,V=8,U=this.videoSampleDuration,A,E,B=Number.POSITIVE_INFINITY,F=Number.NEGATIVE_INFINITY,R=!1;if(!J||j===null){var O=Y*z,M=N[0].pts-x0(N[0].dts,N[0].pts);if(t0&&j!==null&&Math.abs(O-M-j)<15000)J=!0;else j=O-M}var L=K.baseTime*z/K.timescale;for(var I=0;I<G;I++){var w=N[I];if(w.pts=x0(w.pts-L,j),w.dts=x0(w.dts-L,j),w.dts<N[I>0?I-1:I].dts)R=!0}if(R)N.sort(function(hY,TJ){var Vq=hY.dts-TJ.dts,Aq=hY.pts-TJ.pts;return Vq||Aq});A=N[0].dts,E=N[N.length-1].dts;var S=E-A,P=S?Math.round(S/(G-1)):U||Q.inputTimeScale/30;if(J){var b=A-j,C=b>P,x=b<-1;if(C||x){if(C)this.logger.warn((Q.segmentCodec||"").toUpperCase()+": "+NY(b)+" ms ("+b+"dts) hole between fragments detected at "+Y.toFixed(3));else this.logger.warn((Q.segmentCodec||"").toUpperCase()+": "+NY(-b)+" ms ("+b+"dts) overlapping between fragments detected at "+Y.toFixed(3));if(!x||j>=N[0].pts||t0){A=j;var _=N[0].pts-b;if(C)N[0].dts=A,N[0].pts=_;else{var y=!0;for(var T=0;T<N.length;T++){if(N[T].dts>_&&y)break;var h=N[T].pts;if(N[T].dts-=b,N[T].pts-=b,T<N.length-1){var g=N[T+1].pts,m=N[T].pts,p=g<=m,r=g<=h;y=p==r}}}this.logger.log("Video: Initial PTS/DTS adjusted: "+NY(_)+"/"+NY(A)+", delta: "+NY(b)+" ms")}}}A=Math.max(0,A);var n=0,a=0,l=A;for(var X0=0;X0<G;X0++){var t=N[X0],q0=t.units,R0=q0.length,U0=0;for(var e=0;e<R0;e++)U0+=q0[e].data.length;if(a+=U0,n+=R0,t.length=U0,t.dts<l)t.dts=l,l+=P/4|0||1;else l=t.dts;B=Math.min(t.pts,B),F=Math.max(t.pts,F)}E=N[G-1].dts;var M0=a+4*n+8,z0;try{z0=new Uint8Array(M0)}catch(hY){this.observer.emit($.ERROR,$.ERROR,{type:f.MUX_ERROR,details:D.REMUX_ALLOC_ERROR,fatal:!1,error:hY,bytes:M0,reason:"fail allocating video mdat "+M0});return}var J0=new DataView(z0.buffer);J0.setUint32(0,M0),z0.set(V0.types.mdat,4);var I0=!1,E0=Number.POSITIVE_INFINITY,b0=Number.POSITIVE_INFINITY,Y0=Number.NEGATIVE_INFINITY,B0=Number.NEGATIVE_INFINITY;for(var N0=0;N0<G;N0++){var w0=N[N0],jY=w0.units,bJ=0;for(var M7=0,Xq=jY.length;M7<Xq;M7++){var CJ=jY[M7],Hq=CJ.data,I7=CJ.data.byteLength;J0.setUint32(V,I7),V+=4,z0.set(Hq,V),V+=I7,bJ+=4+I7}var kY=void 0;if(N0<G-1)U=N[N0+1].dts-w0.dts,kY=N[N0+1].pts-w0.pts;else{var PJ=this.config,_Y=N0>0?w0.dts-N[N0-1].dts:P;if(kY=N0>0?w0.pts-N[N0-1].pts:P,PJ.stretchShortVideoTrack&&this.nextAudioPts!==null){var zq=Math.floor(PJ.maxBufferHole*z),w7=(X?B+X*z:this.nextAudioPts)-w0.pts;if(w7>zq){if(U=w7-_Y,U<0)U=_Y;else I0=!0;this.logger.log("[mp4-remuxer]: It is approximately "+w7/90+" ms to the next segment; using duration "+U/90+" ms for the last video frame.")}else U=_Y}else U=_Y}var Nq=Math.round(w0.pts-w0.dts);E0=Math.min(E0,U),Y0=Math.max(Y0,U),b0=Math.min(b0,kY),B0=Math.max(B0,kY),W.push(eQ(w0.key,U,bJ,Nq))}if(W.length){if(t0){if(t0<70){var DJ=W[0].flags;DJ.dependsOn=2,DJ.isNonSync=0}}else if(j7){if(B0-b0<Y0-E0&&P/Y0<0.025&&W[0].cts===0){this.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");var L7=A;for(var T0=0,SJ=W.length;T0<SJ;T0++){var xJ=L7+W[T0].duration,Wq=L7+W[T0].cts;if(T0<SJ-1){var Gq=xJ+W[T0+1].cts;W[T0].duration=Gq-Wq}else W[T0].duration=T0?W[T0-1].duration:P;W[T0].cts=0,L7=xJ}}}}U=I0||!U?P:U,this.nextAvcDts=j=E+U,this.videoSampleDuration=U,this.isVideoContiguous=!0;var Kq=V0.moof(Q.sequenceNumber++,A,W0(Q,{samples:W})),jq="video",Uq={data1:Kq,data2:z0,startPTS:B/z,endPTS:(F+U)/z,startDTS:A/z,endDTS:j/z,type:jq,hasAudio:!1,hasVideo:!0,nb:W.length,dropped:Q.dropped};return Q.samples=[],Q.dropped=0,Uq},H.getSamplesPerFrame=function Z(Q){switch(Q.segmentCodec){case"mp3":return aZ;case"ac3":return tZ;default:return rZ}},H.remuxAudio=function Z(Q,Y,J,X,z){var N=Q.inputTimeScale,W=Q.samplerate?Q.samplerate:N,G=N/W,K=this.getSamplesPerFrame(Q),j=K*G,V=this._initPTS,U=Q.segmentCodec==="mp3"&&this.typeSupported.mpeg,A=[],E=z!==void 0,B=Q.samples,F=U?0:8,R=this.nextAudioPts||-1,O=Y*N,M=V.baseTime*N/V.timescale;if(this.isAudioContiguous=J=J||B.length&&R>0&&(X&&Math.abs(O-R)<9000||Math.abs(x0(B[0].pts-M,O)-R)<20*j),B.forEach(function(Y0){Y0.pts=x0(Y0.pts-M,O)}),!J||R<0){if(B=B.filter(function(Y0){return Y0.pts>=0}),!B.length)return;if(z===0)R=0;else if(X&&!E)R=Math.max(0,O);else R=B[0].pts}if(Q.segmentCodec==="aac"){var L=this.config.maxAudioFramesDrift;for(var I=0,w=R;I<B.length;I++){var S=B[I],P=S.pts,b=P-w,C=Math.abs(1000*b/N);if(b<=-L*j&&E){if(I===0)this.logger.warn("Audio frame @ "+(P/N).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1000*b/N)+" ms."),this.nextAudioPts=R=w=P}else if(b>=L*j&&C<iZ&&E){var x=Math.round(b/j);if(w=P-x*j,w<0)x--,w+=j;if(I===0)this.nextAudioPts=R=w;this.logger.warn("[mp4-remuxer]: Injecting "+x+" audio frame @ "+(w/N).toFixed(3)+"s due to "+Math.round(1000*b/N)+" ms gap.");for(var _=0;_<x;_++){var y=Math.max(w,0),T=nZ.getSilentFrame(Q.parsedCodec||Q.manifestCodec||Q.codec,Q.channelCount);if(!T)this.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),T=S.unit.subarray();B.splice(I,0,{unit:T,pts:y}),w+=j,I++}}S.pts=w,w+=j}}var h=null,g=null,m,p=0,r=B.length;while(r--)p+=B[r].unit.byteLength;for(var n=0,a=B.length;n<a;n++){var l=B[n],X0=l.unit,t=l.pts;if(g!==null){var q0=A[n-1];q0.duration=Math.round((t-g)/G)}else{if(J&&Q.segmentCodec==="aac")t=R;if(h=t,p>0){p+=F;try{m=new Uint8Array(p)}catch(Y0){this.observer.emit($.ERROR,$.ERROR,{type:f.MUX_ERROR,details:D.REMUX_ALLOC_ERROR,fatal:!1,error:Y0,bytes:p,reason:"fail allocating audio mdat "+p});return}if(!U){var R0=new DataView(m.buffer);R0.setUint32(0,p),m.set(V0.types.mdat,4)}}else return}m.set(X0,F);var U0=X0.byteLength;F+=U0,A.push(eQ(!0,K,U0,0)),g=t}var e=A.length;if(!e)return;var M0=A[A.length-1];this.nextAudioPts=R=g+G*M0.duration;var z0=U?new Uint8Array(0):V0.moof(Q.sequenceNumber++,h/G,W0({},Q,{samples:A}));Q.samples=[];var J0=h/N,I0=R/N,E0="audio",b0={data1:z0,data2:m,startPTS:J0,endPTS:I0,startDTS:J0,endDTS:I0,type:E0,hasAudio:!0,hasVideo:!1,nb:e};return this.isAudioContiguous=!0,b0},q}();function x0(q,H){var Z;if(H===null)return q;if(H<q)Z=-8589934592;else Z=8589934592;while(Math.abs(q-H)>4294967296)q+=Z;return q}function eZ(q){for(var H=0;H<q.length;H++)if(q[H].key)return H;return-1}function YJ(q,H,Z,Q){var Y=q.samples.length;if(!Y)return;var J=q.inputTimeScale;for(var X=0;X<Y;X++){var z=q.samples[X];z.pts=x0(z.pts-Z.baseTime*J/Z.timescale,H*J)/J,z.dts=x0(z.dts-Q.baseTime*J/Q.timescale,H*J)/J}var N=q.samples;return q.samples=[],{samples:N}}function QJ(q,H,Z){var Q=q.samples.length;if(!Q)return;var Y=q.inputTimeScale;for(var J=0;J<Q;J++){var X=q.samples[J];X.pts=x0(X.pts-Z.baseTime*Y/Z.timescale,H*Y)/Y}q.samples.sort(function(N,W){return N.pts-W.pts});var z=q.samples;return q.samples=[],{samples:z}}var Y9=function(){function q(Z,Q,Y,J){this.logger=void 0,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,this.logger=J}var H=q.prototype;return H.destroy=function Z(){},H.resetTimeStamp=function Z(Q){this.initPTS=Q,this.lastEndTime=null},H.resetNextTimestamp=function Z(){this.lastEndTime=null},H.resetInitSegment=function Z(Q,Y,J,X){this.audioCodec=Y,this.videoCodec=J,this.generateInitSegment(J8(Q,X)),this.emitInitSegment=!0},H.generateInitSegment=function Z(Q){var Y=this.audioCodec,J=this.videoCodec;if(!(Q!=null&&Q.byteLength)){this.initTracks=void 0,this.initData=void 0;return}var X=this.initData=d7(Q);if(X.audio)Y=JJ(X.audio,Q0.AUDIO);if(X.video)J=JJ(X.video,Q0.VIDEO);var z={};if(X.audio&&X.video)z.audiovideo={container:"video/mp4",codec:Y+","+J,supplemental:X.video.supplemental,initSegment:Q,id:"main"};else if(X.audio)z.audio={container:"audio/mp4",codec:Y,initSegment:Q,id:"audio"};else if(X.video)z.video={container:"video/mp4",codec:J,supplemental:X.video.supplemental,initSegment:Q,id:"main"};else this.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes.");this.initTracks=z},H.remux=function Z(Q,Y,J,X,z,N){var W,G,K=this.initPTS,j=this.lastEndTime,V={audio:void 0,video:void 0,text:X,id3:J,initSegment:void 0};if(!v(j))j=this.lastEndTime=z||0;var U=Y.samples;if(!(U!=null&&U.length))return V;var A={initPTS:void 0,timescale:1},E=this.initData;if(!((W=E)!=null&&W.length))this.generateInitSegment(U),E=this.initData;if(!((G=E)!=null&&G.length))return this.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),V;if(this.emitInitSegment)A.tracks=this.initTracks,this.emitInitSegment=!1;var B=X8(U,E),F=q8(E,U),R=F===null?z:F;if((N||!K)&&(Q9(K,R,z,B)||A.timescale!==K.timescale)){if(A.initPTS=R-z,K&&K.timescale===1)this.logger.warn("Adjusting initPTS @"+z+" from "+K.baseTime/K.timescale+" to "+A.initPTS);this.initPTS=K={baseTime:A.initPTS,timescale:1}}var O=Q?R-K.baseTime/K.timescale:j,M=O+B;if(z8(E,U,K.baseTime/K.timescale),B>0)this.lastEndTime=M;else this.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp();var L=!!E.audio,I=!!E.video,w="";if(L)w+="audio";if(I)w+="video";var S={data1:U,startPTS:O,startDTS:O,endPTS:M,endDTS:M,type:w,hasAudio:L,hasVideo:I,nb:1,dropped:0};if(V.audio=S.type==="audio"?S:void 0,V.video=S.type!=="audio"?S:void 0,V.initSegment=A,V.id3=YJ(J,z,K,K),X.samples.length)V.text=QJ(X,z,K);return V},q}();function Q9(q,H,Z,Q){if(q===null)return!0;var Y=Math.max(Q,1),J=H-q.baseTime/q.timescale;return Math.abs(J-Z)>Y}function JJ(q,H){var Z=q==null?void 0:q.codec;if(Z&&Z.length>4)return Z;if(H===Q0.AUDIO){if(Z==="ec-3"||Z==="ac-3"||Z==="alac")return Z;if(Z==="fLaC"||Z==="Opus"){var Q=!1;return BY(Z,Q)}return s.warn('Unhandled audio codec "'+Z+'" in mp4 MAP'),Z||"mp4a"}return s.warn('Unhandled video codec "'+Z+'" in mp4 MAP'),Z||"avc1"}var u0;try{u0=self.performance.now.bind(self.performance)}catch(q){u0=Date.now}var V7=[{demux:pZ,remux:Y9},{demux:fZ,remux:U7},{demux:SZ,remux:U7},{demux:TZ,remux:U7}],A7=function(){function q(Z,Q,Y,J,X,z){this.asyncResult=!1,this.logger=void 0,this.observer=void 0,this.typeSupported=void 0,this.config=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=Z,this.typeSupported=Q,this.config=Y,this.id=X,this.logger=z}var H=q.prototype;return H.configure=function Z(Q){if(this.transmuxConfig=Q,this.decrypter)this.decrypter.reset()},H.push=function Z(Q,Y,J,X){var z=this,N=J.transmuxing;N.executeStart=u0();var W=new Uint8Array(Q),G=this.currentTransmuxState,K=this.transmuxConfig;if(X)this.currentTransmuxState=X;var j=X||G,V=j.contiguous,U=j.discontinuity,A=j.trackSwitch,E=j.accurateTimeOffset,B=j.timeOffset,F=j.initSegmentChange,R=K.audioCodec,O=K.videoCodec,M=K.defaultInitPts,L=K.duration,I=K.initSegmentData,w=J9(W,Y);if(w&&HY(w.method)){var S=this.getDecrypter(),P=EQ(w.method);if(S.isSync()){var b=S.softwareDecrypt(W,w.key.buffer,w.iv.buffer,P),C=J.part>-1;if(C){var x=S.flush();b=x?x.buffer:x}if(!b)return N.executeEnd=u0(),E7(J);W=new Uint8Array(b)}else return this.asyncResult=!0,this.decryptionPromise=S.webCryptoDecrypt(W,w.key.buffer,w.iv.buffer,P).then(function(g){var m=z.push(g,null,J);return z.decryptionPromise=null,m}),this.decryptionPromise}var _=this.needsProbing(U,A);if(_){var y=this.configureTransmuxer(W);if(y)return this.logger.warn("[transmuxer] "+y.message),this.observer.emit($.ERROR,$.ERROR,{type:f.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,error:y,reason:y.message}),N.executeEnd=u0(),E7(J)}if(U||A||F||_)this.resetInitSegment(I,R,O,L,Y);if(U||F||_)this.resetInitialTimestamp(M);if(!V)this.resetContiguity();var T=this.transmux(W,w,B,E,J);this.asyncResult=o0(T);var h=this.currentTransmuxState;return h.contiguous=!0,h.discontinuity=!1,h.trackSwitch=!1,N.executeEnd=u0(),T},H.flush=function Z(Q){var Y=this,J=Q.transmuxing;J.executeStart=u0();var X=this.decrypter,z=this.currentTransmuxState,N=this.decryptionPromise;if(N)return this.asyncResult=!0,N.then(function(){return Y.flush(Q)});var W=[],G=z.timeOffset;if(X){var K=X.flush();if(K)W.push(this.push(K.buffer,null,Q))}var j=this.demuxer,V=this.remuxer;if(!j||!V){J.executeEnd=u0();var U=[E7(Q)];if(this.asyncResult)return Promise.resolve(U);return U}var A=j.flush(G);if(o0(A))return this.asyncResult=!0,A.then(function(E){return Y.flushRemux(W,E,Q),W});if(this.flushRemux(W,A,Q),this.asyncResult)return Promise.resolve(W);return W},H.flushRemux=function Z(Q,Y,J){var{audioTrack:X,videoTrack:z,id3Track:N,textTrack:W}=Y,G=this.currentTransmuxState,K=G.accurateTimeOffset,j=G.timeOffset;this.logger.log("[transmuxer.ts]: Flushed "+this.id+" sn: "+J.sn+(J.part>-1?" part: "+J.part:"")+" of "+(this.id===d.MAIN?"level":"track")+" "+J.level);var V=this.remuxer.remux(X,z,N,W,j,K,!0,this.id);Q.push({remuxResult:V,chunkMeta:J}),J.transmuxing.executeEnd=u0()},H.resetInitialTimestamp=function Z(Q){var Y=this.demuxer,J=this.remuxer;if(!Y||!J)return;Y.resetTimeStamp(Q),J.resetTimeStamp(Q)},H.resetContiguity=function Z(){var Q=this.demuxer,Y=this.remuxer;if(!Q||!Y)return;Q.resetContiguity(),Y.resetNextTimestamp()},H.resetInitSegment=function Z(Q,Y,J,X,z){var N=this.demuxer,W=this.remuxer;if(!N||!W)return;N.resetInitSegment(Q,Y,J,X),W.resetInitSegment(Q,Y,J,z)},H.destroy=function Z(){if(this.demuxer)this.demuxer.destroy(),this.demuxer=void 0;if(this.remuxer)this.remuxer.destroy(),this.remuxer=void 0},H.transmux=function Z(Q,Y,J,X,z){var N;if(Y&&Y.method==="SAMPLE-AES")N=this.transmuxSampleAes(Q,Y,J,X,z);else N=this.transmuxUnencrypted(Q,J,X,z);return N},H.transmuxUnencrypted=function Z(Q,Y,J,X){var z=this.demuxer.demux(Q,Y,!1,!this.config.progressive),N=z.audioTrack,W=z.videoTrack,G=z.id3Track,K=z.textTrack,j=this.remuxer.remux(N,W,G,K,Y,J,!1,this.id);return{remuxResult:j,chunkMeta:X}},H.transmuxSampleAes=function Z(Q,Y,J,X,z){var N=this;return this.demuxer.demuxSampleAes(Q,Y,J).then(function(W){var G=N.remuxer.remux(W.audioTrack,W.videoTrack,W.id3Track,W.textTrack,J,X,!1,N.id);return{remuxResult:G,chunkMeta:z}})},H.configureTransmuxer=function Z(Q){var Y=this.config,J=this.observer,X=this.typeSupported,z;for(var N=0,W=V7.length;N<W;N++){var G;if((G=V7[N].demux)!=null&&G.probe(Q,this.logger)){z=V7[N];break}}if(!z)return new Error("Failed to find demuxer by probing fragment data");var K=this.demuxer,j=this.remuxer,V=z.remux,U=z.demux;if(!j||!(j instanceof V))this.remuxer=new V(J,Y,X,this.logger);if(!K||!(K instanceof U))this.demuxer=new U(J,Y,X,this.logger),this.probe=U.probe},H.needsProbing=function Z(Q,Y){return!this.demuxer||!this.remuxer||Q||Y},H.getDecrypter=function Z(){var Q=this.decrypter;if(!Q)Q=this.decrypter=new W7(this.config);return Q},q}();function J9(q,H){var Z=null;if(q.byteLength>0&&(H==null?void 0:H.key)!=null&&H.iv!==null&&H.method!=null)Z=H;return Z}var E7=function q(H){return{remuxResult:{},chunkMeta:H}};function o0(q){return"then"in q&&q.then instanceof Function}var Z9=function q(H,Z,Q,Y,J){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=H,this.videoCodec=Z,this.initSegmentData=Q,this.duration=Y,this.defaultInitPts=J||null},q9=function q(H,Z,Q,Y,J,X){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=H,this.contiguous=Z,this.accurateTimeOffset=Q,this.trackSwitch=Y,this.timeOffset=J,this.initSegmentChange=X};function X9(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(q){}return!1}var H9=/(\d+)-(\d+)\/(\d+)/,ZJ=function(){function q(Z){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=Z.fetchSetup||G9,this.controller=new self.AbortController,this.stats=new lY}var H=q.prototype;return H.destroy=function Z(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null},H.abortInternal=function Z(){if(this.controller&&!this.stats.loading.end)this.stats.aborted=!0,this.controller.abort()},H.abort=function Z(){var Q;if(this.abortInternal(),(Q=this.callbacks)!=null&&Q.onAbort)this.callbacks.onAbort(this.stats,this.context,this.response)},H.load=function Z(Q,Y,J){var X=this,z=this.stats;if(z.loading.start)throw new Error("Loader can only be used once.");z.loading.start=self.performance.now();var N=z9(Q,this.controller.signal),W=Q.responseType==="arraybuffer",G=W?"byteLength":"length",K=Y.loadPolicy,j=K.maxTimeToFirstByteMs,V=K.maxLoadTimeMs;this.context=Q,this.config=Y,this.callbacks=J,this.request=this.fetchSetup(Q,N),self.clearTimeout(this.requestTimeout),Y.timeout=j&&v(j)?j:V,this.requestTimeout=self.setTimeout(function(){if(X.callbacks)X.abortInternal(),X.callbacks.onTimeout(z,Q,X.response)},Y.timeout);var U=o0(this.request)?this.request.then(self.fetch):self.fetch(this.request);U.then(function(A){var E;X.response=X.loader=A;var B=Math.max(self.performance.now(),z.loading.start);if(self.clearTimeout(X.requestTimeout),Y.timeout=V,X.requestTimeout=self.setTimeout(function(){if(X.callbacks)X.abortInternal(),X.callbacks.onTimeout(z,Q,X.response)},V-(B-z.loading.start)),!A.ok){var{status:F,statusText:R}=A;throw new K9(R||"fetch, bad network response",F,A)}z.loading.first=B,z.total=W9(A.headers)||z.total;var O=(E=X.callbacks)==null?void 0:E.onProgress;if(O&&v(Y.highWaterMark))return X.loadProgressively(A,z,Q,Y.highWaterMark,O);if(W)return A.arrayBuffer();if(Q.responseType==="json")return A.json();return A.text()}).then(function(A){var E,B,F=X.response;if(!F)throw new Error("loader destroyed");self.clearTimeout(X.requestTimeout),z.loading.end=Math.max(self.performance.now(),z.loading.first);var R=A[G];if(R)z.loaded=z.total=R;var O={url:F.url,data:A,code:F.status},M=(E=X.callbacks)==null?void 0:E.onProgress;if(M&&!v(Y.highWaterMark))M(z,Q,A,F);(B=X.callbacks)==null||B.onSuccess(O,z,Q,F)}).catch(function(A){var E;if(self.clearTimeout(X.requestTimeout),z.aborted)return;var B=!A?0:A.code||0,F=!A?null:A.message;(E=X.callbacks)==null||E.onError({code:B,text:F},Q,A?A.details:null,z)})},H.getCacheAge=function Z(){var Q=null;if(this.response){var Y=this.response.headers.get("age");Q=Y?parseFloat(Y):null}return Q},H.getResponseHeader=function Z(Q){return this.response?this.response.headers.get(Q):null},H.loadProgressively=function Z(Q,Y,J,X,z){if(X===void 0)X=0;var N=new qZ,W=Q.body.getReader(),G=function K(){return W.read().then(function(j){if(j.done){if(N.dataLength)z(Y,J,N.flush().buffer,Q);return Promise.resolve(new ArrayBuffer(0))}var V=j.value,U=V.length;if(Y.loaded+=U,U<X||N.dataLength){if(N.push(V),N.dataLength>=X)z(Y,J,N.flush().buffer,Q)}else z(Y,J,V.buffer,Q);return G()}).catch(function(){return Promise.reject()})};return G()},q}();function z9(q,H){var Z={method:"GET",mode:"cors",credentials:"same-origin",signal:H,headers:new self.Headers(W0({},q.headers))};if(q.rangeEnd)Z.headers.set("Range","bytes="+q.rangeStart+"-"+String(q.rangeEnd-1));return Z}function N9(q){var H=H9.exec(q);if(H)return parseInt(H[2])-parseInt(H[1])+1}function W9(q){var H=q.get("Content-Range");if(H){var Z=N9(H);if(v(Z))return Z}var Q=q.get("Content-Length");if(Q)return parseInt(Q)}function G9(q,H){return new self.Request(q.url,H)}var K9=function(q){function H(Z,Q,Y){var J=q.call(this,Z)||this;return J.code=void 0,J.details=void 0,J.code=Q,J.details=Y,J}return G0(H,q),H}(qY(Error)),j9=/^age:\s*[\d.]+\s*$/im,qJ=function(){function q(Z){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=Z?Z.xhrSetup||null:null,this.stats=new lY,this.retryDelay=0}var H=q.prototype;return H.destroy=function Z(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null},H.abortInternal=function Z(){var Q=this.loader;if(self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),Q){if(Q.onreadystatechange=null,Q.onprogress=null,Q.readyState!==4)this.stats.aborted=!0,Q.abort()}},H.abort=function Z(){var Q;if(this.abortInternal(),(Q=this.callbacks)!=null&&Q.onAbort)this.callbacks.onAbort(this.stats,this.context,this.loader)},H.load=function Z(Q,Y,J){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=Q,this.config=Y,this.callbacks=J,this.loadInternal()},H.loadInternal=function Z(){var Q=this,Y=this.config,J=this.context;if(!Y||!J)return;var X=this.loader=new self.XMLHttpRequest,z=this.stats;z.loading.first=0,z.loaded=0,z.aborted=!1;var N=this.xhrSetup;if(N)Promise.resolve().then(function(){if(Q.loader!==X||Q.stats.aborted)return;return N(X,J.url)}).catch(function(W){if(Q.loader!==X||Q.stats.aborted)return;return X.open("GET",J.url,!0),N(X,J.url)}).then(function(){if(Q.loader!==X||Q.stats.aborted)return;Q.openAndSendXhr(X,J,Y)}).catch(function(W){var G;(G=Q.callbacks)==null||G.onError({code:X.status,text:W.message},J,X,z);return});else this.openAndSendXhr(X,J,Y)},H.openAndSendXhr=function Z(Q,Y,J){if(!Q.readyState)Q.open("GET",Y.url,!0);var X=Y.headers,z=J.loadPolicy,N=z.maxTimeToFirstByteMs,W=z.maxLoadTimeMs;if(X)for(var G in X)Q.setRequestHeader(G,X[G]);if(Y.rangeEnd)Q.setRequestHeader("Range","bytes="+Y.rangeStart+"-"+(Y.rangeEnd-1));Q.onreadystatechange=this.readystatechange.bind(this),Q.onprogress=this.loadprogress.bind(this),Q.responseType=Y.responseType,self.clearTimeout(this.requestTimeout),J.timeout=N&&v(N)?N:W,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),J.timeout),Q.send()},H.readystatechange=function Z(){var Q=this.context,Y=this.loader,J=this.stats;if(!Q||!Y)return;var X=Y.readyState,z=this.config;if(J.aborted)return;if(X>=2){if(J.loading.first===0){if(J.loading.first=Math.max(self.performance.now(),J.loading.start),z.timeout!==z.loadPolicy.maxLoadTimeMs)self.clearTimeout(this.requestTimeout),z.timeout=z.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),z.loadPolicy.maxLoadTimeMs-(J.loading.first-J.loading.start))}if(X===4){self.clearTimeout(this.requestTimeout),Y.onreadystatechange=null,Y.onprogress=null;var N=Y.status,W=Y.responseType==="text"?Y.responseText:null;if(N>=200&&N<300){var G=W!=null?W:Y.response;if(G!=null){var K,j;J.loading.end=Math.max(self.performance.now(),J.loading.first);var V=Y.responseType==="arraybuffer"?G.byteLength:G.length;J.loaded=J.total=V,J.bwEstimate=J.total*8000/(J.loading.end-J.loading.first);var U=(K=this.callbacks)==null?void 0:K.onProgress;if(U)U(J,Q,G,Y);var A={url:Y.responseURL,data:G,code:N};(j=this.callbacks)==null||j.onSuccess(A,J,Q,Y);return}}var E=z.loadPolicy.errorRetry,B=J.retry,F={url:Q.url,data:void 0,code:N};if(MY(E,B,!1,F))this.retry(E);else{var R;s.error(N+" while loading "+Q.url),(R=this.callbacks)==null||R.onError({code:N,text:Y.statusText},Q,Y,J)}}}},H.loadtimeout=function Z(){if(!this.config)return;var Q=this.config.loadPolicy.timeoutRetry,Y=this.stats.retry;if(MY(Q,Y,!0))this.retry(Q);else{var J;s.warn("timeout while loading "+((J=this.context)==null?void 0:J.url));var X=this.callbacks;if(X)this.abortInternal(),X.onTimeout(this.stats,this.context,this.loader)}},H.retry=function Z(Q){var Y=this.context,J=this.stats;this.retryDelay=Y7(Q,J.retry),J.retry++,s.warn((status?"HTTP Status "+status:"Timeout")+" while loading "+(Y==null?void 0:Y.url)+", retrying "+J.retry+"/"+Q.maxNumRetry+" in "+this.retryDelay+"ms"),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)},H.loadprogress=function Z(Q){var Y=this.stats;if(Y.loaded=Q.loaded,Q.lengthComputable)Y.total=Q.total},H.getCacheAge=function Z(){var Q=null;if(this.loader&&j9.test(this.loader.getAllResponseHeaders())){var Y=this.loader.getResponseHeader("age");Q=Y?parseFloat(Y):null}return Q},H.getResponseHeader=function Z(Q){if(this.loader&&new RegExp("^"+Q+":\\s*[\\d.]+\\s*$","im").test(this.loader.getAllResponseHeaders()))return this.loader.getResponseHeader(Q);return null},q}(),XJ={maxTimeToFirstByteMs:8000,maxLoadTimeMs:20000,timeoutRetry:null,errorRetry:null},U9=F0(F0({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,maxDevicePixelRatio:Number.POSITIVE_INFINITY,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,maxBufferSize:60000000,maxFragLookUpTolerance:0.25,maxBufferHole:0.1,detectStallWithCurrentTimeMs:1250,highBufferWatchdogPeriod:2,nudgeOffset:0.1,nudgeMaxRetry:3,nudgeOnVideoHole:!0,liveSyncDurationCount:3,liveSyncOnStallIncrease:1,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:5000,fpsDroppedMonitoringThreshold:0.2,appendErrorMaxRetry:3,ignorePlaylistParsingErrors:!1,loader:qJ,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:L8,bufferController:k8,capLevelController:h8,errorController:T8,fpsController:ZZ,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:500000,abrEwmaDefaultEstimateMax:5000000,abrBandWidthFactor:0.95,abrBandWidthUpFactor:0.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:null,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableEmsgKLVMetadata:!1,enableID3MetadataCues:!0,enableInterstitialPlayback:!1,interstitialAppendInPlace:!0,interstitialLiveLookAhead:10,useMediaCapabilities:!1,certLoadPolicy:{default:XJ},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8000,maxLoadTimeMs:20000,timeoutRetry:{maxNumRetry:1,retryDelayMs:1000,maxRetryDelayMs:20000,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1000,maxRetryDelayMs:20000,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:20000,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1000,maxRetryDelayMs:8000}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:20000,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1000,maxRetryDelayMs:8000}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:120000,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1000,maxRetryDelayMs:8000}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:20000,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1000,maxRetryDelayMs:8000}}},interstitialAssetListLoadPolicy:{default:XJ},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1000,manifestLoadingMaxRetryTimeout:64000,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1000,levelLoadingMaxRetryTimeout:64000,fragLoadingTimeOut:20000,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1000,fragLoadingMaxRetryTimeout:64000},V9()),{},{subtitleStreamController:void 0,subtitleTrackController:void 0,timelineController:void 0,audioStreamController:void 0,audioTrackController:void 0,emeController:void 0,cmcdController:void 0,contentSteeringController:JZ,interstitialsController:void 0});function V9(){return{cueHandler:iJ,enableWebVTT:!1,enableIMSC1:!1,enableCEA708Captions:!1,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function A9(q,H,Z){if((H.liveSyncDurationCount||H.liveMaxLatencyDurationCount)&&(H.liveSyncDuration||H.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(H.liveMaxLatencyDurationCount!==void 0&&(H.liveSyncDurationCount===void 0||H.liveMaxLatencyDurationCount<=H.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(H.liveMaxLatencyDuration!==void 0&&(H.liveSyncDuration===void 0||H.liveMaxLatencyDuration<=H.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var Q=B7(q),Y=["manifest","level","frag"],J=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return Y.forEach(function(X){var z=(X==="level"?"playlist":X)+"LoadPolicy",N=H[z]===void 0,W=[];if(J.forEach(function(G){var K=X+"Loading"+G,j=H[K];if(j!==void 0&&N){W.push(K);var V=Q[z].default;switch(H[z]={default:V},G){case"TimeOut":V.maxLoadTimeMs=j,V.maxTimeToFirstByteMs=j;break;case"MaxRetry":V.errorRetry.maxNumRetry=j,V.timeoutRetry.maxNumRetry=j;break;case"RetryDelay":V.errorRetry.retryDelayMs=j,V.timeoutRetry.retryDelayMs=j;break;case"MaxRetryTimeout":V.errorRetry.maxRetryDelayMs=j,V.timeoutRetry.maxRetryDelayMs=j;break}}}),W.length)Z.warn('hls.js config: "'+W.join('", "')+'" setting(s) are deprecated, use "'+z+'": '+$0(H[z]))}),F0(F0({},Q),H)}function B7(q){if(q&&typeof q==="object"){if(Array.isArray(q))return q.map(B7);return Object.keys(q).reduce(function(H,Z){return H[Z]=B7(q[Z]),H},{})}return q}function E9(q,H){var Z=q.loader;if(Z!==ZJ&&Z!==qJ)H.log("[config]: Custom loader detected, cannot enable progressive streaming"),q.progressive=!1;else{var Q=X9();if(Q)q.loader=ZJ,q.progressive=!0,q.enableSoftwareAES=!0,H.log("[config]: Progressive streaming enabled, using FetchLoader")}}var O0={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"},B9=function(){function q(Z){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=0.2,this.hls=void 0,this.hasGaps=!1,this.hls=Z,this._registerListeners()}var H=q.prototype;return H._registerListeners=function Z(){var Q=this.hls;Q.on($.MANIFEST_LOADING,this.onManifestLoading,this),Q.on($.BUFFER_APPENDED,this.onBufferAppended,this),Q.on($.FRAG_BUFFERED,this.onFragBuffered,this),Q.on($.FRAG_LOADED,this.onFragLoaded,this)},H._unregisterListeners=function Z(){var Q=this.hls;Q.off($.MANIFEST_LOADING,this.onManifestLoading,this),Q.off($.BUFFER_APPENDED,this.onBufferAppended,this),Q.off($.FRAG_BUFFERED,this.onFragBuffered,this),Q.off($.FRAG_LOADED,this.onFragLoaded,this)},H.destroy=function Z(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null},H.getAppendedFrag=function Z(Q,Y){var J=this.activePartLists[Y];if(J)for(var X=J.length;X--;){var z=J[X];if(!z)break;var N=z.end;if(z.start<=Q&&N!==null&&Q<=N)return z}return this.getBufferedFrag(Q,Y)},H.getBufferedFrag=function Z(Q,Y){return this.getFragAtPos(Q,Y,!0)},H.getFragAtPos=function Z(Q,Y,J){var X=this.fragments,z=Object.keys(X);for(var N=z.length;N--;){var W=X[z[N]];if((W==null?void 0:W.body.type)===Y&&(!J||W.buffered)){var G=W.body;if(G.start<=Q&&Q<=G.end)return G}}return null},H.detectEvictedFragments=function Z(Q,Y,J,X,z){var N=this;if(this.timeRanges)this.timeRanges[Q]=Y;var W=(X==null?void 0:X.fragment.sn)||-1;Object.keys(this.fragments).forEach(function(G){var K=N.fragments[G];if(!K)return;if(W>=K.body.sn)return;if(!K.buffered&&(!K.loaded||z)){if(K.body.type===J)N.removeFragment(K.body);return}var j=K.range[Q];if(!j)return;if(j.time.length===0){N.removeFragment(K.body);return}j.time.some(function(V){var U=!N.isTimeBuffered(V.startPTS,V.endPTS,Y);if(U)N.removeFragment(K.body);return U})})},H.detectPartialFragments=function Z(Q){var Y=this,J=this.timeRanges;if(!J||Q.frag.sn==="initSegment")return;var X=Q.frag,z=e0(X),N=this.fragments[z];if(!N||N.buffered&&X.gap)return;var W=!X.relurl;if(Object.keys(J).forEach(function(K){var j=X.elementaryStreams[K];if(!j)return;var V=J[K],U=W||j.partial===!0;N.range[K]=Y.getBufferedTimes(X,Q.part,U,V)}),N.loaded=null,Object.keys(N.range).length){N.buffered=!0;var G=N.body.endList=X.endList||N.body.endList;if(G)this.endListFragments[N.body.type]=N;if(!SY(N))this.removeParts(X.sn-1,X.type)}else this.removeFragment(N.body)},H.removeParts=function Z(Q,Y){var J=this.activePartLists[Y];if(!J)return;this.activePartLists[Y]=J.filter(function(X){return X.fragment.sn>=Q})},H.fragBuffered=function Z(Q,Y){var J=e0(Q),X=this.fragments[J];if(!X&&Y){if(X=this.fragments[J]={body:Q,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},Q.gap)this.hasGaps=!0}if(X)X.loaded=null,X.buffered=!0},H.getBufferedTimes=function Z(Q,Y,J,X){var z={time:[],partial:J},N=Q.start,W=Q.end,G=Q.minEndPTS||W,K=Q.maxStartPTS||N;for(var j=0;j<X.length;j++){var V=X.start(j)-this.bufferPadding,U=X.end(j)+this.bufferPadding;if(K>=V&&G<=U){z.time.push({startPTS:Math.max(N,X.start(j)),endPTS:Math.min(W,X.end(j))});break}else if(N<U&&W>V){var A=Math.max(N,X.start(j)),E=Math.min(W,X.end(j));if(E>A)z.partial=!0,z.time.push({startPTS:A,endPTS:E})}else if(W<=V)break}return z},H.getPartialFragment=function Z(Q){var Y=null,J,X,z,N=0,W=this.bufferPadding,G=this.fragments;return Object.keys(G).forEach(function(K){var j=G[K];if(!j)return;if(SY(j)){if(X=j.body.start-W,z=j.body.end+W,Q>=X&&Q<=z){if(J=Math.min(Q-X,z-Q),N<=J)Y=j.body,N=J}}}),Y},H.isEndListAppended=function Z(Q){var Y=this.endListFragments[Q];return Y!==void 0&&(Y.buffered||SY(Y))},H.getState=function Z(Q){var Y=e0(Q),J=this.fragments[Y];if(J)if(!J.buffered)return O0.APPENDING;else if(SY(J))return O0.PARTIAL;else return O0.OK;return O0.NOT_LOADED},H.isTimeBuffered=function Z(Q,Y,J){var X,z;for(var N=0;N<J.length;N++){if(X=J.start(N)-this.bufferPadding,z=J.end(N)+this.bufferPadding,Q>=X&&Y<=z)return!0;if(Y<=X)return!1}return!1},H.onManifestLoading=function Z(){this.removeAllFragments()},H.onFragLoaded=function Z(Q,Y){if(Y.frag.sn==="initSegment"||Y.frag.bitrateTest)return;var J=Y.frag,X=Y.part?null:Y,z=e0(J);this.fragments[z]={body:J,appendedPTS:null,loaded:X,buffered:!1,range:Object.create(null)}},H.onBufferAppended=function Z(Q,Y){var{frag:J,part:X,timeRanges:z,type:N}=Y;if(J.sn==="initSegment")return;var W=J.type;if(X){var G=this.activePartLists[W];if(!G)this.activePartLists[W]=G=[];G.push(X)}this.timeRanges=z;var K=z[N];this.detectEvictedFragments(N,K,W,X)},H.onFragBuffered=function Z(Q,Y){this.detectPartialFragments(Y)},H.hasFragment=function Z(Q){var Y=e0(Q);return!!this.fragments[Y]},H.hasFragments=function Z(Q){var Y=this.fragments,J=Object.keys(Y);if(!Q)return J.length>0;for(var X=J.length;X--;){var z=Y[J[X]];if((z==null?void 0:z.body.type)===Q)return!0}return!1},H.hasParts=function Z(Q){var Y;return!!((Y=this.activePartLists[Q])!=null&&Y.length)},H.removeFragmentsInRange=function Z(Q,Y,J,X,z){var N=this;if(X&&!this.hasGaps)return;Object.keys(this.fragments).forEach(function(W){var G=N.fragments[W];if(!G)return;var K=G.body;if(K.type!==J||X&&!K.gap)return;if(K.start<Y&&K.end>Q&&(G.buffered||z))N.removeFragment(K)})},H.removeFragment=function Z(Q){var Y=e0(Q);Q.clearElementaryStreamInfo();var J=this.activePartLists[Q.type];if(J){var X=Q.sn;this.activePartLists[Q.type]=J.filter(function(z){return z.fragment.sn!==X})}if(delete this.fragments[Y],Q.endList)delete this.endListFragments[Q.type]},H.removeAllFragments=function Z(){var Q,Y;this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1;var J=(Q=this.hls)==null?void 0:(Y=Q.latestLevelDetails)==null?void 0:Y.partList;if(J)J.forEach(function(X){return X.clearElementaryStreamInfo()})},q}();function SY(q){var H,Z,Q;return q.buffered&&(q.body.gap||((H=q.range.video)==null?void 0:H.partial)||((Z=q.range.audio)==null?void 0:Z.partial)||((Q=q.range.audiovideo)==null?void 0:Q.partial))}function e0(q){return q.type+"_"+q.level+"_"+q.sn}var HJ=Math.pow(2,17),$9=function(){function q(Z){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=Z}var H=q.prototype;return H.destroy=function Z(){if(this.loader)this.loader.destroy(),this.loader=null},H.abort=function Z(){if(this.loader)this.loader.abort()},H.load=function Z(Q,Y){var J=this,X=Q.url;if(!X)return Promise.reject(new c0({type:f.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:Q,error:new Error("Fragment does not have a "+(X?"part list":"url")),networkDetails:null}));this.abort();var z=this.config,N=z.fLoader,W=z.loader;return new Promise(function(G,K){if(J.loader)J.loader.destroy();if(Q.gap)if(Q.tagList.some(function(B){return B[0]==="GAP"})){K(NJ(Q));return}else Q.gap=!1;var j=J.loader=N?new N(z):new W(z),V=zJ(Q);Q.loader=j;var U=WQ(z.fragLoadPolicy.default),A={loadPolicy:U,timeout:U.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:Q.sn==="initSegment"?1/0:HJ};Q.stats=j.stats;var E={onSuccess:function B(F,R,O,M){J.resetLoader(Q,j);var L=F.data;if(O.resetIV&&Q.decryptdata)Q.decryptdata.iv=new Uint8Array(L.slice(0,16)),L=L.slice(16);G({frag:Q,part:null,payload:L,networkDetails:M})},onError:function B(F,R,O,M){J.resetLoader(Q,j),K(new c0({type:f.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:Q,response:F0({url:X,data:void 0},F),error:new Error("HTTP Error "+F.code+" "+F.text),networkDetails:O,stats:M}))},onAbort:function B(F,R,O){J.resetLoader(Q,j),K(new c0({type:f.NETWORK_ERROR,details:D.INTERNAL_ABORTED,fatal:!1,frag:Q,error:new Error("Aborted"),networkDetails:O,stats:F}))},onTimeout:function B(F,R,O){J.resetLoader(Q,j),K(new c0({type:f.NETWORK_ERROR,details:D.FRAG_LOAD_TIMEOUT,fatal:!1,frag:Q,error:new Error("Timeout after "+A.timeout+"ms"),networkDetails:O,stats:F}))}};if(Y)E.onProgress=function(B,F,R,O){return Y({frag:Q,part:null,payload:R,networkDetails:O})};j.load(V,A,E)})},H.loadPart=function Z(Q,Y,J){var X=this;this.abort();var z=this.config,N=z.fLoader,W=z.loader;return new Promise(function(G,K){if(X.loader)X.loader.destroy();if(Q.gap||Y.gap){K(NJ(Q,Y));return}var j=X.loader=N?new N(z):new W(z),V=zJ(Q,Y);Q.loader=j;var U=WQ(z.fragLoadPolicy.default),A={loadPolicy:U,timeout:U.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:HJ};Y.stats=j.stats,j.load(V,A,{onSuccess:function E(B,F,R,O){X.resetLoader(Q,j),X.updateStatsFromPart(Q,Y);var M={frag:Q,part:Y,payload:B.data,networkDetails:O};J(M),G(M)},onError:function E(B,F,R,O){X.resetLoader(Q,j),K(new c0({type:f.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:Q,part:Y,response:F0({url:V.url,data:void 0},B),error:new Error("HTTP Error "+B.code+" "+B.text),networkDetails:R,stats:O}))},onAbort:function E(B,F,R){Q.stats.aborted=Y.stats.aborted,X.resetLoader(Q,j),K(new c0({type:f.NETWORK_ERROR,details:D.INTERNAL_ABORTED,fatal:!1,frag:Q,part:Y,error:new Error("Aborted"),networkDetails:R,stats:B}))},onTimeout:function E(B,F,R){X.resetLoader(Q,j),K(new c0({type:f.NETWORK_ERROR,details:D.FRAG_LOAD_TIMEOUT,fatal:!1,frag:Q,part:Y,error:new Error("Timeout after "+A.timeout+"ms"),networkDetails:R,stats:B}))}})})},H.updateStatsFromPart=function Z(Q,Y){var J=Q.stats,X=Y.stats,z=X.total;if(J.loaded+=X.loaded,z){var N=Math.round(Q.duration/Y.duration),W=Math.min(Math.round(J.loaded/z),N),G=N-W,K=G*Math.round(J.loaded/W);J.total=J.loaded+K}else J.total=Math.max(J.loaded,J.total);var j=J.loading,V=X.loading;if(j.start)j.first+=V.first-V.start;else j.start=V.start,j.first=V.first;j.end=V.end},H.resetLoader=function Z(Q,Y){if(Q.loader=null,this.loader===Y)self.clearTimeout(this.partLoadTimeout),this.loader=null;Y.destroy()},q}();function zJ(q,H){if(H===void 0)H=null;var Z=H||q,Q={frag:q,part:H,responseType:"arraybuffer",url:Z.url,headers:{},rangeStart:0,rangeEnd:0},Y=Z.byteRangeStartOffset,J=Z.byteRangeEndOffset;if(v(Y)&&v(J)){var X,z=Y,N=J;if(q.sn==="initSegment"&&F9((X=q.decryptdata)==null?void 0:X.method)){var W=J-Y;if(W%16)N=J+(16-W%16);if(Y!==0)Q.resetIV=!0,z=Y-16}Q.rangeStart=z,Q.rangeEnd=N}return Q}function NJ(q,H){var Z=new Error("GAP "+(q.gap?"tag":"attribute")+" found"),Q={type:f.MEDIA_ERROR,details:D.FRAG_GAP,fatal:!1,frag:q,error:Z,networkDetails:null};if(H)Q.part=H;return(H?H:q).stats.aborted=!0,new c0(Q)}function F9(q){return q==="AES-128"||q==="AES-256"}var c0=function(q){function H(Z){var Q=q.call(this,Z.error.message)||this;return Q.data=void 0,Q.data=Z,Q}return G0(H,q),H}(qY(Error)),WJ=function(q){function H(Q,Y){var J=q.call(this,Q,Y)||this;return J._boundTick=void 0,J._tickTimer=null,J._tickInterval=null,J._tickCallCount=0,J._boundTick=J.tick.bind(J),J}G0(H,q);var Z=H.prototype;return Z.destroy=function Q(){this.onHandlerDestroying(),this.onHandlerDestroyed()},Z.onHandlerDestroying=function Q(){this.clearNextTick(),this.clearInterval()},Z.onHandlerDestroyed=function Q(){},Z.hasInterval=function Q(){return!!this._tickInterval},Z.hasNextTick=function Q(){return!!this._tickTimer},Z.setInterval=function Q(Y){if(!this._tickInterval)return this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,Y),!0;return!1},Z.clearInterval=function Q(){if(this._tickInterval)return self.clearInterval(this._tickInterval),this._tickInterval=null,!0;return!1},Z.clearNextTick=function Q(){if(this._tickTimer)return self.clearTimeout(this._tickTimer),this._tickTimer=null,!0;return!1},Z.tick=function Q(){if(this._tickCallCount++,this._tickCallCount===1){if(this.doTick(),this._tickCallCount>1)this.tickImmediate();this._tickCallCount=0}},Z.tickImmediate=function Q(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},Z.doTick=function Q(){},H}(i0),GJ=function q(H,Z,Q,Y,J,X){if(Y===void 0)Y=0;if(J===void 0)J=-1;if(X===void 0)X=!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=xY(),this.buffering={audio:xY(),video:xY(),audiovideo:xY()},this.level=H,this.sn=Z,this.id=Q,this.size=Y,this.part=J,this.partial=X};function xY(){return{start:0,executeStart:0,executeEnd:0,end:0}}function WY(q,H){for(var Z=0,Q=q.length;Z<Q;Z++){var Y;if(((Y=q[Z])==null?void 0:Y.cc)===H)return q[Z]}return null}function O9(q,H){if(q){if(H.startCC<q.endCC&&H.endCC>q.startCC)return!0}return!1}function KJ(q,H){if(q){var Z=q.start+H;q.start=q.startPTS=Z,q.endPTS=Z+q.duration}}function jJ(q,H){var Z=H.fragments;for(var Q=0,Y=Z.length;Q<Y;Q++)KJ(Z[Q],q);if(H.fragmentHint)KJ(H.fragmentHint,q);H.alignedSliding=!0}function R9(q,H){if(!q)return;if(M9(H,q),!H.alignedSliding&&q)I9(H,q);if(!H.alignedSliding&&q&&!H.skippedSegments)DQ(q,H,!1)}function M9(q,H){if(!O9(H,q))return;var Z=Math.min(H.endCC,q.endCC),Q=WY(H.fragments,Z),Y=WY(q.fragments,Z);if(!Q||!Y)return;s.log("Aligning playlist at start of dicontinuity sequence "+Z);var J=Q.start-Y.start;jJ(J,q)}function I9(q,H){if(!q.hasProgramDateTime||!H.hasProgramDateTime)return;var Z=q.fragments,Q=H.fragments;if(!Z.length||!Q.length)return;var Y,J,X=Math.min(H.endCC,q.endCC);if(H.startCC<X&&q.startCC<X)Y=WY(Q,X),J=WY(Z,X);if(!Y||!J)Y=Q[Math.floor(Q.length/2)],J=WY(Z,Y.cc)||Z[Math.floor(Z.length/2)];var z=Y.programDateTime,N=J.programDateTime;if(!z||!N)return;var W=(N-z)/1000-(J.start-Y.start);jJ(W,q)}var w9={toString:function q(H){var Z="",Q=H.length;for(var Y=0;Y<Q;Y++)Z+="["+H.start(Y).toFixed(3)+"-"+H.end(Y).toFixed(3)+"]";return Z}},k={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_LEVEL:"WAITING_LEVEL"},L9=function(q){function H(Q,Y,J,X,z){var N=q.call(this,X,Q.logger)||this;return N.hls=void 0,N.fragPrevious=null,N.fragCurrent=null,N.fragmentTracker=void 0,N.transmuxer=null,N._state=k.STOPPED,N.playlistType=void 0,N.media=null,N.mediaBuffer=null,N.config=void 0,N.bitrateTest=!1,N.lastCurrentTime=0,N.nextLoadPosition=0,N.startPosition=0,N.startTimeOffset=null,N.retryDate=0,N.levels=null,N.fragmentLoader=void 0,N.keyLoader=void 0,N.levelLastLoaded=null,N.startFragRequested=!1,N.decrypter=void 0,N.initPTS=[],N.buffering=!0,N.loadingParts=!1,N.loopSn=void 0,N.onMediaSeeking=function(){var W=N,G=W.config,K=W.fragCurrent,j=W.media,V=W.mediaBuffer,U=W.state,A=j?j.currentTime:0,E=i.bufferInfo(V?V:j,A,G.maxBufferHole);if(N.log("media seeking to "+(v(A)?A.toFixed(3):A)+", state: "+U),N.state===k.ENDED)N.resetLoadingState();else if(K){var B=G.maxFragLookUpTolerance,F=K.start-B,R=K.start+K.duration+B;if(!E.len||R<E.start||F>E.end){var O=A>R;if(A<F||O){if(O&&K.loader)N.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),K.abortRequests(),N.resetLoadingState();N.fragPrevious=null}}}if(j){N.fragmentTracker.removeFragmentsInRange(A,1/0,N.playlistType,!0);var M=N.lastCurrentTime;if(A>M)N.lastCurrentTime=A;if(!N.loadingParts){var L=Math.max(E.end,A),I=N.shouldLoadParts(N.getLevelDetails(),L);if(I)N.log("LL-Part loading ON after seeking to "+A.toFixed(2)+" with buffer @"+L.toFixed(2)),N.loadingParts=I}}if(!N.hls.hasEnoughToStart&&!E.len)N.log("setting startPosition to "+A+" because of seek before start"),N.nextLoadPosition=N.startPosition=A;N.tickImmediate()},N.onMediaEnded=function(){N.log("setting startPosition to 0 because media ended"),N.startPosition=N.lastCurrentTime=0},N.playlistType=z,N.hls=Q,N.fragmentLoader=new $9(Q.config),N.keyLoader=J,N.fragmentTracker=Y,N.config=Q.config,N.decrypter=new W7(Q.config),N}G0(H,q);var Z=H.prototype;return Z.registerListeners=function Q(){var Y=this.hls;Y.on($.MEDIA_ATTACHED,this.onMediaAttached,this),Y.on($.MEDIA_DETACHING,this.onMediaDetaching,this),Y.on($.MANIFEST_LOADING,this.onManifestLoading,this),Y.on($.MANIFEST_LOADED,this.onManifestLoaded,this),Y.on($.ERROR,this.onError,this)},Z.unregisterListeners=function Q(){var Y=this.hls;Y.off($.MEDIA_ATTACHED,this.onMediaAttached,this),Y.off($.MEDIA_DETACHING,this.onMediaDetaching,this),Y.off($.MANIFEST_LOADING,this.onManifestLoading,this),Y.off($.MANIFEST_LOADED,this.onManifestLoaded,this),Y.off($.ERROR,this.onError,this)},Z.doTick=function Q(){this.onTickEnd()},Z.onTickEnd=function Q(){},Z.startLoad=function Q(Y){},Z.stopLoad=function Q(){if(this.state===k.STOPPED)return;this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);var Y=this.fragCurrent;if(Y!=null&&Y.loader)Y.abortRequests(),this.fragmentTracker.removeFragment(Y);this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=k.STOPPED},Z.pauseBuffering=function Q(){this.buffering=!1},Z.resumeBuffering=function Q(){this.buffering=!0},Z._streamEnded=function Q(Y,J){if(J.live||!this.media)return!1;var X=Y.end||0,z=this.config.timelineOffset||0;if(X<=z)return!1;var N=Y.nextStart,W=N&&N>z&&N<J.edge;if(W)return!1;if(this.media.currentTime<Y.start)return!1;var G=J.partList;if(G!=null&&G.length){var K=G[G.length-1],j=i.isBuffered(this.media,K.start+K.duration/2);return j}var V=J.fragments[J.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(V)},Z.getLevelDetails=function Q(){if(this.levels&&this.levelLastLoaded!==null){var Y;return(Y=this.levelLastLoaded)==null?void 0:Y.details}},Z.onMediaAttached=function Q(Y,J){var X=this.media=this.mediaBuffer=J.media;X.removeEventListener("seeking",this.onMediaSeeking),X.removeEventListener("ended",this.onMediaEnded),X.addEventListener("seeking",this.onMediaSeeking),X.addEventListener("ended",this.onMediaEnded);var z=this.config;if(this.levels&&z.autoStartLoad&&this.state===k.STOPPED)this.startLoad(z.startPosition)},Z.onMediaDetaching=function Q(Y,J){var X=!!J.transferMedia,z=this.media;if(z===null)return;if(z.ended)this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0;if(z.removeEventListener("seeking",this.onMediaSeeking),z.removeEventListener("ended",this.onMediaEnded),this.keyLoader&&!X)this.keyLoader.detach();if(this.media=this.mediaBuffer=null,this.loopSn=void 0,X){this.resetLoadingState(),this.resetTransmuxer();return}this.loadingParts=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},Z.onManifestLoading=function Q(){this.initPTS=[],this.levels=this.levelLastLoaded=this.fragCurrent=null,this.lastCurrentTime=this.startPosition=0,this.startFragRequested=!1},Z.onError=function Q(Y,J){},Z.onManifestLoaded=function Q(Y,J){this.startTimeOffset=J.startTimeOffset},Z.onHandlerDestroying=function Q(){if(this.stopLoad(),this.transmuxer)this.transmuxer.destroy(),this.transmuxer=null;q.prototype.onHandlerDestroying.call(this),this.hls=this.onMediaSeeking=this.onMediaEnded=null},Z.onHandlerDestroyed=function Q(){if(this.state=k.STOPPED,this.fragmentLoader)this.fragmentLoader.destroy();if(this.keyLoader)this.keyLoader.destroy();if(this.decrypter)this.decrypter.destroy();this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,q.prototype.onHandlerDestroyed.call(this)},Z.loadFragment=function Q(Y,J,X){this.startFragRequested=!0,this._loadFragForPlayback(Y,J,X)},Z._loadFragForPlayback=function Q(Y,J,X){var z=this,N=function W(G){var K=G.frag;if(z.fragContextChanged(K)){z.warn(K.type+" sn: "+K.sn+(G.part?" part: "+G.part.index:"")+" of "+z.fragInfo(K,!1,G.part)+") was dropped during download."),z.fragmentTracker.removeFragment(K);return}K.stats.chunkCount++,z._handleFragmentLoadProgress(G)};this._doFragLoad(Y,J,X,N).then(function(W){if(!W)return;var G=z.state,K=W.frag;if(z.fragContextChanged(K)){if(G===k.FRAG_LOADING||!z.fragCurrent&&G===k.PARSING)z.fragmentTracker.removeFragment(K),z.state=k.IDLE;return}if("payload"in W)z.log("Loaded "+K.type+" sn: "+K.sn+" of "+z.playlistLabel()+" "+K.level),z.hls.trigger($.FRAG_LOADED,W);z._handleFragmentLoadComplete(W)}).catch(function(W){if(z.state===k.STOPPED||z.state===k.ERROR)return;z.warn("Frag error: "+((W==null?void 0:W.message)||W)),z.resetFragmentLoading(Y)})},Z.clearTrackerIfNeeded=function Q(Y){var J,X=this.fragmentTracker,z=X.getState(Y);if(z===O0.APPENDING){var N=Y.type,W=this.getFwdBufferInfo(this.mediaBuffer,N),G=Math.max(Y.duration,W?W.len:this.config.maxBufferLength),K=this.backtrackFragment,j=K?Y.sn-K.sn:0;if(j===1||this.reduceMaxBufferLength(G,Y.duration))X.removeFragment(Y)}else if(((J=this.mediaBuffer)==null?void 0:J.buffered.length)===0)X.removeAllFragments();else if(X.hasParts(Y.type)){if(X.detectPartialFragments({frag:Y,part:null,stats:Y.stats,id:Y.type}),X.getState(Y)===O0.PARTIAL)X.removeFragment(Y)}},Z.checkLiveUpdate=function Q(Y){if(Y.updated&&!Y.live){var J=Y.fragments[Y.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:J,part:null,stats:J.stats,id:J.type})}if(!Y.fragments[0])Y.deltaUpdateFailed=!0},Z.waitForLive=function Q(Y){var J=Y.details;return(J==null?void 0:J.live)&&J.type!=="EVENT"&&(this.levelLastLoaded!==Y||J.expired)},Z.flushMainBuffer=function Q(Y,J,X){if(X===void 0)X=null;if(!(Y-J))return;var z={startOffset:Y,endOffset:J,type:X};this.hls.trigger($.BUFFER_FLUSHING,z)},Z._loadInitSegment=function Q(Y,J){var X=this;this._doFragLoad(Y,J).then(function(z){var N=z==null?void 0:z.frag;if(!N||X.fragContextChanged(N)||!X.levels)throw new Error("init load aborted");return z}).then(function(z){var N=X.hls,W=z.frag,G=z.payload,K=W.decryptdata;if(G&&G.byteLength>0&&K!=null&&K.key&&K.iv&&HY(K.method)){var j=self.performance.now();return X.decrypter.decrypt(new Uint8Array(G),K.key.buffer,K.iv.buffer,EQ(K.method)).catch(function(V){throw N.trigger($.ERROR,{type:f.MEDIA_ERROR,details:D.FRAG_DECRYPT_ERROR,fatal:!1,error:V,reason:V.message,frag:W}),V}).then(function(V){var U=self.performance.now();return N.trigger($.FRAG_DECRYPTED,{frag:W,payload:V,stats:{tstart:j,tdecrypt:U}}),z.payload=V,X.completeInitSegmentLoad(z)})}return X.completeInitSegmentLoad(z)}).catch(function(z){if(X.state===k.STOPPED||X.state===k.ERROR)return;X.warn(z),X.resetFragmentLoading(Y)})},Z.completeInitSegmentLoad=function Q(Y){var J=this.levels;if(!J)throw new Error("init load aborted, missing levels");var X=Y.frag.stats;if(this.state!==k.STOPPED)this.state=k.IDLE;Y.frag.data=new Uint8Array(Y.payload),X.parsing.start=X.buffering.start=self.performance.now(),X.parsing.end=X.buffering.end=self.performance.now(),this.tick()},Z.fragContextChanged=function Q(Y){var J=this.fragCurrent;return!Y||!J||Y.sn!==J.sn||Y.level!==J.level},Z.fragBufferedComplete=function Q(Y,J){var X=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log("Buffered "+Y.type+" sn: "+Y.sn+(J?" part: "+J.index:"")+" of "+this.fragInfo(Y,!1,J)+" > buffer:"+(X?w9.toString(i.getBuffered(X)):"(detached)")+")"),k0(Y)){var z;if(Y.type!==d.SUBTITLE){var N=Y.elementaryStreams;if(!Object.keys(N).some(function(G){return!!N[G]})){this.state=k.IDLE;return}}var W=(z=this.levels)==null?void 0:z[Y.level];if(W!=null&&W.fragmentError)this.log("Resetting level fragment error count of "+W.fragmentError+" on frag buffered"),W.fragmentError=0}this.state=k.IDLE},Z._handleFragmentLoadComplete=function Q(Y){var J=this.transmuxer;if(!J)return;var{frag:X,part:z,partsLoaded:N}=Y,W=!N||N.length===0||N.some(function(K){return!K}),G=new GJ(X.level,X.sn,X.stats.chunkCount+1,0,z?z.index:-1,!W);J.flush(G)},Z._handleFragmentLoadProgress=function Q(Y){},Z._doFragLoad=function Q(Y,J,X,z){var N,W=this;if(X===void 0)X=null;this.fragCurrent=Y;var G=J==null?void 0:J.details;if(!this.levels||!G)throw new Error("frag load aborted, missing level"+(G?"":" detail")+"s");var K=null;if(Y.encrypted&&!((N=Y.decryptdata)!=null&&N.key)){if(this.log("Loading key for "+Y.sn+" of ["+G.startSN+"-"+G.endSN+"], "+this.playlistLabel()+" "+Y.level),this.state=k.KEY_LOADING,this.fragCurrent=Y,K=this.keyLoader.load(Y).then(function(O){if(!W.fragContextChanged(O.frag)){if(W.hls.trigger($.KEY_LOADED,O),W.state===k.KEY_LOADING)W.state=k.IDLE;return O}}),this.hls.trigger($.KEY_LOADING,{frag:Y}),this.fragCurrent===null)K=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING"))}else if(!Y.encrypted&&G.encryptedFragments.length)this.keyLoader.loadClear(Y,G.encryptedFragments);var j=this.fragPrevious;if(k0(Y)&&(!j||Y.sn!==j.sn)){var V=this.shouldLoadParts(J.details,Y.end);if(V!==this.loadingParts)this.log("LL-Part loading "+(V?"ON":"OFF")+" loading sn "+(j==null?void 0:j.sn)+"->"+Y.sn),this.loadingParts=V}if(X=Math.max(Y.start,X||0),this.loadingParts&&k0(Y)){var U=G.partList;if(U&&z){if(X>Y.end&&G.fragmentHint)Y=G.fragmentHint;var A=this.getNextPart(U,Y,X);if(A>-1){var E=U[A];Y=this.fragCurrent=E.fragment,this.log("Loading "+Y.type+" sn: "+Y.sn+" part: "+E.index+" ("+A+"/"+(U.length-1)+") of "+this.fragInfo(Y,!1,E)+") cc: "+Y.cc+" ["+G.startSN+"-"+G.endSN+"], target: "+parseFloat(X.toFixed(3))),this.nextLoadPosition=E.start+E.duration,this.state=k.FRAG_LOADING;var B;if(K)B=K.then(function(O){if(!O||W.fragContextChanged(O.frag))return null;return W.doFragPartsLoad(Y,E,J,z)}).catch(function(O){return W.handleFragLoadError(O)});else B=this.doFragPartsLoad(Y,E,J,z).catch(function(O){return W.handleFragLoadError(O)});if(this.hls.trigger($.FRAG_LOADING,{frag:Y,part:E,targetBufferTime:X}),this.fragCurrent===null)return Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts"));return B}else if(!Y.url||this.loadedEndOfParts(U,X))return Promise.resolve(null)}}if(k0(Y)&&this.loadingParts)this.log("LL-Part loading OFF after next part miss @"+X.toFixed(2)),this.loadingParts=!1;else if(!Y.url)return Promise.resolve(null);if(this.log("Loading "+Y.type+" sn: "+Y.sn+" of "+this.fragInfo(Y,!1)+") cc: "+Y.cc+" "+(G?"["+G.startSN+"-"+G.endSN+"]":"")+", target: "+parseFloat(X.toFixed(3))),v(Y.sn)&&!this.bitrateTest)this.nextLoadPosition=Y.start+Y.duration;this.state=k.FRAG_LOADING;var F=this.config.progressive,R;if(F&&K)R=K.then(function(O){if(!O||W.fragContextChanged(O==null?void 0:O.frag))return null;return W.fragmentLoader.load(Y,z)}).catch(function(O){return W.handleFragLoadError(O)});else R=Promise.all([this.fragmentLoader.load(Y,F?z:void 0),K]).then(function(O){var M=O[0];if(!F&&M&&z)z(M);return M}).catch(function(O){return W.handleFragLoadError(O)});if(this.hls.trigger($.FRAG_LOADING,{frag:Y,targetBufferTime:X}),this.fragCurrent===null)return Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING"));return R},Z.doFragPartsLoad=function Q(Y,J,X,z){var N=this;return new Promise(function(W,G){var K,j=[],V=(K=X.details)==null?void 0:K.partList,U=function A(E){N.fragmentLoader.loadPart(Y,E,z).then(function(B){j[E.index]=B;var F=B.part;N.hls.trigger($.FRAG_LOADED,B);var R=xQ(X.details,Y.sn,E.index+1)||TQ(V,Y.sn,E.index+1);if(R)U(R);else return W({frag:Y,part:F,partsLoaded:j})}).catch(G)};U(J)})},Z.handleFragLoadError=function Q(Y){if("data"in Y){var J=Y.data;if(Y.data&&J.details===D.INTERNAL_ABORTED)this.handleFragLoadAborted(J.frag,J.part);else this.hls.trigger($.ERROR,J)}else this.hls.trigger($.ERROR,{type:f.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,err:Y,error:Y,fatal:!0});return null},Z._handleTransmuxerFlush=function Q(Y){var J=this.getCurrentContext(Y);if(!J||this.state!==k.PARSING){if(!this.fragCurrent&&this.state!==k.STOPPED&&this.state!==k.ERROR)this.state=k.IDLE;return}var{frag:X,part:z,level:N}=J,W=self.performance.now();if(X.stats.parsing.end=W,z)z.stats.parsing.end=W;var G=this.getLevelDetails(),K=G&&X.sn>G.endSN,j=K||this.shouldLoadParts(G,X.end);if(j!==this.loadingParts)this.log("LL-Part loading "+(j?"ON":"OFF")+" after parsing segment ending @"+X.end.toFixed(2)),this.loadingParts=j;this.updateLevelTiming(X,z,N,Y.partial)},Z.shouldLoadParts=function Q(Y,J){if(this.config.lowLatencyMode){if(!Y)return this.loadingParts;if(Y!=null&&Y.partList){var X,z=Y.partList[0],N=z.end+(((X=Y.fragmentHint)==null?void 0:X.duration)||0);if(J>=N){var W,G=this.hls.hasEnoughToStart?((W=this.media)==null?void 0:W.currentTime)||this.lastCurrentTime:this.getLoadPosition();if(G>z.start-z.fragment.duration)return!0}}}return!1},Z.getCurrentContext=function Q(Y){var J=this.levels,X=this.fragCurrent,z=Y.level,N=Y.sn,W=Y.part;if(!(J!=null&&J[z]))return this.warn("Levels object was unset while buffering fragment "+N+" of "+this.playlistLabel()+" "+z+". The current chunk will not be buffered."),null;var G=J[z],K=G.details,j=W>-1?xQ(K,N,W):null,V=j?j.fragment:YZ(K,N,X);if(!V)return null;if(X&&X!==V)V.stats=X.stats;return{frag:V,part:j,level:G}},Z.bufferFragmentData=function Q(Y,J,X,z,N){var W;if(!Y||this.state!==k.PARSING)return;var{data1:G,data2:K}=Y,j=G;if(G&&K)j=D0(G,K);if(!((W=j)!=null&&W.length))return;var V={type:Y.type,frag:J,part:X,chunkMeta:z,parent:J.type,data:j};if(this.hls.trigger($.BUFFER_APPENDING,V),Y.dropped&&Y.independent&&!X){if(N)return;this.flushBufferGap(J)}},Z.flushBufferGap=function Q(Y){var J=this.media;if(!J)return;if(!i.isBuffered(J,J.currentTime)){this.flushMainBuffer(0,Y.start);return}var X=J.currentTime,z=i.bufferInfo(J,X,0),N=Y.duration,W=Math.min(this.config.maxFragLookUpTolerance*2,N*0.25),G=Math.max(Math.min(Y.start-W,z.end-W),X+W);if(Y.start-G>W)this.flushMainBuffer(G,Y.start)},Z.getFwdBufferInfo=function Q(Y,J){var X,z=this.getLoadPosition();if(!v(z))return null;var N=this.lastCurrentTime>z,W=N||(X=this.media)!=null&&X.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(Y,z,J,W)},Z.getFwdBufferInfoAtPos=function Q(Y,J,X,z){var N=i.bufferInfo(Y,J,z);if(N.len===0&&N.nextStart!==void 0){var W=this.fragmentTracker.getBufferedFrag(J,X);if(W&&(N.nextStart<=W.end||W.gap)){var G=Math.max(Math.min(N.nextStart,W.end)-J,z);return i.bufferInfo(Y,J,G)}}return N},Z.getMaxBufferLength=function Q(Y){var J=this.config,X;if(Y)X=Math.max(8*J.maxBufferSize/Y,J.maxBufferLength);else X=J.maxBufferLength;return Math.min(X,J.maxMaxBufferLength)},Z.reduceMaxBufferLength=function Q(Y,J){var X=this.config,z=Math.max(Math.min(Y-J,X.maxBufferLength),J),N=Math.max(Y-J*3,X.maxMaxBufferLength/2,z);if(N>=z)return X.maxMaxBufferLength=N,this.warn("Reduce max buffer length to "+N+"s"),!0;return!1},Z.getAppendedFrag=function Q(Y,J){var X;if(J===void 0)J=d.MAIN;var z=(X=this.fragmentTracker)==null?void 0:X.getAppendedFrag(Y,J);if(z&&"fragment"in z)return z.fragment;return z},Z.getNextFragment=function Q(Y,J){var X=J.fragments,z=X.length;if(!z)return null;var N=this.config,W=X[0].start,G=N.lowLatencyMode&&!!J.partList,K=null;if(J.live){var j=N.initialLiveManifestSize;if(z<j)return this.warn("Not enough fragments to start playback (have: "+z+", need: "+j+")"),null;if(!J.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||Y<W){var V;if(G&&!this.loadingParts)this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0;K=this.getInitialLiveFragment(J,X);var U=this.hls.startPosition,A=this.hls.liveSyncPosition,E=K?(U!==-1&&U>=W?U:A)||K.start:Y;this.log("Setting startPosition to "+E+" to match start frag at live edge. mainStart: "+U+" liveSyncPosition: "+A+" frag.start: "+((V=K)==null?void 0:V.start)),this.startPosition=this.nextLoadPosition=E}}else if(Y<=W)K=X[0];if(!K){var B=this.loadingParts?J.partEnd:J.fragmentEnd;K=this.getFragmentAtPosition(Y,B,J)}var F=this.filterReplacedPrimary(K,J);if(!F&&K){var R=K.sn-J.startSN;F=this.filterReplacedPrimary(X[R+1]||null,J)}return this.mapToInitFragWhenRequired(F)},Z.isLoopLoading=function Q(Y,J){var X=this.fragmentTracker.getState(Y);return(X===O0.OK||X===O0.PARTIAL&&!!Y.gap)&&this.nextLoadPosition>J},Z.getNextFragmentLoopLoading=function Q(Y,J,X,z,N){var W=null;if(Y.gap){if(W=this.getNextFragment(this.nextLoadPosition,J),W&&!W.gap&&X.nextStart){var G=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,X.nextStart,z,0);if(G!==null&&X.len+G.len>=N){var K=W.sn;if(this.loopSn!==K)this.log('buffer full after gaps in "'+z+'" playlist starting at sn: '+K),this.loopSn=K;return null}}}return this.loopSn=void 0,W},Z.filterReplacedPrimary=function Q(Y,J){if(!Y)return Y;if(UJ(this.hls.config));return Y},Z.mapToInitFragWhenRequired=function Q(Y){if(Y!=null&&Y.initSegment&&!(Y!=null&&Y.initSegment.data)&&!this.bitrateTest)return Y.initSegment;return Y},Z.getNextPart=function Q(Y,J,X){var z=-1,N=!1,W=!0;for(var G=0,K=Y.length;G<K;G++){var j=Y[G];if(W=W&&!j.independent,z>-1&&X<j.start)break;var V=j.loaded;if(V)z=-1;else if((N||j.independent||W)&&j.fragment===J)z=G;N=V}return z},Z.loadedEndOfParts=function Q(Y,J){var X=Y[Y.length-1];return X&&J>X.start&&X.loaded},Z.getInitialLiveFragment=function Q(Y,J){var X=this.fragPrevious,z=null;if(X){if(Y.hasProgramDateTime)this.log("Live playlist, switching playlist, load frag with same PDT: "+X.programDateTime),z=C8(J,X.endProgramDateTime,this.config.maxFragLookUpTolerance);if(!z){var N=X.sn+1;if(N>=Y.startSN&&N<=Y.endSN){var W=J[N-Y.startSN];if(X.cc===W.cc)z=W,this.log("Live playlist, switching playlist, load frag with next SN: "+z.sn)}if(!z){if(z=S8(J,X.cc),z)this.log("Live playlist, switching playlist, load frag with same CC: "+z.sn)}}}else{var G=this.hls.liveSyncPosition;if(G!==null)z=this.getFragmentAtPosition(G,this.bitrateTest?Y.fragmentEnd:Y.edge,Y)}return z},Z.getFragmentAtPosition=function Q(Y,J,X){var z=this.config,N=this.fragPrevious,W=X.fragments,G=X.endSN,K=X.fragmentHint,j=z.maxFragLookUpTolerance,V=X.partList,U=!!(this.loadingParts&&V!=null&&V.length&&K);if(U&&K&&!this.bitrateTest&&V[V.length-1].fragment.sn===K.sn)W=W.concat(K),G=K.sn;var A;if(Y<J){var E,B=Y<this.lastCurrentTime,F=B||Y>J-j||(E=this.media)!=null&&E.paused||!this.startFragRequested?0:j;A=eY(N,W,Y,F)}else A=W[W.length-1];if(A){var R=A.sn-X.startSN,O=this.fragmentTracker.getState(A);if(O===O0.OK||O===O0.PARTIAL&&A.gap)N=A;if(N&&A.sn===N.sn&&(!U||V[0].fragment.sn>A.sn||!X.live&&!U)){var M=N&&A.level===N.level;if(M){var L=W[R+1];if(A.sn<G&&this.fragmentTracker.getState(L)!==O0.OK)A=L;else A=null}}}return A},Z.alignPlaylists=function Q(Y,J,X){var z=Y.fragments.length;if(!z)return this.warn("No fragments in live playlist"),0;var N=Y.fragmentStart,W=!J,G=Y.alignedSliding&&v(N);if(W||!G&&!N){R9(X,Y);var K=Y.fragmentStart;return this.log("Live playlist sliding: "+K.toFixed(2)+" start-sn: "+(J?J.startSN:"na")+"->"+Y.startSN+" fragments: "+z),K}return N},Z.waitForCdnTuneIn=function Q(Y){var J=3;return Y.live&&Y.canBlockReload&&Y.partTarget&&Y.tuneInGoal>Math.max(Y.partHoldBack,Y.partTarget*J)},Z.setStartPosition=function Q(Y,J){var X=this.startPosition;if(X<J)X=-1;var z=this.timelineOffset;if(X===-1){var N=this.startTimeOffset!==null,W=N?this.startTimeOffset:Y.startTimeOffset;if(W!==null&&v(W)){if(X=J+W,W<0)X+=Y.edge;X=Math.min(Math.max(J,X),J+Y.totalduration),this.log("Setting startPosition to "+X+" for start time offset "+W+" found in "+(N?"multivariant":"media")+" playlist"),this.startPosition=X}else if(Y.live)X=this.hls.liveSyncPosition||J,this.log("Setting startPosition to -1 to start at live edge "+X),this.startPosition=-1;else this.log("setting startPosition to 0 by default"),this.startPosition=X=0;this.lastCurrentTime=X+z}this.nextLoadPosition=X+z},Z.getLoadPosition=function Q(){var Y,J=this.media,X=0;if((Y=this.hls)!=null&&Y.hasEnoughToStart&&J)X=J.currentTime;else if(this.nextLoadPosition>=0)X=this.nextLoadPosition;return X},Z.handleFragLoadAborted=function Q(Y,J){if(this.transmuxer&&Y.type===this.playlistType&&k0(Y)&&Y.stats.aborted)this.warn("Fragment "+Y.sn+(J?" part "+J.index:"")+" of "+this.playlistLabel()+" "+Y.level+" was aborted"),this.resetFragmentLoading(Y)},Z.resetFragmentLoading=function Q(Y){if(!this.fragCurrent||!this.fragContextChanged(Y)&&this.state!==k.FRAG_LOADING_WAITING_RETRY)this.state=k.IDLE},Z.onFragmentOrKeyLoadError=function Q(Y,J){if(J.chunkMeta&&!J.frag){var X=this.getCurrentContext(J.chunkMeta);if(X)J.frag=X.frag}var z=J.frag;if(!z||z.type!==Y||!this.levels)return;if(this.fragContextChanged(z)){var N;this.warn("Frag load error must match current frag to retry "+z.url+" > "+((N=this.fragCurrent)==null?void 0:N.url));return}var W=J.details===D.FRAG_GAP;if(W)this.fragmentTracker.fragBuffered(z,!0);var G=J.errorAction,K=G||{},j=K.action,V=K.flags,U=K.retryCount,A=U===void 0?0:U,E=K.retryConfig,B=!!G&&!!E,F=B&&j===A0.RetryRequest,R=B&&!G.resolved&&V===S0.MoveAllAlternatesMatchingHost;if(!F&&R&&k0(z)&&!z.endList)this.resetFragmentErrors(Y),this.treatAsGap(z),G.resolved=!0;else if((F||R)&&A<E.maxNumRetry){this.resetStartWhenNotLoaded(this.levelLastLoaded);var O=Y7(E,A);this.warn("Fragment "+z.sn+" of "+Y+" "+z.level+" errored with "+J.details+", retrying loading "+(A+1)+"/"+E.maxNumRetry+" in "+O+"ms"),G.resolved=!0,this.retryDate=self.performance.now()+O,this.state=k.FRAG_LOADING_WAITING_RETRY}else if(E&&G)if(this.resetFragmentErrors(Y),A<E.maxNumRetry){if(!W&&j!==A0.RemoveAlternatePermanently)G.resolved=!0}else{this.warn(J.details+" reached or exceeded max retry ("+A+")");return}else if(j===A0.SendAlternateToPenaltyBox)this.state=k.WAITING_LEVEL;else this.state=k.ERROR;this.tickImmediate()},Z.reduceLengthAndFlushBuffer=function Q(Y){if(this.state===k.PARSING||this.state===k.PARSED){var{frag:J,parent:X}=Y,z=this.getFwdBufferInfo(this.mediaBuffer,X),N=z&&z.len>0.5;if(N)this.reduceMaxBufferLength(z.len,(J==null?void 0:J.duration)||10);var W=!N;if(W)this.warn("Buffer full error while media.currentTime is not buffered, flush "+X+" buffer");if(J)this.fragmentTracker.removeFragment(J),this.nextLoadPosition=J.start;return this.resetLoadingState(),W}return!1},Z.resetFragmentErrors=function Q(Y){if(Y===d.AUDIO)this.fragCurrent=null;if(!this.hls.hasEnoughToStart)this.startFragRequested=!1;if(this.state!==k.STOPPED)this.state=k.IDLE},Z.afterBufferFlushed=function Q(Y,J,X){if(!Y)return;var z=i.getBuffered(Y);if(this.fragmentTracker.detectEvictedFragments(J,z,X),this.state===k.ENDED)this.resetLoadingState()},Z.resetLoadingState=function Q(){if(this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==k.STOPPED)this.state=k.IDLE},Z.resetStartWhenNotLoaded=function Q(Y){if(!this.hls.hasEnoughToStart){this.startFragRequested=!1;var J=Y?Y.details:null;if(J!=null&&J.live)this.log("resetting startPosition for live start"),this.startPosition=-1,this.setStartPosition(J,J.fragmentStart),this.resetLoadingState();else this.nextLoadPosition=this.startPosition}},Z.resetWhenMissingContext=function Q(Y){this.warn("The loading context changed while buffering fragment "+Y.sn+" of "+this.playlistLabel()+" "+Y.level+". This chunk will not be buffered."),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()},Z.removeUnbufferedFrags=function Q(Y){if(Y===void 0)Y=0;this.fragmentTracker.removeFragmentsInRange(Y,1/0,this.playlistType,!1,!0)},Z.updateLevelTiming=function Q(Y,J,X,z){var N=this,W=X.details;if(!W){this.warn("level.details undefined");return}var G=Object.keys(Y.elementaryStreams).reduce(function(V,U){var A=Y.elementaryStreams[U];if(A){var E=A.endPTS-A.startPTS;if(E<=0)return N.warn("Could not parse fragment "+Y.sn+" "+U+" duration reliably ("+E+")"),V||!1;var B=z?0:CQ(W,Y,A.startPTS,A.endPTS,A.startDTS,A.endDTS);return N.hls.trigger($.LEVEL_PTS_UPDATED,{details:W,level:X,drift:B,type:U,frag:Y,start:A.startPTS,end:A.endPTS}),!0}return V},!1);if(!G){var K;if(X.fragmentError===0)this.treatAsGap(Y,X);if(((K=this.transmuxer)==null?void 0:K.error)===null){var j=new Error("Found no media in fragment "+Y.sn+" of "+this.playlistLabel()+" "+Y.level+" resetting transmuxer to fallback to playlist timing");if(this.warn(j.message),this.hls.trigger($.ERROR,{type:f.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,error:j,frag:Y,reason:"Found no media in msn "+Y.sn+" of "+this.playlistLabel()+' "'+X.url+'"'}),!this.hls)return;this.resetTransmuxer()}}this.state=k.PARSED,this.log("Parsed "+Y.type+" sn: "+Y.sn+(J?" part: "+J.index:"")+" of "+this.fragInfo(Y,!1,J)+")"),this.hls.trigger($.FRAG_PARSED,{frag:Y,part:J})},Z.playlistLabel=function Q(){return this.playlistType===d.MAIN?"level":"track"},Z.fragInfo=function Q(Y,J,X){var z,N;if(J===void 0)J=!0;return this.playlistLabel()+" "+Y.level+" ("+(X?"part":"frag")+":["+((z=J&&!X?Y.startPTS:(X||Y).start)!=null?z:NaN).toFixed(3)+"-"+((N=J&&!X?Y.endPTS:(X||Y).end)!=null?N:NaN).toFixed(3)+"]"+(X&&Y.type==="main"?"INDEPENDENT="+(X.independent?"YES":"NO"):"")},Z.treatAsGap=function Q(Y,J){if(J)J.fragmentError++;Y.gap=!0,this.fragmentTracker.removeFragment(Y),this.fragmentTracker.fragBuffered(Y,!0)},Z.resetTransmuxer=function Q(){var Y;(Y=this.transmuxer)==null||Y.reset()},Z.recoverWorkerError=function Q(Y){if(Y.event==="demuxerWorker"){if(this.fragmentTracker.removeAllFragments(),this.transmuxer)this.transmuxer.destroy(),this.transmuxer=null;this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()}},Z0(H,[{key:"startPositionValue",get:function Q(){var Y=this.nextLoadPosition,J=this.startPosition;if(J===-1&&Y)return Y;return J}},{key:"bufferingEnabled",get:function Q(){return this.buffering}},{key:"inFlightFrag",get:function Q(){return{frag:this.fragCurrent,state:this.state}}},{key:"timelineOffset",get:function Q(){var Y=this.config.timelineOffset;if(Y){var J;return((J=this.getLevelDetails())==null?void 0:J.appliedTimelineOffset)||Y}return 0}},{key:"primaryPrefetch",get:function Q(){if(UJ(this.hls.config));return!1}},{key:"state",get:function Q(){return this._state},set:function Q(Y){var J=this._state;if(J!==Y)this._state=Y,this.log(J+"->"+Y)}}])}(WJ);function UJ(q){return!1}function GY(q,H,Z){YY(q,H,Z),q.addEventListener(H,Z)}function YY(q,H,Z){q.removeEventListener(H,Z)}var TY=2,b9=0.1,C9=0.05,P9=100,D9=function(q){function H(Q,Y){var J=q.call(this,"gap-controller",Q.logger)||this;return J.hls=null,J.fragmentTracker=null,J.media=null,J.mediaSource=void 0,J.nudgeRetry=0,J.stallReported=!1,J.stalled=null,J.moved=!1,J.seeking=!1,J.buffered={},J.lastCurrentTime=0,J.ended=0,J.waiting=0,J.onMediaPlaying=function(){J.ended=0,J.waiting=0},J.onMediaWaiting=function(){var X;if((X=J.media)!=null&&X.seeking)return;J.waiting=self.performance.now(),J.tick()},J.onMediaEnded=function(){if(J.hls){var X;J.ended=((X=J.media)==null?void 0:X.currentTime)||1,J.hls.trigger($.MEDIA_ENDED,{stalled:!1})}},J.hls=Q,J.fragmentTracker=Y,J.registerListeners(),J}G0(H,q);var Z=H.prototype;return Z.registerListeners=function Q(){var Y=this.hls;if(Y)Y.on($.MEDIA_ATTACHED,this.onMediaAttached,this),Y.on($.MEDIA_DETACHING,this.onMediaDetaching,this),Y.on($.BUFFER_APPENDED,this.onBufferAppended,this)},Z.unregisterListeners=function Q(){var Y=this.hls;if(Y)Y.off($.MEDIA_ATTACHED,this.onMediaAttached,this),Y.off($.MEDIA_DETACHING,this.onMediaDetaching,this),Y.off($.BUFFER_APPENDED,this.onBufferAppended,this)},Z.destroy=function Q(){q.prototype.destroy.call(this),this.unregisterListeners(),this.media=this.hls=this.fragmentTracker=null,this.mediaSource=void 0},Z.onMediaAttached=function Q(Y,J){this.setInterval(P9),this.mediaSource=J.mediaSource;var X=this.media=J.media;GY(X,"playing",this.onMediaPlaying),GY(X,"waiting",this.onMediaWaiting),GY(X,"ended",this.onMediaEnded)},Z.onMediaDetaching=function Q(Y,J){this.clearInterval();var X=this.media;if(X)YY(X,"playing",this.onMediaPlaying),YY(X,"waiting",this.onMediaWaiting),YY(X,"ended",this.onMediaEnded),this.media=null;this.mediaSource=void 0},Z.onBufferAppended=function Q(Y,J){this.buffered=J.timeRanges},Z.tick=function Q(){var Y;if(!((Y=this.media)!=null&&Y.readyState)||!this.hasBuffered)return;var J=this.media.currentTime;this.poll(J,this.lastCurrentTime),this.lastCurrentTime=J},Z.poll=function Q(Y,J){var X,z,N=(X=this.hls)==null?void 0:X.config;if(!N)return;var W=this.media,G=this.stalled;if(!W)return;var K=W.seeking,j=this.seeking&&!K,V=!this.seeking&&K,U=W.paused&&!K||W.ended||W.playbackRate===0;if(this.seeking=K,Y!==J){if(J)this.ended=0;if(this.moved=!0,!K){if(this.nudgeRetry=0,N.nudgeOnVideoHole&&!U&&Y>J)this.nudgeOnVideoHole(Y,J)}if(this.waiting===0)this.stallResolved(Y);return}if(V||j){if(j)this.stallResolved(Y);return}if(U){if(this.nudgeRetry=0,this.stallResolved(Y),!this.ended&&W.ended&&this.hls)this.ended=Y||1,this.hls.trigger($.MEDIA_ENDED,{stalled:!1});return}if(!i.getBuffered(W).length){this.nudgeRetry=0;return}var A=i.bufferInfo(W,Y,0),E=A.nextStart||0,B=this.fragmentTracker;if(K&&B&&this.hls){var F=VJ(this.hls.inFlightFragments,Y),R=A.len>TY,O=!E||F||E-Y>TY&&!B.getPartialFragment(Y);if(R||O)return;this.moved=!1}var M=(z=this.hls)==null?void 0:z.latestLevelDetails;if(!this.moved&&this.stalled!==null&&B){var L=A.len>0;if(!L&&!E)return;var I=Math.max(E,A.start||0)-Y,w=!!(M!=null&&M.live),S=w?M.targetduration*2:TY,P=B.getPartialFragment(Y);if(I>0&&(I<=S||P)){if(!W.paused)this._trySkipBufferHole(P);return}}var b=N.detectStallWithCurrentTimeMs,C=self.performance.now(),x=this.waiting;if(G===null){if(x>0&&C-x<b)this.stalled=x;else this.stalled=C;return}var _=C-G;if(!K&&(_>=b||x)&&this.hls){var y;if(((y=this.mediaSource)==null?void 0:y.readyState)==="ended"&&!(M!=null&&M.live)&&Math.abs(Y-((M==null?void 0:M.edge)||0))<1){if(this.ended)return;this.ended=Y||1,this.hls.trigger($.MEDIA_ENDED,{stalled:!0});return}if(this._reportStall(A),!this.media||!this.hls)return}var T=i.bufferInfo(W,Y,N.maxBufferHole);this._tryFixBufferStall(T,_)},Z.stallResolved=function Q(Y){var J=this.stalled;if(J&&this.hls){if(this.stalled=null,this.stallReported){var X=self.performance.now()-J;this.log("playback not stuck anymore @"+Y+", after "+Math.round(X)+"ms"),this.stallReported=!1,this.waiting=0,this.hls.trigger($.STALL_RESOLVED,{})}}},Z.nudgeOnVideoHole=function Q(Y,J){var X,z=this.buffered.video;if(this.hls&&this.media&&this.fragmentTracker&&(X=this.buffered.audio)!=null&&X.length&&z&&z.length>1&&Y>z.end(0)){var N=i.bufferedInfo(i.timeRangesToArray(this.buffered.audio),Y,0);if(N.len>1&&J>=N.start){var W=i.timeRangesToArray(z),G=i.bufferedInfo(W,J,0).bufferedIndex;if(G>-1&&G<W.length-1){var K=i.bufferedInfo(W,Y,0).bufferedIndex,j=W[G].end,V=W[G+1].start;if((K===-1||K>G)&&V-j<1&&Y-j<2){var U=new Error("nudging playhead to flush pipeline after video hole. currentTime: "+Y+" hole: "+j+" -> "+V+" buffered index: "+K);this.warn(U.message),this.media.currentTime+=0.000001;var A=this.fragmentTracker.getPartialFragment(Y)||void 0,E=i.bufferInfo(this.media,Y,0);this.hls.trigger($.ERROR,{type:f.MEDIA_ERROR,details:D.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:U,reason:U.message,frag:A,buffer:E.len,bufferInfo:E})}}}}},Z._tryFixBufferStall=function Q(Y,J){var X,z,N=this.fragmentTracker,W=this.media,G=(X=this.hls)==null?void 0:X.config;if(!W||!N||!G)return;var K=W.currentTime,j=(z=this.hls)==null?void 0:z.latestLevelDetails,V=N.getPartialFragment(K);if(V||j!=null&&j.live&&K<j.fragmentStart){var U=this._trySkipBufferHole(V);if(U||!this.media)return}var A=Y.buffered;if((A&&A.length>1&&Y.len>G.maxBufferHole||Y.nextStart&&Y.nextStart-K<G.maxBufferHole)&&(J>G.highBufferWatchdogPeriod*1000||this.waiting))this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(Y)},Z._reportStall=function Q(Y){var J=this.hls,X=this.media,z=this.stallReported,N=this.stalled;if(!z&&N!==null&&X&&J){this.stallReported=!0;var W=new Error("Playback stalling at @"+X.currentTime+" due to low buffer ("+$0(Y)+")");this.warn(W.message),J.trigger($.ERROR,{type:f.MEDIA_ERROR,details:D.BUFFER_STALLED_ERROR,fatal:!1,error:W,buffer:Y.len,bufferInfo:Y,stalled:{start:N}})}},Z._trySkipBufferHole=function Q(Y){var J,X=this.fragmentTracker,z=this.media,N=(J=this.hls)==null?void 0:J.config;if(!z||!X||!N)return 0;var W=z.currentTime,G=i.bufferInfo(z,W,0),K=W<G.start?G.start:G.nextStart;if(K&&this.hls){var j=G.len<=N.maxBufferHole,V=G.len>0&&G.len<1&&z.readyState<3,U=K-W;if(U>0&&(j||V)){if(U>N.maxBufferHole){var A=!1;if(W===0){var E=X.getAppendedFrag(0,d.MAIN);if(E&&K<E.end)A=!0}if(!A){var B=Y||X.getAppendedFrag(W,d.MAIN);if(B){var F;if(!((F=this.hls.loadLevelObj)!=null&&F.details))return 0;var R=VJ(this.hls.inFlightFragments,K);if(R)return 0;var O=!1,M=B.end;while(M<K){var L=X.getPartialFragment(M);if(L)M+=L.duration;else{O=!0;break}}if(O)return 0}}}var I=Math.max(K+C9,W+b9);if(this.warn("skipping hole, adjusting currentTime from "+W+" to "+I),this.moved=!0,z.currentTime=I,!(Y!=null&&Y.gap)){var w=new Error("fragment loaded with buffer holes, seeking from "+W+" to "+I);this.hls.trigger($.ERROR,{type:f.MEDIA_ERROR,details:D.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:w,reason:w.message,frag:Y||void 0,buffer:G.len,bufferInfo:G})}return I}}return 0},Z._tryNudgeBuffer=function Q(Y){var J=this.hls,X=this.media,z=this.nudgeRetry,N=J==null?void 0:J.config;if(!X||!N)return 0;var W=X.currentTime;if(this.nudgeRetry++,z<N.nudgeMaxRetry){var G=W+(z+1)*N.nudgeOffset,K=new Error("Nudging 'currentTime' from "+W+" to "+G);this.warn(K.message),X.currentTime=G,J.trigger($.ERROR,{type:f.MEDIA_ERROR,details:D.BUFFER_NUDGE_ON_STALL,error:K,fatal:!1,buffer:Y.len,bufferInfo:Y})}else{var j=new Error("Playhead still not moving while enough data buffered @"+W+" after "+N.nudgeMaxRetry+" nudges");this.error(j.message),J.trigger($.ERROR,{type:f.MEDIA_ERROR,details:D.BUFFER_STALLED_ERROR,error:j,fatal:!0,buffer:Y.len,bufferInfo:Y})}},Z0(H,[{key:"hasBuffered",get:function Q(){return Object.keys(this.buffered).length>0}}])}(WJ);function VJ(q,H){var Z=AJ(q.main);if(Z&&Z.start<=H)return Z;var Q=AJ(q.audio);if(Q&&Q.start<=H)return Q;return null}function AJ(q){if(!q)return null;switch(q.state){case k.IDLE:case k.STOPPED:case k.ENDED:case k.ERROR:return null}return q.frag}function S9(q,H){var Z;try{Z=new Event("addtrack")}catch(Q){Z=document.createEvent("Event"),Z.initEvent("addtrack",!1,!1)}Z.track=q,H.dispatchEvent(Z)}function x9(q,H){var Z=q.mode;if(Z==="disabled")q.mode="hidden";if(q.cues)for(var Q=q.cues.length;Q--;){if(H)q.cues[Q].removeEventListener("enter",H);q.removeCue(q.cues[Q])}if(Z==="disabled")q.mode=Z}function T9(q,H,Z,Q){var Y=q.mode;if(Y==="disabled")q.mode="hidden";if(q.cues&&q.cues.length>0){var J=k9(q.cues,H,Z);for(var X=0;X<J.length;X++)if(!Q||Q(J[X]))q.removeCue(J[X])}if(Y==="disabled")q.mode=Y}function y9(q,H){if(H<=q[0].startTime)return 0;var Z=q.length-1;if(H>q[Z].endTime)return-1;var Q=0,Y=Z,J;while(Q<=Y)if(J=Math.floor((Y+Q)/2),H<q[J].startTime)Y=J-1;else if(H>q[J].startTime&&Q<Z)Q=J+1;else return J;return q[Q].startTime-H<H-q[Y].startTime?Q:Y}function k9(q,H,Z){var Q=[],Y=y9(q,H);if(Y>-1)for(var J=Y,X=q.length;J<X;J++){var z=q[J];if(z.startTime>=H&&z.endTime<=Z)Q.push(z);else if(z.startTime>Z)return Q}return Q}var _9=0.25;function $7(){if(typeof self==="undefined")return;return self.VTTCue||self.TextTrackCue}function EJ(q,H,Z,Q,Y){var J=new q(H,Z,"");try{if(J.value=Q,Y)J.type=Y}catch(X){J=new q(H,Z,$0(Y?F0({type:Y},Q):Q))}return J}var yY=function(){var q=$7();try{q&&new q(0,Number.POSITIVE_INFINITY,"")}catch(H){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function h9(q){return Uint8Array.from(q.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var v9=function(){function q(Z){var Q=this;this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=!0,this.onEventCueEnter=function(){if(!Q.hls)return;Q.hls.trigger($.EVENT_CUE_ENTER,{})},this.hls=Z,this._registerListeners()}var H=q.prototype;return H.destroy=function Z(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null},H._registerListeners=function Z(){var Q=this.hls;Q.on($.MEDIA_ATTACHING,this.onMediaAttaching,this),Q.on($.MEDIA_ATTACHED,this.onMediaAttached,this),Q.on($.MEDIA_DETACHING,this.onMediaDetaching,this),Q.on($.MANIFEST_LOADING,this.onManifestLoading,this),Q.on($.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),Q.on($.BUFFER_FLUSHING,this.onBufferFlushing,this),Q.on($.LEVEL_UPDATED,this.onLevelUpdated,this),Q.on($.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this)},H._unregisterListeners=function Z(){var Q=this.hls;Q.off($.MEDIA_ATTACHING,this.onMediaAttaching,this),Q.off($.MEDIA_ATTACHED,this.onMediaAttached,this),Q.off($.MEDIA_DETACHING,this.onMediaDetaching,this),Q.off($.MANIFEST_LOADING,this.onManifestLoading,this),Q.off($.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),Q.off($.BUFFER_FLUSHING,this.onBufferFlushing,this),Q.off($.LEVEL_UPDATED,this.onLevelUpdated,this),Q.off($.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this)},H.onMediaAttaching=function Z(Q,Y){var J;if(this.media=Y.media,((J=Y.overrides)==null?void 0:J.cueRemoval)===!1)this.removeCues=!1},H.onMediaAttached=function Z(){var Q=this.hls.latestLevelDetails;if(Q)this.updateDateRangeCues(Q)},H.onMediaDetaching=function Z(Q,Y){this.media=null;var J=!!Y.transferMedia;if(J)return;if(this.id3Track){if(this.removeCues)x9(this.id3Track,this.onEventCueEnter);this.id3Track=null}this.dateRangeCuesAppended={}},H.onManifestLoading=function Z(){this.dateRangeCuesAppended={}},H.createTrack=function Z(Q){var Y=this.getID3Track(Q.textTracks);return Y.mode="hidden",Y},H.getID3Track=function Z(Q){if(!this.media)return;for(var Y=0;Y<Q.length;Y++){var J=Q[Y];if(J.kind==="metadata"&&J.label==="id3")return S9(J,this.media),J}return this.media.addTextTrack("metadata","id3")},H.onFragParsingMetadata=function Z(Q,Y){if(!this.media)return;var J=this.hls.config,X=J.enableEmsgMetadataCues,z=J.enableID3MetadataCues;if(!X&&!z)return;var N=Y.samples;if(!this.id3Track)this.id3Track=this.createTrack(this.media);var W=$7();if(!W)return;for(var G=0;G<N.length;G++){var K=N[G].type;if(K===L0.emsg&&!X||!z)continue;var j=cQ(N[G].data);if(j){var V=N[G].pts,U=V+N[G].duration;if(U>yY)U=yY;var A=U-V;if(A<=0)U=V+_9;for(var E=0;E<j.length;E++){var B=j[E];if(!fQ(B)){this.updateId3CueEnds(V,K);var F=EJ(W,V,U,B,K);if(F)this.id3Track.addCue(F)}}}}},H.updateId3CueEnds=function Z(Q,Y){var J,X=(J=this.id3Track)==null?void 0:J.cues;if(X)for(var z=X.length;z--;){var N=X[z];if(N.type===Y&&N.startTime<Q&&N.endTime===yY)N.endTime=Q}},H.onBufferFlushing=function Z(Q,Y){var{startOffset:J,endOffset:X,type:z}=Y,N=this.id3Track,W=this.hls;if(!W)return;var G=W.config,K=G.enableEmsgMetadataCues,j=G.enableID3MetadataCues;if(N&&(K||j)){var V;if(z==="audio")V=function U(A){return A.type===L0.audioId3&&j};else if(z==="video")V=function U(A){return A.type===L0.emsg&&K};else V=function U(A){return A.type===L0.audioId3&&j||A.type===L0.emsg&&K};T9(N,J,X,V)}},H.onLevelUpdated=function Z(Q,Y){var J=Y.details;this.updateDateRangeCues(J,!0)},H.onLevelPtsUpdated=function Z(Q,Y){if(Math.abs(Y.drift)>0.01)this.updateDateRangeCues(Y.details)},H.updateDateRangeCues=function Z(Q,Y){var J=this;if(!this.media||!Q.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;var X=this.id3Track,z=Q.dateRanges,N=Object.keys(z),W=this.dateRangeCuesAppended;if(X&&Y){var G;if((G=X.cues)!=null&&G.length){var K=Object.keys(W).filter(function(F){return!N.includes(F)}),j=function F(){var R=K[V],O=W[R].cues;delete W[R],Object.keys(O).forEach(function(M){try{var L=O[M];L.removeEventListener("enter",J.onEventCueEnter),X.removeCue(L)}catch(I){}})};for(var V=K.length;V--;)j()}else W=this.dateRangeCuesAppended={}}var U=Q.fragments[Q.fragments.length-1];if(N.length===0||!v(U==null?void 0:U.programDateTime))return;if(!this.id3Track)this.id3Track=this.createTrack(this.media);var A=$7(),E=function F(){var R=N[B],O=z[R],M=O.startTime,L=W[R],I=(L==null?void 0:L.cues)||{},w=(L==null?void 0:L.durationKnown)||!1,S=yY,P=O.duration,b=O.endDate;if(b&&P!==null)S=M+P,w=!0;else if(O.endOnNext&&!w){var C=N.reduce(function(p,r){if(r!==O.id){var n=z[r];if(n.class===O.class&&n.startDate>O.startDate&&(!p||O.startDate<p.startDate))return n}return p},null);if(C)S=C.startTime,w=!0}var x=Object.keys(O.attr);for(var _=0;_<x.length;_++){var y=x[_];if(!m8(y))continue;var T=I[y];if(T){if(w&&!L.durationKnown)T.endTime=S;else if(Math.abs(T.startTime-M)>0.01)T.startTime=M,T.endTime=S}else if(A){var h=O.attr[y];if(p8(y))h=h9(h);var g={key:y,data:h},m=EJ(A,M,S,g,L0.dateRange);if(m)m.id=R,J.id3Track.addCue(m),I[y]=m}}W[R]={cues:I,dateRange:O,durationKnown:w}};for(var B=0;B<N.length;B++)E()},q}(),g9=function(){function q(Z){var Q=this;this.hls=void 0,this.config=void 0,this.media=null,this.currentTime=0,this.stallCount=0,this._latency=null,this._targetLatencyUpdated=!1,this.onTimeupdate=function(){var{media:Y,levelDetails:J}=Q;if(!Y||!J)return;Q.currentTime=Y.currentTime;var X=Q.computeLatency();if(X===null)return;Q._latency=X;var z=Q.config,N=z.lowLatencyMode,W=z.maxLiveSyncPlaybackRate;if(!N||W===1||!J.live)return;var G=Q.targetLatency;if(G===null)return;var K=X-G,j=Math.min(Q.maxLatency,G+J.targetduration),V=K<j;if(V&&K>0.05&&Q.forwardBufferLength>1){var U=Math.min(2,Math.max(1,W)),A=Math.round(2/(1+Math.exp(-0.75*K-Q.edgeStalled))*20)/20,E=Math.min(U,Math.max(1,A));Q.changeMediaPlaybackRate(Y,E)}else if(Y.playbackRate!==1&&Y.playbackRate!==0)Q.changeMediaPlaybackRate(Y,1)},this.hls=Z,this.config=Z.config,this.registerListeners()}var H=q.prototype;return H.destroy=function Z(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null},H.registerListeners=function Z(){var Q=this.hls;if(!Q)return;Q.on($.MEDIA_ATTACHED,this.onMediaAttached,this),Q.on($.MEDIA_DETACHING,this.onMediaDetaching,this),Q.on($.MANIFEST_LOADING,this.onManifestLoading,this),Q.on($.LEVEL_UPDATED,this.onLevelUpdated,this),Q.on($.ERROR,this.onError,this)},H.unregisterListeners=function Z(){var Q=this.hls;if(!Q)return;Q.off($.MEDIA_ATTACHED,this.onMediaAttached,this),Q.off($.MEDIA_DETACHING,this.onMediaDetaching,this),Q.off($.MANIFEST_LOADING,this.onManifestLoading,this),Q.off($.LEVEL_UPDATED,this.onLevelUpdated,this),Q.off($.ERROR,this.onError,this)},H.onMediaAttached=function Z(Q,Y){this.media=Y.media,this.media.addEventListener("timeupdate",this.onTimeupdate)},H.onMediaDetaching=function Z(){if(this.media)this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null},H.onManifestLoading=function Z(){this._latency=null,this.stallCount=0},H.onLevelUpdated=function Z(Q,Y){var J=Y.details;if(J.advanced)this.onTimeupdate();if(!J.live&&this.media)this.media.removeEventListener("timeupdate",this.onTimeupdate)},H.onError=function Z(Q,Y){var J;if(Y.details!==D.BUFFER_STALLED_ERROR)return;if(this.stallCount++,this.hls&&(J=this.levelDetails)!=null&&J.live)this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency")},H.changeMediaPlaybackRate=function Z(Q,Y){var J,X;if(Q.playbackRate===Y)return;(J=this.hls)==null||J.logger.debug("[latency-controller]: latency="+this.latency.toFixed(3)+", targetLatency="+((X=this.targetLatency)==null?void 0:X.toFixed(3))+", forwardBufferLength="+this.forwardBufferLength.toFixed(3)+": adjusting playback rate from "+Q.playbackRate+" to "+Y),Q.playbackRate=Y},H.estimateLiveEdge=function Z(){var Q=this.levelDetails;if(Q===null)return null;return Q.edge+Q.age},H.computeLatency=function Z(){var Q=this.estimateLiveEdge();if(Q===null)return null;return Q-this.currentTime},Z0(q,[{key:"levelDetails",get:function Z(){var Q;return((Q=this.hls)==null?void 0:Q.latestLevelDetails)||null}},{key:"latency",get:function Z(){return this._latency||0}},{key:"maxLatency",get:function Z(){var Q=this.config;if(Q.liveMaxLatencyDuration!==void 0)return Q.liveMaxLatencyDuration;var Y=this.levelDetails;return Y?Q.liveMaxLatencyDurationCount*Y.targetduration:0}},{key:"targetLatency",get:function Z(){var Q=this.levelDetails;if(Q===null||this.hls===null)return null;var{holdBack:Y,partHoldBack:J,targetduration:X}=Q,z=this.config,N=z.liveSyncDuration,W=z.liveSyncDurationCount,G=z.lowLatencyMode,K=this.hls.userConfig,j=G?J||Y:Y;if(this._targetLatencyUpdated||K.liveSyncDuration||K.liveSyncDurationCount||j===0)j=N!==void 0?N:W*X;var V=X;return j+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,V)},set:function Z(Q){this.stallCount=0,this.config.liveSyncDuration=Q,this._targetLatencyUpdated=!0}},{key:"liveSyncPosition",get:function Z(){var Q=this.estimateLiveEdge(),Y=this.targetLatency;if(Q===null||Y===null)return null;var J=this.levelDetails;if(J===null)return null;var X=J.edge,z=Q-Y-this.edgeStalled,N=X-J.totalduration,W=X-(this.config.lowLatencyMode&&J.partTarget||J.targetduration);return Math.min(Math.max(N,z),W)}},{key:"drift",get:function Z(){var Q=this.levelDetails;if(Q===null)return 1;return Q.drift}},{key:"edgeStalled",get:function Z(){var Q=this.levelDetails;if(Q===null)return 0;var Y=(this.config.lowLatencyMode&&Q.partTarget||Q.targetduration)*3;return Math.max(Q.age-Y,0)}},{key:"forwardBufferLength",get:function Z(){var Q=this.media,Y=this.levelDetails;if(!Q||!Y)return 0;var J=Q.buffered.length;return(J?Q.buffered.end(J-1):Y.edge)-this.currentTime}}])}(),m9=function(q){function H(Q,Y){var J=q.call(this,Y,Q.logger)||this;return J.hls=void 0,J.canLoad=!1,J.timer=-1,J.hls=Q,J}G0(H,q);var Z=H.prototype;return Z.destroy=function Q(){this.clearTimer(),this.hls=this.log=this.warn=null},Z.clearTimer=function Q(){if(this.timer!==-1)self.clearTimeout(this.timer),this.timer=-1},Z.startLoad=function Q(){this.canLoad=!0,this.loadPlaylist()},Z.stopLoad=function Q(){this.canLoad=!1,this.clearTimer()},Z.switchParams=function Q(Y,J,X){var z=J==null?void 0:J.renditionReports;if(z){var N=-1;for(var W=0;W<z.length;W++){var G=z[W],K=void 0;try{K=new self.URL(G.URI,J.url).href}catch(B){this.warn("Could not construct new URL for Rendition Report: "+B),K=G.URI||""}if(K===Y){N=W;break}else if(K===Y.substring(0,K.length))N=W}if(N!==-1){var j=z[N],V=parseInt(j["LAST-MSN"])||(J==null?void 0:J.lastPartSn),U=parseInt(j["LAST-PART"])||(J==null?void 0:J.lastPartIndex);if(this.hls.config.lowLatencyMode){var A=Math.min(J.age-J.partTarget,J.targetduration);if(U>=0&&A>J.partTarget)U+=1}var E=X&&YQ(X);return new QQ(V,U>=0?U:void 0,E)}}},Z.loadPlaylist=function Q(Y){this.clearTimer()},Z.loadingPlaylist=function Q(Y,J){this.clearTimer()},Z.shouldLoadPlaylist=function Q(Y){return this.canLoad&&!!Y&&!!Y.url&&(!Y.details||Y.details.live)},Z.getUrlWithDirectives=function Q(Y,J){if(J)try{return J.addDirectives(Y)}catch(X){this.warn("Could not construct new URL with HLS Delivery Directives: "+X)}return Y},Z.playlistLoaded=function Q(Y,J,X){var{details:z,stats:N}=J,W=self.performance.now(),G=N.loading.first?Math.max(0,W-N.loading.first):0;z.advancedDateTime=Date.now()-G;var K=this.hls.config.timelineOffset;if(K!==z.appliedTimelineOffset){var j=Math.max(K||0,0);z.appliedTimelineOffset=j,z.fragments.forEach(function(p){p.start=p.playlistOffset+j})}if(z.live||X!=null&&X.live){var V="levelInfo"in J?J.levelInfo:J.track;if(z.reloaded(X),X&&z.fragments.length>0){i8(X,z);var U=z.playlistParsingError;if(U){this.warn(U);var A=this.hls;if(!A.config.ignorePlaylistParsingErrors){var E,B=J.networkDetails;A.trigger($.ERROR,{type:f.NETWORK_ERROR,details:D.LEVEL_PARSING_ERROR,fatal:!1,url:z.url,error:U,reason:U.message,level:J.level||void 0,parent:(E=z.fragments[0])==null?void 0:E.type,networkDetails:B,stats:N});return}z.playlistParsingError=null}}if(z.requestScheduled===-1)z.requestScheduled=N.loading.start;var F=this.hls.mainForwardBufferInfo,R=F?F.end-F.len:0,O=(z.edge-R)*1000,M=SQ(z,O);if(z.requestScheduled+M<W)z.requestScheduled=W;else z.requestScheduled+=M;if(this.log("live playlist "+Y+" "+(z.advanced?"REFRESHED "+z.lastPartSn+"-"+z.lastPartIndex:z.updated?"UPDATED":"MISSED")),!this.canLoad||!z.live)return;var L,I=void 0,w=void 0;if(z.canBlockReload&&z.endSN&&z.advanced){var S=this.hls.config.lowLatencyMode,P=z.lastPartSn,b=z.endSN,C=z.lastPartIndex,x=C!==-1,_=P===b;if(x)if(_)I=b+1,w=S?0:C;else I=P,w=S?C+1:z.maxPartIndex;else I=b+1;var y=z.age,T=y+z.ageHeader,h=Math.min(T-z.partTarget,z.targetduration*1.5);if(h>0){if(T>z.targetduration*3)this.log("Playlist last advanced "+y.toFixed(2)+"s ago. Omitting segment and part directives."),I=void 0,w=void 0;else if(X!=null&&X.tuneInGoal&&T-z.partTarget>X.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+X.tuneInGoal+" to: "+h+" with playlist age: "+z.age),h=0;else{var g=Math.floor(h/z.targetduration);if(I+=g,w!==void 0){var m=Math.round(h%z.targetduration/z.partTarget);w+=m}this.log("CDN Tune-in age: "+z.ageHeader+"s last advanced "+y.toFixed(2)+"s goal: "+h+" skip sn "+g+" to part "+w)}z.tuneInGoal=h}if(L=this.getDeliveryDirectives(z,J.deliveryDirectives,I,w),S||!_){z.requestScheduled=W,this.loadingPlaylist(V,L);return}}else if(z.canBlockReload||z.canSkipUntil)L=this.getDeliveryDirectives(z,J.deliveryDirectives,I,w);if(L&&I!==void 0&&z.canBlockReload)z.requestScheduled=N.loading.first+Math.max(M-G*2,M/2);this.scheduleLoading(V,L,z)}else this.clearTimer()},Z.scheduleLoading=function Q(Y,J,X){var z=this,N=X||Y.details;if(!N){this.loadingPlaylist(Y,J);return}var W=self.performance.now(),G=N.requestScheduled;if(W>=G){this.loadingPlaylist(Y,J);return}var K=G-W;this.log("reload live playlist "+(Y.name||Y.bitrate+"bps")+" in "+Math.round(K)+" ms"),this.clearTimer(),this.timer=self.setTimeout(function(){return z.loadingPlaylist(Y,J)},K)},Z.getDeliveryDirectives=function Q(Y,J,X,z){var N=YQ(Y);if(J!=null&&J.skip&&Y.deltaUpdateFailed)X=J.msn,z=J.part,N=OY.No;return new QQ(X,z,N)},Z.checkRetry=function Q(Y){var J=this,X=Y.details,z=RY(Y),N=Y.errorAction,W=N||{},G=W.action,K=W.retryCount,j=K===void 0?0:K,V=W.retryConfig,U=!!N&&!!V&&(G===A0.RetryRequest||!N.resolved&&G===A0.SendAlternateToPenaltyBox);if(U){var A;if(j>=V.maxNumRetry)return!1;if(z&&(A=Y.context)!=null&&A.deliveryDirectives)this.warn("Retrying playlist loading "+(j+1)+"/"+V.maxNumRetry+' after "'+X+'" without delivery-directives'),this.loadPlaylist();else{var E=Y7(V,j);this.clearTimer(),this.timer=self.setTimeout(function(){return J.loadPlaylist()},E),this.warn("Retrying playlist loading "+(j+1)+"/"+V.maxNumRetry+' after "'+X+'" in '+E+"ms")}Y.levelRetry=!0,N.resolved=!0}return U},H}(i0),p9=function(q){function H(Q,Y){var J=q.call(this,Q,"level-controller")||this;return J._levels=[],J._firstLevel=-1,J._maxAutoLevel=-1,J._startLevel=void 0,J.currentLevel=null,J.currentLevelIndex=-1,J.manualLevelIndex=-1,J.steering=void 0,J.onParsedComplete=void 0,J.steering=Y,J._registerListeners(),J}G0(H,q);var Z=H.prototype;return Z._registerListeners=function Q(){var Y=this.hls;Y.on($.MANIFEST_LOADING,this.onManifestLoading,this),Y.on($.MANIFEST_LOADED,this.onManifestLoaded,this),Y.on($.LEVEL_LOADED,this.onLevelLoaded,this),Y.on($.LEVELS_UPDATED,this.onLevelsUpdated,this),Y.on($.FRAG_BUFFERED,this.onFragBuffered,this),Y.on($.ERROR,this.onError,this)},Z._unregisterListeners=function Q(){var Y=this.hls;Y.off($.MANIFEST_LOADING,this.onManifestLoading,this),Y.off($.MANIFEST_LOADED,this.onManifestLoaded,this),Y.off($.LEVEL_LOADED,this.onLevelLoaded,this),Y.off($.LEVELS_UPDATED,this.onLevelsUpdated,this),Y.off($.FRAG_BUFFERED,this.onFragBuffered,this),Y.off($.ERROR,this.onError,this)},Z.destroy=function Q(){this._unregisterListeners(),this.steering=null,this.resetLevels(),q.prototype.destroy.call(this)},Z.stopLoad=function Q(){var Y=this._levels;Y.forEach(function(J){J.loadError=0,J.fragmentError=0}),q.prototype.stopLoad.call(this)},Z.resetLevels=function Q(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1},Z.onManifestLoading=function Q(Y,J){this.resetLevels()},Z.onManifestLoaded=function Q(Y,J){var X=this,z=this.hls.config.preferManagedMediaSource,N=[],W={},G={},K=!1,j=!1,V=!1;J.levels.forEach(function(U){var A,E=U.attrs,B=U.audioCodec,F=U.videoCodec;if(B)U.audioCodec=B=BY(B,z)||void 0;if(((A=F)==null?void 0:A.indexOf("avc1"))===0)F=U.videoCodec=E8(F);var{width:R,height:O,unknownCodecs:M}=U,L=M?M.length:0;if(M)for(var I=L;I--;){var w=M[I];if(X.isAudioSupported(w))U.audioCodec=B=B?B+","+w:w,L--,r0.audio[B.substring(0,4)]=2;else if(X.isVideoSupported(w))U.videoCodec=F=F?F+","+w:w,L--,r0.video[F.substring(0,4)]=2}if(K||(K=!!(R&&O)),j||(j=!!F),V||(V=!!B),L||B&&!X.isAudioSupported(B)||F&&!X.isVideoSupported(F)){X.log('Some or all CODECS not supported "'+E.CODECS+'"');return}var S=E.CODECS,P=E["FRAME-RATE"],b=E["HDCP-LEVEL"],C=E["PATHWAY-ID"],x=E.RESOLUTION,_=E["VIDEO-RANGE"],y=(C||".")+"-",T=""+y+U.bitrate+"-"+x+"-"+P+"-"+S+"-"+_+"-"+b;if(!W[T]){var h=X.createLevel(U);W[T]=h,G[T]=1,N.push(h)}else if(W[T].uri!==U.url&&!U.attrs["PATHWAY-ID"]){var g=G[T]+=1;U.attrs["PATHWAY-ID"]=new Array(g+1).join(".");var m=X.createLevel(U);W[T]=m,N.push(m)}else W[T].addGroupId("audio",E.AUDIO),W[T].addGroupId("text",E.SUBTITLES)}),this.filterAndSortMediaOptions(N,J,K,j,V)},Z.createLevel=function Q(Y){var J=new JQ(Y),X=Y.supplemental;if(X!=null&&X.videoCodec&&!this.isVideoSupported(X.videoCodec)){var z=new Error('SUPPLEMENTAL-CODECS not supported "'+X.videoCodec+'"');this.log(z.message),J.supportedResult=h7.getUnsupportedResult(z,[])}return J},Z.isAudioSupported=function Q(Y){return rY(Y,"audio",this.hls.config.preferManagedMediaSource)},Z.isVideoSupported=function Q(Y){return rY(Y,"video",this.hls.config.preferManagedMediaSource)},Z.filterAndSortMediaOptions=function Q(Y,J,X,z,N){var W=this,G=[],K=[],j=Y;if((X||z)&&N)j=j.filter(function(I){var{videoCodec:w,videoRange:S,width:P,height:b}=I;return(!!w||!!(P&&b))&&F8(S)});if(j.length===0){Promise.resolve().then(function(){if(W.hls){var I="no level with compatible codecs found in manifest",w=I;if(J.levels.length)w="one or more CODECS in variant not supported: "+$0(J.levels.map(function(P){return P.attrs.CODECS}).filter(function(P,b,C){return C.indexOf(P)===b})),W.warn(w),I+=" ("+w+")";var S=new Error(I);W.hls.trigger($.ERROR,{type:f.MEDIA_ERROR,details:D.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:J.url,error:S,reason:w})}});return}if(J.audioTracks)G=J.audioTracks.filter(function(I){return!I.audioCodec||W.isAudioSupported(I.audioCodec)}),BJ(G);if(J.subtitles)K=J.subtitles,BJ(K);var V=j.slice(0);j.sort(function(I,w){if(I.attrs["HDCP-LEVEL"]!==w.attrs["HDCP-LEVEL"])return(I.attrs["HDCP-LEVEL"]||"")>(w.attrs["HDCP-LEVEL"]||"")?1:-1;if(X&&I.height!==w.height)return I.height-w.height;if(I.frameRate!==w.frameRate)return I.frameRate-w.frameRate;if(I.videoRange!==w.videoRange)return FY.indexOf(I.videoRange)-FY.indexOf(w.videoRange);if(I.videoCodec!==w.videoCodec){var S=a7(I.videoCodec),P=a7(w.videoCodec);if(S!==P)return P-S}if(I.uri===w.uri&&I.codecSet!==w.codecSet){var b=EY(I.codecSet),C=EY(w.codecSet);if(b!==C)return C-b}if(I.averageBitrate!==w.averageBitrate)return I.averageBitrate-w.averageBitrate;return 0});var U=V[0];if(this.steering){if(j=this.steering.filterParsedLevels(j),j.length!==V.length){for(var A=0;A<V.length;A++)if(V[A].pathwayId===j[0].pathwayId){U=V[A];break}}}this._levels=j;for(var E=0;E<j.length;E++)if(j[E]===U){var B;this._firstLevel=E;var F=U.bitrate,R=this.hls.bandwidthEstimate;if(this.log("manifest loaded, "+j.length+" level(s) found, first bitrate: "+F),((B=this.hls.userConfig)==null?void 0:B.abrEwmaDefaultEstimate)===void 0){var O=Math.min(F,this.hls.config.abrEwmaDefaultEstimateMax);if(O>R&&R===this.hls.abrEwmaDefaultEstimate)this.hls.bandwidthEstimate=O}break}var M=N&&!z,L={levels:j,audioTracks:G,subtitleTracks:K,sessionData:J.sessionData,sessionKeys:J.sessionKeys,firstLevel:this._firstLevel,stats:J.stats,audio:N,video:z,altAudio:!M&&G.some(function(I){return!!I.url})};this.hls.trigger($.MANIFEST_PARSED,L)},Z.onError=function Q(Y,J){if(J.fatal||!J.context)return;if(J.context.type===o.LEVEL&&J.context.level===this.level)this.checkRetry(J)},Z.onFragBuffered=function Q(Y,J){var X=J.frag;if(X!==void 0&&X.type===d.MAIN){var z=X.elementaryStreams;if(!Object.keys(z).some(function(W){return!!z[W]}))return;var N=this._levels[X.level];if(N!=null&&N.loadError)this.log("Resetting level error count of "+N.loadError+" on frag buffered"),N.loadError=0}},Z.onLevelLoaded=function Q(Y,J){var X,z=J.level,N=J.details,W=J.levelInfo;if(!W){var G;if(this.warn("Invalid level index "+z),(G=J.deliveryDirectives)!=null&&G.skip)N.deltaUpdateFailed=!0;return}if(W===this.currentLevel||J.withoutMultiVariant){if(W.fragmentError===0)W.loadError=0;var K=W.details;if(K===J.details&&K.advanced)K=void 0;this.playlistLoaded(z,J,K)}else if((X=J.deliveryDirectives)!=null&&X.skip)N.deltaUpdateFailed=!0},Z.loadPlaylist=function Q(Y){if(q.prototype.loadPlaylist.call(this),this.shouldLoadPlaylist(this.currentLevel))this.scheduleLoading(this.currentLevel,Y)},Z.loadingPlaylist=function Q(Y,J){q.prototype.loadingPlaylist.call(this,Y,J);var X=this.getUrlWithDirectives(Y.uri,J),z=this.currentLevelIndex,N=Y.attrs["PATHWAY-ID"],W=Y.details,G=W==null?void 0:W.age;this.log("Loading level index "+z+((J==null?void 0:J.msn)!==void 0?" at sn "+J.msn+" part "+J.part:"")+(N?" Pathway "+N:"")+(G&&W.live?" age "+G.toFixed(1)+(W.type?" "+W.type||"":""):"")+" "+X),this.hls.trigger($.LEVEL_LOADING,{url:X,level:z,levelInfo:Y,pathwayId:Y.attrs["PATHWAY-ID"],id:0,deliveryDirectives:J||null})},Z.removeLevel=function Q(Y){var J=this,X;if(this._levels.length===1)return;var z=this._levels.filter(function(W,G){if(G!==Y)return!0;if(J.steering)J.steering.removeLevel(W);if(W===J.currentLevel){if(J.currentLevel=null,J.currentLevelIndex=-1,W.details)W.details.fragments.forEach(function(K){return K.level=-1})}return!1});if(yQ(z),this._levels=z,this.currentLevelIndex>-1&&(X=this.currentLevel)!=null&&X.details)this.currentLevelIndex=this.currentLevel.details.fragments[0].level;if(this.manualLevelIndex>-1)this.manualLevelIndex=this.currentLevelIndex;var N=z.length-1;if(this._firstLevel=Math.min(this._firstLevel,N),this._startLevel)this._startLevel=Math.min(this._startLevel,N);this.hls.trigger($.LEVELS_UPDATED,{levels:z})},Z.onLevelsUpdated=function Q(Y,J){var X=J.levels;this._levels=X},Z.checkMaxAutoUpdated=function Q(){var Y=this.hls,J=Y.autoLevelCapping,X=Y.maxAutoLevel,z=Y.maxHdcpLevel;if(this._maxAutoLevel!==X)this._maxAutoLevel=X,this.hls.trigger($.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:J,levels:this.levels,maxAutoLevel:X,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:z})},Z0(H,[{key:"levels",get:function Q(){if(this._levels.length===0)return null;return this._levels}},{key:"loadLevelObj",get:function Q(){return this.currentLevel}},{key:"level",get:function Q(){return this.currentLevelIndex},set:function Q(Y){var J=this._levels;if(J.length===0)return;if(Y<0||Y>=J.length){var X=new Error("invalid level idx"),z=Y<0;if(this.hls.trigger($.ERROR,{type:f.OTHER_ERROR,details:D.LEVEL_SWITCH_ERROR,level:Y,fatal:z,error:X,reason:X.message}),z)return;Y=Math.min(Y,J.length-1)}var N=this.currentLevelIndex,W=this.currentLevel,G=W?W.attrs["PATHWAY-ID"]:void 0,K=J[Y],j=K.attrs["PATHWAY-ID"];if(this.currentLevelIndex=Y,this.currentLevel=K,N===Y&&W&&G===j)return;this.log("Switching to level "+Y+" ("+(K.height?K.height+"p ":"")+(K.videoRange?K.videoRange+" ":"")+(K.codecSet?K.codecSet+" ":"")+"@"+K.bitrate+")"+(j?" with Pathway "+j:"")+" from level "+N+(G?" with Pathway "+G:""));var V={level:Y,attrs:K.attrs,details:K.details,bitrate:K.bitrate,averageBitrate:K.averageBitrate,maxBitrate:K.maxBitrate,realBitrate:K.realBitrate,width:K.width,height:K.height,codecSet:K.codecSet,audioCodec:K.audioCodec,videoCodec:K.videoCodec,audioGroups:K.audioGroups,subtitleGroups:K.subtitleGroups,loaded:K.loaded,loadError:K.loadError,fragmentError:K.fragmentError,name:K.name,id:K.id,uri:K.uri,url:K.url,urlId:0,audioGroupIds:K.audioGroupIds,textGroupIds:K.textGroupIds};this.hls.trigger($.LEVEL_SWITCHING,V);var U=K.details;if(!U||U.live){var A=this.switchParams(K.uri,W==null?void 0:W.details,U);this.loadPlaylist(A)}}},{key:"manualLevel",get:function Q(){return this.manualLevelIndex},set:function Q(Y){if(this.manualLevelIndex=Y,this._startLevel===void 0)this._startLevel=Y;if(Y!==-1)this.level=Y}},{key:"firstLevel",get:function Q(){return this._firstLevel},set:function Q(Y){this._firstLevel=Y}},{key:"startLevel",get:function Q(){if(this._startLevel===void 0){var Y=this.hls.config.startLevel;if(Y!==void 0)return Y;return this.hls.firstAutoLevel}return this._startLevel},set:function Q(Y){this._startLevel=Y}},{key:"pathways",get:function Q(){if(this.steering)return this.steering.pathways();return[]}},{key:"pathwayPriority",get:function Q(){if(this.steering)return this.steering.pathwayPriority;return null},set:function Q(Y){if(this.steering){var J=this.steering.pathways(),X=Y.filter(function(z){return J.indexOf(z)!==-1});if(Y.length<1){this.warn("pathwayPriority "+Y+" should contain at least one pathway from list: "+J);return}this.steering.pathwayPriority=X}}},{key:"nextLoadLevel",get:function Q(){if(this.manualLevelIndex!==-1)return this.manualLevelIndex;else return this.hls.nextAutoLevel},set:function Q(Y){if(this.level=Y,this.manualLevelIndex===-1)this.hls.nextAutoLevel=Y}}])}(m9);function BJ(q){var H={};q.forEach(function(Z){var Q=Z.groupId||"";Z.id=H[Q]=H[Q]||0,H[Q]++})}var F7=[];if(typeof g0!=="undefined"&&g0)u9();function u9(){self.addEventListener("message",function(q){var H=q.data,Z=H.instanceNo;if(Z===void 0)return;var Q=F7[Z];if(H.cmd==="reset"){if(delete F7[H.resetNo],Q)Q.destroy();H.cmd="init"}if(H.cmd==="init"){var Y=JSON.parse(H.config),J=new mY;J.on($.FRAG_DECRYPTED,QY),J.on($.ERROR,QY);var X=k7(Y.debug,H.id);c9(X,Z),F7[Z]=new A7(J,H.typeSupported,Y,"",H.id,X),QY("init",null,Z);return}if(!Q)return;switch(H.cmd){case"configure":{Q.configure(H.config);break}case"demux":{var z=Q.push(H.data,H.decryptdata,H.chunkMeta,H.state);if(o0(z))z.then(function(G){O7(self,G,Z)}).catch(function(G){QY($.ERROR,{instanceNo:Z,type:f.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,chunkMeta:H.chunkMeta,fatal:!1,error:G,err:G,reason:"transmuxer-worker push error"},Z)});else O7(self,z,Z);break}case"flush":{var N=H.chunkMeta,W=Q.flush(N);if(o0(W))W.then(function(G){FJ(self,G,N,Z)}).catch(function(G){QY($.ERROR,{type:f.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,chunkMeta:H.chunkMeta,fatal:!1,error:G,err:G,reason:"transmuxer-worker flush error"},Z)});else FJ(self,W,N,Z);break}}})}function O7(q,H,Z){if(f9(H.remuxResult))return!1;var Q=[],Y=H.remuxResult,J=Y.audio,X=Y.video;if(J)$J(Q,J);if(X)$J(Q,X);return q.postMessage({event:"transmuxComplete",data:H,instanceNo:Z},Q),!0}function $J(q,H){if(H.data1)q.push(H.data1.buffer);if(H.data2)q.push(H.data2.buffer)}function FJ(q,H,Z,Q){var Y=H.reduce(function(J,X){return O7(q,X,Q)||J},!1);if(!Y)q.postMessage({event:"transmuxComplete",data:H[0],instanceNo:Q});q.postMessage({event:"flush",data:Z,instanceNo:Q})}function QY(q,H,Z){self.postMessage({event:q,data:H,instanceNo:Z})}function c9(q,H){var Z=function Y(J){var X=function z(N){QY("workerLog",{logType:J,message:N},H)};q[J]=X};for(var Q in q)Z(Q)}function f9(q){return!q.audio&&!q.video&&!q.text&&!q.id3&&!q.initSegment}var KY="1.6.0",JY={};function d9(){return typeof C0==="function"}function l9(){var q=JY[KY];if(q)return q.clientCount++,q;var H=new self.Blob(["var exports={};var module={exports:exports};function define(f){f()};define.amd=true;("+C0.toString()+")(true);"],{type:"text/javascript"}),Z=self.URL.createObjectURL(H),Q=new self.Worker(Z),Y={worker:Q,objectURL:Z,clientCount:1};return JY[KY]=Y,Y}function n9(q){var H=JY[q];if(H)return H.clientCount++,H;var Z=new self.URL(q,self.location.href).href,Q=new self.Worker(Z),Y={worker:Q,scriptURL:Z,clientCount:1};return JY[q]=Y,Y}function o9(q){var H=JY[q||KY];if(H){var Z=H.clientCount--;if(Z===1){var{worker:Q,objectURL:Y}=H;if(delete JY[q||KY],Y)self.URL.revokeObjectURL(Y);Q.terminate()}}}var OJ=0,s9=function(){function q(Z,Q,Y,J){var X=this;this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=OJ++,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.onWorkerMessage=function(V){var U=V.data,A=X.hls;if(!A||!(U!=null&&U.event)||U.instanceNo!==X.instanceNo)return;switch(U.event){case"init":{var E,B=(E=X.workerContext)==null?void 0:E.objectURL;if(B)self.URL.revokeObjectURL(B);break}case"transmuxComplete":{X.handleTransmuxComplete(U.data);break}case"flush":{X.onFlush(U.data);break}case"workerLog":{if(A.logger[U.data.logType])A.logger[U.data.logType](U.data.message);break}default:{U.data=U.data||{},U.data.frag=X.frag,U.data.part=X.part,U.data.id=X.id,A.trigger(U.event,U.data);break}}},this.onWorkerError=function(V){if(!X.hls)return;var U=new Error(V.message+" ("+V.filename+":"+V.lineno+")");X.hls.config.enableWorker=!1,X.hls.logger.warn('Error in "'+X.id+'" Web Worker, fallback to inline'),X.hls.trigger($.ERROR,{type:f.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:U})};var z=Z.config;this.hls=Z,this.id=Q,this.useWorker=!!z.enableWorker,this.onTransmuxComplete=Y,this.onFlush=J;var N=function V(U,A){if(A=A||{},A.frag=X.frag||void 0,U===$.ERROR)A=A,A.parent=X.id,A.part=X.part,X.error=A.error;X.hls.trigger(U,A)};this.observer=new mY,this.observer.on($.FRAG_DECRYPTED,N),this.observer.on($.ERROR,N);var W=t7(z.preferManagedMediaSource);if(this.useWorker&&typeof Worker!=="undefined"){var G=this.hls.logger,K=z.workerPath||d9();if(K){try{if(z.workerPath)G.log("loading Web Worker "+z.workerPath+' for "'+Q+'"'),this.workerContext=n9(z.workerPath);else G.log('injecting Web Worker for "'+Q+'"'),this.workerContext=l9();var j=this.workerContext.worker;j.addEventListener("message",this.onWorkerMessage),j.addEventListener("error",this.onWorkerError),j.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:W,id:Q,config:$0(z)})}catch(V){G.warn('Error setting up "'+Q+'" Web Worker, fallback to inline',V),this.terminateWorker(),this.error=null,this.transmuxer=new A7(this.observer,W,z,"",Q,Z.logger)}return}}this.transmuxer=new A7(this.observer,W,z,"",Q,Z.logger)}var H=q.prototype;return H.reset=function Z(){if(this.frag=null,this.part=null,this.workerContext){var Q=this.instanceNo;this.instanceNo=OJ++;var Y=this.hls.config,J=t7(Y.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:Q,typeSupported:J,id:this.id,config:$0(Y)})}},H.terminateWorker=function Z(){if(this.workerContext){var Q=this.workerContext.worker;this.workerContext=null,Q.removeEventListener("message",this.onWorkerMessage),Q.removeEventListener("error",this.onWorkerError),o9(this.hls.config.workerPath)}},H.destroy=function Z(){if(this.workerContext)this.terminateWorker(),this.onWorkerMessage=this.onWorkerError=null;else{var Q=this.transmuxer;if(Q)Q.destroy(),this.transmuxer=null}var Y=this.observer;if(Y)Y.removeAllListeners();this.frag=null,this.part=null,this.observer=null,this.hls=null},H.push=function Z(Q,Y,J,X,z,N,W,G,K,j){var V,U,A=this;K.transmuxing.start=self.performance.now();var E=this.instanceNo,B=this.transmuxer,F=N?N.start:z.start,R=z.decryptdata,O=this.frag,M=!(O&&z.cc===O.cc),L=!(O&&K.level===O.level),I=O?K.sn-O.sn:-1,w=this.part?K.part-this.part.index:-1,S=I===0&&K.id>1&&K.id===(O==null?void 0:O.stats.chunkCount),P=!L&&(I===1||I===0&&(w===1||S&&w<=0)),b=self.performance.now();if(L||I||z.stats.parsing.start===0)z.stats.parsing.start=b;if(N&&(w||!P))N.stats.parsing.start=b;var C=!(O&&((V=z.initSegment)==null?void 0:V.url)===((U=O.initSegment)==null?void 0:U.url)),x=new q9(M,P,G,L,F,C);if(!P||M||C){this.hls.logger.log("[transmuxer-interface]: Starting new transmux session for "+z.type+" sn: "+K.sn+(K.part>-1?" part: "+K.part:"")+" "+(this.id===d.MAIN?"level":"track")+": "+K.level+" id: "+K.id+`
22
+ discontinuity: `+M+`
11
23
  trackSwitch: `+L+`
12
- contiguous: `+b+`
13
- accurateTimeOffset: `+d+`
14
- timeOffset: `+p+`
15
- initSegmentChange: `+P);var w=new Gs(r,s,t,u,h);this.configureTransmuxer(w)}if(this.frag=o,this.part=l,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:y,chunkMeta:f,state:C},e instanceof ArrayBuffer?[e]:[]);else if(m){var O=m.push(e,y,f,C);He(O)?(m.async=!0,O.then(function(F){g.handleTransmuxComplete(F)}).catch(function(F){g.transmuxerError(F,f,"transmuxer-interface push error")})):(m.async=!1,this.handleTransmuxComplete(O))}},n.flush=function(e){var t=this;e.transmuxing.start=self.performance.now();var r=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(r){var s=r.flush(e),o=He(s);o||r.async?(He(s)||(s=Promise.resolve(s)),s.then(function(l){t.handleFlushResult(l,e)}).catch(function(l){t.transmuxerError(l,e,"transmuxer-interface flush error")})):this.handleFlushResult(s,e)}},n.transmuxerError=function(e,t,r){this.hls&&(this.error=e,this.hls.trigger(x.ERROR,{type:V.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,fatal:!1,error:e,err:e,reason:r}))},n.handleFlushResult=function(e,t){var r=this;e.forEach(function(s){r.handleTransmuxComplete(s)}),this.onFlush(t)},n.onWorkerMessage=function(e){var t=e.data;if(!(t!=null&&t.event)){R.warn("worker message received with no "+(t?"event name":"data"));return}var r=this.hls;if(this.hls)switch(t.event){case"init":{var s,o=(s=this.workerContext)==null?void 0:s.objectURL;o&&self.URL.revokeObjectURL(o);break}case"transmuxComplete":{this.handleTransmuxComplete(t.data);break}case"flush":{this.onFlush(t.data);break}case"workerLog":R[t.data.logType]&&R[t.data.logType](t.data.message);break;default:{t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,r.trigger(t.event,t.data);break}}},n.configureTransmuxer=function(e){var t=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)},n.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},a}(),zs=250,yt=2,$s=.1,Qs=.05,Zs=function(){function a(i,e,t,r){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=i,this.media=e,this.fragmentTracker=t,this.hls=r}var n=a.prototype;return n.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},n.poll=function(e,t){var r=this.config,s=this.media,o=this.stalled;if(s!==null){var l=s.currentTime,u=s.seeking,d=this.seeking&&!u,f=!this.seeking&&u;if(this.seeking=u,l!==e){if(this.moved=!0,u||(this.nudgeRetry=0),o!==null){if(this.stallReported){var h=self.performance.now()-o;R.warn("playback not stuck anymore @"+l+", after "+Math.round(h)+"ms"),this.stallReported=!1}this.stalled=null}return}if(f||d){this.stalled=null;return}if(s.paused&&!u||s.ended||s.playbackRate===0||!le.getBuffered(s).length){this.nudgeRetry=0;return}var c=le.bufferInfo(s,l,0),v=c.nextStart||0;if(u){var g=c.len>yt,m=!v||t&&t.start<=l||v-l>yt&&!this.fragmentTracker.getPartialFragment(l);if(g||m)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var p,y=c.len>0;if(!y&&!v)return;var E=Math.max(v,c.start||0)-l,S=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,L=S==null||(p=S.details)==null?void 0:p.live,_=L?S.details.targetduration*2:yt,A=this.fragmentTracker.getPartialFragment(l);if(E>0&&(E<=_||A)){s.paused||this._trySkipBufferHole(A);return}}var T=self.performance.now();if(o===null){this.stalled=T;return}var b=T-o;if(!(!u&&b>=zs&&(this._reportStall(c),!this.media))){var I=le.bufferInfo(s,l,r.maxBufferHole);this._tryFixBufferStall(I,b)}}},n._tryFixBufferStall=function(e,t){var r=this.config,s=this.fragmentTracker,o=this.media;if(o!==null){var l=o.currentTime,u=s.getPartialFragment(l);if(u){var d=this._trySkipBufferHole(u);if(d||!this.media)return}(e.len>r.maxBufferHole||e.nextStart&&e.nextStart-l<r.maxBufferHole)&&t>r.highBufferWatchdogPeriod*1e3&&(R.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},n._reportStall=function(e){var t=this.hls,r=this.media,s=this.stallReported;if(!s&&r){this.stallReported=!0;var o=new Error("Playback stalling at @"+r.currentTime+" due to low buffer ("+JSON.stringify(e)+")");R.warn(o.message),t.trigger(x.ERROR,{type:V.MEDIA_ERROR,details:D.BUFFER_STALLED_ERROR,fatal:!1,error:o,buffer:e.len})}},n._trySkipBufferHole=function(e){var t=this.config,r=this.hls,s=this.media;if(s===null)return 0;var o=s.currentTime,l=le.bufferInfo(s,o,0),u=o<l.start?l.start:l.nextStart;if(u){var d=l.len<=t.maxBufferHole,f=l.len>0&&l.len<1&&s.readyState<3,h=u-o;if(h>0&&(d||f)){if(h>t.maxBufferHole){var c=this.fragmentTracker,v=!1;if(o===0){var g=c.getAppendedFrag(0,q.MAIN);g&&u<g.end&&(v=!0)}if(!v){var m=e||c.getAppendedFrag(o,q.MAIN);if(m){for(var p=!1,y=m.end;y<u;){var E=c.getPartialFragment(y);if(E)y+=E.duration;else{p=!0;break}}if(p)return 0}}}var S=Math.max(u+Qs,o+$s);if(R.warn("skipping hole, adjusting currentTime from "+o+" to "+S),this.moved=!0,this.stalled=null,s.currentTime=S,e&&!e.gap){var L=new Error("fragment loaded with buffer holes, seeking from "+o+" to "+S);r.trigger(x.ERROR,{type:V.MEDIA_ERROR,details:D.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:L,reason:L.message,frag:e})}return S}}return 0},n._tryNudgeBuffer=function(){var e=this.config,t=this.hls,r=this.media,s=this.nudgeRetry;if(r!==null){var o=r.currentTime;if(this.nudgeRetry++,s<e.nudgeMaxRetry){var l=o+(s+1)*e.nudgeOffset,u=new Error("Nudging 'currentTime' from "+o+" to "+l);R.warn(u.message),r.currentTime=l,t.trigger(x.ERROR,{type:V.MEDIA_ERROR,details:D.BUFFER_NUDGE_ON_STALL,error:u,fatal:!1})}else{var d=new Error("Playhead still not moving while enough data buffered @"+o+" after "+e.nudgeMaxRetry+" nudges");R.error(d.message),t.trigger(x.ERROR,{type:V.MEDIA_ERROR,details:D.BUFFER_STALLED_ERROR,error:d,fatal:!0})}}},a}(),Js=100,eo=function(a){_e(n,a);function n(e,t,r){var s;return s=a.call(this,e,t,r,"[stream-controller]",q.MAIN)||this,s.audioCodecSwap=!1,s.gapController=null,s.level=-1,s._forceStartLoad=!1,s.altAudio=!1,s.audioOnly=!1,s.fragPlaying=null,s.onvplaying=null,s.onvseeked=null,s.fragLastKbps=0,s.couldBacktrack=!1,s.backtrackFragment=null,s.audioCodecSwitch=!1,s.videoBuffer=null,s._registerListeners(),s}var i=n.prototype;return i._registerListeners=function(){var t=this.hls;t.on(x.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(x.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(x.MANIFEST_LOADING,this.onManifestLoading,this),t.on(x.MANIFEST_PARSED,this.onManifestParsed,this),t.on(x.LEVEL_LOADING,this.onLevelLoading,this),t.on(x.LEVEL_LOADED,this.onLevelLoaded,this),t.on(x.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(x.ERROR,this.onError,this),t.on(x.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(x.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(x.BUFFER_CREATED,this.onBufferCreated,this),t.on(x.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(x.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(x.FRAG_BUFFERED,this.onFragBuffered,this)},i._unregisterListeners=function(){var t=this.hls;t.off(x.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(x.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(x.MANIFEST_LOADING,this.onManifestLoading,this),t.off(x.MANIFEST_PARSED,this.onManifestParsed,this),t.off(x.LEVEL_LOADED,this.onLevelLoaded,this),t.off(x.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(x.ERROR,this.onError,this),t.off(x.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(x.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(x.BUFFER_CREATED,this.onBufferCreated,this),t.off(x.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(x.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(x.FRAG_BUFFERED,this.onFragBuffered,this)},i.onHandlerDestroying=function(){this._unregisterListeners(),a.prototype.onHandlerDestroying.call(this)},i.startLoad=function(t){if(this.levels){var r=this.lastCurrentTime,s=this.hls;if(this.stopLoad(),this.setInterval(Js),this.level=-1,!this.startFragRequested){var o=s.startLevel;o===-1&&(s.config.testBandwidth&&this.levels.length>1?(o=0,this.bitrateTest=!0):o=s.firstAutoLevel),s.nextLoadLevel=o,this.level=s.loadLevel,this.loadedmetadata=!1}r>0&&t===-1&&(this.log("Override startPosition with lastCurrentTime @"+r.toFixed(3)),t=r),this.state=k.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=k.STOPPED},i.stopLoad=function(){this._forceStartLoad=!1,a.prototype.stopLoad.call(this)},i.doTick=function(){switch(this.state){case k.WAITING_LEVEL:{var t=this.levels,r=this.level,s=t?.[r],o=s?.details;if(o&&(!o.live||this.levelLastLoaded===s)){if(this.waitForCdnTuneIn(o))break;this.state=k.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=k.IDLE;break}break}case k.FRAG_LOADING_WAITING_RETRY:{var l,u=self.performance.now(),d=this.retryDate;if(!d||u>=d||(l=this.media)!=null&&l.seeking){var f=this.levels,h=this.level,c=f?.[h];this.resetStartWhenNotLoaded(c||null),this.state=k.IDLE}}break}this.state===k.IDLE&&this.doTickIdle(),this.onTickEnd()},i.onTickEnd=function(){a.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},i.doTickIdle=function(){var t=this.hls,r=this.levelLastLoaded,s=this.levels,o=this.media;if(!(r===null||!o&&(this.startFragRequested||!t.config.startFragPrefetch))&&!(this.altAudio&&this.audioOnly)){var l=t.nextLoadLevel;if(s!=null&&s[l]){var u=s[l],d=this.getMainFwdBufferInfo();if(d!==null){var f=this.getLevelDetails();if(f&&this._streamEnded(d,f)){var h={};this.altAudio&&(h.type="video"),this.hls.trigger(x.BUFFER_EOS,h),this.state=k.ENDED;return}t.loadLevel!==l&&t.manualLevel===-1&&this.log("Adapting to level "+l+" from level "+this.level),this.level=t.nextLoadLevel=l;var c=u.details;if(!c||this.state===k.WAITING_LEVEL||c.live&&this.levelLastLoaded!==u){this.level=l,this.state=k.WAITING_LEVEL;return}var v=d.len,g=this.getMaxBufferLength(u.maxBitrate);if(!(v>=g)){this.backtrackFragment&&this.backtrackFragment.start>d.end&&(this.backtrackFragment=null);var m=this.backtrackFragment?this.backtrackFragment.start:d.end,p=this.getNextFragment(m,c);if(this.couldBacktrack&&!this.fragPrevious&&p&&p.sn!=="initSegment"&&this.fragmentTracker.getState(p)!==Ee.OK){var y,E=((y=this.backtrackFragment)!=null?y:p).sn,S=E-c.startSN,L=c.fragments[S-1];L&&p.cc===L.cc&&(p=L,this.fragmentTracker.removeFragment(L))}else this.backtrackFragment&&d.len&&(this.backtrackFragment=null);if(p&&this.isLoopLoading(p,m)){var _=p.gap;if(!_){var A=this.audioOnly&&!this.altAudio?$.AUDIO:$.VIDEO,T=(A===$.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;T&&this.afterBufferFlushed(T,A,q.MAIN)}p=this.getNextFragmentLoopLoading(p,c,d,q.MAIN,g)}p&&(p.initSegment&&!p.initSegment.data&&!this.bitrateTest&&(p=p.initSegment),this.loadFragment(p,u,m))}}}}},i.loadFragment=function(t,r,s){var o=this.fragmentTracker.getState(t);this.fragCurrent=t,o===Ee.NOT_LOADED||o===Ee.PARTIAL?t.sn==="initSegment"?this._loadInitSegment(t,r):this.bitrateTest?(this.log("Fragment "+t.sn+" of level "+t.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(t,r)):(this.startFragRequested=!0,a.prototype.loadFragment.call(this,t,r,s)):this.clearTrackerIfNeeded(t)},i.getBufferedFrag=function(t){return this.fragmentTracker.getBufferedFrag(t,q.MAIN)},i.followingBufferedFrag=function(t){return t?this.getBufferedFrag(t.end+.5):null},i.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},i.nextLevelSwitch=function(){var t=this.levels,r=this.media;if(r!=null&&r.readyState){var s,o=this.getAppendedFrag(r.currentTime);o&&o.start>1&&this.flushMainBuffer(0,o.start-1);var l=this.getLevelDetails();if(l!=null&&l.live){var u=this.getMainFwdBufferInfo();if(!u||u.len<l.targetduration*2)return}if(!r.paused&&t){var d=this.hls.nextLoadLevel,f=t[d],h=this.fragLastKbps;h&&this.fragCurrent?s=this.fragCurrent.duration*f.maxBitrate/(1e3*h)+1:s=0}else s=0;var c=this.getBufferedFrag(r.currentTime+s);if(c){var v=this.followingBufferedFrag(c);if(v){this.abortCurrentFrag();var g=v.maxStartPTS?v.maxStartPTS:v.start,m=v.duration,p=Math.max(c.end,g+Math.min(Math.max(m-this.config.maxFragLookUpTolerance,m*(this.couldBacktrack?.5:.125)),m*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(p,Number.POSITIVE_INFINITY)}}}},i.abortCurrentFrag=function(){var t=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,t&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.state){case k.KEY_LOADING:case k.FRAG_LOADING:case k.FRAG_LOADING_WAITING_RETRY:case k.PARSING:case k.PARSED:this.state=k.IDLE;break}this.nextLoadPosition=this.getLoadPosition()},i.flushMainBuffer=function(t,r){a.prototype.flushMainBuffer.call(this,t,r,this.altAudio?"video":null)},i.onMediaAttached=function(t,r){a.prototype.onMediaAttached.call(this,t,r);var s=r.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),s.addEventListener("playing",this.onvplaying),s.addEventListener("seeked",this.onvseeked),this.gapController=new Zs(this.config,s,this.fragmentTracker,this.hls)},i.onMediaDetaching=function(){var t=this.media;t&&this.onvplaying&&this.onvseeked&&(t.removeEventListener("playing",this.onvplaying),t.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),a.prototype.onMediaDetaching.call(this)},i.onMediaPlaying=function(){this.tick()},i.onMediaSeeked=function(){var t=this.media,r=t?t.currentTime:null;M(r)&&this.log("Media seeked to "+r.toFixed(3));var s=this.getMainFwdBufferInfo();if(s===null||s.len===0){this.warn('Main forward buffer length on "seeked" event '+(s?s.len:"empty")+")");return}this.tick()},i.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(x.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=this.fragLastKbps=0,this.levels=this.fragPlaying=this.backtrackFragment=this.levelLastLoaded=null,this.altAudio=this.audioOnly=this.startFragRequested=!1},i.onManifestParsed=function(t,r){var s=!1,o=!1;r.levels.forEach(function(l){var u=l.audioCodec;u&&(s=s||u.indexOf("mp4a.40.2")!==-1,o=o||u.indexOf("mp4a.40.5")!==-1)}),this.audioCodecSwitch=s&&o&&!ls(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=r.levels,this.startFragRequested=!1},i.onLevelLoading=function(t,r){var s=this.levels;if(!(!s||this.state!==k.IDLE)){var o=s[r.level];(!o.details||o.details.live&&this.levelLastLoaded!==o||this.waitForCdnTuneIn(o.details))&&(this.state=k.WAITING_LEVEL)}},i.onLevelLoaded=function(t,r){var s,o=this.levels,l=r.level,u=r.details,d=u.totalduration;if(!o){this.warn("Levels were reset while loading level "+l);return}this.log("Level "+l+" loaded ["+u.startSN+","+u.endSN+"]"+(u.lastPartSn?"[part-"+u.lastPartSn+"-"+u.lastPartIndex+"]":"")+", cc ["+u.startCC+", "+u.endCC+"] duration:"+d);var f=o[l],h=this.fragCurrent;h&&(this.state===k.FRAG_LOADING||this.state===k.FRAG_LOADING_WAITING_RETRY)&&h.level!==r.level&&h.loader&&this.abortCurrentFrag();var c=0;if(u.live||(s=f.details)!=null&&s.live){var v;if(this.checkLiveUpdate(u),u.deltaUpdateFailed)return;c=this.alignPlaylists(u,f.details,(v=this.levelLastLoaded)==null?void 0:v.details)}if(f.details=u,this.levelLastLoaded=f,this.hls.trigger(x.LEVEL_UPDATED,{details:u,level:l}),this.state===k.WAITING_LEVEL){if(this.waitForCdnTuneIn(u))return;this.state=k.IDLE}this.startFragRequested?u.live&&this.synchronizeToLiveEdge(u):this.setStartPosition(u,c),this.tick()},i._handleFragmentLoadProgress=function(t){var r,s=t.frag,o=t.part,l=t.payload,u=this.levels;if(!u){this.warn("Levels were reset while fragment load was in progress. Fragment "+s.sn+" of level "+s.level+" will not be buffered");return}var d=u[s.level],f=d.details;if(!f){this.warn("Dropping fragment "+s.sn+" of level "+s.level+" after level details were reset"),this.fragmentTracker.removeFragment(s);return}var h=d.videoCodec,c=f.PTSKnown||!f.live,v=(r=s.initSegment)==null?void 0:r.data,g=this._getAudioCodec(d),m=this.transmuxer=this.transmuxer||new Xs(this.hls,q.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),p=o?o.index:-1,y=p!==-1,E=new fi(s.level,s.sn,s.stats.chunkCount,l.byteLength,p,y),S=this.initPTS[s.cc];m.push(l,v,g,h,s,o,f.totalduration,c,E,S)},i.onAudioTrackSwitching=function(t,r){var s=this.altAudio,o=!!r.url;if(!o){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var l=this.fragCurrent;l&&(this.log("Switching to main audio track, cancel main fragment load"),l.abortRequests(),this.fragmentTracker.removeFragment(l)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var u=this.hls;s&&(u.trigger(x.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),u.trigger(x.AUDIO_TRACK_SWITCHED,r)}},i.onAudioTrackSwitched=function(t,r){var s=r.id,o=!!this.hls.audioTracks[s].url;if(o){var l=this.videoBuffer;l&&this.mediaBuffer!==l&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=l)}this.altAudio=o,this.tick()},i.onBufferCreated=function(t,r){var s=r.tracks,o,l,u=!1;for(var d in s){var f=s[d];if(f.id==="main"){if(l=d,o=f,d==="video"){var h=s[d];h&&(this.videoBuffer=h.buffer)}}else u=!0}u&&o?(this.log("Alternate track found, use "+l+".buffered to schedule main fragment loading"),this.mediaBuffer=o.buffer):this.mediaBuffer=this.media},i.onFragBuffered=function(t,r){var s=r.frag,o=r.part;if(!(s&&s.type!==q.MAIN)){if(this.fragContextChanged(s)){this.warn("Fragment "+s.sn+(o?" p: "+o.index:"")+" of level "+s.level+" finished buffering, but was aborted. state: "+this.state),this.state===k.PARSED&&(this.state=k.IDLE);return}var l=o?o.stats:s.stats;this.fragLastKbps=Math.round(8*l.total/(l.buffering.end-l.loading.first)),s.sn!=="initSegment"&&(this.fragPrevious=s),this.fragBufferedComplete(s,o)}},i.onError=function(t,r){var s;if(r.fatal){this.state=k.ERROR;return}switch(r.details){case D.FRAG_GAP:case D.FRAG_PARSING_ERROR:case D.FRAG_DECRYPT_ERROR:case D.FRAG_LOAD_ERROR:case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_ERROR:case D.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(q.MAIN,r);break;case D.LEVEL_LOAD_ERROR:case D.LEVEL_LOAD_TIMEOUT:case D.LEVEL_PARSING_ERROR:!r.levelRetry&&this.state===k.WAITING_LEVEL&&((s=r.context)==null?void 0:s.type)===Y.LEVEL&&(this.state=k.IDLE);break;case D.BUFFER_APPEND_ERROR:case D.BUFFER_FULL_ERROR:if(!r.parent||r.parent!=="main")return;if(r.details===D.BUFFER_APPEND_ERROR){this.resetLoadingState();return}this.reduceLengthAndFlushBuffer(r)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case D.INTERNAL_EXCEPTION:this.recoverWorkerError(r);break}},i.checkBuffer=function(){var t=this.media,r=this.gapController;if(!(!t||!r||!t.readyState)){if(this.loadedmetadata||!le.getBuffered(t).length){var s=this.state!==k.IDLE?this.fragCurrent:null;r.poll(this.lastCurrentTime,s)}this.lastCurrentTime=t.currentTime}},i.onFragLoadEmergencyAborted=function(){this.state=k.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},i.onBufferFlushed=function(t,r){var s=r.type;if(s!==$.AUDIO||this.audioOnly&&!this.altAudio){var o=(s===$.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(o,s,q.MAIN),this.tick()}},i.onLevelsUpdated=function(t,r){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level),this.levels=r.levels},i.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},i.seekToStartPos=function(){var t=this.media;if(t){var r=t.currentTime,s=this.startPosition;if(s>=0&&r<s){if(t.seeking){this.log("could not seek to "+s+", already seeking at "+r);return}var o=le.getBuffered(t),l=o.length?o.start(0):0,u=l-s;u>0&&(u<this.config.maxBufferHole||u<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+u+" to match buffer start"),s+=u,this.startPosition=s),this.log("seek to target start position "+s+" from current time "+r),t.currentTime=s}}},i._getAudioCodec=function(t){var r=this.config.defaultAudioCodec||t.audioCodec;return this.audioCodecSwap&&r&&(this.log("Swapping audio codec"),r.indexOf("mp4a.40.5")!==-1?r="mp4a.40.2":r="mp4a.40.5"),r},i._loadBitrateTestFrag=function(t,r){var s=this;t.bitrateTest=!0,this._doFragLoad(t,r).then(function(o){var l=s.hls;if(!(!o||s.fragContextChanged(t))){r.fragmentError=0,s.state=k.IDLE,s.startFragRequested=!1,s.bitrateTest=!1;var u=t.stats;u.parsing.start=u.parsing.end=u.buffering.start=u.buffering.end=self.performance.now(),l.trigger(x.FRAG_LOADED,o),t.bitrateTest=!1}})},i._handleTransmuxComplete=function(t){var r,s="main",o=this.hls,l=t.remuxResult,u=t.chunkMeta,d=this.getCurrentContext(u);if(!d){this.resetWhenMissingContext(u);return}var f=d.frag,h=d.part,c=d.level,v=l.video,g=l.text,m=l.id3,p=l.initSegment,y=c.details,E=this.altAudio?void 0:l.audio;if(this.fragContextChanged(f)){this.fragmentTracker.removeFragment(f);return}if(this.state=k.PARSING,p){if(p!=null&&p.tracks){var S=f.initSegment||f;this._bufferInitSegment(c,p.tracks,S,u),o.trigger(x.FRAG_PARSING_INIT_SEGMENT,{frag:S,id:s,tracks:p.tracks})}var L=p.initPTS,_=p.timescale;M(L)&&(this.initPTS[f.cc]={baseTime:L,timescale:_},o.trigger(x.INIT_PTS_FOUND,{frag:f,id:s,initPTS:L,timescale:_}))}if(v&&y&&f.sn!=="initSegment"){var A=y.fragments[f.sn-1-y.startSN],T=f.sn===y.startSN,b=!A||f.cc>A.cc;if(l.independent!==!1){var I=v.startPTS,P=v.endPTS,C=v.startDTS,w=v.endDTS;if(h)h.elementaryStreams[v.type]={startPTS:I,endPTS:P,startDTS:C,endDTS:w};else if(v.firstKeyFrame&&v.independent&&u.id===1&&!b&&(this.couldBacktrack=!0),v.dropped&&v.independent){var O=this.getMainFwdBufferInfo(),F=(O?O.end:this.getLoadPosition())+this.config.maxBufferHole,H=v.firstKeyFramePTS?v.firstKeyFramePTS:I;if(!T&&F<H-this.config.maxBufferHole&&!b){this.backtrack(f);return}else b&&(f.gap=!0);f.setElementaryStreamInfo(v.type,f.start,P,f.start,w,!0)}else T&&I>yt&&(f.gap=!0);f.setElementaryStreamInfo(v.type,I,P,C,w),this.backtrackFragment&&(this.backtrackFragment=f),this.bufferFragmentData(v,f,h,u,T||b)}else if(T||b)f.gap=!0;else{this.backtrack(f);return}}if(E){var U=E.startPTS,W=E.endPTS,K=E.startDTS,B=E.endDTS;h&&(h.elementaryStreams[$.AUDIO]={startPTS:U,endPTS:W,startDTS:K,endDTS:B}),f.setElementaryStreamInfo($.AUDIO,U,W,K,B),this.bufferFragmentData(E,f,h,u)}if(y&&m!=null&&(r=m.samples)!=null&&r.length){var Q={id:s,frag:f,details:y,samples:m.samples};o.trigger(x.FRAG_PARSING_METADATA,Q)}if(y&&g){var j={id:s,frag:f,details:y,samples:g.samples};o.trigger(x.FRAG_PARSING_USERDATA,j)}},i._bufferInitSegment=function(t,r,s,o){var l=this;if(this.state===k.PARSING){this.audioOnly=!!r.audio&&!r.video,this.altAudio&&!this.audioOnly&&delete r.audio;var u=r.audio,d=r.video,f=r.audiovideo;if(u){var h=t.audioCodec,c=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){h&&(h.indexOf("mp4a.40.5")!==-1?h="mp4a.40.2":h="mp4a.40.5");var v=u.metadata;v&&"channelCount"in v&&(v.channelCount||1)!==1&&c.indexOf("firefox")===-1&&(h="mp4a.40.5")}h&&h.indexOf("mp4a.40.5")!==-1&&c.indexOf("android")!==-1&&u.container!=="audio/mpeg"&&(h="mp4a.40.2",this.log("Android: force audio codec to "+h)),t.audioCodec&&t.audioCodec!==h&&this.log('Swapping manifest audio codec "'+t.audioCodec+'" for "'+h+'"'),u.levelCodec=h,u.id="main",this.log("Init audio buffer, container:"+u.container+", codecs[selected/level/parsed]=["+(h||"")+"/"+(t.audioCodec||"")+"/"+u.codec+"]")}d&&(d.levelCodec=t.videoCodec,d.id="main",this.log("Init video buffer, container:"+d.container+", codecs[level/parsed]=["+(t.videoCodec||"")+"/"+d.codec+"]")),f&&this.log("Init audiovideo buffer, container:"+f.container+", codecs[level/parsed]=["+t.codecs+"/"+f.codec+"]"),this.hls.trigger(x.BUFFER_CODECS,r),Object.keys(r).forEach(function(g){var m=r[g],p=m.initSegment;p!=null&&p.byteLength&&l.hls.trigger(x.BUFFER_APPENDING,{type:g,data:p,frag:s,part:null,chunkMeta:o,parent:s.type})}),this.tickImmediate()}},i.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,q.MAIN)},i.backtrack=function(t){this.couldBacktrack=!0,this.backtrackFragment=t,this.resetTransmuxer(),this.flushBufferGap(t),this.fragmentTracker.removeFragment(t),this.fragPrevious=null,this.nextLoadPosition=t.start,this.state=k.IDLE},i.checkFragmentChanged=function(){var t=this.media,r=null;if(t&&t.readyState>1&&t.seeking===!1){var s=t.currentTime;if(le.isBuffered(t,s)?r=this.getAppendedFrag(s):le.isBuffered(t,s+.1)&&(r=this.getAppendedFrag(s+.1)),r){this.backtrackFragment=null;var o=this.fragPlaying,l=r.level;(!o||r.sn!==o.sn||o.level!==l)&&(this.fragPlaying=r,this.hls.trigger(x.FRAG_CHANGED,{frag:r}),(!o||o.level!==l)&&this.hls.trigger(x.LEVEL_SWITCHED,{level:l}))}}},me(n,[{key:"nextLevel",get:function(){var t=this.nextBufferedFrag;return t?t.level:-1}},{key:"currentFrag",get:function(){var t=this.media;return t?this.fragPlaying||this.getAppendedFrag(t.currentTime):null}},{key:"currentProgramDateTime",get:function(){var t=this.media;if(t){var r=t.currentTime,s=this.currentFrag;if(s&&M(r)&&M(s.programDateTime)){var o=s.programDateTime+(r-s.start)*1e3;return new Date(o)}}return null}},{key:"currentLevel",get:function(){var t=this.currentFrag;return t?t.level:-1}},{key:"nextBufferedFrag",get:function(){var t=this.currentFrag;return t?this.followingBufferedFrag(t):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),n}(ss),Oi=function(){a.isMSESupported=function(){return vi()},a.isSupported=function(){return os()},a.getMediaSource=function(){return Ge()};function a(i){i===void 0&&(i={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this.started=!1,this._emitter=new Jt,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,ur(i.debug||!1,"Hls instance");var e=this.config=Va(a.DefaultConfig,i);this.userConfig=i,e.progressive&&Ka(e);var t=e.abrController,r=e.bufferController,s=e.capLevelController,o=e.errorController,l=e.fpsController,u=new o(this),d=this.abrController=new t(this),f=this.bufferController=new r(this),h=this.capLevelController=new s(this),c=new l(this),v=new Kn(this),g=new Qn(this),m=e.contentSteeringController,p=m?new m(this):null,y=this.levelController=new Wa(this,p),E=new Ya(this),S=new ja(this.config),L=this.streamController=new eo(this,E,S);h.setStreamController(L),c.setStreamController(L);var _=[v,y,L];p&&_.splice(1,0,p),this.networkControllers=_;var A=[d,f,h,c,g,E];this.audioTrackController=this.createController(e.audioTrackController,_);var T=e.audioStreamController;T&&_.push(new T(this,E,S)),this.subtitleTrackController=this.createController(e.subtitleTrackController,_);var b=e.subtitleStreamController;b&&_.push(new b(this,E,S)),this.createController(e.timelineController,A),S.emeController=this.emeController=this.createController(e.emeController,A),this.cmcdController=this.createController(e.cmcdController,A),this.latencyController=this.createController(Zn,A),this.coreComponents=A,_.push(u);var I=u.onErrorOut;typeof I=="function"&&this.on(x.ERROR,I,u)}var n=a.prototype;return n.createController=function(e,t){if(e){var r=new e(this);return t&&t.push(r),r}return null},n.on=function(e,t,r){r===void 0&&(r=this),this._emitter.on(e,t,r)},n.once=function(e,t,r){r===void 0&&(r=this),this._emitter.once(e,t,r)},n.removeAllListeners=function(e){this._emitter.removeAllListeners(e)},n.off=function(e,t,r,s){r===void 0&&(r=this),this._emitter.off(e,t,r,s)},n.listeners=function(e){return this._emitter.listeners(e)},n.emit=function(e,t,r){return this._emitter.emit(e,t,r)},n.trigger=function(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(s){if(R.error("An internal error happened while handling event "+e+'. Error message: "'+s.message+'". Here is a stacktrace:',s),!this.triggeringException){this.triggeringException=!0;var r=e===x.ERROR;this.trigger(x.ERROR,{type:V.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,fatal:r,event:e,error:s}),this.triggeringException=!1}}return!1},n.listenerCount=function(e){return this._emitter.listenerCount(e)},n.destroy=function(){R.log("destroy"),this.trigger(x.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},n.attachMedia=function(e){R.log("attachMedia"),this._media=e,this.trigger(x.MEDIA_ATTACHING,{media:e})},n.detachMedia=function(){R.log("detachMedia"),this.trigger(x.MEDIA_DETACHING,void 0),this._media=null},n.loadSource=function(e){this.stopLoad();var t=this.media,r=this.url,s=this.url=At.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,R.log("loadSource:"+s),t&&r&&(r!==s||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(x.MANIFEST_LOADING,{url:e})},n.startLoad=function(e){e===void 0&&(e=-1),R.log("startLoad("+e+")"),this.started=!0,this.networkControllers.forEach(function(t){t.startLoad(e)})},n.stopLoad=function(){R.log("stopLoad"),this.started=!1,this.networkControllers.forEach(function(e){e.stopLoad()})},n.resumeBuffering=function(){this.started&&this.networkControllers.forEach(function(e){"fragmentLoader"in e&&e.startLoad(-1)})},n.pauseBuffering=function(){this.networkControllers.forEach(function(e){"fragmentLoader"in e&&e.stopLoad()})},n.swapAudioCodec=function(){R.log("swapAudioCodec"),this.streamController.swapAudioCodec()},n.recoverMediaError=function(){R.log("recoverMediaError");var e=this._media;this.detachMedia(),e&&this.attachMedia(e)},n.removeLevel=function(e){this.levelController.removeLevel(e)},n.setAudioOption=function(e){var t;return(t=this.audioTrackController)==null?void 0:t.setAudioOption(e)},n.setSubtitleOption=function(e){var t;return(t=this.subtitleTrackController)==null||t.setSubtitleOption(e),null},me(a,[{key:"levels",get:function(){var e=this.levelController.levels;return e||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(e){R.log("set currentLevel:"+e),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){R.log("set nextLevel:"+e),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){R.log("set loadLevel:"+e),this.levelController.manualLevel=e}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(e){this.levelController.nextLoadLevel=e}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(e){R.log("set firstLevel:"+e),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){var e=this.levelController.startLevel;return e===-1&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e},set:function(e){R.log("set startLevel:"+e),e!==-1&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(e){var t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){this._autoLevelCapping!==e&&(R.log("set autoLevelCapping:"+e),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}},{key:"bandwidthEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimate():NaN},set:function(e){this.abrController.resetEstimator(e)}},{key:"ttfbEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimateTTFB():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(e){Jn(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var e=this.levels,t=this.config.minAutoBitrate;if(!e)return 0;for(var r=e.length,s=0;s<r;s++)if(e[s].maxBitrate>=t)return s;return 0}},{key:"maxAutoLevel",get:function(){var e=this.levels,t=this.autoLevelCapping,r=this.maxHdcpLevel,s;if(t===-1&&e!=null&&e.length?s=e.length-1:s=t,r)for(var o=s;o--;){var l=e[o].attrs["HDCP-LEVEL"];if(l&&l<=r)return o}return s}},{key:"firstAutoLevel",get:function(){return this.abrController.firstAutoLevel}},{key:"nextAutoLevel",get:function(){return this.abrController.nextAutoLevel},set:function(e){this.abrController.nextAutoLevel=e}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"allAudioTracks",get:function(){var e=this.audioTrackController;return e?e.allAudioTracks:[]}},{key:"audioTracks",get:function(){var e=this.audioTrackController;return e?e.audioTracks:[]}},{key:"audioTrack",get:function(){var e=this.audioTrackController;return e?e.audioTrack:-1},set:function(e){var t=this.audioTrackController;t&&(t.audioTrack=e)}},{key:"allSubtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}},{key:"subtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return e?e.subtitleDisplay:!1},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(e){this.config.lowLatencyMode=e}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.5.17"}},{key:"Events",get:function(){return x}},{key:"ErrorTypes",get:function(){return V}},{key:"ErrorDetails",get:function(){return D}},{key:"DefaultConfig",get:function(){return a.defaultConfig?a.defaultConfig:ai},set:function(e){a.defaultConfig=e}}]),a}();return Oi.defaultConfig=void 0,Oi})})(!1)});var To={};yo(To,{Hls:()=>qi.default});module.exports=xo(To);var qi=Eo(Yi(),1);
16
- ;if (typeof module.exports == "object" && typeof exports == "object") {
17
- var __cp = (to, from, except, desc) => {
18
- if ((from && typeof from === "object") || typeof from === "function") {
19
- for (let key of Object.getOwnPropertyNames(from)) {
20
- if (!Object.prototype.hasOwnProperty.call(to, key) && key !== except)
21
- Object.defineProperty(to, key, {
22
- get: () => from[key],
23
- enumerable: !(desc = Object.getOwnPropertyDescriptor(from, key)) || desc.enumerable,
24
- });
25
- }
26
- }
27
- return to;
28
- };
29
- module.exports = __cp(module.exports, exports);
30
- }
31
- return module.exports;
32
- }))
24
+ contiguous: `+P+`
25
+ accurateTimeOffset: `+G+`
26
+ timeOffset: `+F+`
27
+ initSegmentChange: `+C);var _=new Z9(J,X,Y,W,j);this.configureTransmuxer(_)}if(this.frag=z,this.part=N,this.workerContext)this.workerContext.worker.postMessage({instanceNo:E,cmd:"demux",data:Q,decryptdata:R,chunkMeta:K,state:x},Q instanceof ArrayBuffer?[Q]:[]);else if(B){var y=B.push(Q,R,K,x);if(o0(y))y.then(function(T){A.handleTransmuxComplete(T)}).catch(function(T){A.transmuxerError(T,K,"transmuxer-interface push error")});else this.handleTransmuxComplete(y)}},H.flush=function Z(Q){var Y=this;Q.transmuxing.start=self.performance.now();var J=this.instanceNo,X=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:J,cmd:"flush",chunkMeta:Q});else if(X){var z=X.flush(Q);if(o0(z))z.then(function(N){Y.handleFlushResult(N,Q)}).catch(function(N){Y.transmuxerError(N,Q,"transmuxer-interface flush error")});else this.handleFlushResult(z,Q)}},H.transmuxerError=function Z(Q,Y,J){if(!this.hls)return;this.error=Q,this.hls.trigger($.ERROR,{type:f.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,chunkMeta:Y,frag:this.frag||void 0,part:this.part||void 0,fatal:!1,error:Q,err:Q,reason:J})},H.handleFlushResult=function Z(Q,Y){var J=this;Q.forEach(function(X){J.handleTransmuxComplete(X)}),this.onFlush(Y)},H.configureTransmuxer=function Z(Q){var Y=this.instanceNo,J=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:Y,cmd:"configure",config:Q});else if(J)J.configure(Q)},H.handleTransmuxComplete=function Z(Q){Q.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(Q)},q}();function RJ(){return self.SourceBuffer||self.WebKitSourceBuffer}function MJ(){var q=d0();if(!q)return!1;var H=RJ();return!H||H.prototype&&typeof H.prototype.appendBuffer==="function"&&typeof H.prototype.remove==="function"}function i9(){if(!MJ())return!1;var q=d0();return typeof(q==null?void 0:q.isTypeSupported)==="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(function(H){return q.isTypeSupported(XY(H,"video"))})||["mp4a.40.2","fLaC"].some(function(H){return q.isTypeSupported(XY(H,"audio"))}))}function r9(){var q,H=RJ();return typeof(H==null?void 0:(q=H.prototype)==null?void 0:q.changeType)==="function"}var a9=100,t9=function(q){function H(Q,Y,J){var X=q.call(this,Q,Y,J,"stream-controller",d.MAIN)||this;return X.audioCodecSwap=!1,X.level=-1,X._forceStartLoad=!1,X._hasEnoughToStart=!1,X.altAudio=0,X.audioOnly=!1,X.fragPlaying=null,X.fragLastKbps=0,X.couldBacktrack=!1,X.backtrackFragment=null,X.audioCodecSwitch=!1,X.videoBuffer=null,X.onMediaPlaying=function(){X.tick()},X.onMediaSeeked=function(){var z=X.media,N=z?z.currentTime:null;if(N===null||!v(N))return;if(X.log("Media seeked to "+N.toFixed(3)),!X.getBufferedFrag(N))return;var W=X.getFwdBufferInfoAtPos(z,N,d.MAIN,0);if(W===null||W.len===0){X.warn("Main forward buffer length at "+N+' on "seeked" event '+(W?W.len:"empty")+")");return}X.tick()},X.registerListeners(),X}G0(H,q);var Z=H.prototype;return Z.registerListeners=function Q(){q.prototype.registerListeners.call(this);var Y=this.hls;Y.on($.MANIFEST_PARSED,this.onManifestParsed,this),Y.on($.LEVEL_LOADING,this.onLevelLoading,this),Y.on($.LEVEL_LOADED,this.onLevelLoaded,this),Y.on($.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),Y.on($.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),Y.on($.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),Y.on($.BUFFER_CREATED,this.onBufferCreated,this),Y.on($.BUFFER_FLUSHED,this.onBufferFlushed,this),Y.on($.LEVELS_UPDATED,this.onLevelsUpdated,this),Y.on($.FRAG_BUFFERED,this.onFragBuffered,this)},Z.unregisterListeners=function Q(){q.prototype.unregisterListeners.call(this);var Y=this.hls;Y.off($.MANIFEST_PARSED,this.onManifestParsed,this),Y.off($.LEVEL_LOADED,this.onLevelLoaded,this),Y.off($.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),Y.off($.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),Y.off($.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),Y.off($.BUFFER_CREATED,this.onBufferCreated,this),Y.off($.BUFFER_FLUSHED,this.onBufferFlushed,this),Y.off($.LEVELS_UPDATED,this.onLevelsUpdated,this),Y.off($.FRAG_BUFFERED,this.onFragBuffered,this)},Z.onHandlerDestroying=function Q(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),q.prototype.onHandlerDestroying.call(this)},Z.startLoad=function Q(Y,J){if(this.levels){var X=this.lastCurrentTime,z=this.hls;if(this.stopLoad(),this.setInterval(a9),this.level=-1,!this.startFragRequested){var N=z.startLevel;if(N===-1)if(z.config.testBandwidth&&this.levels.length>1)N=0,this.bitrateTest=!0;else N=z.firstAutoLevel;z.nextLoadLevel=N,this.level=z.loadLevel,this._hasEnoughToStart=!!J}if(X>0&&Y===-1&&!J)this.log("Override startPosition with lastCurrentTime @"+X.toFixed(3)),Y=X;this.state=k.IDLE,this.nextLoadPosition=this.lastCurrentTime=Y+this.timelineOffset,this.startPosition=J?-1:Y,this.tick()}else this._forceStartLoad=!0,this.state=k.STOPPED},Z.stopLoad=function Q(){this._forceStartLoad=!1,q.prototype.stopLoad.call(this)},Z.doTick=function Q(){switch(this.state){case k.WAITING_LEVEL:{var Y=this.levels,J=this.level,X=Y==null?void 0:Y[J],z=X==null?void 0:X.details;if(z&&(!z.live||this.levelLastLoaded===X&&!this.waitForLive(X))){if(this.waitForCdnTuneIn(z))break;this.state=k.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=k.IDLE;break}break}case k.FRAG_LOADING_WAITING_RETRY:{var N,W=self.performance.now(),G=this.retryDate;if(!G||W>=G||(N=this.media)!=null&&N.seeking){var K=this.levels,j=this.level,V=K==null?void 0:K[j];this.resetStartWhenNotLoaded(V||null),this.state=k.IDLE}}break}if(this.state===k.IDLE)this.doTickIdle();this.onTickEnd()},Z.onTickEnd=function Q(){var Y;if(q.prototype.onTickEnd.call(this),(Y=this.media)!=null&&Y.readyState&&this.media.seeking===!1)this.lastCurrentTime=this.media.currentTime;this.checkFragmentChanged()},Z.doTickIdle=function Q(){var Y=this.hls,J=this.levelLastLoaded,X=this.levels,z=this.media;if(J===null||!z&&!this.primaryPrefetch&&(this.startFragRequested||!Y.config.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;var N=this.buffering?Y.nextLoadLevel:Y.loadLevel;if(!(X!=null&&X[N]))return;var W=X[N],G=this.getMainFwdBufferInfo();if(G===null)return;var K=this.getLevelDetails();if(K&&this._streamEnded(G,K)){var j={};if(this.altAudio===2)j.type="video";this.hls.trigger($.BUFFER_EOS,j),this.state=k.ENDED;return}if(!this.buffering)return;if(Y.loadLevel!==N&&Y.manualLevel===-1)this.log("Adapting to level "+N+" from level "+this.level);this.level=Y.nextLoadLevel=N;var V=W.details;if(!V||this.state===k.WAITING_LEVEL||this.waitForLive(W)){this.level=N,this.state=k.WAITING_LEVEL,this.startFragRequested=!1;return}var U=G.len,A=this.getMaxBufferLength(W.maxBitrate);if(U>=A)return;if(this.backtrackFragment&&this.backtrackFragment.start>G.end)this.backtrackFragment=null;var E=this.backtrackFragment?this.backtrackFragment.start:G.end,B=this.getNextFragment(E,V);if(this.couldBacktrack&&!this.fragPrevious&&B&&k0(B)&&this.fragmentTracker.getState(B)!==O0.OK){var F,R=((F=this.backtrackFragment)!=null?F:B).sn,O=R-V.startSN,M=V.fragments[O-1];if(M&&B.cc===M.cc)B=M,this.fragmentTracker.removeFragment(M)}else if(this.backtrackFragment&&G.len)this.backtrackFragment=null;if(B&&this.isLoopLoading(B,E)){var L=B.gap;if(!L){var I=this.audioOnly&&!this.altAudio?Q0.AUDIO:Q0.VIDEO,w=(I===Q0.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;if(w)this.afterBufferFlushed(w,I,d.MAIN)}B=this.getNextFragmentLoopLoading(B,V,G,d.MAIN,A)}if(!B)return;if(B.initSegment&&!B.initSegment.data&&!this.bitrateTest)B=B.initSegment;this.loadFragment(B,W,E)},Z.loadFragment=function Q(Y,J,X){var z=this.fragmentTracker.getState(Y);if(z===O0.NOT_LOADED||z===O0.PARTIAL)if(!k0(Y))this._loadInitSegment(Y,J);else if(this.bitrateTest)this.log("Fragment "+Y.sn+" of level "+Y.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(Y,J);else q.prototype.loadFragment.call(this,Y,J,X);else this.clearTrackerIfNeeded(Y)},Z.getBufferedFrag=function Q(Y){return this.fragmentTracker.getBufferedFrag(Y,d.MAIN)},Z.followingBufferedFrag=function Q(Y){if(Y)return this.getBufferedFrag(Y.end+0.5);return null},Z.immediateLevelSwitch=function Q(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},Z.nextLevelSwitch=function Q(){var Y=this.levels,J=this.media;if(J!=null&&J.readyState){var X,z=this.getAppendedFrag(J.currentTime);if(z&&z.start>1)this.flushMainBuffer(0,z.start-1);var N=this.getLevelDetails();if(N!=null&&N.live){var W=this.getMainFwdBufferInfo();if(!W||W.len<N.targetduration*2)return}if(!J.paused&&Y){var G=this.hls.nextLoadLevel,K=Y[G],j=this.fragLastKbps;if(j&&this.fragCurrent)X=this.fragCurrent.duration*K.maxBitrate/(1000*j)+1;else X=0}else X=0;var V=this.getBufferedFrag(J.currentTime+X);if(V){var U=this.followingBufferedFrag(V);if(U){this.abortCurrentFrag();var A=U.maxStartPTS?U.maxStartPTS:U.start,E=U.duration,B=Math.max(V.end,A+Math.min(Math.max(E-this.config.maxFragLookUpTolerance,E*(this.couldBacktrack?0.5:0.125)),E*(this.couldBacktrack?0.75:0.25)));this.flushMainBuffer(B,Number.POSITIVE_INFINITY)}}}},Z.abortCurrentFrag=function Q(){var Y=this.fragCurrent;if(this.fragCurrent=null,this.backtrackFragment=null,Y)Y.abortRequests(),this.fragmentTracker.removeFragment(Y);switch(this.state){case k.KEY_LOADING:case k.FRAG_LOADING:case k.FRAG_LOADING_WAITING_RETRY:case k.PARSING:case k.PARSED:this.state=k.IDLE;break}this.nextLoadPosition=this.getLoadPosition()},Z.flushMainBuffer=function Q(Y,J){q.prototype.flushMainBuffer.call(this,Y,J,this.altAudio===2?"video":null)},Z.onMediaAttached=function Q(Y,J){q.prototype.onMediaAttached.call(this,Y,J);var X=J.media;GY(X,"playing",this.onMediaPlaying),GY(X,"seeked",this.onMediaSeeked)},Z.onMediaDetaching=function Q(Y,J){var X=this.media;if(X)YY(X,"playing",this.onMediaPlaying),YY(X,"seeked",this.onMediaSeeked);this.videoBuffer=null,this.fragPlaying=null,q.prototype.onMediaDetaching.call(this,Y,J);var z=!!J.transferMedia;if(z)return;this._hasEnoughToStart=!1},Z.onManifestLoading=function Q(){q.prototype.onManifestLoading.call(this),this.log("Trigger BUFFER_RESET"),this.hls.trigger($.BUFFER_RESET,void 0),this.couldBacktrack=!1,this.fragLastKbps=0,this.fragPlaying=this.backtrackFragment=null,this.altAudio=0,this.audioOnly=!1},Z.onManifestParsed=function Q(Y,J){var X=!1,z=!1;if(J.levels.forEach(function(N){var W=N.audioCodec;if(W)X=X||W.indexOf("mp4a.40.2")!==-1,z=z||W.indexOf("mp4a.40.5")!==-1}),this.audioCodecSwitch=X&&z&&!r9(),this.audioCodecSwitch)this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC");this.levels=J.levels,this.startFragRequested=!1},Z.onLevelLoading=function Q(Y,J){var X=this.levels;if(!X||this.state!==k.IDLE)return;var z=J.levelInfo;if(!z.details||z.details.live&&(this.levelLastLoaded!==z||z.details.expired)||this.waitForCdnTuneIn(z.details))this.state=k.WAITING_LEVEL},Z.onLevelLoaded=function Q(Y,J){var X,z=this.levels,N=this.startFragRequested,W=J.level,G=J.details,K=G.totalduration;if(!z){this.warn("Levels were reset while loading level "+W);return}this.log("Level "+W+" loaded ["+G.startSN+","+G.endSN+"]"+(G.lastPartSn?"[part-"+G.lastPartSn+"-"+G.lastPartIndex+"]":"")+", cc ["+G.startCC+", "+G.endCC+"] duration:"+K);var j=J.levelInfo,V=this.fragCurrent;if(V&&(this.state===k.FRAG_LOADING||this.state===k.FRAG_LOADING_WAITING_RETRY)){if(V.level!==J.level&&V.loader)this.abortCurrentFrag()}var U=0;if(G.live||(X=j.details)!=null&&X.live){var A;if(this.checkLiveUpdate(G),G.deltaUpdateFailed)return;U=this.alignPlaylists(G,j.details,(A=this.levelLastLoaded)==null?void 0:A.details)}if(j.details=G,this.levelLastLoaded=j,!N)this.setStartPosition(G,U);if(this.hls.trigger($.LEVEL_UPDATED,{details:G,level:W}),this.state===k.WAITING_LEVEL){if(this.waitForCdnTuneIn(G))return;this.state=k.IDLE}if(N&&G.live)this.synchronizeToLiveEdge(G);this.tick()},Z.synchronizeToLiveEdge=function Q(Y){var J=this.config,X=this.media;if(!X)return;var z=this.hls.liveSyncPosition,N=this.getLoadPosition(),W=Y.fragmentStart,G=Y.edge,K=N>=W-J.maxFragLookUpTolerance&&N<=G;if(z!==null&&X.duration>z&&(N<z||!K)){var j=J.liveMaxLatencyDuration!==void 0?J.liveMaxLatencyDuration:J.liveMaxLatencyDurationCount*Y.targetduration;if(!K&&X.readyState<4||N<G-j){if(!this._hasEnoughToStart)this.nextLoadPosition=z;if(X.readyState)this.warn("Playback: "+N.toFixed(3)+" is located too far from the end of live sliding playlist: "+G+", reset currentTime to : "+z.toFixed(3)),X.currentTime=z}}},Z._handleFragmentLoadProgress=function Q(Y){var J,X=Y.frag,z=Y.part,N=Y.payload,W=this.levels;if(!W){this.warn("Levels were reset while fragment load was in progress. Fragment "+X.sn+" of level "+X.level+" will not be buffered");return}var G=W[X.level];if(!G){this.warn("Level "+X.level+" not found on progress");return}var K=G.details;if(!K){this.warn("Dropping fragment "+X.sn+" of level "+X.level+" after level details were reset"),this.fragmentTracker.removeFragment(X);return}var j=G.videoCodec,V=K.PTSKnown||!K.live,U=(J=X.initSegment)==null?void 0:J.data,A=this._getAudioCodec(G),E=this.transmuxer=this.transmuxer||new s9(this.hls,d.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),B=z?z.index:-1,F=B!==-1,R=new GJ(X.level,X.sn,X.stats.chunkCount,N.byteLength,B,F),O=this.initPTS[X.cc];E.push(N,U,A,j,X,z,K.totalduration,V,R,O)},Z.onAudioTrackSwitching=function Q(Y,J){var X=this,z=this.hls,N=this.altAudio===2,W=XQ(J.url,z);if(!W){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var G=this.fragCurrent;if(G)this.log("Switching to main audio track, cancel main fragment load"),G.abortRequests(),this.fragmentTracker.removeFragment(G);this.resetTransmuxer(),this.resetLoadingState()}else if(this.audioOnly)this.resetTransmuxer();if(N){this.fragmentTracker.removeAllFragments(),z.once($.BUFFER_FLUSHED,function(){var K;(K=X.hls)==null||K.trigger($.AUDIO_TRACK_SWITCHED,J)}),z.trigger($.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});return}z.trigger($.AUDIO_TRACK_SWITCHED,J)}else this.altAudio=1},Z.onAudioTrackSwitched=function Q(Y,J){var X=XQ(J.url,this.hls);if(X){var z=this.videoBuffer;if(z&&this.mediaBuffer!==z)this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=z}this.altAudio=X?2:0,this.tick()},Z.onBufferCreated=function Q(Y,J){var X=J.tracks,z,N,W=!1;for(var G in X){var K=X[G];if(K.id==="main"){if(N=G,z=K,G==="video"){var j=X[G];if(j)this.videoBuffer=j.buffer}}else W=!0}if(W&&z)this.log("Alternate track found, use "+N+".buffered to schedule main fragment loading"),this.mediaBuffer=z.buffer;else this.mediaBuffer=this.media},Z.onFragBuffered=function Q(Y,J){var{frag:X,part:z}=J,N=X.type===d.MAIN;if(N){if(this.fragContextChanged(X)){if(this.warn("Fragment "+X.sn+(z?" p: "+z.index:"")+" of level "+X.level+" finished buffering, but was aborted. state: "+this.state),this.state===k.PARSED)this.state=k.IDLE;return}var W=z?z.stats:X.stats;if(this.fragLastKbps=Math.round(8*W.total/(W.buffering.end-W.loading.first)),k0(X))this.fragPrevious=X;this.fragBufferedComplete(X,z)}var G=this.media;if(!G)return;if(!this._hasEnoughToStart&&i.getBuffered(G).length)this._hasEnoughToStart=!0,this.seekToStartPos();if(N)this.tick()},Z.onError=function Q(Y,J){var X;if(J.fatal){this.state=k.ERROR;return}switch(J.details){case D.FRAG_GAP:case D.FRAG_PARSING_ERROR:case D.FRAG_DECRYPT_ERROR:case D.FRAG_LOAD_ERROR:case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_ERROR:case D.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(d.MAIN,J);break;case D.LEVEL_LOAD_ERROR:case D.LEVEL_LOAD_TIMEOUT:case D.LEVEL_PARSING_ERROR:if(!J.levelRetry&&this.state===k.WAITING_LEVEL&&((X=J.context)==null?void 0:X.type)===o.LEVEL)this.state=k.IDLE;break;case D.BUFFER_ADD_CODEC_ERROR:case D.BUFFER_APPEND_ERROR:if(J.parent!=="main")return;this.resetLoadingState();break;case D.BUFFER_FULL_ERROR:if(J.parent!=="main")return;if(this.reduceLengthAndFlushBuffer(J))this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case D.INTERNAL_EXCEPTION:this.recoverWorkerError(J);break}},Z.onFragLoadEmergencyAborted=function Q(){if(this.state=k.IDLE,!this._hasEnoughToStart)this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime;this.tickImmediate()},Z.onBufferFlushed=function Q(Y,J){var X=J.type;if(X!==Q0.AUDIO||!this.altAudio){var z=(X===Q0.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;if(z)this.afterBufferFlushed(z,X,d.MAIN),this.tick()}},Z.onLevelsUpdated=function Q(Y,J){if(this.level>-1&&this.fragCurrent){if(this.level=this.fragCurrent.level,this.level===-1)this.resetWhenMissingContext(this.fragCurrent)}this.levels=J.levels},Z.swapAudioCodec=function Q(){this.audioCodecSwap=!this.audioCodecSwap},Z.seekToStartPos=function Q(){var Y=this.media;if(!Y)return;var J=Y.currentTime,X=this.startPosition;if(X>=0&&J<X){if(Y.seeking){this.log("could not seek to "+X+", already seeking at "+J);return}var z=this.timelineOffset;if(z&&X)X+=z;var N=this.getLevelDetails(),W=i.getBuffered(Y),G=W.length?W.start(0):0,K=G-X,j=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);if(K>0&&(K<j||this.loadingParts&&K<2*((N==null?void 0:N.partTarget)||0)))this.log("adjusting start position by "+K+" to match buffer start"),X+=K,this.startPosition=X;if(J<X)this.log("seek to target start position "+X+" from current time "+J+" buffer start "+G),Y.currentTime=X}},Z._getAudioCodec=function Q(Y){var J=this.config.defaultAudioCodec||Y.audioCodec;if(this.audioCodecSwap&&J)if(this.log("Swapping audio codec"),J.indexOf("mp4a.40.5")!==-1)J="mp4a.40.2";else J="mp4a.40.5";return J},Z._loadBitrateTestFrag=function Q(Y,J){var X=this;Y.bitrateTest=!0,this._doFragLoad(Y,J).then(function(z){var N=X.hls,W=z==null?void 0:z.frag;if(!W||X.fragContextChanged(W))return;J.fragmentError=0,X.state=k.IDLE,X.startFragRequested=!1,X.bitrateTest=!1;var G=W.stats;G.parsing.start=G.parsing.end=G.buffering.start=G.buffering.end=self.performance.now(),N.trigger($.FRAG_LOADED,z),W.bitrateTest=!1})},Z._handleTransmuxComplete=function Q(Y){var J,X=this.playlistType,z=this.hls,N=Y.remuxResult,W=Y.chunkMeta,G=this.getCurrentContext(W);if(!G){this.resetWhenMissingContext(W);return}var{frag:K,part:j,level:V}=G,U=N.video,A=N.text,E=N.id3,B=N.initSegment,F=V.details,R=this.altAudio?void 0:N.audio;if(this.fragContextChanged(K)){this.fragmentTracker.removeFragment(K);return}if(this.state=k.PARSING,B){if(B!=null&&B.tracks){var O=K.initSegment||K;this._bufferInitSegment(V,B.tracks,O,W),z.trigger($.FRAG_PARSING_INIT_SEGMENT,{frag:O,id:X,tracks:B.tracks})}var{initPTS:M,timescale:L}=B;if(v(M))this.initPTS[K.cc]={baseTime:M,timescale:L},z.trigger($.INIT_PTS_FOUND,{frag:K,id:X,initPTS:M,timescale:L})}if(U&&F){var I=F.fragments[K.sn-1-F.startSN],w=K.sn===F.startSN,S=!I||K.cc>I.cc;if(N.independent!==!1){var{startPTS:P,endPTS:b,startDTS:C,endDTS:x}=U;if(j)j.elementaryStreams[U.type]={startPTS:P,endPTS:b,startDTS:C,endDTS:x};else{if(U.firstKeyFrame&&U.independent&&W.id===1&&!S)this.couldBacktrack=!0;if(U.dropped&&U.independent){var _=this.getMainFwdBufferInfo(),y=(_?_.end:this.getLoadPosition())+this.config.maxBufferHole,T=U.firstKeyFramePTS?U.firstKeyFramePTS:P;if(!w&&y<T-this.config.maxBufferHole&&!S){this.backtrack(K);return}else if(S)K.gap=!0;K.setElementaryStreamInfo(U.type,K.start,b,K.start,x,!0)}else if(w&&P-(F.appliedTimelineOffset||0)>TY)K.gap=!0}if(K.setElementaryStreamInfo(U.type,P,b,C,x),this.backtrackFragment)this.backtrackFragment=K;this.bufferFragmentData(U,K,j,W,w||S)}else if(w||S)K.gap=!0;else{this.backtrack(K);return}}if(R){var{startPTS:h,endPTS:g,startDTS:m,endDTS:p}=R;if(j)j.elementaryStreams[Q0.AUDIO]={startPTS:h,endPTS:g,startDTS:m,endDTS:p};K.setElementaryStreamInfo(Q0.AUDIO,h,g,m,p),this.bufferFragmentData(R,K,j,W)}if(F&&E!=null&&(J=E.samples)!=null&&J.length){var r={id:X,frag:K,details:F,samples:E.samples};z.trigger($.FRAG_PARSING_METADATA,r)}if(F&&A){var n={id:X,frag:K,details:F,samples:A.samples};z.trigger($.FRAG_PARSING_USERDATA,n)}},Z._bufferInitSegment=function Q(Y,J,X,z){var N=this;if(this.state!==k.PARSING)return;if(this.audioOnly=!!J.audio&&!J.video,this.altAudio&&!this.audioOnly)delete J.audio;var{audio:W,video:G,audiovideo:K}=J;if(W){var j=$Y(W.codec,Y.audioCodec);if(j==="mp4a")j="mp4a.40.5";var V=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){if(j)if(j.indexOf("mp4a.40.5")!==-1)j="mp4a.40.2";else j="mp4a.40.5";var U=W.metadata;if(U&&"channelCount"in U&&(U.channelCount||1)!==1&&V.indexOf("firefox")===-1)j="mp4a.40.5"}if(j&&j.indexOf("mp4a.40.5")!==-1&&V.indexOf("android")!==-1&&W.container!=="audio/mpeg")j="mp4a.40.2",this.log("Android: force audio codec to "+j);if(Y.audioCodec&&Y.audioCodec!==j)this.log('Swapping manifest audio codec "'+Y.audioCodec+'" for "'+j+'"');W.levelCodec=j,W.id=d.MAIN,this.log("Init audio buffer, container:"+W.container+", codecs[selected/level/parsed]=["+(j||"")+"/"+(Y.audioCodec||"")+"/"+W.codec+"]"),delete J.audiovideo}if(G){G.levelCodec=Y.videoCodec,G.id=d.MAIN;var A=G.codec;if((A==null?void 0:A.length)===4)switch(A){case"hvc1":case"hev1":G.codec="hvc1.1.6.L120.90";break;case"av01":G.codec="av01.0.04M.08";break;case"avc1":G.codec="avc1.42e01e";break}this.log("Init video buffer, container:"+G.container+", codecs[level/parsed]=["+(Y.videoCodec||"")+"/"+A+"]"+(G.codec!==A?" parsed-corrected="+G.codec:"")+(G.supplemental?" supplemental="+G.supplemental:"")),delete J.audiovideo}if(K)this.log("Init audiovideo buffer, container:"+K.container+", codecs[level/parsed]=["+Y.codecs+"/"+K.codec+"]"),delete J.video,delete J.audio;var E=Object.keys(J);if(E.length){if(this.hls.trigger($.BUFFER_CODECS,J),!this.hls)return;E.forEach(function(B){var F=J[B],R=F.initSegment;if(R!=null&&R.byteLength)N.hls.trigger($.BUFFER_APPENDING,{type:B,data:R,frag:X,part:null,chunkMeta:z,parent:X.type})})}this.tickImmediate()},Z.getMainFwdBufferInfo=function Q(){var Y=this.mediaBuffer&&this.altAudio===2?this.mediaBuffer:this.media;return this.getFwdBufferInfo(Y,d.MAIN)},Z.backtrack=function Q(Y){this.couldBacktrack=!0,this.backtrackFragment=Y,this.resetTransmuxer(),this.flushBufferGap(Y),this.fragmentTracker.removeFragment(Y),this.fragPrevious=null,this.nextLoadPosition=Y.start,this.state=k.IDLE},Z.checkFragmentChanged=function Q(){var Y=this.media,J=null;if(Y&&Y.readyState>1&&Y.seeking===!1){var X=Y.currentTime;if(i.isBuffered(Y,X))J=this.getAppendedFrag(X);else if(i.isBuffered(Y,X+0.1))J=this.getAppendedFrag(X+0.1);if(J){this.backtrackFragment=null;var z=this.fragPlaying,N=J.level;if(!z||J.sn!==z.sn||z.level!==N){if(this.fragPlaying=J,this.hls.trigger($.FRAG_CHANGED,{frag:J}),!z||z.level!==N)this.hls.trigger($.LEVEL_SWITCHED,{level:N})}}}},Z0(H,[{key:"hasEnoughToStart",get:function Q(){return this._hasEnoughToStart}},{key:"maxBufferLength",get:function Q(){var Y=this.levels,J=this.level,X=Y==null?void 0:Y[J];if(!X)return this.config.maxBufferLength;return this.getMaxBufferLength(X.maxBitrate)}},{key:"nextLevel",get:function Q(){var Y=this.nextBufferedFrag;if(Y)return Y.level;return-1}},{key:"currentFrag",get:function Q(){var Y;if(this.fragPlaying)return this.fragPlaying;var J=((Y=this.media)==null?void 0:Y.currentTime)||this.lastCurrentTime;if(v(J))return this.getAppendedFrag(J);return null}},{key:"currentProgramDateTime",get:function Q(){var Y,J=((Y=this.media)==null?void 0:Y.currentTime)||this.lastCurrentTime;if(v(J)){var X=this.getLevelDetails(),z=this.currentFrag||(X?eY(null,X.fragments,J):null);if(z){var N=z.programDateTime;if(N!==null){var W=N+(J-z.start)*1000;return new Date(W)}}}return null}},{key:"currentLevel",get:function Q(){var Y=this.currentFrag;if(Y)return Y.level;return-1}},{key:"nextBufferedFrag",get:function Q(){var Y=this.currentFrag;if(Y)return this.followingBufferedFrag(Y);return null}},{key:"forceStartLoad",get:function Q(){return this._forceStartLoad}}])}(L9),e9=function(){function q(Z){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=Z}var H=q.prototype;return H.abort=function Z(Q){for(var Y in this.keyUriToKeyInfo){var J=this.keyUriToKeyInfo[Y].loader;if(J){var X;if(Q&&Q!==((X=J.context)==null?void 0:X.frag.type))return;J.abort()}}},H.detach=function Z(){for(var Q in this.keyUriToKeyInfo){var Y=this.keyUriToKeyInfo[Q];if(Y.mediaKeySessionContext||Y.decryptdata.isCommonEncryption)delete this.keyUriToKeyInfo[Q]}},H.destroy=function Z(){this.detach();for(var Q in this.keyUriToKeyInfo){var Y=this.keyUriToKeyInfo[Q].loader;if(Y)Y.destroy()}this.keyUriToKeyInfo={}},H.createKeyLoadError=function Z(Q,Y,J,X,z){if(Y===void 0)Y=D.KEY_LOAD_ERROR;return new c0({type:f.NETWORK_ERROR,details:Y,fatal:!1,frag:Q,response:z,error:J,networkDetails:X})},H.loadClear=function Z(Q,Y){var J=this;if(this.emeController&&this.config.emeEnabled){var{sn:X,cc:z}=Q,N=function G(){var K=Y[W];if(z<=K.cc&&(X==="initSegment"||K.sn==="initSegment"||X<K.sn))return J.emeController.selectKeySystemFormat(K).then(function(j){K.setKeyFormat(j)}),1};for(var W=0;W<Y.length;W++)if(N())break}},H.load=function Z(Q){var Y=this;if(!Q.decryptdata&&Q.encrypted&&this.emeController&&this.config.emeEnabled)return this.emeController.selectKeySystemFormat(Q).then(function(J){return Y.loadInternal(Q,J)});return this.loadInternal(Q)},H.loadInternal=function Z(Q,Y){var J,X;if(Y)Q.setKeyFormat(Y);var z=Q.decryptdata;if(!z){var N=new Error(Y?"Expected frag.decryptdata to be defined after setting format "+Y:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(Q,D.KEY_LOAD_ERROR,N))}var W=z.uri;if(!W)return Promise.reject(this.createKeyLoadError(Q,D.KEY_LOAD_ERROR,new Error('Invalid key URI: "'+W+'"')));var G=this.keyUriToKeyInfo[W];if((J=G)!=null&&J.decryptdata.key)return z.key=G.decryptdata.key,Promise.resolve({frag:Q,keyInfo:G});if((X=G)!=null&&X.keyLoadPromise){var K;switch((K=G.mediaKeySessionContext)==null?void 0:K.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return G.keyLoadPromise.then(function(j){return z.key=j.keyInfo.decryptdata.key,{frag:Q,keyInfo:G}})}}switch(G=this.keyUriToKeyInfo[W]={decryptdata:z,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},z.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":if(z.keyFormat==="identity")return this.loadKeyHTTP(G,Q);return this.loadKeyEME(G,Q);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(G,Q);default:return Promise.reject(this.createKeyLoadError(Q,D.KEY_LOAD_ERROR,new Error('Key supplied with unsupported METHOD: "'+z.method+'"')))}},H.loadKeyEME=function Z(Q,Y){var J={frag:Y,keyInfo:Q};if(this.emeController&&this.config.emeEnabled){var X=this.emeController.loadKey(J);if(X)return(Q.keyLoadPromise=X.then(function(z){return Q.mediaKeySessionContext=z,J})).catch(function(z){throw Q.keyLoadPromise=null,z})}return Promise.resolve(J)},H.loadKeyHTTP=function Z(Q,Y){var J=this,X=this.config,z=X.loader,N=new z(X);return Y.keyLoader=Q.loader=N,Q.keyLoadPromise=new Promise(function(W,G){var K={keyInfo:Q,frag:Y,responseType:"arraybuffer",url:Q.decryptdata.uri},j=X.keyLoadPolicy.default,V={loadPolicy:j,timeout:j.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},U={onSuccess:function A(E,B,F,R){var{frag:O,keyInfo:M,url:L}=F;if(!O.decryptdata||M!==J.keyUriToKeyInfo[L])return G(J.createKeyLoadError(O,D.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),R));M.decryptdata.key=O.decryptdata.key=new Uint8Array(E.data),O.keyLoader=null,M.loader=null,W({frag:O,keyInfo:M})},onError:function A(E,B,F,R){J.resetLoader(B),G(J.createKeyLoadError(Y,D.KEY_LOAD_ERROR,new Error("HTTP Error "+E.code+" loading key "+E.text),F,F0({url:K.url,data:void 0},E)))},onTimeout:function A(E,B,F){J.resetLoader(B),G(J.createKeyLoadError(Y,D.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),F))},onAbort:function A(E,B,F){J.resetLoader(B),G(J.createKeyLoadError(Y,D.INTERNAL_ABORTED,new Error("key loading aborted"),F))}};N.load(K,V,U)})},H.resetLoader=function Z(Q){var{frag:Y,keyInfo:J,url:X}=Q,z=J.loader;if(Y.keyLoader===z)Y.keyLoader=null,J.loader=null;if(delete this.keyUriToKeyInfo[X],z)z.destroy()},q}();function IJ(q){var H=q.type;switch(H){case o.AUDIO_TRACK:return d.AUDIO;case o.SUBTITLE_TRACK:return d.SUBTITLE;default:return d.MAIN}}function R7(q,H){var Z=q.url;if(Z===void 0||Z.indexOf("data:")===0)Z=H.url;return Z}var Yq=function(){function q(Z){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=Z,this.registerListeners()}var H=q.prototype;return H.startLoad=function Z(Q){},H.stopLoad=function Z(){this.destroyInternalLoaders()},H.registerListeners=function Z(){var Q=this.hls;Q.on($.MANIFEST_LOADING,this.onManifestLoading,this),Q.on($.LEVEL_LOADING,this.onLevelLoading,this),Q.on($.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),Q.on($.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),Q.on($.LEVELS_UPDATED,this.onLevelsUpdated,this)},H.unregisterListeners=function Z(){var Q=this.hls;Q.off($.MANIFEST_LOADING,this.onManifestLoading,this),Q.off($.LEVEL_LOADING,this.onLevelLoading,this),Q.off($.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),Q.off($.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),Q.off($.LEVELS_UPDATED,this.onLevelsUpdated,this)},H.createInternalLoader=function Z(Q){var Y=this.hls.config,J=Y.pLoader,X=Y.loader,z=J||X,N=new z(Y);return this.loaders[Q.type]=N,N},H.getInternalLoader=function Z(Q){return this.loaders[Q.type]},H.resetInternalLoader=function Z(Q){if(this.loaders[Q])delete this.loaders[Q]},H.destroyInternalLoaders=function Z(){for(var Q in this.loaders){var Y=this.loaders[Q];if(Y)Y.destroy();this.resetInternalLoader(Q)}},H.destroy=function Z(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()},H.onManifestLoading=function Z(Q,Y){var J=Y.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:o.MANIFEST,url:J,deliveryDirectives:null,levelOrTrack:null})},H.onLevelLoading=function Z(Q,Y){var{id:J,level:X,pathwayId:z,url:N,deliveryDirectives:W,levelInfo:G}=Y;this.load({id:J,level:X,pathwayId:z,responseType:"text",type:o.LEVEL,url:N,deliveryDirectives:W,levelOrTrack:G})},H.onAudioTrackLoading=function Z(Q,Y){var{id:J,groupId:X,url:z,deliveryDirectives:N,track:W}=Y;this.load({id:J,groupId:X,level:null,responseType:"text",type:o.AUDIO_TRACK,url:z,deliveryDirectives:N,levelOrTrack:W})},H.onSubtitleTrackLoading=function Z(Q,Y){var{id:J,groupId:X,url:z,deliveryDirectives:N,track:W}=Y;this.load({id:J,groupId:X,level:null,responseType:"text",type:o.SUBTITLE_TRACK,url:z,deliveryDirectives:N,levelOrTrack:W})},H.onLevelsUpdated=function Z(Q,Y){var J=this.loaders[o.LEVEL];if(J){var X=J.context;if(X&&!Y.levels.some(function(z){return z===X.levelOrTrack}))J.abort(),delete this.loaders[o.LEVEL]}},H.load=function Z(Q){var Y,J=this,X=this.hls.config,z=this.getInternalLoader(Q);if(z){var N=this.hls.logger,W=z.context;if(W&&W.levelOrTrack===Q.levelOrTrack&&(W.url===Q.url||W.deliveryDirectives&&!Q.deliveryDirectives)){if(W.url===Q.url)N.log("[playlist-loader]: ignore "+Q.url+" ongoing request");else N.log("[playlist-loader]: ignore "+Q.url+" in favor of "+W.url);return}N.log("[playlist-loader]: aborting previous loader for type: "+Q.type),z.abort()}var G;if(Q.type===o.MANIFEST)G=X.manifestLoadPolicy.default;else G=W0({},X.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null});if(z=this.createInternalLoader(Q),v((Y=Q.deliveryDirectives)==null?void 0:Y.part)){var K;if(Q.type===o.LEVEL&&Q.level!==null)K=this.hls.levels[Q.level].details;else if(Q.type===o.AUDIO_TRACK&&Q.id!==null)K=this.hls.audioTracks[Q.id].details;else if(Q.type===o.SUBTITLE_TRACK&&Q.id!==null)K=this.hls.subtitleTracks[Q.id].details;if(K){var{partTarget:j,targetduration:V}=K;if(j&&V){var U=Math.max(j*3,V*0.8)*1000;G=W0({},G,{maxTimeToFirstByteMs:Math.min(U,G.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(U,G.maxTimeToFirstByteMs)})}}}var A=G.errorRetry||G.timeoutRetry||{},E={loadPolicy:G,timeout:G.maxLoadTimeMs,maxRetry:A.maxNumRetry||0,retryDelay:A.retryDelayMs||0,maxRetryDelay:A.maxRetryDelayMs||0},B={onSuccess:function F(R,O,M,L){var I=J.getInternalLoader(M);J.resetInternalLoader(M.type);var w=R.data;if(w.indexOf("#EXTM3U")!==0){J.handleManifestParsingError(R,M,new Error("no EXTM3U delimiter"),L||null,O);return}if(O.parsing.start=performance.now(),zY.isMediaPlaylist(w)||M.type!==o.MANIFEST)J.handleTrackOrLevelPlaylist(R,O,M,L||null,I);else J.handleMasterPlaylist(R,O,M,L)},onError:function F(R,O,M,L){J.handleNetworkError(O,M,!1,R,L)},onTimeout:function F(R,O,M){J.handleNetworkError(O,M,!0,void 0,R)}};z.load(Q,E,B)},H.checkAutostartLoad=function Z(){if(!this.hls)return;var Q=this.hls,Y=Q.config,J=Y.autoStartLoad,X=Y.startPosition,z=Q.forceStartLoad;if(J||z)this.hls.logger.log((J?"auto":"force")+" startLoad with configured startPosition "+X),this.hls.startLoad(X)},H.handleMasterPlaylist=function Z(Q,Y,J,X){var z=this.hls,N=Q.data,W=R7(Q,J),G=zY.parseMasterPlaylist(N,W);if(G.playlistParsingError){this.handleManifestParsingError(Q,J,G.playlistParsingError,X,Y);return}var{contentSteering:K,levels:j,sessionData:V,sessionKeys:U,startTimeOffset:A,variableList:E}=G;this.variableList=E;var B=zY.parseMasterPlaylistMedia(N,W,G),F=B.AUDIO,R=F===void 0?[]:F,O=B.SUBTITLES,M=B["CLOSED-CAPTIONS"];if(R.length){var L=R.some(function(I){return!I.url});if(!L&&j[0].audioCodec&&!j[0].attrs.AUDIO)this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),R.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new H0({}),bitrate:0,url:""})}z.trigger($.MANIFEST_LOADED,{levels:j,audioTracks:R,subtitles:O,captions:M,contentSteering:K,url:W,stats:Y,networkDetails:X,sessionData:V,sessionKeys:U,startTimeOffset:A,variableList:E})},H.handleTrackOrLevelPlaylist=function Z(Q,Y,J,X,z){var N=this.hls,W=J.id,G=J.level,K=J.type,j=R7(Q,J),V=v(G)?G:v(W)?W:0,U=IJ(J),A=zY.parseLevelPlaylist(Q.data,j,V,U,0,this.variableList);if(K===o.MANIFEST){var E={attrs:new H0({}),bitrate:0,details:A,name:"",url:j};A.requestScheduled=Y.loading.start+SQ(A,0),N.trigger($.MANIFEST_LOADED,{levels:[E],audioTracks:[],url:j,stats:Y,networkDetails:X,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}Y.parsing.end=performance.now(),J.levelDetails=A,this.handlePlaylistLoaded(A,Q,Y,J,X,z)},H.handleManifestParsingError=function Z(Q,Y,J,X,z){this.hls.trigger($.ERROR,{type:f.NETWORK_ERROR,details:D.MANIFEST_PARSING_ERROR,fatal:Y.type===o.MANIFEST,url:Q.url,err:J,error:J,reason:J.message,response:Q,context:Y,networkDetails:X,stats:z})},H.handleNetworkError=function Z(Q,Y,J,X,z){if(J===void 0)J=!1;var N="A network "+(J?"timeout":"error"+(X?" (status "+X.code+")":""))+" occurred while loading "+Q.type;if(Q.type===o.LEVEL)N+=": "+Q.level+" id: "+Q.id;else if(Q.type===o.AUDIO_TRACK||Q.type===o.SUBTITLE_TRACK)N+=" id: "+Q.id+' group-id: "'+Q.groupId+'"';var W=new Error(N);this.hls.logger.warn("[playlist-loader]: "+N);var G=D.UNKNOWN,K=!1,j=this.getInternalLoader(Q);switch(Q.type){case o.MANIFEST:G=J?D.MANIFEST_LOAD_TIMEOUT:D.MANIFEST_LOAD_ERROR,K=!0;break;case o.LEVEL:G=J?D.LEVEL_LOAD_TIMEOUT:D.LEVEL_LOAD_ERROR,K=!1;break;case o.AUDIO_TRACK:G=J?D.AUDIO_TRACK_LOAD_TIMEOUT:D.AUDIO_TRACK_LOAD_ERROR,K=!1;break;case o.SUBTITLE_TRACK:G=J?D.SUBTITLE_TRACK_LOAD_TIMEOUT:D.SUBTITLE_LOAD_ERROR,K=!1;break}if(j)this.resetInternalLoader(Q.type);var V={type:f.NETWORK_ERROR,details:G,fatal:K,url:Q.url,loader:j,context:Q,error:W,networkDetails:Y,stats:z};if(X){var U=(Y==null?void 0:Y.url)||Q.url;V.response=F0({url:U,data:void 0},X)}this.hls.trigger($.ERROR,V)},H.handlePlaylistLoaded=function Z(Q,Y,J,X,z,N){var W=this.hls,G=X.type,K=X.level,j=X.id,V=X.groupId,U=X.deliveryDirectives,A=R7(Y,X),E=IJ(X),B=typeof X.level==="number"&&E===d.MAIN?K:void 0;if(!Q.fragments.length){var F=Q.playlistParsingError=new Error("No Segments found in Playlist");W.trigger($.ERROR,{type:f.NETWORK_ERROR,details:D.LEVEL_EMPTY_ERROR,fatal:!1,url:A,error:F,reason:F.message,response:Y,context:X,level:B,parent:E,networkDetails:z,stats:J});return}if(!Q.targetduration)Q.playlistParsingError=new Error("Missing Target Duration");var R=Q.playlistParsingError;if(R){if(this.hls.logger.warn(R),!W.config.ignorePlaylistParsingErrors){W.trigger($.ERROR,{type:f.NETWORK_ERROR,details:D.LEVEL_PARSING_ERROR,fatal:!1,url:A,error:R,reason:R.message,response:Y,context:X,level:B,parent:E,networkDetails:z,stats:J});return}Q.playlistParsingError=null}if(Q.live&&N){if(N.getCacheAge)Q.ageHeader=N.getCacheAge()||0;if(!N.getCacheAge||isNaN(Q.ageHeader))Q.ageHeader=0}switch(G){case o.MANIFEST:case o.LEVEL:W.trigger($.LEVEL_LOADED,{details:Q,levelInfo:X.levelOrTrack||W.levels[0],level:B||0,id:j||0,stats:J,networkDetails:z,deliveryDirectives:U,withoutMultiVariant:G===o.MANIFEST});break;case o.AUDIO_TRACK:W.trigger($.AUDIO_TRACK_LOADED,{details:Q,track:X.levelOrTrack,id:j||0,groupId:V||"",stats:J,networkDetails:z,deliveryDirectives:U});break;case o.SUBTITLE_TRACK:W.trigger($.SUBTITLE_TRACK_LOADED,{details:Q,track:X.levelOrTrack,id:j||0,groupId:V||"",stats:J,networkDetails:z,deliveryDirectives:U});break}},q}(),Qq={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]};function Jq(q,H){return{supported:!1,configurations:H,decodingInfoResults:[{supported:!1,smooth:!1,powerEfficient:!1}],error:q}}var wJ={};function Zq(q,H,Z){var{videoCodec:Q,audioCodec:Y}=q;if(!Q&&!Y||!Z)return Promise.resolve(Qq);var J=[];if(Q){var X={width:q.width,height:q.height,bitrate:Math.ceil(Math.max(q.bitrate*0.9,q.averageBitrate)),framerate:q.frameRate||30},z=q.videoRange;if(z!=="SDR")X.transferFunction=z.toLowerCase();var N=Q.split(","),W=navigator.userAgent;if(N.some(function(G){return iY(G)})&&s7())return Promise.resolve(Jq(new Error("Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent sting: ("+W+")"),J));J.push.apply(J,N.map(function(G){return{type:"media-source",video:F0(F0({},X),{},{contentType:XY(B8(G),"video")})}}))}if(Y&&q.audioGroups)q.audioGroups.forEach(function(G){var K;if(!G)return;(K=H.groups[G])==null||K.tracks.forEach(function(j){if(j.groupId===G){var V=j.channels||"",U=parseFloat(V);if(v(U)&&U>2)J.push.apply(J,Y.split(",").map(function(A){return{type:"media-source",audio:{contentType:XY(A,"audio"),channels:""+U}}}))}})});return Promise.all(J.map(function(G){var K=qq(G);return wJ[K]||(wJ[K]=Z.decodingInfo(G))})).then(function(G){return{supported:!G.some(function(K){return!K.supported}),configurations:J,decodingInfoResults:G}}).catch(function(G){return{supported:!1,configurations:J,decodingInfoResults:[],error:G}})}function qq(q){var{audio:H,video:Z}=q,Q=Z||H;if(Q){var Y=e7(Q.contentType);if(Z)return"r"+Z.height+"x"+Z.width+"f"+Math.ceil(Z.framerate)+(Z.transferFunction||"sd")+"_"+Y+"_"+Math.ceil(Z.bitrate/1e5);if(H)return"c"+H.channels+(H.spatialRendering?"s":"n")+"_"+Y}return""}var LJ=function(){function q(Z){if(Z===void 0)Z={};this.config=void 0,this.userConfig=void 0,this.logger=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new mY,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.audioStreamController=void 0,this.subtititleStreamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.interstitialsController=void 0,this.gapController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this._url=null,this._sessionId=void 0,this.triggeringException=void 0,this.started=!1;var Q=this.logger=k7(Z.debug||!1,"Hls instance",Z.assetPlayerId),Y=this.config=A9(q.DefaultConfig,Z,Q);if(this.userConfig=Z,Y.progressive)E9(Y,Q);var{abrController:J,bufferController:X,capLevelController:z,errorController:N,fpsController:W}=Y,G=new N(this),K=this.abrController=new J(this),j=new B9(this),V=Y.interstitialsController,U=V?this.interstitialsController=new V(this,q):null,A=this.bufferController=new X(this,j),E=this.capLevelController=new z(this),B=new W(this),F=new Yq(this),R=Y.contentSteeringController,O=R?new R(this):null,M=this.levelController=new p9(this,O),L=new v9(this),I=new e9(this.config),w=this.streamController=new t9(this,j,I),S=this.gapController=new D9(this,j);E.setStreamController(w),B.setStreamController(w);var P=[F,M,w];if(U)P.splice(1,0,U);if(O)P.splice(1,0,O);this.networkControllers=P;var b=[K,A,S,E,B,L,j];this.audioTrackController=this.createController(Y.audioTrackController,P);var C=Y.audioStreamController;if(C)P.push(this.audioStreamController=new C(this,j,I));this.subtitleTrackController=this.createController(Y.subtitleTrackController,P);var x=Y.subtitleStreamController;if(x)P.push(this.subtititleStreamController=new x(this,j,I));this.createController(Y.timelineController,b),I.emeController=this.emeController=this.createController(Y.emeController,b),this.cmcdController=this.createController(Y.cmcdController,b),this.latencyController=this.createController(g9,b),this.coreComponents=b,P.push(G);var _=G.onErrorOut;if(typeof _==="function")this.on($.ERROR,_,G);this.on($.MANIFEST_LOADED,F.onManifestLoaded,F)}q.isMSESupported=function Z(){return MJ()},q.isSupported=function Z(){return i9()},q.getMediaSource=function Z(){return d0()};var H=q.prototype;return H.createController=function Z(Q,Y){if(Q){var J=new Q(this);if(Y)Y.push(J);return J}return null},H.on=function Z(Q,Y,J){if(J===void 0)J=this;this._emitter.on(Q,Y,J)},H.once=function Z(Q,Y,J){if(J===void 0)J=this;this._emitter.once(Q,Y,J)},H.removeAllListeners=function Z(Q){this._emitter.removeAllListeners(Q)},H.off=function Z(Q,Y,J,X){if(J===void 0)J=this;this._emitter.off(Q,Y,J,X)},H.listeners=function Z(Q){return this._emitter.listeners(Q)},H.emit=function Z(Q,Y,J){return this._emitter.emit(Q,Y,J)},H.trigger=function Z(Q,Y){if(this.config.debug)return this.emit(Q,Q,Y);else try{return this.emit(Q,Q,Y)}catch(X){if(this.logger.error("An internal error happened while handling event "+Q+'. Error message: "'+X.message+'". Here is a stacktrace:',X),!this.triggeringException){this.triggeringException=!0;var J=Q===$.ERROR;this.trigger($.ERROR,{type:f.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,fatal:J,event:Q,error:X}),this.triggeringException=!1}}return!1},H.listenerCount=function Z(Q){return this._emitter.listenerCount(Q)},H.destroy=function Z(){this.logger.log("destroy"),this.trigger($.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this._url=null,this.networkControllers.forEach(function(Y){return Y.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(Y){return Y.destroy()}),this.coreComponents.length=0;var Q=this.config;Q.xhrSetup=Q.fetchSetup=void 0,this.userConfig=null},H.attachMedia=function Z(Q){if(!Q||"media"in Q&&!Q.media){var Y=new Error("attachMedia failed: invalid argument ("+Q+")");this.trigger($.ERROR,{type:f.OTHER_ERROR,details:D.ATTACH_MEDIA_ERROR,fatal:!0,error:Y});return}if(this.logger.log("attachMedia"),this._media)this.logger.warn("media must be detached before attaching"),this.detachMedia();var J="media"in Q,X=J?Q.media:Q,z=J?Q:{media:X};this._media=X,this.trigger($.MEDIA_ATTACHING,z)},H.detachMedia=function Z(){this.logger.log("detachMedia"),this.trigger($.MEDIA_DETACHING,{}),this._media=null},H.transferMedia=function Z(){this._media=null;var Q=this.bufferController.transferMedia();return this.trigger($.MEDIA_DETACHING,{transferMedia:Q}),Q},H.loadSource=function Z(Q){this.stopLoad();var Y=this.media,J=this._url,X=this._url=uY.buildAbsoluteURL(self.location.href,Q,{alwaysNormalize:!0});if(this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log("loadSource:"+X),Y&&J&&(J!==X||this.bufferController.hasSourceTypes()))this.detachMedia(),this.attachMedia(Y);this.trigger($.MANIFEST_LOADING,{url:Q})},H.startLoad=function Z(Q,Y){if(Q===void 0)Q=-1;this.logger.log("startLoad("+(Q+(Y?", <skip seek to start>":""))+")"),this.started=!0,this.resumeBuffering();for(var J=0;J<this.networkControllers.length;J++)if(this.networkControllers[J].startLoad(Q,Y),!this.started||!this.networkControllers)break},H.stopLoad=function Z(){this.logger.log("stopLoad"),this.started=!1;for(var Q=0;Q<this.networkControllers.length;Q++)if(this.networkControllers[Q].stopLoad(),this.started||!this.networkControllers)break},H.resumeBuffering=function Z(){if(!this.bufferingEnabled)this.logger.log("resume buffering"),this.networkControllers.forEach(function(Q){if(Q.resumeBuffering)Q.resumeBuffering()})},H.pauseBuffering=function Z(){if(this.bufferingEnabled)this.logger.log("pause buffering"),this.networkControllers.forEach(function(Q){if(Q.pauseBuffering)Q.pauseBuffering()})},H.swapAudioCodec=function Z(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},H.recoverMediaError=function Z(){this.logger.log("recoverMediaError");var Q=this._media,Y=Q==null?void 0:Q.currentTime;if(this.detachMedia(),Q){if(this.attachMedia(Q),Y)this.startLoad(Y)}},H.removeLevel=function Z(Q){this.levelController.removeLevel(Q)},H.setAudioOption=function Z(Q){var Y;return((Y=this.audioTrackController)==null?void 0:Y.setAudioOption(Q))||null},H.setSubtitleOption=function Z(Q){var Y;return((Y=this.subtitleTrackController)==null?void 0:Y.setSubtitleOption(Q))||null},H.getMediaDecodingInfo=function Z(Q,Y){if(Y===void 0)Y=this.allAudioTracks;var J=qQ(Y);return Zq(Q,J,navigator.mediaCapabilities)},Z0(q,[{key:"url",get:function Z(){return this._url}},{key:"hasEnoughToStart",get:function Z(){return this.streamController.hasEnoughToStart}},{key:"startPosition",get:function Z(){return this.streamController.startPositionValue}},{key:"loadingEnabled",get:function Z(){return this.started}},{key:"bufferingEnabled",get:function Z(){return this.streamController.bufferingEnabled}},{key:"inFlightFragments",get:function Z(){var Q,Y=(Q={},Q[d.MAIN]=this.streamController.inFlightFrag,Q);if(this.audioStreamController)Y[d.AUDIO]=this.audioStreamController.inFlightFrag;if(this.subtititleStreamController)Y[d.SUBTITLE]=this.subtititleStreamController.inFlightFrag;return Y}},{key:"sessionId",get:function Z(){var Q=this._sessionId;if(!Q)Q=this._sessionId=mJ();return Q}},{key:"levels",get:function Z(){var Q=this.levelController.levels;return Q?Q:[]}},{key:"latestLevelDetails",get:function Z(){return this.streamController.getLevelDetails()||null}},{key:"loadLevelObj",get:function Z(){return this.levelController.loadLevelObj}},{key:"currentLevel",get:function Z(){return this.streamController.currentLevel},set:function Z(Q){this.logger.log("set currentLevel:"+Q),this.levelController.manualLevel=Q,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function Z(){return this.streamController.nextLevel},set:function Z(Q){this.logger.log("set nextLevel:"+Q),this.levelController.manualLevel=Q,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function Z(){return this.levelController.level},set:function Z(Q){this.logger.log("set loadLevel:"+Q),this.levelController.manualLevel=Q}},{key:"nextLoadLevel",get:function Z(){return this.levelController.nextLoadLevel},set:function Z(Q){this.levelController.nextLoadLevel=Q}},{key:"firstLevel",get:function Z(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function Z(Q){this.logger.log("set firstLevel:"+Q),this.levelController.firstLevel=Q}},{key:"startLevel",get:function Z(){var Q=this.levelController.startLevel;if(Q===-1&&this.abrController.forcedAutoLevel>-1)return this.abrController.forcedAutoLevel;return Q},set:function Z(Q){if(this.logger.log("set startLevel:"+Q),Q!==-1)Q=Math.max(Q,this.minAutoLevel);this.levelController.startLevel=Q}},{key:"capLevelToPlayerSize",get:function Z(){return this.config.capLevelToPlayerSize},set:function Z(Q){var Y=!!Q;if(Y!==this.config.capLevelToPlayerSize){if(Y)this.capLevelController.startCapping();else this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch();this.config.capLevelToPlayerSize=Y}}},{key:"autoLevelCapping",get:function Z(){return this._autoLevelCapping},set:function Z(Q){if(this._autoLevelCapping!==Q)this.logger.log("set autoLevelCapping:"+Q),this._autoLevelCapping=Q,this.levelController.checkMaxAutoUpdated()}},{key:"bandwidthEstimate",get:function Z(){var Q=this.abrController.bwEstimator;if(!Q)return NaN;return Q.getEstimate()},set:function Z(Q){this.abrController.resetEstimator(Q)}},{key:"abrEwmaDefaultEstimate",get:function Z(){var Q=this.abrController.bwEstimator;if(!Q)return NaN;return Q.defaultEstimate}},{key:"ttfbEstimate",get:function Z(){var Q=this.abrController.bwEstimator;if(!Q)return NaN;return Q.getEstimateTTFB()}},{key:"maxHdcpLevel",get:function Z(){return this._maxHdcpLevel},set:function Z(Q){if($8(Q)&&this._maxHdcpLevel!==Q)this._maxHdcpLevel=Q,this.levelController.checkMaxAutoUpdated()}},{key:"autoLevelEnabled",get:function Z(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function Z(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function Z(){var Q=this.levels,Y=this.config.minAutoBitrate;if(!Q)return 0;var J=Q.length;for(var X=0;X<J;X++)if(Q[X].maxBitrate>=Y)return X;return 0}},{key:"maxAutoLevel",get:function Z(){var Q=this.levels,Y=this.autoLevelCapping,J=this.maxHdcpLevel,X;if(Y===-1&&Q!=null&&Q.length)X=Q.length-1;else X=Y;if(J)for(var z=X;z--;){var N=Q[z].attrs["HDCP-LEVEL"];if(N&&N<=J)return z}return X}},{key:"firstAutoLevel",get:function Z(){return this.abrController.firstAutoLevel}},{key:"nextAutoLevel",get:function Z(){return this.abrController.nextAutoLevel},set:function Z(Q){this.abrController.nextAutoLevel=Q}},{key:"playingDate",get:function Z(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function Z(){return this.streamController.getMainFwdBufferInfo()}},{key:"maxBufferLength",get:function Z(){return this.streamController.maxBufferLength}},{key:"allAudioTracks",get:function Z(){var Q=this.audioTrackController;return Q?Q.allAudioTracks:[]}},{key:"audioTracks",get:function Z(){var Q=this.audioTrackController;return Q?Q.audioTracks:[]}},{key:"audioTrack",get:function Z(){var Q=this.audioTrackController;return Q?Q.audioTrack:-1},set:function Z(Q){var Y=this.audioTrackController;if(Y)Y.audioTrack=Q}},{key:"allSubtitleTracks",get:function Z(){var Q=this.subtitleTrackController;return Q?Q.allSubtitleTracks:[]}},{key:"subtitleTracks",get:function Z(){var Q=this.subtitleTrackController;return Q?Q.subtitleTracks:[]}},{key:"subtitleTrack",get:function Z(){var Q=this.subtitleTrackController;return Q?Q.subtitleTrack:-1},set:function Z(Q){var Y=this.subtitleTrackController;if(Y)Y.subtitleTrack=Q}},{key:"media",get:function Z(){return this._media}},{key:"subtitleDisplay",get:function Z(){var Q=this.subtitleTrackController;return Q?Q.subtitleDisplay:!1},set:function Z(Q){var Y=this.subtitleTrackController;if(Y)Y.subtitleDisplay=Q}},{key:"lowLatencyMode",get:function Z(){return this.config.lowLatencyMode},set:function Z(Q){this.config.lowLatencyMode=Q}},{key:"liveSyncPosition",get:function Z(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function Z(){return this.latencyController.latency}},{key:"maxLatency",get:function Z(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function Z(){return this.latencyController.targetLatency},set:function Z(Q){this.latencyController.targetLatency=Q}},{key:"drift",get:function Z(){return this.latencyController.drift}},{key:"forceStartLoad",get:function Z(){return this.streamController.forceStartLoad}},{key:"pathways",get:function Z(){return this.levelController.pathways}},{key:"pathwayPriority",get:function Z(){return this.levelController.pathwayPriority},set:function Z(Q){this.levelController.pathwayPriority=Q}},{key:"bufferedToEnd",get:function Z(){var Q;return!!((Q=this.bufferController)!=null&&Q.bufferedToEnd)}},{key:"interstitialsManager",get:function Z(){var Q;return((Q=this.interstitialsController)==null?void 0:Q.interstitialsManager)||null}}],[{key:"version",get:function Z(){return KY}},{key:"Events",get:function Z(){return $}},{key:"MetadataSchema",get:function Z(){return L0}},{key:"ErrorTypes",get:function Z(){return f}},{key:"ErrorDetails",get:function Z(){return D}},{key:"DefaultConfig",get:function Z(){if(!q.defaultConfig)return U9;return q.defaultConfig},set:function Z(Q){q.defaultConfig=Q}}])}();return LJ.defaultConfig=void 0,LJ})})(!1)});var Mq=Oq(_J(),1);var export_Hls=Mq.default;export{export_Hls as Hls};