@v360-tech/v360-player 1.0.1 → 1.2.1

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.
@@ -1,55 +1,12 @@
1
- (function(Ri,se){typeof exports=="object"&&typeof module<"u"?se(exports):typeof define=="function"&&define.amd?define(["exports"],se):(Ri=typeof globalThis<"u"?globalThis:Ri||self,se(Ri.V360Player={}))})(this,(function(Ri){"use strict";const se=Number.isFinite||function(a){return typeof a=="number"&&isFinite(a)},Iu=Number.isSafeInteger||function(a){return typeof a=="number"&&Math.abs(a)<=Cu},Cu=Number.MAX_SAFE_INTEGER||9007199254740991;let de=(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})({}),U=(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.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",a.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",a.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",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.ASSET_LIST_LOAD_ERROR="assetListLoadError",a.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",a.ASSET_LIST_PARSING_ERROR="assetListParsingError",a.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",a.INTERNAL_EXCEPTION="internalException",a.INTERNAL_ABORTED="aborted",a.ATTACH_MEDIA_ERROR="attachMediaError",a.UNKNOWN="unknown",a})({}),y=(function(a){return a.MEDIA_ATTACHING="hlsMediaAttaching",a.MEDIA_ATTACHED="hlsMediaAttached",a.MEDIA_DETACHING="hlsMediaDetaching",a.MEDIA_DETACHED="hlsMediaDetached",a.MEDIA_ENDED="hlsMediaEnded",a.STALL_RESOLVED="hlsStallResolved",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.BUFFERED_TO_END="hlsBufferedToEnd",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.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",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_TRACK_UPDATED="hlsSubtitleTrackUpdated",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.ASSET_LIST_LOADING="hlsAssetListLoading",a.ASSET_LIST_LOADED="hlsAssetListLoaded",a.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",a.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",a.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",a.INTERSTITIAL_STARTED="hlsInterstitialStarted",a.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",a.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",a.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",a.INTERSTITIAL_ENDED="hlsInterstitialEnded",a.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",a.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",a.EVENT_CUE_ENTER="hlsEventCueEnter",a})({});var be={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},he={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};class Di{constructor(e,t=0,i=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=i}sample(e,t){const i=Math.pow(this.alpha_,e);this.estimate_=t*(1-i)+i*this.estimate_,this.totalWeight_+=e}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){const e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}}class yu{constructor(e,t,i,s=100){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=i,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new Di(e),this.fast_=new Di(t),this.defaultTTFB_=s,this.ttfb_=new Di(e)}update(e,t){const{slow_:i,fast_:s,ttfb_:r}=this;i.halfLife!==e&&(this.slow_=new Di(e,i.getEstimate(),i.getTotalWeight())),s.halfLife!==t&&(this.fast_=new Di(t,s.getEstimate(),s.getTotalWeight())),r.halfLife!==e&&(this.ttfb_=new Di(e,r.getEstimate(),r.getTotalWeight()))}sample(e,t){e=Math.max(e,this.minDelayMs_);const i=8*t,s=e/1e3,r=i/s;this.fast_.sample(s,r),this.slow_.sample(s,r)}sampleTTFB(e){const t=e/1e3,i=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(i,Math.max(e,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}get defaultEstimate(){return this.defaultEstimate_}destroy(){}}function Eu(a,e,t){return(e=Tu(e))in a?Object.defineProperty(a,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):a[e]=t,a}function Ne(){return Ne=Object.assign?Object.assign.bind():function(a){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)({}).hasOwnProperty.call(t,i)&&(a[i]=t[i])}return a},Ne.apply(null,arguments)}function qn(a,e){var t=Object.keys(a);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(a);e&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(a,s).enumerable})),t.push.apply(t,i)}return t}function Be(a){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?qn(Object(t),!0).forEach(function(i){Eu(a,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(t)):qn(Object(t)).forEach(function(i){Object.defineProperty(a,i,Object.getOwnPropertyDescriptor(t,i))})}return a}function vu(a,e){if(typeof a!="object"||!a)return a;var t=a[Symbol.toPrimitive];if(t!==void 0){var i=t.call(a,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(a)}function Tu(a){var e=vu(a,"string");return typeof e=="symbol"?e:e+""}class Tt{constructor(e,t){this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;const i=`[${e}]:`;this.trace=si,this.debug=t.debug.bind(null,i),this.log=t.log.bind(null,i),this.warn=t.warn.bind(null,i),this.info=t.info.bind(null,i),this.error=t.error.bind(null,i)}}const si=function(){},Su={trace:si,debug:si,log:si,warn:si,info:si,error:si};function dr(){return Ne({},Su)}function xu(a,e){const t=self.console[a];return t?t.bind(self.console,`${e?"["+e+"] ":""}[${a}] >`):si}function Xn(a,e,t){return e[a]?e[a].bind(e):xu(a,t)}const fr=dr();function bu(a,e,t){const i=dr();if(typeof console=="object"&&a===!0||typeof a=="object"){const s=["debug","log","info","warn","error"];s.forEach(r=>{i[r]=Xn(r,a,t)});try{i.log(`Debug logs enabled for "${e}" in hls.js version 1.6.11`)}catch{return dr()}s.forEach(r=>{fr[r]=Xn(r,a)})}else Ne(fr,i);return i}const Oe=fr;function ri(a=!0){return typeof self>"u"?void 0:(a||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function Lu(a){return typeof self<"u"&&a===self.ManagedMediaSource}function Zn(a,e){const t=Object.keys(a),i=Object.keys(e),s=t.length,r=i.length;return!s||!r||s===r&&!t.some(n=>i.indexOf(n)===-1)}function mt(a,e=!1){if(typeof TextDecoder<"u"){const u=new TextDecoder("utf-8").decode(a);if(e){const h=u.indexOf("\0");return h!==-1?u.substring(0,h):u}return u.replace(/\0/g,"")}const t=a.length;let i,s,r,n="",o=0;for(;o<t;){if(i=a[o++],i===0&&e)return n;if(i===0||i===3)continue;switch(i>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:n+=String.fromCharCode(i);break;case 12:case 13:s=a[o++],n+=String.fromCharCode((i&31)<<6|s&63);break;case 14:s=a[o++],r=a[o++],n+=String.fromCharCode((i&15)<<12|(s&63)<<6|(r&63)<<0);break}}return n}function It(a){let e="";for(let t=0;t<a.length;t++){let i=a[t].toString(16);i.length<2&&(i="0"+i),e+=i}return e}function Qn(a){return Uint8Array.from(a.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}function Ru(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var gr={exports:{}},Jn;function Du(){return Jn||(Jn=1,(function(a,e){(function(t){var i=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,s=/^(?=([^\/?#]*))\1([^]*)$/,r=/(?:\/|^)\.(?=\/)/g,n=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(c,u,h){if(h=h||{},c=c.trim(),u=u.trim(),!u){if(!h.alwaysNormalize)return c;var f=o.parseURL(c);if(!f)throw new Error("Error trying to parse base URL.");return f.path=o.normalizePath(f.path),o.buildURLFromParts(f)}var g=o.parseURL(u);if(!g)throw new Error("Error trying to parse relative URL.");if(g.scheme)return h.alwaysNormalize?(g.path=o.normalizePath(g.path),o.buildURLFromParts(g)):u;var I=o.parseURL(c);if(!I)throw new Error("Error trying to parse base URL.");if(!I.netLoc&&I.path&&I.path[0]!=="/"){var m=s.exec(I.path);I.netLoc=m[1],I.path=m[2]}I.netLoc&&!I.path&&(I.path="/");var E={scheme:I.scheme,netLoc:g.netLoc,path:null,params:g.params,query:g.query,fragment:g.fragment};if(!g.netLoc&&(E.netLoc=I.netLoc,g.path[0]!=="/"))if(!g.path)E.path=I.path,g.params||(E.params=I.params,g.query||(E.query=I.query));else{var v=I.path,x=v.substring(0,v.lastIndexOf("/")+1)+g.path;E.path=o.normalizePath(x)}return E.path===null&&(E.path=h.alwaysNormalize?o.normalizePath(g.path):g.path),o.buildURLFromParts(E)},parseURL:function(c){var u=i.exec(c);return u?{scheme:u[1]||"",netLoc:u[2]||"",path:u[3]||"",params:u[4]||"",query:u[5]||"",fragment:u[6]||""}:null},normalizePath:function(c){for(c=c.split("").reverse().join("").replace(r,"");c.length!==(c=c.replace(n,"")).length;);return c.split("").reverse().join("")},buildURLFromParts:function(c){return c.scheme+c.netLoc+c.path+c.params+c.query+c.fragment}};a.exports=o})()})(gr)),gr.exports}var pr=Du();class Ar{constructor(){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}}}var Ue={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class ea{constructor(e){this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,typeof e=="string"&&(e={url:e}),this.base=e,_u(this,"stats")}setByteRange(e,t){const i=e.split("@",2);let s;i.length===1?s=t?.byteRangeEndOffset||0:s=parseInt(i[1]),this._byteRange=[s,parseInt(i[0])+s]}get baseurl(){return this.base.url}get byteRange(){return this._byteRange===null?[]:this._byteRange}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get elementaryStreams(){return this._streams===null&&(this._streams={[Ue.AUDIO]:null,[Ue.VIDEO]:null,[Ue.AUDIOVIDEO]:null}),this._streams}set elementaryStreams(e){this._streams=e}get hasStats(){return this._stats!==null}get hasStreams(){return this._streams!==null}get stats(){return this._stats===null&&(this._stats=new Ar),this._stats}set stats(e){this._stats=e}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=pr.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[Ue.AUDIO]=null,e[Ue.VIDEO]=null,e[Ue.AUDIOVIDEO]=null}}function qe(a){return a.sn!=="initSegment"}class mr extends ea{constructor(e,t){super(t),this._decryptdata=null,this._programDateTime=null,this._ref=null,this._bitrate=void 0,this.rawProgramDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.playlistOffset=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.urlId=0,this.type=e}get byteLength(){if(this.hasStats){const e=this.stats.total;if(e)return e}if(this.byteRange.length){const e=this.byteRange[0],t=this.byteRange[1];if(se(e)&&se(t))return t-e}return null}get bitrate(){return this.byteLength?this.byteLength*8/this.duration:this._bitrate?this._bitrate:null}set bitrate(e){this._bitrate=e}get decryptdata(){const{levelkeys:e}=this;if(!e&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){const t=this.levelkeys.identity;if(t)this._decryptdata=t.getDecryptData(this.sn);else{const i=Object.keys(this.levelkeys);if(i.length===1){const s=this._decryptdata=this.levelkeys[i[0]]||null;if(s)return s.getDecryptData(this.sn)}}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null)return null;const e=se(this.duration)?this.duration:0;return this.programDateTime+e*1e3}get encrypted(){var e;if((e=this._decryptdata)!=null&&e.encrypted)return!0;if(this.levelkeys){var t;const i=Object.keys(this.levelkeys),s=i.length;if(s>1||s===1&&(t=this.levelkeys[i[0]])!=null&&t.encrypted)return!0}return!1}get programDateTime(){return this._programDateTime===null&&this.rawProgramDateTime&&(this.programDateTime=Date.parse(this.rawProgramDateTime)),this._programDateTime}set programDateTime(e){if(!se(e)){this._programDateTime=this.rawProgramDateTime=null;return}this._programDateTime=e}get ref(){return qe(this)?(this._ref||(this._ref={base:this.base,start:this.start,duration:this.duration,sn:this.sn,programDateTime:this.programDateTime}),this._ref):null}addStart(e){this.setStart(this.start+e)}setStart(e){this.start=e,this._ref&&(this._ref.start=e)}setDuration(e){this.duration=e,this._ref&&(this._ref.duration=e)}setKeyFormat(e){if(this.levelkeys){const t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}}abortRequests(){var e,t;(e=this.loader)==null||e.abort(),(t=this.keyLoader)==null||t.abort()}setElementaryStreamInfo(e,t,i,s,r,n=!1){const{elementaryStreams:o}=this,c=o[e];if(!c){o[e]={startPTS:t,endPTS:i,startDTS:s,endDTS:r,partial:n};return}c.startPTS=Math.min(c.startPTS,t),c.endPTS=Math.max(c.endPTS,i),c.startDTS=Math.min(c.startDTS,s),c.endDTS=Math.max(c.endDTS,r)}}class Pu extends ea{constructor(e,t,i,s,r){super(i),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=s;const n=e.enumeratedString("BYTERANGE");n&&this.setByteRange(n,r),r&&(this.fragOffset=r.fragOffset+r.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){const{elementaryStreams:e}=this;return!!(e.audio||e.video||e.audiovideo)}}function ta(a,e){const t=Object.getPrototypeOf(a);if(t){const i=Object.getOwnPropertyDescriptor(t,e);return i||ta(t,e)}}function _u(a,e){const t=ta(a,e);t&&(t.enumerable=!0,Object.defineProperty(a,e,t))}const ia=Math.pow(2,32)-1,wu=[].push,sa={video:1,audio:2,id3:3,text:4};function Ze(a){return String.fromCharCode.apply(null,a)}function ra(a,e){const t=a[e]<<8|a[e+1];return t<0?65536+t:t}function Ie(a,e){const t=aa(a,e);return t<0?4294967296+t:t}function na(a,e){let t=Ie(a,e);return t*=Math.pow(2,32),t+=Ie(a,e+4),t}function aa(a,e){return a[e]<<24|a[e+1]<<16|a[e+2]<<8|a[e+3]}function ku(a){const e=a.byteLength;for(let t=0;t<e;){const i=Ie(a,t);if(i>8&&a[t+4]===109&&a[t+5]===111&&a[t+6]===111&&a[t+7]===102)return!0;t=i>1?t+i:e}return!1}function xe(a,e){const t=[];if(!e.length)return t;const i=a.byteLength;for(let s=0;s<i;){const r=Ie(a,s),n=Ze(a.subarray(s+4,s+8)),o=r>1?s+r:i;if(n===e[0])if(e.length===1)t.push(a.subarray(s+8,o));else{const c=xe(a.subarray(s+8,o),e.slice(1));c.length&&wu.apply(t,c)}s=o}return t}function Mu(a){const e=[],t=a[0];let i=8;const s=Ie(a,i);i+=4;let r=0,n=0;t===0?(r=Ie(a,i),n=Ie(a,i+4),i+=8):(r=na(a,i),n=na(a,i+8),i+=16),i+=2;let o=a.length+n;const c=ra(a,i);i+=2;for(let u=0;u<c;u++){let h=i;const f=Ie(a,h);h+=4;const g=f&2147483647;if((f&2147483648)>>>31===1)return Oe.warn("SIDX has hierarchical references (not supported)"),null;const m=Ie(a,h);h+=4,e.push({referenceSize:g,subsegmentDuration:m,info:{duration:m/s,start:o,end:o+g-1}}),o+=g,h+=4,i=h}return{earliestPresentationTime:r,timescale:s,version:t,referencesCount:c,references:e}}function oa(a){const e=[],t=xe(a,["moov","trak"]);for(let s=0;s<t.length;s++){const r=t[s],n=xe(r,["tkhd"])[0];if(n){let o=n[0];const c=Ie(n,o===0?12:20),u=xe(r,["mdia","mdhd"])[0];if(u){o=u[0];const h=Ie(u,o===0?12:20),f=xe(r,["mdia","hdlr"])[0];if(f){const g=Ze(f.subarray(8,12)),I={soun:Ue.AUDIO,vide:Ue.VIDEO}[g],m=xe(r,["mdia","minf","stbl","stsd"])[0],E=Ou(m);I?(e[c]={timescale:h,type:I,stsd:E},e[I]=Be({timescale:h,id:c},E)):e[c]={timescale:h,type:g,stsd:E}}}}}return xe(a,["moov","mvex","trex"]).forEach(s=>{const r=Ie(s,4),n=e[r];n&&(n.default={duration:Ie(s,12),flags:Ie(s,20)})}),e}function Ou(a){const e=a.subarray(8),t=e.subarray(86),i=Ze(e.subarray(4,8));let s=i,r;const n=i==="enca"||i==="encv";if(n){const u=xe(e,[i])[0].subarray(i==="enca"?28:78);xe(u,["sinf"]).forEach(f=>{const g=xe(f,["schm"])[0];if(g){const I=Ze(g.subarray(4,8));if(I==="cbcs"||I==="cenc"){const m=xe(f,["frma"])[0];m&&(s=Ze(m))}}})}const o=s;switch(s){case"avc1":case"avc2":case"avc3":case"avc4":{const c=xe(t,["avcC"])[0];c&&c.length>3&&(s+="."+Is(c[1])+Is(c[2])+Is(c[3]),r=ms(o==="avc1"?"dva1":"dvav",t));break}case"mp4a":{const c=xe(e,[i])[0],u=xe(c.subarray(28),["esds"])[0];if(u&&u.length>7){let h=4;if(u[h++]!==3)break;h=Ir(u,h),h+=2;const f=u[h++];if(f&128&&(h+=2),f&64&&(h+=u[h++]),u[h++]!==4)break;h=Ir(u,h);const g=u[h++];if(g===64)s+="."+Is(g);else break;if(h+=12,u[h++]!==5)break;h=Ir(u,h);const I=u[h++];let m=(I&248)>>3;m===31&&(m+=1+((I&7)<<3)+((u[h]&224)>>5)),s+="."+m}break}case"hvc1":case"hev1":{const c=xe(t,["hvcC"])[0];if(c&&c.length>12){const u=c[1],h=["","A","B","C"][u>>6],f=u&31,g=Ie(c,2),I=(u&32)>>5?"H":"L",m=c[12],E=c.subarray(6,12);s+="."+h+f,s+="."+Fu(g).toString(16).toUpperCase(),s+="."+I+m;let v="";for(let x=E.length;x--;){const D=E[x];(D||v)&&(v="."+D.toString(16).toUpperCase()+v)}s+=v}r=ms(o=="hev1"?"dvhe":"dvh1",t);break}case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":{s=ms(s,t)||s;break}case"vp09":{const c=xe(t,["vpcC"])[0];if(c&&c.length>6){const u=c[4],h=c[5],f=c[6]>>4&15;s+="."+Mt(u)+"."+Mt(h)+"."+Mt(f)}break}case"av01":{const c=xe(t,["av1C"])[0];if(c&&c.length>2){const u=c[1]>>>5,h=c[1]&31,f=c[2]>>>7?"H":"M",g=(c[2]&64)>>6,I=(c[2]&32)>>5,m=u===2&&g?I?12:10:g?10:8,E=(c[2]&16)>>4,v=(c[2]&8)>>3,x=(c[2]&4)>>2,D=c[2]&3;s+="."+u+"."+Mt(h)+f+"."+Mt(m)+"."+E+"."+v+x+D+"."+Mt(1)+"."+Mt(1)+"."+Mt(1)+"."+0,r=ms("dav1",t)}break}}return{codec:s,encrypted:n,supplemental:r}}function ms(a,e){const t=xe(e,["dvvC"]),i=t.length?t[0]:xe(e,["dvcC"])[0];if(i){const s=i[2]>>1&127,r=i[2]<<5&32|i[3]>>3&31;return a+"."+Mt(s)+"."+Mt(r)}}function Fu(a){let e=0;for(let t=0;t<32;t++)e|=(a>>t&1)<<31-t;return e>>>0}function Ir(a,e){const t=e+5;for(;a[e++]&128&&e<t;);return e}function Is(a){return("0"+a.toString(16).toUpperCase()).slice(-2)}function Mt(a){return(a<10?"0":"")+a}function Nu(a,e){if(!a||!e)return;const t=e.keyId;t&&e.isCommonEncryption&&xe(a,["moov","trak"]).forEach(s=>{const n=xe(s,["mdia","minf","stbl","stsd"])[0].subarray(8);let o=xe(n,["enca"]);const c=o.length>0;c||(o=xe(n,["encv"])),o.forEach(u=>{const h=c?u.subarray(28):u.subarray(78);xe(h,["sinf"]).forEach(g=>{const I=la(g);if(I){const m=I.subarray(8,24);m.some(E=>E!==0)||(Oe.log(`[eme] Patching keyId in 'enc${c?"a":"v"}>sinf>>tenc' box: ${It(m)} -> ${It(t)}`),I.set(t,8))}})})})}function la(a){const e=xe(a,["schm"])[0];if(e){const t=Ze(e.subarray(4,8));if(t==="cbcs"||t==="cenc")return xe(a,["schi","tenc"])[0]}return null}function Bu(a,e,t){const i={},s=xe(a,["moof","traf"]);for(let r=0;r<s.length;r++){const n=s[r],o=xe(n,["tfhd"])[0],c=Ie(o,4),u=e[c];if(!u)continue;i[c]||(i[c]={start:NaN,duration:0,sampleCount:0,timescale:u.timescale,type:u.type});const h=i[c],f=xe(n,["tfdt"])[0];if(f){const L=f[0];let w=Ie(f,4);L===1&&(w===ia?t.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"):(w*=ia+1,w+=Ie(f,8))),se(w)&&(!se(h.start)||w<h.start)&&(h.start=w)}const g=u.default,I=Ie(o,0)|g?.flags;let m=g?.duration||0;I&8&&(I&2?m=Ie(o,12):m=Ie(o,8));const E=xe(n,["trun"]);let v=h.start||0,x=0,D=m;for(let L=0;L<E.length;L++){const w=E[L],N=Ie(w,4),K=h.sampleCount;h.sampleCount+=N;const p=w[3]&1,$=w[3]&4,F=w[2]&1,O=w[2]&2,W=w[2]&4,ie=w[2]&8;let X=8,ce=N;for(p&&(X+=4),$&&N&&(!(w[X+1]&1)&&h.keyFrameIndex===void 0&&(h.keyFrameIndex=K),X+=4,F?(D=Ie(w,X),X+=4):D=m,O&&(X+=4),ie&&(X+=4),v+=D,x+=D,ce--);ce--;)F?(D=Ie(w,X),X+=4):D=m,O&&(X+=4),W&&(w[X+1]&1||h.keyFrameIndex===void 0&&(h.keyFrameIndex=h.sampleCount-(ce+1),h.keyFrameStart=v),X+=4),ie&&(X+=4),v+=D,x+=D;!x&&m&&(x+=m*N)}h.duration+=x}if(!Object.keys(i).some(r=>i[r].duration)){let r=1/0,n=0;const o=xe(a,["sidx"]);for(let c=0;c<o.length;c++){const u=Mu(o[c]);if(u!=null&&u.references){r=Math.min(r,u.earliestPresentationTime/u.timescale);const h=u.references.reduce((f,g)=>f+g.info.duration||0,0);n=Math.max(n,h+u.earliestPresentationTime/u.timescale)}}n&&se(n)&&Object.keys(i).forEach(c=>{i[c].duration||(i[c].duration=n*i[c].timescale-i[c].start)})}return i}function Uu(a){const e={valid:null,remainder:null},t=xe(a,["moof"]);if(t.length<2)return e.remainder=a,e;const i=t[t.length-1];return e.valid=a.slice(0,i.byteOffset-8),e.remainder=a.slice(i.byteOffset-8),e}function St(a,e){const t=new Uint8Array(a.length+e.length);return t.set(a),t.set(e,a.length),t}function ua(a,e){const t=[],i=e.samples,s=e.timescale,r=e.id;let n=!1;return xe(i,["moof"]).map(c=>{const u=c.byteOffset-8;xe(c,["traf"]).map(f=>{const g=xe(f,["tfdt"]).map(I=>{const m=I[0];let E=Ie(I,4);return m===1&&(E*=Math.pow(2,32),E+=Ie(I,8)),E/s})[0];return g!==void 0&&(a=g),xe(f,["tfhd"]).map(I=>{const m=Ie(I,4),E=Ie(I,0)&16777215,v=(E&1)!==0,x=(E&2)!==0,D=(E&8)!==0;let L=0;const w=(E&16)!==0;let N=0;const K=(E&32)!==0;let p=8;m===r&&(v&&(p+=8),x&&(p+=4),D&&(L=Ie(I,p),p+=4),w&&(N=Ie(I,p),p+=4),K&&(p+=4),e.type==="video"&&(n=Cs(e.codec)),xe(f,["trun"]).map($=>{const F=$[0],O=Ie($,0)&16777215,W=(O&1)!==0;let ie=0;const X=(O&4)!==0,ce=(O&256)!==0;let ue=0;const Q=(O&512)!==0;let ne=0;const re=(O&1024)!==0,le=(O&2048)!==0;let pe=0;const J=Ie($,4);let ee=8;W&&(ie=Ie($,ee),ee+=4),X&&(ee+=4);let ve=ie+u;for(let ke=0;ke<J;ke++){if(ce?(ue=Ie($,ee),ee+=4):ue=L,Q?(ne=Ie($,ee),ee+=4):ne=N,re&&(ee+=4),le&&(F===0?pe=Ie($,ee):pe=aa($,ee),ee+=4),e.type===Ue.VIDEO){let Te=0;for(;Te<ne;){const Le=Ie(i,ve);if(ve+=4,$u(n,i[ve])){const it=i.subarray(ve,ve+Le);Cr(it,n?2:1,a+pe/s,t)}ve+=Le,Te+=Le+4}}a+=ue/s}}))})})}),t}function Cs(a){if(!a)return!1;const e=a.substring(0,4);return e==="hvc1"||e==="hev1"||e==="dvh1"||e==="dvhe"}function $u(a,e){if(a){const t=e>>1&63;return t===39||t===40}else return(e&31)===6}function Cr(a,e,t,i){const s=ca(a);let r=0;r+=e;let n=0,o=0,c=0;for(;r<s.length;){n=0;do{if(r>=s.length)break;c=s[r++],n+=c}while(c===255);o=0;do{if(r>=s.length)break;c=s[r++],o+=c}while(c===255);const u=s.length-r;let h=r;if(o<u)r+=o;else if(o>u){Oe.error(`Malformed SEI payload. ${o} is too small, only ${u} bytes left to parse.`);break}if(n===4){if(s[h++]===181){const g=ra(s,h);if(h+=2,g===49){const I=Ie(s,h);if(h+=4,I===1195456820){const m=s[h++];if(m===3){const E=s[h++],v=31&E,x=64&E,D=x?2+v*3:0,L=new Uint8Array(D);if(x){L[0]=E;for(let w=1;w<D;w++)L[w]=s[h++]}i.push({type:m,payloadType:n,pts:t,bytes:L})}}}}}else if(n===5&&o>16){const f=[];for(let m=0;m<16;m++){const E=s[h++].toString(16);f.push(E.length==1?"0"+E:E),(m===3||m===5||m===7||m===9)&&f.push("-")}const g=o-16,I=new Uint8Array(g);for(let m=0;m<g;m++)I[m]=s[h++];i.push({payloadType:n,pts:t,uuid:f.join(""),userData:mt(I),userDataBytes:I})}}}function ca(a){const e=a.byteLength,t=[];let i=1;for(;i<e-2;)a[i]===0&&a[i+1]===0&&a[i+2]===3?(t.push(i+2),i+=2):i++;if(t.length===0)return a;const s=e-t.length,r=new Uint8Array(s);let n=0;for(i=0;i<s;n++,i++)n===t[0]&&(n++,t.shift()),r[i]=a[n];return r}function Gu(a){const e=a[0];let t="",i="",s=0,r=0,n=0,o=0,c=0,u=0;if(e===0){for(;Ze(a.subarray(u,u+1))!=="\0";)t+=Ze(a.subarray(u,u+1)),u+=1;for(t+=Ze(a.subarray(u,u+1)),u+=1;Ze(a.subarray(u,u+1))!=="\0";)i+=Ze(a.subarray(u,u+1)),u+=1;i+=Ze(a.subarray(u,u+1)),u+=1,s=Ie(a,12),r=Ie(a,16),o=Ie(a,20),c=Ie(a,24),u=28}else if(e===1){u+=4,s=Ie(a,u),u+=4;const f=Ie(a,u);u+=4;const g=Ie(a,u);for(u+=4,n=2**32*f+g,Iu(n)||(n=Number.MAX_SAFE_INTEGER,Oe.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=Ie(a,u),u+=4,c=Ie(a,u),u+=4;Ze(a.subarray(u,u+1))!=="\0";)t+=Ze(a.subarray(u,u+1)),u+=1;for(t+=Ze(a.subarray(u,u+1)),u+=1;Ze(a.subarray(u,u+1))!=="\0";)i+=Ze(a.subarray(u,u+1)),u+=1;i+=Ze(a.subarray(u,u+1)),u+=1}const h=a.subarray(u,a.byteLength);return{schemeIdUri:t,value:i,timeScale:s,presentationTime:n,presentationTimeDelta:r,eventDuration:o,id:c,payload:h}}function Hu(a,...e){const t=e.length;let i=8,s=t;for(;s--;)i+=e[s].byteLength;const r=new Uint8Array(i);for(r[0]=i>>24&255,r[1]=i>>16&255,r[2]=i>>8&255,r[3]=i&255,r.set(a,4),s=0,i=8;s<t;s++)r.set(e[s],i),i+=e[s].byteLength;return r}function Vu(a,e,t){if(a.byteLength!==16)throw new RangeError("Invalid system id");let i,s;i=0,s=new Uint8Array;let r;i>0?(r=new Uint8Array(4),e.length>0&&new DataView(r.buffer).setUint32(0,e.length,!1)):r=new Uint8Array;const n=new Uint8Array(4);return t.byteLength>0&&new DataView(n.buffer).setUint32(0,t.byteLength,!1),Hu([112,115,115,104],new Uint8Array([i,0,0,0]),a,r,s,n,t)}const ha=()=>/\(Windows.+Firefox\//i.test(navigator.userAgent),Pi={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,dav1:.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 yr(a,e){const t=Pi[e];return!!t&&!!t[a.slice(0,4)]}function Er(a,e,t=!0){return!a.split(",").some(i=>!vr(i,e,t))}function vr(a,e,t=!0){var i;const s=ri(t);return(i=s?.isTypeSupported(Xi(a,e)))!=null?i:!1}function Xi(a,e){return`${e}/mp4;codecs=${a}`}function da(a){if(a){const e=a.substring(0,4);return Pi.video[e]}return 2}function ys(a){const e=ha();return a.split(",").reduce((t,i)=>{const r=e&&Cs(i)?9:Pi.video[i];return r?(r*2+t)/(t?3:2):(Pi.audio[i]+t)/(t?2:1)},0)}const Tr={};function Ku(a,e=!0){if(Tr[a])return Tr[a];const t={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[a];for(let s=0;s<t.length;s++){var i;if(vr(t[s],"audio",e))return Tr[a]=t[s],t[s];if(t[s]==="mp3"&&(i=ri(e))!=null&&i.isTypeSupported("audio/mpeg"))return""}return a}const Yu=/flac|opus|mp4a\.40\.34/i;function Es(a,e=!0){return a.replace(Yu,t=>Ku(t.toLowerCase(),e))}function Wu(a,e){const t=[];if(a){const i=a.split(",");for(let s=0;s<i.length;s++)yr(i[s],"video")||t.push(i[s])}return e&&t.push(e),t.join(",")}function vs(a,e){if(a&&(a.length>4||["ac-3","ec-3","alac","fLaC","Opus"].indexOf(a)!==-1)&&(fa(a,"audio")||fa(a,"video")))return a;if(e){const t=e.split(",");if(t.length>1){if(a){for(let i=t.length;i--;)if(t[i].substring(0,4)===a.substring(0,4))return t[i]}return t[0]}}return e||a}function fa(a,e){return yr(a,e)&&vr(a,e)}function ju(a){const e=a.split(",");for(let t=0;t<e.length;t++){const i=e[t].split(".");i.length>2&&i[0]==="avc1"&&(e[t]=`avc1.${parseInt(i[1]).toString(16)}${("000"+parseInt(i[2]).toString(16)).slice(-4)}`)}return e.join(",")}function zu(a){if(a.startsWith("av01.")){const e=a.split("."),t=["0","111","01","01","01","0"];for(let i=e.length;i>4&&i<10;i++)e[i]=t[i-4];return e.join(".")}return a}function ga(a){const e=ri(a)||{isTypeSupported:()=>!1};return{mpeg:e.isTypeSupported("audio/mpeg"),mp3:e.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:e.isTypeSupported('audio/mp4; codecs="ac-3"')}}function Sr(a){return a.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}const qu={supported:!0,powerEfficient:!0,smooth:!0},Xu={supported:!1,smooth:!1,powerEfficient:!1},pa={supported:!0,configurations:[],decodingInfoResults:[qu]};function Aa(a,e){return{supported:!1,configurations:e,decodingInfoResults:[Xu],error:a}}function Zu(a,e,t,i,s,r){const n=a.videoCodec,o=a.audioCodec?a.audioGroups:null,c=r?.audioCodec,u=r?.channels,h=u?parseInt(u):c?1/0:2;let f=null;if(o!=null&&o.length)try{o.length===1&&o[0]?f=e.groups[o[0]].channels:f=o.reduce((g,I)=>{if(I){const m=e.groups[I];if(!m)throw new Error(`Audio track group ${I} not found`);Object.keys(m.channels).forEach(E=>{g[E]=(g[E]||0)+m.channels[E]})}return g},{2:0})}catch{return!0}return n!==void 0&&(n.split(",").some(g=>Cs(g))||a.width>1920&&a.height>1088||a.height>1920&&a.width>1088||a.frameRate>Math.max(i,30)||a.videoRange!=="SDR"&&a.videoRange!==t||a.bitrate>Math.max(s,8e6))||!!f&&se(h)&&Object.keys(f).some(g=>parseInt(g)>h)}function ma(a,e,t,i={}){const s=a.videoCodec;if(!s&&!a.audioCodec||!t)return Promise.resolve(pa);const r=[],n=Qu(a),o=n.length,c=Ju(a,e,o>0),u=c.length;for(let h=o||1*u||1;h--;){const f={type:"media-source"};if(o&&(f.video=n[h%o]),u){f.audio=c[h%u];const g=f.audio.bitrate;f.video&&g&&(f.video.bitrate-=g)}r.push(f)}if(s){const h=navigator.userAgent;if(s.split(",").some(f=>Cs(f))&&ha())return Promise.resolve(Aa(new Error(`Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent string: (${h})`),r))}return Promise.all(r.map(h=>{const f=tc(h);return i[f]||(i[f]=t.decodingInfo(h))})).then(h=>({supported:!h.some(f=>!f.supported),configurations:r,decodingInfoResults:h})).catch(h=>({supported:!1,configurations:r,decodingInfoResults:[],error:h}))}function Qu(a){var e;const t=(e=a.videoCodec)==null?void 0:e.split(","),i=Ia(a),s=a.width||640,r=a.height||480,n=a.frameRate||30,o=a.videoRange.toLowerCase();return t?t.map(c=>{const u={contentType:Xi(zu(c),"video"),width:s,height:r,bitrate:i,framerate:n};return o!=="sdr"&&(u.transferFunction=o),u}):[]}function Ju(a,e,t){var i;const s=(i=a.audioCodec)==null?void 0:i.split(","),r=Ia(a);return s&&a.audioGroups?a.audioGroups.reduce((n,o)=>{var c;const u=o?(c=e.groups[o])==null?void 0:c.tracks:null;return u?u.reduce((h,f)=>{if(f.groupId===o){const g=parseFloat(f.channels||"");s.forEach(I=>{const m={contentType:Xi(I,"audio"),bitrate:t?ec(I,r):r};g&&(m.channels=""+g),h.push(m)})}return h},n):n},[]):[]}function ec(a,e){if(e<=1)return 1;let t=128e3;return a==="ec-3"?t=768e3:a==="ac-3"&&(t=64e4),Math.min(e/2,t)}function Ia(a){return Math.ceil(Math.max(a.bitrate*.9,a.averageBitrate)/1e3)*1e3||1}function tc(a){let e="";const{audio:t,video:i}=a;if(i){const s=Sr(i.contentType);e+=`${s}_r${i.height}x${i.width}f${Math.ceil(i.framerate)}${i.transferFunction||"sd"}_${Math.ceil(i.bitrate/1e5)}`}if(t){const s=Sr(t.contentType);e+=`${i?"_":""}${s}_c${t.channels}`}return e}const xr=["NONE","TYPE-0","TYPE-1",null];function ic(a){return xr.indexOf(a)>-1}const Ts=["SDR","PQ","HLG"];function sc(a){return!!a&&Ts.indexOf(a)>-1}var Ss={No:"",Yes:"YES",v2:"v2"};function Ca(a){const{canSkipUntil:e,canSkipDateRanges:t,age:i}=a,s=i<e/2;return e&&s?t?Ss.v2:Ss.Yes:Ss.No}class ya{constructor(e,t,i){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=i}addDirectives(e){const 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}}class Zi{constructor(e){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=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.frameRate=e.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=e.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.codecSet=[e.videoCodec,e.audioCodec].filter(i=>!!i).map(i=>i.substring(0,4)).join(","),"supplemental"in e){var t;this.supplemental=e.supplemental;const i=(t=e.supplemental)==null?void 0:t.videoCodec;i&&i!==e.videoCodec&&(this.codecSet+=`,${i.substring(0,4)}`)}this.addGroupId("audio",e.attrs.AUDIO),this.addGroupId("text",e.attrs.SUBTITLES)}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get averageBitrate(){return this._avgBitrate||this.realBitrate||this.bitrate}get attrs(){return this._attrs[0]}get codecs(){return this.attrs.CODECS||""}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get videoRange(){return this.attrs["VIDEO-RANGE"]||"SDR"}get score(){return this.attrs.optionalFloat("SCORE",0)}get uri(){return this.url[0]||""}hasAudioGroup(e){return Ea(this._audioGroups,e)}hasSubtitleGroup(e){return Ea(this._subtitleGroups,e)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(e,t){if(t){if(e==="audio"){let i=this._audioGroups;i||(i=this._audioGroups=[]),i.indexOf(t)===-1&&i.push(t)}else if(e==="text"){let i=this._subtitleGroups;i||(i=this._subtitleGroups=[]),i.indexOf(t)===-1&&i.push(t)}}}get urlId(){return 0}set urlId(e){}get audioGroupIds(){return this.audioGroups?[this.audioGroupId]:void 0}get textGroupIds(){return this.subtitleGroups?[this.textGroupId]:void 0}get audioGroupId(){var e;return(e=this.audioGroups)==null?void 0:e[0]}get textGroupId(){var e;return(e=this.subtitleGroups)==null?void 0:e[0]}addFallback(){}}function Ea(a,e){return!e||!a?!1:a.indexOf(e)!==-1}function rc(){if(typeof matchMedia=="function"){const a=matchMedia("(dynamic-range: high)"),e=matchMedia("bad query");if(a.media!==e.media)return a.matches===!0}return!1}function nc(a,e){let t=!1,i=[];if(a&&(t=a!=="SDR",i=[a]),e){i=e.allowedVideoRanges||Ts.slice(0);const s=i.join("")!=="SDR"&&!e.videoCodec;t=e.preferHDR!==void 0?e.preferHDR:s&&rc(),t||(i=["SDR"])}return{preferHDR:t,allowedVideoRanges:i}}const ac=a=>{const e=new WeakSet;return(t,i)=>{if(a&&(i=a(t,i)),typeof i=="object"&&i!==null){if(e.has(i))return;e.add(i)}return i}},Ge=(a,e)=>JSON.stringify(a,ac(e));function oc(a,e,t,i,s){const r=Object.keys(a),n=i?.channels,o=i?.audioCodec,c=s?.videoCodec,u=n&&parseInt(n)===2;let h=!1,f=!1,g=1/0,I=1/0,m=1/0,E=1/0,v=0,x=[];const{preferHDR:D,allowedVideoRanges:L}=nc(e,s);for(let $=r.length;$--;){const F=a[r[$]];h||(h=F.channels[2]>0),g=Math.min(g,F.minHeight),I=Math.min(I,F.minFramerate),m=Math.min(m,F.minBitrate),L.filter(W=>F.videoRanges[W]>0).length>0&&(f=!0)}g=se(g)?g:0,I=se(I)?I:0;const w=Math.max(1080,g),N=Math.max(30,I);m=se(m)?m:t,t=Math.max(m,t),f||(e=void 0);const K=r.length>1;return{codecSet:r.reduce(($,F)=>{const O=a[F];if(F===$)return $;if(x=f?L.filter(W=>O.videoRanges[W]>0):[],K){if(O.minBitrate>t)return Ot(F,`min bitrate of ${O.minBitrate} > current estimate of ${t}`),$;if(!O.hasDefaultAudio)return Ot(F,"no renditions with default or auto-select sound found"),$;if(o&&F.indexOf(o.substring(0,4))%5!==0)return Ot(F,`audio codec preference "${o}" not found`),$;if(n&&!u){if(!O.channels[n])return Ot(F,`no renditions with ${n} channel sound found (channels options: ${Object.keys(O.channels)})`),$}else if((!o||u)&&h&&O.channels[2]===0)return Ot(F,"no renditions with stereo sound found"),$;if(O.minHeight>w)return Ot(F,`min resolution of ${O.minHeight} > maximum of ${w}`),$;if(O.minFramerate>N)return Ot(F,`min framerate of ${O.minFramerate} > maximum of ${N}`),$;if(!x.some(W=>O.videoRanges[W]>0))return Ot(F,`no variants with VIDEO-RANGE of ${Ge(x)} found`),$;if(c&&F.indexOf(c.substring(0,4))%5!==0)return Ot(F,`video codec preference "${c}" not found`),$;if(O.maxScore<v)return Ot(F,`max score of ${O.maxScore} < selected max of ${v}`),$}return $&&(ys(F)>=ys($)||O.fragmentError>a[$].fragmentError)?$:(E=O.minIndex,v=O.maxScore,F)},void 0),videoRanges:x,preferHDR:D,minFramerate:I,minBitrate:m,minIndex:E}}function Ot(a,e){Oe.log(`[abr] start candidates with "${a}" ignored because ${e}`)}function va(a){return a.reduce((e,t)=>{let i=e.groups[t.groupId];i||(i=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),i.tracks.push(t);const s=t.channels||"2";return i.channels[s]=(i.channels[s]||0)+1,i.hasDefault=i.hasDefault||t.default,i.hasAutoSelect=i.hasAutoSelect||t.autoselect,i.hasDefault&&(e.hasDefaultAudio=!0),i.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function lc(a,e,t,i){return a.slice(t,i+1).reduce((s,r,n)=>{if(!r.codecSet)return s;const o=r.audioGroups;let c=s[r.codecSet];c||(s[r.codecSet]=c={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:n,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!o,fragmentError:0}),c.minBitrate=Math.min(c.minBitrate,r.bitrate);const u=Math.min(r.height,r.width);return c.minHeight=Math.min(c.minHeight,u),c.minFramerate=Math.min(c.minFramerate,r.frameRate),c.minIndex=Math.min(c.minIndex,n),c.maxScore=Math.max(c.maxScore,r.score),c.fragmentError+=r.fragmentError,c.videoRanges[r.videoRange]=(c.videoRanges[r.videoRange]||0)+1,o&&o.forEach(h=>{if(!h)return;const f=e.groups[h];f&&(c.hasDefaultAudio=c.hasDefaultAudio||e.hasDefaultAudio?f.hasDefault:f.hasAutoSelect||!e.hasDefaultAudio&&!e.hasAutoSelectAudio,Object.keys(f.channels).forEach(g=>{c.channels[g]=(c.channels[g]||0)+f.channels[g]}))}),s},{})}function Ta(a){if(!a)return a;const{lang:e,assocLang:t,characteristics:i,channels:s,audioCodec:r}=a;return{lang:e,assocLang:t,characteristics:i,channels:s,audioCodec:r}}function Ft(a,e,t){if("attrs"in a){const i=e.indexOf(a);if(i!==-1)return i}for(let i=0;i<e.length;i++){const s=e[i];if(Ii(a,s,t))return i}return-1}function Ii(a,e,t){const{groupId:i,name:s,lang:r,assocLang:n,default:o}=a,c=a.forced;return(i===void 0||e.groupId===i)&&(s===void 0||e.name===s)&&(r===void 0||uc(r,e.lang))&&(r===void 0||e.assocLang===n)&&(o===void 0||e.default===o)&&(c===void 0||e.forced===c)&&(!("characteristics"in a)||cc(a.characteristics||"",e.characteristics))&&(t===void 0||t(a,e))}function uc(a,e="--"){return a.length===e.length?a===e:a.startsWith(e)||e.startsWith(a)}function cc(a,e=""){const t=a.split(","),i=e.split(",");return t.length===i.length&&!t.some(s=>i.indexOf(s)===-1)}function Ci(a,e){const{audioCodec:t,channels:i}=a;return(t===void 0||(e.audioCodec||"").substring(0,4)===t.substring(0,4))&&(i===void 0||i===(e.channels||"2"))}function hc(a,e,t,i,s){const r=e[i],o=e.reduce((g,I,m)=>{const E=I.uri;return(g[E]||(g[E]=[])).push(m),g},{})[r.uri];o.length>1&&(i=Math.max.apply(Math,o));const c=r.videoRange,u=r.frameRate,h=r.codecSet.substring(0,4),f=Sa(e,i,g=>{if(g.videoRange!==c||g.frameRate!==u||g.codecSet.substring(0,4)!==h)return!1;const I=g.audioGroups,m=t.filter(E=>!I||I.indexOf(E.groupId)!==-1);return Ft(a,m,s)>-1});return f>-1?f:Sa(e,i,g=>{const I=g.audioGroups,m=t.filter(E=>!I||I.indexOf(E.groupId)!==-1);return Ft(a,m,s)>-1})}function Sa(a,e,t){for(let i=e;i>-1;i--)if(t(a[i]))return i;for(let i=e+1;i<a.length;i++)if(t(a[i]))return i;return-1}function xs(a,e){var t;return!!a&&a!==((t=e.loadLevelObj)==null?void 0:t.uri)}class dc extends Tt{constructor(e){super("abr",e.logger),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.rebufferNotice=-1,this.supportedCache={},this.bwEstimator=void 0,this._abandonRulesCheck=t=>{var i;const{fragCurrent:s,partCurrent:r,hls:n}=this,{autoLevelEnabled:o,media:c}=n;if(!s||!c)return;const u=performance.now(),h=r?r.stats:s.stats,f=r?r.duration:s.duration,g=u-h.loading.start,I=n.minAutoLevel,m=s.level,E=this._nextAutoLevel;if(h.aborted||h.loaded&&h.loaded===h.total||m<=I){this.clearTimer(),this._nextAutoLevel=-1;return}if(!o)return;const v=E>-1&&E!==m,x=!!t||v;if(!x&&(c.paused||!c.playbackRate||!c.readyState))return;const D=n.mainForwardBufferInfo;if(!x&&D===null)return;const L=this.bwEstimator.getEstimateTTFB(),w=Math.abs(c.playbackRate);if(g<=Math.max(L,1e3*(f/(w*2))))return;const N=D?D.len/w:0,K=h.loading.first?h.loading.first-h.loading.start:-1,p=h.loaded&&K>-1,$=this.getBwEstimate(),F=n.levels,O=F[m],W=Math.max(h.loaded,Math.round(f*(s.bitrate||O.averageBitrate)/8));let ie=p?g-K:g;ie<1&&p&&(ie=Math.min(g,h.loaded*8/$));const X=p?h.loaded*1e3/ie:0,ce=L/1e3,ue=X?(W-h.loaded)/X:W*8/$+ce;if(ue<=N)return;const Q=X?X*8:$,ne=((i=t?.details||this.hls.latestLevelDetails)==null?void 0:i.live)===!0,re=this.hls.config.abrBandWidthUpFactor;let le=Number.POSITIVE_INFINITY,pe;for(pe=m-1;pe>I;pe--){const ke=F[pe].maxBitrate,Te=!F[pe].details||ne;if(le=this.getTimeToLoadFrag(ce,Q,f*ke,Te),le<Math.min(N,f+ce))break}if(le>=ue||le>f*10)return;p?this.bwEstimator.sample(g-Math.min(L,K),h.loaded):this.bwEstimator.sampleTTFB(g);const J=F[pe].maxBitrate;this.getBwEstimate()*re>J&&this.resetEstimator(J);const ee=this.findBestLevel(J,I,pe,0,N,1,1);ee>-1&&(pe=ee),this.warn(`Fragment ${s.sn}${r?" part "+r.index:""} of level ${m} is loading too slowly;
2
- Fragment duration: ${s.duration.toFixed(3)}
3
- Time to underbuffer: ${N.toFixed(3)} s
4
- Estimated load time for current fragment: ${ue.toFixed(3)} s
5
- Estimated load time for down switch fragment: ${le.toFixed(3)} s
6
- TTFB estimate: ${K|0} ms
7
- Current BW estimate: ${se($)?$|0:"Unknown"} bps
8
- New BW estimate: ${this.getBwEstimate()|0} bps
9
- Switching to level ${pe} @ ${J|0} bps`),n.nextLoadLevel=n.nextAutoLevel=pe,this.clearTimer();const ve=()=>{if(this.clearTimer(),this.fragCurrent===s&&this.hls.loadLevel===pe&&pe>0){const ke=this.getStarvationDelay();if(this.warn(`Aborting inflight request ${pe>0?"and switching down":""}
10
- Fragment duration: ${s.duration.toFixed(3)} s
11
- Time to underbuffer: ${ke.toFixed(3)} s`),s.abortRequests(),this.fragCurrent=this.partCurrent=null,pe>I){let Te=this.findBestLevel(this.hls.levels[I].bitrate,I,pe,0,ke,1,1);Te===-1&&(Te=I),this.hls.nextLoadLevel=this.hls.nextAutoLevel=Te,this.resetEstimator(this.hls.levels[Te].bitrate)}}};v||ue>le*2?ve():this.timer=self.setInterval(ve,le*1e3),n.trigger(y.FRAG_LOAD_EMERGENCY_ABORTED,{frag:s,part:r,stats:h})},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners()}resetEstimator(e){e&&(this.log(`setting initial bwe to ${e}`),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}initEstimator(){const e=this.hls.config;return new yu(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){const{hls:e}=this;e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.FRAG_LOADING,this.onFragLoading,this),e.on(y.FRAG_LOADED,this.onFragLoaded,this),e.on(y.FRAG_BUFFERED,this.onFragBuffered,this),e.on(y.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(y.LEVEL_LOADED,this.onLevelLoaded,this),e.on(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(y.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(y.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e&&(e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.FRAG_LOADING,this.onFragLoading,this),e.off(y.FRAG_LOADED,this.onFragLoaded,this),e.off(y.FRAG_BUFFERED,this.onFragBuffered,this),e.off(y.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(y.LEVEL_LOADED,this.onLevelLoaded,this),e.off(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(y.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(y.ERROR,this.onError,this))}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=this.supportedCache=null,this.fragCurrent=this.partCurrent=null}onManifestLoading(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.supportedCache={},this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()}onLevelsUpdated(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null}onMaxAutoLevelUpdated(){this.firstSelection=-1,this.nextAutoLevelKey=""}onFragLoading(e,t){const i=t.frag;if(!this.ignoreFragment(i)){if(!i.bitrateTest){var s;this.fragCurrent=i,this.partCurrent=(s=t.part)!=null?s:null}this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}}onLevelSwitching(e,t){this.clearTimer()}onError(e,t){if(!t.fatal)switch(t.details){case U.BUFFER_ADD_CODEC_ERROR:case U.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case U.FRAG_LOAD_TIMEOUT:{const i=t.frag,{fragCurrent:s,partCurrent:r}=this;if(i&&s&&i.sn===s.sn&&i.level===s.level){const n=performance.now(),o=r?r.stats:i.stats,c=n-o.loading.start,u=o.loading.first?o.loading.first-o.loading.start:-1;if(o.loaded&&u>-1){const f=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(c-Math.min(f,u),o.loaded)}else this.bwEstimator.sampleTTFB(c)}break}}}getTimeToLoadFrag(e,t,i,s){const r=e+i/t,n=s?e+this.lastLevelLoadSec:0;return r+n}onLevelLoaded(e,t){const i=this.hls.config,{loading:s}=t.stats,r=s.end-s.first;se(r)&&(this.lastLevelLoadSec=r/1e3),t.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD),this.timer>-1&&this._abandonRulesCheck(t.levelInfo)}onFragLoaded(e,{frag:t,part:i}){const s=i?i.stats:t.stats;if(t.type===he.MAIN&&this.bwEstimator.sampleTTFB(s.loading.first-s.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),t.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){const r=i?i.duration:t.duration,n=this.hls.levels[t.level],o=(n.loaded?n.loaded.bytes:0)+s.loaded,c=(n.loaded?n.loaded.duration:0)+r;n.loaded={bytes:o,duration:c},n.realBitrate=Math.round(8*o/c)}if(t.bitrateTest){const r={stats:s,frag:t,part:i,id:t.type};this.onFragBuffered(y.FRAG_BUFFERED,r),t.bitrateTest=!1}else this.lastLoadedFragLevel=t.level}}onFragBuffered(e,t){const{frag:i,part:s}=t,r=s!=null&&s.stats.loaded?s.stats:i.stats;if(r.aborted||this.ignoreFragment(i))return;const n=r.parsing.end-r.loading.start-Math.min(r.loading.first-r.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(n,r.loaded),r.bwEstimate=this.getBwEstimate(),i.bitrateTest?this.bitrateTestDelay=n/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==he.MAIN||e.sn==="initSegment"}clearTimer(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}get firstAutoLevel(){const{maxAutoLevel:e,minAutoLevel:t}=this.hls,i=this.getBwEstimate(),s=this.hls.config.maxStarvationDelay,r=this.findBestLevel(i,t,e,0,s,1,1);if(r>-1)return r;const n=this.hls.firstLevel,o=Math.min(Math.max(n,t),e);return this.warn(`Could not find best starting auto level. Defaulting to first in playlist ${n} clamped to ${o}`),o}get forcedAutoLevel(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}get nextAutoLevel(){const e=this.forcedAutoLevel,i=this.bwEstimator.canEstimate(),s=this.lastLoadedFragLevel>-1;if(e!==-1&&(!i||!s||this.nextAutoLevelKey===this.getAutoLevelKey()))return e;const r=i&&s?this.getNextABRAutoLevel():this.firstAutoLevel;if(e!==-1){const n=this.hls.levels;if(n.length>Math.max(e,r)&&n[e].loadError<=n[r].loadError)return e}return this._nextAutoLevel=r,this.nextAutoLevelKey=this.getAutoLevelKey(),r}getAutoLevelKey(){return`${this.getBwEstimate()}_${this.getStarvationDelay().toFixed(2)}`}getNextABRAutoLevel(){const{fragCurrent:e,partCurrent:t,hls:i}=this;if(i.levels.length<=1)return i.loadLevel;const{maxAutoLevel:s,config:r,minAutoLevel:n}=i,o=t?t.duration:e?e.duration:0,c=this.getBwEstimate(),u=this.getStarvationDelay();let h=r.abrBandWidthFactor,f=r.abrBandWidthUpFactor;if(u){const v=this.findBestLevel(c,n,s,u,0,h,f);if(v>=0)return this.rebufferNotice=-1,v}let g=o?Math.min(o,r.maxStarvationDelay):r.maxStarvationDelay;if(!u){const v=this.bitrateTestDelay;v&&(g=(o?Math.min(o,r.maxLoadingDelay):r.maxLoadingDelay)-v,this.info(`bitrate test took ${Math.round(1e3*v)}ms, set first fragment max fetchDuration to ${Math.round(1e3*g)} ms`),h=f=1)}const I=this.findBestLevel(c,n,s,u,g,h,f);if(this.rebufferNotice!==I&&(this.rebufferNotice=I,this.info(`${u?"rebuffering expected":"buffer is empty"}, optimal quality level ${I}`)),I>-1)return I;const m=i.levels[n],E=i.loadLevelObj;return E&&m?.bitrate<E.bitrate?n:i.loadLevel}getStarvationDelay(){const e=this.hls,t=e.media;if(!t)return 1/0;const i=t&&t.playbackRate!==0?Math.abs(t.playbackRate):1,s=e.mainForwardBufferInfo;return(s?s.len:0)/i}getBwEstimate(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}findBestLevel(e,t,i,s,r,n,o){var c;const u=s+r,h=this.lastLoadedFragLevel,f=h===-1?this.hls.firstLevel:h,{fragCurrent:g,partCurrent:I}=this,{levels:m,allAudioTracks:E,loadLevel:v,config:x}=this.hls;if(m.length===1)return 0;const D=m[f],L=!!((c=this.hls.latestLevelDetails)!=null&&c.live),w=v===-1||h===-1;let N,K="SDR",p=D?.frameRate||0;const{audioPreference:$,videoPreference:F}=x,O=this.audioTracksByGroup||(this.audioTracksByGroup=va(E));let W=-1;if(w){if(this.firstSelection!==-1)return this.firstSelection;const Q=this.codecTiers||(this.codecTiers=lc(m,O,t,i)),ne=oc(Q,K,e,$,F),{codecSet:re,videoRanges:le,minFramerate:pe,minBitrate:J,minIndex:ee,preferHDR:ve}=ne;W=ee,N=re,K=ve?le[le.length-1]:le[0],p=pe,e=Math.max(e,J),this.log(`picked start tier ${Ge(ne)}`)}else N=D?.codecSet,K=D?.videoRange;const ie=I?I.duration:g?g.duration:0,X=this.bwEstimator.getEstimateTTFB()/1e3,ce=[];for(let Q=i;Q>=t;Q--){var ue;const ne=m[Q],re=Q>f;if(!ne)continue;if(x.useMediaCapabilities&&!ne.supportedResult&&!ne.supportedPromise){const Te=navigator.mediaCapabilities;typeof Te?.decodingInfo=="function"&&Zu(ne,O,K,p,e,$)?(ne.supportedPromise=ma(ne,O,Te,this.supportedCache),ne.supportedPromise.then(Le=>{if(!this.hls)return;ne.supportedResult=Le;const it=this.hls.levels,Je=it.indexOf(ne);Le.error?this.warn(`MediaCapabilities decodingInfo error: "${Le.error}" for level ${Je} ${Ge(Le)}`):Le.supported?Le.decodingInfoResults.some(lt=>lt.smooth===!1||lt.powerEfficient===!1)&&this.log(`MediaCapabilities decodingInfo for level ${Je} not smooth or powerEfficient: ${Ge(Le)}`):(this.warn(`Unsupported MediaCapabilities decodingInfo result for level ${Je} ${Ge(Le)}`),Je>-1&&it.length>1&&(this.log(`Removing unsupported level ${Je}`),this.hls.removeLevel(Je),this.hls.loadLevel===-1&&(this.hls.nextLoadLevel=0)))}).catch(Le=>{this.warn(`Error handling MediaCapabilities decodingInfo: ${Le}`)})):ne.supportedResult=pa}if((N&&ne.codecSet!==N||K&&ne.videoRange!==K||re&&p>ne.frameRate||!re&&p>0&&p<ne.frameRate||(ue=ne.supportedResult)!=null&&(ue=ue.decodingInfoResults)!=null&&ue.some(Te=>Te.smooth===!1))&&(!w||Q!==W)){ce.push(Q);continue}const le=ne.details,pe=(I?le?.partTarget:le?.averagetargetduration)||ie;let J;re?J=o*e:J=n*e;const ee=ie&&s>=ie*2&&r===0?ne.averageBitrate:ne.maxBitrate,ve=this.getTimeToLoadFrag(X,J,ee*pe,le===void 0);if(J>=ee&&(Q===h||ne.loadError===0&&ne.fragmentError===0)&&(ve<=X||!se(ve)||L&&!this.bitrateTestDelay||ve<u)){const Te=this.forcedAutoLevel;return Q!==v&&(Te===-1||Te!==v)&&(ce.length&&this.trace(`Skipped level(s) ${ce.join(",")} of ${i} max with CODECS and VIDEO-RANGE:"${m[ce[0]].codecs}" ${m[ce[0]].videoRange}; not compatible with "${N}" ${K}`),this.info(`switch candidate:${f}->${Q} adjustedbw(${Math.round(J)})-bitrate=${Math.round(J-ee)} ttfb:${X.toFixed(1)} avgDuration:${pe.toFixed(1)} maxFetchDuration:${u.toFixed(1)} fetchDuration:${ve.toFixed(1)} firstSelection:${w} codecSet:${ne.codecSet} videoRange:${ne.videoRange} hls.loadLevel:${v}`)),w&&(this.firstSelection=Q),Q}}return-1}set nextAutoLevel(e){const t=this.deriveNextAutoLevel(e);this._nextAutoLevel!==t&&(this.nextAutoLevelKey="",this._nextAutoLevel=t)}deriveNextAutoLevel(e){const{maxAutoLevel:t,minAutoLevel:i}=this.hls;return Math.min(Math.max(e,i),t)}}const xa={search:function(a,e){let t=0,i=a.length-1,s=null,r=null;for(;t<=i;){s=(t+i)/2|0,r=a[s];const n=e(r);if(n>0)t=s+1;else if(n<0)i=s-1;else return r}return null}};function fc(a,e,t){if(e===null||!Array.isArray(a)||!a.length||!se(e))return null;const i=a[0].programDateTime;if(e<(i||0))return null;const s=a[a.length-1].endProgramDateTime;if(e>=(s||0))return null;for(let r=0;r<a.length;++r){const n=a[r];if(pc(e,t,n))return n}return null}function yi(a,e,t=0,i=0,s=.005){let r=null;if(a){r=e[1+a.sn-e[0].sn]||null;const o=a.endDTS-t;o>0&&o<15e-7&&(t+=15e-7),r&&a.level!==r.level&&r.end<=a.end&&(r=e[2+a.sn-e[0].sn]||null)}else t===0&&e[0].start===0&&(r=e[0]);if(r&&((!a||a.level===r.level)&&ba(t,i,r)===0||gc(r,a,Math.min(s,i))))return r;const n=xa.search(e,ba.bind(null,t,i));return n&&(n!==a||!r)?n:r}function gc(a,e,t){if(e&&e.start===0&&e.level<a.level&&(e.endPTS||0)>0){const i=e.tagList.reduce((s,r)=>(r[0]==="INF"&&(s+=parseFloat(r[1])),s),t);return a.start<=i}return!1}function ba(a=0,e=0,t){if(t.start<=a&&t.start+t.duration>a)return 0;const i=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0));return t.start+t.duration-i<=a?1:t.start-i>a&&t.start?-1:0}function pc(a,e,t){const i=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0))*1e3;return(t.endProgramDateTime||0)-i>a}function La(a,e,t){if(a&&a.startCC<=e&&a.endCC>=e){let i=a.fragments;const{fragmentHint:s}=a;s&&(i=i.concat(s));let r;return xa.search(i,n=>n.cc<e?1:n.cc>e?-1:(r=n,n.end<=t?1:n.start>t?-1:0)),r||null}return null}function bs(a){switch(a.details){case U.FRAG_LOAD_TIMEOUT:case U.KEY_LOAD_TIMEOUT:case U.LEVEL_LOAD_TIMEOUT:case U.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function Ra(a,e){const t=bs(e);return a.default[`${t?"timeout":"error"}Retry`]}function br(a,e){const t=a.backoff==="linear"?1:Math.pow(2,e);return Math.min(t*a.retryDelayMs,a.maxRetryDelayMs)}function Da(a){return Be(Be({},a),{errorRetry:null,timeoutRetry:null})}function Ls(a,e,t,i){if(!a)return!1;const s=i?.code,r=e<a.maxNumRetry&&(Ac(s)||!!t);return a.shouldRetry?a.shouldRetry(a,e,t,i,r):r}function Ac(a){return Lr(a)||!!a&&(a<400||a>499)}function Lr(a){return a===0&&navigator.onLine===!1}var rt={DoNothing:0,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,RetryRequest:5},Ct={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,MoveAllAlternatesMatchingKey:4};class mc extends Tt{constructor(e){super("error-controller",e.logger),this.hls=void 0,this.playlistError=0,this.hls=e,this.registerListeners()}registerListeners(){const e=this.hls;e.on(y.ERROR,this.onError,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const e=this.hls;e&&(e.off(y.ERROR,this.onError,this),e.off(y.ERROR,this.onErrorOut,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null}startLoad(e){}stopLoad(){this.playlistError=0}getVariantLevelIndex(e){return e?.type===he.MAIN?e.level:this.getVariantIndex()}getVariantIndex(){var e;const t=this.hls,i=t.currentLevel;return(e=t.loadLevelObj)!=null&&e.details||i===-1?t.loadLevel:i}variantHasKey(e,t){if(e){var i;if((i=e.details)!=null&&i.hasKey(t))return!0;const s=e.audioGroups;if(s)return this.hls.allAudioTracks.filter(n=>s.indexOf(n.groupId)>=0).some(n=>{var o;return(o=n.details)==null?void 0:o.hasKey(t)})}return!1}onManifestLoading(){this.playlistError=0}onLevelUpdated(){this.playlistError=0}onError(e,t){var i;if(t.fatal)return;const s=this.hls,r=t.context;switch(t.details){case U.FRAG_LOAD_ERROR:case U.FRAG_LOAD_TIMEOUT:case U.KEY_LOAD_ERROR:case U.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case U.FRAG_PARSING_ERROR:if((i=t.frag)!=null&&i.gap){t.errorAction=_i();return}case U.FRAG_GAP:case U.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=rt.SendAlternateToPenaltyBox;return}case U.LEVEL_EMPTY_ERROR:case U.LEVEL_PARSING_ERROR:{var n;const c=t.parent===he.MAIN?t.level:s.loadLevel;t.details===U.LEVEL_EMPTY_ERROR&&((n=t.context)!=null&&(n=n.levelDetails)!=null&&n.live)?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,c):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,c))}return;case U.LEVEL_LOAD_ERROR:case U.LEVEL_LOAD_TIMEOUT:typeof r?.level=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,r.level));return;case U.AUDIO_TRACK_LOAD_ERROR:case U.AUDIO_TRACK_LOAD_TIMEOUT:case U.SUBTITLE_LOAD_ERROR:case U.SUBTITLE_TRACK_LOAD_TIMEOUT:if(r){const c=s.loadLevelObj;if(c&&(r.type===be.AUDIO_TRACK&&c.hasAudioGroup(r.groupId)||r.type===be.SUBTITLE_TRACK&&c.hasSubtitleGroup(r.groupId))){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,s.loadLevel),t.errorAction.action=rt.SendAlternateToPenaltyBox,t.errorAction.flags=Ct.MoveAllAlternatesMatchingHost;return}}return;case U.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:t.errorAction={action:rt.SendAlternateToPenaltyBox,flags:Ct.MoveAllAlternatesMatchingHDCP};return;case U.KEY_SYSTEM_SESSION_UPDATE_FAILED:case U.KEY_SYSTEM_STATUS_INTERNAL_ERROR:case U.KEY_SYSTEM_NO_SESSION:t.errorAction={action:rt.SendAlternateToPenaltyBox,flags:Ct.MoveAllAlternatesMatchingKey};return;case U.BUFFER_ADD_CODEC_ERROR:case U.REMUX_ALLOC_ERROR:case U.BUFFER_APPEND_ERROR:if(!t.errorAction){var o;t.errorAction=this.getLevelSwitchAction(t,(o=t.level)!=null?o:s.loadLevel)}return;case U.INTERNAL_EXCEPTION:case U.BUFFER_APPENDING_ERROR:case U.BUFFER_FULL_ERROR:case U.LEVEL_SWITCH_ERROR:case U.BUFFER_STALLED_ERROR:case U.BUFFER_SEEK_OVER_HOLE:case U.BUFFER_NUDGE_ON_STALL:t.errorAction=_i();return}t.type===de.KEY_SYSTEM_ERROR&&(t.levelRetry=!1,t.errorAction=_i())}getPlaylistRetryOrSwitchAction(e,t){const i=this.hls,s=Ra(i.config.playlistLoadPolicy,e),r=this.playlistError++;if(Ls(s,r,bs(e),e.response))return{action:rt.RetryRequest,flags:Ct.None,retryConfig:s,retryCount:r};const o=this.getLevelSwitchAction(e,t);return s&&(o.retryConfig=s,o.retryCount=r),o}getFragRetryOrSwitchAction(e){const t=this.hls,i=this.getVariantLevelIndex(e.frag),s=t.levels[i],{fragLoadPolicy:r,keyLoadPolicy:n}=t.config,o=Ra(e.details.startsWith("key")?n:r,e),c=t.levels.reduce((h,f)=>h+f.fragmentError,0);if(s&&(e.details!==U.FRAG_GAP&&s.fragmentError++,Ls(o,c,bs(e),e.response)))return{action:rt.RetryRequest,flags:Ct.None,retryConfig:o,retryCount:c};const u=this.getLevelSwitchAction(e,i);return o&&(u.retryConfig=o,u.retryCount=c),u}getLevelSwitchAction(e,t){const i=this.hls;t==null&&(t=i.loadLevel);const s=this.hls.levels[t];if(s){var r,n;const u=e.details;s.loadError++,u===U.BUFFER_APPEND_ERROR&&s.fragmentError++;let h=-1;const{levels:f,loadLevel:g,minAutoLevel:I,maxAutoLevel:m}=i;!i.autoLevelEnabled&&!i.config.preserveManualLevelOnError&&(i.loadLevel=-1);const E=(r=e.frag)==null?void 0:r.type,x=(E===he.AUDIO&&u===U.FRAG_PARSING_ERROR||e.sourceBufferName==="audio"&&(u===U.BUFFER_ADD_CODEC_ERROR||u===U.BUFFER_APPEND_ERROR))&&f.some(({audioCodec:K})=>s.audioCodec!==K),L=e.sourceBufferName==="video"&&(u===U.BUFFER_ADD_CODEC_ERROR||u===U.BUFFER_APPEND_ERROR)&&f.some(({codecSet:K,audioCodec:p})=>s.codecSet!==K&&s.audioCodec===p),{type:w,groupId:N}=(n=e.context)!=null?n:{};for(let K=f.length;K--;){const p=(K+g)%f.length;if(p!==g&&p>=I&&p<=m&&f[p].loadError===0){var o,c;const $=f[p];if(u===U.FRAG_GAP&&E===he.MAIN&&e.frag){const F=f[p].details;if(F){const O=yi(e.frag,F.fragments,e.frag.start);if(O!=null&&O.gap)continue}}else{if(w===be.AUDIO_TRACK&&$.hasAudioGroup(N)||w===be.SUBTITLE_TRACK&&$.hasSubtitleGroup(N))continue;if(E===he.AUDIO&&(o=s.audioGroups)!=null&&o.some(F=>$.hasAudioGroup(F))||E===he.SUBTITLE&&(c=s.subtitleGroups)!=null&&c.some(F=>$.hasSubtitleGroup(F))||x&&s.audioCodec===$.audioCodec||L&&s.codecSet===$.codecSet||!x&&s.codecSet!==$.codecSet)continue}h=p;break}}if(h>-1&&i.loadLevel!==h)return e.levelRetry=!0,this.playlistError=0,{action:rt.SendAlternateToPenaltyBox,flags:Ct.None,nextAutoLevel:h}}return{action:rt.SendAlternateToPenaltyBox,flags:Ct.MoveAllAlternatesMatchingHost}}onErrorOut(e,t){var i;switch((i=t.errorAction)==null?void 0:i.action){case rt.DoNothing:break;case rt.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),!t.errorAction.resolved&&t.details!==U.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}}sendAlternateToPenaltyBox(e){const t=this.hls,i=e.errorAction;if(!i)return;const{flags:s}=i,r=i.nextAutoLevel;switch(s){case Ct.None:this.switchLevel(e,r);break;case Ct.MoveAllAlternatesMatchingHDCP:{const c=this.getVariantLevelIndex(e.frag),u=t.levels[c],h=u?.attrs["HDCP-LEVEL"];if(i.hdcpLevel=h,h){t.maxHdcpLevel=xr[xr.indexOf(h)-1],i.resolved=!0,this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}}case Ct.MoveAllAlternatesMatchingKey:{const c=e.decryptdata;if(c){const u=this.hls.levels;for(let h=u.length;h--;)if(this.variantHasKey(u[h],c)){var n,o;this.log(`Banned key found in level ${h} (${u[h].bitrate}bps) or audio group "${(n=u[h].audioGroups)==null?void 0:n.join(",")}" (${(o=e.frag)==null?void 0:o.type} fragment) ${It(c.keyId||[])}`),u[h].fragmentError++,u[h].loadError++,this.log(`Removing level ${h} with key error (${e.error})`),this.hls.removeLevel(h)}u.length&&(i.resolved=!0)}break}}i.resolved||this.switchLevel(e,r)}switchLevel(e,t){if(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,e.details===U.BUFFER_ADD_CODEC_ERROR&&e.mimeType&&e.sourceBufferName!=="audiovideo")){const i=Sr(e.mimeType),s=this.hls.levels;for(let r=s.length;r--;)s[r][`${e.sourceBufferName}Codec`]===i&&(this.log(`Removing level ${r} for ${e.details} ("${i}" not supported)`),this.hls.removeLevel(r))}}}function _i(a){const e={action:rt.DoNothing,flags:Ct.None};return a&&(e.resolved=!0),e}var Qe={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};class Ic{constructor(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}_registerListeners(){const{hls:e}=this;e&&(e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.BUFFER_APPENDED,this.onBufferAppended,this),e.on(y.FRAG_BUFFERED,this.onFragBuffered,this),e.on(y.FRAG_LOADED,this.onFragLoaded,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.BUFFER_APPENDED,this.onBufferAppended,this),e.off(y.FRAG_BUFFERED,this.onFragBuffered,this),e.off(y.FRAG_LOADED,this.onFragLoaded,this))}destroy(){this._unregisterListeners(),this.hls=this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){const i=this.activePartLists[t];if(i)for(let s=i.length;s--;){const r=i[s];if(!r)break;if(r.start<=e&&e<=r.end&&r.loaded)return r}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){return this.getFragAtPos(e,t,!0)}getFragAtPos(e,t,i){const{fragments:s}=this,r=Object.keys(s);for(let n=r.length;n--;){const o=s[r[n]];if(o?.body.type===t&&(!i||o.buffered)){const c=o.body;if(c.start<=e&&e<=c.end)return c}}return null}detectEvictedFragments(e,t,i,s,r){this.timeRanges&&(this.timeRanges[e]=t);const n=s?.fragment.sn||-1;Object.keys(this.fragments).forEach(o=>{const c=this.fragments[o];if(!c||n>=c.body.sn)return;if(!c.buffered&&(!c.loaded||r)){c.body.type===i&&this.removeFragment(c.body);return}const u=c.range[e];if(u){if(u.time.length===0){this.removeFragment(c.body);return}u.time.some(h=>{const f=!this.isTimeBuffered(h.startPTS,h.endPTS,t);return f&&this.removeFragment(c.body),f})}})}detectPartialFragments(e){const t=this.timeRanges;if(!t||e.frag.sn==="initSegment")return;const i=e.frag,s=wi(i),r=this.fragments[s];if(!r||r.buffered&&i.gap)return;const n=!i.relurl;Object.keys(t).forEach(o=>{const c=i.elementaryStreams[o];if(!c)return;const u=t[o],h=n||c.partial===!0;r.range[o]=this.getBufferedTimes(i,e.part,h,u)}),r.loaded=null,Object.keys(r.range).length?(r.buffered=!0,(r.body.endList=i.endList||r.body.endList)&&(this.endListFragments[r.body.type]=r),Rs(r)||this.removeParts(i.sn-1,i.type)):this.removeFragment(r.body)}removeParts(e,t){const i=this.activePartLists[t];i&&(this.activePartLists[t]=Pa(i,s=>s.fragment.sn>=e))}fragBuffered(e,t){const i=wi(e);let s=this.fragments[i];!s&&t&&(s=this.fragments[i]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),s&&(s.loaded=null,s.buffered=!0)}getBufferedTimes(e,t,i,s){const r={time:[],partial:i},n=e.start,o=e.end,c=e.minEndPTS||o,u=e.maxStartPTS||n;for(let h=0;h<s.length;h++){const f=s.start(h)-this.bufferPadding,g=s.end(h)+this.bufferPadding;if(u>=f&&c<=g){r.time.push({startPTS:Math.max(n,s.start(h)),endPTS:Math.min(o,s.end(h))});break}else if(n<g&&o>f){const I=Math.max(n,s.start(h)),m=Math.min(o,s.end(h));m>I&&(r.partial=!0,r.time.push({startPTS:I,endPTS:m}))}else if(o<=f)break}return r}getPartialFragment(e){let t=null,i,s,r,n=0;const{bufferPadding:o,fragments:c}=this;return Object.keys(c).forEach(u=>{const h=c[u];h&&Rs(h)&&(s=h.body.start-o,r=h.body.end+o,e>=s&&e<=r&&(i=Math.min(e-s,r-e),n<=i&&(t=h.body,n=i)))}),t}isEndListAppended(e){const t=this.endListFragments[e];return t!==void 0&&(t.buffered||Rs(t))}getState(e){const t=wi(e),i=this.fragments[t];return i?i.buffered?Rs(i)?Qe.PARTIAL:Qe.OK:Qe.APPENDING:Qe.NOT_LOADED}isTimeBuffered(e,t,i){let s,r;for(let n=0;n<i.length;n++){if(s=i.start(n)-this.bufferPadding,r=i.end(n)+this.bufferPadding,e>=s&&t<=r)return!0;if(t<=s)return!1}return!1}onManifestLoading(){this.removeAllFragments()}onFragLoaded(e,t){if(t.frag.sn==="initSegment"||t.frag.bitrateTest)return;const i=t.frag,s=t.part?null:t,r=wi(i);this.fragments[r]={body:i,appendedPTS:null,loaded:s,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){const{frag:i,part:s,timeRanges:r,type:n}=t;if(i.sn==="initSegment")return;const o=i.type;if(s){let u=this.activePartLists[o];u||(this.activePartLists[o]=u=[]),u.push(s)}this.timeRanges=r;const c=r[n];this.detectEvictedFragments(n,c,o,s)}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){const t=wi(e);return!!this.fragments[t]}hasFragments(e){const{fragments:t}=this,i=Object.keys(t);if(!e)return i.length>0;for(let s=i.length;s--;){const r=t[i[s]];if(r?.body.type===e)return!0}return!1}hasParts(e){var t;return!!((t=this.activePartLists[e])!=null&&t.length)}removeFragmentsInRange(e,t,i,s,r){s&&!this.hasGaps||Object.keys(this.fragments).forEach(n=>{const o=this.fragments[n];if(!o)return;const c=o.body;c.type!==i||s&&!c.gap||c.start<t&&c.end>e&&(o.buffered||r)&&this.removeFragment(c)})}removeFragment(e){const t=wi(e);e.clearElementaryStreamInfo();const i=this.activePartLists[e.type];if(i){const s=e.sn;this.activePartLists[e.type]=Pa(i,r=>r.fragment.sn!==s)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){var e;this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1;const t=(e=this.hls)==null||(e=e.latestLevelDetails)==null?void 0:e.partList;t&&t.forEach(i=>i.clearElementaryStreamInfo())}}function Rs(a){var e,t,i;return a.buffered&&!!(a.body.gap||(e=a.range.video)!=null&&e.partial||(t=a.range.audio)!=null&&t.partial||(i=a.range.audiovideo)!=null&&i.partial)}function wi(a){return`${a.type}_${a.level}_${a.sn}`}function Pa(a,e){return a.filter(t=>{const i=e(t);return i||t.clearElementaryStreamInfo(),i})}var ni={cbc:0,ctr:1};class Cc{constructor(e,t,i){this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=e,this.aesIV=t,this.aesMode=i}decrypt(e,t){switch(this.aesMode){case ni.cbc:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case ni.ctr:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},t,e);default:throw new Error(`[AESCrypto] invalid aes mode ${this.aesMode}`)}}}function yc(a){const e=a.byteLength,t=e&&new DataView(a.buffer).getUint8(e-1);return t?a.slice(0,e-t):a}class Ec{constructor(){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()}uint8ArrayToUint32Array_(e){const t=new DataView(e),i=new Uint32Array(4);for(let s=0;s<4;s++)i[s]=t.getUint32(s*4);return i}initTable(){const e=this.sBox,t=this.invSBox,i=this.subMix,s=i[0],r=i[1],n=i[2],o=i[3],c=this.invSubMix,u=c[0],h=c[1],f=c[2],g=c[3],I=new Uint32Array(256);let m=0,E=0,v=0;for(v=0;v<256;v++)v<128?I[v]=v<<1:I[v]=v<<1^283;for(v=0;v<256;v++){let x=E^E<<1^E<<2^E<<3^E<<4;x=x>>>8^x&255^99,e[m]=x,t[x]=m;const D=I[m],L=I[D],w=I[L];let N=I[x]*257^x*16843008;s[m]=N<<24|N>>>8,r[m]=N<<16|N>>>16,n[m]=N<<8|N>>>24,o[m]=N,N=w*16843009^L*65537^D*257^m*16843008,u[x]=N<<24|N>>>8,h[x]=N<<16|N>>>16,f[x]=N<<8|N>>>24,g[x]=N,m?(m=D^I[I[I[w^D]]],E^=I[I[E]]):m=E=1}}expandKey(e){const t=this.uint8ArrayToUint32Array_(e);let i=!0,s=0;for(;s<t.length&&i;)i=t[s]===this.key[s],s++;if(i)return;this.key=t;const r=this.keySize=t.length;if(r!==4&&r!==6&&r!==8)throw new Error("Invalid aes key size="+r);const n=this.ksRows=(r+6+1)*4;let o,c;const u=this.keySchedule=new Uint32Array(n),h=this.invKeySchedule=new Uint32Array(n),f=this.sBox,g=this.rcon,I=this.invSubMix,m=I[0],E=I[1],v=I[2],x=I[3];let D,L;for(o=0;o<n;o++){if(o<r){D=u[o]=t[o];continue}L=D,o%r===0?(L=L<<8|L>>>24,L=f[L>>>24]<<24|f[L>>>16&255]<<16|f[L>>>8&255]<<8|f[L&255],L^=g[o/r|0]<<24):r>6&&o%r===4&&(L=f[L>>>24]<<24|f[L>>>16&255]<<16|f[L>>>8&255]<<8|f[L&255]),u[o]=D=(u[o-r]^L)>>>0}for(c=0;c<n;c++)o=n-c,c&3?L=u[o]:L=u[o-4],c<4||o<=4?h[c]=L:h[c]=m[f[L>>>24]]^E[f[L>>>16&255]]^v[f[L>>>8&255]]^x[f[L&255]],h[c]=h[c]>>>0}networkToHostOrderSwap(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24}decrypt(e,t,i){const s=this.keySize+6,r=this.invKeySchedule,n=this.invSBox,o=this.invSubMix,c=o[0],u=o[1],h=o[2],f=o[3],g=this.uint8ArrayToUint32Array_(i);let I=g[0],m=g[1],E=g[2],v=g[3];const x=new Int32Array(e),D=new Int32Array(x.length);let L,w,N,K,p,$,F,O,W,ie,X,ce,ue,Q;const ne=this.networkToHostOrderSwap;for(;t<x.length;){for(W=ne(x[t]),ie=ne(x[t+1]),X=ne(x[t+2]),ce=ne(x[t+3]),p=W^r[0],$=ce^r[1],F=X^r[2],O=ie^r[3],ue=4,Q=1;Q<s;Q++)L=c[p>>>24]^u[$>>16&255]^h[F>>8&255]^f[O&255]^r[ue],w=c[$>>>24]^u[F>>16&255]^h[O>>8&255]^f[p&255]^r[ue+1],N=c[F>>>24]^u[O>>16&255]^h[p>>8&255]^f[$&255]^r[ue+2],K=c[O>>>24]^u[p>>16&255]^h[$>>8&255]^f[F&255]^r[ue+3],p=L,$=w,F=N,O=K,ue=ue+4;L=n[p>>>24]<<24^n[$>>16&255]<<16^n[F>>8&255]<<8^n[O&255]^r[ue],w=n[$>>>24]<<24^n[F>>16&255]<<16^n[O>>8&255]<<8^n[p&255]^r[ue+1],N=n[F>>>24]<<24^n[O>>16&255]<<16^n[p>>8&255]<<8^n[$&255]^r[ue+2],K=n[O>>>24]<<24^n[p>>16&255]<<16^n[$>>8&255]<<8^n[F&255]^r[ue+3],D[t]=ne(L^I),D[t+1]=ne(K^m),D[t+2]=ne(N^E),D[t+3]=ne(w^v),I=W,m=ie,E=X,v=ce,t=t+4}return D.buffer}}class vc{constructor(e,t,i){this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=e,this.key=t,this.aesMode=i}expandKey(){const e=Tc(this.aesMode);return this.subtle.importKey("raw",this.key,{name:e},!1,["encrypt","decrypt"])}}function Tc(a){switch(a){case ni.cbc:return"AES-CBC";case ni.ctr:return"AES-CTR";default:throw new Error(`[FastAESKey] invalid aes mode ${a}`)}}const Sc=16;class Rr{constructor(e,{removePKCS7Padding:t=!0}={}){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=e.enableSoftwareAES,this.removePKCS7Padding=t,t)try{const i=self.crypto;i&&(this.subtle=i.subtle||i.webkitSubtle)}catch{}this.useSoftware=!this.subtle}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){const{currentResult:e,remainderData:t}=this;if(!e||t)return this.reset(),null;const i=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?yc(i):i}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,i,s){return this.useSoftware?new Promise((r,n)=>{const o=ArrayBuffer.isView(e)?e:new Uint8Array(e);this.softwareDecrypt(o,t,i,s);const c=this.flush();c?r(c.buffer):n(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,i,s)}softwareDecrypt(e,t,i,s){const{currentIV:r,currentResult:n,remainderData:o}=this;if(s!==ni.cbc||t.byteLength!==16)return Oe.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),o&&(e=St(o,e),this.remainderData=null);const c=this.getValidChunk(e);if(!c.length)return null;r&&(i=r);let u=this.softwareDecrypter;u||(u=this.softwareDecrypter=new Ec),u.expandKey(t);const h=n;return this.currentResult=u.decrypt(c.buffer,0,i),this.currentIV=c.slice(-16).buffer,h||null}webCryptoDecrypt(e,t,i,s){if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,i,s));this.key=t,this.fastAesKey=new vc(this.subtle,t,s)}return this.fastAesKey.expandKey().then(r=>this.subtle?(this.logOnce("WebCrypto AES decrypt"),new Cc(this.subtle,new Uint8Array(i),s).decrypt(e.buffer,r)):Promise.reject(new Error("web crypto not initialized"))).catch(r=>(Oe.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${r.name}: ${r.message}`),this.onWebCryptoError(e,t,i,s)))}onWebCryptoError(e,t,i,s){const r=this.enableSoftwareAES;if(r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,i,s);const n=this.flush();if(n)return n.buffer}throw new Error("WebCrypto"+(r?" and softwareDecrypt":"")+": failed to decrypt data")}getValidChunk(e){let t=e;const i=e.length-e.length%Sc;return i!==e.length&&(t=e.slice(0,i),this.remainderData=e.slice(i)),t}logOnce(e){this.logEnabled&&(Oe.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}const _a=Math.pow(2,17);class xc{constructor(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(e,t){const i=e.url;if(!i)return Promise.reject(new zt({type:de.NETWORK_ERROR,details:U.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error(`Fragment does not have a ${i?"part list":"url"}`),networkDetails:null}));this.abort();const s=this.config,r=s.fLoader,n=s.loader;return new Promise((o,c)=>{if(this.loader&&this.loader.destroy(),e.gap)if(e.tagList.some(m=>m[0]==="GAP")){c(ka(e));return}else e.gap=!1;const u=this.loader=r?new r(s):new n(s),h=wa(e);e.loader=u;const f=Da(s.fragLoadPolicy.default),g={loadPolicy:f,timeout:f.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:_a};e.stats=u.stats;const I={onSuccess:(m,E,v,x)=>{this.resetLoader(e,u);let D=m.data;v.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(D.slice(0,16)),D=D.slice(16)),o({frag:e,part:null,payload:D,networkDetails:x})},onError:(m,E,v,x)=>{this.resetLoader(e,u),c(new zt({type:de.NETWORK_ERROR,details:U.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:Be({url:i,data:void 0},m),error:new Error(`HTTP Error ${m.code} ${m.text}`),networkDetails:v,stats:x}))},onAbort:(m,E,v)=>{this.resetLoader(e,u),c(new zt({type:de.NETWORK_ERROR,details:U.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:v,stats:m}))},onTimeout:(m,E,v)=>{this.resetLoader(e,u),c(new zt({type:de.NETWORK_ERROR,details:U.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${g.timeout}ms`),networkDetails:v,stats:m}))}};t&&(I.onProgress=(m,E,v,x)=>t({frag:e,part:null,payload:v,networkDetails:x})),u.load(h,g,I)})}loadPart(e,t,i){this.abort();const s=this.config,r=s.fLoader,n=s.loader;return new Promise((o,c)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap){c(ka(e,t));return}const u=this.loader=r?new r(s):new n(s),h=wa(e,t);e.loader=u;const f=Da(s.fragLoadPolicy.default),g={loadPolicy:f,timeout:f.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:_a};t.stats=u.stats,u.load(h,g,{onSuccess:(I,m,E,v)=>{this.resetLoader(e,u),this.updateStatsFromPart(e,t);const x={frag:e,part:t,payload:I.data,networkDetails:v};i(x),o(x)},onError:(I,m,E,v)=>{this.resetLoader(e,u),c(new zt({type:de.NETWORK_ERROR,details:U.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:Be({url:h.url,data:void 0},I),error:new Error(`HTTP Error ${I.code} ${I.text}`),networkDetails:E,stats:v}))},onAbort:(I,m,E)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,u),c(new zt({type:de.NETWORK_ERROR,details:U.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:E,stats:I}))},onTimeout:(I,m,E)=>{this.resetLoader(e,u),c(new zt({type:de.NETWORK_ERROR,details:U.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${g.timeout}ms`),networkDetails:E,stats:I}))}})})}updateStatsFromPart(e,t){const i=e.stats,s=t.stats,r=s.total;if(i.loaded+=s.loaded,r){const c=Math.round(e.duration/t.duration),u=Math.min(Math.round(i.loaded/r),c),f=(c-u)*Math.round(i.loaded/u);i.total=i.loaded+f}else i.total=Math.max(i.loaded,i.total);const n=i.loading,o=s.loading;n.start?n.first+=o.first-o.start:(n.start=o.start,n.first=o.first),n.end=o.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}function wa(a,e=null){const t=e||a,i={frag:a,part:e,responseType:"arraybuffer",url:t.url,headers:{},rangeStart:0,rangeEnd:0},s=t.byteRangeStartOffset,r=t.byteRangeEndOffset;if(se(s)&&se(r)){var n;let o=s,c=r;if(a.sn==="initSegment"&&bc((n=a.decryptdata)==null?void 0:n.method)){const u=r-s;u%16&&(c=r+(16-u%16)),s!==0&&(i.resetIV=!0,o=s-16)}i.rangeStart=o,i.rangeEnd=c}return i}function ka(a,e){const t=new Error(`GAP ${a.gap?"tag":"attribute"} found`),i={type:de.MEDIA_ERROR,details:U.FRAG_GAP,fatal:!1,frag:a,error:t,networkDetails:null};return e&&(i.part=e),(e||a).stats.aborted=!0,new zt(i)}function bc(a){return a==="AES-128"||a==="AES-256"}class zt extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class Ma extends Tt{constructor(e,t){super(e,t),this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(e){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}clearInterval(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1}clearNextTick(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1}tick(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}class Dr{constructor(e,t,i,s=0,r=-1,n=!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=Ds(),this.buffering={audio:Ds(),video:Ds(),audiovideo:Ds()},this.level=e,this.sn=t,this.id=i,this.size=s,this.part=r,this.partial=n}}function Ds(){return{start:0,executeStart:0,executeEnd:0,end:0}}const Oa={length:0,start:()=>0,end:()=>0};class ye{static isBuffered(e,t){if(e){const i=ye.getBuffered(e);for(let s=i.length;s--;)if(t>=i.start(s)&&t<=i.end(s))return!0}return!1}static bufferedRanges(e){if(e){const t=ye.getBuffered(e);return ye.timeRangesToArray(t)}return[]}static timeRangesToArray(e){const t=[];for(let i=0;i<e.length;i++)t.push({start:e.start(i),end:e.end(i)});return t}static bufferInfo(e,t,i){if(e){const s=ye.bufferedRanges(e);if(s.length)return ye.bufferedInfo(s,t,i)}return{len:0,start:t,end:t,bufferedIndex:-1}}static bufferedInfo(e,t,i){t=Math.max(0,t),e.length>1&&e.sort((h,f)=>h.start-f.start||f.end-h.end);let s=-1,r=[];if(i)for(let h=0;h<e.length;h++){t>=e[h].start&&t<=e[h].end&&(s=h);const f=r.length;if(f){const g=r[f-1].end;e[h].start-g<i?e[h].end>g&&(r[f-1].end=e[h].end):r.push(e[h])}else r.push(e[h])}else r=e;let n=0,o,c=t,u=t;for(let h=0;h<r.length;h++){const f=r[h].start,g=r[h].end;if(s===-1&&t>=f&&t<=g&&(s=h),t+i>=f&&t<g)c=f,u=g,n=u-t;else if(t+i<f){o=f;break}}return{len:n,start:c||0,end:u||0,nextStart:o,buffered:e,bufferedIndex:s}}static getBuffered(e){try{return e.buffered||Oa}catch(t){return Oe.log("failed to get media.buffered",t),Oa}}}const Fa=/\{\$([a-zA-Z0-9-_]+)\}/g;function Na(a){return Fa.test(a)}function Pr(a,e){if(a.variableList!==null||a.hasVariableRefs){const t=a.variableList;return e.replace(Fa,i=>{const s=i.substring(2,i.length-1),r=t?.[s];return r===void 0?(a.playlistParsingError||(a.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${s}"`)),i):r})}return e}function Ba(a,e,t){let i=a.variableList;i||(a.variableList=i={});let s,r;if("QUERYPARAM"in e){s=e.QUERYPARAM;try{const n=new self.URL(t).searchParams;if(n.has(s))r=n.get(s);else throw new Error(`"${s}" does not match any query parameter in URI: "${t}"`)}catch(n){a.playlistParsingError||(a.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${n.message}`))}}else s=e.NAME,r=e.VALUE;s in i?a.playlistParsingError||(a.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${s}"`)):i[s]=r||""}function Lc(a,e,t){const i=e.IMPORT;if(t&&i in t){let s=a.variableList;s||(a.variableList=s={}),s[i]=t[i]}else a.playlistParsingError||(a.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${i}"`))}const Rc=/^(\d+)x(\d+)$/,Ua=/(.+?)=(".*?"|.*?)(?:,|$)/g;class He{constructor(e,t){typeof e=="string"&&(e=He.parseAttrList(e,t)),Ne(this,e)}get clientAttrs(){return Object.keys(this).filter(e=>e.substring(0,2)==="X-")}decimalInteger(e){const t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(e){if(this[e]){let t=(this[e]||"0x").slice(2);t=(t.length&1?"0":"")+t;const i=new Uint8Array(t.length/2);for(let s=0;s<t.length/2;s++)i[s]=parseInt(t.slice(s*2,s*2+2),16);return i}return null}hexadecimalIntegerAsNumber(e){const t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){const i=this[e];return i?parseFloat(i):t}enumeratedString(e){return this[e]}enumeratedStringList(e,t){const i=this[e];return(i?i.split(/[ ,]+/):[]).reduce((s,r)=>(s[r.toLowerCase()]=!0,s),t)}bool(e){return this[e]==="YES"}decimalResolution(e){const t=Rc.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e,t){let i;const s={};for(Ua.lastIndex=0;(i=Ua.exec(e))!==null;){const n=i[1].trim();let o=i[2];const c=o.indexOf('"')===0&&o.lastIndexOf('"')===o.length-1;let u=!1;if(c)o=o.slice(1,-1);else switch(n){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":u=!0}if(t&&(c||u))o=Pr(t,o);else if(!u&&!c)switch(n){case"CLOSED-CAPTIONS":if(o==="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":Oe.warn(`${e}: attribute ${n} is missing quotes`)}s[n]=o}return s}}const Dc="com.apple.hls.interstitial";function Pc(a){return a!=="ID"&&a!=="CLASS"&&a!=="CUE"&&a!=="START-DATE"&&a!=="DURATION"&&a!=="END-DATE"&&a!=="END-ON-NEXT"}function _c(a){return a==="SCTE35-OUT"||a==="SCTE35-IN"||a==="SCTE35-CMD"}class $a{constructor(e,t,i=0){var s;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=t?.tagAnchor||null,this.tagOrder=(s=t?.tagOrder)!=null?s:i,t){const r=t.attr;for(const n in r)if(Object.prototype.hasOwnProperty.call(e,n)&&e[n]!==r[n]){Oe.warn(`DATERANGE tag attribute: "${n}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=n;break}e=Ne(new He({}),r,e)}if(this.attr=e,t?(this._startDate=t._startDate,this._cue=t._cue,this._endDate=t._endDate,this._dateAtEnd=t._dateAtEnd):this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){const r=t?.endDate||new Date(this.attr["END-DATE"]);se(r.getTime())&&(this._endDate=r)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get cue(){const e=this._cue;return e===void 0?this._cue=this.attr.enumeratedStringList(this.attr.CUE?"CUE":"X-CUE",{pre:!1,post:!1,once:!1}):e}get startTime(){const{tagAnchor:e}=this;return e===null||e.programDateTime===null?(Oe.warn(`Expected tagAnchor Fragment with PDT set for DateRange "${this.id}": ${e}`),NaN):e.start+(this.startDate.getTime()-e.programDateTime)/1e3}get startDate(){return this._startDate}get endDate(){const e=this._endDate||this._dateAtEnd;if(e)return e;const t=this.duration;return t!==null?this._dateAtEnd=new Date(this._startDate.getTime()+t*1e3):null}get duration(){if("DURATION"in this.attr){const e=this.attr.decimalFloatingPoint("DURATION");if(se(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isInterstitial(){return this.class===Dc}get isValid(){return!!this.id&&!this._badValueForSameId&&se(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)}}const wc=10;class kc{constructor(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.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=e}reloaded(e){if(!e){this.advanced=!0,this.updated=!0;return}const t=this.lastPartSn-e.lastPartSn,i=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!i||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||t===0&&i>0,this.updated||this.advanced?this.misses=Math.floor(e.misses*.6):this.misses=e.misses+1}hasKey(e){return this.encryptedFragments.some(t=>{let i=t.decryptdata;return i||(t.setKeyFormat(e.keyFormat),i=t.decryptdata),!!i&&e.matches(i)})}get hasProgramDateTime(){return this.fragments.length?se(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||wc}get drift(){const e=this.driftEndTime-this.driftStartTime;return e>0?(this.driftEnd-this.driftStart)*1e3/e:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){return this.fragments.length?this.fragments[this.fragments.length-1].end:0}get fragmentStart(){return this.fragments.length?this.fragments[0].start:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].index:-1}get maxPartIndex(){const e=this.partList;if(e){const t=this.lastPartIndex;if(t!==-1){for(let i=e.length;i--;)if(e[i].index>t)return e[i].index;return t}}return 0}get lastPartSn(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}get expired(){if(this.live&&this.age&&this.misses<3){const e=this.partEnd-this.fragmentStart;return this.age>Math.max(e,this.totalduration)+this.levelTargetDuration}return!1}}function Ga(a,e){return a.length===e.length?!a.some((t,i)=>t!==e[i]):!1}function Ha(a,e){return!a&&!e?!0:!a||!e?!1:Ga(a,e)}function ki(a){return a==="AES-128"||a==="AES-256"||a==="AES-256-CTR"}function _r(a){switch(a){case"AES-128":case"AES-256":return ni.cbc;case"AES-256-CTR":return ni.ctr;default:throw new Error(`invalid full segment method ${a}`)}}function wr(a){return Uint8Array.from(atob(a),e=>e.charCodeAt(0))}function kr(a){return Uint8Array.from(unescape(encodeURIComponent(a)),e=>e.charCodeAt(0))}function Mc(a){const e=kr(a).subarray(0,16),t=new Uint8Array(16);return t.set(e,16-e.length),t}function Oc(a){const e=function(i,s,r){const n=i[s];i[s]=i[r],i[r]=n};e(a,0,3),e(a,1,2),e(a,4,5),e(a,6,7)}function Fc(a){const e=a.split(":");let t=null;if(e[0]==="data"&&e.length===2){const i=e[1].split(";"),s=i[i.length-1].split(",");if(s.length===2){const r=s[0]==="base64",n=s[1];r?(i.splice(-1,1),t=wr(n)):t=Mc(n)}}return t}const Ps=typeof self<"u"?self:void 0;var Ve={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},ct={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function _s(a){switch(a){case ct.FAIRPLAY:return Ve.FAIRPLAY;case ct.PLAYREADY:return Ve.PLAYREADY;case ct.WIDEVINE:return Ve.WIDEVINE;case ct.CLEARKEY:return Ve.CLEARKEY}}function Mr(a){switch(a){case Ve.FAIRPLAY:return ct.FAIRPLAY;case Ve.PLAYREADY:return ct.PLAYREADY;case Ve.WIDEVINE:return ct.WIDEVINE;case Ve.CLEARKEY:return ct.CLEARKEY}}function Qi(a){const{drmSystems:e,widevineLicenseUrl:t}=a,i=e?[Ve.FAIRPLAY,Ve.WIDEVINE,Ve.PLAYREADY,Ve.CLEARKEY].filter(s=>!!e[s]):[];return!i[Ve.WIDEVINE]&&t&&i.push(Ve.WIDEVINE),i}const Va=(function(a){return Ps!=null&&(a=Ps.navigator)!=null&&a.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null})();function Nc(a,e,t,i){let s;switch(a){case Ve.FAIRPLAY:s=["cenc","sinf"];break;case Ve.WIDEVINE:case Ve.PLAYREADY:s=["cenc"];break;case Ve.CLEARKEY:s=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${a}`)}return Bc(s,e,t,i)}function Bc(a,e,t,i){return[{initDataTypes:a,persistentState:i.persistentState||"optional",distinctiveIdentifier:i.distinctiveIdentifier||"optional",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:e.map(r=>({contentType:`audio/mp4; codecs=${r}`,robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null})),videoCapabilities:t.map(r=>({contentType:`video/mp4; codecs=${r}`,robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}))}]}function Uc(a){var e;return!!a&&(a.sessionType==="persistent-license"||!!((e=a.sessionTypes)!=null&&e.some(t=>t==="persistent-license")))}function $c(a){const e=new Uint16Array(a.buffer,a.byteOffset,a.byteLength/2),t=String.fromCharCode.apply(null,Array.from(e)),i=t.substring(t.indexOf("<"),t.length),n=new DOMParser().parseFromString(i,"text/xml").getElementsByTagName("KID")[0];if(n){const o=n.childNodes[0]?n.childNodes[0].nodeValue:n.getAttribute("VALUE");if(o){const c=wr(o).subarray(0,16);return Oc(c),c}}return null}let ws={};class ks{static clearKeyUriToKeyIdMap(){ws={}}constructor(e,t,i,s=[1],r=null,n){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=e,this.uri=t,this.keyFormat=i,this.keyFormatVersions=s,this.iv=r,this.encrypted=e?e!=="NONE":!1,this.isCommonEncryption=this.encrypted&&!ki(e),n!=null&&n.startsWith("0x")&&(this.keyId=new Uint8Array(Qn(n)))}matches(e){return e.uri===this.uri&&e.method===this.method&&e.encrypted===this.encrypted&&e.keyFormat===this.keyFormat&&Ga(e.keyFormatVersions,this.keyFormatVersions)&&Ha(e.iv,this.iv)&&Ha(e.keyId,this.keyId)}isSupported(){if(this.method){if(ki(this.method)||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case ct.FAIRPLAY:case ct.WIDEVINE:case ct.PLAYREADY:case ct.CLEARKEY:return["SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1}getDecryptData(e){if(!this.encrypted||!this.uri)return null;if(ki(this.method)&&this.uri&&!this.iv){typeof e!="number"&&(Oe.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0);const i=Gc(e);return new ks(this.method,this.uri,"identity",this.keyFormatVersions,i)}if(this.pssh&&this.keyId)return this;const t=Fc(this.uri);if(t)switch(this.keyFormat){case ct.WIDEVINE:if(this.pssh=t,!this.keyId&&t.length>=22){const i=t.length-22;this.keyId=t.subarray(i,i+16)}break;case ct.PLAYREADY:{const i=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=Vu(i,null,t),this.keyId=$c(t);break}default:{let i=t.subarray(0,16);if(i.length!==16){const s=new Uint8Array(16);s.set(i,16-i.length),i=s}this.keyId=i;break}}if(!this.keyId||this.keyId.byteLength!==16){let i=ws[this.uri];if(!i){const s=Object.keys(ws).length%Number.MAX_SAFE_INTEGER;i=new Uint8Array(16),new DataView(i.buffer,12,4).setUint32(0,s),ws[this.uri]=i}this.keyId=i}return this}}function Gc(a){const e=new Uint8Array(16);for(let t=12;t<16;t++)e[t]=a>>8*(15-t)&255;return e}const Ka=/#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,Ya=/#EXT-X-MEDIA:(.*)/g,Hc=/^#EXT(?:INF|-X-TARGETDURATION):/m,Or=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),Vc=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("|"));class Nt{static findGroup(e,t){for(let i=0;i<e.length;i++){const s=e[i];if(s.id===t)return s}}static resolve(e,t){return pr.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return Hc.test(e)}static parseMasterPlaylist(e,t){const i=Na(e),s={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:i},r=[];Ka.lastIndex=0;let n;for(;(n=Ka.exec(e))!=null;)if(n[1]){var o;const u=new He(n[1],s),h=Pr(s,n[2]),f={attrs:u,bitrate:u.decimalInteger("BANDWIDTH")||u.decimalInteger("AVERAGE-BANDWIDTH"),name:u.NAME,url:Nt.resolve(h,t)},g=u.decimalResolution("RESOLUTION");g&&(f.width=g.width,f.height=g.height),qa(u.CODECS,f);const I=u["SUPPLEMENTAL-CODECS"];I&&(f.supplemental={},qa(I,f.supplemental)),(o=f.unknownCodecs)!=null&&o.length||r.push(f),s.levels.push(f)}else if(n[3]){const u=n[3],h=n[4];switch(u){case"SESSION-DATA":{const f=new He(h,s),g=f["DATA-ID"];g&&(s.sessionData===null&&(s.sessionData={}),s.sessionData[g]=f);break}case"SESSION-KEY":{const f=ja(h,t,s);f.encrypted&&f.isSupported()?(s.sessionKeys===null&&(s.sessionKeys=[]),s.sessionKeys.push(f)):Oe.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${h}"`);break}case"DEFINE":{{const f=new He(h,s);Ba(s,f,t)}break}case"CONTENT-STEERING":{const f=new He(h,s);s.contentSteering={uri:Nt.resolve(f["SERVER-URI"],t),pathwayId:f["PATHWAY-ID"]||"."};break}case"START":{s.startTimeOffset=za(h);break}}}const c=r.length>0&&r.length<s.levels.length;return s.levels=c?r:s.levels,s.levels.length===0&&(s.playlistParsingError=new Error("no levels found in manifest")),s}static parseMasterPlaylistMedia(e,t,i){let s;const r={},n=i.levels,o={AUDIO:n.map(u=>({id:u.attrs.AUDIO,audioCodec:u.audioCodec})),SUBTITLES:n.map(u=>({id:u.attrs.SUBTITLES,textCodec:u.textCodec})),"CLOSED-CAPTIONS":[]};let c=0;for(Ya.lastIndex=0;(s=Ya.exec(e))!==null;){const u=new He(s[1],i),h=u.TYPE;if(h){const f=o[h],g=r[h]||[];r[h]=g;const I=u.LANGUAGE,m=u["ASSOC-LANGUAGE"],E=u.CHANNELS,v=u.CHARACTERISTICS,x=u["INSTREAM-ID"],D={attrs:u,bitrate:0,id:c++,groupId:u["GROUP-ID"]||"",name:u.NAME||I||"",type:h,default:u.bool("DEFAULT"),autoselect:u.bool("AUTOSELECT"),forced:u.bool("FORCED"),lang:I,url:u.URI?Nt.resolve(u.URI,t):""};if(m&&(D.assocLang=m),E&&(D.channels=E),v&&(D.characteristics=v),x&&(D.instreamId=x),f!=null&&f.length){const L=Nt.findGroup(f,D.groupId)||f[0];Xa(D,L,"audioCodec"),Xa(D,L,"textCodec")}g.push(D)}}return r}static parseLevelPlaylist(e,t,i,s,r,n){var o;const c={url:t},u=new kc(t),h=u.fragments,f=[];let g=null,I=0,m=0,E=0,v=0,x=0,D=null,L=new mr(s,c),w,N,K,p=-1,$=!1,F=null,O;if(Or.lastIndex=0,u.m3u8=e,u.hasVariableRefs=Na(e),((o=Or.exec(e))==null?void 0:o[0])!=="#EXTM3U")return u.playlistParsingError=new Error("Missing format identifier #EXTM3U"),u;for(;(w=Or.exec(e))!==null;){$&&($=!1,L=new mr(s,c),L.playlistOffset=E,L.setStart(E),L.sn=I,L.cc=v,x&&(L.bitrate=x),L.level=i,g&&(L.initSegment=g,g.rawProgramDateTime&&(L.rawProgramDateTime=g.rawProgramDateTime,g.rawProgramDateTime=null),F&&(L.setByteRange(F),F=null)));const ce=w[1];if(ce){L.duration=parseFloat(ce);const ue=(" "+w[2]).slice(1);L.title=ue||null,L.tagList.push(ue?["INF",ce,ue]:["INF",ce])}else if(w[3]){if(se(L.duration)){L.playlistOffset=E,L.setStart(E),K&&Qa(L,K,u),L.sn=I,L.level=i,L.cc=v,h.push(L);const ue=(" "+w[3]).slice(1);L.relurl=Pr(u,ue),Fr(L,D,f),D=L,E+=L.duration,I++,m=0,$=!0}}else{if(w=w[0].match(Vc),!w){Oe.warn("No matches on slow regex match for level playlist!");continue}for(N=1;N<w.length&&w[N]===void 0;N++);const ue=(" "+w[N]).slice(1),Q=(" "+w[N+1]).slice(1),ne=w[N+2]?(" "+w[N+2]).slice(1):null;switch(ue){case"BYTERANGE":D?L.setByteRange(Q,D):L.setByteRange(Q);break;case"PROGRAM-DATE-TIME":L.rawProgramDateTime=Q,L.tagList.push(["PROGRAM-DATE-TIME",Q]),p===-1&&(p=h.length);break;case"PLAYLIST-TYPE":u.type&&qt(u,ue,w),u.type=Q.toUpperCase();break;case"MEDIA-SEQUENCE":u.startSN!==0?qt(u,ue,w):h.length>0&&Ja(u,ue,w),I=u.startSN=parseInt(Q);break;case"SKIP":{u.skippedSegments&&qt(u,ue,w);const re=new He(Q,u),le=re.decimalInteger("SKIPPED-SEGMENTS");if(se(le)){u.skippedSegments+=le;for(let J=le;J--;)h.push(null);I+=le}const pe=re.enumeratedString("RECENTLY-REMOVED-DATERANGES");pe&&(u.recentlyRemovedDateranges=(u.recentlyRemovedDateranges||[]).concat(pe.split(" ")));break}case"TARGETDURATION":u.targetduration!==0&&qt(u,ue,w),u.targetduration=Math.max(parseInt(Q),1);break;case"VERSION":u.version!==null&&qt(u,ue,w),u.version=parseInt(Q);break;case"INDEPENDENT-SEGMENTS":break;case"ENDLIST":u.live||qt(u,ue,w),u.live=!1;break;case"#":(Q||ne)&&L.tagList.push(ne?[Q,ne]:[Q]);break;case"DISCONTINUITY":v++,L.tagList.push(["DIS"]);break;case"GAP":L.gap=!0,L.tagList.push([ue]);break;case"BITRATE":L.tagList.push([ue,Q]),x=parseInt(Q)*1e3,se(x)?L.bitrate=x:x=0;break;case"DATERANGE":{const re=new He(Q,u),le=new $a(re,u.dateRanges[re.ID],u.dateRangeTagCount);u.dateRangeTagCount++,le.isValid||u.skippedSegments?u.dateRanges[le.id]=le:Oe.warn(`Ignoring invalid DATERANGE tag: "${Q}"`),L.tagList.push(["EXT-X-DATERANGE",Q]);break}case"DEFINE":{{const re=new He(Q,u);"IMPORT"in re?Lc(u,re,n):Ba(u,re,t)}break}case"DISCONTINUITY-SEQUENCE":u.startCC!==0?qt(u,ue,w):h.length>0&&Ja(u,ue,w),u.startCC=v=parseInt(Q);break;case"KEY":{const re=ja(Q,t,u);if(re.isSupported()){if(re.method==="NONE"){K=void 0;break}K||(K={});const le=K[re.keyFormat];le!=null&&le.matches(re)||(le&&(K=Ne({},K)),K[re.keyFormat]=re)}else Oe.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${Q}"`);break}case"START":u.startTimeOffset=za(Q);break;case"MAP":{const re=new He(Q,u);if(L.duration){const le=new mr(s,c);Za(le,re,i,K),g=le,L.initSegment=g,g.rawProgramDateTime&&!L.rawProgramDateTime&&(L.rawProgramDateTime=g.rawProgramDateTime)}else{const le=L.byteRangeEndOffset;if(le){const pe=L.byteRangeStartOffset;F=`${le-pe}@${pe}`}else F=null;Za(L,re,i,K),g=L,$=!0}g.cc=v;break}case"SERVER-CONTROL":{O&&qt(u,ue,w),O=new He(Q),u.canBlockReload=O.bool("CAN-BLOCK-RELOAD"),u.canSkipUntil=O.optionalFloat("CAN-SKIP-UNTIL",0),u.canSkipDateRanges=u.canSkipUntil>0&&O.bool("CAN-SKIP-DATERANGES"),u.partHoldBack=O.optionalFloat("PART-HOLD-BACK",0),u.holdBack=O.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{u.partTarget&&qt(u,ue,w);const re=new He(Q);u.partTarget=re.decimalFloatingPoint("PART-TARGET");break}case"PART":{let re=u.partList;re||(re=u.partList=[]);const le=m>0?re[re.length-1]:void 0,pe=m++,J=new He(Q,u),ee=new Pu(J,L,c,pe,le);re.push(ee),L.duration+=ee.duration;break}case"PRELOAD-HINT":{const re=new He(Q,u);u.preloadHint=re;break}case"RENDITION-REPORT":{const re=new He(Q,u);u.renditionReports=u.renditionReports||[],u.renditionReports.push(re);break}default:Oe.warn(`line parsed but not handled: ${w}`);break}}}D&&!D.relurl?(h.pop(),E-=D.duration,u.partList&&(u.fragmentHint=D)):u.partList&&(Fr(L,D,f),L.cc=v,u.fragmentHint=L,K&&Qa(L,K,u)),u.targetduration||(u.playlistParsingError=new Error("#EXT-X-TARGETDURATION is required"));const W=h.length,ie=h[0],X=h[W-1];if(E+=u.skippedSegments*u.targetduration,E>0&&W&&X){u.averagetargetduration=E/W;const ce=X.sn;u.endSN=ce!=="initSegment"?ce:0,u.live||(X.endList=!0),p>0&&(Yc(h,p),ie&&f.unshift(ie))}return u.fragmentHint&&(E+=u.fragmentHint.duration),u.totalduration=E,f.length&&u.dateRangeTagCount&&ie&&Wa(f,u),u.endCC=v,u}}function Wa(a,e){let t=a.length;if(!t)if(e.hasProgramDateTime){const o=e.fragments[e.fragments.length-1];a.push(o),t++}else return;const i=a[t-1],s=e.live?1/0:e.totalduration,r=Object.keys(e.dateRanges);for(let o=r.length;o--;){const c=e.dateRanges[r[o]],u=c.startDate.getTime();c.tagAnchor=i.ref;for(let h=t;h--;){var n;if(((n=a[h])==null?void 0:n.sn)<e.startSN)break;const f=Kc(e,u,a,h,s);if(f!==-1){c.tagAnchor=e.fragments[f].ref;break}}}}function Kc(a,e,t,i,s){const r=t[i];if(r){const o=r.programDateTime;if(e>=o||i===0){var n;const c=(((n=t[i+1])==null?void 0:n.start)||s)-r.start;if(e<=o+c*1e3){const u=t[i].sn-a.startSN;if(u<0)return-1;const h=a.fragments;if(h.length>t.length){const g=(t[i+1]||h[h.length-1]).sn-a.startSN;for(let I=g;I>u;I--){const m=h[I].programDateTime;if(e>=m&&e<m+h[I].duration*1e3)return I}}return u}}}return-1}function ja(a,e,t){var i,s;const r=new He(a,t),n=(i=r.METHOD)!=null?i:"",o=r.URI,c=r.hexadecimalInteger("IV"),u=r.KEYFORMATVERSIONS,h=(s=r.KEYFORMAT)!=null?s:"identity";o&&r.IV&&!c&&Oe.error(`Invalid IV: ${r.IV}`);const f=o?Nt.resolve(o,e):"",g=(u||"1").split("/").map(Number).filter(Number.isFinite);return new ks(n,f,h,g,c,r.KEYID)}function za(a){const t=new He(a).decimalFloatingPoint("TIME-OFFSET");return se(t)?t:null}function qa(a,e){let t=(a||"").split(/[ ,]+/).filter(i=>i);["video","audio","text"].forEach(i=>{const s=t.filter(r=>yr(r,i));s.length&&(e[`${i}Codec`]=s.map(r=>r.split("/")[0]).join(","),t=t.filter(r=>s.indexOf(r)===-1))}),e.unknownCodecs=t}function Xa(a,e,t){const i=e[t];i&&(a[t]=i)}function Yc(a,e){let t=a[e];for(let i=e;i--;){const s=a[i];if(!s)return;s.programDateTime=t.programDateTime-s.duration*1e3,t=s}}function Fr(a,e,t){a.rawProgramDateTime?t.push(a):e!=null&&e.programDateTime&&(a.programDateTime=e.endProgramDateTime)}function Za(a,e,t,i){a.relurl=e.URI,e.BYTERANGE&&a.setByteRange(e.BYTERANGE),a.level=t,a.sn="initSegment",i&&(a.levelkeys=i),a.initSegment=null}function Qa(a,e,t){a.levelkeys=e;const{encryptedFragments:i}=t;(!i.length||i[i.length-1].levelkeys!==e)&&Object.keys(e).some(s=>e[s].isCommonEncryption)&&i.push(a)}function qt(a,e,t){a.playlistParsingError=new Error(`#EXT-X-${e} must not appear more than once (${t[0]})`)}function Ja(a,e,t){a.playlistParsingError=new Error(`#EXT-X-${e} must appear before the first Media Segment (${t[0]})`)}function Nr(a,e){const t=e.startPTS;if(se(t)){let i=0,s;e.sn>a.sn?(i=t-a.start,s=a):(i=a.start-t,s=e),s.duration!==i&&s.setDuration(i)}else e.sn>a.sn?a.cc===e.cc&&a.minEndPTS?e.setStart(a.start+(a.minEndPTS-a.start)):e.setStart(a.start+a.duration):e.setStart(Math.max(a.start-e.duration,0))}function eo(a,e,t,i,s,r,n){i-t<=0&&(n.warn("Fragment should have a positive duration",e),i=t+e.duration,r=s+e.duration);let c=t,u=i;const h=e.startPTS,f=e.endPTS;if(se(h)){const x=Math.abs(h-t);a&&x>a.totalduration?n.warn(`media timestamps and playlist times differ by ${x}s for level ${e.level} ${a.url}`):se(e.deltaPTS)?e.deltaPTS=Math.max(x,e.deltaPTS):e.deltaPTS=x,c=Math.max(t,h),t=Math.min(t,h),s=e.startDTS!==void 0?Math.min(s,e.startDTS):s,u=Math.min(i,f),i=Math.max(i,f),r=e.endDTS!==void 0?Math.max(r,e.endDTS):r}const g=t-e.start;e.start!==0&&e.setStart(t),e.setDuration(i-e.start),e.startPTS=t,e.maxStartPTS=c,e.startDTS=s,e.endPTS=i,e.minEndPTS=u,e.endDTS=r;const I=e.sn;if(!a||I<a.startSN||I>a.endSN)return 0;let m;const E=I-a.startSN,v=a.fragments;for(v[E]=e,m=E;m>0;m--)Nr(v[m],v[m-1]);for(m=E;m<v.length-1;m++)Nr(v[m],v[m+1]);return a.fragmentHint&&Nr(v[v.length-1],a.fragmentHint),a.PTSKnown=a.alignedSliding=!0,g}function Wc(a,e,t){if(a===e)return;let i=null;const s=a.fragments;for(let h=s.length-1;h>=0;h--){const f=s[h].initSegment;if(f){i=f;break}}a.fragmentHint&&delete a.fragmentHint.endPTS;let r;qc(a,e,(h,f,g,I)=>{if((!e.startCC||e.skippedSegments)&&f.cc!==h.cc){const m=h.cc-f.cc;for(let E=g;E<I.length;E++)I[E].cc+=m;e.endCC=I[I.length-1].cc}se(h.startPTS)&&se(h.endPTS)&&(f.setStart(f.startPTS=h.startPTS),f.startDTS=h.startDTS,f.maxStartPTS=h.maxStartPTS,f.endPTS=h.endPTS,f.endDTS=h.endDTS,f.minEndPTS=h.minEndPTS,f.setDuration(h.endPTS-h.startPTS),f.duration&&(r=f),e.PTSKnown=e.alignedSliding=!0),h.hasStreams&&(f.elementaryStreams=h.elementaryStreams),f.loader=h.loader,h.hasStats&&(f.stats=h.stats),h.initSegment&&(f.initSegment=h.initSegment,i=h.initSegment)});const n=e.fragments,o=e.fragmentHint?n.concat(e.fragmentHint):n;if(i&&o.forEach(h=>{var f;h&&(!h.initSegment||h.initSegment.relurl===((f=i)==null?void 0:f.relurl))&&(h.initSegment=i)}),e.skippedSegments){if(e.deltaUpdateFailed=n.some(h=>!h),e.deltaUpdateFailed){t.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let h=e.skippedSegments;h--;)n.shift();e.startSN=n[0].sn}else{e.canSkipDateRanges&&(e.dateRanges=jc(a.dateRanges,e,t));const h=a.fragments.filter(f=>f.rawProgramDateTime);if(a.hasProgramDateTime&&!e.hasProgramDateTime)for(let f=1;f<o.length;f++)o[f].programDateTime===null&&Fr(o[f],o[f-1],h);Wa(h,e)}e.endCC=n[n.length-1].cc}if(!e.startCC){var c;const h=ro(a,e.startSN-1);e.startCC=(c=h?.cc)!=null?c:n[0].cc}zc(a.partList,e.partList,(h,f)=>{f.elementaryStreams=h.elementaryStreams,f.stats=h.stats}),r?eo(e,r,r.startPTS,r.endPTS,r.startDTS,r.endDTS,t):io(a,e),n.length&&(e.totalduration=e.edge-n[0].start),e.driftStartTime=a.driftStartTime,e.driftStart=a.driftStart;const u=e.advancedDateTime;if(e.advanced&&u){const h=e.edge;e.driftStart||(e.driftStartTime=u,e.driftStart=h),e.driftEndTime=u,e.driftEnd=h}else e.driftEndTime=a.driftEndTime,e.driftEnd=a.driftEnd,e.advancedDateTime=a.advancedDateTime;e.requestScheduled===-1&&(e.requestScheduled=a.requestScheduled)}function jc(a,e,t){const{dateRanges:i,recentlyRemovedDateranges:s}=e,r=Ne({},a);s&&s.forEach(c=>{delete r[c]});const o=Object.keys(r).length;return o?(Object.keys(i).forEach(c=>{const u=r[c],h=new $a(i[c].attr,u);h.isValid?(r[c]=h,u||(h.tagOrder+=o)):t.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${Ge(i[c].attr)}"`)}),r):i}function zc(a,e,t){if(a&&e){let i=0;for(let s=0,r=a.length;s<=r;s++){const n=a[s],o=e[s+i];n&&o&&n.index===o.index&&n.fragment.sn===o.fragment.sn?t(n,o):i--}}}function qc(a,e,t){const i=e.skippedSegments,s=Math.max(a.startSN,e.startSN)-e.startSN,r=(a.fragmentHint?1:0)+(i?e.endSN:Math.min(a.endSN,e.endSN))-e.startSN,n=e.startSN-a.startSN,o=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,c=a.fragmentHint?a.fragments.concat(a.fragmentHint):a.fragments;for(let u=s;u<=r;u++){const h=c[n+u];let f=o[u];if(i&&!f&&h&&(f=e.fragments[u]=h),h&&f){t(h,f,u,o);const g=h.relurl,I=f.relurl;if(g&&Xc(g,I)){e.playlistParsingError=to(`media sequence mismatch ${f.sn}:`,a,e,h,f);return}else if(h.cc!==f.cc){e.playlistParsingError=to(`discontinuity sequence mismatch (${h.cc}!=${f.cc})`,a,e,h,f);return}}}}function to(a,e,t,i,s){return new Error(`${a} ${s.url}
12
- Playlist starting @${e.startSN}
13
- ${e.m3u8}
14
-
15
- Playlist starting @${t.startSN}
16
- ${t.m3u8}`)}function io(a,e,t=!0){const i=e.startSN+e.skippedSegments-a.startSN,s=a.fragments,r=i>=0;let n=0;if(r&&i<s.length)n=s[i].start;else if(r&&e.startSN===a.endSN+1)n=a.fragmentEnd;else if(r&&t)n=a.fragmentStart+i*e.levelTargetDuration;else if(!e.skippedSegments&&e.fragmentStart===0)n=a.fragmentStart;else return;Br(e,n)}function Br(a,e){if(e){const t=a.fragments;for(let i=a.skippedSegments;i<t.length;i++)t[i].addStart(e);a.fragmentHint&&a.fragmentHint.addStart(e)}}function so(a,e=1/0){let t=1e3*a.targetduration;if(a.updated){const i=a.fragments;if(i.length&&t*4>e){const r=i[i.length-1].duration*1e3;r<t&&(t=r)}}else t/=2;return Math.round(t)}function ro(a,e,t){if(!a)return null;let i=a.fragments[e-a.startSN];return i||(i=a.fragmentHint,i&&i.sn===e)?i:e<a.startSN&&t&&t.sn===e?t:null}function no(a,e,t){return a?ao(a.partList,e,t):null}function ao(a,e,t){if(a)for(let i=a.length;i--;){const s=a[i];if(s.index===t&&s.fragment.sn===e)return s}return null}function oo(a){a.forEach((e,t)=>{var i;(i=e.details)==null||i.fragments.forEach(s=>{s.level=t,s.initSegment&&(s.initSegment.level=t)})})}function Xc(a,e){return a!==e&&e?lo(a)!==lo(e):!1}function lo(a){return a.replace(/\?[^?]*$/,"")}function Ji(a,e){for(let i=0,s=a.length;i<s;i++){var t;if(((t=a[i])==null?void 0:t.cc)===e)return a[i]}return null}function Zc(a,e){return!!(a&&e.startCC<a.endCC&&e.endCC>a.startCC)}function uo(a,e){const t=a.start+e;a.startPTS=t,a.setStart(t),a.endPTS=t+a.duration}function co(a,e){const t=e.fragments;for(let i=0,s=t.length;i<s;i++)uo(t[i],a);e.fragmentHint&&uo(e.fragmentHint,a),e.alignedSliding=!0}function Qc(a,e){a&&(ho(e,a),e.alignedSliding||Ms(e,a),!e.alignedSliding&&!e.skippedSegments&&io(a,e,!1))}function ho(a,e){if(!Zc(e,a))return;const t=Math.min(e.endCC,a.endCC),i=Ji(e.fragments,t),s=Ji(a.fragments,t);if(!i||!s)return;Oe.log(`Aligning playlist at start of dicontinuity sequence ${t}`);const r=i.start-s.start;co(r,a)}function Ms(a,e){if(!a.hasProgramDateTime||!e.hasProgramDateTime)return;const t=a.fragments,i=e.fragments;if(!t.length||!i.length)return;let s,r;const n=Math.min(e.endCC,a.endCC);e.startCC<n&&a.startCC<n&&(s=Ji(i,n),r=Ji(t,n)),(!s||!r)&&(s=i[Math.floor(i.length/2)],r=Ji(t,s.cc)||t[Math.floor(t.length/2)]);const o=s.programDateTime,c=r.programDateTime;if(!o||!c)return;const u=(c-o)/1e3-(r.start-s.start);co(u,a)}function ot(a,e,t){ht(a,e,t),a.addEventListener(e,t)}function ht(a,e,t){a.removeEventListener(e,t)}const Jc={toString:function(a){let e="";const t=a.length;for(let i=0;i<t;i++)e+=`[${a.start(i).toFixed(3)}-${a.end(i).toFixed(3)}]`;return e}},j={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"};class Ur extends Ma{constructor(e,t,i,s,r){super(s,e.logger),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=j.STOPPED,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.buffering=!0,this.loadingParts=!1,this.loopSn=void 0,this.onMediaSeeking=()=>{const{config:n,fragCurrent:o,media:c,mediaBuffer:u,state:h}=this,f=c?c.currentTime:0,g=ye.bufferInfo(u||c,f,n.maxBufferHole),I=!g.len;if(this.log(`Media seeking to ${se(f)?f.toFixed(3):f}, state: ${h}, ${I?"out of":"in"} buffer`),this.state===j.ENDED)this.resetLoadingState();else if(o){const m=n.maxFragLookUpTolerance,E=o.start-m,v=o.start+o.duration+m;if(I||v<g.start||E>g.end){const x=f>v;(f<E||x)&&(x&&o.loader&&(this.log(`Cancelling fragment load for seek (sn: ${o.sn})`),o.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}if(c){this.fragmentTracker.removeFragmentsInRange(f,1/0,this.playlistType,!0);const m=this.lastCurrentTime;if(f>m&&(this.lastCurrentTime=f),!this.loadingParts){const E=Math.max(g.end,f),v=this.shouldLoadParts(this.getLevelDetails(),E);v&&(this.log(`LL-Part loading ON after seeking to ${f.toFixed(2)} with buffer @${E.toFixed(2)}`),this.loadingParts=v)}}this.hls.hasEnoughToStart||(this.log(`Setting ${I?"startPosition":"nextLoadPosition"} to ${f} for seek without enough to start`),this.nextLoadPosition=f,I&&(this.startPosition=f)),I&&this.state===j.IDLE&&this.tickImmediate()},this.onMediaEnded=()=>{this.log("setting startPosition to 0 because media ended"),this.startPosition=this.lastCurrentTime=0},this.playlistType=r,this.hls=e,this.fragmentLoader=new xc(e.config),this.keyLoader=i,this.fragmentTracker=t,this.config=e.config,this.decrypter=new Rr(e.config)}registerListeners(){const{hls:e}=this;e.on(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(y.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(y.ERROR,this.onError,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){if(this.state===j.STOPPED)return;this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);const e=this.fragCurrent;e!=null&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=j.STOPPED}get startPositionValue(){const{nextLoadPosition:e,startPosition:t}=this;return t===-1&&e?e:t}get bufferingEnabled(){return this.buffering}pauseBuffering(){this.buffering=!1}resumeBuffering(){this.buffering=!0}get inFlightFrag(){return{frag:this.fragCurrent,state:this.state}}_streamEnded(e,t){if(t.live||!this.media)return!1;const i=e.end||0,s=this.config.timelineOffset||0;if(i<=s)return!1;const r=e.buffered;this.config.maxBufferHole&&r&&r.length>1&&(e=ye.bufferedInfo(r,e.start,0));const n=e.nextStart;if(n&&n>s&&n<t.edge||this.media.currentTime<e.start)return!1;const c=t.partList;if(c!=null&&c.length){const h=c[c.length-1];return ye.isBuffered(this.media,h.start+h.duration/2)}const u=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(u)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null)return this.levelLastLoaded.details}get timelineOffset(){const e=this.config.timelineOffset;if(e){var t;return((t=this.getLevelDetails())==null?void 0:t.appliedTimelineOffset)||e}return 0}onMediaAttached(e,t){const i=this.media=this.mediaBuffer=t.media;ot(i,"seeking",this.onMediaSeeking),ot(i,"ended",this.onMediaEnded);const s=this.config;this.levels&&s.autoStartLoad&&this.state===j.STOPPED&&this.startLoad(s.startPosition)}onMediaDetaching(e,t){const i=!!t.transferMedia,s=this.media;if(s!==null){if(s.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),ht(s,"seeking",this.onMediaSeeking),ht(s,"ended",this.onMediaEnded),this.keyLoader&&!i&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loopSn=void 0,i){this.resetLoadingState(),this.resetTransmuxer();return}this.loadingParts=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}}onManifestLoading(){this.initPTS=[],this.levels=this.levelLastLoaded=this.fragCurrent=null,this.lastCurrentTime=this.startPosition=0,this.startFragRequested=!1}onError(e,t){}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset}onHandlerDestroying(){this.stopLoad(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),super.onHandlerDestroying(),this.hls=this.onMediaSeeking=this.onMediaEnded=null}onHandlerDestroyed(){this.state=j.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,super.onHandlerDestroyed()}loadFragment(e,t,i){this.startFragRequested=!0,this._loadFragForPlayback(e,t,i)}_loadFragForPlayback(e,t,i){const s=r=>{const n=r.frag;if(this.fragContextChanged(n)){this.warn(`${n.type} sn: ${n.sn}${r.part?" part: "+r.part.index:""} of ${this.fragInfo(n,!1,r.part)}) was dropped during download.`),this.fragmentTracker.removeFragment(n);return}n.stats.chunkCount++,this._handleFragmentLoadProgress(r)};this._doFragLoad(e,t,i,s).then(r=>{if(!r)return;const n=this.state,o=r.frag;if(this.fragContextChanged(o)){(n===j.FRAG_LOADING||!this.fragCurrent&&n===j.PARSING)&&(this.fragmentTracker.removeFragment(o),this.state=j.IDLE);return}"payload"in r&&(this.log(`Loaded ${o.type} sn: ${o.sn} of ${this.playlistLabel()} ${o.level}`),this.hls.trigger(y.FRAG_LOADED,r)),this._handleFragmentLoadComplete(r)}).catch(r=>{this.state===j.STOPPED||this.state===j.ERROR||(this.warn(`Frag error: ${r?.message||r}`),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;const{fragmentTracker:i}=this;if(i.getState(e)===Qe.APPENDING){const r=e.type,n=this.getFwdBufferInfo(this.mediaBuffer,r),o=Math.max(e.duration,n?n.len:this.config.maxBufferLength),c=this.backtrackFragment;((c?e.sn-c.sn:0)===1||this.reduceMaxBufferLength(o,e.duration))&&i.removeFragment(e)}else((t=this.mediaBuffer)==null?void 0:t.buffered.length)===0?i.removeAllFragments():i.hasParts(e.type)&&(i.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),i.getState(e)===Qe.PARTIAL&&i.removeFragment(e))}checkLiveUpdate(e){if(e.updated&&!e.live){const t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)}waitForLive(e){const t=e.details;return t?.live&&t.type!=="EVENT"&&(this.levelLastLoaded!==e||t.expired)}flushMainBuffer(e,t,i=null){if(!(e-t))return;const s={startOffset:e,endOffset:t,type:i};this.hls.trigger(y.BUFFER_FLUSHING,s)}_loadInitSegment(e,t){this._doFragLoad(e,t).then(i=>{const s=i?.frag;if(!s||this.fragContextChanged(s)||!this.levels)throw new Error("init load aborted");return i}).then(i=>{const{hls:s}=this,{frag:r,payload:n}=i,o=r.decryptdata;if(n&&n.byteLength>0&&o!=null&&o.key&&o.iv&&ki(o.method)){const c=self.performance.now();return this.decrypter.decrypt(new Uint8Array(n),o.key.buffer,o.iv.buffer,_r(o.method)).catch(u=>{throw s.trigger(y.ERROR,{type:de.MEDIA_ERROR,details:U.FRAG_DECRYPT_ERROR,fatal:!1,error:u,reason:u.message,frag:r}),u}).then(u=>{const h=self.performance.now();return s.trigger(y.FRAG_DECRYPTED,{frag:r,payload:u,stats:{tstart:c,tdecrypt:h}}),i.payload=u,this.completeInitSegmentLoad(i)})}return this.completeInitSegmentLoad(i)}).catch(i=>{this.state===j.STOPPED||this.state===j.ERROR||(this.warn(i),this.resetFragmentLoading(e))})}completeInitSegmentLoad(e){const{levels:t}=this;if(!t)throw new Error("init load aborted, missing levels");const i=e.frag.stats;this.state!==j.STOPPED&&(this.state=j.IDLE),e.frag.data=new Uint8Array(e.payload),i.parsing.start=i.buffering.start=self.performance.now(),i.parsing.end=i.buffering.end=self.performance.now(),this.tick()}unhandledEncryptionError(e,t){var i,s;const r=e.tracks;if(r&&!t.encrypted&&((i=r.audio)!=null&&i.encrypted||(s=r.video)!=null&&s.encrypted)&&(!this.config.emeEnabled||!this.keyLoader.emeController)){const n=this.media,o=new Error(`Encrypted track with no key in ${this.fragInfo(t)} (media ${n?"attached mediaKeys: "+n.mediaKeys:"detached"})`);return this.warn(o.message),!n||n.mediaKeys?!1:(this.hls.trigger(y.ERROR,{type:de.KEY_SYSTEM_ERROR,details:U.KEY_SYSTEM_NO_KEYS,fatal:!1,error:o,frag:t}),this.resetTransmuxer(),!0)}return!1}fragContextChanged(e){const{fragCurrent:t}=this;return!e||!t||e.sn!==t.sn||e.level!==t.level}fragBufferedComplete(e,t){const i=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)} > buffer:${i?Jc.toString(ye.getBuffered(i)):"(detached)"})`),qe(e)){var s;if(e.type!==he.SUBTITLE){const n=e.elementaryStreams;if(!Object.keys(n).some(o=>!!n[o])){this.state=j.IDLE;return}}const r=(s=this.levels)==null?void 0:s[e.level];r!=null&&r.fragmentError&&(this.log(`Resetting level fragment error count of ${r.fragmentError} on frag buffered`),r.fragmentError=0)}this.state=j.IDLE}_handleFragmentLoadComplete(e){const{transmuxer:t}=this;if(!t)return;const{frag:i,part:s,partsLoaded:r}=e,n=!r||r.length===0||r.some(c=>!c),o=new Dr(i.level,i.sn,i.stats.chunkCount+1,0,s?s.index:-1,!n);t.flush(o)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,i=null,s){var r;this.fragCurrent=e;const n=t.details;if(!this.levels||!n)throw new Error(`frag load aborted, missing level${n?"":" detail"}s`);let o=null;if(e.encrypted&&!((r=e.decryptdata)!=null&&r.key)){if(this.log(`Loading key for ${e.sn} of [${n.startSN}-${n.endSN}], ${this.playlistLabel()} ${e.level}`),this.state=j.KEY_LOADING,this.fragCurrent=e,o=this.keyLoader.load(e).then(g=>{if(!this.fragContextChanged(g.frag))return this.hls.trigger(y.KEY_LOADED,g),this.state===j.KEY_LOADING&&(this.state=j.IDLE),g}),this.hls.trigger(y.KEY_LOADING,{frag:e}),this.fragCurrent===null)return this.log("context changed in KEY_LOADING"),Promise.resolve(null)}else e.encrypted||(o=this.keyLoader.loadClear(e,n.encryptedFragments,this.startFragRequested),o&&this.log("[eme] blocking frag load until media-keys acquired"));const c=this.fragPrevious;if(qe(e)&&(!c||e.sn!==c.sn)){const g=this.shouldLoadParts(t.details,e.end);g!==this.loadingParts&&(this.log(`LL-Part loading ${g?"ON":"OFF"} loading sn ${c?.sn}->${e.sn}`),this.loadingParts=g)}if(i=Math.max(e.start,i||0),this.loadingParts&&qe(e)){const g=n.partList;if(g&&s){i>n.fragmentEnd&&n.fragmentHint&&(e=n.fragmentHint);const I=this.getNextPart(g,e,i);if(I>-1){const m=g[I];e=this.fragCurrent=m.fragment,this.log(`Loading ${e.type} sn: ${e.sn} part: ${m.index} (${I}/${g.length-1}) of ${this.fragInfo(e,!1,m)}) cc: ${e.cc} [${n.startSN}-${n.endSN}], target: ${parseFloat(i.toFixed(3))}`),this.nextLoadPosition=m.start+m.duration,this.state=j.FRAG_LOADING;let E;return o?E=o.then(v=>!v||this.fragContextChanged(v.frag)?null:this.doFragPartsLoad(e,m,t,s)).catch(v=>this.handleFragLoadError(v)):E=this.doFragPartsLoad(e,m,t,s).catch(v=>this.handleFragLoadError(v)),this.hls.trigger(y.FRAG_LOADING,{frag:e,part:m,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):E}else if(!e.url||this.loadedEndOfParts(g,i))return Promise.resolve(null)}}if(qe(e)&&this.loadingParts){var u;this.log(`LL-Part loading OFF after next part miss @${i.toFixed(2)} Check buffer at sn: ${e.sn} loaded parts: ${(u=n.partList)==null?void 0:u.filter(g=>g.loaded).map(g=>`[${g.start}-${g.end}]`)}`),this.loadingParts=!1}else if(!e.url)return Promise.resolve(null);this.log(`Loading ${e.type} sn: ${e.sn} of ${this.fragInfo(e,!1)}) cc: ${e.cc} ${"["+n.startSN+"-"+n.endSN+"]"}, target: ${parseFloat(i.toFixed(3))}`),se(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=j.FRAG_LOADING;const h=this.config.progressive;let f;return h&&o?f=o.then(g=>!g||this.fragContextChanged(g.frag)?null:this.fragmentLoader.load(e,s)).catch(g=>this.handleFragLoadError(g)):f=Promise.all([this.fragmentLoader.load(e,h?s:void 0),o]).then(([g])=>(!h&&s&&s(g),g)).catch(g=>this.handleFragLoadError(g)),this.hls.trigger(y.FRAG_LOADING,{frag:e,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):f}doFragPartsLoad(e,t,i,s){return new Promise((r,n)=>{var o;const c=[],u=(o=i.details)==null?void 0:o.partList,h=f=>{this.fragmentLoader.loadPart(e,f,s).then(g=>{c[f.index]=g;const I=g.part;this.hls.trigger(y.FRAG_LOADED,g);const m=no(i.details,e.sn,f.index+1)||ao(u,e.sn,f.index+1);if(m)h(m);else return r({frag:e,part:I,partsLoaded:c})}).catch(n)};h(t)})}handleFragLoadError(e){if("data"in e){const t=e.data;t.frag&&t.details===U.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):t.frag&&t.type===de.KEY_SYSTEM_ERROR?(t.frag.abortRequests(),this.resetFragmentLoading(t.frag)):this.hls.trigger(y.ERROR,t)}else this.hls.trigger(y.ERROR,{type:de.OTHER_ERROR,details:U.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){const t=this.getCurrentContext(e);if(!t||this.state!==j.PARSING){!this.fragCurrent&&this.state!==j.STOPPED&&this.state!==j.ERROR&&(this.state=j.IDLE);return}const{frag:i,part:s,level:r}=t,n=self.performance.now();i.stats.parsing.end=n,s&&(s.stats.parsing.end=n);const o=this.getLevelDetails(),u=o&&i.sn>o.endSN||this.shouldLoadParts(o,i.end);u!==this.loadingParts&&(this.log(`LL-Part loading ${u?"ON":"OFF"} after parsing segment ending @${i.end.toFixed(2)}`),this.loadingParts=u),this.updateLevelTiming(i,s,r,e.partial)}shouldLoadParts(e,t){if(this.config.lowLatencyMode){if(!e)return this.loadingParts;if(e.partList){var i;const r=e.partList[0];if(r.fragment.type===he.SUBTITLE)return!1;const n=r.end+(((i=e.fragmentHint)==null?void 0:i.duration)||0);if(t>=n){var s;if((this.hls.hasEnoughToStart?((s=this.media)==null?void 0:s.currentTime)||this.lastCurrentTime:this.getLoadPosition())>r.start-r.fragment.duration)return!0}}}return!1}getCurrentContext(e){const{levels:t,fragCurrent:i}=this,{level:s,sn:r,part:n}=e;if(!(t!=null&&t[s]))return this.warn(`Levels object was unset while buffering fragment ${r} of ${this.playlistLabel()} ${s}. The current chunk will not be buffered.`),null;const o=t[s],c=o.details,u=n>-1?no(c,r,n):null,h=u?u.fragment:ro(c,r,i);return h?(i&&i!==h&&(h.stats=i.stats),{frag:h,part:u,level:o}):null}bufferFragmentData(e,t,i,s,r){if(this.state!==j.PARSING)return;const{data1:n,data2:o}=e;let c=n;if(o&&(c=St(n,o)),!c.length)return;const u=this.initPTS[t.cc],h=u?-u.baseTime/u.timescale:void 0,f={type:e.type,frag:t,part:i,chunkMeta:s,offset:h,parent:t.type,data:c};if(this.hls.trigger(y.BUFFER_APPENDING,f),e.dropped&&e.independent&&!i){if(r)return;this.flushBufferGap(t)}}flushBufferGap(e){const t=this.media;if(!t)return;if(!ye.isBuffered(t,t.currentTime)){this.flushMainBuffer(0,e.start);return}const i=t.currentTime,s=ye.bufferInfo(t,i,0),r=e.duration,n=Math.min(this.config.maxFragLookUpTolerance*2,r*.25),o=Math.max(Math.min(e.start-n,s.end-n),i+n);e.start-o>n&&this.flushMainBuffer(o,e.start)}getFwdBufferInfo(e,t){var i;const s=this.getLoadPosition();if(!se(s))return null;const n=this.lastCurrentTime>s||(i=this.media)!=null&&i.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(e,s,t,n)}getFwdBufferInfoAtPos(e,t,i,s){const r=ye.bufferInfo(e,t,s);if(r.len===0&&r.nextStart!==void 0){const n=this.fragmentTracker.getBufferedFrag(t,i);if(n&&(r.nextStart<=n.end||n.gap)){const o=Math.max(Math.min(r.nextStart,n.end)-t,s);return ye.bufferInfo(e,t,o)}}return r}getMaxBufferLength(e){const{config:t}=this;let i;return e?i=Math.max(8*t.maxBufferSize/e,t.maxBufferLength):i=t.maxBufferLength,Math.min(i,t.maxMaxBufferLength)}reduceMaxBufferLength(e,t){const i=this.config,s=Math.max(Math.min(e-t,i.maxBufferLength),t),r=Math.max(e-t*3,i.maxMaxBufferLength/2,s);return r>=s?(i.maxMaxBufferLength=r,this.warn(`Reduce max buffer length to ${r}s`),!0):!1}getAppendedFrag(e,t=he.MAIN){const i=this.fragmentTracker?this.fragmentTracker.getAppendedFrag(e,t):null;return i&&"fragment"in i?i.fragment:i}getNextFragment(e,t){const i=t.fragments,s=i.length;if(!s)return null;const{config:r}=this,n=i[0].start,o=r.lowLatencyMode&&!!t.partList;let c=null;if(t.live){const f=r.initialLiveManifestSize;if(s<f)return this.warn(`Not enough fragments to start playback (have: ${s}, need: ${f})`),null;if(!t.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||e<n){var u;o&&!this.loadingParts&&(this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0),c=this.getInitialLiveFragment(t);const g=this.hls.startPosition,I=this.hls.liveSyncPosition,m=c?(g!==-1&&g>=n?g:I)||c.start:e;this.log(`Setting startPosition to ${m} to match start frag at live edge. mainStart: ${g} liveSyncPosition: ${I} frag.start: ${(u=c)==null?void 0:u.start}`),this.startPosition=this.nextLoadPosition=m}}else e<=n&&(c=i[0]);if(!c){const f=this.loadingParts?t.partEnd:t.fragmentEnd;c=this.getFragmentAtPosition(e,f,t)}let h=this.filterReplacedPrimary(c,t);if(!h&&c){const f=c.sn-t.startSN;h=this.filterReplacedPrimary(i[f+1]||null,t)}return this.mapToInitFragWhenRequired(h)}isLoopLoading(e,t){const i=this.fragmentTracker.getState(e);return(i===Qe.OK||i===Qe.PARTIAL&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,i,s,r){let n=null;if(e.gap&&(n=this.getNextFragment(this.nextLoadPosition,t),n&&!n.gap&&i.nextStart)){const o=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,s,0);if(o!==null&&i.len+o.len>=r){const c=n.sn;return this.loopSn!==c&&(this.log(`buffer full after gaps in "${s}" playlist starting at sn: ${c}`),this.loopSn=c),null}}return this.loopSn=void 0,n}get primaryPrefetch(){if(fo(this.config)){var e;if((e=this.hls.interstitialsManager)==null||(e=e.playingItem)==null?void 0:e.event)return!0}return!1}filterReplacedPrimary(e,t){if(!e)return e;if(fo(this.config)&&e.type!==he.SUBTITLE){const i=this.hls.interstitialsManager,s=i?.bufferingItem;if(s){const n=s.event;if(n){if(n.appendInPlace||Math.abs(e.start-s.start)>1||s.start===0)return null}else if(e.end<=s.start&&t?.live===!1||e.start>s.end&&s.nextEvent&&(s.nextEvent.appendInPlace||e.start-s.end>1))return null}const r=i?.playerQueue;if(r)for(let n=r.length;n--;){const o=r[n].interstitial;if(o.appendInPlace&&e.start>=o.startTime&&e.end<=o.resumeTime)return null}}return e}mapToInitFragWhenRequired(e){return e!=null&&e.initSegment&&!e.initSegment.data&&!this.bitrateTest?e.initSegment:e}getNextPart(e,t,i){let s=-1,r=!1,n=!0;for(let o=0,c=e.length;o<c;o++){const u=e[o];if(n=n&&!u.independent,s>-1&&i<u.start)break;const h=u.loaded;h?s=-1:(r||(u.independent||n)&&u.fragment===t)&&(u.fragment!==t&&this.warn(`Need buffer at ${i} but next unloaded part starts at ${u.start}`),s=o),r=h}return s}loadedEndOfParts(e,t){let i;for(let s=e.length;s--;){if(i=e[s],!i.loaded)return!1;if(t>i.start)return!0}return!1}getInitialLiveFragment(e){const t=e.fragments,i=this.fragPrevious;let s=null;if(i){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${i.programDateTime}`),s=fc(t,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),!s){const r=i.sn+1;if(r>=e.startSN&&r<=e.endSN){const n=t[r-e.startSN];i.cc===n.cc&&(s=n,this.log(`Live playlist, switching playlist, load frag with next SN: ${s.sn}`))}s||(s=La(e,i.cc,i.end),s&&this.log(`Live playlist, switching playlist, load frag with same CC: ${s.sn}`))}}else{const r=this.hls.liveSyncPosition;r!==null&&(s=this.getFragmentAtPosition(r,this.bitrateTest?e.fragmentEnd:e.edge,e))}return s}getFragmentAtPosition(e,t,i){const{config:s}=this;let{fragPrevious:r}=this,{fragments:n,endSN:o}=i;const{fragmentHint:c}=i,{maxFragLookUpTolerance:u}=s,h=i.partList,f=!!(this.loadingParts&&h!=null&&h.length&&c);f&&!this.bitrateTest&&h[h.length-1].fragment.sn===c.sn&&(n=n.concat(c),o=c.sn);let g;if(e<t){var I;const E=e<this.lastCurrentTime||e>t-u||(I=this.media)!=null&&I.paused||!this.startFragRequested?0:u;g=yi(r,n,e,E)}else g=n[n.length-1];if(g){const m=g.sn-i.startSN,E=this.fragmentTracker.getState(g);if((E===Qe.OK||E===Qe.PARTIAL&&g.gap)&&(r=g),r&&g.sn===r.sn&&(!f||h[0].fragment.sn>g.sn||!i.live)&&g.level===r.level){const x=n[m+1];g.sn<o&&this.fragmentTracker.getState(x)!==Qe.OK?g=x:g=null}}return g}alignPlaylists(e,t,i){const s=e.fragments.length;if(!s)return this.warn("No fragments in live playlist"),0;const r=e.fragmentStart,n=!t,o=e.alignedSliding&&se(r);if(n||!o&&!r){Qc(i,e);const c=e.fragmentStart;return this.log(`Live playlist sliding: ${c.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} fragments: ${s}`),c}return r}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,e.partTarget*3)}setStartPosition(e,t){let i=this.startPosition;i<t&&(i=-1);const s=this.timelineOffset;if(i===-1){const r=this.startTimeOffset!==null,n=r?this.startTimeOffset:e.startTimeOffset;n!==null&&se(n)?(i=t+n,n<0&&(i+=e.edge),i=Math.min(Math.max(t,i),t+e.totalduration),this.log(`Setting startPosition to ${i} for start time offset ${n} found in ${r?"multivariant":"media"} playlist`),this.startPosition=i):e.live?(i=this.hls.liveSyncPosition||t,this.log(`Setting startPosition to -1 to start at live edge ${i}`),this.startPosition=-1):(this.log("setting startPosition to 0 by default"),this.startPosition=i=0),this.lastCurrentTime=i+s}this.nextLoadPosition=i+s}getLoadPosition(){var e;const{media:t}=this;let i=0;return(e=this.hls)!=null&&e.hasEnoughToStart&&t?i=t.currentTime:this.nextLoadPosition>=0&&(i=this.nextLoadPosition),i}handleFragLoadAborted(e,t){this.transmuxer&&e.type===this.playlistType&&qe(e)&&e.stats.aborted&&(this.log(`Fragment ${e.sn}${t?" part "+t.index:""} of ${this.playlistLabel()} ${e.level} was aborted`),this.resetFragmentLoading(e))}resetFragmentLoading(e){(!this.fragCurrent||!this.fragContextChanged(e)&&this.state!==j.FRAG_LOADING_WAITING_RETRY)&&(this.state=j.IDLE)}onFragmentOrKeyLoadError(e,t){var i;if(t.chunkMeta&&!t.frag){const x=this.getCurrentContext(t.chunkMeta);x&&(t.frag=x.frag)}const s=t.frag;if(!s||s.type!==e||!this.levels)return;if(this.fragContextChanged(s)){var r;this.warn(`Frag load error must match current frag to retry ${s.url} > ${(r=this.fragCurrent)==null?void 0:r.url}`);return}const n=t.details===U.FRAG_GAP;n&&this.fragmentTracker.fragBuffered(s,!0);const o=t.errorAction;if(!o){this.state=j.ERROR;return}const{action:c,flags:u,retryCount:h=0,retryConfig:f}=o,g=!!f,I=g&&c===rt.RetryRequest,m=g&&!o.resolved&&u===Ct.MoveAllAlternatesMatchingHost,E=(i=this.hls.latestLevelDetails)==null?void 0:i.live;if(!I&&m&&qe(s)&&!s.endList&&E)this.resetFragmentErrors(e),this.treatAsGap(s),o.resolved=!0;else if((I||m)&&h<f.maxNumRetry){var v;const x=Lr((v=t.response)==null?void 0:v.code),D=br(f,h);if(this.resetStartWhenNotLoaded(),this.retryDate=self.performance.now()+D,this.state=j.FRAG_LOADING_WAITING_RETRY,o.resolved=!0,x){this.log("Waiting for connection (offline)"),this.retryDate=1/0,t.reason="offline";return}this.warn(`Fragment ${s.sn} of ${e} ${s.level} errored with ${t.details}, retrying loading ${h+1}/${f.maxNumRetry} in ${D}ms`)}else if(f)if(this.resetFragmentErrors(e),h<f.maxNumRetry)!n&&c!==rt.RemoveAlternatePermanently&&(o.resolved=!0);else{this.warn(`${t.details} reached or exceeded max retry (${h})`);return}else c===rt.SendAlternateToPenaltyBox?this.state=j.WAITING_LEVEL:this.state=j.ERROR;this.tickImmediate()}checkRetryDate(){const e=self.performance.now(),t=this.retryDate,i=t===1/0;(!t||e>=t||i&&!Lr(0))&&(i&&this.log("Connection restored (online)"),this.resetStartWhenNotLoaded(),this.state=j.IDLE)}reduceLengthAndFlushBuffer(e){if(this.state===j.PARSING||this.state===j.PARSED){const t=e.frag,i=e.parent,s=this.getFwdBufferInfo(this.mediaBuffer,i),r=s&&s.len>.5;r&&this.reduceMaxBufferLength(s.len,t?.duration||10);const n=!r;return n&&this.warn(`Buffer full error while media.currentTime (${this.getLoadPosition()}) is not buffered, flush ${i} buffer`),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),n}return!1}resetFragmentErrors(e){e===he.AUDIO&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==j.STOPPED&&(this.state=j.IDLE)}afterBufferFlushed(e,t,i){if(!e)return;const s=ye.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,s,i),this.state===j.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==j.STOPPED&&(this.state=j.IDLE)}resetStartWhenNotLoaded(){if(!this.hls.hasEnoughToStart){this.startFragRequested=!1;const e=this.levelLastLoaded,t=e?e.details:null;t!=null&&t.live?(this.log("resetting startPosition for live start"),this.startPosition=-1,this.setStartPosition(t,t.fragmentStart),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){this.log(`Loading context changed while buffering sn ${e.sn} of ${this.playlistLabel()} ${e.level===-1?"<removed>":e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,t,i,s){const r=i.details;if(!r){this.warn("level.details undefined");return}if(!Object.keys(e.elementaryStreams).reduce((c,u)=>{const h=e.elementaryStreams[u];if(h){const f=h.endPTS-h.startPTS;if(f<=0)return this.warn(`Could not parse fragment ${e.sn} ${u} duration reliably (${f})`),c||!1;const g=s?0:eo(r,e,h.startPTS,h.endPTS,h.startDTS,h.endDTS,this);return this.hls.trigger(y.LEVEL_PTS_UPDATED,{details:r,level:i,drift:g,type:u,frag:e,start:h.startPTS,end:h.endPTS}),!0}return c},!1)){var o;if(i.fragmentError===0&&this.treatAsGap(e,i),((o=this.transmuxer)==null?void 0:o.error)===null){const c=new Error(`Found no media in fragment ${e.sn} of ${this.playlistLabel()} ${e.level} resetting transmuxer to fallback to playlist timing`);if(this.warn(c.message),this.hls.trigger(y.ERROR,{type:de.MEDIA_ERROR,details:U.FRAG_PARSING_ERROR,fatal:!1,error:c,frag:e,reason:`Found no media in msn ${e.sn} of ${this.playlistLabel()} "${i.url}"`}),!this.hls)return;this.resetTransmuxer()}}this.state=j.PARSED,this.log(`Parsed ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)})`),this.hls.trigger(y.FRAG_PARSED,{frag:e,part:t})}playlistLabel(){return this.playlistType===he.MAIN?"level":"track"}fragInfo(e,t=!0,i){var s,r;return`${this.playlistLabel()} ${e.level} (${i?"part":"frag"}:[${((s=t&&!i?e.startPTS:(i||e).start)!=null?s:NaN).toFixed(3)}-${((r=t&&!i?e.endPTS:(i||e).end)!=null?r:NaN).toFixed(3)}]${i&&e.type==="main"?"INDEPENDENT="+(i.independent?"YES":"NO"):""}`}treatAsGap(e,t){t&&t.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)}resetTransmuxer(){var e;(e=this.transmuxer)==null||e.reset()}recoverWorkerError(e){e.event==="demuxerWorker"&&(this.fragmentTracker.removeAllFragments(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),this.resetStartWhenNotLoaded(),this.resetLoadingState())}set state(e){const t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}get state(){return this._state}}function fo(a){return!!a.interstitialsController&&a.enableInterstitialPlayback!==!1}class go{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){const{chunks:e,dataLength:t}=this;let i;if(e.length)e.length===1?i=e[0]:i=eh(e,t);else return new Uint8Array(0);return this.reset(),i}reset(){this.chunks.length=0,this.dataLength=0}}function eh(a,e){const t=new Uint8Array(e);let i=0;for(let s=0;s<a.length;s++){const r=a[s];t.set(r,i),i+=r.length}return t}var $r={exports:{}},po;function th(){return po||(po=1,(function(a){var e=Object.prototype.hasOwnProperty,t="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(t=!1));function s(c,u,h){this.fn=c,this.context=u,this.once=h||!1}function r(c,u,h,f,g){if(typeof h!="function")throw new TypeError("The listener must be a function");var I=new s(h,f||c,g),m=t?t+u:u;return c._events[m]?c._events[m].fn?c._events[m]=[c._events[m],I]:c._events[m].push(I):(c._events[m]=I,c._eventsCount++),c}function n(c,u){--c._eventsCount===0?c._events=new i:delete c._events[u]}function o(){this._events=new i,this._eventsCount=0}o.prototype.eventNames=function(){var u=[],h,f;if(this._eventsCount===0)return u;for(f in h=this._events)e.call(h,f)&&u.push(t?f.slice(1):f);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(h)):u},o.prototype.listeners=function(u){var h=t?t+u:u,f=this._events[h];if(!f)return[];if(f.fn)return[f.fn];for(var g=0,I=f.length,m=new Array(I);g<I;g++)m[g]=f[g].fn;return m},o.prototype.listenerCount=function(u){var h=t?t+u:u,f=this._events[h];return f?f.fn?1:f.length:0},o.prototype.emit=function(u,h,f,g,I,m){var E=t?t+u:u;if(!this._events[E])return!1;var v=this._events[E],x=arguments.length,D,L;if(v.fn){switch(v.once&&this.removeListener(u,v.fn,void 0,!0),x){case 1:return v.fn.call(v.context),!0;case 2:return v.fn.call(v.context,h),!0;case 3:return v.fn.call(v.context,h,f),!0;case 4:return v.fn.call(v.context,h,f,g),!0;case 5:return v.fn.call(v.context,h,f,g,I),!0;case 6:return v.fn.call(v.context,h,f,g,I,m),!0}for(L=1,D=new Array(x-1);L<x;L++)D[L-1]=arguments[L];v.fn.apply(v.context,D)}else{var w=v.length,N;for(L=0;L<w;L++)switch(v[L].once&&this.removeListener(u,v[L].fn,void 0,!0),x){case 1:v[L].fn.call(v[L].context);break;case 2:v[L].fn.call(v[L].context,h);break;case 3:v[L].fn.call(v[L].context,h,f);break;case 4:v[L].fn.call(v[L].context,h,f,g);break;default:if(!D)for(N=1,D=new Array(x-1);N<x;N++)D[N-1]=arguments[N];v[L].fn.apply(v[L].context,D)}}return!0},o.prototype.on=function(u,h,f){return r(this,u,h,f,!1)},o.prototype.once=function(u,h,f){return r(this,u,h,f,!0)},o.prototype.removeListener=function(u,h,f,g){var I=t?t+u:u;if(!this._events[I])return this;if(!h)return n(this,I),this;var m=this._events[I];if(m.fn)m.fn===h&&(!g||m.once)&&(!f||m.context===f)&&n(this,I);else{for(var E=0,v=[],x=m.length;E<x;E++)(m[E].fn!==h||g&&!m[E].once||f&&m[E].context!==f)&&v.push(m[E]);v.length?this._events[I]=v.length===1?v[0]:v:n(this,I)}return this},o.prototype.removeAllListeners=function(u){var h;return u?(h=t?t+u:u,this._events[h]&&n(this,h)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=t,o.EventEmitter=o,a.exports=o})($r)),$r.exports}var ih=th(),Gr=Ru(ih);const es="1.6.11",Mi={};function sh(){return typeof __HLS_WORKER_BUNDLE__=="function"}function rh(){const a=Mi[es];if(a)return a.clientCount++,a;const e=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),t=self.URL.createObjectURL(e),s={worker:new self.Worker(t),objectURL:t,clientCount:1};return Mi[es]=s,s}function nh(a){const e=Mi[a];if(e)return e.clientCount++,e;const t=new self.URL(a,self.location.href).href,s={worker:new self.Worker(t),scriptURL:t,clientCount:1};return Mi[a]=s,s}function ah(a){const e=Mi[a||es];if(e&&e.clientCount--===1){const{worker:i,objectURL:s}=e;delete Mi[a||es],s&&self.URL.revokeObjectURL(s),i.terminate()}}function Ao(a,e){return e+10<=a.length&&a[e]===51&&a[e+1]===68&&a[e+2]===73&&a[e+3]<255&&a[e+4]<255&&a[e+6]<128&&a[e+7]<128&&a[e+8]<128&&a[e+9]<128}function Hr(a,e){return e+10<=a.length&&a[e]===73&&a[e+1]===68&&a[e+2]===51&&a[e+3]<255&&a[e+4]<255&&a[e+6]<128&&a[e+7]<128&&a[e+8]<128&&a[e+9]<128}function Os(a,e){let t=0;return t=(a[e]&127)<<21,t|=(a[e+1]&127)<<14,t|=(a[e+2]&127)<<7,t|=a[e+3]&127,t}function ts(a,e){const t=e;let i=0;for(;Hr(a,e);){i+=10;const s=Os(a,e+6);i+=s,Ao(a,e+10)&&(i+=10),e+=i}if(i>0)return a.subarray(t,t+i)}function oh(a,e,t,i){const s=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],r=e[t+2],n=r>>2&15;if(n>12){const I=new Error(`invalid ADTS sampling index:${n}`);a.emit(y.ERROR,y.ERROR,{type:de.MEDIA_ERROR,details:U.FRAG_PARSING_ERROR,fatal:!0,error:I,reason:I.message});return}const o=(r>>6&3)+1,c=e[t+3]>>6&3|(r&1)<<2,u="mp4a.40."+o,h=s[n];let f=n;(o===5||o===29)&&(f-=3);const g=[o<<3|(f&14)>>1,(f&1)<<7|c<<3];return Oe.log(`manifest codec:${i}, parsed codec:${u}, channels:${c}, rate:${h} (ADTS object type:${o} sampling index:${n})`),{config:g,samplerate:h,channelCount:c,codec:u,parsedCodec:u,manifestCodec:i}}function mo(a,e){return a[e]===255&&(a[e+1]&246)===240}function Io(a,e){return a[e+1]&1?7:9}function Vr(a,e){return(a[e+3]&3)<<11|a[e+4]<<3|(a[e+5]&224)>>>5}function lh(a,e){return e+5<a.length}function Fs(a,e){return e+1<a.length&&mo(a,e)}function uh(a,e){return lh(a,e)&&mo(a,e)&&Vr(a,e)<=a.length-e}function ch(a,e){if(Fs(a,e)){const t=Io(a,e);if(e+t>=a.length)return!1;const i=Vr(a,e);if(i<=t)return!1;const s=e+i;return s===a.length||Fs(a,s)}return!1}function Co(a,e,t,i,s){if(!a.samplerate){const r=oh(e,t,i,s);if(!r)return;Ne(a,r)}}function yo(a){return 1024*9e4/a}function hh(a,e){const t=Io(a,e);if(e+t<=a.length){const i=Vr(a,e)-t;if(i>0)return{headerLength:t,frameLength:i}}}function Eo(a,e,t,i,s){const r=yo(a.samplerate),n=i+s*r,o=hh(e,t);let c;if(o){const{frameLength:f,headerLength:g}=o,I=g+f,m=Math.max(0,t+I-e.length);m?(c=new Uint8Array(I-g),c.set(e.subarray(t+g,e.length),0)):c=e.subarray(t+g,t+I);const E={unit:c,pts:n};return m||a.samples.push(E),{sample:E,length:I,missing:m}}const u=e.length-t;return c=new Uint8Array(u),c.set(e.subarray(t,e.length),0),{sample:{unit:c,pts:n},length:u,missing:-1}}function dh(a,e){return Hr(a,e)&&Os(a,e+6)+10<=a.length-e}function fh(a){return a instanceof ArrayBuffer?a:a.byteOffset==0&&a.byteLength==a.buffer.byteLength?a.buffer:new Uint8Array(a).buffer}function Kr(a,e=0,t=1/0){return gh(a,e,t,Uint8Array)}function gh(a,e,t,i){const s=ph(a);let r=1;"BYTES_PER_ELEMENT"in i&&(r=i.BYTES_PER_ELEMENT);const n=Ah(a)?a.byteOffset:0,o=(n+a.byteLength)/r,c=(n+e)/r,u=Math.floor(Math.max(0,Math.min(c,o))),h=Math.floor(Math.min(u+Math.max(t,0),o));return new i(s,u,h-u)}function ph(a){return a instanceof ArrayBuffer?a:a.buffer}function Ah(a){return a&&a.buffer instanceof ArrayBuffer&&a.byteLength!==void 0&&a.byteOffset!==void 0}function mh(a){const e={key:a.type,description:"",data:"",mimeType:null,pictureType:null},t=3;if(a.size<2)return;if(a.data[0]!==t){console.log("Ignore frame with unrecognized character encoding");return}const i=a.data.subarray(1).indexOf(0);if(i===-1)return;const s=mt(Kr(a.data,1,i)),r=a.data[2+i],n=a.data.subarray(3+i).indexOf(0);if(n===-1)return;const o=mt(Kr(a.data,3+i,n));let c;return s==="-->"?c=mt(Kr(a.data,4+i+n)):c=fh(a.data.subarray(4+i+n)),e.mimeType=s,e.pictureType=r,e.description=o,e.data=c,e}function Ih(a){if(a.size<2)return;const e=mt(a.data,!0),t=new Uint8Array(a.data.subarray(e.length+1));return{key:a.type,info:e,data:t.buffer}}function Ch(a){if(a.size<2)return;if(a.type==="TXXX"){let t=1;const i=mt(a.data.subarray(t),!0);t+=i.length+1;const s=mt(a.data.subarray(t));return{key:a.type,info:i,data:s}}const e=mt(a.data.subarray(1));return{key:a.type,info:"",data:e}}function yh(a){if(a.type==="WXXX"){if(a.size<2)return;let t=1;const i=mt(a.data.subarray(t),!0);t+=i.length+1;const s=mt(a.data.subarray(t));return{key:a.type,info:i,data:s}}const e=mt(a.data);return{key:a.type,info:"",data:e}}function Eh(a){return a.type==="PRIV"?Ih(a):a.type[0]==="W"?yh(a):a.type==="APIC"?mh(a):Ch(a)}function vh(a){const e=String.fromCharCode(a[0],a[1],a[2],a[3]),t=Os(a,4),i=10;return{type:e,size:t,data:a.subarray(i,i+t)}}const Ns=10,Th=10;function vo(a){let e=0;const t=[];for(;Hr(a,e);){const i=Os(a,e+6);a[e+5]>>6&1&&(e+=Ns),e+=Ns;const s=e+i;for(;e+Th<s;){const r=vh(a.subarray(e)),n=Eh(r);n&&t.push(n),e+=r.size+Ns}Ao(a,e)&&(e+=Ns)}return t}function To(a){return a&&a.key==="PRIV"&&a.info==="com.apple.streaming.transportStreamTimestamp"}function Sh(a){if(a.data.byteLength===8){const e=new Uint8Array(a.data),t=e[3]&1;let i=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return i/=45,t&&(i+=4772185884e-2),Math.round(i)}}function Yr(a){const e=vo(a);for(let t=0;t<e.length;t++){const i=e[t];if(To(i))return Sh(i)}}let yt=(function(a){return a.audioId3="org.id3",a.dateRange="com.apple.quicktime.HLS",a.emsg="https://aomedia.org/emsg/ID3",a.misbklv="urn:misb:KLV:bin:1910.1",a})({});function Bt(a="",e=9e4){return{type:a,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}class Wr{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(e,t,i,s){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(e){this.initPTS=e,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(e,t){return!1}appendFrame(e,t,i){}demux(e,t){this.cachedData&&(e=St(this.cachedData,e),this.cachedData=null);let i=ts(e,0),s=i?i.length:0,r;const n=this._audioTrack,o=this._id3Track,c=i?Yr(i):void 0,u=e.length;for((this.basePTS===null||this.frameIndex===0&&se(c))&&(this.basePTS=xh(c,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),i&&i.length>0&&o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:yt.audioId3,duration:Number.POSITIVE_INFINITY});s<u;){if(this.canParse(e,s)){const h=this.appendFrame(n,e,s);h?(this.frameIndex++,this.lastPTS=h.sample.pts,s+=h.length,r=s):s=u}else dh(e,s)?(i=ts(e,s),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:yt.audioId3,duration:Number.POSITIVE_INFINITY}),s+=i.length,r=s):s++;if(s===u&&r!==u){const h=e.slice(r);this.cachedData?this.cachedData=St(this.cachedData,h):this.cachedData=h}}return{audioTrack:n,videoTrack:Bt(),id3Track:o,textTrack:Bt()}}demuxSampleAes(e,t,i){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(e){const t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:Bt(),id3Track:this._id3Track,textTrack:Bt()}}destroy(){this.cachedData=null,this._audioTrack=this._id3Track=void 0}}const xh=(a,e,t)=>{if(se(a))return a*90;const i=t?t.baseTime*9e4/t.timescale:0;return e*9e4+i};let Bs=null;const bh=[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],Lh=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Rh=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Dh=[0,1,1,4];function So(a,e,t,i,s){if(t+24>e.length)return;const r=xo(e,t);if(r&&t+r.frameLength<=e.length){const n=r.samplesPerFrame*9e4/r.sampleRate,o=i+s*n,c={unit:e.subarray(t,t+r.frameLength),pts:o,dts:o};return a.config=[],a.channelCount=r.channelCount,a.samplerate=r.sampleRate,a.samples.push(c),{sample:c,length:r.frameLength,missing:0}}}function xo(a,e){const t=a[e+1]>>3&3,i=a[e+1]>>1&3,s=a[e+2]>>4&15,r=a[e+2]>>2&3;if(t!==1&&s!==0&&s!==15&&r!==3){const n=a[e+2]>>1&1,o=a[e+3]>>6,c=t===3?3-i:i===3?3:4,u=bh[c*14+s-1]*1e3,f=Lh[(t===3?0:t===2?1:2)*3+r],g=o===3?1:2,I=Rh[t][i],m=Dh[i],E=I*8*m,v=Math.floor(I*u/f+n)*m;if(Bs===null){const L=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Bs=L?parseInt(L[1]):0}return!!Bs&&Bs<=87&&i===2&&u>=224e3&&o===0&&(a[e+3]=a[e+3]|128),{sampleRate:f,channelCount:g,frameLength:v,samplesPerFrame:E}}}function jr(a,e){return a[e]===255&&(a[e+1]&224)===224&&(a[e+1]&6)!==0}function bo(a,e){return e+1<a.length&&jr(a,e)}function Ph(a,e){return jr(a,e)&&4<=a.length-e}function Lo(a,e){if(e+1<a.length&&jr(a,e)){const i=xo(a,e);let s=4;i!=null&&i.frameLength&&(s=i.frameLength);const r=e+s;return r===a.length||bo(a,r)}return!1}class _h extends Wr{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,i,s){super.resetInitSegment(e,t,i,s),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}static probe(e,t){if(!e)return!1;const i=ts(e,0);let s=i?.length||0;if(Lo(e,s))return!1;for(let r=e.length;s<r;s++)if(ch(e,s))return t.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return uh(e,t)}appendFrame(e,t,i){Co(e,this.observer,t,i,e.manifestCodec);const s=Eo(e,t,i,this.basePTS,this.frameIndex);if(s&&s.missing===0)return s}}const Ro=(a,e)=>{let t=0,i=5;e+=i;const s=new Uint32Array(1),r=new Uint32Array(1),n=new Uint8Array(1);for(;i>0;){n[0]=a[e];const o=Math.min(i,8),c=8-o;r[0]=4278190080>>>24+c<<c,s[0]=(n[0]&r[0])>>c,t=t?t<<o|s[0]:s[0],e+=1,i-=o}return t};class wh extends Wr{constructor(e){super(),this.observer=void 0,this.observer=e}resetInitSegment(e,t,i,s){super.resetInitSegment(e,t,i,s),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}canParse(e,t){return t+64<e.length}appendFrame(e,t,i){const s=Do(e,t,i,this.basePTS,this.frameIndex);if(s!==-1)return{sample:e.samples[e.samples.length-1],length:s,missing:0}}static probe(e){if(!e)return!1;const t=ts(e,0);if(!t)return!1;const i=t.length;return e[i]===11&&e[i+1]===119&&Yr(t)!==void 0&&Ro(e,i)<16}}function Do(a,e,t,i,s){if(t+8>e.length||e[t]!==11||e[t+1]!==119)return-1;const r=e[t+4]>>6;if(r>=3)return-1;const o=[48e3,44100,32e3][r],c=e[t+4]&63,h=[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][c*3+r]*2;if(t+h>e.length)return-1;const f=e[t+6]>>5;let g=0;f===2?g+=2:(f&1&&f!==1&&(g+=2),f&4&&(g+=2));const I=(e[t+6]<<8|e[t+7])>>12-g&1,E=[2,1,2,3,3,4,4,5][f]+I,v=e[t+5]>>3,x=e[t+5]&7,D=new Uint8Array([r<<6|v<<1|x>>2,(x&3)<<6|f<<3|I<<2|c>>4,c<<4&224]),L=1536/o*9e4,w=i+s*L,N=e.subarray(t,t+h);return a.config=D,a.channelCount=E,a.samplerate=o,a.samples.push({unit:N,pts:w}),h}class kh extends Wr{resetInitSegment(e,t,i,s){super.resetInitSegment(e,t,i,s),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;const t=ts(e,0);let i=t?.length||0;if(t&&e[i]===11&&e[i+1]===119&&Yr(t)!==void 0&&Ro(e,i)<=16)return!1;for(let s=e.length;i<s;i++)if(Lo(e,i))return Oe.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return Ph(e,t)}appendFrame(e,t,i){if(this.basePTS!==null)return So(e,t,i,this.basePTS,this.frameIndex)}}const Mh=/\/emsg[-/]ID3/i;class Oh{constructor(e,t){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=t}resetTimeStamp(){}resetInitSegment(e,t,i,s){const r=this.videoTrack=Bt("video",1),n=this.audioTrack=Bt("audio",1),o=this.txtTrack=Bt("text",1);if(this.id3Track=Bt("id3",1),this.timeOffset=0,!(e!=null&&e.byteLength))return;const c=oa(e);if(c.video){const{id:u,timescale:h,codec:f,supplemental:g}=c.video;r.id=u,r.timescale=o.timescale=h,r.codec=f,r.supplemental=g}if(c.audio){const{id:u,timescale:h,codec:f}=c.audio;n.id=u,n.timescale=h,n.codec=f}o.id=sa.text,r.sampleDuration=0,r.duration=n.duration=s}resetContiguity(){this.remainderData=null}static probe(e){return ku(e)}demux(e,t){this.timeOffset=t;let i=e;const s=this.videoTrack,r=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=St(this.remainderData,e));const o=Uu(i);this.remainderData=o.remainder,s.samples=o.valid||new Uint8Array}else s.samples=i;const n=this.extractID3Track(s,t);return r.samples=ua(t,s),{videoTrack:s,audioTrack:this.audioTrack,id3Track:n,textTrack:this.txtTrack}}flush(){const e=this.timeOffset,t=this.videoTrack,i=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;const s=this.extractID3Track(t,this.timeOffset);return i.samples=ua(e,t),{videoTrack:t,audioTrack:Bt(),id3Track:s,textTrack:Bt()}}extractID3Track(e,t){const i=this.id3Track;if(e.samples.length){const s=xe(e.samples,["emsg"]);s&&s.forEach(r=>{const n=Gu(r);if(Mh.test(n.schemeIdUri)){const o=Po(n,t);let c=n.eventDuration===4294967295?Number.POSITIVE_INFINITY:n.eventDuration/n.timeScale;c<=.001&&(c=Number.POSITIVE_INFINITY);const u=n.payload;i.samples.push({data:u,len:u.byteLength,dts:o,pts:o,type:yt.emsg,duration:c})}else if(this.config.enableEmsgKLVMetadata&&n.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){const o=Po(n,t);i.samples.push({data:n.payload,len:n.payload.byteLength,dts:o,pts:o,type:yt.misbklv,duration:Number.POSITIVE_INFINITY})}})}return i}demuxSampleAes(e,t,i){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){this.config=null,this.remainderData=null,this.videoTrack=this.audioTrack=this.id3Track=this.txtTrack=void 0}}function Po(a,e){return se(a.presentationTime)?a.presentationTime/a.timeScale:e+a.presentationTimeDelta/a.timeScale}class Fh{constructor(e,t,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new Rr(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,ni.cbc)}decryptAacSample(e,t,i){const s=e[t].unit;if(s.length<=16)return;const r=s.subarray(16,s.length-s.length%16),n=r.buffer.slice(r.byteOffset,r.byteOffset+r.length);this.decryptBuffer(n).then(o=>{const c=new Uint8Array(o);s.set(c,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,i)}).catch(i)}decryptAacSamples(e,t,i){for(;;t++){if(t>=e.length){i();return}if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,i),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){const t=Math.floor((e.length-48)/160)*16+16,i=new Int8Array(t);let s=0;for(let r=32;r<e.length-16;r+=160,s+=16)i.set(e.subarray(r,r+16),s);return i}getAvcDecryptedUnit(e,t){const i=new Uint8Array(t);let s=0;for(let r=32;r<e.length-16;r+=160,s+=16)e.set(i.subarray(s,s+16),r);return e}decryptAvcSample(e,t,i,s,r){const n=ca(r.data),o=this.getAvcEncryptedData(n);this.decryptBuffer(o.buffer).then(c=>{r.data=this.getAvcDecryptedUnit(n,c),this.decrypter.isSync()||this.decryptAvcSamples(e,t,i+1,s)}).catch(s)}decryptAvcSamples(e,t,i,s){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,i=0){if(t>=e.length){s();return}const r=e[t].units;for(;!(i>=r.length);i++){const n=r[i];if(!(n.data.length<=48||n.type!==1&&n.type!==5)&&(this.decryptAvcSample(e,t,i,s,n),!this.decrypter.isSync()))return}}}}class _o{constructor(){this.VideoSample=null}createVideoSample(e,t,i){return{key:e,frame:!1,pts:t,dts:i,units:[],length:0}}getLastNalUnit(e){var t;let i=this.VideoSample,s;if((!i||i.units.length===0)&&(i=e[e.length-1]),(t=i)!=null&&t.units){const r=i.units;s=r[r.length-1]}return s}pushAccessUnit(e,t){if(e.units.length&&e.frame){if(e.pts===void 0){const i=t.samples,s=i.length;if(s){const r=i[s-1];e.pts=r.pts,e.dts=r.dts}else{t.dropped++;return}}t.samples.push(e)}}parseNALu(e,t,i){const s=t.byteLength;let r=e.naluState||0;const n=r,o=[];let c=0,u,h,f,g=-1,I=0;for(r===-1&&(g=0,I=this.getNALuType(t,0),r=0,c=1);c<s;){if(u=t[c++],!r){r=u?0:1;continue}if(r===1){r=u?0:2;continue}if(!u)r=3;else if(u===1){if(h=c-r-1,g>=0){const m={data:t.subarray(g,h),type:I};o.push(m)}else{const m=this.getLastNalUnit(e.samples);m&&(n&&c<=4-n&&m.state&&(m.data=m.data.subarray(0,m.data.byteLength-n)),h>0&&(m.data=St(m.data,t.subarray(0,h)),m.state=0))}c<s?(f=this.getNALuType(t,c),g=c,I=f,r=0):r=-1}else r=0}if(g>=0&&r>=0){const m={data:t.subarray(g,s),type:I,state:r};o.push(m)}if(o.length===0){const m=this.getLastNalUnit(e.samples);m&&(m.data=St(m.data,t))}return e.naluState=r,o}}class is{constructor(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){const e=this.data,t=this.bytesAvailable,i=e.byteLength-t,s=new Uint8Array(4),r=Math.min(4,t);if(r===0)throw new Error("no bytes available");s.set(e.subarray(i,i+r)),this.word=new DataView(s.buffer).getUint32(0),this.bitsAvailable=r*8,this.bytesAvailable-=r}skipBits(e){let 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)}readBits(e){let t=Math.min(this.bitsAvailable,e);const i=this.word>>>32-t;if(e>32&&Oe.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?i<<t|this.readBits(t):i}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if((this.word&2147483648>>>e)!==0)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){const e=this.skipLZ();return this.readBits(e+1)-1}readEG(){const e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}readBoolean(){return this.readBits(1)===1}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}}class Nh extends _o{parsePES(e,t,i,s){const r=this.parseNALu(e,i.data,s);let n=this.VideoSample,o,c=!1;i.data=null,n&&r.length&&!e.audFound&&(this.pushAccessUnit(n,e),n=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),r.forEach(u=>{var h,f;switch(u.type){case 1:{let E=!1;o=!0;const v=u.data;if(c&&v.length>4){const x=this.readSliceType(v);(x===2||x===4||x===7||x===9)&&(E=!0)}if(E){var g;(g=n)!=null&&g.frame&&!n.key&&(this.pushAccessUnit(n,e),n=this.VideoSample=null)}n||(n=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),n.frame=!0,n.key=E;break}case 5:o=!0,(h=n)!=null&&h.frame&&!n.key&&(this.pushAccessUnit(n,e),n=this.VideoSample=null),n||(n=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),n.key=!0,n.frame=!0;break;case 6:{o=!0,Cr(u.data,1,i.pts,t.samples);break}case 7:{var I,m;o=!0,c=!0;const E=u.data,v=this.readSPS(E);if(!e.sps||e.width!==v.width||e.height!==v.height||((I=e.pixelRatio)==null?void 0:I[0])!==v.pixelRatio[0]||((m=e.pixelRatio)==null?void 0:m[1])!==v.pixelRatio[1]){e.width=v.width,e.height=v.height,e.pixelRatio=v.pixelRatio,e.sps=[E];const x=E.subarray(1,4);let D="avc1.";for(let L=0;L<3;L++){let w=x[L].toString(16);w.length<2&&(w="0"+w),D+=w}e.codec=D}break}case 8:o=!0,e.pps=[u.data];break;case 9:o=!0,e.audFound=!0,(f=n)!=null&&f.frame&&(this.pushAccessUnit(n,e),n=null),n||(n=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts));break;case 12:o=!0;break;default:o=!1;break}n&&o&&n.units.push(u)}),s&&n&&(this.pushAccessUnit(n,e),this.VideoSample=null)}getNALuType(e,t){return e[t]&31}readSliceType(e){const t=new is(e);return t.readUByte(),t.readUEG(),t.readUEG()}skipScalingList(e,t){let i=8,s=8,r;for(let n=0;n<e;n++)s!==0&&(r=t.readEG(),s=(i+r+256)%256),i=s===0?i:s}readSPS(e){const t=new is(e);let i=0,s=0,r=0,n=0,o,c,u;const h=t.readUByte.bind(t),f=t.readBits.bind(t),g=t.readUEG.bind(t),I=t.readBoolean.bind(t),m=t.skipBits.bind(t),E=t.skipEG.bind(t),v=t.skipUEG.bind(t),x=this.skipScalingList.bind(this);h();const D=h();if(f(5),m(3),h(),v(),D===100||D===110||D===122||D===244||D===44||D===83||D===86||D===118||D===128){const $=g();if($===3&&m(1),v(),v(),m(1),I())for(c=$!==3?8:12,u=0;u<c;u++)I()&&(u<6?x(16,t):x(64,t))}v();const L=g();if(L===0)g();else if(L===1)for(m(1),E(),E(),o=g(),u=0;u<o;u++)E();v(),m(1);const w=g(),N=g(),K=f(1);K===0&&m(1),m(1),I()&&(i=g(),s=g(),r=g(),n=g());let p=[1,1];if(I()&&I())switch(h()){case 1:p=[1,1];break;case 2:p=[12,11];break;case 3:p=[10,11];break;case 4:p=[16,11];break;case 5:p=[40,33];break;case 6:p=[24,11];break;case 7:p=[20,11];break;case 8:p=[32,11];break;case 9:p=[80,33];break;case 10:p=[18,11];break;case 11:p=[15,11];break;case 12:p=[64,33];break;case 13:p=[160,99];break;case 14:p=[4,3];break;case 15:p=[3,2];break;case 16:p=[2,1];break;case 255:{p=[h()<<8|h(),h()<<8|h()];break}}return{width:Math.ceil((w+1)*16-i*2-s*2),height:(2-K)*(N+1)*16-(K?2:4)*(r+n),pixelRatio:p}}}class Bh extends _o{constructor(...e){super(...e),this.initVPS=null}parsePES(e,t,i,s){const r=this.parseNALu(e,i.data,s);let n=this.VideoSample,o,c=!1;i.data=null,n&&r.length&&!e.audFound&&(this.pushAccessUnit(n,e),n=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),r.forEach(u=>{var h,f;switch(u.type){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:n||(n=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),n.frame=!0,o=!0;break;case 16:case 17:case 18:case 21:if(o=!0,c){var g;(g=n)!=null&&g.frame&&!n.key&&(this.pushAccessUnit(n,e),n=this.VideoSample=null)}n||(n=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),n.key=!0,n.frame=!0;break;case 19:case 20:o=!0,(h=n)!=null&&h.frame&&!n.key&&(this.pushAccessUnit(n,e),n=this.VideoSample=null),n||(n=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),n.key=!0,n.frame=!0;break;case 39:o=!0,Cr(u.data,2,i.pts,t.samples);break;case 32:o=!0,e.vps||(typeof e.params!="object"&&(e.params={}),e.params=Ne(e.params,this.readVPS(u.data)),this.initVPS=u.data),e.vps=[u.data];break;case 33:if(o=!0,c=!0,e.vps!==void 0&&e.vps[0]!==this.initVPS&&e.sps!==void 0&&!this.matchSPS(e.sps[0],u.data)&&(this.initVPS=e.vps[0],e.sps=e.pps=void 0),!e.sps){const I=this.readSPS(u.data);e.width=I.width,e.height=I.height,e.pixelRatio=I.pixelRatio,e.codec=I.codecString,e.sps=[],typeof e.params!="object"&&(e.params={});for(const m in I.params)e.params[m]=I.params[m]}this.pushParameterSet(e.sps,u.data,e.vps),n||(n=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),n.key=!0;break;case 34:if(o=!0,typeof e.params=="object"){if(!e.pps){e.pps=[];const I=this.readPPS(u.data);for(const m in I)e.params[m]=I[m]}this.pushParameterSet(e.pps,u.data,e.vps)}break;case 35:o=!0,e.audFound=!0,(f=n)!=null&&f.frame&&(this.pushAccessUnit(n,e),n=null),n||(n=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts));break;default:o=!1;break}n&&o&&n.units.push(u)}),s&&n&&(this.pushAccessUnit(n,e),this.VideoSample=null)}pushParameterSet(e,t,i){(i&&i[0]===this.initVPS||!i&&!e.length)&&e.push(t)}getNALuType(e,t){return(e[t]&126)>>>1}ebsp2rbsp(e){const t=new Uint8Array(e.byteLength);let i=0;for(let s=0;s<e.byteLength;s++)s>=2&&e[s]===3&&e[s-1]===0&&e[s-2]===0||(t[i]=e[s],i++);return new Uint8Array(t.buffer,0,i)}pushAccessUnit(e,t){super.pushAccessUnit(e,t),this.initVPS&&(this.initVPS=null)}readVPS(e){const t=new is(e);t.readUByte(),t.readUByte(),t.readBits(4),t.skipBits(2),t.readBits(6);const i=t.readBits(3),s=t.readBoolean();return{numTemporalLayers:i+1,temporalIdNested:s}}readSPS(e){const t=new is(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.readBits(4);const i=t.readBits(3);t.readBoolean();const s=t.readBits(2),r=t.readBoolean(),n=t.readBits(5),o=t.readUByte(),c=t.readUByte(),u=t.readUByte(),h=t.readUByte(),f=t.readUByte(),g=t.readUByte(),I=t.readUByte(),m=t.readUByte(),E=t.readUByte(),v=t.readUByte(),x=t.readUByte(),D=[],L=[];for(let Pe=0;Pe<i;Pe++)D.push(t.readBoolean()),L.push(t.readBoolean());if(i>0)for(let Pe=i;Pe<8;Pe++)t.readBits(2);for(let Pe=0;Pe<i;Pe++)D[Pe]&&(t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte()),L[Pe]&&t.readUByte();t.readUEG();const w=t.readUEG();w==3&&t.skipBits(1);const N=t.readUEG(),K=t.readUEG(),p=t.readBoolean();let $=0,F=0,O=0,W=0;p&&($+=t.readUEG(),F+=t.readUEG(),O+=t.readUEG(),W+=t.readUEG());const ie=t.readUEG(),X=t.readUEG(),ce=t.readUEG(),ue=t.readBoolean();for(let Pe=ue?0:i;Pe<=i;Pe++)t.skipUEG(),t.skipUEG(),t.skipUEG();if(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.readBoolean()&&t.readBoolean())for(let ze=0;ze<4;ze++)for(let Ye=0;Ye<(ze===3?2:6);Ye++)if(!t.readBoolean())t.readUEG();else{const vt=Math.min(64,1<<4+(ze<<1));ze>1&&t.readEG();for(let di=0;di<vt;di++)t.readEG()}t.readBoolean(),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.skipUEG(),t.skipUEG(),t.readBoolean());const re=t.readUEG();let le=0;for(let Pe=0;Pe<re;Pe++){let ze=!1;if(Pe!==0&&(ze=t.readBoolean()),ze){Pe===re&&t.readUEG(),t.readBoolean(),t.readUEG();let Ye=0;for(let Jt=0;Jt<=le;Jt++){const vt=t.readBoolean();let di=!1;vt||(di=t.readBoolean()),(vt||di)&&Ye++}le=Ye}else{const Ye=t.readUEG(),Jt=t.readUEG();le=Ye+Jt;for(let vt=0;vt<Ye;vt++)t.readUEG(),t.readBoolean();for(let vt=0;vt<Jt;vt++)t.readUEG(),t.readBoolean()}}if(t.readBoolean()){const Pe=t.readUEG();for(let ze=0;ze<Pe;ze++){for(let Ye=0;Ye<ce+4;Ye++)t.readBits(1);t.readBits(1)}}let J=0,ee=1,ve=1,ke=!0,Te=1,Le=0;t.readBoolean(),t.readBoolean();let it=!1;if(t.readBoolean()){if(t.readBoolean()){const st=t.readUByte(),fi=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2],Ht=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1];st>0&&st<16?(ee=fi[st-1],ve=Ht[st-1]):st===255&&(ee=t.readBits(16),ve=t.readBits(16))}if(t.readBoolean()&&t.readBoolean(),t.readBoolean()&&(t.readBits(3),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.readUByte(),t.readUByte())),t.readBoolean()&&(t.readUEG(),t.readUEG()),t.readBoolean(),t.readBoolean(),t.readBoolean(),it=t.readBoolean(),it&&(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG()),t.readBoolean()&&(Te=t.readBits(32),Le=t.readBits(32),t.readBoolean()&&t.readUEG(),t.readBoolean())){const Ht=t.readBoolean(),fe=t.readBoolean();let Xe=!1;(Ht||fe)&&(Xe=t.readBoolean(),Xe&&(t.readUByte(),t.readBits(5),t.readBoolean(),t.readBits(5)),t.readBits(4),t.readBits(4),Xe&&t.readBits(4),t.readBits(5),t.readBits(5),t.readBits(5));for(let tr=0;tr<=i;tr++){ke=t.readBoolean();const Ln=ke||t.readBoolean();let ir=!1;Ln?t.readEG():ir=t.readBoolean();const os=ir?1:t.readUEG()+1;if(Ht)for(let gi=0;gi<os;gi++)t.readUEG(),t.readUEG(),Xe&&(t.readUEG(),t.readUEG()),t.skipBits(1);if(fe)for(let gi=0;gi<os;gi++)t.readUEG(),t.readUEG(),Xe&&(t.readUEG(),t.readUEG()),t.skipBits(1)}}t.readBoolean()&&(t.readBoolean(),t.readBoolean(),t.readBoolean(),J=t.readUEG())}let lt=N,je=K;if(p){let Pe=1,ze=1;w===1?Pe=ze=2:w==2&&(Pe=2),lt=N-Pe*F-Pe*$,je=K-ze*W-ze*O}const Qt=s?["A","B","C"][s]:"",ci=o<<24|c<<16|u<<8|h;let hi=0;for(let Pe=0;Pe<32;Pe++)hi=(hi|(ci>>Pe&1)<<31-Pe)>>>0;let Gi=hi.toString(16);return n===1&&Gi==="2"&&(Gi="6"),{codecString:`hvc1.${Qt}${n}.${Gi}.${r?"H":"L"}${x}.B0`,params:{general_tier_flag:r,general_profile_idc:n,general_profile_space:s,general_profile_compatibility_flags:[o,c,u,h],general_constraint_indicator_flags:[f,g,I,m,E,v],general_level_idc:x,bit_depth:ie+8,bit_depth_luma_minus8:ie,bit_depth_chroma_minus8:X,min_spatial_segmentation_idc:J,chroma_format_idc:w,frame_rate:{fixed:ke,fps:Le/Te}},width:lt,height:je,pixelRatio:[ee,ve]}}readPPS(e){const t=new is(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.skipUEG(),t.skipUEG(),t.skipBits(2),t.skipBits(3),t.skipBits(2),t.skipUEG(),t.skipUEG(),t.skipEG(),t.skipBits(2),t.readBoolean()&&t.skipUEG(),t.skipEG(),t.skipEG(),t.skipBits(4);const s=t.readBoolean(),r=t.readBoolean();let n=1;return r&&s?n=0:r?n=3:s&&(n=2),{parallelismType:n}}matchSPS(e,t){return String.fromCharCode.apply(null,e).substr(3)===String.fromCharCode.apply(null,t).substr(3)}}const tt=188;class ai{constructor(e,t,i,s){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=e,this.config=t,this.typeSupported=i,this.logger=s,this.videoParser=null}static probe(e,t){const i=ai.syncOffset(e);return i>0&&t.warn(`MPEG2-TS detected but first sync word found @ offset ${i}`),i!==-1}static syncOffset(e){const t=e.length;let i=Math.min(tt*5,t-tt)+1,s=0;for(;s<i;){let r=!1,n=-1,o=0;for(let c=s;c<t;c+=tt)if(e[c]===71&&(t-c===tt||e[c+tt]===71)){if(o++,n===-1&&(n=c,n!==0&&(i=Math.min(n+tt*99,e.length-tt)+1)),r||(r=zr(e,c)===0),r&&o>1&&(n===0&&o>2||c+tt>i))return n}else{if(o)return-1;break}s++}return-1}static createTrack(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:sa[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}}resetInitSegment(e,t,i,s){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=ai.createTrack("video"),this._videoTrack.duration=s,this._audioTrack=ai.createTrack("audio",s),this._id3Track=ai.createTrack("id3"),this._txtTrack=ai.createTrack("text"),this._audioTrack.segmentCodec="aac",this.videoParser=null,this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=i}resetTimeStamp(){}resetContiguity(){const{_audioTrack:e,_videoTrack:t,_id3Track:i}=this;e&&(e.pesData=null),t&&(t.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.remainderData=null}demux(e,t,i=!1,s=!1){i||(this.sampleAes=null);let r;const n=this._videoTrack,o=this._audioTrack,c=this._id3Track,u=this._txtTrack;let h=n.pid,f=n.pesData,g=o.pid,I=c.pid,m=o.pesData,E=c.pesData,v=null,x=this.pmtParsed,D=this._pmtId,L=e.length;if(this.remainderData&&(e=St(this.remainderData,e),L=e.length,this.remainderData=null),L<tt&&!s)return this.remainderData=e,{audioTrack:o,videoTrack:n,id3Track:c,textTrack:u};const w=Math.max(0,ai.syncOffset(e));L-=(L-w)%tt,L<e.byteLength&&!s&&(this.remainderData=new Uint8Array(e.buffer,L,e.buffer.byteLength-L));let N=0;for(let p=w;p<L;p+=tt)if(e[p]===71){const $=!!(e[p+1]&64),F=zr(e,p),O=(e[p+3]&48)>>4;let W;if(O>1){if(W=p+5+e[p+4],W===p+tt)continue}else W=p+4;switch(F){case h:$&&(f&&(r=Oi(f,this.logger))&&(this.readyVideoParser(n.segmentCodec),this.videoParser!==null&&this.videoParser.parsePES(n,u,r,!1)),f={data:[],size:0}),f&&(f.data.push(e.subarray(W,p+tt)),f.size+=p+tt-W);break;case g:if($){if(m&&(r=Oi(m,this.logger)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,r);break;case"mp3":this.parseMPEGPES(o,r);break;case"ac3":this.parseAC3PES(o,r);break}m={data:[],size:0}}m&&(m.data.push(e.subarray(W,p+tt)),m.size+=p+tt-W);break;case I:$&&(E&&(r=Oi(E,this.logger))&&this.parseID3PES(c,r),E={data:[],size:0}),E&&(E.data.push(e.subarray(W,p+tt)),E.size+=p+tt-W);break;case 0:$&&(W+=e[W]+1),D=this._pmtId=Uh(e,W);break;case D:{$&&(W+=e[W]+1);const ie=$h(e,W,this.typeSupported,i,this.observer,this.logger);h=ie.videoPid,h>0&&(n.pid=h,n.segmentCodec=ie.segmentVideoCodec),g=ie.audioPid,g>0&&(o.pid=g,o.segmentCodec=ie.segmentAudioCodec),I=ie.id3Pid,I>0&&(c.pid=I),v!==null&&!x&&(this.logger.warn(`MPEG-TS PMT found at ${p} after unknown PID '${v}'. Backtracking to sync byte @${w} to parse all TS packets.`),v=null,p=w-188),x=this.pmtParsed=!0;break}case 17:case 8191:break;default:v=F;break}}else N++;N>0&&qr(this.observer,new Error(`Found ${N} TS packet/s that do not start with 0x47`),void 0,this.logger),n.pesData=f,o.pesData=m,c.pesData=E;const K={audioTrack:o,videoTrack:n,id3Track:c,textTrack:u};return s&&this.extractRemainingSamples(K),K}flush(){const{remainderData:e}=this;this.remainderData=null;let 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}extractRemainingSamples(e){const{audioTrack:t,videoTrack:i,id3Track:s,textTrack:r}=e,n=i.pesData,o=t.pesData,c=s.pesData;let u;if(n&&(u=Oi(n,this.logger))?(this.readyVideoParser(i.segmentCodec),this.videoParser!==null&&(this.videoParser.parsePES(i,r,u,!0),i.pesData=null)):i.pesData=n,o&&(u=Oi(o,this.logger))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,u);break;case"mp3":this.parseMPEGPES(t,u);break;case"ac3":this.parseAC3PES(t,u);break}t.pesData=null}else o!=null&&o.size&&this.logger.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=o;c&&(u=Oi(c,this.logger))?(this.parseID3PES(s,u),s.pesData=null):s.pesData=c}demuxSampleAes(e,t,i){const s=this.demux(e,i,!0,!this.config.progressive),r=this.sampleAes=new Fh(this.observer,this.config,t);return this.decrypt(s,r)}readyVideoParser(e){this.videoParser===null&&(e==="avc"?this.videoParser=new Nh:e==="hevc"&&(this.videoParser=new Bh))}decrypt(e,t){return new Promise(i=>{const{audioTrack:s,videoTrack:r}=e;s.samples&&s.segmentCodec==="aac"?t.decryptAacSamples(s.samples,0,()=>{r.samples?t.decryptAvcSamples(r.samples,0,0,()=>{i(e)}):i(e)}):r.samples&&t.decryptAvcSamples(r.samples,0,0,()=>{i(e)})})}destroy(){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}parseAACPES(e,t){let i=0;const s=this.aacOverFlow;let r=t.data;if(s){this.aacOverFlow=null;const f=s.missing,g=s.sample.unit.byteLength;if(f===-1)r=St(s.sample.unit,r);else{const I=g-f;s.sample.unit.set(r.subarray(0,f),I),e.samples.push(s.sample),i=s.missing}}let n,o;for(n=i,o=r.length;n<o-1&&!Fs(r,n);n++);if(n!==i){let f;const g=n<o-1;if(g?f=`AAC PES did not start with ADTS header,offset:${n}`:f="No ADTS header found in AAC PES",qr(this.observer,new Error(f),g,this.logger),!g)return}Co(e,this.observer,r,n,this.audioCodec);let c;if(t.pts!==void 0)c=t.pts;else if(s){const f=yo(e.samplerate);c=s.sample.pts+f}else{this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}let u=0,h;for(;n<o;)if(h=Eo(e,r,n,c,u),n+=h.length,h.missing){this.aacOverFlow=h;break}else for(u++;n<o-1&&!Fs(r,n);n++);}parseMPEGPES(e,t){const i=t.data,s=i.length;let r=0,n=0;const o=t.pts;if(o===void 0){this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;n<s;)if(bo(i,n)){const c=So(e,i,n,o,r);if(c)n+=c.length,r++;else break}else n++}parseAC3PES(e,t){{const i=t.data,s=t.pts;if(s===void 0){this.logger.warn("[tsdemuxer]: AC3 PES unknown PTS");return}const r=i.length;let n=0,o=0,c;for(;o<r&&(c=Do(e,i,o,s,n++))>0;)o+=c}}parseID3PES(e,t){if(t.pts===void 0){this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}const i=Ne({},t,{type:this._videoTrack?yt.emsg:yt.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(i)}}function zr(a,e){return((a[e+1]&31)<<8)+a[e+2]}function Uh(a,e){return(a[e+10]&31)<<8|a[e+11]}function $h(a,e,t,i,s,r){const n={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},o=(a[e+1]&15)<<8|a[e+2],c=e+3+o-4,u=(a[e+10]&15)<<8|a[e+11];for(e+=12+u;e<c;){const h=zr(a,e),f=(a[e+3]&15)<<8|a[e+4];switch(a[e]){case 207:if(!i){Xr("ADTS AAC",r);break}case 15:n.audioPid===-1&&(n.audioPid=h);break;case 21:n.id3Pid===-1&&(n.id3Pid=h);break;case 219:if(!i){Xr("H.264",r);break}case 27:n.videoPid===-1&&(n.videoPid=h);break;case 3:case 4:!t.mpeg&&!t.mp3?r.log("MPEG audio found, not supported in this browser"):n.audioPid===-1&&(n.audioPid=h,n.segmentAudioCodec="mp3");break;case 193:if(!i){Xr("AC-3",r);break}case 129:t.ac3?n.audioPid===-1&&(n.audioPid=h,n.segmentAudioCodec="ac3"):r.log("AC-3 audio found, not supported in this browser");break;case 6:if(n.audioPid===-1&&f>0){let g=e+5,I=f;for(;I>2;){switch(a[g]){case 106:t.ac3!==!0?r.log("AC-3 audio found, not supported in this browser for now"):(n.audioPid=h,n.segmentAudioCodec="ac3");break}const E=a[g+1]+2;g+=E,I-=E}}break;case 194:case 135:return qr(s,new Error("Unsupported EC-3 in M2TS found"),void 0,r),n;case 36:n.videoPid===-1&&(n.videoPid=h,n.segmentVideoCodec="hevc",r.log("HEVC in M2TS found"));break}e+=f+5}return n}function qr(a,e,t,i){i.warn(`parsing error: ${e.message}`),a.emit(y.ERROR,y.ERROR,{type:de.MEDIA_ERROR,details:U.FRAG_PARSING_ERROR,fatal:!1,levelRetry:t,error:e,reason:e.message})}function Xr(a,e){e.log(`${a} with AES-128-CBC encryption found in unencrypted stream`)}function Oi(a,e){let t=0,i,s,r,n,o;const c=a.data;if(!a||a.size===0)return null;for(;c[0].length<19&&c.length>1;)c[0]=St(c[0],c[1]),c.splice(1,1);if(i=c[0],(i[0]<<16)+(i[1]<<8)+i[2]===1){if(s=(i[4]<<8)+i[5],s&&s>a.size-6)return null;const h=i[7];h&192&&(n=(i[9]&14)*536870912+(i[10]&255)*4194304+(i[11]&254)*16384+(i[12]&255)*128+(i[13]&254)/2,h&64?(o=(i[14]&14)*536870912+(i[15]&255)*4194304+(i[16]&254)*16384+(i[17]&255)*128+(i[18]&254)/2,n-o>60*9e4&&(e.warn(`${Math.round((n-o)/9e4)}s delta between PTS and DTS, align them`),n=o)):o=n),r=i[8];let f=r+9;if(a.size<=f)return null;a.size-=f;const g=new Uint8Array(a.size);for(let I=0,m=c.length;I<m;I++){i=c[I];let E=i.byteLength;if(f)if(f>E){f-=E;continue}else i=i.subarray(f),E-=f,f=0;g.set(i,t),t+=E}return s&&(s-=r+3),{data:g,pts:n,dts:o,len:s}}return null}class Gh{static getSilentFrame(e,t){switch(e){case"mp4a.40.2":if(t===1)return new Uint8Array([0,200,0,128,35,128]);if(t===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(t===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(t===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(t===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(t===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(t===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(t===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(t===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}}}const oi=Math.pow(2,32)-1;class B{static init(){B.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:[]};let e;for(e in B.types)B.types.hasOwnProperty(e)&&(B.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);const t=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),i=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);B.HDLR_TYPES={video:t,audio:i};const s=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),r=new Uint8Array([0,0,0,0,0,0,0,0]);B.STTS=B.STSC=B.STCO=r,B.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),B.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),B.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),B.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const n=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),c=new Uint8Array([0,0,0,1]);B.FTYP=B.box(B.types.ftyp,n,c,n,o),B.DINF=B.box(B.types.dinf,B.box(B.types.dref,s))}static box(e,...t){let i=8,s=t.length;const r=s;for(;s--;)i+=t[s].byteLength;const n=new Uint8Array(i);for(n[0]=i>>24&255,n[1]=i>>16&255,n[2]=i>>8&255,n[3]=i&255,n.set(e,4),s=0,i=8;s<r;s++)n.set(t[s],i),i+=t[s].byteLength;return n}static hdlr(e){return B.box(B.types.hdlr,B.HDLR_TYPES[e])}static mdat(e){return B.box(B.types.mdat,e)}static mdhd(e,t){t*=e;const i=Math.floor(t/(oi+1)),s=Math.floor(t%(oi+1));return B.box(B.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,i>>24,i>>16&255,i>>8&255,i&255,s>>24,s>>16&255,s>>8&255,s&255,85,196,0,0]))}static mdia(e){return B.box(B.types.mdia,B.mdhd(e.timescale||0,e.duration||0),B.hdlr(e.type),B.minf(e))}static mfhd(e){return B.box(B.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255]))}static minf(e){return e.type==="audio"?B.box(B.types.minf,B.box(B.types.smhd,B.SMHD),B.DINF,B.stbl(e)):B.box(B.types.minf,B.box(B.types.vmhd,B.VMHD),B.DINF,B.stbl(e))}static moof(e,t,i){return B.box(B.types.moof,B.mfhd(e),B.traf(i,t))}static moov(e){let t=e.length;const i=[];for(;t--;)i[t]=B.trak(e[t]);return B.box.apply(null,[B.types.moov,B.mvhd(e[0].timescale||0,e[0].duration||0)].concat(i).concat(B.mvex(e)))}static mvex(e){let t=e.length;const i=[];for(;t--;)i[t]=B.trex(e[t]);return B.box.apply(null,[B.types.mvex,...i])}static mvhd(e,t){t*=e;const i=Math.floor(t/(oi+1)),s=Math.floor(t%(oi+1)),r=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,i>>24,i>>16&255,i>>8&255,i&255,s>>24,s>>16&255,s>>8&255,s&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 B.box(B.types.mvhd,r)}static sdtp(e){const t=e.samples||[],i=new Uint8Array(4+t.length);let s,r;for(s=0;s<t.length;s++)r=t[s].flags,i[s+4]=r.dependsOn<<4|r.isDependedOn<<2|r.hasRedundancy;return B.box(B.types.sdtp,i)}static stbl(e){return B.box(B.types.stbl,B.stsd(e),B.box(B.types.stts,B.STTS),B.box(B.types.stsc,B.STSC),B.box(B.types.stsz,B.STSZ),B.box(B.types.stco,B.STCO))}static avc1(e){let t=[],i=[],s,r,n;for(s=0;s<e.sps.length;s++)r=e.sps[s],n=r.byteLength,t.push(n>>>8&255),t.push(n&255),t=t.concat(Array.prototype.slice.call(r));for(s=0;s<e.pps.length;s++)r=e.pps[s],n=r.byteLength,i.push(n>>>8&255),i.push(n&255),i=i.concat(Array.prototype.slice.call(r));const o=B.box(B.types.avcC,new Uint8Array([1,t[3],t[4],t[5],255,224|e.sps.length].concat(t).concat([e.pps.length]).concat(i))),c=e.width,u=e.height,h=e.pixelRatio[0],f=e.pixelRatio[1];return B.box(B.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,c>>8&255,c&255,u>>8&255,u&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]),o,B.box(B.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),B.box(B.types.pasp,new Uint8Array([h>>24,h>>16&255,h>>8&255,h&255,f>>24,f>>16&255,f>>8&255,f&255])))}static esds(e){const t=e.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,...t,6,1,2])}static audioStsd(e){const t=e.samplerate||0;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount||0,0,16,0,0,0,0,t>>8&255,t&255,0,0])}static mp4a(e){return B.box(B.types.mp4a,B.audioStsd(e),B.box(B.types.esds,B.esds(e)))}static mp3(e){return B.box(B.types[".mp3"],B.audioStsd(e))}static ac3(e){return B.box(B.types["ac-3"],B.audioStsd(e),B.box(B.types.dac3,e.config))}static stsd(e){const{segmentCodec:t}=e;if(e.type==="audio"){if(t==="aac")return B.box(B.types.stsd,B.STSD,B.mp4a(e));if(t==="ac3"&&e.config)return B.box(B.types.stsd,B.STSD,B.ac3(e));if(t==="mp3"&&e.codec==="mp3")return B.box(B.types.stsd,B.STSD,B.mp3(e))}else if(e.pps&&e.sps){if(t==="avc")return B.box(B.types.stsd,B.STSD,B.avc1(e));if(t==="hevc"&&e.vps)return B.box(B.types.stsd,B.STSD,B.hvc1(e))}else throw new Error("video track missing pps or sps");throw new Error(`unsupported ${e.type} segment codec (${t}/${e.codec})`)}static tkhd(e){const t=e.id,i=(e.duration||0)*(e.timescale||0),s=e.width||0,r=e.height||0,n=Math.floor(i/(oi+1)),o=Math.floor(i%(oi+1));return B.box(B.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,t&255,0,0,0,0,n>>24,n>>16&255,n>>8&255,n&255,o>>24,o>>16&255,o>>8&255,o&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,s>>8&255,s&255,0,0,r>>8&255,r&255,0,0]))}static traf(e,t){const i=B.sdtp(e),s=e.id,r=Math.floor(t/(oi+1)),n=Math.floor(t%(oi+1));return B.box(B.types.traf,B.box(B.types.tfhd,new Uint8Array([0,0,0,0,s>>24,s>>16&255,s>>8&255,s&255])),B.box(B.types.tfdt,new Uint8Array([1,0,0,0,r>>24,r>>16&255,r>>8&255,r&255,n>>24,n>>16&255,n>>8&255,n&255])),B.trun(e,i.length+16+20+8+16+8+8),i)}static trak(e){return e.duration=e.duration||4294967295,B.box(B.types.trak,B.tkhd(e),B.mdia(e))}static trex(e){const t=e.id;return B.box(B.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){const i=e.samples||[],s=i.length,r=12+16*s,n=new Uint8Array(r);let o,c,u,h,f,g;for(t+=8+r,n.set([e.type==="video"?1:0,0,15,1,s>>>24&255,s>>>16&255,s>>>8&255,s&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255],0),o=0;o<s;o++)c=i[o],u=c.duration,h=c.size,f=c.flags,g=c.cts,n.set([u>>>24&255,u>>>16&255,u>>>8&255,u&255,h>>>24&255,h>>>16&255,h>>>8&255,h&255,f.isLeading<<2|f.dependsOn,f.isDependedOn<<6|f.hasRedundancy<<4|f.paddingValue<<1|f.isNonSync,f.degradPrio&61440,f.degradPrio&15,g>>>24&255,g>>>16&255,g>>>8&255,g&255],12+16*o);return B.box(B.types.trun,n)}static initSegment(e){B.types||B.init();const t=B.moov(e);return St(B.FTYP,t)}static hvc1(e){const t=e.params,i=[e.vps,e.sps,e.pps],s=4,r=new Uint8Array([1,t.general_profile_space<<6|(t.general_tier_flag?32:0)|t.general_profile_idc,t.general_profile_compatibility_flags[0],t.general_profile_compatibility_flags[1],t.general_profile_compatibility_flags[2],t.general_profile_compatibility_flags[3],t.general_constraint_indicator_flags[0],t.general_constraint_indicator_flags[1],t.general_constraint_indicator_flags[2],t.general_constraint_indicator_flags[3],t.general_constraint_indicator_flags[4],t.general_constraint_indicator_flags[5],t.general_level_idc,240|t.min_spatial_segmentation_idc>>8,255&t.min_spatial_segmentation_idc,252|t.parallelismType,252|t.chroma_format_idc,248|t.bit_depth_luma_minus8,248|t.bit_depth_chroma_minus8,0,parseInt(t.frame_rate.fps),s-1|t.temporal_id_nested<<2|t.num_temporal_layers<<3|(t.frame_rate.fixed?64:0),i.length]);let n=r.length;for(let m=0;m<i.length;m+=1){n+=3;for(let E=0;E<i[m].length;E+=1)n+=2+i[m][E].length}const o=new Uint8Array(n);o.set(r,0),n=r.length;const c=i.length-1;for(let m=0;m<i.length;m+=1){o.set(new Uint8Array([32+m|(m===c?128:0),0,i[m].length]),n),n+=3;for(let E=0;E<i[m].length;E+=1)o.set(new Uint8Array([i[m][E].length>>8,i[m][E].length&255]),n),n+=2,o.set(i[m][E],n),n+=i[m][E].length}const u=B.box(B.types.hvcC,o),h=e.width,f=e.height,g=e.pixelRatio[0],I=e.pixelRatio[1];return B.box(B.types.hvc1,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,h>>8&255,h&255,f>>8&255,f&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]),u,B.box(B.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),B.box(B.types.pasp,new Uint8Array([g>>24,g>>16&255,g>>8&255,g&255,I>>24,I>>16&255,I>>8&255,I&255])))}}B.types=void 0,B.HDLR_TYPES=void 0,B.STTS=void 0,B.STSC=void 0,B.STCO=void 0,B.STSZ=void 0,B.VMHD=void 0,B.SMHD=void 0,B.STSD=void 0,B.FTYP=void 0,B.DINF=void 0;const wo=9e4;function Zr(a,e,t=1,i=!1){const s=a*e*t;return i?Math.round(s):s}function Hh(a,e,t=1,i=!1){return Zr(a,e,1/t,i)}function ss(a,e=!1){return Zr(a,1e3,1/wo,e)}function Vh(a,e=1){return Zr(a,wo,1/e)}const Kh=10*1e3,Yh=1024,Wh=1152,jh=1536;let Fi=null,Qr=null;function ko(a,e,t,i){return{duration:e,size:t,cts:i,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:a?2:1,isNonSync:a?0:1}}}class Us extends Tt{constructor(e,t,i,s){if(super("mp4-remuxer",s),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextVideoTs=null,this.nextAudioTs=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=e,this.config=t,this.typeSupported=i,this.ISGenerated=!1,Fi===null){const n=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Fi=n?parseInt(n[1]):0}if(Qr===null){const r=navigator.userAgent.match(/Safari\/(\d+)/i);Qr=r?parseInt(r[1]):0}}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}resetTimeStamp(e){this.log("initPTS & initDTS reset"),this._initPTS=this._initDTS=e}resetNextTimestamp(){this.log("reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){this.log("ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}getVideoStartPts(e){let t=!1;const i=e[0].pts,s=e.reduce((r,n)=>{let o=n.pts,c=o-r;return c<-4294967296&&(t=!0,o=xt(o,i),c=o-r),c>0?r:o},i);return t&&this.debug("PTS rollover detected"),s}remux(e,t,i,s,r,n,o,c){let u,h,f,g,I,m,E=r,v=r;const x=e.pid>-1,D=t.pid>-1,L=t.samples.length,w=e.samples.length>0,N=o&&L>0||L>1;if((!x||w)&&(!D||N)||this.ISGenerated||o){if(this.ISGenerated){var p,$,F,O;const ce=this.videoTrackConfig;(ce&&(t.width!==ce.width||t.height!==ce.height||((p=t.pixelRatio)==null?void 0:p[0])!==(($=ce.pixelRatio)==null?void 0:$[0])||((F=t.pixelRatio)==null?void 0:F[1])!==((O=ce.pixelRatio)==null?void 0:O[1]))||!ce&&N||this.nextAudioTs===null&&w)&&this.resetInitSegment()}this.ISGenerated||(f=this.generateIS(e,t,r,n));const W=this.isVideoContiguous;let ie=-1,X;if(N&&(ie=zh(t.samples),!W&&this.config.forceKeyFrameOnDiscontinuity))if(m=!0,ie>0){this.warn(`Dropped ${ie} out of ${L} video samples due to a missing keyframe`);const ce=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(ie),t.dropped+=ie,v+=(t.samples[0].pts-ce)/t.inputTimeScale,X=v}else ie===-1&&(this.warn(`No keyframe found out of ${L} video samples`),m=!1);if(this.ISGenerated){if(w&&N){const ce=this.getVideoStartPts(t.samples),Q=(xt(e.samples[0].pts,ce)-ce)/t.inputTimeScale;E+=Math.max(0,Q),v+=Math.max(0,-Q)}if(w){if(e.samplerate||(this.warn("regenerate InitSegment as audio detected"),f=this.generateIS(e,t,r,n)),h=this.remuxAudio(e,E,this.isAudioContiguous,n,D||N||c===he.AUDIO?v:void 0),N){const ce=h?h.endPTS-h.startPTS:0;t.inputTimeScale||(this.warn("regenerate InitSegment as video detected"),f=this.generateIS(e,t,r,n)),u=this.remuxVideo(t,v,W,ce)}}else N&&(u=this.remuxVideo(t,v,W,0));u&&(u.firstKeyFrame=ie,u.independent=ie!==-1,u.firstKeyFramePTS=X)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(I=Mo(i,r,this._initPTS,this._initDTS)),s.samples.length&&(g=Oo(s,r,this._initPTS))),{audio:h,video:u,initSegment:f,independent:m,text:g,id3:I}}generateIS(e,t,i,s){const r=e.samples,n=t.samples,o=this.typeSupported,c={},u=this._initPTS;let h=!u||s,f="audio/mp4",g,I,m,E=-1;if(h&&(g=I=1/0),e.config&&r.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":o.mpeg?(f="audio/mpeg",e.codec=""):o.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3";break}c.audio={id:"audio",container:f,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&o.mpeg?new Uint8Array(0):B.initSegment([e]),metadata:{channelCount:e.channelCount}},h&&(E=e.id,m=e.inputTimeScale,!u||m!==u.timescale?g=I=r[0].pts-Math.round(m*i):h=!1)}if(t.sps&&t.pps&&n.length){if(t.timescale=t.inputTimeScale,c.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:B.initSegment([t]),metadata:{width:t.width,height:t.height}},h)if(E=t.id,m=t.inputTimeScale,!u||m!==u.timescale){const v=this.getVideoStartPts(n),x=Math.round(m*i);I=Math.min(I,xt(n[0].dts,v)-x),g=Math.min(g,v-x)}else h=!1;this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(c).length)return this.ISGenerated=!0,h?(u&&this.warn(`Timestamps at playlist time: ${s?"":"~"}${i} ${g/m} != initPTS: ${u.baseTime/u.timescale} (${u.baseTime}/${u.timescale}) trackId: ${u.trackId}`),this.log(`Found initPTS at playlist time: ${i} offset: ${g/m} (${g}/${m}) trackId: ${E}`),this._initPTS={baseTime:g,timescale:m,trackId:E},this._initDTS={baseTime:I,timescale:m,trackId:E}):g=m=void 0,{tracks:c,initPTS:g,timescale:m,trackId:E}}remuxVideo(e,t,i,s){const r=e.inputTimeScale,n=e.samples,o=[],c=n.length,u=this._initPTS,h=u.baseTime*r/u.timescale;let f=this.nextVideoTs,g=8,I=this.videoSampleDuration,m,E,v=Number.POSITIVE_INFINITY,x=Number.NEGATIVE_INFINITY,D=!1;if(!i||f===null){const J=h+t*r,ee=n[0].pts-xt(n[0].dts,n[0].pts);Fi&&f!==null&&Math.abs(J-ee-(f+h))<15e3?i=!0:f=J-ee-h}const L=f+h;for(let J=0;J<c;J++){const ee=n[J];ee.pts=xt(ee.pts,L),ee.dts=xt(ee.dts,L),ee.dts<n[J>0?J-1:J].dts&&(D=!0)}D&&n.sort(function(J,ee){const ve=J.dts-ee.dts,ke=J.pts-ee.pts;return ve||ke}),m=n[0].dts,E=n[n.length-1].dts;const w=E-m,N=w?Math.round(w/(c-1)):I||e.inputTimeScale/30;if(i){const J=m-L,ee=J>N,ve=J<-1;if((ee||ve)&&(ee?this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${ss(J,!0)} ms (${J}dts) hole between fragments detected at ${t.toFixed(3)}`):this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${ss(-J,!0)} ms (${J}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!ve||L>=n[0].pts||Fi)){m=L;const ke=n[0].pts-J;if(ee)n[0].dts=m,n[0].pts=ke;else{let Te=!0;for(let Le=0;Le<n.length&&!(n[Le].dts>ke&&Te);Le++){const it=n[Le].pts;if(n[Le].dts-=J,n[Le].pts-=J,Le<n.length-1){const Je=n[Le+1].pts,lt=n[Le].pts,je=Je<=lt,Qt=Je<=it;Te=je==Qt}}}this.log(`Video: Initial PTS/DTS adjusted: ${ss(ke,!0)}/${ss(m,!0)}, delta: ${ss(J,!0)} ms`)}}m=Math.max(0,m);let K=0,p=0,$=m;for(let J=0;J<c;J++){const ee=n[J],ve=ee.units,ke=ve.length;let Te=0;for(let Le=0;Le<ke;Le++)Te+=ve[Le].data.length;p+=Te,K+=ke,ee.length=Te,ee.dts<$?(ee.dts=$,$+=N/4|0||1):$=ee.dts,v=Math.min(ee.pts,v),x=Math.max(ee.pts,x)}E=n[c-1].dts;const F=p+4*K+8;let O;try{O=new Uint8Array(F)}catch(J){this.observer.emit(y.ERROR,y.ERROR,{type:de.MUX_ERROR,details:U.REMUX_ALLOC_ERROR,fatal:!1,error:J,bytes:F,reason:`fail allocating video mdat ${F}`});return}const W=new DataView(O.buffer);W.setUint32(0,F),O.set(B.types.mdat,4);let ie=!1,X=Number.POSITIVE_INFINITY,ce=Number.POSITIVE_INFINITY,ue=Number.NEGATIVE_INFINITY,Q=Number.NEGATIVE_INFINITY;for(let J=0;J<c;J++){const ee=n[J],ve=ee.units;let ke=0;for(let it=0,Je=ve.length;it<Je;it++){const lt=ve[it],je=lt.data,Qt=lt.data.byteLength;W.setUint32(g,Qt),g+=4,O.set(je,g),g+=Qt,ke+=4+Qt}let Te;if(J<c-1)I=n[J+1].dts-ee.dts,Te=n[J+1].pts-ee.pts;else{const it=this.config,Je=J>0?ee.dts-n[J-1].dts:N;if(Te=J>0?ee.pts-n[J-1].pts:N,it.stretchShortVideoTrack&&this.nextAudioTs!==null){const lt=Math.floor(it.maxBufferHole*r),je=(s?v+s*r:this.nextAudioTs+h)-ee.pts;je>lt?(I=je-Je,I<0?I=Je:ie=!0,this.log(`It is approximately ${je/90} ms to the next segment; using duration ${I/90} ms for the last video frame.`)):I=Je}else I=Je}const Le=Math.round(ee.pts-ee.dts);X=Math.min(X,I),ue=Math.max(ue,I),ce=Math.min(ce,Te),Q=Math.max(Q,Te),o.push(ko(ee.key,I,ke,Le))}if(o.length){if(Fi){if(Fi<70){const J=o[0].flags;J.dependsOn=2,J.isNonSync=0}}else if(Qr&&Q-ce<ue-X&&N/ue<.025&&o[0].cts===0){this.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let J=m;for(let ee=0,ve=o.length;ee<ve;ee++){const ke=J+o[ee].duration,Te=J+o[ee].cts;if(ee<ve-1){const Le=ke+o[ee+1].cts;o[ee].duration=Le-Te}else o[ee].duration=ee?o[ee-1].duration:N;o[ee].cts=0,J=ke}}}I=ie||!I?N:I;const ne=E+I;this.nextVideoTs=f=ne-h,this.videoSampleDuration=I,this.isVideoContiguous=!0;const pe={data1:B.moof(e.sequenceNumber++,m,Ne(e,{samples:o})),data2:O,startPTS:(v-h)/r,endPTS:(x+I-h)/r,startDTS:(m-h)/r,endDTS:f/r,type:"video",hasAudio:!1,hasVideo:!0,nb:o.length,dropped:e.dropped};return e.samples=[],e.dropped=0,pe}getSamplesPerFrame(e){switch(e.segmentCodec){case"mp3":return Wh;case"ac3":return jh;default:return Yh}}remuxAudio(e,t,i,s,r){const n=e.inputTimeScale,o=e.samplerate?e.samplerate:n,c=n/o,u=this.getSamplesPerFrame(e),h=u*c,f=this._initPTS,g=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,I=[],m=r!==void 0;let E=e.samples,v=g?0:8,x=this.nextAudioTs||-1;const D=f.baseTime*n/f.timescale,L=D+t*n;if(this.isAudioContiguous=i=i||E.length&&x>0&&(s&&Math.abs(L-(x+D))<9e3||Math.abs(xt(E[0].pts,L)-(x+D))<20*h),E.forEach(function(Q){Q.pts=xt(Q.pts,L)}),!i||x<0){if(E=E.filter(Q=>Q.pts>=0),!E.length)return;r===0?x=0:s&&!m?x=Math.max(0,L-D):x=E[0].pts-D}if(e.segmentCodec==="aac"){const Q=this.config.maxAudioFramesDrift;for(let ne=0,re=x+D;ne<E.length;ne++){const le=E[ne],pe=le.pts,J=pe-re,ee=Math.abs(1e3*J/n);if(J<=-Q*h&&m)ne===0&&(this.warn(`Audio frame @ ${(pe/n).toFixed(3)}s overlaps marker by ${Math.round(1e3*J/n)} ms.`),this.nextAudioTs=x=pe-D,re=pe);else if(J>=Q*h&&ee<Kh&&m){let ve=Math.round(J/h);for(re=pe-ve*h;re<0&&ve&&h;)ve--,re+=h;ne===0&&(this.nextAudioTs=x=re-D),this.warn(`Injecting ${ve} audio frames @ ${((re-D)/n).toFixed(3)}s due to ${Math.round(1e3*J/n)} ms gap.`);for(let ke=0;ke<ve;ke++){let Te=Gh.getSilentFrame(e.parsedCodec||e.manifestCodec||e.codec,e.channelCount);Te||(this.log("Unable to get silent frame for given audio codec; duplicating last frame instead."),Te=le.unit.subarray()),E.splice(ne,0,{unit:Te,pts:re}),re+=h,ne++}}le.pts=re,re+=h}}let w=null,N=null,K,p=0,$=E.length;for(;$--;)p+=E[$].unit.byteLength;for(let Q=0,ne=E.length;Q<ne;Q++){const re=E[Q],le=re.unit;let pe=re.pts;if(N!==null){const ee=I[Q-1];ee.duration=Math.round((pe-N)/c)}else if(i&&e.segmentCodec==="aac"&&(pe=x+D),w=pe,p>0){p+=v;try{K=new Uint8Array(p)}catch(ee){this.observer.emit(y.ERROR,y.ERROR,{type:de.MUX_ERROR,details:U.REMUX_ALLOC_ERROR,fatal:!1,error:ee,bytes:p,reason:`fail allocating audio mdat ${p}`});return}g||(new DataView(K.buffer).setUint32(0,p),K.set(B.types.mdat,4))}else return;K.set(le,v);const J=le.byteLength;v+=J,I.push(ko(!0,u,J,0)),N=pe}const F=I.length;if(!F)return;const O=I[I.length-1];x=N-D,this.nextAudioTs=x+c*O.duration;const W=g?new Uint8Array(0):B.moof(e.sequenceNumber++,w/c,Ne({},e,{samples:I}));e.samples=[];const ie=(w-D)/n,X=x/n,ue={data1:W,data2:K,startPTS:ie,endPTS:X,startDTS:ie,endDTS:X,type:"audio",hasAudio:!0,hasVideo:!1,nb:F};return this.isAudioContiguous=!0,ue}}function xt(a,e){let t;if(e===null)return a;for(e<a?t=-8589934592:t=8589934592;Math.abs(a-e)>4294967296;)a+=t;return a}function zh(a){for(let e=0;e<a.length;e++)if(a[e].key)return e;return-1}function Mo(a,e,t,i){const s=a.samples.length;if(!s)return;const r=a.inputTimeScale;for(let o=0;o<s;o++){const c=a.samples[o];c.pts=xt(c.pts-t.baseTime*r/t.timescale,e*r)/r,c.dts=xt(c.dts-i.baseTime*r/i.timescale,e*r)/r}const n=a.samples;return a.samples=[],{samples:n}}function Oo(a,e,t){const i=a.samples.length;if(!i)return;const s=a.inputTimeScale;for(let n=0;n<i;n++){const o=a.samples[n];o.pts=xt(o.pts-t.baseTime*s/t.timescale,e*s)/s}a.samples.sort((n,o)=>n.pts-o.pts);const r=a.samples;return a.samples=[],{samples:r}}class qh extends Tt{constructor(e,t,i,s){super("passthrough-remuxer",s),this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null,this.isVideoContiguous=!1}destroy(){}resetTimeStamp(e){this.lastEndTime=null;const t=this.initPTS;t&&e&&t.baseTime===e.baseTime&&t.timescale===e.timescale||(this.initPTS=e)}resetNextTimestamp(){this.isVideoContiguous=!1,this.lastEndTime=null}resetInitSegment(e,t,i,s){this.audioCodec=t,this.videoCodec=i,this.generateInitSegment(e,s),this.emitInitSegment=!0}generateInitSegment(e,t){let{audioCodec:i,videoCodec:s}=this;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}const{audio:r,video:n}=this.initData=oa(e);if(t)Nu(e,t);else{const c=r||n;c!=null&&c.encrypted&&this.warn(`Init segment with encrypted track with has no key ("${c.codec}")!`)}r&&(i=Fo(r,Ue.AUDIO,this)),n&&(s=Fo(n,Ue.VIDEO,this));const o={};r&&n?o.audiovideo={container:"video/mp4",codec:i+","+s,supplemental:n.supplemental,encrypted:n.encrypted,initSegment:e,id:"main"}:r?o.audio={container:"audio/mp4",codec:i,encrypted:r.encrypted,initSegment:e,id:"audio"}:n?o.video={container:"video/mp4",codec:s,supplemental:n.supplemental,encrypted:n.encrypted,initSegment:e,id:"main"}:this.warn("initSegment does not contain moov or trak boxes."),this.initTracks=o}remux(e,t,i,s,r,n){var o,c;let{initPTS:u,lastEndTime:h}=this;const f={audio:void 0,video:void 0,text:s,id3:i,initSegment:void 0};se(h)||(h=this.lastEndTime=r||0);const g=t.samples;if(!g.length)return f;const I={initPTS:void 0,timescale:void 0,trackId:void 0};let m=this.initData;if((o=m)!=null&&o.length||(this.generateInitSegment(g),m=this.initData),!((c=m)!=null&&c.length))return this.warn("Failed to generate initSegment."),f;this.emitInitSegment&&(I.tracks=this.initTracks,this.emitInitSegment=!1);const E=Bu(g,m,this),v=m.audio?E[m.audio.id]:null,x=m.video?E[m.video.id]:null,D=$s(x,1/0),L=$s(v,1/0),w=$s(x,0,!0),N=$s(v,0,!0);let K=r,p=0;const $=v&&(!x||!u&&L<D||u&&u.trackId===m.audio.id),F=$?v:x;if(F){const re=F.timescale,le=F.start-r*re,pe=$?m.audio.id:m.video.id;K=F.start/re,p=$?N-L:w-D,(n||!u)&&(Xh(u,K,r,p)||re!==u.timescale)&&(u&&this.warn(`Timestamps at playlist time: ${n?"":"~"}${r} ${le/re} != initPTS: ${u.baseTime/u.timescale} (${u.baseTime}/${u.timescale}) trackId: ${u.trackId}`),this.log(`Found initPTS at playlist time: ${r} offset: ${K-r} (${le}/${re}) trackId: ${pe}`),u=null,I.initPTS=le,I.timescale=re,I.trackId=pe)}else this.warn(`No audio or video samples found for initPTS at playlist time: ${r}`);u?(I.initPTS=u.baseTime,I.timescale=u.timescale,I.trackId=u.trackId):((!I.timescale||I.trackId===void 0||I.initPTS===void 0)&&(this.warn("Could not set initPTS"),I.initPTS=K,I.timescale=1,I.trackId=-1),this.initPTS=u={baseTime:I.initPTS,timescale:I.timescale,trackId:I.trackId});const O=K-u.baseTime/u.timescale,W=O+p;p>0?this.lastEndTime=W:(this.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const ie=!!m.audio,X=!!m.video;let ce="";ie&&(ce+="audio"),X&&(ce+="video");const ue=(m.audio?m.audio.encrypted:!1)||(m.video?m.video.encrypted:!1),Q={data1:g,startPTS:O,startDTS:O,endPTS:W,endDTS:W,type:ce,hasAudio:ie,hasVideo:X,nb:1,dropped:0,encrypted:ue};f.audio=ie&&!X?Q:void 0,f.video=X?Q:void 0;const ne=x?.sampleCount;if(ne){const re=x.keyFrameIndex,le=re!==-1;Q.nb=ne,Q.dropped=re===0||this.isVideoContiguous?0:le?re:ne,Q.independent=le,Q.firstKeyFrame=re,le&&x.keyFrameStart&&(Q.firstKeyFramePTS=(x.keyFrameStart-u.baseTime)/u.timescale),this.isVideoContiguous||(f.independent=le),this.isVideoContiguous||(this.isVideoContiguous=le),Q.dropped&&this.warn(`fmp4 does not start with IDR: firstIDR ${re}/${ne} dropped: ${Q.dropped} start: ${Q.firstKeyFramePTS||"NA"}`)}return f.initSegment=I,f.id3=Mo(i,r,u,u),s.samples.length&&(f.text=Oo(s,r,u)),f}}function $s(a,e,t=!1){return a?.start!==void 0?(a.start+(t?a.duration:0))/a.timescale:e}function Xh(a,e,t,i){if(a===null)return!0;const s=Math.max(i,1),r=e-a.baseTime/a.timescale;return Math.abs(r-t)>s}function Fo(a,e,t){const i=a.codec;return i&&i.length>4?i:e===Ue.AUDIO?i==="ec-3"||i==="ac-3"||i==="alac"?i:i==="fLaC"||i==="Opus"?Es(i,!1):(t.warn(`Unhandled audio codec "${i}" in mp4 MAP`),i||"mp4a"):(t.warn(`Unhandled video codec "${i}" in mp4 MAP`),i||"avc1")}let Xt;try{Xt=self.performance.now.bind(self.performance)}catch{Xt=Date.now}const Gs=[{demux:Oh,remux:qh},{demux:ai,remux:Us},{demux:_h,remux:Us},{demux:kh,remux:Us}];Gs.splice(2,0,{demux:wh,remux:Us});class No{constructor(e,t,i,s,r,n){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=e,this.typeSupported=t,this.config=i,this.id=r,this.logger=n}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,i,s){const r=i.transmuxing;r.executeStart=Xt();let n=new Uint8Array(e);const{currentTransmuxState:o,transmuxConfig:c}=this;s&&(this.currentTransmuxState=s);const{contiguous:u,discontinuity:h,trackSwitch:f,accurateTimeOffset:g,timeOffset:I,initSegmentChange:m}=s||o,{audioCodec:E,videoCodec:v,defaultInitPts:x,duration:D,initSegmentData:L}=c,w=Zh(n,t);if(w&&ki(w.method)){const $=this.getDecrypter(),F=_r(w.method);if($.isSync()){let O=$.softwareDecrypt(n,w.key.buffer,w.iv.buffer,F);if(i.part>-1){const ie=$.flush();O=ie&&ie.buffer}if(!O)return r.executeEnd=Xt(),Jr(i);n=new Uint8Array(O)}else return this.asyncResult=!0,this.decryptionPromise=$.webCryptoDecrypt(n,w.key.buffer,w.iv.buffer,F).then(O=>{const W=this.push(O,null,i);return this.decryptionPromise=null,W}),this.decryptionPromise}const N=this.needsProbing(h,f);if(N){const $=this.configureTransmuxer(n);if($)return this.logger.warn(`[transmuxer] ${$.message}`),this.observer.emit(y.ERROR,y.ERROR,{type:de.MEDIA_ERROR,details:U.FRAG_PARSING_ERROR,fatal:!1,error:$,reason:$.message}),r.executeEnd=Xt(),Jr(i)}(h||f||m||N)&&this.resetInitSegment(L,E,v,D,t),(h||m||N)&&this.resetInitialTimestamp(x),u||this.resetContiguity();const K=this.transmux(n,w,I,g,i);this.asyncResult=rs(K);const p=this.currentTransmuxState;return p.contiguous=!0,p.discontinuity=!1,p.trackSwitch=!1,r.executeEnd=Xt(),K}flush(e){const t=e.transmuxing;t.executeStart=Xt();const{decrypter:i,currentTransmuxState:s,decryptionPromise:r}=this;if(r)return this.asyncResult=!0,r.then(()=>this.flush(e));const n=[],{timeOffset:o}=s;if(i){const f=i.flush();f&&n.push(this.push(f.buffer,null,e))}const{demuxer:c,remuxer:u}=this;if(!c||!u){t.executeEnd=Xt();const f=[Jr(e)];return this.asyncResult?Promise.resolve(f):f}const h=c.flush(o);return rs(h)?(this.asyncResult=!0,h.then(f=>(this.flushRemux(n,f,e),n))):(this.flushRemux(n,h,e),this.asyncResult?Promise.resolve(n):n)}flushRemux(e,t,i){const{audioTrack:s,videoTrack:r,id3Track:n,textTrack:o}=t,{accurateTimeOffset:c,timeOffset:u}=this.currentTransmuxState;this.logger.log(`[transmuxer.ts]: Flushed ${this.id} sn: ${i.sn}${i.part>-1?" part: "+i.part:""} of ${this.id===he.MAIN?"level":"track"} ${i.level}`);const h=this.remuxer.remux(s,r,n,o,u,c,!0,this.id);e.push({remuxResult:h,chunkMeta:i}),i.transmuxing.executeEnd=Xt()}resetInitialTimestamp(e){const{demuxer:t,remuxer:i}=this;!t||!i||(t.resetTimeStamp(e),i.resetTimeStamp(e))}resetContiguity(){const{demuxer:e,remuxer:t}=this;!e||!t||(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,i,s,r){const{demuxer:n,remuxer:o}=this;!n||!o||(n.resetInitSegment(e,t,i,s),o.resetInitSegment(e,t,i,r))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,i,s,r){let n;return t&&t.method==="SAMPLE-AES"?n=this.transmuxSampleAes(e,t,i,s,r):n=this.transmuxUnencrypted(e,i,s,r),n}transmuxUnencrypted(e,t,i,s){const{audioTrack:r,videoTrack:n,id3Track:o,textTrack:c}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(r,n,o,c,t,i,!1,this.id),chunkMeta:s}}transmuxSampleAes(e,t,i,s,r){return this.demuxer.demuxSampleAes(e,t,i).then(n=>({remuxResult:this.remuxer.remux(n.audioTrack,n.videoTrack,n.id3Track,n.textTrack,i,s,!1,this.id),chunkMeta:r}))}configureTransmuxer(e){const{config:t,observer:i,typeSupported:s}=this;let r;for(let f=0,g=Gs.length;f<g;f++){var n;if((n=Gs[f].demux)!=null&&n.probe(e,this.logger)){r=Gs[f];break}}if(!r)return new Error("Failed to find demuxer by probing fragment data");const o=this.demuxer,c=this.remuxer,u=r.remux,h=r.demux;(!c||!(c instanceof u))&&(this.remuxer=new u(i,t,s,this.logger)),(!o||!(o instanceof h))&&(this.demuxer=new h(i,t,s,this.logger),this.probe=h.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new Rr(this.config)),e}}function Zh(a,e){let t=null;return a.byteLength>0&&e?.key!=null&&e.iv!==null&&e.method!=null&&(t=e),t}const Jr=a=>({remuxResult:{},chunkMeta:a});function rs(a){return"then"in a&&a.then instanceof Function}class Qh{constructor(e,t,i,s,r){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=i,this.duration=s,this.defaultInitPts=r||null}}class Jh{constructor(e,t,i,s,r,n){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=e,this.contiguous=t,this.accurateTimeOffset=i,this.trackSwitch=s,this.timeOffset=r,this.initSegmentChange=n}}let Bo=0;class Uo{constructor(e,t,i,s){this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=Bo++,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=c=>{const u=c.data,h=this.hls;if(!(!h||!(u!=null&&u.event)||u.instanceNo!==this.instanceNo))switch(u.event){case"init":{var f;const g=(f=this.workerContext)==null?void 0:f.objectURL;g&&self.URL.revokeObjectURL(g);break}case"transmuxComplete":{this.handleTransmuxComplete(u.data);break}case"flush":{this.onFlush(u.data);break}case"workerLog":{h.logger[u.data.logType]&&h.logger[u.data.logType](u.data.message);break}default:{u.data=u.data||{},u.data.frag=this.frag,u.data.part=this.part,u.data.id=this.id,h.trigger(u.event,u.data);break}}},this.onWorkerError=c=>{if(!this.hls)return;const u=new Error(`${c.message} (${c.filename}:${c.lineno})`);this.hls.config.enableWorker=!1,this.hls.logger.warn(`Error in "${this.id}" Web Worker, fallback to inline`),this.hls.trigger(y.ERROR,{type:de.OTHER_ERROR,details:U.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:u})};const r=e.config;this.hls=e,this.id=t,this.useWorker=!!r.enableWorker,this.onTransmuxComplete=i,this.onFlush=s;const n=(c,u)=>{u=u||{},u.frag=this.frag||void 0,c===y.ERROR&&(u=u,u.parent=this.id,u.part=this.part,this.error=u.error),this.hls.trigger(c,u)};this.observer=new Gr,this.observer.on(y.FRAG_DECRYPTED,n),this.observer.on(y.ERROR,n);const o=ga(r.preferManagedMediaSource);if(this.useWorker&&typeof Worker<"u"){const c=this.hls.logger;if(r.workerPath||sh()){try{r.workerPath?(c.log(`loading Web Worker ${r.workerPath} for "${t}"`),this.workerContext=nh(r.workerPath)):(c.log(`injecting Web Worker for "${t}"`),this.workerContext=rh());const{worker:h}=this.workerContext;h.addEventListener("message",this.onWorkerMessage),h.addEventListener("error",this.onWorkerError),h.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:o,id:t,config:Ge(r)})}catch(h){c.warn(`Error setting up "${t}" Web Worker, fallback to inline`,h),this.terminateWorker(),this.error=null,this.transmuxer=new No(this.observer,o,r,"",t,e.logger)}return}}this.transmuxer=new No(this.observer,o,r,"",t,e.logger)}reset(){if(this.frag=null,this.part=null,this.workerContext){const e=this.instanceNo;this.instanceNo=Bo++;const t=this.hls.config,i=ga(t.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:e,typeSupported:i,id:this.id,config:Ge(t)})}}terminateWorker(){if(this.workerContext){const{worker:e}=this.workerContext;this.workerContext=null,e.removeEventListener("message",this.onWorkerMessage),e.removeEventListener("error",this.onWorkerError),ah(this.hls.config.workerPath)}}destroy(){if(this.workerContext)this.terminateWorker(),this.onWorkerMessage=this.onWorkerError=null;else{const t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}const e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.part=null,this.observer=null,this.hls=null}push(e,t,i,s,r,n,o,c,u,h){var f,g;u.transmuxing.start=self.performance.now();const{instanceNo:I,transmuxer:m}=this,E=n?n.start:r.start,v=r.decryptdata,x=this.frag,D=!(x&&r.cc===x.cc),L=!(x&&u.level===x.level),w=x?u.sn-x.sn:-1,N=this.part?u.part-this.part.index:-1,K=w===0&&u.id>1&&u.id===x?.stats.chunkCount,p=!L&&(w===1||w===0&&(N===1||K&&N<=0)),$=self.performance.now();(L||w||r.stats.parsing.start===0)&&(r.stats.parsing.start=$),n&&(N||!p)&&(n.stats.parsing.start=$);const F=!(x&&((f=r.initSegment)==null?void 0:f.url)===((g=x.initSegment)==null?void 0:g.url)),O=new Jh(D,p,c,L,E,F);if(!p||D||F){this.hls.logger.log(`[transmuxer-interface]: Starting new transmux session for ${r.type} sn: ${u.sn}${u.part>-1?" part: "+u.part:""} ${this.id===he.MAIN?"level":"track"}: ${u.level} id: ${u.id}
17
- discontinuity: ${D}
18
- trackSwitch: ${L}
19
- contiguous: ${p}
20
- accurateTimeOffset: ${c}
21
- timeOffset: ${E}
22
- initSegmentChange: ${F}`);const W=new Qh(i,s,t,o,h);this.configureTransmuxer(W)}if(this.frag=r,this.part=n,this.workerContext)this.workerContext.worker.postMessage({instanceNo:I,cmd:"demux",data:e,decryptdata:v,chunkMeta:u,state:O},e instanceof ArrayBuffer?[e]:[]);else if(m){const W=m.push(e,v,u,O);rs(W)?W.then(ie=>{this.handleTransmuxComplete(ie)}).catch(ie=>{this.transmuxerError(ie,u,"transmuxer-interface push error")}):this.handleTransmuxComplete(W)}}flush(e){e.transmuxing.start=self.performance.now();const{instanceNo:t,transmuxer:i}=this;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:t,cmd:"flush",chunkMeta:e});else if(i){const s=i.flush(e);rs(s)?s.then(r=>{this.handleFlushResult(r,e)}).catch(r=>{this.transmuxerError(r,e,"transmuxer-interface flush error")}):this.handleFlushResult(s,e)}}transmuxerError(e,t,i){this.hls&&(this.error=e,this.hls.trigger(y.ERROR,{type:de.MEDIA_ERROR,details:U.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,part:this.part||void 0,fatal:!1,error:e,err:e,reason:i}))}handleFlushResult(e,t){e.forEach(i=>{this.handleTransmuxComplete(i)}),this.onFlush(t)}configureTransmuxer(e){const{instanceNo:t,transmuxer:i}=this;this.workerContext?this.workerContext.worker.postMessage({instanceNo:t,cmd:"configure",config:e}):i&&i.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}const $o=100;class ed extends Ur{constructor(e,t,i){super(e,t,i,"audio-stream-controller",he.AUDIO),this.mainAnchor=null,this.mainFragLoading=null,this.audioOnly=!1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.flushing=!1,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this.registerListeners()}onHandlerDestroying(){this.unregisterListeners(),super.onHandlerDestroying(),this.resetItem()}resetItem(){this.mainDetails=this.mainAnchor=this.mainFragLoading=this.bufferedTrack=this.switchingTrack=this.waitingData=this.cachedTrackLoadedData=null}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(y.LEVEL_LOADED,this.onLevelLoaded,this),e.on(y.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(y.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(y.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(y.BUFFER_RESET,this.onBufferReset,this),e.on(y.BUFFER_CREATED,this.onBufferCreated,this),e.on(y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(y.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(y.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(y.FRAG_LOADING,this.onFragLoading,this),e.on(y.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){const{hls:e}=this;e&&(super.unregisterListeners(),e.off(y.LEVEL_LOADED,this.onLevelLoaded,this),e.off(y.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(y.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(y.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(y.BUFFER_RESET,this.onBufferReset,this),e.off(y.BUFFER_CREATED,this.onBufferCreated,this),e.off(y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(y.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(y.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(y.FRAG_LOADING,this.onFragLoading,this),e.off(y.FRAG_BUFFERED,this.onFragBuffered,this))}onInitPtsFound(e,{frag:t,id:i,initPTS:s,timescale:r,trackId:n}){if(i===he.MAIN){const o=t.cc,c=this.fragCurrent;if(this.initPTS[o]={baseTime:s,timescale:r,trackId:n},this.log(`InitPTS for cc: ${o} found from main: ${s/r} (${s}/${r}) trackId: ${n}`),this.mainAnchor=t,this.state===j.WAITING_INIT_PTS){const u=this.waitingData;(!u&&!this.loadingParts||u&&u.frag.cc!==o)&&this.syncWithAnchor(t,u?.frag)}else!this.hls.hasEnoughToStart&&c&&c.cc!==o?(c.abortRequests(),this.syncWithAnchor(t,c)):this.state===j.IDLE&&this.tick()}}getLoadPosition(){return!this.startFragRequested&&this.nextLoadPosition>=0?this.nextLoadPosition:super.getLoadPosition()}syncWithAnchor(e,t){var i;const s=((i=this.mainFragLoading)==null?void 0:i.frag)||null;if(t&&s?.cc===t.cc)return;const r=(s||e).cc,n=this.getLevelDetails(),o=this.getLoadPosition(),c=La(n,r,o);c&&(this.log(`Syncing with main frag at ${c.start} cc ${c.cc}`),this.startFragRequested=!1,this.nextLoadPosition=c.start,this.resetLoadingState(),this.state===j.IDLE&&this.doTickIdle())}startLoad(e,t){if(!this.levels){this.startPosition=e,this.state=j.STOPPED;return}const i=this.lastCurrentTime;this.stopLoad(),this.setInterval($o),i>0&&e===-1?(this.log(`Override startPosition with lastCurrentTime @${i.toFixed(3)}`),e=i,this.state=j.IDLE):this.state=j.WAITING_TRACK,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}doTick(){switch(this.state){case j.IDLE:this.doTickIdle();break;case j.WAITING_TRACK:{const{levels:e,trackId:t}=this,i=e?.[t],s=i?.details;if(s&&!this.waitForLive(i)){if(this.waitForCdnTuneIn(s))break;this.state=j.WAITING_INIT_PTS}break}case j.FRAG_LOADING_WAITING_RETRY:{this.checkRetryDate();break}case j.WAITING_INIT_PTS:{const e=this.waitingData;if(e){const{frag:t,part:i,cache:s,complete:r}=e,n=this.mainAnchor;if(this.initPTS[t.cc]!==void 0){this.waitingData=null,this.state=j.FRAG_LOADING;const o=s.flush().buffer,c={frag:t,part:i,payload:o,networkDetails:null};this._handleFragmentLoadProgress(c),r&&super._handleFragmentLoadComplete(c)}else n&&n.cc!==e.frag.cc&&this.syncWithAnchor(n,e.frag)}else this.state=j.IDLE}}this.onTickEnd()}resetLoadingState(){const e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null),super.resetLoadingState()}onTickEnd(){const{media:e}=this;e!=null&&e.readyState&&(this.lastCurrentTime=e.currentTime)}doTickIdle(){var e;const{hls:t,levels:i,media:s,trackId:r}=this,n=t.config;if(!this.buffering||!s&&!this.primaryPrefetch&&(this.startFragRequested||!n.startFragPrefetch)||!(i!=null&&i[r]))return;const o=i[r],c=o.details;if(!c||this.waitForLive(o)||this.waitForCdnTuneIn(c)){this.state=j.WAITING_TRACK,this.startFragRequested=!1;return}const u=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&u&&(this.bufferFlushed=!1,this.afterBufferFlushed(u,Ue.AUDIO,he.AUDIO));const h=this.getFwdBufferInfo(u,he.AUDIO);if(h===null)return;if(!this.switchingTrack&&this._streamEnded(h,c)){t.trigger(y.BUFFER_EOS,{type:"audio"}),this.state=j.ENDED;return}const f=h.len,g=t.maxBufferLength,I=c.fragments,m=I[0].start,E=this.getLoadPosition(),v=this.flushing?E:h.end;if(this.switchingTrack&&s){const L=E;c.PTSKnown&&L<m&&(h.end>m||h.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),s.currentTime=m+.05)}if(f>=g&&!this.switchingTrack&&v<I[I.length-1].start)return;let x=this.getNextFragment(v,c);if(x&&this.isLoopLoading(x,v)&&(x=this.getNextFragmentLoopLoading(x,c,h,he.MAIN,g)),!x){this.bufferFlushed=!0;return}let D=((e=this.mainFragLoading)==null?void 0:e.frag)||null;if(!this.audioOnly&&this.startFragRequested&&D&&qe(x)&&!x.endList&&(!c.live||!this.loadingParts&&v<this.hls.liveSyncPosition)&&(this.fragmentTracker.getState(D)===Qe.OK&&(this.mainFragLoading=D=null),D&&qe(D))){if(x.start>D.end){const w=this.fragmentTracker.getFragAtPos(v,he.MAIN);w&&w.end>D.end&&(D=w,this.mainFragLoading={frag:w,targetBufferTime:null})}if(x.start>D.end)return}this.loadFragment(x,o,v)}onMediaDetaching(e,t){this.bufferFlushed=this.flushing=!1,super.onMediaDetaching(e,t)}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(i=>new Zi(i))}onAudioTrackSwitching(e,t){const i=!!t.url;this.trackId=t.id;const{fragCurrent:s}=this;s&&(s.abortRequests(),this.removeUnbufferedFrags(s.start)),this.resetLoadingState(),i?(this.switchingTrack=t,this.flushAudioIfNeeded(t),this.state!==j.STOPPED&&(this.setInterval($o),this.state=j.IDLE,this.tick())):(this.resetTransmuxer(),this.switchingTrack=null,this.bufferedTrack=t,this.clearInterval())}onManifestLoading(){super.onManifestLoading(),this.bufferFlushed=this.flushing=this.audioOnly=!1,this.resetItem(),this.trackId=-1}onLevelLoaded(e,t){this.mainDetails=t.details;const i=this.cachedTrackLoadedData;i&&(this.cachedTrackLoadedData=null,this.onAudioTrackLoaded(y.AUDIO_TRACK_LOADED,i))}onAudioTrackLoaded(e,t){var i;const{levels:s}=this,{details:r,id:n,groupId:o,track:c}=t;if(!s){this.warn(`Audio tracks reset while loading track ${n} "${c.name}" of "${o}"`);return}const u=this.mainDetails;if(!u||r.endCC>u.endCC||u.expired){this.cachedTrackLoadedData=t,this.state!==j.STOPPED&&(this.state=j.WAITING_TRACK);return}this.cachedTrackLoadedData=null,this.log(`Audio track ${n} "${c.name}" of "${o}" loaded [${r.startSN},${r.endSN}]${r.lastPartSn?`[part-${r.lastPartSn}-${r.lastPartIndex}]`:""},duration:${r.totalduration}`);const h=s[n];let f=0;if(r.live||(i=h.details)!=null&&i.live){if(this.checkLiveUpdate(r),r.deltaUpdateFailed)return;if(h.details){var g;f=this.alignPlaylists(r,h.details,(g=this.levelLastLoaded)==null?void 0:g.details)}r.alignedSliding||(ho(r,u),r.alignedSliding||Ms(r,u),f=r.fragmentStart)}h.details=r,this.levelLastLoaded=h,this.startFragRequested||this.setStartPosition(u,f),this.hls.trigger(y.AUDIO_TRACK_UPDATED,{details:r,id:n,groupId:t.groupId}),this.state===j.WAITING_TRACK&&!this.waitForCdnTuneIn(r)&&(this.state=j.IDLE),this.tick()}_handleFragmentLoadProgress(e){var t;const i=e.frag,{part:s,payload:r}=e,{config:n,trackId:o,levels:c}=this;if(!c){this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);return}const u=c[o];if(!u){this.warn("Audio track is undefined on fragment load progress");return}const h=u.details;if(!h){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(i.start);return}const f=n.defaultAudioCodec||u.audioCodec||"mp4a.40.2";let g=this.transmuxer;g||(g=this.transmuxer=new Uo(this.hls,he.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const I=this.initPTS[i.cc],m=(t=i.initSegment)==null?void 0:t.data;if(I!==void 0){const v=s?s.index:-1,x=v!==-1,D=new Dr(i.level,i.sn,i.stats.chunkCount,r.byteLength,v,x);g.push(r,m,f,"",i,s,h.totalduration,!1,D,I)}else{this.log(`Unknown video PTS for cc ${i.cc}, waiting for video PTS before demuxing audio frag ${i.sn} of [${h.startSN} ,${h.endSN}],track ${o}`);const{cache:E}=this.waitingData=this.waitingData||{frag:i,part:s,cache:new go,complete:!1};E.push(new Uint8Array(r)),this.state!==j.STOPPED&&(this.state=j.WAITING_INIT_PTS)}}_handleFragmentLoadComplete(e){if(this.waitingData){this.waitingData.complete=!0;return}super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=null}onBufferCreated(e,t){this.bufferFlushed=this.flushing=!1;const i=t.tracks.audio;i&&(this.mediaBuffer=i.buffer||null)}onFragLoading(e,t){!this.audioOnly&&t.frag.type===he.MAIN&&qe(t.frag)&&(this.mainFragLoading=t,this.state===j.IDLE&&this.tick())}onFragBuffered(e,t){const{frag:i,part:s}=t;if(i.type!==he.AUDIO){!this.audioOnly&&i.type===he.MAIN&&!i.elementaryStreams.video&&!i.elementaryStreams.audiovideo&&(this.audioOnly=!0,this.mainFragLoading=null);return}if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${s?" p: "+s.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);return}if(qe(i)){this.fragPrevious=i;const r=this.switchingTrack;r&&(this.bufferedTrack=r,this.switchingTrack=null,this.hls.trigger(y.AUDIO_TRACK_SWITCHED,Be({},r)))}this.fragBufferedComplete(i,s),this.media&&this.tick()}onError(e,t){var i;if(t.fatal){this.state=j.ERROR;return}switch(t.details){case U.FRAG_GAP:case U.FRAG_PARSING_ERROR:case U.FRAG_DECRYPT_ERROR:case U.FRAG_LOAD_ERROR:case U.FRAG_LOAD_TIMEOUT:case U.KEY_LOAD_ERROR:case U.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(he.AUDIO,t);break;case U.AUDIO_TRACK_LOAD_ERROR:case U.AUDIO_TRACK_LOAD_TIMEOUT:case U.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===j.WAITING_TRACK&&((i=t.context)==null?void 0:i.type)===be.AUDIO_TRACK&&(this.state=j.IDLE);break;case U.BUFFER_ADD_CODEC_ERROR:case U.BUFFER_APPEND_ERROR:if(t.parent!=="audio")return;this.reduceLengthAndFlushBuffer(t)||this.resetLoadingState();break;case U.BUFFER_FULL_ERROR:if(t.parent!=="audio")return;this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case U.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onBufferFlushing(e,{type:t}){t!==Ue.VIDEO&&(this.flushing=!0)}onBufferFlushed(e,{type:t}){if(t!==Ue.VIDEO){this.flushing=!1,this.bufferFlushed=!0,this.state===j.ENDED&&(this.state=j.IDLE);const i=this.mediaBuffer||this.media;i&&(this.afterBufferFlushed(i,t,he.AUDIO),this.tick())}}_handleTransmuxComplete(e){var t;const i="audio",{hls:s}=this,{remuxResult:r,chunkMeta:n}=e,o=this.getCurrentContext(n);if(!o){this.resetWhenMissingContext(n);return}const{frag:c,part:u,level:h}=o,{details:f}=h,{audio:g,text:I,id3:m,initSegment:E}=r;if(this.fragContextChanged(c)||!f){this.fragmentTracker.removeFragment(c);return}if(this.state=j.PARSING,this.switchingTrack&&g&&this.completeAudioSwitch(this.switchingTrack),E!=null&&E.tracks){const v=c.initSegment||c;if(this.unhandledEncryptionError(E,c))return;this._bufferInitSegment(h,E.tracks,v,n),s.trigger(y.FRAG_PARSING_INIT_SEGMENT,{frag:v,id:i,tracks:E.tracks})}if(g){const{startPTS:v,endPTS:x,startDTS:D,endDTS:L}=g;u&&(u.elementaryStreams[Ue.AUDIO]={startPTS:v,endPTS:x,startDTS:D,endDTS:L}),c.setElementaryStreamInfo(Ue.AUDIO,v,x,D,L),this.bufferFragmentData(g,c,u,n)}if(m!=null&&(t=m.samples)!=null&&t.length){const v=Ne({id:i,frag:c,details:f},m);s.trigger(y.FRAG_PARSING_METADATA,v)}if(I){const v=Ne({id:i,frag:c,details:f},I);s.trigger(y.FRAG_PARSING_USERDATA,v)}}_bufferInitSegment(e,t,i,s){if(this.state!==j.PARSING||(t.video&&delete t.video,t.audiovideo&&delete t.audiovideo,!t.audio))return;const r=t.audio;r.id=he.AUDIO;const n=e.audioCodec;this.log(`Init audio buffer, container:${r.container}, codecs[level/parsed]=[${n}/${r.codec}]`),n&&n.split(",").length===1&&(r.levelCodec=n),this.hls.trigger(y.BUFFER_CODECS,t);const o=r.initSegment;if(o!=null&&o.byteLength){const c={type:"audio",frag:i,part:null,chunkMeta:s,parent:i.type,data:o};this.hls.trigger(y.BUFFER_APPENDING,c)}this.tickImmediate()}loadFragment(e,t,i){const s=this.fragmentTracker.getState(e);if(this.switchingTrack||s===Qe.NOT_LOADED||s===Qe.PARTIAL){var r;if(!qe(e))this._loadInitSegment(e,t);else if((r=t.details)!=null&&r.live&&!this.initPTS[e.cc]){this.log(`Waiting for video PTS in continuity counter ${e.cc} of live stream before loading audio fragment ${e.sn} of level ${this.trackId}`),this.state=j.WAITING_INIT_PTS;const n=this.mainDetails;n&&n.fragmentStart!==t.details.fragmentStart&&Ms(t.details,n)}else super.loadFragment(e,t,i)}else this.clearTrackerIfNeeded(e)}flushAudioIfNeeded(e){if(this.media&&this.bufferedTrack){const{name:t,lang:i,assocLang:s,characteristics:r,audioCodec:n,channels:o}=this.bufferedTrack;Ii({name:t,lang:i,assocLang:s,characteristics:r,audioCodec:n,channels:o},e,Ci)||(xs(e.url,this.hls)?(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null):this.bufferedTrack=e)}}completeAudioSwitch(e){const{hls:t}=this;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(y.AUDIO_TRACK_SWITCHED,Be({},e))}}class en extends Tt{constructor(e,t){super(t,e.logger),this.hls=void 0,this.canLoad=!1,this.timer=-1,this.hls=e}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){this.timer!==-1&&(self.clearTimeout(this.timer),this.timer=-1)}startLoad(){this.canLoad=!0,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,t,i){const s=t?.renditionReports;if(s){let r=-1;for(let n=0;n<s.length;n++){const o=s[n];let c;try{c=new self.URL(o.URI,t.url).href}catch(u){this.warn(`Could not construct new URL for Rendition Report: ${u}`),c=o.URI||""}if(c===e){r=n;break}else c===e.substring(0,c.length)&&(r=n)}if(r!==-1){const n=s[r],o=parseInt(n["LAST-MSN"])||t.lastPartSn;let c=parseInt(n["LAST-PART"])||t.lastPartIndex;if(this.hls.config.lowLatencyMode){const h=Math.min(t.age-t.partTarget,t.targetduration);c>=0&&h>t.partTarget&&(c+=1)}const u=i&&Ca(i);return new ya(o,c>=0?c:void 0,u)}}}loadPlaylist(e){this.clearTimer()}loadingPlaylist(e,t){this.clearTimer()}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}getUrlWithDirectives(e,t){if(t)try{return t.addDirectives(e)}catch(i){this.warn(`Could not construct new URL with HLS Delivery Directives: ${i}`)}return e}playlistLoaded(e,t,i){const{details:s,stats:r}=t,n=self.performance.now(),o=r.loading.first?Math.max(0,n-r.loading.first):0;s.advancedDateTime=Date.now()-o;const c=this.hls.config.timelineOffset;if(c!==s.appliedTimelineOffset){const h=Math.max(c||0,0);s.appliedTimelineOffset=h,s.fragments.forEach(f=>{f.setStart(f.playlistOffset+h)})}if(s.live||i!=null&&i.live){const h="levelInfo"in t?t.levelInfo:t.track;if(s.reloaded(i),i&&s.fragments.length>0){Wc(i,s,this);const D=s.playlistParsingError;if(D){this.warn(D);const L=this.hls;if(!L.config.ignorePlaylistParsingErrors){var u;const{networkDetails:w}=t;L.trigger(y.ERROR,{type:de.NETWORK_ERROR,details:U.LEVEL_PARSING_ERROR,fatal:!1,url:s.url,error:D,reason:D.message,level:t.level||void 0,parent:(u=s.fragments[0])==null?void 0:u.type,networkDetails:w,stats:r});return}s.playlistParsingError=null}}s.requestScheduled===-1&&(s.requestScheduled=r.loading.start);const f=this.hls.mainForwardBufferInfo,g=f?f.end-f.len:0,I=(s.edge-g)*1e3,m=so(s,I);if(s.requestScheduled+m<n?s.requestScheduled=n:s.requestScheduled+=m,this.log(`live playlist ${e} ${s.advanced?"REFRESHED "+s.lastPartSn+"-"+s.lastPartIndex:s.updated?"UPDATED":"MISSED"}`),!this.canLoad||!s.live)return;let E,v,x;if(s.canBlockReload&&s.endSN&&s.advanced){const D=this.hls.config.lowLatencyMode,L=s.lastPartSn,w=s.endSN,N=s.lastPartIndex,K=N!==-1,p=L===w;K?p?(v=w+1,x=D?0:N):(v=L,x=D?N+1:s.maxPartIndex):v=w+1;const $=s.age,F=$+s.ageHeader;let O=Math.min(F-s.partTarget,s.targetduration*1.5);if(O>0){if(F>s.targetduration*3)this.log(`Playlist last advanced ${$.toFixed(2)}s ago. Omitting segment and part directives.`),v=void 0,x=void 0;else if(i!=null&&i.tuneInGoal&&F-s.partTarget>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.tuneInGoal} to: ${O} with playlist age: ${s.age}`),O=0;else{const W=Math.floor(O/s.targetduration);if(v+=W,x!==void 0){const ie=Math.round(O%s.targetduration/s.partTarget);x+=ie}this.log(`CDN Tune-in age: ${s.ageHeader}s last advanced ${$.toFixed(2)}s goal: ${O} skip sn ${W} to part ${x}`)}s.tuneInGoal=O}if(E=this.getDeliveryDirectives(s,t.deliveryDirectives,v,x),D||!p){s.requestScheduled=n,this.loadingPlaylist(h,E);return}}else(s.canBlockReload||s.canSkipUntil)&&(E=this.getDeliveryDirectives(s,t.deliveryDirectives,v,x));E&&v!==void 0&&s.canBlockReload&&(s.requestScheduled=r.loading.first+Math.max(m-o*2,m/2)),this.scheduleLoading(h,E,s)}else this.clearTimer()}scheduleLoading(e,t,i){const s=i||e.details;if(!s){this.loadingPlaylist(e,t);return}const r=self.performance.now(),n=s.requestScheduled;if(r>=n){this.loadingPlaylist(e,t);return}const o=n-r;this.log(`reload live playlist ${e.name||e.bitrate+"bps"} in ${Math.round(o)} ms`),this.clearTimer(),this.timer=self.setTimeout(()=>this.loadingPlaylist(e,t),o)}getDeliveryDirectives(e,t,i,s){let r=Ca(e);return t!=null&&t.skip&&e.deltaUpdateFailed&&(i=t.msn,s=t.part,r=Ss.No),new ya(i,s,r)}checkRetry(e){const t=e.details,i=bs(e),s=e.errorAction,{action:r,retryCount:n=0,retryConfig:o}=s||{},c=!!s&&!!o&&(r===rt.RetryRequest||!s.resolved&&r===rt.SendAlternateToPenaltyBox);if(c){var u;if(n>=o.maxNumRetry)return!1;if(i&&(u=e.context)!=null&&u.deliveryDirectives)this.warn(`Retrying playlist loading ${n+1}/${o.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{const h=br(o,n);this.clearTimer(),this.timer=self.setTimeout(()=>this.loadPlaylist(),h),this.warn(`Retrying playlist loading ${n+1}/${o.maxNumRetry} after "${t}" in ${h}ms`)}e.levelRetry=!0,s.resolved=!0}return c}}function Go(a,e){if(a.length!==e.length)return!1;for(let t=0;t<a.length;t++)if(!ns(a[t].attrs,e[t].attrs))return!1;return!0}function ns(a,e,t){const i=a["STABLE-RENDITION-ID"];return i&&!t?i===e["STABLE-RENDITION-ID"]:!(t||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some(s=>a[s]!==e[s])}function tn(a,e){return e.label.toLowerCase()===a.name.toLowerCase()&&(!e.language||e.language.toLowerCase()===(a.lang||"").toLowerCase())}class td extends en{constructor(e){super(e,"audio-track-controller"),this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){const{hls:e}=this;e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(y.LEVEL_LOADING,this.onLevelLoading,this),e.on(y.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(y.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(y.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(y.LEVEL_LOADING,this.onLevelLoading,this),e.off(y.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(y.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(y.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.tracksInGroup=[],this.groupIds=null,this.currentTrack=null,this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.audioTracks||[]}onAudioTrackLoaded(e,t){const{id:i,groupId:s,details:r}=t,n=this.tracksInGroup[i];if(!n||n.groupId!==s){this.warn(`Audio track with id:${i} and group:${s} not found in active group ${n?.groupId}`);return}const o=n.details;n.details=t.details,this.log(`Audio track ${i} "${n.name}" lang:${n.lang} group:${s} loaded [${r.startSN}-${r.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!t)return;const i=t.audioGroups||null,s=this.groupIds;let r=this.currentTrack;if(!i||s?.length!==i?.length||i!=null&&i.some(o=>s?.indexOf(o)===-1)){this.groupIds=i,this.trackId=-1,this.currentTrack=null;const o=this.tracks.filter(g=>!i||i.indexOf(g.groupId)!==-1);if(o.length)this.selectDefaultTrack&&!o.some(g=>g.default)&&(this.selectDefaultTrack=!1),o.forEach((g,I)=>{g.id=I});else if(!r&&!this.tracksInGroup.length)return;this.tracksInGroup=o;const c=this.hls.config.audioPreference;if(!r&&c){const g=Ft(c,o,Ci);if(g>-1)r=o[g];else{const I=Ft(c,this.tracks);r=this.tracks[I]}}let u=this.findTrackId(r);u===-1&&r&&(u=this.findTrackId(null));const h={audioTracks:o};this.log(`Updating audio tracks, ${o.length} track(s) found in group(s): ${i?.join(",")}`),this.hls.trigger(y.AUDIO_TRACKS_UPDATED,h);const f=this.trackId;if(u!==-1&&f===-1)this.setAudioTrack(u);else if(o.length&&f===-1){var n;const g=new Error(`No audio track selected for current audio group-ID(s): ${(n=this.groupIds)==null?void 0:n.join(",")} track count: ${o.length}`);this.warn(g.message),this.hls.trigger(y.ERROR,{type:de.MEDIA_ERROR,details:U.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:g})}}}onError(e,t){t.fatal||!t.context||t.context.type===be.AUDIO_TRACK&&t.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(t.context.groupId)!==-1)&&this.checkRetry(t)}get allAudioTracks(){return this.tracks}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}setAudioOption(e){const t=this.hls;if(t.config.audioPreference=e,e){const i=this.allAudioTracks;if(this.selectDefaultTrack=!1,i.length){const s=this.currentTrack;if(s&&Ii(e,s,Ci))return s;const r=Ft(e,this.tracksInGroup,Ci);if(r>-1){const n=this.tracksInGroup[r];return this.setAudioTrack(r),n}else if(s){let n=t.loadLevel;n===-1&&(n=t.firstAutoLevel);const o=hc(e,t.levels,i,n,Ci);if(o===-1)return null;t.nextLoadLevel=o}if(e.channels||e.audioCodec){const n=Ft(e,i);if(n>-1)return i[n]}}}return null}setAudioTrack(e){const t=this.tracksInGroup;if(e<0||e>=t.length){this.warn(`Invalid audio track id: ${e}`);return}this.selectDefaultTrack=!1;const i=this.currentTrack,s=t[e],r=s.details&&!s.details.live;if(e===this.trackId&&s===i&&r||(this.log(`Switching to audio-track ${e} "${s.name}" lang:${s.lang} group:${s.groupId} channels:${s.channels}`),this.trackId=e,this.currentTrack=s,this.hls.trigger(y.AUDIO_TRACK_SWITCHING,Be({},s)),r))return;const n=this.switchParams(s.url,i?.details,s.details);this.loadPlaylist(n)}findTrackId(e){const t=this.tracksInGroup;for(let i=0;i<t.length;i++){const s=t[i];if(!(this.selectDefaultTrack&&!s.default)&&(!e||Ii(e,s,Ci)))return i}if(e){const{name:i,lang:s,assocLang:r,characteristics:n,audioCodec:o,channels:c}=e;for(let u=0;u<t.length;u++){const h=t[u];if(Ii({name:i,lang:s,assocLang:r,characteristics:n,audioCodec:o,channels:c},h,Ci))return u}for(let u=0;u<t.length;u++){const h=t[u];if(ns(e.attrs,h.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return u}for(let u=0;u<t.length;u++){const h=t[u];if(ns(e.attrs,h.attrs,["LANGUAGE"]))return u}}return-1}loadPlaylist(e){super.loadPlaylist();const t=this.currentTrack;this.shouldLoadPlaylist(t)&&xs(t.url,this.hls)&&this.scheduleLoading(t,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const i=e.id,s=e.groupId,r=this.getUrlWithDirectives(e.url,t),n=e.details,o=n?.age;this.log(`Loading audio-track ${i} "${e.name}" lang:${e.lang} group:${s}${t?.msn!==void 0?" at sn "+t.msn+" part "+t.part:""}${o&&n.live?" age "+o.toFixed(1)+(n.type&&" "+n.type||""):""} ${r}`),this.hls.trigger(y.AUDIO_TRACK_LOADING,{url:r,id:i,groupId:s,deliveryDirectives:t||null,track:e})}}class id{constructor(e){this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=e}destroy(){this.tracks=this.queues=null}append(e,t,i){if(this.queues===null||this.tracks===null)return;const s=this.queues[t];s.push(e),s.length===1&&!i&&this.executeNext(t)}appendBlocker(e){return new Promise(t=>{const i={label:"async-blocker",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.append(i,e)})}prependBlocker(e){return new Promise(t=>{if(this.queues){const i={label:"async-blocker-prepend",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.queues[e].unshift(i)}})}removeBlockers(){this.queues!==null&&[this.queues.video,this.queues.audio,this.queues.audiovideo].forEach(e=>{var t;const i=(t=e[0])==null?void 0:t.label;(i==="async-blocker"||i==="async-blocker-prepend")&&(e[0].execute(),e.splice(0,1))})}unblockAudio(e){if(this.queues===null)return;this.queues.audio[0]===e&&this.shiftAndExecuteNext("audio")}executeNext(e){if(this.queues===null||this.tracks===null)return;const t=this.queues[e];if(t.length){const s=t[0];try{s.execute()}catch(r){var i;if(s.onError(r),this.queues===null||this.tracks===null)return;const n=(i=this.tracks[e])==null?void 0:i.buffer;n!=null&&n.updating||this.shiftAndExecuteNext(e)}}}shiftAndExecuteNext(e){this.queues!==null&&(this.queues[e].shift(),this.executeNext(e))}current(e){var t;return((t=this.queues)==null?void 0:t[e][0])||null}toString(){const{queues:e,tracks:t}=this;return e===null||t===null?"<destroyed>":`
23
- ${this.list("video")}
24
- ${this.list("audio")}
25
- ${this.list("audiovideo")}}`}list(e){var t,i;return(t=this.queues)!=null&&t[e]||(i=this.tracks)!=null&&i[e]?`${e}: (${this.listSbInfo(e)}) ${this.listOps(e)}`:""}listSbInfo(e){var t;const i=(t=this.tracks)==null?void 0:t[e],s=i?.buffer;return s?`SourceBuffer${s.updating?" updating":""}${i.ended?" ended":""}${i.ending?" ending":""}`:"none"}listOps(e){var t;return((t=this.queues)==null?void 0:t[e].map(i=>i.label).join(", "))||""}}const Ho=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,Vo="HlsJsTrackRemovedError";class sd extends Error{constructor(e){super(e),this.name=Vo}}class rd extends Tt{constructor(e,t){super("buffer-controller",e.logger),this.hls=void 0,this.fragmentTracker=void 0,this.details=null,this._objectUrl=null,this.operationQueue=null,this.bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.blockedAudioAppend=null,this.lastVideoAppendEnd=0,this.appendSource=void 0,this.transferData=void 0,this.overrides=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.sourceBuffers=[[null,null],[null,null]],this._onEndStreaming=i=>{var s;this.hls&&((s=this.mediaSource)==null?void 0:s.readyState)==="open"&&this.hls.pauseBuffering()},this._onStartStreaming=i=>{this.hls&&this.hls.resumeBuffering()},this._onMediaSourceOpen=i=>{const{media:s,mediaSource:r}=this;i&&this.log("Media source opened"),!(!s||!r)&&(r.removeEventListener("sourceopen",this._onMediaSourceOpen),s.removeEventListener("emptied",this._onMediaEmptied),this.updateDuration(),this.hls.trigger(y.MEDIA_ATTACHED,{media:s,mediaSource:r}),this.mediaSource!==null&&this.checkPendingTracks())},this._onMediaSourceClose=()=>{this.log("Media source closed")},this._onMediaSourceEnded=()=>{this.log("Media source ended")},this._onMediaEmptied=()=>{const{mediaSrc:i,_objectUrl:s}=this;i!==s&&this.error(`Media element src was set while attaching MediaSource (${s} > ${i})`)},this.hls=e,this.fragmentTracker=t,this.appendSource=Lu(ri(e.config.preferManagedMediaSource)),this.initTracks(),this.registerListeners()}hasSourceTypes(){return Object.keys(this.tracks).length>0}destroy(){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}registerListeners(){const{hls:e}=this;e.on(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(y.BUFFER_RESET,this.onBufferReset,this),e.on(y.BUFFER_APPENDING,this.onBufferAppending,this),e.on(y.BUFFER_CODECS,this.onBufferCodecs,this),e.on(y.BUFFER_EOS,this.onBufferEos,this),e.on(y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(y.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(y.FRAG_PARSED,this.onFragParsed,this),e.on(y.FRAG_CHANGED,this.onFragChanged,this),e.on(y.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(y.BUFFER_RESET,this.onBufferReset,this),e.off(y.BUFFER_APPENDING,this.onBufferAppending,this),e.off(y.BUFFER_CODECS,this.onBufferCodecs,this),e.off(y.BUFFER_EOS,this.onBufferEos,this),e.off(y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(y.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(y.FRAG_PARSED,this.onFragParsed,this),e.off(y.FRAG_CHANGED,this.onFragChanged,this),e.off(y.ERROR,this.onError,this)}transferMedia(){const{media:e,mediaSource:t}=this;if(!e)return null;const i={};if(this.operationQueue){const r=this.isUpdating();r||this.operationQueue.removeBlockers();const n=this.isQueued();(r||n)&&this.warn(`Transfering MediaSource with${n?" operations in queue":""}${r?" updating SourceBuffer(s)":""} ${this.operationQueue}`),this.operationQueue.destroy()}const s=this.transferData;return!this.sourceBufferCount&&s&&s.mediaSource===t?Ne(i,s.tracks):this.sourceBuffers.forEach(r=>{const[n]=r;n&&(i[n]=Ne({},this.tracks[n]),this.removeBuffer(n)),r[0]=r[1]=null}),{media:e,mediaSource:t,tracks:i}}initTracks(){const e={};this.sourceBuffers=[[null,null],[null,null]],this.tracks=e,this.resetQueue(),this.resetAppendErrors(),this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.lastVideoAppendEnd=0}onManifestLoading(){this.bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){var i;let s=2;(t.audio&&!t.video||!t.altAudio)&&(s=1),this.bufferCodecEventsTotal=s,this.log(`${s} bufferCodec event(s) expected.`),(i=this.transferData)!=null&&i.mediaSource&&this.sourceBufferCount&&s&&this.bufferCreated()}onMediaAttaching(e,t){const i=this.media=t.media;this.transferData=this.overrides=void 0;const s=ri(this.appendSource);if(s){const r=!!t.mediaSource;(r||t.overrides)&&(this.transferData=t,this.overrides=t.overrides);const n=this.mediaSource=t.mediaSource||new s;if(this.assignMediaSource(n),r)this._objectUrl=i.src,this.attachTransferred();else{const o=this._objectUrl=self.URL.createObjectURL(n);if(this.appendSource)try{i.removeAttribute("src");const c=self.ManagedMediaSource;i.disableRemotePlayback=i.disableRemotePlayback||c&&n instanceof c,Ko(i),nd(i,o),i.load()}catch{i.src=o}else i.src=o}i.addEventListener("emptied",this._onMediaEmptied)}}assignMediaSource(e){var t,i;this.log(`${((t=this.transferData)==null?void 0:t.mediaSource)===e?"transferred":"created"} media source: ${(i=e.constructor)==null?void 0:i.name}`),e.addEventListener("sourceopen",this._onMediaSourceOpen),e.addEventListener("sourceended",this._onMediaSourceEnded),e.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(e.addEventListener("startstreaming",this._onStartStreaming),e.addEventListener("endstreaming",this._onEndStreaming))}attachTransferred(){const e=this.media,t=this.transferData;if(!t||!e)return;const i=this.tracks,s=t.tracks,r=s?Object.keys(s):null,n=r?r.length:0,o=()=>{Promise.resolve().then(()=>{this.media&&this.mediaSourceOpenOrEnded&&this._onMediaSourceOpen()})};if(s&&r&&n){if(!this.tracksReady){this.hls.config.startFragPrefetch=!0,this.log("attachTransferred: waiting for SourceBuffer track info");return}if(this.log(`attachTransferred: (bufferCodecEventsTotal ${this.bufferCodecEventsTotal})
26
- required tracks: ${Ge(i,(c,u)=>c==="initSegment"?void 0:u)};
27
- transfer tracks: ${Ge(s,(c,u)=>c==="initSegment"?void 0:u)}}`),!Zn(s,i)){t.mediaSource=null,t.tracks=void 0;const c=e.currentTime,u=this.details,h=Math.max(c,u?.fragments[0].start||0);if(h-c>1){this.log(`attachTransferred: waiting for playback to reach new tracks start time ${c} -> ${h}`);return}this.warn(`attachTransferred: resetting MediaSource for incompatible tracks ("${Object.keys(s)}"->"${Object.keys(i)}") start time: ${h} currentTime: ${c}`),this.onMediaDetaching(y.MEDIA_DETACHING,{}),this.onMediaAttaching(y.MEDIA_ATTACHING,t),e.currentTime=h;return}this.transferData=void 0,r.forEach(c=>{const u=c,h=s[u];if(h){const f=h.buffer;if(f){const g=this.fragmentTracker,I=h.id;if(g.hasFragments(I)||g.hasParts(I)){const v=ye.getBuffered(f);g.detectEvictedFragments(u,v,I,null,!0)}const m=sn(u),E=[u,f];this.sourceBuffers[m]=E,f.updating&&this.operationQueue&&this.operationQueue.prependBlocker(u),this.trackSourceBuffer(u,h)}}}),o(),this.bufferCreated()}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),o()}get mediaSourceOpenOrEnded(){var e;const t=(e=this.mediaSource)==null?void 0:e.readyState;return t==="open"||t==="ended"}onMediaDetaching(e,t){const i=!!t.transferMedia;this.transferData=this.overrides=void 0;const{media:s,mediaSource:r,_objectUrl:n}=this;if(r){if(this.log(`media source ${i?"transferring":"detaching"}`),i)this.sourceBuffers.forEach(([o])=>{o&&this.removeBuffer(o)}),this.resetQueue();else{if(this.mediaSourceOpenOrEnded){const o=r.readyState==="open";try{const c=r.sourceBuffers;for(let u=c.length;u--;)o&&c[u].abort(),r.removeSourceBuffer(c[u]);o&&r.endOfStream()}catch(c){this.warn(`onMediaDetaching: ${c.message} while calling endOfStream`)}}this.sourceBufferCount&&this.onBufferReset()}r.removeEventListener("sourceopen",this._onMediaSourceOpen),r.removeEventListener("sourceended",this._onMediaSourceEnded),r.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(r.removeEventListener("startstreaming",this._onStartStreaming),r.removeEventListener("endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null}s&&(s.removeEventListener("emptied",this._onMediaEmptied),i||(n&&self.URL.revokeObjectURL(n),this.mediaSrc===n?(s.removeAttribute("src"),this.appendSource&&Ko(s),s.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger(y.MEDIA_DETACHED,t)}onBufferReset(){this.sourceBuffers.forEach(([e])=>{e&&this.resetBuffer(e)}),this.initTracks()}resetBuffer(e){var t;const i=(t=this.tracks[e])==null?void 0:t.buffer;if(this.removeBuffer(e),i)try{var s;(s=this.mediaSource)!=null&&s.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(i)}catch(r){this.warn(`onBufferReset ${e}`,r)}delete this.tracks[e]}removeBuffer(e){this.removeBufferListeners(e),this.sourceBuffers[sn(e)]=[null,null];const t=this.tracks[e];t&&(t.buffer=void 0)}resetQueue(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new id(this.tracks)}onBufferCodecs(e,t){const i=this.tracks,s=Object.keys(t);this.log(`BUFFER_CODECS: "${s}" (current SB count ${this.sourceBufferCount})`);const r="audiovideo"in t&&(i.audio||i.video)||i.audiovideo&&("audio"in t||"video"in t),n=!r&&this.sourceBufferCount&&this.media&&s.some(o=>!i[o]);if(r||n){this.warn(`Unsupported transition between "${Object.keys(i)}" and "${s}" SourceBuffers`);return}s.forEach(o=>{var c,u;const h=t[o],{id:f,codec:g,levelCodec:I,container:m,metadata:E,supplemental:v}=h;let x=i[o];const D=(c=this.transferData)==null||(c=c.tracks)==null?void 0:c[o],L=D!=null&&D.buffer?D:x,w=L?.pendingCodec||L?.codec,N=L?.levelCodec;x||(x=i[o]={buffer:void 0,listeners:[],codec:g,supplemental:v,container:m,levelCodec:I,metadata:E,id:f});const K=vs(w,N),p=K?.replace(Ho,"$1");let $=vs(g,I);const F=(u=$)==null?void 0:u.replace(Ho,"$1");$&&K&&p!==F&&(o.slice(0,5)==="audio"&&($=Es($,this.appendSource)),this.log(`switching codec ${w} to ${$}`),$!==(x.pendingCodec||x.codec)&&(x.pendingCodec=$),x.container=m,this.appendChangeType(o,m,$))}),(this.tracksReady||this.sourceBufferCount)&&(t.tracks=this.sourceBufferTracks),!this.sourceBufferCount&&this.mediaSourceOpenOrEnded&&this.checkPendingTracks()}get sourceBufferTracks(){return Object.keys(this.tracks).reduce((e,t)=>{const i=this.tracks[t];return e[t]={id:i.id,container:i.container,codec:i.codec,levelCodec:i.levelCodec},e},{})}appendChangeType(e,t,i){const s=`${t};codecs=${i}`,r={label:`change-type=${s}`,execute:()=>{const n=this.tracks[e];if(n){const o=n.buffer;o!=null&&o.changeType&&(this.log(`changing ${e} sourceBuffer type to ${s}`),o.changeType(s),n.codec=i,n.container=t)}this.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:n=>{this.warn(`Failed to change ${e} SourceBuffer type`,n)}};this.append(r,e,this.isPending(this.tracks[e]))}blockAudio(e){var t;const i=e.start,s=i+e.duration*.05;if(((t=this.fragmentTracker.getAppendedFrag(i,he.MAIN))==null?void 0:t.gap)===!0)return;const n={label:"block-audio",execute:()=>{var o;const c=this.tracks.video;(this.lastVideoAppendEnd>s||c!=null&&c.buffer&&ye.isBuffered(c.buffer,s)||((o=this.fragmentTracker.getAppendedFrag(s,he.MAIN))==null?void 0:o.gap)===!0)&&(this.blockedAudioAppend=null,this.shiftAndExecuteNext("audio"))},onStart:()=>{},onComplete:()=>{},onError:o=>{this.warn("Error executing block-audio operation",o)}};this.blockedAudioAppend={op:n,frag:e},this.append(n,"audio",!0)}unblockAudio(){const{blockedAudioAppend:e,operationQueue:t}=this;e&&t&&(this.blockedAudioAppend=null,t.unblockAudio(e.op))}onBufferAppending(e,t){const{tracks:i}=this,{data:s,type:r,parent:n,frag:o,part:c,chunkMeta:u,offset:h}=t,f=u.buffering[r],{sn:g,cc:I}=o,m=self.performance.now();f.start=m;const E=o.stats.buffering,v=c?c.stats.buffering:null;E.start===0&&(E.start=m),v&&v.start===0&&(v.start=m);const x=i.audio;let D=!1;r==="audio"&&x?.container==="audio/mpeg"&&(D=!this.lastMpegAudioChunk||u.id===1||this.lastMpegAudioChunk.sn!==u.sn,this.lastMpegAudioChunk=u);const L=i.video,w=L?.buffer;if(w&&g!=="initSegment"){const p=c||o,$=this.blockedAudioAppend;if(r==="audio"&&n!=="main"&&!this.blockedAudioAppend&&!(L.ending||L.ended)){const O=p.start+p.duration*.05,W=w.buffered,ie=this.currentOp("video");!W.length&&!ie?this.blockAudio(p):!ie&&!ye.isBuffered(w,O)&&this.lastVideoAppendEnd<O&&this.blockAudio(p)}else if(r==="video"){const F=p.end;if($){const O=$.frag.start;(F>O||F<this.lastVideoAppendEnd||ye.isBuffered(w,O))&&this.unblockAudio()}this.lastVideoAppendEnd=F}}const N=(c||o).start,K={label:`append-${r}`,execute:()=>{var p;f.executeStart=self.performance.now();const $=(p=this.tracks[r])==null?void 0:p.buffer;$&&(D?this.updateTimestampOffset($,N,.1,r,g,I):h!==void 0&&se(h)&&this.updateTimestampOffset($,h,1e-6,r,g,I)),this.appendExecutor(s,r)},onStart:()=>{},onComplete:()=>{const p=self.performance.now();f.executeEnd=f.end=p,E.first===0&&(E.first=p),v&&v.first===0&&(v.first=p);const $={};this.sourceBuffers.forEach(([F,O])=>{F&&($[F]=ye.getBuffered(O))}),this.appendErrors[r]=0,r==="audio"||r==="video"?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(y.BUFFER_APPENDED,{type:r,frag:o,part:c,chunkMeta:u,parent:o.type,timeRanges:$})},onError:p=>{var $;const F={type:de.MEDIA_ERROR,parent:o.type,details:U.BUFFER_APPEND_ERROR,sourceBufferName:r,frag:o,part:c,chunkMeta:u,error:p,err:p,fatal:!1},O=($=this.media)==null?void 0:$.error;if(p.code===DOMException.QUOTA_EXCEEDED_ERR||p.name=="QuotaExceededError"||"quota"in p)F.details=U.BUFFER_FULL_ERROR;else if(p.code===DOMException.INVALID_STATE_ERR&&this.mediaSourceOpenOrEnded&&!O)F.errorAction=_i(!0);else if(p.name===Vo&&this.sourceBufferCount===0)F.errorAction=_i(!0);else{const W=++this.appendErrors[r];this.warn(`Failed ${W}/${this.hls.config.appendErrorMaxRetry} times to append segment in "${r}" sourceBuffer (${O||"no media error"})`),(W>=this.hls.config.appendErrorMaxRetry||O)&&(F.fatal=!0)}this.hls.trigger(y.ERROR,F)}};this.append(K,r,this.isPending(this.tracks[r]))}getFlushOp(e,t,i){return this.log(`queuing "${e}" remove ${t}-${i}`),{label:"remove",execute:()=>{this.removeExecutor(e,t,i)},onStart:()=>{},onComplete:()=>{this.hls.trigger(y.BUFFER_FLUSHED,{type:e})},onError:s=>{this.warn(`Failed to remove ${t}-${i} from "${e}" SourceBuffer`,s)}}}onBufferFlushing(e,t){const{type:i,startOffset:s,endOffset:r}=t;i?this.append(this.getFlushOp(i,s,r),i):this.sourceBuffers.forEach(([n])=>{n&&this.append(this.getFlushOp(n,s,r),n)})}onFragParsed(e,t){const{frag:i,part:s}=t,r=[],n=s?s.elementaryStreams:i.elementaryStreams;n[Ue.AUDIOVIDEO]?r.push("audiovideo"):(n[Ue.AUDIO]&&r.push("audio"),n[Ue.VIDEO]&&r.push("video"));const o=()=>{const c=self.performance.now();i.stats.buffering.end=c,s&&(s.stats.buffering.end=c);const u=s?s.stats:i.stats;this.hls.trigger(y.FRAG_BUFFERED,{frag:i,part:s,stats:u,id:i.type})};r.length===0&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${i.type} level: ${i.level} sn: ${i.sn}`),this.blockBuffers(o,r).catch(c=>{this.warn(`Fragment buffered callback ${c}`),this.stepOperationQueue(this.sourceBufferTypes)})}onFragChanged(e,t){this.trimBuffers()}get bufferedToEnd(){return this.sourceBufferCount>0&&!this.sourceBuffers.some(([e])=>{if(e){const t=this.tracks[e];if(t)return!t.ended||t.ending}return!1})}onBufferEos(e,t){var i;this.sourceBuffers.forEach(([n])=>{if(n){const o=this.tracks[n];(!t.type||t.type===n)&&(o.ending=!0,o.ended||(o.ended=!0,this.log(`${n} buffer reached EOS`)))}});const s=((i=this.overrides)==null?void 0:i.endOfStream)!==!1;this.sourceBufferCount>0&&!this.sourceBuffers.some(([n])=>{var o;return n&&!((o=this.tracks[n])!=null&&o.ended)})?s?(this.log("Queueing EOS"),this.blockUntilOpen(()=>{this.tracksEnded();const{mediaSource:n}=this;if(!n||n.readyState!=="open"){n&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${n.readyState}`);return}this.log("Calling mediaSource.endOfStream()"),n.endOfStream(),this.hls.trigger(y.BUFFERED_TO_END,void 0)})):(this.tracksEnded(),this.hls.trigger(y.BUFFERED_TO_END,void 0)):t.type==="video"&&this.unblockAudio()}tracksEnded(){this.sourceBuffers.forEach(([e])=>{if(e!==null){const t=this.tracks[e];t&&(t.ending=!1)}})}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.updateDuration())}updateDuration(){this.blockUntilOpen(()=>{const e=this.getDurationAndRange();e&&this.updateMediaSource(e)})}onError(e,t){if(t.details===U.BUFFER_APPEND_ERROR&&t.frag){var i;const s=(i=t.errorAction)==null?void 0:i.nextAutoLevel;se(s)&&s!==t.frag.level&&this.resetAppendErrors()}}resetAppendErrors(){this.appendErrors={audio:0,video:0,audiovideo:0}}trimBuffers(){const{hls:e,details:t,media:i}=this;if(!i||t===null||!this.sourceBufferCount)return;const s=e.config,r=i.currentTime,n=t.levelTargetDuration,o=t.live&&s.liveBackBufferLength!==null?s.liveBackBufferLength:s.backBufferLength;if(se(o)&&o>=0){const u=Math.max(o,n),h=Math.floor(r/n)*n-u;this.flushBackBuffer(r,n,h)}const c=s.frontBufferFlushThreshold;if(se(c)&&c>0){const u=Math.max(s.maxBufferLength,c),h=Math.max(u,n),f=Math.floor(r/n)*n+h;this.flushFrontBuffer(r,n,f)}}flushBackBuffer(e,t,i){this.sourceBuffers.forEach(([s,r])=>{if(r){const o=ye.getBuffered(r);if(o.length>0&&i>o.start(0)){var n;this.hls.trigger(y.BACK_BUFFER_REACHED,{bufferEnd:i});const c=this.tracks[s];if((n=this.details)!=null&&n.live)this.hls.trigger(y.LIVE_BACK_BUFFER_REACHED,{bufferEnd:i});else if(c!=null&&c.ended){this.log(`Cannot flush ${s} back buffer while SourceBuffer is in ended state`);return}this.hls.trigger(y.BUFFER_FLUSHING,{startOffset:0,endOffset:i,type:s})}}})}flushFrontBuffer(e,t,i){this.sourceBuffers.forEach(([s,r])=>{if(r){const n=ye.getBuffered(r),o=n.length;if(o<2)return;const c=n.start(o-1),u=n.end(o-1);if(i>c||e>=c&&e<=u)return;this.hls.trigger(y.BUFFER_FLUSHING,{startOffset:c,endOffset:1/0,type:s})}})}getDurationAndRange(){var e;const{details:t,mediaSource:i}=this;if(!t||!this.media||i?.readyState!=="open")return null;const s=t.edge;if(t.live&&this.hls.config.liveDurationInfinity){if(t.fragments.length&&i.setLiveSeekableRange){const u=Math.max(0,t.fragmentStart),h=Math.max(u,s);return{duration:1/0,start:u,end:h}}return{duration:1/0}}const r=(e=this.overrides)==null?void 0:e.duration;if(r)return se(r)?{duration:r}:null;const n=this.media.duration,o=se(i.duration)?i.duration:0;return s>o&&s>n||!se(n)?{duration:s}:null}updateMediaSource({duration:e,start:t,end:i}){const s=this.mediaSource;!this.media||!s||s.readyState!=="open"||(s.duration!==e&&(se(e)&&this.log(`Updating MediaSource duration to ${e.toFixed(3)}`),s.duration=e),t!==void 0&&i!==void 0&&(this.log(`MediaSource duration is set to ${s.duration}. Setting seekable range to ${t}-${i}.`),s.setLiveSeekableRange(t,i)))}get tracksReady(){const e=this.pendingTrackCount;return e>0&&(e>=this.bufferCodecEventsTotal||this.isPending(this.tracks.audiovideo))}checkPendingTracks(){const{bufferCodecEventsTotal:e,pendingTrackCount:t,tracks:i}=this;if(this.log(`checkPendingTracks (pending: ${t} codec events expected: ${e}) ${Ge(i)}`),this.tracksReady){var s;const r=(s=this.transferData)==null?void 0:s.tracks;r&&Object.keys(r).length?this.attachTransferred():this.createSourceBuffers()}}bufferCreated(){if(this.sourceBufferCount){const e={};this.sourceBuffers.forEach(([t,i])=>{if(t){const s=this.tracks[t];e[t]={buffer:i,container:s.container,codec:s.codec,supplemental:s.supplemental,levelCodec:s.levelCodec,id:s.id,metadata:s.metadata}}}),this.hls.trigger(y.BUFFER_CREATED,{tracks:e}),this.log(`SourceBuffers created. Running queue: ${this.operationQueue}`),this.sourceBuffers.forEach(([t])=>{this.executeNext(t)})}else{const e=new Error("could not create source buffer for media codec(s)");this.hls.trigger(y.ERROR,{type:de.MEDIA_ERROR,details:U.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:e,reason:e.message})}}createSourceBuffers(){const{tracks:e,sourceBuffers:t,mediaSource:i}=this;if(!i)throw new Error("createSourceBuffers called when mediaSource was null");for(const r in e){const n=r,o=e[n];if(this.isPending(o)){const c=this.getTrackCodec(o,n),u=`${o.container};codecs=${c}`;o.codec=c,this.log(`creating sourceBuffer(${u})${this.currentOp(n)?" Queued":""} ${Ge(o)}`);try{const h=i.addSourceBuffer(u),f=sn(n),g=[n,h];t[f]=g,o.buffer=h}catch(h){var s;this.error(`error while trying to add sourceBuffer: ${h.message}`),this.shiftAndExecuteNext(n),(s=this.operationQueue)==null||s.removeBlockers(),delete this.tracks[n],this.hls.trigger(y.ERROR,{type:de.MEDIA_ERROR,details:U.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:h,sourceBufferName:n,mimeType:u,parent:o.id});return}this.trackSourceBuffer(n,o)}}this.bufferCreated()}getTrackCodec(e,t){const i=e.supplemental;let s=e.codec;i&&(t==="video"||t==="audiovideo")&&Er(i,"video")&&(s=Wu(s,i));const r=vs(s,e.levelCodec);return r?t.slice(0,5)==="audio"?Es(r,this.appendSource):r:""}trackSourceBuffer(e,t){const i=t.buffer;if(!i)return;const s=this.getTrackCodec(t,e);this.tracks[e]={buffer:i,codec:s,container:t.container,levelCodec:t.levelCodec,supplemental:t.supplemental,metadata:t.metadata,id:t.id,listeners:[]},this.removeBufferListeners(e),this.addBufferListener(e,"updatestart",this.onSBUpdateStart),this.addBufferListener(e,"updateend",this.onSBUpdateEnd),this.addBufferListener(e,"error",this.onSBUpdateError),this.appendSource&&this.addBufferListener(e,"bufferedchange",(r,n)=>{const o=n.removedRanges;o!=null&&o.length&&this.hls.trigger(y.BUFFER_FLUSHED,{type:r})})}get mediaSrc(){var e,t;const i=((e=this.media)==null||(t=e.querySelector)==null?void 0:t.call(e,"source"))||this.media;return i?.src}onSBUpdateStart(e){const t=this.currentOp(e);t&&t.onStart()}onSBUpdateEnd(e){var t;if(((t=this.mediaSource)==null?void 0:t.readyState)==="closed"){this.resetBuffer(e);return}const i=this.currentOp(e);i&&(i.onComplete(),this.shiftAndExecuteNext(e))}onSBUpdateError(e,t){var i;const s=new Error(`${e} SourceBuffer error. MediaSource readyState: ${(i=this.mediaSource)==null?void 0:i.readyState}`);this.error(`${s}`,t),this.hls.trigger(y.ERROR,{type:de.MEDIA_ERROR,details:U.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:s,fatal:!1});const r=this.currentOp(e);r&&r.onError(s)}updateTimestampOffset(e,t,i,s,r,n){const o=t-e.timestampOffset;Math.abs(o)>=i&&(this.log(`Updating ${s} SourceBuffer timestampOffset to ${t} (sn: ${r} cc: ${n})`),e.timestampOffset=t)}removeExecutor(e,t,i){const{media:s,mediaSource:r}=this,n=this.tracks[e],o=n?.buffer;if(!s||!r||!o){this.warn(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`),this.shiftAndExecuteNext(e);return}const c=se(s.duration)?s.duration:1/0,u=se(r.duration)?r.duration:1/0,h=Math.max(0,t),f=Math.min(i,c,u);f>h&&(!n.ending||n.ended)?(n.ended=!1,this.log(`Removing [${h},${f}] from the ${e} SourceBuffer`),o.remove(h,f)):this.shiftAndExecuteNext(e)}appendExecutor(e,t){const i=this.tracks[t],s=i?.buffer;if(!s)throw new sd(`Attempting to append to the ${t} SourceBuffer, but it does not exist`);i.ending=!1,i.ended=!1,s.appendBuffer(e)}blockUntilOpen(e){if(this.isUpdating()||this.isQueued())this.blockBuffers(e).catch(t=>{this.warn(`SourceBuffer blocked callback ${t}`),this.stepOperationQueue(this.sourceBufferTypes)});else try{e()}catch(t){this.warn(`Callback run without blocking ${this.operationQueue} ${t}`)}}isUpdating(){return this.sourceBuffers.some(([e,t])=>e&&t.updating)}isQueued(){return this.sourceBuffers.some(([e])=>e&&!!this.currentOp(e))}isPending(e){return!!e&&!e.buffer}blockBuffers(e,t=this.sourceBufferTypes){if(!t.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);const{operationQueue:i}=this,s=t.map(n=>this.appendBlocker(n));return t.length>1&&!!this.blockedAudioAppend&&this.unblockAudio(),Promise.all(s).then(n=>{i===this.operationQueue&&(e(),this.stepOperationQueue(this.sourceBufferTypes))})}stepOperationQueue(e){e.forEach(t=>{var i;const s=(i=this.tracks[t])==null?void 0:i.buffer;!s||s.updating||this.shiftAndExecuteNext(t)})}append(e,t,i){this.operationQueue&&this.operationQueue.append(e,t,i)}appendBlocker(e){if(this.operationQueue)return this.operationQueue.appendBlocker(e)}currentOp(e){return this.operationQueue?this.operationQueue.current(e):null}executeNext(e){e&&this.operationQueue&&this.operationQueue.executeNext(e)}shiftAndExecuteNext(e){this.operationQueue&&this.operationQueue.shiftAndExecuteNext(e)}get pendingTrackCount(){return Object.keys(this.tracks).reduce((e,t)=>e+(this.isPending(this.tracks[t])?1:0),0)}get sourceBufferCount(){return this.sourceBuffers.reduce((e,[t])=>e+(t?1:0),0)}get sourceBufferTypes(){return this.sourceBuffers.map(([e])=>e).filter(e=>!!e)}addBufferListener(e,t,i){const s=this.tracks[e];if(!s)return;const r=s.buffer;if(!r)return;const n=i.bind(this,e);s.listeners.push({event:t,listener:n}),r.addEventListener(t,n)}removeBufferListeners(e){const t=this.tracks[e];if(!t)return;const i=t.buffer;i&&(t.listeners.forEach(s=>{i.removeEventListener(s.event,s.listener)}),t.listeners.length=0)}}function Ko(a){const e=a.querySelectorAll("source");[].slice.call(e).forEach(t=>{a.removeChild(t)})}function nd(a,e){const t=self.document.createElement("source");t.type="video/mp4",t.src=e,a.appendChild(t)}function sn(a){return a==="audio"?1:0}class rn{constructor(e){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(e){this.streamController=e}destroy(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){const{hls:e}=this;e.on(y.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(y.BUFFER_CODECS,this.onBufferCodecs,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:e}=this;e.off(y.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(y.BUFFER_CODECS,this.onBufferCodecs,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){const i=this.hls.levels[t.droppedLevel];this.isLevelAllowed(i)&&this.restrictedLevels.push({bitrate:i.bitrate,height:i.height,width:i.width})}onMediaAttaching(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()}onManifestParsed(e,t){const i=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,i.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onLevelsUpdated(e,t){this.timer&&se(this.autoLevelCapping)&&this.detectPlayerSize()}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping(),this.media=null}detectPlayerSize(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0){this.clientRect=null;return}const e=this.hls.levels;if(e.length){const t=this.hls,i=this.getMaxLevel(e.length-1);i!==this.autoLevelCapping&&t.logger.log(`Setting autoLevelCapping to ${i}: ${e[i].height}p@${e[i].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),t.autoLevelCapping=i,t.autoLevelEnabled&&t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}getMaxLevel(e){const t=this.hls.levels;if(!t.length)return-1;const i=t.filter((s,r)=>this.isLevelAllowed(s)&&r<=e);return this.clientRect=null,rn.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}getDimensions(){if(this.clientRect)return this.clientRect;const e=this.media,t={width:0,height:0};if(e){const i=e.getBoundingClientRect();t.width=i.width,t.height=i.height,!t.width&&!t.height&&(t.width=i.right-i.left||e.width||0,t.height=i.bottom-i.top||e.height||0)}return this.clientRect=t,t}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch{}return Math.min(e,this.hls.config.maxDevicePixelRatio)}isLevelAllowed(e){return!this.restrictedLevels.some(i=>e.bitrate===i.bitrate&&e.width===i.width&&e.height===i.height)}static getMaxLevelByMediaSize(e,t,i){if(!(e!=null&&e.length))return-1;const s=(o,c)=>c?o.width!==c.width||o.height!==c.height:!0;let r=e.length-1;const n=Math.max(t,i);for(let o=0;o<e.length;o+=1){const c=e[o];if((c.width>=n||c.height>=n)&&s(c,e[o+1])){r=o;break}}return r}}const dt={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"},ad={HLS:"h"};class Ut{constructor(e,t){Array.isArray(e)&&(e=e.map(i=>i instanceof Ut?i:new Ut(i))),this.value=e,this.params=t}}const od="Dict";function ld(a){return Array.isArray(a)?JSON.stringify(a):a instanceof Map?"Map{}":a instanceof Set?"Set{}":typeof a=="object"?JSON.stringify(a):String(a)}function ud(a,e,t,i){return new Error(`failed to ${a} "${ld(e)}" as ${t}`,{cause:i})}function $t(a,e,t){return ud("serialize",a,e,t)}class Yo{constructor(e){this.description=e}}const Wo="Bare Item",cd="Boolean";function hd(a){if(typeof a!="boolean")throw $t(a,cd);return a?"?1":"?0"}function dd(a){return btoa(String.fromCharCode(...a))}const fd="Byte Sequence";function gd(a){if(ArrayBuffer.isView(a)===!1)throw $t(a,fd);return`:${dd(a)}:`}const pd="Integer";function Ad(a){return a<-999999999999999||999999999999999<a}function jo(a){if(Ad(a))throw $t(a,pd);return a.toString()}function md(a){return`@${jo(a.getTime()/1e3)}`}function zo(a,e){if(a<0)return-zo(-a,e);const t=Math.pow(10,e);if(Math.abs(a*t%1-.5)<Number.EPSILON){const s=Math.floor(a*t);return(s%2===0?s:s+1)/t}else return Math.round(a*t)/t}const Id="Decimal";function Cd(a){const e=zo(a,3);if(Math.floor(Math.abs(e)).toString().length>12)throw $t(a,Id);const t=e.toString();return t.includes(".")?t:`${t}.0`}const yd="String",Ed=/[\x00-\x1f\x7f]+/;function vd(a){if(Ed.test(a))throw $t(a,yd);return`"${a.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function Td(a){return a.description||a.toString().slice(7,-1)}const Sd="Token";function qo(a){const e=Td(a);if(/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(e)===!1)throw $t(e,Sd);return e}function nn(a){switch(typeof a){case"number":if(!se(a))throw $t(a,Wo);return Number.isInteger(a)?jo(a):Cd(a);case"string":return vd(a);case"symbol":return qo(a);case"boolean":return hd(a);case"object":if(a instanceof Date)return md(a);if(a instanceof Uint8Array)return gd(a);if(a instanceof Yo)return qo(a);default:throw $t(a,Wo)}}const xd="Key";function an(a){if(/^[a-z*][a-z0-9\-_.*]*$/.test(a)===!1)throw $t(a,xd);return a}function on(a){return a==null?"":Object.entries(a).map(([e,t])=>t===!0?`;${an(e)}`:`;${an(e)}=${nn(t)}`).join("")}function Xo(a){return a instanceof Ut?`${nn(a.value)}${on(a.params)}`:nn(a)}function bd(a){return`(${a.value.map(Xo).join(" ")})${on(a.params)}`}function Ld(a,e={whitespace:!0}){if(typeof a!="object"||a==null)throw $t(a,od);const t=a instanceof Map?a.entries():Object.entries(a),i=e?.whitespace?" ":"";return Array.from(t).map(([s,r])=>{r instanceof Ut||(r=new Ut(r));let n=an(s);return r.value===!0?n+=on(r.params):(n+="=",Array.isArray(r.value)?n+=bd(r):n+=Xo(r)),n}).join(`,${i}`)}function Zo(a,e){return Ld(a,e)}const Gt="CMCD-Object",Ke="CMCD-Request",Ei="CMCD-Session",li="CMCD-Status",Rd={br:Gt,ab:Gt,d:Gt,ot:Gt,tb:Gt,tpb:Gt,lb:Gt,tab:Gt,lab:Gt,url:Gt,pb:Ke,bl:Ke,tbl:Ke,dl:Ke,ltc:Ke,mtp:Ke,nor:Ke,nrr:Ke,rc:Ke,sn:Ke,sta:Ke,su:Ke,ttfb:Ke,ttfbb:Ke,ttlb:Ke,cmsdd:Ke,cmsds:Ke,smrt:Ke,df:Ke,cs:Ke,ts:Ke,cid:Ei,pr:Ei,sf:Ei,sid:Ei,st:Ei,v:Ei,msd:Ei,bs:li,bsd:li,cdn:li,rtp:li,bg:li,pt:li,ec:li,e:li},Dd={REQUEST:Ke};function Pd(a){return Object.keys(a).reduce((e,t)=>{var i;return(i=a[t])===null||i===void 0||i.forEach(s=>e[s]=t),e},{})}function _d(a,e){const t={};if(!a)return t;const i=Object.keys(a),s=e?Pd(e):{};return i.reduce((r,n)=>{var o;const c=Rd[n]||s[n]||Dd.REQUEST,u=(o=r[c])!==null&&o!==void 0?o:r[c]={};return u[n]=a[n],r},t)}function wd(a){return["ot","sf","st","e","sta"].includes(a)}function kd(a){return typeof a=="number"?se(a):a!=null&&a!==""&&a!==!1}const Qo="event";function Md(a,e){const t=new URL(a),i=new URL(e);if(t.origin!==i.origin)return a;const s=t.pathname.split("/").slice(1),r=i.pathname.split("/").slice(1,-1);for(;s[0]===r[0];)s.shift(),r.shift();for(;r.length;)r.shift(),s.unshift("..");return s.join("/")+t.search+t.hash}const Hs=a=>Math.round(a),ln=(a,e)=>Array.isArray(a)?a.map(t=>ln(t,e)):a instanceof Ut&&typeof a.value=="string"?new Ut(ln(a.value,e),a.params):(e.baseUrl&&(a=Md(a,e.baseUrl)),e.version===1?encodeURIComponent(a):a),Vs=a=>Hs(a/100)*100,Od={br:Hs,d:Hs,bl:Vs,dl:Vs,mtp:Vs,nor:(a,e)=>{let t=a;return e.version>=2&&(a instanceof Ut&&typeof a.value=="string"?t=new Ut([a]):typeof a=="string"&&(t=[a])),ln(t,e)},rtp:Vs,tb:Hs},Jo="request",el="response",un=["ab","bg","bl","br","bs","bsd","cdn","cid","cs","df","ec","lab","lb","ltc","msd","mtp","pb","pr","pt","sf","sid","sn","st","sta","tab","tb","tbl","tpb","ts","v"],Fd=["e"],Nd=/^[a-zA-Z0-9-.]+-[a-zA-Z0-9-.]+$/;function Ks(a){return Nd.test(a)}function Bd(a){return un.includes(a)||Fd.includes(a)||Ks(a)}const tl=["d","dl","nor","ot","rtp","su"];function Ud(a){return un.includes(a)||tl.includes(a)||Ks(a)}const $d=["cmsdd","cmsds","rc","smrt","ttfb","ttfbb","ttlb","url"];function Gd(a){return un.includes(a)||tl.includes(a)||$d.includes(a)||Ks(a)}const Hd=["bl","br","bs","cid","d","dl","mtp","nor","nrr","ot","pr","rtp","sf","sid","st","su","tb","v"];function Vd(a){return Hd.includes(a)||Ks(a)}const Kd={[el]:Gd,[Qo]:Bd,[Jo]:Ud};function il(a,e={}){const t={};if(a==null||typeof a!="object")return t;const i=e.version||a.v||1,s=e.reportingMode||Jo,r=i===1?Vd:Kd[s];let n=Object.keys(a).filter(r);const o=e.filter;typeof o=="function"&&(n=n.filter(o));const c=s===el||s===Qo;c&&!n.includes("ts")&&n.push("ts"),i>1&&!n.includes("v")&&n.push("v");const u=Ne({},Od,e.formatters),h={version:i,reportingMode:s,baseUrl:e.baseUrl};return n.sort().forEach(f=>{let g=a[f];const I=u[f];if(typeof I=="function"&&(g=I(g,h)),f==="v"){if(i===1)return;g=i}f=="pr"&&g===1||(c&&f==="ts"&&!se(g)&&(g=Date.now()),kd(g)&&(wd(f)&&typeof g=="string"&&(g=new Yo(g)),t[f]=g))}),t}function Yd(a,e={}){const t={};if(!a)return t;const i=il(a,e),s=_d(i,e?.customHeaderMap);return Object.entries(s).reduce((r,[n,o])=>{const c=Zo(o,{whitespace:!1});return c&&(r[n]=c),r},t)}function Wd(a,e,t){return Ne(a,Yd(e,t))}const jd="CMCD";function zd(a,e={}){return a?Zo(il(a,e),{whitespace:!1}):""}function qd(a,e={}){if(!a)return"";const t=zd(a,e);return encodeURIComponent(t)}function Xd(a,e={}){if(!a)return"";const t=qd(a,e);return`${jd}=${t}`}const sl=/CMCD=[^&#]+/;function Zd(a,e,t){const i=Xd(e,t);if(!i)return a;if(sl.test(a))return a.replace(sl,i);const s=a.includes("?")?"&":"?";return`${a}${s}${i}`}class Qd{constructor(e){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.includeKeys=void 0,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=s=>{try{this.apply(s,{ot:dt.MANIFEST,su:!this.initialized})}catch(r){this.hls.logger.warn("Could not generate manifest CMCD data.",r)}},this.applyFragmentData=s=>{try{const{frag:r,part:n}=s,o=this.hls.levels[r.level],c=this.getObjectType(r),u={d:(n||r).duration*1e3,ot:c};(c===dt.VIDEO||c===dt.AUDIO||c==dt.MUXED)&&(u.br=o.bitrate/1e3,u.tb=this.getTopBandwidth(c)/1e3,u.bl=this.getBufferLength(c));const h=n?this.getNextPart(n):this.getNextFrag(r);h!=null&&h.url&&h.url!==r.url&&(u.nor=h.url),this.apply(s,u)}catch(r){this.hls.logger.warn("Could not generate segment CMCD data.",r)}},this.hls=e;const t=this.config=e.config,{cmcd:i}=t;i!=null&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=i.sessionId||e.sessionId,this.cid=i.contentId,this.useHeaders=i.useHeaders===!0,this.includeKeys=i.includeKeys,this.registerListeners())}registerListeners(){const e=this.hls;e.on(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(y.MEDIA_DETACHED,this.onMediaDetached,this),e.on(y.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const e=this.hls;e.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(y.MEDIA_DETACHED,this.onMediaDetached,this),e.off(y.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=this.media=null}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(e,t){var i,s;this.audioBuffer=(i=t.tracks.audio)==null?void 0:i.buffer,this.videoBuffer=(s=t.tracks.video)==null?void 0:s.buffer}createData(){var e;return{v:1,sf:ad.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){Ne(t,this.createData());const i=t.ot===dt.INIT||t.ot===dt.VIDEO||t.ot===dt.MUXED;this.starved&&i&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering);const{includeKeys:s}=this;s&&(t=Object.keys(t).reduce((n,o)=>(s.includes(o)&&(n[o]=t[o]),n),{}));const r={baseUrl:e.url};this.useHeaders?(e.headers||(e.headers={}),Wd(e.headers,t,r)):e.url=Zd(e.url,t,r)}getNextFrag(e){var t;const i=(t=this.hls.levels[e.level])==null?void 0:t.details;if(i){const s=e.sn-i.startSN;return i.fragments[s+1]}}getNextPart(e){var t;const{index:i,fragment:s}=e,r=(t=this.hls.levels[s.level])==null||(t=t.details)==null?void 0:t.partList;if(r){const{sn:n}=s;for(let o=r.length-1;o>=0;o--){const c=r[o];if(c.index===i&&c.fragment.sn===n)return r[o+1]}}}getObjectType(e){const{type:t}=e;if(t==="subtitle")return dt.TIMED_TEXT;if(e.sn==="initSegment")return dt.INIT;if(t==="audio")return dt.AUDIO;if(t==="main")return this.hls.audioTracks.length?dt.VIDEO:dt.MUXED}getTopBandwidth(e){let t=0,i;const s=this.hls;if(e===dt.AUDIO)i=s.audioTracks;else{const r=s.maxAutoLevel,n=r>-1?r+1:s.levels.length;i=s.levels.slice(0,n)}return i.forEach(r=>{r.bitrate>t&&(t=r.bitrate)}),t>0?t:NaN}getBufferLength(e){const t=this.media,i=e===dt.AUDIO?this.audioBuffer:this.videoBuffer;return!i||!t?NaN:ye.bufferInfo(i,t.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){const{pLoader:e}=this.config,t=this.applyPlaylistData,i=e||this.config.loader;return class{constructor(r){this.loader=void 0,this.loader=new i(r)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(r,n,o){t(r),this.loader.load(r,n,o)}}}createFragmentLoader(){const{fLoader:e}=this.config,t=this.applyFragmentData,i=e||this.config.loader;return class{constructor(r){this.loader=void 0,this.loader=new i(r)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(r,n,o){t(r),this.loader.load(r,n,o)}}}}const Jd=3e5;class ef extends Tt{constructor(e){super("content-steering",e.logger),this.hls=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this._pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.registerListeners()}registerListeners(){const e=this.hls;e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(y.ERROR,this.onError,this)}unregisterListeners(){const e=this.hls;e&&(e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(y.ERROR,this.onError,this))}pathways(){return(this.levels||[]).reduce((e,t)=>(e.indexOf(t.pathwayId)===-1&&e.push(t.pathwayId),e),[])}get pathwayPriority(){return this._pathwayPriority}set pathwayPriority(e){this.updatePathwayPriority(e)}startLoad(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){const e=this.timeToLoad*1e3-(performance.now()-this.updated);if(e>0){this.scheduleRefresh(this.uri,e);return}}this.loadSteeringManifest(this.uri)}}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}clearTimeout(){this.reloadTimer!==-1&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(e){const t=this.levels;t&&(this.levels=t.filter(i=>i!==e))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(e,t){const{contentSteering:i}=t;i!==null&&(this.pathwayId=i.pathwayId,this.uri=i.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){const{errorAction:i}=t;if(i?.action===rt.SendAlternateToPenaltyBox&&i.flags===Ct.MoveAllAlternatesMatchingHost){const s=this.levels;let r=this._pathwayPriority,n=this.pathwayId;if(t.context){const{groupId:o,pathwayId:c,type:u}=t.context;o&&s?n=this.getPathwayForGroupId(o,u,n):c&&(n=c)}n in this.penalizedPathways||(this.penalizedPathways[n]=performance.now()),!r&&s&&(r=this.pathways()),r&&r.length>1&&(this.updatePathwayPriority(r),i.resolved=this.pathwayId!==n),t.details===U.BUFFER_APPEND_ERROR&&!t.fatal?i.resolved=!0:i.resolved||this.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${n} levels: ${s&&s.length} priorities: ${Ge(r)} penalized: ${Ge(this.penalizedPathways)}`)}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){const i=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${i}"`),t=this.getLevelsForPathway(i),this.pathwayId=i}return t.length!==e.length&&this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t}getLevelsForPathway(e){return this.levels===null?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){this._pathwayPriority=e;let t;const i=this.penalizedPathways,s=performance.now();Object.keys(i).forEach(r=>{s-i[r]>Jd&&delete i[r]});for(let r=0;r<e.length;r++){const n=e[r];if(n in i)continue;if(n===this.pathwayId)return;const o=this.hls.nextLoadLevel,c=this.hls.levels[o];if(t=this.getLevelsForPathway(n),t.length>0){this.log(`Setting Pathway to "${n}"`),this.pathwayId=n,oo(t),this.hls.trigger(y.LEVELS_UPDATED,{levels:t});const u=this.hls.levels[o];c&&u&&this.levels&&(u.attrs["STABLE-VARIANT-ID"]!==c.attrs["STABLE-VARIANT-ID"]&&u.bitrate!==c.bitrate&&this.log(`Unstable Pathways change from bitrate ${c.bitrate} to ${u.bitrate}`),this.hls.nextLoadLevel=o);break}}}getPathwayForGroupId(e,t,i){const s=this.getLevelsForPathway(i).concat(this.levels||[]);for(let r=0;r<s.length;r++)if(t===be.AUDIO_TRACK&&s[r].hasAudioGroup(e)||t===be.SUBTITLE_TRACK&&s[r].hasSubtitleGroup(e))return s[r].pathwayId;return i}clonePathways(e){const t=this.levels;if(!t)return;const i={},s={};e.forEach(r=>{const{ID:n,"BASE-ID":o,"URI-REPLACEMENT":c}=r;if(t.some(h=>h.pathwayId===n))return;const u=this.getLevelsForPathway(o).map(h=>{const f=new He(h.attrs);f["PATHWAY-ID"]=n;const g=f.AUDIO&&`${f.AUDIO}_clone_${n}`,I=f.SUBTITLES&&`${f.SUBTITLES}_clone_${n}`;g&&(i[f.AUDIO]=g,f.AUDIO=g),I&&(s[f.SUBTITLES]=I,f.SUBTITLES=I);const m=nl(h.uri,f["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",c),E=new Zi({attrs:f,audioCodec:h.audioCodec,bitrate:h.bitrate,height:h.height,name:h.name,url:m,videoCodec:h.videoCodec,width:h.width});if(h.audioGroups)for(let v=1;v<h.audioGroups.length;v++)E.addGroupId("audio",`${h.audioGroups[v]}_clone_${n}`);if(h.subtitleGroups)for(let v=1;v<h.subtitleGroups.length;v++)E.addGroupId("text",`${h.subtitleGroups[v]}_clone_${n}`);return E});t.push(...u),rl(this.audioTracks,i,c,n),rl(this.subtitleTracks,s,c,n)})}loadSteeringManifest(e){const t=this.hls.config,i=t.loader;this.loader&&this.loader.destroy(),this.loader=new i(t);let s;try{s=new self.URL(e)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${e}`);return}if(s.protocol!=="data:"){const h=(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate)|0;s.searchParams.set("_HLS_pathway",this.pathwayId),s.searchParams.set("_HLS_throughput",""+h)}const r={responseType:"json",url:s.href},n=t.steeringManifestLoadPolicy.default,o=n.errorRetry||n.timeoutRetry||{},c={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:o.maxNumRetry||0,retryDelay:o.retryDelayMs||0,maxRetryDelay:o.maxRetryDelayMs||0},u={onSuccess:(h,f,g,I)=>{this.log(`Loaded steering manifest: "${s}"`);const m=h.data;if(m?.VERSION!==1){this.log(`Steering VERSION ${m.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=m.TTL;const{"RELOAD-URI":E,"PATHWAY-CLONES":v,"PATHWAY-PRIORITY":x}=m;if(E)try{this.uri=new self.URL(E,s).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${E}`);return}this.scheduleRefresh(this.uri||g.url),v&&this.clonePathways(v);const D={steeringManifest:m,url:s.toString()};this.hls.trigger(y.STEERING_MANIFEST_LOADED,D),x&&this.updatePathwayPriority(x)},onError:(h,f,g,I)=>{if(this.log(`Error loading steering manifest: ${h.code} ${h.text} (${f.url})`),this.stopLoad(),h.code===410){this.enabled=!1,this.log(`Steering manifest ${f.url} no longer available`);return}let m=this.timeToLoad*1e3;if(h.code===429){const E=this.loader;if(typeof E?.getResponseHeader=="function"){const v=E.getResponseHeader("Retry-After");v&&(m=parseFloat(v)*1e3)}this.log(`Steering manifest ${f.url} rate limited`);return}this.scheduleRefresh(this.uri||f.url,m)},onTimeout:(h,f,g)=>{this.log(`Timeout loading steering manifest (${f.url})`),this.scheduleRefresh(this.uri||f.url)}};this.log(`Requesting steering manifest: ${s}`),this.loader.load(r,c,u)}scheduleRefresh(e,t=this.timeToLoad*1e3){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var i;const s=(i=this.hls)==null?void 0:i.media;if(s&&!s.ended){this.loadSteeringManifest(e);return}this.scheduleRefresh(e,this.timeToLoad*1e3)},t)}}function rl(a,e,t,i){a&&Object.keys(e).forEach(s=>{const r=a.filter(n=>n.groupId===s).map(n=>{const o=Ne({},n);return o.details=void 0,o.attrs=new He(o.attrs),o.url=o.attrs.URI=nl(n.url,n.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",t),o.groupId=o.attrs["GROUP-ID"]=e[s],o.attrs["PATHWAY-ID"]=i,o});a.push(...r)})}function nl(a,e,t,i){const{HOST:s,PARAMS:r,[t]:n}=i;let o;e&&(o=n?.[e],o&&(a=o));const c=new self.URL(a);return s&&!o&&(c.host=s),r&&Object.keys(r).sort().forEach(u=>{u&&c.searchParams.set(u,r[u])}),c.href}class Ni extends Tt{constructor(e){super("eme",e.logger),this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.mediaKeys=null,this.setMediaKeysQueue=Ni.CDMCleanupPromise?[Ni.CDMCleanupPromise]:[],this.bannedKeyIds={},this.onMediaEncrypted=t=>{const{initDataType:i,initData:s}=t,r=`"${t.type}" event: init data type: "${i}"`;if(this.debug(r),s!==null){if(!this.keyFormatPromise){let n=Object.keys(this.keySystemAccessPromises);n.length||(n=Qi(this.config));const o=n.map(Mr).filter(c=>!!c);this.keyFormatPromise=this.getKeyFormatPromise(o)}this.keyFormatPromise.then(n=>{const o=_s(n);if(i!=="sinf"||o!==Ve.FAIRPLAY){this.log(`Ignoring "${t.type}" event with init data type: "${i}" for selected key-system ${o}`);return}let c;try{const I=Ze(new Uint8Array(s)),m=wr(JSON.parse(I).sinf),E=la(m);if(!E)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");c=new Uint8Array(E.subarray(8,24))}catch(I){this.warn(`${r} Failed to parse sinf: ${I}`);return}const u=It(c),{keyIdToKeySessionPromise:h,mediaKeySessions:f}=this;let g=h[u];for(let I=0;I<f.length;I++){const m=f[I],E=m.decryptdata;if(!E.keyId)continue;const v=It(E.keyId);if(u===v||E.uri.replace(/-/g,"").indexOf(u)!==-1){if(g=h[v],!g)continue;if(E.pssh)break;delete h[v],E.pssh=new Uint8Array(s),E.keyId=c,g=h[u]=g.then(()=>this.generateRequestWithPreferredKeySession(m,i,s,"encrypted-event-key-match")),g.catch(x=>this.handleError(x));break}}g||this.handleError(new Error(`Key ID ${u} not encountered in playlist. Key-system sessions ${f.length}.`))}).catch(n=>this.handleError(n))}},this.onWaitingForKey=t=>{this.log(`"${t.type}" event`)},this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.onDestroying(),this.onMediaDetached();const e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.config=this.keyIdToKeySessionPromise=null,this.onMediaEncrypted=this.onWaitingForKey=null}registerListeners(){this.hls.on(y.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(y.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(y.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(y.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.on(y.DESTROYING,this.onDestroying,this)}unregisterListeners(){this.hls.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(y.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(y.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(y.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.off(y.DESTROYING,this.onDestroying,this)}getLicenseServerUrl(e){const{drmSystems:t,widevineLicenseUrl:i}=this.config,s=t?.[e];if(s)return s.licenseUrl;if(e===Ve.WIDEVINE&&i)return i}getLicenseServerUrlOrThrow(e){const t=this.getLicenseServerUrl(e);if(t===void 0)throw new Error(`no license server URL configured for key-system "${e}"`);return t}getServerCertificateUrl(e){const{drmSystems:t}=this.config,i=t?.[e];if(i)return i.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){const t=this.hls.levels,i=(n,o,c)=>!!n&&c.indexOf(n)===o,s=t.map(n=>n.audioCodec).filter(i),r=t.map(n=>n.videoCodec).filter(i);return s.length+r.length===0&&r.push("avc1.42e01e"),new Promise((n,o)=>{const c=u=>{const h=u.shift();this.getMediaKeysPromise(h,s,r).then(f=>n({keySystem:h,mediaKeys:f})).catch(f=>{u.length?c(u):f instanceof Dt?o(f):o(new Dt({type:de.KEY_SYSTEM_ERROR,details:U.KEY_SYSTEM_NO_ACCESS,error:f,fatal:!0},f.message))})};c(e)})}requestMediaKeySystemAccess(e,t){const{requestMediaKeySystemAccessFunc:i}=this.config;if(typeof i!="function"){let s=`Configured requestMediaKeySystemAccess is not a function ${i}`;return Va===null&&self.location.protocol==="http:"&&(s=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(s))}return i(e,t)}getMediaKeysPromise(e,t,i){var s;const r=Nc(e,t,i,this.config.drmSystemOptions||{});let n=this.keySystemAccessPromises[e],o=(s=n)==null?void 0:s.keySystemAccess;if(!o){this.log(`Requesting encrypted media "${e}" key-system access with config: ${Ge(r)}`),o=this.requestMediaKeySystemAccess(e,r);const c=n=this.keySystemAccessPromises[e]={keySystemAccess:o};return o.catch(u=>{this.log(`Failed to obtain access to key-system "${e}": ${u}`)}),o.then(u=>{this.log(`Access for key-system "${u.keySystem}" obtained`);const h=this.fetchServerCertificate(e);this.log(`Create media-keys for "${e}"`);const f=c.mediaKeys=u.createMediaKeys().then(g=>(this.log(`Media-keys created for "${e}"`),c.hasMediaKeys=!0,h.then(I=>I?this.setMediaKeysServerCertificate(g,e,I):g)));return f.catch(g=>{this.error(`Failed to create media-keys for "${e}"}: ${g}`)}),f})}return o.then(()=>n.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:i}){this.log(`Creating key-system session "${t}" keyId: ${It(e.keyId||[])}`);const s=i.createSession(),r={decryptdata:e,keySystem:t,mediaKeys:i,mediaKeysSession:s,keyStatus:"status-pending"};return this.mediaKeySessions.push(r),r}renewKeySession(e){const t=e.decryptdata;if(t.pssh){const i=this.createMediaKeySessionContext(e),s=this.getKeyIdString(t),r="cenc";this.keyIdToKeySessionPromise[s]=this.generateRequestWithPreferredKeySession(i,r,t.pssh.buffer,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}getKeyIdString(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(e.keyId===null)throw new Error("keyId is null");return It(e.keyId)}updateKeySession(e,t){const i=e.mediaKeysSession;return this.log(`Updating key-session "${i.sessionId}" for keyId ${It(e.decryptdata.keyId||[])}
28
- } (data length: ${t.byteLength})`),i.update(t)}getSelectedKeySystemFormats(){return Object.keys(this.keySystemAccessPromises).map(e=>({keySystem:e,hasMediaKeys:this.keySystemAccessPromises[e].hasMediaKeys})).filter(({hasMediaKeys:e})=>!!e).map(({keySystem:e})=>Mr(e)).filter(e=>!!e)}getKeySystemAccess(e){return this.getKeySystemSelectionPromise(e).then(({keySystem:t,mediaKeys:i})=>this.attemptSetMediaKeys(t,i))}selectKeySystem(e){return new Promise((t,i)=>{this.getKeySystemSelectionPromise(e).then(({keySystem:s})=>{const r=Mr(s);r?t(r):i(new Error(`Unable to find format for key-system "${s}"`))}).catch(i)})}selectKeySystemFormat(e){const t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}getKeyFormatPromise(e){const t=Qi(this.config),i=e.map(_s).filter(s=>!!s&&t.indexOf(s)!==-1);return this.selectKeySystem(i)}loadKey(e){const t=e.keyInfo.decryptdata,i=this.getKeyIdString(t),s=this.bannedKeyIds[i];if(s){const o=al(s,t);return this.handleError(o,e.frag),Promise.reject(o)}const r=`(keyId: ${i} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${r}`);const n=this.keyIdToKeySessionPromise[i];if(!n){const o=this.getKeySystemForKeyPromise(t).then(({keySystem:c,mediaKeys:u})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${r}`),this.attemptSetMediaKeys(c,u).then(()=>(this.throwIfDestroyed(),this.createMediaKeySessionContext({keySystem:c,mediaKeys:u,decryptdata:t}))))).then(c=>{const u="cenc",h=t.pssh?t.pssh.buffer:null;return this.generateRequestWithPreferredKeySession(c,u,h,"playlist-key")});return o.catch(c=>this.handleError(c,e.frag)),this.keyIdToKeySessionPromise[i]=o,o}return n}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e,t){this.hls&&(this.error(e.message),e instanceof Dt?(t&&(e.data.frag=t),this.hls.trigger(y.ERROR,e.data)):this.hls.trigger(y.ERROR,{type:de.KEY_SYSTEM_ERROR,details:U.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))}getKeySystemForKeyPromise(e){const t=this.getKeyIdString(e),i=this.keyIdToKeySessionPromise[t];if(!i){const s=_s(e.keyFormat),r=s?[s]:Qi(this.config);return this.attemptKeySystemAccess(r)}return i}getKeySystemSelectionPromise(e){if(e.length||(e=Qi(this.config)),e.length===0)throw new Dt({type:de.KEY_SYSTEM_ERROR,details:U.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${Ge({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}attemptSetMediaKeys(e,t){if(this.mediaKeys===t)return Promise.resolve();const i=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);const s=Promise.all(i).then(()=>{if(!this.media)throw this.mediaKeys=null,new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(t)});return this.mediaKeys=t,this.setMediaKeysQueue.push(s),s.then(()=>{this.log(`Media-keys set for "${e}"`),i.push(s),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(r=>i.indexOf(r)===-1)})}generateRequestWithPreferredKeySession(e,t,i,s){var r;const n=(r=this.config.drmSystems)==null||(r=r[e.keySystem])==null?void 0:r.generateRequest;if(n)try{const g=n.call(this.hls,t,i,e);if(!g)throw new Error("Invalid response from configured generateRequest filter");t=g.initDataType,i=g.initData?g.initData:null,e.decryptdata.pssh=i?new Uint8Array(i):null}catch(g){if(this.warn(g.message),this.hls&&this.hls.config.debug)throw g}if(i===null)return this.log(`Skipping key-session request for "${s}" (no initData)`),Promise.resolve(e);const o=this.getKeyIdString(e.decryptdata);this.log(`Generating key-session request for "${s}": ${o} (init data type: ${t} length: ${i.byteLength})`);const c=new Gr,u=e._onmessage=g=>{const I=e.mediaKeysSession;if(!I){c.emit("error",new Error("invalid state"));return}const{messageType:m,message:E}=g;this.log(`"${m}" message event for session "${I.sessionId}" message size: ${E.byteLength}`),m==="license-request"||m==="license-renewal"?this.renewLicense(e,E).catch(v=>{c.eventNames().length?c.emit("error",v):this.handleError(v)}):m==="license-release"?e.keySystem===Ve.FAIRPLAY&&(this.updateKeySession(e,kr("acknowledged")),this.removeSession(e)):this.warn(`unhandled media key message type "${m}"`)},h=e._onkeystatuseschange=g=>{if(!e.mediaKeysSession){c.emit("error",new Error("invalid state"));return}const m=e.keyStatus;this.onKeyStatusChange(e);const E=e.keyStatus;E!==m&&(c.emit("keyStatus",E,e),E==="expired"&&(this.log(`${e.keySystem} expired for key ${o}`),this.renewKeySession(e)))};ot(e.mediaKeysSession,"message",u),ot(e.mediaKeysSession,"keystatuseschange",h);const f=new Promise((g,I)=>{c.on("error",I),c.on("keyStatus",(m,{decryptdata:E})=>{m.startsWith("usable")?g():m==="internal-error"||m==="output-restricted"?I(al(m,E)):m==="expired"?I(new Error(`key expired while generating request (keyId: ${o})`)):this.warn(`unhandled key status change "${m}" (keyId: ${o})`)})});return e.mediaKeysSession.generateRequest(t,i).then(()=>{this.log(`Request generated for key-session "${e.mediaKeysSession.sessionId}" keyId: ${o}`)}).catch(g=>{throw new Dt({type:de.KEY_SYSTEM_ERROR,details:U.KEY_SYSTEM_NO_SESSION,error:g,decryptdata:e.decryptdata,fatal:!1},`Error generating key-session request: ${g}`)}).then(()=>f).catch(g=>{throw c.removeAllListeners(),this.removeSession(e),g}).then(()=>(c.removeAllListeners(),e))}onKeyStatusChange(e){const t=It(new Uint8Array(e.decryptdata.keyId||[]));e.mediaKeysSession.keyStatuses.forEach((i,s)=>{if(typeof s=="string"&&typeof i=="object"){const o=s;s=i,i=o}const r=It("buffer"in s?new Uint8Array(s.buffer,s.byteOffset,s.byteLength):new Uint8Array(s));i==="internal-error"&&(this.bannedKeyIds[r]=i);const n=r===t;this.log(`${n?"":"un"}matched key status change "${i}" for keyStatuses keyId: ${r} session keyId: ${t} uri: ${e.decryptdata.uri}`),n&&(e.keyStatus=i)})}fetchServerCertificate(e){const t=this.config,i=t.loader,s=new i(t),r=this.getServerCertificateUrl(e);return r?(this.log(`Fetching server certificate for "${e}"`),new Promise((n,o)=>{const c={responseType:"arraybuffer",url:r},u=t.certLoadPolicy.default,h={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},f={onSuccess:(g,I,m,E)=>{n(g.data)},onError:(g,I,m,E)=>{o(new Dt({type:de.KEY_SYSTEM_ERROR,details:U.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:m,response:Be({url:c.url,data:void 0},g)},`"${e}" certificate request failed (${r}). Status: ${g.code} (${g.text})`))},onTimeout:(g,I,m)=>{o(new Dt({type:de.KEY_SYSTEM_ERROR,details:U.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:m,response:{url:c.url,data:void 0}},`"${e}" certificate request timed out (${r})`))},onAbort:(g,I,m)=>{o(new Error("aborted"))}};s.load(c,h,f)})):Promise.resolve()}setMediaKeysServerCertificate(e,t,i){return new Promise((s,r)=>{e.setServerCertificate(i).then(n=>{this.log(`setServerCertificate ${n?"success":"not supported by CDM"} (${i.byteLength}) on "${t}"`),s(e)}).catch(n=>{r(new Dt({type:de.KEY_SYSTEM_ERROR,details:U.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:n,fatal:!0},n.message))})})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(i=>this.updateKeySession(e,new Uint8Array(i)).catch(s=>{throw new Dt({type:de.KEY_SYSTEM_ERROR,details:U.KEY_SYSTEM_SESSION_UPDATE_FAILED,decryptdata:e.decryptdata,error:s,fatal:!1},s.message)}))}unpackPlayReadyKeyMessage(e,t){const i=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!i.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;const s=new DOMParser().parseFromString(i,"application/xml"),r=s.querySelectorAll("HttpHeader");if(r.length>0){let h;for(let f=0,g=r.length;f<g;f++){var n,o;h=r[f];const I=(n=h.querySelector("name"))==null?void 0:n.textContent,m=(o=h.querySelector("value"))==null?void 0:o.textContent;I&&m&&e.setRequestHeader(I,m)}}const c=s.querySelector("Challenge"),u=c?.textContent;if(!u)throw new Error("Cannot find <Challenge> in key message");return kr(atob(u))}setupLicenseXHR(e,t,i,s){const r=this.config.licenseXhrSetup;return r?Promise.resolve().then(()=>{if(!i.decryptdata)throw new Error("Key removed");return r.call(this.hls,e,t,i,s)}).catch(n=>{if(!i.decryptdata)throw n;return e.open("POST",t,!0),r.call(this.hls,e,t,i,s)}).then(n=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:n||s})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:s}))}requestLicense(e,t){const i=this.config.keyLoadPolicy.default;return new Promise((s,r)=>{const n=this.getLicenseServerUrlOrThrow(e.keySystem);this.log(`Sending license request to URL: ${n}`);const o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return r(new Error("invalid state"));if(o.readyState===4)if(o.status===200){this._requestLicenseFailureCount=0;let c=o.response;this.log(`License received ${c instanceof ArrayBuffer?c.byteLength:c}`);const u=this.config.licenseResponseCallback;if(u)try{c=u.call(this.hls,o,n,e)}catch(h){this.error(h)}s(c)}else{const c=i.errorRetry,u=c?c.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>u||o.status>=400&&o.status<500)r(new Dt({type:de.KEY_SYSTEM_ERROR,details:U.KEY_SYSTEM_LICENSE_REQUEST_FAILED,decryptdata:e.decryptdata,fatal:!0,networkDetails:o,response:{url:n,data:void 0,code:o.status,text:o.statusText}},`License Request XHR failed (${n}). Status: ${o.status} (${o.statusText})`));else{const h=u-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${h} attempts left`),this.requestLicense(e,t).then(s,r)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,this.setupLicenseXHR(o,n,e,t).then(({xhr:c,licenseChallenge:u})=>{e.keySystem==Ve.PLAYREADY&&(u=this.unpackPlayReadyKeyMessage(c,u)),c.send(u)}).catch(r)})}onDestroying(){this.unregisterListeners(),this._clear()}onMediaAttached(e,t){if(!this.config.emeEnabled)return;const i=t.media;this.media=i,ot(i,"encrypted",this.onMediaEncrypted),ot(i,"waitingforkey",this.onWaitingForKey)}onMediaDetached(){const e=this.media;e&&(ht(e,"encrypted",this.onMediaEncrypted),ht(e,"waitingforkey",this.onWaitingForKey),this.media=null,this.mediaKeys=null)}_clear(){var e;if(this._requestLicenseFailureCount=0,this.keyIdToKeySessionPromise={},this.bannedKeyIds={},!this.mediaKeys&&!this.mediaKeySessions.length)return;const t=this.media,i=this.mediaKeySessions.slice();this.mediaKeySessions=[],this.mediaKeys=null,ks.clearKeyUriToKeyIdMap();const s=i.length;Ni.CDMCleanupPromise=Promise.all(i.map(r=>this.removeSession(r)).concat(t==null||(e=t.setMediaKeys(null))==null?void 0:e.catch(r=>{this.log(`Could not clear media keys: ${r}`),this.hls&&this.hls.trigger(y.ERROR,{type:de.OTHER_ERROR,details:U.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR,fatal:!1,error:new Error(`Could not clear media keys: ${r}`)})}))).catch(r=>{this.log(`Could not close sessions and clear media keys: ${r}`),this.hls&&this.hls.trigger(y.ERROR,{type:de.OTHER_ERROR,details:U.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close sessions and clear media keys: ${r}`)})}).then(()=>{s&&this.log("finished closing key sessions and clearing media keys")})}onManifestLoading(){this.keyFormatPromise=null,this.bannedKeyIds={}}onManifestLoaded(e,{sessionKeys:t}){if(!(!t||!this.config.emeEnabled)&&!this.keyFormatPromise){const i=t.reduce((s,r)=>(s.indexOf(r.keyFormat)===-1&&s.push(r.keyFormat),s),[]);this.log(`Selecting key-system from session-keys ${i.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(i)}}removeSession(e){const{mediaKeysSession:t,licenseXhr:i,decryptdata:s}=e;if(t){this.log(`Remove licenses and keys and close session "${t.sessionId}" keyId: ${It(s?.keyId||[])}`),e._onmessage&&(t.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(t.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),i&&i.readyState!==XMLHttpRequest.DONE&&i.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;const r=this.mediaKeySessions.indexOf(e);r>-1&&this.mediaKeySessions.splice(r,1);const{drmSystemOptions:n}=this.config;return(Uc(n)?new Promise((c,u)=>{self.setTimeout(()=>u(new Error("MediaKeySession.remove() timeout")),8e3),t.remove().then(c).catch(u)}):Promise.resolve()).catch(c=>{this.log(`Could not remove session: ${c}`),this.hls&&this.hls.trigger(y.ERROR,{type:de.OTHER_ERROR,details:U.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR,fatal:!1,error:new Error(`Could not remove session: ${c}`)})}).then(()=>t.close()).catch(c=>{this.log(`Could not close session: ${c}`),this.hls&&this.hls.trigger(y.ERROR,{type:de.OTHER_ERROR,details:U.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close session: ${c}`)})})}}}Ni.CDMCleanupPromise=void 0;class Dt extends Error{constructor(e,t){super(t),this.data=void 0,e.error||(e.error=new Error(t)),this.data=e,e.err=e.error}}function al(a,e){const t=a==="output-restricted",i=t?U.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:U.KEY_SYSTEM_STATUS_INTERNAL_ERROR;return new Dt({type:de.KEY_SYSTEM_ERROR,details:i,fatal:!1,decryptdata:e},t?"HDCP level output restricted":`key status changed to "${a}"`)}class tf{constructor(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners()}setStreamController(e){this.streamController=e}registerListeners(){this.hls.on(y.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(y.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListeners(){this.hls.off(y.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(y.MEDIA_DETACHING,this.onMediaDetaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){const i=this.hls.config;if(i.capLevelOnFPSDrop){const 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),i.fpsDroppedMonitoringPeriod)}}onMediaDetaching(){this.media=null}checkFPS(e,t,i){const s=performance.now();if(t){if(this.lastTime){const r=s-this.lastTime,n=i-this.lastDroppedFrames,o=t-this.lastDecodedFrames,c=1e3*n/r,u=this.hls;if(u.trigger(y.FPS_DROP,{currentDropped:n,currentDecoded:o,totalDroppedFrames:i}),c>0&&n>u.config.fpsDroppedMonitoringThreshold*o){let h=u.currentLevel;u.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+h),h>0&&(u.autoLevelCapping===-1||u.autoLevelCapping>=h)&&(h=h-1,u.trigger(y.FPS_DROP_LEVEL_CAPPING,{level:h,droppedLevel:u.currentLevel}),u.autoLevelCapping=h,this.streamController.nextLevelSwitch())}}this.lastTime=s,this.lastDroppedFrames=i,this.lastDecodedFrames=t}}checkFPSInterval(){const e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){const t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}}function ol(a,e){let t;try{t=new Event("addtrack")}catch{t=document.createEvent("Event"),t.initEvent("addtrack",!1,!1)}t.track=a,e.dispatchEvent(t)}function ll(a,e){const t=a.mode;if(t==="disabled"&&(a.mode="hidden"),a.cues&&!a.cues.getCueById(e.id))try{if(a.addCue(e),!a.cues.getCueById(e.id))throw new Error(`addCue is failed for: ${e}`)}catch(i){Oe.debug(`[texttrack-utils]: ${i}`);try{const s=new self.TextTrackCue(e.startTime,e.endTime,e.text);s.id=e.id,a.addCue(s)}catch(s){Oe.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${s}`)}}t==="disabled"&&(a.mode=t)}function Bi(a,e){const t=a.mode;if(t==="disabled"&&(a.mode="hidden"),a.cues)for(let i=a.cues.length;i--;)e&&a.cues[i].removeEventListener("enter",e),a.removeCue(a.cues[i]);t==="disabled"&&(a.mode=t)}function cn(a,e,t,i){const s=a.mode;if(s==="disabled"&&(a.mode="hidden"),a.cues&&a.cues.length>0){const r=rf(a.cues,e,t);for(let n=0;n<r.length;n++)(!i||i(r[n]))&&a.removeCue(r[n])}s==="disabled"&&(a.mode=s)}function sf(a,e){if(e<=a[0].startTime)return 0;const t=a.length-1;if(e>a[t].endTime)return-1;let i=0,s=t,r;for(;i<=s;)if(r=Math.floor((s+i)/2),e<a[r].startTime)s=r-1;else if(e>a[r].startTime&&i<t)i=r+1;else return r;return a[i].startTime-e<e-a[s].startTime?i:s}function rf(a,e,t){const i=[],s=sf(a,e);if(s>-1)for(let r=s,n=a.length;r<n;r++){const o=a[r];if(o.startTime>=e&&o.endTime<=t)i.push(o);else if(o.startTime>t)return i}return i}function Ys(a){const e=[];for(let t=0;t<a.length;t++){const i=a[t];(i.kind==="subtitles"||i.kind==="captions")&&i.label&&e.push(a[t])}return e}class nf extends en{constructor(e){super(e,"subtitle-track-controller"),this.media=null,this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.onTextTracksChanged=()=>{if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let t=null;const i=Ys(this.media.textTracks);for(let r=0;r<i.length;r++)if(i[r].mode==="hidden")t=i[r];else if(i[r].mode==="showing"){t=i[r];break}const s=this.findTrackForTextTrack(t);this.subtitleTrack!==s&&this.setSubtitleTrack(s)},this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes()}registerListeners(){const{hls:e}=this;e.on(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(y.LEVEL_LOADING,this.onLevelLoading,this),e.on(y.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(y.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(y.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(y.LEVEL_LOADING,this.onLevelLoading,this),e.off(y.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(y.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(y.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))}pollTrackChange(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.onTextTracksChanged,e)}onMediaDetaching(e,t){const i=this.media;if(!i)return;const s=!!t.transferMedia;if(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||i.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),this.subtitleTrack=-1,this.media=null,s)return;Ys(i.textTracks).forEach(n=>{Bi(n)})}onManifestLoading(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.subtitleTracks}onSubtitleTrackLoaded(e,t){const{id:i,groupId:s,details:r}=t,n=this.tracksInGroup[i];if(!n||n.groupId!==s){this.warn(`Subtitle track with id:${i} and group:${s} not found in active group ${n?.groupId}`);return}const o=n.details;n.details=t.details,this.log(`Subtitle track ${i} "${n.name}" lang:${n.lang} group:${s} loaded [${r.startSN}-${r.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!t)return;const i=t.subtitleGroups||null,s=this.groupIds;let r=this.currentTrack;if(!i||s?.length!==i?.length||i!=null&&i.some(n=>s?.indexOf(n)===-1)){this.groupIds=i,this.trackId=-1,this.currentTrack=null;const n=this.tracks.filter(h=>!i||i.indexOf(h.groupId)!==-1);if(n.length)this.selectDefaultTrack&&!n.some(h=>h.default)&&(this.selectDefaultTrack=!1),n.forEach((h,f)=>{h.id=f});else if(!r&&!this.tracksInGroup.length)return;this.tracksInGroup=n;const o=this.hls.config.subtitlePreference;if(!r&&o){this.selectDefaultTrack=!1;const h=Ft(o,n);if(h>-1)r=n[h];else{const f=Ft(o,this.tracks);r=this.tracks[f]}}let c=this.findTrackId(r);c===-1&&r&&(c=this.findTrackId(null));const u={subtitleTracks:n};this.log(`Updating subtitle tracks, ${n.length} track(s) found in "${i?.join(",")}" group-id`),this.hls.trigger(y.SUBTITLE_TRACKS_UPDATED,u),c!==-1&&this.trackId===-1&&this.setSubtitleTrack(c)}}findTrackId(e){const t=this.tracksInGroup,i=this.selectDefaultTrack;for(let s=0;s<t.length;s++){const r=t[s];if(!(i&&!r.default||!i&&!e)&&(!e||Ii(r,e)))return s}if(e){for(let s=0;s<t.length;s++){const r=t[s];if(ns(e.attrs,r.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return s}for(let s=0;s<t.length;s++){const r=t[s];if(ns(e.attrs,r.attrs,["LANGUAGE"]))return s}}return-1}findTrackForTextTrack(e){if(e){const t=this.tracksInGroup;for(let i=0;i<t.length;i++){const s=t[i];if(tn(s,e))return i}}return-1}onError(e,t){t.fatal||!t.context||t.context.type===be.SUBTITLE_TRACK&&t.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(t.context.groupId)!==-1)&&this.checkRetry(t)}get allSubtitleTracks(){return this.tracks}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(e){this.selectDefaultTrack=!1,this.setSubtitleTrack(e)}setSubtitleOption(e){if(this.hls.config.subtitlePreference=e,e){if(e.id===-1)return this.setSubtitleTrack(-1),null;const t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){const i=this.currentTrack;if(i&&Ii(e,i))return i;const s=Ft(e,this.tracksInGroup);if(s>-1){const r=this.tracksInGroup[s];return this.setSubtitleTrack(s),r}else{if(i)return null;{const r=Ft(e,t);if(r>-1)return t[r]}}}}return null}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentTrack)&&this.scheduleLoading(this.currentTrack,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const i=e.id,s=e.groupId,r=this.getUrlWithDirectives(e.url,t),n=e.details,o=n?.age;this.log(`Loading subtitle ${i} "${e.name}" lang:${e.lang} group:${s}${t?.msn!==void 0?" at sn "+t.msn+" part "+t.part:""}${o&&n.live?" age "+o.toFixed(1)+(n.type&&" "+n.type||""):""} ${r}`),this.hls.trigger(y.SUBTITLE_TRACK_LOADING,{url:r,id:i,groupId:s,deliveryDirectives:t||null,track:e})}toggleTrackModes(){const{media:e}=this;if(!e)return;const t=Ys(e.textTracks),i=this.currentTrack;let s;if(i&&(s=t.filter(r=>tn(i,r))[0],s||this.warn(`Unable to find subtitle TextTrack with name "${i.name}" and language "${i.lang}"`)),[].slice.call(t).forEach(r=>{r.mode!=="disabled"&&r!==s&&(r.mode="disabled")}),s){const r=this.subtitleDisplay?"showing":"hidden";s.mode!==r&&(s.mode=r)}}setSubtitleTrack(e){const t=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(e<-1||e>=t.length||!se(e)){this.warn(`Invalid subtitle track id: ${e}`);return}this.selectDefaultTrack=!1;const i=this.currentTrack,s=t[e]||null;if(this.trackId=e,this.currentTrack=s,this.toggleTrackModes(),!s){this.hls.trigger(y.SUBTITLE_TRACK_SWITCH,{id:e});return}const r=!!s.details&&!s.details.live;if(e===this.trackId&&s===i&&r)return;this.log(`Switching to subtitle-track ${e}`+(s?` "${s.name}" lang:${s.lang} group:${s.groupId}`:""));const{id:n,groupId:o="",name:c,type:u,url:h}=s;this.hls.trigger(y.SUBTITLE_TRACK_SWITCH,{id:n,groupId:o,name:c,type:u,url:h});const f=this.switchParams(s.url,i?.details,s.details);this.loadPlaylist(f)}}function af(){try{return crypto.randomUUID()}catch{try{const e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch{let t=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,s=>{const r=(t+Math.random()*16)%16|0;return t=Math.floor(t/16),(s=="x"?r:r&3|8).toString(16)})}}}function as(a){let e=5381,t=a.length;for(;t;)e=e*33^a.charCodeAt(--t);return(e>>>0).toString()}const Ui=.025;let Ws=(function(a){return a[a.Point=0]="Point",a[a.Range=1]="Range",a})({});function of(a,e,t){return`${a.identifier}-${t+1}-${as(e)}`}class lf{constructor(e,t){this.base=void 0,this._duration=null,this._timelineStart=null,this.appendInPlaceDisabled=void 0,this.appendInPlaceStarted=void 0,this.dateRange=void 0,this.hasPlayed=!1,this.cumulativeDuration=0,this.resumeOffset=NaN,this.playoutLimit=NaN,this.restrictions={skip:!1,jump:!1},this.snapOptions={out:!1,in:!1},this.assetList=[],this.assetListLoader=void 0,this.assetListResponse=null,this.resumeAnchor=void 0,this.error=void 0,this.resetOnResume=void 0,this.base=t,this.dateRange=e,this.setDateRange(e)}setDateRange(e){this.dateRange=e,this.resumeOffset=e.attr.optionalFloat("X-RESUME-OFFSET",this.resumeOffset),this.playoutLimit=e.attr.optionalFloat("X-PLAYOUT-LIMIT",this.playoutLimit),this.restrictions=e.attr.enumeratedStringList("X-RESTRICT",this.restrictions),this.snapOptions=e.attr.enumeratedStringList("X-SNAP",this.snapOptions)}reset(){var e;this.appendInPlaceStarted=!1,(e=this.assetListLoader)==null||e.destroy(),this.assetListLoader=void 0,this.supplementsPrimary||(this.assetListResponse=null,this.assetList=[],this._duration=null)}isAssetPastPlayoutLimit(e){var t;if(e>0&&e>=this.assetList.length)return!0;const i=this.playoutLimit;return e<=0||isNaN(i)?!1:i===0?!0:(((t=this.assetList[e])==null?void 0:t.startOffset)||0)>i}findAssetIndex(e){return this.assetList.indexOf(e)}get identifier(){return this.dateRange.id}get startDate(){return this.dateRange.startDate}get startTime(){const e=this.dateRange.startTime;if(this.snapOptions.out){const t=this.dateRange.tagAnchor;if(t)return hn(e,t)}return e}get startOffset(){return this.cue.pre?0:this.startTime}get startIsAligned(){if(this.startTime===0||this.snapOptions.out)return!0;const e=this.dateRange.tagAnchor;if(e){const t=this.dateRange.startTime,i=hn(t,e);return t-i<.1}return!1}get resumptionOffset(){const e=this.resumeOffset,t=se(e)?e:this.duration;return this.cumulativeDuration+t}get resumeTime(){const e=this.startOffset+this.resumptionOffset;if(this.snapOptions.in){const t=this.resumeAnchor;if(t)return hn(e,t)}return e}get appendInPlace(){return this.appendInPlaceStarted?!0:this.appendInPlaceDisabled?!1:!!(!this.cue.once&&!this.cue.pre&&this.startIsAligned&&(isNaN(this.playoutLimit)&&isNaN(this.resumeOffset)||this.resumeOffset&&this.duration&&Math.abs(this.resumeOffset-this.duration)<Ui))}set appendInPlace(e){if(this.appendInPlaceStarted){this.resetOnResume=!e;return}this.appendInPlaceDisabled=!e}get timelineStart(){return this._timelineStart!==null?this._timelineStart:this.startTime}set timelineStart(e){this._timelineStart=e}get duration(){const e=this.playoutLimit;let t;return this._duration!==null?t=this._duration:this.dateRange.duration?t=this.dateRange.duration:t=this.dateRange.plannedDuration||0,!isNaN(e)&&e<t&&(t=e),t}set duration(e){this._duration=e}get cue(){return this.dateRange.cue}get timelineOccupancy(){return this.dateRange.attr["X-TIMELINE-OCCUPIES"]==="RANGE"?Ws.Range:Ws.Point}get supplementsPrimary(){return this.dateRange.attr["X-TIMELINE-STYLE"]==="PRIMARY"}get contentMayVary(){return this.dateRange.attr["X-CONTENT-MAY-VARY"]!=="NO"}get assetUrl(){return this.dateRange.attr["X-ASSET-URI"]}get assetListUrl(){return this.dateRange.attr["X-ASSET-LIST"]}get baseUrl(){return this.base.url}get assetListLoaded(){return this.assetList.length>0||this.assetListResponse!==null}toString(){return uf(this)}}function hn(a,e){return a-e.start<e.duration/2&&!(Math.abs(a-(e.start+e.duration))<Ui)?e.start:e.start+e.duration}function ul(a,e,t){const i=new self.URL(a,t);return i.protocol!=="data:"&&i.searchParams.set("_HLS_primary_id",e),i}function dn(a,e){for(;(t=a.assetList[++e])!=null&&t.error;)var t;return e}function uf(a){return`["${a.identifier}" ${a.cue.pre?"<pre>":a.cue.post?"<post>":""}${a.timelineStart.toFixed(2)}-${a.resumeTime.toFixed(2)}]`}function $i(a){const e=a.timelineStart,t=a.duration||0;return`["${a.identifier}" ${e.toFixed(2)}-${(e+t).toFixed(2)}]`}class cf{constructor(e,t,i,s){this.hls=void 0,this.interstitial=void 0,this.assetItem=void 0,this.tracks=null,this.hasDetails=!1,this.mediaAttached=null,this._currentTime=void 0,this._bufferedEosTime=void 0,this.checkPlayout=()=>{this.reachedPlayout(this.currentTime)&&this.hls&&this.hls.trigger(y.PLAYOUT_LIMIT_REACHED,{})};const r=this.hls=new e(t);this.interstitial=i,this.assetItem=s;const n=()=>{this.hasDetails=!0};r.once(y.LEVEL_LOADED,n),r.once(y.AUDIO_TRACK_LOADED,n),r.once(y.SUBTITLE_TRACK_LOADED,n),r.on(y.MEDIA_ATTACHING,(o,{media:c})=>{this.removeMediaListeners(),this.mediaAttached=c,this.interstitial.playoutLimit&&(c.addEventListener("timeupdate",this.checkPlayout),this.appendInPlace&&r.on(y.BUFFER_APPENDED,()=>{const h=this.bufferedEnd;this.reachedPlayout(h)&&(this._bufferedEosTime=h,r.trigger(y.BUFFERED_TO_END,void 0))}))})}get appendInPlace(){return this.interstitial.appendInPlace}loadSource(){const e=this.hls;if(e)if(e.url)e.levels.length&&!e.started&&e.startLoad(-1,!0);else{let t=this.assetItem.uri;try{t=ul(t,e.config.primarySessionId||"").href}catch{}e.loadSource(t)}}bufferedInPlaceToEnd(e){var t;if(!this.appendInPlace)return!1;if((t=this.hls)!=null&&t.bufferedToEnd)return!0;if(!e)return!1;const i=Math.min(this._bufferedEosTime||1/0,this.duration),s=this.timelineOffset,r=ye.bufferInfo(e,s,0);return this.getAssetTime(r.end)>=i-.02}reachedPlayout(e){const i=this.interstitial.playoutLimit;return this.startOffset+e>=i}get destroyed(){var e;return!((e=this.hls)!=null&&e.userConfig)}get assetId(){return this.assetItem.identifier}get interstitialId(){return this.assetItem.parentIdentifier}get media(){var e;return((e=this.hls)==null?void 0:e.media)||null}get bufferedEnd(){const e=this.media||this.mediaAttached;if(!e)return this._bufferedEosTime?this._bufferedEosTime:this.currentTime;const t=ye.bufferInfo(e,e.currentTime,.001);return this.getAssetTime(t.end)}get currentTime(){const e=this.media||this.mediaAttached;return e?this.getAssetTime(e.currentTime):this._currentTime||0}get duration(){const e=this.assetItem.duration;if(!e)return 0;const t=this.interstitial.playoutLimit;if(t){const i=t-this.startOffset;if(i>0&&i<e)return i}return e}get remaining(){const e=this.duration;return e?Math.max(0,e-this.currentTime):0}get startOffset(){return this.assetItem.startOffset}get timelineOffset(){var e;return((e=this.hls)==null?void 0:e.config.timelineOffset)||0}set timelineOffset(e){const t=this.timelineOffset;if(e!==t){const i=e-t;if(Math.abs(i)>1/9e4&&this.hls){if(this.hasDetails)throw new Error("Cannot set timelineOffset after playlists are loaded");this.hls.config.timelineOffset=e}}}getAssetTime(e){const t=this.timelineOffset,i=this.duration;return Math.min(Math.max(0,e-t),i)}removeMediaListeners(){const e=this.mediaAttached;e&&(this._currentTime=e.currentTime,this.bufferSnapShot(),e.removeEventListener("timeupdate",this.checkPlayout))}bufferSnapShot(){if(this.mediaAttached){var e;(e=this.hls)!=null&&e.bufferedToEnd&&(this._bufferedEosTime=this.bufferedEnd)}}destroy(){this.removeMediaListeners(),this.hls&&this.hls.destroy(),this.hls=null,this.tracks=this.mediaAttached=this.checkPlayout=null}attachMedia(e){var t;this.loadSource(),(t=this.hls)==null||t.attachMedia(e)}detachMedia(){var e;this.removeMediaListeners(),this.mediaAttached=null,(e=this.hls)==null||e.detachMedia()}resumeBuffering(){var e;(e=this.hls)==null||e.resumeBuffering()}pauseBuffering(){var e;(e=this.hls)==null||e.pauseBuffering()}transferMedia(){var e;return this.bufferSnapShot(),((e=this.hls)==null?void 0:e.transferMedia())||null}resetDetails(){const e=this.hls;if(e&&this.hasDetails){e.stopLoad();const t=i=>delete i.details;e.levels.forEach(t),e.allAudioTracks.forEach(t),e.allSubtitleTracks.forEach(t),this.hasDetails=!1}}on(e,t,i){var s;(s=this.hls)==null||s.on(e,t)}once(e,t,i){var s;(s=this.hls)==null||s.once(e,t)}off(e,t,i){var s;(s=this.hls)==null||s.off(e,t)}toString(){var e;return`HlsAssetPlayer: ${$i(this.assetItem)} ${(e=this.hls)==null?void 0:e.sessionId} ${this.appendInPlace?"append-in-place":""}`}}const cl=.033;class hf extends Tt{constructor(e,t){super("interstitials-sched",t),this.onScheduleUpdate=void 0,this.eventMap={},this.events=null,this.items=null,this.durations={primary:0,playout:0,integrated:0},this.onScheduleUpdate=e}destroy(){this.reset(),this.onScheduleUpdate=null}reset(){this.eventMap={},this.setDurations(0,0,0),this.events&&this.events.forEach(e=>e.reset()),this.events=this.items=null}resetErrorsInRange(e,t){return this.events?this.events.reduce((i,s)=>e<=s.startOffset&&t>s.startOffset?(delete s.error,i+1):i,0):0}get duration(){const e=this.items;return e?e[e.length-1].end:0}get length(){return this.items?this.items.length:0}getEvent(e){return e&&this.eventMap[e]||null}hasEvent(e){return e in this.eventMap}findItemIndex(e,t){if(e.event)return this.findEventIndex(e.event.identifier);let i=-1;e.nextEvent?i=this.findEventIndex(e.nextEvent.identifier)-1:e.previousEvent&&(i=this.findEventIndex(e.previousEvent.identifier)+1);const s=this.items;if(s)for(s[i]||(t===void 0&&(t=e.start),i=this.findItemIndexAtTime(t));i>=0&&(r=s[i])!=null&&r.event;){var r;i--}return i}findItemIndexAtTime(e,t){const i=this.items;if(i)for(let s=0;s<i.length;s++){let r=i[s];if(t&&t!=="primary"&&(r=r[t]),e===r.start||e>r.start&&e<r.end)return s}return-1}findJumpRestrictedIndex(e,t){const i=this.items;if(i)for(let s=e;s<=t&&i[s];s++){const r=i[s].event;if(r!=null&&r.restrictions.jump&&!r.appendInPlace)return s}return-1}findEventIndex(e){const t=this.items;if(t)for(let s=t.length;s--;){var i;if(((i=t[s].event)==null?void 0:i.identifier)===e)return s}return-1}findAssetIndex(e,t){const i=e.assetList,s=i.length;if(s>1)for(let r=0;r<s;r++){const n=i[r];if(!n.error){const o=n.timelineStart;if(t===o||t>o&&(t<o+(n.duration||0)||r===s-1))return r}}return 0}get assetIdAtEnd(){var e;const t=(e=this.items)==null||(e=e[this.length-1])==null?void 0:e.event;if(t){const i=t.assetList,s=i[i.length-1];if(s)return s.identifier}return null}parseInterstitialDateRanges(e,t){const i=e.main.details,{dateRanges:s}=i,r=this.events,n=this.parseDateRanges(s,{url:i.url},t),o=Object.keys(s),c=r?r.filter(u=>!o.includes(u.identifier)):[];n.length&&n.sort((u,h)=>{const f=u.cue.pre,g=u.cue.post,I=h.cue.pre,m=h.cue.post;if(f&&!I)return-1;if(I&&!f||g&&!m)return 1;if(m&&!g)return-1;if(!f&&!I&&!g&&!m){const E=u.startTime,v=h.startTime;if(E!==v)return E-v}return u.dateRange.tagOrder-h.dateRange.tagOrder}),this.events=n,c.forEach(u=>{this.removeEvent(u)}),this.updateSchedule(e,c)}updateSchedule(e,t=[],i=!1){const s=this.events||[];if(s.length||t.length||this.length<2){const r=this.items,n=this.parseSchedule(s,e);(i||t.length||r?.length!==n.length||n.some((c,u)=>Math.abs(c.playout.start-r[u].playout.start)>.005||Math.abs(c.playout.end-r[u].playout.end)>.005))&&(this.items=n,this.onScheduleUpdate(t,r))}}parseDateRanges(e,t,i){const s=[],r=Object.keys(e);for(let n=0;n<r.length;n++){const o=r[n],c=e[o];if(c.isInterstitial){let u=this.eventMap[o];u?u.setDateRange(c):(u=new lf(c,t),this.eventMap[o]=u,i===!1&&(u.appendInPlace=i)),s.push(u)}}return s}parseSchedule(e,t){const i=[],s=t.main.details,r=s.live?1/0:s.edge;let n=0;if(e=e.filter(c=>!c.error&&!(c.cue.once&&c.hasPlayed)),e.length){this.resolveOffsets(e,t);let c=0,u=0;if(e.forEach((h,f)=>{const g=h.cue.pre,I=h.cue.post,m=e[f-1]||null,E=h.appendInPlace,v=I?r:h.startOffset,x=h.duration,D=h.timelineOccupancy===Ws.Range?x:0,L=h.resumptionOffset,w=m?.startTime===v,N=v+h.cumulativeDuration;let K=E?N+x:v+L;if(g||!I&&v<=0){const $=u;u+=D,h.timelineStart=N;const F=n;n+=x,i.push({event:h,start:N,end:K,playout:{start:F,end:n},integrated:{start:$,end:u}})}else if(v<=r){if(!w){const O=v-c;if(O>cl){const W=c,ie=u;u+=O;const X=n;n+=O;const ce={previousEvent:e[f-1]||null,nextEvent:h,start:W,end:W+O,playout:{start:X,end:n},integrated:{start:ie,end:u}};i.push(ce)}else O>0&&m&&(m.cumulativeDuration+=O,i[i.length-1].end=v)}I&&(K=N),h.timelineStart=N;const $=u;u+=D;const F=n;n+=x,i.push({event:h,start:N,end:K,playout:{start:F,end:n},integrated:{start:$,end:u}})}else return;const p=h.resumeTime;I||p>r?c=r:c=p}),c<r){var o;const h=c,f=u,g=r-c;u+=g;const I=n;n+=g,i.push({previousEvent:((o=i[i.length-1])==null?void 0:o.event)||null,nextEvent:null,start:c,end:h+g,playout:{start:I,end:n},integrated:{start:f,end:u}})}this.setDurations(r,n,u)}else i.push({previousEvent:null,nextEvent:null,start:0,end:r,playout:{start:0,end:r},integrated:{start:0,end:r}}),this.setDurations(r,r,r);return i}setDurations(e,t,i){this.durations={primary:e,playout:t,integrated:i}}resolveOffsets(e,t){const i=t.main.details,s=i.live?1/0:i.edge;let r=0,n=-1;e.forEach((o,c)=>{const u=o.cue.pre,h=o.cue.post,f=u?0:h?s:o.startTime;this.updateAssetDurations(o),n===f?o.cumulativeDuration=r:(r=0,n=f),!h&&o.snapOptions.in&&(o.resumeAnchor=yi(null,i.fragments,o.startOffset+o.resumptionOffset,0,0)||void 0),o.appendInPlace&&!o.appendInPlaceStarted&&(this.primaryCanResumeInPlaceAt(o,t)||(o.appendInPlace=!1)),!o.appendInPlace&&c+1<e.length&&e[c+1].startTime-e[c].resumeTime<cl&&(e[c+1].appendInPlace=!1,e[c+1].appendInPlace&&this.warn(`Could not change append strategy for abutting event ${o}`));const I=se(o.resumeOffset)?o.resumeOffset:o.duration;r+=I})}primaryCanResumeInPlaceAt(e,t){const i=e.resumeTime,s=e.startTime+e.resumptionOffset;return Math.abs(i-s)>Ui?(this.log(`"${e.identifier}" resumption ${i} not aligned with estimated timeline end ${s}`),!1):!Object.keys(t).some(n=>{const o=t[n].details,c=o.edge;if(i>=c)return this.log(`"${e.identifier}" resumption ${i} past ${n} playlist end ${c}`),!1;const u=yi(null,o.fragments,i);if(!u)return this.log(`"${e.identifier}" resumption ${i} does not align with any fragments in ${n} playlist (${o.fragStart}-${o.fragmentEnd})`),!0;const h=n==="audio"?.175:0;return Math.abs(u.start-i)<Ui+h||Math.abs(u.end-i)<Ui+h?!1:(this.log(`"${e.identifier}" resumption ${i} not aligned with ${n} fragment bounds (${u.start}-${u.end} sn: ${u.sn} cc: ${u.cc})`),!0)})}updateAssetDurations(e){if(!e.assetListLoaded)return;const t=e.timelineStart;let i=0,s=!1,r=!1;for(let n=0;n<e.assetList.length;n++){const o=e.assetList[n],c=t+i;o.startOffset=i,o.timelineStart=c,s||(s=o.duration===null),r||(r=!!o.error);const u=o.error?0:o.duration||0;i+=u}s&&!r?e.duration=Math.max(i,e.duration):e.duration=i}removeEvent(e){e.reset(),delete this.eventMap[e.identifier]}}function Pt(a){return`[${a.event?'"'+a.event.identifier+'"':"primary"}: ${a.start.toFixed(2)}-${a.end.toFixed(2)}]`}class df{constructor(e){this.hls=void 0,this.hls=e}destroy(){this.hls=null}loadAssetList(e,t){const i=e.assetListUrl;let s;try{s=ul(i,this.hls.sessionId,e.baseUrl)}catch(g){const I=this.assignAssetListError(e,U.ASSET_LIST_LOAD_ERROR,g,i);this.hls.trigger(y.ERROR,I);return}t&&s.protocol!=="data:"&&s.searchParams.set("_HLS_start_offset",""+t);const r=this.hls.config,n=r.loader,o=new n(r),c={responseType:"json",url:s.href},u=r.interstitialAssetListLoadPolicy.default,h={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},f={onSuccess:(g,I,m,E)=>{const v=g.data,x=v?.ASSETS;if(!Array.isArray(x)){const D=this.assignAssetListError(e,U.ASSET_LIST_PARSING_ERROR,new Error("Invalid interstitial asset list"),m.url,I,E);this.hls.trigger(y.ERROR,D);return}e.assetListResponse=v,this.hls.trigger(y.ASSET_LIST_LOADED,{event:e,assetListResponse:v,networkDetails:E})},onError:(g,I,m,E)=>{const v=this.assignAssetListError(e,U.ASSET_LIST_LOAD_ERROR,new Error(`Error loading X-ASSET-LIST: HTTP status ${g.code} ${g.text} (${I.url})`),I.url,E,m);this.hls.trigger(y.ERROR,v)},onTimeout:(g,I,m)=>{const E=this.assignAssetListError(e,U.ASSET_LIST_LOAD_TIMEOUT,new Error(`Timeout loading X-ASSET-LIST (${I.url})`),I.url,g,m);this.hls.trigger(y.ERROR,E)}};return o.load(c,h,f),this.hls.trigger(y.ASSET_LIST_LOADING,{event:e}),o}assignAssetListError(e,t,i,s,r,n){return e.error=i,{type:de.NETWORK_ERROR,details:t,fatal:!1,interstitial:e,url:s,error:i,networkDetails:n,stats:r}}}function hl(a){a?.play().catch(()=>{})}function js(a,e){return`[${a}] Advancing timeline position to ${e}`}class ff extends Tt{constructor(e,t){super("interstitials",e.logger),this.HlsPlayerClass=void 0,this.hls=void 0,this.assetListLoader=void 0,this.mediaSelection=null,this.altSelection=null,this.media=null,this.detachedData=null,this.requiredTracks=null,this.manager=null,this.playerQueue=[],this.bufferedPos=-1,this.timelinePos=-1,this.schedule=void 0,this.playingItem=null,this.bufferingItem=null,this.waitingItem=null,this.endedItem=null,this.playingAsset=null,this.endedAsset=null,this.bufferingAsset=null,this.shouldPlay=!1,this.onPlay=()=>{this.shouldPlay=!0},this.onPause=()=>{this.shouldPlay=!1},this.onSeeking=()=>{const i=this.currentTime;if(i===void 0||this.playbackDisabled||!this.schedule)return;const s=i-this.timelinePos;if(Math.abs(s)<1/7056e5)return;const n=s<=-.01;this.timelinePos=i,this.bufferedPos=i;const o=this.playingItem;if(!o){this.checkBuffer();return}if(n&&this.schedule.resetErrorsInRange(i,i-s)&&this.updateSchedule(!0),this.checkBuffer(),n&&i<o.start||i>=o.end){var c;const I=this.findItemIndex(o);let m=this.schedule.findItemIndexAtTime(i);if(m===-1&&(m=I+(n?-1:1),this.log(`seeked ${n?"back ":""}to position not covered by schedule ${i} (resolving from ${I} to ${m})`)),!this.isInterstitial(o)&&(c=this.media)!=null&&c.paused&&(this.shouldPlay=!1),!n&&m>I){const E=this.schedule.findJumpRestrictedIndex(I+1,m);if(E>I){this.setSchedulePosition(E);return}}this.setSchedulePosition(m);return}const u=this.playingAsset;if(!u){if(this.playingLastItem&&this.isInterstitial(o)){const I=o.event.assetList[0];I&&(this.endedItem=this.playingItem,this.playingItem=null,this.setScheduleToAssetAtTime(i,I))}return}const h=u.timelineStart,f=u.duration||0;if(n&&i<h||i>=h+f){var g;(g=o.event)!=null&&g.appendInPlace&&(this.clearInterstitial(o.event,o),this.flushFrontBuffer(i)),this.setScheduleToAssetAtTime(i,u)}},this.onTimeupdate=()=>{const i=this.currentTime;if(i===void 0||this.playbackDisabled)return;if(i>this.timelinePos)this.timelinePos=i,i>this.bufferedPos&&this.checkBuffer();else return;const s=this.playingItem;if(!s||this.playingLastItem)return;if(i>=s.end){this.timelinePos=s.end;const o=this.findItemIndex(s);this.setSchedulePosition(o+1)}const r=this.playingAsset;if(!r)return;const n=r.timelineStart+(r.duration||0);i>=n&&this.setScheduleToAssetAtTime(i,r)},this.onScheduleUpdate=(i,s)=>{const r=this.schedule;if(!r)return;const n=this.playingItem,o=r.events||[],c=r.items||[],u=r.durations,h=i.map(E=>E.identifier),f=!!(o.length||h.length);(f||s)&&this.log(`INTERSTITIALS_UPDATED (${o.length}): ${o}
29
- Schedule: ${c.map(E=>Pt(E))} pos: ${this.timelinePos}`),h.length&&this.log(`Removed events ${h}`);let g=null,I=null;n&&(g=this.updateItem(n,this.timelinePos),this.itemsMatch(n,g)?this.playingItem=g:this.waitingItem=this.endedItem=null),this.waitingItem=this.updateItem(this.waitingItem),this.endedItem=this.updateItem(this.endedItem);const m=this.bufferingItem;if(m&&(I=this.updateItem(m,this.bufferedPos),this.itemsMatch(m,I)?this.bufferingItem=I:m.event&&(this.bufferingItem=this.playingItem,this.clearInterstitial(m.event,null))),i.forEach(E=>{E.assetList.forEach(v=>{this.clearAssetPlayer(v.identifier,null)})}),this.playerQueue.forEach(E=>{if(E.interstitial.appendInPlace){const v=E.assetItem.timelineStart,x=E.timelineOffset-v;if(x)try{E.timelineOffset=v}catch(D){Math.abs(x)>Ui&&this.warn(`${D} ("${E.assetId}" ${E.timelineOffset}->${v})`)}}}),f||s){if(this.hls.trigger(y.INTERSTITIALS_UPDATED,{events:o.slice(0),schedule:c.slice(0),durations:u,removedIds:h}),this.isInterstitial(n)&&h.includes(n.event.identifier)){this.warn(`Interstitial "${n.event.identifier}" removed while playing`),this.primaryFallback(n.event);return}n&&this.trimInPlace(g,n),m&&I!==g&&this.trimInPlace(I,m),this.checkBuffer()}},this.hls=e,this.HlsPlayerClass=t,this.assetListLoader=new df(e),this.schedule=new hf(this.onScheduleUpdate,e.logger),this.registerListeners()}registerListeners(){const e=this.hls;e&&(e.on(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(y.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(y.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.on(y.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(y.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.on(y.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.on(y.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.on(y.BUFFER_APPENDED,this.onBufferAppended,this),e.on(y.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(y.BUFFERED_TO_END,this.onBufferedToEnd,this),e.on(y.MEDIA_ENDED,this.onMediaEnded,this),e.on(y.ERROR,this.onError,this),e.on(y.DESTROYING,this.onDestroying,this))}unregisterListeners(){const e=this.hls;e&&(e.off(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(y.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(y.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.off(y.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(y.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.off(y.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.off(y.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.off(y.BUFFER_CODECS,this.onBufferCodecs,this),e.off(y.BUFFER_APPENDED,this.onBufferAppended,this),e.off(y.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(y.BUFFERED_TO_END,this.onBufferedToEnd,this),e.off(y.MEDIA_ENDED,this.onMediaEnded,this),e.off(y.ERROR,this.onError,this),e.off(y.DESTROYING,this.onDestroying,this))}startLoad(){this.resumeBuffering()}stopLoad(){this.pauseBuffering()}resumeBuffering(){var e;(e=this.getBufferingPlayer())==null||e.resumeBuffering()}pauseBuffering(){var e;(e=this.getBufferingPlayer())==null||e.pauseBuffering()}destroy(){this.unregisterListeners(),this.stopLoad(),this.assetListLoader&&this.assetListLoader.destroy(),this.emptyPlayerQueue(),this.clearScheduleState(),this.schedule&&this.schedule.destroy(),this.media=this.detachedData=this.mediaSelection=this.requiredTracks=this.altSelection=this.schedule=this.manager=null,this.hls=this.HlsPlayerClass=this.log=null,this.assetListLoader=null,this.onPlay=this.onPause=this.onSeeking=this.onTimeupdate=null,this.onScheduleUpdate=null}onDestroying(){const e=this.primaryMedia||this.media;e&&this.removeMediaListeners(e)}removeMediaListeners(e){ht(e,"play",this.onPlay),ht(e,"pause",this.onPause),ht(e,"seeking",this.onSeeking),ht(e,"timeupdate",this.onTimeupdate)}onMediaAttaching(e,t){const i=this.media=t.media;ot(i,"seeking",this.onSeeking),ot(i,"timeupdate",this.onTimeupdate),ot(i,"play",this.onPlay),ot(i,"pause",this.onPause)}onMediaAttached(e,t){const i=this.effectivePlayingItem,s=this.detachedData;if(this.detachedData=null,i===null)this.checkStart();else if(!s){this.clearScheduleState();const r=this.findItemIndex(i);this.setSchedulePosition(r)}}clearScheduleState(){this.log("clear schedule state"),this.playingItem=this.bufferingItem=this.waitingItem=this.endedItem=this.playingAsset=this.endedAsset=this.bufferingAsset=null}onMediaDetaching(e,t){const i=!!t.transferMedia,s=this.media;if(this.media=null,!i&&(s&&this.removeMediaListeners(s),this.detachedData)){const r=this.getBufferingPlayer();r&&(this.log(`Removing schedule state for detachedData and ${r}`),this.playingAsset=this.endedAsset=this.bufferingAsset=this.bufferingItem=this.waitingItem=this.detachedData=null,r.detachMedia()),this.shouldPlay=!1}}get interstitialsManager(){if(!this.hls)return null;if(this.manager)return this.manager;const e=this,t=()=>e.bufferingItem||e.waitingItem,i=f=>f&&e.getAssetPlayer(f.identifier),s=(f,g,I,m,E)=>{if(f){let v=f[g].start;const x=f.event;if(x){if(g==="playout"||x.timelineOccupancy!==Ws.Point){const D=i(I);D?.interstitial===x&&(v+=D.assetItem.startOffset+D[E])}}else{const D=m==="bufferedPos"?n():e[m];v+=D-f.start}return v}return 0},r=(f,g)=>{var I;if(f!==0&&g!=="primary"&&(I=e.schedule)!=null&&I.length){var m;const E=e.schedule.findItemIndexAtTime(f),v=(m=e.schedule.items)==null?void 0:m[E];if(v){const x=v[g].start-v.start;return f+x}}return f},n=()=>{const f=e.bufferedPos;return f===Number.MAX_VALUE?o("primary"):Math.max(f,0)},o=f=>{var g,I;return(g=e.primaryDetails)!=null&&g.live?e.primaryDetails.edge:((I=e.schedule)==null?void 0:I.durations[f])||0},c=(f,g)=>{var I,m;const E=e.effectivePlayingItem;if(E!=null&&(I=E.event)!=null&&I.restrictions.skip||!e.schedule)return;e.log(`seek to ${f} "${g}"`);const v=e.effectivePlayingItem,x=e.schedule.findItemIndexAtTime(f,g),D=(m=e.schedule.items)==null?void 0:m[x],L=e.getBufferingPlayer(),w=L?.interstitial,N=w?.appendInPlace,K=v&&e.itemsMatch(v,D);if(v&&(N||K)){const p=i(e.playingAsset),$=p?.media||e.primaryMedia;if($){const F=g==="primary"?$.currentTime:s(v,g,e.playingAsset,"timelinePos","currentTime"),O=f-F,W=(N?F:$.currentTime)+O;if(W>=0&&(!p||N||W<=p.duration)){$.currentTime=W;return}}}if(D){let p=f;if(g!=="primary"){const F=D[g].start,O=f-F;p=D.start+O}const $=!e.isInterstitial(D);if((!e.isInterstitial(v)||v.event.appendInPlace)&&($||D.event.appendInPlace)){const F=e.media||(N?L?.media:null);F&&(F.currentTime=p)}else if(v){const F=e.findItemIndex(v);if(x>F){const W=e.schedule.findJumpRestrictedIndex(F+1,x);if(W>F){e.setSchedulePosition(W);return}}let O=0;if($)e.timelinePos=p,e.checkBuffer();else{const W=D.event.assetList,ie=f-(D[g]||D).start;for(let X=W.length;X--;){const ce=W[X];if(ce.duration&&ie>=ce.startOffset&&ie<ce.startOffset+ce.duration){O=X;break}}}e.setSchedulePosition(x,O)}}},u=()=>{const f=e.effectivePlayingItem;if(e.isInterstitial(f))return f;const g=t();return e.isInterstitial(g)?g:null},h={get bufferedEnd(){const f=t(),g=e.bufferingItem;if(g&&g===f){var I;return s(g,"playout",e.bufferingAsset,"bufferedPos","bufferedEnd")-g.playout.start||((I=e.bufferingAsset)==null?void 0:I.startOffset)||0}return 0},get currentTime(){const f=u(),g=e.effectivePlayingItem;return g&&g===f?s(g,"playout",e.effectivePlayingAsset,"timelinePos","currentTime")-g.playout.start:0},set currentTime(f){const g=u(),I=e.effectivePlayingItem;I&&I===g&&c(f+I.playout.start,"playout")},get duration(){const f=u();return f?f.playout.end-f.playout.start:0},get assetPlayers(){var f;const g=(f=u())==null?void 0:f.event.assetList;return g?g.map(I=>e.getAssetPlayer(I.identifier)):[]},get playingIndex(){var f;const g=(f=u())==null?void 0:f.event;return g&&e.effectivePlayingAsset?g.findAssetIndex(e.effectivePlayingAsset):-1},get scheduleItem(){return u()}};return this.manager={get events(){var f;return((f=e.schedule)==null||(f=f.events)==null?void 0:f.slice(0))||[]},get schedule(){var f;return((f=e.schedule)==null||(f=f.items)==null?void 0:f.slice(0))||[]},get interstitialPlayer(){return u()?h:null},get playerQueue(){return e.playerQueue.slice(0)},get bufferingAsset(){return e.bufferingAsset},get bufferingItem(){return t()},get bufferingIndex(){const f=t();return e.findItemIndex(f)},get playingAsset(){return e.effectivePlayingAsset},get playingItem(){return e.effectivePlayingItem},get playingIndex(){const f=e.effectivePlayingItem;return e.findItemIndex(f)},primary:{get bufferedEnd(){return n()},get currentTime(){const f=e.timelinePos;return f>0?f:0},set currentTime(f){c(f,"primary")},get duration(){return o("primary")},get seekableStart(){var f;return((f=e.primaryDetails)==null?void 0:f.fragmentStart)||0}},integrated:{get bufferedEnd(){return s(t(),"integrated",e.bufferingAsset,"bufferedPos","bufferedEnd")},get currentTime(){return s(e.effectivePlayingItem,"integrated",e.effectivePlayingAsset,"timelinePos","currentTime")},set currentTime(f){c(f,"integrated")},get duration(){return o("integrated")},get seekableStart(){var f;return r(((f=e.primaryDetails)==null?void 0:f.fragmentStart)||0,"integrated")}},skip:()=>{const f=e.effectivePlayingItem,g=f?.event;if(g&&!g.restrictions.skip){const I=e.findItemIndex(f);if(g.appendInPlace){const m=f.playout.start+f.event.duration;c(m+.001,"playout")}else e.advanceAfterAssetEnded(g,I,1/0)}}}}get effectivePlayingItem(){return this.waitingItem||this.playingItem||this.endedItem}get effectivePlayingAsset(){return this.playingAsset||this.endedAsset}get playingLastItem(){var e;const t=this.playingItem,i=(e=this.schedule)==null?void 0:e.items;return!this.playbackStarted||!t||!i?!1:this.findItemIndex(t)===i.length-1}get playbackStarted(){return this.effectivePlayingItem!==null}get currentTime(){var e,t;if(this.mediaSelection===null)return;const i=this.waitingItem||this.playingItem;if(this.isInterstitial(i)&&!i.event.appendInPlace)return;let s=this.media;!s&&(e=this.bufferingItem)!=null&&(e=e.event)!=null&&e.appendInPlace&&(s=this.primaryMedia);const r=(t=s)==null?void 0:t.currentTime;if(!(r===void 0||!se(r)))return r}get primaryMedia(){var e;return this.media||((e=this.detachedData)==null?void 0:e.media)||null}isInterstitial(e){return!!(e!=null&&e.event)}retreiveMediaSource(e,t){const i=this.getAssetPlayer(e);i&&this.transferMediaFromPlayer(i,t)}transferMediaFromPlayer(e,t){const i=e.interstitial.appendInPlace,s=e.media;if(i&&s===this.primaryMedia){if(this.bufferingAsset=null,(!t||this.isInterstitial(t)&&!t.event.appendInPlace)&&t&&s){this.detachedData={media:s};return}const r=e.transferMedia();this.log(`transfer MediaSource from ${e} ${Ge(r)}`),this.detachedData=r}else t&&s&&(this.shouldPlay||(this.shouldPlay=!s.paused))}transferMediaTo(e,t){var i,s;if(e.media===t)return;let r=null;const n=this.hls,o=e!==n,c=o&&e.interstitial.appendInPlace,u=(i=this.detachedData)==null?void 0:i.mediaSource;let h;if(n.media)c&&(r=n.transferMedia(),this.detachedData=r),h="Primary";else if(u){const m=this.getBufferingPlayer();m?(r=m.transferMedia(),h=`${m}`):h="detached MediaSource"}else h="detached media";if(!r){if(u)r=this.detachedData,this.log(`using detachedData: MediaSource ${Ge(r)}`);else if(!this.detachedData||n.media===t){const m=this.playerQueue;m.length>1&&m.forEach(E=>{if(o&&E.interstitial.appendInPlace!==c){const v=E.interstitial;this.clearInterstitial(E.interstitial,null),v.appendInPlace=!1,v.appendInPlace&&this.warn(`Could not change append strategy for queued assets ${v}`)}}),this.hls.detachMedia(),this.detachedData={media:t}}}const f=r&&"mediaSource"in r&&((s=r.mediaSource)==null?void 0:s.readyState)!=="closed",g=f&&r?r:t;this.log(`${f?"transfering MediaSource":"attaching media"} to ${o?e:"Primary"} from ${h} (media.currentTime: ${t.currentTime})`);const I=this.schedule;if(g===r&&I){const m=o&&e.assetId===I.assetIdAtEnd;g.overrides={duration:I.duration,endOfStream:!o||m,cueRemoval:!o}}e.attachMedia(g)}onInterstitialCueEnter(){this.onTimeupdate()}checkStart(){const e=this.schedule,t=e?.events;if(!t||this.playbackDisabled||!this.media)return;this.bufferedPos===-1&&(this.bufferedPos=0);const i=this.timelinePos,s=this.effectivePlayingItem;if(i===-1){const r=this.hls.startPosition;if(this.log(js("checkStart",r)),this.timelinePos=r,t.length&&t[0].cue.pre){const n=e.findEventIndex(t[0].identifier);this.setSchedulePosition(n)}else if(r>=0||!this.primaryLive){const n=this.timelinePos=r>0?r:0,o=e.findItemIndexAtTime(n);this.setSchedulePosition(o)}}else if(s&&!this.playingItem){const r=e.findItemIndex(s);this.setSchedulePosition(r)}}advanceAssetBuffering(e,t){const i=e.event,s=i.findAssetIndex(t),r=dn(i,s);if(!i.isAssetPastPlayoutLimit(r))this.bufferedToEvent(e,r);else if(this.schedule){var n;const o=(n=this.schedule.items)==null?void 0:n[this.findItemIndex(e)+1];o&&this.bufferedToItem(o)}}advanceAfterAssetEnded(e,t,i){const s=dn(e,i);if(e.isAssetPastPlayoutLimit(s)){if(this.schedule){const r=this.schedule.items;if(r){const n=t+1,o=r.length;if(n>=o){this.setSchedulePosition(-1);return}const c=e.resumeTime;this.timelinePos<c&&(this.log(js("advanceAfterAssetEnded",c)),this.timelinePos=c,e.appendInPlace&&this.advanceInPlace(c),this.checkBuffer(this.bufferedPos<c)),this.setSchedulePosition(n)}}}else{if(e.appendInPlace){const r=e.assetList[s];r&&this.advanceInPlace(r.timelineStart)}this.setSchedulePosition(t,s)}}setScheduleToAssetAtTime(e,t){const i=this.schedule;if(!i)return;const s=t.parentIdentifier,r=i.getEvent(s);if(r){const n=i.findEventIndex(s),o=i.findAssetIndex(r,e);this.advanceAfterAssetEnded(r,n,o-1)}}setSchedulePosition(e,t){var i;const s=(i=this.schedule)==null?void 0:i.items;if(!s||this.playbackDisabled)return;const r=e>=0?s[e]:null;this.log(`setSchedulePosition ${e}, ${t} (${r&&Pt(r)}) pos: ${this.timelinePos}`);const n=this.waitingItem||this.playingItem,o=this.playingLastItem;if(this.isInterstitial(n)){const h=n.event,f=this.playingAsset,g=f?.identifier,I=g?this.getAssetPlayer(g):null;if(I&&g&&(!this.eventItemsMatch(n,r)||t!==void 0&&g!==h.assetList[t].identifier)){var c;const m=h.findAssetIndex(f);if(this.log(`INTERSTITIAL_ASSET_ENDED ${m+1}/${h.assetList.length} ${$i(f)}`),this.endedAsset=f,this.playingAsset=null,this.hls.trigger(y.INTERSTITIAL_ASSET_ENDED,{asset:f,assetListIndex:m,event:h,schedule:s.slice(0),scheduleIndex:e,player:I}),n!==this.playingItem){this.itemsMatch(n,this.playingItem)&&!this.playingAsset&&this.advanceAfterAssetEnded(h,this.findItemIndex(this.playingItem),m);return}this.retreiveMediaSource(g,r),I.media&&!((c=this.detachedData)!=null&&c.mediaSource)&&I.detachMedia()}if(!this.eventItemsMatch(n,r)&&(this.endedItem=n,this.playingItem=null,this.log(`INTERSTITIAL_ENDED ${h} ${Pt(n)}`),h.hasPlayed=!0,this.hls.trigger(y.INTERSTITIAL_ENDED,{event:h,schedule:s.slice(0),scheduleIndex:e}),h.cue.once)){var u;this.updateSchedule();const m=(u=this.schedule)==null?void 0:u.items;if(r&&m){const E=this.findItemIndex(r);this.advanceSchedule(E,m,t,n,o)}return}}this.advanceSchedule(e,s,t,n,o)}advanceSchedule(e,t,i,s,r){const n=this.schedule;if(!n)return;const o=t[e]||null,c=this.primaryMedia,u=this.playerQueue;if(u.length&&u.forEach(h=>{const f=h.interstitial,g=n.findEventIndex(f.identifier);(g<e||g>e+1)&&this.clearInterstitial(f,o)}),this.isInterstitial(o)){this.timelinePos=Math.min(Math.max(this.timelinePos,o.start),o.end);const h=o.event;if(i===void 0){i=n.findAssetIndex(h,this.timelinePos);const m=dn(h,i-1);if(h.isAssetPastPlayoutLimit(m)||h.appendInPlace&&this.timelinePos===o.end){this.advanceAfterAssetEnded(h,e,i);return}i=m}const f=this.waitingItem;this.assetsBuffered(o,c)||this.setBufferingItem(o);let g=this.preloadAssets(h,i);if(this.eventItemsMatch(o,f||s)||(this.waitingItem=o,this.log(`INTERSTITIAL_STARTED ${Pt(o)} ${h.appendInPlace?"append in place":""}`),this.hls.trigger(y.INTERSTITIAL_STARTED,{event:h,schedule:t.slice(0),scheduleIndex:e})),!h.assetListLoaded){this.log(`Waiting for ASSET-LIST to complete loading ${h}`);return}if(h.assetListLoader&&(h.assetListLoader.destroy(),h.assetListLoader=void 0),!c){this.log(`Waiting for attachMedia to start Interstitial ${h}`);return}this.waitingItem=this.endedItem=null,this.playingItem=o;const I=h.assetList[i];if(!I){this.advanceAfterAssetEnded(h,e,i||0);return}if(g||(g=this.getAssetPlayer(I.identifier)),g===null||g.destroyed){const m=h.assetList.length;this.warn(`asset ${i+1}/${m} player destroyed ${h}`),g=this.createAssetPlayer(h,I,i),g.loadSource()}if(!this.eventItemsMatch(o,this.bufferingItem)&&h.appendInPlace&&this.isAssetBuffered(I))return;this.startAssetPlayer(g,i,t,e,c),this.shouldPlay&&hl(g.media)}else o?(this.resumePrimary(o,e,s),this.shouldPlay&&hl(this.hls.media)):r&&this.isInterstitial(s)&&(this.endedItem=null,this.playingItem=s,s.event.appendInPlace||this.attachPrimary(n.durations.primary,null))}get playbackDisabled(){return this.hls.config.enableInterstitialPlayback===!1}get primaryDetails(){var e;return(e=this.mediaSelection)==null?void 0:e.main.details}get primaryLive(){var e;return!!((e=this.primaryDetails)!=null&&e.live)}resumePrimary(e,t,i){var s,r;if(this.playingItem=e,this.playingAsset=this.endedAsset=null,this.waitingItem=this.endedItem=null,this.bufferedToItem(e),this.log(`resuming ${Pt(e)}`),!((s=this.detachedData)!=null&&s.mediaSource)){let o=this.timelinePos;(o<e.start||o>=e.end)&&(o=this.getPrimaryResumption(e,t),this.log(js("resumePrimary",o)),this.timelinePos=o),this.attachPrimary(o,e)}if(!i)return;const n=(r=this.schedule)==null?void 0:r.items;n&&(this.log(`INTERSTITIALS_PRIMARY_RESUMED ${Pt(e)}`),this.hls.trigger(y.INTERSTITIALS_PRIMARY_RESUMED,{schedule:n.slice(0),scheduleIndex:t}),this.checkBuffer())}getPrimaryResumption(e,t){const i=e.start;if(this.primaryLive){const s=this.primaryDetails;if(t===0)return this.hls.startPosition;if(s&&(i<s.fragmentStart||i>s.edge))return this.hls.liveSyncPosition||-1}return i}isAssetBuffered(e){const t=this.getAssetPlayer(e.identifier);return t!=null&&t.hls?t.hls.bufferedToEnd:ye.bufferInfo(this.primaryMedia,this.timelinePos,0).end+1>=e.timelineStart+(e.duration||0)}attachPrimary(e,t,i){t?this.setBufferingItem(t):this.bufferingItem=this.playingItem,this.bufferingAsset=null;const s=this.primaryMedia;if(!s)return;const r=this.hls;r.media?this.checkBuffer():(this.transferMediaTo(r,s),i&&this.startLoadingPrimaryAt(e,i)),i||(this.log(js("attachPrimary",e)),this.timelinePos=e,this.startLoadingPrimaryAt(e,i))}startLoadingPrimaryAt(e,t){var i;const s=this.hls;!s.loadingEnabled||!s.media||Math.abs((((i=s.mainForwardBufferInfo)==null?void 0:i.start)||s.media.currentTime)-e)>.5?s.startLoad(e,t):s.bufferingEnabled||s.resumeBuffering()}onManifestLoading(){var e;this.stopLoad(),(e=this.schedule)==null||e.reset(),this.emptyPlayerQueue(),this.clearScheduleState(),this.shouldPlay=!1,this.bufferedPos=this.timelinePos=-1,this.mediaSelection=this.altSelection=this.manager=this.requiredTracks=null,this.hls.off(y.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on(y.BUFFER_CODECS,this.onBufferCodecs,this)}onLevelUpdated(e,t){if(t.level===-1||!this.schedule)return;const i=this.hls.levels[t.level],s=Be(Be({},this.mediaSelection||this.altSelection),{},{main:i});this.mediaSelection=s,this.schedule.parseInterstitialDateRanges(s,this.hls.config.interstitialAppendInPlace),!this.effectivePlayingItem&&this.schedule.items&&this.checkStart()}onAudioTrackUpdated(e,t){const i=this.hls.audioTracks[t.id],s=this.mediaSelection;if(!s){this.altSelection=Be(Be({},this.altSelection),{},{audio:i});return}const r=Be(Be({},s),{},{audio:i});this.mediaSelection=r}onSubtitleTrackUpdated(e,t){const i=this.hls.subtitleTracks[t.id],s=this.mediaSelection;if(!s){this.altSelection=Be(Be({},this.altSelection),{},{subtitles:i});return}const r=Be(Be({},s),{},{subtitles:i});this.mediaSelection=r}onAudioTrackSwitching(e,t){const i=Ta(t);this.playerQueue.forEach(({hls:s})=>s&&(s.setAudioOption(t)||s.setAudioOption(i)))}onSubtitleTrackSwitch(e,t){const i=Ta(t);this.playerQueue.forEach(({hls:s})=>s&&(s.setSubtitleOption(t)||t.id!==-1&&s.setSubtitleOption(i)))}onBufferCodecs(e,t){const i=t.tracks;i&&(this.requiredTracks=i)}onBufferAppended(e,t){this.checkBuffer()}onBufferFlushed(e,t){const i=this.playingItem;if(i&&!this.itemsMatch(i,this.bufferingItem)&&!this.isInterstitial(i)){const s=this.timelinePos;this.bufferedPos=s,this.checkBuffer()}}onBufferedToEnd(e){if(!this.schedule)return;const t=this.schedule.events;if(this.bufferedPos<Number.MAX_VALUE&&t){for(let s=0;s<t.length;s++){const r=t[s];if(r.cue.post){var i;const n=this.schedule.findEventIndex(r.identifier),o=(i=this.schedule.items)==null?void 0:i[n];this.isInterstitial(o)&&this.eventItemsMatch(o,this.bufferingItem)&&this.bufferedToItem(o,0);break}}this.bufferedPos=Number.MAX_VALUE}}onMediaEnded(e){const t=this.playingItem;if(!this.playingLastItem&&t){const i=this.findItemIndex(t);this.setSchedulePosition(i+1)}else this.shouldPlay=!1}updateItem(e,t){var i;const s=(i=this.schedule)==null?void 0:i.items;if(e&&s){const r=this.findItemIndex(e,t);return s[r]||null}return null}trimInPlace(e,t){if(this.isInterstitial(e)&&e.event.appendInPlace&&t.end-e.end>.25){e.event.assetList.forEach((r,n)=>{e.event.isAssetPastPlayoutLimit(n)&&this.clearAssetPlayer(r.identifier,null)});const i=e.end+.25,s=ye.bufferInfo(this.primaryMedia,i,0);(s.end>i||(s.nextStart||0)>i)&&(this.log(`trim buffered interstitial ${Pt(e)} (was ${Pt(t)})`),this.attachPrimary(i,null,!0),this.flushFrontBuffer(i))}}itemsMatch(e,t){return!!t&&(e===t||e.event&&t.event&&this.eventItemsMatch(e,t)||!e.event&&!t.event&&this.findItemIndex(e)===this.findItemIndex(t))}eventItemsMatch(e,t){var i;return!!t&&(e===t||e.event.identifier===((i=t.event)==null?void 0:i.identifier))}findItemIndex(e,t){return e&&this.schedule?this.schedule.findItemIndex(e,t):-1}updateSchedule(e=!1){var t;const i=this.mediaSelection;i&&((t=this.schedule)==null||t.updateSchedule(i,[],e))}checkBuffer(e){var t;const i=(t=this.schedule)==null?void 0:t.items;if(!i)return;const s=ye.bufferInfo(this.primaryMedia,this.timelinePos,0);e&&(this.bufferedPos=this.timelinePos),e||(e=s.len<1),this.updateBufferedPos(s.end,i,e)}updateBufferedPos(e,t,i){const s=this.schedule,r=this.bufferingItem;if(this.bufferedPos>e||!s)return;if(t.length===1&&this.itemsMatch(t[0],r)){this.bufferedPos=e;return}const n=this.playingItem,o=this.findItemIndex(n);let c=s.findItemIndexAtTime(e);if(this.bufferedPos<e){var u;const h=this.findItemIndex(r),f=Math.min(h+1,t.length-1),g=t[f];if((c===-1&&r&&e>=r.end||(u=g.event)!=null&&u.appendInPlace&&e+.01>=g.start)&&(c=f),this.isInterstitial(r)){const I=r.event;if(f-o>1&&I.appendInPlace===!1||I.assetList.length===0&&I.assetListLoader)return}if(this.bufferedPos=e,c>h&&c>o)this.bufferedToItem(g);else{const I=this.primaryDetails;this.primaryLive&&I&&e>I.edge-I.targetduration&&g.start<I.edge+this.hls.config.interstitialLiveLookAhead&&this.isInterstitial(g)&&this.preloadAssets(g.event,0)}}else i&&n&&!this.itemsMatch(n,r)&&(c===o?this.bufferedToItem(n):c===o+1&&this.bufferedToItem(t[c]))}assetsBuffered(e,t){return e.event.assetList.length===0?!1:!e.event.assetList.some(s=>{const r=this.getAssetPlayer(s.identifier);return!(r!=null&&r.bufferedInPlaceToEnd(t))})}setBufferingItem(e){const t=this.bufferingItem,i=this.schedule;if(!this.itemsMatch(e,t)&&i){const{items:s,events:r}=i;if(!s||!r)return t;const n=this.isInterstitial(e),o=this.getBufferingPlayer();this.bufferingItem=e,this.bufferedPos=Math.max(e.start,Math.min(e.end,this.timelinePos));const c=o?o.remaining:t?t.end-this.timelinePos:0;if(this.log(`INTERSTITIALS_BUFFERED_TO_BOUNDARY ${Pt(e)}`+(t?` (${c.toFixed(2)} remaining)`:"")),!this.playbackDisabled)if(n){const u=i.findAssetIndex(e.event,this.bufferedPos);e.event.assetList.forEach((h,f)=>{const g=this.getAssetPlayer(h.identifier);g&&(f===u&&g.loadSource(),g.resumeBuffering())})}else this.hls.resumeBuffering(),this.playerQueue.forEach(u=>u.pauseBuffering());this.hls.trigger(y.INTERSTITIALS_BUFFERED_TO_BOUNDARY,{events:r.slice(0),schedule:s.slice(0),bufferingIndex:this.findItemIndex(e),playingIndex:this.findItemIndex(this.playingItem)})}else this.bufferingItem!==e&&(this.bufferingItem=e);return t}bufferedToItem(e,t=0){const i=this.setBufferingItem(e);if(!this.playbackDisabled){if(this.isInterstitial(e))this.bufferedToEvent(e,t);else if(i!==null){this.bufferingAsset=null;const s=this.detachedData;s?s.mediaSource?this.attachPrimary(e.start,e,!0):this.preloadPrimary(e):this.preloadPrimary(e)}}}preloadPrimary(e){const t=this.findItemIndex(e),i=this.getPrimaryResumption(e,t);this.startLoadingPrimaryAt(i)}bufferedToEvent(e,t){const i=e.event,s=i.assetList.length===0&&!i.assetListLoader,r=i.cue.once;if(s||!r){const n=this.preloadAssets(i,t);if(n!=null&&n.interstitial.appendInPlace){const o=this.primaryMedia;o&&this.bufferAssetPlayer(n,o)}}}preloadAssets(e,t){const i=e.assetUrl,s=e.assetList.length,r=s===0&&!e.assetListLoader,n=e.cue.once;if(r){const c=e.timelineStart;if(e.appendInPlace){var o;const g=this.playingItem;!this.isInterstitial(g)&&(g==null||(o=g.nextEvent)==null?void 0:o.identifier)===e.identifier&&this.flushFrontBuffer(c+.25)}let u,h=0;if(!this.playingItem&&this.primaryLive&&(h=this.hls.startPosition,h===-1&&(h=this.hls.liveSyncPosition||0)),h&&!(e.cue.pre||e.cue.post)){const g=h-c;g>0&&(u=Math.round(g*1e3)/1e3)}if(this.log(`Load interstitial asset ${t+1}/${i?1:s} ${e}${u?` live-start: ${h} start-offset: ${u}`:""}`),i)return this.createAsset(e,0,0,c,e.duration,i);const f=this.assetListLoader.loadAssetList(e,u);f&&(e.assetListLoader=f)}else if(!n&&s){for(let u=t;u<s;u++){const h=e.assetList[u],f=this.getAssetPlayerQueueIndex(h.identifier);(f===-1||this.playerQueue[f].destroyed)&&!h.error&&this.createAssetPlayer(e,h,u)}const c=e.assetList[t];if(c){const u=this.getAssetPlayer(c.identifier);return u&&u.loadSource(),u}}return null}flushFrontBuffer(e){const t=this.requiredTracks;if(!t)return;this.log(`Removing front buffer starting at ${e}`),Object.keys(t).forEach(s=>{this.hls.trigger(y.BUFFER_FLUSHING,{startOffset:e,endOffset:1/0,type:s})})}getAssetPlayerQueueIndex(e){const t=this.playerQueue;for(let i=0;i<t.length;i++)if(e===t[i].assetId)return i;return-1}getAssetPlayer(e){const t=this.getAssetPlayerQueueIndex(e);return this.playerQueue[t]||null}getBufferingPlayer(){const{playerQueue:e,primaryMedia:t}=this;if(t){for(let i=0;i<e.length;i++)if(e[i].media===t)return e[i]}return null}createAsset(e,t,i,s,r,n){const o={parentIdentifier:e.identifier,identifier:of(e,n,t),duration:r,startOffset:i,timelineStart:s,uri:n};return this.createAssetPlayer(e,o,t)}createAssetPlayer(e,t,i){const s=this.hls,r=s.userConfig;let n=r.videoPreference;const o=s.loadLevelObj||s.levels[s.currentLevel];(n||o)&&(n=Ne({},n),o.videoCodec&&(n.videoCodec=o.videoCodec),o.videoRange&&(n.allowedVideoRanges=[o.videoRange]));const c=s.audioTracks[s.audioTrack],u=s.subtitleTracks[s.subtitleTrack];let h=0;if(this.primaryLive||e.appendInPlace){const w=this.timelinePos-t.timelineStart;if(w>1){const N=t.duration;N&&w<N&&(h=w)}}const f=t.identifier,g=Be(Be({},r),{},{maxMaxBufferLength:Math.min(180,s.config.maxMaxBufferLength),autoStartLoad:!0,startFragPrefetch:!0,primarySessionId:s.sessionId,assetPlayerId:f,abrEwmaDefaultEstimate:s.bandwidthEstimate,interstitialsController:void 0,startPosition:h,liveDurationInfinity:!1,testBandwidth:!1,videoPreference:n,audioPreference:c||r.audioPreference,subtitlePreference:u||r.subtitlePreference});e.appendInPlace&&(e.appendInPlaceStarted=!0,t.timelineStart&&(g.timelineOffset=t.timelineStart));const I=g.cmcd;I!=null&&I.sessionId&&I.contentId&&(g.cmcd=Ne({},I,{contentId:as(t.uri)})),this.getAssetPlayer(f)&&this.warn(`Duplicate date range identifier ${e} and asset ${f}`);const m=new cf(this.HlsPlayerClass,g,e,t);this.playerQueue.push(m),e.assetList[i]=t;let E=!0;const v=w=>{if(w.live){var N;const $=new Error(`Interstitials MUST be VOD assets ${e}`),F={fatal:!0,type:de.OTHER_ERROR,details:U.INTERSTITIAL_ASSET_ITEM_ERROR,error:$},O=((N=this.schedule)==null?void 0:N.findEventIndex(e.identifier))||-1;this.handleAssetItemError(F,e,O,i,$.message);return}const K=w.edge-w.fragmentStart,p=t.duration;(E||p===null||K>p)&&(E=!1,this.log(`Interstitial asset "${f}" duration change ${p} > ${K}`),t.duration=K,this.updateSchedule())};m.on(y.LEVEL_UPDATED,(w,{details:N})=>v(N)),m.on(y.LEVEL_PTS_UPDATED,(w,{details:N})=>v(N)),m.on(y.EVENT_CUE_ENTER,()=>this.onInterstitialCueEnter());const x=(w,N)=>{const K=this.getAssetPlayer(f);if(K&&N.tracks){K.off(y.BUFFER_CODECS,x),K.tracks=N.tracks;const p=this.primaryMedia;this.bufferingAsset===K.assetItem&&p&&!K.media&&this.bufferAssetPlayer(K,p)}};m.on(y.BUFFER_CODECS,x);const D=()=>{var w;const N=this.getAssetPlayer(f);if(this.log(`buffered to end of asset ${N}`),!N||!this.schedule)return;const K=this.schedule.findEventIndex(e.identifier),p=(w=this.schedule.items)==null?void 0:w[K];this.isInterstitial(p)&&this.advanceAssetBuffering(p,t)};m.on(y.BUFFERED_TO_END,D);const L=w=>()=>{if(!this.getAssetPlayer(f)||!this.schedule)return;this.shouldPlay=!0;const K=this.schedule.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,K,w)};return m.once(y.MEDIA_ENDED,L(i)),m.once(y.PLAYOUT_LIMIT_REACHED,L(1/0)),m.on(y.ERROR,(w,N)=>{if(!this.schedule)return;const K=this.getAssetPlayer(f);if(N.details===U.BUFFER_STALLED_ERROR){if(K!=null&&K.appendInPlace){this.handleInPlaceStall(e);return}this.onTimeupdate(),this.checkBuffer(!0);return}this.handleAssetItemError(N,e,this.schedule.findEventIndex(e.identifier),i,`Asset player error ${N.error} ${e}`)}),m.on(y.DESTROYING,()=>{if(!this.getAssetPlayer(f)||!this.schedule)return;const N=new Error(`Asset player destroyed unexpectedly ${f}`),K={fatal:!0,type:de.OTHER_ERROR,details:U.INTERSTITIAL_ASSET_ITEM_ERROR,error:N};this.handleAssetItemError(K,e,this.schedule.findEventIndex(e.identifier),i,N.message)}),this.log(`INTERSTITIAL_ASSET_PLAYER_CREATED ${$i(t)}`),this.hls.trigger(y.INTERSTITIAL_ASSET_PLAYER_CREATED,{asset:t,assetListIndex:i,event:e,player:m}),m}clearInterstitial(e,t){e.assetList.forEach(i=>{this.clearAssetPlayer(i.identifier,t)}),e.reset()}resetAssetPlayer(e){const t=this.getAssetPlayerQueueIndex(e);if(t!==-1){this.log(`reset asset player "${e}" after error`);const i=this.playerQueue[t];this.transferMediaFromPlayer(i,null),i.resetDetails()}}clearAssetPlayer(e,t){const i=this.getAssetPlayerQueueIndex(e);if(i!==-1){const s=this.playerQueue[i];this.log(`clear ${s} toSegment: ${t&&Pt(t)}`),this.transferMediaFromPlayer(s,t),this.playerQueue.splice(i,1),s.destroy()}}emptyPlayerQueue(){let e;for(;e=this.playerQueue.pop();)e.destroy();this.playerQueue=[]}startAssetPlayer(e,t,i,s,r){const{interstitial:n,assetItem:o,assetId:c}=e,u=n.assetList.length,h=this.playingAsset;this.endedAsset=null,this.playingAsset=o,(!h||h.identifier!==c)&&(h&&(this.clearAssetPlayer(h.identifier,i[s]),delete h.error),this.log(`INTERSTITIAL_ASSET_STARTED ${t+1}/${u} ${$i(o)}`),this.hls.trigger(y.INTERSTITIAL_ASSET_STARTED,{asset:o,assetListIndex:t,event:n,schedule:i.slice(0),scheduleIndex:s,player:e})),this.bufferAssetPlayer(e,r)}bufferAssetPlayer(e,t){var i,s;if(!this.schedule)return;const{interstitial:r,assetItem:n}=e,o=this.schedule.findEventIndex(r.identifier),c=(i=this.schedule.items)==null?void 0:i[o];if(!c)return;e.loadSource(),this.setBufferingItem(c),this.bufferingAsset=n;const u=this.getBufferingPlayer();if(u===e)return;const h=r.appendInPlace;if(h&&u?.interstitial.appendInPlace===!1)return;const f=u?.tracks||((s=this.detachedData)==null?void 0:s.tracks)||this.requiredTracks;if(h&&n!==this.playingAsset){if(!e.tracks){this.log(`Waiting for track info before buffering ${e}`);return}if(f&&!Zn(f,e.tracks)){const g=new Error(`Asset ${$i(n)} SourceBuffer tracks ('${Object.keys(e.tracks)}') are not compatible with primary content tracks ('${Object.keys(f)}')`),I={fatal:!0,type:de.OTHER_ERROR,details:U.INTERSTITIAL_ASSET_ITEM_ERROR,error:g},m=r.findAssetIndex(n);this.handleAssetItemError(I,r,o,m,g.message);return}}this.transferMediaTo(e,t)}handleInPlaceStall(e){const t=this.schedule,i=this.primaryMedia;if(!t||!i)return;const s=i.currentTime,r=t.findAssetIndex(e,s),n=e.assetList[r];if(n){const o=this.getAssetPlayer(n.identifier);if(o){const c=o.currentTime||s-n.timelineStart,u=o.duration-c;if(this.warn(`Stalled at ${c} of ${c+u} in ${o} ${e} (media.currentTime: ${s})`),c&&(u/i.playbackRate<.5||o.bufferedInPlaceToEnd(i))&&o.hls){const h=t.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,h,r)}}}}advanceInPlace(e){const t=this.primaryMedia;t&&t.currentTime<e&&(t.currentTime=e)}handleAssetItemError(e,t,i,s,r){if(e.details===U.BUFFER_STALLED_ERROR)return;const n=t.assetList[s]||null;if(this.warn(`INTERSTITIAL_ASSET_ERROR ${n&&$i(n)} ${e.error}`),!this.schedule)return;const o=n?.identifier||"",c=this.getAssetPlayerQueueIndex(o),u=this.playerQueue[c]||null,h=this.schedule.items,f=Ne({},e,{fatal:!1,errorAction:_i(!0),asset:n,assetListIndex:s,event:t,schedule:h,scheduleIndex:i,player:u});if(this.hls.trigger(y.INTERSTITIAL_ASSET_ERROR,f),!e.fatal)return;const g=this.playingAsset,I=this.bufferingAsset,m=new Error(r);if(n&&(this.clearAssetPlayer(o,null),n.error=m),!t.assetList.some(E=>!E.error))t.error=m;else for(let E=s;E<t.assetList.length;E++)this.resetAssetPlayer(t.assetList[E].identifier);this.updateSchedule(!0),t.error?this.primaryFallback(t):g&&g.identifier===o?this.advanceAfterAssetEnded(t,i,s):I&&I.identifier===o&&this.isInterstitial(this.bufferingItem)&&this.advanceAssetBuffering(this.bufferingItem,I)}primaryFallback(e){const t=e.timelineStart,i=this.effectivePlayingItem;if(i){this.log(`Fallback to primary from event "${e.identifier}" start: ${t} pos: ${this.timelinePos} playing: ${Pt(i)} error: ${e.error}`);let s=this.timelinePos;s===-1&&(s=this.hls.startPosition);const r=this.updateItem(i,s);if(this.itemsMatch(i,r)&&this.clearInterstitial(e,null),e.appendInPlace&&(this.attachPrimary(t,null),this.flushFrontBuffer(t)),!this.schedule)return;const n=this.schedule.findItemIndexAtTime(s);this.setSchedulePosition(n)}else this.checkStart()}onAssetListLoaded(e,t){var i,s;const r=t.event,n=r.identifier,o=t.assetListResponse.ASSETS;if(!((i=this.schedule)!=null&&i.hasEvent(n)))return;const c=r.timelineStart,u=r.duration;let h=0;o.forEach((E,v)=>{const x=parseFloat(E.DURATION);this.createAsset(r,v,h,c+h,x,E.URI),h+=x}),r.duration=h,this.log(`Loaded asset-list with duration: ${h} (was: ${u}) ${r}`);const f=this.waitingItem,g=f?.event.identifier===n;this.updateSchedule();const I=(s=this.bufferingItem)==null?void 0:s.event;if(g){var m;const E=this.schedule.findEventIndex(n),v=(m=this.schedule.items)==null?void 0:m[E];if(v){if(!this.playingItem&&this.timelinePos>v.end&&this.schedule.findItemIndexAtTime(this.timelinePos)!==E){r.error=new Error(`Interstitial no longer within playback range ${this.timelinePos} ${r}`),this.updateSchedule(!0),this.primaryFallback(r);return}this.setBufferingItem(v)}this.setSchedulePosition(E)}else if(I?.identifier===n){const E=r.assetList[0];if(E){const v=this.getAssetPlayer(E.identifier);if(I.appendInPlace){const x=this.primaryMedia;v&&x&&this.bufferAssetPlayer(v,x)}else v&&v.loadSource()}}}onError(e,t){if(this.schedule)switch(t.details){case U.ASSET_LIST_PARSING_ERROR:case U.ASSET_LIST_LOAD_ERROR:case U.ASSET_LIST_LOAD_TIMEOUT:{const i=t.interstitial;i&&(this.updateSchedule(!0),this.primaryFallback(i));break}case U.BUFFER_STALLED_ERROR:{const i=this.endedItem||this.waitingItem||this.playingItem;if(this.isInterstitial(i)&&i.event.appendInPlace){this.handleInPlaceStall(i.event);return}this.log(`Primary player stall @${this.timelinePos} bufferedPos: ${this.bufferedPos}`),this.onTimeupdate(),this.checkBuffer(!0);break}}}}const dl=500;class gf extends Ur{constructor(e,t,i){super(e,t,i,"subtitle-stream-controller",he.SUBTITLE),this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this.registerListeners()}onHandlerDestroying(){this.unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(y.LEVEL_LOADED,this.onLevelLoaded,this),e.on(y.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(y.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(y.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(y.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(y.BUFFER_FLUSHING,this.onBufferFlushing,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off(y.LEVEL_LOADED,this.onLevelLoaded,this),e.off(y.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(y.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(y.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(y.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(y.BUFFER_FLUSHING,this.onBufferFlushing,this)}startLoad(e,t){this.stopLoad(),this.state=j.IDLE,this.setInterval(dl),this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}onManifestLoading(){super.onManifestLoading(),this.mainDetails=null}onMediaDetaching(e,t){this.tracksBuffered=[],super.onMediaDetaching(e,t)}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,t){const{frag:i,success:s}=t;if(this.fragContextChanged(i)||(qe(i)&&(this.fragPrevious=i),this.state=j.IDLE),!s)return;const r=this.tracksBuffered[this.currentTrackId];if(!r)return;let n;const o=i.start;for(let u=0;u<r.length;u++)if(o>=r[u].start&&o<=r[u].end){n=r[u];break}const c=i.start+i.duration;n?n.end=c:(n={start:o,end:c},r.push(n)),this.fragmentTracker.fragBuffered(i),this.fragBufferedComplete(i,null),this.media&&this.tick()}onBufferFlushing(e,t){const{startOffset:i,endOffset:s}=t;if(i===0&&s!==Number.POSITIVE_INFINITY){const r=s-1;if(r<=0)return;t.endOffsetSubtitles=Math.max(0,r),this.tracksBuffered.forEach(n=>{for(let o=0;o<n.length;){if(n[o].end<=r){n.shift();continue}else if(n[o].start<r)n[o].start=r;else break;o++}}),this.fragmentTracker.removeFragmentsInRange(i,r,he.SUBTITLE)}}onError(e,t){const i=t.frag;i?.type===he.SUBTITLE&&(t.details===U.FRAG_GAP&&this.fragmentTracker.fragBuffered(i,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==j.STOPPED&&(this.state=j.IDLE))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){if(this.levels&&Go(this.levels,t)){this.levels=t.map(i=>new Zi(i));return}this.tracksBuffered=[],this.levels=t.map(i=>{const s=new Zi(i);return this.tracksBuffered[s.id]=[],s}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,he.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null}onSubtitleTrackSwitch(e,t){var i;if(this.currentTrackId=t.id,!((i=this.levels)!=null&&i.length)||this.currentTrackId===-1){this.clearInterval();return}const s=this.levels[this.currentTrackId];s!=null&&s.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,s&&this.state!==j.STOPPED&&this.setInterval(dl)}onSubtitleTrackLoaded(e,t){var i;const{currentTrackId:s,levels:r}=this,{details:n,id:o}=t;if(!r){this.warn(`Subtitle tracks were reset while loading level ${o}`);return}const c=r[o];if(o>=r.length||!c)return;this.log(`Subtitle track ${o} loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""},duration:${n.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;let u=0;if(n.live||(i=c.details)!=null&&i.live){if(n.deltaUpdateFailed)return;const f=this.mainDetails;if(!f){this.startFragRequested=!1;return}const g=f.fragments[0];if(!c.details)n.hasProgramDateTime&&f.hasProgramDateTime?(Ms(n,f),u=n.fragmentStart):g&&(u=g.start,Br(n,u));else{var h;u=this.alignPlaylists(n,c.details,(h=this.levelLastLoaded)==null?void 0:h.details),u===0&&g&&(u=g.start,Br(n,u))}f&&!this.startFragRequested&&this.setStartPosition(f,u)}c.details=n,this.levelLastLoaded=c,o===s&&(this.hls.trigger(y.SUBTITLE_TRACK_UPDATED,{details:n,id:o,groupId:t.groupId}),this.tick(),n.live&&!this.fragCurrent&&this.media&&this.state===j.IDLE&&(yi(null,n.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),c.details=void 0)))}_handleFragmentLoadComplete(e){const{frag:t,payload:i}=e,s=t.decryptdata,r=this.hls;if(!this.fragContextChanged(t)&&i&&i.byteLength>0&&s!=null&&s.key&&s.iv&&ki(s.method)){const n=performance.now();this.decrypter.decrypt(new Uint8Array(i),s.key.buffer,s.iv.buffer,_r(s.method)).catch(o=>{throw r.trigger(y.ERROR,{type:de.MEDIA_ERROR,details:U.FRAG_DECRYPT_ERROR,fatal:!1,error:o,reason:o.message,frag:t}),o}).then(o=>{const c=performance.now();r.trigger(y.FRAG_DECRYPTED,{frag:t,payload:o,stats:{tstart:n,tdecrypt:c}})}).catch(o=>{this.warn(`${o.name}: ${o.message}`),this.state=j.IDLE})}}doTick(){if(!this.media){this.state=j.IDLE;return}if(this.state===j.IDLE){const{currentTrackId:e,levels:t}=this,i=t?.[e];if(!i||!t.length||!i.details||this.waitForLive(i))return;const{config:s}=this,r=this.getLoadPosition(),n=ye.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],r,s.maxBufferHole),{end:o,len:c}=n,u=i.details,h=this.hls.maxBufferLength+u.levelTargetDuration;if(c>h)return;const f=u.fragments,g=f.length,I=u.edge;let m=null;const E=this.fragPrevious;if(o<I){const D=s.maxFragLookUpTolerance,L=o>I-D?0:D;m=yi(E,f,Math.max(f[0].start,o),L),!m&&E&&E.start<f[0].start&&(m=f[0])}else m=f[g-1];if(m=this.filterReplacedPrimary(m,i.details),!m)return;const v=m.sn-u.startSN,x=f[v-1];if(x&&x.cc===m.cc&&this.fragmentTracker.getState(x)===Qe.NOT_LOADED&&(m=x),this.fragmentTracker.getState(m)===Qe.NOT_LOADED){const D=this.mapToInitFragWhenRequired(m);D&&this.loadFragment(D,i,o)}}}loadFragment(e,t,i){qe(e)?super.loadFragment(e,t,i):this._loadInitSegment(e,t)}get mediaBufferTimeRanges(){return new pf(this.tracksBuffered[this.currentTrackId]||[])}}class pf{constructor(e){this.buffered=void 0;const t=(i,s,r)=>{if(s=s>>>0,s>r-1)throw new DOMException(`Failed to execute '${i}' on 'TimeRanges': The index provided (${s}) is greater than the maximum bound (${r})`);return e[s][i]};this.buffered={get length(){return e.length},end(i){return t("end",i,e.length)},start(i){return t("start",i,e.length)}}}}const Af={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},fl=a=>String.fromCharCode(Af[a]||a),_t=15,Zt=100,mf={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},If={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Cf={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},yf={25:2,26:4,29:6,30:8,31:10,27:13,28:15},Ef=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class vf{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){const i=typeof t=="function"?t():t;Oe.log(`${this.time} [${e}] ${i}`)}}}const vi=function(e){const t=[];for(let i=0;i<e.length;i++)t.push(e[i].toString(16));return t};class gl{constructor(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(e){const t=["foreground","underline","italics","background","flash"];for(let i=0;i<t.length;i++){const s=t[i];e.hasOwnProperty(s)&&(this[s]=e[s])}}isDefault(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash}equals(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}copy(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}class Tf{constructor(){this.uchar=" ",this.penState=new gl}reset(){this.uchar=" ",this.penState.reset()}setChar(e,t){this.uchar=e,this.penState.copy(t)}setPenState(e){this.penState.copy(e)}equals(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}copy(e){this.uchar=e.uchar,this.penState.copy(e.penState)}isEmpty(){return this.uchar===" "&&this.penState.isDefault()}}class Sf{constructor(e){this.chars=[],this.pos=0,this.currPenState=new gl,this.cueStartTime=null,this.logger=void 0;for(let t=0;t<Zt;t++)this.chars.push(new Tf);this.logger=e}equals(e){for(let t=0;t<Zt;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}copy(e){for(let t=0;t<Zt;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<Zt;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e}setCursor(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>Zt&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=Zt)}moveCursor(e){const t=this.pos+e;if(e>1)for(let i=this.pos+1;i<t+1;i++)this.chars[i].setPenState(this.currPenState);this.setCursor(t)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(e){e>=144&&this.backSpace();const t=fl(e);if(this.pos>=Zt){this.logger.log(0,()=>"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1)}clearFromPos(e){let t;for(t=e;t<Zt;t++)this.chars[t].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){const e=[];let t=!0;for(let i=0;i<Zt;i++){const s=this.chars[i].uchar;s!==" "&&(t=!1),e.push(s)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}}class fn{constructor(e){this.rows=[],this.currRow=_t-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<_t;t++)this.rows.push(new Sf(e));this.logger=e}reset(){for(let e=0;e<_t;e++)this.rows[e].clear();this.currRow=_t-1}equals(e){let t=!0;for(let i=0;i<_t;i++)if(!this.rows[i].equals(e.rows[i])){t=!1;break}return t}copy(e){for(let t=0;t<_t;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<_t;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(e){this.rows[this.currRow].insertChar(e)}setPen(e){this.rows[this.currRow].setPenStyles(e)}moveCursor(e){this.rows[this.currRow].moveCursor(e)}setCursor(e){this.logger.log(2,"setCursor: "+e),this.rows[this.currRow].setCursor(e)}setPAC(e){this.logger.log(2,()=>"pacData = "+Ge(e));let t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(let o=0;o<_t;o++)this.rows[o].clear();const r=this.currRow+1-this.nrRollUpRows,n=this.lastOutputScreen;if(n){const o=n.rows[r].cueStartTime,c=this.logger.time;if(o!==null&&c!==null&&o<c)for(let u=0;u<this.nrRollUpRows;u++)this.rows[t-this.nrRollUpRows+u+1].copy(n.rows[r+u])}}this.currRow=t;const i=this.rows[this.currRow];if(e.indent!==null){const r=e.indent,n=Math.max(r-1,0);i.setCursor(e.indent),e.color=i.chars[n].penState.foreground}const s={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(s)}setBkgData(e){this.logger.log(2,()=>"bkgData = "+Ge(e)),this.backSpace(),this.setPen(e),this.insertChar(32)}setRollUpRows(e){this.nrRollUpRows=e}rollUp(){if(this.nrRollUpRows===null){this.logger.log(3,"roll_up but nrRollUpRows not set yet");return}this.logger.log(1,()=>this.getDisplayText());const e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(2,"Rolling up")}getDisplayText(e){e=e||!1;const t=[];let i="",s=-1;for(let r=0;r<_t;r++){const n=this.rows[r].getTextString();n&&(s=r+1,e?t.push("Row "+s+": '"+n+"'"):t.push(n.trim()))}return t.length>0&&(e?i="["+t.join(" | ")+"]":i=t.join(`
30
- `)),i}getTextAndFormat(){return this.rows}}class pl{constructor(e,t,i){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new fn(i),this.nonDisplayedMemory=new fn(i),this.lastOutputScreen=new fn(i),this.currRollUpRow=this.displayedMemory.rows[_t-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=i}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[_t-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(e){this.outputFilter=e}setPAC(e){this.writeScreen.setPAC(e)}setBkgData(e){this.writeScreen.setBkgData(e)}setMode(e){e!==this.mode&&(this.mode=e,this.logger.log(2,()=>"MODE="+e),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}insertChars(e){for(let i=0;i<e.length;i++)this.writeScreen.insertChar(e[i]);const t=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>t+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(1,()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){const e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}ccTO(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}ccMIDROW(e){const t={flash:!1};if(t.underline=e%2===1,t.italics=e>=46,t.italics)t.foreground="white";else{const i=Math.floor(e/2)-16,s=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=s[i]}this.logger.log(2,"MIDROW: "+Ge(t)),this.writeScreen.setPen(t)}outputDataUpdate(e=!1){const t=this.logger.time;t!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=t:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t),this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))}}class Al{constructor(e,t,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory=bf(),this.logger=void 0;const s=this.logger=new vf;this.channels=[null,new pl(e,t,s),new pl(e+1,i,s)]}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t)}addData(e,t){this.logger.time=e;for(let i=0;i<t.length;i+=2){const s=t[i]&127,r=t[i+1]&127;let n=!1,o=null;if(s===0&&r===0)continue;this.logger.log(3,()=>"["+vi([t[i],t[i+1]])+"] -> ("+vi([s,r])+")");const c=this.cmdHistory;if(s>=16&&s<=31){if(xf(s,r,c)){zs(null,null,c),this.logger.log(3,()=>"Repeated command ("+vi([s,r])+") is dropped");continue}zs(s,r,this.cmdHistory),n=this.parseCmd(s,r),n||(n=this.parseMidrow(s,r)),n||(n=this.parsePAC(s,r)),n||(n=this.parseBackgroundAttributes(s,r))}else zs(null,null,c);if(!n&&(o=this.parseChars(s,r),o)){const h=this.currentChannel;h&&h>0?this.channels[h].insertChars(o):this.logger.log(2,"No channel found yet. TEXT-MODE?")}!n&&!o&&this.logger.log(2,()=>"Couldn't parse cleaned data "+vi([s,r])+" orig: "+vi([t[i],t[i+1]]))}}parseCmd(e,t){const i=(e===20||e===28||e===21||e===29)&&t>=32&&t<=47,s=(e===23||e===31)&&t>=33&&t<=35;if(!(i||s))return!1;const r=e===20||e===21||e===23?1:2,n=this.channels[r];return e===20||e===21||e===28||e===29?t===32?n.ccRCL():t===33?n.ccBS():t===34?n.ccAOF():t===35?n.ccAON():t===36?n.ccDER():t===37?n.ccRU(2):t===38?n.ccRU(3):t===39?n.ccRU(4):t===40?n.ccFON():t===41?n.ccRDC():t===42?n.ccTR():t===43?n.ccRTD():t===44?n.ccEDM():t===45?n.ccCR():t===46?n.ccENM():t===47&&n.ccEOC():n.ccTO(t-32),this.currentChannel=r,!0}parseMidrow(e,t){let i=0;if((e===17||e===25)&&t>=32&&t<=47){if(e===17?i=1:i=2,i!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;const s=this.channels[i];return s?(s.ccMIDROW(t),this.logger.log(3,()=>"MIDROW ("+vi([e,t])+")"),!0):!1}return!1}parsePAC(e,t){let i;const s=(e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127,r=(e===16||e===24)&&t>=64&&t<=95;if(!(s||r))return!1;const n=e<=23?1:2;t>=64&&t<=95?i=n===1?mf[e]:Cf[e]:i=n===1?If[e]:yf[e];const o=this.channels[n];return o?(o.setPAC(this.interpretPAC(i,t)),this.currentChannel=n,!0):!1}interpretPAC(e,t){let i;const s={color:null,italics:!1,indent:null,underline:!1,row:e};return t>95?i=t-96:i=t-64,s.underline=(i&1)===1,i<=13?s.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(i/2)]:i<=15?(s.italics=!0,s.color="white"):s.indent=Math.floor((i-16)/2)*4,s}parseChars(e,t){let i,s=null,r=null;if(e>=25?(i=2,r=e-8):(i=1,r=e),r>=17&&r<=19){let n;r===17?n=t+80:r===18?n=t+112:n=t+144,this.logger.log(2,()=>"Special char '"+fl(n)+"' in channel "+i),s=[n]}else e>=32&&e<=127&&(s=t===0?[e]:[e,t]);return s&&this.logger.log(3,()=>"Char codes = "+vi(s).join(",")),s}parseBackgroundAttributes(e,t){const i=(e===16||e===24)&&t>=32&&t<=47,s=(e===23||e===31)&&t>=45&&t<=47;if(!(i||s))return!1;let r;const n={};e===16||e===24?(r=Math.floor((t-32)/2),n.background=Ef[r],t%2===1&&(n.background=n.background+"_semi")):t===45?n.background="transparent":(n.foreground="black",t===47&&(n.underline=!0));const o=e<=23?1:2;return this.channels[o].setBkgData(n),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){const t=this.channels[e];t&&t.reset()}zs(null,null,this.cmdHistory)}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){const i=this.channels[t];i&&i.cueSplitAtTime(e)}}}function zs(a,e,t){t.a=a,t.b=e}function xf(a,e,t){return t.a===a&&t.b===e}function bf(){return{a:null,b:null}}var gn=(function(){if(Ps!=null&&Ps.VTTCue)return self.VTTCue;const a=["","lr","rl"],e=["start","middle","end","left","right"];function t(o,c){if(typeof c!="string"||!Array.isArray(o))return!1;const u=c.toLowerCase();return~o.indexOf(u)?u:!1}function i(o){return t(a,o)}function s(o){return t(e,o)}function r(o,...c){let u=1;for(;u<arguments.length;u++){const h=arguments[u];for(const f in h)o[f]=h[f]}return o}function n(o,c,u){const h=this,f={enumerable:!0};h.hasBeenReset=!1;let g="",I=!1,m=o,E=c,v=u,x=null,D="",L=!0,w="auto",N="start",K=50,p="middle",$=50,F="middle";Object.defineProperty(h,"id",r({},f,{get:function(){return g},set:function(O){g=""+O}})),Object.defineProperty(h,"pauseOnExit",r({},f,{get:function(){return I},set:function(O){I=!!O}})),Object.defineProperty(h,"startTime",r({},f,{get:function(){return m},set:function(O){if(typeof O!="number")throw new TypeError("Start time must be set to a number.");m=O,this.hasBeenReset=!0}})),Object.defineProperty(h,"endTime",r({},f,{get:function(){return E},set:function(O){if(typeof O!="number")throw new TypeError("End time must be set to a number.");E=O,this.hasBeenReset=!0}})),Object.defineProperty(h,"text",r({},f,{get:function(){return v},set:function(O){v=""+O,this.hasBeenReset=!0}})),Object.defineProperty(h,"region",r({},f,{get:function(){return x},set:function(O){x=O,this.hasBeenReset=!0}})),Object.defineProperty(h,"vertical",r({},f,{get:function(){return D},set:function(O){const W=i(O);if(W===!1)throw new SyntaxError("An invalid or illegal string was specified.");D=W,this.hasBeenReset=!0}})),Object.defineProperty(h,"snapToLines",r({},f,{get:function(){return L},set:function(O){L=!!O,this.hasBeenReset=!0}})),Object.defineProperty(h,"line",r({},f,{get:function(){return w},set:function(O){if(typeof O!="number"&&O!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");w=O,this.hasBeenReset=!0}})),Object.defineProperty(h,"lineAlign",r({},f,{get:function(){return N},set:function(O){const W=s(O);if(!W)throw new SyntaxError("An invalid or illegal string was specified.");N=W,this.hasBeenReset=!0}})),Object.defineProperty(h,"position",r({},f,{get:function(){return K},set:function(O){if(O<0||O>100)throw new Error("Position must be between 0 and 100.");K=O,this.hasBeenReset=!0}})),Object.defineProperty(h,"positionAlign",r({},f,{get:function(){return p},set:function(O){const W=s(O);if(!W)throw new SyntaxError("An invalid or illegal string was specified.");p=W,this.hasBeenReset=!0}})),Object.defineProperty(h,"size",r({},f,{get:function(){return $},set:function(O){if(O<0||O>100)throw new Error("Size must be between 0 and 100.");$=O,this.hasBeenReset=!0}})),Object.defineProperty(h,"align",r({},f,{get:function(){return F},set:function(O){const W=s(O);if(!W)throw new SyntaxError("An invalid or illegal string was specified.");F=W,this.hasBeenReset=!0}})),h.displayState=void 0}return n.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},n})();class Lf{decode(e,t){if(!e)return"";if(typeof e!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}function ml(a){function e(i,s,r,n){return(i|0)*3600+(s|0)*60+(r|0)+parseFloat(n||0)}const t=a.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return t?parseFloat(t[2])>59?e(t[2],t[3],0,t[4]):e(t[1],t[2],t[3],t[4]):null}class Rf{constructor(){this.values=Object.create(null)}set(e,t){!this.get(e)&&t!==""&&(this.values[e]=t)}get(e,t,i){return i?this.has(e)?this.values[e]:t[i]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,i){for(let s=0;s<i.length;++s)if(t===i[s]){this.set(e,t);break}}integer(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))}percent(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){const i=parseFloat(t);if(i>=0&&i<=100)return this.set(e,i),!0}return!1}}function Il(a,e,t,i){const s=i?a.split(i):[a];for(const r in s){if(typeof s[r]!="string")continue;const n=s[r].split(t);if(n.length!==2)continue;const o=n[0],c=n[1];e(o,c)}}const pn=new gn(0,0,""),qs=pn.align==="middle"?"middle":"center";function Df(a,e,t){const i=a;function s(){const o=ml(a);if(o===null)throw new Error("Malformed timestamp: "+i);return a=a.replace(/^[^\sa-zA-Z-]+/,""),o}function r(o,c){const u=new Rf;Il(o,function(g,I){let m;switch(g){case"region":for(let E=t.length-1;E>=0;E--)if(t[E].id===I){u.set(g,t[E].region);break}break;case"vertical":u.alt(g,I,["rl","lr"]);break;case"line":m=I.split(","),u.integer(g,m[0]),u.percent(g,m[0])&&u.set("snapToLines",!1),u.alt(g,m[0],["auto"]),m.length===2&&u.alt("lineAlign",m[1],["start",qs,"end"]);break;case"position":m=I.split(","),u.percent(g,m[0]),m.length===2&&u.alt("positionAlign",m[1],["start",qs,"end","line-left","line-right","auto"]);break;case"size":u.percent(g,I);break;case"align":u.alt(g,I,["start",qs,"end","left","right"]);break}},/:/,/\s/),c.region=u.get("region",null),c.vertical=u.get("vertical","");let h=u.get("line","auto");h==="auto"&&pn.line===-1&&(h=-1),c.line=h,c.lineAlign=u.get("lineAlign","start"),c.snapToLines=u.get("snapToLines",!0),c.size=u.get("size",100),c.align=u.get("align",qs);let f=u.get("position","auto");f==="auto"&&pn.position===50&&(f=c.align==="start"||c.align==="left"?0:c.align==="end"||c.align==="right"?100:50),c.position=f}function n(){a=a.replace(/^\s+/,"")}if(n(),e.startTime=s(),n(),a.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+i);a=a.slice(3),n(),e.endTime=s(),n(),r(a,e)}function Cl(a){return a.replace(/<br(?: \/)?>/gi,`
31
- `)}class Pf{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new Lf,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(e){const t=this;e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));function i(){let r=t.buffer,n=0;for(r=Cl(r);n<r.length&&r[n]!=="\r"&&r[n]!==`
32
- `;)++n;const o=r.slice(0,n);return r[n]==="\r"&&++n,r[n]===`
33
- `&&++n,t.buffer=r.slice(n),o}function s(r){Il(r,function(n,o){},/:/)}try{let r="";if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer))return this;r=i();const o=r.match(/^()?WEBVTT([ \t].*)?$/);if(!(o!=null&&o[0]))throw new Error("Malformed WebVTT signature.");t.state="HEADER"}let n=!1;for(;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(n?n=!1:r=i(),t.state){case"HEADER":/:/.test(r)?s(r):r||(t.state="ID");continue;case"NOTE":r||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(r)){t.state="NOTE";break}if(!r)continue;if(t.cue=new gn(0,0,""),t.state="CUE",r.indexOf("-->")===-1){t.cue.id=r;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{Df(r,t.cue,t.regionList)}catch{t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{const o=r.indexOf("-->")!==-1;if(!r||o&&(n=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(t.cue===null)continue;t.cue.text&&(t.cue.text+=`
34
- `),t.cue.text+=r}continue;case"BADCUE":r||(t.state="ID")}}}catch{t.state==="CUETEXT"&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state=t.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this}flush(){const e=this;try{if((e.cue||e.state==="HEADER")&&(e.buffer+=`
35
-
36
- `,e.parse()),e.state==="INITIAL"||e.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this}}const _f=/\r\n|\n\r|\n|\r/g,An=function(e,t,i=0){return e.slice(i,i+t.length)===t},wf=function(e){let t=parseInt(e.slice(-3));const i=parseInt(e.slice(-6,-4)),s=parseInt(e.slice(-9,-7)),r=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!se(t)||!se(i)||!se(s)||!se(r))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*i,t+=60*1e3*s,t+=3600*1e3*r,t};function mn(a,e,t){return as(a.toString())+as(e.toString())+as(t)}const kf=function(e,t,i){let s=e[t],r=e[s.prevCC];if(!r||!r.new&&s.new){e.ccOffset=e.presentationOffset=s.start,s.new=!1;return}for(;(n=r)!=null&&n.new;){var n;e.ccOffset+=s.start-r.start,s.new=!1,s=r,r=e[s.prevCC]}e.presentationOffset=i};function Mf(a,e,t,i,s,r,n){const o=new Pf,c=mt(new Uint8Array(a)).trim().replace(_f,`
37
- `).split(`
38
- `),u=[],h=e?Vh(e.baseTime,e.timescale):0;let f="00:00.000",g=0,I=0,m,E=!0;o.oncue=function(v){const x=t[i];let D=t.ccOffset;const L=(g-h)/9e4;if(x!=null&&x.new&&(I!==void 0?D=t.ccOffset=x.start:kf(t,i,L)),L){if(!e){m=new Error("Missing initPTS for VTT MPEGTS");return}D=L-t.presentationOffset}const w=v.endTime-v.startTime,N=xt((v.startTime+D-I)*9e4,s*9e4)/9e4;v.startTime=Math.max(N,0),v.endTime=Math.max(N+w,0);const K=v.text.trim();v.text=decodeURIComponent(encodeURIComponent(K)),v.id||(v.id=mn(v.startTime,v.endTime,K)),v.endTime>0&&u.push(v)},o.onparsingerror=function(v){m=v},o.onflush=function(){if(m){n(m);return}r(u)},c.forEach(v=>{if(E)if(An(v,"X-TIMESTAMP-MAP=")){E=!1,v.slice(16).split(",").forEach(x=>{An(x,"LOCAL:")?f=x.slice(6):An(x,"MPEGTS:")&&(g=parseInt(x.slice(7)))});try{I=wf(f)/1e3}catch(x){m=x}return}else v===""&&(E=!1);o.parse(v+`
39
- `)}),o.flush()}const In="stpp.ttml.im1t",yl=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,El=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,Of={left:"start",center:"center",right:"end",start:"start",end:"end"};function vl(a,e,t,i){const s=xe(new Uint8Array(a),["mdat"]);if(s.length===0){i(new Error("Could not parse IMSC1 mdat"));return}const r=s.map(o=>mt(o)),n=Hh(e.baseTime,1,e.timescale);try{r.forEach(o=>t(Ff(o,n)))}catch(o){i(o)}}function Ff(a,e){const s=new DOMParser().parseFromString(a,"text/xml").getElementsByTagName("tt")[0];if(!s)throw new Error("Invalid ttml");const r={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},n=Object.keys(r).reduce((f,g)=>(f[g]=s.getAttribute(`ttp:${g}`)||r[g],f),{}),o=s.getAttribute("xml:space")!=="preserve",c=Tl(Cn(s,"styling","style")),u=Tl(Cn(s,"layout","region")),h=Cn(s,"body","[begin]");return[].map.call(h,f=>{const g=Sl(f,o);if(!g||!f.hasAttribute("begin"))return null;const I=En(f.getAttribute("begin"),n),m=En(f.getAttribute("dur"),n);let E=En(f.getAttribute("end"),n);if(I===null)throw xl(f);if(E===null){if(m===null)throw xl(f);E=I+m}const v=new gn(I-e,E-e,g);v.id=mn(v.startTime,v.endTime,v.text);const x=u[f.getAttribute("region")],D=c[f.getAttribute("style")],L=Nf(x,D,c),{textAlign:w}=L;if(w){const N=Of[w];N&&(v.lineAlign=N),v.align=w}return Ne(v,L),v}).filter(f=>f!==null)}function Cn(a,e,t){const i=a.getElementsByTagName(e)[0];return i?[].slice.call(i.querySelectorAll(t)):[]}function Tl(a){return a.reduce((e,t)=>{const i=t.getAttribute("xml:id");return i&&(e[i]=t),e},{})}function Sl(a,e){return[].slice.call(a.childNodes).reduce((t,i,s)=>{var r;return i.nodeName==="br"&&s?t+`
40
- `:(r=i.childNodes)!=null&&r.length?Sl(i,e):e?t+i.textContent.trim().replace(/\s+/g," "):t+i.textContent},"")}function Nf(a,e,t){const i="http://www.w3.org/ns/ttml#styling";let s=null;const r=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],n=a!=null&&a.hasAttribute("style")?a.getAttribute("style"):null;return n&&t.hasOwnProperty(n)&&(s=t[n]),r.reduce((o,c)=>{const u=yn(e,i,c)||yn(a,i,c)||yn(s,i,c);return u&&(o[c]=u),o},{})}function yn(a,e,t){return a&&a.hasAttributeNS(e,t)?a.getAttributeNS(e,t):null}function xl(a){return new Error(`Could not parse ttml timestamp ${a}`)}function En(a,e){if(!a)return null;let t=ml(a);return t===null&&(yl.test(a)?t=Bf(a,e):El.test(a)&&(t=Uf(a,e))),t}function Bf(a,e){const t=yl.exec(a),i=(t[4]|0)+(t[5]|0)/e.subFrameRate;return(t[1]|0)*3600+(t[2]|0)*60+(t[3]|0)+i/e.frameRate}function Uf(a,e){const t=El.exec(a),i=Number(t[1]);switch(t[2]){case"h":return i*3600;case"m":return i*60;case"ms":return i*1e3;case"f":return i/e.frameRate;case"t":return i/e.tickRate}return i}class Xs{constructor(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}dispatchCue(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(e,t,i){(this.startTime===null||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=i,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}class $f{constructor(e){this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=Rl(),this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},e.on(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(y.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(y.FRAG_LOADING,this.onFragLoading,this),e.on(y.FRAG_LOADED,this.onFragLoaded,this),e.on(y.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(y.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(y.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(y.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(y.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:e}=this;e.off(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(y.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(y.FRAG_LOADING,this.onFragLoading,this),e.off(y.FRAG_LOADED,this.onFragLoaded,this),e.off(y.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(y.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(y.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(y.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(y.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){const e=new Xs(this,"textTrack1"),t=new Xs(this,"textTrack2"),i=new Xs(this,"textTrack3"),s=new Xs(this,"textTrack4");this.cea608Parser1=new Al(1,e,t),this.cea608Parser2=new Al(3,i,s)}addCues(e,t,i,s,r){let n=!1;for(let o=r.length;o--;){const c=r[o],u=Gf(c[0],c[1],t,i);if(u>=0&&(c[0]=Math.min(c[0],t),c[1]=Math.max(c[1],i),n=!0,u/(i-t)>.5))return}if(n||r.push([t,i]),this.config.renderTextTracksNatively){const o=this.captionsTracks[e];this.Cues.newCue(o,t,i,s)}else{const o=this.Cues.newCue(null,t,i,s);this.hls.trigger(y.CUES_PARSED,{type:"captions",cues:o,track:e})}}onInitPtsFound(e,{frag:t,id:i,initPTS:s,timescale:r,trackId:n}){const{unparsedVttFrags:o}=this;i===he.MAIN&&(this.initPTS[t.cc]={baseTime:s,timescale:r,trackId:n}),o.length&&(this.unparsedVttFrags=[],o.forEach(c=>{this.initPTS[c.frag.cc]?this.onFragLoaded(y.FRAG_LOADED,c):this.hls.trigger(y.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:c.frag,error:new Error("Subtitle discontinuity domain does not match main")})}))}getExistingTrack(e,t){const{media:i}=this;if(i)for(let s=0;s<i.textTracks.length;s++){const r=i.textTracks[s];if(Ll(r,{name:e,lang:t,characteristics:"transcribes-spoken-dialog,describes-music-and-sound"}))return r}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;const{captionsProperties:t,captionsTracks:i,media:s}=this,{label:r,languageCode:n}=t[e],o=this.getExistingTrack(r,n);if(o)i[e]=o,Bi(i[e]),ol(i[e],s);else{const c=this.createTextTrack("captions",r,n);c&&(c[e]=!0,i[e]=c)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;const t=this.captionsProperties[e];if(!t)return;const i=t.label,s={_id:e,label:i,kind:"captions",default:t.media?!!t.media.default:!1,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=s,this.hls.trigger(y.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[s]})}createTextTrack(e,t,i){const s=this.media;if(s)return s.addTextTrack(e,t,i)}onMediaAttaching(e,t){this.media=t.media,t.mediaSource||this._cleanTracks()}onMediaDetaching(e,t){const i=!!t.transferMedia;if(this.media=null,i)return;const{captionsTracks:s}=this;Object.keys(s).forEach(r=>{Bi(s[r]),delete s[r]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=Rl(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){const{media:e}=this;if(!e)return;const t=e.textTracks;if(t)for(let i=0;i<t.length;i++)Bi(t[i])}onSubtitleTracksUpdated(e,t){const i=t.subtitleTracks||[],s=i.some(r=>r.textCodec===In);if(this.config.enableWebVTT||s&&this.config.enableIMSC1){if(Go(this.tracks,i)){this.tracks=i;return}if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){const n=this.media,o=n?Ys(n.textTracks):null;if(this.tracks.forEach((c,u)=>{let h;if(o){let f=null;for(let g=0;g<o.length;g++)if(o[g]&&Ll(o[g],c)){f=o[g],o[g]=null;break}f&&(h=f)}if(h)Bi(h);else{const f=bl(c);h=this.createTextTrack(f,c.name,c.lang),h&&(h.mode="disabled")}h&&this.textTracks.push(h)}),o!=null&&o.length){const c=o.filter(u=>u!==null).map(u=>u.label);c.length&&this.hls.logger.warn(`Media element contains unused subtitle tracks: ${c.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`)}}else if(this.tracks.length){const n=this.tracks.map(o=>({label:o.name,kind:o.type.toLowerCase(),default:o.default,subtitleTrack:o}));this.hls.trigger(y.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:n})}}}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(i=>{const s=/(?:CC|SERVICE)([1-4])/.exec(i.instreamId);if(!s)return;const r=`textTrack${s[1]}`,n=this.captionsProperties[r];n&&(n.label=i.name,i.lang&&(n.languageCode=i.lang),n.media=i)})}closedCaptionsForLevel(e){const t=this.hls.levels[e.level];return t?.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){if(this.enabled&&t.frag.type===he.MAIN){var i,s;const{cea608Parser1:r,cea608Parser2:n,lastSn:o}=this,{cc:c,sn:u}=t.frag,h=(i=(s=t.part)==null?void 0:s.index)!=null?i:-1;r&&n&&(u!==o+1||u===o&&h!==this.lastPartIndex+1||c!==this.lastCc)&&(r.reset(),n.reset()),this.lastCc=c,this.lastSn=u,this.lastPartIndex=h}}onFragLoaded(e,t){const{frag:i,payload:s}=t;if(i.type===he.SUBTITLE)if(s.byteLength){const r=i.decryptdata,n="stats"in t;if(r==null||!r.encrypted||n){const o=this.tracks[i.level],c=this.vttCCs;c[i.cc]||(c[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),o&&o.textCodec===In?this._parseIMSC1(i,s):this._parseVTTs(t)}}else this.hls.trigger(y.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){const i=this.hls;vl(t,this.initPTS[e.cc],s=>{this._appendCues(s,e.level),i.trigger(y.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},s=>{i.logger.log(`Failed to parse IMSC1: ${s}`),i.trigger(y.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:s})})}_parseVTTs(e){var t;const{frag:i,payload:s}=e,{initPTS:r,unparsedVttFrags:n}=this,o=r.length-1;if(!r[i.cc]&&o===-1){n.push(e);return}const c=this.hls,u=(t=i.initSegment)!=null&&t.data?St(i.initSegment.data,new Uint8Array(s)).buffer:s;Mf(u,this.initPTS[i.cc],this.vttCCs,i.cc,i.start,h=>{this._appendCues(h,i.level),c.trigger(y.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:i})},h=>{const f=h.message==="Missing initPTS for VTT MPEGTS";f?n.push(e):this._fallbackToIMSC1(i,s),c.logger.log(`Failed to parse VTT cue: ${h}`),!(f&&o>i.cc)&&c.trigger(y.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:h})})}_fallbackToIMSC1(e,t){const i=this.tracks[e.level];i.textCodec||vl(t,this.initPTS[e.cc],()=>{i.textCodec=In,this._parseIMSC1(e,t)},()=>{i.textCodec="wvtt"})}_appendCues(e,t){const i=this.hls;if(this.config.renderTextTracksNatively){const s=this.textTracks[t];if(!s||s.mode==="disabled")return;e.forEach(r=>ll(s,r))}else{const s=this.tracks[t];if(!s)return;const r=s.default?"default":"subtitles"+t;i.trigger(y.CUES_PARSED,{type:"subtitles",cues:e,track:r})}}onFragDecrypted(e,t){const{frag:i}=t;i.type===he.SUBTITLE&&this.onFragLoaded(y.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){if(!this.enabled||!this.config.enableCEA708Captions)return;const{frag:i,samples:s}=t;if(!(i.type===he.MAIN&&this.closedCaptionsForLevel(i)==="NONE"))for(let r=0;r<s.length;r++){const n=s[r].bytes;if(n){this.cea608Parser1||this.initCea608Parsers();const o=this.extractCea608Data(n);this.cea608Parser1.addData(s[r].pts,o[0]),this.cea608Parser2.addData(s[r].pts,o[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:i,endOffsetSubtitles:s,type:r}){const{media:n}=this;if(!(!n||n.currentTime<i)){if(!r||r==="video"){const{captionsTracks:o}=this;Object.keys(o).forEach(c=>cn(o[c],t,i))}if(this.config.renderTextTracksNatively&&t===0&&s!==void 0){const{textTracks:o}=this;Object.keys(o).forEach(c=>cn(o[c],t,s))}}}extractCea608Data(e){const t=[[],[]],i=e[0]&31;let s=2;for(let r=0;r<i;r++){const n=e[s++],o=127&e[s++],c=127&e[s++];if(o===0&&c===0)continue;if((4&n)!==0){const h=3&n;(h===0||h===1)&&(t[h].push(o),t[h].push(c))}}return t}}function bl(a){return a.characteristics&&/transcribes-spoken-dialog/gi.test(a.characteristics)&&/describes-music-and-sound/gi.test(a.characteristics)?"captions":"subtitles"}function Ll(a,e){return!!a&&a.kind===bl(e)&&tn(e,a)}function Gf(a,e,t,i){return Math.min(e,i)-Math.max(a,t)}function Rl(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}const Hf=/\s/,Vf={newCue(a,e,t,i){const s=[];let r,n,o,c,u;const h=self.VTTCue||self.TextTrackCue;for(let g=0;g<i.rows.length;g++)if(r=i.rows[g],o=!0,c=0,u="",!r.isEmpty()){var f;for(let E=0;E<r.chars.length;E++)Hf.test(r.chars[E].uchar)&&o?c++:(u+=r.chars[E].uchar,o=!1);r.cueStartTime=e,e===t&&(t+=1e-4),c>=16?c--:c++;const I=Cl(u.trim()),m=mn(e,t,I);a!=null&&(f=a.cues)!=null&&f.getCueById(m)||(n=new h(e,t,I),n.id=m,n.line=g+1,n.align="left",n.position=10+Math.min(80,Math.floor(c*8/32)*10),s.push(n))}return a&&s.length&&(s.sort((g,I)=>g.line==="auto"||I.line==="auto"?0:g.line>8&&I.line>8?I.line-g.line:g.line-I.line),s.forEach(g=>ll(a,g))),s}};function Kf(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}const Yf=/(\d+)-(\d+)\/(\d+)/;class Dl{constructor(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||qf,this.controller=new self.AbortController,this.stats=new Ar}destroy(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null}abortInternal(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(e,t,i){const s=this.stats;if(s.loading.start)throw new Error("Loader can only be used once.");s.loading.start=self.performance.now();const r=Wf(e,this.controller.signal),n=e.responseType==="arraybuffer",o=n?"byteLength":"length",{maxTimeToFirstByteMs:c,maxLoadTimeMs:u}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=i,this.request=this.fetchSetup(e,r),self.clearTimeout(this.requestTimeout),t.timeout=c&&se(c)?c:u,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(s,e,this.response))},t.timeout),(rs(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then(f=>{var g;this.response=this.loader=f;const I=Math.max(self.performance.now(),s.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=u,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(s,e,this.response))},u-(I-s.loading.start)),!f.ok){const{status:E,statusText:v}=f;throw new Xf(v||"fetch, bad network response",E,f)}s.loading.first=I,s.total=zf(f.headers)||s.total;const m=(g=this.callbacks)==null?void 0:g.onProgress;return m&&se(t.highWaterMark)?this.loadProgressively(f,s,e,t.highWaterMark,m):n?f.arrayBuffer():e.responseType==="json"?f.json():f.text()}).then(f=>{var g,I;const m=this.response;if(!m)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),s.loading.end=Math.max(self.performance.now(),s.loading.first);const E=f[o];E&&(s.loaded=s.total=E);const v={url:m.url,data:f,code:m.status},x=(g=this.callbacks)==null?void 0:g.onProgress;x&&!se(t.highWaterMark)&&x(s,e,f,m),(I=this.callbacks)==null||I.onSuccess(v,s,e,m)}).catch(f=>{var g;if(self.clearTimeout(this.requestTimeout),s.aborted)return;const I=f&&f.code||0,m=f?f.message:null;(g=this.callbacks)==null||g.onError({code:I,text:m},e,f?f.details:null,s)})}getCacheAge(){let e=null;if(this.response){const t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,i,s=0,r){const n=new go,o=e.body.getReader(),c=()=>o.read().then(u=>{if(u.done)return n.dataLength&&r(t,i,n.flush().buffer,e),Promise.resolve(new ArrayBuffer(0));const h=u.value,f=h.length;return t.loaded+=f,f<s||n.dataLength?(n.push(h),n.dataLength>=s&&r(t,i,n.flush().buffer,e)):r(t,i,h.buffer,e),c()}).catch(()=>Promise.reject());return c()}}function Wf(a,e){const t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(Ne({},a.headers))};return a.rangeEnd&&t.headers.set("Range","bytes="+a.rangeStart+"-"+String(a.rangeEnd-1)),t}function jf(a){const e=Yf.exec(a);if(e)return parseInt(e[2])-parseInt(e[1])+1}function zf(a){const e=a.get("Content-Range");if(e){const i=jf(e);if(se(i))return i}const t=a.get("Content-Length");if(t)return parseInt(t)}function qf(a,e){return new self.Request(a.url,e)}class Xf extends Error{constructor(e,t,i){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=i}}const Zf=/^age:\s*[\d.]+\s*$/im;class Pl{constructor(e){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=e&&e.xhrSetup||null,this.stats=new Ar,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null}abortInternal(){const 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()))}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(e,t,i){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=i,this.loadInternal()}loadInternal(){const{config:e,context:t}=this;if(!e||!t)return;const i=this.loader=new self.XMLHttpRequest,s=this.stats;s.loading.first=0,s.loaded=0,s.aborted=!1;const r=this.xhrSetup;r?Promise.resolve().then(()=>{if(!(this.loader!==i||this.stats.aborted))return r(i,t.url)}).catch(n=>{if(!(this.loader!==i||this.stats.aborted))return i.open("GET",t.url,!0),r(i,t.url)}).then(()=>{this.loader!==i||this.stats.aborted||this.openAndSendXhr(i,t,e)}).catch(n=>{var o;(o=this.callbacks)==null||o.onError({code:i.status,text:n.message},t,i,s)}):this.openAndSendXhr(i,t,e)}openAndSendXhr(e,t,i){e.readyState||e.open("GET",t.url,!0);const s=t.headers,{maxTimeToFirstByteMs:r,maxLoadTimeMs:n}=i.loadPolicy;if(s)for(const o in s)e.setRequestHeader(o,s[o]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),i.timeout=r&&se(r)?r:n,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.timeout),e.send()}readystatechange(){const{context:e,loader:t,stats:i}=this;if(!e||!t)return;const s=t.readyState,r=this.config;if(!i.aborted&&s>=2&&(i.loading.first===0&&(i.loading.first=Math.max(self.performance.now(),i.loading.start),r.timeout!==r.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),r.timeout=r.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.loadPolicy.maxLoadTimeMs-(i.loading.first-i.loading.start)))),s===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;const u=t.status,h=t.responseType==="text"?t.responseText:null;if(u>=200&&u<300){const m=h??t.response;if(m!=null){var n,o;i.loading.end=Math.max(self.performance.now(),i.loading.first);const E=t.responseType==="arraybuffer"?m.byteLength:m.length;i.loaded=i.total=E,i.bwEstimate=i.total*8e3/(i.loading.end-i.loading.first);const v=(n=this.callbacks)==null?void 0:n.onProgress;v&&v(i,e,m,t);const x={url:t.responseURL,data:m,code:u};(o=this.callbacks)==null||o.onSuccess(x,i,e,t);return}}const f=r.loadPolicy.errorRetry,g=i.retry,I={url:e.url,data:void 0,code:u};if(Ls(f,g,!1,I))this.retry(f);else{var c;Oe.error(`${u} while loading ${e.url}`),(c=this.callbacks)==null||c.onError({code:u,text:t.statusText},e,t,i)}}}loadtimeout(){if(!this.config)return;const e=this.config.loadPolicy.timeoutRetry,t=this.stats.retry;if(Ls(e,t,!0))this.retry(e);else{var i;Oe.warn(`timeout while loading ${(i=this.context)==null?void 0:i.url}`);const s=this.callbacks;s&&(this.abortInternal(),s.onTimeout(this.stats,this.context,this.loader))}}retry(e){const{context:t,stats:i}=this;this.retryDelay=br(e,i.retry),i.retry++,Oe.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${t?.url}, retrying ${i.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)}loadprogress(e){const t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}getCacheAge(){let e=null;if(this.loader&&Zf.test(this.loader.getAllResponseHeaders())){const t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}const Qf={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},Jf=Be(Be({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,startOnSegmentBoundary:!1,maxBufferSize:60*1e3*1e3,maxFragLookUpTolerance:.25,maxBufferHole:.1,detectStallWithCurrentTimeMs:1250,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,nudgeOnVideoHole:!0,liveSyncMode:"edge",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:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,ignorePlaylistParsingErrors:!1,loader:Pl,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:dc,bufferController:rd,capLevelController:rn,errorController:mc,fpsController:tf,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:Va,requireKeySystemAccessOnStart:!1,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableEmsgKLVMetadata:!1,enableID3MetadataCues:!0,enableInterstitialPlayback:!0,interstitialAppendInPlace:!0,interstitialLiveLookAhead:10,useMediaCapabilities:!0,preserveManualLevelOnError:!1,certLoadPolicy:{default:Qf},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}}},interstitialAssetListLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:3e4,timeoutRetry:{maxNumRetry:0,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:0,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},eg()),{},{subtitleStreamController:gf,subtitleTrackController:nf,timelineController:$f,audioStreamController:ed,audioTrackController:td,emeController:Ni,cmcdController:Qd,contentSteeringController:ef,interstitialsController:ff});function eg(){return{cueHandler:Vf,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function tg(a,e,t){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(e.liveMaxLatencyDurationCount!==void 0&&(e.liveSyncDurationCount===void 0||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(e.liveMaxLatencyDuration!==void 0&&(e.liveSyncDuration===void 0||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const i=vn(a),s=["manifest","level","frag"],r=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return s.forEach(n=>{const o=`${n==="level"?"playlist":n}LoadPolicy`,c=e[o]===void 0,u=[];r.forEach(h=>{const f=`${n}Loading${h}`,g=e[f];if(g!==void 0&&c){u.push(f);const I=i[o].default;switch(e[o]={default:I},h){case"TimeOut":I.maxLoadTimeMs=g,I.maxTimeToFirstByteMs=g;break;case"MaxRetry":I.errorRetry.maxNumRetry=g,I.timeoutRetry.maxNumRetry=g;break;case"RetryDelay":I.errorRetry.retryDelayMs=g,I.timeoutRetry.retryDelayMs=g;break;case"MaxRetryTimeout":I.errorRetry.maxRetryDelayMs=g,I.timeoutRetry.maxRetryDelayMs=g;break}}}),u.length&&t.warn(`hls.js config: "${u.join('", "')}" setting(s) are deprecated, use "${o}": ${Ge(e[o])}`)}),Be(Be({},i),e)}function vn(a){return a&&typeof a=="object"?Array.isArray(a)?a.map(vn):Object.keys(a).reduce((e,t)=>(e[t]=vn(a[t]),e),{}):a}function ig(a,e){const t=a.loader;t!==Dl&&t!==Pl?(e.log("[config]: Custom loader detected, cannot enable progressive streaming"),a.progressive=!1):Kf()&&(a.loader=Dl,a.progressive=!0,a.enableSoftwareAES=!0,e.log("[config]: Progressive streaming enabled, using FetchLoader"))}const Zs=2,sg=.1,rg=.05,ng=100;class ag extends Ma{constructor(e,t){super("gap-controller",e.logger),this.hls=void 0,this.fragmentTracker=void 0,this.media=null,this.mediaSource=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.buffered={},this.lastCurrentTime=0,this.ended=0,this.waiting=0,this.onMediaPlaying=()=>{this.ended=0,this.waiting=0},this.onMediaWaiting=()=>{var i;(i=this.media)!=null&&i.seeking||(this.waiting=self.performance.now(),this.tick())},this.onMediaEnded=()=>{if(this.hls){var i;this.ended=((i=this.media)==null?void 0:i.currentTime)||1,this.hls.trigger(y.MEDIA_ENDED,{stalled:!1})}},this.hls=e,this.fragmentTracker=t,this.registerListeners()}registerListeners(){const{hls:e}=this;e&&(e.on(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.BUFFER_APPENDED,this.onBufferAppended,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.BUFFER_APPENDED,this.onBufferAppended,this))}destroy(){super.destroy(),this.unregisterListeners(),this.media=this.hls=this.fragmentTracker=null,this.mediaSource=void 0}onMediaAttached(e,t){this.setInterval(ng),this.mediaSource=t.mediaSource;const i=this.media=t.media;ot(i,"playing",this.onMediaPlaying),ot(i,"waiting",this.onMediaWaiting),ot(i,"ended",this.onMediaEnded)}onMediaDetaching(e,t){this.clearInterval();const{media:i}=this;i&&(ht(i,"playing",this.onMediaPlaying),ht(i,"waiting",this.onMediaWaiting),ht(i,"ended",this.onMediaEnded),this.media=null),this.mediaSource=void 0}onBufferAppended(e,t){this.buffered=t.timeRanges}get hasBuffered(){return Object.keys(this.buffered).length>0}tick(){var e;if(!((e=this.media)!=null&&e.readyState)||!this.hasBuffered)return;const t=this.media.currentTime;this.poll(t,this.lastCurrentTime),this.lastCurrentTime=t}poll(e,t){var i,s;const r=(i=this.hls)==null?void 0:i.config;if(!r)return;const n=this.media;if(!n)return;const{seeking:o}=n,c=this.seeking&&!o,u=!this.seeking&&o,h=n.paused&&!o||n.ended||n.playbackRate===0;if(this.seeking=o,e!==t){t&&(this.ended=0),this.moved=!0,o||(this.nudgeRetry=0,r.nudgeOnVideoHole&&!h&&e>t&&this.nudgeOnVideoHole(e,t)),this.waiting===0&&this.stallResolved(e);return}if(u||c){c&&this.stallResolved(e);return}if(h){this.nudgeRetry=0,this.stallResolved(e),!this.ended&&n.ended&&this.hls&&(this.ended=e||1,this.hls.trigger(y.MEDIA_ENDED,{stalled:!1}));return}if(!ye.getBuffered(n).length){this.nudgeRetry=0;return}const f=ye.bufferInfo(n,e,0),g=f.nextStart||0,I=this.fragmentTracker;if(o&&I&&this.hls){const K=_l(this.hls.inFlightFragments,e),p=f.len>Zs,$=!g||K||g-e>Zs&&!I.getPartialFragment(e);if(p||$)return;this.moved=!1}const m=(s=this.hls)==null?void 0:s.latestLevelDetails;if(!this.moved&&this.stalled!==null&&I){if(!(f.len>0)&&!g)return;const p=Math.max(g,f.start||0)-e,F=!!(m!=null&&m.live)?m.targetduration*2:Zs,O=Qs(e,I);if(p>0&&(p<=F||O)){n.paused||this._trySkipBufferHole(O);return}}const E=r.detectStallWithCurrentTimeMs,v=self.performance.now(),x=this.waiting;let D=this.stalled;if(D===null)if(x>0&&v-x<E)D=this.stalled=x;else{this.stalled=v;return}const L=v-D;if(!o&&(L>=E||x)&&this.hls){var w;if(((w=this.mediaSource)==null?void 0:w.readyState)==="ended"&&!(m!=null&&m.live)&&Math.abs(e-(m?.edge||0))<1){if(this.ended)return;this.ended=e||1,this.hls.trigger(y.MEDIA_ENDED,{stalled:!0});return}if(this._reportStall(f),!this.media||!this.hls)return}const N=ye.bufferInfo(n,e,r.maxBufferHole);this._tryFixBufferStall(N,L,e)}stallResolved(e){const t=this.stalled;if(t&&this.hls&&(this.stalled=null,this.stallReported)){const i=self.performance.now()-t;this.log(`playback not stuck anymore @${e}, after ${Math.round(i)}ms`),this.stallReported=!1,this.waiting=0,this.hls.trigger(y.STALL_RESOLVED,{})}}nudgeOnVideoHole(e,t){var i;const s=this.buffered.video;if(this.hls&&this.media&&this.fragmentTracker&&(i=this.buffered.audio)!=null&&i.length&&s&&s.length>1&&e>s.end(0)){const r=ye.bufferedInfo(ye.timeRangesToArray(this.buffered.audio),e,0);if(r.len>1&&t>=r.start){const n=ye.timeRangesToArray(s),o=ye.bufferedInfo(n,t,0).bufferedIndex;if(o>-1&&o<n.length-1){const c=ye.bufferedInfo(n,e,0).bufferedIndex,u=n[o].end,h=n[o+1].start;if((c===-1||c>o)&&h-u<1&&e-u<2){const f=new Error(`nudging playhead to flush pipeline after video hole. currentTime: ${e} hole: ${u} -> ${h} buffered index: ${c}`);this.warn(f.message),this.media.currentTime+=1e-6;let g=Qs(e,this.fragmentTracker);g&&"fragment"in g?g=g.fragment:g||(g=void 0);const I=ye.bufferInfo(this.media,e,0);this.hls.trigger(y.ERROR,{type:de.MEDIA_ERROR,details:U.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:f,reason:f.message,frag:g,buffer:I.len,bufferInfo:I})}}}}}_tryFixBufferStall(e,t,i){var s,r;const{fragmentTracker:n,media:o}=this,c=(s=this.hls)==null?void 0:s.config;if(!o||!n||!c)return;const u=(r=this.hls)==null?void 0:r.latestLevelDetails,h=Qs(i,n);if((h||u!=null&&u.live&&i<u.fragmentStart)&&(this._trySkipBufferHole(h)||!this.media))return;const f=e.buffered,g=this.adjacentTraversal(e,i);(f&&f.length>1&&e.len>c.maxBufferHole||e.nextStart&&(e.nextStart-i<c.maxBufferHole||g))&&(t>c.highBufferWatchdogPeriod*1e3||this.waiting)&&(this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(e))}adjacentTraversal(e,t){const i=this.fragmentTracker,s=e.nextStart;if(i&&s){const r=i.getFragAtPos(t,he.MAIN),n=i.getFragAtPos(s,he.MAIN);if(r&&n)return n.sn-r.sn<2}return!1}_reportStall(e){const{hls:t,media:i,stallReported:s,stalled:r}=this;if(!s&&r!==null&&i&&t){this.stallReported=!0;const n=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${Ge(e)})`);this.warn(n.message),t.trigger(y.ERROR,{type:de.MEDIA_ERROR,details:U.BUFFER_STALLED_ERROR,fatal:!1,error:n,buffer:e.len,bufferInfo:e,stalled:{start:r}})}}_trySkipBufferHole(e){var t;const{fragmentTracker:i,media:s}=this,r=(t=this.hls)==null?void 0:t.config;if(!s||!i||!r)return 0;const n=s.currentTime,o=ye.bufferInfo(s,n,0),c=n<o.start?o.start:o.nextStart;if(c&&this.hls){const h=o.len<=r.maxBufferHole,f=o.len>0&&o.len<1&&s.readyState<3,g=c-n;if(g>0&&(h||f)){if(g>r.maxBufferHole){let m=!1;if(n===0){const E=i.getAppendedFrag(0,he.MAIN);E&&c<E.end&&(m=!0)}if(!m&&e){var u;if(!((u=this.hls.loadLevelObj)!=null&&u.details)||_l(this.hls.inFlightFragments,c))return 0;let v=!1,x=e.end;for(;x<c;){const D=Qs(x,i);if(D)x+=D.duration;else{v=!0;break}}if(v)return 0}}const I=Math.max(c+rg,n+sg);if(this.warn(`skipping hole, adjusting currentTime from ${n} to ${I}`),this.moved=!0,s.currentTime=I,!(e!=null&&e.gap)){const m=new Error(`fragment loaded with buffer holes, seeking from ${n} to ${I}`),E={type:de.MEDIA_ERROR,details:U.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:m,reason:m.message,buffer:o.len,bufferInfo:o};e&&("fragment"in e?E.part=e:E.frag=e),this.hls.trigger(y.ERROR,E)}return I}}return 0}_tryNudgeBuffer(e){const{hls:t,media:i,nudgeRetry:s}=this,r=t?.config;if(!i||!r)return 0;const n=i.currentTime;if(this.nudgeRetry++,s<r.nudgeMaxRetry){const o=n+(s+1)*r.nudgeOffset,c=new Error(`Nudging 'currentTime' from ${n} to ${o}`);this.warn(c.message),i.currentTime=o,t.trigger(y.ERROR,{type:de.MEDIA_ERROR,details:U.BUFFER_NUDGE_ON_STALL,error:c,fatal:!1,buffer:e.len,bufferInfo:e})}else{const o=new Error(`Playhead still not moving while enough data buffered @${n} after ${r.nudgeMaxRetry} nudges`);this.error(o.message),t.trigger(y.ERROR,{type:de.MEDIA_ERROR,details:U.BUFFER_STALLED_ERROR,error:o,fatal:!0,buffer:e.len,bufferInfo:e})}}}function _l(a,e){const t=wl(a.main);if(t&&t.start<=e)return t;const i=wl(a.audio);return i&&i.start<=e?i:null}function wl(a){if(!a)return null;switch(a.state){case j.IDLE:case j.STOPPED:case j.ENDED:case j.ERROR:return null}return a.frag}function Qs(a,e){return e.getAppendedFrag(a,he.MAIN)||e.getPartialFragment(a)}const og=.25;function Tn(){if(!(typeof self>"u"))return self.VTTCue||self.TextTrackCue}function Sn(a,e,t,i,s){let r=new a(e,t,"");try{r.value=i,s&&(r.type=s)}catch{r=new a(e,t,Ge(s?Be({type:s},i):i))}return r}const Js=(()=>{const a=Tn();try{a&&new a(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();class lg{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=!0,this.assetCue=void 0,this.onEventCueEnter=()=>{this.hls&&this.hls.trigger(y.EVENT_CUE_ENTER,{})},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null}_registerListeners(){const{hls:e}=this;e&&(e.on(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(y.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(y.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(y.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(y.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}onMediaAttaching(e,t){var i;this.media=t.media,((i=t.overrides)==null?void 0:i.cueRemoval)===!1&&(this.removeCues=!1)}onMediaAttached(){var e;const t=(e=this.hls)==null?void 0:e.latestLevelDetails;t&&this.updateDateRangeCues(t)}onMediaDetaching(e,t){this.media=null,!t.transferMedia&&(this.id3Track&&(this.removeCues&&Bi(this.id3Track,this.onEventCueEnter),this.id3Track=null),this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){const t=this.getID3Track(e.textTracks);return t.mode="hidden",t}getID3Track(e){if(this.media){for(let t=0;t<e.length;t++){const i=e[t];if(i.kind==="metadata"&&i.label==="id3")return ol(i,this.media),i}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media||!this.hls)return;const{enableEmsgMetadataCues:i,enableID3MetadataCues:s}=this.hls.config;if(!i&&!s)return;const{samples:r}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));const n=Tn();if(n)for(let o=0;o<r.length;o++){const c=r[o].type;if(c===yt.emsg&&!i||!s)continue;const u=vo(r[o].data),h=r[o].pts;let f=h+r[o].duration;f>Js&&(f=Js),f-h<=0&&(f=h+og);for(let I=0;I<u.length;I++){const m=u[I];if(!To(m)){this.updateId3CueEnds(h,c);const E=Sn(n,h,f,m,c);E&&this.id3Track.addCue(E)}}}}updateId3CueEnds(e,t){var i;const s=(i=this.id3Track)==null?void 0:i.cues;if(s)for(let r=s.length;r--;){const n=s[r];n.type===t&&n.startTime<e&&n.endTime===Js&&(n.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:i,type:s}){const{id3Track:r,hls:n}=this;if(!n)return;const{config:{enableEmsgMetadataCues:o,enableID3MetadataCues:c}}=n;if(r&&(o||c)){let u;s==="audio"?u=h=>h.type===yt.audioId3&&c:s==="video"?u=h=>h.type===yt.emsg&&o:u=h=>h.type===yt.audioId3&&c||h.type===yt.emsg&&o,cn(r,t,i,u)}}onLevelUpdated(e,{details:t}){this.updateDateRangeCues(t,!0)}onLevelPtsUpdated(e,t){Math.abs(t.drift)>.01&&this.updateDateRangeCues(t.details)}updateDateRangeCues(e,t){if(!this.hls||!this.media)return;const{assetPlayerId:i,timelineOffset:s,enableDateRangeMetadataCues:r,interstitialsController:n}=this.hls.config;if(!r)return;const o=Tn();if(i&&s&&!n){const{fragmentStart:E,fragmentEnd:v}=e;let x=this.assetCue;x?(x.startTime=E,x.endTime=v):o&&(x=this.assetCue=Sn(o,E,v,{assetPlayerId:this.hls.config.assetPlayerId},"hlsjs.interstitial.asset"),x&&(x.id=i,this.id3Track||(this.id3Track=this.createTrack(this.media)),this.id3Track.addCue(x),x.addEventListener("enter",this.onEventCueEnter)))}if(!e.hasProgramDateTime)return;const{id3Track:c}=this,{dateRanges:u}=e,h=Object.keys(u);let f=this.dateRangeCuesAppended;if(c&&t){var g;if((g=c.cues)!=null&&g.length){const E=Object.keys(f).filter(v=>!h.includes(v));for(let v=E.length;v--;){var I;const x=E[v],D=(I=f[x])==null?void 0:I.cues;delete f[x],D&&Object.keys(D).forEach(L=>{const w=D[L];if(w){w.removeEventListener("enter",this.onEventCueEnter);try{c.removeCue(w)}catch{}}})}}else f=this.dateRangeCuesAppended={}}const m=e.fragments[e.fragments.length-1];if(!(h.length===0||!se(m?.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(let E=0;E<h.length;E++){const v=h[E],x=u[v],D=x.startTime,L=f[v],w=L?.cues||{};let N=L?.durationKnown||!1,K=Js;const{duration:p,endDate:$}=x;if($&&p!==null)K=D+p,N=!0;else if(x.endOnNext&&!N){const O=h.reduce((W,ie)=>{if(ie!==x.id){const X=u[ie];if(X.class===x.class&&X.startDate>x.startDate&&(!W||x.startDate<W.startDate))return X}return W},null);O&&(K=O.startTime,N=!0)}const F=Object.keys(x.attr);for(let O=0;O<F.length;O++){const W=F[O];if(!Pc(W))continue;const ie=w[W];if(ie)N&&!(L!=null&&L.durationKnown)?ie.endTime=K:Math.abs(ie.startTime-D)>.01&&(ie.startTime=D,ie.endTime=K);else if(o){let X=x.attr[W];_c(W)&&(X=Qn(X));const ue=Sn(o,D,K,{key:W,data:X},yt.dateRange);ue&&(ue.id=v,this.id3Track.addCue(ue),w[W]=ue,n&&(W==="X-ASSET-LIST"||W==="X-ASSET-URL")&&ue.addEventListener("enter",this.onEventCueEnter))}}f[v]={cues:w,dateRange:x,durationKnown:N}}}}}class ug{constructor(e){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=()=>{const{media:t}=this,i=this.levelDetails;if(!t||!i)return;this.currentTime=t.currentTime;const s=this.computeLatency();if(s===null)return;this._latency=s;const{lowLatencyMode:r,maxLiveSyncPlaybackRate:n}=this.config;if(!r||n===1||!i.live)return;const o=this.targetLatency;if(o===null)return;const c=s-o,u=Math.min(this.maxLatency,o+i.targetduration);if(c<u&&c>.05&&this.forwardBufferLength>1){const f=Math.min(2,Math.max(1,n)),g=Math.round(2/(1+Math.exp(-.75*c-this.edgeStalled))*20)/20,I=Math.min(f,Math.max(1,g));this.changeMediaPlaybackRate(t,I)}else t.playbackRate!==1&&t.playbackRate!==0&&this.changeMediaPlaybackRate(t,1)},this.hls=e,this.config=e.config,this.registerListeners()}get levelDetails(){var e;return((e=this.hls)==null?void 0:e.latestLevelDetails)||null}get latency(){return this._latency||0}get maxLatency(){const{config:e}=this;if(e.liveMaxLatencyDuration!==void 0)return e.liveMaxLatencyDuration;const t=this.levelDetails;return t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){const e=this.levelDetails;if(e===null||this.hls===null)return null;const{holdBack:t,partHoldBack:i,targetduration:s}=e,{liveSyncDuration:r,liveSyncDurationCount:n,lowLatencyMode:o}=this.config,c=this.hls.userConfig;let u=o&&i||t;(this._targetLatencyUpdated||c.liveSyncDuration||c.liveSyncDurationCount||u===0)&&(u=r!==void 0?r:n*s);const h=s;return u+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,h)}set targetLatency(e){this.stallCount=0,this.config.liveSyncDuration=e,this._targetLatencyUpdated=!0}get liveSyncPosition(){const e=this.estimateLiveEdge(),t=this.targetLatency;if(e===null||t===null)return null;const i=this.levelDetails;if(i===null)return null;const s=i.edge,r=e-t-this.edgeStalled,n=s-i.totalduration,o=s-(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.min(Math.max(n,r),o)}get drift(){const e=this.levelDetails;return e===null?1:e.drift}get edgeStalled(){const e=this.levelDetails;if(e===null)return 0;const t=(this.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;return Math.max(e.age-t,0)}get forwardBufferLength(){const{media:e}=this,t=this.levelDetails;if(!e||!t)return 0;const i=e.buffered.length;return(i?e.buffered.end(i-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null}registerListeners(){const{hls:e}=this;e&&(e.on(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(y.ERROR,this.onError,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(y.ERROR,this.onError,this))}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.onTimeupdate)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null)}onManifestLoading(){this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:t}){t.advanced&&this.onTimeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.onTimeupdate)}onError(e,t){var i;t.details===U.BUFFER_STALLED_ERROR&&(this.stallCount++,this.hls&&(i=this.levelDetails)!=null&&i.live&&this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency"))}changeMediaPlaybackRate(e,t){var i,s;e.playbackRate!==t&&((i=this.hls)==null||i.logger.debug(`[latency-controller]: latency=${this.latency.toFixed(3)}, targetLatency=${(s=this.targetLatency)==null?void 0:s.toFixed(3)}, forwardBufferLength=${this.forwardBufferLength.toFixed(3)}: adjusting playback rate from ${e.playbackRate} to ${t}`),e.playbackRate=t)}estimateLiveEdge(){const e=this.levelDetails;return e===null?null:e.edge+e.age}computeLatency(){const e=this.estimateLiveEdge();return e===null?null:e-this.currentTime}}class cg extends en{constructor(e,t){super(e,"level-controller"),this._levels=[],this._firstLevel=-1,this._maxAutoLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=t,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(y.LEVEL_LOADED,this.onLevelLoaded,this),e.on(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(y.FRAG_BUFFERED,this.onFragBuffered,this),e.on(y.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(y.LEVEL_LOADED,this.onLevelLoaded,this),e.off(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(y.FRAG_BUFFERED,this.onFragBuffered,this),e.off(y.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}stopLoad(){this._levels.forEach(t=>{t.loadError=0,t.fragmentError=0}),super.stopLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1}onManifestLoading(e,t){this.resetLevels()}onManifestLoaded(e,t){const i=this.hls.config.preferManagedMediaSource,s=[],r={},n={};let o=!1,c=!1,u=!1;t.levels.forEach(h=>{const f=h.attrs;let{audioCodec:g,videoCodec:I}=h;g&&(h.audioCodec=g=Es(g,i)||void 0),I&&(I=h.videoCodec=ju(I));const{width:m,height:E,unknownCodecs:v}=h;let x=v?v.length:0;if(v)for(let O=x;O--;){const W=v[O];this.isAudioSupported(W)?(h.audioCodec=g=g?`${g},${W}`:W,x--,Pi.audio[g.substring(0,4)]=2):this.isVideoSupported(W)&&(h.videoCodec=I=I?`${I},${W}`:W,x--,Pi.video[I.substring(0,4)]=2)}if(o||(o=!!(m&&E)),c||(c=!!I),u||(u=!!g),x||g&&!this.isAudioSupported(g)||I&&!this.isVideoSupported(I)){this.log(`Some or all CODECS not supported "${f.CODECS}"`);return}const{CODECS:D,"FRAME-RATE":L,"HDCP-LEVEL":w,"PATHWAY-ID":N,RESOLUTION:K,"VIDEO-RANGE":p}=f,F=`${`${N||"."}-`}${h.bitrate}-${K}-${L}-${D}-${p}-${w}`;if(r[F])if(r[F].uri!==h.url&&!h.attrs["PATHWAY-ID"]){const O=n[F]+=1;h.attrs["PATHWAY-ID"]=new Array(O+1).join(".");const W=this.createLevel(h);r[F]=W,s.push(W)}else r[F].addGroupId("audio",f.AUDIO),r[F].addGroupId("text",f.SUBTITLES);else{const O=this.createLevel(h);r[F]=O,n[F]=1,s.push(O)}}),this.filterAndSortMediaOptions(s,t,o,c,u)}createLevel(e){const t=new Zi(e),i=e.supplemental;if(i!=null&&i.videoCodec&&!this.isVideoSupported(i.videoCodec)){const s=new Error(`SUPPLEMENTAL-CODECS not supported "${i.videoCodec}"`);this.log(s.message),t.supportedResult=Aa(s,[])}return t}isAudioSupported(e){return Er(e,"audio",this.hls.config.preferManagedMediaSource)}isVideoSupported(e){return Er(e,"video",this.hls.config.preferManagedMediaSource)}filterAndSortMediaOptions(e,t,i,s,r){let n=[],o=[],c=e;if((i||s)&&r&&(c=c.filter(({videoCodec:v,videoRange:x,width:D,height:L})=>(!!v||!!(D&&L))&&sc(x))),c.length===0){Promise.resolve().then(()=>{if(this.hls){let v="no level with compatible codecs found in manifest",x=v;t.levels.length&&(x=`one or more CODECS in variant not supported: ${Ge(t.levels.map(L=>L.attrs.CODECS).filter((L,w,N)=>N.indexOf(L)===w))}`,this.warn(x),v+=` (${x})`);const D=new Error(v);this.hls.trigger(y.ERROR,{type:de.MEDIA_ERROR,details:U.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:D,reason:x})}});return}t.audioTracks&&(n=t.audioTracks.filter(v=>!v.audioCodec||this.isAudioSupported(v.audioCodec)),kl(n)),t.subtitles&&(o=t.subtitles,kl(o));const u=c.slice(0);c.sort((v,x)=>{if(v.attrs["HDCP-LEVEL"]!==x.attrs["HDCP-LEVEL"])return(v.attrs["HDCP-LEVEL"]||"")>(x.attrs["HDCP-LEVEL"]||"")?1:-1;if(i&&v.height!==x.height)return v.height-x.height;if(v.frameRate!==x.frameRate)return v.frameRate-x.frameRate;if(v.videoRange!==x.videoRange)return Ts.indexOf(v.videoRange)-Ts.indexOf(x.videoRange);if(v.videoCodec!==x.videoCodec){const D=da(v.videoCodec),L=da(x.videoCodec);if(D!==L)return L-D}if(v.uri===x.uri&&v.codecSet!==x.codecSet){const D=ys(v.codecSet),L=ys(x.codecSet);if(D!==L)return L-D}return v.averageBitrate!==x.averageBitrate?v.averageBitrate-x.averageBitrate:0});let h=u[0];if(this.steering&&(c=this.steering.filterParsedLevels(c),c.length!==u.length)){for(let v=0;v<u.length;v++)if(u[v].pathwayId===c[0].pathwayId){h=u[v];break}}this._levels=c;for(let v=0;v<c.length;v++)if(c[v]===h){var f;this._firstLevel=v;const x=h.bitrate,D=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${c.length} level(s) found, first bitrate: ${x}`),((f=this.hls.userConfig)==null?void 0:f.abrEwmaDefaultEstimate)===void 0){const L=Math.min(x,this.hls.config.abrEwmaDefaultEstimateMax);L>D&&D===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=L)}break}const g=r&&!s,I=this.hls.config,m=!!(I.audioStreamController&&I.audioTrackController),E={levels:c,audioTracks:n,subtitleTracks:o,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:r,video:s,altAudio:m&&!g&&n.some(v=>!!v.url)};this.hls.trigger(y.MANIFEST_PARSED,E)}get levels(){return this._levels.length===0?null:this._levels}get loadLevelObj(){return this.currentLevel}get level(){return this.currentLevelIndex}set level(e){const t=this._levels;if(t.length===0)return;if(e<0||e>=t.length){const h=new Error("invalid level idx"),f=e<0;if(this.hls.trigger(y.ERROR,{type:de.OTHER_ERROR,details:U.LEVEL_SWITCH_ERROR,level:e,fatal:f,error:h,reason:h.message}),f)return;e=Math.min(e,t.length-1)}const i=this.currentLevelIndex,s=this.currentLevel,r=s?s.attrs["PATHWAY-ID"]:void 0,n=t[e],o=n.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=n,i===e&&s&&r===o)return;this.log(`Switching to level ${e} (${n.height?n.height+"p ":""}${n.videoRange?n.videoRange+" ":""}${n.codecSet?n.codecSet+" ":""}@${n.bitrate})${o?" with Pathway "+o:""} from level ${i}${r?" with Pathway "+r:""}`);const c={level:e,attrs:n.attrs,details:n.details,bitrate:n.bitrate,averageBitrate:n.averageBitrate,maxBitrate:n.maxBitrate,realBitrate:n.realBitrate,width:n.width,height:n.height,codecSet:n.codecSet,audioCodec:n.audioCodec,videoCodec:n.videoCodec,audioGroups:n.audioGroups,subtitleGroups:n.subtitleGroups,loaded:n.loaded,loadError:n.loadError,fragmentError:n.fragmentError,name:n.name,id:n.id,uri:n.uri,url:n.url,urlId:0,audioGroupIds:n.audioGroupIds,textGroupIds:n.textGroupIds};this.hls.trigger(y.LEVEL_SWITCHING,c);const u=n.details;if(!u||u.live){const h=this.switchParams(n.uri,s?.details,u);this.loadPlaylist(h)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,this._startLevel===void 0&&(this._startLevel=e),e!==-1&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){if(this._startLevel===void 0){const e=this.hls.config.startLevel;return e!==void 0?e:this.hls.firstAutoLevel}return this._startLevel}set startLevel(e){this._startLevel=e}get pathways(){return this.steering?this.steering.pathways():[]}get pathwayPriority(){return this.steering?this.steering.pathwayPriority:null}set pathwayPriority(e){if(this.steering){const t=this.steering.pathways(),i=e.filter(s=>t.indexOf(s)!==-1);if(e.length<1){this.warn(`pathwayPriority ${e} should contain at least one pathway from list: ${t}`);return}this.steering.pathwayPriority=i}}onError(e,t){t.fatal||!t.context||t.context.type===be.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(t!==void 0&&t.type===he.MAIN){const i=t.elementaryStreams;if(!Object.keys(i).some(r=>!!i[r]))return;const s=this._levels[t.level];s!=null&&s.loadError&&(this.log(`Resetting level error count of ${s.loadError} on frag buffered`),s.loadError=0)}}onLevelLoaded(e,t){var i;const{level:s,details:r}=t,n=t.levelInfo;if(!n){var o;this.warn(`Invalid level index ${s}`),(o=t.deliveryDirectives)!=null&&o.skip&&(r.deltaUpdateFailed=!0);return}if(n===this.currentLevel||t.withoutMultiVariant){n.fragmentError===0&&(n.loadError=0);let c=n.details;c===t.details&&c.advanced&&(c=void 0),this.playlistLoaded(s,t,c)}else(i=t.deliveryDirectives)!=null&&i.skip&&(r.deltaUpdateFailed=!0)}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const i=this.getUrlWithDirectives(e.uri,t),s=this.currentLevelIndex,r=e.attrs["PATHWAY-ID"],n=e.details,o=n?.age;this.log(`Loading level index ${s}${t?.msn!==void 0?" at sn "+t.msn+" part "+t.part:""}${r?" Pathway "+r:""}${o&&n.live?" age "+o.toFixed(1)+(n.type&&" "+n.type||""):""} ${i}`),this.hls.trigger(y.LEVEL_LOADING,{url:i,level:s,levelInfo:e,pathwayId:e.attrs["PATHWAY-ID"],id:0,deliveryDirectives:t||null})}get nextLoadLevel(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=e)}removeLevel(e){var t;if(this._levels.length===1)return;const i=this._levels.filter((r,n)=>n!==e?!0:(this.steering&&this.steering.removeLevel(r),r===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,r.details&&r.details.fragments.forEach(o=>o.level=-1)),!1));oo(i),this._levels=i,this.currentLevelIndex>-1&&(t=this.currentLevel)!=null&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.manualLevelIndex>-1&&(this.manualLevelIndex=this.currentLevelIndex);const s=i.length-1;this._firstLevel=Math.min(this._firstLevel,s),this._startLevel&&(this._startLevel=Math.min(this._startLevel,s)),this.hls.trigger(y.LEVELS_UPDATED,{levels:i})}onLevelsUpdated(e,{levels:t}){this._levels=t}checkMaxAutoUpdated(){const{autoLevelCapping:e,maxAutoLevel:t,maxHdcpLevel:i}=this.hls;this._maxAutoLevel!==t&&(this._maxAutoLevel=t,this.hls.trigger(y.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:i}))}}function kl(a){const e={};a.forEach(t=>{const i=t.groupId||"";t.id=e[i]=e[i]||0,e[i]++})}function Ml(){return self.SourceBuffer||self.WebKitSourceBuffer}function Ol(){if(!ri())return!1;const e=Ml();return!e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function"}function hg(){if(!Ol())return!1;const a=ri();return typeof a?.isTypeSupported=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(e=>a.isTypeSupported(Xi(e,"video")))||["mp4a.40.2","fLaC"].some(e=>a.isTypeSupported(Xi(e,"audio"))))}function dg(){var a;const e=Ml();return typeof(e==null||(a=e.prototype)==null?void 0:a.changeType)=="function"}const fg=100;class gg extends Ur{constructor(e,t,i){super(e,t,i,"stream-controller",he.MAIN),this.audioCodecSwap=!1,this.level=-1,this._forceStartLoad=!1,this._hasEnoughToStart=!1,this.altAudio=0,this.audioOnly=!1,this.fragPlaying=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this.onMediaPlaying=()=>{this.tick()},this.onMediaSeeked=()=>{const s=this.media,r=s?s.currentTime:null;if(r===null||!se(r)||(this.log(`Media seeked to ${r.toFixed(3)}`),!this.getBufferedFrag(r)))return;const n=this.getFwdBufferInfoAtPos(s,r,he.MAIN,0);if(n===null||n.len===0){this.warn(`Main forward buffer length at ${r} on "seeked" event ${n?n.len:"empty"})`);return}this.tick()},this.registerListeners()}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(y.LEVEL_LOADING,this.onLevelLoading,this),e.on(y.LEVEL_LOADED,this.onLevelLoaded,this),e.on(y.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(y.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(y.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(y.BUFFER_CREATED,this.onBufferCreated,this),e.on(y.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(y.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off(y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(y.LEVEL_LOADED,this.onLevelLoaded,this),e.off(y.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(y.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(y.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(y.BUFFER_CREATED,this.onBufferCreated,this),e.off(y.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(y.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),super.onHandlerDestroying()}startLoad(e,t){if(this.levels){const{lastCurrentTime:i,hls:s}=this;if(this.stopLoad(),this.setInterval(fg),this.level=-1,!this.startFragRequested){let r=s.startLevel;r===-1&&(s.config.testBandwidth&&this.levels.length>1?(r=0,this.bitrateTest=!0):r=s.firstAutoLevel),s.nextLoadLevel=r,this.level=s.loadLevel,this._hasEnoughToStart=!!t}i>0&&e===-1&&!t&&(this.log(`Override startPosition with lastCurrentTime @${i.toFixed(3)}`),e=i),this.state=j.IDLE,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}else this._forceStartLoad=!0,this.state=j.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case j.WAITING_LEVEL:{const{levels:e,level:t}=this,i=e?.[t],s=i?.details;if(s&&(!s.live||this.levelLastLoaded===i&&!this.waitForLive(i))){if(this.waitForCdnTuneIn(s))break;this.state=j.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=j.IDLE;break}break}case j.FRAG_LOADING_WAITING_RETRY:this.checkRetryDate();break}this.state===j.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){var e;super.onTickEnd(),(e=this.media)!=null&&e.readyState&&this.media.seeking===!1&&(this.lastCurrentTime=this.media.currentTime),this.checkFragmentChanged()}doTickIdle(){const{hls:e,levelLastLoaded:t,levels:i,media:s}=this;if(t===null||!s&&!this.primaryPrefetch&&(this.startFragRequested||!e.config.startFragPrefetch)||this.altAudio&&this.audioOnly)return;const r=this.buffering?e.nextLoadLevel:e.loadLevel;if(!(i!=null&&i[r]))return;const n=i[r],o=this.getMainFwdBufferInfo();if(o===null)return;const c=this.getLevelDetails();if(c&&this._streamEnded(o,c)){const E={};this.altAudio===2&&(E.type="video"),this.hls.trigger(y.BUFFER_EOS,E),this.state=j.ENDED;return}if(!this.buffering)return;e.loadLevel!==r&&e.manualLevel===-1&&this.log(`Adapting to level ${r} from level ${this.level}`),this.level=e.nextLoadLevel=r;const u=n.details;if(!u||this.state===j.WAITING_LEVEL||this.waitForLive(n)){this.level=r,this.state=j.WAITING_LEVEL,this.startFragRequested=!1;return}const h=o.len,f=this.getMaxBufferLength(n.maxBitrate);if(h>=f)return;this.backtrackFragment&&this.backtrackFragment.start>o.end&&(this.backtrackFragment=null);const g=this.backtrackFragment?this.backtrackFragment.start:o.end;let I=this.getNextFragment(g,u);if(this.couldBacktrack&&!this.fragPrevious&&I&&qe(I)&&this.fragmentTracker.getState(I)!==Qe.OK){var m;const v=((m=this.backtrackFragment)!=null?m:I).sn-u.startSN,x=u.fragments[v-1];x&&I.cc===x.cc&&(I=x,this.fragmentTracker.removeFragment(x))}else this.backtrackFragment&&o.len&&(this.backtrackFragment=null);if(I&&this.isLoopLoading(I,g)){if(!I.gap){const v=this.audioOnly&&!this.altAudio?Ue.AUDIO:Ue.VIDEO,x=(v===Ue.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;x&&this.afterBufferFlushed(x,v,he.MAIN)}I=this.getNextFragmentLoopLoading(I,u,o,he.MAIN,f)}I&&(I.initSegment&&!I.initSegment.data&&!this.bitrateTest&&(I=I.initSegment),this.loadFragment(I,n,g))}loadFragment(e,t,i){const s=this.fragmentTracker.getState(e);s===Qe.NOT_LOADED||s===Qe.PARTIAL?qe(e)?this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):super.loadFragment(e,t,i):this._loadInitSegment(e,t):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,he.MAIN)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){const{levels:e,media:t}=this;if(t!=null&&t.readyState){let i;const s=this.getAppendedFrag(t.currentTime);s&&s.start>1&&this.flushMainBuffer(0,s.start-1);const r=this.getLevelDetails();if(r!=null&&r.live){const o=this.getMainFwdBufferInfo();if(!o||o.len<r.targetduration*2)return}if(!t.paused&&e){const o=this.hls.nextLoadLevel,c=e[o],u=this.fragLastKbps;u&&this.fragCurrent?i=this.fragCurrent.duration*c.maxBitrate/(1e3*u)+1:i=0}else i=0;const n=this.getBufferedFrag(t.currentTime+i);if(n){const o=this.followingBufferedFrag(n);if(o){this.abortCurrentFrag();const c=o.maxStartPTS?o.maxStartPTS:o.start,u=o.duration,h=Math.max(n.end,c+Math.min(Math.max(u-this.config.maxFragLookUpTolerance,u*(this.couldBacktrack?.5:.125)),u*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(h,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){const e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case j.KEY_LOADING:case j.FRAG_LOADING:case j.FRAG_LOADING_WAITING_RETRY:case j.PARSING:case j.PARSED:this.state=j.IDLE;break}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.altAudio===2?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);const i=t.media;ot(i,"playing",this.onMediaPlaying),ot(i,"seeked",this.onMediaSeeked)}onMediaDetaching(e,t){const{media:i}=this;i&&(ht(i,"playing",this.onMediaPlaying),ht(i,"seeked",this.onMediaSeeked)),this.videoBuffer=null,this.fragPlaying=null,super.onMediaDetaching(e,t),!t.transferMedia&&(this._hasEnoughToStart=!1)}onManifestLoading(){super.onManifestLoading(),this.log("Trigger BUFFER_RESET"),this.hls.trigger(y.BUFFER_RESET,void 0),this.couldBacktrack=!1,this.fragLastKbps=0,this.fragPlaying=this.backtrackFragment=null,this.altAudio=0,this.audioOnly=!1}onManifestParsed(e,t){let i=!1,s=!1;for(let r=0;r<t.levels.length;r++){const n=t.levels[r].audioCodec;n&&(i=i||n.indexOf("mp4a.40.2")!==-1,s=s||n.indexOf("mp4a.40.5")!==-1)}this.audioCodecSwitch=i&&s&&!dg(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}onLevelLoading(e,t){const{levels:i}=this;if(!i||this.state!==j.IDLE)return;const s=t.levelInfo;(!s.details||s.details.live&&(this.levelLastLoaded!==s||s.details.expired)||this.waitForCdnTuneIn(s.details))&&(this.state=j.WAITING_LEVEL)}onLevelLoaded(e,t){var i;const{levels:s,startFragRequested:r}=this,n=t.level,o=t.details,c=o.totalduration;if(!s){this.warn(`Levels were reset while loading level ${n}`);return}this.log(`Level ${n} loaded [${o.startSN},${o.endSN}]${o.lastPartSn?`[part-${o.lastPartSn}-${o.lastPartIndex}]`:""}, cc [${o.startCC}, ${o.endCC}] duration:${c}`);const u=t.levelInfo,h=this.fragCurrent;h&&(this.state===j.FRAG_LOADING||this.state===j.FRAG_LOADING_WAITING_RETRY)&&h.level!==t.level&&h.loader&&this.abortCurrentFrag();let f=0;if(o.live||(i=u.details)!=null&&i.live){var g;if(this.checkLiveUpdate(o),o.deltaUpdateFailed)return;f=this.alignPlaylists(o,u.details,(g=this.levelLastLoaded)==null?void 0:g.details)}if(u.details=o,this.levelLastLoaded=u,r||this.setStartPosition(o,f),this.hls.trigger(y.LEVEL_UPDATED,{details:o,level:n}),this.state===j.WAITING_LEVEL){if(this.waitForCdnTuneIn(o))return;this.state=j.IDLE}r&&o.live&&this.synchronizeToLiveEdge(o),this.tick()}synchronizeToLiveEdge(e){const{config:t,media:i}=this;if(!i)return;const s=this.hls.liveSyncPosition,r=this.getLoadPosition(),n=e.fragmentStart,o=e.edge,c=r>=n-t.maxFragLookUpTolerance&&r<=o;if(s!==null&&i.duration>s&&(r<s||!c)){const h=t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;if((!c&&i.readyState<4||r<o-h)&&(this._hasEnoughToStart||(this.nextLoadPosition=s),i.readyState))if(this.warn(`Playback: ${r.toFixed(3)} is located too far from the end of live sliding playlist: ${o}, reset currentTime to : ${s.toFixed(3)}`),this.config.liveSyncMode==="buffered"){var u;const f=ye.bufferInfo(i,s,0);if(!((u=f.buffered)!=null&&u.length)){i.currentTime=s;return}if(f.start<=r){i.currentTime=s;return}const{nextStart:I}=ye.bufferedInfo(f.buffered,r,0);I&&(i.currentTime=I)}else i.currentTime=s}}_handleFragmentLoadProgress(e){var t;const i=e.frag,{part:s,payload:r}=e,{levels:n}=this;if(!n){this.warn(`Levels were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);return}const o=n[i.level];if(!o){this.warn(`Level ${i.level} not found on progress`);return}const c=o.details;if(!c){this.warn(`Dropping fragment ${i.sn} of level ${i.level} after level details were reset`),this.fragmentTracker.removeFragment(i);return}const u=o.videoCodec,h=c.PTSKnown||!c.live,f=(t=i.initSegment)==null?void 0:t.data,g=this._getAudioCodec(o),I=this.transmuxer=this.transmuxer||new Uo(this.hls,he.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),m=s?s.index:-1,E=m!==-1,v=new Dr(i.level,i.sn,i.stats.chunkCount,r.byteLength,m,E),x=this.initPTS[i.cc];I.push(r,f,g,u,i,s,c.totalduration,h,v,x)}onAudioTrackSwitching(e,t){const i=this.hls,s=this.altAudio===2;if(xs(t.url,i))this.altAudio=1;else{if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;const n=this.fragCurrent;n&&(this.log("Switching to main audio track, cancel main fragment load"),n.abortRequests(),this.fragmentTracker.removeFragment(n)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();if(s){this.fragmentTracker.removeAllFragments(),i.once(y.BUFFER_FLUSHED,()=>{this.hls&&this.hls.trigger(y.AUDIO_TRACK_SWITCHED,t)}),i.trigger(y.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});return}i.trigger(y.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){const i=xs(t.url,this.hls);if(i){const s=this.videoBuffer;s&&this.mediaBuffer!==s&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=s)}this.altAudio=i?2:0,this.tick()}onBufferCreated(e,t){const i=t.tracks;let s,r,n=!1;for(const o in i){const c=i[o];if(c.id==="main"){if(r=o,s=c,o==="video"){const u=i[o];u&&(this.videoBuffer=u.buffer)}}else n=!0}n&&s?(this.log(`Alternate track found, use ${r}.buffered to schedule main fragment loading`),this.mediaBuffer=s.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){const{frag:i,part:s}=t,r=i.type===he.MAIN;if(r){if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${s?" p: "+s.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}`),this.state===j.PARSED&&(this.state=j.IDLE);return}const o=s?s.stats:i.stats;this.fragLastKbps=Math.round(8*o.total/(o.buffering.end-o.loading.first)),qe(i)&&(this.fragPrevious=i),this.fragBufferedComplete(i,s)}const n=this.media;n&&(!this._hasEnoughToStart&&ye.getBuffered(n).length&&(this._hasEnoughToStart=!0,this.seekToStartPos()),r&&this.tick())}get hasEnoughToStart(){return this._hasEnoughToStart}onError(e,t){var i;if(t.fatal){this.state=j.ERROR;return}switch(t.details){case U.FRAG_GAP:case U.FRAG_PARSING_ERROR:case U.FRAG_DECRYPT_ERROR:case U.FRAG_LOAD_ERROR:case U.FRAG_LOAD_TIMEOUT:case U.KEY_LOAD_ERROR:case U.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(he.MAIN,t);break;case U.LEVEL_LOAD_ERROR:case U.LEVEL_LOAD_TIMEOUT:case U.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===j.WAITING_LEVEL&&((i=t.context)==null?void 0:i.type)===be.LEVEL&&(this.state=j.IDLE);break;case U.BUFFER_ADD_CODEC_ERROR:case U.BUFFER_APPEND_ERROR:if(t.parent!=="main")return;this.reduceLengthAndFlushBuffer(t)&&this.resetLoadingState();break;case U.BUFFER_FULL_ERROR:if(t.parent!=="main")return;this.reduceLengthAndFlushBuffer(t)&&(!this.config.interstitialsController&&this.config.assetPlayerId?this._hasEnoughToStart=!0:this.flushMainBuffer(0,Number.POSITIVE_INFINITY));break;case U.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onFragLoadEmergencyAborted(){this.state=j.IDLE,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==Ue.AUDIO||!this.altAudio){const i=(t===Ue.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;i&&(this.afterBufferFlushed(i,t,he.MAIN),this.tick())}}onLevelsUpdated(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level,this.level===-1&&this.resetWhenMissingContext(this.fragCurrent)),this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:e}=this;if(!e)return;const t=e.currentTime;let i=this.startPosition;if(i>=0&&t<i){if(e.seeking){this.log(`could not seek to ${i}, already seeking at ${t}`);return}const s=this.timelineOffset;s&&i&&(i+=s);const r=this.getLevelDetails(),n=ye.getBuffered(e),o=n.length?n.start(0):0,c=o-i,u=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);(this.config.startOnSegmentBoundary||c>0&&(c<u||this.loadingParts&&c<2*(r?.partTarget||0)))&&(this.log(`adjusting start position by ${c} to match buffer start`),i+=c,this.startPosition=i),t<i&&(this.log(`seek to target start position ${i} from current time ${t} buffer start ${o}`),e.currentTime=i)}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t.indexOf("mp4a.40.5")!==-1?t="mp4a.40.2":t="mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(i=>{const{hls:s}=this,r=i?.frag;if(!r||this.fragContextChanged(r))return;t.fragmentError=0,this.state=j.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;const n=r.stats;n.parsing.start=n.parsing.end=n.buffering.start=n.buffering.end=self.performance.now(),s.trigger(y.FRAG_LOADED,i),r.bitrateTest=!1}).catch(i=>{this.state===j.STOPPED||this.state===j.ERROR||(this.warn(i),this.resetFragmentLoading(e))})}_handleTransmuxComplete(e){const t=this.playlistType,{hls:i}=this,{remuxResult:s,chunkMeta:r}=e,n=this.getCurrentContext(r);if(!n){this.resetWhenMissingContext(r);return}const{frag:o,part:c,level:u}=n,{video:h,text:f,id3:g,initSegment:I}=s,{details:m}=u,E=this.altAudio?void 0:s.audio;if(this.fragContextChanged(o)){this.fragmentTracker.removeFragment(o);return}if(this.state=j.PARSING,I){const v=I.tracks;if(v){const w=o.initSegment||o;if(this.unhandledEncryptionError(I,o))return;this._bufferInitSegment(u,v,w,r),i.trigger(y.FRAG_PARSING_INIT_SEGMENT,{frag:w,id:t,tracks:v})}const x=I.initPTS,D=I.timescale,L=this.initPTS[o.cc];if(se(x)&&(!L||L.baseTime!==x||L.timescale!==D)){const w=I.trackId;this.initPTS[o.cc]={baseTime:x,timescale:D,trackId:w},i.trigger(y.INIT_PTS_FOUND,{frag:o,id:t,initPTS:x,timescale:D,trackId:w})}}if(h&&m){E&&h.type==="audiovideo"&&this.logMuxedErr(o);const v=m.fragments[o.sn-1-m.startSN],x=o.sn===m.startSN,D=!v||o.cc>v.cc;if(s.independent!==!1){const{startPTS:L,endPTS:w,startDTS:N,endDTS:K}=h;if(c)c.elementaryStreams[h.type]={startPTS:L,endPTS:w,startDTS:N,endDTS:K};else if(h.firstKeyFrame&&h.independent&&r.id===1&&!D&&(this.couldBacktrack=!0),h.dropped&&h.independent){const p=this.getMainFwdBufferInfo(),$=(p?p.end:this.getLoadPosition())+this.config.maxBufferHole,F=h.firstKeyFramePTS?h.firstKeyFramePTS:L;if(!x&&$<F-this.config.maxBufferHole&&!D){this.backtrack(o);return}else D&&(o.gap=!0);o.setElementaryStreamInfo(h.type,o.start,w,o.start,K,!0)}else x&&L-(m.appliedTimelineOffset||0)>Zs&&(o.gap=!0);o.setElementaryStreamInfo(h.type,L,w,N,K),this.backtrackFragment&&(this.backtrackFragment=o),this.bufferFragmentData(h,o,c,r,x||D)}else if(x||D)o.gap=!0;else{this.backtrack(o);return}}if(E){const{startPTS:v,endPTS:x,startDTS:D,endDTS:L}=E;c&&(c.elementaryStreams[Ue.AUDIO]={startPTS:v,endPTS:x,startDTS:D,endDTS:L}),o.setElementaryStreamInfo(Ue.AUDIO,v,x,D,L),this.bufferFragmentData(E,o,c,r)}if(m&&g!=null&&g.samples.length){const v={id:t,frag:o,details:m,samples:g.samples};i.trigger(y.FRAG_PARSING_METADATA,v)}if(m&&f){const v={id:t,frag:o,details:m,samples:f.samples};i.trigger(y.FRAG_PARSING_USERDATA,v)}}logMuxedErr(e){this.warn(`${qe(e)?"Media":"Init"} segment with muxed audiovideo where only video expected: ${e.url}`)}_bufferInitSegment(e,t,i,s){if(this.state!==j.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&(delete t.audio,t.audiovideo&&this.logMuxedErr(i));const{audio:r,video:n,audiovideo:o}=t;if(r){const u=e.audioCodec;let h=vs(r.codec,u);h==="mp4a"&&(h="mp4a.40.5");const f=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){h&&(h.indexOf("mp4a.40.5")!==-1?h="mp4a.40.2":h="mp4a.40.5");const g=r.metadata;g&&"channelCount"in g&&(g.channelCount||1)!==1&&f.indexOf("firefox")===-1&&(h="mp4a.40.5")}h&&h.indexOf("mp4a.40.5")!==-1&&f.indexOf("android")!==-1&&r.container!=="audio/mpeg"&&(h="mp4a.40.2",this.log(`Android: force audio codec to ${h}`)),u&&u!==h&&this.log(`Swapping manifest audio codec "${u}" for "${h}"`),r.levelCodec=h,r.id=he.MAIN,this.log(`Init audio buffer, container:${r.container}, codecs[selected/level/parsed]=[${h||""}/${u||""}/${r.codec}]`),delete t.audiovideo}if(n){n.levelCodec=e.videoCodec,n.id=he.MAIN;const u=n.codec;if(u?.length===4)switch(u){case"hvc1":case"hev1":n.codec="hvc1.1.6.L120.90";break;case"av01":n.codec="av01.0.04M.08";break;case"avc1":n.codec="avc1.42e01e";break}this.log(`Init video buffer, container:${n.container}, codecs[level/parsed]=[${e.videoCodec||""}/${u}]${n.codec!==u?" parsed-corrected="+n.codec:""}${n.supplemental?" supplemental="+n.supplemental:""}`),delete t.audiovideo}o&&(this.log(`Init audiovideo buffer, container:${o.container}, codecs[level/parsed]=[${e.codecs}/${o.codec}]`),delete t.video,delete t.audio);const c=Object.keys(t);if(c.length){if(this.hls.trigger(y.BUFFER_CODECS,t),!this.hls)return;c.forEach(u=>{const f=t[u].initSegment;f!=null&&f.byteLength&&this.hls.trigger(y.BUFFER_APPENDING,{type:u,data:f,frag:i,part:null,chunkMeta:s,parent:i.type})})}this.tickImmediate()}getMainFwdBufferInfo(){const e=this.mediaBuffer&&this.altAudio===2?this.mediaBuffer:this.media;return this.getFwdBufferInfo(e,he.MAIN)}get maxBufferLength(){const{levels:e,level:t}=this,i=e?.[t];return i?this.getMaxBufferLength(i.maxBitrate):this.config.maxBufferLength}backtrack(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=j.IDLE}checkFragmentChanged(){const e=this.media;let t=null;if(e&&e.readyState>1&&e.seeking===!1){const i=e.currentTime;if(ye.isBuffered(e,i)?t=this.getAppendedFrag(i):ye.isBuffered(e,i+.1)&&(t=this.getAppendedFrag(i+.1)),t){this.backtrackFragment=null;const s=this.fragPlaying,r=t.level;(!s||t.sn!==s.sn||s.level!==r)&&(this.fragPlaying=t,this.hls.trigger(y.FRAG_CHANGED,{frag:t}),(!s||s.level!==r)&&this.hls.trigger(y.LEVEL_SWITCHED,{level:r}))}}}get nextLevel(){const e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){var e;if(this.fragPlaying)return this.fragPlaying;const t=((e=this.media)==null?void 0:e.currentTime)||this.lastCurrentTime;return se(t)?this.getAppendedFrag(t):null}get currentProgramDateTime(){var e;const t=((e=this.media)==null?void 0:e.currentTime)||this.lastCurrentTime;if(se(t)){const i=this.getLevelDetails(),s=this.currentFrag||(i?yi(null,i.fragments,t):null);if(s){const r=s.programDateTime;if(r!==null){const n=r+(t-s.start)*1e3;return new Date(n)}}}return null}get currentLevel(){const e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){const e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}}class pg extends Tt{constructor(e,t){super("key-loader",t),this.config=void 0,this.keyIdToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(const i in this.keyIdToKeyInfo){const s=this.keyIdToKeyInfo[i].loader;if(s){var t;if(e&&e!==((t=s.context)==null?void 0:t.frag.type))return;s.abort()}}}detach(){for(const e in this.keyIdToKeyInfo){const t=this.keyIdToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyIdToKeyInfo[e]}}destroy(){this.detach();for(const e in this.keyIdToKeyInfo){const t=this.keyIdToKeyInfo[e].loader;t&&t.destroy()}this.keyIdToKeyInfo={}}createKeyLoadError(e,t=U.KEY_LOAD_ERROR,i,s,r){return new zt({type:de.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:r,error:i,networkDetails:s})}loadClear(e,t,i){if(this.emeController&&this.config.emeEnabled&&!this.emeController.getSelectedKeySystemFormats().length){if(t.length)for(let s=0,r=t.length;s<r;s++){const n=t[s];if(e.cc<=n.cc&&(!qe(e)||!qe(n)||e.sn<n.sn)||!i&&s==r-1)return this.emeController.selectKeySystemFormat(n).then(o=>{if(!this.emeController)return;n.setKeyFormat(o);const c=_s(o);if(c)return this.emeController.getKeySystemAccess([c])})}if(this.config.requireKeySystemAccessOnStart){const s=Qi(this.config);if(s.length)return this.emeController.getKeySystemAccess(s)}}return null}load(e){return!e.decryptdata&&e.encrypted&&this.emeController&&this.config.emeEnabled?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){var i,s;t&&e.setKeyFormat(t);const r=e.decryptdata;if(!r){const h=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,U.KEY_LOAD_ERROR,h))}const n=r.uri;if(!n)return Promise.reject(this.createKeyLoadError(e,U.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${n}"`)));const o=xn(r);let c=this.keyIdToKeyInfo[o];if((i=c)!=null&&i.decryptdata.key)return r.key=c.decryptdata.key,Promise.resolve({frag:e,keyInfo:c});if((s=c)!=null&&s.keyLoadPromise){var u;switch((u=c.mediaKeySessionContext)==null?void 0:u.keyStatus){case"usable":case"usable-in-future":return c.keyLoadPromise.then(f=>{const{keyInfo:g}=f;return r.key=g.decryptdata.key,{frag:e,keyInfo:g}})}}switch(this.log(`Loading key ${It(r.keyId||[])} from ${e.type} ${e.level}`),c=this.keyIdToKeyInfo[o]={decryptdata:r,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},r.method){case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return r.keyFormat==="identity"?this.loadKeyHTTP(c,e):this.loadKeyEME(c,e);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(c,e);default:return Promise.reject(this.createKeyLoadError(e,U.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${r.method}"`)))}}loadKeyEME(e,t){const i={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){const s=this.emeController.loadKey(i);return(e.keyLoadPromise=s.then(r=>(e.mediaKeySessionContext=r,i))).catch(r=>{throw e.keyLoadPromise=null,r.data&&(r.data.frag=t),r})}return Promise.resolve(i)}loadKeyHTTP(e,t){const i=this.config,s=i.loader,r=new s(i);return t.keyLoader=e.loader=r,e.keyLoadPromise=new Promise((n,o)=>{const c={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},u=i.keyLoadPolicy.default,h={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},f={onSuccess:(g,I,m,E)=>{const{frag:v,keyInfo:x,url:D}=m,L=xn(x.decryptdata)||D;if(!v.decryptdata||x!==this.keyIdToKeyInfo[L])return o(this.createKeyLoadError(v,U.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),E));x.decryptdata.key=v.decryptdata.key=new Uint8Array(g.data),v.keyLoader=null,x.loader=null,n({frag:v,keyInfo:x})},onError:(g,I,m,E)=>{this.resetLoader(I),o(this.createKeyLoadError(t,U.KEY_LOAD_ERROR,new Error(`HTTP Error ${g.code} loading key ${g.text}`),m,Be({url:c.url,data:void 0},g)))},onTimeout:(g,I,m)=>{this.resetLoader(I),o(this.createKeyLoadError(t,U.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),m))},onAbort:(g,I,m)=>{this.resetLoader(I),o(this.createKeyLoadError(t,U.INTERNAL_ABORTED,new Error("key loading aborted"),m))}};r.load(c,h,f)})}resetLoader(e){const{frag:t,keyInfo:i,url:s}=e,r=i.loader;t.keyLoader===r&&(t.keyLoader=null,i.loader=null);const n=xn(i.decryptdata)||s;delete this.keyIdToKeyInfo[n],r&&r.destroy()}}function xn(a){const e=a.keyId;return e?It(e):a.uri}function Fl(a){const{type:e}=a;switch(e){case be.AUDIO_TRACK:return he.AUDIO;case be.SUBTITLE_TRACK:return he.SUBTITLE;default:return he.MAIN}}function bn(a,e){let t=a.url;return(t===void 0||t.indexOf("data:")===0)&&(t=e.url),t}class Ag{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:e}=this;e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.LEVEL_LOADING,this.onLevelLoading,this),e.on(y.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(y.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on(y.LEVELS_UPDATED,this.onLevelsUpdated,this)}unregisterListeners(){const{hls:e}=this;e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.LEVEL_LOADING,this.onLevelLoading,this),e.off(y.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(y.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off(y.LEVELS_UPDATED,this.onLevelsUpdated,this)}createInternalLoader(e){const t=this.hls.config,i=t.pLoader,s=t.loader,r=i||s,n=new r(t);return this.loaders[e.type]=n,n}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(const e in this.loaders){const t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,t){const{url:i}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:be.MANIFEST,url:i,deliveryDirectives:null,levelOrTrack:null})}onLevelLoading(e,t){const{id:i,level:s,pathwayId:r,url:n,deliveryDirectives:o,levelInfo:c}=t;this.load({id:i,level:s,pathwayId:r,responseType:"text",type:be.LEVEL,url:n,deliveryDirectives:o,levelOrTrack:c})}onAudioTrackLoading(e,t){const{id:i,groupId:s,url:r,deliveryDirectives:n,track:o}=t;this.load({id:i,groupId:s,level:null,responseType:"text",type:be.AUDIO_TRACK,url:r,deliveryDirectives:n,levelOrTrack:o})}onSubtitleTrackLoading(e,t){const{id:i,groupId:s,url:r,deliveryDirectives:n,track:o}=t;this.load({id:i,groupId:s,level:null,responseType:"text",type:be.SUBTITLE_TRACK,url:r,deliveryDirectives:n,levelOrTrack:o})}onLevelsUpdated(e,t){const i=this.loaders[be.LEVEL];if(i){const s=i.context;s&&!t.levels.some(r=>r===s.levelOrTrack)&&(i.abort(),delete this.loaders[be.LEVEL])}}load(e){var t;const i=this.hls.config;let s=this.getInternalLoader(e);if(s){const u=this.hls.logger,h=s.context;if(h&&h.levelOrTrack===e.levelOrTrack&&(h.url===e.url||h.deliveryDirectives&&!e.deliveryDirectives)){h.url===e.url?u.log(`[playlist-loader]: ignore ${e.url} ongoing request`):u.log(`[playlist-loader]: ignore ${e.url} in favor of ${h.url}`);return}u.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),s.abort()}let r;if(e.type===be.MANIFEST?r=i.manifestLoadPolicy.default:r=Ne({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(e),se((t=e.deliveryDirectives)==null?void 0:t.part)){let u;if(e.type===be.LEVEL&&e.level!==null?u=this.hls.levels[e.level].details:e.type===be.AUDIO_TRACK&&e.id!==null?u=this.hls.audioTracks[e.id].details:e.type===be.SUBTITLE_TRACK&&e.id!==null&&(u=this.hls.subtitleTracks[e.id].details),u){const h=u.partTarget,f=u.targetduration;if(h&&f){const g=Math.max(h*3,f*.8)*1e3;r=Ne({},r,{maxTimeToFirstByteMs:Math.min(g,r.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(g,r.maxTimeToFirstByteMs)})}}}const n=r.errorRetry||r.timeoutRetry||{},o={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:n.maxNumRetry||0,retryDelay:n.retryDelayMs||0,maxRetryDelay:n.maxRetryDelayMs||0},c={onSuccess:(u,h,f,g)=>{const I=this.getInternalLoader(f);this.resetInternalLoader(f.type);const m=u.data;if(m.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(u,f,new Error("no EXTM3U delimiter"),g||null,h);return}h.parsing.start=performance.now(),Nt.isMediaPlaylist(m)||f.type!==be.MANIFEST?this.handleTrackOrLevelPlaylist(u,h,f,g||null,I):this.handleMasterPlaylist(u,h,f,g)},onError:(u,h,f,g)=>{this.handleNetworkError(h,f,!1,u,g)},onTimeout:(u,h,f)=>{this.handleNetworkError(h,f,!0,void 0,u)}};s.load(e,o,c)}checkAutostartLoad(){if(!this.hls)return;const{config:{autoStartLoad:e,startPosition:t},forceStartLoad:i}=this.hls;(e||i)&&(this.hls.logger.log(`${e?"auto":"force"} startLoad with configured startPosition ${t}`),this.hls.startLoad(t))}handleMasterPlaylist(e,t,i,s){const r=this.hls,n=e.data,o=bn(e,i),c=Nt.parseMasterPlaylist(n,o);if(c.playlistParsingError){this.handleManifestParsingError(e,i,c.playlistParsingError,s,t);return}const{contentSteering:u,levels:h,sessionData:f,sessionKeys:g,startTimeOffset:I,variableList:m}=c;this.variableList=m;const{AUDIO:E=[],SUBTITLES:v,"CLOSED-CAPTIONS":x}=Nt.parseMasterPlaylistMedia(n,o,c);E.length&&!E.some(L=>!L.url)&&h[0].audioCodec&&!h[0].attrs.AUDIO&&(this.hls.logger.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 He({}),bitrate:0,url:""})),r.trigger(y.MANIFEST_LOADED,{levels:h,audioTracks:E,subtitles:v,captions:x,contentSteering:u,url:o,stats:t,networkDetails:s,sessionData:f,sessionKeys:g,startTimeOffset:I,variableList:m})}handleTrackOrLevelPlaylist(e,t,i,s,r){const n=this.hls,{id:o,level:c,type:u}=i,h=bn(e,i),f=se(c)?c:se(o)?o:0,g=Fl(i),I=Nt.parseLevelPlaylist(e.data,h,f,g,0,this.variableList);if(u===be.MANIFEST){const m={attrs:new He({}),bitrate:0,details:I,name:"",url:h};I.requestScheduled=t.loading.start+so(I,0),n.trigger(y.MANIFEST_LOADED,{levels:[m],audioTracks:[],url:h,stats:t,networkDetails:s,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),i.levelDetails=I,this.handlePlaylistLoaded(I,e,t,i,s,r)}handleManifestParsingError(e,t,i,s,r){this.hls.trigger(y.ERROR,{type:de.NETWORK_ERROR,details:U.MANIFEST_PARSING_ERROR,fatal:t.type===be.MANIFEST,url:e.url,err:i,error:i,reason:i.message,response:e,context:t,networkDetails:s,stats:r})}handleNetworkError(e,t,i=!1,s,r){let n=`A network ${i?"timeout":"error"+(s?" (status "+s.code+")":"")} occurred while loading ${e.type}`;e.type===be.LEVEL?n+=`: ${e.level} id: ${e.id}`:(e.type===be.AUDIO_TRACK||e.type===be.SUBTITLE_TRACK)&&(n+=` id: ${e.id} group-id: "${e.groupId}"`);const o=new Error(n);this.hls.logger.warn(`[playlist-loader]: ${n}`);let c=U.UNKNOWN,u=!1;const h=this.getInternalLoader(e);switch(e.type){case be.MANIFEST:c=i?U.MANIFEST_LOAD_TIMEOUT:U.MANIFEST_LOAD_ERROR,u=!0;break;case be.LEVEL:c=i?U.LEVEL_LOAD_TIMEOUT:U.LEVEL_LOAD_ERROR,u=!1;break;case be.AUDIO_TRACK:c=i?U.AUDIO_TRACK_LOAD_TIMEOUT:U.AUDIO_TRACK_LOAD_ERROR,u=!1;break;case be.SUBTITLE_TRACK:c=i?U.SUBTITLE_TRACK_LOAD_TIMEOUT:U.SUBTITLE_LOAD_ERROR,u=!1;break}h&&this.resetInternalLoader(e.type);const f={type:de.NETWORK_ERROR,details:c,fatal:u,url:e.url,loader:h,context:e,error:o,networkDetails:t,stats:r};if(s){const g=t?.url||e.url;f.response=Be({url:g,data:void 0},s)}this.hls.trigger(y.ERROR,f)}handlePlaylistLoaded(e,t,i,s,r,n){const o=this.hls,{type:c,level:u,id:h,groupId:f,deliveryDirectives:g}=s,I=bn(t,s),m=Fl(s),E=typeof s.level=="number"&&m===he.MAIN?u:void 0;if(!e.fragments.length){const x=e.playlistParsingError=new Error("No Segments found in Playlist");o.trigger(y.ERROR,{type:de.NETWORK_ERROR,details:U.LEVEL_EMPTY_ERROR,fatal:!1,url:I,error:x,reason:x.message,response:t,context:s,level:E,parent:m,networkDetails:r,stats:i});return}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));const v=e.playlistParsingError;if(v){if(this.hls.logger.warn(`${v} ${e.url}`),!o.config.ignorePlaylistParsingErrors){o.trigger(y.ERROR,{type:de.NETWORK_ERROR,details:U.LEVEL_PARSING_ERROR,fatal:!1,url:I,error:v,reason:v.message,response:t,context:s,level:E,parent:m,networkDetails:r,stats:i});return}e.playlistParsingError=null}switch(e.live&&n&&(n.getCacheAge&&(e.ageHeader=n.getCacheAge()||0),(!n.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),c){case be.MANIFEST:case be.LEVEL:o.trigger(y.LEVEL_LOADED,{details:e,levelInfo:s.levelOrTrack||o.levels[0],level:E||0,id:h||0,stats:i,networkDetails:r,deliveryDirectives:g,withoutMultiVariant:c===be.MANIFEST});break;case be.AUDIO_TRACK:o.trigger(y.AUDIO_TRACK_LOADED,{details:e,track:s.levelOrTrack,id:h||0,groupId:f||"",stats:i,networkDetails:r,deliveryDirectives:g});break;case be.SUBTITLE_TRACK:o.trigger(y.SUBTITLE_TRACK_LOADED,{details:e,track:s.levelOrTrack,id:h||0,groupId:f||"",stats:i,networkDetails:r,deliveryDirectives:g});break}}}class ft{static get version(){return es}static isMSESupported(){return Ol()}static isSupported(){return hg()}static getMediaSource(){return ri()}static get Events(){return y}static get MetadataSchema(){return yt}static get ErrorTypes(){return de}static get ErrorDetails(){return U}static get DefaultConfig(){return ft.defaultConfig?ft.defaultConfig:Jf}static set DefaultConfig(e){ft.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.logger=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new Gr,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;const t=this.logger=bu(e.debug||!1,"Hls instance",e.assetPlayerId),i=this.config=tg(ft.DefaultConfig,e,t);this.userConfig=e,i.progressive&&ig(i,t);const{abrController:s,bufferController:r,capLevelController:n,errorController:o,fpsController:c}=i,u=new o(this),h=this.abrController=new s(this),f=new Ic(this),g=i.interstitialsController,I=g?this.interstitialsController=new g(this,ft):null,m=this.bufferController=new r(this,f),E=this.capLevelController=new n(this),v=new c(this),x=new Ag(this),D=i.contentSteeringController,L=D?new D(this):null,w=this.levelController=new cg(this,L),N=new lg(this),K=new pg(this.config,this.logger),p=this.streamController=new gg(this,f,K),$=this.gapController=new ag(this,f);E.setStreamController(p),v.setStreamController(p);const F=[x,w,p];I&&F.splice(1,0,I),L&&F.splice(1,0,L),this.networkControllers=F;const O=[h,m,$,E,v,N,f];this.audioTrackController=this.createController(i.audioTrackController,F);const W=i.audioStreamController;W&&F.push(this.audioStreamController=new W(this,f,K)),this.subtitleTrackController=this.createController(i.subtitleTrackController,F);const ie=i.subtitleStreamController;ie&&F.push(this.subtititleStreamController=new ie(this,f,K)),this.createController(i.timelineController,O),K.emeController=this.emeController=this.createController(i.emeController,O),this.cmcdController=this.createController(i.cmcdController,O),this.latencyController=this.createController(ug,O),this.coreComponents=O,F.push(u);const X=u.onErrorOut;typeof X=="function"&&this.on(y.ERROR,X,u),this.on(y.MANIFEST_LOADED,x.onManifestLoaded,x)}createController(e,t){if(e){const i=new e(this);return t&&t.push(i),i}return null}on(e,t,i=this){this._emitter.on(e,t,i)}once(e,t,i=this){this._emitter.once(e,t,i)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,i=this,s){this._emitter.off(e,t,i,s)}listeners(e){return this._emitter.listeners(e)}emit(e,t,i){return this._emitter.emit(e,t,i)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(i){if(this.logger.error("An internal error happened while handling event "+e+'. Error message: "'+i.message+'". Here is a stacktrace:',i),!this.triggeringException){this.triggeringException=!0;const s=e===y.ERROR;this.trigger(y.ERROR,{type:de.OTHER_ERROR,details:U.INTERNAL_EXCEPTION,fatal:s,event:e,error:i}),this.triggeringException=!1}}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){this.logger.log("destroy"),this.trigger(y.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this._url=null,this.networkControllers.forEach(t=>t.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(t=>t.destroy()),this.coreComponents.length=0;const e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){if(!e||"media"in e&&!e.media){const r=new Error(`attachMedia failed: invalid argument (${e})`);this.trigger(y.ERROR,{type:de.OTHER_ERROR,details:U.ATTACH_MEDIA_ERROR,fatal:!0,error:r});return}this.logger.log("attachMedia"),this._media&&(this.logger.warn("media must be detached before attaching"),this.detachMedia());const t="media"in e,i=t?e.media:e,s=t?e:{media:i};this._media=i,this.trigger(y.MEDIA_ATTACHING,s)}detachMedia(){this.logger.log("detachMedia"),this.trigger(y.MEDIA_DETACHING,{}),this._media=null}transferMedia(){this._media=null;const e=this.bufferController.transferMedia();return this.trigger(y.MEDIA_DETACHING,{transferMedia:e}),e}loadSource(e){this.stopLoad();const t=this.media,i=this._url,s=this._url=pr.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log(`loadSource:${s}`),t&&i&&(i!==s||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(y.MANIFEST_LOADING,{url:e})}get url(){return this._url}get hasEnoughToStart(){return this.streamController.hasEnoughToStart}get startPosition(){return this.streamController.startPositionValue}startLoad(e=-1,t){this.logger.log(`startLoad(${e+(t?", <skip seek to start>":"")})`),this.started=!0,this.resumeBuffering();for(let i=0;i<this.networkControllers.length&&(this.networkControllers[i].startLoad(e,t),!(!this.started||!this.networkControllers));i++);}stopLoad(){this.logger.log("stopLoad"),this.started=!1;for(let e=0;e<this.networkControllers.length&&(this.networkControllers[e].stopLoad(),!(this.started||!this.networkControllers));e++);}get loadingEnabled(){return this.started}get bufferingEnabled(){return this.streamController.bufferingEnabled}resumeBuffering(){this.bufferingEnabled||(this.logger.log("resume buffering"),this.networkControllers.forEach(e=>{e.resumeBuffering&&e.resumeBuffering()}))}pauseBuffering(){this.bufferingEnabled&&(this.logger.log("pause buffering"),this.networkControllers.forEach(e=>{e.pauseBuffering&&e.pauseBuffering()}))}get inFlightFragments(){const e={[he.MAIN]:this.streamController.inFlightFrag};return this.audioStreamController&&(e[he.AUDIO]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(e[he.SUBTITLE]=this.subtititleStreamController.inFlightFrag),e}swapAudioCodec(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){this.logger.log("recoverMediaError");const e=this._media,t=e?.currentTime;this.detachMedia(),e&&(this.attachMedia(e),t&&this.startLoad(t))}removeLevel(e){this.levelController.removeLevel(e)}get sessionId(){let e=this._sessionId;return e||(e=this._sessionId=af()),e}get levels(){const e=this.levelController.levels;return e||[]}get latestLevelDetails(){return this.streamController.getLevelDetails()||null}get loadLevelObj(){return this.levelController.loadLevelObj}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){this.logger.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){this.logger.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){this.logger.log(`set loadLevel:${e}`),this.levelController.manualLevel=e}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){this.logger.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}get startLevel(){const e=this.levelController.startLevel;return e===-1&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e}set startLevel(e){this.logger.log(`set startLevel:${e}`),e!==-1&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){const t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}set bandwidthEstimate(e){this.abrController.resetEstimator(e)}get abrEwmaDefaultEstimate(){const{bwEstimator:e}=this.abrController;return e?e.defaultEstimate:NaN}get ttfbEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(this.logger.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){ic(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}get autoLevelEnabled(){return this.levelController.manualLevel===-1}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;const i=e.length;for(let s=0;s<i;s++)if(e[s].maxBitrate>=t)return s;return 0}get maxAutoLevel(){const{levels:e,autoLevelCapping:t,maxHdcpLevel:i}=this;let s;if(t===-1&&e!=null&&e.length?s=e.length-1:s=t,i)for(let r=s;r--;){const n=e[r].attrs["HDCP-LEVEL"];if(n&&n<=i)return r}return s}get firstAutoLevel(){return this.abrController.firstAutoLevel}get nextAutoLevel(){return this.abrController.nextAutoLevel}set nextAutoLevel(e){this.abrController.nextAutoLevel=e}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get maxBufferLength(){return this.streamController.maxBufferLength}setAudioOption(e){var t;return((t=this.audioTrackController)==null?void 0:t.setAudioOption(e))||null}setSubtitleOption(e){var t;return((t=this.subtitleTrackController)==null?void 0:t.setSubtitleOption(e))||null}get allAudioTracks(){const e=this.audioTrackController;return e?e.allAudioTracks:[]}get audioTracks(){const e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){const e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){const t=this.audioTrackController;t&&(t.audioTrack=e)}get allSubtitleTracks(){const e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}get subtitleTracks(){const e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){const e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){const t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}get subtitleDisplay(){const e=this.subtitleTrackController;return e?e.subtitleDisplay:!1}set subtitleDisplay(e){const t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}set targetLatency(e){this.latencyController.targetLatency=e}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}get pathways(){return this.levelController.pathways}get pathwayPriority(){return this.levelController.pathwayPriority}set pathwayPriority(e){this.levelController.pathwayPriority=e}get bufferedToEnd(){var e;return!!((e=this.bufferController)!=null&&e.bufferedToEnd)}get interstitialsManager(){var e;return((e=this.interstitialsController)==null?void 0:e.interstitialsManager)||null}getMediaDecodingInfo(e,t=this.allAudioTracks){const i=va(t);return ma(e,i,navigator.mediaCapabilities)}}ft.defaultConfig=void 0;function mg(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var er={exports:{}};/*!
41
- * jQuery JavaScript Library v3.7.1
42
- * https://jquery.com/
43
- *
44
- * Copyright OpenJS Foundation and other contributors
45
- * Released under the MIT license
46
- * https://jquery.org/license
47
- *
48
- * Date: 2023-08-28T13:37Z
49
- */var Ig=er.exports,Nl;function Cg(){return Nl||(Nl=1,(function(a){(function(e,t){a.exports=e.document?t(e,!0):function(i){if(!i.document)throw new Error("jQuery requires a window with a document");return t(i)}})(typeof window<"u"?window:Ig,function(e,t){var i=[],s=Object.getPrototypeOf,r=i.slice,n=i.flat?function(l){return i.flat.call(l)}:function(l){return i.concat.apply([],l)},o=i.push,c=i.indexOf,u={},h=u.toString,f=u.hasOwnProperty,g=f.toString,I=g.call(Object),m={},E=function(d){return typeof d=="function"&&typeof d.nodeType!="number"&&typeof d.item!="function"},v=function(d){return d!=null&&d===d.window},x=e.document,D={type:!0,src:!0,nonce:!0,noModule:!0};function L(l,d,A){A=A||x;var C,T,S=A.createElement("script");if(S.text=l,d)for(C in D)T=d[C]||d.getAttribute&&d.getAttribute(C),T&&S.setAttribute(C,T);A.head.appendChild(S).parentNode.removeChild(S)}function w(l){return l==null?l+"":typeof l=="object"||typeof l=="function"?u[h.call(l)]||"object":typeof l}var N="3.7.1",K=/HTML$/i,p=function(l,d){return new p.fn.init(l,d)};p.fn=p.prototype={jquery:N,constructor:p,length:0,toArray:function(){return r.call(this)},get:function(l){return l==null?r.call(this):l<0?this[l+this.length]:this[l]},pushStack:function(l){var d=p.merge(this.constructor(),l);return d.prevObject=this,d},each:function(l){return p.each(this,l)},map:function(l){return this.pushStack(p.map(this,function(d,A){return l.call(d,A,d)}))},slice:function(){return this.pushStack(r.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},even:function(){return this.pushStack(p.grep(this,function(l,d){return(d+1)%2}))},odd:function(){return this.pushStack(p.grep(this,function(l,d){return d%2}))},eq:function(l){var d=this.length,A=+l+(l<0?d:0);return this.pushStack(A>=0&&A<d?[this[A]]:[])},end:function(){return this.prevObject||this.constructor()},push:o,sort:i.sort,splice:i.splice},p.extend=p.fn.extend=function(){var l,d,A,C,T,S,b=arguments[0]||{},_=1,P=arguments.length,M=!1;for(typeof b=="boolean"&&(M=b,b=arguments[_]||{},_++),typeof b!="object"&&!E(b)&&(b={}),_===P&&(b=this,_--);_<P;_++)if((l=arguments[_])!=null)for(d in l)C=l[d],!(d==="__proto__"||b===C)&&(M&&C&&(p.isPlainObject(C)||(T=Array.isArray(C)))?(A=b[d],T&&!Array.isArray(A)?S=[]:!T&&!p.isPlainObject(A)?S={}:S=A,T=!1,b[d]=p.extend(M,S,C)):C!==void 0&&(b[d]=C));return b},p.extend({expando:"jQuery"+(N+Math.random()).replace(/\D/g,""),isReady:!0,error:function(l){throw new Error(l)},noop:function(){},isPlainObject:function(l){var d,A;return!l||h.call(l)!=="[object Object]"?!1:(d=s(l),d?(A=f.call(d,"constructor")&&d.constructor,typeof A=="function"&&g.call(A)===I):!0)},isEmptyObject:function(l){var d;for(d in l)return!1;return!0},globalEval:function(l,d,A){L(l,{nonce:d&&d.nonce},A)},each:function(l,d){var A,C=0;if($(l))for(A=l.length;C<A&&d.call(l[C],C,l[C])!==!1;C++);else for(C in l)if(d.call(l[C],C,l[C])===!1)break;return l},text:function(l){var d,A="",C=0,T=l.nodeType;if(!T)for(;d=l[C++];)A+=p.text(d);return T===1||T===11?l.textContent:T===9?l.documentElement.textContent:T===3||T===4?l.nodeValue:A},makeArray:function(l,d){var A=d||[];return l!=null&&($(Object(l))?p.merge(A,typeof l=="string"?[l]:l):o.call(A,l)),A},inArray:function(l,d,A){return d==null?-1:c.call(d,l,A)},isXMLDoc:function(l){var d=l&&l.namespaceURI,A=l&&(l.ownerDocument||l).documentElement;return!K.test(d||A&&A.nodeName||"HTML")},merge:function(l,d){for(var A=+d.length,C=0,T=l.length;C<A;C++)l[T++]=d[C];return l.length=T,l},grep:function(l,d,A){for(var C,T=[],S=0,b=l.length,_=!A;S<b;S++)C=!d(l[S],S),C!==_&&T.push(l[S]);return T},map:function(l,d,A){var C,T,S=0,b=[];if($(l))for(C=l.length;S<C;S++)T=d(l[S],S,A),T!=null&&b.push(T);else for(S in l)T=d(l[S],S,A),T!=null&&b.push(T);return n(b)},guid:1,support:m}),typeof Symbol=="function"&&(p.fn[Symbol.iterator]=i[Symbol.iterator]),p.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(l,d){u["[object "+d+"]"]=d.toLowerCase()});function $(l){var d=!!l&&"length"in l&&l.length,A=w(l);return E(l)||v(l)?!1:A==="array"||d===0||typeof d=="number"&&d>0&&d-1 in l}function F(l,d){return l.nodeName&&l.nodeName.toLowerCase()===d.toLowerCase()}var O=i.pop,W=i.sort,ie=i.splice,X="[\\x20\\t\\r\\n\\f]",ce=new RegExp("^"+X+"+|((?:^|[^\\\\])(?:\\\\.)*)"+X+"+$","g");p.contains=function(l,d){var A=d&&d.parentNode;return l===A||!!(A&&A.nodeType===1&&(l.contains?l.contains(A):l.compareDocumentPosition&&l.compareDocumentPosition(A)&16))};var ue=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g;function Q(l,d){return d?l==="\0"?"�":l.slice(0,-1)+"\\"+l.charCodeAt(l.length-1).toString(16)+" ":"\\"+l}p.escapeSelector=function(l){return(l+"").replace(ue,Q)};var ne=x,re=o;(function(){var l,d,A,C,T,S=re,b,_,P,M,Y,q=p.expando,H=0,Z=0,Ce=lr(),we=lr(),Se=lr(),nt=lr(),et=function(R,k){return R===k&&(T=!0),0},Vt="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",Kt="(?:\\\\[\\da-fA-F]{1,6}"+X+"?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+",_e="\\["+X+"*("+Kt+")(?:"+X+"*([*^$|!~]?=)"+X+`*(?:'((?:\\\\.|[^\\\\'])*)'|"((?:\\\\.|[^\\\\"])*)"|(`+Kt+"))|)"+X+"*\\]",bi=":("+Kt+`)(?:\\((('((?:\\\\.|[^\\\\'])*)'|"((?:\\\\.|[^\\\\"])*)")|((?:\\\\.|[^\\\\()[\\]]|`+_e+")*)|.*)\\)|)",Me=new RegExp(X+"+","g"),We=new RegExp("^"+X+"*,"+X+"*"),gs=new RegExp("^"+X+"*([>+~]|"+X+")"+X+"*"),Hn=new RegExp(X+"|>"),Yt=new RegExp(bi),ps=new RegExp("^"+Kt+"$"),Wt={ID:new RegExp("^#("+Kt+")"),CLASS:new RegExp("^\\.("+Kt+")"),TAG:new RegExp("^("+Kt+"|[*])"),ATTR:new RegExp("^"+_e),PSEUDO:new RegExp("^"+bi),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+X+"*(even|odd|(([+-]|)(\\d*)n|)"+X+"*(?:([+-]|)"+X+"*(\\d+)|))"+X+"*\\)|)","i"),bool:new RegExp("^(?:"+Vt+")$","i"),needsContext:new RegExp("^"+X+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+X+"*((?:-\\d)?\\d*)"+X+"*\\)|)(?=[^-]|$)","i")},pi=/^(?:input|select|textarea|button)$/i,Ai=/^h\d$/i,Lt=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,Vn=/[+~]/,ti=new RegExp("\\\\[\\da-fA-F]{1,6}"+X+"?|\\\\([^\\r\\n\\f])","g"),ii=function(R,k){var G="0x"+R.slice(1)-65536;return k||(G<0?String.fromCharCode(G+65536):String.fromCharCode(G>>10|55296,G&1023|56320))},np=function(){mi()},ap=cr(function(R){return R.disabled===!0&&F(R,"fieldset")},{dir:"parentNode",next:"legend"});function op(){try{return b.activeElement}catch{}}try{S.apply(i=r.call(ne.childNodes),ne.childNodes),i[ne.childNodes.length].nodeType}catch{S={apply:function(k,G){re.apply(k,r.call(G))},call:function(k){re.apply(k,r.call(arguments,1))}}}function Fe(R,k,G,V){var z,te,ae,ge,oe,Re,me,Ee=k&&k.ownerDocument,De=k?k.nodeType:9;if(G=G||[],typeof R!="string"||!R||De!==1&&De!==9&&De!==11)return G;if(!V&&(mi(k),k=k||b,P)){if(De!==11&&(oe=Lt.exec(R)))if(z=oe[1]){if(De===9)if(ae=k.getElementById(z)){if(ae.id===z)return S.call(G,ae),G}else return G;else if(Ee&&(ae=Ee.getElementById(z))&&Fe.contains(k,ae)&&ae.id===z)return S.call(G,ae),G}else{if(oe[2])return S.apply(G,k.getElementsByTagName(R)),G;if((z=oe[3])&&k.getElementsByClassName)return S.apply(G,k.getElementsByClassName(z)),G}if(!nt[R+" "]&&(!M||!M.test(R))){if(me=R,Ee=k,De===1&&(Hn.test(R)||gs.test(R))){for(Ee=Vn.test(R)&&Kn(k.parentNode)||k,(Ee!=k||!m.scope)&&((ge=k.getAttribute("id"))?ge=p.escapeSelector(ge):k.setAttribute("id",ge=q)),Re=As(R),te=Re.length;te--;)Re[te]=(ge?"#"+ge:":scope")+" "+ur(Re[te]);me=Re.join(",")}try{return S.apply(G,Ee.querySelectorAll(me)),G}catch{nt(R,!0)}finally{ge===q&&k.removeAttribute("id")}}}return mu(R.replace(ce,"$1"),k,G,V)}function lr(){var R=[];function k(G,V){return R.push(G+" ")>d.cacheLength&&delete k[R.shift()],k[G+" "]=V}return k}function kt(R){return R[q]=!0,R}function zi(R){var k=b.createElement("fieldset");try{return!!R(k)}catch{return!1}finally{k.parentNode&&k.parentNode.removeChild(k),k=null}}function lp(R){return function(k){return F(k,"input")&&k.type===R}}function up(R){return function(k){return(F(k,"input")||F(k,"button"))&&k.type===R}}function pu(R){return function(k){return"form"in k?k.parentNode&&k.disabled===!1?"label"in k?"label"in k.parentNode?k.parentNode.disabled===R:k.disabled===R:k.isDisabled===R||k.isDisabled!==!R&&ap(k)===R:k.disabled===R:"label"in k?k.disabled===R:!1}}function Li(R){return kt(function(k){return k=+k,kt(function(G,V){for(var z,te=R([],G.length,k),ae=te.length;ae--;)G[z=te[ae]]&&(G[z]=!(V[z]=G[z]))})})}function Kn(R){return R&&typeof R.getElementsByTagName<"u"&&R}function mi(R){var k,G=R?R.ownerDocument||R:ne;return G==b||G.nodeType!==9||!G.documentElement||(b=G,_=b.documentElement,P=!p.isXMLDoc(b),Y=_.matches||_.webkitMatchesSelector||_.msMatchesSelector,_.msMatchesSelector&&ne!=b&&(k=b.defaultView)&&k.top!==k&&k.addEventListener("unload",np),m.getById=zi(function(V){return _.appendChild(V).id=p.expando,!b.getElementsByName||!b.getElementsByName(p.expando).length}),m.disconnectedMatch=zi(function(V){return Y.call(V,"*")}),m.scope=zi(function(){return b.querySelectorAll(":scope")}),m.cssHas=zi(function(){try{return b.querySelector(":has(*,:jqfake)"),!1}catch{return!0}}),m.getById?(d.filter.ID=function(V){var z=V.replace(ti,ii);return function(te){return te.getAttribute("id")===z}},d.find.ID=function(V,z){if(typeof z.getElementById<"u"&&P){var te=z.getElementById(V);return te?[te]:[]}}):(d.filter.ID=function(V){var z=V.replace(ti,ii);return function(te){var ae=typeof te.getAttributeNode<"u"&&te.getAttributeNode("id");return ae&&ae.value===z}},d.find.ID=function(V,z){if(typeof z.getElementById<"u"&&P){var te,ae,ge,oe=z.getElementById(V);if(oe){if(te=oe.getAttributeNode("id"),te&&te.value===V)return[oe];for(ge=z.getElementsByName(V),ae=0;oe=ge[ae++];)if(te=oe.getAttributeNode("id"),te&&te.value===V)return[oe]}return[]}}),d.find.TAG=function(V,z){return typeof z.getElementsByTagName<"u"?z.getElementsByTagName(V):z.querySelectorAll(V)},d.find.CLASS=function(V,z){if(typeof z.getElementsByClassName<"u"&&P)return z.getElementsByClassName(V)},M=[],zi(function(V){var z;_.appendChild(V).innerHTML="<a id='"+q+"' href='' disabled='disabled'></a><select id='"+q+"-\r\\' disabled='disabled'><option selected=''></option></select>",V.querySelectorAll("[selected]").length||M.push("\\["+X+"*(?:value|"+Vt+")"),V.querySelectorAll("[id~="+q+"-]").length||M.push("~="),V.querySelectorAll("a#"+q+"+*").length||M.push(".#.+[+~]"),V.querySelectorAll(":checked").length||M.push(":checked"),z=b.createElement("input"),z.setAttribute("type","hidden"),V.appendChild(z).setAttribute("name","D"),_.appendChild(V).disabled=!0,V.querySelectorAll(":disabled").length!==2&&M.push(":enabled",":disabled"),z=b.createElement("input"),z.setAttribute("name",""),V.appendChild(z),V.querySelectorAll("[name='']").length||M.push("\\["+X+"*name"+X+"*="+X+`*(?:''|"")`)}),m.cssHas||M.push(":has"),M=M.length&&new RegExp(M.join("|")),et=function(V,z){if(V===z)return T=!0,0;var te=!V.compareDocumentPosition-!z.compareDocumentPosition;return te||(te=(V.ownerDocument||V)==(z.ownerDocument||z)?V.compareDocumentPosition(z):1,te&1||!m.sortDetached&&z.compareDocumentPosition(V)===te?V===b||V.ownerDocument==ne&&Fe.contains(ne,V)?-1:z===b||z.ownerDocument==ne&&Fe.contains(ne,z)?1:C?c.call(C,V)-c.call(C,z):0:te&4?-1:1)}),b}Fe.matches=function(R,k){return Fe(R,null,null,k)},Fe.matchesSelector=function(R,k){if(mi(R),P&&!nt[k+" "]&&(!M||!M.test(k)))try{var G=Y.call(R,k);if(G||m.disconnectedMatch||R.document&&R.document.nodeType!==11)return G}catch{nt(k,!0)}return Fe(k,b,null,[R]).length>0},Fe.contains=function(R,k){return(R.ownerDocument||R)!=b&&mi(R),p.contains(R,k)},Fe.attr=function(R,k){(R.ownerDocument||R)!=b&&mi(R);var G=d.attrHandle[k.toLowerCase()],V=G&&f.call(d.attrHandle,k.toLowerCase())?G(R,k,!P):void 0;return V!==void 0?V:R.getAttribute(k)},Fe.error=function(R){throw new Error("Syntax error, unrecognized expression: "+R)},p.uniqueSort=function(R){var k,G=[],V=0,z=0;if(T=!m.sortStable,C=!m.sortStable&&r.call(R,0),W.call(R,et),T){for(;k=R[z++];)k===R[z]&&(V=G.push(z));for(;V--;)ie.call(R,G[V],1)}return C=null,R},p.fn.uniqueSort=function(){return this.pushStack(p.uniqueSort(r.apply(this)))},d=p.expr={cacheLength:50,createPseudo:kt,match:Wt,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(R){return R[1]=R[1].replace(ti,ii),R[3]=(R[3]||R[4]||R[5]||"").replace(ti,ii),R[2]==="~="&&(R[3]=" "+R[3]+" "),R.slice(0,4)},CHILD:function(R){return R[1]=R[1].toLowerCase(),R[1].slice(0,3)==="nth"?(R[3]||Fe.error(R[0]),R[4]=+(R[4]?R[5]+(R[6]||1):2*(R[3]==="even"||R[3]==="odd")),R[5]=+(R[7]+R[8]||R[3]==="odd")):R[3]&&Fe.error(R[0]),R},PSEUDO:function(R){var k,G=!R[6]&&R[2];return Wt.CHILD.test(R[0])?null:(R[3]?R[2]=R[4]||R[5]||"":G&&Yt.test(G)&&(k=As(G,!0))&&(k=G.indexOf(")",G.length-k)-G.length)&&(R[0]=R[0].slice(0,k),R[2]=G.slice(0,k)),R.slice(0,3))}},filter:{TAG:function(R){var k=R.replace(ti,ii).toLowerCase();return R==="*"?function(){return!0}:function(G){return F(G,k)}},CLASS:function(R){var k=Ce[R+" "];return k||(k=new RegExp("(^|"+X+")"+R+"("+X+"|$)"))&&Ce(R,function(G){return k.test(typeof G.className=="string"&&G.className||typeof G.getAttribute<"u"&&G.getAttribute("class")||"")})},ATTR:function(R,k,G){return function(V){var z=Fe.attr(V,R);return z==null?k==="!=":k?(z+="",k==="="?z===G:k==="!="?z!==G:k==="^="?G&&z.indexOf(G)===0:k==="*="?G&&z.indexOf(G)>-1:k==="$="?G&&z.slice(-G.length)===G:k==="~="?(" "+z.replace(Me," ")+" ").indexOf(G)>-1:k==="|="?z===G||z.slice(0,G.length+1)===G+"-":!1):!0}},CHILD:function(R,k,G,V,z){var te=R.slice(0,3)!=="nth",ae=R.slice(-4)!=="last",ge=k==="of-type";return V===1&&z===0?function(oe){return!!oe.parentNode}:function(oe,Re,me){var Ee,De,Ae,$e,At,at=te!==ae?"nextSibling":"previousSibling",Rt=oe.parentNode,jt=ge&&oe.nodeName.toLowerCase(),qi=!me&&!ge,ut=!1;if(Rt){if(te){for(;at;){for(Ae=oe;Ae=Ae[at];)if(ge?F(Ae,jt):Ae.nodeType===1)return!1;At=at=R==="only"&&!At&&"nextSibling"}return!0}if(At=[ae?Rt.firstChild:Rt.lastChild],ae&&qi){for(De=Rt[q]||(Rt[q]={}),Ee=De[R]||[],$e=Ee[0]===H&&Ee[1],ut=$e&&Ee[2],Ae=$e&&Rt.childNodes[$e];Ae=++$e&&Ae&&Ae[at]||(ut=$e=0)||At.pop();)if(Ae.nodeType===1&&++ut&&Ae===oe){De[R]=[H,$e,ut];break}}else if(qi&&(De=oe[q]||(oe[q]={}),Ee=De[R]||[],$e=Ee[0]===H&&Ee[1],ut=$e),ut===!1)for(;(Ae=++$e&&Ae&&Ae[at]||(ut=$e=0)||At.pop())&&!((ge?F(Ae,jt):Ae.nodeType===1)&&++ut&&(qi&&(De=Ae[q]||(Ae[q]={}),De[R]=[H,ut]),Ae===oe)););return ut-=z,ut===V||ut%V===0&&ut/V>=0}}},PSEUDO:function(R,k){var G,V=d.pseudos[R]||d.setFilters[R.toLowerCase()]||Fe.error("unsupported pseudo: "+R);return V[q]?V(k):V.length>1?(G=[R,R,"",k],d.setFilters.hasOwnProperty(R.toLowerCase())?kt(function(z,te){for(var ae,ge=V(z,k),oe=ge.length;oe--;)ae=c.call(z,ge[oe]),z[ae]=!(te[ae]=ge[oe])}):function(z){return V(z,0,G)}):V}},pseudos:{not:kt(function(R){var k=[],G=[],V=zn(R.replace(ce,"$1"));return V[q]?kt(function(z,te,ae,ge){for(var oe,Re=V(z,null,ge,[]),me=z.length;me--;)(oe=Re[me])&&(z[me]=!(te[me]=oe))}):function(z,te,ae){return k[0]=z,V(k,null,ae,G),k[0]=null,!G.pop()}}),has:kt(function(R){return function(k){return Fe(R,k).length>0}}),contains:kt(function(R){return R=R.replace(ti,ii),function(k){return(k.textContent||p.text(k)).indexOf(R)>-1}}),lang:kt(function(R){return ps.test(R||"")||Fe.error("unsupported lang: "+R),R=R.replace(ti,ii).toLowerCase(),function(k){var G;do if(G=P?k.lang:k.getAttribute("xml:lang")||k.getAttribute("lang"))return G=G.toLowerCase(),G===R||G.indexOf(R+"-")===0;while((k=k.parentNode)&&k.nodeType===1);return!1}}),target:function(R){var k=e.location&&e.location.hash;return k&&k.slice(1)===R.id},root:function(R){return R===_},focus:function(R){return R===op()&&b.hasFocus()&&!!(R.type||R.href||~R.tabIndex)},enabled:pu(!1),disabled:pu(!0),checked:function(R){return F(R,"input")&&!!R.checked||F(R,"option")&&!!R.selected},selected:function(R){return R.parentNode&&R.parentNode.selectedIndex,R.selected===!0},empty:function(R){for(R=R.firstChild;R;R=R.nextSibling)if(R.nodeType<6)return!1;return!0},parent:function(R){return!d.pseudos.empty(R)},header:function(R){return Ai.test(R.nodeName)},input:function(R){return pi.test(R.nodeName)},button:function(R){return F(R,"input")&&R.type==="button"||F(R,"button")},text:function(R){var k;return F(R,"input")&&R.type==="text"&&((k=R.getAttribute("type"))==null||k.toLowerCase()==="text")},first:Li(function(){return[0]}),last:Li(function(R,k){return[k-1]}),eq:Li(function(R,k,G){return[G<0?G+k:G]}),even:Li(function(R,k){for(var G=0;G<k;G+=2)R.push(G);return R}),odd:Li(function(R,k){for(var G=1;G<k;G+=2)R.push(G);return R}),lt:Li(function(R,k,G){var V;for(G<0?V=G+k:G>k?V=k:V=G;--V>=0;)R.push(V);return R}),gt:Li(function(R,k,G){for(var V=G<0?G+k:G;++V<k;)R.push(V);return R})}},d.pseudos.nth=d.pseudos.eq;for(l in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})d.pseudos[l]=lp(l);for(l in{submit:!0,reset:!0})d.pseudos[l]=up(l);function Au(){}Au.prototype=d.filters=d.pseudos,d.setFilters=new Au;function As(R,k){var G,V,z,te,ae,ge,oe,Re=we[R+" "];if(Re)return k?0:Re.slice(0);for(ae=R,ge=[],oe=d.preFilter;ae;){(!G||(V=We.exec(ae)))&&(V&&(ae=ae.slice(V[0].length)||ae),ge.push(z=[])),G=!1,(V=gs.exec(ae))&&(G=V.shift(),z.push({value:G,type:V[0].replace(ce," ")}),ae=ae.slice(G.length));for(te in d.filter)(V=Wt[te].exec(ae))&&(!oe[te]||(V=oe[te](V)))&&(G=V.shift(),z.push({value:G,type:te,matches:V}),ae=ae.slice(G.length));if(!G)break}return k?ae.length:ae?Fe.error(R):we(R,ge).slice(0)}function ur(R){for(var k=0,G=R.length,V="";k<G;k++)V+=R[k].value;return V}function cr(R,k,G){var V=k.dir,z=k.next,te=z||V,ae=G&&te==="parentNode",ge=Z++;return k.first?function(oe,Re,me){for(;oe=oe[V];)if(oe.nodeType===1||ae)return R(oe,Re,me);return!1}:function(oe,Re,me){var Ee,De,Ae=[H,ge];if(me){for(;oe=oe[V];)if((oe.nodeType===1||ae)&&R(oe,Re,me))return!0}else for(;oe=oe[V];)if(oe.nodeType===1||ae)if(De=oe[q]||(oe[q]={}),z&&F(oe,z))oe=oe[V]||oe;else{if((Ee=De[te])&&Ee[0]===H&&Ee[1]===ge)return Ae[2]=Ee[2];if(De[te]=Ae,Ae[2]=R(oe,Re,me))return!0}return!1}}function Yn(R){return R.length>1?function(k,G,V){for(var z=R.length;z--;)if(!R[z](k,G,V))return!1;return!0}:R[0]}function cp(R,k,G){for(var V=0,z=k.length;V<z;V++)Fe(R,k[V],G);return G}function hr(R,k,G,V,z){for(var te,ae=[],ge=0,oe=R.length,Re=k!=null;ge<oe;ge++)(te=R[ge])&&(!G||G(te,V,z))&&(ae.push(te),Re&&k.push(ge));return ae}function Wn(R,k,G,V,z,te){return V&&!V[q]&&(V=Wn(V)),z&&!z[q]&&(z=Wn(z,te)),kt(function(ae,ge,oe,Re){var me,Ee,De,Ae,$e=[],At=[],at=ge.length,Rt=ae||cp(k||"*",oe.nodeType?[oe]:oe,[]),jt=R&&(ae||!k)?hr(Rt,$e,R,oe,Re):Rt;if(G?(Ae=z||(ae?R:at||V)?[]:ge,G(jt,Ae,oe,Re)):Ae=jt,V)for(me=hr(Ae,At),V(me,[],oe,Re),Ee=me.length;Ee--;)(De=me[Ee])&&(Ae[At[Ee]]=!(jt[At[Ee]]=De));if(ae){if(z||R){if(z){for(me=[],Ee=Ae.length;Ee--;)(De=Ae[Ee])&&me.push(jt[Ee]=De);z(null,Ae=[],me,Re)}for(Ee=Ae.length;Ee--;)(De=Ae[Ee])&&(me=z?c.call(ae,De):$e[Ee])>-1&&(ae[me]=!(ge[me]=De))}}else Ae=hr(Ae===ge?Ae.splice(at,Ae.length):Ae),z?z(null,ge,Ae,Re):S.apply(ge,Ae)})}function jn(R){for(var k,G,V,z=R.length,te=d.relative[R[0].type],ae=te||d.relative[" "],ge=te?1:0,oe=cr(function(Ee){return Ee===k},ae,!0),Re=cr(function(Ee){return c.call(k,Ee)>-1},ae,!0),me=[function(Ee,De,Ae){var $e=!te&&(Ae||De!=A)||((k=De).nodeType?oe(Ee,De,Ae):Re(Ee,De,Ae));return k=null,$e}];ge<z;ge++)if(G=d.relative[R[ge].type])me=[cr(Yn(me),G)];else{if(G=d.filter[R[ge].type].apply(null,R[ge].matches),G[q]){for(V=++ge;V<z&&!d.relative[R[V].type];V++);return Wn(ge>1&&Yn(me),ge>1&&ur(R.slice(0,ge-1).concat({value:R[ge-2].type===" "?"*":""})).replace(ce,"$1"),G,ge<V&&jn(R.slice(ge,V)),V<z&&jn(R=R.slice(V)),V<z&&ur(R))}me.push(G)}return Yn(me)}function hp(R,k){var G=k.length>0,V=R.length>0,z=function(te,ae,ge,oe,Re){var me,Ee,De,Ae=0,$e="0",At=te&&[],at=[],Rt=A,jt=te||V&&d.find.TAG("*",Re),qi=H+=Rt==null?1:Math.random()||.1,ut=jt.length;for(Re&&(A=ae==b||ae||Re);$e!==ut&&(me=jt[$e])!=null;$e++){if(V&&me){for(Ee=0,!ae&&me.ownerDocument!=b&&(mi(me),ge=!P);De=R[Ee++];)if(De(me,ae||b,ge)){S.call(oe,me);break}Re&&(H=qi)}G&&((me=!De&&me)&&Ae--,te&&At.push(me))}if(Ae+=$e,G&&$e!==Ae){for(Ee=0;De=k[Ee++];)De(At,at,ae,ge);if(te){if(Ae>0)for(;$e--;)At[$e]||at[$e]||(at[$e]=O.call(oe));at=hr(at)}S.apply(oe,at),Re&&!te&&at.length>0&&Ae+k.length>1&&p.uniqueSort(oe)}return Re&&(H=qi,A=Rt),At};return G?kt(z):z}function zn(R,k){var G,V=[],z=[],te=Se[R+" "];if(!te){for(k||(k=As(R)),G=k.length;G--;)te=jn(k[G]),te[q]?V.push(te):z.push(te);te=Se(R,hp(z,V)),te.selector=R}return te}function mu(R,k,G,V){var z,te,ae,ge,oe,Re=typeof R=="function"&&R,me=!V&&As(R=Re.selector||R);if(G=G||[],me.length===1){if(te=me[0]=me[0].slice(0),te.length>2&&(ae=te[0]).type==="ID"&&k.nodeType===9&&P&&d.relative[te[1].type]){if(k=(d.find.ID(ae.matches[0].replace(ti,ii),k)||[])[0],k)Re&&(k=k.parentNode);else return G;R=R.slice(te.shift().value.length)}for(z=Wt.needsContext.test(R)?0:te.length;z--&&(ae=te[z],!d.relative[ge=ae.type]);)if((oe=d.find[ge])&&(V=oe(ae.matches[0].replace(ti,ii),Vn.test(te[0].type)&&Kn(k.parentNode)||k))){if(te.splice(z,1),R=V.length&&ur(te),!R)return S.apply(G,V),G;break}}return(Re||zn(R,me))(V,k,!P,G,!k||Vn.test(R)&&Kn(k.parentNode)||k),G}m.sortStable=q.split("").sort(et).join("")===q,mi(),m.sortDetached=zi(function(R){return R.compareDocumentPosition(b.createElement("fieldset"))&1}),p.find=Fe,p.expr[":"]=p.expr.pseudos,p.unique=p.uniqueSort,Fe.compile=zn,Fe.select=mu,Fe.setDocument=mi,Fe.tokenize=As,Fe.escape=p.escapeSelector,Fe.getText=p.text,Fe.isXML=p.isXMLDoc,Fe.selectors=p.expr,Fe.support=p.support,Fe.uniqueSort=p.uniqueSort})();var le=function(l,d,A){for(var C=[],T=A!==void 0;(l=l[d])&&l.nodeType!==9;)if(l.nodeType===1){if(T&&p(l).is(A))break;C.push(l)}return C},pe=function(l,d){for(var A=[];l;l=l.nextSibling)l.nodeType===1&&l!==d&&A.push(l);return A},J=p.expr.match.needsContext,ee=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function ve(l,d,A){return E(d)?p.grep(l,function(C,T){return!!d.call(C,T,C)!==A}):d.nodeType?p.grep(l,function(C){return C===d!==A}):typeof d!="string"?p.grep(l,function(C){return c.call(d,C)>-1!==A}):p.filter(d,l,A)}p.filter=function(l,d,A){var C=d[0];return A&&(l=":not("+l+")"),d.length===1&&C.nodeType===1?p.find.matchesSelector(C,l)?[C]:[]:p.find.matches(l,p.grep(d,function(T){return T.nodeType===1}))},p.fn.extend({find:function(l){var d,A,C=this.length,T=this;if(typeof l!="string")return this.pushStack(p(l).filter(function(){for(d=0;d<C;d++)if(p.contains(T[d],this))return!0}));for(A=this.pushStack([]),d=0;d<C;d++)p.find(l,T[d],A);return C>1?p.uniqueSort(A):A},filter:function(l){return this.pushStack(ve(this,l||[],!1))},not:function(l){return this.pushStack(ve(this,l||[],!0))},is:function(l){return!!ve(this,typeof l=="string"&&J.test(l)?p(l):l||[],!1).length}});var ke,Te=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,Le=p.fn.init=function(l,d,A){var C,T;if(!l)return this;if(A=A||ke,typeof l=="string")if(l[0]==="<"&&l[l.length-1]===">"&&l.length>=3?C=[null,l,null]:C=Te.exec(l),C&&(C[1]||!d))if(C[1]){if(d=d instanceof p?d[0]:d,p.merge(this,p.parseHTML(C[1],d&&d.nodeType?d.ownerDocument||d:x,!0)),ee.test(C[1])&&p.isPlainObject(d))for(C in d)E(this[C])?this[C](d[C]):this.attr(C,d[C]);return this}else return T=x.getElementById(C[2]),T&&(this[0]=T,this.length=1),this;else return!d||d.jquery?(d||A).find(l):this.constructor(d).find(l);else{if(l.nodeType)return this[0]=l,this.length=1,this;if(E(l))return A.ready!==void 0?A.ready(l):l(p)}return p.makeArray(l,this)};Le.prototype=p.fn,ke=p(x);var it=/^(?:parents|prev(?:Until|All))/,Je={children:!0,contents:!0,next:!0,prev:!0};p.fn.extend({has:function(l){var d=p(l,this),A=d.length;return this.filter(function(){for(var C=0;C<A;C++)if(p.contains(this,d[C]))return!0})},closest:function(l,d){var A,C=0,T=this.length,S=[],b=typeof l!="string"&&p(l);if(!J.test(l)){for(;C<T;C++)for(A=this[C];A&&A!==d;A=A.parentNode)if(A.nodeType<11&&(b?b.index(A)>-1:A.nodeType===1&&p.find.matchesSelector(A,l))){S.push(A);break}}return this.pushStack(S.length>1?p.uniqueSort(S):S)},index:function(l){return l?typeof l=="string"?c.call(p(l),this[0]):c.call(this,l.jquery?l[0]:l):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(l,d){return this.pushStack(p.uniqueSort(p.merge(this.get(),p(l,d))))},addBack:function(l){return this.add(l==null?this.prevObject:this.prevObject.filter(l))}});function lt(l,d){for(;(l=l[d])&&l.nodeType!==1;);return l}p.each({parent:function(l){var d=l.parentNode;return d&&d.nodeType!==11?d:null},parents:function(l){return le(l,"parentNode")},parentsUntil:function(l,d,A){return le(l,"parentNode",A)},next:function(l){return lt(l,"nextSibling")},prev:function(l){return lt(l,"previousSibling")},nextAll:function(l){return le(l,"nextSibling")},prevAll:function(l){return le(l,"previousSibling")},nextUntil:function(l,d,A){return le(l,"nextSibling",A)},prevUntil:function(l,d,A){return le(l,"previousSibling",A)},siblings:function(l){return pe((l.parentNode||{}).firstChild,l)},children:function(l){return pe(l.firstChild)},contents:function(l){return l.contentDocument!=null&&s(l.contentDocument)?l.contentDocument:(F(l,"template")&&(l=l.content||l),p.merge([],l.childNodes))}},function(l,d){p.fn[l]=function(A,C){var T=p.map(this,d,A);return l.slice(-5)!=="Until"&&(C=A),C&&typeof C=="string"&&(T=p.filter(C,T)),this.length>1&&(Je[l]||p.uniqueSort(T),it.test(l)&&T.reverse()),this.pushStack(T)}});var je=/[^\x20\t\r\n\f]+/g;function Qt(l){var d={};return p.each(l.match(je)||[],function(A,C){d[C]=!0}),d}p.Callbacks=function(l){l=typeof l=="string"?Qt(l):p.extend({},l);var d,A,C,T,S=[],b=[],_=-1,P=function(){for(T=T||l.once,C=d=!0;b.length;_=-1)for(A=b.shift();++_<S.length;)S[_].apply(A[0],A[1])===!1&&l.stopOnFalse&&(_=S.length,A=!1);l.memory||(A=!1),d=!1,T&&(A?S=[]:S="")},M={add:function(){return S&&(A&&!d&&(_=S.length-1,b.push(A)),(function Y(q){p.each(q,function(H,Z){E(Z)?(!l.unique||!M.has(Z))&&S.push(Z):Z&&Z.length&&w(Z)!=="string"&&Y(Z)})})(arguments),A&&!d&&P()),this},remove:function(){return p.each(arguments,function(Y,q){for(var H;(H=p.inArray(q,S,H))>-1;)S.splice(H,1),H<=_&&_--}),this},has:function(Y){return Y?p.inArray(Y,S)>-1:S.length>0},empty:function(){return S&&(S=[]),this},disable:function(){return T=b=[],S=A="",this},disabled:function(){return!S},lock:function(){return T=b=[],!A&&!d&&(S=A=""),this},locked:function(){return!!T},fireWith:function(Y,q){return T||(q=q||[],q=[Y,q.slice?q.slice():q],b.push(q),d||P()),this},fire:function(){return M.fireWith(this,arguments),this},fired:function(){return!!C}};return M};function ci(l){return l}function hi(l){throw l}function Gi(l,d,A,C){var T;try{l&&E(T=l.promise)?T.call(l).done(d).fail(A):l&&E(T=l.then)?T.call(l,d,A):d.apply(void 0,[l].slice(C))}catch(S){A.apply(void 0,[S])}}p.extend({Deferred:function(l){var d=[["notify","progress",p.Callbacks("memory"),p.Callbacks("memory"),2],["resolve","done",p.Callbacks("once memory"),p.Callbacks("once memory"),0,"resolved"],["reject","fail",p.Callbacks("once memory"),p.Callbacks("once memory"),1,"rejected"]],A="pending",C={state:function(){return A},always:function(){return T.done(arguments).fail(arguments),this},catch:function(S){return C.then(null,S)},pipe:function(){var S=arguments;return p.Deferred(function(b){p.each(d,function(_,P){var M=E(S[P[4]])&&S[P[4]];T[P[1]](function(){var Y=M&&M.apply(this,arguments);Y&&E(Y.promise)?Y.promise().progress(b.notify).done(b.resolve).fail(b.reject):b[P[0]+"With"](this,M?[Y]:arguments)})}),S=null}).promise()},then:function(S,b,_){var P=0;function M(Y,q,H,Z){return function(){var Ce=this,we=arguments,Se=function(){var et,Vt;if(!(Y<P)){if(et=H.apply(Ce,we),et===q.promise())throw new TypeError("Thenable self-resolution");Vt=et&&(typeof et=="object"||typeof et=="function")&&et.then,E(Vt)?Z?Vt.call(et,M(P,q,ci,Z),M(P,q,hi,Z)):(P++,Vt.call(et,M(P,q,ci,Z),M(P,q,hi,Z),M(P,q,ci,q.notifyWith))):(H!==ci&&(Ce=void 0,we=[et]),(Z||q.resolveWith)(Ce,we))}},nt=Z?Se:function(){try{Se()}catch(et){p.Deferred.exceptionHook&&p.Deferred.exceptionHook(et,nt.error),Y+1>=P&&(H!==hi&&(Ce=void 0,we=[et]),q.rejectWith(Ce,we))}};Y?nt():(p.Deferred.getErrorHook?nt.error=p.Deferred.getErrorHook():p.Deferred.getStackHook&&(nt.error=p.Deferred.getStackHook()),e.setTimeout(nt))}}return p.Deferred(function(Y){d[0][3].add(M(0,Y,E(_)?_:ci,Y.notifyWith)),d[1][3].add(M(0,Y,E(S)?S:ci)),d[2][3].add(M(0,Y,E(b)?b:hi))}).promise()},promise:function(S){return S!=null?p.extend(S,C):C}},T={};return p.each(d,function(S,b){var _=b[2],P=b[5];C[b[1]]=_.add,P&&_.add(function(){A=P},d[3-S][2].disable,d[3-S][3].disable,d[0][2].lock,d[0][3].lock),_.add(b[3].fire),T[b[0]]=function(){return T[b[0]+"With"](this===T?void 0:this,arguments),this},T[b[0]+"With"]=_.fireWith}),C.promise(T),l&&l.call(T,T),T},when:function(l){var d=arguments.length,A=d,C=Array(A),T=r.call(arguments),S=p.Deferred(),b=function(_){return function(P){C[_]=this,T[_]=arguments.length>1?r.call(arguments):P,--d||S.resolveWith(C,T)}};if(d<=1&&(Gi(l,S.done(b(A)).resolve,S.reject,!d),S.state()==="pending"||E(T[A]&&T[A].then)))return S.then();for(;A--;)Gi(T[A],b(A),S.reject);return S.promise()}});var Ul=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;p.Deferred.exceptionHook=function(l,d){e.console&&e.console.warn&&l&&Ul.test(l.name)&&e.console.warn("jQuery.Deferred exception: "+l.message,l.stack,d)},p.readyException=function(l){e.setTimeout(function(){throw l})};var Pe=p.Deferred();p.fn.ready=function(l){return Pe.then(l).catch(function(d){p.readyException(d)}),this},p.extend({isReady:!1,readyWait:1,ready:function(l){(l===!0?--p.readyWait:p.isReady)||(p.isReady=!0,!(l!==!0&&--p.readyWait>0)&&Pe.resolveWith(x,[p]))}}),p.ready.then=Pe.then;function ze(){x.removeEventListener("DOMContentLoaded",ze),e.removeEventListener("load",ze),p.ready()}x.readyState==="complete"||x.readyState!=="loading"&&!x.documentElement.doScroll?e.setTimeout(p.ready):(x.addEventListener("DOMContentLoaded",ze),e.addEventListener("load",ze));var Ye=function(l,d,A,C,T,S,b){var _=0,P=l.length,M=A==null;if(w(A)==="object"){T=!0;for(_ in A)Ye(l,d,_,A[_],!0,S,b)}else if(C!==void 0&&(T=!0,E(C)||(b=!0),M&&(b?(d.call(l,C),d=null):(M=d,d=function(Y,q,H){return M.call(p(Y),H)})),d))for(;_<P;_++)d(l[_],A,b?C:C.call(l[_],_,d(l[_],A)));return T?l:M?d.call(l):P?d(l[0],A):S},Jt=/^-ms-/,vt=/-([a-z])/g;function di(l,d){return d.toUpperCase()}function st(l){return l.replace(Jt,"ms-").replace(vt,di)}var fi=function(l){return l.nodeType===1||l.nodeType===9||!+l.nodeType};function Ht(){this.expando=p.expando+Ht.uid++}Ht.uid=1,Ht.prototype={cache:function(l){var d=l[this.expando];return d||(d={},fi(l)&&(l.nodeType?l[this.expando]=d:Object.defineProperty(l,this.expando,{value:d,configurable:!0}))),d},set:function(l,d,A){var C,T=this.cache(l);if(typeof d=="string")T[st(d)]=A;else for(C in d)T[st(C)]=d[C];return T},get:function(l,d){return d===void 0?this.cache(l):l[this.expando]&&l[this.expando][st(d)]},access:function(l,d,A){return d===void 0||d&&typeof d=="string"&&A===void 0?this.get(l,d):(this.set(l,d,A),A!==void 0?A:d)},remove:function(l,d){var A,C=l[this.expando];if(C!==void 0){if(d!==void 0)for(Array.isArray(d)?d=d.map(st):(d=st(d),d=d in C?[d]:d.match(je)||[]),A=d.length;A--;)delete C[d[A]];(d===void 0||p.isEmptyObject(C))&&(l.nodeType?l[this.expando]=void 0:delete l[this.expando])}},hasData:function(l){var d=l[this.expando];return d!==void 0&&!p.isEmptyObject(d)}};var fe=new Ht,Xe=new Ht,tr=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,Ln=/[A-Z]/g;function ir(l){return l==="true"?!0:l==="false"?!1:l==="null"?null:l===+l+""?+l:tr.test(l)?JSON.parse(l):l}function os(l,d,A){var C;if(A===void 0&&l.nodeType===1)if(C="data-"+d.replace(Ln,"-$&").toLowerCase(),A=l.getAttribute(C),typeof A=="string"){try{A=ir(A)}catch{}Xe.set(l,d,A)}else A=void 0;return A}p.extend({hasData:function(l){return Xe.hasData(l)||fe.hasData(l)},data:function(l,d,A){return Xe.access(l,d,A)},removeData:function(l,d){Xe.remove(l,d)},_data:function(l,d,A){return fe.access(l,d,A)},_removeData:function(l,d){fe.remove(l,d)}}),p.fn.extend({data:function(l,d){var A,C,T,S=this[0],b=S&&S.attributes;if(l===void 0){if(this.length&&(T=Xe.get(S),S.nodeType===1&&!fe.get(S,"hasDataAttrs"))){for(A=b.length;A--;)b[A]&&(C=b[A].name,C.indexOf("data-")===0&&(C=st(C.slice(5)),os(S,C,T[C])));fe.set(S,"hasDataAttrs",!0)}return T}return typeof l=="object"?this.each(function(){Xe.set(this,l)}):Ye(this,function(_){var P;if(S&&_===void 0)return P=Xe.get(S,l),P!==void 0||(P=os(S,l),P!==void 0)?P:void 0;this.each(function(){Xe.set(this,l,_)})},null,d,arguments.length>1,null,!0)},removeData:function(l){return this.each(function(){Xe.remove(this,l)})}}),p.extend({queue:function(l,d,A){var C;if(l)return d=(d||"fx")+"queue",C=fe.get(l,d),A&&(!C||Array.isArray(A)?C=fe.access(l,d,p.makeArray(A)):C.push(A)),C||[]},dequeue:function(l,d){d=d||"fx";var A=p.queue(l,d),C=A.length,T=A.shift(),S=p._queueHooks(l,d),b=function(){p.dequeue(l,d)};T==="inprogress"&&(T=A.shift(),C--),T&&(d==="fx"&&A.unshift("inprogress"),delete S.stop,T.call(l,b,S)),!C&&S&&S.empty.fire()},_queueHooks:function(l,d){var A=d+"queueHooks";return fe.get(l,A)||fe.access(l,A,{empty:p.Callbacks("once memory").add(function(){fe.remove(l,[d+"queue",A])})})}}),p.fn.extend({queue:function(l,d){var A=2;return typeof l!="string"&&(d=l,l="fx",A--),arguments.length<A?p.queue(this[0],l):d===void 0?this:this.each(function(){var C=p.queue(this,l,d);p._queueHooks(this,l),l==="fx"&&C[0]!=="inprogress"&&p.dequeue(this,l)})},dequeue:function(l){return this.each(function(){p.dequeue(this,l)})},clearQueue:function(l){return this.queue(l||"fx",[])},promise:function(l,d){var A,C=1,T=p.Deferred(),S=this,b=this.length,_=function(){--C||T.resolveWith(S,[S])};for(typeof l!="string"&&(d=l,l=void 0),l=l||"fx";b--;)A=fe.get(S[b],l+"queueHooks"),A&&A.empty&&(C++,A.empty.add(_));return _(),T.promise(d)}});var gi=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,ls=new RegExp("^(?:([+-])=|)("+gi+")([a-z%]*)$","i"),ei=["Top","Right","Bottom","Left"],Ti=x.documentElement,Hi=function(l){return p.contains(l.ownerDocument,l)},Tg={composed:!0};Ti.getRootNode&&(Hi=function(l){return p.contains(l.ownerDocument,l)||l.getRootNode(Tg)===l.ownerDocument});var sr=function(l,d){return l=d||l,l.style.display==="none"||l.style.display===""&&Hi(l)&&p.css(l,"display")==="none"};function $l(l,d,A,C){var T,S,b=20,_=C?function(){return C.cur()}:function(){return p.css(l,d,"")},P=_(),M=A&&A[3]||(p.cssNumber[d]?"":"px"),Y=l.nodeType&&(p.cssNumber[d]||M!=="px"&&+P)&&ls.exec(p.css(l,d));if(Y&&Y[3]!==M){for(P=P/2,M=M||Y[3],Y=+P||1;b--;)p.style(l,d,Y+M),(1-S)*(1-(S=_()/P||.5))<=0&&(b=0),Y=Y/S;Y=Y*2,p.style(l,d,Y+M),A=A||[]}return A&&(Y=+Y||+P||0,T=A[1]?Y+(A[1]+1)*A[2]:+A[2],C&&(C.unit=M,C.start=Y,C.end=T)),T}var Gl={};function Sg(l){var d,A=l.ownerDocument,C=l.nodeName,T=Gl[C];return T||(d=A.body.appendChild(A.createElement(C)),T=p.css(d,"display"),d.parentNode.removeChild(d),T==="none"&&(T="block"),Gl[C]=T,T)}function Vi(l,d){for(var A,C,T=[],S=0,b=l.length;S<b;S++)C=l[S],C.style&&(A=C.style.display,d?(A==="none"&&(T[S]=fe.get(C,"display")||null,T[S]||(C.style.display="")),C.style.display===""&&sr(C)&&(T[S]=Sg(C))):A!=="none"&&(T[S]="none",fe.set(C,"display",A)));for(S=0;S<b;S++)T[S]!=null&&(l[S].style.display=T[S]);return l}p.fn.extend({show:function(){return Vi(this,!0)},hide:function(){return Vi(this)},toggle:function(l){return typeof l=="boolean"?l?this.show():this.hide():this.each(function(){sr(this)?p(this).show():p(this).hide()})}});var us=/^(?:checkbox|radio)$/i,Hl=/<([a-z][^\/\0>\x20\t\r\n\f]*)/i,Vl=/^$|^module$|\/(?:java|ecma)script/i;(function(){var l=x.createDocumentFragment(),d=l.appendChild(x.createElement("div")),A=x.createElement("input");A.setAttribute("type","radio"),A.setAttribute("checked","checked"),A.setAttribute("name","t"),d.appendChild(A),m.checkClone=d.cloneNode(!0).cloneNode(!0).lastChild.checked,d.innerHTML="<textarea>x</textarea>",m.noCloneChecked=!!d.cloneNode(!0).lastChild.defaultValue,d.innerHTML="<option></option>",m.option=!!d.lastChild})();var bt={thead:[1,"<table>","</table>"],col:[2,"<table><colgroup>","</colgroup></table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:[0,"",""]};bt.tbody=bt.tfoot=bt.colgroup=bt.caption=bt.thead,bt.th=bt.td,m.option||(bt.optgroup=bt.option=[1,"<select multiple='multiple'>","</select>"]);function gt(l,d){var A;return typeof l.getElementsByTagName<"u"?A=l.getElementsByTagName(d||"*"):typeof l.querySelectorAll<"u"?A=l.querySelectorAll(d||"*"):A=[],d===void 0||d&&F(l,d)?p.merge([l],A):A}function Rn(l,d){for(var A=0,C=l.length;A<C;A++)fe.set(l[A],"globalEval",!d||fe.get(d[A],"globalEval"))}var xg=/<|&#?\w+;/;function Kl(l,d,A,C,T){for(var S,b,_,P,M,Y,q=d.createDocumentFragment(),H=[],Z=0,Ce=l.length;Z<Ce;Z++)if(S=l[Z],S||S===0)if(w(S)==="object")p.merge(H,S.nodeType?[S]:S);else if(!xg.test(S))H.push(d.createTextNode(S));else{for(b=b||q.appendChild(d.createElement("div")),_=(Hl.exec(S)||["",""])[1].toLowerCase(),P=bt[_]||bt._default,b.innerHTML=P[1]+p.htmlPrefilter(S)+P[2],Y=P[0];Y--;)b=b.lastChild;p.merge(H,b.childNodes),b=q.firstChild,b.textContent=""}for(q.textContent="",Z=0;S=H[Z++];){if(C&&p.inArray(S,C)>-1){T&&T.push(S);continue}if(M=Hi(S),b=gt(q.appendChild(S),"script"),M&&Rn(b),A)for(Y=0;S=b[Y++];)Vl.test(S.type||"")&&A.push(S)}return q}var Yl=/^([^.]*)(?:\.(.+)|)/;function Ki(){return!0}function Yi(){return!1}function Dn(l,d,A,C,T,S){var b,_;if(typeof d=="object"){typeof A!="string"&&(C=C||A,A=void 0);for(_ in d)Dn(l,_,A,C,d[_],S);return l}if(C==null&&T==null?(T=A,C=A=void 0):T==null&&(typeof A=="string"?(T=C,C=void 0):(T=C,C=A,A=void 0)),T===!1)T=Yi;else if(!T)return l;return S===1&&(b=T,T=function(P){return p().off(P),b.apply(this,arguments)},T.guid=b.guid||(b.guid=p.guid++)),l.each(function(){p.event.add(this,d,T,C,A)})}p.event={global:{},add:function(l,d,A,C,T){var S,b,_,P,M,Y,q,H,Z,Ce,we,Se=fe.get(l);if(fi(l))for(A.handler&&(S=A,A=S.handler,T=S.selector),T&&p.find.matchesSelector(Ti,T),A.guid||(A.guid=p.guid++),(P=Se.events)||(P=Se.events=Object.create(null)),(b=Se.handle)||(b=Se.handle=function(nt){return typeof p<"u"&&p.event.triggered!==nt.type?p.event.dispatch.apply(l,arguments):void 0}),d=(d||"").match(je)||[""],M=d.length;M--;)_=Yl.exec(d[M])||[],Z=we=_[1],Ce=(_[2]||"").split(".").sort(),Z&&(q=p.event.special[Z]||{},Z=(T?q.delegateType:q.bindType)||Z,q=p.event.special[Z]||{},Y=p.extend({type:Z,origType:we,data:C,handler:A,guid:A.guid,selector:T,needsContext:T&&p.expr.match.needsContext.test(T),namespace:Ce.join(".")},S),(H=P[Z])||(H=P[Z]=[],H.delegateCount=0,(!q.setup||q.setup.call(l,C,Ce,b)===!1)&&l.addEventListener&&l.addEventListener(Z,b)),q.add&&(q.add.call(l,Y),Y.handler.guid||(Y.handler.guid=A.guid)),T?H.splice(H.delegateCount++,0,Y):H.push(Y),p.event.global[Z]=!0)},remove:function(l,d,A,C,T){var S,b,_,P,M,Y,q,H,Z,Ce,we,Se=fe.hasData(l)&&fe.get(l);if(!(!Se||!(P=Se.events))){for(d=(d||"").match(je)||[""],M=d.length;M--;){if(_=Yl.exec(d[M])||[],Z=we=_[1],Ce=(_[2]||"").split(".").sort(),!Z){for(Z in P)p.event.remove(l,Z+d[M],A,C,!0);continue}for(q=p.event.special[Z]||{},Z=(C?q.delegateType:q.bindType)||Z,H=P[Z]||[],_=_[2]&&new RegExp("(^|\\.)"+Ce.join("\\.(?:.*\\.|)")+"(\\.|$)"),b=S=H.length;S--;)Y=H[S],(T||we===Y.origType)&&(!A||A.guid===Y.guid)&&(!_||_.test(Y.namespace))&&(!C||C===Y.selector||C==="**"&&Y.selector)&&(H.splice(S,1),Y.selector&&H.delegateCount--,q.remove&&q.remove.call(l,Y));b&&!H.length&&((!q.teardown||q.teardown.call(l,Ce,Se.handle)===!1)&&p.removeEvent(l,Z,Se.handle),delete P[Z])}p.isEmptyObject(P)&&fe.remove(l,"handle events")}},dispatch:function(l){var d,A,C,T,S,b,_=new Array(arguments.length),P=p.event.fix(l),M=(fe.get(this,"events")||Object.create(null))[P.type]||[],Y=p.event.special[P.type]||{};for(_[0]=P,d=1;d<arguments.length;d++)_[d]=arguments[d];if(P.delegateTarget=this,!(Y.preDispatch&&Y.preDispatch.call(this,P)===!1)){for(b=p.event.handlers.call(this,P,M),d=0;(T=b[d++])&&!P.isPropagationStopped();)for(P.currentTarget=T.elem,A=0;(S=T.handlers[A++])&&!P.isImmediatePropagationStopped();)(!P.rnamespace||S.namespace===!1||P.rnamespace.test(S.namespace))&&(P.handleObj=S,P.data=S.data,C=((p.event.special[S.origType]||{}).handle||S.handler).apply(T.elem,_),C!==void 0&&(P.result=C)===!1&&(P.preventDefault(),P.stopPropagation()));return Y.postDispatch&&Y.postDispatch.call(this,P),P.result}},handlers:function(l,d){var A,C,T,S,b,_=[],P=d.delegateCount,M=l.target;if(P&&M.nodeType&&!(l.type==="click"&&l.button>=1)){for(;M!==this;M=M.parentNode||this)if(M.nodeType===1&&!(l.type==="click"&&M.disabled===!0)){for(S=[],b={},A=0;A<P;A++)C=d[A],T=C.selector+" ",b[T]===void 0&&(b[T]=C.needsContext?p(T,this).index(M)>-1:p.find(T,this,null,[M]).length),b[T]&&S.push(C);S.length&&_.push({elem:M,handlers:S})}}return M=this,P<d.length&&_.push({elem:M,handlers:d.slice(P)}),_},addProp:function(l,d){Object.defineProperty(p.Event.prototype,l,{enumerable:!0,configurable:!0,get:E(d)?function(){if(this.originalEvent)return d(this.originalEvent)}:function(){if(this.originalEvent)return this.originalEvent[l]},set:function(A){Object.defineProperty(this,l,{enumerable:!0,configurable:!0,writable:!0,value:A})}})},fix:function(l){return l[p.expando]?l:new p.Event(l)},special:{load:{noBubble:!0},click:{setup:function(l){var d=this||l;return us.test(d.type)&&d.click&&F(d,"input")&&rr(d,"click",!0),!1},trigger:function(l){var d=this||l;return us.test(d.type)&&d.click&&F(d,"input")&&rr(d,"click"),!0},_default:function(l){var d=l.target;return us.test(d.type)&&d.click&&F(d,"input")&&fe.get(d,"click")||F(d,"a")}},beforeunload:{postDispatch:function(l){l.result!==void 0&&l.originalEvent&&(l.originalEvent.returnValue=l.result)}}}};function rr(l,d,A){if(!A){fe.get(l,d)===void 0&&p.event.add(l,d,Ki);return}fe.set(l,d,!1),p.event.add(l,d,{namespace:!1,handler:function(C){var T,S=fe.get(this,d);if(C.isTrigger&1&&this[d]){if(S)(p.event.special[d]||{}).delegateType&&C.stopPropagation();else if(S=r.call(arguments),fe.set(this,d,S),this[d](),T=fe.get(this,d),fe.set(this,d,!1),S!==T)return C.stopImmediatePropagation(),C.preventDefault(),T}else S&&(fe.set(this,d,p.event.trigger(S[0],S.slice(1),this)),C.stopPropagation(),C.isImmediatePropagationStopped=Ki)}})}p.removeEvent=function(l,d,A){l.removeEventListener&&l.removeEventListener(d,A)},p.Event=function(l,d){if(!(this instanceof p.Event))return new p.Event(l,d);l&&l.type?(this.originalEvent=l,this.type=l.type,this.isDefaultPrevented=l.defaultPrevented||l.defaultPrevented===void 0&&l.returnValue===!1?Ki:Yi,this.target=l.target&&l.target.nodeType===3?l.target.parentNode:l.target,this.currentTarget=l.currentTarget,this.relatedTarget=l.relatedTarget):this.type=l,d&&p.extend(this,d),this.timeStamp=l&&l.timeStamp||Date.now(),this[p.expando]=!0},p.Event.prototype={constructor:p.Event,isDefaultPrevented:Yi,isPropagationStopped:Yi,isImmediatePropagationStopped:Yi,isSimulated:!1,preventDefault:function(){var l=this.originalEvent;this.isDefaultPrevented=Ki,l&&!this.isSimulated&&l.preventDefault()},stopPropagation:function(){var l=this.originalEvent;this.isPropagationStopped=Ki,l&&!this.isSimulated&&l.stopPropagation()},stopImmediatePropagation:function(){var l=this.originalEvent;this.isImmediatePropagationStopped=Ki,l&&!this.isSimulated&&l.stopImmediatePropagation(),this.stopPropagation()}},p.each({altKey:!0,bubbles:!0,cancelable:!0,changedTouches:!0,ctrlKey:!0,detail:!0,eventPhase:!0,metaKey:!0,pageX:!0,pageY:!0,shiftKey:!0,view:!0,char:!0,code:!0,charCode:!0,key:!0,keyCode:!0,button:!0,buttons:!0,clientX:!0,clientY:!0,offsetX:!0,offsetY:!0,pointerId:!0,pointerType:!0,screenX:!0,screenY:!0,targetTouches:!0,toElement:!0,touches:!0,which:!0},p.event.addProp),p.each({focus:"focusin",blur:"focusout"},function(l,d){function A(C){if(x.documentMode){var T=fe.get(this,"handle"),S=p.event.fix(C);S.type=C.type==="focusin"?"focus":"blur",S.isSimulated=!0,T(C),S.target===S.currentTarget&&T(S)}else p.event.simulate(d,C.target,p.event.fix(C))}p.event.special[l]={setup:function(){var C;if(rr(this,l,!0),x.documentMode)C=fe.get(this,d),C||this.addEventListener(d,A),fe.set(this,d,(C||0)+1);else return!1},trigger:function(){return rr(this,l),!0},teardown:function(){var C;if(x.documentMode)C=fe.get(this,d)-1,C?fe.set(this,d,C):(this.removeEventListener(d,A),fe.remove(this,d));else return!1},_default:function(C){return fe.get(C.target,l)},delegateType:d},p.event.special[d]={setup:function(){var C=this.ownerDocument||this.document||this,T=x.documentMode?this:C,S=fe.get(T,d);S||(x.documentMode?this.addEventListener(d,A):C.addEventListener(l,A,!0)),fe.set(T,d,(S||0)+1)},teardown:function(){var C=this.ownerDocument||this.document||this,T=x.documentMode?this:C,S=fe.get(T,d)-1;S?fe.set(T,d,S):(x.documentMode?this.removeEventListener(d,A):C.removeEventListener(l,A,!0),fe.remove(T,d))}}}),p.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(l,d){p.event.special[l]={delegateType:d,bindType:d,handle:function(A){var C,T=this,S=A.relatedTarget,b=A.handleObj;return(!S||S!==T&&!p.contains(T,S))&&(A.type=b.origType,C=b.handler.apply(this,arguments),A.type=d),C}}}),p.fn.extend({on:function(l,d,A,C){return Dn(this,l,d,A,C)},one:function(l,d,A,C){return Dn(this,l,d,A,C,1)},off:function(l,d,A){var C,T;if(l&&l.preventDefault&&l.handleObj)return C=l.handleObj,p(l.delegateTarget).off(C.namespace?C.origType+"."+C.namespace:C.origType,C.selector,C.handler),this;if(typeof l=="object"){for(T in l)this.off(T,d,l[T]);return this}return(d===!1||typeof d=="function")&&(A=d,d=void 0),A===!1&&(A=Yi),this.each(function(){p.event.remove(this,l,A,d)})}});var bg=/<script|<style|<link/i,Lg=/checked\s*(?:[^=]|=\s*.checked.)/i,Rg=/^\s*<!\[CDATA\[|\]\]>\s*$/g;function Wl(l,d){return F(l,"table")&&F(d.nodeType!==11?d:d.firstChild,"tr")&&p(l).children("tbody")[0]||l}function Dg(l){return l.type=(l.getAttribute("type")!==null)+"/"+l.type,l}function Pg(l){return(l.type||"").slice(0,5)==="true/"?l.type=l.type.slice(5):l.removeAttribute("type"),l}function jl(l,d){var A,C,T,S,b,_,P;if(d.nodeType===1){if(fe.hasData(l)&&(S=fe.get(l),P=S.events,P)){fe.remove(d,"handle events");for(T in P)for(A=0,C=P[T].length;A<C;A++)p.event.add(d,T,P[T][A])}Xe.hasData(l)&&(b=Xe.access(l),_=p.extend({},b),Xe.set(d,_))}}function _g(l,d){var A=d.nodeName.toLowerCase();A==="input"&&us.test(l.type)?d.checked=l.checked:(A==="input"||A==="textarea")&&(d.defaultValue=l.defaultValue)}function Wi(l,d,A,C){d=n(d);var T,S,b,_,P,M,Y=0,q=l.length,H=q-1,Z=d[0],Ce=E(Z);if(Ce||q>1&&typeof Z=="string"&&!m.checkClone&&Lg.test(Z))return l.each(function(we){var Se=l.eq(we);Ce&&(d[0]=Z.call(this,we,Se.html())),Wi(Se,d,A,C)});if(q&&(T=Kl(d,l[0].ownerDocument,!1,l,C),S=T.firstChild,T.childNodes.length===1&&(T=S),S||C)){for(b=p.map(gt(T,"script"),Dg),_=b.length;Y<q;Y++)P=T,Y!==H&&(P=p.clone(P,!0,!0),_&&p.merge(b,gt(P,"script"))),A.call(l[Y],P,Y);if(_)for(M=b[b.length-1].ownerDocument,p.map(b,Pg),Y=0;Y<_;Y++)P=b[Y],Vl.test(P.type||"")&&!fe.access(P,"globalEval")&&p.contains(M,P)&&(P.src&&(P.type||"").toLowerCase()!=="module"?p._evalUrl&&!P.noModule&&p._evalUrl(P.src,{nonce:P.nonce||P.getAttribute("nonce")},M):L(P.textContent.replace(Rg,""),P,M))}return l}function zl(l,d,A){for(var C,T=d?p.filter(d,l):l,S=0;(C=T[S])!=null;S++)!A&&C.nodeType===1&&p.cleanData(gt(C)),C.parentNode&&(A&&Hi(C)&&Rn(gt(C,"script")),C.parentNode.removeChild(C));return l}p.extend({htmlPrefilter:function(l){return l},clone:function(l,d,A){var C,T,S,b,_=l.cloneNode(!0),P=Hi(l);if(!m.noCloneChecked&&(l.nodeType===1||l.nodeType===11)&&!p.isXMLDoc(l))for(b=gt(_),S=gt(l),C=0,T=S.length;C<T;C++)_g(S[C],b[C]);if(d)if(A)for(S=S||gt(l),b=b||gt(_),C=0,T=S.length;C<T;C++)jl(S[C],b[C]);else jl(l,_);return b=gt(_,"script"),b.length>0&&Rn(b,!P&&gt(l,"script")),_},cleanData:function(l){for(var d,A,C,T=p.event.special,S=0;(A=l[S])!==void 0;S++)if(fi(A)){if(d=A[fe.expando]){if(d.events)for(C in d.events)T[C]?p.event.remove(A,C):p.removeEvent(A,C,d.handle);A[fe.expando]=void 0}A[Xe.expando]&&(A[Xe.expando]=void 0)}}}),p.fn.extend({detach:function(l){return zl(this,l,!0)},remove:function(l){return zl(this,l)},text:function(l){return Ye(this,function(d){return d===void 0?p.text(this):this.empty().each(function(){(this.nodeType===1||this.nodeType===11||this.nodeType===9)&&(this.textContent=d)})},null,l,arguments.length)},append:function(){return Wi(this,arguments,function(l){if(this.nodeType===1||this.nodeType===11||this.nodeType===9){var d=Wl(this,l);d.appendChild(l)}})},prepend:function(){return Wi(this,arguments,function(l){if(this.nodeType===1||this.nodeType===11||this.nodeType===9){var d=Wl(this,l);d.insertBefore(l,d.firstChild)}})},before:function(){return Wi(this,arguments,function(l){this.parentNode&&this.parentNode.insertBefore(l,this)})},after:function(){return Wi(this,arguments,function(l){this.parentNode&&this.parentNode.insertBefore(l,this.nextSibling)})},empty:function(){for(var l,d=0;(l=this[d])!=null;d++)l.nodeType===1&&(p.cleanData(gt(l,!1)),l.textContent="");return this},clone:function(l,d){return l=l??!1,d=d??l,this.map(function(){return p.clone(this,l,d)})},html:function(l){return Ye(this,function(d){var A=this[0]||{},C=0,T=this.length;if(d===void 0&&A.nodeType===1)return A.innerHTML;if(typeof d=="string"&&!bg.test(d)&&!bt[(Hl.exec(d)||["",""])[1].toLowerCase()]){d=p.htmlPrefilter(d);try{for(;C<T;C++)A=this[C]||{},A.nodeType===1&&(p.cleanData(gt(A,!1)),A.innerHTML=d);A=0}catch{}}A&&this.empty().append(d)},null,l,arguments.length)},replaceWith:function(){var l=[];return Wi(this,arguments,function(d){var A=this.parentNode;p.inArray(this,l)<0&&(p.cleanData(gt(this)),A&&A.replaceChild(d,this))},l)}}),p.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(l,d){p.fn[l]=function(A){for(var C,T=[],S=p(A),b=S.length-1,_=0;_<=b;_++)C=_===b?this:this.clone(!0),p(S[_])[d](C),o.apply(T,C.get());return this.pushStack(T)}});var Pn=new RegExp("^("+gi+")(?!px)[a-z%]+$","i"),_n=/^--/,nr=function(l){var d=l.ownerDocument.defaultView;return(!d||!d.opener)&&(d=e),d.getComputedStyle(l)},ql=function(l,d,A){var C,T,S={};for(T in d)S[T]=l.style[T],l.style[T]=d[T];C=A.call(l);for(T in d)l.style[T]=S[T];return C},wg=new RegExp(ei.join("|"),"i");(function(){function l(){if(M){P.style.cssText="position:absolute;left:-11111px;width:60px;margin-top:1px;padding:0;border:0",M.style.cssText="position:relative;display:block;box-sizing:border-box;overflow:scroll;margin:auto;border:1px;padding:1px;width:60%;top:1%",Ti.appendChild(P).appendChild(M);var Y=e.getComputedStyle(M);A=Y.top!=="1%",_=d(Y.marginLeft)===12,M.style.right="60%",S=d(Y.right)===36,C=d(Y.width)===36,M.style.position="absolute",T=d(M.offsetWidth/3)===12,Ti.removeChild(P),M=null}}function d(Y){return Math.round(parseFloat(Y))}var A,C,T,S,b,_,P=x.createElement("div"),M=x.createElement("div");M.style&&(M.style.backgroundClip="content-box",M.cloneNode(!0).style.backgroundClip="",m.clearCloneStyle=M.style.backgroundClip==="content-box",p.extend(m,{boxSizingReliable:function(){return l(),C},pixelBoxStyles:function(){return l(),S},pixelPosition:function(){return l(),A},reliableMarginLeft:function(){return l(),_},scrollboxSize:function(){return l(),T},reliableTrDimensions:function(){var Y,q,H,Z;return b==null&&(Y=x.createElement("table"),q=x.createElement("tr"),H=x.createElement("div"),Y.style.cssText="position:absolute;left:-11111px;border-collapse:separate",q.style.cssText="box-sizing:content-box;border:1px solid",q.style.height="1px",H.style.height="9px",H.style.display="block",Ti.appendChild(Y).appendChild(q).appendChild(H),Z=e.getComputedStyle(q),b=parseInt(Z.height,10)+parseInt(Z.borderTopWidth,10)+parseInt(Z.borderBottomWidth,10)===q.offsetHeight,Ti.removeChild(Y)),b}}))})();function cs(l,d,A){var C,T,S,b,_=_n.test(d),P=l.style;return A=A||nr(l),A&&(b=A.getPropertyValue(d)||A[d],_&&b&&(b=b.replace(ce,"$1")||void 0),b===""&&!Hi(l)&&(b=p.style(l,d)),!m.pixelBoxStyles()&&Pn.test(b)&&wg.test(d)&&(C=P.width,T=P.minWidth,S=P.maxWidth,P.minWidth=P.maxWidth=P.width=b,b=A.width,P.width=C,P.minWidth=T,P.maxWidth=S)),b!==void 0?b+"":b}function Xl(l,d){return{get:function(){if(l()){delete this.get;return}return(this.get=d).apply(this,arguments)}}}var Zl=["Webkit","Moz","ms"],Ql=x.createElement("div").style,Jl={};function kg(l){for(var d=l[0].toUpperCase()+l.slice(1),A=Zl.length;A--;)if(l=Zl[A]+d,l in Ql)return l}function wn(l){var d=p.cssProps[l]||Jl[l];return d||(l in Ql?l:Jl[l]=kg(l)||l)}var Mg=/^(none|table(?!-c[ea]).+)/,Og={position:"absolute",visibility:"hidden",display:"block"},eu={letterSpacing:"0",fontWeight:"400"};function tu(l,d,A){var C=ls.exec(d);return C?Math.max(0,C[2]-(A||0))+(C[3]||"px"):d}function kn(l,d,A,C,T,S){var b=d==="width"?1:0,_=0,P=0,M=0;if(A===(C?"border":"content"))return 0;for(;b<4;b+=2)A==="margin"&&(M+=p.css(l,A+ei[b],!0,T)),C?(A==="content"&&(P-=p.css(l,"padding"+ei[b],!0,T)),A!=="margin"&&(P-=p.css(l,"border"+ei[b]+"Width",!0,T))):(P+=p.css(l,"padding"+ei[b],!0,T),A!=="padding"?P+=p.css(l,"border"+ei[b]+"Width",!0,T):_+=p.css(l,"border"+ei[b]+"Width",!0,T));return!C&&S>=0&&(P+=Math.max(0,Math.ceil(l["offset"+d[0].toUpperCase()+d.slice(1)]-S-P-_-.5))||0),P+M}function iu(l,d,A){var C=nr(l),T=!m.boxSizingReliable()||A,S=T&&p.css(l,"boxSizing",!1,C)==="border-box",b=S,_=cs(l,d,C),P="offset"+d[0].toUpperCase()+d.slice(1);if(Pn.test(_)){if(!A)return _;_="auto"}return(!m.boxSizingReliable()&&S||!m.reliableTrDimensions()&&F(l,"tr")||_==="auto"||!parseFloat(_)&&p.css(l,"display",!1,C)==="inline")&&l.getClientRects().length&&(S=p.css(l,"boxSizing",!1,C)==="border-box",b=P in l,b&&(_=l[P])),_=parseFloat(_)||0,_+kn(l,d,A||(S?"border":"content"),b,C,_)+"px"}p.extend({cssHooks:{opacity:{get:function(l,d){if(d){var A=cs(l,"opacity");return A===""?"1":A}}}},cssNumber:{animationIterationCount:!0,aspectRatio:!0,borderImageSlice:!0,columnCount:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,gridArea:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnStart:!0,gridRow:!0,gridRowEnd:!0,gridRowStart:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,scale:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeMiterlimit:!0,strokeOpacity:!0},cssProps:{},style:function(l,d,A,C){if(!(!l||l.nodeType===3||l.nodeType===8||!l.style)){var T,S,b,_=st(d),P=_n.test(d),M=l.style;if(P||(d=wn(_)),b=p.cssHooks[d]||p.cssHooks[_],A!==void 0){if(S=typeof A,S==="string"&&(T=ls.exec(A))&&T[1]&&(A=$l(l,d,T),S="number"),A==null||A!==A)return;S==="number"&&!P&&(A+=T&&T[3]||(p.cssNumber[_]?"":"px")),!m.clearCloneStyle&&A===""&&d.indexOf("background")===0&&(M[d]="inherit"),(!b||!("set"in b)||(A=b.set(l,A,C))!==void 0)&&(P?M.setProperty(d,A):M[d]=A)}else return b&&"get"in b&&(T=b.get(l,!1,C))!==void 0?T:M[d]}},css:function(l,d,A,C){var T,S,b,_=st(d),P=_n.test(d);return P||(d=wn(_)),b=p.cssHooks[d]||p.cssHooks[_],b&&"get"in b&&(T=b.get(l,!0,A)),T===void 0&&(T=cs(l,d,C)),T==="normal"&&d in eu&&(T=eu[d]),A===""||A?(S=parseFloat(T),A===!0||isFinite(S)?S||0:T):T}}),p.each(["height","width"],function(l,d){p.cssHooks[d]={get:function(A,C,T){if(C)return Mg.test(p.css(A,"display"))&&(!A.getClientRects().length||!A.getBoundingClientRect().width)?ql(A,Og,function(){return iu(A,d,T)}):iu(A,d,T)},set:function(A,C,T){var S,b=nr(A),_=!m.scrollboxSize()&&b.position==="absolute",P=_||T,M=P&&p.css(A,"boxSizing",!1,b)==="border-box",Y=T?kn(A,d,T,M,b):0;return M&&_&&(Y-=Math.ceil(A["offset"+d[0].toUpperCase()+d.slice(1)]-parseFloat(b[d])-kn(A,d,"border",!1,b)-.5)),Y&&(S=ls.exec(C))&&(S[3]||"px")!=="px"&&(A.style[d]=C,C=p.css(A,d)),tu(A,C,Y)}}}),p.cssHooks.marginLeft=Xl(m.reliableMarginLeft,function(l,d){if(d)return(parseFloat(cs(l,"marginLeft"))||l.getBoundingClientRect().left-ql(l,{marginLeft:0},function(){return l.getBoundingClientRect().left}))+"px"}),p.each({margin:"",padding:"",border:"Width"},function(l,d){p.cssHooks[l+d]={expand:function(A){for(var C=0,T={},S=typeof A=="string"?A.split(" "):[A];C<4;C++)T[l+ei[C]+d]=S[C]||S[C-2]||S[0];return T}},l!=="margin"&&(p.cssHooks[l+d].set=tu)}),p.fn.extend({css:function(l,d){return Ye(this,function(A,C,T){var S,b,_={},P=0;if(Array.isArray(C)){for(S=nr(A),b=C.length;P<b;P++)_[C[P]]=p.css(A,C[P],!1,S);return _}return T!==void 0?p.style(A,C,T):p.css(A,C)},l,d,arguments.length>1)}});function pt(l,d,A,C,T){return new pt.prototype.init(l,d,A,C,T)}p.Tween=pt,pt.prototype={constructor:pt,init:function(l,d,A,C,T,S){this.elem=l,this.prop=A,this.easing=T||p.easing._default,this.options=d,this.start=this.now=this.cur(),this.end=C,this.unit=S||(p.cssNumber[A]?"":"px")},cur:function(){var l=pt.propHooks[this.prop];return l&&l.get?l.get(this):pt.propHooks._default.get(this)},run:function(l){var d,A=pt.propHooks[this.prop];return this.options.duration?this.pos=d=p.easing[this.easing](l,this.options.duration*l,0,1,this.options.duration):this.pos=d=l,this.now=(this.end-this.start)*d+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),A&&A.set?A.set(this):pt.propHooks._default.set(this),this}},pt.prototype.init.prototype=pt.prototype,pt.propHooks={_default:{get:function(l){var d;return l.elem.nodeType!==1||l.elem[l.prop]!=null&&l.elem.style[l.prop]==null?l.elem[l.prop]:(d=p.css(l.elem,l.prop,""),!d||d==="auto"?0:d)},set:function(l){p.fx.step[l.prop]?p.fx.step[l.prop](l):l.elem.nodeType===1&&(p.cssHooks[l.prop]||l.elem.style[wn(l.prop)]!=null)?p.style(l.elem,l.prop,l.now+l.unit):l.elem[l.prop]=l.now}}},pt.propHooks.scrollTop=pt.propHooks.scrollLeft={set:function(l){l.elem.nodeType&&l.elem.parentNode&&(l.elem[l.prop]=l.now)}},p.easing={linear:function(l){return l},swing:function(l){return .5-Math.cos(l*Math.PI)/2},_default:"swing"},p.fx=pt.prototype.init,p.fx.step={};var ji,ar,Fg=/^(?:toggle|show|hide)$/,Ng=/queueHooks$/;function Mn(){ar&&(x.hidden===!1&&e.requestAnimationFrame?e.requestAnimationFrame(Mn):e.setTimeout(Mn,p.fx.interval),p.fx.tick())}function su(){return e.setTimeout(function(){ji=void 0}),ji=Date.now()}function or(l,d){var A,C=0,T={height:l};for(d=d?1:0;C<4;C+=2-d)A=ei[C],T["margin"+A]=T["padding"+A]=l;return d&&(T.opacity=T.width=l),T}function ru(l,d,A){for(var C,T=(wt.tweeners[d]||[]).concat(wt.tweeners["*"]),S=0,b=T.length;S<b;S++)if(C=T[S].call(A,d,l))return C}function Bg(l,d,A){var C,T,S,b,_,P,M,Y,q="width"in d||"height"in d,H=this,Z={},Ce=l.style,we=l.nodeType&&sr(l),Se=fe.get(l,"fxshow");A.queue||(b=p._queueHooks(l,"fx"),b.unqueued==null&&(b.unqueued=0,_=b.empty.fire,b.empty.fire=function(){b.unqueued||_()}),b.unqueued++,H.always(function(){H.always(function(){b.unqueued--,p.queue(l,"fx").length||b.empty.fire()})}));for(C in d)if(T=d[C],Fg.test(T)){if(delete d[C],S=S||T==="toggle",T===(we?"hide":"show"))if(T==="show"&&Se&&Se[C]!==void 0)we=!0;else continue;Z[C]=Se&&Se[C]||p.style(l,C)}if(P=!p.isEmptyObject(d),!(!P&&p.isEmptyObject(Z))){q&&l.nodeType===1&&(A.overflow=[Ce.overflow,Ce.overflowX,Ce.overflowY],M=Se&&Se.display,M==null&&(M=fe.get(l,"display")),Y=p.css(l,"display"),Y==="none"&&(M?Y=M:(Vi([l],!0),M=l.style.display||M,Y=p.css(l,"display"),Vi([l]))),(Y==="inline"||Y==="inline-block"&&M!=null)&&p.css(l,"float")==="none"&&(P||(H.done(function(){Ce.display=M}),M==null&&(Y=Ce.display,M=Y==="none"?"":Y)),Ce.display="inline-block")),A.overflow&&(Ce.overflow="hidden",H.always(function(){Ce.overflow=A.overflow[0],Ce.overflowX=A.overflow[1],Ce.overflowY=A.overflow[2]})),P=!1;for(C in Z)P||(Se?"hidden"in Se&&(we=Se.hidden):Se=fe.access(l,"fxshow",{display:M}),S&&(Se.hidden=!we),we&&Vi([l],!0),H.done(function(){we||Vi([l]),fe.remove(l,"fxshow");for(C in Z)p.style(l,C,Z[C])})),P=ru(we?Se[C]:0,C,H),C in Se||(Se[C]=P.start,we&&(P.end=P.start,P.start=0))}}function Ug(l,d){var A,C,T,S,b;for(A in l)if(C=st(A),T=d[C],S=l[A],Array.isArray(S)&&(T=S[1],S=l[A]=S[0]),A!==C&&(l[C]=S,delete l[A]),b=p.cssHooks[C],b&&"expand"in b){S=b.expand(S),delete l[C];for(A in S)A in l||(l[A]=S[A],d[A]=T)}else d[C]=T}function wt(l,d,A){var C,T,S=0,b=wt.prefilters.length,_=p.Deferred().always(function(){delete P.elem}),P=function(){if(T)return!1;for(var q=ji||su(),H=Math.max(0,M.startTime+M.duration-q),Z=H/M.duration||0,Ce=1-Z,we=0,Se=M.tweens.length;we<Se;we++)M.tweens[we].run(Ce);return _.notifyWith(l,[M,Ce,H]),Ce<1&&Se?H:(Se||_.notifyWith(l,[M,1,0]),_.resolveWith(l,[M]),!1)},M=_.promise({elem:l,props:p.extend({},d),opts:p.extend(!0,{specialEasing:{},easing:p.easing._default},A),originalProperties:d,originalOptions:A,startTime:ji||su(),duration:A.duration,tweens:[],createTween:function(q,H){var Z=p.Tween(l,M.opts,q,H,M.opts.specialEasing[q]||M.opts.easing);return M.tweens.push(Z),Z},stop:function(q){var H=0,Z=q?M.tweens.length:0;if(T)return this;for(T=!0;H<Z;H++)M.tweens[H].run(1);return q?(_.notifyWith(l,[M,1,0]),_.resolveWith(l,[M,q])):_.rejectWith(l,[M,q]),this}}),Y=M.props;for(Ug(Y,M.opts.specialEasing);S<b;S++)if(C=wt.prefilters[S].call(M,l,Y,M.opts),C)return E(C.stop)&&(p._queueHooks(M.elem,M.opts.queue).stop=C.stop.bind(C)),C;return p.map(Y,ru,M),E(M.opts.start)&&M.opts.start.call(l,M),M.progress(M.opts.progress).done(M.opts.done,M.opts.complete).fail(M.opts.fail).always(M.opts.always),p.fx.timer(p.extend(P,{elem:l,anim:M,queue:M.opts.queue})),M}p.Animation=p.extend(wt,{tweeners:{"*":[function(l,d){var A=this.createTween(l,d);return $l(A.elem,l,ls.exec(d),A),A}]},tweener:function(l,d){E(l)?(d=l,l=["*"]):l=l.match(je);for(var A,C=0,T=l.length;C<T;C++)A=l[C],wt.tweeners[A]=wt.tweeners[A]||[],wt.tweeners[A].unshift(d)},prefilters:[Bg],prefilter:function(l,d){d?wt.prefilters.unshift(l):wt.prefilters.push(l)}}),p.speed=function(l,d,A){var C=l&&typeof l=="object"?p.extend({},l):{complete:A||!A&&d||E(l)&&l,duration:l,easing:A&&d||d&&!E(d)&&d};return p.fx.off?C.duration=0:typeof C.duration!="number"&&(C.duration in p.fx.speeds?C.duration=p.fx.speeds[C.duration]:C.duration=p.fx.speeds._default),(C.queue==null||C.queue===!0)&&(C.queue="fx"),C.old=C.complete,C.complete=function(){E(C.old)&&C.old.call(this),C.queue&&p.dequeue(this,C.queue)},C},p.fn.extend({fadeTo:function(l,d,A,C){return this.filter(sr).css("opacity",0).show().end().animate({opacity:d},l,A,C)},animate:function(l,d,A,C){var T=p.isEmptyObject(l),S=p.speed(d,A,C),b=function(){var _=wt(this,p.extend({},l),S);(T||fe.get(this,"finish"))&&_.stop(!0)};return b.finish=b,T||S.queue===!1?this.each(b):this.queue(S.queue,b)},stop:function(l,d,A){var C=function(T){var S=T.stop;delete T.stop,S(A)};return typeof l!="string"&&(A=d,d=l,l=void 0),d&&this.queue(l||"fx",[]),this.each(function(){var T=!0,S=l!=null&&l+"queueHooks",b=p.timers,_=fe.get(this);if(S)_[S]&&_[S].stop&&C(_[S]);else for(S in _)_[S]&&_[S].stop&&Ng.test(S)&&C(_[S]);for(S=b.length;S--;)b[S].elem===this&&(l==null||b[S].queue===l)&&(b[S].anim.stop(A),T=!1,b.splice(S,1));(T||!A)&&p.dequeue(this,l)})},finish:function(l){return l!==!1&&(l=l||"fx"),this.each(function(){var d,A=fe.get(this),C=A[l+"queue"],T=A[l+"queueHooks"],S=p.timers,b=C?C.length:0;for(A.finish=!0,p.queue(this,l,[]),T&&T.stop&&T.stop.call(this,!0),d=S.length;d--;)S[d].elem===this&&S[d].queue===l&&(S[d].anim.stop(!0),S.splice(d,1));for(d=0;d<b;d++)C[d]&&C[d].finish&&C[d].finish.call(this);delete A.finish})}}),p.each(["toggle","show","hide"],function(l,d){var A=p.fn[d];p.fn[d]=function(C,T,S){return C==null||typeof C=="boolean"?A.apply(this,arguments):this.animate(or(d,!0),C,T,S)}}),p.each({slideDown:or("show"),slideUp:or("hide"),slideToggle:or("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(l,d){p.fn[l]=function(A,C,T){return this.animate(d,A,C,T)}}),p.timers=[],p.fx.tick=function(){var l,d=0,A=p.timers;for(ji=Date.now();d<A.length;d++)l=A[d],!l()&&A[d]===l&&A.splice(d--,1);A.length||p.fx.stop(),ji=void 0},p.fx.timer=function(l){p.timers.push(l),p.fx.start()},p.fx.interval=13,p.fx.start=function(){ar||(ar=!0,Mn())},p.fx.stop=function(){ar=null},p.fx.speeds={slow:600,fast:200,_default:400},p.fn.delay=function(l,d){return l=p.fx&&p.fx.speeds[l]||l,d=d||"fx",this.queue(d,function(A,C){var T=e.setTimeout(A,l);C.stop=function(){e.clearTimeout(T)}})},(function(){var l=x.createElement("input"),d=x.createElement("select"),A=d.appendChild(x.createElement("option"));l.type="checkbox",m.checkOn=l.value!=="",m.optSelected=A.selected,l=x.createElement("input"),l.value="t",l.type="radio",m.radioValue=l.value==="t"})();var nu,hs=p.expr.attrHandle;p.fn.extend({attr:function(l,d){return Ye(this,p.attr,l,d,arguments.length>1)},removeAttr:function(l){return this.each(function(){p.removeAttr(this,l)})}}),p.extend({attr:function(l,d,A){var C,T,S=l.nodeType;if(!(S===3||S===8||S===2)){if(typeof l.getAttribute>"u")return p.prop(l,d,A);if((S!==1||!p.isXMLDoc(l))&&(T=p.attrHooks[d.toLowerCase()]||(p.expr.match.bool.test(d)?nu:void 0)),A!==void 0){if(A===null){p.removeAttr(l,d);return}return T&&"set"in T&&(C=T.set(l,A,d))!==void 0?C:(l.setAttribute(d,A+""),A)}return T&&"get"in T&&(C=T.get(l,d))!==null?C:(C=p.find.attr(l,d),C??void 0)}},attrHooks:{type:{set:function(l,d){if(!m.radioValue&&d==="radio"&&F(l,"input")){var A=l.value;return l.setAttribute("type",d),A&&(l.value=A),d}}}},removeAttr:function(l,d){var A,C=0,T=d&&d.match(je);if(T&&l.nodeType===1)for(;A=T[C++];)l.removeAttribute(A)}}),nu={set:function(l,d,A){return d===!1?p.removeAttr(l,A):l.setAttribute(A,A),A}},p.each(p.expr.match.bool.source.match(/\w+/g),function(l,d){var A=hs[d]||p.find.attr;hs[d]=function(C,T,S){var b,_,P=T.toLowerCase();return S||(_=hs[P],hs[P]=b,b=A(C,T,S)!=null?P:null,hs[P]=_),b}});var $g=/^(?:input|select|textarea|button)$/i,Gg=/^(?:a|area)$/i;p.fn.extend({prop:function(l,d){return Ye(this,p.prop,l,d,arguments.length>1)},removeProp:function(l){return this.each(function(){delete this[p.propFix[l]||l]})}}),p.extend({prop:function(l,d,A){var C,T,S=l.nodeType;if(!(S===3||S===8||S===2))return(S!==1||!p.isXMLDoc(l))&&(d=p.propFix[d]||d,T=p.propHooks[d]),A!==void 0?T&&"set"in T&&(C=T.set(l,A,d))!==void 0?C:l[d]=A:T&&"get"in T&&(C=T.get(l,d))!==null?C:l[d]},propHooks:{tabIndex:{get:function(l){var d=p.find.attr(l,"tabindex");return d?parseInt(d,10):$g.test(l.nodeName)||Gg.test(l.nodeName)&&l.href?0:-1}}},propFix:{for:"htmlFor",class:"className"}}),m.optSelected||(p.propHooks.selected={get:function(l){var d=l.parentNode;return d&&d.parentNode&&d.parentNode.selectedIndex,null},set:function(l){var d=l.parentNode;d&&(d.selectedIndex,d.parentNode&&d.parentNode.selectedIndex)}}),p.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){p.propFix[this.toLowerCase()]=this});function Si(l){var d=l.match(je)||[];return d.join(" ")}function xi(l){return l.getAttribute&&l.getAttribute("class")||""}function On(l){return Array.isArray(l)?l:typeof l=="string"?l.match(je)||[]:[]}p.fn.extend({addClass:function(l){var d,A,C,T,S,b;return E(l)?this.each(function(_){p(this).addClass(l.call(this,_,xi(this)))}):(d=On(l),d.length?this.each(function(){if(C=xi(this),A=this.nodeType===1&&" "+Si(C)+" ",A){for(S=0;S<d.length;S++)T=d[S],A.indexOf(" "+T+" ")<0&&(A+=T+" ");b=Si(A),C!==b&&this.setAttribute("class",b)}}):this)},removeClass:function(l){var d,A,C,T,S,b;return E(l)?this.each(function(_){p(this).removeClass(l.call(this,_,xi(this)))}):arguments.length?(d=On(l),d.length?this.each(function(){if(C=xi(this),A=this.nodeType===1&&" "+Si(C)+" ",A){for(S=0;S<d.length;S++)for(T=d[S];A.indexOf(" "+T+" ")>-1;)A=A.replace(" "+T+" "," ");b=Si(A),C!==b&&this.setAttribute("class",b)}}):this):this.attr("class","")},toggleClass:function(l,d){var A,C,T,S,b=typeof l,_=b==="string"||Array.isArray(l);return E(l)?this.each(function(P){p(this).toggleClass(l.call(this,P,xi(this),d),d)}):typeof d=="boolean"&&_?d?this.addClass(l):this.removeClass(l):(A=On(l),this.each(function(){if(_)for(S=p(this),T=0;T<A.length;T++)C=A[T],S.hasClass(C)?S.removeClass(C):S.addClass(C);else(l===void 0||b==="boolean")&&(C=xi(this),C&&fe.set(this,"__className__",C),this.setAttribute&&this.setAttribute("class",C||l===!1?"":fe.get(this,"__className__")||""))}))},hasClass:function(l){var d,A,C=0;for(d=" "+l+" ";A=this[C++];)if(A.nodeType===1&&(" "+Si(xi(A))+" ").indexOf(d)>-1)return!0;return!1}});var Hg=/\r/g;p.fn.extend({val:function(l){var d,A,C,T=this[0];return arguments.length?(C=E(l),this.each(function(S){var b;this.nodeType===1&&(C?b=l.call(this,S,p(this).val()):b=l,b==null?b="":typeof b=="number"?b+="":Array.isArray(b)&&(b=p.map(b,function(_){return _==null?"":_+""})),d=p.valHooks[this.type]||p.valHooks[this.nodeName.toLowerCase()],(!d||!("set"in d)||d.set(this,b,"value")===void 0)&&(this.value=b))})):T?(d=p.valHooks[T.type]||p.valHooks[T.nodeName.toLowerCase()],d&&"get"in d&&(A=d.get(T,"value"))!==void 0?A:(A=T.value,typeof A=="string"?A.replace(Hg,""):A??"")):void 0}}),p.extend({valHooks:{option:{get:function(l){var d=p.find.attr(l,"value");return d??Si(p.text(l))}},select:{get:function(l){var d,A,C,T=l.options,S=l.selectedIndex,b=l.type==="select-one",_=b?null:[],P=b?S+1:T.length;for(S<0?C=P:C=b?S:0;C<P;C++)if(A=T[C],(A.selected||C===S)&&!A.disabled&&(!A.parentNode.disabled||!F(A.parentNode,"optgroup"))){if(d=p(A).val(),b)return d;_.push(d)}return _},set:function(l,d){for(var A,C,T=l.options,S=p.makeArray(d),b=T.length;b--;)C=T[b],(C.selected=p.inArray(p.valHooks.option.get(C),S)>-1)&&(A=!0);return A||(l.selectedIndex=-1),S}}}}),p.each(["radio","checkbox"],function(){p.valHooks[this]={set:function(l,d){if(Array.isArray(d))return l.checked=p.inArray(p(l).val(),d)>-1}},m.checkOn||(p.valHooks[this].get=function(l){return l.getAttribute("value")===null?"on":l.value})});var ds=e.location,au={guid:Date.now()},Fn=/\?/;p.parseXML=function(l){var d,A;if(!l||typeof l!="string")return null;try{d=new e.DOMParser().parseFromString(l,"text/xml")}catch{}return A=d&&d.getElementsByTagName("parsererror")[0],(!d||A)&&p.error("Invalid XML: "+(A?p.map(A.childNodes,function(C){return C.textContent}).join(`
50
- `):l)),d};var ou=/^(?:focusinfocus|focusoutblur)$/,lu=function(l){l.stopPropagation()};p.extend(p.event,{trigger:function(l,d,A,C){var T,S,b,_,P,M,Y,q,H=[A||x],Z=f.call(l,"type")?l.type:l,Ce=f.call(l,"namespace")?l.namespace.split("."):[];if(S=q=b=A=A||x,!(A.nodeType===3||A.nodeType===8)&&!ou.test(Z+p.event.triggered)&&(Z.indexOf(".")>-1&&(Ce=Z.split("."),Z=Ce.shift(),Ce.sort()),P=Z.indexOf(":")<0&&"on"+Z,l=l[p.expando]?l:new p.Event(Z,typeof l=="object"&&l),l.isTrigger=C?2:3,l.namespace=Ce.join("."),l.rnamespace=l.namespace?new RegExp("(^|\\.)"+Ce.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,l.result=void 0,l.target||(l.target=A),d=d==null?[l]:p.makeArray(d,[l]),Y=p.event.special[Z]||{},!(!C&&Y.trigger&&Y.trigger.apply(A,d)===!1))){if(!C&&!Y.noBubble&&!v(A)){for(_=Y.delegateType||Z,ou.test(_+Z)||(S=S.parentNode);S;S=S.parentNode)H.push(S),b=S;b===(A.ownerDocument||x)&&H.push(b.defaultView||b.parentWindow||e)}for(T=0;(S=H[T++])&&!l.isPropagationStopped();)q=S,l.type=T>1?_:Y.bindType||Z,M=(fe.get(S,"events")||Object.create(null))[l.type]&&fe.get(S,"handle"),M&&M.apply(S,d),M=P&&S[P],M&&M.apply&&fi(S)&&(l.result=M.apply(S,d),l.result===!1&&l.preventDefault());return l.type=Z,!C&&!l.isDefaultPrevented()&&(!Y._default||Y._default.apply(H.pop(),d)===!1)&&fi(A)&&P&&E(A[Z])&&!v(A)&&(b=A[P],b&&(A[P]=null),p.event.triggered=Z,l.isPropagationStopped()&&q.addEventListener(Z,lu),A[Z](),l.isPropagationStopped()&&q.removeEventListener(Z,lu),p.event.triggered=void 0,b&&(A[P]=b)),l.result}},simulate:function(l,d,A){var C=p.extend(new p.Event,A,{type:l,isSimulated:!0});p.event.trigger(C,null,d)}}),p.fn.extend({trigger:function(l,d){return this.each(function(){p.event.trigger(l,d,this)})},triggerHandler:function(l,d){var A=this[0];if(A)return p.event.trigger(l,d,A,!0)}});var Vg=/\[\]$/,uu=/\r?\n/g,Kg=/^(?:submit|button|image|reset|file)$/i,Yg=/^(?:input|select|textarea|keygen)/i;function Nn(l,d,A,C){var T;if(Array.isArray(d))p.each(d,function(S,b){A||Vg.test(l)?C(l,b):Nn(l+"["+(typeof b=="object"&&b!=null?S:"")+"]",b,A,C)});else if(!A&&w(d)==="object")for(T in d)Nn(l+"["+T+"]",d[T],A,C);else C(l,d)}p.param=function(l,d){var A,C=[],T=function(S,b){var _=E(b)?b():b;C[C.length]=encodeURIComponent(S)+"="+encodeURIComponent(_??"")};if(l==null)return"";if(Array.isArray(l)||l.jquery&&!p.isPlainObject(l))p.each(l,function(){T(this.name,this.value)});else for(A in l)Nn(A,l[A],d,T);return C.join("&")},p.fn.extend({serialize:function(){return p.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var l=p.prop(this,"elements");return l?p.makeArray(l):this}).filter(function(){var l=this.type;return this.name&&!p(this).is(":disabled")&&Yg.test(this.nodeName)&&!Kg.test(l)&&(this.checked||!us.test(l))}).map(function(l,d){var A=p(this).val();return A==null?null:Array.isArray(A)?p.map(A,function(C){return{name:d.name,value:C.replace(uu,`\r
51
- `)}}):{name:d.name,value:A.replace(uu,`\r
52
- `)}}).get()}});var Wg=/%20/g,jg=/#.*$/,zg=/([?&])_=[^&]*/,qg=/^(.*?):[ \t]*([^\r\n]*)$/mg,Xg=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Zg=/^(?:GET|HEAD)$/,Qg=/^\/\//,cu={},Bn={},hu="*/".concat("*"),Un=x.createElement("a");Un.href=ds.href;function du(l){return function(d,A){typeof d!="string"&&(A=d,d="*");var C,T=0,S=d.toLowerCase().match(je)||[];if(E(A))for(;C=S[T++];)C[0]==="+"?(C=C.slice(1)||"*",(l[C]=l[C]||[]).unshift(A)):(l[C]=l[C]||[]).push(A)}}function fu(l,d,A,C){var T={},S=l===Bn;function b(_){var P;return T[_]=!0,p.each(l[_]||[],function(M,Y){var q=Y(d,A,C);if(typeof q=="string"&&!S&&!T[q])return d.dataTypes.unshift(q),b(q),!1;if(S)return!(P=q)}),P}return b(d.dataTypes[0])||!T["*"]&&b("*")}function $n(l,d){var A,C,T=p.ajaxSettings.flatOptions||{};for(A in d)d[A]!==void 0&&((T[A]?l:C||(C={}))[A]=d[A]);return C&&p.extend(!0,l,C),l}function Jg(l,d,A){for(var C,T,S,b,_=l.contents,P=l.dataTypes;P[0]==="*";)P.shift(),C===void 0&&(C=l.mimeType||d.getResponseHeader("Content-Type"));if(C){for(T in _)if(_[T]&&_[T].test(C)){P.unshift(T);break}}if(P[0]in A)S=P[0];else{for(T in A){if(!P[0]||l.converters[T+" "+P[0]]){S=T;break}b||(b=T)}S=S||b}if(S)return S!==P[0]&&P.unshift(S),A[S]}function ep(l,d,A,C){var T,S,b,_,P,M={},Y=l.dataTypes.slice();if(Y[1])for(b in l.converters)M[b.toLowerCase()]=l.converters[b];for(S=Y.shift();S;)if(l.responseFields[S]&&(A[l.responseFields[S]]=d),!P&&C&&l.dataFilter&&(d=l.dataFilter(d,l.dataType)),P=S,S=Y.shift(),S){if(S==="*")S=P;else if(P!=="*"&&P!==S){if(b=M[P+" "+S]||M["* "+S],!b){for(T in M)if(_=T.split(" "),_[1]===S&&(b=M[P+" "+_[0]]||M["* "+_[0]],b)){b===!0?b=M[T]:M[T]!==!0&&(S=_[0],Y.unshift(_[1]));break}}if(b!==!0)if(b&&l.throws)d=b(d);else try{d=b(d)}catch(q){return{state:"parsererror",error:b?q:"No conversion from "+P+" to "+S}}}}return{state:"success",data:d}}p.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:ds.href,type:"GET",isLocal:Xg.test(ds.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":hu,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":p.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(l,d){return d?$n($n(l,p.ajaxSettings),d):$n(p.ajaxSettings,l)},ajaxPrefilter:du(cu),ajaxTransport:du(Bn),ajax:function(l,d){typeof l=="object"&&(d=l,l=void 0),d=d||{};var A,C,T,S,b,_,P,M,Y,q,H=p.ajaxSetup({},d),Z=H.context||H,Ce=H.context&&(Z.nodeType||Z.jquery)?p(Z):p.event,we=p.Deferred(),Se=p.Callbacks("once memory"),nt=H.statusCode||{},et={},Vt={},Kt="canceled",_e={readyState:0,getResponseHeader:function(Me){var We;if(P){if(!S)for(S={};We=qg.exec(T);)S[We[1].toLowerCase()+" "]=(S[We[1].toLowerCase()+" "]||[]).concat(We[2]);We=S[Me.toLowerCase()+" "]}return We==null?null:We.join(", ")},getAllResponseHeaders:function(){return P?T:null},setRequestHeader:function(Me,We){return P==null&&(Me=Vt[Me.toLowerCase()]=Vt[Me.toLowerCase()]||Me,et[Me]=We),this},overrideMimeType:function(Me){return P==null&&(H.mimeType=Me),this},statusCode:function(Me){var We;if(Me)if(P)_e.always(Me[_e.status]);else for(We in Me)nt[We]=[nt[We],Me[We]];return this},abort:function(Me){var We=Me||Kt;return A&&A.abort(We),bi(0,We),this}};if(we.promise(_e),H.url=((l||H.url||ds.href)+"").replace(Qg,ds.protocol+"//"),H.type=d.method||d.type||H.method||H.type,H.dataTypes=(H.dataType||"*").toLowerCase().match(je)||[""],H.crossDomain==null){_=x.createElement("a");try{_.href=H.url,_.href=_.href,H.crossDomain=Un.protocol+"//"+Un.host!=_.protocol+"//"+_.host}catch{H.crossDomain=!0}}if(H.data&&H.processData&&typeof H.data!="string"&&(H.data=p.param(H.data,H.traditional)),fu(cu,H,d,_e),P)return _e;M=p.event&&H.global,M&&p.active++===0&&p.event.trigger("ajaxStart"),H.type=H.type.toUpperCase(),H.hasContent=!Zg.test(H.type),C=H.url.replace(jg,""),H.hasContent?H.data&&H.processData&&(H.contentType||"").indexOf("application/x-www-form-urlencoded")===0&&(H.data=H.data.replace(Wg,"+")):(q=H.url.slice(C.length),H.data&&(H.processData||typeof H.data=="string")&&(C+=(Fn.test(C)?"&":"?")+H.data,delete H.data),H.cache===!1&&(C=C.replace(zg,"$1"),q=(Fn.test(C)?"&":"?")+"_="+au.guid+++q),H.url=C+q),H.ifModified&&(p.lastModified[C]&&_e.setRequestHeader("If-Modified-Since",p.lastModified[C]),p.etag[C]&&_e.setRequestHeader("If-None-Match",p.etag[C])),(H.data&&H.hasContent&&H.contentType!==!1||d.contentType)&&_e.setRequestHeader("Content-Type",H.contentType),_e.setRequestHeader("Accept",H.dataTypes[0]&&H.accepts[H.dataTypes[0]]?H.accepts[H.dataTypes[0]]+(H.dataTypes[0]!=="*"?", "+hu+"; q=0.01":""):H.accepts["*"]);for(Y in H.headers)_e.setRequestHeader(Y,H.headers[Y]);if(H.beforeSend&&(H.beforeSend.call(Z,_e,H)===!1||P))return _e.abort();if(Kt="abort",Se.add(H.complete),_e.done(H.success),_e.fail(H.error),A=fu(Bn,H,d,_e),!A)bi(-1,"No Transport");else{if(_e.readyState=1,M&&Ce.trigger("ajaxSend",[_e,H]),P)return _e;H.async&&H.timeout>0&&(b=e.setTimeout(function(){_e.abort("timeout")},H.timeout));try{P=!1,A.send(et,bi)}catch(Me){if(P)throw Me;bi(-1,Me)}}function bi(Me,We,gs,Hn){var Yt,ps,Wt,pi,Ai,Lt=We;P||(P=!0,b&&e.clearTimeout(b),A=void 0,T=Hn||"",_e.readyState=Me>0?4:0,Yt=Me>=200&&Me<300||Me===304,gs&&(pi=Jg(H,_e,gs)),!Yt&&p.inArray("script",H.dataTypes)>-1&&p.inArray("json",H.dataTypes)<0&&(H.converters["text script"]=function(){}),pi=ep(H,pi,_e,Yt),Yt?(H.ifModified&&(Ai=_e.getResponseHeader("Last-Modified"),Ai&&(p.lastModified[C]=Ai),Ai=_e.getResponseHeader("etag"),Ai&&(p.etag[C]=Ai)),Me===204||H.type==="HEAD"?Lt="nocontent":Me===304?Lt="notmodified":(Lt=pi.state,ps=pi.data,Wt=pi.error,Yt=!Wt)):(Wt=Lt,(Me||!Lt)&&(Lt="error",Me<0&&(Me=0))),_e.status=Me,_e.statusText=(We||Lt)+"",Yt?we.resolveWith(Z,[ps,Lt,_e]):we.rejectWith(Z,[_e,Lt,Wt]),_e.statusCode(nt),nt=void 0,M&&Ce.trigger(Yt?"ajaxSuccess":"ajaxError",[_e,H,Yt?ps:Wt]),Se.fireWith(Z,[_e,Lt]),M&&(Ce.trigger("ajaxComplete",[_e,H]),--p.active||p.event.trigger("ajaxStop")))}return _e},getJSON:function(l,d,A){return p.get(l,d,A,"json")},getScript:function(l,d){return p.get(l,void 0,d,"script")}}),p.each(["get","post"],function(l,d){p[d]=function(A,C,T,S){return E(C)&&(S=S||T,T=C,C=void 0),p.ajax(p.extend({url:A,type:d,dataType:S,data:C,success:T},p.isPlainObject(A)&&A))}}),p.ajaxPrefilter(function(l){var d;for(d in l.headers)d.toLowerCase()==="content-type"&&(l.contentType=l.headers[d]||"")}),p._evalUrl=function(l,d,A){return p.ajax({url:l,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,converters:{"text script":function(){}},dataFilter:function(C){p.globalEval(C,d,A)}})},p.fn.extend({wrapAll:function(l){var d;return this[0]&&(E(l)&&(l=l.call(this[0])),d=p(l,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&d.insertBefore(this[0]),d.map(function(){for(var A=this;A.firstElementChild;)A=A.firstElementChild;return A}).append(this)),this},wrapInner:function(l){return E(l)?this.each(function(d){p(this).wrapInner(l.call(this,d))}):this.each(function(){var d=p(this),A=d.contents();A.length?A.wrapAll(l):d.append(l)})},wrap:function(l){var d=E(l);return this.each(function(A){p(this).wrapAll(d?l.call(this,A):l)})},unwrap:function(l){return this.parent(l).not("body").each(function(){p(this).replaceWith(this.childNodes)}),this}}),p.expr.pseudos.hidden=function(l){return!p.expr.pseudos.visible(l)},p.expr.pseudos.visible=function(l){return!!(l.offsetWidth||l.offsetHeight||l.getClientRects().length)},p.ajaxSettings.xhr=function(){try{return new e.XMLHttpRequest}catch{}};var tp={0:200,1223:204},fs=p.ajaxSettings.xhr();m.cors=!!fs&&"withCredentials"in fs,m.ajax=fs=!!fs,p.ajaxTransport(function(l){var d,A;if(m.cors||fs&&!l.crossDomain)return{send:function(C,T){var S,b=l.xhr();if(b.open(l.type,l.url,l.async,l.username,l.password),l.xhrFields)for(S in l.xhrFields)b[S]=l.xhrFields[S];l.mimeType&&b.overrideMimeType&&b.overrideMimeType(l.mimeType),!l.crossDomain&&!C["X-Requested-With"]&&(C["X-Requested-With"]="XMLHttpRequest");for(S in C)b.setRequestHeader(S,C[S]);d=function(_){return function(){d&&(d=A=b.onload=b.onerror=b.onabort=b.ontimeout=b.onreadystatechange=null,_==="abort"?b.abort():_==="error"?typeof b.status!="number"?T(0,"error"):T(b.status,b.statusText):T(tp[b.status]||b.status,b.statusText,(b.responseType||"text")!=="text"||typeof b.responseText!="string"?{binary:b.response}:{text:b.responseText},b.getAllResponseHeaders()))}},b.onload=d(),A=b.onerror=b.ontimeout=d("error"),b.onabort!==void 0?b.onabort=A:b.onreadystatechange=function(){b.readyState===4&&e.setTimeout(function(){d&&A()})},d=d("abort");try{b.send(l.hasContent&&l.data||null)}catch(_){if(d)throw _}},abort:function(){d&&d()}}}),p.ajaxPrefilter(function(l){l.crossDomain&&(l.contents.script=!1)}),p.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(l){return p.globalEval(l),l}}}),p.ajaxPrefilter("script",function(l){l.cache===void 0&&(l.cache=!1),l.crossDomain&&(l.type="GET")}),p.ajaxTransport("script",function(l){if(l.crossDomain||l.scriptAttrs){var d,A;return{send:function(C,T){d=p("<script>").attr(l.scriptAttrs||{}).prop({charset:l.scriptCharset,src:l.url}).on("load error",A=function(S){d.remove(),A=null,S&&T(S.type==="error"?404:200,S.type)}),x.head.appendChild(d[0])},abort:function(){A&&A()}}}});var gu=[],Gn=/(=)\?(?=&|$)|\?\?/;p.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var l=gu.pop()||p.expando+"_"+au.guid++;return this[l]=!0,l}}),p.ajaxPrefilter("json jsonp",function(l,d,A){var C,T,S,b=l.jsonp!==!1&&(Gn.test(l.url)?"url":typeof l.data=="string"&&(l.contentType||"").indexOf("application/x-www-form-urlencoded")===0&&Gn.test(l.data)&&"data");if(b||l.dataTypes[0]==="jsonp")return C=l.jsonpCallback=E(l.jsonpCallback)?l.jsonpCallback():l.jsonpCallback,b?l[b]=l[b].replace(Gn,"$1"+C):l.jsonp!==!1&&(l.url+=(Fn.test(l.url)?"&":"?")+l.jsonp+"="+C),l.converters["script json"]=function(){return S||p.error(C+" was not called"),S[0]},l.dataTypes[0]="json",T=e[C],e[C]=function(){S=arguments},A.always(function(){T===void 0?p(e).removeProp(C):e[C]=T,l[C]&&(l.jsonpCallback=d.jsonpCallback,gu.push(C)),S&&E(T)&&T(S[0]),S=T=void 0}),"script"}),m.createHTMLDocument=(function(){var l=x.implementation.createHTMLDocument("").body;return l.innerHTML="<form></form><form></form>",l.childNodes.length===2})(),p.parseHTML=function(l,d,A){if(typeof l!="string")return[];typeof d=="boolean"&&(A=d,d=!1);var C,T,S;return d||(m.createHTMLDocument?(d=x.implementation.createHTMLDocument(""),C=d.createElement("base"),C.href=x.location.href,d.head.appendChild(C)):d=x),T=ee.exec(l),S=!A&&[],T?[d.createElement(T[1])]:(T=Kl([l],d,S),S&&S.length&&p(S).remove(),p.merge([],T.childNodes))},p.fn.load=function(l,d,A){var C,T,S,b=this,_=l.indexOf(" ");return _>-1&&(C=Si(l.slice(_)),l=l.slice(0,_)),E(d)?(A=d,d=void 0):d&&typeof d=="object"&&(T="POST"),b.length>0&&p.ajax({url:l,type:T||"GET",dataType:"html",data:d}).done(function(P){S=arguments,b.html(C?p("<div>").append(p.parseHTML(P)).find(C):P)}).always(A&&function(P,M){b.each(function(){A.apply(this,S||[P.responseText,M,P])})}),this},p.expr.pseudos.animated=function(l){return p.grep(p.timers,function(d){return l===d.elem}).length},p.offset={setOffset:function(l,d,A){var C,T,S,b,_,P,M,Y=p.css(l,"position"),q=p(l),H={};Y==="static"&&(l.style.position="relative"),_=q.offset(),S=p.css(l,"top"),P=p.css(l,"left"),M=(Y==="absolute"||Y==="fixed")&&(S+P).indexOf("auto")>-1,M?(C=q.position(),b=C.top,T=C.left):(b=parseFloat(S)||0,T=parseFloat(P)||0),E(d)&&(d=d.call(l,A,p.extend({},_))),d.top!=null&&(H.top=d.top-_.top+b),d.left!=null&&(H.left=d.left-_.left+T),"using"in d?d.using.call(l,H):q.css(H)}},p.fn.extend({offset:function(l){if(arguments.length)return l===void 0?this:this.each(function(T){p.offset.setOffset(this,l,T)});var d,A,C=this[0];if(C)return C.getClientRects().length?(d=C.getBoundingClientRect(),A=C.ownerDocument.defaultView,{top:d.top+A.pageYOffset,left:d.left+A.pageXOffset}):{top:0,left:0}},position:function(){if(this[0]){var l,d,A,C=this[0],T={top:0,left:0};if(p.css(C,"position")==="fixed")d=C.getBoundingClientRect();else{for(d=this.offset(),A=C.ownerDocument,l=C.offsetParent||A.documentElement;l&&(l===A.body||l===A.documentElement)&&p.css(l,"position")==="static";)l=l.parentNode;l&&l!==C&&l.nodeType===1&&(T=p(l).offset(),T.top+=p.css(l,"borderTopWidth",!0),T.left+=p.css(l,"borderLeftWidth",!0))}return{top:d.top-T.top-p.css(C,"marginTop",!0),left:d.left-T.left-p.css(C,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){for(var l=this.offsetParent;l&&p.css(l,"position")==="static";)l=l.offsetParent;return l||Ti})}}),p.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(l,d){var A=d==="pageYOffset";p.fn[l]=function(C){return Ye(this,function(T,S,b){var _;if(v(T)?_=T:T.nodeType===9&&(_=T.defaultView),b===void 0)return _?_[d]:T[S];_?_.scrollTo(A?_.pageXOffset:b,A?b:_.pageYOffset):T[S]=b},l,C,arguments.length)}}),p.each(["top","left"],function(l,d){p.cssHooks[d]=Xl(m.pixelPosition,function(A,C){if(C)return C=cs(A,d),Pn.test(C)?p(A).position()[d]+"px":C})}),p.each({Height:"height",Width:"width"},function(l,d){p.each({padding:"inner"+l,content:d,"":"outer"+l},function(A,C){p.fn[C]=function(T,S){var b=arguments.length&&(A||typeof T!="boolean"),_=A||(T===!0||S===!0?"margin":"border");return Ye(this,function(P,M,Y){var q;return v(P)?C.indexOf("outer")===0?P["inner"+l]:P.document.documentElement["client"+l]:P.nodeType===9?(q=P.documentElement,Math.max(P.body["scroll"+l],q["scroll"+l],P.body["offset"+l],q["offset"+l],q["client"+l])):Y===void 0?p.css(P,M,_):p.style(P,M,Y,_)},d,b?T:void 0,b)}})}),p.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(l,d){p.fn[d]=function(A){return this.on(d,A)}}),p.fn.extend({bind:function(l,d,A){return this.on(l,null,d,A)},unbind:function(l,d){return this.off(l,null,d)},delegate:function(l,d,A,C){return this.on(d,l,A,C)},undelegate:function(l,d,A){return arguments.length===1?this.off(l,"**"):this.off(d,l||"**",A)},hover:function(l,d){return this.on("mouseenter",l).on("mouseleave",d||l)}}),p.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(l,d){p.fn[d]=function(A,C){return arguments.length>0?this.on(d,null,A,C):this.trigger(d)}});var ip=/^[\s\uFEFF\xA0]+|([^\s\uFEFF\xA0])[\s\uFEFF\xA0]+$/g;p.proxy=function(l,d){var A,C,T;if(typeof d=="string"&&(A=l[d],d=l,l=A),!!E(l))return C=r.call(arguments,2),T=function(){return l.apply(d||this,C.concat(r.call(arguments)))},T.guid=l.guid=l.guid||p.guid++,T},p.holdReady=function(l){l?p.readyWait++:p.ready(!0)},p.isArray=Array.isArray,p.parseJSON=JSON.parse,p.nodeName=F,p.isFunction=E,p.isWindow=v,p.camelCase=st,p.type=w,p.now=Date.now,p.isNumeric=function(l){var d=p.type(l);return(d==="number"||d==="string")&&!isNaN(l-parseFloat(l))},p.trim=function(l){return l==null?"":(l+"").replace(ip,"$1")};var sp=e.jQuery,rp=e.$;return p.noConflict=function(l){return e.$===p&&(e.$=rp),l&&e.jQuery===p&&(e.jQuery=sp),p},typeof t>"u"&&(e.jQuery=e.$=p),p})})(er)),er.exports}var yg=Cg();const ui=mg(yg),Et={None:"none",DualLayer:"dual-layer",Segments:"segments",MinimalWave:"minimal-wave"},Eg={[Et.None]:`
1
+ import l from "hls.js";
2
+ import a from "jquery";
3
+ const e = {
4
+ None: "none",
5
+ DualLayer: "dual-layer",
6
+ Segments: "segments",
7
+ MinimalWave: "minimal-wave"
8
+ }, v = {
9
+ [e.None]: `
53
10
  .progress-bar {
54
11
  flex: 1;
55
12
  height: 4px;
@@ -66,7 +23,8 @@ Schedule: ${c.map(E=>Pt(E))} pos: ${this.timelinePos}`),h.length&&this.log(`Remo
66
23
  background: #0A84FF;
67
24
  border-radius: 2px;
68
25
  }
69
- `,[Et.DualLayer]:`
26
+ `,
27
+ [e.DualLayer]: `
70
28
  .progress-bar {
71
29
  flex: 1;
72
30
  height: 8px;
@@ -108,7 +66,8 @@ Schedule: ${c.map(E=>Pt(E))} pos: ${this.timelinePos}`),h.length&&this.log(`Remo
108
66
  .progress-bar:hover .progress-handle {
109
67
  transform: translateY(-50%) scale(1.2);
110
68
  }
111
- `,[Et.Segments]:`
69
+ `,
70
+ [e.Segments]: `
112
71
  .progress-bar {
113
72
  flex: 1;
114
73
  height: 4px;
@@ -145,7 +104,8 @@ Schedule: ${c.map(E=>Pt(E))} pos: ${this.timelinePos}`),h.length&&this.log(`Remo
145
104
  .progress-segment.filled:hover {
146
105
  background: #40A2FF;
147
106
  }
148
- `,[Et.MinimalWave]:`
107
+ `,
108
+ [e.MinimalWave]: `
149
109
  .progress-bar {
150
110
  flex: 1;
151
111
  height: 2px;
@@ -182,34 +142,132 @@ Schedule: ${c.map(E=>Pt(E))} pos: ${this.timelinePos}`),h.length&&this.log(`Remo
182
142
  50% { transform: translateY(-50%) scaleY(0.6); }
183
143
  100% { transform: translateY(-50%) scaleY(1); }
184
144
  }
185
- `},vg={play:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="black">
145
+ `
146
+ }, Z = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAAC9HpUWHRSYXcgcHJvZmlsZSB0eXBlIGV4aWYAAH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REY+CjwveDp4bXBtZXRhPgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKIC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AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAKPD94cGFja2V0IGVuZD0idyI/Pk8m2PUAAAAGYktHRAD/AP8A/6C9p5MAAAAJcEhZcwAALiMAAC4jAXilP3YAAAAHdElNRQfpAQsJDAJalFv0AAAFB0lEQVR42u2bfYgVVRTAf7u+LdvN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OjU5KzA1OjMwIi8+CiAgICAgPHJkZjpsaQogICAgICBzdEV2dDphY3Rpb249InNhdmVkIgogICAgICBzdEV2dDpjaGFuZ2VkPSIvIgogICAgICBzdEV2dDppbnN0YW5jZUlEPSJ4bXAuaWlkOmQ3YWQ3ZmQ3LWY0YTItNDM2MC05ZDE1LTgwM2E0NzliZDFhMCIKICAgICAgc3RFdnQ6c29mdHdhcmVBZ2VudD0iR2ltcCAyLjEwIChMaW51eCkiCiAgICAgIHN0RXZ0OndoZW49IjIwMjMtMTEtMDNUMTI6MjA6NDQrMDU6MzAiLz4KICAgICA8cmRmOmxpCiAgICAgIHN0RXZ0OmFjdGlvbj0ic2F2ZWQiCiAgICAgIHN0RXZ0OmNoYW5nZWQ9Ii8iCiAgICAgIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6YjUwZjgyM2QtYjEzNy00ODUxLTk3NGEtOGQxMDE4YmIwOThkIgogICAgICBzdEV2dDpzb2Z0d2FyZUFnZW50PSJHaW1wIDIuMTAgKExpbnV4KSIKICAgICAgc3RFdnQ6d2hlbj0iMjAyNS0wMS0xMVQxNDo0MjozOSswNTozMCIvPgogICAgPC9yZGY6U2VxPgogICA8L3htcE1NOkhpc3Rvcnk+CiAgPC9yZGY6RGVzY3JpcHRpb24+CiA8L3JkZjpSREY+CjwveDp4bXBtZXRhPgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgCjw/eHBhY2tldCBlbmQ9InciPz53lMvMAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH6QELCQwnEZCPswAABNZJREFUeNrtm2uIVVUUgD9nUhvL0Ap7EDOOlmMxPc0cGBKNkH74qLCcHxFR2EPwTxYkQQQWJo5GRIX1J9FIf/ig1IEaqIgY1LG0iIjKsdBQnCy1cnzMmX7sdbj7ns45d87cfe69c+76YMO9++579j7rrL3X2muvA4qiKIqiKIqiKIqiKIoybBgxjMdeA1xmlTlSfxg4BBwAzuojzudK4GngM6AfGIgpfUAX8Dr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gICBzdEV2dDp3aGVuPSIyMDIzLTExLTAzVDEyOjIwOjQ4KzA1OjMwIi8+CiAgICAgPHJkZjpsaQogICAgICBzdEV2dDphY3Rpb249InNhdmVkIgogICAgICBzdEV2dDpjaGFuZ2VkPSIvIgogICAgICBzdEV2dDppbnN0YW5jZUlEPSJ4bXAuaWlkOjA1YjNjZDZjLWUwZGYtNGYzNy04ZTg5LTVmMDFiOTNiZTM2NCIKICAgICAgc3RFdnQ6c29mdHdhcmVBZ2VudD0iR2ltcCAyLjEwIChMaW51eCkiCiAgICAgIHN0RXZ0OndoZW49IjIwMjUtMDEtMTFUMTQ6NDA6MzArMDU6MzAiLz4KICAgIDwvcmRmOlNlcT4KICAgPC94bXBNTTpIaXN0b3J5PgogIDwvcmRmOkRlc2NyaXB0aW9uPgogPC9yZGY6UkRGPgo8L3g6eG1wbWV0YT4KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgIAo8P3hwYWNrZXQgZW5kPSJ3Ij8+T3zvpgAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAuIwAALiMBeKU/dgAAAAd0SU1FB+kBCwkKHhjPoD0AAATqSURBVHja7ZtbbBVFGMd/p0VLSxGIIIIXEChiDAaMl2ii4C3Cg/ogEJqIxngJeGlCUB7UmII+mHglpmrigzFRDAEUJAIx4ZJoA0IUSqq2WFACjUBBQFKL2J7jw3wnDuvZs+cye5bu+X7JJGfPzs7O/vebmW++mQVFURRFURRFURRFURRF6TckYvAMFwBDgKHAKGAm0A6cBvYA+4CUCngu1wH1wFxgbEDeLuA7STuAncCJcmwt44GXgFaxqEJTH7ASmFQuwlUBX/mIsQt4DVgMzAe+l/87gWnAcyLWwQzX/gN8CFwRdwGv9jz4L8ASHwv6UvJ0ZDh3OTBLBE1a5fUArwMXx1nEp4BG4IaAfKtElJ8C8l0PbPC8mJPAfeXuVdwjfeRjOea/A9jmadZPqnOWvyfyCHDGEnJDrh5KKdyYacAiYISDsn4GXgYOhVDP+4EvgAo5bgKeOR/e8DdFuh3e1BhCHYeJf+i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+J26gBeyGWkjdMcdjomyny6QBeoB/gUs2iWcFWp/kgt8CBwE3CllewdCMeA36zUDnyOCfkrPgwGbsZnP7OiKIqiKIqiKIqiKIqilDn/AkkxNGAuRZ+BAAAAAElFTkSuQmCC", W = {
147
+ play: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="black">
186
148
  <path d="M8 5v14l11-7z"/>
187
- </svg>`,pause:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="black">
149
+ </svg>`,
150
+ pause: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="black">
188
151
  <path d="M6 19h4V5H6v14zm8-14v14h4V5h-4z"/>
189
- </svg>`,forward:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="black">
152
+ </svg>`,
153
+ forward: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="black">
190
154
  <path d="M4 18l8.5-6L4 6v12zm9-12v12l8.5-6L13 6z"/>
191
- </svg>`,backward:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="black">
155
+ </svg>`,
156
+ backward: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="black">
192
157
  <path d="M11 18V6l-8.5 6 8.5 6zm.5-6l8.5 6V6l-8.5 6z"/>
193
- </svg>`,fullscreen:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="black">
158
+ </svg>`,
159
+ fullscreen: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="black">
194
160
  <path d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"/>
195
- </svg>`,"speed-0.50":'<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUg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ICA8L3htcE1NOkhpc3Rvcnk+CiAgPC9yZGY6RGVzY3JpcHRpb24+CiA8L3JkZjpSREY+CjwveDp4bXBtZXRhPgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA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AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAKPD94cGFja2V0IGVuZD0idyI/Pk8m2PUAAAAGYktHRAD/A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lNmY2MDRiZDQiCiAgICAgIHN0RXZ0OnNvZnR3YXJlQWdlbnQ9IkdpbXAgMi4xMCAoTGludXgpIgogICAgICBzdEV2dDp3aGVuPSIyMDIzLTEwLTMxVDE1OjMxOjU5KzA1OjMwIi8+CiAgICAgPHJkZjpsaQogICAgICBzdEV2dDphY3Rpb249InNhdmVkIgogICAgICBzdEV2dDpjaGFuZ2VkPSIvIgogICAgICBzdEV2dDppbnN0YW5jZUlEPSJ4bXAuaWlkOmQ3YWQ3ZmQ3LWY0YTItNDM2MC05ZDE1LTgwM2E0NzliZDFhMCIKICAgICAgc3RFdnQ6c29mdHdhcmVBZ2VudD0iR2ltcCAyLjEwIChMaW51eCkiCiAgICAgIHN0RXZ0OndoZW49IjIwMjMtMTEtMDNUMTI6MjA6NDQrMDU6MzAiLz4KICAgICA8cmRmOmxpCiAgICAgIHN0RXZ0OmFjdGlvbj0ic2F2ZWQiCiAgICAgIHN0RXZ0OmNoYW5nZWQ9Ii8iCiAgICAgIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6YjUwZjgyM2QtYjEzNy00ODUxLTk3NGEtOGQxMDE4YmIwOThkIgogICAgICBzdEV2dDpzb2Z0d2FyZUFnZW50PSJHaW1wIDIuMTAgKExpbnV4KSIKICAgICAgc3RFdnQ6d2hlbj0iMjAyNS0wMS0xMVQxNDo0MjozOSswNTozMCIvPgogICAgPC9yZGY6U2VxPgogICA8L3htcE1NOkhpc3Rvcnk+CiAgPC9yZGY6RGVzY3JpcHRpb24+CiA8L3JkZjpSREY+CjwveDp4bXBtZXRhPgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgCjw/eHBhY2tldCBlbmQ9InciPz53lMvMAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH6QELCQwnEZCPswAABNZJREFUeNrtm2uIVVUUgD9nUhvL0Ap7EDOOlmMxPc0cGBKNkH74qLCcHxFR2EPwTxYkQQQWJo5GRIX1J9FIf/ig1IEaqIgY1LG0iI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VAbhNWMSmZB1tV9XtGRssnYpt6k4knEjuTjgdhVHMkbITsbXvmkqkmhmS2CkzapbZhmvbZU46FqSH22mlbf3oaVpizGpHH7O4M+U5zArlskS+UjqxnjAuhTG0wr8a/Vxglw6cXMlat+8InzBtFyZe8k/x/YwweJBUeq84A7gcYaW3rYlpTGdkWnrn2VvrVbLO474RPSwtXipNYUHMGH9kdUovHrgb0xgdDBpIC2YY0r7FYrHsiiYpZjEnjcwKSNRLLKEMaOA4NaT/5rYHuD6rGrW7oAh+UrW0InkH0dEvWhTgwlJvUB+Nr4fYV6Z9Sk7HfNioRdilXsxIaZ2zPmIX79OSpdM6+D/TmPyratqh9EIvIw5pRuqG7QbeBKT9+d03zfc9qmtmFO4BjEe9ZgDb/9e+jDvCx/CHE/2AJ8A3+rONZpRYmQa0KRwRVEURVEURVEURVEURYniPzhn3IN1irUKAAAAAElFTkSuQmCC" width="24" height="24" alt="1.5x speed">',"speed-2.00":'<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAAC83pUWHRSYXcgcHJvZmlsZSB0eXBlIGV4aWYAAHja7ZdNkuQoDIX3nGKOYP0hcRwMJqJvMMefB3Z6qrKyFzmz6oiEMGCBn0AfkFXp+PvXSH8hUYmc1DxyyXlD0qKFKxqxnamukjZd5Up2deH9mz3dHQyToJbzNfI1/mGnW+CsKlr2RSja1bF/7yh66ceT0OVI5owYjX4JlUtI+OygS6Cey9pyCf+6hP046/5YSZxPmsVoXNb697Pv+V0d0esGP8J8CMmGUuSagMzHklQ0CCUJwoFS0VbY6jWUzoC8itOd4DaNOVV9OegblbtFr+3pmZbyNUSegpzv+qU9kb2mskL/xbPG1eLvdpdTKm1P0V/BHz3GWjNWUTUj1Pla1B21BWV04NDpOhL08uZ4DBK+ckEO7OqGrdC3tu3IjQoxcA1S6lRp0LHqRg1TVD4SOxrMjWUZQ5wLNzn5IdNglyJdApDbwq7C91xouS1bS8tbwHMnDGWCGOGTt3N694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3RFdnQ6aW5zdGFuY2VJRD0ieG1wLmlpZDo4OTI1MjY2OS01M2JkLTRlNTktOGE2My1lN2M5ZTgxYzZmNjQiCiAgICAgIHN0RXZ0OnNvZnR3YXJlQWdlbnQ9IkdpbXAgMi4xMCAoTGludXgpIgogICAgICBzdEV2dDp3aGVuPSIyMDIzLTExLTAzVDEyOjIwOjQ4KzA1OjMwIi8+CiAgICAgPHJkZjpsaQogICAgICBzdEV2dDphY3Rpb249InNhdmVkIgogICAgICBzdEV2dDpjaGFuZ2VkPSIvIgogICAgICBzdEV2dDppbnN0YW5jZUlEPSJ4bXAuaWlkOjA1YjNjZDZjLWUwZGYtNGYzNy04ZTg5LTVmMDFiOTNiZTM2NCIKICAgICAgc3RFdnQ6c29mdHdhcmVBZ2VudD0iR2ltcCAyLjEwIChMaW51eCkiCiAgICAgIHN0RXZ0OndoZW49IjIwMjUtMDEtMTFUMTQ6NDA6MzArMDU6MzAiLz4KICAgIDwvcmRmOlNlcT4KICAgPC94bXBNTTpIaXN0b3J5PgogIDwvcmRmOkRlc2NyaXB0aW9uPgogPC9yZGY6UkRGPgo8L3g6eG1wbWV0YT4KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgIAo8P3hwYWNrZXQgZW5kPSJ3Ij8+T3zvpgAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAuIwAALiMBeKU/dgAAAAd0SU1FB+kBCwkKHhjPoD0AAATqSURBVHja7ZtbbBVFGMd/p0VLSxGIIIIXEChiDAaMl2ii4C3Cg/ogEJqIxngJeGlCUB7UmII+mHglpmrigzFRDAEUJAIx4ZJoA0IUSqq2WFACjUBBQFKL2J7jw3wnDuvZs+cye5bu+X7JJGfPzs7O/vebmW++mQVFURRFURRFURRFURRF6TckYvAMFwBDgKHAKGAm0A6cBvYA+4CUCngu1wH1wFxgbEDeLuA7STuAncCJcmwt44GXgFaxqEJTH7ASmFQuwlUBX/mIsQt4DVgMzAe+l/87gWnAcyLWwQzX/gN8CFwRdwGv9jz4L8ASHwv6UvJ0ZDh3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6LWcYsO0blmX8kZjnADok9X66jaYPflCsDlZL/pCXeD5jPKmIXqlqLWUBvkNmBH9m+E0lTAzwkYqWFS4pzXRVHq6rj/4s6H2M+aRiSo4DVwO2YL5O8HsFhzOpbrHlWQkneETmJ+XJppUy72ixXZKn8385/i+J26gBeyGWkjdMcdjomyny6QBeoB/gUs2iWcFWp/kgt8CBwE3CllewdCMeA36zUDnyOCfkrPgwGbsZnP7OiKIqiKIqiKIqiKIqilDn/AkkxNGAuRZ+BAAAAAElFTkSuQmCC" width="24" height="24" alt="2x speed">'};class Bl extends HTMLElement{progressBarStyle=Et.None;_hls;_videoPlayer;background="dark";aspectRatio="16:9";calculateAspectRatioPadding(){const[e,t]=this.aspectRatio.split(":").map(Number);return t/e*100}isValidProgressBarStyle(e){return Object.values(Et).includes(e)}svgIcons=vg;constructor(){super(),this.attachShadow({mode:"open"})}static get observedAttributes(){return["video-src","poster-src","auto-play","width","playback-speeds","default-speed","default-quality","show-time-display","show-speed-control","progress-bar-style","background","aspect-ratio"]}attributeChangedCallback(e,t,i){if(e==="progress-bar-style")this.progressBarStyle=this.isValidProgressBarStyle(i)?i:Et.None,this.render();else if(e==="background")this.background=i==="light"?"light":"dark",this.updateControlsColor();else if(e==="aspect-ratio"){const s=/^\d+:\d+$/;this.aspectRatio=s.test(i)?i:"16:9",this.render()}}async connectedCallback(){this.background=this.getAttribute("background")==="light"?"light":"dark";const e=this.getAttribute("aspect-ratio");e&&/^\d+:\d+$/.test(e)&&(this.aspectRatio=e),await this.render(),await this.initializePlayer(),this.setupProgressBarInteractions(),this.updateControlsColor()}setupProgressBarInteractions(){if(!this.shadowRoot||!this._videoPlayer)return;const e=this.shadowRoot.querySelector(".progress-bar"),t=this.shadowRoot.querySelector(".progress-bar-fill");if(!e||!t)return;const i=()=>{if(!this._videoPlayer)return;const r=this._videoPlayer.currentTime/this._videoPlayer.duration*100;if(t.style.width=`${r}%`,this.progressBarStyle===Et.Segments){const n=this.shadowRoot?.querySelectorAll(".progress-segment");n&&n.forEach((o,c)=>{const u=(c+1)*(100/n.length);r>=u?o.classList.add("filled"):o.classList.remove("filled")})}};this._videoPlayer.addEventListener("timeupdate",i);const s=r=>{if(!this._videoPlayer||!(r instanceof MouseEvent))return;const n=e.getBoundingClientRect(),o=Math.max(0,Math.min(1,(r.clientX-n.left)/n.width));this._videoPlayer.currentTime=o*this._videoPlayer.duration};e.addEventListener("click",s)}renderProgressBar(){switch(this.progressBarStyle){case Et.DualLayer:return`
161
+ </svg>`,
162
+ "speed-0.50": `<img src="${Z}" width="24" height="24" alt="0.5x speed">`,
163
+ "speed-1.00": `<img src="${Y}" width="24" height="24" alt="1x speed">`,
164
+ "speed-1.50": `<img src="${R}" width="24" height="24" alt="1.5x speed">`,
165
+ "speed-2.00": `<img src="${N}" width="24" height="24" alt="2x speed">`
166
+ };
167
+ class j extends HTMLElement {
168
+ progressBarStyle = e.None;
169
+ _hls;
170
+ _videoPlayer;
171
+ background = "dark";
172
+ aspectRatio = "16:9";
173
+ calculateAspectRatioPadding() {
174
+ const [A, g] = this.aspectRatio.split(":").map(Number);
175
+ return g / A * 100;
176
+ }
177
+ isValidProgressBarStyle(A) {
178
+ return Object.values(e).includes(A);
179
+ }
180
+ // Import icons from dedicated file
181
+ svgIcons = W;
182
+ constructor() {
183
+ super(), this.attachShadow({ mode: "open" });
184
+ }
185
+ static get observedAttributes() {
186
+ return [
187
+ "video-src",
188
+ "poster-src",
189
+ "auto-play",
190
+ "width",
191
+ "playback-speeds",
192
+ "default-speed",
193
+ "default-quality",
194
+ "show-time-display",
195
+ "show-speed-control",
196
+ "progress-bar-style",
197
+ "background",
198
+ "aspect-ratio"
199
+ ];
200
+ }
201
+ attributeChangedCallback(A, g, I) {
202
+ if (A === "progress-bar-style")
203
+ this.progressBarStyle = this.isValidProgressBarStyle(I) ? I : e.None, this.render();
204
+ else if (A === "background")
205
+ this.background = I === "light" ? "light" : "dark", this.updateControlsColor();
206
+ else if (A === "aspect-ratio") {
207
+ const s = /^\d+:\d+$/;
208
+ this.aspectRatio = s.test(I) ? I : "16:9", this.render();
209
+ }
210
+ }
211
+ async connectedCallback() {
212
+ this.background = this.getAttribute("background") === "light" ? "light" : "dark";
213
+ const A = this.getAttribute("aspect-ratio");
214
+ A && /^\d+:\d+$/.test(A) && (this.aspectRatio = A), await this.render(), await this.initializePlayer(), this.setupProgressBarInteractions(), this.updateControlsColor();
215
+ }
216
+ setupProgressBarInteractions() {
217
+ if (!this.shadowRoot || !this._videoPlayer) return;
218
+ const A = this.shadowRoot.querySelector(".progress-bar"), g = this.shadowRoot.querySelector(".progress-bar-fill");
219
+ if (!A || !g) return;
220
+ const I = () => {
221
+ if (!this._videoPlayer) return;
222
+ const i = this._videoPlayer.currentTime / this._videoPlayer.duration * 100;
223
+ if (g.style.width = `${i}%`, this.progressBarStyle === e.Segments) {
224
+ const t = this.shadowRoot?.querySelectorAll(".progress-segment");
225
+ t && t.forEach((C, o) => {
226
+ const n = (o + 1) * (100 / t.length);
227
+ i >= n ? C.classList.add("filled") : C.classList.remove("filled");
228
+ });
229
+ }
230
+ };
231
+ this._videoPlayer.addEventListener("timeupdate", I);
232
+ const s = (i) => {
233
+ if (!this._videoPlayer || !(i instanceof MouseEvent)) return;
234
+ const t = A.getBoundingClientRect(), C = Math.max(0, Math.min(1, (i.clientX - t.left) / t.width));
235
+ this._videoPlayer.currentTime = C * this._videoPlayer.duration;
236
+ };
237
+ A.addEventListener("click", s);
238
+ }
239
+ renderProgressBar() {
240
+ switch (this.progressBarStyle) {
241
+ case e.DualLayer:
242
+ return `
196
243
  <div class="progress-bar">
197
244
  <div class="progress-bar-buffer"></div>
198
245
  <div class="progress-bar-fill" style="width: 0%"></div>
199
246
  <div class="progress-handle"></div>
200
247
  </div>
201
- `;case Et.Segments:return`
248
+ `;
249
+ case e.Segments:
250
+ return `
202
251
  <div class="progress-bar">
203
- ${Array.from({length:20},(e,t)=>`
204
- <div class="progress-segment" data-index="${t}"></div>
252
+ ${Array.from({ length: 20 }, (A, g) => `
253
+ <div class="progress-segment" data-index="${g}"></div>
205
254
  `).join("")}
206
255
  </div>
207
- `;case Et.MinimalWave:return`
256
+ `;
257
+ case e.MinimalWave:
258
+ return `
208
259
  <div class="progress-bar">
209
260
  <div class="progress-bar-fill" style="width: 0%"></div>
210
261
  <div class="progress-wave"></div>
211
262
  </div>
212
- `;case Et.None:default:return""}}async render(){const e=`
263
+ `;
264
+ case e.None:
265
+ default:
266
+ return "";
267
+ }
268
+ }
269
+ async render() {
270
+ const A = `
213
271
  :host {
214
272
  display: block;
215
273
  }
@@ -220,7 +278,7 @@ Schedule: ${c.map(E=>Pt(E))} pos: ${this.timelinePos}`),h.length&&this.log(`Remo
220
278
  padding-bottom: ${this.calculateAspectRatioPadding()}%;
221
279
  background: var(--player-bg, #000);
222
280
  overflow: hidden;
223
- max-width: ${this.getAttribute("width")||"100%"};
281
+ max-width: ${this.getAttribute("width") || "100%"};
224
282
  margin: 0 auto;
225
283
  }
226
284
  .video-container svg {
@@ -304,7 +362,7 @@ Schedule: ${c.map(E=>Pt(E))} pos: ${this.timelinePos}`),h.length&&this.log(`Remo
304
362
  .light-theme .time-display {
305
363
  color: #000;
306
364
  }
307
- ${Eg[this.progressBarStyle]}
365
+ ${v[this.progressBarStyle]}
308
366
  .video-controls {
309
367
  display: flex;
310
368
  align-items: center;
@@ -329,21 +387,21 @@ Schedule: ${c.map(E=>Pt(E))} pos: ${this.timelinePos}`),h.length&&this.log(`Remo
329
387
  .speed-container:hover svg {
330
388
  opacity: 0.7;
331
389
  }
332
- `,t=`
390
+ `, g = `
333
391
  <div class="video-container">
334
392
  <video id="player"
335
393
  muted
336
394
  loop
337
395
  playsinline
338
- poster="${this.getAttribute("poster-src")||""}"
396
+ poster="${this.getAttribute("poster-src") || ""}"
339
397
  style="width: 100%; height: 100%;">
340
398
  </video>
341
399
 
342
400
  <div id="control-bar">
343
401
  <div id="progress-row">
344
- ${this.hasAttribute("show-time-display")?'<span class="time-display current-time">0:00</span>':""}
402
+ ${this.hasAttribute("show-time-display") ? '<span class="time-display current-time">0:00</span>' : ""}
345
403
  ${this.renderProgressBar()}
346
- ${this.hasAttribute("show-time-display")?'<span class="time-display duration">0:00</span>':""}
404
+ ${this.hasAttribute("show-time-display") ? '<span class="time-display duration">0:00</span>' : ""}
347
405
  </div>
348
406
  <div id="controls-row">
349
407
  <div class="video-controls">
@@ -371,4 +429,171 @@ Schedule: ${c.map(E=>Pt(E))} pos: ${this.timelinePos}`),h.length&&this.log(`Remo
371
429
  </div>
372
430
  </div>
373
431
  </div>
374
- `;if(this.shadowRoot){const i=new CSSStyleSheet;await i.replace(e),this.shadowRoot.adoptedStyleSheets=[i],this.shadowRoot.innerHTML=t}}async initializePlayer(){if(!this.shadowRoot){console.error("Shadow root not found");return}console.log("Initialize player called");const e=this.shadowRoot.querySelector("video");if(!e){console.error("Video element not found");return}this._videoPlayer=e;const t=this.getAttribute("video-src");if(!t){console.error("Video source is required");return}this._hls&&(this._hls.destroy(),this._hls=void 0),e.removeAttribute("src"),e.load(),e.addEventListener("error",()=>{console.error("Video element error:",e.error)});try{if(ft.isSupported())console.log("HLS.js is supported, initializing..."),await this.initializeHls(e,t);else if(e.canPlayType("application/vnd.apple.mpegurl"))console.log("Using native HLS support"),e.src=t,this.startListeners();else throw new Error("Neither HLS.js nor native HLS is supported")}catch(i){console.error("Failed to initialize player:",i)}}async initializeHls(e,t){return new Promise((i,s)=>{try{const r={debug:!0,enableWorker:!0,lowLatencyMode:!0,backBufferLength:90,startLevel:-1,autoStartLoad:!0,manifestLoadingTimeOut:2e4,manifestLoadingMaxRetry:3,manifestLoadingRetryDelay:500,levelLoadingTimeOut:2e4,levelLoadingMaxRetry:3,levelLoadingRetryDelay:500,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:3,fragLoadingRetryDelay:500,xhrSetup:n=>{n.withCredentials=!1}};this._hls=new ft(r),this._hls.on(ft.Events.ERROR,(n,o)=>{if(console.error("HLS Error:",o),o.fatal)switch(o.type){case ft.ErrorTypes.NETWORK_ERROR:console.log("Fatal network error encountered, trying to recover..."),this._hls?.startLoad();break;case ft.ErrorTypes.MEDIA_ERROR:console.log("Fatal media error encountered, trying to recover..."),this._hls?.recoverMediaError();break;default:console.error("Fatal error, cannot recover:",o.details),this._hls?.destroy(),s(new Error(`Fatal HLS error: ${o.details}`));break}}),this._hls.on(ft.Events.MEDIA_ATTACHED,()=>{console.log("Media attached, loading source:",t),this._hls?.loadSource(t)}),this._hls.on(ft.Events.MANIFEST_PARSED,(n,o)=>{console.log("Manifest parsed, levels:",o.levels),this.startListeners(),i(),this.hasAttribute("auto-play")&&(console.log("Attempting autoplay..."),e.play().then(()=>console.log("Playback started successfully")).catch(async c=>{console.error("Autoplay failed:",c),e.muted=!0;try{await e.play(),console.log("Muted autoplay successful")}catch(u){console.error("Muted autoplay also failed:",u)}}))}),console.log("Attaching media element..."),this._hls.attachMedia(e)}catch(r){console.error("Error in HLS initialization:",r),s(r)}})}startListeners(){if(!this.shadowRoot)return;const e=ui(this.shadowRoot).find(".play"),t=ui(this.shadowRoot).find(".pause"),i=ui(this.shadowRoot).find(".forward"),s=ui(this.shadowRoot).find(".backward"),r=ui(this.shadowRoot).find(".fullscreen");if(e.on("click",()=>this.play()),t.on("click",()=>this.pause()),i.on("click",()=>this.forward()),s.on("click",()=>this.backward()),r.on("click",()=>this.toggleFullscreen()),this._videoPlayer){const n=ui(this.shadowRoot).find(".duration"),o=ui(this.shadowRoot).find(".progress-bar"),c=ui(this.shadowRoot).find(".speed-container");this._videoPlayer.addEventListener("play",()=>{e.hide(),t.show()}),this._videoPlayer.addEventListener("pause",()=>{t.hide(),e.show()}),this._videoPlayer.addEventListener("timeupdate",()=>{if(!this._videoPlayer||!this.shadowRoot)return;const I=this._videoPlayer.currentTime,m=this._videoPlayer.duration,E=I/m*100;if(this.hasAttribute("show-time-display")){const x=this.shadowRoot.querySelector(".current-time");x&&(x.textContent=this.formatTime(I))}const v=this.shadowRoot.querySelector(".progress-bar-fill");if(v instanceof HTMLElement&&(v.style.width=`${E}%`),this.progressBarStyle===Et.Segments){const x=this.shadowRoot.querySelectorAll(".progress-segment");x.forEach((D,L)=>{const w=(L+1)*(100/x.length);E>=w?D.classList.add("filled"):D.classList.remove("filled")})}}),this._videoPlayer.addEventListener("loadedmetadata",()=>{this.hasAttribute("show-time-display")&&n.text(this.formatTime(this._videoPlayer.duration))}),o.on("click",I=>{const m=I.currentTarget.getBoundingClientRect(),E=(I.clientX-m.left)/m.width;this._videoPlayer.currentTime=E*this._videoPlayer.duration});const u=[.25,.5,.75,1,1.25,1.5,2],h=this.getAttribute("playback-speeds")?.split(",").map(Number)||u,f=parseFloat(this.getAttribute("default-speed")||"1");let g=h.indexOf(f);g===-1&&(g=h.indexOf(1)||0),f&&!isNaN(f)&&(this._videoPlayer.playbackRate=f,c.text(`${f}x`)),this.hasAttribute("show-speed-control")?(c.show(),c.html(this.getSpeedIcon(f)),c.on("click",()=>{g=(g+1)%h.length;const I=h[g];this._videoPlayer.playbackRate=I,c.html(this.getSpeedIcon(I))})):c.hide()}}play(){this._videoPlayer&&this._videoPlayer.play()}pause(){this._videoPlayer&&this._videoPlayer.pause()}forward(){this._videoPlayer&&(this._videoPlayer.paused||this._videoPlayer.pause(),this._videoPlayer.currentTime=this._videoPlayer.currentTime+.2*this._videoPlayer.playbackRate)}backward(){this._videoPlayer&&(this._videoPlayer.paused||this._videoPlayer.pause(),this._videoPlayer.currentTime=this._videoPlayer.currentTime-.2*this._videoPlayer.playbackRate)}toggleFullscreen(){this._videoPlayer&&(document.fullscreenElement?document.exitFullscreen():this._videoPlayer.requestFullscreen())}getSpeedIcon(e){const i=`speed-${e.toFixed(2)}`;return this.svgIcons[i]||this.svgIcons["speed-1.00"]}formatTime(e){if(!isFinite(e))return"0:00";const t=Math.floor(e/60),i=Math.floor(e%60);return`${t}:${i.toString().padStart(2,"0")}`}updateControlsColor(){requestAnimationFrame(()=>{if(!this.shadowRoot)return;const e=this.shadowRoot.querySelector(".video-container");e&&(e.classList.remove("light-theme"),this.background==="light"&&e.classList.add("light-theme"))})}disconnectedCallback(){this._hls&&this._hls.destroy()}}customElements.define("v360-player",Bl),Ri.V360Player=Bl,Object.defineProperty(Ri,Symbol.toStringTag,{value:"Module"})}));
432
+ `;
433
+ if (this.shadowRoot) {
434
+ const I = new CSSStyleSheet();
435
+ await I.replace(A), this.shadowRoot.adoptedStyleSheets = [I], this.shadowRoot.innerHTML = g;
436
+ }
437
+ }
438
+ async initializePlayer() {
439
+ if (!this.shadowRoot) {
440
+ console.error("Shadow root not found");
441
+ return;
442
+ }
443
+ console.log("Initialize player called");
444
+ const A = this.shadowRoot.querySelector("video");
445
+ if (!A) {
446
+ console.error("Video element not found");
447
+ return;
448
+ }
449
+ this._videoPlayer = A;
450
+ const g = this.getAttribute("video-src");
451
+ if (!g) {
452
+ console.error("Video source is required");
453
+ return;
454
+ }
455
+ this._hls && (this._hls.destroy(), this._hls = void 0), A.removeAttribute("src"), A.load(), A.addEventListener("error", () => {
456
+ console.error("Video element error:", A.error);
457
+ });
458
+ try {
459
+ if (l.isSupported())
460
+ console.log("HLS.js is supported, initializing..."), await this.initializeHls(A, g);
461
+ else if (A.canPlayType("application/vnd.apple.mpegurl"))
462
+ console.log("Using native HLS support"), A.src = g, this.startListeners();
463
+ else
464
+ throw new Error("Neither HLS.js nor native HLS is supported");
465
+ } catch (I) {
466
+ console.error("Failed to initialize player:", I);
467
+ }
468
+ }
469
+ async initializeHls(A, g) {
470
+ return new Promise((I, s) => {
471
+ try {
472
+ const i = {
473
+ debug: !0,
474
+ enableWorker: !0,
475
+ lowLatencyMode: !0,
476
+ backBufferLength: 90,
477
+ startLevel: -1,
478
+ autoStartLoad: !0,
479
+ manifestLoadingTimeOut: 2e4,
480
+ manifestLoadingMaxRetry: 3,
481
+ manifestLoadingRetryDelay: 500,
482
+ levelLoadingTimeOut: 2e4,
483
+ levelLoadingMaxRetry: 3,
484
+ levelLoadingRetryDelay: 500,
485
+ fragLoadingTimeOut: 2e4,
486
+ fragLoadingMaxRetry: 3,
487
+ fragLoadingRetryDelay: 500,
488
+ xhrSetup: (t) => {
489
+ t.withCredentials = !1;
490
+ }
491
+ };
492
+ this._hls = new l(i), this._hls.on(l.Events.ERROR, (t, C) => {
493
+ if (console.error("HLS Error:", C), C.fatal)
494
+ switch (C.type) {
495
+ case l.ErrorTypes.NETWORK_ERROR:
496
+ console.log("Fatal network error encountered, trying to recover..."), this._hls?.startLoad();
497
+ break;
498
+ case l.ErrorTypes.MEDIA_ERROR:
499
+ console.log("Fatal media error encountered, trying to recover..."), this._hls?.recoverMediaError();
500
+ break;
501
+ default:
502
+ console.error("Fatal error, cannot recover:", C.details), this._hls?.destroy(), s(new Error(`Fatal HLS error: ${C.details}`));
503
+ break;
504
+ }
505
+ }), this._hls.on(l.Events.MEDIA_ATTACHED, () => {
506
+ console.log("Media attached, loading source:", g), this._hls?.loadSource(g);
507
+ }), this._hls.on(l.Events.MANIFEST_PARSED, (t, C) => {
508
+ console.log("Manifest parsed, levels:", C.levels), this.startListeners(), I(), this.hasAttribute("auto-play") && (console.log("Attempting autoplay..."), A.play().then(() => console.log("Playback started successfully")).catch(async (o) => {
509
+ console.error("Autoplay failed:", o), A.muted = !0;
510
+ try {
511
+ await A.play(), console.log("Muted autoplay successful");
512
+ } catch (n) {
513
+ console.error("Muted autoplay also failed:", n);
514
+ }
515
+ }));
516
+ }), console.log("Attaching media element..."), this._hls.attachMedia(A);
517
+ } catch (i) {
518
+ console.error("Error in HLS initialization:", i), s(i);
519
+ }
520
+ });
521
+ }
522
+ startListeners() {
523
+ if (!this.shadowRoot) return;
524
+ const A = a(this.shadowRoot).find(".play"), g = a(this.shadowRoot).find(".pause"), I = a(this.shadowRoot).find(".forward"), s = a(this.shadowRoot).find(".backward"), i = a(this.shadowRoot).find(".fullscreen");
525
+ if (A.on("click", () => this.play()), g.on("click", () => this.pause()), I.on("click", () => this.forward()), s.on("click", () => this.backward()), i.on("click", () => this.toggleFullscreen()), this._videoPlayer) {
526
+ const t = a(this.shadowRoot).find(".duration"), C = a(this.shadowRoot).find(".progress-bar"), o = a(this.shadowRoot).find(".speed-container");
527
+ this._videoPlayer.addEventListener("play", () => {
528
+ A.hide(), g.show();
529
+ }), this._videoPlayer.addEventListener("pause", () => {
530
+ g.hide(), A.show();
531
+ }), this._videoPlayer.addEventListener("timeupdate", () => {
532
+ if (!this._videoPlayer || !this.shadowRoot) return;
533
+ const r = this._videoPlayer.currentTime, m = this._videoPlayer.duration, u = r / m * 100;
534
+ if (this.hasAttribute("show-time-display")) {
535
+ const h = this.shadowRoot.querySelector(".current-time");
536
+ h && (h.textContent = this.formatTime(r));
537
+ }
538
+ const b = this.shadowRoot.querySelector(".progress-bar-fill");
539
+ if (b instanceof HTMLElement && (b.style.width = `${u}%`), this.progressBarStyle === e.Segments) {
540
+ const h = this.shadowRoot.querySelectorAll(".progress-segment");
541
+ h.forEach((M, w) => {
542
+ const y = (w + 1) * (100 / h.length);
543
+ u >= y ? M.classList.add("filled") : M.classList.remove("filled");
544
+ });
545
+ }
546
+ }), this._videoPlayer.addEventListener("loadedmetadata", () => {
547
+ this.hasAttribute("show-time-display") && t.text(this.formatTime(this._videoPlayer.duration));
548
+ }), C.on("click", (r) => {
549
+ const m = r.currentTarget.getBoundingClientRect(), u = (r.clientX - m.left) / m.width;
550
+ this._videoPlayer.currentTime = u * this._videoPlayer.duration;
551
+ });
552
+ const n = [0.25, 0.5, 0.75, 1, 1.25, 1.5, 2], p = this.getAttribute("playback-speeds")?.split(",").map(Number) || n, d = parseFloat(this.getAttribute("default-speed") || "1");
553
+ let c = p.indexOf(d);
554
+ c === -1 && (c = p.indexOf(1) || 0), d && !isNaN(d) && (this._videoPlayer.playbackRate = d, o.text(`${d}x`)), this.hasAttribute("show-speed-control") ? (o.show(), o.html(this.getSpeedIcon(d)), o.on("click", () => {
555
+ c = (c + 1) % p.length;
556
+ const r = p[c];
557
+ this._videoPlayer.playbackRate = r, o.html(this.getSpeedIcon(r));
558
+ })) : o.hide();
559
+ }
560
+ }
561
+ play() {
562
+ this._videoPlayer && this._videoPlayer.play();
563
+ }
564
+ pause() {
565
+ this._videoPlayer && this._videoPlayer.pause();
566
+ }
567
+ forward() {
568
+ this._videoPlayer && (this._videoPlayer.paused || this._videoPlayer.pause(), this._videoPlayer.currentTime = this._videoPlayer.currentTime + 0.2 * this._videoPlayer.playbackRate);
569
+ }
570
+ backward() {
571
+ this._videoPlayer && (this._videoPlayer.paused || this._videoPlayer.pause(), this._videoPlayer.currentTime = this._videoPlayer.currentTime - 0.2 * this._videoPlayer.playbackRate);
572
+ }
573
+ toggleFullscreen() {
574
+ this._videoPlayer && (document.fullscreenElement ? document.exitFullscreen() : this._videoPlayer.requestFullscreen());
575
+ }
576
+ getSpeedIcon(A) {
577
+ const I = `speed-${A.toFixed(2)}`;
578
+ return this.svgIcons[I] || this.svgIcons["speed-1.00"];
579
+ }
580
+ formatTime(A) {
581
+ if (!isFinite(A)) return "0:00";
582
+ const g = Math.floor(A / 60), I = Math.floor(A % 60);
583
+ return `${g}:${I.toString().padStart(2, "0")}`;
584
+ }
585
+ updateControlsColor() {
586
+ requestAnimationFrame(() => {
587
+ if (!this.shadowRoot) return;
588
+ const A = this.shadowRoot.querySelector(".video-container");
589
+ A && (A.classList.remove("light-theme"), this.background === "light" && A.classList.add("light-theme"));
590
+ });
591
+ }
592
+ disconnectedCallback() {
593
+ this._hls && this._hls.destroy();
594
+ }
595
+ }
596
+ customElements.define("v360-player", j);
597
+ export {
598
+ j as V360Player
599
+ };