@streamlayer/react 1.14.7 → 1.14.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/advertisement.js +1 -1
- package/lib/cjs/index2.js +3 -3
- package/lib/cjs/notification.js +1 -1
- package/lib/cjs/provider.js +17 -17
- package/lib/cjs/useStreamLayerApp2.js +2 -2
- package/lib/classic/cjs/advertisement.js +1 -1
- package/lib/classic/cjs/index2.js +3 -3
- package/lib/classic/cjs/notification.js +1 -1
- package/lib/classic/cjs/provider.js +16 -16
- package/lib/classic/cjs/useStreamLayerApp2.js +2 -2
- package/lib/classic/es/advertisement.js +1 -1
- package/lib/classic/es/index.js +1 -1
- package/lib/classic/es/index2.js +209 -209
- package/lib/classic/es/masters2.js +17 -17
- package/lib/classic/es/notification.js +19 -19
- package/lib/classic/es/provider.js +2173 -2163
- package/lib/classic/es/useStreamLayerApp2.js +2 -2
- package/lib/classic/style.css +1 -1
- package/lib/dist/cjs/masters.js +27 -27
- package/lib/dist/es/masters.js +3180 -3171
- package/lib/dist/style.css +1 -1
- package/lib/es/advertisement.js +1 -1
- package/lib/es/index.js +1 -1
- package/lib/es/index2.js +209 -209
- package/lib/es/masters2.js +17 -17
- package/lib/es/notification.js +19 -19
- package/lib/es/provider.js +2170 -2160
- package/lib/es/useStreamLayerApp2.js +2 -2
- package/lib/style.css +1 -1
- package/package.json +14 -14
package/lib/cjs/advertisement.js
CHANGED
|
@@ -220,4 +220,4 @@ ${br(e)}`),t.map&&!t.map.bytes&&(this.logger_("going to request init segment."),
|
|
|
220
220
|
`.split("").map(i=>i.charCodeAt(0)));class Hw extends Error{constructor(){super("Trying to parse received VTT cues, but there is no WebVTT. Make sure vtt.js is loaded.")}}class zw extends fl{constructor(e,t={}){super(e,t),this.mediaSource_=null,this.subtitlesTrack_=null,this.featuresNativeTextTracks_=e.featuresNativeTextTracks,this.loadVttJs=e.loadVttJs,this.shouldSaveSegmentTimingInfo_=!1}buffered_(){if(!this.subtitlesTrack_||!this.subtitlesTrack_.cues||!this.subtitlesTrack_.cues.length)return it();const e=this.subtitlesTrack_.cues,t=e[0].startTime,r=e[e.length-1].startTime;return it([[t,r]])}initSegmentForMap(e,t=!1){if(!e)return null;const r=ma(e);let n=this.initSegments_[r];if(t&&!n&&e.bytes){const s=oh.byteLength+e.bytes.byteLength,a=new Uint8Array(s);a.set(e.bytes),a.set(oh,e.bytes.byteLength),this.initSegments_[r]=n={resolvedUri:e.resolvedUri,byterange:e.byterange,bytes:a}}return n||e}couldBeginLoading_(){return this.playlist_&&this.subtitlesTrack_&&!this.paused()}init_(){return this.state="READY",this.resetEverything(),this.monitorBuffer_()}track(e){return typeof e>"u"?this.subtitlesTrack_:(this.subtitlesTrack_=e,this.state==="INIT"&&this.couldBeginLoading_()&&this.init_(),this.subtitlesTrack_)}remove(e,t){xn(e,t,this.subtitlesTrack_)}fillBuffer_(){const e=this.chooseNextRequest_();if(e){if(this.syncController_.timestampOffsetForTimeline(e.timeline)===null){const t=()=>{this.state="READY",this.paused()||this.monitorBuffer_()};this.syncController_.one("timestampoffset",t),this.state="WAITING_ON_TIMELINE";return}this.loadSegment_(e)}}timestampOffsetForSegment_(){return null}chooseNextRequest_(){return this.skipEmptySegments_(super.chooseNextRequest_())}skipEmptySegments_(e){for(;e&&e.segment.empty;){if(e.mediaIndex+1>=e.playlist.segments.length){e=null;break}e=this.generateSegmentInfo_({playlist:e.playlist,mediaIndex:e.mediaIndex+1,startOfSegment:e.startOfSegment+e.duration,isSyncRequest:e.isSyncRequest})}return e}stopForError(e){this.error(e),this.state="READY",this.pause(),this.trigger("error")}segmentRequestFinished_(e,t,r){if(!this.subtitlesTrack_){this.state="READY";return}if(this.saveTransferStats_(t.stats),!this.pendingSegment_){this.state="READY",this.mediaRequestsAborted+=1;return}if(e){e.code===ti.TIMEOUT&&this.handleTimeout_(),e.code===ti.ABORTED?this.mediaRequestsAborted+=1:this.mediaRequestsErrored+=1,this.stopForError(e);return}const n=this.pendingSegment_,s=r.mp4VttCues&&r.mp4VttCues.length;s&&(n.mp4VttCues=r.mp4VttCues),this.saveBandwidthRelatedStats_(n.duration,t.stats),t.key&&this.segmentKey(t.key,!0),this.state="APPENDING",this.trigger("appending");const a=n.segment;if(a.map&&(a.map.bytes=t.map.bytes),n.bytes=t.bytes,typeof x.WebVTT!="function"&&typeof this.loadVttJs=="function"){this.state="WAITING_ON_VTTJS",this.loadVttJs().then(()=>this.segmentRequestFinished_(e,t,r),()=>this.stopForError({message:"Error loading vtt.js"}));return}a.requested=!0;try{this.parseVTTCues_(n)}catch(l){this.stopForError({message:l.message,metadata:{errorType:B.Error.StreamingVttParserError,error:l}});return}if(s||this.updateTimeMapping_(n,this.syncController_.timelines[n.timeline],this.playlist_),n.cues.length?n.timingInfo={start:n.cues[0].startTime,end:n.cues[n.cues.length-1].endTime}:n.timingInfo={start:n.startOfSegment,end:n.startOfSegment+n.duration},n.isSyncRequest){this.trigger("syncinfoupdate"),this.pendingSegment_=null,this.state="READY";return}n.byteLength=n.bytes.byteLength,this.mediaSecondsLoaded+=a.duration,n.cues.forEach(l=>{this.subtitlesTrack_.addCue(this.featuresNativeTextTracks_?new x.VTTCue(l.startTime,l.endTime,l.text):l)}),Iw(this.subtitlesTrack_),this.handleAppendsDone_()}handleData_(e,t){const r=e&&e.type==="vtt",n=t&&t.type==="text";r&&n&&super.handleData_(e,t)}updateTimingInfoEnd_(){}parseMp4VttCues_(e){const t=this.sourceUpdater_.videoTimestampOffset()===null?this.sourceUpdater_.audioTimestampOffset():this.sourceUpdater_.videoTimestampOffset();e.mp4VttCues.forEach(r=>{const n=r.start+t,s=r.end+t,a=new x.VTTCue(n,s,r.cueText);r.settings&&r.settings.split(" ").forEach(l=>{const u=l.split(":"),p=u[0],g=u[1];a[p]=isNaN(g)?g:Number(g)}),e.cues.push(a)})}parseVTTCues_(e){let t,r=!1;if(typeof x.WebVTT!="function")throw new Hw;if(e.cues=[],e.timestampmap={MPEGTS:0,LOCAL:0},e.mp4VttCues){this.parseMp4VttCues_(e);return}typeof x.TextDecoder=="function"?t=new x.TextDecoder("utf8"):(t=x.WebVTT.StringDecoder(),r=!0);const n=new x.WebVTT.Parser(x,x.vttjs,t);if(n.oncue=e.cues.push.bind(e.cues),n.ontimestampmap=a=>{e.timestampmap=a},n.onparsingerror=a=>{B.log.warn("Error encountered when parsing cues: "+a.message)},e.segment.map){let a=e.segment.map.bytes;r&&(a=ah(a)),n.parse(a)}let s=e.bytes;r&&(s=ah(s)),n.parse(s),n.flush()}updateTimeMapping_(e,t,r){const n=e.segment;if(!t)return;if(!e.cues.length){n.empty=!0;return}const{MPEGTS:s,LOCAL:a}=e.timestampmap,l=s/Yi.ONE_SECOND_IN_TS-a+t.mapping;if(e.cues.forEach(u=>{const p=u.endTime-u.startTime,g=this.handleRollover_(u.startTime+l,t.time);u.startTime=Math.max(g,0),u.endTime=Math.max(g+p,0)}),!r.syncInfo){const u=e.cues[0].startTime,p=e.cues[e.cues.length-1].startTime;r.syncInfo={mediaSequence:r.mediaSequence+e.mediaIndex,time:Math.min(u,p-n.duration)}}}handleRollover_(e,t){if(t===null)return e;let r=e*Yi.ONE_SECOND_IN_TS;const n=t*Yi.ONE_SECOND_IN_TS;let s;for(n<r?s=-8589934592:s=8589934592;Math.abs(r-n)>4294967296;)r+=s;return r/Yi.ONE_SECOND_IN_TS}}const Ww=function(i,e){const t=i.cues;for(let r=0;r<t.length;r++){const n=t[r];if(e>=n.adStartTime&&e<=n.adEndTime)return n}return null},Gw=function(i,e,t=0){if(!i.segments)return;let r=t,n;for(let s=0;s<i.segments.length;s++){const a=i.segments[s];if(n||(n=Ww(e,r+a.duration/2)),n){if("cueIn"in a){n.endTime=r,n.adEndTime=r,r+=a.duration,n=null;continue}if(r<n.endTime){r+=a.duration;continue}n.endTime+=a.duration}else if("cueOut"in a&&(n=new x.VTTCue(r,r+a.duration,a.cueOut),n.adStartTime=r,n.adEndTime=r+parseFloat(a.cueOut),e.addCue(n)),"cueOutCont"in a){const[l,u]=a.cueOutCont.split("/").map(parseFloat);n=new x.VTTCue(r,r+a.duration,""),n.adStartTime=r-l,n.adEndTime=n.adStartTime+u,e.addCue(n)}r+=a.duration}};class lh{constructor({start:e,end:t,segmentIndex:r,partIndex:n=null,appended:s=!1}){this.start_=e,this.end_=t,this.segmentIndex_=r,this.partIndex_=n,this.appended_=s}isInRange(e){return e>=this.start&&e<this.end}markAppended(){this.appended_=!0}resetAppendedStatus(){this.appended_=!1}get isAppended(){return this.appended_}get start(){return this.start_}get end(){return this.end_}get segmentIndex(){return this.segmentIndex_}get partIndex(){return this.partIndex_}}class Xw{constructor(e,t=[]){this.segmentSyncInfo_=e,this.partsSyncInfo_=t}get segmentSyncInfo(){return this.segmentSyncInfo_}get partsSyncInfo(){return this.partsSyncInfo_}get hasPartsSyncInfo(){return this.partsSyncInfo_.length>0}resetAppendStatus(){this.segmentSyncInfo_.resetAppendedStatus(),this.partsSyncInfo_.forEach(e=>e.resetAppendedStatus())}}class Gm{constructor(){this.storage_=new Map,this.diagnostics_="",this.isReliable_=!1,this.start_=-1/0,this.end_=1/0}get start(){return this.start_}get end(){return this.end_}get diagnostics(){return this.diagnostics_}get isReliable(){return this.isReliable_}resetAppendedStatus(){this.storage_.forEach(e=>e.resetAppendStatus())}update(e,t){const{mediaSequence:r,segments:n}=e;if(this.isReliable_=this.isReliablePlaylist_(r,n),!!this.isReliable_)return this.updateStorage_(n,r,this.calculateBaseTime_(r,n,t))}getSyncInfoForTime(e){for(const{segmentSyncInfo:t,partsSyncInfo:r}of this.storage_.values())if(r.length){for(const n of r)if(n.isInRange(e))return n}else if(t.isInRange(e))return t;return null}getSyncInfoForMediaSequence(e){return this.storage_.get(e)}updateStorage_(e,t,r){const n=new Map;let s=`
|
|
221
221
|
`,a=r,l=t;this.start_=a,e.forEach((u,p)=>{const g=this.storage_.get(l),b=a,S=b+u.duration,w=!!(g&&g.segmentSyncInfo&&g.segmentSyncInfo.isAppended),C=new lh({start:b,end:S,appended:w,segmentIndex:p});u.syncInfo=C;let v=a;const D=(u.parts||[]).map((L,O)=>{const U=v,F=v+L.duration,N=!!(g&&g.partsSyncInfo&&g.partsSyncInfo[O]&&g.partsSyncInfo[O].isAppended),V=new lh({start:U,end:F,appended:N,segmentIndex:p,partIndex:O});return v=F,s+=`Media Sequence: ${l}.${O} | Range: ${U} --> ${F} | Appended: ${N}
|
|
222
222
|
`,L.syncInfo=V,V});n.set(l,new Xw(C,D)),s+=`${Vm(u.resolvedUri)} | Media Sequence: ${l} | Range: ${b} --> ${S} | Appended: ${w}
|
|
223
|
-
`,l++,a=S}),this.end_=a,this.storage_=n,this.diagnostics_=s}calculateBaseTime_(e,t,r){if(!this.storage_.size)return 0;if(this.storage_.has(e))return this.storage_.get(e).segmentSyncInfo.start;const n=Math.min(...this.storage_.keys());if(e<n){const s=n-e;let a=this.storage_.get(n).segmentSyncInfo.start;for(let l=0;l<s;l++){const u=t[l];a-=u.duration}return a}return r}isReliablePlaylist_(e,t){return e!=null&&Array.isArray(t)&&t.length}}class uh extends Gm{constructor(e){super(),this.parent_=e}calculateBaseTime_(e,t,r){if(!this.storage_.size){const n=this.parent_.getSyncInfoForMediaSequence(e);return n?n.segmentSyncInfo.start:0}return super.calculateBaseTime_(e,t,r)}}const Kw=86400,qo=[{name:"VOD",run:(i,e,t,r,n)=>t!==1/0?{time:0,segmentIndex:0,partIndex:null}:null},{name:"MediaSequence",run:(i,e,t,r,n,s)=>{const a=i.getMediaSequenceSync(s);if(!a||!a.isReliable)return null;const l=a.getSyncInfoForTime(n);return l?{time:l.start,partIndex:l.partIndex,segmentIndex:l.segmentIndex}:null}},{name:"ProgramDateTime",run:(i,e,t,r,n)=>{if(!Object.keys(i.timelineToDatetimeMappings).length)return null;let s=null,a=null;const l=ol(e);n=n||0;for(let u=0;u<l.length;u++){const p=e.endList||n===0?u:l.length-(u+1),g=l[p],b=g.segment,S=i.timelineToDatetimeMappings[b.timeline];if(!S||!b.dateTimeObject)continue;let w=b.dateTimeObject.getTime()/1e3+S;if(b.parts&&typeof g.partIndex=="number")for(let v=0;v<g.partIndex;v++)w+=b.parts[v].duration;const C=Math.abs(n-w);if(a!==null&&(C===0||a<C))break;a=C,s={time:w,segmentIndex:g.segmentIndex,partIndex:g.partIndex}}return s}},{name:"Segment",run:(i,e,t,r,n)=>{let s=null,a=null;n=n||0;const l=ol(e);for(let u=0;u<l.length;u++){const p=e.endList||n===0?u:l.length-(u+1),g=l[p],b=g.segment,S=g.part&&g.part.start||b&&b.start;if(b.timeline===r&&typeof S<"u"){const w=Math.abs(n-S);if(a!==null&&a<w)break;(!s||a===null||a>=w)&&(a=w,s={time:S,segmentIndex:g.segmentIndex,partIndex:g.partIndex})}}return s}},{name:"Discontinuity",run:(i,e,t,r,n)=>{let s=null;if(n=n||0,e.discontinuityStarts&&e.discontinuityStarts.length){let a=null;for(let l=0;l<e.discontinuityStarts.length;l++){const u=e.discontinuityStarts[l],p=e.discontinuitySequence+l+1,g=i.discontinuities[p];if(g){const b=Math.abs(n-g.time);if(a!==null&&a<b)break;(!s||a===null||a>=b)&&(a=b,s={time:g.time,segmentIndex:u,partIndex:null})}}}return s}},{name:"Playlist",run:(i,e,t,r,n)=>e.syncInfo?{time:e.syncInfo.time,segmentIndex:e.syncInfo.mediaSequence-e.mediaSequence,partIndex:null}:null}];class Yw extends B.EventTarget{constructor(e={}){super(),this.timelines=[],this.discontinuities=[],this.timelineToDatetimeMappings={};const t=new Gm,r=new uh(t),n=new uh(t);this.mediaSequenceStorage_={main:t,audio:r,vtt:n},this.logger_=Nt("SyncController")}getMediaSequenceSync(e){return this.mediaSequenceStorage_[e]||null}getSyncPoint(e,t,r,n,s){if(t!==1/0)return qo.find(({name:l})=>l==="VOD").run(this,e,t);const a=this.runStrategies_(e,t,r,n,s);if(!a.length)return null;for(const l of a){const{syncPoint:u,strategy:p}=l,{segmentIndex:g,time:b}=u;if(g<0)continue;const S=e.segments[g],w=b,C=w+S.duration;if(this.logger_(`Strategy: ${p}. Current time: ${n}. selected segment: ${g}. Time: [${w} -> ${C}]}`),n>=w&&n<C)return this.logger_("Found sync point with exact match: ",u),u}return this.selectSyncPoint_(a,{key:"time",value:n})}getExpiredTime(e,t){if(!e||!e.segments)return null;const r=this.runStrategies_(e,t,e.discontinuitySequence,0);if(!r.length)return null;const n=this.selectSyncPoint_(r,{key:"segmentIndex",value:0});return n.segmentIndex>0&&(n.time*=-1),Math.abs(n.time+On({defaultDuration:e.targetDuration,durationList:e.segments,startIndex:n.segmentIndex,endIndex:0}))}runStrategies_(e,t,r,n,s){const a=[];for(let l=0;l<qo.length;l++){const u=qo[l],p=u.run(this,e,t,r,n,s);p&&(p.strategy=u.name,a.push({strategy:u.name,syncPoint:p}))}return a}selectSyncPoint_(e,t){let r=e[0].syncPoint,n=Math.abs(e[0].syncPoint[t.key]-t.value),s=e[0].strategy;for(let a=1;a<e.length;a++){const l=Math.abs(e[a].syncPoint[t.key]-t.value);l<n&&(n=l,r=e[a].syncPoint,s=e[a].strategy)}return this.logger_(`syncPoint for [${t.key}: ${t.value}] chosen with strategy [${s}]: [time:${r.time}, segmentIndex:${r.segmentIndex}`+(typeof r.partIndex=="number"?`,partIndex:${r.partIndex}`:"")+"]"),r}saveExpiredSegmentInfo(e,t){const r=t.mediaSequence-e.mediaSequence;if(r>Kw){B.log.warn(`Not saving expired segment info. Media sequence gap ${r} is too large.`);return}for(let n=r-1;n>=0;n--){const s=e.segments[n];if(s&&typeof s.start<"u"){t.syncInfo={mediaSequence:e.mediaSequence+n,time:s.start},this.logger_(`playlist refresh sync: [time:${t.syncInfo.time}, mediaSequence: ${t.syncInfo.mediaSequence}]`),this.trigger("syncinfoupdate");break}}}setDateTimeMappingForStart(e){if(this.timelineToDatetimeMappings={},e.segments&&e.segments.length&&e.segments[0].dateTimeObject){const t=e.segments[0],r=t.dateTimeObject.getTime()/1e3;this.timelineToDatetimeMappings[t.timeline]=-r}}saveSegmentTimingInfo({segmentInfo:e,shouldSaveTimelineMapping:t}){const r=this.calculateSegmentTimeMapping_(e,e.timingInfo,t),n=e.segment;r&&(this.saveDiscontinuitySyncInfo_(e),e.playlist.syncInfo||(e.playlist.syncInfo={mediaSequence:e.playlist.mediaSequence+e.mediaIndex,time:n.start}));const s=n.dateTimeObject;n.discontinuity&&t&&s&&(this.timelineToDatetimeMappings[n.timeline]=-(s.getTime()/1e3))}timestampOffsetForTimeline(e){return typeof this.timelines[e]>"u"?null:this.timelines[e].time}mappingForTimeline(e){return typeof this.timelines[e]>"u"?null:this.timelines[e].mapping}calculateSegmentTimeMapping_(e,t,r){const n=e.segment,s=e.part;let a=this.timelines[e.timeline],l,u;if(typeof e.timestampOffset=="number")a={time:e.startOfSegment,mapping:e.startOfSegment-t.start},r&&(this.timelines[e.timeline]=a,this.trigger("timestampoffset"),this.logger_(`time mapping for timeline ${e.timeline}: [time: ${a.time}] [mapping: ${a.mapping}]`)),l=e.startOfSegment,u=t.end+a.mapping;else if(a)l=t.start+a.mapping,u=t.end+a.mapping;else return!1;return s&&(s.start=l,s.end=u),(!n.start||l<n.start)&&(n.start=l),n.end=u,!0}saveDiscontinuitySyncInfo_(e){const t=e.playlist,r=e.segment;if(r.discontinuity)this.discontinuities[r.timeline]={time:r.start,accuracy:0};else if(t.discontinuityStarts&&t.discontinuityStarts.length)for(let n=0;n<t.discontinuityStarts.length;n++){const s=t.discontinuityStarts[n],a=t.discontinuitySequence+n+1,l=s-e.mediaIndex,u=Math.abs(l);if(!this.discontinuities[a]||this.discontinuities[a].accuracy>u){let p;l<0?p=r.start-On({defaultDuration:t.targetDuration,durationList:t.segments,startIndex:e.mediaIndex,endIndex:s}):p=r.end+On({defaultDuration:t.targetDuration,durationList:t.segments,startIndex:e.mediaIndex+1,endIndex:s}),this.discontinuities[a]={time:p,accuracy:u}}}}dispose(){this.trigger("dispose"),this.off()}}class Qw extends B.EventTarget{constructor(){super(),this.pendingTimelineChanges_={},this.lastTimelineChanges_={}}clearPendingTimelineChange(e){this.pendingTimelineChanges_[e]=null,this.trigger("pendingtimelinechange")}pendingTimelineChange({type:e,from:t,to:r}){return typeof t=="number"&&typeof r=="number"&&(this.pendingTimelineChanges_[e]={type:e,from:t,to:r},this.trigger("pendingtimelinechange")),this.pendingTimelineChanges_[e]}lastTimelineChange({type:e,from:t,to:r}){if(typeof t=="number"&&typeof r=="number"){this.lastTimelineChanges_[e]={type:e,from:t,to:r},delete this.pendingTimelineChanges_[e];const n={timelineChangeInfo:{from:t,to:r}};this.trigger({type:"timelinechange",metadata:n})}return this.lastTimelineChanges_[e]}dispose(){this.trigger("dispose"),this.pendingTimelineChanges_={},this.lastTimelineChanges_={},this.off()}}const Jw=Dm(Pm(function(){var i=function(){function v(){this.listeners={}}var D=v.prototype;return D.on=function(L,O){this.listeners[L]||(this.listeners[L]=[]),this.listeners[L].push(O)},D.off=function(L,O){if(!this.listeners[L])return!1;var U=this.listeners[L].indexOf(O);return this.listeners[L]=this.listeners[L].slice(0),this.listeners[L].splice(U,1),U>-1},D.trigger=function(L){var O=this.listeners[L];if(O)if(arguments.length===2)for(var U=O.length,F=0;F<U;++F)O[F].call(this,arguments[1]);else for(var N=Array.prototype.slice.call(arguments,1),V=O.length,J=0;J<V;++J)O[J].apply(this,N)},D.dispose=function(){this.listeners={}},D.pipe=function(L){this.on("data",function(O){L.push(O)})},v}();/*! @name pkcs7 @version 1.0.4 @license Apache-2.0 */function e(v){return v.subarray(0,v.byteLength-v[v.byteLength-1])}/*! @name aes-decrypter @version 4.0.2 @license Apache-2.0 */const t=function(){const v=[[[],[],[],[],[]],[[],[],[],[],[]]],D=v[0],L=v[1],O=D[4],U=L[4];let F,N,V;const J=[],Y=[];let ie,he,le,pe,ee,ce;for(F=0;F<256;F++)Y[(J[F]=F<<1^(F>>7)*283)^F]=F;for(N=V=0;!O[N];N^=ie||1,V=Y[V]||1)for(pe=V^V<<1^V<<2^V<<3^V<<4,pe=pe>>8^pe&255^99,O[N]=pe,U[pe]=N,le=J[he=J[ie=J[N]]],ce=le*16843009^he*65537^ie*257^N*16843008,ee=J[pe]*257^pe*16843008,F=0;F<4;F++)D[F][N]=ee=ee<<24^ee>>>8,L[F][pe]=ce=ce<<24^ce>>>8;for(F=0;F<5;F++)D[F]=D[F].slice(0),L[F]=L[F].slice(0);return v};let r=null;class n{constructor(D){r||(r=t()),this._tables=[[r[0][0].slice(),r[0][1].slice(),r[0][2].slice(),r[0][3].slice(),r[0][4].slice()],[r[1][0].slice(),r[1][1].slice(),r[1][2].slice(),r[1][3].slice(),r[1][4].slice()]];let L,O,U;const F=this._tables[0][4],N=this._tables[1],V=D.length;let J=1;if(V!==4&&V!==6&&V!==8)throw new Error("Invalid aes key size");const Y=D.slice(0),ie=[];for(this._key=[Y,ie],L=V;L<4*V+28;L++)U=Y[L-1],(L%V===0||V===8&&L%V===4)&&(U=F[U>>>24]<<24^F[U>>16&255]<<16^F[U>>8&255]<<8^F[U&255],L%V===0&&(U=U<<8^U>>>24^J<<24,J=J<<1^(J>>7)*283)),Y[L]=Y[L-V]^U;for(O=0;L;O++,L--)U=Y[O&3?L:L-4],L<=4||O<4?ie[O]=U:ie[O]=N[0][F[U>>>24]]^N[1][F[U>>16&255]]^N[2][F[U>>8&255]]^N[3][F[U&255]]}decrypt(D,L,O,U,F,N){const V=this._key[1];let J=D^V[0],Y=U^V[1],ie=O^V[2],he=L^V[3],le,pe,ee;const ce=V.length/4-2;let ne,de=4;const we=this._tables[1],ze=we[0],dt=we[1],Ot=we[2],ht=we[3],Ut=we[4];for(ne=0;ne<ce;ne++)le=ze[J>>>24]^dt[Y>>16&255]^Ot[ie>>8&255]^ht[he&255]^V[de],pe=ze[Y>>>24]^dt[ie>>16&255]^Ot[he>>8&255]^ht[J&255]^V[de+1],ee=ze[ie>>>24]^dt[he>>16&255]^Ot[J>>8&255]^ht[Y&255]^V[de+2],he=ze[he>>>24]^dt[J>>16&255]^Ot[Y>>8&255]^ht[ie&255]^V[de+3],de+=4,J=le,Y=pe,ie=ee;for(ne=0;ne<4;ne++)F[(3&-ne)+N]=Ut[J>>>24]<<24^Ut[Y>>16&255]<<16^Ut[ie>>8&255]<<8^Ut[he&255]^V[de++],le=J,J=Y,Y=ie,ie=he,he=le}}class s extends i{constructor(){super(i),this.jobs=[],this.delay=1,this.timeout_=null}processJob_(){this.jobs.shift()(),this.jobs.length?this.timeout_=setTimeout(this.processJob_.bind(this),this.delay):this.timeout_=null}push(D){this.jobs.push(D),this.timeout_||(this.timeout_=setTimeout(this.processJob_.bind(this),this.delay))}}const a=function(v){return v<<24|(v&65280)<<8|(v&16711680)>>8|v>>>24},l=function(v,D,L){const O=new Int32Array(v.buffer,v.byteOffset,v.byteLength>>2),U=new n(Array.prototype.slice.call(D)),F=new Uint8Array(v.byteLength),N=new Int32Array(F.buffer);let V,J,Y,ie,he,le,pe,ee,ce;for(V=L[0],J=L[1],Y=L[2],ie=L[3],ce=0;ce<O.length;ce+=4)he=a(O[ce]),le=a(O[ce+1]),pe=a(O[ce+2]),ee=a(O[ce+3]),U.decrypt(he,le,pe,ee,N,ce),N[ce]=a(N[ce]^V),N[ce+1]=a(N[ce+1]^J),N[ce+2]=a(N[ce+2]^Y),N[ce+3]=a(N[ce+3]^ie),V=he,J=le,Y=pe,ie=ee;return F};class u{constructor(D,L,O,U){const F=u.STEP,N=new Int32Array(D.buffer),V=new Uint8Array(D.byteLength);let J=0;for(this.asyncStream_=new s,this.asyncStream_.push(this.decryptChunk_(N.subarray(J,J+F),L,O,V)),J=F;J<N.length;J+=F)O=new Uint32Array([a(N[J-4]),a(N[J-3]),a(N[J-2]),a(N[J-1])]),this.asyncStream_.push(this.decryptChunk_(N.subarray(J,J+F),L,O,V));this.asyncStream_.push(function(){U(null,e(V))})}static get STEP(){return 32e3}decryptChunk_(D,L,O,U){return function(){const F=l(D,L,O);U.set(F,D.byteOffset)}}}var p=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof Ys<"u"?Ys:typeof self<"u"?self:{},g;typeof window<"u"?g=window:typeof p<"u"?g=p:typeof self<"u"?g=self:g={};var b=g,S=function(v){return ArrayBuffer.isView==="function"?ArrayBuffer.isView(v):v&&v.buffer instanceof ArrayBuffer},w=b.BigInt||Number;w("0x1"),w("0x100"),w("0x10000"),w("0x1000000"),w("0x100000000"),w("0x10000000000"),w("0x1000000000000"),w("0x100000000000000"),w("0x10000000000000000"),function(){var v=new Uint16Array([65484]),D=new Uint8Array(v.buffer,v.byteOffset,v.byteLength);return D[0]===255?"big":D[0]===204?"little":"unknown"}();const C=function(v){const D={};return Object.keys(v).forEach(L=>{const O=v[L];S(O)?D[L]={bytes:O.buffer,byteOffset:O.byteOffset,byteLength:O.byteLength}:D[L]=O}),D};self.onmessage=function(v){const D=v.data,L=new Uint8Array(D.encrypted.bytes,D.encrypted.byteOffset,D.encrypted.byteLength),O=new Uint32Array(D.key.bytes,D.key.byteOffset,D.key.byteLength/4),U=new Uint32Array(D.iv.bytes,D.iv.byteOffset,D.iv.byteLength/4);new u(L,O,U,function(F,N){self.postMessage(C({source:D.source,decrypted:N}),[N.buffer])})}}));var Zw=Lm(Jw);const e2=i=>{let e=i.default?"main":"alternative";return i.characteristics&&i.characteristics.indexOf("public.accessibility.describes-video")>=0&&(e="main-desc"),e},Xm=(i,e)=>{i.abort(),i.pause(),e&&e.activePlaylistLoader&&(e.activePlaylistLoader.pause(),e.activePlaylistLoader=null)},_l=(i,e)=>{e.activePlaylistLoader=i,i.load()},t2=(i,e)=>()=>{const{segmentLoaders:{[i]:t,main:r},mediaTypes:{[i]:n}}=e,s=n.activeTrack(),a=n.getActiveGroup(),l=n.activePlaylistLoader,u=n.lastGroup_;if(!(a&&u&&a.id===u.id)&&(n.lastGroup_=a,n.lastTrack_=s,Xm(t,n),!(!a||a.isMainPlaylist))){if(!a.playlistLoader){l&&r.resetEverything();return}t.resyncLoader(),_l(a.playlistLoader,n)}},i2=(i,e)=>()=>{const{segmentLoaders:{[i]:t},mediaTypes:{[i]:r}}=e;r.lastGroup_=null,t.abort(),t.pause()},r2=(i,e)=>()=>{const{mainPlaylistLoader:t,segmentLoaders:{[i]:r,main:n},mediaTypes:{[i]:s}}=e,a=s.activeTrack(),l=s.getActiveGroup(),u=s.activePlaylistLoader,p=s.lastTrack_;if(!(p&&a&&p.id===a.id)&&(s.lastGroup_=l,s.lastTrack_=a,Xm(r,s),!!l)){if(l.isMainPlaylist){if(!a||!p||a.id===p.id)return;const g=e.vhs.playlistController_,b=g.selectPlaylist();if(g.media()===b)return;s.logger_(`track change. Switching main audio from ${p.id} to ${a.id}`),t.pause(),n.resetEverything(),g.fastQualityChange_(b);return}if(i==="AUDIO"){if(!l.playlistLoader){n.setAudio(!0),n.resetEverything();return}r.setAudio(!0),n.setAudio(!1)}if(u===l.playlistLoader){_l(l.playlistLoader,s);return}r.track&&r.track(a),r.resetEverything(),_l(l.playlistLoader,s)}},_a={AUDIO:(i,e)=>()=>{const{mediaTypes:{[i]:t},excludePlaylist:r}=e,n=t.activeTrack(),s=t.activeGroup(),a=(s.filter(u=>u.default)[0]||s[0]).id,l=t.tracks[a];if(n===l){r({error:{message:"Problem encountered loading the default audio track."}});return}B.log.warn("Problem encountered loading the alternate audio track.Switching back to default.");for(const u in t.tracks)t.tracks[u].enabled=t.tracks[u]===l;t.onTrackChanged()},SUBTITLES:(i,e)=>()=>{const{mediaTypes:{[i]:t}}=e;B.log.warn("Problem encountered loading the subtitle track.Disabling subtitle track.");const r=t.activeTrack();r&&(r.mode="disabled"),t.onTrackChanged()}},ch={AUDIO:(i,e,t)=>{if(!e)return;const{tech:r,requestOptions:n,segmentLoaders:{[i]:s}}=t;e.on("loadedmetadata",()=>{const a=e.media();s.playlist(a,n),(!r.paused()||a.endList&&r.preload()!=="none")&&s.load()}),e.on("loadedplaylist",()=>{s.playlist(e.media(),n),r.paused()||s.load()}),e.on("error",_a[i](i,t))},SUBTITLES:(i,e,t)=>{const{tech:r,requestOptions:n,segmentLoaders:{[i]:s},mediaTypes:{[i]:a}}=t;e.on("loadedmetadata",()=>{const l=e.media();s.playlist(l,n),s.track(a.activeTrack()),(!r.paused()||l.endList&&r.preload()!=="none")&&s.load()}),e.on("loadedplaylist",()=>{s.playlist(e.media(),n),r.paused()||s.load()}),e.on("error",_a[i](i,t))}},n2={AUDIO:(i,e)=>{const{vhs:t,sourceType:r,segmentLoaders:{[i]:n},requestOptions:s,main:{mediaGroups:a},mediaTypes:{[i]:{groups:l,tracks:u,logger_:p}},mainPlaylistLoader:g}=e,b=ts(g.main);(!a[i]||Object.keys(a[i]).length===0)&&(a[i]={main:{default:{default:!0}}},b&&(a[i].main.default.playlists=g.main.playlists));for(const S in a[i]){l[S]||(l[S]=[]);for(const w in a[i][S]){let C=a[i][S][w],v;if(b?(p(`AUDIO group '${S}' label '${w}' is a main playlist`),C.isMainPlaylist=!0,v=null):r==="vhs-json"&&C.playlists?v=new Er(C.playlists[0],t,s):C.resolvedUri?v=new Er(C.resolvedUri,t,s):C.playlists&&r==="dash"?v=new pl(C.playlists[0],t,s,g):v=null,C=fe({id:w,playlistLoader:v},C),ch[i](i,C.playlistLoader,e),l[S].push(C),typeof u[w]>"u"){const D=new B.AudioTrack({id:w,kind:e2(C),enabled:!1,language:C.language,default:C.default,label:w});u[w]=D}}}n.on("error",_a[i](i,e))},SUBTITLES:(i,e)=>{const{tech:t,vhs:r,sourceType:n,segmentLoaders:{[i]:s},requestOptions:a,main:{mediaGroups:l},mediaTypes:{[i]:{groups:u,tracks:p}},mainPlaylistLoader:g}=e;for(const b in l[i]){u[b]||(u[b]=[]);for(const S in l[i][b]){if(!r.options_.useForcedSubtitles&&l[i][b][S].forced)continue;let w=l[i][b][S],C;if(n==="hls")C=new Er(w.resolvedUri,r,a);else if(n==="dash"){if(!w.playlists.filter(v=>v.excludeUntil!==1/0).length)return;C=new pl(w.playlists[0],r,a,g)}else n==="vhs-json"&&(C=new Er(w.playlists?w.playlists[0]:w.resolvedUri,r,a));if(w=fe({id:S,playlistLoader:C},w),ch[i](i,w.playlistLoader,e),u[b].push(w),typeof p[S]>"u"){const v=t.addRemoteTextTrack({id:S,kind:"subtitles",default:w.default&&w.autoselect,language:w.language,label:S},!1).track;p[S]=v}}}s.on("error",_a[i](i,e))},"CLOSED-CAPTIONS":(i,e)=>{const{tech:t,main:{mediaGroups:r},mediaTypes:{[i]:{groups:n,tracks:s}}}=e;for(const a in r[i]){n[a]||(n[a]=[]);for(const l in r[i][a]){const u=r[i][a][l];if(!/^(?:CC|SERVICE)/.test(u.instreamId))continue;const p=t.options_.vhs&&t.options_.vhs.captionServices||{};let g={label:l,language:u.language,instreamId:u.instreamId,default:u.default&&u.autoselect};if(p[g.instreamId]&&(g=fe(g,p[g.instreamId])),g.default===void 0&&delete g.default,n[a].push(fe({id:l},u)),typeof s[l]>"u"){const b=t.addRemoteTextTrack({id:g.instreamId,kind:"captions",default:g.default,language:g.language,label:g.label},!1).track;s[l]=b}}}}},Km=(i,e)=>{for(let t=0;t<i.length;t++)if(Eu(e,i[t])||i[t].playlists&&Km(i[t].playlists,e))return!0;return!1},s2=(i,e)=>t=>{const{mainPlaylistLoader:r,mediaTypes:{[i]:{groups:n}}}=e,s=r.media();if(!s)return null;let a=null;s.attributes[i]&&(a=n[s.attributes[i]]);const l=Object.keys(n);if(!a)if(i==="AUDIO"&&l.length>1&&ts(e.main))for(let u=0;u<l.length;u++){const p=n[l[u]];if(Km(p,s)){a=p;break}}else n.main?a=n.main:l.length===1&&(a=n[l[0]]);return typeof t>"u"?a:t===null||!a?null:a.filter(u=>u.id===t.id)[0]||null},a2={AUDIO:(i,e)=>()=>{const{mediaTypes:{[i]:{tracks:t}}}=e;for(const r in t)if(t[r].enabled)return t[r];return null},SUBTITLES:(i,e)=>()=>{const{mediaTypes:{[i]:{tracks:t}}}=e;for(const r in t)if(t[r].mode==="showing"||t[r].mode==="hidden")return t[r];return null}},o2=(i,{mediaTypes:e})=>()=>{const t=e[i].activeTrack();return t?e[i].activeGroup(t):null},l2=i=>{["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(p=>{n2[p](p,i)});const{mediaTypes:e,mainPlaylistLoader:t,tech:r,vhs:n,segmentLoaders:{["AUDIO"]:s,main:a}}=i;["AUDIO","SUBTITLES"].forEach(p=>{e[p].activeGroup=s2(p,i),e[p].activeTrack=a2[p](p,i),e[p].onGroupChanged=t2(p,i),e[p].onGroupChanging=i2(p,i),e[p].onTrackChanged=r2(p,i),e[p].getActiveGroup=o2(p,i)});const l=e.AUDIO.activeGroup();if(l){const p=(l.filter(g=>g.default)[0]||l[0]).id;e.AUDIO.tracks[p].enabled=!0,e.AUDIO.onGroupChanged(),e.AUDIO.onTrackChanged(),e.AUDIO.getActiveGroup().playlistLoader?(a.setAudio(!1),s.setAudio(!0)):a.setAudio(!0)}t.on("mediachange",()=>{["AUDIO","SUBTITLES"].forEach(p=>e[p].onGroupChanged())}),t.on("mediachanging",()=>{["AUDIO","SUBTITLES"].forEach(p=>e[p].onGroupChanging())});const u=()=>{e.AUDIO.onTrackChanged(),r.trigger({type:"usage",name:"vhs-audio-change"})};r.audioTracks().addEventListener("change",u),r.remoteTextTracks().addEventListener("change",e.SUBTITLES.onTrackChanged),n.on("dispose",()=>{r.audioTracks().removeEventListener("change",u),r.remoteTextTracks().removeEventListener("change",e.SUBTITLES.onTrackChanged)}),r.clearTracks("audio");for(const p in e.AUDIO.tracks)r.audioTracks().addTrack(e.AUDIO.tracks[p])},u2=()=>{const i={};return["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(e=>{i[e]={groups:{},tracks:{},activePlaylistLoader:null,activeGroup:pi,activeTrack:pi,getActiveGroup:pi,onGroupChanged:pi,onTrackChanged:pi,lastTrack_:null,logger_:Nt(`MediaGroups[${e}]`)}}),i};class dh{constructor(){this.priority_=[],this.pathwayClones_=new Map}set version(e){e===1&&(this.version_=e)}set ttl(e){this.ttl_=e||300}set reloadUri(e){e&&(this.reloadUri_=yt(this.reloadUri_,e))}set priority(e){e&&e.length&&(this.priority_=e)}set pathwayClones(e){e&&e.length&&(this.pathwayClones_=new Map(e.map(t=>[t.ID,t])))}get version(){return this.version_}get ttl(){return this.ttl_}get reloadUri(){return this.reloadUri_}get priority(){return this.priority_}get pathwayClones(){return this.pathwayClones_}}class c2 extends B.EventTarget{constructor(e,t){super(),this.currentPathway=null,this.defaultPathway=null,this.queryBeforeStart=!1,this.availablePathways_=new Set,this.steeringManifest=new dh,this.proxyServerUrl_=null,this.manifestType_=null,this.ttlTimeout_=null,this.request_=null,this.currentPathwayClones=new Map,this.nextPathwayClones=new Map,this.excludedSteeringManifestURLs=new Set,this.logger_=Nt("Content Steering"),this.xhr_=e,this.getBandwidth_=t}assignTagProperties(e,t){this.manifestType_=t.serverUri?"HLS":"DASH";const r=t.serverUri||t.serverURL;if(!r){this.logger_(`steering manifest URL is ${r}, cannot request steering manifest.`),this.trigger("error");return}if(r.startsWith("data:")){this.decodeDataUriManifest_(r.substring(r.indexOf(",")+1));return}this.steeringManifest.reloadUri=yt(e,r),this.defaultPathway=t.pathwayId||t.defaultServiceLocation,this.queryBeforeStart=t.queryBeforeStart,this.proxyServerUrl_=t.proxyServerURL,this.defaultPathway&&!this.queryBeforeStart&&this.trigger("content-steering")}requestSteeringManifest(e){const t=this.steeringManifest.reloadUri;if(!t)return;const r=e?t:this.getRequestURI(t);if(!r){this.logger_("No valid content steering manifest URIs. Stopping content steering."),this.trigger("error"),this.dispose();return}const n={contentSteeringInfo:{uri:r}};this.trigger({type:"contentsteeringloadstart",metadata:n}),this.request_=this.xhr_({uri:r,requestType:"content-steering-manifest"},(s,a)=>{if(s){if(a.status===410){this.logger_(`manifest request 410 ${s}.`),this.logger_(`There will be no more content steering requests to ${r} this session.`),this.excludedSteeringManifestURLs.add(r);return}if(a.status===429){const p=a.responseHeaders["retry-after"];this.logger_(`manifest request 429 ${s}.`),this.logger_(`content steering will retry in ${p} seconds.`),this.startTTLTimeout_(parseInt(p,10));return}this.logger_(`manifest failed to load ${s}.`),this.startTTLTimeout_();return}this.trigger({type:"contentsteeringloadcomplete",metadata:n});let l;try{l=JSON.parse(this.request_.responseText)}catch(p){const g={errorType:B.Error.StreamingContentSteeringParserError,error:p};this.trigger({type:"error",metadata:g})}this.assignSteeringProperties_(l);const u={contentSteeringInfo:n.contentSteeringInfo,contentSteeringManifest:{version:this.steeringManifest.version,reloadUri:this.steeringManifest.reloadUri,priority:this.steeringManifest.priority}};this.trigger({type:"contentsteeringparsed",metadata:u}),this.startTTLTimeout_()})}setProxyServerUrl_(e){const t=new x.URL(e),r=new x.URL(this.proxyServerUrl_);return r.searchParams.set("url",encodeURI(t.toString())),this.setSteeringParams_(r.toString())}decodeDataUriManifest_(e){const t=JSON.parse(x.atob(e));this.assignSteeringProperties_(t)}setSteeringParams_(e){const t=new x.URL(e),r=this.getPathway(),n=this.getBandwidth_();if(r){const s=`_${this.manifestType_}_pathway`;t.searchParams.set(s,r)}if(n){const s=`_${this.manifestType_}_throughput`;t.searchParams.set(s,n)}return t.toString()}assignSteeringProperties_(e){if(this.steeringManifest.version=e.VERSION,!this.steeringManifest.version){this.logger_(`manifest version is ${e.VERSION}, which is not supported.`),this.trigger("error");return}this.steeringManifest.ttl=e.TTL,this.steeringManifest.reloadUri=e["RELOAD-URI"],this.steeringManifest.priority=e["PATHWAY-PRIORITY"]||e["SERVICE-LOCATION-PRIORITY"],this.steeringManifest.pathwayClones=e["PATHWAY-CLONES"],this.nextPathwayClones=this.steeringManifest.pathwayClones,this.availablePathways_.size||(this.logger_("There are no available pathways for content steering. Ending content steering."),this.trigger("error"),this.dispose());const t=(r=>{for(const n of r)if(this.availablePathways_.has(n))return n;return[...this.availablePathways_][0]})(this.steeringManifest.priority);this.currentPathway!==t&&(this.currentPathway=t,this.trigger("content-steering"))}getPathway(){return this.currentPathway||this.defaultPathway}getRequestURI(e){if(!e)return null;const t=n=>this.excludedSteeringManifestURLs.has(n);if(this.proxyServerUrl_){const n=this.setProxyServerUrl_(e);if(!t(n))return n}const r=this.setSteeringParams_(e);return t(r)?null:r}startTTLTimeout_(e=this.steeringManifest.ttl){const t=e*1e3;this.ttlTimeout_=x.setTimeout(()=>{this.requestSteeringManifest()},t)}clearTTLTimeout_(){x.clearTimeout(this.ttlTimeout_),this.ttlTimeout_=null}abort(){this.request_&&this.request_.abort(),this.request_=null}dispose(){this.off("content-steering"),this.off("error"),this.abort(),this.clearTTLTimeout_(),this.currentPathway=null,this.defaultPathway=null,this.queryBeforeStart=null,this.proxyServerUrl_=null,this.manifestType_=null,this.ttlTimeout_=null,this.request_=null,this.excludedSteeringManifestURLs=new Set,this.availablePathways_=new Set,this.steeringManifest=new dh}addAvailablePathway(e){e&&this.availablePathways_.add(e)}clearAvailablePathways(){this.availablePathways_.clear()}excludePathway(e){return this.availablePathways_.delete(e)}didDASHTagChange(e,t){return!t&&this.steeringManifest.reloadUri||t&&(yt(e,t.serverURL)!==this.steeringManifest.reloadUri||t.defaultServiceLocation!==this.defaultPathway||t.queryBeforeStart!==this.queryBeforeStart||t.proxyServerURL!==this.proxyServerUrl_)}getAvailablePathways(){return this.availablePathways_}}const d2=(i,e)=>{let t=null;return(...r)=>{clearTimeout(t),t=setTimeout(()=>{i.apply(null,r)},e)}},h2=10;let Pi;const p2=["mediaRequests","mediaRequestsAborted","mediaRequestsTimedout","mediaRequestsErrored","mediaTransferDuration","mediaBytesTransferred","mediaAppends"],g2=function(i){return this.audioSegmentLoader_[i]+this.mainSegmentLoader_[i]},m2=function({currentPlaylist:i,buffered:e,currentTime:t,nextPlaylist:r,bufferLowWaterLine:n,bufferHighWaterLine:s,duration:a,bufferBasedABR:l,log:u}){if(!r)return B.log.warn("We received no playlist to switch to. Please check your stream."),!1;const p=`allowing switch ${i&&i.id||"null"} -> ${r.id}`;if(!i)return u(`${p} as current playlist is not set`),!0;if(r.id===i.id)return!1;const g=!!Sr(e,t).length;if(!i.endList)return!g&&typeof i.partTargetDuration=="number"?(u(`not ${p} as current playlist is live llhls, but currentTime isn't in buffered.`),!1):(u(`${p} as current playlist is live`),!0);const b=vu(e,t),S=l?Xe.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE:Xe.MAX_BUFFER_LOW_WATER_LINE;if(a<S)return u(`${p} as duration < max low water line (${a} < ${S})`),!0;const w=r.attributes.BANDWIDTH,C=i.attributes.BANDWIDTH;if(w<C&&(!l||b<s)){let v=`${p} as next bandwidth < current bandwidth (${w} < ${C})`;return l&&(v+=` and forwardBuffer < bufferHighWaterLine (${b} < ${s})`),u(v),!0}if((!l||w>C)&&b>=n){let v=`${p} as forwardBuffer >= bufferLowWaterLine (${b} >= ${n})`;return l&&(v+=` and next bandwidth > current bandwidth (${w} > ${C})`),u(v),!0}return u(`not ${p} as no switching criteria met`),!1};class f2 extends B.EventTarget{constructor(e){super(),this.fastQualityChange_=d2(this.fastQualityChange_.bind(this),100);const{src:t,withCredentials:r,tech:n,bandwidth:s,externVhs:a,useCueTags:l,playlistExclusionDuration:u,enableLowInitialPlaylist:p,sourceType:g,cacheEncryptionKeys:b,bufferBasedABR:S,leastPixelDiffSelector:w,captionServices:C,experimentalUseMMS:v}=e;if(!t)throw new Error("A non-empty playlist URL or JSON manifest string is required");let{maxPlaylistRetries:D}=e;(D===null||typeof D>"u")&&(D=1/0),Pi=a,this.bufferBasedABR=!!S,this.leastPixelDiffSelector=!!w,this.withCredentials=r,this.tech_=n,this.vhs_=n.vhs,this.player_=e.player_,this.sourceType_=g,this.useCueTags_=l,this.playlistExclusionDuration=u,this.maxPlaylistRetries=D,this.enableLowInitialPlaylist=p,this.usingManagedMediaSource_=!1,this.useCueTags_&&(this.cueTagsTrack_=this.tech_.addTextTrack("metadata","ad-cues"),this.cueTagsTrack_.inBandMetadataTrackDispatchType=""),this.requestOptions_={withCredentials:r,maxPlaylistRetries:D,timeout:null},this.on("error",this.pauseLoading),this.mediaTypes_=u2(),v&&x.ManagedMediaSource?(this.tech_.el_.disableRemotePlayback=!0,this.mediaSource=new x.ManagedMediaSource,this.usingManagedMediaSource_=!0,B.log("Using ManagedMediaSource")):x.MediaSource&&(this.mediaSource=new x.MediaSource),this.handleDurationChange_=this.handleDurationChange_.bind(this),this.handleSourceOpen_=this.handleSourceOpen_.bind(this),this.handleSourceEnded_=this.handleSourceEnded_.bind(this),this.load=this.load.bind(this),this.pause=this.pause.bind(this),this.mediaSource.addEventListener("durationchange",this.handleDurationChange_),this.mediaSource.addEventListener("sourceopen",this.handleSourceOpen_),this.mediaSource.addEventListener("sourceended",this.handleSourceEnded_),this.mediaSource.addEventListener("startstreaming",this.load),this.mediaSource.addEventListener("endstreaming",this.pause),this.seekable_=it(),this.hasPlayed_=!1,this.syncController_=new Yw(e),this.segmentMetadataTrack_=n.addRemoteTextTrack({kind:"metadata",label:"segment-metadata"},!1).track,this.decrypter_=new Zw,this.sourceUpdater_=new Wm(this.mediaSource),this.inbandTextTracks_={},this.timelineChangeController_=new Qw,this.keyStatusMap_=new Map;const L={vhs:this.vhs_,parse708captions:e.parse708captions,useDtsForTimestampOffset:e.useDtsForTimestampOffset,captionServices:C,mediaSource:this.mediaSource,currentTime:this.tech_.currentTime.bind(this.tech_),seekable:()=>this.seekable(),seeking:()=>this.tech_.seeking(),duration:()=>this.duration(),hasPlayed:()=>this.hasPlayed_,goalBufferLength:()=>this.goalBufferLength(),bandwidth:s,syncController:this.syncController_,decrypter:this.decrypter_,sourceType:this.sourceType_,inbandTextTracks:this.inbandTextTracks_,cacheEncryptionKeys:b,sourceUpdater:this.sourceUpdater_,timelineChangeController:this.timelineChangeController_,exactManifestTimings:e.exactManifestTimings,addMetadataToTextTrack:this.addMetadataToTextTrack.bind(this)};this.mainPlaylistLoader_=this.sourceType_==="dash"?new pl(t,this.vhs_,fe(this.requestOptions_,{addMetadataToTextTrack:this.addMetadataToTextTrack.bind(this)})):new Er(t,this.vhs_,fe(this.requestOptions_,{addDateRangesToTextTrack:this.addDateRangesToTextTrack_.bind(this)})),this.setupMainPlaylistLoaderListeners_(),this.mainSegmentLoader_=new fl(fe(L,{segmentMetadataTrack:this.segmentMetadataTrack_,loaderType:"main"}),e),this.audioSegmentLoader_=new fl(fe(L,{loaderType:"audio"}),e),this.subtitleSegmentLoader_=new zw(fe(L,{loaderType:"vtt",featuresNativeTextTracks:this.tech_.featuresNativeTextTracks,loadVttJs:()=>new Promise((F,N)=>{function V(){n.off("vttjserror",J),F()}function J(){n.off("vttjsloaded",V),N()}n.one("vttjsloaded",V),n.one("vttjserror",J),n.addWebVttScript_()})}),e);const O=()=>this.mainSegmentLoader_.bandwidth;this.contentSteeringController_=new c2(this.vhs_.xhr,O),this.setupSegmentLoaderListeners_(),this.bufferBasedABR&&(this.mainPlaylistLoader_.one("loadedplaylist",()=>this.startABRTimer_()),this.tech_.on("pause",()=>this.stopABRTimer_()),this.tech_.on("play",()=>this.startABRTimer_())),p2.forEach(F=>{this[F+"_"]=g2.bind(this,F)}),this.logger_=Nt("pc"),this.triggeredFmp4Usage=!1,this.tech_.preload()==="none"?(this.loadOnPlay_=()=>{this.loadOnPlay_=null,this.mainPlaylistLoader_.load()},this.tech_.one("play",this.loadOnPlay_)):this.mainPlaylistLoader_.load(),this.timeToLoadedData__=-1,this.mainAppendsToLoadedData__=-1,this.audioAppendsToLoadedData__=-1;const U=this.tech_.preload()==="none"?"play":"loadstart";this.tech_.one(U,()=>{const F=Date.now();this.tech_.one("loadeddata",()=>{this.timeToLoadedData__=Date.now()-F,this.mainAppendsToLoadedData__=this.mainSegmentLoader_.mediaAppends,this.audioAppendsToLoadedData__=this.audioSegmentLoader_.mediaAppends})})}mainAppendsToLoadedData_(){return this.mainAppendsToLoadedData__}audioAppendsToLoadedData_(){return this.audioAppendsToLoadedData__}appendsToLoadedData_(){const e=this.mainAppendsToLoadedData_(),t=this.audioAppendsToLoadedData_();return e===-1||t===-1?-1:e+t}timeToLoadedData_(){return this.timeToLoadedData__}checkABR_(e="abr"){const t=this.selectPlaylist();t&&this.shouldSwitchToMedia_(t)&&this.switchMedia_(t,e)}switchMedia_(e,t,r){const n=this.media(),s=n&&(n.id||n.uri),a=e&&(e.id||e.uri);if(s&&s!==a){this.logger_(`switch media ${s} -> ${a} from ${t}`);const l={renditionInfo:{id:a,bandwidth:e.attributes.BANDWIDTH,resolution:e.attributes.RESOLUTION,codecs:e.attributes.CODECS},cause:t};this.trigger({type:"renditionselected",metadata:l}),this.tech_.trigger({type:"usage",name:`vhs-rendition-change-${t}`})}this.mainPlaylistLoader_.media(e,r)}switchMediaForDASHContentSteering_(){["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(e=>{const t=this.mediaTypes_[e],r=t?t.activeGroup():null,n=this.contentSteeringController_.getPathway();if(r&&n){const s=(r.length?r[0].playlists:r.playlists).filter(a=>a.attributes.serviceLocation===n);s.length&&this.mediaTypes_[e].activePlaylistLoader.media(s[0])}})}startABRTimer_(){this.stopABRTimer_(),this.abrTimer_=x.setInterval(()=>this.checkABR_(),250)}stopABRTimer_(){this.tech_.scrubbing&&this.tech_.scrubbing()||(x.clearInterval(this.abrTimer_),this.abrTimer_=null)}getAudioTrackPlaylists_(){const e=this.main(),t=e&&e.playlists||[];if(!e||!e.mediaGroups||!e.mediaGroups.AUDIO)return t;const r=e.mediaGroups.AUDIO,n=Object.keys(r);let s;if(Object.keys(this.mediaTypes_.AUDIO.groups).length)s=this.mediaTypes_.AUDIO.activeTrack();else{const l=r.main||n.length&&r[n[0]];for(const u in l)if(l[u].default){s={label:u};break}}if(!s)return t;const a=[];for(const l in r)if(r[l][s.label]){const u=r[l][s.label];if(u.playlists&&u.playlists.length)a.push.apply(a,u.playlists);else if(u.uri)a.push(u);else if(e.playlists.length)for(let p=0;p<e.playlists.length;p++){const g=e.playlists[p];g.attributes&&g.attributes.AUDIO&&g.attributes.AUDIO===l&&a.push(g)}}return a.length?a:t}setupMainPlaylistLoaderListeners_(){this.mainPlaylistLoader_.on("loadedmetadata",()=>{const e=this.mainPlaylistLoader_.media(),t=e.targetDuration*1.5*1e3;ll(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.media())?this.requestOptions_.timeout=0:this.requestOptions_.timeout=t,e.endList&&this.tech_.preload()!=="none"&&(this.mainSegmentLoader_.playlist(e,this.requestOptions_),this.mainSegmentLoader_.load()),l2({sourceType:this.sourceType_,segmentLoaders:{AUDIO:this.audioSegmentLoader_,SUBTITLES:this.subtitleSegmentLoader_,main:this.mainSegmentLoader_},tech:this.tech_,requestOptions:this.requestOptions_,mainPlaylistLoader:this.mainPlaylistLoader_,vhs:this.vhs_,main:this.main(),mediaTypes:this.mediaTypes_,excludePlaylist:this.excludePlaylist.bind(this)}),this.triggerPresenceUsage_(this.main(),e),this.setupFirstPlay(),!this.mediaTypes_.AUDIO.activePlaylistLoader||this.mediaTypes_.AUDIO.activePlaylistLoader.media()?this.trigger("selectedinitialmedia"):this.mediaTypes_.AUDIO.activePlaylistLoader.one("loadedmetadata",()=>{this.trigger("selectedinitialmedia")})}),this.mainPlaylistLoader_.on("loadedplaylist",()=>{this.loadOnPlay_&&this.tech_.off("play",this.loadOnPlay_);let e=this.mainPlaylistLoader_.media();if(!e){this.attachContentSteeringListeners_(),this.initContentSteeringController_(),this.excludeUnsupportedVariants_();let t;if(this.enableLowInitialPlaylist&&(t=this.selectInitialPlaylist()),t||(t=this.selectPlaylist()),!t||!this.shouldSwitchToMedia_(t)||(this.initialMedia_=t,this.switchMedia_(this.initialMedia_,"initial"),!(this.sourceType_==="vhs-json"&&this.initialMedia_.segments)))return;e=this.initialMedia_}this.handleUpdatedMediaPlaylist(e)}),this.mainPlaylistLoader_.on("error",()=>{const e=this.mainPlaylistLoader_.error;this.excludePlaylist({playlistToExclude:e.playlist,error:e})}),this.mainPlaylistLoader_.on("mediachanging",()=>{this.mainSegmentLoader_.abort(),this.mainSegmentLoader_.pause()}),this.mainPlaylistLoader_.on("mediachange",()=>{const e=this.mainPlaylistLoader_.media(),t=e.targetDuration*1.5*1e3;ll(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.media())?this.requestOptions_.timeout=0:this.requestOptions_.timeout=t,this.sourceType_==="dash"&&this.mainPlaylistLoader_.isPaused&&this.mainPlaylistLoader_.load(),this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.playlist(e,this.requestOptions_),this.waitingForFastQualityPlaylistReceived_?this.runFastQualitySwitch_():this.mainSegmentLoader_.load(),this.tech_.trigger({type:"mediachange",bubbles:!0})}),this.mainPlaylistLoader_.on("playlistunchanged",()=>{const e=this.mainPlaylistLoader_.media();e.lastExcludeReason_!=="playlist-unchanged"&&this.stuckAtPlaylistEnd_(e)&&(this.excludePlaylist({error:{message:"Playlist no longer updating.",reason:"playlist-unchanged"}}),this.tech_.trigger("playliststuck"))}),this.mainPlaylistLoader_.on("renditiondisabled",()=>{this.tech_.trigger({type:"usage",name:"vhs-rendition-disabled"})}),this.mainPlaylistLoader_.on("renditionenabled",()=>{this.tech_.trigger({type:"usage",name:"vhs-rendition-enabled"})}),["manifestrequeststart","manifestrequestcomplete","manifestparsestart","manifestparsecomplete","playlistrequeststart","playlistrequestcomplete","playlistparsestart","playlistparsecomplete","renditiondisabled","renditionenabled"].forEach(e=>{this.mainPlaylistLoader_.on(e,t=>{this.player_.trigger(Ve({},t))})})}handleUpdatedMediaPlaylist(e){this.useCueTags_&&this.updateAdCues_(e),this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.playlist(e,this.requestOptions_),this.waitingForFastQualityPlaylistReceived_&&this.runFastQualitySwitch_(),this.updateDuration(!e.endList),this.tech_.paused()||(this.mainSegmentLoader_.load(),this.audioSegmentLoader_&&this.audioSegmentLoader_.load())}triggerPresenceUsage_(e,t){const r=e.mediaGroups||{};let n=!0;const s=Object.keys(r.AUDIO);for(const a in r.AUDIO)for(const l in r.AUDIO[a])r.AUDIO[a][l].uri||(n=!1);n&&this.tech_.trigger({type:"usage",name:"vhs-demuxed"}),Object.keys(r.SUBTITLES).length&&this.tech_.trigger({type:"usage",name:"vhs-webvtt"}),Pi.Playlist.isAes(t)&&this.tech_.trigger({type:"usage",name:"vhs-aes"}),s.length&&Object.keys(r.AUDIO[s[0]]).length>1&&this.tech_.trigger({type:"usage",name:"vhs-alternate-audio"}),this.useCueTags_&&this.tech_.trigger({type:"usage",name:"vhs-playlist-cue-tags"})}shouldSwitchToMedia_(e){const t=this.mainPlaylistLoader_.media()||this.mainPlaylistLoader_.pendingMedia_,r=this.tech_.currentTime(),n=this.bufferLowWaterLine(),s=this.bufferHighWaterLine(),a=this.tech_.buffered();return m2({buffered:a,currentTime:r,currentPlaylist:t,nextPlaylist:e,bufferLowWaterLine:n,bufferHighWaterLine:s,duration:this.duration(),bufferBasedABR:this.bufferBasedABR,log:this.logger_})}setupSegmentLoaderListeners_(){this.mainSegmentLoader_.on("bandwidthupdate",()=>{this.checkABR_("bandwidthupdate"),this.tech_.trigger("bandwidthupdate")}),this.mainSegmentLoader_.on("timeout",()=>{this.bufferBasedABR&&this.mainSegmentLoader_.load()}),this.bufferBasedABR||this.mainSegmentLoader_.on("progress",()=>{this.trigger("progress")}),this.mainSegmentLoader_.on("error",()=>{const t=this.mainSegmentLoader_.error();this.excludePlaylist({playlistToExclude:t.playlist,error:t})}),this.mainSegmentLoader_.on("appenderror",()=>{this.error=this.mainSegmentLoader_.error_,this.trigger("error")}),this.mainSegmentLoader_.on("syncinfoupdate",()=>{this.onSyncInfoUpdate_()}),this.mainSegmentLoader_.on("timestampoffset",()=>{this.tech_.trigger({type:"usage",name:"vhs-timestamp-offset"})}),this.audioSegmentLoader_.on("syncinfoupdate",()=>{this.onSyncInfoUpdate_()}),this.audioSegmentLoader_.on("appenderror",()=>{this.error=this.audioSegmentLoader_.error_,this.trigger("error")}),this.mainSegmentLoader_.on("ended",()=>{this.logger_("main segment loader ended"),this.onEndOfStream()}),this.timelineChangeController_.on("audioTimelineBehind",()=>{const t=this.audioSegmentLoader_.pendingSegment_;if(!t||!t.segment||!t.segment.syncInfo)return;const r=t.segment.syncInfo.end+.01;this.tech_.setCurrentTime(r)}),this.timelineChangeController_.on("fixBadTimelineChange",()=>{this.logger_("Fix bad timeline change. Restarting al segment loaders..."),this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.resetEverything(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.pause(),this.audioSegmentLoader_.resetEverything()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.pause(),this.subtitleSegmentLoader_.resetEverything()),this.load()}),this.mainSegmentLoader_.on("earlyabort",t=>{this.bufferBasedABR||(this.delegateLoaders_("all",["abort"]),this.excludePlaylist({error:{message:"Aborted early because there isn't enough bandwidth to complete the request without rebuffering."},playlistExclusionDuration:h2}))});const e=()=>{if(!this.sourceUpdater_.hasCreatedSourceBuffers())return this.tryToCreateSourceBuffers_();const t=this.getCodecsOrExclude_();t&&this.sourceUpdater_.addOrChangeSourceBuffers(t)};this.mainSegmentLoader_.on("trackinfo",e),this.audioSegmentLoader_.on("trackinfo",e),this.mainSegmentLoader_.on("fmp4",()=>{this.triggeredFmp4Usage||(this.tech_.trigger({type:"usage",name:"vhs-fmp4"}),this.triggeredFmp4Usage=!0)}),this.audioSegmentLoader_.on("fmp4",()=>{this.triggeredFmp4Usage||(this.tech_.trigger({type:"usage",name:"vhs-fmp4"}),this.triggeredFmp4Usage=!0)}),this.audioSegmentLoader_.on("ended",()=>{this.logger_("audioSegmentLoader ended"),this.onEndOfStream()}),["segmentselected","segmentloadstart","segmentloaded","segmentkeyloadstart","segmentkeyloadcomplete","segmentdecryptionstart","segmentdecryptioncomplete","segmenttransmuxingstart","segmenttransmuxingcomplete","segmenttransmuxingtrackinfoavailable","segmenttransmuxingtiminginfoavailable","segmentappendstart","appendsdone","bandwidthupdated","timelinechange","codecschange"].forEach(t=>{this.mainSegmentLoader_.on(t,r=>{this.player_.trigger(Ve({},r))}),this.audioSegmentLoader_.on(t,r=>{this.player_.trigger(Ve({},r))}),this.subtitleSegmentLoader_.on(t,r=>{this.player_.trigger(Ve({},r))})})}mediaSecondsLoaded_(){return Math.max(this.audioSegmentLoader_.mediaSecondsLoaded+this.mainSegmentLoader_.mediaSecondsLoaded)}load(){this.mainSegmentLoader_.load(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.load(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.load()}pause(){this.mainSegmentLoader_.pause(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.pause(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.pause()}fastQualityChange_(e=this.selectPlaylist()){if(e&&e===this.mainPlaylistLoader_.media()){this.logger_("skipping fastQualityChange because new media is same as old");return}this.switchMedia_(e,"fast-quality"),this.waitingForFastQualityPlaylistReceived_=!0}runFastQualitySwitch_(){this.waitingForFastQualityPlaylistReceived_=!1,this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.resetEverything(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.pause(),this.audioSegmentLoader_.resetEverything()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.pause(),this.subtitleSegmentLoader_.resetEverything()),this.load()}play(){if(this.setupFirstPlay())return;this.tech_.ended()&&this.tech_.setCurrentTime(0),this.hasPlayed_&&this.load();const e=this.tech_.seekable();if(this.tech_.duration()===1/0&&this.tech_.currentTime()<e.start(0))return this.tech_.setCurrentTime(e.end(e.length-1))}setupFirstPlay(){const e=this.mainPlaylistLoader_.media();if(!e||this.tech_.paused()||this.hasPlayed_)return!1;if(!e.endList||e.start){const t=this.seekable();if(!t.length)return!1;const r=t.end(0);let n=r;if(e.start){const s=e.start.timeOffset;s<0?n=Math.max(r+s,t.start(0)):n=Math.min(r,s)}this.trigger("firstplay"),this.tech_.setCurrentTime(n)}return this.hasPlayed_=!0,this.load(),!0}handleSourceOpen_(){if(this.tryToCreateSourceBuffers_(),this.tech_.autoplay()){const e=this.tech_.play();typeof e<"u"&&typeof e.then=="function"&&e.then(null,t=>{})}this.trigger("sourceopen")}handleSourceEnded_(){if(!this.inbandTextTracks_.metadataTrack_)return;const e=this.inbandTextTracks_.metadataTrack_.cues;if(!e||!e.length)return;const t=this.duration();e[e.length-1].endTime=isNaN(t)||Math.abs(t)===1/0?Number.MAX_VALUE:t}handleDurationChange_(){this.tech_.trigger("durationchange")}onEndOfStream(){let e=this.mainSegmentLoader_.ended_;if(this.mediaTypes_.AUDIO.activePlaylistLoader){const t=this.mainSegmentLoader_.getCurrentMediaInfo_();!t||t.hasVideo?e=e&&this.audioSegmentLoader_.ended_:e=this.audioSegmentLoader_.ended_}e&&(this.stopABRTimer_(),this.sourceUpdater_.endOfStream())}stuckAtPlaylistEnd_(e){if(!this.seekable().length)return!1;const t=this.syncController_.getExpiredTime(e,this.duration());if(t===null)return!1;const r=Pi.Playlist.playlistEnd(e,t),n=this.tech_.currentTime(),s=this.tech_.buffered();if(!s.length)return r-n<=ei;const a=s.end(s.length-1);return a-n<=ei&&r-a<=ei}excludePlaylist({playlistToExclude:e=this.mainPlaylistLoader_.media(),error:t={},playlistExclusionDuration:r}){if(e=e||this.mainPlaylistLoader_.media(),r=r||t.playlistExclusionDuration||this.playlistExclusionDuration,!e){this.error=t,this.mediaSource.readyState!=="open"?this.trigger("error"):this.sourceUpdater_.endOfStream("network");return}e.playlistErrors_++;const n=this.mainPlaylistLoader_.main.playlists,s=n.filter(Ga),a=s.length===1&&s[0]===e;if(n.length===1&&r!==1/0)return B.log.warn(`Problem encountered with playlist ${e.id}. Trying again since it is the only playlist.`),this.tech_.trigger("retryplaylist"),this.mainPlaylistLoader_.load(a);if(a){if(this.main().contentSteering){const C=this.pathwayAttribute_(e),v=this.contentSteeringController_.steeringManifest.ttl*1e3;this.contentSteeringController_.excludePathway(C),this.excludeThenChangePathway_(),setTimeout(()=>{this.contentSteeringController_.addAvailablePathway(C)},v);return}let w=!1;n.forEach(C=>{if(C===e)return;const v=C.excludeUntil;typeof v<"u"&&v!==1/0&&(w=!0,delete C.excludeUntil)}),w&&(B.log.warn("Removing other playlists from the exclusion list because the last rendition is about to be excluded."),this.tech_.trigger("retryplaylist"))}let l;e.playlistErrors_>this.maxPlaylistRetries?l=1/0:l=Date.now()+r*1e3,e.excludeUntil=l,t.reason&&(e.lastExcludeReason_=t.reason),this.tech_.trigger("excludeplaylist"),this.tech_.trigger({type:"usage",name:"vhs-rendition-excluded"});const u=this.selectPlaylist();if(!u){this.error="Playback cannot continue. No available working or supported playlists.",this.trigger("error");return}const p=t.internal?this.logger_:B.log.warn,g=t.message?" "+t.message:"";p(`${t.internal?"Internal problem":"Problem"} encountered with playlist ${e.id}.${g} Switching to playlist ${u.id}.`),u.attributes.AUDIO!==e.attributes.AUDIO&&this.delegateLoaders_("audio",["abort","pause"]),u.attributes.SUBTITLES!==e.attributes.SUBTITLES&&this.delegateLoaders_("subtitle",["abort","pause"]),this.delegateLoaders_("main",["abort","pause"]);const b=u.targetDuration/2*1e3||5*1e3,S=typeof u.lastRequest=="number"&&Date.now()-u.lastRequest<=b;return this.switchMedia_(u,"exclude",a||S)}pauseLoading(){this.delegateLoaders_("all",["abort","pause"]),this.stopABRTimer_()}delegateLoaders_(e,t){const r=[],n=e==="all";(n||e==="main")&&r.push(this.mainPlaylistLoader_);const s=[];(n||e==="audio")&&s.push("AUDIO"),(n||e==="subtitle")&&(s.push("CLOSED-CAPTIONS"),s.push("SUBTITLES")),s.forEach(a=>{const l=this.mediaTypes_[a]&&this.mediaTypes_[a].activePlaylistLoader;l&&r.push(l)}),["main","audio","subtitle"].forEach(a=>{const l=this[`${a}SegmentLoader_`];l&&(e===a||e==="all")&&r.push(l)}),r.forEach(a=>t.forEach(l=>{typeof a[l]=="function"&&a[l]()}))}setCurrentTime(e){const t=Sr(this.tech_.buffered(),e);if(!(this.mainPlaylistLoader_&&this.mainPlaylistLoader_.media())||!this.mainPlaylistLoader_.media().segments)return 0;if(t&&t.length)return e;this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.resetEverything(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.pause(),this.audioSegmentLoader_.resetEverything()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.pause(),this.subtitleSegmentLoader_.resetEverything()),this.load()}duration(){if(!this.mainPlaylistLoader_)return 0;const e=this.mainPlaylistLoader_.media();return e?e.endList?this.mediaSource?this.mediaSource.duration:Pi.Playlist.duration(e):1/0:0}seekable(){return this.seekable_}getSeekableRange_(e,t){const r=e.media();if(!r)return null;const n=this.syncController_.getMediaSequenceSync(t);if(n&&n.isReliable){const l=n.start,u=n.end;if(!isFinite(l)||!isFinite(u))return null;const p=Pi.Playlist.liveEdgeDelay(this.mainPlaylistLoader_.main,r),g=Math.max(0,u-p);return g<l?null:it([[l,g]])}const s=this.syncController_.getExpiredTime(r,this.duration());if(s===null)return null;const a=Pi.Playlist.seekable(r,s,Pi.Playlist.liveEdgeDelay(this.mainPlaylistLoader_.main,r));return a.length?a:null}computeFinalSeekable_(e,t){if(!t)return e;const r=e.start(0),n=e.end(0),s=t.start(0),a=t.end(0);return s>n||r>a?e:it([[Math.max(r,s),Math.min(n,a)]])}onSyncInfoUpdate_(){if(!this.mainPlaylistLoader_)return;const e=this.getSeekableRange_(this.mainPlaylistLoader_,"main");if(!e)return;let t;if(this.mediaTypes_.AUDIO.activePlaylistLoader&&(t=this.getSeekableRange_(this.mediaTypes_.AUDIO.activePlaylistLoader,"audio"),!t))return;const r=this.seekable_;if(this.seekable_=this.computeFinalSeekable_(e,t),!this.seekable_||r&&r.length&&this.seekable_.length&&r.start(0)===this.seekable_.start(0)&&r.end(0)===this.seekable_.end(0))return;this.logger_(`seekable updated [${am(this.seekable_)}]`);const n={seekableRanges:this.seekable_};this.trigger({type:"seekablerangeschanged",metadata:n}),this.tech_.trigger("seekablechanged")}updateDuration(e){if(this.updateDuration_&&(this.mediaSource.removeEventListener("sourceopen",this.updateDuration_),this.updateDuration_=null),this.mediaSource.readyState!=="open"){this.updateDuration_=this.updateDuration.bind(this,e),this.mediaSource.addEventListener("sourceopen",this.updateDuration_);return}if(e){const n=this.seekable();if(!n.length)return;(isNaN(this.mediaSource.duration)||this.mediaSource.duration<n.end(n.length-1))&&this.sourceUpdater_.setDuration(n.end(n.length-1));return}const t=this.tech_.buffered();let r=Pi.Playlist.duration(this.mainPlaylistLoader_.media());t.length>0&&(r=Math.max(r,t.end(t.length-1))),this.mediaSource.duration!==r&&this.sourceUpdater_.setDuration(r)}dispose(){this.trigger("dispose"),this.decrypter_.terminate(),this.mainPlaylistLoader_.dispose(),this.mainSegmentLoader_.dispose(),this.contentSteeringController_.dispose(),this.keyStatusMap_.clear(),this.loadOnPlay_&&this.tech_.off("play",this.loadOnPlay_),["AUDIO","SUBTITLES"].forEach(e=>{const t=this.mediaTypes_[e].groups;for(const r in t)t[r].forEach(n=>{n.playlistLoader&&n.playlistLoader.dispose()})}),this.audioSegmentLoader_.dispose(),this.subtitleSegmentLoader_.dispose(),this.sourceUpdater_.dispose(),this.timelineChangeController_.dispose(),this.stopABRTimer_(),this.updateDuration_&&this.mediaSource.removeEventListener("sourceopen",this.updateDuration_),this.mediaSource.removeEventListener("durationchange",this.handleDurationChange_),this.mediaSource.removeEventListener("sourceopen",this.handleSourceOpen_),this.mediaSource.removeEventListener("sourceended",this.handleSourceEnded_),this.off()}main(){return this.mainPlaylistLoader_.main}media(){return this.mainPlaylistLoader_.media()||this.initialMedia_}areMediaTypesKnown_(){const e=!!this.mediaTypes_.AUDIO.activePlaylistLoader,t=!!this.mainSegmentLoader_.getCurrentMediaInfo_(),r=e?!!this.audioSegmentLoader_.getCurrentMediaInfo_():!0;return!(!t||!r)}getCodecsOrExclude_(){const e={main:this.mainSegmentLoader_.getCurrentMediaInfo_()||{},audio:this.audioSegmentLoader_.getCurrentMediaInfo_()||{}},t=this.mainSegmentLoader_.getPendingSegmentPlaylist()||this.media();e.video=e.main;const r=Un(this.main(),t),n={},s=!!this.mediaTypes_.AUDIO.activePlaylistLoader;if(e.main.hasVideo&&(n.video=r.video||e.main.videoCodec||aT),e.main.isMuxed&&(n.video+=`,${r.audio||e.main.audioCodec||ad}`),(e.main.hasAudio&&!e.main.isMuxed||e.audio.hasAudio||s)&&(n.audio=r.audio||e.main.audioCodec||e.audio.audioCodec||ad,e.audio.isFmp4=e.main.hasAudio&&!e.main.isMuxed?e.main.isFmp4:e.audio.isFmp4),!n.audio&&!n.video){this.excludePlaylist({playlistToExclude:t,error:{message:"Could not determine codecs for playlist."},playlistExclusionDuration:1/0});return}const a=(p,g)=>p?Dn(g,this.usingManagedMediaSource_):ko(g),l={};let u;if(["video","audio"].forEach(function(p){if(n.hasOwnProperty(p)&&!a(e[p].isFmp4,n[p])){const g=e[p].isFmp4?"browser":"muxer";l[g]=l[g]||[],l[g].push(n[p]),p==="audio"&&(u=g)}}),s&&u&&t.attributes.AUDIO){const p=t.attributes.AUDIO;this.main().playlists.forEach(g=>{(g.attributes&&g.attributes.AUDIO)===p&&g!==t&&(g.excludeUntil=1/0)}),this.logger_(`excluding audio group ${p} as ${u} does not support codec(s): "${n.audio}"`)}if(Object.keys(l).length){const p=Object.keys(l).reduce((g,b)=>(g&&(g+=", "),g+=`${b} does not support codec(s): "${l[b].join(",")}"`,g),"")+".";this.excludePlaylist({playlistToExclude:t,error:{internal:!0,message:p},playlistExclusionDuration:1/0});return}if(this.sourceUpdater_.hasCreatedSourceBuffers()&&!this.sourceUpdater_.canChangeType()){const p=[];if(["video","audio"].forEach(g=>{const b=(Kt(this.sourceUpdater_.codecs[g]||"")[0]||{}).type,S=(Kt(n[g]||"")[0]||{}).type;b&&S&&b.toLowerCase()!==S.toLowerCase()&&p.push(`"${this.sourceUpdater_.codecs[g]}" -> "${n[g]}"`)}),p.length){this.excludePlaylist({playlistToExclude:t,error:{message:`Codec switching not supported: ${p.join(", ")}.`,internal:!0},playlistExclusionDuration:1/0});return}}return n}tryToCreateSourceBuffers_(){if(this.mediaSource.readyState!=="open"||this.sourceUpdater_.hasCreatedSourceBuffers()||!this.areMediaTypesKnown_())return;const e=this.getCodecsOrExclude_();if(!e)return;this.sourceUpdater_.createSourceBuffers(e);const t=[e.video,e.audio].filter(Boolean).join(",");this.excludeIncompatibleVariants_(t)}excludeUnsupportedVariants_(){const e=this.main().playlists,t=[];Object.keys(e).forEach(r=>{const n=e[r];if(t.indexOf(n.id)!==-1)return;t.push(n.id);const s=Un(this.main,n),a=[];s.audio&&!ko(s.audio)&&!Dn(s.audio,this.usingManagedMediaSource_)&&a.push(`audio codec ${s.audio}`),s.video&&!ko(s.video)&&!Dn(s.video,this.usingManagedMediaSource_)&&a.push(`video codec ${s.video}`),s.text&&s.text==="stpp.ttml.im1t"&&a.push(`text codec ${s.text}`),a.length&&(n.excludeUntil=1/0,this.logger_(`excluding ${n.id} for unsupported: ${a.join(", ")}`))})}excludeIncompatibleVariants_(e){const t=[],r=this.main().playlists,n=fa(Kt(e)),s=Jd(n),a=n.video&&Kt(n.video)[0]||null,l=n.audio&&Kt(n.audio)[0]||null;Object.keys(r).forEach(u=>{const p=r[u];if(t.indexOf(p.id)!==-1||p.excludeUntil===1/0)return;t.push(p.id);const g=[],b=Un(this.mainPlaylistLoader_.main,p),S=Jd(b);if(!(!b.audio&&!b.video)){if(S!==s&&g.push(`codec count "${S}" !== "${s}"`),!this.sourceUpdater_.canChangeType()){const w=b.video&&Kt(b.video)[0]||null,C=b.audio&&Kt(b.audio)[0]||null;w&&a&&w.type.toLowerCase()!==a.type.toLowerCase()&&g.push(`video codec "${w.type}" !== "${a.type}"`),C&&l&&C.type.toLowerCase()!==l.type.toLowerCase()&&g.push(`audio codec "${C.type}" !== "${l.type}"`)}g.length&&(p.excludeUntil=1/0,this.logger_(`excluding ${p.id}: ${g.join(" && ")}`))}})}updateAdCues_(e){let t=0;const r=this.seekable();r.length&&(t=r.start(0)),Gw(e,this.cueTagsTrack_,t)}goalBufferLength(){const e=this.tech_.currentTime(),t=Xe.GOAL_BUFFER_LENGTH,r=Xe.GOAL_BUFFER_LENGTH_RATE,n=Math.max(t,Xe.MAX_GOAL_BUFFER_LENGTH);return Math.min(t+e*r,n)}bufferLowWaterLine(){const e=this.tech_.currentTime(),t=Xe.BUFFER_LOW_WATER_LINE,r=Xe.BUFFER_LOW_WATER_LINE_RATE,n=Math.max(t,Xe.MAX_BUFFER_LOW_WATER_LINE),s=Math.max(t,Xe.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE);return Math.min(t+e*r,this.bufferBasedABR?s:n)}bufferHighWaterLine(){return Xe.BUFFER_HIGH_WATER_LINE}addDateRangesToTextTrack_(e){th(this.inbandTextTracks_,"com.apple.streaming",this.tech_),Cw({inbandTextTracks:this.inbandTextTracks_,dateRanges:e})}addMetadataToTextTrack(e,t,r){const n=this.sourceUpdater_.videoBuffer?this.sourceUpdater_.videoTimestampOffset():this.sourceUpdater_.audioTimestampOffset();th(this.inbandTextTracks_,e,this.tech_),Ew({inbandTextTracks:this.inbandTextTracks_,metadataArray:t,timestampOffset:n,videoDuration:r})}pathwayAttribute_(e){return e.attributes["PATHWAY-ID"]||e.attributes.serviceLocation}initContentSteeringController_(){const e=this.main();if(e.contentSteering){for(const t of e.playlists)this.contentSteeringController_.addAvailablePathway(this.pathwayAttribute_(t));if(this.contentSteeringController_.assignTagProperties(e.uri,e.contentSteering),this.contentSteeringController_.queryBeforeStart){this.contentSteeringController_.requestSteeringManifest(!0);return}this.tech_.one("canplay",()=>{this.contentSteeringController_.requestSteeringManifest()})}}resetContentSteeringController_(){this.contentSteeringController_.clearAvailablePathways(),this.contentSteeringController_.dispose(),this.initContentSteeringController_()}attachContentSteeringListeners_(){this.contentSteeringController_.on("content-steering",this.excludeThenChangePathway_.bind(this)),["contentsteeringloadstart","contentsteeringloadcomplete","contentsteeringparsed"].forEach(e=>{this.contentSteeringController_.on(e,t=>{this.trigger(Ve({},t))})}),this.sourceType_==="dash"&&this.mainPlaylistLoader_.on("loadedplaylist",()=>{const e=this.main();(this.contentSteeringController_.didDASHTagChange(e.uri,e.contentSteering)||(()=>{const t=this.contentSteeringController_.getAvailablePathways(),r=[];for(const n of e.playlists){const s=n.attributes.serviceLocation;if(s&&(r.push(s),!t.has(s)))return!0}return!!(!r.length&&t.size)})())&&this.resetContentSteeringController_()})}excludeThenChangePathway_(){const e=this.contentSteeringController_.getPathway();if(!e)return;this.handlePathwayClones_();const t=this.main().playlists,r=new Set;let n=!1;Object.keys(t).forEach(s=>{const a=t[s],l=this.pathwayAttribute_(a),u=l&&e!==l;a.excludeUntil===1/0&&a.lastExcludeReason_==="content-steering"&&!u&&(delete a.excludeUntil,delete a.lastExcludeReason_,n=!0);const p=!a.excludeUntil&&a.excludeUntil!==1/0;!r.has(a.id)&&u&&p&&(r.add(a.id),a.excludeUntil=1/0,a.lastExcludeReason_="content-steering",this.logger_(`excluding ${a.id} for ${a.lastExcludeReason_}`))}),this.contentSteeringController_.manifestType_==="DASH"&&Object.keys(this.mediaTypes_).forEach(s=>{const a=this.mediaTypes_[s];if(a.activePlaylistLoader){const l=a.activePlaylistLoader.media_;l&&l.attributes.serviceLocation!==e&&(n=!0)}}),n&&this.changeSegmentPathway_()}handlePathwayClones_(){const e=this.main().playlists,t=this.contentSteeringController_.currentPathwayClones,r=this.contentSteeringController_.nextPathwayClones;if(t&&t.size||r&&r.size){for(const[n,s]of t.entries())r.get(n)||(this.mainPlaylistLoader_.updateOrDeleteClone(s),this.contentSteeringController_.excludePathway(n));for(const[n,s]of r.entries()){const a=t.get(n);if(!a){e.filter(l=>l.attributes["PATHWAY-ID"]===s["BASE-ID"]).forEach(l=>{this.mainPlaylistLoader_.addClonePathway(s,l)}),this.contentSteeringController_.addAvailablePathway(n);continue}this.equalPathwayClones_(a,s)||(this.mainPlaylistLoader_.updateOrDeleteClone(s,!0),this.contentSteeringController_.addAvailablePathway(n))}this.contentSteeringController_.currentPathwayClones=new Map(JSON.parse(JSON.stringify([...r])))}}equalPathwayClones_(e,t){if(e["BASE-ID"]!==t["BASE-ID"]||e.ID!==t.ID||e["URI-REPLACEMENT"].HOST!==t["URI-REPLACEMENT"].HOST)return!1;const r=e["URI-REPLACEMENT"].PARAMS,n=t["URI-REPLACEMENT"].PARAMS;for(const s in r)if(r[s]!==n[s])return!1;for(const s in n)if(r[s]!==n[s])return!1;return!0}changeSegmentPathway_(){const e=this.selectPlaylist();this.pauseLoading(),this.contentSteeringController_.manifestType_==="DASH"&&this.switchMediaForDASHContentSteering_(),this.switchMedia_(e,"content-steering")}excludeNonUsablePlaylistsByKeyId_(){if(!this.mainPlaylistLoader_||!this.mainPlaylistLoader_.main)return;let e=0;const t="non-usable";this.mainPlaylistLoader_.main.playlists.forEach(r=>{const n=this.mainPlaylistLoader_.getKeyIdSet(r);!n||!n.size||n.forEach(s=>{const a="usable",l=this.keyStatusMap_.has(s)&&this.keyStatusMap_.get(s)===a,u=r.lastExcludeReason_===t&&r.excludeUntil===1/0;l?l&&u&&(delete r.excludeUntil,delete r.lastExcludeReason_,this.logger_(`enabling playlist ${r.id} because key ID ${s} is ${a}`)):(r.excludeUntil!==1/0&&r.lastExcludeReason_!==t&&(r.excludeUntil=1/0,r.lastExcludeReason_=t,this.logger_(`excluding playlist ${r.id} because the key ID ${s} doesn't exist in the keyStatusMap or is not ${a}`)),e++)})}),e>=this.mainPlaylistLoader_.main.playlists.length&&this.mainPlaylistLoader_.main.playlists.forEach(r=>{const n=r&&r.attributes&&r.attributes.RESOLUTION&&r.attributes.RESOLUTION.height<720,s=r.excludeUntil===1/0&&r.lastExcludeReason_===t;n&&s&&(delete r.excludeUntil,B.log.warn(`enabling non-HD playlist ${r.id} because all playlists were excluded due to ${t} key IDs`))})}addKeyStatus_(e,t){const r=(typeof e=="string"?e:Vw(e)).slice(0,32).toLowerCase();this.logger_(`KeyStatus '${t}' with key ID ${r} added to the keyStatusMap`),this.keyStatusMap_.set(r,t)}updatePlaylistByKeyStatus(e,t){this.addKeyStatus_(e,t),this.waitingForFastQualityPlaylistReceived_||this.excludeNonUsableThenChangePlaylist_(),this.mainPlaylistLoader_.off("loadedplaylist",this.excludeNonUsableThenChangePlaylist_.bind(this)),this.mainPlaylistLoader_.on("loadedplaylist",this.excludeNonUsableThenChangePlaylist_.bind(this))}excludeNonUsableThenChangePlaylist_(){this.excludeNonUsablePlaylistsByKeyId_(),this.fastQualityChange_()}}const y2=(i,e,t)=>r=>{const n=i.main.playlists[e],s=Su(n),a=Ga(n);if(typeof r>"u")return a;r?delete n.disabled:n.disabled=!0;const l={renditionInfo:{id:e,bandwidth:n.attributes.BANDWIDTH,resolution:n.attributes.RESOLUTION,codecs:n.attributes.CODECS},cause:"fast-quality"};return r!==a&&!s&&(r?(t(n),i.trigger({type:"renditionenabled",metadata:l})):i.trigger({type:"renditiondisabled",metadata:l})),r};class _2{constructor(e,t,r){const{playlistController_:n}=e,s=n.fastQualityChange_.bind(n);if(t.attributes){const a=t.attributes.RESOLUTION;this.width=a&&a.width,this.height=a&&a.height,this.bandwidth=t.attributes.BANDWIDTH,this.frameRate=t.attributes["FRAME-RATE"]}this.codecs=Un(n.main(),t),this.playlist=t,this.id=r,this.enabled=y2(e.playlists,t.id,s)}}const b2=function(i){i.representations=()=>{const e=i.playlistController_.main(),t=ts(e)?i.playlistController_.getAudioTrackPlaylists_():e.playlists;return t?t.filter(r=>!Su(r)).map((r,n)=>new _2(i,r,r.id)):[]}},hh=["seeking","seeked","pause","playing","error"];class v2 extends B.EventTarget{constructor(e){super(),this.playlistController_=e.playlistController,this.tech_=e.tech,this.seekable=e.seekable,this.allowSeeksWithinUnsafeLiveWindow=e.allowSeeksWithinUnsafeLiveWindow,this.liveRangeSafeTimeDelta=e.liveRangeSafeTimeDelta,this.media=e.media,this.playedRanges_=[],this.consecutiveUpdates=0,this.lastRecordedTime=null,this.checkCurrentTimeTimeout_=null,this.logger_=Nt("PlaybackWatcher"),this.logger_("initialize");const t=()=>this.monitorCurrentTime_(),r=()=>this.monitorCurrentTime_(),n=()=>this.techWaiting_(),s=()=>this.resetTimeUpdate_(),a=this.playlistController_,l=["main","subtitle","audio"],u={};l.forEach(g=>{u[g]={reset:()=>this.resetSegmentDownloads_(g),updateend:()=>this.checkSegmentDownloads_(g)},a[`${g}SegmentLoader_`].on("appendsdone",u[g].updateend),a[`${g}SegmentLoader_`].on("playlistupdate",u[g].reset),this.tech_.on(["seeked","seeking"],u[g].reset)});const p=g=>{["main","audio"].forEach(b=>{a[`${b}SegmentLoader_`][g]("appended",this.seekingAppendCheck_)})};this.seekingAppendCheck_=()=>{this.fixesBadSeeks_()&&(this.consecutiveUpdates=0,this.lastRecordedTime=this.tech_.currentTime(),p("off"))},this.clearSeekingAppendCheck_=()=>p("off"),this.watchForBadSeeking_=()=>{this.clearSeekingAppendCheck_(),p("on")},this.tech_.on("seeked",this.clearSeekingAppendCheck_),this.tech_.on("seeking",this.watchForBadSeeking_),this.tech_.on("waiting",n),this.tech_.on(hh,s),this.tech_.on("canplay",r),this.tech_.one("play",t),this.dispose=()=>{this.clearSeekingAppendCheck_(),this.logger_("dispose"),this.tech_.off("waiting",n),this.tech_.off(hh,s),this.tech_.off("canplay",r),this.tech_.off("play",t),this.tech_.off("seeking",this.watchForBadSeeking_),this.tech_.off("seeked",this.clearSeekingAppendCheck_),l.forEach(g=>{a[`${g}SegmentLoader_`].off("appendsdone",u[g].updateend),a[`${g}SegmentLoader_`].off("playlistupdate",u[g].reset),this.tech_.off(["seeked","seeking"],u[g].reset)}),this.checkCurrentTimeTimeout_&&x.clearTimeout(this.checkCurrentTimeTimeout_),this.resetTimeUpdate_()}}monitorCurrentTime_(){this.checkCurrentTime_(),this.checkCurrentTimeTimeout_&&x.clearTimeout(this.checkCurrentTimeTimeout_),this.checkCurrentTimeTimeout_=x.setTimeout(this.monitorCurrentTime_.bind(this),250)}resetSegmentDownloads_(e){const t=this.playlistController_[`${e}SegmentLoader_`];this[`${e}StalledDownloads_`]>0&&this.logger_(`resetting possible stalled download count for ${e} loader`),this[`${e}StalledDownloads_`]=0,this[`${e}Buffered_`]=t.buffered_()}checkSegmentDownloads_(e){const t=this.playlistController_,r=t[`${e}SegmentLoader_`],n=r.buffered_(),s=nE(this[`${e}Buffered_`],n);if(this[`${e}Buffered_`]=n,s){const a={bufferedRanges:n};t.trigger({type:"bufferedrangeschanged",metadata:a}),this.resetSegmentDownloads_(e);return}this[`${e}StalledDownloads_`]++,this.logger_(`found #${this[`${e}StalledDownloads_`]} ${e} appends that did not increase buffer (possible stalled download)`,{playlistId:r.playlist_&&r.playlist_.id,buffered:Qi(n)}),!(this[`${e}StalledDownloads_`]<10)&&(this.logger_(`${e} loader stalled download exclusion`),this.resetSegmentDownloads_(e),this.tech_.trigger({type:"usage",name:`vhs-${e}-download-exclusion`}),e!=="subtitle"&&t.excludePlaylist({error:{message:`Excessive ${e} segment downloading detected.`},playlistExclusionDuration:1/0}))}checkCurrentTime_(){if(this.tech_.paused()||this.tech_.seeking())return;const e=this.tech_.currentTime(),t=this.tech_.buffered();if(this.lastRecordedTime===e&&(!t.length||e+ei>=t.end(t.length-1)))return this.techWaiting_();if(this.consecutiveUpdates>=5&&e===this.lastRecordedTime)this.consecutiveUpdates++,this.waiting_();else if(e===this.lastRecordedTime)this.consecutiveUpdates++;else{this.playedRanges_.push(it([this.lastRecordedTime,e]));const r={playedRanges:this.playedRanges_};this.playlistController_.trigger({type:"playedrangeschanged",metadata:r}),this.consecutiveUpdates=0,this.lastRecordedTime=e}}resetTimeUpdate_(){this.consecutiveUpdates=0}fixesBadSeeks_(){if(!this.tech_.seeking())return!1;const e=this.seekable(),t=this.tech_.currentTime(),r=this.afterSeekableWindow_(e,t,this.media(),this.allowSeeksWithinUnsafeLiveWindow);let n;if(r&&(n=e.end(e.length-1)),this.beforeSeekableWindow_(e,t)){const w=e.start(0);n=w+(w===e.end(0)?0:ei)}if(typeof n<"u")return this.logger_(`Trying to seek outside of seekable at time ${t} with seekable range ${am(e)}. Seeking to ${n}.`),this.tech_.setCurrentTime(n),!0;const s=this.playlistController_.sourceUpdater_,a=this.tech_.buffered(),l=s.audioBuffer?s.audioBuffered():null,u=s.videoBuffer?s.videoBuffered():null,p=this.media(),g=p.partTargetDuration?p.partTargetDuration:(p.targetDuration-Zt)*2,b=[l,u];for(let w=0;w<b.length;w++)if(b[w]&&vu(b[w],t)<g)return!1;const S=Ms(a,t);return S.length===0?!1:(n=S.start(0)+ei,this.logger_(`Buffered region starts (${S.start(0)}) just beyond seek point (${t}). Seeking to ${n}.`),this.tech_.setCurrentTime(n),!0)}waiting_(){if(this.techWaiting_())return;const e=this.tech_.currentTime(),t=this.tech_.buffered(),r=Sr(t,e);if(r.length&&e+3<=r.end(0)){this.resetTimeUpdate_(),this.tech_.setCurrentTime(e),this.logger_(`Stopped at ${e} while inside a buffered region [${r.start(0)} -> ${r.end(0)}]. Attempting to resume playback by seeking to the current time.`),this.tech_.trigger({type:"usage",name:"vhs-unknown-waiting"});return}}techWaiting_(){const e=this.seekable(),t=this.tech_.currentTime();if(this.tech_.seeking())return!0;if(this.beforeSeekableWindow_(e,t)){const a=e.end(e.length-1);return this.logger_(`Fell out of live window at time ${t}. Seeking to live point (seekable end) ${a}`),this.resetTimeUpdate_(),this.tech_.setCurrentTime(a),this.tech_.trigger({type:"usage",name:"vhs-live-resync"}),!0}const r=this.tech_.vhs.playlistController_.sourceUpdater_,n=this.tech_.buffered();if(this.videoUnderflow_({audioBuffered:r.audioBuffered(),videoBuffered:r.videoBuffered(),currentTime:t}))return this.resetTimeUpdate_(),this.tech_.setCurrentTime(t),this.tech_.trigger({type:"usage",name:"vhs-video-underflow"}),!0;const s=Ms(n,t);return s.length>0?(this.logger_(`Stopped at ${t} and seeking to ${s.start(0)}`),this.resetTimeUpdate_(),this.skipTheGap_(t),!0):!1}afterSeekableWindow_(e,t,r,n=!1){if(!e.length)return!1;let s=e.end(e.length-1)+ei;const a=!r.endList,l=typeof r.partTargetDuration=="number";return a&&(l||n)&&(s=e.end(e.length-1)+r.targetDuration*3),t>s}beforeSeekableWindow_(e,t){return!!(e.length&&e.start(0)>0&&t<e.start(0)-this.liveRangeSafeTimeDelta)}videoUnderflow_({videoBuffered:e,audioBuffered:t,currentTime:r}){if(!e)return;let n;if(e.length&&t.length){const s=Sr(e,r-3),a=Sr(e,r),l=Sr(t,r);l.length&&!a.length&&s.length&&(n={start:s.end(0),end:l.end(0)})}else Ms(e,r).length||(n=this.gapFromVideoUnderflow_(e,r));return n?(this.logger_(`Encountered a gap in video from ${n.start} to ${n.end}. Seeking to current time ${r}`),!0):!1}skipTheGap_(e){const t=this.tech_.buffered(),r=this.tech_.currentTime(),n=Ms(t,r);if(this.resetTimeUpdate_(),n.length===0||r!==e)return;this.logger_("skipTheGap_:","currentTime:",r,"scheduled currentTime:",e,"nextRange start:",n.start(0)),this.tech_.setCurrentTime(n.start(0)+Zt);const s={gapInfo:{from:r,to:n.start(0)}};this.playlistController_.trigger({type:"gapjumped",metadata:s}),this.tech_.trigger({type:"usage",name:"vhs-gap-skip"})}gapFromVideoUnderflow_(e,t){const r=tE(e);for(let n=0;n<r.length;n++){const s=r.start(n),a=r.end(n);if(t-s<4&&t-s>2)return{start:s,end:a}}return null}}const T2={errorInterval:30,getSource(i){const e=this.tech({IWillNotUseThisInPlugins:!0}).currentSource_||this.currentSource();return i(e)}},Ym=function(i,e){let t=0,r=0;const n=fe(T2,e);i.ready(()=>{i.trigger({type:"usage",name:"vhs-error-reload-initialized"})});const s=function(){r&&i.currentTime(r)},a=function(g){g!=null&&(r=i.duration()!==1/0&&i.currentTime()||0,i.one("loadedmetadata",s),i.src(g),i.trigger({type:"usage",name:"vhs-error-reload"}),i.play())},l=function(){if(Date.now()-t<n.errorInterval*1e3){i.trigger({type:"usage",name:"vhs-error-reload-canceled"});return}if(!n.getSource||typeof n.getSource!="function"){B.log.error("ERROR: reloadSourceOnError - The option getSource must be a function!");return}return t=Date.now(),n.getSource.call(i,a)},u=function(){i.off("loadedmetadata",s),i.off("error",l),i.off("dispose",u)},p=function(g){u(),Ym(i,g)};i.on("error",l),i.on("dispose",u),i.reloadSourceOnError=p},S2=function(i){Ym(this,i)};var Qm="3.16.2",E2="7.1.0",w2="1.3.1",k2="7.2.0",C2="4.0.2";const Ne={PlaylistLoader:Er,Playlist:_t,utils:AE,STANDARD_PLAYLIST_SELECTOR:eh,INITIAL_PLAYLIST_SELECTOR:_w,lastBandwidthSelector:eh,movingAverageBandwidthSelector:fw,comparePlaylistBandwidth:ku,comparePlaylistResolution:mw,xhr:Em()};Object.keys(Xe).forEach(i=>{Object.defineProperty(Ne,i,{get(){return B.log.warn(`using Vhs.${i} is UNSAFE be sure you know what you are doing`),Xe[i]},set(e){if(B.log.warn(`using Vhs.${i} is UNSAFE be sure you know what you are doing`),typeof e!="number"||e<0){B.log.warn(`value of Vhs.${i} must be greater than or equal to 0`);return}Xe[i]=e}})});const Jm="videojs-vhs",Zm=function(i,e){const t=e.media();let r=-1;for(let n=0;n<i.length;n++)if(i[n].id===t.id){r=n;break}i.selectedIndex_=r,i.trigger({selectedIndex:r,type:"change"})},I2=function(i,e){e.representations().forEach(t=>{i.addQualityLevel(t)}),Zm(i,e.playlists)};Ne.canPlaySource=function(){return B.log.warn("VHS is no longer a tech. Please remove it from your player's techOrder.")};const A2=(i,e,t)=>{if(!i)return i;let r={};e&&e.attributes&&e.attributes.CODECS&&(r=fa(Kt(e.attributes.CODECS))),t&&t.attributes&&t.attributes.CODECS&&(r.audio=t.attributes.CODECS);const n=Or(r.video),s=Or(r.audio),a={};for(const l in i)a[l]={},s&&(a[l].audioContentType=s),n&&(a[l].videoContentType=n),e.contentProtection&&e.contentProtection[l]&&e.contentProtection[l].pssh&&(a[l].pssh=e.contentProtection[l].pssh),typeof i[l]=="string"&&(a[l].url=i[l]);return fe(i,a)},x2=(i,e)=>i.reduce((t,r)=>{if(!r.contentProtection)return t;const n=e.reduce((s,a)=>{const l=r.contentProtection[a];return l&&l.pssh&&(s[a]={pssh:l.pssh}),s},{});return Object.keys(n).length&&t.push(n),t},[]),L2=({player:i,sourceKeySystems:e,audioMedia:t,mainPlaylists:r})=>{if(!i.eme.initializeMediaKeys)return Promise.resolve();const n=t?r.concat([t]):r,s=x2(n,Object.keys(e)),a=[],l=[];return s.forEach(u=>{l.push(new Promise((p,g)=>{i.tech_.one("keysessioncreated",p)})),a.push(new Promise((p,g)=>{i.eme.initializeMediaKeys({keySystems:u},b=>{if(b){g(b);return}p()})}))}),Promise.race([Promise.all(a),Promise.race(l)])},D2=({player:i,sourceKeySystems:e,media:t,audioMedia:r})=>{const n=A2(e,t,r);return n?(i.currentSource().keySystems=n,n&&!i.eme?(B.log.warn("DRM encrypted source cannot be decrypted without a DRM plugin"),!1):!0):!1},ef=()=>{if(!x.localStorage)return null;const i=x.localStorage.getItem(Jm);if(!i)return null;try{return JSON.parse(i)}catch{return null}},P2=i=>{if(!x.localStorage)return!1;let e=ef();e=e?fe(e,i):i;try{x.localStorage.setItem(Jm,JSON.stringify(e))}catch{return!1}return e},R2=i=>i.toLowerCase().indexOf("data:application/vnd.videojs.vhs+json,")===0?JSON.parse(i.substring(i.indexOf(",")+1)):i,tf=(i,e)=>{i._requestCallbackSet||(i._requestCallbackSet=new Set),i._requestCallbackSet.add(e)},rf=(i,e)=>{i._responseCallbackSet||(i._responseCallbackSet=new Set),i._responseCallbackSet.add(e)},nf=(i,e)=>{i._requestCallbackSet&&(i._requestCallbackSet.delete(e),i._requestCallbackSet.size||delete i._requestCallbackSet)},sf=(i,e)=>{i._responseCallbackSet&&(i._responseCallbackSet.delete(e),i._responseCallbackSet.size||delete i._responseCallbackSet)};Ne.supportsNativeHls=function(){if(!G||!G.createElement)return!1;const i=G.createElement("video");return B.getTech("Html5").isSupported()?["application/vnd.apple.mpegurl","audio/mpegurl","audio/x-mpegurl","application/x-mpegurl","video/x-mpegurl","video/mpegurl","application/mpegurl"].some(function(e){return/maybe|probably/i.test(i.canPlayType(e))}):!1}();Ne.supportsNativeDash=function(){return!G||!G.createElement||!B.getTech("Html5").isSupported()?!1:/maybe|probably/i.test(G.createElement("video").canPlayType("application/dash+xml"))}();Ne.supportsTypeNatively=i=>i==="hls"?Ne.supportsNativeHls:i==="dash"?Ne.supportsNativeDash:!1;Ne.isSupported=function(){return B.log.warn("VHS is no longer a tech. Please remove it from your player's techOrder.")};Ne.xhr.onRequest=function(i){tf(Ne.xhr,i)};Ne.xhr.onResponse=function(i){rf(Ne.xhr,i)};Ne.xhr.offRequest=function(i){nf(Ne.xhr,i)};Ne.xhr.offResponse=function(i){sf(Ne.xhr,i)};const N2=B.getComponent("Component");class af extends N2{constructor(e,t,r){if(super(t,r.vhs),typeof r.initialBandwidth=="number"&&(this.options_.bandwidth=r.initialBandwidth),this.logger_=Nt("VhsHandler"),t.options_&&t.options_.playerId){const n=B.getPlayer(t.options_.playerId);this.player_=n}if(this.tech_=t,this.source_=e,this.stats={},this.ignoreNextSeekingEvent_=!1,this.setOptions_(),this.options_.overrideNative&&t.overrideNativeAudioTracks&&t.overrideNativeVideoTracks)t.overrideNativeAudioTracks(!0),t.overrideNativeVideoTracks(!0);else if(this.options_.overrideNative&&(t.featuresNativeVideoTracks||t.featuresNativeAudioTracks))throw new Error("Overriding native VHS requires emulated tracks. See https://git.io/vMpjB");this.on(G,["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],n=>{const s=G.fullscreenElement||G.webkitFullscreenElement||G.mozFullScreenElement||G.msFullscreenElement;s&&s.contains(this.tech_.el())?this.playlistController_.fastQualityChange_():this.playlistController_.checkABR_()}),this.on(this.tech_,"seeking",function(){if(this.ignoreNextSeekingEvent_){this.ignoreNextSeekingEvent_=!1;return}this.setCurrentTime(this.tech_.currentTime())}),this.on(this.tech_,"error",function(){this.tech_.error()&&this.playlistController_&&this.playlistController_.pauseLoading()}),this.on(this.tech_,"play",this.play)}setOptions_(e={}){if(this.options_=fe(this.options_,e),this.options_.withCredentials=this.options_.withCredentials||!1,this.options_.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions!==!1,this.options_.useDevicePixelRatio=this.options_.useDevicePixelRatio||!1,this.options_.useBandwidthFromLocalStorage=typeof this.source_.useBandwidthFromLocalStorage<"u"?this.source_.useBandwidthFromLocalStorage:this.options_.useBandwidthFromLocalStorage||!1,this.options_.useForcedSubtitles=this.options_.useForcedSubtitles||!1,this.options_.useNetworkInformationApi=this.options_.useNetworkInformationApi||!1,this.options_.useDtsForTimestampOffset=this.options_.useDtsForTimestampOffset||!1,this.options_.customTagParsers=this.options_.customTagParsers||[],this.options_.customTagMappers=this.options_.customTagMappers||[],this.options_.cacheEncryptionKeys=this.options_.cacheEncryptionKeys||!1,this.options_.llhls=this.options_.llhls!==!1,this.options_.bufferBasedABR=this.options_.bufferBasedABR||!1,typeof this.options_.playlistExclusionDuration!="number"&&(this.options_.playlistExclusionDuration=60),typeof this.options_.bandwidth!="number"&&this.options_.useBandwidthFromLocalStorage){const r=ef();r&&r.bandwidth&&(this.options_.bandwidth=r.bandwidth,this.tech_.trigger({type:"usage",name:"vhs-bandwidth-from-local-storage"})),r&&r.throughput&&(this.options_.throughput=r.throughput,this.tech_.trigger({type:"usage",name:"vhs-throughput-from-local-storage"}))}typeof this.options_.bandwidth!="number"&&(this.options_.bandwidth=Xe.INITIAL_BANDWIDTH),this.options_.enableLowInitialPlaylist=this.options_.enableLowInitialPlaylist&&this.options_.bandwidth===Xe.INITIAL_BANDWIDTH,["withCredentials","useDevicePixelRatio","customPixelRatio","limitRenditionByPlayerDimensions","bandwidth","customTagParsers","customTagMappers","cacheEncryptionKeys","playlistSelector","initialPlaylistSelector","bufferBasedABR","liveRangeSafeTimeDelta","llhls","useForcedSubtitles","useNetworkInformationApi","useDtsForTimestampOffset","exactManifestTimings","leastPixelDiffSelector"].forEach(r=>{typeof this.source_[r]<"u"&&(this.options_[r]=this.source_[r])}),this.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions,this.useDevicePixelRatio=this.options_.useDevicePixelRatio;const t=this.options_.customPixelRatio;typeof t=="number"&&t>=0&&(this.customPixelRatio=t)}setOptions(e={}){this.setOptions_(e)}src(e,t){if(!e)return;this.setOptions_(),this.options_.src=R2(this.source_.src),this.options_.tech=this.tech_,this.options_.externVhs=Ne,this.options_.sourceType=kp(t),this.options_.seekTo=s=>{this.tech_.setCurrentTime(s)},this.options_.player_=this.player_,this.playlistController_=new f2(this.options_);const r=fe({liveRangeSafeTimeDelta:ei},this.options_,{seekable:()=>this.seekable(),media:()=>this.playlistController_.media(),playlistController:this.playlistController_});this.playbackWatcher_=new v2(r),this.attachStreamingEventListeners_(),this.playlistController_.on("error",()=>{const s=B.players[this.tech_.options_.playerId];let a=this.playlistController_.error;typeof a=="object"&&!a.code?a.code=3:typeof a=="string"&&(a={message:a,code:3}),s.error(a)});const n=this.options_.bufferBasedABR?Ne.movingAverageBandwidthSelector(.55):Ne.STANDARD_PLAYLIST_SELECTOR;this.playlistController_.selectPlaylist=this.selectPlaylist?this.selectPlaylist.bind(this):n.bind(this),this.playlistController_.selectInitialPlaylist=Ne.INITIAL_PLAYLIST_SELECTOR.bind(this),this.playlists=this.playlistController_.mainPlaylistLoader_,this.mediaSource=this.playlistController_.mediaSource,Object.defineProperties(this,{selectPlaylist:{get(){return this.playlistController_.selectPlaylist},set(s){this.playlistController_.selectPlaylist=s.bind(this)}},throughput:{get(){return this.playlistController_.mainSegmentLoader_.throughput.rate},set(s){this.playlistController_.mainSegmentLoader_.throughput.rate=s,this.playlistController_.mainSegmentLoader_.throughput.count=1}},bandwidth:{get(){let s=this.playlistController_.mainSegmentLoader_.bandwidth;const a=x.navigator.connection||x.navigator.mozConnection||x.navigator.webkitConnection,l=1e7;if(this.options_.useNetworkInformationApi&&a){const u=a.downlink*1e3*1e3;u>=l&&s>=l?s=Math.max(s,u):s=u}return s},set(s){this.playlistController_.mainSegmentLoader_.bandwidth=s,this.playlistController_.mainSegmentLoader_.throughput={rate:0,count:0}}},systemBandwidth:{get(){const s=1/(this.bandwidth||1);let a;return this.throughput>0?a=1/this.throughput:a=0,Math.floor(1/(s+a))},set(){B.log.error('The "systemBandwidth" property is read-only')}}}),this.options_.bandwidth&&(this.bandwidth=this.options_.bandwidth),this.options_.throughput&&(this.throughput=this.options_.throughput),Object.defineProperties(this.stats,{bandwidth:{get:()=>this.bandwidth||0,enumerable:!0},mediaRequests:{get:()=>this.playlistController_.mediaRequests_()||0,enumerable:!0},mediaRequestsAborted:{get:()=>this.playlistController_.mediaRequestsAborted_()||0,enumerable:!0},mediaRequestsTimedout:{get:()=>this.playlistController_.mediaRequestsTimedout_()||0,enumerable:!0},mediaRequestsErrored:{get:()=>this.playlistController_.mediaRequestsErrored_()||0,enumerable:!0},mediaTransferDuration:{get:()=>this.playlistController_.mediaTransferDuration_()||0,enumerable:!0},mediaBytesTransferred:{get:()=>this.playlistController_.mediaBytesTransferred_()||0,enumerable:!0},mediaSecondsLoaded:{get:()=>this.playlistController_.mediaSecondsLoaded_()||0,enumerable:!0},mediaAppends:{get:()=>this.playlistController_.mediaAppends_()||0,enumerable:!0},mainAppendsToLoadedData:{get:()=>this.playlistController_.mainAppendsToLoadedData_()||0,enumerable:!0},audioAppendsToLoadedData:{get:()=>this.playlistController_.audioAppendsToLoadedData_()||0,enumerable:!0},appendsToLoadedData:{get:()=>this.playlistController_.appendsToLoadedData_()||0,enumerable:!0},timeToLoadedData:{get:()=>this.playlistController_.timeToLoadedData_()||0,enumerable:!0},buffered:{get:()=>Qi(this.tech_.buffered()),enumerable:!0},currentTime:{get:()=>this.tech_.currentTime(),enumerable:!0},currentSource:{get:()=>this.tech_.currentSource_,enumerable:!0},currentTech:{get:()=>this.tech_.name_,enumerable:!0},duration:{get:()=>this.tech_.duration(),enumerable:!0},main:{get:()=>this.playlists.main,enumerable:!0},playerDimensions:{get:()=>this.tech_.currentDimensions(),enumerable:!0},seekable:{get:()=>Qi(this.tech_.seekable()),enumerable:!0},timestamp:{get:()=>Date.now(),enumerable:!0},videoPlaybackQuality:{get:()=>this.tech_.getVideoPlaybackQuality(),enumerable:!0}}),this.tech_.one("canplay",this.playlistController_.setupFirstPlay.bind(this.playlistController_)),this.tech_.on("bandwidthupdate",()=>{this.options_.useBandwidthFromLocalStorage&&P2({bandwidth:this.bandwidth,throughput:Math.round(this.throughput)})}),this.playlistController_.on("selectedinitialmedia",()=>{b2(this)}),this.playlistController_.sourceUpdater_.on("createdsourcebuffers",()=>{this.setupEme_()}),this.on(this.playlistController_,"progress",function(){this.tech_.trigger("progress")}),this.on(this.playlistController_,"firstplay",function(){this.ignoreNextSeekingEvent_=!0}),this.setupQualityLevels_(),this.tech_.el()&&(this.mediaSourceUrl_=x.URL.createObjectURL(this.playlistController_.mediaSource),(B.browser.IS_ANY_SAFARI||B.browser.IS_IOS)&&this.options_.overrideNative&&this.options_.sourceType==="hls"&&typeof this.tech_.addSourceElement=="function"?(this.tech_.addSourceElement(this.mediaSourceUrl_),this.tech_.addSourceElement(this.source_.src)):this.tech_.src(this.mediaSourceUrl_))}createKeySessions_(){const e=this.playlistController_.mediaTypes_.AUDIO.activePlaylistLoader;this.logger_("waiting for EME key session creation"),L2({player:this.player_,sourceKeySystems:this.source_.keySystems,audioMedia:e&&e.media(),mainPlaylists:this.playlists.main.playlists}).then(()=>{this.logger_("created EME key session"),this.playlistController_.sourceUpdater_.initializedEme()}).catch(t=>{this.logger_("error while creating EME key session",t),this.player_.error({message:"Failed to initialize media keys for EME",code:3})})}handleWaitingForKey_(){this.logger_("waitingforkey fired, attempting to create any new key sessions"),this.createKeySessions_()}setupEme_(){const e=this.playlistController_.mediaTypes_.AUDIO.activePlaylistLoader,t=D2({player:this.player_,sourceKeySystems:this.source_.keySystems,media:this.playlists.media(),audioMedia:e&&e.media()});if(this.player_.tech_.on("keystatuschange",r=>{this.playlistController_.updatePlaylistByKeyStatus(r.keyId,r.status)}),this.handleWaitingForKey_=this.handleWaitingForKey_.bind(this),this.player_.tech_.on("waitingforkey",this.handleWaitingForKey_),!t){this.playlistController_.sourceUpdater_.initializedEme();return}this.createKeySessions_()}setupQualityLevels_(){const e=B.players[this.tech_.options_.playerId];!e||!e.qualityLevels||this.qualityLevels_||(this.qualityLevels_=e.qualityLevels(),this.playlistController_.on("selectedinitialmedia",()=>{I2(this.qualityLevels_,this)}),this.playlists.on("mediachange",()=>{Zm(this.qualityLevels_,this.playlists)}))}static version(){return{"@videojs/http-streaming":Qm,"mux.js":E2,"mpd-parser":w2,"m3u8-parser":k2,"aes-decrypter":C2}}version(){return this.constructor.version()}canChangeType(){return Wm.canChangeType()}play(){this.playlistController_.play()}setCurrentTime(e){this.playlistController_.setCurrentTime(e)}duration(){return this.playlistController_.duration()}seekable(){return this.playlistController_.seekable()}dispose(){this.playbackWatcher_&&this.playbackWatcher_.dispose(),this.playlistController_&&this.playlistController_.dispose(),this.qualityLevels_&&this.qualityLevels_.dispose(),this.tech_&&this.tech_.vhs&&delete this.tech_.vhs,this.mediaSourceUrl_&&x.URL.revokeObjectURL&&(x.URL.revokeObjectURL(this.mediaSourceUrl_),this.mediaSourceUrl_=null),this.tech_&&this.tech_.off("waitingforkey",this.handleWaitingForKey_),super.dispose()}convertToProgramTime(e,t){return OE({playlist:this.playlistController_.media(),time:e,callback:t})}seekToProgramTime(e,t,r=!0,n=2){return Am({programTime:e,playlist:this.playlistController_.media(),retryCount:n,pauseAfterSeek:r,seekTo:this.options_.seekTo,tech:this.options_.tech,callback:t})}setupXhrHooks_(){this.xhr.onRequest=e=>{tf(this.xhr,e)},this.xhr.onResponse=e=>{rf(this.xhr,e)},this.xhr.offRequest=e=>{nf(this.xhr,e)},this.xhr.offResponse=e=>{sf(this.xhr,e)},this.player_.trigger("xhr-hooks-ready")}attachStreamingEventListeners_(){const e=["seekablerangeschanged","bufferedrangeschanged","contentsteeringloadstart","contentsteeringloadcomplete","contentsteeringparsed"],t=["gapjumped","playedrangeschanged"];e.forEach(r=>{this.playlistController_.on(r,n=>{this.player_.trigger(Ve({},n))})}),t.forEach(r=>{this.playbackWatcher_.on(r,n=>{this.player_.trigger(Ve({},n))})})}}const ba={name:"videojs-http-streaming",VERSION:Qm,canHandleSource(i,e={}){const t=fe(B.options,e);return!t.vhs.experimentalUseMMS&&!Dn("avc1.4d400d,mp4a.40.2",!1)?!1:ba.canPlayType(i.type,t)},handleSource(i,e,t={}){const r=fe(B.options,t);return e.vhs=new af(i,e,r),e.vhs.xhr=Em(),e.vhs.setupXhrHooks_(),e.vhs.src(i.src,i.type),e.vhs},canPlayType(i,e){const t=kp(i);if(!t)return"";const r=ba.getOverrideNative(e);return!Ne.supportsTypeNatively(t)||r?"maybe":""},getOverrideNative(i={}){const{vhs:e={}}=i,t=!(B.browser.IS_ANY_SAFARI||B.browser.IS_IOS),{overrideNative:r=t}=e;return r}},O2=()=>Dn("avc1.4d400d,mp4a.40.2",!0);O2()&&B.getTech("Html5").registerSourceHandler(ba,0);B.VhsHandler=af;B.VhsSourceHandler=ba;B.Vhs=Ne;B.use||B.registerComponent("Vhs",Ne);B.options.vhs=B.options.vhs||{};(!B.getPlugin||!B.getPlugin("reloadSourceOnError"))&&B.registerPlugin("reloadSourceOnError",S2);const U2=i=>{const e=Me.useRef();return Me.useEffect(()=>{if(!e.current&&i.current){const t=document.createElement("video-js");t.classList.add("vjs-big-play-centered"),i.current.appendChild(t),e.current=B(t,{controls:!1,playsinline:!0})}return()=>{e.current&&(e.current.dispose(),e.current=void 0)}},[]),e},of={time:0,adCount:0,adPosition:0,skipDelay:0,playing:!1,paused:!1,reset:()=>{},whyThisAd:null,hasAdUrl:!1,adAction:i=>{},playMuted:!1,muted:!1,autoplay:!0},De=X.i(of),ph=i=>{if(!i)return 0;const e=i.duration(),t=i.currentTime();return e===void 0||isNaN(e)||t===void 0||isNaN(t)?0:Math.round(e-t)},M2=(i,e)=>{const t=db(i,e),r=U2(i),n=Me.useRef(),s=Me.useCallback(()=>{var p,g;const{adPosition:b,adCount:S}=De.get();if(r.current){if(b<S){const w=b+1,{ads:C,muted:v,autoplay:D}=t.get(),L=C[w-1];if(L){(p=n.current)==null||p.complete(),n.current=new ib(null,L.ad,L.creative),n.current.on("clickthrough",O=>{window.open(O,"_blank")}),De.setKey("adPosition",w),De.setKey("playMuted",v),De.setKey("skipDelay",L.creative.skipDelay||0),De.setKey("time",0),De.setKey("adAction",O=>{n.current&&n.current.click(null,{CLICKPOS:[O.clientX,O.clientY]})}),De.setKey("whyThisAd",L.creative.icons.find(O=>O.program==="GoogleWhyThisAd")||null),De.setKey("hasAdUrl",!!((g=L.creative.videoClickThroughURLTemplate)!=null&&g.url)),r.current.src(L.mediaFileUrl),De.setKey("playing",!0),b===0?(De.setKey("muted",v),De.setKey("autoplay",D),v&&r.current.muted(!0),D?r.current.play():(r.current.pause(),De.setKey("paused",!0))):r.current.play();return}}De.set(of),r.current.pause(),r.current.src(void 0)}},[r,t]),a=Me.useCallback(()=>{if(!r.current)return;const p=r.current.muted();r.current.muted(!p),De.setKey("muted",!p),n.current&&n.current.setMuted(!p)},[r]),l=Me.useCallback(()=>{r.current&&(r.current.paused()?(r.current.play(),n.current&&n.current.setPaused(!1)):(r.current.pause(),n.current&&n.current.setPaused(!0)))},[r]),u=Me.useCallback(()=>{r.current&&(n.current&&n.current.skip(),s())},[s,r]);return Me.useEffect(()=>{r.current&&(r.current.on("play",p=>{De.setKey("playing",!0),De.setKey("paused",!1),De.setKey("time",ph(p.target.player))}),r.current.on("ended",()=>{s()}),r.current.on("muted",p=>{console.log("muted",p),De.setKey("muted",p.target.player.muted())}),r.current.on("pause",()=>{De.setKey("paused",!0)}),r.current.on("click",function(p){p.target.tagName==="VIDEO"&&(De.get().autoplay||l())}),r.current.on("timeupdate",p=>{De.setKey("time",ph(p.target.player)),n.current&&n.current.setProgress(p.target.player.currentTime())}))},[l,s,r]),Me.useEffect(()=>t.subscribe(p=>{p&&(De.setKey("adCount",p.ads.length),De.setKey("adPosition",0),s())}),[t,r,s]),[De,a,l,u]},B2=({promotion:i,onClose:e,promotionId:t,externalAd:r,skipAutoClose:n})=>{var s,a,l,u,p;const g=Me.useRef(null),[b,S,w,C]=M2(g,r==null?void 0:r.url),{time:v,adCount:D,adPosition:L,skipDelay:O,playing:U,paused:F,reset:N,muted:V,playMuted:J,autoplay:Y,whyThisAd:ie,hasAdUrl:he,adAction:le}=X.useStore(b),pe=((s=i.sponsor)==null?void 0:s.logo)&&i.logoMode===ge.PromotionLogoMode.CENTER;return W.jsxs(yh,{className:"PromoOverlay",children:[W.jsxs(_h,{children:[W.jsx(bh,{className:X.cx_default(!pe&&vh),children:W.jsx(Sh,{style:{transform:"scale(1.5)"},children:"Ad"})}),W.jsxs(B0,{children:[W.jsx(x0,{time:v,adCount:D,adPosition:L}),!!O&&U&&W.jsx(X.y$1,{timerClassName:"SkipTimerCount",className:"ClosePromoIcon",close:()=>{C()},duration:O,isPlaying:!F,skipIcon:!0}),n&&W.jsx(X.y$1,{className:"ClosePromoIcon",close:()=>{N(),e==null||e()}})]})]}),W.jsx(Th,{className:X.cx_default(bc,U&&vc,!U&&Tc),children:W.jsxs(M0,{ref:g,children:[ie&&W.jsx(D0,{whyThisAd:ie}),W.jsxs(P0,{style:(ie==null?void 0:ie.xPosition)==="right"?{left:"8px"}:{right:"8px"},children:[J&&W.jsx(N0,{className:X.cx_default(!V&&"muted"),onClick:()=>S()}),F&&!Y&&W.jsx(U0,{onClick:()=>w()})]})]})}),he&&W.jsx(Eh,{className:X.cx_default(bc,U&&vc,!U&&Tc),children:W.jsx(wh,{as:"button",onClick:le,style:{backgroundColor:((l=(a=i.banner)==null?void 0:a.ctaButton)==null?void 0:l.color)||"#009dc4",color:((p=(u=i.banner)==null?void 0:u.ctaButton)==null?void 0:p.textColor)||"#fff"},"data-analytics":"button","data-promo-id":t,"data-promo-type":i.type,target:"_blank",children:"Show more"})})]})},gh=i=>{var e,t,r,n,s,a,l,u,p,g,b,S,w,C,v,D,L,O,U,F,N,V,J,Y,ie,he,le,pe,ee,ce;const{promotion:ne,open:de,advertisementPaused:we,togglePause:ze,controlVideo:dt,skipAutoClose:Ot,promotionId:ht,onClose:Ut,markAsViewed:Vt,externalAd:xe}=i,Fe=ne.type===ge.PromotionType.INGAME_IAB11_LBAR||ne.type===ge.PromotionType.INGAME_IAB11,oi=((e=ne.sponsor)==null?void 0:e.logo)&&ne.logoMode===ge.PromotionLogoMode.CENTER,Fi=!!((r=(t=ne.banner)==null?void 0:t.video)!=null&&r.url),li=ne.autoPlayVideo===ge.AutoPlayVideo.ENABLED;if(Me.useEffect(()=>{ze==null||ze(Fi||li),de==null||de()},[]),Me.useEffect(()=>{ht&&ne.type&&Vt&&Vt()},[ht,ne.type,Vt]),Me.useEffect(()=>()=>{dt==null||dt({muted:!1})},[dt]),xe)return W.jsx(B2,{...i,externalAd:xe});let Ht=(n=ne.banner)==null?void 0:n.url;Ht&&Ht.indexOf("http")!==0&&(Ht=`https://${Ht}`);let Ti=!0;return Fi&&(!we||!li?Ti=!0:Ti=!1),W.jsxs(yh,{className:"PromoOverlay",children:[W.jsxs(_h,{children:[W.jsxs(bh,{className:X.cx_default(!oi&&vh),children:[((s=ne.sponsor)==null?void 0:s.logo)&&ne.logoMode===ge.PromotionLogoMode.LEFT&&W.jsx(fc,{className:"PromoSponsorLogo",src:(a=ne.sponsor)==null?void 0:a.logo,alt:"promo"}),W.jsxs(S0,{style:{paddingLeft:(l=ne.sponsor)!=null&&l.logo&&ne.logoMode===ge.PromotionLogoMode.LEFT?"0px":"8px"},children:[((u=ne.sponsor)==null?void 0:u.logo)&&ne.logoMode===ge.PromotionLogoMode.LEFT&&W.jsx(_0,{children:(p=ne.sponsor)==null?void 0:p.name}),W.jsxs(E0,{className:"SponsorText",children:[W.jsx(Sh,{children:"AD"}),W.jsx(w0,{children:"SPONSORED"})]})]})]}),W.jsx(X.y$1,{className:"ClosePromoIcon",close:Ut,autoClose:(g=ne.closeTimer)==null?void 0:g.auto,duration:Ot?0:(b=ne.closeTimer)==null?void 0:b.seconds,isPlaying:Ti})]}),W.jsxs(Th,{children:[oi&&W.jsx(fc,{className:v0,src:(S=ne.sponsor)==null?void 0:S.logo,alt:"promo"}),W.jsx(yc,{children:(C=(w=ne.banner)==null?void 0:w.video)!=null&&C.url?W.jsx(X.Z,{source:(D=(v=ne.banner)==null?void 0:v.video)==null?void 0:D.url,poster:(O=(L=ne.banner)==null?void 0:L.video)==null?void 0:O.thumbnailUrl,aspectRatio:Fe?"1/1":"16/9",onPause:()=>{li&&(ze==null||ze(!0))},onPlay:()=>{X.eventBus.emit("advertisement",{action:"videoPlay",payload:{id:ht,type:ne.type}}),ze==null||ze(!1)},controlVideo:dt,autoPlay:li}):(U=ne.banner)!=null&&U.imageUrl?W.jsx(b0,{style:Fe?{aspectRatio:"1/1"}:{},src:(F=ne.banner)==null?void 0:F.imageUrl,alt:"promo"}):null}),!Fe&&W.jsxs(yc,{children:[((N=ne.banner)==null?void 0:N.title)&&W.jsx(k0,{className:X.cx_default("AdvTitle",oi&&C0),children:(V=ne.banner)==null?void 0:V.title}),((J=ne.banner)==null?void 0:J.body)&&W.jsx(T0,{className:"AdvDescription",children:(Y=ne.banner)==null?void 0:Y.body})]})]}),ne.buttonType!==ge.PromotionButtonType.NO_BUTTON&&W.jsx(Eh,{children:W.jsx(wh,{href:Ht,style:{backgroundColor:((he=(ie=ne.banner)==null?void 0:ie.ctaButton)==null?void 0:he.color)||"#009dc4",color:((pe=(le=ne.banner)==null?void 0:le.ctaButton)==null?void 0:pe.textColor)||"#fff"},"data-analytics":"button","data-promo-id":ht,"data-promo-type":ne.type,target:"_blank",children:(ce=(ee=ne.banner)==null?void 0:ee.ctaButton)==null?void 0:ce.label})})]})},F2=X.styled_default("div")({name:"SidebarContainer",class:"s1abskp8",propsAsIs:!1}),j2=({children:i,direction:e,style:t,className:r,hiding:n})=>W.jsx(bl,{direction:e,style:t,hiding:n,className:r,children:W.jsx(F2,{children:i})}),q2=i=>(i==null?void 0:i.type)===ge.PromotionType.INGAME_IAB11_LBAR||(i==null?void 0:i.type)===ge.PromotionType.INGAME_IAB21_LBAR,$2=i=>(i==null?void 0:i.type)===ge.PromotionType.INGAME_IAB11||(i==null?void 0:i.type)===ge.PromotionType.INGAME_IAB21,V2=({advertisement:i,close:e,skipTypeCheck:t,skipAutoClose:r,layoutMode:n="side-by-side",sidebar:s,isNotification:a,banner:l,markAsViewed:u,open:p,externalAd:g,controlVideo:b,advertisementPaused:S,togglePause:w})=>i.promotion?a&&i.notification?W.jsx(f0,{open:()=>p==null?void 0:p({fromNotification:!0}),notification:i.notification,promotionId:i.question.id}):!s&&!l&&(t||$2(i.promotion))?W.jsx(y0,{className:"PromoOverlayContainer",children:W.jsx(gh,{markAsViewed:u,promotionId:i.question.id,promotion:i.promotion,onClose:e,open:p,skipAutoClose:r,externalAd:g,controlVideo:b,advertisementPaused:S,togglePause:w})}):s&&(t||q2(i.promotion))?W.jsx(j2,{className:"PromoSidebarContainer",direction:s,hiding:!1,children:W.jsx(gh,{markAsViewed:u,promotionId:i.question.id,promotion:i.promotion,externalAd:g,onClose:e,open:p,controlVideo:b,skipAutoClose:r,advertisementPaused:S,togglePause:w})}):l?W.jsx(N_,{promotionId:i.question.id,hiding:!1,promotion:i.promotion,direction:l}):null:null,H2=X.styled_default("div")({name:"AdvertisementUIWrap",class:"aa6pjif",propsAsIs:!1}),z2=i=>{const e=i.target;if(e instanceof HTMLAnchorElement&&e.target==="_blank"){const t=e.getAttribute("data-promo-id")||"",r=e.getAttribute("data-promo-type")||ge.PromotionType.UNSET;e.getAttribute("data-analytics")==="button"&&X.eventBus.emit("advertisement",{action:"buttonSelect",payload:{id:t,type:r}}),e.getAttribute("data-analytics")==="banner"&&X.eventBus.emit("advertisement",{action:"bannerSelect",payload:{id:t,type:r}})}},W2=({gamification:i,layoutMode:e,skipAutoClose:t,skipTypeCheck:r,sidebar:n,banner:s,notification:a,isMobileScreen:l,persistent:u,externalAd:p,controlVideo:g})=>{var b,S,w;const C=Me.useRef(null),v=X.useStore(i.advertisement.$store);X.y(C,{enabled:!!v.data,event:"click",listener:z2});const D=!s&&!n;if(v.data===void 0||!u&&v.isViewed)return null;const L=((w=(S=(b=v==null?void 0:v.data)==null?void 0:b.notification)==null?void 0:S.promotion)==null?void 0:w.mode)===ge.NotificationPromotionMode.LOWER_THIRD;return W.jsx(H2,{ref:C,style:{height:D?"auto":"100%"},className:X.cx_default("SL-AdvertisementUIWrap",l&&"mobile-view",L&&"SL-AdvertisementUIWrap--lower-third"),children:W.jsx(V2,{skipTypeCheck:r,sidebar:n,banner:s,advertisement:v.data,advertisementPaused:v.isPaused,togglePause:v.togglePause,close:v.close,externalAd:p?v.externalAd:void 0,markAsViewed:i.advertisement.markAsViewed,open:i.advertisement.open,layoutMode:e,isNotification:a,skipAutoClose:t,controlVideo:g})})},lf=({sdk:i,sidebar:e,externalAd:t,banner:r,skipAutoClose:n,skipTypeCheck:s,layoutMode:a,isMobileScreen:l,persistent:u,notification:p})=>{const g=X.useStore(i.featuresList.getStore()),[b,S]=Me.useState(!t);if(Me.useEffect(()=>{if(t){const C=document.createElement("script");C.async=!0,C.src="https://imasdk.googleapis.com/pal/sdkloader/pal.js",document.body.appendChild(C),C.onload=()=>{S(!0)}}},[t]),e&&r)return W.jsx("div",{style:{color:"red"},children:"define either sidebar or banner, not both."});if(r&&t)return W.jsx("div",{style:{color:"red"},children:"externalAd is not supported with banner"});if(!g)return null;const w=i.getFeature(ge.SdkOverlayType.GAMES);return!w||t&&!b?null:W.jsx(W2,{gamification:w,sidebar:e,banner:r,layoutMode:a,isMobileScreen:l,persistent:u,notification:p,skipTypeCheck:s,skipAutoClose:n,externalAd:t,controlVideo:i.controlVideoPlayer})},G2=({event:i,sidebar:e,banner:t,isMobileScreen:r,skipAutoClose:n,persistent:s,theme:a,notification:l,skipTypeCheck:u,externalAd:p})=>{const g=X.useStreamLayer(),b=X.useStreamLayerUI(),S=X.useStreamLayerTheme();return g?p&&!b.promotionExternalAd?i!==void 0&&W.jsx(X.StreamLayerSDKEvent,{event:i}):!p&&b.promotionExternalAd?i!==void 0&&W.jsx(X.StreamLayerSDKEvent,{event:i}):e&&!b.promotionSidebar?i!==void 0&&W.jsx(X.StreamLayerSDKEvent,{event:i}):t&&!b.promotionBanner?i!==void 0&&W.jsx(X.StreamLayerSDKEvent,{event:i}):l&&!b.promotionNotification?i!==void 0&&W.jsx(X.StreamLayerSDKEvent,{event:i}):!t&&!e&&!l&&!b.promotionOverlay?i!==void 0&&W.jsx(X.StreamLayerSDKEvent,{event:i}):W.jsxs("div",{className:"StreamLayerSDK",children:[W.jsx(X.h,{customTheme:a??S.theme,themeMode:S.themeMode,children:W.jsx(lf,{sdk:g,sidebar:e,banner:t,isMobileScreen:r,persistent:s,notification:l,skipTypeCheck:u,skipAutoClose:n,layoutMode:"side-by-side",externalAd:p})}),i!==void 0&&W.jsx(X.StreamLayerSDKEvent,{event:i})]}):null};exports.StreamLayerSDKAdvertisement=G2;exports.StreamLayerSDKAdvertisementUI=lf;
|
|
223
|
+
`,l++,a=S}),this.end_=a,this.storage_=n,this.diagnostics_=s}calculateBaseTime_(e,t,r){if(!this.storage_.size)return 0;if(this.storage_.has(e))return this.storage_.get(e).segmentSyncInfo.start;const n=Math.min(...this.storage_.keys());if(e<n){const s=n-e;let a=this.storage_.get(n).segmentSyncInfo.start;for(let l=0;l<s;l++){const u=t[l];a-=u.duration}return a}return r}isReliablePlaylist_(e,t){return e!=null&&Array.isArray(t)&&t.length}}class uh extends Gm{constructor(e){super(),this.parent_=e}calculateBaseTime_(e,t,r){if(!this.storage_.size){const n=this.parent_.getSyncInfoForMediaSequence(e);return n?n.segmentSyncInfo.start:0}return super.calculateBaseTime_(e,t,r)}}const Kw=86400,qo=[{name:"VOD",run:(i,e,t,r,n)=>t!==1/0?{time:0,segmentIndex:0,partIndex:null}:null},{name:"MediaSequence",run:(i,e,t,r,n,s)=>{const a=i.getMediaSequenceSync(s);if(!a||!a.isReliable)return null;const l=a.getSyncInfoForTime(n);return l?{time:l.start,partIndex:l.partIndex,segmentIndex:l.segmentIndex}:null}},{name:"ProgramDateTime",run:(i,e,t,r,n)=>{if(!Object.keys(i.timelineToDatetimeMappings).length)return null;let s=null,a=null;const l=ol(e);n=n||0;for(let u=0;u<l.length;u++){const p=e.endList||n===0?u:l.length-(u+1),g=l[p],b=g.segment,S=i.timelineToDatetimeMappings[b.timeline];if(!S||!b.dateTimeObject)continue;let w=b.dateTimeObject.getTime()/1e3+S;if(b.parts&&typeof g.partIndex=="number")for(let v=0;v<g.partIndex;v++)w+=b.parts[v].duration;const C=Math.abs(n-w);if(a!==null&&(C===0||a<C))break;a=C,s={time:w,segmentIndex:g.segmentIndex,partIndex:g.partIndex}}return s}},{name:"Segment",run:(i,e,t,r,n)=>{let s=null,a=null;n=n||0;const l=ol(e);for(let u=0;u<l.length;u++){const p=e.endList||n===0?u:l.length-(u+1),g=l[p],b=g.segment,S=g.part&&g.part.start||b&&b.start;if(b.timeline===r&&typeof S<"u"){const w=Math.abs(n-S);if(a!==null&&a<w)break;(!s||a===null||a>=w)&&(a=w,s={time:S,segmentIndex:g.segmentIndex,partIndex:g.partIndex})}}return s}},{name:"Discontinuity",run:(i,e,t,r,n)=>{let s=null;if(n=n||0,e.discontinuityStarts&&e.discontinuityStarts.length){let a=null;for(let l=0;l<e.discontinuityStarts.length;l++){const u=e.discontinuityStarts[l],p=e.discontinuitySequence+l+1,g=i.discontinuities[p];if(g){const b=Math.abs(n-g.time);if(a!==null&&a<b)break;(!s||a===null||a>=b)&&(a=b,s={time:g.time,segmentIndex:u,partIndex:null})}}}return s}},{name:"Playlist",run:(i,e,t,r,n)=>e.syncInfo?{time:e.syncInfo.time,segmentIndex:e.syncInfo.mediaSequence-e.mediaSequence,partIndex:null}:null}];class Yw extends B.EventTarget{constructor(e={}){super(),this.timelines=[],this.discontinuities=[],this.timelineToDatetimeMappings={};const t=new Gm,r=new uh(t),n=new uh(t);this.mediaSequenceStorage_={main:t,audio:r,vtt:n},this.logger_=Nt("SyncController")}getMediaSequenceSync(e){return this.mediaSequenceStorage_[e]||null}getSyncPoint(e,t,r,n,s){if(t!==1/0)return qo.find(({name:l})=>l==="VOD").run(this,e,t);const a=this.runStrategies_(e,t,r,n,s);if(!a.length)return null;for(const l of a){const{syncPoint:u,strategy:p}=l,{segmentIndex:g,time:b}=u;if(g<0)continue;const S=e.segments[g],w=b,C=w+S.duration;if(this.logger_(`Strategy: ${p}. Current time: ${n}. selected segment: ${g}. Time: [${w} -> ${C}]}`),n>=w&&n<C)return this.logger_("Found sync point with exact match: ",u),u}return this.selectSyncPoint_(a,{key:"time",value:n})}getExpiredTime(e,t){if(!e||!e.segments)return null;const r=this.runStrategies_(e,t,e.discontinuitySequence,0);if(!r.length)return null;const n=this.selectSyncPoint_(r,{key:"segmentIndex",value:0});return n.segmentIndex>0&&(n.time*=-1),Math.abs(n.time+On({defaultDuration:e.targetDuration,durationList:e.segments,startIndex:n.segmentIndex,endIndex:0}))}runStrategies_(e,t,r,n,s){const a=[];for(let l=0;l<qo.length;l++){const u=qo[l],p=u.run(this,e,t,r,n,s);p&&(p.strategy=u.name,a.push({strategy:u.name,syncPoint:p}))}return a}selectSyncPoint_(e,t){let r=e[0].syncPoint,n=Math.abs(e[0].syncPoint[t.key]-t.value),s=e[0].strategy;for(let a=1;a<e.length;a++){const l=Math.abs(e[a].syncPoint[t.key]-t.value);l<n&&(n=l,r=e[a].syncPoint,s=e[a].strategy)}return this.logger_(`syncPoint for [${t.key}: ${t.value}] chosen with strategy [${s}]: [time:${r.time}, segmentIndex:${r.segmentIndex}`+(typeof r.partIndex=="number"?`,partIndex:${r.partIndex}`:"")+"]"),r}saveExpiredSegmentInfo(e,t){const r=t.mediaSequence-e.mediaSequence;if(r>Kw){B.log.warn(`Not saving expired segment info. Media sequence gap ${r} is too large.`);return}for(let n=r-1;n>=0;n--){const s=e.segments[n];if(s&&typeof s.start<"u"){t.syncInfo={mediaSequence:e.mediaSequence+n,time:s.start},this.logger_(`playlist refresh sync: [time:${t.syncInfo.time}, mediaSequence: ${t.syncInfo.mediaSequence}]`),this.trigger("syncinfoupdate");break}}}setDateTimeMappingForStart(e){if(this.timelineToDatetimeMappings={},e.segments&&e.segments.length&&e.segments[0].dateTimeObject){const t=e.segments[0],r=t.dateTimeObject.getTime()/1e3;this.timelineToDatetimeMappings[t.timeline]=-r}}saveSegmentTimingInfo({segmentInfo:e,shouldSaveTimelineMapping:t}){const r=this.calculateSegmentTimeMapping_(e,e.timingInfo,t),n=e.segment;r&&(this.saveDiscontinuitySyncInfo_(e),e.playlist.syncInfo||(e.playlist.syncInfo={mediaSequence:e.playlist.mediaSequence+e.mediaIndex,time:n.start}));const s=n.dateTimeObject;n.discontinuity&&t&&s&&(this.timelineToDatetimeMappings[n.timeline]=-(s.getTime()/1e3))}timestampOffsetForTimeline(e){return typeof this.timelines[e]>"u"?null:this.timelines[e].time}mappingForTimeline(e){return typeof this.timelines[e]>"u"?null:this.timelines[e].mapping}calculateSegmentTimeMapping_(e,t,r){const n=e.segment,s=e.part;let a=this.timelines[e.timeline],l,u;if(typeof e.timestampOffset=="number")a={time:e.startOfSegment,mapping:e.startOfSegment-t.start},r&&(this.timelines[e.timeline]=a,this.trigger("timestampoffset"),this.logger_(`time mapping for timeline ${e.timeline}: [time: ${a.time}] [mapping: ${a.mapping}]`)),l=e.startOfSegment,u=t.end+a.mapping;else if(a)l=t.start+a.mapping,u=t.end+a.mapping;else return!1;return s&&(s.start=l,s.end=u),(!n.start||l<n.start)&&(n.start=l),n.end=u,!0}saveDiscontinuitySyncInfo_(e){const t=e.playlist,r=e.segment;if(r.discontinuity)this.discontinuities[r.timeline]={time:r.start,accuracy:0};else if(t.discontinuityStarts&&t.discontinuityStarts.length)for(let n=0;n<t.discontinuityStarts.length;n++){const s=t.discontinuityStarts[n],a=t.discontinuitySequence+n+1,l=s-e.mediaIndex,u=Math.abs(l);if(!this.discontinuities[a]||this.discontinuities[a].accuracy>u){let p;l<0?p=r.start-On({defaultDuration:t.targetDuration,durationList:t.segments,startIndex:e.mediaIndex,endIndex:s}):p=r.end+On({defaultDuration:t.targetDuration,durationList:t.segments,startIndex:e.mediaIndex+1,endIndex:s}),this.discontinuities[a]={time:p,accuracy:u}}}}dispose(){this.trigger("dispose"),this.off()}}class Qw extends B.EventTarget{constructor(){super(),this.pendingTimelineChanges_={},this.lastTimelineChanges_={}}clearPendingTimelineChange(e){this.pendingTimelineChanges_[e]=null,this.trigger("pendingtimelinechange")}pendingTimelineChange({type:e,from:t,to:r}){return typeof t=="number"&&typeof r=="number"&&(this.pendingTimelineChanges_[e]={type:e,from:t,to:r},this.trigger("pendingtimelinechange")),this.pendingTimelineChanges_[e]}lastTimelineChange({type:e,from:t,to:r}){if(typeof t=="number"&&typeof r=="number"){this.lastTimelineChanges_[e]={type:e,from:t,to:r},delete this.pendingTimelineChanges_[e];const n={timelineChangeInfo:{from:t,to:r}};this.trigger({type:"timelinechange",metadata:n})}return this.lastTimelineChanges_[e]}dispose(){this.trigger("dispose"),this.pendingTimelineChanges_={},this.lastTimelineChanges_={},this.off()}}const Jw=Dm(Pm(function(){var i=function(){function v(){this.listeners={}}var D=v.prototype;return D.on=function(L,O){this.listeners[L]||(this.listeners[L]=[]),this.listeners[L].push(O)},D.off=function(L,O){if(!this.listeners[L])return!1;var U=this.listeners[L].indexOf(O);return this.listeners[L]=this.listeners[L].slice(0),this.listeners[L].splice(U,1),U>-1},D.trigger=function(L){var O=this.listeners[L];if(O)if(arguments.length===2)for(var U=O.length,F=0;F<U;++F)O[F].call(this,arguments[1]);else for(var N=Array.prototype.slice.call(arguments,1),V=O.length,J=0;J<V;++J)O[J].apply(this,N)},D.dispose=function(){this.listeners={}},D.pipe=function(L){this.on("data",function(O){L.push(O)})},v}();/*! @name pkcs7 @version 1.0.4 @license Apache-2.0 */function e(v){return v.subarray(0,v.byteLength-v[v.byteLength-1])}/*! @name aes-decrypter @version 4.0.2 @license Apache-2.0 */const t=function(){const v=[[[],[],[],[],[]],[[],[],[],[],[]]],D=v[0],L=v[1],O=D[4],U=L[4];let F,N,V;const J=[],Y=[];let ie,he,le,pe,ee,ce;for(F=0;F<256;F++)Y[(J[F]=F<<1^(F>>7)*283)^F]=F;for(N=V=0;!O[N];N^=ie||1,V=Y[V]||1)for(pe=V^V<<1^V<<2^V<<3^V<<4,pe=pe>>8^pe&255^99,O[N]=pe,U[pe]=N,le=J[he=J[ie=J[N]]],ce=le*16843009^he*65537^ie*257^N*16843008,ee=J[pe]*257^pe*16843008,F=0;F<4;F++)D[F][N]=ee=ee<<24^ee>>>8,L[F][pe]=ce=ce<<24^ce>>>8;for(F=0;F<5;F++)D[F]=D[F].slice(0),L[F]=L[F].slice(0);return v};let r=null;class n{constructor(D){r||(r=t()),this._tables=[[r[0][0].slice(),r[0][1].slice(),r[0][2].slice(),r[0][3].slice(),r[0][4].slice()],[r[1][0].slice(),r[1][1].slice(),r[1][2].slice(),r[1][3].slice(),r[1][4].slice()]];let L,O,U;const F=this._tables[0][4],N=this._tables[1],V=D.length;let J=1;if(V!==4&&V!==6&&V!==8)throw new Error("Invalid aes key size");const Y=D.slice(0),ie=[];for(this._key=[Y,ie],L=V;L<4*V+28;L++)U=Y[L-1],(L%V===0||V===8&&L%V===4)&&(U=F[U>>>24]<<24^F[U>>16&255]<<16^F[U>>8&255]<<8^F[U&255],L%V===0&&(U=U<<8^U>>>24^J<<24,J=J<<1^(J>>7)*283)),Y[L]=Y[L-V]^U;for(O=0;L;O++,L--)U=Y[O&3?L:L-4],L<=4||O<4?ie[O]=U:ie[O]=N[0][F[U>>>24]]^N[1][F[U>>16&255]]^N[2][F[U>>8&255]]^N[3][F[U&255]]}decrypt(D,L,O,U,F,N){const V=this._key[1];let J=D^V[0],Y=U^V[1],ie=O^V[2],he=L^V[3],le,pe,ee;const ce=V.length/4-2;let ne,de=4;const we=this._tables[1],ze=we[0],dt=we[1],Ot=we[2],ht=we[3],Ut=we[4];for(ne=0;ne<ce;ne++)le=ze[J>>>24]^dt[Y>>16&255]^Ot[ie>>8&255]^ht[he&255]^V[de],pe=ze[Y>>>24]^dt[ie>>16&255]^Ot[he>>8&255]^ht[J&255]^V[de+1],ee=ze[ie>>>24]^dt[he>>16&255]^Ot[J>>8&255]^ht[Y&255]^V[de+2],he=ze[he>>>24]^dt[J>>16&255]^Ot[Y>>8&255]^ht[ie&255]^V[de+3],de+=4,J=le,Y=pe,ie=ee;for(ne=0;ne<4;ne++)F[(3&-ne)+N]=Ut[J>>>24]<<24^Ut[Y>>16&255]<<16^Ut[ie>>8&255]<<8^Ut[he&255]^V[de++],le=J,J=Y,Y=ie,ie=he,he=le}}class s extends i{constructor(){super(i),this.jobs=[],this.delay=1,this.timeout_=null}processJob_(){this.jobs.shift()(),this.jobs.length?this.timeout_=setTimeout(this.processJob_.bind(this),this.delay):this.timeout_=null}push(D){this.jobs.push(D),this.timeout_||(this.timeout_=setTimeout(this.processJob_.bind(this),this.delay))}}const a=function(v){return v<<24|(v&65280)<<8|(v&16711680)>>8|v>>>24},l=function(v,D,L){const O=new Int32Array(v.buffer,v.byteOffset,v.byteLength>>2),U=new n(Array.prototype.slice.call(D)),F=new Uint8Array(v.byteLength),N=new Int32Array(F.buffer);let V,J,Y,ie,he,le,pe,ee,ce;for(V=L[0],J=L[1],Y=L[2],ie=L[3],ce=0;ce<O.length;ce+=4)he=a(O[ce]),le=a(O[ce+1]),pe=a(O[ce+2]),ee=a(O[ce+3]),U.decrypt(he,le,pe,ee,N,ce),N[ce]=a(N[ce]^V),N[ce+1]=a(N[ce+1]^J),N[ce+2]=a(N[ce+2]^Y),N[ce+3]=a(N[ce+3]^ie),V=he,J=le,Y=pe,ie=ee;return F};class u{constructor(D,L,O,U){const F=u.STEP,N=new Int32Array(D.buffer),V=new Uint8Array(D.byteLength);let J=0;for(this.asyncStream_=new s,this.asyncStream_.push(this.decryptChunk_(N.subarray(J,J+F),L,O,V)),J=F;J<N.length;J+=F)O=new Uint32Array([a(N[J-4]),a(N[J-3]),a(N[J-2]),a(N[J-1])]),this.asyncStream_.push(this.decryptChunk_(N.subarray(J,J+F),L,O,V));this.asyncStream_.push(function(){U(null,e(V))})}static get STEP(){return 32e3}decryptChunk_(D,L,O,U){return function(){const F=l(D,L,O);U.set(F,D.byteOffset)}}}var p=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof Ys<"u"?Ys:typeof self<"u"?self:{},g;typeof window<"u"?g=window:typeof p<"u"?g=p:typeof self<"u"?g=self:g={};var b=g,S=function(v){return ArrayBuffer.isView==="function"?ArrayBuffer.isView(v):v&&v.buffer instanceof ArrayBuffer},w=b.BigInt||Number;w("0x1"),w("0x100"),w("0x10000"),w("0x1000000"),w("0x100000000"),w("0x10000000000"),w("0x1000000000000"),w("0x100000000000000"),w("0x10000000000000000"),function(){var v=new Uint16Array([65484]),D=new Uint8Array(v.buffer,v.byteOffset,v.byteLength);return D[0]===255?"big":D[0]===204?"little":"unknown"}();const C=function(v){const D={};return Object.keys(v).forEach(L=>{const O=v[L];S(O)?D[L]={bytes:O.buffer,byteOffset:O.byteOffset,byteLength:O.byteLength}:D[L]=O}),D};self.onmessage=function(v){const D=v.data,L=new Uint8Array(D.encrypted.bytes,D.encrypted.byteOffset,D.encrypted.byteLength),O=new Uint32Array(D.key.bytes,D.key.byteOffset,D.key.byteLength/4),U=new Uint32Array(D.iv.bytes,D.iv.byteOffset,D.iv.byteLength/4);new u(L,O,U,function(F,N){self.postMessage(C({source:D.source,decrypted:N}),[N.buffer])})}}));var Zw=Lm(Jw);const e2=i=>{let e=i.default?"main":"alternative";return i.characteristics&&i.characteristics.indexOf("public.accessibility.describes-video")>=0&&(e="main-desc"),e},Xm=(i,e)=>{i.abort(),i.pause(),e&&e.activePlaylistLoader&&(e.activePlaylistLoader.pause(),e.activePlaylistLoader=null)},_l=(i,e)=>{e.activePlaylistLoader=i,i.load()},t2=(i,e)=>()=>{const{segmentLoaders:{[i]:t,main:r},mediaTypes:{[i]:n}}=e,s=n.activeTrack(),a=n.getActiveGroup(),l=n.activePlaylistLoader,u=n.lastGroup_;if(!(a&&u&&a.id===u.id)&&(n.lastGroup_=a,n.lastTrack_=s,Xm(t,n),!(!a||a.isMainPlaylist))){if(!a.playlistLoader){l&&r.resetEverything();return}t.resyncLoader(),_l(a.playlistLoader,n)}},i2=(i,e)=>()=>{const{segmentLoaders:{[i]:t},mediaTypes:{[i]:r}}=e;r.lastGroup_=null,t.abort(),t.pause()},r2=(i,e)=>()=>{const{mainPlaylistLoader:t,segmentLoaders:{[i]:r,main:n},mediaTypes:{[i]:s}}=e,a=s.activeTrack(),l=s.getActiveGroup(),u=s.activePlaylistLoader,p=s.lastTrack_;if(!(p&&a&&p.id===a.id)&&(s.lastGroup_=l,s.lastTrack_=a,Xm(r,s),!!l)){if(l.isMainPlaylist){if(!a||!p||a.id===p.id)return;const g=e.vhs.playlistController_,b=g.selectPlaylist();if(g.media()===b)return;s.logger_(`track change. Switching main audio from ${p.id} to ${a.id}`),t.pause(),n.resetEverything(),g.fastQualityChange_(b);return}if(i==="AUDIO"){if(!l.playlistLoader){n.setAudio(!0),n.resetEverything();return}r.setAudio(!0),n.setAudio(!1)}if(u===l.playlistLoader){_l(l.playlistLoader,s);return}r.track&&r.track(a),r.resetEverything(),_l(l.playlistLoader,s)}},_a={AUDIO:(i,e)=>()=>{const{mediaTypes:{[i]:t},excludePlaylist:r}=e,n=t.activeTrack(),s=t.activeGroup(),a=(s.filter(u=>u.default)[0]||s[0]).id,l=t.tracks[a];if(n===l){r({error:{message:"Problem encountered loading the default audio track."}});return}B.log.warn("Problem encountered loading the alternate audio track.Switching back to default.");for(const u in t.tracks)t.tracks[u].enabled=t.tracks[u]===l;t.onTrackChanged()},SUBTITLES:(i,e)=>()=>{const{mediaTypes:{[i]:t}}=e;B.log.warn("Problem encountered loading the subtitle track.Disabling subtitle track.");const r=t.activeTrack();r&&(r.mode="disabled"),t.onTrackChanged()}},ch={AUDIO:(i,e,t)=>{if(!e)return;const{tech:r,requestOptions:n,segmentLoaders:{[i]:s}}=t;e.on("loadedmetadata",()=>{const a=e.media();s.playlist(a,n),(!r.paused()||a.endList&&r.preload()!=="none")&&s.load()}),e.on("loadedplaylist",()=>{s.playlist(e.media(),n),r.paused()||s.load()}),e.on("error",_a[i](i,t))},SUBTITLES:(i,e,t)=>{const{tech:r,requestOptions:n,segmentLoaders:{[i]:s},mediaTypes:{[i]:a}}=t;e.on("loadedmetadata",()=>{const l=e.media();s.playlist(l,n),s.track(a.activeTrack()),(!r.paused()||l.endList&&r.preload()!=="none")&&s.load()}),e.on("loadedplaylist",()=>{s.playlist(e.media(),n),r.paused()||s.load()}),e.on("error",_a[i](i,t))}},n2={AUDIO:(i,e)=>{const{vhs:t,sourceType:r,segmentLoaders:{[i]:n},requestOptions:s,main:{mediaGroups:a},mediaTypes:{[i]:{groups:l,tracks:u,logger_:p}},mainPlaylistLoader:g}=e,b=ts(g.main);(!a[i]||Object.keys(a[i]).length===0)&&(a[i]={main:{default:{default:!0}}},b&&(a[i].main.default.playlists=g.main.playlists));for(const S in a[i]){l[S]||(l[S]=[]);for(const w in a[i][S]){let C=a[i][S][w],v;if(b?(p(`AUDIO group '${S}' label '${w}' is a main playlist`),C.isMainPlaylist=!0,v=null):r==="vhs-json"&&C.playlists?v=new Er(C.playlists[0],t,s):C.resolvedUri?v=new Er(C.resolvedUri,t,s):C.playlists&&r==="dash"?v=new pl(C.playlists[0],t,s,g):v=null,C=fe({id:w,playlistLoader:v},C),ch[i](i,C.playlistLoader,e),l[S].push(C),typeof u[w]>"u"){const D=new B.AudioTrack({id:w,kind:e2(C),enabled:!1,language:C.language,default:C.default,label:w});u[w]=D}}}n.on("error",_a[i](i,e))},SUBTITLES:(i,e)=>{const{tech:t,vhs:r,sourceType:n,segmentLoaders:{[i]:s},requestOptions:a,main:{mediaGroups:l},mediaTypes:{[i]:{groups:u,tracks:p}},mainPlaylistLoader:g}=e;for(const b in l[i]){u[b]||(u[b]=[]);for(const S in l[i][b]){if(!r.options_.useForcedSubtitles&&l[i][b][S].forced)continue;let w=l[i][b][S],C;if(n==="hls")C=new Er(w.resolvedUri,r,a);else if(n==="dash"){if(!w.playlists.filter(v=>v.excludeUntil!==1/0).length)return;C=new pl(w.playlists[0],r,a,g)}else n==="vhs-json"&&(C=new Er(w.playlists?w.playlists[0]:w.resolvedUri,r,a));if(w=fe({id:S,playlistLoader:C},w),ch[i](i,w.playlistLoader,e),u[b].push(w),typeof p[S]>"u"){const v=t.addRemoteTextTrack({id:S,kind:"subtitles",default:w.default&&w.autoselect,language:w.language,label:S},!1).track;p[S]=v}}}s.on("error",_a[i](i,e))},"CLOSED-CAPTIONS":(i,e)=>{const{tech:t,main:{mediaGroups:r},mediaTypes:{[i]:{groups:n,tracks:s}}}=e;for(const a in r[i]){n[a]||(n[a]=[]);for(const l in r[i][a]){const u=r[i][a][l];if(!/^(?:CC|SERVICE)/.test(u.instreamId))continue;const p=t.options_.vhs&&t.options_.vhs.captionServices||{};let g={label:l,language:u.language,instreamId:u.instreamId,default:u.default&&u.autoselect};if(p[g.instreamId]&&(g=fe(g,p[g.instreamId])),g.default===void 0&&delete g.default,n[a].push(fe({id:l},u)),typeof s[l]>"u"){const b=t.addRemoteTextTrack({id:g.instreamId,kind:"captions",default:g.default,language:g.language,label:g.label},!1).track;s[l]=b}}}}},Km=(i,e)=>{for(let t=0;t<i.length;t++)if(Eu(e,i[t])||i[t].playlists&&Km(i[t].playlists,e))return!0;return!1},s2=(i,e)=>t=>{const{mainPlaylistLoader:r,mediaTypes:{[i]:{groups:n}}}=e,s=r.media();if(!s)return null;let a=null;s.attributes[i]&&(a=n[s.attributes[i]]);const l=Object.keys(n);if(!a)if(i==="AUDIO"&&l.length>1&&ts(e.main))for(let u=0;u<l.length;u++){const p=n[l[u]];if(Km(p,s)){a=p;break}}else n.main?a=n.main:l.length===1&&(a=n[l[0]]);return typeof t>"u"?a:t===null||!a?null:a.filter(u=>u.id===t.id)[0]||null},a2={AUDIO:(i,e)=>()=>{const{mediaTypes:{[i]:{tracks:t}}}=e;for(const r in t)if(t[r].enabled)return t[r];return null},SUBTITLES:(i,e)=>()=>{const{mediaTypes:{[i]:{tracks:t}}}=e;for(const r in t)if(t[r].mode==="showing"||t[r].mode==="hidden")return t[r];return null}},o2=(i,{mediaTypes:e})=>()=>{const t=e[i].activeTrack();return t?e[i].activeGroup(t):null},l2=i=>{["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(p=>{n2[p](p,i)});const{mediaTypes:e,mainPlaylistLoader:t,tech:r,vhs:n,segmentLoaders:{["AUDIO"]:s,main:a}}=i;["AUDIO","SUBTITLES"].forEach(p=>{e[p].activeGroup=s2(p,i),e[p].activeTrack=a2[p](p,i),e[p].onGroupChanged=t2(p,i),e[p].onGroupChanging=i2(p,i),e[p].onTrackChanged=r2(p,i),e[p].getActiveGroup=o2(p,i)});const l=e.AUDIO.activeGroup();if(l){const p=(l.filter(g=>g.default)[0]||l[0]).id;e.AUDIO.tracks[p].enabled=!0,e.AUDIO.onGroupChanged(),e.AUDIO.onTrackChanged(),e.AUDIO.getActiveGroup().playlistLoader?(a.setAudio(!1),s.setAudio(!0)):a.setAudio(!0)}t.on("mediachange",()=>{["AUDIO","SUBTITLES"].forEach(p=>e[p].onGroupChanged())}),t.on("mediachanging",()=>{["AUDIO","SUBTITLES"].forEach(p=>e[p].onGroupChanging())});const u=()=>{e.AUDIO.onTrackChanged(),r.trigger({type:"usage",name:"vhs-audio-change"})};r.audioTracks().addEventListener("change",u),r.remoteTextTracks().addEventListener("change",e.SUBTITLES.onTrackChanged),n.on("dispose",()=>{r.audioTracks().removeEventListener("change",u),r.remoteTextTracks().removeEventListener("change",e.SUBTITLES.onTrackChanged)}),r.clearTracks("audio");for(const p in e.AUDIO.tracks)r.audioTracks().addTrack(e.AUDIO.tracks[p])},u2=()=>{const i={};return["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(e=>{i[e]={groups:{},tracks:{},activePlaylistLoader:null,activeGroup:pi,activeTrack:pi,getActiveGroup:pi,onGroupChanged:pi,onTrackChanged:pi,lastTrack_:null,logger_:Nt(`MediaGroups[${e}]`)}}),i};class dh{constructor(){this.priority_=[],this.pathwayClones_=new Map}set version(e){e===1&&(this.version_=e)}set ttl(e){this.ttl_=e||300}set reloadUri(e){e&&(this.reloadUri_=yt(this.reloadUri_,e))}set priority(e){e&&e.length&&(this.priority_=e)}set pathwayClones(e){e&&e.length&&(this.pathwayClones_=new Map(e.map(t=>[t.ID,t])))}get version(){return this.version_}get ttl(){return this.ttl_}get reloadUri(){return this.reloadUri_}get priority(){return this.priority_}get pathwayClones(){return this.pathwayClones_}}class c2 extends B.EventTarget{constructor(e,t){super(),this.currentPathway=null,this.defaultPathway=null,this.queryBeforeStart=!1,this.availablePathways_=new Set,this.steeringManifest=new dh,this.proxyServerUrl_=null,this.manifestType_=null,this.ttlTimeout_=null,this.request_=null,this.currentPathwayClones=new Map,this.nextPathwayClones=new Map,this.excludedSteeringManifestURLs=new Set,this.logger_=Nt("Content Steering"),this.xhr_=e,this.getBandwidth_=t}assignTagProperties(e,t){this.manifestType_=t.serverUri?"HLS":"DASH";const r=t.serverUri||t.serverURL;if(!r){this.logger_(`steering manifest URL is ${r}, cannot request steering manifest.`),this.trigger("error");return}if(r.startsWith("data:")){this.decodeDataUriManifest_(r.substring(r.indexOf(",")+1));return}this.steeringManifest.reloadUri=yt(e,r),this.defaultPathway=t.pathwayId||t.defaultServiceLocation,this.queryBeforeStart=t.queryBeforeStart,this.proxyServerUrl_=t.proxyServerURL,this.defaultPathway&&!this.queryBeforeStart&&this.trigger("content-steering")}requestSteeringManifest(e){const t=this.steeringManifest.reloadUri;if(!t)return;const r=e?t:this.getRequestURI(t);if(!r){this.logger_("No valid content steering manifest URIs. Stopping content steering."),this.trigger("error"),this.dispose();return}const n={contentSteeringInfo:{uri:r}};this.trigger({type:"contentsteeringloadstart",metadata:n}),this.request_=this.xhr_({uri:r,requestType:"content-steering-manifest"},(s,a)=>{if(s){if(a.status===410){this.logger_(`manifest request 410 ${s}.`),this.logger_(`There will be no more content steering requests to ${r} this session.`),this.excludedSteeringManifestURLs.add(r);return}if(a.status===429){const p=a.responseHeaders["retry-after"];this.logger_(`manifest request 429 ${s}.`),this.logger_(`content steering will retry in ${p} seconds.`),this.startTTLTimeout_(parseInt(p,10));return}this.logger_(`manifest failed to load ${s}.`),this.startTTLTimeout_();return}this.trigger({type:"contentsteeringloadcomplete",metadata:n});let l;try{l=JSON.parse(this.request_.responseText)}catch(p){const g={errorType:B.Error.StreamingContentSteeringParserError,error:p};this.trigger({type:"error",metadata:g})}this.assignSteeringProperties_(l);const u={contentSteeringInfo:n.contentSteeringInfo,contentSteeringManifest:{version:this.steeringManifest.version,reloadUri:this.steeringManifest.reloadUri,priority:this.steeringManifest.priority}};this.trigger({type:"contentsteeringparsed",metadata:u}),this.startTTLTimeout_()})}setProxyServerUrl_(e){const t=new x.URL(e),r=new x.URL(this.proxyServerUrl_);return r.searchParams.set("url",encodeURI(t.toString())),this.setSteeringParams_(r.toString())}decodeDataUriManifest_(e){const t=JSON.parse(x.atob(e));this.assignSteeringProperties_(t)}setSteeringParams_(e){const t=new x.URL(e),r=this.getPathway(),n=this.getBandwidth_();if(r){const s=`_${this.manifestType_}_pathway`;t.searchParams.set(s,r)}if(n){const s=`_${this.manifestType_}_throughput`;t.searchParams.set(s,n)}return t.toString()}assignSteeringProperties_(e){if(this.steeringManifest.version=e.VERSION,!this.steeringManifest.version){this.logger_(`manifest version is ${e.VERSION}, which is not supported.`),this.trigger("error");return}this.steeringManifest.ttl=e.TTL,this.steeringManifest.reloadUri=e["RELOAD-URI"],this.steeringManifest.priority=e["PATHWAY-PRIORITY"]||e["SERVICE-LOCATION-PRIORITY"],this.steeringManifest.pathwayClones=e["PATHWAY-CLONES"],this.nextPathwayClones=this.steeringManifest.pathwayClones,this.availablePathways_.size||(this.logger_("There are no available pathways for content steering. Ending content steering."),this.trigger("error"),this.dispose());const t=(r=>{for(const n of r)if(this.availablePathways_.has(n))return n;return[...this.availablePathways_][0]})(this.steeringManifest.priority);this.currentPathway!==t&&(this.currentPathway=t,this.trigger("content-steering"))}getPathway(){return this.currentPathway||this.defaultPathway}getRequestURI(e){if(!e)return null;const t=n=>this.excludedSteeringManifestURLs.has(n);if(this.proxyServerUrl_){const n=this.setProxyServerUrl_(e);if(!t(n))return n}const r=this.setSteeringParams_(e);return t(r)?null:r}startTTLTimeout_(e=this.steeringManifest.ttl){const t=e*1e3;this.ttlTimeout_=x.setTimeout(()=>{this.requestSteeringManifest()},t)}clearTTLTimeout_(){x.clearTimeout(this.ttlTimeout_),this.ttlTimeout_=null}abort(){this.request_&&this.request_.abort(),this.request_=null}dispose(){this.off("content-steering"),this.off("error"),this.abort(),this.clearTTLTimeout_(),this.currentPathway=null,this.defaultPathway=null,this.queryBeforeStart=null,this.proxyServerUrl_=null,this.manifestType_=null,this.ttlTimeout_=null,this.request_=null,this.excludedSteeringManifestURLs=new Set,this.availablePathways_=new Set,this.steeringManifest=new dh}addAvailablePathway(e){e&&this.availablePathways_.add(e)}clearAvailablePathways(){this.availablePathways_.clear()}excludePathway(e){return this.availablePathways_.delete(e)}didDASHTagChange(e,t){return!t&&this.steeringManifest.reloadUri||t&&(yt(e,t.serverURL)!==this.steeringManifest.reloadUri||t.defaultServiceLocation!==this.defaultPathway||t.queryBeforeStart!==this.queryBeforeStart||t.proxyServerURL!==this.proxyServerUrl_)}getAvailablePathways(){return this.availablePathways_}}const d2=(i,e)=>{let t=null;return(...r)=>{clearTimeout(t),t=setTimeout(()=>{i.apply(null,r)},e)}},h2=10;let Pi;const p2=["mediaRequests","mediaRequestsAborted","mediaRequestsTimedout","mediaRequestsErrored","mediaTransferDuration","mediaBytesTransferred","mediaAppends"],g2=function(i){return this.audioSegmentLoader_[i]+this.mainSegmentLoader_[i]},m2=function({currentPlaylist:i,buffered:e,currentTime:t,nextPlaylist:r,bufferLowWaterLine:n,bufferHighWaterLine:s,duration:a,bufferBasedABR:l,log:u}){if(!r)return B.log.warn("We received no playlist to switch to. Please check your stream."),!1;const p=`allowing switch ${i&&i.id||"null"} -> ${r.id}`;if(!i)return u(`${p} as current playlist is not set`),!0;if(r.id===i.id)return!1;const g=!!Sr(e,t).length;if(!i.endList)return!g&&typeof i.partTargetDuration=="number"?(u(`not ${p} as current playlist is live llhls, but currentTime isn't in buffered.`),!1):(u(`${p} as current playlist is live`),!0);const b=vu(e,t),S=l?Xe.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE:Xe.MAX_BUFFER_LOW_WATER_LINE;if(a<S)return u(`${p} as duration < max low water line (${a} < ${S})`),!0;const w=r.attributes.BANDWIDTH,C=i.attributes.BANDWIDTH;if(w<C&&(!l||b<s)){let v=`${p} as next bandwidth < current bandwidth (${w} < ${C})`;return l&&(v+=` and forwardBuffer < bufferHighWaterLine (${b} < ${s})`),u(v),!0}if((!l||w>C)&&b>=n){let v=`${p} as forwardBuffer >= bufferLowWaterLine (${b} >= ${n})`;return l&&(v+=` and next bandwidth > current bandwidth (${w} > ${C})`),u(v),!0}return u(`not ${p} as no switching criteria met`),!1};class f2 extends B.EventTarget{constructor(e){super(),this.fastQualityChange_=d2(this.fastQualityChange_.bind(this),100);const{src:t,withCredentials:r,tech:n,bandwidth:s,externVhs:a,useCueTags:l,playlistExclusionDuration:u,enableLowInitialPlaylist:p,sourceType:g,cacheEncryptionKeys:b,bufferBasedABR:S,leastPixelDiffSelector:w,captionServices:C,experimentalUseMMS:v}=e;if(!t)throw new Error("A non-empty playlist URL or JSON manifest string is required");let{maxPlaylistRetries:D}=e;(D===null||typeof D>"u")&&(D=1/0),Pi=a,this.bufferBasedABR=!!S,this.leastPixelDiffSelector=!!w,this.withCredentials=r,this.tech_=n,this.vhs_=n.vhs,this.player_=e.player_,this.sourceType_=g,this.useCueTags_=l,this.playlistExclusionDuration=u,this.maxPlaylistRetries=D,this.enableLowInitialPlaylist=p,this.usingManagedMediaSource_=!1,this.useCueTags_&&(this.cueTagsTrack_=this.tech_.addTextTrack("metadata","ad-cues"),this.cueTagsTrack_.inBandMetadataTrackDispatchType=""),this.requestOptions_={withCredentials:r,maxPlaylistRetries:D,timeout:null},this.on("error",this.pauseLoading),this.mediaTypes_=u2(),v&&x.ManagedMediaSource?(this.tech_.el_.disableRemotePlayback=!0,this.mediaSource=new x.ManagedMediaSource,this.usingManagedMediaSource_=!0,B.log("Using ManagedMediaSource")):x.MediaSource&&(this.mediaSource=new x.MediaSource),this.handleDurationChange_=this.handleDurationChange_.bind(this),this.handleSourceOpen_=this.handleSourceOpen_.bind(this),this.handleSourceEnded_=this.handleSourceEnded_.bind(this),this.load=this.load.bind(this),this.pause=this.pause.bind(this),this.mediaSource.addEventListener("durationchange",this.handleDurationChange_),this.mediaSource.addEventListener("sourceopen",this.handleSourceOpen_),this.mediaSource.addEventListener("sourceended",this.handleSourceEnded_),this.mediaSource.addEventListener("startstreaming",this.load),this.mediaSource.addEventListener("endstreaming",this.pause),this.seekable_=it(),this.hasPlayed_=!1,this.syncController_=new Yw(e),this.segmentMetadataTrack_=n.addRemoteTextTrack({kind:"metadata",label:"segment-metadata"},!1).track,this.decrypter_=new Zw,this.sourceUpdater_=new Wm(this.mediaSource),this.inbandTextTracks_={},this.timelineChangeController_=new Qw,this.keyStatusMap_=new Map;const L={vhs:this.vhs_,parse708captions:e.parse708captions,useDtsForTimestampOffset:e.useDtsForTimestampOffset,captionServices:C,mediaSource:this.mediaSource,currentTime:this.tech_.currentTime.bind(this.tech_),seekable:()=>this.seekable(),seeking:()=>this.tech_.seeking(),duration:()=>this.duration(),hasPlayed:()=>this.hasPlayed_,goalBufferLength:()=>this.goalBufferLength(),bandwidth:s,syncController:this.syncController_,decrypter:this.decrypter_,sourceType:this.sourceType_,inbandTextTracks:this.inbandTextTracks_,cacheEncryptionKeys:b,sourceUpdater:this.sourceUpdater_,timelineChangeController:this.timelineChangeController_,exactManifestTimings:e.exactManifestTimings,addMetadataToTextTrack:this.addMetadataToTextTrack.bind(this)};this.mainPlaylistLoader_=this.sourceType_==="dash"?new pl(t,this.vhs_,fe(this.requestOptions_,{addMetadataToTextTrack:this.addMetadataToTextTrack.bind(this)})):new Er(t,this.vhs_,fe(this.requestOptions_,{addDateRangesToTextTrack:this.addDateRangesToTextTrack_.bind(this)})),this.setupMainPlaylistLoaderListeners_(),this.mainSegmentLoader_=new fl(fe(L,{segmentMetadataTrack:this.segmentMetadataTrack_,loaderType:"main"}),e),this.audioSegmentLoader_=new fl(fe(L,{loaderType:"audio"}),e),this.subtitleSegmentLoader_=new zw(fe(L,{loaderType:"vtt",featuresNativeTextTracks:this.tech_.featuresNativeTextTracks,loadVttJs:()=>new Promise((F,N)=>{function V(){n.off("vttjserror",J),F()}function J(){n.off("vttjsloaded",V),N()}n.one("vttjsloaded",V),n.one("vttjserror",J),n.addWebVttScript_()})}),e);const O=()=>this.mainSegmentLoader_.bandwidth;this.contentSteeringController_=new c2(this.vhs_.xhr,O),this.setupSegmentLoaderListeners_(),this.bufferBasedABR&&(this.mainPlaylistLoader_.one("loadedplaylist",()=>this.startABRTimer_()),this.tech_.on("pause",()=>this.stopABRTimer_()),this.tech_.on("play",()=>this.startABRTimer_())),p2.forEach(F=>{this[F+"_"]=g2.bind(this,F)}),this.logger_=Nt("pc"),this.triggeredFmp4Usage=!1,this.tech_.preload()==="none"?(this.loadOnPlay_=()=>{this.loadOnPlay_=null,this.mainPlaylistLoader_.load()},this.tech_.one("play",this.loadOnPlay_)):this.mainPlaylistLoader_.load(),this.timeToLoadedData__=-1,this.mainAppendsToLoadedData__=-1,this.audioAppendsToLoadedData__=-1;const U=this.tech_.preload()==="none"?"play":"loadstart";this.tech_.one(U,()=>{const F=Date.now();this.tech_.one("loadeddata",()=>{this.timeToLoadedData__=Date.now()-F,this.mainAppendsToLoadedData__=this.mainSegmentLoader_.mediaAppends,this.audioAppendsToLoadedData__=this.audioSegmentLoader_.mediaAppends})})}mainAppendsToLoadedData_(){return this.mainAppendsToLoadedData__}audioAppendsToLoadedData_(){return this.audioAppendsToLoadedData__}appendsToLoadedData_(){const e=this.mainAppendsToLoadedData_(),t=this.audioAppendsToLoadedData_();return e===-1||t===-1?-1:e+t}timeToLoadedData_(){return this.timeToLoadedData__}checkABR_(e="abr"){const t=this.selectPlaylist();t&&this.shouldSwitchToMedia_(t)&&this.switchMedia_(t,e)}switchMedia_(e,t,r){const n=this.media(),s=n&&(n.id||n.uri),a=e&&(e.id||e.uri);if(s&&s!==a){this.logger_(`switch media ${s} -> ${a} from ${t}`);const l={renditionInfo:{id:a,bandwidth:e.attributes.BANDWIDTH,resolution:e.attributes.RESOLUTION,codecs:e.attributes.CODECS},cause:t};this.trigger({type:"renditionselected",metadata:l}),this.tech_.trigger({type:"usage",name:`vhs-rendition-change-${t}`})}this.mainPlaylistLoader_.media(e,r)}switchMediaForDASHContentSteering_(){["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(e=>{const t=this.mediaTypes_[e],r=t?t.activeGroup():null,n=this.contentSteeringController_.getPathway();if(r&&n){const s=(r.length?r[0].playlists:r.playlists).filter(a=>a.attributes.serviceLocation===n);s.length&&this.mediaTypes_[e].activePlaylistLoader.media(s[0])}})}startABRTimer_(){this.stopABRTimer_(),this.abrTimer_=x.setInterval(()=>this.checkABR_(),250)}stopABRTimer_(){this.tech_.scrubbing&&this.tech_.scrubbing()||(x.clearInterval(this.abrTimer_),this.abrTimer_=null)}getAudioTrackPlaylists_(){const e=this.main(),t=e&&e.playlists||[];if(!e||!e.mediaGroups||!e.mediaGroups.AUDIO)return t;const r=e.mediaGroups.AUDIO,n=Object.keys(r);let s;if(Object.keys(this.mediaTypes_.AUDIO.groups).length)s=this.mediaTypes_.AUDIO.activeTrack();else{const l=r.main||n.length&&r[n[0]];for(const u in l)if(l[u].default){s={label:u};break}}if(!s)return t;const a=[];for(const l in r)if(r[l][s.label]){const u=r[l][s.label];if(u.playlists&&u.playlists.length)a.push.apply(a,u.playlists);else if(u.uri)a.push(u);else if(e.playlists.length)for(let p=0;p<e.playlists.length;p++){const g=e.playlists[p];g.attributes&&g.attributes.AUDIO&&g.attributes.AUDIO===l&&a.push(g)}}return a.length?a:t}setupMainPlaylistLoaderListeners_(){this.mainPlaylistLoader_.on("loadedmetadata",()=>{const e=this.mainPlaylistLoader_.media(),t=e.targetDuration*1.5*1e3;ll(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.media())?this.requestOptions_.timeout=0:this.requestOptions_.timeout=t,e.endList&&this.tech_.preload()!=="none"&&(this.mainSegmentLoader_.playlist(e,this.requestOptions_),this.mainSegmentLoader_.load()),l2({sourceType:this.sourceType_,segmentLoaders:{AUDIO:this.audioSegmentLoader_,SUBTITLES:this.subtitleSegmentLoader_,main:this.mainSegmentLoader_},tech:this.tech_,requestOptions:this.requestOptions_,mainPlaylistLoader:this.mainPlaylistLoader_,vhs:this.vhs_,main:this.main(),mediaTypes:this.mediaTypes_,excludePlaylist:this.excludePlaylist.bind(this)}),this.triggerPresenceUsage_(this.main(),e),this.setupFirstPlay(),!this.mediaTypes_.AUDIO.activePlaylistLoader||this.mediaTypes_.AUDIO.activePlaylistLoader.media()?this.trigger("selectedinitialmedia"):this.mediaTypes_.AUDIO.activePlaylistLoader.one("loadedmetadata",()=>{this.trigger("selectedinitialmedia")})}),this.mainPlaylistLoader_.on("loadedplaylist",()=>{this.loadOnPlay_&&this.tech_.off("play",this.loadOnPlay_);let e=this.mainPlaylistLoader_.media();if(!e){this.attachContentSteeringListeners_(),this.initContentSteeringController_(),this.excludeUnsupportedVariants_();let t;if(this.enableLowInitialPlaylist&&(t=this.selectInitialPlaylist()),t||(t=this.selectPlaylist()),!t||!this.shouldSwitchToMedia_(t)||(this.initialMedia_=t,this.switchMedia_(this.initialMedia_,"initial"),!(this.sourceType_==="vhs-json"&&this.initialMedia_.segments)))return;e=this.initialMedia_}this.handleUpdatedMediaPlaylist(e)}),this.mainPlaylistLoader_.on("error",()=>{const e=this.mainPlaylistLoader_.error;this.excludePlaylist({playlistToExclude:e.playlist,error:e})}),this.mainPlaylistLoader_.on("mediachanging",()=>{this.mainSegmentLoader_.abort(),this.mainSegmentLoader_.pause()}),this.mainPlaylistLoader_.on("mediachange",()=>{const e=this.mainPlaylistLoader_.media(),t=e.targetDuration*1.5*1e3;ll(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.media())?this.requestOptions_.timeout=0:this.requestOptions_.timeout=t,this.sourceType_==="dash"&&this.mainPlaylistLoader_.isPaused&&this.mainPlaylistLoader_.load(),this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.playlist(e,this.requestOptions_),this.waitingForFastQualityPlaylistReceived_?this.runFastQualitySwitch_():this.mainSegmentLoader_.load(),this.tech_.trigger({type:"mediachange",bubbles:!0})}),this.mainPlaylistLoader_.on("playlistunchanged",()=>{const e=this.mainPlaylistLoader_.media();e.lastExcludeReason_!=="playlist-unchanged"&&this.stuckAtPlaylistEnd_(e)&&(this.excludePlaylist({error:{message:"Playlist no longer updating.",reason:"playlist-unchanged"}}),this.tech_.trigger("playliststuck"))}),this.mainPlaylistLoader_.on("renditiondisabled",()=>{this.tech_.trigger({type:"usage",name:"vhs-rendition-disabled"})}),this.mainPlaylistLoader_.on("renditionenabled",()=>{this.tech_.trigger({type:"usage",name:"vhs-rendition-enabled"})}),["manifestrequeststart","manifestrequestcomplete","manifestparsestart","manifestparsecomplete","playlistrequeststart","playlistrequestcomplete","playlistparsestart","playlistparsecomplete","renditiondisabled","renditionenabled"].forEach(e=>{this.mainPlaylistLoader_.on(e,t=>{this.player_.trigger(Ve({},t))})})}handleUpdatedMediaPlaylist(e){this.useCueTags_&&this.updateAdCues_(e),this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.playlist(e,this.requestOptions_),this.waitingForFastQualityPlaylistReceived_&&this.runFastQualitySwitch_(),this.updateDuration(!e.endList),this.tech_.paused()||(this.mainSegmentLoader_.load(),this.audioSegmentLoader_&&this.audioSegmentLoader_.load())}triggerPresenceUsage_(e,t){const r=e.mediaGroups||{};let n=!0;const s=Object.keys(r.AUDIO);for(const a in r.AUDIO)for(const l in r.AUDIO[a])r.AUDIO[a][l].uri||(n=!1);n&&this.tech_.trigger({type:"usage",name:"vhs-demuxed"}),Object.keys(r.SUBTITLES).length&&this.tech_.trigger({type:"usage",name:"vhs-webvtt"}),Pi.Playlist.isAes(t)&&this.tech_.trigger({type:"usage",name:"vhs-aes"}),s.length&&Object.keys(r.AUDIO[s[0]]).length>1&&this.tech_.trigger({type:"usage",name:"vhs-alternate-audio"}),this.useCueTags_&&this.tech_.trigger({type:"usage",name:"vhs-playlist-cue-tags"})}shouldSwitchToMedia_(e){const t=this.mainPlaylistLoader_.media()||this.mainPlaylistLoader_.pendingMedia_,r=this.tech_.currentTime(),n=this.bufferLowWaterLine(),s=this.bufferHighWaterLine(),a=this.tech_.buffered();return m2({buffered:a,currentTime:r,currentPlaylist:t,nextPlaylist:e,bufferLowWaterLine:n,bufferHighWaterLine:s,duration:this.duration(),bufferBasedABR:this.bufferBasedABR,log:this.logger_})}setupSegmentLoaderListeners_(){this.mainSegmentLoader_.on("bandwidthupdate",()=>{this.checkABR_("bandwidthupdate"),this.tech_.trigger("bandwidthupdate")}),this.mainSegmentLoader_.on("timeout",()=>{this.bufferBasedABR&&this.mainSegmentLoader_.load()}),this.bufferBasedABR||this.mainSegmentLoader_.on("progress",()=>{this.trigger("progress")}),this.mainSegmentLoader_.on("error",()=>{const t=this.mainSegmentLoader_.error();this.excludePlaylist({playlistToExclude:t.playlist,error:t})}),this.mainSegmentLoader_.on("appenderror",()=>{this.error=this.mainSegmentLoader_.error_,this.trigger("error")}),this.mainSegmentLoader_.on("syncinfoupdate",()=>{this.onSyncInfoUpdate_()}),this.mainSegmentLoader_.on("timestampoffset",()=>{this.tech_.trigger({type:"usage",name:"vhs-timestamp-offset"})}),this.audioSegmentLoader_.on("syncinfoupdate",()=>{this.onSyncInfoUpdate_()}),this.audioSegmentLoader_.on("appenderror",()=>{this.error=this.audioSegmentLoader_.error_,this.trigger("error")}),this.mainSegmentLoader_.on("ended",()=>{this.logger_("main segment loader ended"),this.onEndOfStream()}),this.timelineChangeController_.on("audioTimelineBehind",()=>{const t=this.audioSegmentLoader_.pendingSegment_;if(!t||!t.segment||!t.segment.syncInfo)return;const r=t.segment.syncInfo.end+.01;this.tech_.setCurrentTime(r)}),this.timelineChangeController_.on("fixBadTimelineChange",()=>{this.logger_("Fix bad timeline change. Restarting al segment loaders..."),this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.resetEverything(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.pause(),this.audioSegmentLoader_.resetEverything()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.pause(),this.subtitleSegmentLoader_.resetEverything()),this.load()}),this.mainSegmentLoader_.on("earlyabort",t=>{this.bufferBasedABR||(this.delegateLoaders_("all",["abort"]),this.excludePlaylist({error:{message:"Aborted early because there isn't enough bandwidth to complete the request without rebuffering."},playlistExclusionDuration:h2}))});const e=()=>{if(!this.sourceUpdater_.hasCreatedSourceBuffers())return this.tryToCreateSourceBuffers_();const t=this.getCodecsOrExclude_();t&&this.sourceUpdater_.addOrChangeSourceBuffers(t)};this.mainSegmentLoader_.on("trackinfo",e),this.audioSegmentLoader_.on("trackinfo",e),this.mainSegmentLoader_.on("fmp4",()=>{this.triggeredFmp4Usage||(this.tech_.trigger({type:"usage",name:"vhs-fmp4"}),this.triggeredFmp4Usage=!0)}),this.audioSegmentLoader_.on("fmp4",()=>{this.triggeredFmp4Usage||(this.tech_.trigger({type:"usage",name:"vhs-fmp4"}),this.triggeredFmp4Usage=!0)}),this.audioSegmentLoader_.on("ended",()=>{this.logger_("audioSegmentLoader ended"),this.onEndOfStream()}),["segmentselected","segmentloadstart","segmentloaded","segmentkeyloadstart","segmentkeyloadcomplete","segmentdecryptionstart","segmentdecryptioncomplete","segmenttransmuxingstart","segmenttransmuxingcomplete","segmenttransmuxingtrackinfoavailable","segmenttransmuxingtiminginfoavailable","segmentappendstart","appendsdone","bandwidthupdated","timelinechange","codecschange"].forEach(t=>{this.mainSegmentLoader_.on(t,r=>{this.player_.trigger(Ve({},r))}),this.audioSegmentLoader_.on(t,r=>{this.player_.trigger(Ve({},r))}),this.subtitleSegmentLoader_.on(t,r=>{this.player_.trigger(Ve({},r))})})}mediaSecondsLoaded_(){return Math.max(this.audioSegmentLoader_.mediaSecondsLoaded+this.mainSegmentLoader_.mediaSecondsLoaded)}load(){this.mainSegmentLoader_.load(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.load(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.load()}pause(){this.mainSegmentLoader_.pause(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.pause(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.pause()}fastQualityChange_(e=this.selectPlaylist()){if(e&&e===this.mainPlaylistLoader_.media()){this.logger_("skipping fastQualityChange because new media is same as old");return}this.switchMedia_(e,"fast-quality"),this.waitingForFastQualityPlaylistReceived_=!0}runFastQualitySwitch_(){this.waitingForFastQualityPlaylistReceived_=!1,this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.resetEverything(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.pause(),this.audioSegmentLoader_.resetEverything()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.pause(),this.subtitleSegmentLoader_.resetEverything()),this.load()}play(){if(this.setupFirstPlay())return;this.tech_.ended()&&this.tech_.setCurrentTime(0),this.hasPlayed_&&this.load();const e=this.tech_.seekable();if(this.tech_.duration()===1/0&&this.tech_.currentTime()<e.start(0))return this.tech_.setCurrentTime(e.end(e.length-1))}setupFirstPlay(){const e=this.mainPlaylistLoader_.media();if(!e||this.tech_.paused()||this.hasPlayed_)return!1;if(!e.endList||e.start){const t=this.seekable();if(!t.length)return!1;const r=t.end(0);let n=r;if(e.start){const s=e.start.timeOffset;s<0?n=Math.max(r+s,t.start(0)):n=Math.min(r,s)}this.trigger("firstplay"),this.tech_.setCurrentTime(n)}return this.hasPlayed_=!0,this.load(),!0}handleSourceOpen_(){if(this.tryToCreateSourceBuffers_(),this.tech_.autoplay()){const e=this.tech_.play();typeof e<"u"&&typeof e.then=="function"&&e.then(null,t=>{})}this.trigger("sourceopen")}handleSourceEnded_(){if(!this.inbandTextTracks_.metadataTrack_)return;const e=this.inbandTextTracks_.metadataTrack_.cues;if(!e||!e.length)return;const t=this.duration();e[e.length-1].endTime=isNaN(t)||Math.abs(t)===1/0?Number.MAX_VALUE:t}handleDurationChange_(){this.tech_.trigger("durationchange")}onEndOfStream(){let e=this.mainSegmentLoader_.ended_;if(this.mediaTypes_.AUDIO.activePlaylistLoader){const t=this.mainSegmentLoader_.getCurrentMediaInfo_();!t||t.hasVideo?e=e&&this.audioSegmentLoader_.ended_:e=this.audioSegmentLoader_.ended_}e&&(this.stopABRTimer_(),this.sourceUpdater_.endOfStream())}stuckAtPlaylistEnd_(e){if(!this.seekable().length)return!1;const t=this.syncController_.getExpiredTime(e,this.duration());if(t===null)return!1;const r=Pi.Playlist.playlistEnd(e,t),n=this.tech_.currentTime(),s=this.tech_.buffered();if(!s.length)return r-n<=ei;const a=s.end(s.length-1);return a-n<=ei&&r-a<=ei}excludePlaylist({playlistToExclude:e=this.mainPlaylistLoader_.media(),error:t={},playlistExclusionDuration:r}){if(e=e||this.mainPlaylistLoader_.media(),r=r||t.playlistExclusionDuration||this.playlistExclusionDuration,!e){this.error=t,this.mediaSource.readyState!=="open"?this.trigger("error"):this.sourceUpdater_.endOfStream("network");return}e.playlistErrors_++;const n=this.mainPlaylistLoader_.main.playlists,s=n.filter(Ga),a=s.length===1&&s[0]===e;if(n.length===1&&r!==1/0)return B.log.warn(`Problem encountered with playlist ${e.id}. Trying again since it is the only playlist.`),this.tech_.trigger("retryplaylist"),this.mainPlaylistLoader_.load(a);if(a){if(this.main().contentSteering){const C=this.pathwayAttribute_(e),v=this.contentSteeringController_.steeringManifest.ttl*1e3;this.contentSteeringController_.excludePathway(C),this.excludeThenChangePathway_(),setTimeout(()=>{this.contentSteeringController_.addAvailablePathway(C)},v);return}let w=!1;n.forEach(C=>{if(C===e)return;const v=C.excludeUntil;typeof v<"u"&&v!==1/0&&(w=!0,delete C.excludeUntil)}),w&&(B.log.warn("Removing other playlists from the exclusion list because the last rendition is about to be excluded."),this.tech_.trigger("retryplaylist"))}let l;e.playlistErrors_>this.maxPlaylistRetries?l=1/0:l=Date.now()+r*1e3,e.excludeUntil=l,t.reason&&(e.lastExcludeReason_=t.reason),this.tech_.trigger("excludeplaylist"),this.tech_.trigger({type:"usage",name:"vhs-rendition-excluded"});const u=this.selectPlaylist();if(!u){this.error="Playback cannot continue. No available working or supported playlists.",this.trigger("error");return}const p=t.internal?this.logger_:B.log.warn,g=t.message?" "+t.message:"";p(`${t.internal?"Internal problem":"Problem"} encountered with playlist ${e.id}.${g} Switching to playlist ${u.id}.`),u.attributes.AUDIO!==e.attributes.AUDIO&&this.delegateLoaders_("audio",["abort","pause"]),u.attributes.SUBTITLES!==e.attributes.SUBTITLES&&this.delegateLoaders_("subtitle",["abort","pause"]),this.delegateLoaders_("main",["abort","pause"]);const b=u.targetDuration/2*1e3||5*1e3,S=typeof u.lastRequest=="number"&&Date.now()-u.lastRequest<=b;return this.switchMedia_(u,"exclude",a||S)}pauseLoading(){this.delegateLoaders_("all",["abort","pause"]),this.stopABRTimer_()}delegateLoaders_(e,t){const r=[],n=e==="all";(n||e==="main")&&r.push(this.mainPlaylistLoader_);const s=[];(n||e==="audio")&&s.push("AUDIO"),(n||e==="subtitle")&&(s.push("CLOSED-CAPTIONS"),s.push("SUBTITLES")),s.forEach(a=>{const l=this.mediaTypes_[a]&&this.mediaTypes_[a].activePlaylistLoader;l&&r.push(l)}),["main","audio","subtitle"].forEach(a=>{const l=this[`${a}SegmentLoader_`];l&&(e===a||e==="all")&&r.push(l)}),r.forEach(a=>t.forEach(l=>{typeof a[l]=="function"&&a[l]()}))}setCurrentTime(e){const t=Sr(this.tech_.buffered(),e);if(!(this.mainPlaylistLoader_&&this.mainPlaylistLoader_.media())||!this.mainPlaylistLoader_.media().segments)return 0;if(t&&t.length)return e;this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.resetEverything(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.pause(),this.audioSegmentLoader_.resetEverything()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.pause(),this.subtitleSegmentLoader_.resetEverything()),this.load()}duration(){if(!this.mainPlaylistLoader_)return 0;const e=this.mainPlaylistLoader_.media();return e?e.endList?this.mediaSource?this.mediaSource.duration:Pi.Playlist.duration(e):1/0:0}seekable(){return this.seekable_}getSeekableRange_(e,t){const r=e.media();if(!r)return null;const n=this.syncController_.getMediaSequenceSync(t);if(n&&n.isReliable){const l=n.start,u=n.end;if(!isFinite(l)||!isFinite(u))return null;const p=Pi.Playlist.liveEdgeDelay(this.mainPlaylistLoader_.main,r),g=Math.max(0,u-p);return g<l?null:it([[l,g]])}const s=this.syncController_.getExpiredTime(r,this.duration());if(s===null)return null;const a=Pi.Playlist.seekable(r,s,Pi.Playlist.liveEdgeDelay(this.mainPlaylistLoader_.main,r));return a.length?a:null}computeFinalSeekable_(e,t){if(!t)return e;const r=e.start(0),n=e.end(0),s=t.start(0),a=t.end(0);return s>n||r>a?e:it([[Math.max(r,s),Math.min(n,a)]])}onSyncInfoUpdate_(){if(!this.mainPlaylistLoader_)return;const e=this.getSeekableRange_(this.mainPlaylistLoader_,"main");if(!e)return;let t;if(this.mediaTypes_.AUDIO.activePlaylistLoader&&(t=this.getSeekableRange_(this.mediaTypes_.AUDIO.activePlaylistLoader,"audio"),!t))return;const r=this.seekable_;if(this.seekable_=this.computeFinalSeekable_(e,t),!this.seekable_||r&&r.length&&this.seekable_.length&&r.start(0)===this.seekable_.start(0)&&r.end(0)===this.seekable_.end(0))return;this.logger_(`seekable updated [${am(this.seekable_)}]`);const n={seekableRanges:this.seekable_};this.trigger({type:"seekablerangeschanged",metadata:n}),this.tech_.trigger("seekablechanged")}updateDuration(e){if(this.updateDuration_&&(this.mediaSource.removeEventListener("sourceopen",this.updateDuration_),this.updateDuration_=null),this.mediaSource.readyState!=="open"){this.updateDuration_=this.updateDuration.bind(this,e),this.mediaSource.addEventListener("sourceopen",this.updateDuration_);return}if(e){const n=this.seekable();if(!n.length)return;(isNaN(this.mediaSource.duration)||this.mediaSource.duration<n.end(n.length-1))&&this.sourceUpdater_.setDuration(n.end(n.length-1));return}const t=this.tech_.buffered();let r=Pi.Playlist.duration(this.mainPlaylistLoader_.media());t.length>0&&(r=Math.max(r,t.end(t.length-1))),this.mediaSource.duration!==r&&this.sourceUpdater_.setDuration(r)}dispose(){this.trigger("dispose"),this.decrypter_.terminate(),this.mainPlaylistLoader_.dispose(),this.mainSegmentLoader_.dispose(),this.contentSteeringController_.dispose(),this.keyStatusMap_.clear(),this.loadOnPlay_&&this.tech_.off("play",this.loadOnPlay_),["AUDIO","SUBTITLES"].forEach(e=>{const t=this.mediaTypes_[e].groups;for(const r in t)t[r].forEach(n=>{n.playlistLoader&&n.playlistLoader.dispose()})}),this.audioSegmentLoader_.dispose(),this.subtitleSegmentLoader_.dispose(),this.sourceUpdater_.dispose(),this.timelineChangeController_.dispose(),this.stopABRTimer_(),this.updateDuration_&&this.mediaSource.removeEventListener("sourceopen",this.updateDuration_),this.mediaSource.removeEventListener("durationchange",this.handleDurationChange_),this.mediaSource.removeEventListener("sourceopen",this.handleSourceOpen_),this.mediaSource.removeEventListener("sourceended",this.handleSourceEnded_),this.off()}main(){return this.mainPlaylistLoader_.main}media(){return this.mainPlaylistLoader_.media()||this.initialMedia_}areMediaTypesKnown_(){const e=!!this.mediaTypes_.AUDIO.activePlaylistLoader,t=!!this.mainSegmentLoader_.getCurrentMediaInfo_(),r=e?!!this.audioSegmentLoader_.getCurrentMediaInfo_():!0;return!(!t||!r)}getCodecsOrExclude_(){const e={main:this.mainSegmentLoader_.getCurrentMediaInfo_()||{},audio:this.audioSegmentLoader_.getCurrentMediaInfo_()||{}},t=this.mainSegmentLoader_.getPendingSegmentPlaylist()||this.media();e.video=e.main;const r=Un(this.main(),t),n={},s=!!this.mediaTypes_.AUDIO.activePlaylistLoader;if(e.main.hasVideo&&(n.video=r.video||e.main.videoCodec||aT),e.main.isMuxed&&(n.video+=`,${r.audio||e.main.audioCodec||ad}`),(e.main.hasAudio&&!e.main.isMuxed||e.audio.hasAudio||s)&&(n.audio=r.audio||e.main.audioCodec||e.audio.audioCodec||ad,e.audio.isFmp4=e.main.hasAudio&&!e.main.isMuxed?e.main.isFmp4:e.audio.isFmp4),!n.audio&&!n.video){this.excludePlaylist({playlistToExclude:t,error:{message:"Could not determine codecs for playlist."},playlistExclusionDuration:1/0});return}const a=(p,g)=>p?Dn(g,this.usingManagedMediaSource_):ko(g),l={};let u;if(["video","audio"].forEach(function(p){if(n.hasOwnProperty(p)&&!a(e[p].isFmp4,n[p])){const g=e[p].isFmp4?"browser":"muxer";l[g]=l[g]||[],l[g].push(n[p]),p==="audio"&&(u=g)}}),s&&u&&t.attributes.AUDIO){const p=t.attributes.AUDIO;this.main().playlists.forEach(g=>{(g.attributes&&g.attributes.AUDIO)===p&&g!==t&&(g.excludeUntil=1/0)}),this.logger_(`excluding audio group ${p} as ${u} does not support codec(s): "${n.audio}"`)}if(Object.keys(l).length){const p=Object.keys(l).reduce((g,b)=>(g&&(g+=", "),g+=`${b} does not support codec(s): "${l[b].join(",")}"`,g),"")+".";this.excludePlaylist({playlistToExclude:t,error:{internal:!0,message:p},playlistExclusionDuration:1/0});return}if(this.sourceUpdater_.hasCreatedSourceBuffers()&&!this.sourceUpdater_.canChangeType()){const p=[];if(["video","audio"].forEach(g=>{const b=(Kt(this.sourceUpdater_.codecs[g]||"")[0]||{}).type,S=(Kt(n[g]||"")[0]||{}).type;b&&S&&b.toLowerCase()!==S.toLowerCase()&&p.push(`"${this.sourceUpdater_.codecs[g]}" -> "${n[g]}"`)}),p.length){this.excludePlaylist({playlistToExclude:t,error:{message:`Codec switching not supported: ${p.join(", ")}.`,internal:!0},playlistExclusionDuration:1/0});return}}return n}tryToCreateSourceBuffers_(){if(this.mediaSource.readyState!=="open"||this.sourceUpdater_.hasCreatedSourceBuffers()||!this.areMediaTypesKnown_())return;const e=this.getCodecsOrExclude_();if(!e)return;this.sourceUpdater_.createSourceBuffers(e);const t=[e.video,e.audio].filter(Boolean).join(",");this.excludeIncompatibleVariants_(t)}excludeUnsupportedVariants_(){const e=this.main().playlists,t=[];Object.keys(e).forEach(r=>{const n=e[r];if(t.indexOf(n.id)!==-1)return;t.push(n.id);const s=Un(this.main,n),a=[];s.audio&&!ko(s.audio)&&!Dn(s.audio,this.usingManagedMediaSource_)&&a.push(`audio codec ${s.audio}`),s.video&&!ko(s.video)&&!Dn(s.video,this.usingManagedMediaSource_)&&a.push(`video codec ${s.video}`),s.text&&s.text==="stpp.ttml.im1t"&&a.push(`text codec ${s.text}`),a.length&&(n.excludeUntil=1/0,this.logger_(`excluding ${n.id} for unsupported: ${a.join(", ")}`))})}excludeIncompatibleVariants_(e){const t=[],r=this.main().playlists,n=fa(Kt(e)),s=Jd(n),a=n.video&&Kt(n.video)[0]||null,l=n.audio&&Kt(n.audio)[0]||null;Object.keys(r).forEach(u=>{const p=r[u];if(t.indexOf(p.id)!==-1||p.excludeUntil===1/0)return;t.push(p.id);const g=[],b=Un(this.mainPlaylistLoader_.main,p),S=Jd(b);if(!(!b.audio&&!b.video)){if(S!==s&&g.push(`codec count "${S}" !== "${s}"`),!this.sourceUpdater_.canChangeType()){const w=b.video&&Kt(b.video)[0]||null,C=b.audio&&Kt(b.audio)[0]||null;w&&a&&w.type.toLowerCase()!==a.type.toLowerCase()&&g.push(`video codec "${w.type}" !== "${a.type}"`),C&&l&&C.type.toLowerCase()!==l.type.toLowerCase()&&g.push(`audio codec "${C.type}" !== "${l.type}"`)}g.length&&(p.excludeUntil=1/0,this.logger_(`excluding ${p.id}: ${g.join(" && ")}`))}})}updateAdCues_(e){let t=0;const r=this.seekable();r.length&&(t=r.start(0)),Gw(e,this.cueTagsTrack_,t)}goalBufferLength(){const e=this.tech_.currentTime(),t=Xe.GOAL_BUFFER_LENGTH,r=Xe.GOAL_BUFFER_LENGTH_RATE,n=Math.max(t,Xe.MAX_GOAL_BUFFER_LENGTH);return Math.min(t+e*r,n)}bufferLowWaterLine(){const e=this.tech_.currentTime(),t=Xe.BUFFER_LOW_WATER_LINE,r=Xe.BUFFER_LOW_WATER_LINE_RATE,n=Math.max(t,Xe.MAX_BUFFER_LOW_WATER_LINE),s=Math.max(t,Xe.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE);return Math.min(t+e*r,this.bufferBasedABR?s:n)}bufferHighWaterLine(){return Xe.BUFFER_HIGH_WATER_LINE}addDateRangesToTextTrack_(e){th(this.inbandTextTracks_,"com.apple.streaming",this.tech_),Cw({inbandTextTracks:this.inbandTextTracks_,dateRanges:e})}addMetadataToTextTrack(e,t,r){const n=this.sourceUpdater_.videoBuffer?this.sourceUpdater_.videoTimestampOffset():this.sourceUpdater_.audioTimestampOffset();th(this.inbandTextTracks_,e,this.tech_),Ew({inbandTextTracks:this.inbandTextTracks_,metadataArray:t,timestampOffset:n,videoDuration:r})}pathwayAttribute_(e){return e.attributes["PATHWAY-ID"]||e.attributes.serviceLocation}initContentSteeringController_(){const e=this.main();if(e.contentSteering){for(const t of e.playlists)this.contentSteeringController_.addAvailablePathway(this.pathwayAttribute_(t));if(this.contentSteeringController_.assignTagProperties(e.uri,e.contentSteering),this.contentSteeringController_.queryBeforeStart){this.contentSteeringController_.requestSteeringManifest(!0);return}this.tech_.one("canplay",()=>{this.contentSteeringController_.requestSteeringManifest()})}}resetContentSteeringController_(){this.contentSteeringController_.clearAvailablePathways(),this.contentSteeringController_.dispose(),this.initContentSteeringController_()}attachContentSteeringListeners_(){this.contentSteeringController_.on("content-steering",this.excludeThenChangePathway_.bind(this)),["contentsteeringloadstart","contentsteeringloadcomplete","contentsteeringparsed"].forEach(e=>{this.contentSteeringController_.on(e,t=>{this.trigger(Ve({},t))})}),this.sourceType_==="dash"&&this.mainPlaylistLoader_.on("loadedplaylist",()=>{const e=this.main();(this.contentSteeringController_.didDASHTagChange(e.uri,e.contentSteering)||(()=>{const t=this.contentSteeringController_.getAvailablePathways(),r=[];for(const n of e.playlists){const s=n.attributes.serviceLocation;if(s&&(r.push(s),!t.has(s)))return!0}return!!(!r.length&&t.size)})())&&this.resetContentSteeringController_()})}excludeThenChangePathway_(){const e=this.contentSteeringController_.getPathway();if(!e)return;this.handlePathwayClones_();const t=this.main().playlists,r=new Set;let n=!1;Object.keys(t).forEach(s=>{const a=t[s],l=this.pathwayAttribute_(a),u=l&&e!==l;a.excludeUntil===1/0&&a.lastExcludeReason_==="content-steering"&&!u&&(delete a.excludeUntil,delete a.lastExcludeReason_,n=!0);const p=!a.excludeUntil&&a.excludeUntil!==1/0;!r.has(a.id)&&u&&p&&(r.add(a.id),a.excludeUntil=1/0,a.lastExcludeReason_="content-steering",this.logger_(`excluding ${a.id} for ${a.lastExcludeReason_}`))}),this.contentSteeringController_.manifestType_==="DASH"&&Object.keys(this.mediaTypes_).forEach(s=>{const a=this.mediaTypes_[s];if(a.activePlaylistLoader){const l=a.activePlaylistLoader.media_;l&&l.attributes.serviceLocation!==e&&(n=!0)}}),n&&this.changeSegmentPathway_()}handlePathwayClones_(){const e=this.main().playlists,t=this.contentSteeringController_.currentPathwayClones,r=this.contentSteeringController_.nextPathwayClones;if(t&&t.size||r&&r.size){for(const[n,s]of t.entries())r.get(n)||(this.mainPlaylistLoader_.updateOrDeleteClone(s),this.contentSteeringController_.excludePathway(n));for(const[n,s]of r.entries()){const a=t.get(n);if(!a){e.filter(l=>l.attributes["PATHWAY-ID"]===s["BASE-ID"]).forEach(l=>{this.mainPlaylistLoader_.addClonePathway(s,l)}),this.contentSteeringController_.addAvailablePathway(n);continue}this.equalPathwayClones_(a,s)||(this.mainPlaylistLoader_.updateOrDeleteClone(s,!0),this.contentSteeringController_.addAvailablePathway(n))}this.contentSteeringController_.currentPathwayClones=new Map(JSON.parse(JSON.stringify([...r])))}}equalPathwayClones_(e,t){if(e["BASE-ID"]!==t["BASE-ID"]||e.ID!==t.ID||e["URI-REPLACEMENT"].HOST!==t["URI-REPLACEMENT"].HOST)return!1;const r=e["URI-REPLACEMENT"].PARAMS,n=t["URI-REPLACEMENT"].PARAMS;for(const s in r)if(r[s]!==n[s])return!1;for(const s in n)if(r[s]!==n[s])return!1;return!0}changeSegmentPathway_(){const e=this.selectPlaylist();this.pauseLoading(),this.contentSteeringController_.manifestType_==="DASH"&&this.switchMediaForDASHContentSteering_(),this.switchMedia_(e,"content-steering")}excludeNonUsablePlaylistsByKeyId_(){if(!this.mainPlaylistLoader_||!this.mainPlaylistLoader_.main)return;let e=0;const t="non-usable";this.mainPlaylistLoader_.main.playlists.forEach(r=>{const n=this.mainPlaylistLoader_.getKeyIdSet(r);!n||!n.size||n.forEach(s=>{const a="usable",l=this.keyStatusMap_.has(s)&&this.keyStatusMap_.get(s)===a,u=r.lastExcludeReason_===t&&r.excludeUntil===1/0;l?l&&u&&(delete r.excludeUntil,delete r.lastExcludeReason_,this.logger_(`enabling playlist ${r.id} because key ID ${s} is ${a}`)):(r.excludeUntil!==1/0&&r.lastExcludeReason_!==t&&(r.excludeUntil=1/0,r.lastExcludeReason_=t,this.logger_(`excluding playlist ${r.id} because the key ID ${s} doesn't exist in the keyStatusMap or is not ${a}`)),e++)})}),e>=this.mainPlaylistLoader_.main.playlists.length&&this.mainPlaylistLoader_.main.playlists.forEach(r=>{const n=r&&r.attributes&&r.attributes.RESOLUTION&&r.attributes.RESOLUTION.height<720,s=r.excludeUntil===1/0&&r.lastExcludeReason_===t;n&&s&&(delete r.excludeUntil,B.log.warn(`enabling non-HD playlist ${r.id} because all playlists were excluded due to ${t} key IDs`))})}addKeyStatus_(e,t){const r=(typeof e=="string"?e:Vw(e)).slice(0,32).toLowerCase();this.logger_(`KeyStatus '${t}' with key ID ${r} added to the keyStatusMap`),this.keyStatusMap_.set(r,t)}updatePlaylistByKeyStatus(e,t){this.addKeyStatus_(e,t),this.waitingForFastQualityPlaylistReceived_||this.excludeNonUsableThenChangePlaylist_(),this.mainPlaylistLoader_.off("loadedplaylist",this.excludeNonUsableThenChangePlaylist_.bind(this)),this.mainPlaylistLoader_.on("loadedplaylist",this.excludeNonUsableThenChangePlaylist_.bind(this))}excludeNonUsableThenChangePlaylist_(){this.excludeNonUsablePlaylistsByKeyId_(),this.fastQualityChange_()}}const y2=(i,e,t)=>r=>{const n=i.main.playlists[e],s=Su(n),a=Ga(n);if(typeof r>"u")return a;r?delete n.disabled:n.disabled=!0;const l={renditionInfo:{id:e,bandwidth:n.attributes.BANDWIDTH,resolution:n.attributes.RESOLUTION,codecs:n.attributes.CODECS},cause:"fast-quality"};return r!==a&&!s&&(r?(t(n),i.trigger({type:"renditionenabled",metadata:l})):i.trigger({type:"renditiondisabled",metadata:l})),r};class _2{constructor(e,t,r){const{playlistController_:n}=e,s=n.fastQualityChange_.bind(n);if(t.attributes){const a=t.attributes.RESOLUTION;this.width=a&&a.width,this.height=a&&a.height,this.bandwidth=t.attributes.BANDWIDTH,this.frameRate=t.attributes["FRAME-RATE"]}this.codecs=Un(n.main(),t),this.playlist=t,this.id=r,this.enabled=y2(e.playlists,t.id,s)}}const b2=function(i){i.representations=()=>{const e=i.playlistController_.main(),t=ts(e)?i.playlistController_.getAudioTrackPlaylists_():e.playlists;return t?t.filter(r=>!Su(r)).map((r,n)=>new _2(i,r,r.id)):[]}},hh=["seeking","seeked","pause","playing","error"];class v2 extends B.EventTarget{constructor(e){super(),this.playlistController_=e.playlistController,this.tech_=e.tech,this.seekable=e.seekable,this.allowSeeksWithinUnsafeLiveWindow=e.allowSeeksWithinUnsafeLiveWindow,this.liveRangeSafeTimeDelta=e.liveRangeSafeTimeDelta,this.media=e.media,this.playedRanges_=[],this.consecutiveUpdates=0,this.lastRecordedTime=null,this.checkCurrentTimeTimeout_=null,this.logger_=Nt("PlaybackWatcher"),this.logger_("initialize");const t=()=>this.monitorCurrentTime_(),r=()=>this.monitorCurrentTime_(),n=()=>this.techWaiting_(),s=()=>this.resetTimeUpdate_(),a=this.playlistController_,l=["main","subtitle","audio"],u={};l.forEach(g=>{u[g]={reset:()=>this.resetSegmentDownloads_(g),updateend:()=>this.checkSegmentDownloads_(g)},a[`${g}SegmentLoader_`].on("appendsdone",u[g].updateend),a[`${g}SegmentLoader_`].on("playlistupdate",u[g].reset),this.tech_.on(["seeked","seeking"],u[g].reset)});const p=g=>{["main","audio"].forEach(b=>{a[`${b}SegmentLoader_`][g]("appended",this.seekingAppendCheck_)})};this.seekingAppendCheck_=()=>{this.fixesBadSeeks_()&&(this.consecutiveUpdates=0,this.lastRecordedTime=this.tech_.currentTime(),p("off"))},this.clearSeekingAppendCheck_=()=>p("off"),this.watchForBadSeeking_=()=>{this.clearSeekingAppendCheck_(),p("on")},this.tech_.on("seeked",this.clearSeekingAppendCheck_),this.tech_.on("seeking",this.watchForBadSeeking_),this.tech_.on("waiting",n),this.tech_.on(hh,s),this.tech_.on("canplay",r),this.tech_.one("play",t),this.dispose=()=>{this.clearSeekingAppendCheck_(),this.logger_("dispose"),this.tech_.off("waiting",n),this.tech_.off(hh,s),this.tech_.off("canplay",r),this.tech_.off("play",t),this.tech_.off("seeking",this.watchForBadSeeking_),this.tech_.off("seeked",this.clearSeekingAppendCheck_),l.forEach(g=>{a[`${g}SegmentLoader_`].off("appendsdone",u[g].updateend),a[`${g}SegmentLoader_`].off("playlistupdate",u[g].reset),this.tech_.off(["seeked","seeking"],u[g].reset)}),this.checkCurrentTimeTimeout_&&x.clearTimeout(this.checkCurrentTimeTimeout_),this.resetTimeUpdate_()}}monitorCurrentTime_(){this.checkCurrentTime_(),this.checkCurrentTimeTimeout_&&x.clearTimeout(this.checkCurrentTimeTimeout_),this.checkCurrentTimeTimeout_=x.setTimeout(this.monitorCurrentTime_.bind(this),250)}resetSegmentDownloads_(e){const t=this.playlistController_[`${e}SegmentLoader_`];this[`${e}StalledDownloads_`]>0&&this.logger_(`resetting possible stalled download count for ${e} loader`),this[`${e}StalledDownloads_`]=0,this[`${e}Buffered_`]=t.buffered_()}checkSegmentDownloads_(e){const t=this.playlistController_,r=t[`${e}SegmentLoader_`],n=r.buffered_(),s=nE(this[`${e}Buffered_`],n);if(this[`${e}Buffered_`]=n,s){const a={bufferedRanges:n};t.trigger({type:"bufferedrangeschanged",metadata:a}),this.resetSegmentDownloads_(e);return}this[`${e}StalledDownloads_`]++,this.logger_(`found #${this[`${e}StalledDownloads_`]} ${e} appends that did not increase buffer (possible stalled download)`,{playlistId:r.playlist_&&r.playlist_.id,buffered:Qi(n)}),!(this[`${e}StalledDownloads_`]<10)&&(this.logger_(`${e} loader stalled download exclusion`),this.resetSegmentDownloads_(e),this.tech_.trigger({type:"usage",name:`vhs-${e}-download-exclusion`}),e!=="subtitle"&&t.excludePlaylist({error:{message:`Excessive ${e} segment downloading detected.`},playlistExclusionDuration:1/0}))}checkCurrentTime_(){if(this.tech_.paused()||this.tech_.seeking())return;const e=this.tech_.currentTime(),t=this.tech_.buffered();if(this.lastRecordedTime===e&&(!t.length||e+ei>=t.end(t.length-1)))return this.techWaiting_();if(this.consecutiveUpdates>=5&&e===this.lastRecordedTime)this.consecutiveUpdates++,this.waiting_();else if(e===this.lastRecordedTime)this.consecutiveUpdates++;else{this.playedRanges_.push(it([this.lastRecordedTime,e]));const r={playedRanges:this.playedRanges_};this.playlistController_.trigger({type:"playedrangeschanged",metadata:r}),this.consecutiveUpdates=0,this.lastRecordedTime=e}}resetTimeUpdate_(){this.consecutiveUpdates=0}fixesBadSeeks_(){if(!this.tech_.seeking())return!1;const e=this.seekable(),t=this.tech_.currentTime(),r=this.afterSeekableWindow_(e,t,this.media(),this.allowSeeksWithinUnsafeLiveWindow);let n;if(r&&(n=e.end(e.length-1)),this.beforeSeekableWindow_(e,t)){const w=e.start(0);n=w+(w===e.end(0)?0:ei)}if(typeof n<"u")return this.logger_(`Trying to seek outside of seekable at time ${t} with seekable range ${am(e)}. Seeking to ${n}.`),this.tech_.setCurrentTime(n),!0;const s=this.playlistController_.sourceUpdater_,a=this.tech_.buffered(),l=s.audioBuffer?s.audioBuffered():null,u=s.videoBuffer?s.videoBuffered():null,p=this.media(),g=p.partTargetDuration?p.partTargetDuration:(p.targetDuration-Zt)*2,b=[l,u];for(let w=0;w<b.length;w++)if(b[w]&&vu(b[w],t)<g)return!1;const S=Ms(a,t);return S.length===0?!1:(n=S.start(0)+ei,this.logger_(`Buffered region starts (${S.start(0)}) just beyond seek point (${t}). Seeking to ${n}.`),this.tech_.setCurrentTime(n),!0)}waiting_(){if(this.techWaiting_())return;const e=this.tech_.currentTime(),t=this.tech_.buffered(),r=Sr(t,e);if(r.length&&e+3<=r.end(0)){this.resetTimeUpdate_(),this.tech_.setCurrentTime(e),this.logger_(`Stopped at ${e} while inside a buffered region [${r.start(0)} -> ${r.end(0)}]. Attempting to resume playback by seeking to the current time.`),this.tech_.trigger({type:"usage",name:"vhs-unknown-waiting"});return}}techWaiting_(){const e=this.seekable(),t=this.tech_.currentTime();if(this.tech_.seeking())return!0;if(this.beforeSeekableWindow_(e,t)){const a=e.end(e.length-1);return this.logger_(`Fell out of live window at time ${t}. Seeking to live point (seekable end) ${a}`),this.resetTimeUpdate_(),this.tech_.setCurrentTime(a),this.tech_.trigger({type:"usage",name:"vhs-live-resync"}),!0}const r=this.tech_.vhs.playlistController_.sourceUpdater_,n=this.tech_.buffered();if(this.videoUnderflow_({audioBuffered:r.audioBuffered(),videoBuffered:r.videoBuffered(),currentTime:t}))return this.resetTimeUpdate_(),this.tech_.setCurrentTime(t),this.tech_.trigger({type:"usage",name:"vhs-video-underflow"}),!0;const s=Ms(n,t);return s.length>0?(this.logger_(`Stopped at ${t} and seeking to ${s.start(0)}`),this.resetTimeUpdate_(),this.skipTheGap_(t),!0):!1}afterSeekableWindow_(e,t,r,n=!1){if(!e.length)return!1;let s=e.end(e.length-1)+ei;const a=!r.endList,l=typeof r.partTargetDuration=="number";return a&&(l||n)&&(s=e.end(e.length-1)+r.targetDuration*3),t>s}beforeSeekableWindow_(e,t){return!!(e.length&&e.start(0)>0&&t<e.start(0)-this.liveRangeSafeTimeDelta)}videoUnderflow_({videoBuffered:e,audioBuffered:t,currentTime:r}){if(!e)return;let n;if(e.length&&t.length){const s=Sr(e,r-3),a=Sr(e,r),l=Sr(t,r);l.length&&!a.length&&s.length&&(n={start:s.end(0),end:l.end(0)})}else Ms(e,r).length||(n=this.gapFromVideoUnderflow_(e,r));return n?(this.logger_(`Encountered a gap in video from ${n.start} to ${n.end}. Seeking to current time ${r}`),!0):!1}skipTheGap_(e){const t=this.tech_.buffered(),r=this.tech_.currentTime(),n=Ms(t,r);if(this.resetTimeUpdate_(),n.length===0||r!==e)return;this.logger_("skipTheGap_:","currentTime:",r,"scheduled currentTime:",e,"nextRange start:",n.start(0)),this.tech_.setCurrentTime(n.start(0)+Zt);const s={gapInfo:{from:r,to:n.start(0)}};this.playlistController_.trigger({type:"gapjumped",metadata:s}),this.tech_.trigger({type:"usage",name:"vhs-gap-skip"})}gapFromVideoUnderflow_(e,t){const r=tE(e);for(let n=0;n<r.length;n++){const s=r.start(n),a=r.end(n);if(t-s<4&&t-s>2)return{start:s,end:a}}return null}}const T2={errorInterval:30,getSource(i){const e=this.tech({IWillNotUseThisInPlugins:!0}).currentSource_||this.currentSource();return i(e)}},Ym=function(i,e){let t=0,r=0;const n=fe(T2,e);i.ready(()=>{i.trigger({type:"usage",name:"vhs-error-reload-initialized"})});const s=function(){r&&i.currentTime(r)},a=function(g){g!=null&&(r=i.duration()!==1/0&&i.currentTime()||0,i.one("loadedmetadata",s),i.src(g),i.trigger({type:"usage",name:"vhs-error-reload"}),i.play())},l=function(){if(Date.now()-t<n.errorInterval*1e3){i.trigger({type:"usage",name:"vhs-error-reload-canceled"});return}if(!n.getSource||typeof n.getSource!="function"){B.log.error("ERROR: reloadSourceOnError - The option getSource must be a function!");return}return t=Date.now(),n.getSource.call(i,a)},u=function(){i.off("loadedmetadata",s),i.off("error",l),i.off("dispose",u)},p=function(g){u(),Ym(i,g)};i.on("error",l),i.on("dispose",u),i.reloadSourceOnError=p},S2=function(i){Ym(this,i)};var Qm="3.16.2",E2="7.1.0",w2="1.3.1",k2="7.2.0",C2="4.0.2";const Ne={PlaylistLoader:Er,Playlist:_t,utils:AE,STANDARD_PLAYLIST_SELECTOR:eh,INITIAL_PLAYLIST_SELECTOR:_w,lastBandwidthSelector:eh,movingAverageBandwidthSelector:fw,comparePlaylistBandwidth:ku,comparePlaylistResolution:mw,xhr:Em()};Object.keys(Xe).forEach(i=>{Object.defineProperty(Ne,i,{get(){return B.log.warn(`using Vhs.${i} is UNSAFE be sure you know what you are doing`),Xe[i]},set(e){if(B.log.warn(`using Vhs.${i} is UNSAFE be sure you know what you are doing`),typeof e!="number"||e<0){B.log.warn(`value of Vhs.${i} must be greater than or equal to 0`);return}Xe[i]=e}})});const Jm="videojs-vhs",Zm=function(i,e){const t=e.media();let r=-1;for(let n=0;n<i.length;n++)if(i[n].id===t.id){r=n;break}i.selectedIndex_=r,i.trigger({selectedIndex:r,type:"change"})},I2=function(i,e){e.representations().forEach(t=>{i.addQualityLevel(t)}),Zm(i,e.playlists)};Ne.canPlaySource=function(){return B.log.warn("VHS is no longer a tech. Please remove it from your player's techOrder.")};const A2=(i,e,t)=>{if(!i)return i;let r={};e&&e.attributes&&e.attributes.CODECS&&(r=fa(Kt(e.attributes.CODECS))),t&&t.attributes&&t.attributes.CODECS&&(r.audio=t.attributes.CODECS);const n=Or(r.video),s=Or(r.audio),a={};for(const l in i)a[l]={},s&&(a[l].audioContentType=s),n&&(a[l].videoContentType=n),e.contentProtection&&e.contentProtection[l]&&e.contentProtection[l].pssh&&(a[l].pssh=e.contentProtection[l].pssh),typeof i[l]=="string"&&(a[l].url=i[l]);return fe(i,a)},x2=(i,e)=>i.reduce((t,r)=>{if(!r.contentProtection)return t;const n=e.reduce((s,a)=>{const l=r.contentProtection[a];return l&&l.pssh&&(s[a]={pssh:l.pssh}),s},{});return Object.keys(n).length&&t.push(n),t},[]),L2=({player:i,sourceKeySystems:e,audioMedia:t,mainPlaylists:r})=>{if(!i.eme.initializeMediaKeys)return Promise.resolve();const n=t?r.concat([t]):r,s=x2(n,Object.keys(e)),a=[],l=[];return s.forEach(u=>{l.push(new Promise((p,g)=>{i.tech_.one("keysessioncreated",p)})),a.push(new Promise((p,g)=>{i.eme.initializeMediaKeys({keySystems:u},b=>{if(b){g(b);return}p()})}))}),Promise.race([Promise.all(a),Promise.race(l)])},D2=({player:i,sourceKeySystems:e,media:t,audioMedia:r})=>{const n=A2(e,t,r);return n?(i.currentSource().keySystems=n,n&&!i.eme?(B.log.warn("DRM encrypted source cannot be decrypted without a DRM plugin"),!1):!0):!1},ef=()=>{if(!x.localStorage)return null;const i=x.localStorage.getItem(Jm);if(!i)return null;try{return JSON.parse(i)}catch{return null}},P2=i=>{if(!x.localStorage)return!1;let e=ef();e=e?fe(e,i):i;try{x.localStorage.setItem(Jm,JSON.stringify(e))}catch{return!1}return e},R2=i=>i.toLowerCase().indexOf("data:application/vnd.videojs.vhs+json,")===0?JSON.parse(i.substring(i.indexOf(",")+1)):i,tf=(i,e)=>{i._requestCallbackSet||(i._requestCallbackSet=new Set),i._requestCallbackSet.add(e)},rf=(i,e)=>{i._responseCallbackSet||(i._responseCallbackSet=new Set),i._responseCallbackSet.add(e)},nf=(i,e)=>{i._requestCallbackSet&&(i._requestCallbackSet.delete(e),i._requestCallbackSet.size||delete i._requestCallbackSet)},sf=(i,e)=>{i._responseCallbackSet&&(i._responseCallbackSet.delete(e),i._responseCallbackSet.size||delete i._responseCallbackSet)};Ne.supportsNativeHls=function(){if(!G||!G.createElement)return!1;const i=G.createElement("video");return B.getTech("Html5").isSupported()?["application/vnd.apple.mpegurl","audio/mpegurl","audio/x-mpegurl","application/x-mpegurl","video/x-mpegurl","video/mpegurl","application/mpegurl"].some(function(e){return/maybe|probably/i.test(i.canPlayType(e))}):!1}();Ne.supportsNativeDash=function(){return!G||!G.createElement||!B.getTech("Html5").isSupported()?!1:/maybe|probably/i.test(G.createElement("video").canPlayType("application/dash+xml"))}();Ne.supportsTypeNatively=i=>i==="hls"?Ne.supportsNativeHls:i==="dash"?Ne.supportsNativeDash:!1;Ne.isSupported=function(){return B.log.warn("VHS is no longer a tech. Please remove it from your player's techOrder.")};Ne.xhr.onRequest=function(i){tf(Ne.xhr,i)};Ne.xhr.onResponse=function(i){rf(Ne.xhr,i)};Ne.xhr.offRequest=function(i){nf(Ne.xhr,i)};Ne.xhr.offResponse=function(i){sf(Ne.xhr,i)};const N2=B.getComponent("Component");class af extends N2{constructor(e,t,r){if(super(t,r.vhs),typeof r.initialBandwidth=="number"&&(this.options_.bandwidth=r.initialBandwidth),this.logger_=Nt("VhsHandler"),t.options_&&t.options_.playerId){const n=B.getPlayer(t.options_.playerId);this.player_=n}if(this.tech_=t,this.source_=e,this.stats={},this.ignoreNextSeekingEvent_=!1,this.setOptions_(),this.options_.overrideNative&&t.overrideNativeAudioTracks&&t.overrideNativeVideoTracks)t.overrideNativeAudioTracks(!0),t.overrideNativeVideoTracks(!0);else if(this.options_.overrideNative&&(t.featuresNativeVideoTracks||t.featuresNativeAudioTracks))throw new Error("Overriding native VHS requires emulated tracks. See https://git.io/vMpjB");this.on(G,["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],n=>{const s=G.fullscreenElement||G.webkitFullscreenElement||G.mozFullScreenElement||G.msFullscreenElement;s&&s.contains(this.tech_.el())?this.playlistController_.fastQualityChange_():this.playlistController_.checkABR_()}),this.on(this.tech_,"seeking",function(){if(this.ignoreNextSeekingEvent_){this.ignoreNextSeekingEvent_=!1;return}this.setCurrentTime(this.tech_.currentTime())}),this.on(this.tech_,"error",function(){this.tech_.error()&&this.playlistController_&&this.playlistController_.pauseLoading()}),this.on(this.tech_,"play",this.play)}setOptions_(e={}){if(this.options_=fe(this.options_,e),this.options_.withCredentials=this.options_.withCredentials||!1,this.options_.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions!==!1,this.options_.useDevicePixelRatio=this.options_.useDevicePixelRatio||!1,this.options_.useBandwidthFromLocalStorage=typeof this.source_.useBandwidthFromLocalStorage<"u"?this.source_.useBandwidthFromLocalStorage:this.options_.useBandwidthFromLocalStorage||!1,this.options_.useForcedSubtitles=this.options_.useForcedSubtitles||!1,this.options_.useNetworkInformationApi=this.options_.useNetworkInformationApi||!1,this.options_.useDtsForTimestampOffset=this.options_.useDtsForTimestampOffset||!1,this.options_.customTagParsers=this.options_.customTagParsers||[],this.options_.customTagMappers=this.options_.customTagMappers||[],this.options_.cacheEncryptionKeys=this.options_.cacheEncryptionKeys||!1,this.options_.llhls=this.options_.llhls!==!1,this.options_.bufferBasedABR=this.options_.bufferBasedABR||!1,typeof this.options_.playlistExclusionDuration!="number"&&(this.options_.playlistExclusionDuration=60),typeof this.options_.bandwidth!="number"&&this.options_.useBandwidthFromLocalStorage){const r=ef();r&&r.bandwidth&&(this.options_.bandwidth=r.bandwidth,this.tech_.trigger({type:"usage",name:"vhs-bandwidth-from-local-storage"})),r&&r.throughput&&(this.options_.throughput=r.throughput,this.tech_.trigger({type:"usage",name:"vhs-throughput-from-local-storage"}))}typeof this.options_.bandwidth!="number"&&(this.options_.bandwidth=Xe.INITIAL_BANDWIDTH),this.options_.enableLowInitialPlaylist=this.options_.enableLowInitialPlaylist&&this.options_.bandwidth===Xe.INITIAL_BANDWIDTH,["withCredentials","useDevicePixelRatio","customPixelRatio","limitRenditionByPlayerDimensions","bandwidth","customTagParsers","customTagMappers","cacheEncryptionKeys","playlistSelector","initialPlaylistSelector","bufferBasedABR","liveRangeSafeTimeDelta","llhls","useForcedSubtitles","useNetworkInformationApi","useDtsForTimestampOffset","exactManifestTimings","leastPixelDiffSelector"].forEach(r=>{typeof this.source_[r]<"u"&&(this.options_[r]=this.source_[r])}),this.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions,this.useDevicePixelRatio=this.options_.useDevicePixelRatio;const t=this.options_.customPixelRatio;typeof t=="number"&&t>=0&&(this.customPixelRatio=t)}setOptions(e={}){this.setOptions_(e)}src(e,t){if(!e)return;this.setOptions_(),this.options_.src=R2(this.source_.src),this.options_.tech=this.tech_,this.options_.externVhs=Ne,this.options_.sourceType=kp(t),this.options_.seekTo=s=>{this.tech_.setCurrentTime(s)},this.options_.player_=this.player_,this.playlistController_=new f2(this.options_);const r=fe({liveRangeSafeTimeDelta:ei},this.options_,{seekable:()=>this.seekable(),media:()=>this.playlistController_.media(),playlistController:this.playlistController_});this.playbackWatcher_=new v2(r),this.attachStreamingEventListeners_(),this.playlistController_.on("error",()=>{const s=B.players[this.tech_.options_.playerId];let a=this.playlistController_.error;typeof a=="object"&&!a.code?a.code=3:typeof a=="string"&&(a={message:a,code:3}),s.error(a)});const n=this.options_.bufferBasedABR?Ne.movingAverageBandwidthSelector(.55):Ne.STANDARD_PLAYLIST_SELECTOR;this.playlistController_.selectPlaylist=this.selectPlaylist?this.selectPlaylist.bind(this):n.bind(this),this.playlistController_.selectInitialPlaylist=Ne.INITIAL_PLAYLIST_SELECTOR.bind(this),this.playlists=this.playlistController_.mainPlaylistLoader_,this.mediaSource=this.playlistController_.mediaSource,Object.defineProperties(this,{selectPlaylist:{get(){return this.playlistController_.selectPlaylist},set(s){this.playlistController_.selectPlaylist=s.bind(this)}},throughput:{get(){return this.playlistController_.mainSegmentLoader_.throughput.rate},set(s){this.playlistController_.mainSegmentLoader_.throughput.rate=s,this.playlistController_.mainSegmentLoader_.throughput.count=1}},bandwidth:{get(){let s=this.playlistController_.mainSegmentLoader_.bandwidth;const a=x.navigator.connection||x.navigator.mozConnection||x.navigator.webkitConnection,l=1e7;if(this.options_.useNetworkInformationApi&&a){const u=a.downlink*1e3*1e3;u>=l&&s>=l?s=Math.max(s,u):s=u}return s},set(s){this.playlistController_.mainSegmentLoader_.bandwidth=s,this.playlistController_.mainSegmentLoader_.throughput={rate:0,count:0}}},systemBandwidth:{get(){const s=1/(this.bandwidth||1);let a;return this.throughput>0?a=1/this.throughput:a=0,Math.floor(1/(s+a))},set(){B.log.error('The "systemBandwidth" property is read-only')}}}),this.options_.bandwidth&&(this.bandwidth=this.options_.bandwidth),this.options_.throughput&&(this.throughput=this.options_.throughput),Object.defineProperties(this.stats,{bandwidth:{get:()=>this.bandwidth||0,enumerable:!0},mediaRequests:{get:()=>this.playlistController_.mediaRequests_()||0,enumerable:!0},mediaRequestsAborted:{get:()=>this.playlistController_.mediaRequestsAborted_()||0,enumerable:!0},mediaRequestsTimedout:{get:()=>this.playlistController_.mediaRequestsTimedout_()||0,enumerable:!0},mediaRequestsErrored:{get:()=>this.playlistController_.mediaRequestsErrored_()||0,enumerable:!0},mediaTransferDuration:{get:()=>this.playlistController_.mediaTransferDuration_()||0,enumerable:!0},mediaBytesTransferred:{get:()=>this.playlistController_.mediaBytesTransferred_()||0,enumerable:!0},mediaSecondsLoaded:{get:()=>this.playlistController_.mediaSecondsLoaded_()||0,enumerable:!0},mediaAppends:{get:()=>this.playlistController_.mediaAppends_()||0,enumerable:!0},mainAppendsToLoadedData:{get:()=>this.playlistController_.mainAppendsToLoadedData_()||0,enumerable:!0},audioAppendsToLoadedData:{get:()=>this.playlistController_.audioAppendsToLoadedData_()||0,enumerable:!0},appendsToLoadedData:{get:()=>this.playlistController_.appendsToLoadedData_()||0,enumerable:!0},timeToLoadedData:{get:()=>this.playlistController_.timeToLoadedData_()||0,enumerable:!0},buffered:{get:()=>Qi(this.tech_.buffered()),enumerable:!0},currentTime:{get:()=>this.tech_.currentTime(),enumerable:!0},currentSource:{get:()=>this.tech_.currentSource_,enumerable:!0},currentTech:{get:()=>this.tech_.name_,enumerable:!0},duration:{get:()=>this.tech_.duration(),enumerable:!0},main:{get:()=>this.playlists.main,enumerable:!0},playerDimensions:{get:()=>this.tech_.currentDimensions(),enumerable:!0},seekable:{get:()=>Qi(this.tech_.seekable()),enumerable:!0},timestamp:{get:()=>Date.now(),enumerable:!0},videoPlaybackQuality:{get:()=>this.tech_.getVideoPlaybackQuality(),enumerable:!0}}),this.tech_.one("canplay",this.playlistController_.setupFirstPlay.bind(this.playlistController_)),this.tech_.on("bandwidthupdate",()=>{this.options_.useBandwidthFromLocalStorage&&P2({bandwidth:this.bandwidth,throughput:Math.round(this.throughput)})}),this.playlistController_.on("selectedinitialmedia",()=>{b2(this)}),this.playlistController_.sourceUpdater_.on("createdsourcebuffers",()=>{this.setupEme_()}),this.on(this.playlistController_,"progress",function(){this.tech_.trigger("progress")}),this.on(this.playlistController_,"firstplay",function(){this.ignoreNextSeekingEvent_=!0}),this.setupQualityLevels_(),this.tech_.el()&&(this.mediaSourceUrl_=x.URL.createObjectURL(this.playlistController_.mediaSource),(B.browser.IS_ANY_SAFARI||B.browser.IS_IOS)&&this.options_.overrideNative&&this.options_.sourceType==="hls"&&typeof this.tech_.addSourceElement=="function"?(this.tech_.addSourceElement(this.mediaSourceUrl_),this.tech_.addSourceElement(this.source_.src)):this.tech_.src(this.mediaSourceUrl_))}createKeySessions_(){const e=this.playlistController_.mediaTypes_.AUDIO.activePlaylistLoader;this.logger_("waiting for EME key session creation"),L2({player:this.player_,sourceKeySystems:this.source_.keySystems,audioMedia:e&&e.media(),mainPlaylists:this.playlists.main.playlists}).then(()=>{this.logger_("created EME key session"),this.playlistController_.sourceUpdater_.initializedEme()}).catch(t=>{this.logger_("error while creating EME key session",t),this.player_.error({message:"Failed to initialize media keys for EME",code:3})})}handleWaitingForKey_(){this.logger_("waitingforkey fired, attempting to create any new key sessions"),this.createKeySessions_()}setupEme_(){const e=this.playlistController_.mediaTypes_.AUDIO.activePlaylistLoader,t=D2({player:this.player_,sourceKeySystems:this.source_.keySystems,media:this.playlists.media(),audioMedia:e&&e.media()});if(this.player_.tech_.on("keystatuschange",r=>{this.playlistController_.updatePlaylistByKeyStatus(r.keyId,r.status)}),this.handleWaitingForKey_=this.handleWaitingForKey_.bind(this),this.player_.tech_.on("waitingforkey",this.handleWaitingForKey_),!t){this.playlistController_.sourceUpdater_.initializedEme();return}this.createKeySessions_()}setupQualityLevels_(){const e=B.players[this.tech_.options_.playerId];!e||!e.qualityLevels||this.qualityLevels_||(this.qualityLevels_=e.qualityLevels(),this.playlistController_.on("selectedinitialmedia",()=>{I2(this.qualityLevels_,this)}),this.playlists.on("mediachange",()=>{Zm(this.qualityLevels_,this.playlists)}))}static version(){return{"@videojs/http-streaming":Qm,"mux.js":E2,"mpd-parser":w2,"m3u8-parser":k2,"aes-decrypter":C2}}version(){return this.constructor.version()}canChangeType(){return Wm.canChangeType()}play(){this.playlistController_.play()}setCurrentTime(e){this.playlistController_.setCurrentTime(e)}duration(){return this.playlistController_.duration()}seekable(){return this.playlistController_.seekable()}dispose(){this.playbackWatcher_&&this.playbackWatcher_.dispose(),this.playlistController_&&this.playlistController_.dispose(),this.qualityLevels_&&this.qualityLevels_.dispose(),this.tech_&&this.tech_.vhs&&delete this.tech_.vhs,this.mediaSourceUrl_&&x.URL.revokeObjectURL&&(x.URL.revokeObjectURL(this.mediaSourceUrl_),this.mediaSourceUrl_=null),this.tech_&&this.tech_.off("waitingforkey",this.handleWaitingForKey_),super.dispose()}convertToProgramTime(e,t){return OE({playlist:this.playlistController_.media(),time:e,callback:t})}seekToProgramTime(e,t,r=!0,n=2){return Am({programTime:e,playlist:this.playlistController_.media(),retryCount:n,pauseAfterSeek:r,seekTo:this.options_.seekTo,tech:this.options_.tech,callback:t})}setupXhrHooks_(){this.xhr.onRequest=e=>{tf(this.xhr,e)},this.xhr.onResponse=e=>{rf(this.xhr,e)},this.xhr.offRequest=e=>{nf(this.xhr,e)},this.xhr.offResponse=e=>{sf(this.xhr,e)},this.player_.trigger("xhr-hooks-ready")}attachStreamingEventListeners_(){const e=["seekablerangeschanged","bufferedrangeschanged","contentsteeringloadstart","contentsteeringloadcomplete","contentsteeringparsed"],t=["gapjumped","playedrangeschanged"];e.forEach(r=>{this.playlistController_.on(r,n=>{this.player_.trigger(Ve({},n))})}),t.forEach(r=>{this.playbackWatcher_.on(r,n=>{this.player_.trigger(Ve({},n))})})}}const ba={name:"videojs-http-streaming",VERSION:Qm,canHandleSource(i,e={}){const t=fe(B.options,e);return!t.vhs.experimentalUseMMS&&!Dn("avc1.4d400d,mp4a.40.2",!1)?!1:ba.canPlayType(i.type,t)},handleSource(i,e,t={}){const r=fe(B.options,t);return e.vhs=new af(i,e,r),e.vhs.xhr=Em(),e.vhs.setupXhrHooks_(),e.vhs.src(i.src,i.type),e.vhs},canPlayType(i,e){const t=kp(i);if(!t)return"";const r=ba.getOverrideNative(e);return!Ne.supportsTypeNatively(t)||r?"maybe":""},getOverrideNative(i={}){const{vhs:e={}}=i,t=!(B.browser.IS_ANY_SAFARI||B.browser.IS_IOS),{overrideNative:r=t}=e;return r}},O2=()=>Dn("avc1.4d400d,mp4a.40.2",!0);O2()&&B.getTech("Html5").registerSourceHandler(ba,0);B.VhsHandler=af;B.VhsSourceHandler=ba;B.Vhs=Ne;B.use||B.registerComponent("Vhs",Ne);B.options.vhs=B.options.vhs||{};(!B.getPlugin||!B.getPlugin("reloadSourceOnError"))&&B.registerPlugin("reloadSourceOnError",S2);const U2=i=>{const e=Me.useRef();return Me.useEffect(()=>{if(!e.current&&i.current){const t=document.createElement("video-js");t.classList.add("vjs-big-play-centered"),i.current.appendChild(t),e.current=B(t,{controls:!1,playsinline:!0})}return()=>{e.current&&(e.current.dispose(),e.current=void 0)}},[]),e},of={time:0,adCount:0,adPosition:0,skipDelay:0,playing:!1,paused:!1,reset:()=>{},whyThisAd:null,hasAdUrl:!1,adAction:i=>{},playMuted:!1,muted:!1,autoplay:!0},De=X.i(of),ph=i=>{if(!i)return 0;const e=i.duration(),t=i.currentTime();return e===void 0||isNaN(e)||t===void 0||isNaN(t)?0:Math.round(e-t)},M2=(i,e)=>{const t=db(i,e),r=U2(i),n=Me.useRef(),s=Me.useCallback(()=>{var p,g;const{adPosition:b,adCount:S}=De.get();if(r.current){if(b<S){const w=b+1,{ads:C,muted:v,autoplay:D}=t.get(),L=C[w-1];if(L){(p=n.current)==null||p.complete(),n.current=new ib(null,L.ad,L.creative),n.current.on("clickthrough",O=>{window.open(O,"_blank")}),De.setKey("adPosition",w),De.setKey("playMuted",v),De.setKey("skipDelay",L.creative.skipDelay||0),De.setKey("time",0),De.setKey("adAction",O=>{n.current&&n.current.click(null,{CLICKPOS:[O.clientX,O.clientY]})}),De.setKey("whyThisAd",L.creative.icons.find(O=>O.program==="GoogleWhyThisAd")||null),De.setKey("hasAdUrl",!!((g=L.creative.videoClickThroughURLTemplate)!=null&&g.url)),r.current.src(L.mediaFileUrl),De.setKey("playing",!0),b===0?(De.setKey("muted",v),De.setKey("autoplay",D),v&&r.current.muted(!0),D?r.current.play():(r.current.pause(),De.setKey("paused",!0))):r.current.play();return}}De.set(of),r.current.pause(),r.current.src(void 0)}},[r,t]),a=Me.useCallback(()=>{if(!r.current)return;const p=r.current.muted();r.current.muted(!p),De.setKey("muted",!p),n.current&&n.current.setMuted(!p)},[r]),l=Me.useCallback(()=>{r.current&&(r.current.paused()?(r.current.play(),n.current&&n.current.setPaused(!1)):(r.current.pause(),n.current&&n.current.setPaused(!0)))},[r]),u=Me.useCallback(()=>{r.current&&(n.current&&n.current.skip(),s())},[s,r]);return Me.useEffect(()=>{r.current&&(r.current.on("play",p=>{De.setKey("playing",!0),De.setKey("paused",!1),De.setKey("time",ph(p.target.player))}),r.current.on("ended",()=>{s()}),r.current.on("muted",p=>{console.log("muted",p),De.setKey("muted",p.target.player.muted())}),r.current.on("pause",()=>{De.setKey("paused",!0)}),r.current.on("click",function(p){p.target.tagName==="VIDEO"&&(De.get().autoplay||l())}),r.current.on("timeupdate",p=>{De.setKey("time",ph(p.target.player)),n.current&&n.current.setProgress(p.target.player.currentTime())}))},[l,s,r]),Me.useEffect(()=>t.subscribe(p=>{p&&(De.setKey("adCount",p.ads.length),De.setKey("adPosition",0),s())}),[t,r,s]),[De,a,l,u]},B2=({promotion:i,onClose:e,promotionId:t,externalAd:r,skipAutoClose:n})=>{var s,a,l,u,p;const g=Me.useRef(null),[b,S,w,C]=M2(g,r==null?void 0:r.url),{time:v,adCount:D,adPosition:L,skipDelay:O,playing:U,paused:F,reset:N,muted:V,playMuted:J,autoplay:Y,whyThisAd:ie,hasAdUrl:he,adAction:le}=X.useStore(b),pe=((s=i.sponsor)==null?void 0:s.logo)&&i.logoMode===ge.PromotionLogoMode.CENTER;return W.jsxs(yh,{className:"PromoOverlay",children:[W.jsxs(_h,{children:[W.jsx(bh,{className:X.cx_default(!pe&&vh),children:W.jsx(Sh,{style:{transform:"scale(1.5)"},children:"Ad"})}),W.jsxs(B0,{children:[W.jsx(x0,{time:v,adCount:D,adPosition:L}),!!O&&U&&W.jsx(X.y$1,{timerClassName:"SkipTimerCount",className:"ClosePromoIcon",close:()=>{C()},duration:O,isPlaying:!F,skipIcon:!0}),n&&W.jsx(X.y$1,{className:"ClosePromoIcon",close:()=>{N(),e==null||e()}})]})]}),W.jsx(Th,{className:X.cx_default(bc,U&&vc,!U&&Tc),children:W.jsxs(M0,{ref:g,children:[ie&&W.jsx(D0,{whyThisAd:ie}),W.jsxs(P0,{style:(ie==null?void 0:ie.xPosition)==="right"?{left:"8px"}:{right:"8px"},children:[J&&W.jsx(N0,{className:X.cx_default(!V&&"muted"),onClick:()=>S()}),F&&!Y&&W.jsx(U0,{onClick:()=>w()})]})]})}),he&&W.jsx(Eh,{className:X.cx_default(bc,U&&vc,!U&&Tc),children:W.jsx(wh,{as:"button",onClick:le,style:{backgroundColor:((l=(a=i.banner)==null?void 0:a.ctaButton)==null?void 0:l.color)||"#009dc4",color:((p=(u=i.banner)==null?void 0:u.ctaButton)==null?void 0:p.textColor)||"#fff"},"data-analytics":"button","data-promo-id":t,"data-promo-type":i.type,target:"_blank",children:"Show more"})})]})},gh=i=>{var e,t,r,n,s,a,l,u,p,g,b,S,w,C,v,D,L,O,U,F,N,V,J,Y,ie,he,le,pe,ee,ce;const{promotion:ne,open:de,advertisementPaused:we,togglePause:ze,controlVideo:dt,skipAutoClose:Ot,promotionId:ht,onClose:Ut,markAsViewed:Vt,externalAd:xe}=i,Fe=ne.type===ge.PromotionType.INGAME_IAB11_LBAR||ne.type===ge.PromotionType.INGAME_IAB11,oi=((e=ne.sponsor)==null?void 0:e.logo)&&ne.logoMode===ge.PromotionLogoMode.CENTER,Fi=!!((r=(t=ne.banner)==null?void 0:t.video)!=null&&r.url),li=ne.autoPlayVideo===ge.AutoPlayVideo.ENABLED;if(Me.useEffect(()=>{ze==null||ze(Fi||li),de==null||de()},[]),Me.useEffect(()=>{ht&&ne.type&&Vt&&Vt()},[ht,ne.type,Vt]),Me.useEffect(()=>()=>{dt==null||dt({muted:!1})},[dt]),xe)return W.jsx(B2,{...i,externalAd:xe});let Ht=(n=ne.banner)==null?void 0:n.url;Ht&&Ht.indexOf("http")!==0&&(Ht=`https://${Ht}`);let Ti=!0;return Fi&&(!we||!li?Ti=!0:Ti=!1),W.jsxs(yh,{className:"PromoOverlay",children:[W.jsxs(_h,{children:[W.jsxs(bh,{className:X.cx_default(!oi&&vh),children:[((s=ne.sponsor)==null?void 0:s.logo)&&ne.logoMode===ge.PromotionLogoMode.LEFT&&W.jsx(fc,{className:"PromoSponsorLogo",src:(a=ne.sponsor)==null?void 0:a.logo,alt:"promo"}),W.jsxs(S0,{style:{paddingLeft:(l=ne.sponsor)!=null&&l.logo&&ne.logoMode===ge.PromotionLogoMode.LEFT?"0px":"8px"},children:[((u=ne.sponsor)==null?void 0:u.logo)&&ne.logoMode===ge.PromotionLogoMode.LEFT&&W.jsx(_0,{children:(p=ne.sponsor)==null?void 0:p.name}),W.jsxs(E0,{className:"SponsorText",children:[W.jsx(Sh,{children:"AD"}),W.jsx(w0,{children:"SPONSORED"})]})]})]}),W.jsx(X.y$1,{className:"ClosePromoIcon",close:Ut,autoClose:(g=ne.closeTimer)==null?void 0:g.auto,duration:Ot?0:(b=ne.closeTimer)==null?void 0:b.seconds,isPlaying:Ti})]}),W.jsxs(Th,{children:[oi&&W.jsx(fc,{className:v0,src:(S=ne.sponsor)==null?void 0:S.logo,alt:"promo"}),W.jsx(yc,{children:(C=(w=ne.banner)==null?void 0:w.video)!=null&&C.url?W.jsx(X.R$1,{source:(D=(v=ne.banner)==null?void 0:v.video)==null?void 0:D.url,poster:(O=(L=ne.banner)==null?void 0:L.video)==null?void 0:O.thumbnailUrl,aspectRatio:Fe?"1/1":"16/9",onPause:()=>{li&&(ze==null||ze(!0))},onPlay:()=>{X.eventBus.emit("advertisement",{action:"videoPlay",payload:{id:ht,type:ne.type}}),ze==null||ze(!1)},controlVideo:dt,autoPlay:li}):(U=ne.banner)!=null&&U.imageUrl?W.jsx(b0,{style:Fe?{aspectRatio:"1/1"}:{},src:(F=ne.banner)==null?void 0:F.imageUrl,alt:"promo"}):null}),!Fe&&W.jsxs(yc,{children:[((N=ne.banner)==null?void 0:N.title)&&W.jsx(k0,{className:X.cx_default("AdvTitle",oi&&C0),children:(V=ne.banner)==null?void 0:V.title}),((J=ne.banner)==null?void 0:J.body)&&W.jsx(T0,{className:"AdvDescription",children:(Y=ne.banner)==null?void 0:Y.body})]})]}),ne.buttonType!==ge.PromotionButtonType.NO_BUTTON&&W.jsx(Eh,{children:W.jsx(wh,{href:Ht,style:{backgroundColor:((he=(ie=ne.banner)==null?void 0:ie.ctaButton)==null?void 0:he.color)||"#009dc4",color:((pe=(le=ne.banner)==null?void 0:le.ctaButton)==null?void 0:pe.textColor)||"#fff"},"data-analytics":"button","data-promo-id":ht,"data-promo-type":ne.type,target:"_blank",children:(ce=(ee=ne.banner)==null?void 0:ee.ctaButton)==null?void 0:ce.label})})]})},F2=X.styled_default("div")({name:"SidebarContainer",class:"s1abskp8",propsAsIs:!1}),j2=({children:i,direction:e,style:t,className:r,hiding:n})=>W.jsx(bl,{direction:e,style:t,hiding:n,className:r,children:W.jsx(F2,{children:i})}),q2=i=>(i==null?void 0:i.type)===ge.PromotionType.INGAME_IAB11_LBAR||(i==null?void 0:i.type)===ge.PromotionType.INGAME_IAB21_LBAR,$2=i=>(i==null?void 0:i.type)===ge.PromotionType.INGAME_IAB11||(i==null?void 0:i.type)===ge.PromotionType.INGAME_IAB21,V2=({advertisement:i,close:e,skipTypeCheck:t,skipAutoClose:r,layoutMode:n="side-by-side",sidebar:s,isNotification:a,banner:l,markAsViewed:u,open:p,externalAd:g,controlVideo:b,advertisementPaused:S,togglePause:w})=>i.promotion?a&&i.notification?W.jsx(f0,{open:()=>p==null?void 0:p({fromNotification:!0}),notification:i.notification,promotionId:i.question.id}):!s&&!l&&(t||$2(i.promotion))?W.jsx(y0,{className:"PromoOverlayContainer",children:W.jsx(gh,{markAsViewed:u,promotionId:i.question.id,promotion:i.promotion,onClose:e,open:p,skipAutoClose:r,externalAd:g,controlVideo:b,advertisementPaused:S,togglePause:w})}):s&&(t||q2(i.promotion))?W.jsx(j2,{className:"PromoSidebarContainer",direction:s,hiding:!1,children:W.jsx(gh,{markAsViewed:u,promotionId:i.question.id,promotion:i.promotion,externalAd:g,onClose:e,open:p,controlVideo:b,skipAutoClose:r,advertisementPaused:S,togglePause:w})}):l?W.jsx(N_,{promotionId:i.question.id,hiding:!1,promotion:i.promotion,direction:l}):null:null,H2=X.styled_default("div")({name:"AdvertisementUIWrap",class:"aa6pjif",propsAsIs:!1}),z2=i=>{const e=i.target;if(e instanceof HTMLAnchorElement&&e.target==="_blank"){const t=e.getAttribute("data-promo-id")||"",r=e.getAttribute("data-promo-type")||ge.PromotionType.UNSET;e.getAttribute("data-analytics")==="button"&&X.eventBus.emit("advertisement",{action:"buttonSelect",payload:{id:t,type:r}}),e.getAttribute("data-analytics")==="banner"&&X.eventBus.emit("advertisement",{action:"bannerSelect",payload:{id:t,type:r}})}},W2=({gamification:i,layoutMode:e,skipAutoClose:t,skipTypeCheck:r,sidebar:n,banner:s,notification:a,isMobileScreen:l,persistent:u,externalAd:p,controlVideo:g})=>{var b,S,w;const C=Me.useRef(null),v=X.useStore(i.advertisement.$store);X.y(C,{enabled:!!v.data,event:"click",listener:z2});const D=!s&&!n;if(v.data===void 0||!u&&v.isViewed)return null;const L=((w=(S=(b=v==null?void 0:v.data)==null?void 0:b.notification)==null?void 0:S.promotion)==null?void 0:w.mode)===ge.NotificationPromotionMode.LOWER_THIRD;return W.jsx(H2,{ref:C,style:{height:D?"auto":"100%"},className:X.cx_default("SL-AdvertisementUIWrap",l&&"mobile-view",L&&"SL-AdvertisementUIWrap--lower-third"),children:W.jsx(V2,{skipTypeCheck:r,sidebar:n,banner:s,advertisement:v.data,advertisementPaused:v.isPaused,togglePause:v.togglePause,close:v.close,externalAd:p?v.externalAd:void 0,markAsViewed:i.advertisement.markAsViewed,open:i.advertisement.open,layoutMode:e,isNotification:a,skipAutoClose:t,controlVideo:g})})},lf=({sdk:i,sidebar:e,externalAd:t,banner:r,skipAutoClose:n,skipTypeCheck:s,layoutMode:a,isMobileScreen:l,persistent:u,notification:p})=>{const g=X.useStore(i.featuresList.getStore()),[b,S]=Me.useState(!t);if(Me.useEffect(()=>{if(t){const C=document.createElement("script");C.async=!0,C.src="https://imasdk.googleapis.com/pal/sdkloader/pal.js",document.body.appendChild(C),C.onload=()=>{S(!0)}}},[t]),e&&r)return W.jsx("div",{style:{color:"red"},children:"define either sidebar or banner, not both."});if(r&&t)return W.jsx("div",{style:{color:"red"},children:"externalAd is not supported with banner"});if(!g)return null;const w=i.getFeature(ge.SdkOverlayType.GAMES);return!w||t&&!b?null:W.jsx(W2,{gamification:w,sidebar:e,banner:r,layoutMode:a,isMobileScreen:l,persistent:u,notification:p,skipTypeCheck:s,skipAutoClose:n,externalAd:t,controlVideo:i.controlVideoPlayer})},G2=({event:i,sidebar:e,banner:t,isMobileScreen:r,skipAutoClose:n,persistent:s,theme:a,notification:l,skipTypeCheck:u,externalAd:p})=>{const g=X.useStreamLayer(),b=X.useStreamLayerUI(),S=X.useStreamLayerTheme();return g?p&&!b.promotionExternalAd?i!==void 0&&W.jsx(X.StreamLayerSDKEvent,{event:i}):!p&&b.promotionExternalAd?i!==void 0&&W.jsx(X.StreamLayerSDKEvent,{event:i}):e&&!b.promotionSidebar?i!==void 0&&W.jsx(X.StreamLayerSDKEvent,{event:i}):t&&!b.promotionBanner?i!==void 0&&W.jsx(X.StreamLayerSDKEvent,{event:i}):l&&!b.promotionNotification?i!==void 0&&W.jsx(X.StreamLayerSDKEvent,{event:i}):!t&&!e&&!l&&!b.promotionOverlay?i!==void 0&&W.jsx(X.StreamLayerSDKEvent,{event:i}):W.jsxs("div",{className:"StreamLayerSDK",children:[W.jsx(X.h,{customTheme:a??S.theme,themeMode:S.themeMode,children:W.jsx(lf,{sdk:g,sidebar:e,banner:t,isMobileScreen:r,persistent:s,notification:l,skipTypeCheck:u,skipAutoClose:n,layoutMode:"side-by-side",externalAd:p})}),i!==void 0&&W.jsx(X.StreamLayerSDKEvent,{event:i})]}):null};exports.StreamLayerSDKAdvertisement=G2;exports.StreamLayerSDKAdvertisementUI=lf;
|