hx-live-client-plus 1.0.67 → 1.0.69

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.
@@ -240,7 +240,7 @@ ${eo(e)}`),t.map&&!t.map.bytes&&(this.logger_("going to request init segment."),
240
240
  `.split("").map(i=>i.charCodeAt(0)));class ZP extends Error{constructor(){super("Trying to parse received VTT cues, but there is no WebVTT. Make sure vtt.js is loaded.")}}class eN extends Wp{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 Pn();const e=this.subtitlesTrack_.cues,t=e[0].startTime,n=e[e.length-1].startTime;return Pn([[t,n]])}initSegmentForMap(e,t=!1){if(!e)return null;const n=zu(e);let r=this.initSegments_[n];if(t&&!r&&e.bytes){const s=m_.byteLength+e.bytes.byteLength,a=new Uint8Array(s);a.set(e.bytes),a.set(m_,e.bytes.byteLength),this.initSegments_[n]=r={resolvedUri:e.resolvedUri,byterange:e.byterange,bytes:a}}return r||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){Sl(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,n){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===mr.TIMEOUT&&this.handleTimeout_(),e.code===mr.ABORTED?this.mediaRequestsAborted+=1:this.mediaRequestsErrored+=1,this.stopForError(e);return}const r=this.pendingSegment_,s=n.mp4VttCues&&n.mp4VttCues.length;s&&(r.mp4VttCues=n.mp4VttCues),this.saveBandwidthRelatedStats_(r.duration,t.stats),t.key&&this.segmentKey(t.key,!0),this.state="APPENDING",this.trigger("appending");const a=r.segment;if(a.map&&(a.map.bytes=t.map.bytes),r.bytes=t.bytes,typeof te.WebVTT!="function"&&typeof this.loadVttJs=="function"){this.state="WAITING_ON_VTTJS",this.loadVttJs().then(()=>this.segmentRequestFinished_(e,t,n),()=>this.stopForError({message:"Error loading vtt.js"}));return}a.requested=!0;try{this.parseVTTCues_(r)}catch(o){this.stopForError({message:o.message,metadata:{errorType:pe.Error.StreamingVttParserError,error:o}});return}if(s||this.updateTimeMapping_(r,this.syncController_.timelines[r.timeline],this.playlist_),r.cues.length?r.timingInfo={start:r.cues[0].startTime,end:r.cues[r.cues.length-1].endTime}:r.timingInfo={start:r.startOfSegment,end:r.startOfSegment+r.duration},r.isSyncRequest){this.trigger("syncinfoupdate"),this.pendingSegment_=null,this.state="READY";return}r.byteLength=r.bytes.byteLength,this.mediaSecondsLoaded+=a.duration,r.cues.forEach(o=>{this.subtitlesTrack_.addCue(this.featuresNativeTextTracks_?new te.VTTCue(o.startTime,o.endTime,o.text):o)}),LP(this.subtitlesTrack_),this.handleAppendsDone_()}handleData_(e,t){const n=e&&e.type==="vtt",r=t&&t.type==="text";n&&r&&super.handleData_(e,t)}updateTimingInfoEnd_(){}parseMp4VttCues_(e){const t=this.sourceUpdater_.videoTimestampOffset()===null?this.sourceUpdater_.audioTimestampOffset():this.sourceUpdater_.videoTimestampOffset();e.mp4VttCues.forEach(n=>{const r=n.start+t,s=n.end+t,a=new te.VTTCue(r,s,n.cueText);n.settings&&n.settings.split(" ").forEach(o=>{const c=o.split(":"),u=c[0],d=c[1];a[u]=isNaN(d)?d:Number(d)}),e.cues.push(a)})}parseVTTCues_(e){let t,n=!1;if(typeof te.WebVTT!="function")throw new ZP;if(e.cues=[],e.timestampmap={MPEGTS:0,LOCAL:0},e.mp4VttCues){this.parseMp4VttCues_(e);return}typeof te.TextDecoder=="function"?t=new te.TextDecoder("utf8"):(t=te.WebVTT.StringDecoder(),n=!0);const r=new te.WebVTT.Parser(te,te.vttjs,t);if(r.oncue=e.cues.push.bind(e.cues),r.ontimestampmap=a=>{e.timestampmap=a},r.onparsingerror=a=>{pe.log.warn("Error encountered when parsing cues: "+a.message)},e.segment.map){let a=e.segment.map.bytes;n&&(a=p_(a)),r.parse(a)}let s=e.bytes;n&&(s=p_(s)),r.parse(s),r.flush()}updateTimeMapping_(e,t,n){const r=e.segment;if(!t)return;if(!e.cues.length){r.empty=!0;return}const{MPEGTS:s,LOCAL:a}=e.timestampmap,c=s/Ls.ONE_SECOND_IN_TS-a+t.mapping;if(e.cues.forEach(u=>{const d=u.endTime-u.startTime,h=this.handleRollover_(u.startTime+c,t.time);u.startTime=Math.max(h,0),u.endTime=Math.max(h+d,0)}),!n.syncInfo){const u=e.cues[0].startTime,d=e.cues[e.cues.length-1].startTime;n.syncInfo={mediaSequence:n.mediaSequence+e.mediaIndex,time:Math.min(u,d-r.duration)}}}handleRollover_(e,t){if(t===null)return e;let n=e*Ls.ONE_SECOND_IN_TS;const r=t*Ls.ONE_SECOND_IN_TS;let s;for(r<n?s=-8589934592:s=8589934592;Math.abs(n-r)>4294967296;)n+=s;return n/Ls.ONE_SECOND_IN_TS}}const tN=function(i,e){const t=i.cues;for(let n=0;n<t.length;n++){const r=t[n];if(e>=r.adStartTime&&e<=r.adEndTime)return r}return null},nN=function(i,e,t=0){if(!i.segments)return;let n=t,r;for(let s=0;s<i.segments.length;s++){const a=i.segments[s];if(r||(r=tN(e,n+a.duration/2)),r){if("cueIn"in a){r.endTime=n,r.adEndTime=n,n+=a.duration,r=null;continue}if(n<r.endTime){n+=a.duration;continue}r.endTime+=a.duration}else if("cueOut"in a&&(r=new te.VTTCue(n,n+a.duration,a.cueOut),r.adStartTime=n,r.adEndTime=n+parseFloat(a.cueOut),e.addCue(r)),"cueOutCont"in a){const[o,c]=a.cueOutCont.split("/").map(parseFloat);r=new te.VTTCue(n,n+a.duration,""),r.adStartTime=n-o,r.adEndTime=r.adStartTime+c,e.addCue(r)}n+=a.duration}};class g_{constructor({start:e,end:t,segmentIndex:n,partIndex:r=null,appended:s=!1}){this.start_=e,this.end_=t,this.segmentIndex_=n,this.partIndex_=r,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 iN{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 v_{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:n,segments:r}=e;if(this.isReliable_=this.isReliablePlaylist_(n,r),!!this.isReliable_)return this.updateStorage_(r,n,this.calculateBaseTime_(n,r,t))}getSyncInfoForTime(e){for(const{segmentSyncInfo:t,partsSyncInfo:n}of this.storage_.values())if(n.length){for(const r of n)if(r.isInRange(e))return r}else if(t.isInRange(e))return t;return null}getSyncInfoForMediaSequence(e){return this.storage_.get(e)}updateStorage_(e,t,n){const r=new Map;let s=`
241
241
  `,a=n,o=t;this.start_=a,e.forEach((c,u)=>{const d=this.storage_.get(o),h=a,y=h+c.duration,v=!!(d&&d.segmentSyncInfo&&d.segmentSyncInfo.isAppended),b=new g_({start:h,end:y,appended:v,segmentIndex:u});c.syncInfo=b;let g=a;const f=(c.parts||[]).map((p,_)=>{const k=g,D=g+p.duration,C=!!(d&&d.partsSyncInfo&&d.partsSyncInfo[_]&&d.partsSyncInfo[_].isAppended),A=new g_({start:k,end:D,appended:C,segmentIndex:u,partIndex:_});return g=D,s+=`Media Sequence: ${o}.${_} | Range: ${k} --> ${D} | Appended: ${C}
242
242
  `,p.syncInfo=A,A});r.set(o,new iN(b,f)),s+=`${s_(c.resolvedUri)} | Media Sequence: ${o} | Range: ${h} --> ${y} | Appended: ${v}
243
- `,o++,a=y}),this.end_=a,this.storage_=r,this.diagnostics_=s}calculateBaseTime_(e,t,n){if(!this.storage_.size)return 0;if(this.storage_.has(e))return this.storage_.get(e).segmentSyncInfo.start;const r=Math.min(...this.storage_.keys());if(e<r){const s=r-e;let a=this.storage_.get(r).segmentSyncInfo.start;for(let o=0;o<s;o++){const c=t[o];a-=c.duration}return a}return n}isReliablePlaylist_(e,t){return e!=null&&Array.isArray(t)&&t.length}}class y_ extends v_{constructor(e){super(),this.parent_=e}calculateBaseTime_(e,t,n){if(!this.storage_.size){const r=this.parent_.getSyncInfoForMediaSequence(e);return r?r.segmentSyncInfo.start:0}return super.calculateBaseTime_(e,t,n)}}const rN=86400,Xp=[{name:"VOD",run:(i,e,t,n,r)=>t!==1/0?{time:0,segmentIndex:0,partIndex:null}:null},{name:"MediaSequence",run:(i,e,t,n,r,s)=>{const a=i.getMediaSequenceSync(s);if(!a||!a.isReliable)return null;const o=a.getSyncInfoForTime(r);return o?{time:o.start,partIndex:o.partIndex,segmentIndex:o.segmentIndex}:null}},{name:"ProgramDateTime",run:(i,e,t,n,r)=>{if(!Object.keys(i.timelineToDatetimeMappings).length)return null;let s=null,a=null;const o=Np(e);r=r||0;for(let c=0;c<o.length;c++){const u=e.endList||r===0?c:o.length-(c+1),d=o[u],h=d.segment,y=i.timelineToDatetimeMappings[h.timeline];if(!y||!h.dateTimeObject)continue;let b=h.dateTimeObject.getTime()/1e3+y;if(h.parts&&typeof d.partIndex=="number")for(let f=0;f<d.partIndex;f++)b+=h.parts[f].duration;const g=Math.abs(r-b);if(a!==null&&(g===0||a<g))break;a=g,s={time:b,segmentIndex:d.segmentIndex,partIndex:d.partIndex}}return s}},{name:"Segment",run:(i,e,t,n,r)=>{let s=null,a=null;r=r||0;const o=Np(e);for(let c=0;c<o.length;c++){const u=e.endList||r===0?c:o.length-(c+1),d=o[u],h=d.segment,y=d.part&&d.part.start||h&&h.start;if(h.timeline===n&&typeof y<"u"){const v=Math.abs(r-y);if(a!==null&&a<v)break;(!s||a===null||a>=v)&&(a=v,s={time:y,segmentIndex:d.segmentIndex,partIndex:d.partIndex})}}return s}},{name:"Discontinuity",run:(i,e,t,n,r)=>{let s=null;if(r=r||0,e.discontinuityStarts&&e.discontinuityStarts.length){let a=null;for(let o=0;o<e.discontinuityStarts.length;o++){const c=e.discontinuityStarts[o],u=e.discontinuitySequence+o+1,d=i.discontinuities[u];if(d){const h=Math.abs(r-d.time);if(a!==null&&a<h)break;(!s||a===null||a>=h)&&(a=h,s={time:d.time,segmentIndex:c,partIndex:null})}}}return s}},{name:"Playlist",run:(i,e,t,n,r)=>e.syncInfo?{time:e.syncInfo.time,segmentIndex:e.syncInfo.mediaSequence-e.mediaSequence,partIndex:null}:null}];class sN extends pe.EventTarget{constructor(e={}){super(),this.timelines=[],this.discontinuities=[],this.timelineToDatetimeMappings={};const t=new v_,n=new y_(t),r=new y_(t);this.mediaSequenceStorage_={main:t,audio:n,vtt:r},this.logger_=Mi("SyncController")}getMediaSequenceSync(e){return this.mediaSequenceStorage_[e]||null}getSyncPoint(e,t,n,r,s){if(t!==1/0)return Xp.find(({name:c})=>c==="VOD").run(this,e,t);const a=this.runStrategies_(e,t,n,r,s);if(!a.length)return null;for(const o of a){const{syncPoint:c,strategy:u}=o,{segmentIndex:d,time:h}=c;if(d<0)continue;const y=e.segments[d],v=h,b=v+y.duration;if(this.logger_(`Strategy: ${u}. Current time: ${r}. selected segment: ${d}. Time: [${v} -> ${b}]}`),r>=v&&r<b)return this.logger_("Found sync point with exact match: ",c),c}return this.selectSyncPoint_(a,{key:"time",value:r})}getExpiredTime(e,t){if(!e||!e.segments)return null;const n=this.runStrategies_(e,t,e.discontinuitySequence,0);if(!n.length)return null;const r=this.selectSyncPoint_(n,{key:"segmentIndex",value:0});return r.segmentIndex>0&&(r.time*=-1),Math.abs(r.time+bl({defaultDuration:e.targetDuration,durationList:e.segments,startIndex:r.segmentIndex,endIndex:0}))}runStrategies_(e,t,n,r,s){const a=[];for(let o=0;o<Xp.length;o++){const c=Xp[o],u=c.run(this,e,t,n,r,s);u&&(u.strategy=c.name,a.push({strategy:c.name,syncPoint:u}))}return a}selectSyncPoint_(e,t){let n=e[0].syncPoint,r=Math.abs(e[0].syncPoint[t.key]-t.value),s=e[0].strategy;for(let a=1;a<e.length;a++){const o=Math.abs(e[a].syncPoint[t.key]-t.value);o<r&&(r=o,n=e[a].syncPoint,s=e[a].strategy)}return this.logger_(`syncPoint for [${t.key}: ${t.value}] chosen with strategy [${s}]: [time:${n.time}, segmentIndex:${n.segmentIndex}`+(typeof n.partIndex=="number"?`,partIndex:${n.partIndex}`:"")+"]"),n}saveExpiredSegmentInfo(e,t){const n=t.mediaSequence-e.mediaSequence;if(n>rN){pe.log.warn(`Not saving expired segment info. Media sequence gap ${n} is too large.`);return}for(let r=n-1;r>=0;r--){const s=e.segments[r];if(s&&typeof s.start<"u"){t.syncInfo={mediaSequence:e.mediaSequence+r,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],n=t.dateTimeObject.getTime()/1e3;this.timelineToDatetimeMappings[t.timeline]=-n}}saveSegmentTimingInfo({segmentInfo:e,shouldSaveTimelineMapping:t}){const n=this.calculateSegmentTimeMapping_(e,e.timingInfo,t),r=e.segment;n&&(this.saveDiscontinuitySyncInfo_(e),e.playlist.syncInfo||(e.playlist.syncInfo={mediaSequence:e.playlist.mediaSequence+e.mediaIndex,time:r.start}));const s=r.dateTimeObject;r.discontinuity&&t&&s&&(this.timelineToDatetimeMappings[r.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,n){const r=e.segment,s=e.part;let a=this.timelines[e.timeline],o,c;if(typeof e.timestampOffset=="number")a={time:e.startOfSegment,mapping:e.startOfSegment-t.start},n&&(this.timelines[e.timeline]=a,this.trigger("timestampoffset"),this.logger_(`time mapping for timeline ${e.timeline}: [time: ${a.time}] [mapping: ${a.mapping}]`)),o=e.startOfSegment,c=t.end+a.mapping;else if(a)o=t.start+a.mapping,c=t.end+a.mapping;else return!1;return s&&(s.start=o,s.end=c),(!r.start||o<r.start)&&(r.start=o),r.end=c,!0}saveDiscontinuitySyncInfo_(e){const t=e.playlist,n=e.segment;if(n.discontinuity)this.discontinuities[n.timeline]={time:n.start,accuracy:0};else if(t.discontinuityStarts&&t.discontinuityStarts.length)for(let r=0;r<t.discontinuityStarts.length;r++){const s=t.discontinuityStarts[r],a=t.discontinuitySequence+r+1,o=s-e.mediaIndex,c=Math.abs(o);if(!this.discontinuities[a]||this.discontinuities[a].accuracy>c){let u;o<0?u=n.start-bl({defaultDuration:t.targetDuration,durationList:t.segments,startIndex:e.mediaIndex,endIndex:s}):u=n.end+bl({defaultDuration:t.targetDuration,durationList:t.segments,startIndex:e.mediaIndex+1,endIndex:s}),this.discontinuities[a]={time:u,accuracy:c}}}}dispose(){this.trigger("dispose"),this.off()}}class aN extends pe.EventTarget{constructor(){super(),this.pendingTimelineChanges_={},this.lastTimelineChanges_={}}clearPendingTimelineChange(e){this.pendingTimelineChanges_[e]=null,this.trigger("pendingtimelinechange")}pendingTimelineChange({type:e,from:t,to:n}){return typeof t=="number"&&typeof n=="number"&&(this.pendingTimelineChanges_[e]={type:e,from:t,to:n},this.trigger("pendingtimelinechange")),this.pendingTimelineChanges_[e]}lastTimelineChange({type:e,from:t,to:n}){if(typeof t=="number"&&typeof n=="number"){this.lastTimelineChanges_[e]={type:e,from:t,to:n},delete this.pendingTimelineChanges_[e];const r={timelineChangeInfo:{from:t,to:n}};this.trigger({type:"timelinechange",metadata:r})}return this.lastTimelineChanges_[e]}dispose(){this.trigger("dispose"),this.pendingTimelineChanges_={},this.lastTimelineChanges_={},this.off()}}const oN=q2(z2(function(){var i=function(){function g(){this.listeners={}}var f=g.prototype;return f.on=function(_,k){this.listeners[_]||(this.listeners[_]=[]),this.listeners[_].push(k)},f.off=function(_,k){if(!this.listeners[_])return!1;var D=this.listeners[_].indexOf(k);return this.listeners[_]=this.listeners[_].slice(0),this.listeners[_].splice(D,1),D>-1},f.trigger=function(_){var k=this.listeners[_];if(k)if(arguments.length===2)for(var D=k.length,C=0;C<D;++C)k[C].call(this,arguments[1]);else for(var A=Array.prototype.slice.call(arguments,1),w=k.length,P=0;P<w;++P)k[P].apply(this,A)},f.dispose=function(){this.listeners={}},f.pipe=function(_){this.on("data",function(k){_.push(k)})},g}();/*! @name pkcs7 @version 1.0.4 @license Apache-2.0 */function e(g){return g.subarray(0,g.byteLength-g[g.byteLength-1])}/*! @name aes-decrypter @version 4.0.2 @license Apache-2.0 */const t=function(){const g=[[[],[],[],[],[]],[[],[],[],[],[]]],f=g[0],p=g[1],_=f[4],k=p[4];let D,C,A;const w=[],P=[];let S,M,U,R,J,ie;for(D=0;D<256;D++)P[(w[D]=D<<1^(D>>7)*283)^D]=D;for(C=A=0;!_[C];C^=S||1,A=P[A]||1)for(R=A^A<<1^A<<2^A<<3^A<<4,R=R>>8^R&255^99,_[C]=R,k[R]=C,U=w[M=w[S=w[C]]],ie=U*16843009^M*65537^S*257^C*16843008,J=w[R]*257^R*16843008,D=0;D<4;D++)f[D][C]=J=J<<24^J>>>8,p[D][R]=ie=ie<<24^ie>>>8;for(D=0;D<5;D++)f[D]=f[D].slice(0),p[D]=p[D].slice(0);return g};let n=null;class r{constructor(f){n||(n=t()),this._tables=[[n[0][0].slice(),n[0][1].slice(),n[0][2].slice(),n[0][3].slice(),n[0][4].slice()],[n[1][0].slice(),n[1][1].slice(),n[1][2].slice(),n[1][3].slice(),n[1][4].slice()]];let p,_,k;const D=this._tables[0][4],C=this._tables[1],A=f.length;let w=1;if(A!==4&&A!==6&&A!==8)throw new Error("Invalid aes key size");const P=f.slice(0),S=[];for(this._key=[P,S],p=A;p<4*A+28;p++)k=P[p-1],(p%A===0||A===8&&p%A===4)&&(k=D[k>>>24]<<24^D[k>>16&255]<<16^D[k>>8&255]<<8^D[k&255],p%A===0&&(k=k<<8^k>>>24^w<<24,w=w<<1^(w>>7)*283)),P[p]=P[p-A]^k;for(_=0;p;_++,p--)k=P[_&3?p:p-4],p<=4||_<4?S[_]=k:S[_]=C[0][D[k>>>24]]^C[1][D[k>>16&255]]^C[2][D[k>>8&255]]^C[3][D[k&255]]}decrypt(f,p,_,k,D,C){const A=this._key[1];let w=f^A[0],P=k^A[1],S=_^A[2],M=p^A[3],U,R,J;const ie=A.length/4-2;let X,V=4;const L=this._tables[1],H=L[0],q=L[1],$=L[2],G=L[3],oe=L[4];for(X=0;X<ie;X++)U=H[w>>>24]^q[P>>16&255]^$[S>>8&255]^G[M&255]^A[V],R=H[P>>>24]^q[S>>16&255]^$[M>>8&255]^G[w&255]^A[V+1],J=H[S>>>24]^q[M>>16&255]^$[w>>8&255]^G[P&255]^A[V+2],M=H[M>>>24]^q[w>>16&255]^$[P>>8&255]^G[S&255]^A[V+3],V+=4,w=U,P=R,S=J;for(X=0;X<4;X++)D[(3&-X)+C]=oe[w>>>24]<<24^oe[P>>16&255]<<16^oe[S>>8&255]<<8^oe[M&255]^A[V++],U=w,w=P,P=S,S=M,M=U}}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(f){this.jobs.push(f),this.timeout_||(this.timeout_=setTimeout(this.processJob_.bind(this),this.delay))}}const a=function(g){return g<<24|(g&65280)<<8|(g&16711680)>>8|g>>>24},o=function(g,f,p){const _=new Int32Array(g.buffer,g.byteOffset,g.byteLength>>2),k=new r(Array.prototype.slice.call(f)),D=new Uint8Array(g.byteLength),C=new Int32Array(D.buffer);let A,w,P,S,M,U,R,J,ie;for(A=p[0],w=p[1],P=p[2],S=p[3],ie=0;ie<_.length;ie+=4)M=a(_[ie]),U=a(_[ie+1]),R=a(_[ie+2]),J=a(_[ie+3]),k.decrypt(M,U,R,J,C,ie),C[ie]=a(C[ie]^A),C[ie+1]=a(C[ie+1]^w),C[ie+2]=a(C[ie+2]^P),C[ie+3]=a(C[ie+3]^S),A=M,w=U,P=R,S=J;return D};class c{constructor(f,p,_,k){const D=c.STEP,C=new Int32Array(f.buffer),A=new Uint8Array(f.byteLength);let w=0;for(this.asyncStream_=new s,this.asyncStream_.push(this.decryptChunk_(C.subarray(w,w+D),p,_,A)),w=D;w<C.length;w+=D)_=new Uint32Array([a(C[w-4]),a(C[w-3]),a(C[w-2]),a(C[w-1])]),this.asyncStream_.push(this.decryptChunk_(C.subarray(w,w+D),p,_,A));this.asyncStream_.push(function(){k(null,e(A))})}static get STEP(){return 32e3}decryptChunk_(f,p,_,k){return function(){const D=o(f,p,_);k.set(D,f.byteOffset)}}}var u=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},d;typeof window<"u"?d=window:typeof u<"u"?d=u:typeof self<"u"?d=self:d={};var h=d,y=function(f){return ArrayBuffer.isView==="function"?ArrayBuffer.isView(f):f&&f.buffer instanceof ArrayBuffer},v=h.BigInt||Number;v("0x1"),v("0x100"),v("0x10000"),v("0x1000000"),v("0x100000000"),v("0x10000000000"),v("0x1000000000000"),v("0x100000000000000"),v("0x10000000000000000"),function(){var g=new Uint16Array([65484]),f=new Uint8Array(g.buffer,g.byteOffset,g.byteLength);return f[0]===255?"big":f[0]===204?"little":"unknown"}();const b=function(g){const f={};return Object.keys(g).forEach(p=>{const _=g[p];y(_)?f[p]={bytes:_.buffer,byteOffset:_.byteOffset,byteLength:_.byteLength}:f[p]=_}),f};self.onmessage=function(g){const f=g.data,p=new Uint8Array(f.encrypted.bytes,f.encrypted.byteOffset,f.encrypted.byteLength),_=new Uint32Array(f.key.bytes,f.key.byteOffset,f.key.byteLength/4),k=new Uint32Array(f.iv.bytes,f.iv.byteOffset,f.iv.byteLength/4);new c(p,_,k,function(D,C){self.postMessage(b({source:f.source,decrypted:C}),[C.buffer])})}}));var lN=H2(oN);const cN=i=>{let e=i.default?"main":"alternative";return i.characteristics&&i.characteristics.indexOf("public.accessibility.describes-video")>=0&&(e="main-desc"),e},b_=(i,e)=>{i.abort(),i.pause(),e&&e.activePlaylistLoader&&(e.activePlaylistLoader.pause(),e.activePlaylistLoader=null)},Yp=(i,e)=>{e.activePlaylistLoader=i,i.load()},uN=(i,e)=>()=>{const{segmentLoaders:{[i]:t,main:n},mediaTypes:{[i]:r}}=e,s=r.activeTrack(),a=r.getActiveGroup(),o=r.activePlaylistLoader,c=r.lastGroup_;if(!(a&&c&&a.id===c.id)&&(r.lastGroup_=a,r.lastTrack_=s,b_(t,r),!(!a||a.isMainPlaylist))){if(!a.playlistLoader){o&&n.resetEverything();return}t.resyncLoader(),Yp(a.playlistLoader,r)}},dN=(i,e)=>()=>{const{segmentLoaders:{[i]:t},mediaTypes:{[i]:n}}=e;n.lastGroup_=null,t.abort(),t.pause()},hN=(i,e)=>()=>{const{mainPlaylistLoader:t,segmentLoaders:{[i]:n,main:r},mediaTypes:{[i]:s}}=e,a=s.activeTrack(),o=s.getActiveGroup(),c=s.activePlaylistLoader,u=s.lastTrack_;if(!(u&&a&&u.id===a.id)&&(s.lastGroup_=o,s.lastTrack_=a,b_(n,s),!!o)){if(o.isMainPlaylist){if(!a||!u||a.id===u.id)return;const d=e.vhs.playlistController_,h=d.selectPlaylist();if(d.media()===h)return;s.logger_(`track change. Switching main audio from ${u.id} to ${a.id}`),t.pause(),r.resetEverything(),d.fastQualityChange_(h);return}if(i==="AUDIO"){if(!o.playlistLoader){r.setAudio(!0),r.resetEverything();return}n.setAudio(!0),r.setAudio(!1)}if(c===o.playlistLoader){Yp(o.playlistLoader,s);return}n.track&&n.track(a),n.resetEverything(),Yp(o.playlistLoader,s)}},Ku={AUDIO:(i,e)=>()=>{const{mediaTypes:{[i]:t},excludePlaylist:n}=e,r=t.activeTrack(),s=t.activeGroup(),a=(s.filter(c=>c.default)[0]||s[0]).id,o=t.tracks[a];if(r===o){n({error:{message:"Problem encountered loading the default audio track."}});return}pe.log.warn("Problem encountered loading the alternate audio track.Switching back to default.");for(const c in t.tracks)t.tracks[c].enabled=t.tracks[c]===o;t.onTrackChanged()},SUBTITLES:(i,e)=>()=>{const{mediaTypes:{[i]:t}}=e;pe.log.warn("Problem encountered loading the subtitle track.Disabling subtitle track.");const n=t.activeTrack();n&&(n.mode="disabled"),t.onTrackChanged()}},__={AUDIO:(i,e,t)=>{if(!e)return;const{tech:n,requestOptions:r,segmentLoaders:{[i]:s}}=t;e.on("loadedmetadata",()=>{const a=e.media();s.playlist(a,r),(!n.paused()||a.endList&&n.preload()!=="none")&&s.load()}),e.on("loadedplaylist",()=>{s.playlist(e.media(),r),n.paused()||s.load()}),e.on("error",Ku[i](i,t))},SUBTITLES:(i,e,t)=>{const{tech:n,requestOptions:r,segmentLoaders:{[i]:s},mediaTypes:{[i]:a}}=t;e.on("loadedmetadata",()=>{const o=e.media();s.playlist(o,r),s.track(a.activeTrack()),(!n.paused()||o.endList&&n.preload()!=="none")&&s.load()}),e.on("loadedplaylist",()=>{s.playlist(e.media(),r),n.paused()||s.load()}),e.on("error",Ku[i](i,t))}},fN={AUDIO:(i,e)=>{const{vhs:t,sourceType:n,segmentLoaders:{[i]:r},requestOptions:s,main:{mediaGroups:a},mediaTypes:{[i]:{groups:o,tracks:c,logger_:u}},mainPlaylistLoader:d}=e,h=_l(d.main);(!a[i]||Object.keys(a[i]).length===0)&&(a[i]={main:{default:{default:!0}}},h&&(a[i].main.default.playlists=d.main.playlists));for(const y in a[i]){o[y]||(o[y]=[]);for(const v in a[i][y]){let b=a[i][y][v],g;if(h?(u(`AUDIO group '${y}' label '${v}' is a main playlist`),b.isMainPlaylist=!0,g=null):n==="vhs-json"&&b.playlists?g=new Ya(b.playlists[0],t,s):b.resolvedUri?g=new Ya(b.resolvedUri,t,s):b.playlists&&n==="dash"?g=new jp(b.playlists[0],t,s,d):g=null,b=Mt({id:v,playlistLoader:g},b),__[i](i,b.playlistLoader,e),o[y].push(b),typeof c[v]>"u"){const f=new pe.AudioTrack({id:v,kind:cN(b),enabled:!1,language:b.language,default:b.default,label:v});c[v]=f}}}r.on("error",Ku[i](i,e))},SUBTITLES:(i,e)=>{const{tech:t,vhs:n,sourceType:r,segmentLoaders:{[i]:s},requestOptions:a,main:{mediaGroups:o},mediaTypes:{[i]:{groups:c,tracks:u}},mainPlaylistLoader:d}=e;for(const h in o[i]){c[h]||(c[h]=[]);for(const y in o[i][h]){if(!n.options_.useForcedSubtitles&&o[i][h][y].forced)continue;let v=o[i][h][y],b;if(r==="hls")b=new Ya(v.resolvedUri,n,a);else if(r==="dash"){if(!v.playlists.filter(f=>f.excludeUntil!==1/0).length)return;b=new jp(v.playlists[0],n,a,d)}else r==="vhs-json"&&(b=new Ya(v.playlists?v.playlists[0]:v.resolvedUri,n,a));if(v=Mt({id:y,playlistLoader:b},v),__[i](i,v.playlistLoader,e),c[h].push(v),typeof u[y]>"u"){const g=t.addRemoteTextTrack({id:y,kind:"subtitles",default:v.default&&v.autoselect,language:v.language,label:y},!1).track;u[y]=g}}}s.on("error",Ku[i](i,e))},"CLOSED-CAPTIONS":(i,e)=>{const{tech:t,main:{mediaGroups:n},mediaTypes:{[i]:{groups:r,tracks:s}}}=e;for(const a in n[i]){r[a]||(r[a]=[]);for(const o in n[i][a]){const c=n[i][a][o];if(!/^(?:CC|SERVICE)/.test(c.instreamId))continue;const u=t.options_.vhs&&t.options_.vhs.captionServices||{};let d={label:o,language:c.language,instreamId:c.instreamId,default:c.default&&c.autoselect};if(u[d.instreamId]&&(d=Mt(d,u[d.instreamId])),d.default===void 0&&delete d.default,r[a].push(Mt({id:o},c)),typeof s[o]>"u"){const h=t.addRemoteTextTrack({id:d.instreamId,kind:"captions",default:d.default,language:d.language,label:d.label},!1).track;s[o]=h}}}}},k_=(i,e)=>{for(let t=0;t<i.length;t++)if(Rp(e,i[t])||i[t].playlists&&k_(i[t].playlists,e))return!0;return!1},pN=(i,e)=>t=>{const{mainPlaylistLoader:n,mediaTypes:{[i]:{groups:r}}}=e,s=n.media();if(!s)return null;let a=null;s.attributes[i]&&(a=r[s.attributes[i]]);const o=Object.keys(r);if(!a)if(i==="AUDIO"&&o.length>1&&_l(e.main))for(let c=0;c<o.length;c++){const u=r[o[c]];if(k_(u,s)){a=u;break}}else r.main?a=r.main:o.length===1&&(a=r[o[0]]);return typeof t>"u"?a:t===null||!a?null:a.filter(c=>c.id===t.id)[0]||null},mN={AUDIO:(i,e)=>()=>{const{mediaTypes:{[i]:{tracks:t}}}=e;for(const n in t)if(t[n].enabled)return t[n];return null},SUBTITLES:(i,e)=>()=>{const{mediaTypes:{[i]:{tracks:t}}}=e;for(const n in t)if(t[n].mode==="showing"||t[n].mode==="hidden")return t[n];return null}},gN=(i,{mediaTypes:e})=>()=>{const t=e[i].activeTrack();return t?e[i].activeGroup(t):null},vN=i=>{["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(u=>{fN[u](u,i)});const{mediaTypes:e,mainPlaylistLoader:t,tech:n,vhs:r,segmentLoaders:{["AUDIO"]:s,main:a}}=i;["AUDIO","SUBTITLES"].forEach(u=>{e[u].activeGroup=pN(u,i),e[u].activeTrack=mN[u](u,i),e[u].onGroupChanged=uN(u,i),e[u].onGroupChanging=dN(u,i),e[u].onTrackChanged=hN(u,i),e[u].getActiveGroup=gN(u,i)});const o=e.AUDIO.activeGroup();if(o){const u=(o.filter(h=>h.default)[0]||o[0]).id;e.AUDIO.tracks[u].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(u=>e[u].onGroupChanged())}),t.on("mediachanging",()=>{["AUDIO","SUBTITLES"].forEach(u=>e[u].onGroupChanging())});const c=()=>{e.AUDIO.onTrackChanged(),n.trigger({type:"usage",name:"vhs-audio-change"})};n.audioTracks().addEventListener("change",c),n.remoteTextTracks().addEventListener("change",e.SUBTITLES.onTrackChanged),r.on("dispose",()=>{n.audioTracks().removeEventListener("change",c),n.remoteTextTracks().removeEventListener("change",e.SUBTITLES.onTrackChanged)}),n.clearTracks("audio");for(const u in e.AUDIO.tracks)n.audioTracks().addTrack(e.AUDIO.tracks[u])},yN=()=>{const i={};return["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(e=>{i[e]={groups:{},tracks:{},activePlaylistLoader:null,activeGroup:Rr,activeTrack:Rr,getActiveGroup:Rr,onGroupChanged:Rr,onTrackChanged:Rr,lastTrack_:null,logger_:Mi(`MediaGroups[${e}]`)}}),i};class T_{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_=ui(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 bN extends pe.EventTarget{constructor(e,t){super(),this.currentPathway=null,this.defaultPathway=null,this.queryBeforeStart=!1,this.availablePathways_=new Set,this.steeringManifest=new T_,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_=Mi("Content Steering"),this.xhr_=e,this.getBandwidth_=t}assignTagProperties(e,t){this.manifestType_=t.serverUri?"HLS":"DASH";const n=t.serverUri||t.serverURL;if(!n){this.logger_(`steering manifest URL is ${n}, cannot request steering manifest.`),this.trigger("error");return}if(n.startsWith("data:")){this.decodeDataUriManifest_(n.substring(n.indexOf(",")+1));return}this.steeringManifest.reloadUri=ui(e,n),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 n=e?t:this.getRequestURI(t);if(!n){this.logger_("No valid content steering manifest URIs. Stopping content steering."),this.trigger("error"),this.dispose();return}const r={contentSteeringInfo:{uri:n}};this.trigger({type:"contentsteeringloadstart",metadata:r}),this.request_=this.xhr_({uri:n,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 ${n} this session.`),this.excludedSteeringManifestURLs.add(n);return}if(a.status===429){const u=a.responseHeaders["retry-after"];this.logger_(`manifest request 429 ${s}.`),this.logger_(`content steering will retry in ${u} seconds.`),this.startTTLTimeout_(parseInt(u,10));return}this.logger_(`manifest failed to load ${s}.`),this.startTTLTimeout_();return}this.trigger({type:"contentsteeringloadcomplete",metadata:r});let o;try{o=JSON.parse(this.request_.responseText)}catch(u){const d={errorType:pe.Error.StreamingContentSteeringParserError,error:u};this.trigger({type:"error",metadata:d})}this.assignSteeringProperties_(o);const c={contentSteeringInfo:r.contentSteeringInfo,contentSteeringManifest:{version:this.steeringManifest.version,reloadUri:this.steeringManifest.reloadUri,priority:this.steeringManifest.priority}};this.trigger({type:"contentsteeringparsed",metadata:c}),this.startTTLTimeout_()})}setProxyServerUrl_(e){const t=new te.URL(e),n=new te.URL(this.proxyServerUrl_);return n.searchParams.set("url",encodeURI(t.toString())),this.setSteeringParams_(n.toString())}decodeDataUriManifest_(e){const t=JSON.parse(te.atob(e));this.assignSteeringProperties_(t)}setSteeringParams_(e){const t=new te.URL(e),n=this.getPathway(),r=this.getBandwidth_();if(n){const s=`_${this.manifestType_}_pathway`;t.searchParams.set(s,n)}if(r){const s=`_${this.manifestType_}_throughput`;t.searchParams.set(s,r)}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 n=(r=>{for(const s of r)if(this.availablePathways_.has(s))return s;return[...this.availablePathways_][0]})(this.steeringManifest.priority);this.currentPathway!==n&&(this.currentPathway=n,this.trigger("content-steering"))}getPathway(){return this.currentPathway||this.defaultPathway}getRequestURI(e){if(!e)return null;const t=r=>this.excludedSteeringManifestURLs.has(r);if(this.proxyServerUrl_){const r=this.setProxyServerUrl_(e);if(!t(r))return r}const n=this.setSteeringParams_(e);return t(n)?null:n}startTTLTimeout_(e=this.steeringManifest.ttl){const t=e*1e3;this.ttlTimeout_=te.setTimeout(()=>{this.requestSteeringManifest()},t)}clearTTLTimeout_(){te.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 T_}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&&(ui(e,t.serverURL)!==this.steeringManifest.reloadUri||t.defaultServiceLocation!==this.defaultPathway||t.queryBeforeStart!==this.queryBeforeStart||t.proxyServerURL!==this.proxyServerUrl_)}getAvailablePathways(){return this.availablePathways_}}const _N=(i,e)=>{let t=null;return(...n)=>{clearTimeout(t),t=setTimeout(()=>{i.apply(null,n)},e)}},kN=10;let ds;const TN=["mediaRequests","mediaRequestsAborted","mediaRequestsTimedout","mediaRequestsErrored","mediaTransferDuration","mediaBytesTransferred","mediaAppends"],SN=function(i){return this.audioSegmentLoader_[i]+this.mainSegmentLoader_[i]},CN=function({currentPlaylist:i,buffered:e,currentTime:t,nextPlaylist:n,bufferLowWaterLine:r,bufferHighWaterLine:s,duration:a,bufferBasedABR:o,log:c}){if(!n)return pe.log.warn("We received no playlist to switch to. Please check your stream."),!1;const u=`allowing switch ${i&&i.id||"null"} -> ${n.id}`;if(!i)return c(`${u} as current playlist is not set`),!0;if(n.id===i.id)return!1;const d=!!Wa(e,t).length;if(!i.endList)return!d&&typeof i.partTargetDuration=="number"?(c(`not ${u} as current playlist is live llhls, but currentTime isn't in buffered.`),!1):(c(`${u} as current playlist is live`),!0);const h=Ip(e,t),y=o?Nn.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE:Nn.MAX_BUFFER_LOW_WATER_LINE;if(a<y)return c(`${u} as duration < max low water line (${a} < ${y})`),!0;const v=n.attributes.BANDWIDTH,b=i.attributes.BANDWIDTH;if(v<b&&(!o||h<s)){let g=`${u} as next bandwidth < current bandwidth (${v} < ${b})`;return o&&(g+=` and forwardBuffer < bufferHighWaterLine (${h} < ${s})`),c(g),!0}if((!o||v>b)&&h>=r){let g=`${u} as forwardBuffer >= bufferLowWaterLine (${h} >= ${r})`;return o&&(g+=` and next bandwidth > current bandwidth (${v} > ${b})`),c(g),!0}return c(`not ${u} as no switching criteria met`),!1};class xN extends pe.EventTarget{constructor(e){super(),this.fastQualityChange_=_N(this.fastQualityChange_.bind(this),100);const{src:t,withCredentials:n,tech:r,bandwidth:s,externVhs:a,useCueTags:o,playlistExclusionDuration:c,enableLowInitialPlaylist:u,sourceType:d,cacheEncryptionKeys:h,bufferBasedABR:y,leastPixelDiffSelector:v,captionServices:b,experimentalUseMMS:g}=e;if(!t)throw new Error("A non-empty playlist URL or JSON manifest string is required");let{maxPlaylistRetries:f}=e;(f===null||typeof f>"u")&&(f=1/0),ds=a,this.bufferBasedABR=!!y,this.leastPixelDiffSelector=!!v,this.withCredentials=n,this.tech_=r,this.vhs_=r.vhs,this.player_=e.player_,this.sourceType_=d,this.useCueTags_=o,this.playlistExclusionDuration=c,this.maxPlaylistRetries=f,this.enableLowInitialPlaylist=u,this.usingManagedMediaSource_=!1,this.useCueTags_&&(this.cueTagsTrack_=this.tech_.addTextTrack("metadata","ad-cues"),this.cueTagsTrack_.inBandMetadataTrackDispatchType=""),this.requestOptions_={withCredentials:n,maxPlaylistRetries:f,timeout:null},this.on("error",this.pauseLoading),this.mediaTypes_=yN(),g&&te.ManagedMediaSource?(this.tech_.el_.disableRemotePlayback=!0,this.mediaSource=new te.ManagedMediaSource,this.usingManagedMediaSource_=!0,pe.log("Using ManagedMediaSource")):te.MediaSource&&(this.mediaSource=new te.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_=Pn(),this.hasPlayed_=!1,this.syncController_=new sN(e),this.segmentMetadataTrack_=r.addRemoteTextTrack({kind:"metadata",label:"segment-metadata"},!1).track,this.segmentMetadataTrack_.mode="hidden",this.decrypter_=new lN,this.sourceUpdater_=new f_(this.mediaSource),this.inbandTextTracks_={},this.timelineChangeController_=new aN,this.keyStatusMap_=new Map;const p={vhs:this.vhs_,parse708captions:e.parse708captions,useDtsForTimestampOffset:e.useDtsForTimestampOffset,captionServices:b,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:h,sourceUpdater:this.sourceUpdater_,timelineChangeController:this.timelineChangeController_,exactManifestTimings:e.exactManifestTimings,addMetadataToTextTrack:this.addMetadataToTextTrack.bind(this)};this.mainPlaylistLoader_=this.sourceType_==="dash"?new jp(t,this.vhs_,Mt(this.requestOptions_,{addMetadataToTextTrack:this.addMetadataToTextTrack.bind(this)})):new Ya(t,this.vhs_,Mt(this.requestOptions_,{addDateRangesToTextTrack:this.addDateRangesToTextTrack_.bind(this)})),this.setupMainPlaylistLoaderListeners_(),this.mainSegmentLoader_=new Wp(Mt(p,{segmentMetadataTrack:this.segmentMetadataTrack_,loaderType:"main"}),e),this.audioSegmentLoader_=new Wp(Mt(p,{loaderType:"audio"}),e),this.subtitleSegmentLoader_=new eN(Mt(p,{loaderType:"vtt",featuresNativeTextTracks:this.tech_.featuresNativeTextTracks,loadVttJs:()=>new Promise((D,C)=>{function A(){r.off("vttjserror",w),D()}function w(){r.off("vttjsloaded",A),C()}r.one("vttjsloaded",A),r.one("vttjserror",w),r.addWebVttScript_()})}),e);const _=()=>this.mainSegmentLoader_.bandwidth;this.contentSteeringController_=new bN(this.vhs_.xhr,_),this.setupSegmentLoaderListeners_(),this.bufferBasedABR&&(this.mainPlaylistLoader_.one("loadedplaylist",()=>this.startABRTimer_()),this.tech_.on("pause",()=>this.stopABRTimer_()),this.tech_.on("play",()=>this.startABRTimer_())),TN.forEach(D=>{this[D+"_"]=SN.bind(this,D)}),this.logger_=Mi("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 k=this.tech_.preload()==="none"?"play":"loadstart";this.tech_.one(k,()=>{const D=Date.now();this.tech_.one("loadeddata",()=>{this.timeToLoadedData__=Date.now()-D,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,n){const r=this.media(),s=r&&(r.id||r.uri),a=e&&(e.id||e.uri);if(s&&s!==a){this.logger_(`switch media ${s} -> ${a} from ${t}`);const o={renditionInfo:{id:a,bandwidth:e.attributes.BANDWIDTH,resolution:e.attributes.RESOLUTION,codecs:e.attributes.CODECS},cause:t};this.trigger({type:"renditionselected",metadata:o}),this.tech_.trigger({type:"usage",name:`vhs-rendition-change-${t}`})}this.mainPlaylistLoader_.media(e,n)}switchMediaForDASHContentSteering_(){["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(e=>{const t=this.mediaTypes_[e],n=t?t.activeGroup():null,r=this.contentSteeringController_.getPathway();if(n&&r){const a=(n.length?n[0].playlists:n.playlists).filter(o=>o.attributes.serviceLocation===r);a.length&&this.mediaTypes_[e].activePlaylistLoader.media(a[0])}})}startABRTimer_(){this.stopABRTimer_(),this.abrTimer_=te.setInterval(()=>this.checkABR_(),250)}stopABRTimer_(){this.tech_.scrubbing&&this.tech_.scrubbing()||(te.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 n=e.mediaGroups.AUDIO,r=Object.keys(n);let s;if(Object.keys(this.mediaTypes_.AUDIO.groups).length)s=this.mediaTypes_.AUDIO.activeTrack();else{const o=n.main||r.length&&n[r[0]];for(const c in o)if(o[c].default){s={label:c};break}}if(!s)return t;const a=[];for(const o in n)if(n[o][s.label]){const c=n[o][s.label];if(c.playlists&&c.playlists.length)a.push.apply(a,c.playlists);else if(c.uri)a.push(c);else if(e.playlists.length)for(let u=0;u<e.playlists.length;u++){const d=e.playlists[u];d.attributes&&d.attributes.AUDIO&&d.attributes.AUDIO===o&&a.push(d)}}return a.length?a:t}setupMainPlaylistLoaderListeners_(){this.mainPlaylistLoader_.on("loadedmetadata",()=>{const t=this.mainPlaylistLoader_.media(),n=t.targetDuration*1.5*1e3;Mp(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.media())?this.requestOptions_.timeout=0:this.requestOptions_.timeout=n,t.endList&&this.tech_.preload()!=="none"&&(this.mainSegmentLoader_.playlist(t,this.requestOptions_),this.mainSegmentLoader_.load()),vN({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(),t),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 t=this.mainPlaylistLoader_.media();if(!t){this.attachContentSteeringListeners_(),this.initContentSteeringController_(),this.excludeUnsupportedVariants_();let n;if(this.enableLowInitialPlaylist&&(n=this.selectInitialPlaylist()),n||(n=this.selectPlaylist()),!n||!this.shouldSwitchToMedia_(n)||(this.initialMedia_=n,this.switchMedia_(this.initialMedia_,"initial"),!(this.sourceType_==="vhs-json"&&this.initialMedia_.segments)))return;t=this.initialMedia_}this.handleUpdatedMediaPlaylist(t)}),this.mainPlaylistLoader_.on("error",()=>{const t=this.mainPlaylistLoader_.error;this.excludePlaylist({playlistToExclude:t.playlist,error:t})}),this.mainPlaylistLoader_.on("mediachanging",()=>{this.mainSegmentLoader_.abort(),this.mainSegmentLoader_.pause()}),this.mainPlaylistLoader_.on("mediachange",()=>{const t=this.mainPlaylistLoader_.media(),n=t.targetDuration*1.5*1e3;Mp(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.media())?this.requestOptions_.timeout=0:this.requestOptions_.timeout=n,this.sourceType_==="dash"&&this.mainPlaylistLoader_.isPaused&&this.mainPlaylistLoader_.load(),this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.playlist(t,this.requestOptions_),this.waitingForFastQualityPlaylistReceived_?this.runFastQualitySwitch_():this.mainSegmentLoader_.load(),this.tech_.trigger({type:"mediachange",bubbles:!0})}),this.mainPlaylistLoader_.on("playlistunchanged",()=>{const t=this.mainPlaylistLoader_.media();if(t.lastExcludeReason_==="playlist-unchanged")return;this.stuckAtPlaylistEnd_(t)&&(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(t=>{this.mainPlaylistLoader_.on(t,n=>{this.player_.trigger(yn({},n))})})}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 n=e.mediaGroups||{};let r=!0;const s=Object.keys(n.AUDIO);for(const a in n.AUDIO)for(const o in n.AUDIO[a])n.AUDIO[a][o].uri||(r=!1);r&&this.tech_.trigger({type:"usage",name:"vhs-demuxed"}),Object.keys(n.SUBTITLES).length&&this.tech_.trigger({type:"usage",name:"vhs-webvtt"}),ds.Playlist.isAes(t)&&this.tech_.trigger({type:"usage",name:"vhs-aes"}),s.length&&Object.keys(n.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_,n=this.tech_.currentTime(),r=this.bufferLowWaterLine(),s=this.bufferHighWaterLine(),a=this.tech_.buffered();return CN({buffered:a,currentTime:n,currentPlaylist:t,nextPlaylist:e,bufferLowWaterLine:r,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 n=this.mainSegmentLoader_.error();this.excludePlaylist({playlistToExclude:n.playlist,error:n})}),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 n=this.audioSegmentLoader_.pendingSegment_;if(!n||!n.segment||!n.segment.syncInfo)return;const r=n.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",n=>{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:kN}))});const e=()=>{if(!this.sourceUpdater_.hasCreatedSourceBuffers())return this.tryToCreateSourceBuffers_();const n=this.getCodecsOrExclude_();n&&this.sourceUpdater_.addOrChangeSourceBuffers(n)};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(n=>{this.mainSegmentLoader_.on(n,r=>{this.player_.trigger(yn({},r))}),this.audioSegmentLoader_.on(n,r=>{this.player_.trigger(yn({},r))}),this.subtitleSegmentLoader_.on(n,r=>{this.player_.trigger(yn({},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 n=t.end(0);let r=n;if(e.start){const s=e.start.timeOffset;s<0?r=Math.max(n+s,t.start(0)):r=Math.min(n,s)}this.trigger("firstplay"),this.tech_.setCurrentTime(r)}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 n=this.syncController_.getExpiredTime(e,this.duration());if(n===null)return!1;const r=ds.Playlist.playlistEnd(e,n),s=this.tech_.currentTime(),a=this.tech_.buffered();if(!a.length)return r-s<=pr;const o=a.end(a.length-1);return o-s<=pr&&r-o<=pr}excludePlaylist({playlistToExclude:e=this.mainPlaylistLoader_.media(),error:t={},playlistExclusionDuration:n}){if(e=e||this.mainPlaylistLoader_.media(),n=n||t.playlistExclusionDuration||this.playlistExclusionDuration,!e){this.error=t,this.mediaSource.readyState!=="open"?this.trigger("error"):this.sourceUpdater_.endOfStream("network");return}e.playlistErrors_++;const r=this.mainPlaylistLoader_.main.playlists,s=r.filter(qu),a=s.length===1&&s[0]===e;if(r.length===1&&n!==1/0)return pe.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 b=this.pathwayAttribute_(e),g=this.contentSteeringController_.steeringManifest.ttl*1e3;this.contentSteeringController_.excludePathway(b),this.excludeThenChangePathway_(),setTimeout(()=>{this.contentSteeringController_.addAvailablePathway(b)},g);return}let v=!1;r.forEach(b=>{if(b===e)return;const g=b.excludeUntil;typeof g<"u"&&g!==1/0&&(v=!0,delete b.excludeUntil)}),v&&(pe.log.warn("Removing other playlists from the exclusion list because the last rendition is about to be excluded."),this.tech_.trigger("retryplaylist"))}let o;e.playlistErrors_>this.maxPlaylistRetries?o=1/0:o=Date.now()+n*1e3,e.excludeUntil=o,t.reason&&(e.lastExcludeReason_=t.reason),this.tech_.trigger("excludeplaylist"),this.tech_.trigger({type:"usage",name:"vhs-rendition-excluded"});const c=this.selectPlaylist();if(!c){this.error="Playback cannot continue. No available working or supported playlists.",this.trigger("error");return}const u=t.internal?this.logger_:pe.log.warn,d=t.message?" "+t.message:"";u(`${t.internal?"Internal problem":"Problem"} encountered with playlist ${e.id}.${d} Switching to playlist ${c.id}.`),c.attributes.AUDIO!==e.attributes.AUDIO&&this.delegateLoaders_("audio",["abort","pause"]),c.attributes.SUBTITLES!==e.attributes.SUBTITLES&&this.delegateLoaders_("subtitle",["abort","pause"]),this.delegateLoaders_("main",["abort","pause"]);const h=c.targetDuration/2*1e3||5*1e3,y=typeof c.lastRequest=="number"&&Date.now()-c.lastRequest<=h;return this.switchMedia_(c,"exclude",a||y)}pauseLoading(){this.delegateLoaders_("all",["abort","pause"]),this.stopABRTimer_()}delegateLoaders_(e,t){const n=[],r=e==="all";(r||e==="main")&&n.push(this.mainPlaylistLoader_);const s=[];(r||e==="audio")&&s.push("AUDIO"),(r||e==="subtitle")&&(s.push("CLOSED-CAPTIONS"),s.push("SUBTITLES")),s.forEach(a=>{const o=this.mediaTypes_[a]&&this.mediaTypes_[a].activePlaylistLoader;o&&n.push(o)}),["main","audio","subtitle"].forEach(a=>{const o=this[`${a}SegmentLoader_`];o&&(e===a||e==="all")&&n.push(o)}),n.forEach(a=>t.forEach(o=>{typeof a[o]=="function"&&a[o]()}))}setCurrentTime(e){const t=Wa(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:ds.Playlist.duration(e):1/0:0}seekable(){return this.seekable_}getSeekableRange_(e,t){const n=e.media();if(!n)return null;const r=this.syncController_.getMediaSequenceSync(t);if(r&&r.isReliable){const o=r.start,c=r.end;if(!isFinite(o)||!isFinite(c))return null;const u=ds.Playlist.liveEdgeDelay(this.mainPlaylistLoader_.main,n),d=Math.max(o,c-u);return Pn([[o,d]])}const s=this.syncController_.getExpiredTime(n,this.duration());if(s===null)return null;const a=ds.Playlist.seekable(n,s,ds.Playlist.liveEdgeDelay(this.mainPlaylistLoader_.main,n));return a.length?a:null}computeFinalSeekable_(e,t){if(!t)return e;const n=e.start(0),r=e.end(0),s=t.start(0),a=t.end(0);return s>r||n>a?e:Pn([[Math.max(n,s),Math.min(r,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 n=this.seekable_;if(this.seekable_=this.computeFinalSeekable_(e,t),!this.seekable_||n&&n.length&&this.seekable_.length&&n.start(0)===this.seekable_.start(0)&&n.end(0)===this.seekable_.end(0))return;this.logger_(`seekable updated [${d2(this.seekable_)}]`);const r={seekableRanges:this.seekable_};this.trigger({type:"seekablerangeschanged",metadata:r}),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 r=this.seekable();if(!r.length)return;(isNaN(this.mediaSource.duration)||this.mediaSource.duration<r.end(r.length-1))&&this.sourceUpdater_.setDuration(r.end(r.length-1));return}const t=this.tech_.buffered();let n=ds.Playlist.duration(this.mainPlaylistLoader_.media());t.length>0&&(n=Math.max(n,t.end(t.length-1))),this.mediaSource.duration!==n&&this.sourceUpdater_.setDuration(n)}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 n in t)t[n].forEach(r=>{r.playlistLoader&&r.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_(),n=e?!!this.audioSegmentLoader_.getCurrentMediaInfo_():!0;return!(!t||!n)}getCodecsOrExclude_(){const e={main:this.mainSegmentLoader_.getCurrentMediaInfo_()||{},audio:this.audioSegmentLoader_.getCurrentMediaInfo_()||{}},t=this.mainSegmentLoader_.getPendingSegmentPlaylist()||this.media();e.video=e.main;const n=Tl(this.main(),t),r={},s=!!this.mediaTypes_.AUDIO.activePlaylistLoader;if(e.main.hasVideo&&(r.video=n.video||e.main.videoCodec||b6),e.main.isMuxed&&(r.video+=`,${n.audio||e.main.audioCodec||jy}`),(e.main.hasAudio&&!e.main.isMuxed||e.audio.hasAudio||s)&&(r.audio=n.audio||e.main.audioCodec||e.audio.audioCodec||jy,e.audio.isFmp4=e.main.hasAudio&&!e.main.isMuxed?e.main.isFmp4:e.audio.isFmp4),!r.audio&&!r.video){this.excludePlaylist({playlistToExclude:t,error:{message:"Could not determine codecs for playlist."},playlistExclusionDuration:1/0});return}const a=(u,d)=>u?el(d,this.usingManagedMediaSource_):_f(d),o={};let c;if(["video","audio"].forEach(function(u){if(r.hasOwnProperty(u)&&!a(e[u].isFmp4,r[u])){const d=e[u].isFmp4?"browser":"muxer";o[d]=o[d]||[],o[d].push(r[u]),u==="audio"&&(c=d)}}),s&&c&&t.attributes.AUDIO){const u=t.attributes.AUDIO;this.main().playlists.forEach(d=>{(d.attributes&&d.attributes.AUDIO)===u&&d!==t&&(d.excludeUntil=1/0)}),this.logger_(`excluding audio group ${u} as ${c} does not support codec(s): "${r.audio}"`)}if(Object.keys(o).length){const u=Object.keys(o).reduce((d,h)=>(d&&(d+=", "),d+=`${h} does not support codec(s): "${o[h].join(",")}"`,d),"")+".";this.excludePlaylist({playlistToExclude:t,error:{internal:!0,message:u},playlistExclusionDuration:1/0});return}if(this.sourceUpdater_.hasCreatedSourceBuffers()&&!this.sourceUpdater_.canChangeType()){const u=[];if(["video","audio"].forEach(d=>{const h=(or(this.sourceUpdater_.codecs[d]||"")[0]||{}).type,y=(or(r[d]||"")[0]||{}).type;h&&y&&h.toLowerCase()!==y.toLowerCase()&&u.push(`"${this.sourceUpdater_.codecs[d]}" -> "${r[d]}"`)}),u.length){this.excludePlaylist({playlistToExclude:t,error:{message:`Codec switching not supported: ${u.join(", ")}.`,internal:!0},playlistExclusionDuration:1/0});return}}return r}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(n=>{const r=e[n];if(t.indexOf(r.id)!==-1)return;t.push(r.id);const s=Tl(this.main,r),a=[];s.audio&&!_f(s.audio)&&!el(s.audio,this.usingManagedMediaSource_)&&a.push(`audio codec ${s.audio}`),s.video&&!_f(s.video)&&!el(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&&(r.excludeUntil=1/0,this.logger_(`excluding ${r.id} for unsupported: ${a.join(", ")}`))})}excludeIncompatibleVariants_(e){const t=[],n=this.main().playlists,r=kl(or(e)),s=A2(r),a=r.video&&or(r.video)[0]||null,o=r.audio&&or(r.audio)[0]||null;Object.keys(n).forEach(c=>{const u=n[c];if(t.indexOf(u.id)!==-1||u.excludeUntil===1/0)return;t.push(u.id);const d=[],h=Tl(this.mainPlaylistLoader_.main,u),y=A2(h);if(!(!h.audio&&!h.video)){if(y!==s&&d.push(`codec count "${y}" !== "${s}"`),!this.sourceUpdater_.canChangeType()){const v=h.video&&or(h.video)[0]||null,b=h.audio&&or(h.audio)[0]||null;v&&a&&v.type.toLowerCase()!==a.type.toLowerCase()&&d.push(`video codec "${v.type}" !== "${a.type}"`),b&&o&&b.type.toLowerCase()!==o.type.toLowerCase()&&d.push(`audio codec "${b.type}" !== "${o.type}"`)}d.length&&(u.excludeUntil=1/0,this.logger_(`excluding ${u.id}: ${d.join(" && ")}`))}})}updateAdCues_(e){let t=0;const n=this.seekable();n.length&&(t=n.start(0)),nN(e,this.cueTagsTrack_,t)}goalBufferLength(){const e=this.tech_.currentTime(),t=Nn.GOAL_BUFFER_LENGTH,n=Nn.GOAL_BUFFER_LENGTH_RATE,r=Math.max(t,Nn.MAX_GOAL_BUFFER_LENGTH);return Math.min(t+e*n,r)}bufferLowWaterLine(){const e=this.tech_.currentTime(),t=Nn.BUFFER_LOW_WATER_LINE,n=Nn.BUFFER_LOW_WATER_LINE_RATE,r=Math.max(t,Nn.MAX_BUFFER_LOW_WATER_LINE),s=Math.max(t,Nn.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE);return Math.min(t+e*n,this.bufferBasedABR?s:r)}bufferHighWaterLine(){return Nn.BUFFER_HIGH_WATER_LINE}addDateRangesToTextTrack_(e){a_(this.inbandTextTracks_,"com.apple.streaming",this.tech_),RP({inbandTextTracks:this.inbandTextTracks_,dateRanges:e})}addMetadataToTextTrack(e,t,n){const r=this.sourceUpdater_.videoBuffer?this.sourceUpdater_.videoTimestampOffset():this.sourceUpdater_.audioTimestampOffset();a_(this.inbandTextTracks_,e,this.tech_),NP({inbandTextTracks:this.inbandTextTracks_,metadataArray:t,timestampOffset:r,videoDuration:n})}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(t=>{this.contentSteeringController_.on(t,n=>{this.trigger(yn({},n))})}),this.sourceType_==="dash"&&this.mainPlaylistLoader_.on("loadedplaylist",()=>{const t=this.main();(this.contentSteeringController_.didDASHTagChange(t.uri,t.contentSteering)||(()=>{const s=this.contentSteeringController_.getAvailablePathways(),a=[];for(const o of t.playlists){const c=o.attributes.serviceLocation;if(c&&(a.push(c),!s.has(c)))return!0}return!!(!a.length&&s.size)})())&&this.resetContentSteeringController_()})}excludeThenChangePathway_(){const e=this.contentSteeringController_.getPathway();if(!e)return;this.handlePathwayClones_();const n=this.main().playlists,r=new Set;let s=!1;Object.keys(n).forEach(a=>{const o=n[a],c=this.pathwayAttribute_(o),u=c&&e!==c;o.excludeUntil===1/0&&o.lastExcludeReason_==="content-steering"&&!u&&(delete o.excludeUntil,delete o.lastExcludeReason_,s=!0);const h=!o.excludeUntil&&o.excludeUntil!==1/0;!r.has(o.id)&&u&&h&&(r.add(o.id),o.excludeUntil=1/0,o.lastExcludeReason_="content-steering",this.logger_(`excluding ${o.id} for ${o.lastExcludeReason_}`))}),this.contentSteeringController_.manifestType_==="DASH"&&Object.keys(this.mediaTypes_).forEach(a=>{const o=this.mediaTypes_[a];if(o.activePlaylistLoader){const c=o.activePlaylistLoader.media_;c&&c.attributes.serviceLocation!==e&&(s=!0)}}),s&&this.changeSegmentPathway_()}handlePathwayClones_(){const t=this.main().playlists,n=this.contentSteeringController_.currentPathwayClones,r=this.contentSteeringController_.nextPathwayClones;if(n&&n.size||r&&r.size){for(const[a,o]of n.entries())r.get(a)||(this.mainPlaylistLoader_.updateOrDeleteClone(o),this.contentSteeringController_.excludePathway(a));for(const[a,o]of r.entries()){const c=n.get(a);if(!c){t.filter(d=>d.attributes["PATHWAY-ID"]===o["BASE-ID"]).forEach(d=>{this.mainPlaylistLoader_.addClonePathway(o,d)}),this.contentSteeringController_.addAvailablePathway(a);continue}this.equalPathwayClones_(c,o)||(this.mainPlaylistLoader_.updateOrDeleteClone(o,!0),this.contentSteeringController_.addAvailablePathway(a))}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 n=e["URI-REPLACEMENT"].PARAMS,r=t["URI-REPLACEMENT"].PARAMS;for(const s in n)if(n[s]!==r[s])return!1;for(const s in r)if(n[s]!==r[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(n=>{const r=this.mainPlaylistLoader_.getKeyIdSet(n);!r||!r.size||r.forEach(s=>{const a="usable",o=this.keyStatusMap_.has(s)&&this.keyStatusMap_.get(s)===a,c=n.lastExcludeReason_===t&&n.excludeUntil===1/0;o?o&&c&&(delete n.excludeUntil,delete n.lastExcludeReason_,this.logger_(`enabling playlist ${n.id} because key ID ${s} is ${a}`)):(n.excludeUntil!==1/0&&n.lastExcludeReason_!==t&&(n.excludeUntil=1/0,n.lastExcludeReason_=t,this.logger_(`excluding playlist ${n.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(n=>{const r=n&&n.attributes&&n.attributes.RESOLUTION&&n.attributes.RESOLUTION.height<720,s=n.excludeUntil===1/0&&n.lastExcludeReason_===t;r&&s&&(delete n.excludeUntil,pe.log.warn(`enabling non-HD playlist ${n.id} because all playlists were excluded due to ${t} key IDs`))})}addKeyStatus_(e,t){const s=(typeof e=="string"?e:QP(e)).slice(0,32).toLowerCase();this.logger_(`KeyStatus '${t}' with key ID ${s} added to the keyStatusMap`),this.keyStatusMap_.set(s,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 EN=(i,e,t)=>n=>{const r=i.main.playlists[e],s=Op(r),a=qu(r);if(typeof n>"u")return a;n?delete r.disabled:r.disabled=!0;const o={renditionInfo:{id:e,bandwidth:r.attributes.BANDWIDTH,resolution:r.attributes.RESOLUTION,codecs:r.attributes.CODECS},cause:"fast-quality"};return n!==a&&!s&&(n?(t(r),i.trigger({type:"renditionenabled",metadata:o})):i.trigger({type:"renditiondisabled",metadata:o})),n};class wN{constructor(e,t,n){const{playlistController_:r}=e,s=r.fastQualityChange_.bind(r);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=Tl(r.main(),t),this.playlist=t,this.id=n,this.enabled=EN(e.playlists,t.id,s)}}const DN=function(i){i.representations=()=>{const e=i.playlistController_.main(),t=_l(e)?i.playlistController_.getAudioTrackPlaylists_():e.playlists;return t?t.filter(n=>!Op(n)).map((n,r)=>new wN(i,n,n.id)):[]}},S_=["seeking","seeked","pause","playing","error"];class AN extends pe.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_=Mi("PlaybackWatcher"),this.logger_("initialize");const t=()=>this.monitorCurrentTime_(),n=()=>this.monitorCurrentTime_(),r=()=>this.techWaiting_(),s=()=>this.resetTimeUpdate_(),a=this.playlistController_,o=["main","subtitle","audio"],c={};o.forEach(d=>{c[d]={reset:()=>this.resetSegmentDownloads_(d),updateend:()=>this.checkSegmentDownloads_(d)},a[`${d}SegmentLoader_`].on("appendsdone",c[d].updateend),a[`${d}SegmentLoader_`].on("playlistupdate",c[d].reset),this.tech_.on(["seeked","seeking"],c[d].reset)});const u=d=>{["main","audio"].forEach(h=>{a[`${h}SegmentLoader_`][d]("appended",this.seekingAppendCheck_)})};this.seekingAppendCheck_=()=>{this.fixesBadSeeks_()&&(this.consecutiveUpdates=0,this.lastRecordedTime=this.tech_.currentTime(),u("off"))},this.clearSeekingAppendCheck_=()=>u("off"),this.watchForBadSeeking_=()=>{this.clearSeekingAppendCheck_(),u("on")},this.tech_.on("seeked",this.clearSeekingAppendCheck_),this.tech_.on("seeking",this.watchForBadSeeking_),this.tech_.on("waiting",r),this.tech_.on(S_,s),this.tech_.on("canplay",n),this.tech_.one("play",t),this.dispose=()=>{this.clearSeekingAppendCheck_(),this.logger_("dispose"),this.tech_.off("waiting",r),this.tech_.off(S_,s),this.tech_.off("canplay",n),this.tech_.off("play",t),this.tech_.off("seeking",this.watchForBadSeeking_),this.tech_.off("seeked",this.clearSeekingAppendCheck_),o.forEach(d=>{a[`${d}SegmentLoader_`].off("appendsdone",c[d].updateend),a[`${d}SegmentLoader_`].off("playlistupdate",c[d].reset),this.tech_.off(["seeked","seeking"],c[d].reset)}),this.checkCurrentTimeTimeout_&&te.clearTimeout(this.checkCurrentTimeTimeout_),this.resetTimeUpdate_()}}monitorCurrentTime_(){this.checkCurrentTime_(),this.checkCurrentTimeTimeout_&&te.clearTimeout(this.checkCurrentTimeTimeout_),this.checkCurrentTimeTimeout_=te.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_,n=t[`${e}SegmentLoader_`],r=n.buffered_(),s=vI(this[`${e}Buffered_`],r);if(this[`${e}Buffered_`]=r,s){const a={bufferedRanges:r};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:n.playlist_&&n.playlist_.id,buffered:qs(r)}),!(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+pr>=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(Pn([this.lastRecordedTime,e]));const n={playedRanges:this.playedRanges_};this.playlistController_.trigger({type:"playedrangeschanged",metadata:n}),this.consecutiveUpdates=0,this.lastRecordedTime=e}}resetTimeUpdate_(){this.consecutiveUpdates=0}fixesBadSeeks_(){if(!this.tech_.seeking())return!1;const t=this.seekable(),n=this.tech_.currentTime(),r=this.afterSeekableWindow_(t,n,this.media(),this.allowSeeksWithinUnsafeLiveWindow);let s;if(r&&(s=t.end(t.length-1)),this.beforeSeekableWindow_(t,n)){const b=t.start(0);s=b+(b===t.end(0)?0:pr)}if(typeof s<"u")return this.logger_(`Trying to seek outside of seekable at time ${n} with seekable range ${d2(t)}. Seeking to ${s}.`),this.tech_.setCurrentTime(s),!0;const a=this.playlistController_.sourceUpdater_,o=this.tech_.buffered(),c=a.audioBuffer?a.audioBuffered():null,u=a.videoBuffer?a.videoBuffered():null,d=this.media(),h=d.partTargetDuration?d.partTargetDuration:(d.targetDuration-fr)*2,y=[c,u];for(let b=0;b<y.length;b++){if(!y[b])continue;if(Ip(y[b],n)<h)return!1}const v=Hu(o,n);return v.length===0?!1:(s=v.start(0)+pr,this.logger_(`Buffered region starts (${v.start(0)}) just beyond seek point (${n}). Seeking to ${s}.`),this.tech_.setCurrentTime(s),!0)}waiting_(){if(this.techWaiting_())return;const e=this.tech_.currentTime(),t=this.tech_.buffered(),n=Wa(t,e);if(n.length&&e+3<=n.end(0)){this.resetTimeUpdate_(),this.tech_.setCurrentTime(e),this.logger_(`Stopped at ${e} while inside a buffered region [${n.start(0)} -> ${n.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 o=e.end(e.length-1);return this.logger_(`Fell out of live window at time ${t}. Seeking to live point (seekable end) ${o}`),this.resetTimeUpdate_(),this.tech_.setCurrentTime(o),this.tech_.trigger({type:"usage",name:"vhs-live-resync"}),!0}const n=this.tech_.vhs.playlistController_.sourceUpdater_,r=this.tech_.buffered();if(this.videoUnderflow_({audioBuffered:n.audioBuffered(),videoBuffered:n.videoBuffered(),currentTime:t}))return this.resetTimeUpdate_(),this.tech_.setCurrentTime(t),this.tech_.trigger({type:"usage",name:"vhs-video-underflow"}),!0;const a=Hu(r,t);return a.length>0?(this.logger_(`Stopped at ${t} and seeking to ${a.start(0)}`),this.resetTimeUpdate_(),this.skipTheGap_(t),!0):!1}afterSeekableWindow_(e,t,n,r=!1){if(!e.length)return!1;let s=e.end(e.length-1)+pr;const a=!n.endList,o=typeof n.partTargetDuration=="number";return a&&(o||r)&&(s=e.end(e.length-1)+n.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:n}){if(!e)return;let r;if(e.length&&t.length){const s=Wa(e,n-3),a=Wa(e,n),o=Wa(t,n);o.length&&!a.length&&s.length&&(r={start:s.end(0),end:o.end(0)})}else Hu(e,n).length||(r=this.gapFromVideoUnderflow_(e,n));return r?(this.logger_(`Encountered a gap in video from ${r.start} to ${r.end}. Seeking to current time ${n}`),!0):!1}skipTheGap_(e){const t=this.tech_.buffered(),n=this.tech_.currentTime(),r=Hu(t,n);if(this.resetTimeUpdate_(),r.length===0||n!==e)return;this.logger_("skipTheGap_:","currentTime:",n,"scheduled currentTime:",e,"nextRange start:",r.start(0)),this.tech_.setCurrentTime(r.start(0)+fr);const s={gapInfo:{from:n,to:r.start(0)}};this.playlistController_.trigger({type:"gapjumped",metadata:s}),this.tech_.trigger({type:"usage",name:"vhs-gap-skip"})}gapFromVideoUnderflow_(e,t){const n=pI(e);for(let r=0;r<n.length;r++){const s=n.start(r),a=n.end(r);if(t-s<4&&t-s>2)return{start:s,end:a}}return null}}const IN={errorInterval:30,getSource(i){const t=this.tech({IWillNotUseThisInPlugins:!0}).currentSource_||this.currentSource();return i(t)}},C_=function(i,e){let t=0,n=0;const r=Mt(IN,e);i.ready(()=>{i.trigger({type:"usage",name:"vhs-error-reload-initialized"})});const s=function(){n&&i.currentTime(n)},a=function(d){d!=null&&(n=i.duration()!==1/0&&i.currentTime()||0,i.one("loadedmetadata",s),i.src(d),i.trigger({type:"usage",name:"vhs-error-reload"}),i.play())},o=function(){if(Date.now()-t<r.errorInterval*1e3){i.trigger({type:"usage",name:"vhs-error-reload-canceled"});return}if(!r.getSource||typeof r.getSource!="function"){pe.log.error("ERROR: reloadSourceOnError - The option getSource must be a function!");return}return t=Date.now(),r.getSource.call(i,a)},c=function(){i.off("loadedmetadata",s),i.off("error",o),i.off("dispose",c)},u=function(d){c(),C_(i,d)};i.on("error",o),i.on("dispose",c),i.reloadSourceOnError=u},PN=function(i){C_(this,i)};var x_="3.17.0",NN="7.1.0",ON="1.3.1",MN="7.2.0",RN="4.0.2";const tn={PlaylistLoader:Ya,Playlist:di,utils:jI,STANDARD_PLAYLIST_SELECTOR:r_,INITIAL_PLAYLIST_SELECTOR:wP,lastBandwidthSelector:r_,movingAverageBandwidthSelector:xP,comparePlaylistBandwidth:zp,comparePlaylistResolution:CP,xhr:M2()};Object.keys(Nn).forEach(i=>{Object.defineProperty(tn,i,{get(){return pe.log.warn(`using Vhs.${i} is UNSAFE be sure you know what you are doing`),Nn[i]},set(e){if(pe.log.warn(`using Vhs.${i} is UNSAFE be sure you know what you are doing`),typeof e!="number"||e<0){pe.log.warn(`value of Vhs.${i} must be greater than or equal to 0`);return}Nn[i]=e}})});const E_="videojs-vhs",w_=function(i,e){const t=e.media();let n=-1;for(let r=0;r<i.length;r++)if(i[r].id===t.id){n=r;break}i.selectedIndex_=n,i.trigger({selectedIndex:n,type:"change"})},LN=function(i,e){e.representations().forEach(t=>{i.addQualityLevel(t)}),w_(i,e.playlists)};tn.canPlaySource=function(){return pe.log.warn("VHS is no longer a tech. Please remove it from your player's techOrder.")};const BN=(i,e,t)=>{if(!i)return i;let n={};e&&e.attributes&&e.attributes.CODECS&&(n=kl(or(e.attributes.CODECS))),t&&t.attributes&&t.attributes.CODECS&&(n.audio=t.attributes.CODECS);const r=xa(n.video),s=xa(n.audio),a={};for(const o in i)a[o]={},s&&(a[o].audioContentType=s),r&&(a[o].videoContentType=r),e.contentProtection&&e.contentProtection[o]&&e.contentProtection[o].pssh&&(a[o].pssh=e.contentProtection[o].pssh),typeof i[o]=="string"&&(a[o].url=i[o]);return Mt(i,a)},UN=(i,e)=>i.reduce((t,n)=>{if(!n.contentProtection)return t;const r=e.reduce((s,a)=>{const o=n.contentProtection[a];return o&&o.pssh&&(s[a]={pssh:o.pssh}),s},{});return Object.keys(r).length&&t.push(r),t},[]),FN=({player:i,sourceKeySystems:e,audioMedia:t,mainPlaylists:n})=>{if(!i.eme.initializeMediaKeys)return Promise.resolve();const r=t?n.concat([t]):n,s=UN(r,Object.keys(e)),a=[],o=[];return s.forEach(c=>{o.push(new Promise((u,d)=>{i.tech_.one("keysessioncreated",u)})),a.push(new Promise((u,d)=>{i.eme.initializeMediaKeys({keySystems:c},h=>{if(h){d(h);return}u()})}))}),Promise.race([Promise.all(a),Promise.race(o)])},VN=({player:i,sourceKeySystems:e,media:t,audioMedia:n})=>{const r=BN(e,t,n);return r?(i.currentSource().keySystems=r,r&&!i.eme?(pe.log.warn("DRM encrypted source cannot be decrypted without a DRM plugin"),!1):!0):!1},D_=()=>{if(!te.localStorage)return null;const i=te.localStorage.getItem(E_);if(!i)return null;try{return JSON.parse(i)}catch{return null}},jN=i=>{if(!te.localStorage)return!1;let e=D_();e=e?Mt(e,i):i;try{te.localStorage.setItem(E_,JSON.stringify(e))}catch{return!1}return e},$N=i=>i.toLowerCase().indexOf("data:application/vnd.videojs.vhs+json,")===0?JSON.parse(i.substring(i.indexOf(",")+1)):i,A_=(i,e)=>{i._requestCallbackSet||(i._requestCallbackSet=new Set),i._requestCallbackSet.add(e)},I_=(i,e)=>{i._responseCallbackSet||(i._responseCallbackSet=new Set),i._responseCallbackSet.add(e)},P_=(i,e)=>{i._requestCallbackSet&&(i._requestCallbackSet.delete(e),i._requestCallbackSet.size||delete i._requestCallbackSet)},N_=(i,e)=>{i._responseCallbackSet&&(i._responseCallbackSet.delete(e),i._responseCallbackSet.size||delete i._responseCallbackSet)};tn.supportsNativeHls=function(){if(!Ue||!Ue.createElement)return!1;const i=Ue.createElement("video");return pe.getTech("Html5").isSupported()?["application/vnd.apple.mpegurl","audio/mpegurl","audio/x-mpegurl","application/x-mpegurl","video/x-mpegurl","video/mpegurl","application/mpegurl"].some(function(t){return/maybe|probably/i.test(i.canPlayType(t))}):!1}(),tn.supportsNativeDash=function(){return!Ue||!Ue.createElement||!pe.getTech("Html5").isSupported()?!1:/maybe|probably/i.test(Ue.createElement("video").canPlayType("application/dash+xml"))}(),tn.supportsTypeNatively=i=>i==="hls"?tn.supportsNativeHls:i==="dash"?tn.supportsNativeDash:!1,tn.isSupported=function(){return pe.log.warn("VHS is no longer a tech. Please remove it from your player's techOrder.")},tn.xhr.onRequest=function(i){A_(tn.xhr,i)},tn.xhr.onResponse=function(i){I_(tn.xhr,i)},tn.xhr.offRequest=function(i){P_(tn.xhr,i)},tn.xhr.offResponse=function(i){N_(tn.xhr,i)};const HN=pe.getComponent("Component");class O_ extends HN{constructor(e,t,n){if(super(t,n.vhs),typeof n.initialBandwidth=="number"&&(this.options_.bandwidth=n.initialBandwidth),this.logger_=Mi("VhsHandler"),t.options_&&t.options_.playerId){const r=pe.getPlayer(t.options_.playerId);this.player_=r}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(Ue,["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],r=>{const s=Ue.fullscreenElement||Ue.webkitFullscreenElement||Ue.mozFullScreenElement||Ue.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_=Mt(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_.usePlayerObjectFit=this.options_.usePlayerObjectFit||!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=typeof this.options_.useNetworkInformationApi<"u"?this.options_.useNetworkInformationApi:!0,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 n=D_();n&&n.bandwidth&&(this.options_.bandwidth=n.bandwidth,this.tech_.trigger({type:"usage",name:"vhs-bandwidth-from-local-storage"})),n&&n.throughput&&(this.options_.throughput=n.throughput,this.tech_.trigger({type:"usage",name:"vhs-throughput-from-local-storage"}))}typeof this.options_.bandwidth!="number"&&(this.options_.bandwidth=Nn.INITIAL_BANDWIDTH),this.options_.enableLowInitialPlaylist=this.options_.enableLowInitialPlaylist&&this.options_.bandwidth===Nn.INITIAL_BANDWIDTH,["withCredentials","useDevicePixelRatio","usePlayerObjectFit","customPixelRatio","limitRenditionByPlayerDimensions","bandwidth","customTagParsers","customTagMappers","cacheEncryptionKeys","playlistSelector","initialPlaylistSelector","bufferBasedABR","liveRangeSafeTimeDelta","llhls","useForcedSubtitles","useNetworkInformationApi","useDtsForTimestampOffset","exactManifestTimings","leastPixelDiffSelector"].forEach(n=>{typeof this.source_[n]<"u"&&(this.options_[n]=this.source_[n])}),this.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions,this.useDevicePixelRatio=this.options_.useDevicePixelRatio,this.usePlayerObjectFit=this.options_.usePlayerObjectFit;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=$N(this.source_.src),this.options_.tech=this.tech_,this.options_.externVhs=tn,this.options_.sourceType=$y(t),this.options_.seekTo=s=>{this.tech_.setCurrentTime(s)},this.options_.player_=this.player_,this.playlistController_=new xN(this.options_);const n=Mt({liveRangeSafeTimeDelta:pr},this.options_,{seekable:()=>this.seekable(),media:()=>this.playlistController_.media(),playlistController:this.playlistController_});this.playbackWatcher_=new AN(n),this.attachStreamingEventListeners_(),this.playlistController_.on("error",()=>{const s=pe.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 r=this.options_.bufferBasedABR?tn.movingAverageBandwidthSelector(.55):tn.STANDARD_PLAYLIST_SELECTOR;this.playlistController_.selectPlaylist=this.selectPlaylist?this.selectPlaylist.bind(this):r.bind(this),this.playlistController_.selectInitialPlaylist=tn.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=te.navigator.connection||te.navigator.mozConnection||te.navigator.webkitConnection,o=1e7;if(this.options_.useNetworkInformationApi&&a){const c=a.downlink*1e3*1e3;c>=o&&s>=o?s=Math.max(s,c):s=c}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(){pe.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:()=>qs(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:()=>qs(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&&jN({bandwidth:this.bandwidth,throughput:Math.round(this.throughput)})}),this.playlistController_.on("selectedinitialmedia",()=>{DN(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_=te.URL.createObjectURL(this.playlistController_.mediaSource),(pe.browser.IS_ANY_SAFARI||pe.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"),FN({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=VN({player:this.player_,sourceKeySystems:this.source_.keySystems,media:this.playlists.media(),audioMedia:e&&e.media()});if(this.player_.tech_.on("keystatuschange",n=>{this.playlistController_.updatePlaylistByKeyStatus(n.keyId,n.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=pe.players[this.tech_.options_.playerId];!e||!e.qualityLevels||this.qualityLevels_||(this.qualityLevels_=e.qualityLevels(),this.playlistController_.on("selectedinitialmedia",()=>{LN(this.qualityLevels_,this)}),this.playlists.on("mediachange",()=>{w_(this.qualityLevels_,this.playlists)}))}static version(){return{"@videojs/http-streaming":x_,"mux.js":NN,"mpd-parser":ON,"m3u8-parser":MN,"aes-decrypter":RN}}version(){return this.constructor.version()}canChangeType(){return f_.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_&&te.URL.revokeObjectURL&&(te.URL.revokeObjectURL(this.mediaSourceUrl_),this.mediaSourceUrl_=null),this.tech_&&this.tech_.off("waitingforkey",this.handleWaitingForKey_),super.dispose()}convertToProgramTime(e,t){return KI({playlist:this.playlistController_.media(),time:e,callback:t})}seekToProgramTime(e,t,n=!0,r=2){return F2({programTime:e,playlist:this.playlistController_.media(),retryCount:r,pauseAfterSeek:n,seekTo:this.options_.seekTo,tech:this.options_.tech,callback:t})}setupXhrHooks_(){this.xhr.onRequest=e=>{A_(this.xhr,e)},this.xhr.onResponse=e=>{I_(this.xhr,e)},this.xhr.offRequest=e=>{P_(this.xhr,e)},this.xhr.offResponse=e=>{N_(this.xhr,e)},this.player_.trigger("xhr-hooks-ready")}attachStreamingEventListeners_(){const e=["seekablerangeschanged","bufferedrangeschanged","contentsteeringloadstart","contentsteeringloadcomplete","contentsteeringparsed"],t=["gapjumped","playedrangeschanged"];e.forEach(n=>{this.playlistController_.on(n,r=>{this.player_.trigger(yn({},r))})}),t.forEach(n=>{this.playbackWatcher_.on(n,r=>{this.player_.trigger(yn({},r))})})}}const Xu={name:"videojs-http-streaming",VERSION:x_,canHandleSource(i,e={}){const t=Mt(pe.options,e);return!t.vhs.experimentalUseMMS&&!el("avc1.4d400d,mp4a.40.2",!1)?!1:Xu.canPlayType(i.type,t)},handleSource(i,e,t={}){const n=Mt(pe.options,t);return e.vhs=new O_(i,e,n),e.vhs.xhr=M2(),e.vhs.setupXhrHooks_(),e.vhs.src(i.src,i.type),e.vhs},canPlayType(i,e){const t=$y(i);if(!t)return"";const n=Xu.getOverrideNative(e);return!tn.supportsTypeNatively(t)||n?"maybe":""},getOverrideNative(i={}){const{vhs:e={}}=i,t=!(pe.browser.IS_ANY_SAFARI||pe.browser.IS_IOS),{overrideNative:n=t}=e;return n}};el("avc1.4d400d,mp4a.40.2",!0)&&pe.getTech("Html5").registerSourceHandler(Xu,0),pe.VhsHandler=O_,pe.VhsSourceHandler=Xu,pe.Vhs=tn,pe.use||pe.registerComponent("Vhs",tn),pe.options.vhs=pe.options.vhs||{},(!pe.getPlugin||!pe.getPlugin("reloadSourceOnError"))&&pe.registerPlugin("reloadSourceOnError",PN);class qN{constructor(){this.isInitialized=!1,this.pollingInterval=null,this.currentPollingIndex=0,this.pollingParticipants=[],this.ctx=null,this.pollingDisabled=!1,this.voiceActivatedIdentity=null,this.voiceActivatedParticipant=null}init(e){this.isInitialized||(this.ctx=Object.assign({getParticipants:()=>[],getCurrentLayout:()=>"grid",getCurrentRoomMode:()=>"normal",pollingIntervalMs:null},e||{}),this.isInitialized=!0,this._setupMittListeners())}destroy(){this.stopScreenPolling(),this.isInitialized=!1,this.ctx=null}getMaxVisibleParticipantsByLayout(){var n,r,s,a;const e=((r=(n=this.ctx)==null?void 0:n.getCurrentLayout)==null?void 0:r.call(n))||"grid";return(((a=(s=this.ctx)==null?void 0:s.getCurrentRoomMode)==null?void 0:a.call(s))||"normal")==="pointTurn"?10:e==="rightSide"?5:e==="grid"?16:4}shouldStartPolling(){var s,a,o,c,u,d,h;const e=((a=(s=this.ctx)==null?void 0:s.getParticipants)==null?void 0:a.call(s))||[],t=((c=(o=this.ctx)==null?void 0:o.getCurrentLayout)==null?void 0:c.call(o))||"grid",n=((d=(u=this.ctx)==null?void 0:u.getCurrentRoomMode)==null?void 0:d.call(u))||"normal",r=(h=this.ctx)==null?void 0:h.pollingIntervalMs;return this.pollingDisabled||!r||r<=0?!1:n==="pointTurn"?e.length>11:t==="rightSide"?e.length>5:e.length>4}adjustPollingState(){if(!this.isInitialized)return;if(this.pollingDisabled){this.stopScreenPolling();return}const e=this.shouldStartPolling(),t=!!this.pollingInterval;e&&!t?this.startScreenPolling():!e&&t&&this.stopScreenPolling()}startScreenPolling(){if(!this.isInitialized||this.pollingInterval||!this.shouldStartPolling())return;this.currentPollingIndex=0,this.pollingParticipants=[];const e=this.ctx.pollingIntervalMs;if(!e||e<=0){console.warn("轮询间隔未设置或无效,无法启动轮询");return}this.executeScreenPolling(),this.pollingInterval=setInterval(()=>{this.executeScreenPolling()},e),setTimeout(()=>{this.pollingInterval&&this.executeScreenPolling()},100)}stopScreenPolling(){this.pollingInterval&&(clearInterval(this.pollingInterval),this.pollingInterval=null),this.currentPollingIndex=0,this.pollingParticipants=[]}executeScreenPolling(){var t,n,r,s;if(!this.isInitialized||!this.shouldStartPolling())return;const e=((n=(t=this.ctx)==null?void 0:t.getCurrentRoomMode)==null?void 0:n.call(t))||"normal";if((s=(r=this.ctx)==null?void 0:r.getCurrentLayout)!=null&&s.call(r),e==="pointTurn"){this.executePointTurnPolling();return}this.updatePollingIndex(),this.emitScreenPollingEvent()}executePointTurnPolling(){var a,o,c,u;const e=((o=(a=this.ctx)==null?void 0:a.getParticipants)==null?void 0:o.call(a))||[],t=10;let n=null;try{n=((u=(c=this.ctx)==null?void 0:c.getHostIdentity)==null?void 0:u.call(c))||null}catch{n=null}let r=[...e];if(n){const d=r.findIndex(h=>h&&h.identity===n);d!==-1&&r.splice(d,1)}if(r.length<=t){this.stopScreenPolling(),this.emitPointTurnPollingEvent(r.slice(0,t));return}this.currentPollingIndex=this.currentPollingIndex%r.length;const s=[];for(let d=0;d<t;d++){const h=(this.currentPollingIndex+d)%r.length;s.push(r[h])}this.emitPointTurnPollingEvent(s),this.currentPollingIndex=(this.currentPollingIndex+5)%r.length}updatePollingIndex(){var a,o,c,u,d,h,y,v;const e=((o=(a=this.ctx)==null?void 0:a.getParticipants)==null?void 0:o.call(a))||[],t=e.length;if(t===0)return;const n=this.getMaxVisibleParticipantsByLayout(),r=((u=(c=this.ctx)==null?void 0:c.getCurrentLayout)==null?void 0:u.call(c))||"grid",s=((h=(d=this.ctx)==null?void 0:d.getCurrentRoomMode)==null?void 0:h.call(d))||"normal";if(t<=n){this.currentPollingIndex=0;return}if(r==="rightSide"&&s==="normal"){let b=null;try{b=((v=(y=this.ctx)==null?void 0:y.getHostIdentity)==null?void 0:v.call(y))||null}catch{b=null}const g=this.voiceActivatedParticipant&&this.voiceActivatedParticipant.identity||this.voiceActivatedIdentity;let f=!1;if(b&&e.find(p=>p&&p.identity===b)&&(f=!0),!f&&g&&e.find(p=>p&&p.identity===g)&&(f=!0),f){const p=Math.max(t-1,1);this.currentPollingIndex=(this.currentPollingIndex+1)%p}else{const p=Math.max(t,1);this.currentPollingIndex=(this.currentPollingIndex+1)%p}}else{const b=Math.max(t-n,1);this.currentPollingIndex=(this.currentPollingIndex+1)%b}}getPollingParticipants(){var c,u,d,h,y,v;const e=[...((u=(c=this.ctx)==null?void 0:c.getParticipants)==null?void 0:u.call(c))||[]],t=this.getMaxVisibleParticipantsByLayout(),n=((h=(d=this.ctx)==null?void 0:d.getCurrentLayout)==null?void 0:h.call(d))||"grid",r=((v=(y=this.ctx)==null?void 0:y.getCurrentRoomMode)==null?void 0:v.call(y))||"normal",s=this.currentPollingIndex,a=[];if(this.shouldStartPolling())if(n==="rightSide"&&r==="normal")a.push(...this._getRightSidePollingParticipants(e,t,s));else for(let b=0;b<t&&b<e.length;b++)a.push(e[(s+b)%e.length]);else for(let b=0;b<t&&b<e.length;b++)a.push(e[b]);const o=this.voiceActivatedParticipant&&this.voiceActivatedParticipant.identity||this.voiceActivatedIdentity;if(o){const b=a.findIndex(g=>g&&g.identity===o);if(b>0){const[g]=a.splice(b,1);a.unshift(g)}}return a}_getRightSidePollingParticipants(e,t,n){var y,v;const r=[];let s=null;try{s=((v=(y=this.ctx)==null?void 0:y.getHostIdentity)==null?void 0:v.call(y))||null}catch{s=null}const a=this.voiceActivatedParticipant&&this.voiceActivatedParticipant.identity||this.voiceActivatedIdentity;let o=null,c=!1;if(s){const b=e.find(g=>g&&g.identity===s);b&&(o=b,c=!0)}if(!c&&a){const b=e.find(g=>g&&g.identity===a);b&&(o=b,c=!0)}if(!o){const b=n%e.length;o=e[b]}o&&r.push(o);const u=new Set;o&&u.add(o.identity);let d=1,h=n;for(;d<t&&d<e.length;){const b=e[h%e.length];if(b&&!u.has(b.identity)&&(r.push(b),u.add(b.identity),d++),h++,h-n>=e.length)break}return r}_setupMittListeners(){try{typeof ht<"u"&&ht&&(ht.on("voiceActivated",e=>{if(e){typeof e=="string"?(this.voiceActivatedIdentity=e,this.voiceActivatedParticipant=null):typeof e=="object"&&(this.voiceActivatedParticipant=e,this.voiceActivatedIdentity=e.identity||null);try{const t=this.getPollingParticipants();ht.emit("updateVisibleParticipants",{participants:t,currentIndex:this.currentPollingIndex,isPolling:!!this.pollingInterval,action:"replace"})}catch(t){console.warn("同步语音激励到可见列表失败",t)}}}),ht.on("setPollingEnabled",e=>{this.setPollingEnabled(!!e)}))}catch(e){console.warn("autoPolling mitt listeners setup failed",e)}}emitScreenPollingEvent(){const e=this.getPollingParticipants();ht.emit("screenPolling",{timestamp:Date.now(),currentIndex:this.currentPollingIndex,participants:this.pollingParticipants,visibleParticipants:e,interval:this.ctx.pollingIntervalMs}),ht.emit("updateVisibleParticipants",{participants:e,currentIndex:this.currentPollingIndex,isPolling:!0,action:"replace"})}emitPointTurnPollingEvent(e){ht.emit("pointTurnPolling",{timestamp:Date.now(),currentIndex:this.currentPollingIndex,participants:e,interval:this.ctx.pollingIntervalMs})}setPollingInterval(e){this.ctx&&(this.ctx.pollingIntervalMs=e,!this.pollingDisabled&&this.pollingInterval&&(this.stopScreenPolling(),this.startScreenPolling()))}setPollingEnabled(e){this.pollingDisabled=!e,e?(this.adjustPollingState(),this.pollingInterval&&this.shouldStartPolling()&&setTimeout(()=>{this.executeScreenPolling()},50)):this.stopScreenPolling()}setVoiceActivatedIdentity(e){this.voiceActivatedIdentity=e||null}getPollingStatus(){var e;return{isActive:!!this.pollingInterval,currentIndex:this.currentPollingIndex,interval:(e=this.ctx)==null?void 0:e.pollingIntervalMs}}}const xl=new qN,zN=i=>xl.init(i),GN=()=>xl.stopScreenPolling(),El=()=>xl.adjustPollingState(),M_=i=>xl.setPollingInterval(i),Yu=i=>xl.setPollingEnabled(i),WN="/assets/img/point/clear_icon.png",Ft=(i,e)=>{const t=i.__vccOpts||i;for(const[n,r]of e)t[n]=r;return t},Ju=i=>(l.pushScopeId("data-v-62825aea"),i=i(),l.popScopeId(),i),KN={class:"live-call-board"},XN={class:"live-call-board-title"},YN=Ju(()=>l.createElementVNode("span",null,"拨号1盘",-1)),JN=["src"],QN={class:"live-call-board-list"},ZN=["onClick"],e7={class:"live-call-board-foot"},t7=[Ju(()=>l.createElementVNode("div",{class:"btn-icon"},null,-1))],n7=[Ju(()=>l.createElementVNode("div",{class:"btn-icon"},null,-1))],i7=[Ju(()=>l.createElementVNode("div",{class:"btn-icon"},null,-1))],wl=Ft({__name:"LiveCallBoard",props:{defaultCallNum:{type:String,default:""},defaultCallingMethod:{type:Array,default:()=>["voice","video","mini"]}},emits:["callBoardClose","voiceCall","videoCall","miniCall"],setup(i,{emit:e}){const t="/".replace(/\/?$/,"/"),n=new An,r=i,s=l.ref(""),a=e;function o(v){return/^[\d#*]+$/.test(v)}function c(v){s.value+=v}function u(){s.value?o(s.value)?(a("voiceCall",s.value),a("callBoardClose")):n.message("error","手机号中包含不合法字符"):n.message("error","联系方式不能为空")}function d(){s.value?o(s.value)?(a("videoCall",s.value),a("callBoardClose")):n.message("error","手机号中包含不合法字符"):n.message("error","联系方式不能为空")}function h(){s.value?o(s.value)?(a("miniCall",s.value),a("callBoardClose")):n.message("error","手机号中包含不合法字符"):n.message("error",{message:"联系方式不能为空"})}function y(){s.value.length>0&&(s.value=s.value.substring(0,s.value.length-1))}return l.onMounted(()=>{s.value=r.defaultCallNum}),(v,b)=>{const g=l.resolveComponent("el-input");return l.openBlock(),l.createElementBlock("div",KN,[l.createElementVNode("div",XN,[YN,l.createElementVNode("img",{class:"title-close-icon",src:l.unref(t)+"assets/img/point/close_icon.png",alt:"",onClick:b[0]||(b[0]=f=>v.$emit("callBoardClose"))},null,8,JN)]),l.createVNode(g,{modelValue:s.value,"onUpdate:modelValue":b[1]||(b[1]=f=>s.value=f),type:"mobile",placeholder:"请输入号码",disabled:"",clearable:""},{suffix:l.withCtx(()=>[l.createElementVNode("img",{class:"del-icon",src:WN,alt:"",onClick:y})]),_:1},8,["modelValue"]),l.createElementVNode("div",QN,[(l.openBlock(),l.createElementBlock(l.Fragment,null,l.renderList("123456789*0#",(f,p)=>l.createElementVNode("div",{class:"live-call-board-list-item",key:p,onClick:_=>c(f)},l.toDisplayString(f),9,ZN)),64))]),l.createElementVNode("div",e7,[i.defaultCallingMethod.includes("voice")?(l.openBlock(),l.createElementBlock("div",{key:0,class:"live-call-board-foot-btn voice-btn",onClick:u},t7)):l.createCommentVNode("",!0),i.defaultCallingMethod.includes("video")?(l.openBlock(),l.createElementBlock("div",{key:1,class:"live-call-board-foot-btn video-btn",onClick:d},n7)):l.createCommentVNode("",!0),i.defaultCallingMethod.includes("mini")?(l.openBlock(),l.createElementBlock("div",{key:2,class:"live-call-board-foot-btn mini-btn",onClick:h},i7)):l.createCommentVNode("",!0)])])}}},[["__scopeId","data-v-62825aea"]]),r7="/assets/img/point/close_icon.png",s7="/assets/img/point/hang_on_icon.png",a7="/assets/img/point/hang_off_icon.png",Qu=i=>(l.pushScopeId("data-v-380eda98"),i=i(),l.popScopeId(),i),o7={class:"receive-board"},l7={class:"receive-board-title"},c7={class:"receive-board-msg"},u7=[Qu(()=>l.createElementVNode("img",{class:"btn-icon",src:s7,alt:""},null,-1)),Qu(()=>l.createElementVNode("span",null,"接听",-1))],d7=[Qu(()=>l.createElementVNode("img",{class:"btn-icon",src:a7,alt:""},null,-1)),Qu(()=>l.createElementVNode("span",null,"挂断",-1))],h7=Ft({__name:"LiveInviteReceive",props:{meetingType:{type:String,default:"video"},inviteData:{type:Object,default:()=>{}}},emits:["receiveBoardClose","acceptInviteCall","refuseInviteCall"],setup(i,{emit:e}){const t=i,n=e;function r(){n("acceptInviteCall",{roomNum:t.inviteData.roomNum,fromIdentity:t.inviteData.fromIdentity,fromOrg:t.inviteData.fromOrg,meetingType:t.meetingType})}function s(){n("refuseInviteCall",{roomNum:t.inviteData.roomNum,fromIdentity:t.inviteData.fromIdentity,fromOrg:t.inviteData.fromOrg,meetingType:t.meetingType})}return(a,o)=>{var c;return l.openBlock(),l.createElementBlock("div",o7,[l.createElementVNode("div",l7,[l.createElementVNode("span",null,l.toDisplayString(i.meetingType==="voice"?"语音呼叫":"视频呼叫"),1),l.createElementVNode("img",{class:"title-close-icon",src:r7,alt:"",onClick:o[0]||(o[0]=u=>a.$emit("receiveBoardClose"))})]),l.createElementVNode("div",c7,[l.createElementVNode("img",{class:l.normalizeClass(["receive-type-icon",i.meetingType==="voice"?"receive-type-icon-voice":"receive-type-icon-video"]),src:"",alt:""},null,2),l.createElementVNode("span",null,l.toDisplayString(`【${((c=i.inviteData)==null?void 0:c.fromIdentity)??"会议发起人"}】邀请您进行${i.meetingType==="voice"?"语音":"视频"}通话`),1)]),l.createElementVNode("div",{class:"receive-board-foot"},[l.createElementVNode("div",{class:"receive-board-foot-btn accept-btn",onClick:r},u7),l.createElementVNode("div",{class:"receive-board-foot-btn refuse-btn",onClick:s},d7)])])}}},[["__scopeId","data-v-380eda98"]]),Un=i=>(l.pushScopeId("data-v-79d2799d"),i=i(),l.popScopeId(),i),f7={class:"point-meeting-top"},p7={class:"top-group"},m7=Un(()=>l.createElementVNode("div",{class:"duration-icon"},null,-1)),g7={class:"point-meeting-wrapper"},v7={key:0,class:"waiting-mask-video"},y7=[Un(()=>l.createElementVNode("div",{class:"icon"},null,-1)),Un(()=>l.createElementVNode("div",{class:"title"},"麦克风",-1))],b7=[Un(()=>l.createElementVNode("div",{class:"icon"},null,-1)),Un(()=>l.createElementVNode("div",{class:"title"},"麦克风",-1))],_7=[Un(()=>l.createElementVNode("div",{class:"icon"},null,-1)),Un(()=>l.createElementVNode("div",{class:"title"},"摄像头",-1))],k7=[Un(()=>l.createElementVNode("div",{class:"icon"},null,-1)),Un(()=>l.createElementVNode("div",{class:"title"},"摄像头",-1))],T7=[Un(()=>l.createElementVNode("div",{class:"icon"},null,-1)),Un(()=>l.createElementVNode("div",{class:"title"},"扬声器",-1))],S7=[Un(()=>l.createElementVNode("div",{class:"icon"},null,-1)),Un(()=>l.createElementVNode("div",{class:"title"},"扬声器",-1))],C7=Un(()=>l.createElementVNode("div",{class:"icon"},null,-1)),x7={class:"title"},E7=Un(()=>l.createElementVNode("div",{class:"icon"},null,-1)),w7={class:"title"},D7=[Un(()=>l.createElementVNode("div",{class:"icon"},null,-1)),Un(()=>l.createElementVNode("div",{class:"title"},"结束通话",-1))],Dl=Ft({__name:"LivePointMeeting",props:{joinType:{type:String,default:"join"},meetingNum:{type:String,default:""},meetingType:{type:String,default:"video"},invitePhone:{type:String,default:""},isDraggable:{type:Boolean,default:!1},inviteWays:{type:String,default:"phoneCall"},inviteIdentity:{type:String,default:""}},emits:["meetingStarted","miniLinkSend","meetingEnded","meetingDialogClose"],setup(i,{emit:e}){const t=new An;let n=null,r=null,s=null;const a=i,o=e,c=l.ref(),u=l.ref(""),d=l.ref(""),h=l.ref(""),y=l.ref(null),v=l.ref([]);l.ref([]);const b=l.ref([]),g=l.ref(!1),f=l.ref(!1),p=l.ref(!1),_=l.ref(!1),k=l.ref(!0),D=l.ref(!1),C=l.ref(!1),A=l.ref(0),w=l.ref(!0),P=l.ref(!1),S=l.ref(3),M=l.computed(()=>b.value.length),U=l.computed(()=>t0(A.value)),R={mounted:(le,ae)=>{ae.value&&(le.style.cursor="move",le.onmousedown=ce=>{ce.stopPropagation(),ce.preventDefault();const Le=document.getElementById("point-meeting"),Ee=/^matrix3d\((?:[-\d.]+,\s*){12}([-\d.]+),\s*([-\d.]+)(?:,\s*[-\d.]+){2}\)/,it=/^matrix\((?:[-\d.]+,\s*){4}([-\d.]+),\s*([-\d.]+)\)$/;let $e=kx(Le,"transform"),Je=$e.match(Ee)||$e.match(it),rt=ce.clientX,De=ce.clientY,Ye=Je[1],Fe=Je[2],Ct=rt-Ye,qt=De-Fe;le.onmousemove=function(It){It.stopPropagation(),It.preventDefault();let Oe=It.clientX-Ct,tt=It.clientY-qt;Le.style.transform=`translate(${Oe}px, ${tt}px)`},le.onmouseup=function(It){le.onmousemove=null,le.onmouseup=null},window.onmouseup=function(It){le.onmousemove=null,le.onmouseup=null}})}};l.watch(()=>S.value,le=>{le<=0&&(P.value=!1,r&&clearInterval(r))});async function J(){s&&await s.createRoom()}async function ie(){if(!s)return;const le={echoCancellation:!0,noiseSuppression:!0,roomNum:a.joinType==="launch"?h.value:a.meetingNum};try{await s.joinRoom(le)}catch{t.message("error","加入会议失败")}}function X(le){v.value.indexOf(le)<0&&v.value.push(le)}function V(){s&&v.value.length>0&&v.value.forEach(le=>{s.off(le)})}function L(){n&&(clearInterval(n),n=null)}async function H(){await s.changeCameraStatus()}async function q(){await s.changeMicrophoneStatus()}async function $(){await s.changeScreenShareStatus()}async function G(){await s.setParticipantDeafness(u.value)}async function oe(){await s.cancelParticipantDeafness(u.value)}function Te(le){S.value=le,P.value=!0,r&&clearInterval(r),r=setInterval(()=>{S.value>0&&S.value--},1e3)}function ge(){if(!D.value)return;const le=document.querySelector("#point-meeting-contain .layout-blur"),ae=document.querySelector("#point-meeting-contain .layout-normal");if(k.value){if(le.hasChildNodes){const ce=le.firstElementChild;if(ce.id===`participant-${u.value}`)le.style.visibility="hidden",k.value=!1;else if(ae.hasChildNodes){const Le=ae.firstElementChild;le.appendChild(Le),ae.appendChild(ce),le.style.visibility="hidden",k.value=!1}else ae.appendChild(ce),le.style.visibility="hidden",k.value=!1}}else if(_.value){t.message("error","当前正在共享屏幕,无法开启预览");return}else le.style.visibility="visible",k.value=!0}function ee(){if(!s){t.message("error","liveClient未能成功初始化");return}s.on("errorPush",le=>{X("errorPush"),console.error("出错位置"+le.type+":",le.message)}),s.on("roomCreatedSuccess",async le=>{X("roomCreatedSuccess"),t.message("success","会议房间创建成功"),h.value=le,await ie()}),s.on("roomCreatedFail",le=>{X("roomCreatedFail"),t.message("error","会议房间创建失败")}),s.on("joinRoomError",le=>{X("joinRoomError"),console.error("加入会议失败",le),t.message("error","加入会议失败")}),s.on("roomConnected",le=>{if(X("roomConnected"),s!=null&&s.room&&(y.value=JSON.parse(s.room.metadata),console.log(y.value,"roomMetadata.value"),D.value=!0,o("meetingStarted"),a.joinType==="launch")){if(a.inviteWays==="phoneCall")a.meetingType==="video"||a.meetingType==="voice"?s.makeCall(a.invitePhone,a.invitePhone).then(()=>{t.message("success","外呼邀请发送成功"),C.value=!0}).catch(ae=>{t.message("error","外呼邀请发送失败"),console.error(ae)}):a.meetingType==="miniLink"&&(o("miniLinkSend",{roomNum:h.value,phone:a.invitePhone}),C.value=!0);else if(a.inviteWays==="identity"){const ae=JSON.stringify({meetingType:a.meetingType});s.inviteThirdParty(a.inviteIdentity,s.org,ae).then(()=>{t.message("success","PC邀请发送成功")}).catch(()=>{t.message("error","PC邀请发送失败")})}}}),s.on("localCameraChange",le=>{X("localCameraChange"),f.value=le,f.value?t.message("success","摄像头已开启"):t.message("success","摄像头已关闭")}),s.on("localMicrophoneChange",le=>{X("localMicrophoneChange"),g.value=le,g.value?t.message("success","麦克风已开启"):t.message("success","麦克风已关闭")}),s.on("localScreenShareChange",le=>{X("localScreenShareChange"),_.value=le,_.value?t.success({messsage:"屏幕共享已开启"}):t.success({messsage:"屏幕共享已关闭"})}),s.on("videoCallRender",le=>{X("videoCallRender"),Xe(le)}),s.on("audioCallRender",le=>{X("audioCallRender"),je(le)}),s.on("roomDisconnected",()=>{if(X("roomDisconnected"),t.message("info","房间链接已断开"),D.value=!1,o("meetingEnded"),s){s._eventsInitialized=!1;try{s.removeAllListeners()}catch(le){console.warn("清理liveClient事件监听器失败:",le)}}s.deleteRoom(u.value).then(()=>{L(),ve()}).catch(le=>{console.error(le),L(),ve()})})}function ve(){o("meetingDialogClose")}async function be(){s&&await s.leaveRoom()}async function Be(le){document.fullscreenElement||document.msFullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement?document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitCancelFullScreen?document.webkitCancelFullScreen():document.msExitFullscreen&&document.msExitFullscreen():(await l.nextTick(),c.value.requestFullscreen&&c.value.requestFullscreen())}function ze(le){if(M.value<=0)b.value.push(le);else{const ae=b.value.findIndex(ce=>ce.identity===le.identity);ae!==-1?b.value.splice(ae,1,le):b.value.push(le)}}function Me(le){if(!(M.value<=0)){const ae=b.value.findIndex(ce=>ce.identity===le.identity);ae!==-1&&b.value.splice(ae,1)}}function Xe(le){if(le.isLocal){const Ct=JSON.parse(le.metadata);f.value=le.isCameraEnabled,g.value=le.isMicrophoneEnabled,_.value=le.isScreenShareEnabled,p.value=!Ct.isDeafness,u.value=le.identity,d.value=le.name}const ae=document.getElementById("point-meeting-contain");let ce=document.getElementById(`participant-${le.identity}`),Le=document.querySelector("#point-meeting-contain .layout-blur"),Ee=document.querySelector("#point-meeting-contain .layout-normal");if(Le||(Le=document.createElement("div"),Le.className="layout-blur",ae.appendChild(Le)),Ee||(Ee=document.createElement("div"),Ee.className="layout-normal",ae.insertBefore(Ee,ae.firstElementChild??null)),!ae){t.message("error","会议容器不存在");return}if(!ce&&!le.remove){if(ce=document.createElement("div"),ce.id=`participant-${le.identity}`,ce.className=le.isLocal?"participant local":"participant",le.isScreenShareEnabled||le.isCameraEnabled?ce.innerHTML=`
243
+ `,o++,a=y}),this.end_=a,this.storage_=r,this.diagnostics_=s}calculateBaseTime_(e,t,n){if(!this.storage_.size)return 0;if(this.storage_.has(e))return this.storage_.get(e).segmentSyncInfo.start;const r=Math.min(...this.storage_.keys());if(e<r){const s=r-e;let a=this.storage_.get(r).segmentSyncInfo.start;for(let o=0;o<s;o++){const c=t[o];a-=c.duration}return a}return n}isReliablePlaylist_(e,t){return e!=null&&Array.isArray(t)&&t.length}}class y_ extends v_{constructor(e){super(),this.parent_=e}calculateBaseTime_(e,t,n){if(!this.storage_.size){const r=this.parent_.getSyncInfoForMediaSequence(e);return r?r.segmentSyncInfo.start:0}return super.calculateBaseTime_(e,t,n)}}const rN=86400,Xp=[{name:"VOD",run:(i,e,t,n,r)=>t!==1/0?{time:0,segmentIndex:0,partIndex:null}:null},{name:"MediaSequence",run:(i,e,t,n,r,s)=>{const a=i.getMediaSequenceSync(s);if(!a||!a.isReliable)return null;const o=a.getSyncInfoForTime(r);return o?{time:o.start,partIndex:o.partIndex,segmentIndex:o.segmentIndex}:null}},{name:"ProgramDateTime",run:(i,e,t,n,r)=>{if(!Object.keys(i.timelineToDatetimeMappings).length)return null;let s=null,a=null;const o=Np(e);r=r||0;for(let c=0;c<o.length;c++){const u=e.endList||r===0?c:o.length-(c+1),d=o[u],h=d.segment,y=i.timelineToDatetimeMappings[h.timeline];if(!y||!h.dateTimeObject)continue;let b=h.dateTimeObject.getTime()/1e3+y;if(h.parts&&typeof d.partIndex=="number")for(let f=0;f<d.partIndex;f++)b+=h.parts[f].duration;const g=Math.abs(r-b);if(a!==null&&(g===0||a<g))break;a=g,s={time:b,segmentIndex:d.segmentIndex,partIndex:d.partIndex}}return s}},{name:"Segment",run:(i,e,t,n,r)=>{let s=null,a=null;r=r||0;const o=Np(e);for(let c=0;c<o.length;c++){const u=e.endList||r===0?c:o.length-(c+1),d=o[u],h=d.segment,y=d.part&&d.part.start||h&&h.start;if(h.timeline===n&&typeof y<"u"){const v=Math.abs(r-y);if(a!==null&&a<v)break;(!s||a===null||a>=v)&&(a=v,s={time:y,segmentIndex:d.segmentIndex,partIndex:d.partIndex})}}return s}},{name:"Discontinuity",run:(i,e,t,n,r)=>{let s=null;if(r=r||0,e.discontinuityStarts&&e.discontinuityStarts.length){let a=null;for(let o=0;o<e.discontinuityStarts.length;o++){const c=e.discontinuityStarts[o],u=e.discontinuitySequence+o+1,d=i.discontinuities[u];if(d){const h=Math.abs(r-d.time);if(a!==null&&a<h)break;(!s||a===null||a>=h)&&(a=h,s={time:d.time,segmentIndex:c,partIndex:null})}}}return s}},{name:"Playlist",run:(i,e,t,n,r)=>e.syncInfo?{time:e.syncInfo.time,segmentIndex:e.syncInfo.mediaSequence-e.mediaSequence,partIndex:null}:null}];class sN extends pe.EventTarget{constructor(e={}){super(),this.timelines=[],this.discontinuities=[],this.timelineToDatetimeMappings={};const t=new v_,n=new y_(t),r=new y_(t);this.mediaSequenceStorage_={main:t,audio:n,vtt:r},this.logger_=Mi("SyncController")}getMediaSequenceSync(e){return this.mediaSequenceStorage_[e]||null}getSyncPoint(e,t,n,r,s){if(t!==1/0)return Xp.find(({name:c})=>c==="VOD").run(this,e,t);const a=this.runStrategies_(e,t,n,r,s);if(!a.length)return null;for(const o of a){const{syncPoint:c,strategy:u}=o,{segmentIndex:d,time:h}=c;if(d<0)continue;const y=e.segments[d],v=h,b=v+y.duration;if(this.logger_(`Strategy: ${u}. Current time: ${r}. selected segment: ${d}. Time: [${v} -> ${b}]}`),r>=v&&r<b)return this.logger_("Found sync point with exact match: ",c),c}return this.selectSyncPoint_(a,{key:"time",value:r})}getExpiredTime(e,t){if(!e||!e.segments)return null;const n=this.runStrategies_(e,t,e.discontinuitySequence,0);if(!n.length)return null;const r=this.selectSyncPoint_(n,{key:"segmentIndex",value:0});return r.segmentIndex>0&&(r.time*=-1),Math.abs(r.time+bl({defaultDuration:e.targetDuration,durationList:e.segments,startIndex:r.segmentIndex,endIndex:0}))}runStrategies_(e,t,n,r,s){const a=[];for(let o=0;o<Xp.length;o++){const c=Xp[o],u=c.run(this,e,t,n,r,s);u&&(u.strategy=c.name,a.push({strategy:c.name,syncPoint:u}))}return a}selectSyncPoint_(e,t){let n=e[0].syncPoint,r=Math.abs(e[0].syncPoint[t.key]-t.value),s=e[0].strategy;for(let a=1;a<e.length;a++){const o=Math.abs(e[a].syncPoint[t.key]-t.value);o<r&&(r=o,n=e[a].syncPoint,s=e[a].strategy)}return this.logger_(`syncPoint for [${t.key}: ${t.value}] chosen with strategy [${s}]: [time:${n.time}, segmentIndex:${n.segmentIndex}`+(typeof n.partIndex=="number"?`,partIndex:${n.partIndex}`:"")+"]"),n}saveExpiredSegmentInfo(e,t){const n=t.mediaSequence-e.mediaSequence;if(n>rN){pe.log.warn(`Not saving expired segment info. Media sequence gap ${n} is too large.`);return}for(let r=n-1;r>=0;r--){const s=e.segments[r];if(s&&typeof s.start<"u"){t.syncInfo={mediaSequence:e.mediaSequence+r,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],n=t.dateTimeObject.getTime()/1e3;this.timelineToDatetimeMappings[t.timeline]=-n}}saveSegmentTimingInfo({segmentInfo:e,shouldSaveTimelineMapping:t}){const n=this.calculateSegmentTimeMapping_(e,e.timingInfo,t),r=e.segment;n&&(this.saveDiscontinuitySyncInfo_(e),e.playlist.syncInfo||(e.playlist.syncInfo={mediaSequence:e.playlist.mediaSequence+e.mediaIndex,time:r.start}));const s=r.dateTimeObject;r.discontinuity&&t&&s&&(this.timelineToDatetimeMappings[r.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,n){const r=e.segment,s=e.part;let a=this.timelines[e.timeline],o,c;if(typeof e.timestampOffset=="number")a={time:e.startOfSegment,mapping:e.startOfSegment-t.start},n&&(this.timelines[e.timeline]=a,this.trigger("timestampoffset"),this.logger_(`time mapping for timeline ${e.timeline}: [time: ${a.time}] [mapping: ${a.mapping}]`)),o=e.startOfSegment,c=t.end+a.mapping;else if(a)o=t.start+a.mapping,c=t.end+a.mapping;else return!1;return s&&(s.start=o,s.end=c),(!r.start||o<r.start)&&(r.start=o),r.end=c,!0}saveDiscontinuitySyncInfo_(e){const t=e.playlist,n=e.segment;if(n.discontinuity)this.discontinuities[n.timeline]={time:n.start,accuracy:0};else if(t.discontinuityStarts&&t.discontinuityStarts.length)for(let r=0;r<t.discontinuityStarts.length;r++){const s=t.discontinuityStarts[r],a=t.discontinuitySequence+r+1,o=s-e.mediaIndex,c=Math.abs(o);if(!this.discontinuities[a]||this.discontinuities[a].accuracy>c){let u;o<0?u=n.start-bl({defaultDuration:t.targetDuration,durationList:t.segments,startIndex:e.mediaIndex,endIndex:s}):u=n.end+bl({defaultDuration:t.targetDuration,durationList:t.segments,startIndex:e.mediaIndex+1,endIndex:s}),this.discontinuities[a]={time:u,accuracy:c}}}}dispose(){this.trigger("dispose"),this.off()}}class aN extends pe.EventTarget{constructor(){super(),this.pendingTimelineChanges_={},this.lastTimelineChanges_={}}clearPendingTimelineChange(e){this.pendingTimelineChanges_[e]=null,this.trigger("pendingtimelinechange")}pendingTimelineChange({type:e,from:t,to:n}){return typeof t=="number"&&typeof n=="number"&&(this.pendingTimelineChanges_[e]={type:e,from:t,to:n},this.trigger("pendingtimelinechange")),this.pendingTimelineChanges_[e]}lastTimelineChange({type:e,from:t,to:n}){if(typeof t=="number"&&typeof n=="number"){this.lastTimelineChanges_[e]={type:e,from:t,to:n},delete this.pendingTimelineChanges_[e];const r={timelineChangeInfo:{from:t,to:n}};this.trigger({type:"timelinechange",metadata:r})}return this.lastTimelineChanges_[e]}dispose(){this.trigger("dispose"),this.pendingTimelineChanges_={},this.lastTimelineChanges_={},this.off()}}const oN=q2(z2(function(){var i=function(){function g(){this.listeners={}}var f=g.prototype;return f.on=function(_,k){this.listeners[_]||(this.listeners[_]=[]),this.listeners[_].push(k)},f.off=function(_,k){if(!this.listeners[_])return!1;var D=this.listeners[_].indexOf(k);return this.listeners[_]=this.listeners[_].slice(0),this.listeners[_].splice(D,1),D>-1},f.trigger=function(_){var k=this.listeners[_];if(k)if(arguments.length===2)for(var D=k.length,C=0;C<D;++C)k[C].call(this,arguments[1]);else for(var A=Array.prototype.slice.call(arguments,1),w=k.length,P=0;P<w;++P)k[P].apply(this,A)},f.dispose=function(){this.listeners={}},f.pipe=function(_){this.on("data",function(k){_.push(k)})},g}();/*! @name pkcs7 @version 1.0.4 @license Apache-2.0 */function e(g){return g.subarray(0,g.byteLength-g[g.byteLength-1])}/*! @name aes-decrypter @version 4.0.2 @license Apache-2.0 */const t=function(){const g=[[[],[],[],[],[]],[[],[],[],[],[]]],f=g[0],p=g[1],_=f[4],k=p[4];let D,C,A;const w=[],P=[];let S,M,U,R,J,ie;for(D=0;D<256;D++)P[(w[D]=D<<1^(D>>7)*283)^D]=D;for(C=A=0;!_[C];C^=S||1,A=P[A]||1)for(R=A^A<<1^A<<2^A<<3^A<<4,R=R>>8^R&255^99,_[C]=R,k[R]=C,U=w[M=w[S=w[C]]],ie=U*16843009^M*65537^S*257^C*16843008,J=w[R]*257^R*16843008,D=0;D<4;D++)f[D][C]=J=J<<24^J>>>8,p[D][R]=ie=ie<<24^ie>>>8;for(D=0;D<5;D++)f[D]=f[D].slice(0),p[D]=p[D].slice(0);return g};let n=null;class r{constructor(f){n||(n=t()),this._tables=[[n[0][0].slice(),n[0][1].slice(),n[0][2].slice(),n[0][3].slice(),n[0][4].slice()],[n[1][0].slice(),n[1][1].slice(),n[1][2].slice(),n[1][3].slice(),n[1][4].slice()]];let p,_,k;const D=this._tables[0][4],C=this._tables[1],A=f.length;let w=1;if(A!==4&&A!==6&&A!==8)throw new Error("Invalid aes key size");const P=f.slice(0),S=[];for(this._key=[P,S],p=A;p<4*A+28;p++)k=P[p-1],(p%A===0||A===8&&p%A===4)&&(k=D[k>>>24]<<24^D[k>>16&255]<<16^D[k>>8&255]<<8^D[k&255],p%A===0&&(k=k<<8^k>>>24^w<<24,w=w<<1^(w>>7)*283)),P[p]=P[p-A]^k;for(_=0;p;_++,p--)k=P[_&3?p:p-4],p<=4||_<4?S[_]=k:S[_]=C[0][D[k>>>24]]^C[1][D[k>>16&255]]^C[2][D[k>>8&255]]^C[3][D[k&255]]}decrypt(f,p,_,k,D,C){const A=this._key[1];let w=f^A[0],P=k^A[1],S=_^A[2],M=p^A[3],U,R,J;const ie=A.length/4-2;let X,V=4;const L=this._tables[1],H=L[0],q=L[1],$=L[2],G=L[3],oe=L[4];for(X=0;X<ie;X++)U=H[w>>>24]^q[P>>16&255]^$[S>>8&255]^G[M&255]^A[V],R=H[P>>>24]^q[S>>16&255]^$[M>>8&255]^G[w&255]^A[V+1],J=H[S>>>24]^q[M>>16&255]^$[w>>8&255]^G[P&255]^A[V+2],M=H[M>>>24]^q[w>>16&255]^$[P>>8&255]^G[S&255]^A[V+3],V+=4,w=U,P=R,S=J;for(X=0;X<4;X++)D[(3&-X)+C]=oe[w>>>24]<<24^oe[P>>16&255]<<16^oe[S>>8&255]<<8^oe[M&255]^A[V++],U=w,w=P,P=S,S=M,M=U}}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(f){this.jobs.push(f),this.timeout_||(this.timeout_=setTimeout(this.processJob_.bind(this),this.delay))}}const a=function(g){return g<<24|(g&65280)<<8|(g&16711680)>>8|g>>>24},o=function(g,f,p){const _=new Int32Array(g.buffer,g.byteOffset,g.byteLength>>2),k=new r(Array.prototype.slice.call(f)),D=new Uint8Array(g.byteLength),C=new Int32Array(D.buffer);let A,w,P,S,M,U,R,J,ie;for(A=p[0],w=p[1],P=p[2],S=p[3],ie=0;ie<_.length;ie+=4)M=a(_[ie]),U=a(_[ie+1]),R=a(_[ie+2]),J=a(_[ie+3]),k.decrypt(M,U,R,J,C,ie),C[ie]=a(C[ie]^A),C[ie+1]=a(C[ie+1]^w),C[ie+2]=a(C[ie+2]^P),C[ie+3]=a(C[ie+3]^S),A=M,w=U,P=R,S=J;return D};class c{constructor(f,p,_,k){const D=c.STEP,C=new Int32Array(f.buffer),A=new Uint8Array(f.byteLength);let w=0;for(this.asyncStream_=new s,this.asyncStream_.push(this.decryptChunk_(C.subarray(w,w+D),p,_,A)),w=D;w<C.length;w+=D)_=new Uint32Array([a(C[w-4]),a(C[w-3]),a(C[w-2]),a(C[w-1])]),this.asyncStream_.push(this.decryptChunk_(C.subarray(w,w+D),p,_,A));this.asyncStream_.push(function(){k(null,e(A))})}static get STEP(){return 32e3}decryptChunk_(f,p,_,k){return function(){const D=o(f,p,_);k.set(D,f.byteOffset)}}}var u=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},d;typeof window<"u"?d=window:typeof u<"u"?d=u:typeof self<"u"?d=self:d={};var h=d,y=function(f){return ArrayBuffer.isView==="function"?ArrayBuffer.isView(f):f&&f.buffer instanceof ArrayBuffer},v=h.BigInt||Number;v("0x1"),v("0x100"),v("0x10000"),v("0x1000000"),v("0x100000000"),v("0x10000000000"),v("0x1000000000000"),v("0x100000000000000"),v("0x10000000000000000"),function(){var g=new Uint16Array([65484]),f=new Uint8Array(g.buffer,g.byteOffset,g.byteLength);return f[0]===255?"big":f[0]===204?"little":"unknown"}();const b=function(g){const f={};return Object.keys(g).forEach(p=>{const _=g[p];y(_)?f[p]={bytes:_.buffer,byteOffset:_.byteOffset,byteLength:_.byteLength}:f[p]=_}),f};self.onmessage=function(g){const f=g.data,p=new Uint8Array(f.encrypted.bytes,f.encrypted.byteOffset,f.encrypted.byteLength),_=new Uint32Array(f.key.bytes,f.key.byteOffset,f.key.byteLength/4),k=new Uint32Array(f.iv.bytes,f.iv.byteOffset,f.iv.byteLength/4);new c(p,_,k,function(D,C){self.postMessage(b({source:f.source,decrypted:C}),[C.buffer])})}}));var lN=H2(oN);const cN=i=>{let e=i.default?"main":"alternative";return i.characteristics&&i.characteristics.indexOf("public.accessibility.describes-video")>=0&&(e="main-desc"),e},b_=(i,e)=>{i.abort(),i.pause(),e&&e.activePlaylistLoader&&(e.activePlaylistLoader.pause(),e.activePlaylistLoader=null)},Yp=(i,e)=>{e.activePlaylistLoader=i,i.load()},uN=(i,e)=>()=>{const{segmentLoaders:{[i]:t,main:n},mediaTypes:{[i]:r}}=e,s=r.activeTrack(),a=r.getActiveGroup(),o=r.activePlaylistLoader,c=r.lastGroup_;if(!(a&&c&&a.id===c.id)&&(r.lastGroup_=a,r.lastTrack_=s,b_(t,r),!(!a||a.isMainPlaylist))){if(!a.playlistLoader){o&&n.resetEverything();return}t.resyncLoader(),Yp(a.playlistLoader,r)}},dN=(i,e)=>()=>{const{segmentLoaders:{[i]:t},mediaTypes:{[i]:n}}=e;n.lastGroup_=null,t.abort(),t.pause()},hN=(i,e)=>()=>{const{mainPlaylistLoader:t,segmentLoaders:{[i]:n,main:r},mediaTypes:{[i]:s}}=e,a=s.activeTrack(),o=s.getActiveGroup(),c=s.activePlaylistLoader,u=s.lastTrack_;if(!(u&&a&&u.id===a.id)&&(s.lastGroup_=o,s.lastTrack_=a,b_(n,s),!!o)){if(o.isMainPlaylist){if(!a||!u||a.id===u.id)return;const d=e.vhs.playlistController_,h=d.selectPlaylist();if(d.media()===h)return;s.logger_(`track change. Switching main audio from ${u.id} to ${a.id}`),t.pause(),r.resetEverything(),d.fastQualityChange_(h);return}if(i==="AUDIO"){if(!o.playlistLoader){r.setAudio(!0),r.resetEverything();return}n.setAudio(!0),r.setAudio(!1)}if(c===o.playlistLoader){Yp(o.playlistLoader,s);return}n.track&&n.track(a),n.resetEverything(),Yp(o.playlistLoader,s)}},Ku={AUDIO:(i,e)=>()=>{const{mediaTypes:{[i]:t},excludePlaylist:n}=e,r=t.activeTrack(),s=t.activeGroup(),a=(s.filter(c=>c.default)[0]||s[0]).id,o=t.tracks[a];if(r===o){n({error:{message:"Problem encountered loading the default audio track."}});return}pe.log.warn("Problem encountered loading the alternate audio track.Switching back to default.");for(const c in t.tracks)t.tracks[c].enabled=t.tracks[c]===o;t.onTrackChanged()},SUBTITLES:(i,e)=>()=>{const{mediaTypes:{[i]:t}}=e;pe.log.warn("Problem encountered loading the subtitle track.Disabling subtitle track.");const n=t.activeTrack();n&&(n.mode="disabled"),t.onTrackChanged()}},__={AUDIO:(i,e,t)=>{if(!e)return;const{tech:n,requestOptions:r,segmentLoaders:{[i]:s}}=t;e.on("loadedmetadata",()=>{const a=e.media();s.playlist(a,r),(!n.paused()||a.endList&&n.preload()!=="none")&&s.load()}),e.on("loadedplaylist",()=>{s.playlist(e.media(),r),n.paused()||s.load()}),e.on("error",Ku[i](i,t))},SUBTITLES:(i,e,t)=>{const{tech:n,requestOptions:r,segmentLoaders:{[i]:s},mediaTypes:{[i]:a}}=t;e.on("loadedmetadata",()=>{const o=e.media();s.playlist(o,r),s.track(a.activeTrack()),(!n.paused()||o.endList&&n.preload()!=="none")&&s.load()}),e.on("loadedplaylist",()=>{s.playlist(e.media(),r),n.paused()||s.load()}),e.on("error",Ku[i](i,t))}},fN={AUDIO:(i,e)=>{const{vhs:t,sourceType:n,segmentLoaders:{[i]:r},requestOptions:s,main:{mediaGroups:a},mediaTypes:{[i]:{groups:o,tracks:c,logger_:u}},mainPlaylistLoader:d}=e,h=_l(d.main);(!a[i]||Object.keys(a[i]).length===0)&&(a[i]={main:{default:{default:!0}}},h&&(a[i].main.default.playlists=d.main.playlists));for(const y in a[i]){o[y]||(o[y]=[]);for(const v in a[i][y]){let b=a[i][y][v],g;if(h?(u(`AUDIO group '${y}' label '${v}' is a main playlist`),b.isMainPlaylist=!0,g=null):n==="vhs-json"&&b.playlists?g=new Ya(b.playlists[0],t,s):b.resolvedUri?g=new Ya(b.resolvedUri,t,s):b.playlists&&n==="dash"?g=new jp(b.playlists[0],t,s,d):g=null,b=Mt({id:v,playlistLoader:g},b),__[i](i,b.playlistLoader,e),o[y].push(b),typeof c[v]>"u"){const f=new pe.AudioTrack({id:v,kind:cN(b),enabled:!1,language:b.language,default:b.default,label:v});c[v]=f}}}r.on("error",Ku[i](i,e))},SUBTITLES:(i,e)=>{const{tech:t,vhs:n,sourceType:r,segmentLoaders:{[i]:s},requestOptions:a,main:{mediaGroups:o},mediaTypes:{[i]:{groups:c,tracks:u}},mainPlaylistLoader:d}=e;for(const h in o[i]){c[h]||(c[h]=[]);for(const y in o[i][h]){if(!n.options_.useForcedSubtitles&&o[i][h][y].forced)continue;let v=o[i][h][y],b;if(r==="hls")b=new Ya(v.resolvedUri,n,a);else if(r==="dash"){if(!v.playlists.filter(f=>f.excludeUntil!==1/0).length)return;b=new jp(v.playlists[0],n,a,d)}else r==="vhs-json"&&(b=new Ya(v.playlists?v.playlists[0]:v.resolvedUri,n,a));if(v=Mt({id:y,playlistLoader:b},v),__[i](i,v.playlistLoader,e),c[h].push(v),typeof u[y]>"u"){const g=t.addRemoteTextTrack({id:y,kind:"subtitles",default:v.default&&v.autoselect,language:v.language,label:y},!1).track;u[y]=g}}}s.on("error",Ku[i](i,e))},"CLOSED-CAPTIONS":(i,e)=>{const{tech:t,main:{mediaGroups:n},mediaTypes:{[i]:{groups:r,tracks:s}}}=e;for(const a in n[i]){r[a]||(r[a]=[]);for(const o in n[i][a]){const c=n[i][a][o];if(!/^(?:CC|SERVICE)/.test(c.instreamId))continue;const u=t.options_.vhs&&t.options_.vhs.captionServices||{};let d={label:o,language:c.language,instreamId:c.instreamId,default:c.default&&c.autoselect};if(u[d.instreamId]&&(d=Mt(d,u[d.instreamId])),d.default===void 0&&delete d.default,r[a].push(Mt({id:o},c)),typeof s[o]>"u"){const h=t.addRemoteTextTrack({id:d.instreamId,kind:"captions",default:d.default,language:d.language,label:d.label},!1).track;s[o]=h}}}}},k_=(i,e)=>{for(let t=0;t<i.length;t++)if(Rp(e,i[t])||i[t].playlists&&k_(i[t].playlists,e))return!0;return!1},pN=(i,e)=>t=>{const{mainPlaylistLoader:n,mediaTypes:{[i]:{groups:r}}}=e,s=n.media();if(!s)return null;let a=null;s.attributes[i]&&(a=r[s.attributes[i]]);const o=Object.keys(r);if(!a)if(i==="AUDIO"&&o.length>1&&_l(e.main))for(let c=0;c<o.length;c++){const u=r[o[c]];if(k_(u,s)){a=u;break}}else r.main?a=r.main:o.length===1&&(a=r[o[0]]);return typeof t>"u"?a:t===null||!a?null:a.filter(c=>c.id===t.id)[0]||null},mN={AUDIO:(i,e)=>()=>{const{mediaTypes:{[i]:{tracks:t}}}=e;for(const n in t)if(t[n].enabled)return t[n];return null},SUBTITLES:(i,e)=>()=>{const{mediaTypes:{[i]:{tracks:t}}}=e;for(const n in t)if(t[n].mode==="showing"||t[n].mode==="hidden")return t[n];return null}},gN=(i,{mediaTypes:e})=>()=>{const t=e[i].activeTrack();return t?e[i].activeGroup(t):null},vN=i=>{["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(u=>{fN[u](u,i)});const{mediaTypes:e,mainPlaylistLoader:t,tech:n,vhs:r,segmentLoaders:{["AUDIO"]:s,main:a}}=i;["AUDIO","SUBTITLES"].forEach(u=>{e[u].activeGroup=pN(u,i),e[u].activeTrack=mN[u](u,i),e[u].onGroupChanged=uN(u,i),e[u].onGroupChanging=dN(u,i),e[u].onTrackChanged=hN(u,i),e[u].getActiveGroup=gN(u,i)});const o=e.AUDIO.activeGroup();if(o){const u=(o.filter(h=>h.default)[0]||o[0]).id;e.AUDIO.tracks[u].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(u=>e[u].onGroupChanged())}),t.on("mediachanging",()=>{["AUDIO","SUBTITLES"].forEach(u=>e[u].onGroupChanging())});const c=()=>{e.AUDIO.onTrackChanged(),n.trigger({type:"usage",name:"vhs-audio-change"})};n.audioTracks().addEventListener("change",c),n.remoteTextTracks().addEventListener("change",e.SUBTITLES.onTrackChanged),r.on("dispose",()=>{n.audioTracks().removeEventListener("change",c),n.remoteTextTracks().removeEventListener("change",e.SUBTITLES.onTrackChanged)}),n.clearTracks("audio");for(const u in e.AUDIO.tracks)n.audioTracks().addTrack(e.AUDIO.tracks[u])},yN=()=>{const i={};return["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(e=>{i[e]={groups:{},tracks:{},activePlaylistLoader:null,activeGroup:Rr,activeTrack:Rr,getActiveGroup:Rr,onGroupChanged:Rr,onTrackChanged:Rr,lastTrack_:null,logger_:Mi(`MediaGroups[${e}]`)}}),i};class T_{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_=ui(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 bN extends pe.EventTarget{constructor(e,t){super(),this.currentPathway=null,this.defaultPathway=null,this.queryBeforeStart=!1,this.availablePathways_=new Set,this.steeringManifest=new T_,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_=Mi("Content Steering"),this.xhr_=e,this.getBandwidth_=t}assignTagProperties(e,t){this.manifestType_=t.serverUri?"HLS":"DASH";const n=t.serverUri||t.serverURL;if(!n){this.logger_(`steering manifest URL is ${n}, cannot request steering manifest.`),this.trigger("error");return}if(n.startsWith("data:")){this.decodeDataUriManifest_(n.substring(n.indexOf(",")+1));return}this.steeringManifest.reloadUri=ui(e,n),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 n=e?t:this.getRequestURI(t);if(!n){this.logger_("No valid content steering manifest URIs. Stopping content steering."),this.trigger("error"),this.dispose();return}const r={contentSteeringInfo:{uri:n}};this.trigger({type:"contentsteeringloadstart",metadata:r}),this.request_=this.xhr_({uri:n,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 ${n} this session.`),this.excludedSteeringManifestURLs.add(n);return}if(a.status===429){const u=a.responseHeaders["retry-after"];this.logger_(`manifest request 429 ${s}.`),this.logger_(`content steering will retry in ${u} seconds.`),this.startTTLTimeout_(parseInt(u,10));return}this.logger_(`manifest failed to load ${s}.`),this.startTTLTimeout_();return}this.trigger({type:"contentsteeringloadcomplete",metadata:r});let o;try{o=JSON.parse(this.request_.responseText)}catch(u){const d={errorType:pe.Error.StreamingContentSteeringParserError,error:u};this.trigger({type:"error",metadata:d})}this.assignSteeringProperties_(o);const c={contentSteeringInfo:r.contentSteeringInfo,contentSteeringManifest:{version:this.steeringManifest.version,reloadUri:this.steeringManifest.reloadUri,priority:this.steeringManifest.priority}};this.trigger({type:"contentsteeringparsed",metadata:c}),this.startTTLTimeout_()})}setProxyServerUrl_(e){const t=new te.URL(e),n=new te.URL(this.proxyServerUrl_);return n.searchParams.set("url",encodeURI(t.toString())),this.setSteeringParams_(n.toString())}decodeDataUriManifest_(e){const t=JSON.parse(te.atob(e));this.assignSteeringProperties_(t)}setSteeringParams_(e){const t=new te.URL(e),n=this.getPathway(),r=this.getBandwidth_();if(n){const s=`_${this.manifestType_}_pathway`;t.searchParams.set(s,n)}if(r){const s=`_${this.manifestType_}_throughput`;t.searchParams.set(s,r)}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 n=(r=>{for(const s of r)if(this.availablePathways_.has(s))return s;return[...this.availablePathways_][0]})(this.steeringManifest.priority);this.currentPathway!==n&&(this.currentPathway=n,this.trigger("content-steering"))}getPathway(){return this.currentPathway||this.defaultPathway}getRequestURI(e){if(!e)return null;const t=r=>this.excludedSteeringManifestURLs.has(r);if(this.proxyServerUrl_){const r=this.setProxyServerUrl_(e);if(!t(r))return r}const n=this.setSteeringParams_(e);return t(n)?null:n}startTTLTimeout_(e=this.steeringManifest.ttl){const t=e*1e3;this.ttlTimeout_=te.setTimeout(()=>{this.requestSteeringManifest()},t)}clearTTLTimeout_(){te.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 T_}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&&(ui(e,t.serverURL)!==this.steeringManifest.reloadUri||t.defaultServiceLocation!==this.defaultPathway||t.queryBeforeStart!==this.queryBeforeStart||t.proxyServerURL!==this.proxyServerUrl_)}getAvailablePathways(){return this.availablePathways_}}const _N=(i,e)=>{let t=null;return(...n)=>{clearTimeout(t),t=setTimeout(()=>{i.apply(null,n)},e)}},kN=10;let ds;const TN=["mediaRequests","mediaRequestsAborted","mediaRequestsTimedout","mediaRequestsErrored","mediaTransferDuration","mediaBytesTransferred","mediaAppends"],SN=function(i){return this.audioSegmentLoader_[i]+this.mainSegmentLoader_[i]},CN=function({currentPlaylist:i,buffered:e,currentTime:t,nextPlaylist:n,bufferLowWaterLine:r,bufferHighWaterLine:s,duration:a,bufferBasedABR:o,log:c}){if(!n)return pe.log.warn("We received no playlist to switch to. Please check your stream."),!1;const u=`allowing switch ${i&&i.id||"null"} -> ${n.id}`;if(!i)return c(`${u} as current playlist is not set`),!0;if(n.id===i.id)return!1;const d=!!Wa(e,t).length;if(!i.endList)return!d&&typeof i.partTargetDuration=="number"?(c(`not ${u} as current playlist is live llhls, but currentTime isn't in buffered.`),!1):(c(`${u} as current playlist is live`),!0);const h=Ip(e,t),y=o?Nn.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE:Nn.MAX_BUFFER_LOW_WATER_LINE;if(a<y)return c(`${u} as duration < max low water line (${a} < ${y})`),!0;const v=n.attributes.BANDWIDTH,b=i.attributes.BANDWIDTH;if(v<b&&(!o||h<s)){let g=`${u} as next bandwidth < current bandwidth (${v} < ${b})`;return o&&(g+=` and forwardBuffer < bufferHighWaterLine (${h} < ${s})`),c(g),!0}if((!o||v>b)&&h>=r){let g=`${u} as forwardBuffer >= bufferLowWaterLine (${h} >= ${r})`;return o&&(g+=` and next bandwidth > current bandwidth (${v} > ${b})`),c(g),!0}return c(`not ${u} as no switching criteria met`),!1};class xN extends pe.EventTarget{constructor(e){super(),this.fastQualityChange_=_N(this.fastQualityChange_.bind(this),100);const{src:t,withCredentials:n,tech:r,bandwidth:s,externVhs:a,useCueTags:o,playlistExclusionDuration:c,enableLowInitialPlaylist:u,sourceType:d,cacheEncryptionKeys:h,bufferBasedABR:y,leastPixelDiffSelector:v,captionServices:b,experimentalUseMMS:g}=e;if(!t)throw new Error("A non-empty playlist URL or JSON manifest string is required");let{maxPlaylistRetries:f}=e;(f===null||typeof f>"u")&&(f=1/0),ds=a,this.bufferBasedABR=!!y,this.leastPixelDiffSelector=!!v,this.withCredentials=n,this.tech_=r,this.vhs_=r.vhs,this.player_=e.player_,this.sourceType_=d,this.useCueTags_=o,this.playlistExclusionDuration=c,this.maxPlaylistRetries=f,this.enableLowInitialPlaylist=u,this.usingManagedMediaSource_=!1,this.useCueTags_&&(this.cueTagsTrack_=this.tech_.addTextTrack("metadata","ad-cues"),this.cueTagsTrack_.inBandMetadataTrackDispatchType=""),this.requestOptions_={withCredentials:n,maxPlaylistRetries:f,timeout:null},this.on("error",this.pauseLoading),this.mediaTypes_=yN(),g&&te.ManagedMediaSource?(this.tech_.el_.disableRemotePlayback=!0,this.mediaSource=new te.ManagedMediaSource,this.usingManagedMediaSource_=!0,pe.log("Using ManagedMediaSource")):te.MediaSource&&(this.mediaSource=new te.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_=Pn(),this.hasPlayed_=!1,this.syncController_=new sN(e),this.segmentMetadataTrack_=r.addRemoteTextTrack({kind:"metadata",label:"segment-metadata"},!1).track,this.segmentMetadataTrack_.mode="hidden",this.decrypter_=new lN,this.sourceUpdater_=new f_(this.mediaSource),this.inbandTextTracks_={},this.timelineChangeController_=new aN,this.keyStatusMap_=new Map;const p={vhs:this.vhs_,parse708captions:e.parse708captions,useDtsForTimestampOffset:e.useDtsForTimestampOffset,captionServices:b,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:h,sourceUpdater:this.sourceUpdater_,timelineChangeController:this.timelineChangeController_,exactManifestTimings:e.exactManifestTimings,addMetadataToTextTrack:this.addMetadataToTextTrack.bind(this)};this.mainPlaylistLoader_=this.sourceType_==="dash"?new jp(t,this.vhs_,Mt(this.requestOptions_,{addMetadataToTextTrack:this.addMetadataToTextTrack.bind(this)})):new Ya(t,this.vhs_,Mt(this.requestOptions_,{addDateRangesToTextTrack:this.addDateRangesToTextTrack_.bind(this)})),this.setupMainPlaylistLoaderListeners_(),this.mainSegmentLoader_=new Wp(Mt(p,{segmentMetadataTrack:this.segmentMetadataTrack_,loaderType:"main"}),e),this.audioSegmentLoader_=new Wp(Mt(p,{loaderType:"audio"}),e),this.subtitleSegmentLoader_=new eN(Mt(p,{loaderType:"vtt",featuresNativeTextTracks:this.tech_.featuresNativeTextTracks,loadVttJs:()=>new Promise((D,C)=>{function A(){r.off("vttjserror",w),D()}function w(){r.off("vttjsloaded",A),C()}r.one("vttjsloaded",A),r.one("vttjserror",w),r.addWebVttScript_()})}),e);const _=()=>this.mainSegmentLoader_.bandwidth;this.contentSteeringController_=new bN(this.vhs_.xhr,_),this.setupSegmentLoaderListeners_(),this.bufferBasedABR&&(this.mainPlaylistLoader_.one("loadedplaylist",()=>this.startABRTimer_()),this.tech_.on("pause",()=>this.stopABRTimer_()),this.tech_.on("play",()=>this.startABRTimer_())),TN.forEach(D=>{this[D+"_"]=SN.bind(this,D)}),this.logger_=Mi("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 k=this.tech_.preload()==="none"?"play":"loadstart";this.tech_.one(k,()=>{const D=Date.now();this.tech_.one("loadeddata",()=>{this.timeToLoadedData__=Date.now()-D,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,n){const r=this.media(),s=r&&(r.id||r.uri),a=e&&(e.id||e.uri);if(s&&s!==a){this.logger_(`switch media ${s} -> ${a} from ${t}`);const o={renditionInfo:{id:a,bandwidth:e.attributes.BANDWIDTH,resolution:e.attributes.RESOLUTION,codecs:e.attributes.CODECS},cause:t};this.trigger({type:"renditionselected",metadata:o}),this.tech_.trigger({type:"usage",name:`vhs-rendition-change-${t}`})}this.mainPlaylistLoader_.media(e,n)}switchMediaForDASHContentSteering_(){["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(e=>{const t=this.mediaTypes_[e],n=t?t.activeGroup():null,r=this.contentSteeringController_.getPathway();if(n&&r){const a=(n.length?n[0].playlists:n.playlists).filter(o=>o.attributes.serviceLocation===r);a.length&&this.mediaTypes_[e].activePlaylistLoader.media(a[0])}})}startABRTimer_(){this.stopABRTimer_(),this.abrTimer_=te.setInterval(()=>this.checkABR_(),250)}stopABRTimer_(){this.tech_.scrubbing&&this.tech_.scrubbing()||(te.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 n=e.mediaGroups.AUDIO,r=Object.keys(n);let s;if(Object.keys(this.mediaTypes_.AUDIO.groups).length)s=this.mediaTypes_.AUDIO.activeTrack();else{const o=n.main||r.length&&n[r[0]];for(const c in o)if(o[c].default){s={label:c};break}}if(!s)return t;const a=[];for(const o in n)if(n[o][s.label]){const c=n[o][s.label];if(c.playlists&&c.playlists.length)a.push.apply(a,c.playlists);else if(c.uri)a.push(c);else if(e.playlists.length)for(let u=0;u<e.playlists.length;u++){const d=e.playlists[u];d.attributes&&d.attributes.AUDIO&&d.attributes.AUDIO===o&&a.push(d)}}return a.length?a:t}setupMainPlaylistLoaderListeners_(){this.mainPlaylistLoader_.on("loadedmetadata",()=>{const t=this.mainPlaylistLoader_.media(),n=t.targetDuration*1.5*1e3;Mp(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.media())?this.requestOptions_.timeout=0:this.requestOptions_.timeout=n,t.endList&&this.tech_.preload()!=="none"&&(this.mainSegmentLoader_.playlist(t,this.requestOptions_),this.mainSegmentLoader_.load()),vN({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(),t),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 t=this.mainPlaylistLoader_.media();if(!t){this.attachContentSteeringListeners_(),this.initContentSteeringController_(),this.excludeUnsupportedVariants_();let n;if(this.enableLowInitialPlaylist&&(n=this.selectInitialPlaylist()),n||(n=this.selectPlaylist()),!n||!this.shouldSwitchToMedia_(n)||(this.initialMedia_=n,this.switchMedia_(this.initialMedia_,"initial"),!(this.sourceType_==="vhs-json"&&this.initialMedia_.segments)))return;t=this.initialMedia_}this.handleUpdatedMediaPlaylist(t)}),this.mainPlaylistLoader_.on("error",()=>{const t=this.mainPlaylistLoader_.error;this.excludePlaylist({playlistToExclude:t.playlist,error:t})}),this.mainPlaylistLoader_.on("mediachanging",()=>{this.mainSegmentLoader_.abort(),this.mainSegmentLoader_.pause()}),this.mainPlaylistLoader_.on("mediachange",()=>{const t=this.mainPlaylistLoader_.media(),n=t.targetDuration*1.5*1e3;Mp(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.media())?this.requestOptions_.timeout=0:this.requestOptions_.timeout=n,this.sourceType_==="dash"&&this.mainPlaylistLoader_.isPaused&&this.mainPlaylistLoader_.load(),this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.playlist(t,this.requestOptions_),this.waitingForFastQualityPlaylistReceived_?this.runFastQualitySwitch_():this.mainSegmentLoader_.load(),this.tech_.trigger({type:"mediachange",bubbles:!0})}),this.mainPlaylistLoader_.on("playlistunchanged",()=>{const t=this.mainPlaylistLoader_.media();if(t.lastExcludeReason_==="playlist-unchanged")return;this.stuckAtPlaylistEnd_(t)&&(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(t=>{this.mainPlaylistLoader_.on(t,n=>{this.player_.trigger(yn({},n))})})}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 n=e.mediaGroups||{};let r=!0;const s=Object.keys(n.AUDIO);for(const a in n.AUDIO)for(const o in n.AUDIO[a])n.AUDIO[a][o].uri||(r=!1);r&&this.tech_.trigger({type:"usage",name:"vhs-demuxed"}),Object.keys(n.SUBTITLES).length&&this.tech_.trigger({type:"usage",name:"vhs-webvtt"}),ds.Playlist.isAes(t)&&this.tech_.trigger({type:"usage",name:"vhs-aes"}),s.length&&Object.keys(n.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_,n=this.tech_.currentTime(),r=this.bufferLowWaterLine(),s=this.bufferHighWaterLine(),a=this.tech_.buffered();return CN({buffered:a,currentTime:n,currentPlaylist:t,nextPlaylist:e,bufferLowWaterLine:r,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 n=this.mainSegmentLoader_.error();this.excludePlaylist({playlistToExclude:n.playlist,error:n})}),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 n=this.audioSegmentLoader_.pendingSegment_;if(!n||!n.segment||!n.segment.syncInfo)return;const r=n.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",n=>{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:kN}))});const e=()=>{if(!this.sourceUpdater_.hasCreatedSourceBuffers())return this.tryToCreateSourceBuffers_();const n=this.getCodecsOrExclude_();n&&this.sourceUpdater_.addOrChangeSourceBuffers(n)};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(n=>{this.mainSegmentLoader_.on(n,r=>{this.player_.trigger(yn({},r))}),this.audioSegmentLoader_.on(n,r=>{this.player_.trigger(yn({},r))}),this.subtitleSegmentLoader_.on(n,r=>{this.player_.trigger(yn({},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 n=t.end(0);let r=n;if(e.start){const s=e.start.timeOffset;s<0?r=Math.max(n+s,t.start(0)):r=Math.min(n,s)}this.trigger("firstplay"),this.tech_.setCurrentTime(r)}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 n=this.syncController_.getExpiredTime(e,this.duration());if(n===null)return!1;const r=ds.Playlist.playlistEnd(e,n),s=this.tech_.currentTime(),a=this.tech_.buffered();if(!a.length)return r-s<=pr;const o=a.end(a.length-1);return o-s<=pr&&r-o<=pr}excludePlaylist({playlistToExclude:e=this.mainPlaylistLoader_.media(),error:t={},playlistExclusionDuration:n}){if(e=e||this.mainPlaylistLoader_.media(),n=n||t.playlistExclusionDuration||this.playlistExclusionDuration,!e){this.error=t,this.mediaSource.readyState!=="open"?this.trigger("error"):this.sourceUpdater_.endOfStream("network");return}e.playlistErrors_++;const r=this.mainPlaylistLoader_.main.playlists,s=r.filter(qu),a=s.length===1&&s[0]===e;if(r.length===1&&n!==1/0)return pe.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 b=this.pathwayAttribute_(e),g=this.contentSteeringController_.steeringManifest.ttl*1e3;this.contentSteeringController_.excludePathway(b),this.excludeThenChangePathway_(),setTimeout(()=>{this.contentSteeringController_.addAvailablePathway(b)},g);return}let v=!1;r.forEach(b=>{if(b===e)return;const g=b.excludeUntil;typeof g<"u"&&g!==1/0&&(v=!0,delete b.excludeUntil)}),v&&(pe.log.warn("Removing other playlists from the exclusion list because the last rendition is about to be excluded."),this.tech_.trigger("retryplaylist"))}let o;e.playlistErrors_>this.maxPlaylistRetries?o=1/0:o=Date.now()+n*1e3,e.excludeUntil=o,t.reason&&(e.lastExcludeReason_=t.reason),this.tech_.trigger("excludeplaylist"),this.tech_.trigger({type:"usage",name:"vhs-rendition-excluded"});const c=this.selectPlaylist();if(!c){this.error="Playback cannot continue. No available working or supported playlists.",this.trigger("error");return}const u=t.internal?this.logger_:pe.log.warn,d=t.message?" "+t.message:"";u(`${t.internal?"Internal problem":"Problem"} encountered with playlist ${e.id}.${d} Switching to playlist ${c.id}.`),c.attributes.AUDIO!==e.attributes.AUDIO&&this.delegateLoaders_("audio",["abort","pause"]),c.attributes.SUBTITLES!==e.attributes.SUBTITLES&&this.delegateLoaders_("subtitle",["abort","pause"]),this.delegateLoaders_("main",["abort","pause"]);const h=c.targetDuration/2*1e3||5*1e3,y=typeof c.lastRequest=="number"&&Date.now()-c.lastRequest<=h;return this.switchMedia_(c,"exclude",a||y)}pauseLoading(){this.delegateLoaders_("all",["abort","pause"]),this.stopABRTimer_()}delegateLoaders_(e,t){const n=[],r=e==="all";(r||e==="main")&&n.push(this.mainPlaylistLoader_);const s=[];(r||e==="audio")&&s.push("AUDIO"),(r||e==="subtitle")&&(s.push("CLOSED-CAPTIONS"),s.push("SUBTITLES")),s.forEach(a=>{const o=this.mediaTypes_[a]&&this.mediaTypes_[a].activePlaylistLoader;o&&n.push(o)}),["main","audio","subtitle"].forEach(a=>{const o=this[`${a}SegmentLoader_`];o&&(e===a||e==="all")&&n.push(o)}),n.forEach(a=>t.forEach(o=>{typeof a[o]=="function"&&a[o]()}))}setCurrentTime(e){const t=Wa(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:ds.Playlist.duration(e):1/0:0}seekable(){return this.seekable_}getSeekableRange_(e,t){const n=e.media();if(!n)return null;const r=this.syncController_.getMediaSequenceSync(t);if(r&&r.isReliable){const o=r.start,c=r.end;if(!isFinite(o)||!isFinite(c))return null;const u=ds.Playlist.liveEdgeDelay(this.mainPlaylistLoader_.main,n),d=Math.max(o,c-u);return Pn([[o,d]])}const s=this.syncController_.getExpiredTime(n,this.duration());if(s===null)return null;const a=ds.Playlist.seekable(n,s,ds.Playlist.liveEdgeDelay(this.mainPlaylistLoader_.main,n));return a.length?a:null}computeFinalSeekable_(e,t){if(!t)return e;const n=e.start(0),r=e.end(0),s=t.start(0),a=t.end(0);return s>r||n>a?e:Pn([[Math.max(n,s),Math.min(r,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 n=this.seekable_;if(this.seekable_=this.computeFinalSeekable_(e,t),!this.seekable_||n&&n.length&&this.seekable_.length&&n.start(0)===this.seekable_.start(0)&&n.end(0)===this.seekable_.end(0))return;this.logger_(`seekable updated [${d2(this.seekable_)}]`);const r={seekableRanges:this.seekable_};this.trigger({type:"seekablerangeschanged",metadata:r}),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 r=this.seekable();if(!r.length)return;(isNaN(this.mediaSource.duration)||this.mediaSource.duration<r.end(r.length-1))&&this.sourceUpdater_.setDuration(r.end(r.length-1));return}const t=this.tech_.buffered();let n=ds.Playlist.duration(this.mainPlaylistLoader_.media());t.length>0&&(n=Math.max(n,t.end(t.length-1))),this.mediaSource.duration!==n&&this.sourceUpdater_.setDuration(n)}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 n in t)t[n].forEach(r=>{r.playlistLoader&&r.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_(),n=e?!!this.audioSegmentLoader_.getCurrentMediaInfo_():!0;return!(!t||!n)}getCodecsOrExclude_(){const e={main:this.mainSegmentLoader_.getCurrentMediaInfo_()||{},audio:this.audioSegmentLoader_.getCurrentMediaInfo_()||{}},t=this.mainSegmentLoader_.getPendingSegmentPlaylist()||this.media();e.video=e.main;const n=Tl(this.main(),t),r={},s=!!this.mediaTypes_.AUDIO.activePlaylistLoader;if(e.main.hasVideo&&(r.video=n.video||e.main.videoCodec||b6),e.main.isMuxed&&(r.video+=`,${n.audio||e.main.audioCodec||jy}`),(e.main.hasAudio&&!e.main.isMuxed||e.audio.hasAudio||s)&&(r.audio=n.audio||e.main.audioCodec||e.audio.audioCodec||jy,e.audio.isFmp4=e.main.hasAudio&&!e.main.isMuxed?e.main.isFmp4:e.audio.isFmp4),!r.audio&&!r.video){this.excludePlaylist({playlistToExclude:t,error:{message:"Could not determine codecs for playlist."},playlistExclusionDuration:1/0});return}const a=(u,d)=>u?el(d,this.usingManagedMediaSource_):_f(d),o={};let c;if(["video","audio"].forEach(function(u){if(r.hasOwnProperty(u)&&!a(e[u].isFmp4,r[u])){const d=e[u].isFmp4?"browser":"muxer";o[d]=o[d]||[],o[d].push(r[u]),u==="audio"&&(c=d)}}),s&&c&&t.attributes.AUDIO){const u=t.attributes.AUDIO;this.main().playlists.forEach(d=>{(d.attributes&&d.attributes.AUDIO)===u&&d!==t&&(d.excludeUntil=1/0)}),this.logger_(`excluding audio group ${u} as ${c} does not support codec(s): "${r.audio}"`)}if(Object.keys(o).length){const u=Object.keys(o).reduce((d,h)=>(d&&(d+=", "),d+=`${h} does not support codec(s): "${o[h].join(",")}"`,d),"")+".";this.excludePlaylist({playlistToExclude:t,error:{internal:!0,message:u},playlistExclusionDuration:1/0});return}if(this.sourceUpdater_.hasCreatedSourceBuffers()&&!this.sourceUpdater_.canChangeType()){const u=[];if(["video","audio"].forEach(d=>{const h=(or(this.sourceUpdater_.codecs[d]||"")[0]||{}).type,y=(or(r[d]||"")[0]||{}).type;h&&y&&h.toLowerCase()!==y.toLowerCase()&&u.push(`"${this.sourceUpdater_.codecs[d]}" -> "${r[d]}"`)}),u.length){this.excludePlaylist({playlistToExclude:t,error:{message:`Codec switching not supported: ${u.join(", ")}.`,internal:!0},playlistExclusionDuration:1/0});return}}return r}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(n=>{const r=e[n];if(t.indexOf(r.id)!==-1)return;t.push(r.id);const s=Tl(this.main,r),a=[];s.audio&&!_f(s.audio)&&!el(s.audio,this.usingManagedMediaSource_)&&a.push(`audio codec ${s.audio}`),s.video&&!_f(s.video)&&!el(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&&(r.excludeUntil=1/0,this.logger_(`excluding ${r.id} for unsupported: ${a.join(", ")}`))})}excludeIncompatibleVariants_(e){const t=[],n=this.main().playlists,r=kl(or(e)),s=A2(r),a=r.video&&or(r.video)[0]||null,o=r.audio&&or(r.audio)[0]||null;Object.keys(n).forEach(c=>{const u=n[c];if(t.indexOf(u.id)!==-1||u.excludeUntil===1/0)return;t.push(u.id);const d=[],h=Tl(this.mainPlaylistLoader_.main,u),y=A2(h);if(!(!h.audio&&!h.video)){if(y!==s&&d.push(`codec count "${y}" !== "${s}"`),!this.sourceUpdater_.canChangeType()){const v=h.video&&or(h.video)[0]||null,b=h.audio&&or(h.audio)[0]||null;v&&a&&v.type.toLowerCase()!==a.type.toLowerCase()&&d.push(`video codec "${v.type}" !== "${a.type}"`),b&&o&&b.type.toLowerCase()!==o.type.toLowerCase()&&d.push(`audio codec "${b.type}" !== "${o.type}"`)}d.length&&(u.excludeUntil=1/0,this.logger_(`excluding ${u.id}: ${d.join(" && ")}`))}})}updateAdCues_(e){let t=0;const n=this.seekable();n.length&&(t=n.start(0)),nN(e,this.cueTagsTrack_,t)}goalBufferLength(){const e=this.tech_.currentTime(),t=Nn.GOAL_BUFFER_LENGTH,n=Nn.GOAL_BUFFER_LENGTH_RATE,r=Math.max(t,Nn.MAX_GOAL_BUFFER_LENGTH);return Math.min(t+e*n,r)}bufferLowWaterLine(){const e=this.tech_.currentTime(),t=Nn.BUFFER_LOW_WATER_LINE,n=Nn.BUFFER_LOW_WATER_LINE_RATE,r=Math.max(t,Nn.MAX_BUFFER_LOW_WATER_LINE),s=Math.max(t,Nn.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE);return Math.min(t+e*n,this.bufferBasedABR?s:r)}bufferHighWaterLine(){return Nn.BUFFER_HIGH_WATER_LINE}addDateRangesToTextTrack_(e){a_(this.inbandTextTracks_,"com.apple.streaming",this.tech_),RP({inbandTextTracks:this.inbandTextTracks_,dateRanges:e})}addMetadataToTextTrack(e,t,n){const r=this.sourceUpdater_.videoBuffer?this.sourceUpdater_.videoTimestampOffset():this.sourceUpdater_.audioTimestampOffset();a_(this.inbandTextTracks_,e,this.tech_),NP({inbandTextTracks:this.inbandTextTracks_,metadataArray:t,timestampOffset:r,videoDuration:n})}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(t=>{this.contentSteeringController_.on(t,n=>{this.trigger(yn({},n))})}),this.sourceType_==="dash"&&this.mainPlaylistLoader_.on("loadedplaylist",()=>{const t=this.main();(this.contentSteeringController_.didDASHTagChange(t.uri,t.contentSteering)||(()=>{const s=this.contentSteeringController_.getAvailablePathways(),a=[];for(const o of t.playlists){const c=o.attributes.serviceLocation;if(c&&(a.push(c),!s.has(c)))return!0}return!!(!a.length&&s.size)})())&&this.resetContentSteeringController_()})}excludeThenChangePathway_(){const e=this.contentSteeringController_.getPathway();if(!e)return;this.handlePathwayClones_();const n=this.main().playlists,r=new Set;let s=!1;Object.keys(n).forEach(a=>{const o=n[a],c=this.pathwayAttribute_(o),u=c&&e!==c;o.excludeUntil===1/0&&o.lastExcludeReason_==="content-steering"&&!u&&(delete o.excludeUntil,delete o.lastExcludeReason_,s=!0);const h=!o.excludeUntil&&o.excludeUntil!==1/0;!r.has(o.id)&&u&&h&&(r.add(o.id),o.excludeUntil=1/0,o.lastExcludeReason_="content-steering",this.logger_(`excluding ${o.id} for ${o.lastExcludeReason_}`))}),this.contentSteeringController_.manifestType_==="DASH"&&Object.keys(this.mediaTypes_).forEach(a=>{const o=this.mediaTypes_[a];if(o.activePlaylistLoader){const c=o.activePlaylistLoader.media_;c&&c.attributes.serviceLocation!==e&&(s=!0)}}),s&&this.changeSegmentPathway_()}handlePathwayClones_(){const t=this.main().playlists,n=this.contentSteeringController_.currentPathwayClones,r=this.contentSteeringController_.nextPathwayClones;if(n&&n.size||r&&r.size){for(const[a,o]of n.entries())r.get(a)||(this.mainPlaylistLoader_.updateOrDeleteClone(o),this.contentSteeringController_.excludePathway(a));for(const[a,o]of r.entries()){const c=n.get(a);if(!c){t.filter(d=>d.attributes["PATHWAY-ID"]===o["BASE-ID"]).forEach(d=>{this.mainPlaylistLoader_.addClonePathway(o,d)}),this.contentSteeringController_.addAvailablePathway(a);continue}this.equalPathwayClones_(c,o)||(this.mainPlaylistLoader_.updateOrDeleteClone(o,!0),this.contentSteeringController_.addAvailablePathway(a))}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 n=e["URI-REPLACEMENT"].PARAMS,r=t["URI-REPLACEMENT"].PARAMS;for(const s in n)if(n[s]!==r[s])return!1;for(const s in r)if(n[s]!==r[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(n=>{const r=this.mainPlaylistLoader_.getKeyIdSet(n);!r||!r.size||r.forEach(s=>{const a="usable",o=this.keyStatusMap_.has(s)&&this.keyStatusMap_.get(s)===a,c=n.lastExcludeReason_===t&&n.excludeUntil===1/0;o?o&&c&&(delete n.excludeUntil,delete n.lastExcludeReason_,this.logger_(`enabling playlist ${n.id} because key ID ${s} is ${a}`)):(n.excludeUntil!==1/0&&n.lastExcludeReason_!==t&&(n.excludeUntil=1/0,n.lastExcludeReason_=t,this.logger_(`excluding playlist ${n.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(n=>{const r=n&&n.attributes&&n.attributes.RESOLUTION&&n.attributes.RESOLUTION.height<720,s=n.excludeUntil===1/0&&n.lastExcludeReason_===t;r&&s&&(delete n.excludeUntil,pe.log.warn(`enabling non-HD playlist ${n.id} because all playlists were excluded due to ${t} key IDs`))})}addKeyStatus_(e,t){const s=(typeof e=="string"?e:QP(e)).slice(0,32).toLowerCase();this.logger_(`KeyStatus '${t}' with key ID ${s} added to the keyStatusMap`),this.keyStatusMap_.set(s,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 EN=(i,e,t)=>n=>{const r=i.main.playlists[e],s=Op(r),a=qu(r);if(typeof n>"u")return a;n?delete r.disabled:r.disabled=!0;const o={renditionInfo:{id:e,bandwidth:r.attributes.BANDWIDTH,resolution:r.attributes.RESOLUTION,codecs:r.attributes.CODECS},cause:"fast-quality"};return n!==a&&!s&&(n?(t(r),i.trigger({type:"renditionenabled",metadata:o})):i.trigger({type:"renditiondisabled",metadata:o})),n};class wN{constructor(e,t,n){const{playlistController_:r}=e,s=r.fastQualityChange_.bind(r);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=Tl(r.main(),t),this.playlist=t,this.id=n,this.enabled=EN(e.playlists,t.id,s)}}const DN=function(i){i.representations=()=>{const e=i.playlistController_.main(),t=_l(e)?i.playlistController_.getAudioTrackPlaylists_():e.playlists;return t?t.filter(n=>!Op(n)).map((n,r)=>new wN(i,n,n.id)):[]}},S_=["seeking","seeked","pause","playing","error"];class AN extends pe.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_=Mi("PlaybackWatcher"),this.logger_("initialize");const t=()=>this.monitorCurrentTime_(),n=()=>this.monitorCurrentTime_(),r=()=>this.techWaiting_(),s=()=>this.resetTimeUpdate_(),a=this.playlistController_,o=["main","subtitle","audio"],c={};o.forEach(d=>{c[d]={reset:()=>this.resetSegmentDownloads_(d),updateend:()=>this.checkSegmentDownloads_(d)},a[`${d}SegmentLoader_`].on("appendsdone",c[d].updateend),a[`${d}SegmentLoader_`].on("playlistupdate",c[d].reset),this.tech_.on(["seeked","seeking"],c[d].reset)});const u=d=>{["main","audio"].forEach(h=>{a[`${h}SegmentLoader_`][d]("appended",this.seekingAppendCheck_)})};this.seekingAppendCheck_=()=>{this.fixesBadSeeks_()&&(this.consecutiveUpdates=0,this.lastRecordedTime=this.tech_.currentTime(),u("off"))},this.clearSeekingAppendCheck_=()=>u("off"),this.watchForBadSeeking_=()=>{this.clearSeekingAppendCheck_(),u("on")},this.tech_.on("seeked",this.clearSeekingAppendCheck_),this.tech_.on("seeking",this.watchForBadSeeking_),this.tech_.on("waiting",r),this.tech_.on(S_,s),this.tech_.on("canplay",n),this.tech_.one("play",t),this.dispose=()=>{this.clearSeekingAppendCheck_(),this.logger_("dispose"),this.tech_.off("waiting",r),this.tech_.off(S_,s),this.tech_.off("canplay",n),this.tech_.off("play",t),this.tech_.off("seeking",this.watchForBadSeeking_),this.tech_.off("seeked",this.clearSeekingAppendCheck_),o.forEach(d=>{a[`${d}SegmentLoader_`].off("appendsdone",c[d].updateend),a[`${d}SegmentLoader_`].off("playlistupdate",c[d].reset),this.tech_.off(["seeked","seeking"],c[d].reset)}),this.checkCurrentTimeTimeout_&&te.clearTimeout(this.checkCurrentTimeTimeout_),this.resetTimeUpdate_()}}monitorCurrentTime_(){this.checkCurrentTime_(),this.checkCurrentTimeTimeout_&&te.clearTimeout(this.checkCurrentTimeTimeout_),this.checkCurrentTimeTimeout_=te.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_,n=t[`${e}SegmentLoader_`],r=n.buffered_(),s=vI(this[`${e}Buffered_`],r);if(this[`${e}Buffered_`]=r,s){const a={bufferedRanges:r};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:n.playlist_&&n.playlist_.id,buffered:qs(r)}),!(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+pr>=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(Pn([this.lastRecordedTime,e]));const n={playedRanges:this.playedRanges_};this.playlistController_.trigger({type:"playedrangeschanged",metadata:n}),this.consecutiveUpdates=0,this.lastRecordedTime=e}}resetTimeUpdate_(){this.consecutiveUpdates=0}fixesBadSeeks_(){if(!this.tech_.seeking())return!1;const t=this.seekable(),n=this.tech_.currentTime(),r=this.afterSeekableWindow_(t,n,this.media(),this.allowSeeksWithinUnsafeLiveWindow);let s;if(r&&(s=t.end(t.length-1)),this.beforeSeekableWindow_(t,n)){const b=t.start(0);s=b+(b===t.end(0)?0:pr)}if(typeof s<"u")return this.logger_(`Trying to seek outside of seekable at time ${n} with seekable range ${d2(t)}. Seeking to ${s}.`),this.tech_.setCurrentTime(s),!0;const a=this.playlistController_.sourceUpdater_,o=this.tech_.buffered(),c=a.audioBuffer?a.audioBuffered():null,u=a.videoBuffer?a.videoBuffered():null,d=this.media(),h=d.partTargetDuration?d.partTargetDuration:(d.targetDuration-fr)*2,y=[c,u];for(let b=0;b<y.length;b++){if(!y[b])continue;if(Ip(y[b],n)<h)return!1}const v=Hu(o,n);return v.length===0?!1:(s=v.start(0)+pr,this.logger_(`Buffered region starts (${v.start(0)}) just beyond seek point (${n}). Seeking to ${s}.`),this.tech_.setCurrentTime(s),!0)}waiting_(){if(this.techWaiting_())return;const e=this.tech_.currentTime(),t=this.tech_.buffered(),n=Wa(t,e);if(n.length&&e+3<=n.end(0)){this.resetTimeUpdate_(),this.tech_.setCurrentTime(e),this.logger_(`Stopped at ${e} while inside a buffered region [${n.start(0)} -> ${n.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 o=e.end(e.length-1);return this.logger_(`Fell out of live window at time ${t}. Seeking to live point (seekable end) ${o}`),this.resetTimeUpdate_(),this.tech_.setCurrentTime(o),this.tech_.trigger({type:"usage",name:"vhs-live-resync"}),!0}const n=this.tech_.vhs.playlistController_.sourceUpdater_,r=this.tech_.buffered();if(this.videoUnderflow_({audioBuffered:n.audioBuffered(),videoBuffered:n.videoBuffered(),currentTime:t}))return this.resetTimeUpdate_(),this.tech_.setCurrentTime(t),this.tech_.trigger({type:"usage",name:"vhs-video-underflow"}),!0;const a=Hu(r,t);return a.length>0?(this.logger_(`Stopped at ${t} and seeking to ${a.start(0)}`),this.resetTimeUpdate_(),this.skipTheGap_(t),!0):!1}afterSeekableWindow_(e,t,n,r=!1){if(!e.length)return!1;let s=e.end(e.length-1)+pr;const a=!n.endList,o=typeof n.partTargetDuration=="number";return a&&(o||r)&&(s=e.end(e.length-1)+n.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:n}){if(!e)return;let r;if(e.length&&t.length){const s=Wa(e,n-3),a=Wa(e,n),o=Wa(t,n);o.length&&!a.length&&s.length&&(r={start:s.end(0),end:o.end(0)})}else Hu(e,n).length||(r=this.gapFromVideoUnderflow_(e,n));return r?(this.logger_(`Encountered a gap in video from ${r.start} to ${r.end}. Seeking to current time ${n}`),!0):!1}skipTheGap_(e){const t=this.tech_.buffered(),n=this.tech_.currentTime(),r=Hu(t,n);if(this.resetTimeUpdate_(),r.length===0||n!==e)return;this.logger_("skipTheGap_:","currentTime:",n,"scheduled currentTime:",e,"nextRange start:",r.start(0)),this.tech_.setCurrentTime(r.start(0)+fr);const s={gapInfo:{from:n,to:r.start(0)}};this.playlistController_.trigger({type:"gapjumped",metadata:s}),this.tech_.trigger({type:"usage",name:"vhs-gap-skip"})}gapFromVideoUnderflow_(e,t){const n=pI(e);for(let r=0;r<n.length;r++){const s=n.start(r),a=n.end(r);if(t-s<4&&t-s>2)return{start:s,end:a}}return null}}const IN={errorInterval:30,getSource(i){const t=this.tech({IWillNotUseThisInPlugins:!0}).currentSource_||this.currentSource();return i(t)}},C_=function(i,e){let t=0,n=0;const r=Mt(IN,e);i.ready(()=>{i.trigger({type:"usage",name:"vhs-error-reload-initialized"})});const s=function(){n&&i.currentTime(n)},a=function(d){d!=null&&(n=i.duration()!==1/0&&i.currentTime()||0,i.one("loadedmetadata",s),i.src(d),i.trigger({type:"usage",name:"vhs-error-reload"}),i.play())},o=function(){if(Date.now()-t<r.errorInterval*1e3){i.trigger({type:"usage",name:"vhs-error-reload-canceled"});return}if(!r.getSource||typeof r.getSource!="function"){pe.log.error("ERROR: reloadSourceOnError - The option getSource must be a function!");return}return t=Date.now(),r.getSource.call(i,a)},c=function(){i.off("loadedmetadata",s),i.off("error",o),i.off("dispose",c)},u=function(d){c(),C_(i,d)};i.on("error",o),i.on("dispose",c),i.reloadSourceOnError=u},PN=function(i){C_(this,i)};var x_="3.17.0",NN="7.1.0",ON="1.3.1",MN="7.2.0",RN="4.0.2";const tn={PlaylistLoader:Ya,Playlist:di,utils:jI,STANDARD_PLAYLIST_SELECTOR:r_,INITIAL_PLAYLIST_SELECTOR:wP,lastBandwidthSelector:r_,movingAverageBandwidthSelector:xP,comparePlaylistBandwidth:zp,comparePlaylistResolution:CP,xhr:M2()};Object.keys(Nn).forEach(i=>{Object.defineProperty(tn,i,{get(){return pe.log.warn(`using Vhs.${i} is UNSAFE be sure you know what you are doing`),Nn[i]},set(e){if(pe.log.warn(`using Vhs.${i} is UNSAFE be sure you know what you are doing`),typeof e!="number"||e<0){pe.log.warn(`value of Vhs.${i} must be greater than or equal to 0`);return}Nn[i]=e}})});const E_="videojs-vhs",w_=function(i,e){const t=e.media();let n=-1;for(let r=0;r<i.length;r++)if(i[r].id===t.id){n=r;break}i.selectedIndex_=n,i.trigger({selectedIndex:n,type:"change"})},LN=function(i,e){e.representations().forEach(t=>{i.addQualityLevel(t)}),w_(i,e.playlists)};tn.canPlaySource=function(){return pe.log.warn("VHS is no longer a tech. Please remove it from your player's techOrder.")};const BN=(i,e,t)=>{if(!i)return i;let n={};e&&e.attributes&&e.attributes.CODECS&&(n=kl(or(e.attributes.CODECS))),t&&t.attributes&&t.attributes.CODECS&&(n.audio=t.attributes.CODECS);const r=xa(n.video),s=xa(n.audio),a={};for(const o in i)a[o]={},s&&(a[o].audioContentType=s),r&&(a[o].videoContentType=r),e.contentProtection&&e.contentProtection[o]&&e.contentProtection[o].pssh&&(a[o].pssh=e.contentProtection[o].pssh),typeof i[o]=="string"&&(a[o].url=i[o]);return Mt(i,a)},UN=(i,e)=>i.reduce((t,n)=>{if(!n.contentProtection)return t;const r=e.reduce((s,a)=>{const o=n.contentProtection[a];return o&&o.pssh&&(s[a]={pssh:o.pssh}),s},{});return Object.keys(r).length&&t.push(r),t},[]),FN=({player:i,sourceKeySystems:e,audioMedia:t,mainPlaylists:n})=>{if(!i.eme.initializeMediaKeys)return Promise.resolve();const r=t?n.concat([t]):n,s=UN(r,Object.keys(e)),a=[],o=[];return s.forEach(c=>{o.push(new Promise((u,d)=>{i.tech_.one("keysessioncreated",u)})),a.push(new Promise((u,d)=>{i.eme.initializeMediaKeys({keySystems:c},h=>{if(h){d(h);return}u()})}))}),Promise.race([Promise.all(a),Promise.race(o)])},VN=({player:i,sourceKeySystems:e,media:t,audioMedia:n})=>{const r=BN(e,t,n);return r?(i.currentSource().keySystems=r,r&&!i.eme?(pe.log.warn("DRM encrypted source cannot be decrypted without a DRM plugin"),!1):!0):!1},D_=()=>{if(!te.localStorage)return null;const i=te.localStorage.getItem(E_);if(!i)return null;try{return JSON.parse(i)}catch{return null}},jN=i=>{if(!te.localStorage)return!1;let e=D_();e=e?Mt(e,i):i;try{te.localStorage.setItem(E_,JSON.stringify(e))}catch{return!1}return e},$N=i=>i.toLowerCase().indexOf("data:application/vnd.videojs.vhs+json,")===0?JSON.parse(i.substring(i.indexOf(",")+1)):i,A_=(i,e)=>{i._requestCallbackSet||(i._requestCallbackSet=new Set),i._requestCallbackSet.add(e)},I_=(i,e)=>{i._responseCallbackSet||(i._responseCallbackSet=new Set),i._responseCallbackSet.add(e)},P_=(i,e)=>{i._requestCallbackSet&&(i._requestCallbackSet.delete(e),i._requestCallbackSet.size||delete i._requestCallbackSet)},N_=(i,e)=>{i._responseCallbackSet&&(i._responseCallbackSet.delete(e),i._responseCallbackSet.size||delete i._responseCallbackSet)};tn.supportsNativeHls=function(){if(!Ue||!Ue.createElement)return!1;const i=Ue.createElement("video");return pe.getTech("Html5").isSupported()?["application/vnd.apple.mpegurl","audio/mpegurl","audio/x-mpegurl","application/x-mpegurl","video/x-mpegurl","video/mpegurl","application/mpegurl"].some(function(t){return/maybe|probably/i.test(i.canPlayType(t))}):!1}(),tn.supportsNativeDash=function(){return!Ue||!Ue.createElement||!pe.getTech("Html5").isSupported()?!1:/maybe|probably/i.test(Ue.createElement("video").canPlayType("application/dash+xml"))}(),tn.supportsTypeNatively=i=>i==="hls"?tn.supportsNativeHls:i==="dash"?tn.supportsNativeDash:!1,tn.isSupported=function(){return pe.log.warn("VHS is no longer a tech. Please remove it from your player's techOrder.")},tn.xhr.onRequest=function(i){A_(tn.xhr,i)},tn.xhr.onResponse=function(i){I_(tn.xhr,i)},tn.xhr.offRequest=function(i){P_(tn.xhr,i)},tn.xhr.offResponse=function(i){N_(tn.xhr,i)};const HN=pe.getComponent("Component");class O_ extends HN{constructor(e,t,n){if(super(t,n.vhs),typeof n.initialBandwidth=="number"&&(this.options_.bandwidth=n.initialBandwidth),this.logger_=Mi("VhsHandler"),t.options_&&t.options_.playerId){const r=pe.getPlayer(t.options_.playerId);this.player_=r}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(Ue,["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],r=>{const s=Ue.fullscreenElement||Ue.webkitFullscreenElement||Ue.mozFullScreenElement||Ue.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_=Mt(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_.usePlayerObjectFit=this.options_.usePlayerObjectFit||!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=typeof this.options_.useNetworkInformationApi<"u"?this.options_.useNetworkInformationApi:!0,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 n=D_();n&&n.bandwidth&&(this.options_.bandwidth=n.bandwidth,this.tech_.trigger({type:"usage",name:"vhs-bandwidth-from-local-storage"})),n&&n.throughput&&(this.options_.throughput=n.throughput,this.tech_.trigger({type:"usage",name:"vhs-throughput-from-local-storage"}))}typeof this.options_.bandwidth!="number"&&(this.options_.bandwidth=Nn.INITIAL_BANDWIDTH),this.options_.enableLowInitialPlaylist=this.options_.enableLowInitialPlaylist&&this.options_.bandwidth===Nn.INITIAL_BANDWIDTH,["withCredentials","useDevicePixelRatio","usePlayerObjectFit","customPixelRatio","limitRenditionByPlayerDimensions","bandwidth","customTagParsers","customTagMappers","cacheEncryptionKeys","playlistSelector","initialPlaylistSelector","bufferBasedABR","liveRangeSafeTimeDelta","llhls","useForcedSubtitles","useNetworkInformationApi","useDtsForTimestampOffset","exactManifestTimings","leastPixelDiffSelector"].forEach(n=>{typeof this.source_[n]<"u"&&(this.options_[n]=this.source_[n])}),this.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions,this.useDevicePixelRatio=this.options_.useDevicePixelRatio,this.usePlayerObjectFit=this.options_.usePlayerObjectFit;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=$N(this.source_.src),this.options_.tech=this.tech_,this.options_.externVhs=tn,this.options_.sourceType=$y(t),this.options_.seekTo=s=>{this.tech_.setCurrentTime(s)},this.options_.player_=this.player_,this.playlistController_=new xN(this.options_);const n=Mt({liveRangeSafeTimeDelta:pr},this.options_,{seekable:()=>this.seekable(),media:()=>this.playlistController_.media(),playlistController:this.playlistController_});this.playbackWatcher_=new AN(n),this.attachStreamingEventListeners_(),this.playlistController_.on("error",()=>{const s=pe.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 r=this.options_.bufferBasedABR?tn.movingAverageBandwidthSelector(.55):tn.STANDARD_PLAYLIST_SELECTOR;this.playlistController_.selectPlaylist=this.selectPlaylist?this.selectPlaylist.bind(this):r.bind(this),this.playlistController_.selectInitialPlaylist=tn.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=te.navigator.connection||te.navigator.mozConnection||te.navigator.webkitConnection,o=1e7;if(this.options_.useNetworkInformationApi&&a){const c=a.downlink*1e3*1e3;c>=o&&s>=o?s=Math.max(s,c):s=c}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(){pe.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:()=>qs(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:()=>qs(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&&jN({bandwidth:this.bandwidth,throughput:Math.round(this.throughput)})}),this.playlistController_.on("selectedinitialmedia",()=>{DN(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_=te.URL.createObjectURL(this.playlistController_.mediaSource),(pe.browser.IS_ANY_SAFARI||pe.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"),FN({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=VN({player:this.player_,sourceKeySystems:this.source_.keySystems,media:this.playlists.media(),audioMedia:e&&e.media()});if(this.player_.tech_.on("keystatuschange",n=>{this.playlistController_.updatePlaylistByKeyStatus(n.keyId,n.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=pe.players[this.tech_.options_.playerId];!e||!e.qualityLevels||this.qualityLevels_||(this.qualityLevels_=e.qualityLevels(),this.playlistController_.on("selectedinitialmedia",()=>{LN(this.qualityLevels_,this)}),this.playlists.on("mediachange",()=>{w_(this.qualityLevels_,this.playlists)}))}static version(){return{"@videojs/http-streaming":x_,"mux.js":NN,"mpd-parser":ON,"m3u8-parser":MN,"aes-decrypter":RN}}version(){return this.constructor.version()}canChangeType(){return f_.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_&&te.URL.revokeObjectURL&&(te.URL.revokeObjectURL(this.mediaSourceUrl_),this.mediaSourceUrl_=null),this.tech_&&this.tech_.off("waitingforkey",this.handleWaitingForKey_),super.dispose()}convertToProgramTime(e,t){return KI({playlist:this.playlistController_.media(),time:e,callback:t})}seekToProgramTime(e,t,n=!0,r=2){return F2({programTime:e,playlist:this.playlistController_.media(),retryCount:r,pauseAfterSeek:n,seekTo:this.options_.seekTo,tech:this.options_.tech,callback:t})}setupXhrHooks_(){this.xhr.onRequest=e=>{A_(this.xhr,e)},this.xhr.onResponse=e=>{I_(this.xhr,e)},this.xhr.offRequest=e=>{P_(this.xhr,e)},this.xhr.offResponse=e=>{N_(this.xhr,e)},this.player_.trigger("xhr-hooks-ready")}attachStreamingEventListeners_(){const e=["seekablerangeschanged","bufferedrangeschanged","contentsteeringloadstart","contentsteeringloadcomplete","contentsteeringparsed"],t=["gapjumped","playedrangeschanged"];e.forEach(n=>{this.playlistController_.on(n,r=>{this.player_.trigger(yn({},r))})}),t.forEach(n=>{this.playbackWatcher_.on(n,r=>{this.player_.trigger(yn({},r))})})}}const Xu={name:"videojs-http-streaming",VERSION:x_,canHandleSource(i,e={}){const t=Mt(pe.options,e);return!t.vhs.experimentalUseMMS&&!el("avc1.4d400d,mp4a.40.2",!1)?!1:Xu.canPlayType(i.type,t)},handleSource(i,e,t={}){const n=Mt(pe.options,t);return e.vhs=new O_(i,e,n),e.vhs.xhr=M2(),e.vhs.setupXhrHooks_(),e.vhs.src(i.src,i.type),e.vhs},canPlayType(i,e){const t=$y(i);if(!t)return"";const n=Xu.getOverrideNative(e);return!tn.supportsTypeNatively(t)||n?"maybe":""},getOverrideNative(i={}){const{vhs:e={}}=i,t=!(pe.browser.IS_ANY_SAFARI||pe.browser.IS_IOS),{overrideNative:n=t}=e;return n}};el("avc1.4d400d,mp4a.40.2",!0)&&pe.getTech("Html5").registerSourceHandler(Xu,0),pe.VhsHandler=O_,pe.VhsSourceHandler=Xu,pe.Vhs=tn,pe.use||pe.registerComponent("Vhs",tn),pe.options.vhs=pe.options.vhs||{},(!pe.getPlugin||!pe.getPlugin("reloadSourceOnError"))&&pe.registerPlugin("reloadSourceOnError",PN);class qN{constructor(){this.isInitialized=!1,this.pollingInterval=null,this.currentPollingIndex=0,this.pollingParticipants=[],this.ctx=null,this.pollingDisabled=!1,this.voiceActivatedIdentity=null,this.voiceActivatedParticipant=null}init(e){this.isInitialized||(this.ctx=Object.assign({getParticipants:()=>[],getCurrentLayout:()=>"grid",getCurrentRoomMode:()=>"normal",pollingIntervalMs:null},e||{}),this.isInitialized=!0,this._setupMittListeners())}destroy(){this.stopScreenPolling(),this.isInitialized=!1,this.ctx=null}getMaxVisibleParticipantsByLayout(){var n,r,s,a;const e=((r=(n=this.ctx)==null?void 0:n.getCurrentLayout)==null?void 0:r.call(n))||"grid";return(((a=(s=this.ctx)==null?void 0:s.getCurrentRoomMode)==null?void 0:a.call(s))||"normal")==="pointTurn"?10:e==="rightSide"?5:e==="grid"?16:4}shouldStartPolling(){var s,a,o,c,u,d,h;const e=((a=(s=this.ctx)==null?void 0:s.getParticipants)==null?void 0:a.call(s))||[],t=((c=(o=this.ctx)==null?void 0:o.getCurrentLayout)==null?void 0:c.call(o))||"grid",n=((d=(u=this.ctx)==null?void 0:u.getCurrentRoomMode)==null?void 0:d.call(u))||"normal",r=(h=this.ctx)==null?void 0:h.pollingIntervalMs;return this.pollingDisabled||!r||r<=0?!1:n==="pointTurn"?e.length>11:t==="rightSide"?e.length>5:e.length>4}adjustPollingState(){if(!this.isInitialized)return;if(this.pollingDisabled){this.stopScreenPolling();return}const e=this.shouldStartPolling(),t=!!this.pollingInterval;e&&!t?this.startScreenPolling():!e&&t&&this.stopScreenPolling()}startScreenPolling(){if(!this.isInitialized||this.pollingInterval||!this.shouldStartPolling())return;this.currentPollingIndex=0,this.pollingParticipants=[];const e=this.ctx.pollingIntervalMs;if(!e||e<=0){console.warn("轮询间隔未设置或无效,无法启动轮询");return}this.executeScreenPolling(),this.pollingInterval=setInterval(()=>{this.executeScreenPolling()},e),setTimeout(()=>{this.pollingInterval&&this.executeScreenPolling()},100)}stopScreenPolling(){this.pollingInterval&&(clearInterval(this.pollingInterval),this.pollingInterval=null),this.currentPollingIndex=0,this.pollingParticipants=[]}executeScreenPolling(){var t,n,r,s;if(!this.isInitialized||!this.shouldStartPolling())return;const e=((n=(t=this.ctx)==null?void 0:t.getCurrentRoomMode)==null?void 0:n.call(t))||"normal";if((s=(r=this.ctx)==null?void 0:r.getCurrentLayout)!=null&&s.call(r),e==="pointTurn"){this.executePointTurnPolling();return}this.updatePollingIndex(),this.emitScreenPollingEvent()}executePointTurnPolling(){var a,o,c,u;const e=((o=(a=this.ctx)==null?void 0:a.getParticipants)==null?void 0:o.call(a))||[],t=10;let n=null;try{n=((u=(c=this.ctx)==null?void 0:c.getHostIdentity)==null?void 0:u.call(c))||null}catch{n=null}let r=[...e];if(n){const d=r.findIndex(h=>h&&h.identity===n);d!==-1&&r.splice(d,1)}if(r.length<=t){this.stopScreenPolling(),this.emitPointTurnPollingEvent(r.slice(0,t));return}this.currentPollingIndex=this.currentPollingIndex%r.length;const s=[];for(let d=0;d<t;d++){const h=(this.currentPollingIndex+d)%r.length;s.push(r[h])}this.emitPointTurnPollingEvent(s),this.currentPollingIndex=(this.currentPollingIndex+5)%r.length}updatePollingIndex(){var a,o,c,u,d,h,y,v;const e=((o=(a=this.ctx)==null?void 0:a.getParticipants)==null?void 0:o.call(a))||[],t=e.length;if(t===0)return;const n=this.getMaxVisibleParticipantsByLayout(),r=((u=(c=this.ctx)==null?void 0:c.getCurrentLayout)==null?void 0:u.call(c))||"grid",s=((h=(d=this.ctx)==null?void 0:d.getCurrentRoomMode)==null?void 0:h.call(d))||"normal";if(t<=n){this.currentPollingIndex=0;return}if(r==="rightSide"&&s==="normal"){let b=null;try{b=((v=(y=this.ctx)==null?void 0:y.getHostIdentity)==null?void 0:v.call(y))||null}catch{b=null}const g=this.voiceActivatedParticipant&&this.voiceActivatedParticipant.identity||this.voiceActivatedIdentity;let f=!1;if(b&&e.find(p=>p&&p.identity===b)&&(f=!0),!f&&g&&e.find(p=>p&&p.identity===g)&&(f=!0),f){const p=Math.max(t-1,1);this.currentPollingIndex=(this.currentPollingIndex+1)%p}else{const p=Math.max(t,1);this.currentPollingIndex=(this.currentPollingIndex+1)%p}}else{const b=Math.max(t-n,1);this.currentPollingIndex=(this.currentPollingIndex+1)%b}}getPollingParticipants(){var c,u,d,h,y,v;const e=[...((u=(c=this.ctx)==null?void 0:c.getParticipants)==null?void 0:u.call(c))||[]],t=this.getMaxVisibleParticipantsByLayout(),n=((h=(d=this.ctx)==null?void 0:d.getCurrentLayout)==null?void 0:h.call(d))||"grid",r=((v=(y=this.ctx)==null?void 0:y.getCurrentRoomMode)==null?void 0:v.call(y))||"normal",s=this.currentPollingIndex,a=[];if(this.shouldStartPolling())if(n==="rightSide"&&r==="normal")a.push(...this._getRightSidePollingParticipants(e,t,s));else for(let b=0;b<t&&b<e.length;b++)a.push(e[(s+b)%e.length]);else for(let b=0;b<t&&b<e.length;b++)a.push(e[b]);const o=this.voiceActivatedParticipant&&this.voiceActivatedParticipant.identity||this.voiceActivatedIdentity;if(o){const b=a.findIndex(g=>g&&g.identity===o);if(b>0){const[g]=a.splice(b,1);a.unshift(g)}}return a}_getRightSidePollingParticipants(e,t,n){var y,v;const r=[];let s=null;try{s=((v=(y=this.ctx)==null?void 0:y.getHostIdentity)==null?void 0:v.call(y))||null}catch{s=null}const a=this.voiceActivatedParticipant&&this.voiceActivatedParticipant.identity||this.voiceActivatedIdentity;let o=null,c=!1;if(s){const b=e.find(g=>g&&g.identity===s);b&&(o=b,c=!0)}if(!c&&a){const b=e.find(g=>g&&g.identity===a);b&&(o=b,c=!0)}if(!o){const b=n%e.length;o=e[b]}o&&r.push(o);const u=new Set;o&&u.add(o.identity);let d=1,h=n;for(;d<t&&d<e.length;){const b=e[h%e.length];if(b&&!u.has(b.identity)&&(r.push(b),u.add(b.identity),d++),h++,h-n>=e.length)break}return r}_setupMittListeners(){try{typeof ht<"u"&&ht&&(ht.on("voiceActivated",e=>{if(e){typeof e=="string"?(this.voiceActivatedIdentity=e,this.voiceActivatedParticipant=null):typeof e=="object"&&(this.voiceActivatedParticipant=e,this.voiceActivatedIdentity=e.identity||null);try{const t=this.getPollingParticipants();ht.emit("updateVisibleParticipants",{participants:t,currentIndex:this.currentPollingIndex,isPolling:!!this.pollingInterval,action:"replace"})}catch(t){console.warn("同步语音激励到可见列表失败",t)}}}),ht.on("setPollingEnabled",e=>{this.setPollingEnabled(!!e)}))}catch(e){console.warn("autoPolling mitt listeners setup failed",e)}}emitScreenPollingEvent(){const e=this.getPollingParticipants();ht.emit("screenPolling",{timestamp:Date.now(),currentIndex:this.currentPollingIndex,participants:this.pollingParticipants,visibleParticipants:e,interval:this.ctx.pollingIntervalMs}),ht.emit("updateVisibleParticipants",{participants:e,currentIndex:this.currentPollingIndex,isPolling:!0,action:"replace"})}emitPointTurnPollingEvent(e){ht.emit("pointTurnPolling",{timestamp:Date.now(),currentIndex:this.currentPollingIndex,participants:e,interval:this.ctx.pollingIntervalMs})}setPollingInterval(e){this.ctx&&(this.ctx.pollingIntervalMs=e,!this.pollingDisabled&&this.pollingInterval&&(this.stopScreenPolling(),this.startScreenPolling()))}setPollingEnabled(e){this.pollingDisabled=!e,e?(this.adjustPollingState(),this.pollingInterval&&this.shouldStartPolling()&&setTimeout(()=>{this.executeScreenPolling()},50)):this.stopScreenPolling()}setVoiceActivatedIdentity(e){this.voiceActivatedIdentity=e||null}getPollingStatus(){var e;return{isActive:!!this.pollingInterval,currentIndex:this.currentPollingIndex,interval:(e=this.ctx)==null?void 0:e.pollingIntervalMs}}}const xl=new qN,zN=i=>xl.init(i),GN=()=>xl.stopScreenPolling(),El=()=>xl.adjustPollingState(),M_=i=>xl.setPollingInterval(i),Yu=i=>xl.setPollingEnabled(i),WN="/assets/img/point/clear_icon.png",Ft=(i,e)=>{const t=i.__vccOpts||i;for(const[n,r]of e)t[n]=r;return t},Ju=i=>(l.pushScopeId("data-v-3bfd9fcb"),i=i(),l.popScopeId(),i),KN={class:"live-call-board"},XN={class:"live-call-board-title"},YN=Ju(()=>l.createElementVNode("span",null,"拨号盘",-1)),JN=["src"],QN={class:"live-call-board-list"},ZN=["onClick"],e7={class:"live-call-board-foot"},t7=[Ju(()=>l.createElementVNode("div",{class:"btn-icon"},null,-1))],n7=[Ju(()=>l.createElementVNode("div",{class:"btn-icon"},null,-1))],i7=[Ju(()=>l.createElementVNode("div",{class:"btn-icon"},null,-1))],wl=Ft({__name:"LiveCallBoard",props:{defaultCallNum:{type:String,default:""},defaultCallingMethod:{type:Array,default:()=>["voice","video","mini"]}},emits:["callBoardClose","voiceCall","videoCall","miniCall"],setup(i,{emit:e}){const t="/".replace(/\/?$/,"/");console.log("其他项目 BASE_URL:","/"),console.log("插件补斜杠后:",t),console.log("图片最终路径:",t+"assets/img/point/close_icon.png"),console.log("publicDir:",void 0);const n=new An,r=i,s=l.ref(""),a=e;function o(v){return/^[\d#*]+$/.test(v)}function c(v){s.value+=v}function u(){s.value?o(s.value)?(a("voiceCall",s.value),a("callBoardClose")):n.message("error","手机号中包含不合法字符"):n.message("error","联系方式不能为空")}function d(){s.value?o(s.value)?(a("videoCall",s.value),a("callBoardClose")):n.message("error","手机号中包含不合法字符"):n.message("error","联系方式不能为空")}function h(){s.value?o(s.value)?(a("miniCall",s.value),a("callBoardClose")):n.message("error","手机号中包含不合法字符"):n.message("error",{message:"联系方式不能为空"})}function y(){s.value.length>0&&(s.value=s.value.substring(0,s.value.length-1))}return l.onMounted(()=>{s.value=r.defaultCallNum}),(v,b)=>{const g=l.resolveComponent("el-input");return l.openBlock(),l.createElementBlock("div",KN,[l.createElementVNode("div",XN,[YN,l.createElementVNode("img",{class:"title-close-icon",src:l.unref(t)+"assets/img/point/close_icon.png",alt:"",onClick:b[0]||(b[0]=f=>v.$emit("callBoardClose"))},null,8,JN)]),l.createVNode(g,{modelValue:s.value,"onUpdate:modelValue":b[1]||(b[1]=f=>s.value=f),type:"mobile",placeholder:"请输入号码",disabled:"",clearable:""},{suffix:l.withCtx(()=>[l.createElementVNode("img",{class:"del-icon",src:WN,alt:"",onClick:y})]),_:1},8,["modelValue"]),l.createElementVNode("div",QN,[(l.openBlock(),l.createElementBlock(l.Fragment,null,l.renderList("123456789*0#",(f,p)=>l.createElementVNode("div",{class:"live-call-board-list-item",key:p,onClick:_=>c(f)},l.toDisplayString(f),9,ZN)),64))]),l.createElementVNode("div",e7,[i.defaultCallingMethod.includes("voice")?(l.openBlock(),l.createElementBlock("div",{key:0,class:"live-call-board-foot-btn voice-btn",onClick:u},t7)):l.createCommentVNode("",!0),i.defaultCallingMethod.includes("video")?(l.openBlock(),l.createElementBlock("div",{key:1,class:"live-call-board-foot-btn video-btn",onClick:d},n7)):l.createCommentVNode("",!0),i.defaultCallingMethod.includes("mini")?(l.openBlock(),l.createElementBlock("div",{key:2,class:"live-call-board-foot-btn mini-btn",onClick:h},i7)):l.createCommentVNode("",!0)])])}}},[["__scopeId","data-v-3bfd9fcb"]]),r7="/assets/img/point/close_icon.png",s7="/assets/img/point/hang_on_icon.png",a7="/assets/img/point/hang_off_icon.png",Qu=i=>(l.pushScopeId("data-v-380eda98"),i=i(),l.popScopeId(),i),o7={class:"receive-board"},l7={class:"receive-board-title"},c7={class:"receive-board-msg"},u7=[Qu(()=>l.createElementVNode("img",{class:"btn-icon",src:s7,alt:""},null,-1)),Qu(()=>l.createElementVNode("span",null,"接听",-1))],d7=[Qu(()=>l.createElementVNode("img",{class:"btn-icon",src:a7,alt:""},null,-1)),Qu(()=>l.createElementVNode("span",null,"挂断",-1))],h7=Ft({__name:"LiveInviteReceive",props:{meetingType:{type:String,default:"video"},inviteData:{type:Object,default:()=>{}}},emits:["receiveBoardClose","acceptInviteCall","refuseInviteCall"],setup(i,{emit:e}){const t=i,n=e;function r(){n("acceptInviteCall",{roomNum:t.inviteData.roomNum,fromIdentity:t.inviteData.fromIdentity,fromOrg:t.inviteData.fromOrg,meetingType:t.meetingType})}function s(){n("refuseInviteCall",{roomNum:t.inviteData.roomNum,fromIdentity:t.inviteData.fromIdentity,fromOrg:t.inviteData.fromOrg,meetingType:t.meetingType})}return(a,o)=>{var c;return l.openBlock(),l.createElementBlock("div",o7,[l.createElementVNode("div",l7,[l.createElementVNode("span",null,l.toDisplayString(i.meetingType==="voice"?"语音呼叫":"视频呼叫"),1),l.createElementVNode("img",{class:"title-close-icon",src:r7,alt:"",onClick:o[0]||(o[0]=u=>a.$emit("receiveBoardClose"))})]),l.createElementVNode("div",c7,[l.createElementVNode("img",{class:l.normalizeClass(["receive-type-icon",i.meetingType==="voice"?"receive-type-icon-voice":"receive-type-icon-video"]),src:"",alt:""},null,2),l.createElementVNode("span",null,l.toDisplayString(`【${((c=i.inviteData)==null?void 0:c.fromIdentity)??"会议发起人"}】邀请您进行${i.meetingType==="voice"?"语音":"视频"}通话`),1)]),l.createElementVNode("div",{class:"receive-board-foot"},[l.createElementVNode("div",{class:"receive-board-foot-btn accept-btn",onClick:r},u7),l.createElementVNode("div",{class:"receive-board-foot-btn refuse-btn",onClick:s},d7)])])}}},[["__scopeId","data-v-380eda98"]]),Un=i=>(l.pushScopeId("data-v-79d2799d"),i=i(),l.popScopeId(),i),f7={class:"point-meeting-top"},p7={class:"top-group"},m7=Un(()=>l.createElementVNode("div",{class:"duration-icon"},null,-1)),g7={class:"point-meeting-wrapper"},v7={key:0,class:"waiting-mask-video"},y7=[Un(()=>l.createElementVNode("div",{class:"icon"},null,-1)),Un(()=>l.createElementVNode("div",{class:"title"},"麦克风",-1))],b7=[Un(()=>l.createElementVNode("div",{class:"icon"},null,-1)),Un(()=>l.createElementVNode("div",{class:"title"},"麦克风",-1))],_7=[Un(()=>l.createElementVNode("div",{class:"icon"},null,-1)),Un(()=>l.createElementVNode("div",{class:"title"},"摄像头",-1))],k7=[Un(()=>l.createElementVNode("div",{class:"icon"},null,-1)),Un(()=>l.createElementVNode("div",{class:"title"},"摄像头",-1))],T7=[Un(()=>l.createElementVNode("div",{class:"icon"},null,-1)),Un(()=>l.createElementVNode("div",{class:"title"},"扬声器",-1))],S7=[Un(()=>l.createElementVNode("div",{class:"icon"},null,-1)),Un(()=>l.createElementVNode("div",{class:"title"},"扬声器",-1))],C7=Un(()=>l.createElementVNode("div",{class:"icon"},null,-1)),x7={class:"title"},E7=Un(()=>l.createElementVNode("div",{class:"icon"},null,-1)),w7={class:"title"},D7=[Un(()=>l.createElementVNode("div",{class:"icon"},null,-1)),Un(()=>l.createElementVNode("div",{class:"title"},"结束通话",-1))],Dl=Ft({__name:"LivePointMeeting",props:{joinType:{type:String,default:"join"},meetingNum:{type:String,default:""},meetingType:{type:String,default:"video"},invitePhone:{type:String,default:""},isDraggable:{type:Boolean,default:!1},inviteWays:{type:String,default:"phoneCall"},inviteIdentity:{type:String,default:""}},emits:["meetingStarted","miniLinkSend","meetingEnded","meetingDialogClose"],setup(i,{emit:e}){const t=new An;let n=null,r=null,s=null;const a=i,o=e,c=l.ref(),u=l.ref(""),d=l.ref(""),h=l.ref(""),y=l.ref(null),v=l.ref([]);l.ref([]);const b=l.ref([]),g=l.ref(!1),f=l.ref(!1),p=l.ref(!1),_=l.ref(!1),k=l.ref(!0),D=l.ref(!1),C=l.ref(!1),A=l.ref(0),w=l.ref(!0),P=l.ref(!1),S=l.ref(3),M=l.computed(()=>b.value.length),U=l.computed(()=>t0(A.value)),R={mounted:(le,ae)=>{ae.value&&(le.style.cursor="move",le.onmousedown=ce=>{ce.stopPropagation(),ce.preventDefault();const Le=document.getElementById("point-meeting"),Ee=/^matrix3d\((?:[-\d.]+,\s*){12}([-\d.]+),\s*([-\d.]+)(?:,\s*[-\d.]+){2}\)/,it=/^matrix\((?:[-\d.]+,\s*){4}([-\d.]+),\s*([-\d.]+)\)$/;let $e=kx(Le,"transform"),Je=$e.match(Ee)||$e.match(it),rt=ce.clientX,De=ce.clientY,Ye=Je[1],Fe=Je[2],Ct=rt-Ye,qt=De-Fe;le.onmousemove=function(It){It.stopPropagation(),It.preventDefault();let Oe=It.clientX-Ct,tt=It.clientY-qt;Le.style.transform=`translate(${Oe}px, ${tt}px)`},le.onmouseup=function(It){le.onmousemove=null,le.onmouseup=null},window.onmouseup=function(It){le.onmousemove=null,le.onmouseup=null}})}};l.watch(()=>S.value,le=>{le<=0&&(P.value=!1,r&&clearInterval(r))});async function J(){s&&await s.createRoom()}async function ie(){if(!s)return;const le={echoCancellation:!0,noiseSuppression:!0,roomNum:a.joinType==="launch"?h.value:a.meetingNum};try{await s.joinRoom(le)}catch{t.message("error","加入会议失败")}}function X(le){v.value.indexOf(le)<0&&v.value.push(le)}function V(){s&&v.value.length>0&&v.value.forEach(le=>{s.off(le)})}function L(){n&&(clearInterval(n),n=null)}async function H(){await s.changeCameraStatus()}async function q(){await s.changeMicrophoneStatus()}async function $(){await s.changeScreenShareStatus()}async function G(){await s.setParticipantDeafness(u.value)}async function oe(){await s.cancelParticipantDeafness(u.value)}function Te(le){S.value=le,P.value=!0,r&&clearInterval(r),r=setInterval(()=>{S.value>0&&S.value--},1e3)}function ge(){if(!D.value)return;const le=document.querySelector("#point-meeting-contain .layout-blur"),ae=document.querySelector("#point-meeting-contain .layout-normal");if(k.value){if(le.hasChildNodes){const ce=le.firstElementChild;if(ce.id===`participant-${u.value}`)le.style.visibility="hidden",k.value=!1;else if(ae.hasChildNodes){const Le=ae.firstElementChild;le.appendChild(Le),ae.appendChild(ce),le.style.visibility="hidden",k.value=!1}else ae.appendChild(ce),le.style.visibility="hidden",k.value=!1}}else if(_.value){t.message("error","当前正在共享屏幕,无法开启预览");return}else le.style.visibility="visible",k.value=!0}function ee(){if(!s){t.message("error","liveClient未能成功初始化");return}s.on("errorPush",le=>{X("errorPush"),console.error("出错位置"+le.type+":",le.message)}),s.on("roomCreatedSuccess",async le=>{X("roomCreatedSuccess"),t.message("success","会议房间创建成功"),h.value=le,await ie()}),s.on("roomCreatedFail",le=>{X("roomCreatedFail"),t.message("error","会议房间创建失败")}),s.on("joinRoomError",le=>{X("joinRoomError"),console.error("加入会议失败",le),t.message("error","加入会议失败")}),s.on("roomConnected",le=>{if(X("roomConnected"),s!=null&&s.room&&(y.value=JSON.parse(s.room.metadata),console.log(y.value,"roomMetadata.value"),D.value=!0,o("meetingStarted"),a.joinType==="launch")){if(a.inviteWays==="phoneCall")a.meetingType==="video"||a.meetingType==="voice"?s.makeCall(a.invitePhone,a.invitePhone).then(()=>{t.message("success","外呼邀请发送成功"),C.value=!0}).catch(ae=>{t.message("error","外呼邀请发送失败"),console.error(ae)}):a.meetingType==="miniLink"&&(o("miniLinkSend",{roomNum:h.value,phone:a.invitePhone}),C.value=!0);else if(a.inviteWays==="identity"){const ae=JSON.stringify({meetingType:a.meetingType});s.inviteThirdParty(a.inviteIdentity,s.org,ae).then(()=>{t.message("success","PC邀请发送成功")}).catch(()=>{t.message("error","PC邀请发送失败")})}}}),s.on("localCameraChange",le=>{X("localCameraChange"),f.value=le,f.value?t.message("success","摄像头已开启"):t.message("success","摄像头已关闭")}),s.on("localMicrophoneChange",le=>{X("localMicrophoneChange"),g.value=le,g.value?t.message("success","麦克风已开启"):t.message("success","麦克风已关闭")}),s.on("localScreenShareChange",le=>{X("localScreenShareChange"),_.value=le,_.value?t.success({messsage:"屏幕共享已开启"}):t.success({messsage:"屏幕共享已关闭"})}),s.on("videoCallRender",le=>{X("videoCallRender"),Xe(le)}),s.on("audioCallRender",le=>{X("audioCallRender"),je(le)}),s.on("roomDisconnected",()=>{if(X("roomDisconnected"),t.message("info","房间链接已断开"),D.value=!1,o("meetingEnded"),s){s._eventsInitialized=!1;try{s.removeAllListeners()}catch(le){console.warn("清理liveClient事件监听器失败:",le)}}s.deleteRoom(u.value).then(()=>{L(),ve()}).catch(le=>{console.error(le),L(),ve()})})}function ve(){o("meetingDialogClose")}async function be(){s&&await s.leaveRoom()}async function Be(le){document.fullscreenElement||document.msFullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement?document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitCancelFullScreen?document.webkitCancelFullScreen():document.msExitFullscreen&&document.msExitFullscreen():(await l.nextTick(),c.value.requestFullscreen&&c.value.requestFullscreen())}function ze(le){if(M.value<=0)b.value.push(le);else{const ae=b.value.findIndex(ce=>ce.identity===le.identity);ae!==-1?b.value.splice(ae,1,le):b.value.push(le)}}function Me(le){if(!(M.value<=0)){const ae=b.value.findIndex(ce=>ce.identity===le.identity);ae!==-1&&b.value.splice(ae,1)}}function Xe(le){if(le.isLocal){const Ct=JSON.parse(le.metadata);f.value=le.isCameraEnabled,g.value=le.isMicrophoneEnabled,_.value=le.isScreenShareEnabled,p.value=!Ct.isDeafness,u.value=le.identity,d.value=le.name}const ae=document.getElementById("point-meeting-contain");let ce=document.getElementById(`participant-${le.identity}`),Le=document.querySelector("#point-meeting-contain .layout-blur"),Ee=document.querySelector("#point-meeting-contain .layout-normal");if(Le||(Le=document.createElement("div"),Le.className="layout-blur",ae.appendChild(Le)),Ee||(Ee=document.createElement("div"),Ee.className="layout-normal",ae.insertBefore(Ee,ae.firstElementChild??null)),!ae){t.message("error","会议容器不存在");return}if(!ce&&!le.remove){if(ce=document.createElement("div"),ce.id=`participant-${le.identity}`,ce.className=le.isLocal?"participant local":"participant",le.isScreenShareEnabled||le.isCameraEnabled?ce.innerHTML=`
244
244
  <video id="video-${le.identity}" class="p-video" autoplay webkit-playsinline playsinline x5-video-player-type="h5"></video>
245
245
  <div id="rotate-${le.identity}" class="rotate-icon"><img id="rotate-img-${le.identity}" src="/assets/flip/1-0.png" /></div>
246
246
  <div id="describe-${le.identity}" class="describe">