vvpf
Version:
hls.js player component for Vue3
11 lines • 532 kB
JavaScript
(function(Ue,T){typeof exports=="object"&&typeof module<"u"?T(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],T):(Ue=typeof globalThis<"u"?globalThis:Ue||self,T(Ue.index={},Ue.Vue))})(this,function(Ue,T){"use strict";function La(a,e,t){var s=t||{},i=s.noTrailing,r=i===void 0?!1:i,n=s.noLeading,o=n===void 0?!1:n,c=s.debounceMode,l=c===void 0?void 0:c,d,h=!1,u=0;function f(){d&&clearTimeout(d)}function g(p){var E=p||{},v=E.upcomingOnly,S=v===void 0?!1:v;f(),h=!S}function y(){for(var p=arguments.length,E=new Array(p),v=0;v<p;v++)E[v]=arguments[v];var S=this,x=Date.now()-u;if(h)return;function A(){u=Date.now(),e.apply(S,E)}function D(){d=void 0}!o&&l&&!d&&A(),f(),l===void 0&&x>a?o?(u=Date.now(),r||(d=setTimeout(l?D:A,a))):A():r!==!0&&(d=setTimeout(l?D:A,l===void 0?a-x:a))}return y.cancel=g,y}function Pi(a,e,t){var s=t||{},i=s.atBegin,r=i===void 0?!1:i;return La(a,e,{debounceMode:r!==!1})}const B=Number.isFinite||function(a){return typeof a=="number"&&isFinite(a)},Ia=Number.isSafeInteger||function(a){return typeof a=="number"&&Math.abs(a)<=Ra},Ra=Number.MAX_SAFE_INTEGER||9007199254740991;let K=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}({}),b=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}({}),m=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 Q={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},G={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};class ot{constructor(e,t=0,s=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_=s}sample(e,t){const s=Math.pow(this.alpha_,e);this.estimate_=t*(1-s)+s*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 ba{constructor(e,t,s,i=100){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=s,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new ot(e),this.fast_=new ot(t),this.defaultTTFB_=i,this.ttfb_=new ot(e)}update(e,t){const{slow_:s,fast_:i,ttfb_:r}=this;s.halfLife!==e&&(this.slow_=new ot(e,s.getEstimate(),s.getTotalWeight())),i.halfLife!==t&&(this.fast_=new ot(t,i.getEstimate(),i.getTotalWeight())),r.halfLife!==e&&(this.ttfb_=new ot(e,r.getEstimate(),r.getTotalWeight()))}sample(e,t){e=Math.max(e,this.minDelayMs_);const s=8*t,i=e/1e3,r=s/i;this.fast_.sample(i,r),this.slow_.sample(i,r)}sampleTTFB(e){const t=e/1e3,s=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(s,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 _a(a,e,t){return(e=Ca(e))in a?Object.defineProperty(a,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):a[e]=t,a}function re(){return re=Object.assign?Object.assign.bind():function(a){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var s in t)({}).hasOwnProperty.call(t,s)&&(a[s]=t[s])}return a},re.apply(null,arguments)}function wi(a,e){var t=Object.keys(a);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(a);e&&(s=s.filter(function(i){return Object.getOwnPropertyDescriptor(a,i).enumerable})),t.push.apply(t,s)}return t}function te(a){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?wi(Object(t),!0).forEach(function(s){_a(a,s,t[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(t)):wi(Object(t)).forEach(function(s){Object.defineProperty(a,s,Object.getOwnPropertyDescriptor(t,s))})}return a}function Da(a,e){if(typeof a!="object"||!a)return a;var t=a[Symbol.toPrimitive];if(t!==void 0){var s=t.call(a,e);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(a)}function Ca(a){var e=Da(a,"string");return typeof e=="symbol"?e:e+""}class $e{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 s=`[${e}]:`;this.trace=Ye,this.debug=t.debug.bind(null,s),this.log=t.log.bind(null,s),this.warn=t.warn.bind(null,s),this.info=t.info.bind(null,s),this.error=t.error.bind(null,s)}}const Ye=function(){},ka={trace:Ye,debug:Ye,log:Ye,warn:Ye,info:Ye,error:Ye};function Es(){return re({},ka)}function Pa(a,e){const t=self.console[a];return t?t.bind(self.console,`${e?"["+e+"] ":""}[${a}] >`):Ye}function Oi(a,e,t){return e[a]?e[a].bind(e):Pa(a,t)}const Ts=Es();function wa(a,e,t){const s=Es();if(typeof console=="object"&&a===!0||typeof a=="object"){const i=["debug","log","info","warn","error"];i.forEach(r=>{s[r]=Oi(r,a,t)});try{s.log(`Debug logs enabled for "${e}" in hls.js version 1.6.2`)}catch{return Es()}i.forEach(r=>{Ts[r]=Oi(r,a)})}else re(Ts,s);return s}const Z=Ts;function qe(a=!0){return typeof self>"u"?void 0:(a||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function Oa(a){return typeof self<"u"&&a===self.ManagedMediaSource}function Fi(a,e){const t=Object.keys(a),s=Object.keys(e),i=t.length,r=s.length;return!i||!r||i===r&&!t.some(n=>s.indexOf(n)===-1)}function Te(a,e=!1){if(typeof TextDecoder<"u"){const l=new TextDecoder("utf-8").decode(a);if(e){const d=l.indexOf("\0");return d!==-1?l.substring(0,d):l}return l.replace(/\0/g,"")}const t=a.length;let s,i,r,n="",o=0;for(;o<t;){if(s=a[o++],s===0&&e)return n;if(s===0||s===3)continue;switch(s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:n+=String.fromCharCode(s);break;case 12:case 13:i=a[o++],n+=String.fromCharCode((s&31)<<6|i&63);break;case 14:i=a[o++],r=a[o++],n+=String.fromCharCode((s&15)<<12|(i&63)<<6|(r&63)<<0);break}}return n}const De={hexDump:function(a){let e="";for(let t=0;t<a.length;t++){let s=a[t].toString(16);s.length<2&&(s="0"+s),e+=s}return e}};function Fa(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var Ss={exports:{}},Mi;function Ma(){return Mi||(Mi=1,function(a,e){(function(t){var s=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,i=/^(?=([^\/?#]*))\1([^]*)$/,r=/(?:\/|^)\.(?=\/)/g,n=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(c,l,d){if(d=d||{},c=c.trim(),l=l.trim(),!l){if(!d.alwaysNormalize)return c;var h=o.parseURL(c);if(!h)throw new Error("Error trying to parse base URL.");return h.path=o.normalizePath(h.path),o.buildURLFromParts(h)}var u=o.parseURL(l);if(!u)throw new Error("Error trying to parse relative URL.");if(u.scheme)return d.alwaysNormalize?(u.path=o.normalizePath(u.path),o.buildURLFromParts(u)):l;var f=o.parseURL(c);if(!f)throw new Error("Error trying to parse base URL.");if(!f.netLoc&&f.path&&f.path[0]!=="/"){var g=i.exec(f.path);f.netLoc=g[1],f.path=g[2]}f.netLoc&&!f.path&&(f.path="/");var y={scheme:f.scheme,netLoc:u.netLoc,path:null,params:u.params,query:u.query,fragment:u.fragment};if(!u.netLoc&&(y.netLoc=f.netLoc,u.path[0]!=="/"))if(!u.path)y.path=f.path,u.params||(y.params=f.params,u.query||(y.query=f.query));else{var p=f.path,E=p.substring(0,p.lastIndexOf("/")+1)+u.path;y.path=o.normalizePath(E)}return y.path===null&&(y.path=d.alwaysNormalize?o.normalizePath(u.path):u.path),o.buildURLFromParts(y)},parseURL:function(c){var l=s.exec(c);return l?{scheme:l[1]||"",netLoc:l[2]||"",path:l[3]||"",params:l[4]||"",query:l[5]||"",fragment:l[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})()}(Ss)),Ss.exports}var vs=Ma();class xs{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 ne={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class Ni{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,Ba(this,"stats")}setByteRange(e,t){const s=e.split("@",2);let i;s.length===1?i=(t==null?void 0:t.byteRangeEndOffset)||0:i=parseInt(s[1]),this._byteRange=[i,parseInt(s[0])+i]}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={[ne.AUDIO]:null,[ne.VIDEO]:null,[ne.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 xs),this._stats}set stats(e){this._stats=e}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=vs.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[ne.AUDIO]=null,e[ne.VIDEO]=null,e[ne.AUDIOVIDEO]=null}}function he(a){return a.sn!=="initSegment"}class As extends Ni{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){const e=this.byteRange[0],t=this.byteRange[1];if(B(e)&&B(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 s=Object.keys(this.levelkeys);if(s.length===1)return this._decryptdata=this.levelkeys[s[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null)return null;const e=B(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){const t=Object.keys(this.levelkeys),s=t.length;if(s>1||s===1&&this.levelkeys[t[0]].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(!B(e)){this._programDateTime=this.rawProgramDateTime=null;return}this._programDateTime=e}get ref(){return he(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,s,i,r,n=!1){const{elementaryStreams:o}=this,c=o[e];if(!c){o[e]={startPTS:t,endPTS:s,startDTS:i,endDTS:r,partial:n};return}c.startPTS=Math.min(c.startPTS,t),c.endPTS=Math.max(c.endPTS,s),c.startDTS=Math.min(c.startDTS,i),c.endDTS=Math.max(c.endDTS,r)}}class Na extends Ni{constructor(e,t,s,i,r){super(s),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=i;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 Bi(a,e){const t=Object.getPrototypeOf(a);if(t){const s=Object.getOwnPropertyDescriptor(t,e);return s||Bi(t,e)}}function Ba(a,e){const t=Bi(a,e);t&&(t.enumerable=!0,Object.defineProperty(a,e,t))}const Nt=Math.pow(2,32)-1,Ua=[].push,Ui={video:1,audio:2,id3:3,text:4};function ce(a){return String.fromCharCode.apply(null,a)}function $i(a,e){const t=a[e]<<8|a[e+1];return t<0?65536+t:t}function Y(a,e){const t=Vi(a,e);return t<0?4294967296+t:t}function Gi(a,e){let t=Y(a,e);return t*=Math.pow(2,32),t+=Y(a,e+4),t}function Vi(a,e){return a[e]<<24|a[e+1]<<16|a[e+2]<<8|a[e+3]}function Ls(a,e,t){a[e]=t>>24,a[e+1]=t>>16&255,a[e+2]=t>>8&255,a[e+3]=t&255}function $a(a){const e=a.byteLength;for(let t=0;t<e;){const s=Y(a,t);if(s>8&&a[t+4]===109&&a[t+5]===111&&a[t+6]===111&&a[t+7]===102)return!0;t=s>1?t+s:e}return!1}function j(a,e){const t=[];if(!e.length)return t;const s=a.byteLength;for(let i=0;i<s;){const r=Y(a,i),n=ce(a.subarray(i+4,i+8)),o=r>1?i+r:s;if(n===e[0])if(e.length===1)t.push(a.subarray(i+8,o));else{const c=j(a.subarray(i+8,o),e.slice(1));c.length&&Ua.apply(t,c)}i=o}return t}function Ga(a){const e=[],t=a[0];let s=8;const i=Y(a,s);s+=4;let r=0,n=0;t===0?(r=Y(a,s),n=Y(a,s+4),s+=8):(r=Gi(a,s),n=Gi(a,s+8),s+=16),s+=2;let o=a.length+n;const c=$i(a,s);s+=2;for(let l=0;l<c;l++){let d=s;const h=Y(a,d);d+=4;const u=h&2147483647;if((h&2147483648)>>>31===1)return Z.warn("SIDX has hierarchical references (not supported)"),null;const g=Y(a,d);d+=4,e.push({referenceSize:u,subsegmentDuration:g,info:{duration:g/i,start:o,end:o+u-1}}),o+=u,d+=4,s=d}return{earliestPresentationTime:r,timescale:i,version:t,referencesCount:c,references:e}}function Ki(a){const e=[],t=j(a,["moov","trak"]);for(let i=0;i<t.length;i++){const r=t[i],n=j(r,["tkhd"])[0];if(n){let o=n[0];const c=Y(n,o===0?12:20),l=j(r,["mdia","mdhd"])[0];if(l){o=l[0];const d=Y(l,o===0?12:20),h=j(r,["mdia","hdlr"])[0];if(h){const u=ce(h.subarray(8,12)),f={soun:ne.AUDIO,vide:ne.VIDEO}[u],g=j(r,["mdia","minf","stbl","stsd"])[0],y=Va(g);f?(e[c]={timescale:d,type:f,stsd:y},e[f]=te({timescale:d,id:c},y)):e[c]={timescale:d,type:u,stsd:y}}}}}return j(a,["moov","mvex","trex"]).forEach(i=>{const r=Y(i,4),n=e[r];n&&(n.default={duration:Y(i,12),flags:Y(i,20)})}),e}function Va(a){const e=a.subarray(8),t=e.subarray(8+78),s=ce(e.subarray(4,8));let i=s,r;const n=s==="enca"||s==="encv";if(n){const l=j(e,[s])[0].subarray(s==="enca"?28:78);j(l,["sinf"]).forEach(h=>{const u=j(h,["schm"])[0];if(u){const f=ce(u.subarray(4,8));if(f==="cbcs"||f==="cenc"){const g=j(h,["frma"])[0];g&&(i=ce(g))}}})}const o=i;switch(i){case"avc1":case"avc2":case"avc3":case"avc4":{const c=j(t,["avcC"])[0];c&&c.length>3&&(i+="."+Ut(c[1])+Ut(c[2])+Ut(c[3]),r=Bt(o==="avc1"?"dva1":"dvav",t));break}case"mp4a":{const c=j(e,[s])[0],l=j(c.subarray(28),["esds"])[0];if(l&&l.length>7){let d=4;if(l[d++]!==3)break;d=Is(l,d),d+=2;const h=l[d++];if(h&128&&(d+=2),h&64&&(d+=l[d++]),l[d++]!==4)break;d=Is(l,d);const u=l[d++];if(u===64)i+="."+Ut(u);else break;if(d+=12,l[d++]!==5)break;d=Is(l,d);const f=l[d++];let g=(f&248)>>3;g===31&&(g+=1+((f&7)<<3)+((l[d]&224)>>5)),i+="."+g}break}case"hvc1":case"hev1":{const c=j(t,["hvcC"])[0];if(c&&c.length>12){const l=c[1],d=["","A","B","C"][l>>6],h=l&31,u=Y(c,2),f=(l&32)>>5?"H":"L",g=c[12],y=c.subarray(6,12);i+="."+d+h,i+="."+u.toString(16).toUpperCase(),i+="."+f+g;let p="";for(let E=y.length;E--;){const v=y[E];(v||p)&&(p="."+v.toString(16).toUpperCase()+p)}i+=p}r=Bt(o=="hev1"?"dvhe":"dvh1",t);break}case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":{i=Bt(i,t)||i;break}case"vp09":{const c=j(t,["vpcC"])[0];if(c&&c.length>6){const l=c[4],d=c[5],h=c[6]>>4&15;i+="."+Ce(l)+"."+Ce(d)+"."+Ce(h)}break}case"av01":{const c=j(t,["av1C"])[0];if(c&&c.length>2){const l=c[1]>>>5,d=c[1]&31,h=c[2]>>>7?"H":"M",u=(c[2]&64)>>6,f=(c[2]&32)>>5,g=l===2&&u?f?12:10:u?10:8,y=(c[2]&16)>>4,p=(c[2]&8)>>3,E=(c[2]&4)>>2,v=c[2]&3,S=1,x=1,A=1,D=0;i+="."+l+"."+Ce(d)+h+"."+Ce(g)+"."+y+"."+p+E+v+"."+Ce(S)+"."+Ce(x)+"."+Ce(A)+"."+D,r=Bt("dav1",t)}break}}return{codec:i,encrypted:n,supplemental:r}}function Bt(a,e){const t=j(e,["dvvC"]),s=t.length?t[0]:j(e,["dvcC"])[0];if(s){const i=s[2]>>1&127,r=s[2]<<5&32|s[3]>>3&31;return a+"."+Ce(i)+"."+Ce(r)}}function Is(a,e){const t=e+5;for(;a[e++]&128&&e<t;);return e}function Ut(a){return("0"+a.toString(16).toUpperCase()).slice(-2)}function Ce(a){return(a<10?"0":"")+a}function Ka(a,e){if(!a||!e)return a;const t=e.keyId;return t&&e.isCommonEncryption&&j(a,["moov","trak"]).forEach(i=>{const n=j(i,["mdia","minf","stbl","stsd"])[0].subarray(8);let o=j(n,["enca"]);const c=o.length>0;c||(o=j(n,["encv"])),o.forEach(l=>{const d=c?l.subarray(28):l.subarray(78);j(d,["sinf"]).forEach(u=>{const f=Hi(u);if(f){const g=f.subarray(8,24);g.some(y=>y!==0)||(Z.log(`[eme] Patching keyId in 'enc${c?"a":"v"}>sinf>>tenc' box: ${De.hexDump(g)} -> ${De.hexDump(t)}`),f.set(t,8))}})})}),a}function Hi(a){const e=j(a,["schm"])[0];if(e){const t=ce(e.subarray(4,8));if(t==="cbcs"||t==="cenc")return j(a,["schi","tenc"])[0]}return null}function Ha(a,e){return j(e,["moof","traf"]).reduce((t,s)=>{const i=j(s,["tfdt"])[0],r=i[0],n=j(s,["tfhd"]).reduce((o,c)=>{const l=Y(c,4),d=a[l];if(d){let h=Y(i,4);if(r===1){if(h===Nt)return Z.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),o;h*=Nt+1,h+=Y(i,8)}const u=d.timescale||9e4,f=h/u;if(B(f)&&(o===null||f<o))return f}return o},null);return n!==null&&B(n)&&(t===null||n<t)?n:t},null)}function Wa(a,e){let t=0,s=0,i=0;const r=j(a,["moof","traf"]);for(let n=0;n<r.length;n++){const o=r[n],c=j(o,["tfhd"])[0],l=Y(c,4),d=e[l];if(!d)continue;const h=d.default,u=Y(c,0)|(h==null?void 0:h.flags);let f=h==null?void 0:h.duration;u&8&&(u&2?f=Y(c,12):f=Y(c,8));const g=d.timescale||9e4,y=j(o,["trun"]);for(let p=0;p<y.length;p++){if(t=Ya(y[p]),!t&&f){const E=Y(y[p],4);t=f*E}d.type===ne.VIDEO?s+=t/g:d.type===ne.AUDIO&&(i+=t/g)}}if(s===0&&i===0){let n=1/0,o=0,c=0;const l=j(a,["sidx"]);for(let d=0;d<l.length;d++){const h=Ga(l[d]);if(h!=null&&h.references){n=Math.min(n,h.earliestPresentationTime/h.timescale);const u=h.references.reduce((f,g)=>f+g.info.duration||0,0);o=Math.max(o,u+h.earliestPresentationTime/h.timescale),c=o-n}}if(c&&B(c))return c}return s||i}function Ya(a){const e=Y(a,0);let t=8;e&1&&(t+=4),e&4&&(t+=4);let s=0;const i=Y(a,4);for(let r=0;r<i;r++){if(e&256){const n=Y(a,t);s+=n,t+=4}e&512&&(t+=4),e&1024&&(t+=4),e&2048&&(t+=4)}return s}function qa(a,e,t){j(e,["moof","traf"]).forEach(s=>{j(s,["tfhd"]).forEach(i=>{const r=Y(i,4),n=a[r];if(!n)return;const o=n.timescale||9e4;j(s,["tfdt"]).forEach(c=>{const l=c[0],d=t*o;if(d){let h=Y(c,4);if(l===0)h-=d,h=Math.max(h,0),Ls(c,4,h);else{h*=Math.pow(2,32),h+=Y(c,8),h-=d,h=Math.max(h,0);const u=Math.floor(h/(Nt+1)),f=Math.floor(h%(Nt+1));Ls(c,4,u),Ls(c,8,f)}}})})})}function ja(a){const e={valid:null,remainder:null},t=j(a,["moof"]);if(t.length<2)return e.remainder=a,e;const s=t[t.length-1];return e.valid=a.slice(0,s.byteOffset-8),e.remainder=a.slice(s.byteOffset-8),e}function xe(a,e){const t=new Uint8Array(a.length+e.length);return t.set(a),t.set(e,a.length),t}function Wi(a,e){const t=[],s=e.samples,i=e.timescale,r=e.id;let n=!1;return j(s,["moof"]).map(c=>{const l=c.byteOffset-8;j(c,["traf"]).map(h=>{const u=j(h,["tfdt"]).map(f=>{const g=f[0];let y=Y(f,4);return g===1&&(y*=Math.pow(2,32),y+=Y(f,8)),y/i})[0];return u!==void 0&&(a=u),j(h,["tfhd"]).map(f=>{const g=Y(f,4),y=Y(f,0)&16777215,p=(y&1)!==0,E=(y&2)!==0,v=(y&8)!==0;let S=0;const x=(y&16)!==0;let A=0;const D=(y&32)!==0;let L=8;g===r&&(p&&(L+=8),E&&(L+=4),v&&(S=Y(f,L),L+=4),x&&(A=Y(f,L),L+=4),D&&(L+=4),e.type==="video"&&(n=$t(e.codec)),j(h,["trun"]).map(_=>{const k=_[0],I=Y(_,0)&16777215,O=(I&1)!==0;let M=0;const X=(I&4)!==0,W=(I&256)!==0;let H=0;const U=(I&512)!==0;let V=0;const $=(I&1024)!==0,F=(I&2048)!==0;let C=0;const w=Y(_,4);let N=8;O&&(M=Y(_,N),N+=4),X&&(N+=4);let q=M+l;for(let J=0;J<w;J++){if(W?(H=Y(_,N),N+=4):H=S,U?(V=Y(_,N),N+=4):V=A,$&&(N+=4),F&&(k===0?C=Y(_,N):C=Vi(_,N),N+=4),e.type===ne.VIDEO){let ie=0;for(;ie<V;){const ae=Y(s,q);if(q+=4,za(n,s[q])){const me=s.subarray(q,q+ae);Rs(me,n?2:1,a+C/i,t)}q+=ae,ie+=ae+4}}a+=H/i}}))})})}),t}function $t(a){if(!a)return!1;const e=a.substring(0,4);return e==="hvc1"||e==="hev1"||e==="dvh1"||e==="dvhe"}function za(a,e){if(a){const t=e>>1&63;return t===39||t===40}else return(e&31)===6}function Rs(a,e,t,s){const i=Yi(a);let r=0;r+=e;let n=0,o=0,c=0;for(;r<i.length;){n=0;do{if(r>=i.length)break;c=i[r++],n+=c}while(c===255);o=0;do{if(r>=i.length)break;c=i[r++],o+=c}while(c===255);const l=i.length-r;let d=r;if(o<l)r+=o;else if(o>l){Z.error(`Malformed SEI payload. ${o} is too small, only ${l} bytes left to parse.`);break}if(n===4){if(i[d++]===181){const u=$i(i,d);if(d+=2,u===49){const f=Y(i,d);if(d+=4,f===1195456820){const g=i[d++];if(g===3){const y=i[d++],p=31&y,E=64&y,v=E?2+p*3:0,S=new Uint8Array(v);if(E){S[0]=y;for(let x=1;x<v;x++)S[x]=i[d++]}s.push({type:g,payloadType:n,pts:t,bytes:S})}}}}}else if(n===5&&o>16){const h=[];for(let g=0;g<16;g++){const y=i[d++].toString(16);h.push(y.length==1?"0"+y:y),(g===3||g===5||g===7||g===9)&&h.push("-")}const u=o-16,f=new Uint8Array(u);for(let g=0;g<u;g++)f[g]=i[d++];s.push({payloadType:n,pts:t,uuid:h.join(""),userData:Te(f),userDataBytes:f})}}}function Yi(a){const e=a.byteLength,t=[];let s=1;for(;s<e-2;)a[s]===0&&a[s+1]===0&&a[s+2]===3?(t.push(s+2),s+=2):s++;if(t.length===0)return a;const i=e-t.length,r=new Uint8Array(i);let n=0;for(s=0;s<i;n++,s++)n===t[0]&&(n++,t.shift()),r[s]=a[n];return r}function Xa(a){const e=a[0];let t="",s="",i=0,r=0,n=0,o=0,c=0,l=0;if(e===0){for(;ce(a.subarray(l,l+1))!=="\0";)t+=ce(a.subarray(l,l+1)),l+=1;for(t+=ce(a.subarray(l,l+1)),l+=1;ce(a.subarray(l,l+1))!=="\0";)s+=ce(a.subarray(l,l+1)),l+=1;s+=ce(a.subarray(l,l+1)),l+=1,i=Y(a,12),r=Y(a,16),o=Y(a,20),c=Y(a,24),l=28}else if(e===1){l+=4,i=Y(a,l),l+=4;const h=Y(a,l);l+=4;const u=Y(a,l);for(l+=4,n=2**32*h+u,Ia(n)||(n=Number.MAX_SAFE_INTEGER,Z.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=Y(a,l),l+=4,c=Y(a,l),l+=4;ce(a.subarray(l,l+1))!=="\0";)t+=ce(a.subarray(l,l+1)),l+=1;for(t+=ce(a.subarray(l,l+1)),l+=1;ce(a.subarray(l,l+1))!=="\0";)s+=ce(a.subarray(l,l+1)),l+=1;s+=ce(a.subarray(l,l+1)),l+=1}const d=a.subarray(l,a.byteLength);return{schemeIdUri:t,value:s,timeScale:i,presentationTime:n,presentationTimeDelta:r,eventDuration:o,id:c,payload:d}}function Qa(a,...e){const t=e.length;let s=8,i=t;for(;i--;)s+=e[i].byteLength;const r=new Uint8Array(s);for(r[0]=s>>24&255,r[1]=s>>16&255,r[2]=s>>8&255,r[3]=s&255,r.set(a,4),i=0,s=8;i<t;i++)r.set(e[i],s),s+=e[i].byteLength;return r}function Za(a,e,t){if(a.byteLength!==16)throw new RangeError("Invalid system id");let s,i;s=0,i=new Uint8Array;let r;s>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&&t.byteLength>0&&new DataView(n.buffer).setUint32(0,t.byteLength,!1),Qa([112,115,115,104],new Uint8Array([s,0,0,0]),a,r,i,n,t||new Uint8Array)}function Ja(a){const e=[];if(a instanceof ArrayBuffer){const t=a.byteLength;let s=0;for(;s+32<t;){const i=new DataView(a,s),r=eo(i);e.push(r),s+=r.size}}return e}function eo(a){const e=a.getUint32(0),t=a.byteOffset,s=a.byteLength;if(s<e)return{offset:t,size:s};if(a.getUint32(4)!==1886614376)return{offset:t,size:e};const r=a.getUint32(8)>>>24;if(r!==0&&r!==1)return{offset:t,size:e};const n=a.buffer,o=De.hexDump(new Uint8Array(n,t+12,16)),c=a.getUint32(28);let l=null,d=null;if(r===0){if(e-32<c||c<22)return{offset:t,size:e};d=new Uint8Array(n,t+32,c)}else if(r===1){if(!c||s<t+32+c*16+16)return{offset:t,size:e};l=[];for(let h=0;h<c;h++)l.push(new Uint8Array(n,t+32+h*16,16))}return{version:r,systemId:o,kids:l,data:d,offset:t,size:e}}const qi=()=>/\(Windows.+Firefox\//i.test(navigator.userAgent),lt={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 ji(a,e){const t=lt[e];return!!t&&!!t[a.slice(0,4)]}function bs(a,e,t=!0){return!a.split(",").some(s=>!zi(s,e,t))}function zi(a,e,t=!0){var s;const i=qe(t);return(s=i==null?void 0:i.isTypeSupported(Tt(a,e)))!=null?s:!1}function Tt(a,e){return`${e}/mp4;codecs=${a}`}function Xi(a){if(a){const e=a.substring(0,4);return lt.video[e]}return 2}function Gt(a){const e=qi();return a.split(",").reduce((t,s)=>{const r=e&&$t(s)?9:lt.video[s];return r?(r*2+t)/(t?3:2):(lt.audio[s]+t)/(t?2:1)},0)}const _s={};function to(a,e=!0){if(_s[a])return _s[a];const t={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[a];for(let i=0;i<t.length;i++){var s;if(zi(t[i],"audio",e))return _s[a]=t[i],t[i];if(t[i]==="mp3"&&(s=qe(e))!=null&&s.isTypeSupported("audio/mpeg"))return""}return a}const so=/flac|opus|mp4a\.40\.34/i;function Vt(a,e=!0){return a.replace(so,t=>to(t.toLowerCase(),e))}function io(a,e){const t=[];if(a){const s=a.split(",");for(let i=0;i<s.length;i++)ji(s[i],"video")||t.push(s[i])}return e&&t.push(e),t.join(",")}function Kt(a,e){if(a&&(a.length>4||["ac-3","ec-3","alac","fLaC","Opus"].indexOf(a)!==-1))return a;if(e){const t=e.split(",");if(t.length>1){if(a){for(let s=t.length;s--;)if(t[s].substring(0,4)===a.substring(0,4))return t[s]}return t[0]}}return e||a}function ro(a){const e=a.split(",");for(let t=0;t<e.length;t++){const s=e[t].split(".");if(s.length>2){let i=s.shift()+".";i+=parseInt(s.shift()).toString(16),i+=("000"+parseInt(s.shift()).toString(16)).slice(-4),e[t]=i}}return e.join(",")}function no(a){if(a.startsWith("av01.")){const e=a.split("."),t=["0","111","01","01","01","0"];for(let s=e.length;s>4&&s<10;s++)e[s]=t[s-4];return e.join(".")}return a}function Qi(a){const e=qe(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 Zi(a){return a.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}const Ji={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]};function er(a,e){return{supported:!1,configurations:e,decodingInfoResults:[{supported:!1,smooth:!1,powerEfficient:!1}],error:a}}const tr={};function ao(a,e,t,s,i,r){const n=a.audioCodec?a.audioGroups:null,o=r==null?void 0:r.audioCodec,c=r==null?void 0:r.channels,l=c?parseInt(c):o?1/0:2;let d=null;if(n!=null&&n.length)try{n.length===1&&n[0]?d=e.groups[n[0]].channels:d=n.reduce((h,u)=>{if(u){const f=e.groups[u];if(!f)throw new Error(`Audio track group ${u} not found`);Object.keys(f.channels).forEach(g=>{h[g]=(h[g]||0)+f.channels[g]})}return h},{2:0})}catch{return!0}return a.videoCodec!==void 0&&(a.width>1920&&a.height>1088||a.height>1920&&a.width>1088||a.frameRate>Math.max(s,30)||a.videoRange!=="SDR"&&a.videoRange!==t||a.bitrate>Math.max(i,8e6))||!!d&&B(l)&&Object.keys(d).some(h=>parseInt(h)>l)}function sr(a,e,t){const s=a.videoCodec,i=a.audioCodec;if(!s&&!i||!t)return Promise.resolve(Ji);const r=[];if(s){const n={width:a.width,height:a.height,bitrate:Math.ceil(Math.max(a.bitrate*.9,a.averageBitrate)),framerate:a.frameRate||30},o=a.videoRange;o!=="SDR"&&(n.transferFunction=o.toLowerCase());const c=s.split(","),l=navigator.userAgent;if(c.some(d=>$t(d))&&qi())return Promise.resolve(er(new Error(`Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent sting: (${l})`),r));r.push.apply(r,c.map(d=>({type:"media-source",video:te(te({},n),{},{contentType:Tt(no(d),"video")})})))}return i&&a.audioGroups&&a.audioGroups.forEach(n=>{var o;n&&((o=e.groups[n])==null||o.tracks.forEach(c=>{if(c.groupId===n){const l=c.channels||"",d=parseFloat(l);B(d)&&d>2&&r.push.apply(r,i.split(",").map(h=>({type:"media-source",audio:{contentType:Tt(h,"audio"),channels:""+d}})))}}))}),Promise.all(r.map(n=>{const o=oo(n);return tr[o]||(tr[o]=t.decodingInfo(n))})).then(n=>({supported:!n.some(o=>!o.supported),configurations:r,decodingInfoResults:n})).catch(n=>({supported:!1,configurations:r,decodingInfoResults:[],error:n}))}function oo(a){const{audio:e,video:t}=a,s=t||e;if(s){const i=Zi(s.contentType);if(t)return`r${t.height}x${t.width}f${Math.ceil(t.framerate)}${t.transferFunction||"sd"}_${i}_${Math.ceil(t.bitrate/1e5)}`;if(e)return`c${e.channels}${e.spatialRendering?"s":"n"}_${i}`}return""}const Ds=["NONE","TYPE-0","TYPE-1",null];function lo(a){return Ds.indexOf(a)>-1}const Ht=["SDR","PQ","HLG"];function co(a){return!!a&&Ht.indexOf(a)>-1}var Wt={No:"",Yes:"YES",v2:"v2"};function ir(a){const{canSkipUntil:e,canSkipDateRanges:t,age:s}=a,i=s<e/2;return e&&i?t?Wt.v2:Wt.Yes:Wt.No}class rr{constructor(e,t,s){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=s}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 St{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(s=>!!s).map(s=>s.substring(0,4)).join(","),"supplemental"in e){var t;this.supplemental=e.supplemental;const s=(t=e.supplemental)==null?void 0:t.videoCodec;s&&s!==e.videoCodec&&(this.codecSet+=`,${s.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 nr(this._audioGroups,e)}hasSubtitleGroup(e){return nr(this._subtitleGroups,e)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(e,t){if(t){if(e==="audio"){let s=this._audioGroups;s||(s=this._audioGroups=[]),s.indexOf(t)===-1&&s.push(t)}else if(e==="text"){let s=this._subtitleGroups;s||(s=this._subtitleGroups=[]),s.indexOf(t)===-1&&s.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 nr(a,e){return!e||!a?!1:a.indexOf(e)!==-1}function ho(){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 uo(a,e){let t=!1,s=[];if(a&&(t=a!=="SDR",s=[a]),e){s=e.allowedVideoRanges||Ht.slice(0);const i=s.join("")!=="SDR"&&!e.videoCodec;t=e.preferHDR!==void 0?e.preferHDR:i&&ho(),t||(s=["SDR"])}return{preferHDR:t,allowedVideoRanges:s}}const fo=a=>{const e=new WeakSet;return(t,s)=>{if(a&&(s=a(t,s)),typeof s=="object"&&s!==null){if(e.has(s))return;e.add(s)}return s}},oe=(a,e)=>JSON.stringify(a,fo(e));function go(a,e,t,s,i){const r=Object.keys(a),n=s==null?void 0:s.channels,o=s==null?void 0:s.audioCodec,c=i==null?void 0:i.videoCodec,l=n&&parseInt(n)===2;let d=!1,h=!1,u=1/0,f=1/0,g=1/0,y=1/0,p=0,E=[];const{preferHDR:v,allowedVideoRanges:S}=uo(e,i);for(let _=r.length;_--;){const k=a[r[_]];d||(d=k.channels[2]>0),u=Math.min(u,k.minHeight),f=Math.min(f,k.minFramerate),g=Math.min(g,k.minBitrate),S.filter(O=>k.videoRanges[O]>0).length>0&&(h=!0)}u=B(u)?u:0,f=B(f)?f:0;const x=Math.max(1080,u),A=Math.max(30,f);g=B(g)?g:t,t=Math.max(g,t),h||(e=void 0);const D=r.length>1;return{codecSet:r.reduce((_,k)=>{const I=a[k];if(k===_)return _;if(E=h?S.filter(O=>I.videoRanges[O]>0):[],D){if(I.minBitrate>t)return ke(k,`min bitrate of ${I.minBitrate} > current estimate of ${t}`),_;if(!I.hasDefaultAudio)return ke(k,"no renditions with default or auto-select sound found"),_;if(o&&k.indexOf(o.substring(0,4))%5!==0)return ke(k,`audio codec preference "${o}" not found`),_;if(n&&!l){if(!I.channels[n])return ke(k,`no renditions with ${n} channel sound found (channels options: ${Object.keys(I.channels)})`),_}else if((!o||l)&&d&&I.channels[2]===0)return ke(k,"no renditions with stereo sound found"),_;if(I.minHeight>x)return ke(k,`min resolution of ${I.minHeight} > maximum of ${x}`),_;if(I.minFramerate>A)return ke(k,`min framerate of ${I.minFramerate} > maximum of ${A}`),_;if(!E.some(O=>I.videoRanges[O]>0))return ke(k,`no variants with VIDEO-RANGE of ${oe(E)} found`),_;if(c&&k.indexOf(c.substring(0,4))%5!==0)return ke(k,`video codec preference "${c}" not found`),_;if(I.maxScore<p)return ke(k,`max score of ${I.maxScore} < selected max of ${p}`),_}return _&&(Gt(k)>=Gt(_)||I.fragmentError>a[_].fragmentError)?_:(y=I.minIndex,p=I.maxScore,k)},void 0),videoRanges:E,preferHDR:v,minFramerate:f,minBitrate:g,minIndex:y}}function ke(a,e){Z.log(`[abr] start candidates with "${a}" ignored because ${e}`)}function ar(a){return a.reduce((e,t)=>{let s=e.groups[t.groupId];s||(s=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),s.tracks.push(t);const i=t.channels||"2";return s.channels[i]=(s.channels[i]||0)+1,s.hasDefault=s.hasDefault||t.default,s.hasAutoSelect=s.hasAutoSelect||t.autoselect,s.hasDefault&&(e.hasDefaultAudio=!0),s.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function mo(a,e,t,s){return a.slice(t,s+1).reduce((i,r,n)=>{if(!r.codecSet)return i;const o=r.audioGroups;let c=i[r.codecSet];c||(i[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 l=Math.min(r.height,r.width);return c.minHeight=Math.min(c.minHeight,l),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(d=>{if(!d)return;const h=e.groups[d];h&&(c.hasDefaultAudio=c.hasDefaultAudio||e.hasDefaultAudio?h.hasDefault:h.hasAutoSelect||!e.hasDefaultAudio&&!e.hasAutoSelectAudio,Object.keys(h.channels).forEach(u=>{c.channels[u]=(c.channels[u]||0)+h.channels[u]}))}),i},{})}function or(a){if(!a)return a;const{lang:e,assocLang:t,characteristics:s,channels:i,audioCodec:r}=a;return{lang:e,assocLang:t,characteristics:s,channels:i,audioCodec:r}}function Pe(a,e,t){if("attrs"in a){const s=e.indexOf(a);if(s!==-1)return s}for(let s=0;s<e.length;s++){const i=e[s];if(et(a,i,t))return s}return-1}function et(a,e,t){const{groupId:s,name:i,lang:r,assocLang:n,default:o}=a,c=a.forced;return(s===void 0||e.groupId===s)&&(i===void 0||e.name===i)&&(r===void 0||po(r,e.lang))&&(r===void 0||e.assocLang===n)&&(o===void 0||e.default===o)&&(c===void 0||e.forced===c)&&(!("characteristics"in a)||yo(a.characteristics||"",e.characteristics))&&(t===void 0||t(a,e))}function po(a,e="--"){return a.length===e.length?a===e:a.startsWith(e)||e.startsWith(a)}function yo(a,e=""){const t=a.split(","),s=e.split(",");return t.length===s.length&&!t.some(i=>s.indexOf(i)===-1)}function tt(a,e){const{audioCodec:t,channels:s}=a;return(t===void 0||(e.audioCodec||"").substring(0,4)===t.substring(0,4))&&(s===void 0||s===(e.channels||"2"))}function Eo(a,e,t,s,i){const r=e[s],o=e.reduce((u,f,g)=>{const y=f.uri;return(u[y]||(u[y]=[])).push(g),u},{})[r.uri];o.length>1&&(s=Math.max.apply(Math,o));const c=r.videoRange,l=r.frameRate,d=r.codecSet.substring(0,4),h=lr(e,s,u=>{if(u.videoRange!==c||u.frameRate!==l||u.codecSet.substring(0,4)!==d)return!1;const f=u.audioGroups,g=t.filter(y=>!f||f.indexOf(y.groupId)!==-1);return Pe(a,g,i)>-1});return h>-1?h:lr(e,s,u=>{const f=u.audioGroups,g=t.filter(y=>!f||f.indexOf(y.groupId)!==-1);return Pe(a,g,i)>-1})}function lr(a,e,t){for(let s=e;s>-1;s--)if(t(a[s]))return s;for(let s=e+1;s<a.length;s++)if(t(a[s]))return s;return-1}function Yt(a,e){var t;return!!a&&a!==((t=e.loadLevelObj)==null?void 0:t.uri)}class To extends $e{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.bwEstimator=void 0,this._abandonRulesCheck=t=>{var s;const{fragCurrent:i,partCurrent:r,hls:n}=this,{autoLevelEnabled:o,media:c}=n;if(!i||!c)return;const l=performance.now(),d=r?r.stats:i.stats,h=r?r.duration:i.duration,u=l-d.loading.start,f=n.minAutoLevel,g=i.level,y=this._nextAutoLevel;if(d.aborted||d.loaded&&d.loaded===d.total||g<=f){this.clearTimer(),this._nextAutoLevel=-1;return}if(!o)return;const p=y>-1&&y!==g,E=!!t||p;if(!E&&(c.paused||!c.playbackRate||!c.readyState))return;const v=n.mainForwardBufferInfo;if(!E&&v===null)return;const S=this.bwEstimator.getEstimateTTFB(),x=Math.abs(c.playbackRate);if(u<=Math.max(S,1e3*(h/(x*2))))return;const A=v?v.len/x:0,D=d.loading.first?d.loading.first-d.loading.start:-1,L=d.loaded&&D>-1,_=this.getBwEstimate(),k=n.levels,I=k[g],O=Math.max(d.loaded,Math.round(h*(i.bitrate||I.averageBitrate)/8));let M=L?u-D:u;M<1&&L&&(M=Math.min(u,d.loaded*8/_));const X=L?d.loaded*1e3/M:0,W=S/1e3,H=X?(O-d.loaded)/X:O*8/_+W;if(H<=A)return;const U=X?X*8:_,V=((s=(t==null?void 0:t.details)||this.hls.latestLevelDetails)==null?void 0:s.live)===!0,$=this.hls.config.abrBandWidthUpFactor;let F=Number.POSITIVE_INFINITY,C;for(C=g-1;C>f;C--){const J=k[C].maxBitrate,ie=!k[C].details||V;if(F=this.getTimeToLoadFrag(W,U,h*J,ie),F<Math.min(A,h+W))break}if(F>=H||F>h*10)return;L?this.bwEstimator.sample(u-Math.min(S,D),d.loaded):this.bwEstimator.sampleTTFB(u);const w=k[C].maxBitrate;this.getBwEstimate()*$>w&&this.resetEstimator(w);const N=this.findBestLevel(w,f,C,0,A,1,1);N>-1&&(C=N),this.warn(`Fragment ${i.sn}${r?" part "+r.index:""} of level ${g} is loading too slowly;
Fragment duration: ${i.duration.toFixed(3)}
Time to underbuffer: ${A.toFixed(3)} s
Estimated load time for current fragment: ${H.toFixed(3)} s
Estimated load time for down switch fragment: ${F.toFixed(3)} s
TTFB estimate: ${D|0} ms
Current BW estimate: ${B(_)?_|0:"Unknown"} bps
New BW estimate: ${this.getBwEstimate()|0} bps
Switching to level ${C} @ ${w|0} bps`),n.nextLoadLevel=n.nextAutoLevel=C,this.clearTimer();const q=()=>{if(this.clearTimer(),this.fragCurrent===i&&this.hls.loadLevel===C&&C>0){const J=this.getStarvationDelay();if(this.warn(`Aborting inflight request ${C>0?"and switching down":""}
Fragment duration: ${i.duration.toFixed(3)} s
Time to underbuffer: ${J.toFixed(3)} s`),i.abortRequests(),this.fragCurrent=this.partCurrent=null,C>f){let ie=this.findBestLevel(this.hls.levels[f].bitrate,f,C,0,J,1,1);ie===-1&&(ie=f),this.hls.nextLoadLevel=this.hls.nextAutoLevel=ie,this.resetEstimator(this.hls.levels[ie].bitrate)}}};p||H>F*2?q():this.timer=self.setInterval(q,F*1e3),n.trigger(m.FRAG_LOAD_EMERGENCY_ABORTED,{frag:i,part:r,stats:d})},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 ba(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){const{hls:e}=this;e.on(m.MANIFEST_LOADING,this.onManifestLoading,this),e.on(m.FRAG_LOADING,this.onFragLoading,this),e.on(m.FRAG_LOADED,this.onFragLoaded,this),e.on(m.FRAG_BUFFERED,this.onFragBuffered,this),e.on(m.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(m.LEVEL_LOADED,this.onLevelLoaded,this),e.on(m.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(m.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(m.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e&&(e.off(m.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m.FRAG_LOADING,this.onFragLoading,this),e.off(m.FRAG_LOADED,this.onFragLoaded,this),e.off(m.FRAG_BUFFERED,this.onFragBuffered,this),e.off(m.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(m.LEVEL_LOADED,this.onLevelLoaded,this),e.off(m.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(m.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(m.ERROR,this.onError,this))}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null}onManifestLoading(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,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 s=t.frag;if(!this.ignoreFragment(s)){if(!s.bitrateTest){var i;this.fragCurrent=s,this.partCurrent=(i=t.part)!=null?i: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 b.BUFFER_ADD_CODEC_ERROR:case b.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case b.FRAG_LOAD_TIMEOUT:{const s=t.frag,{fragCurrent:i,partCurrent:r}=this;if(s&&i&&s.sn===i.sn&&s.level===i.level){const n=performance.now(),o=r?r.stats:s.stats,c=n-o.loading.start,l=o.loading.first?o.loading.first-o.loading.start:-1;if(o.loaded&&l>-1){const h=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(c-Math.min(h,l),o.loaded)}else this.bwEstimator.sampleTTFB(c)}break}}}getTimeToLoadFrag(e,t,s,i){const r=e+s/t,n=i?e+this.lastLevelLoad