stream-engine-player 0.0.45 → 0.0.46

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.
@@ -94,7 +94,7 @@ See https://github.com/videojs/video.js/issues/2617 for more info.
94
94
  `;return n},P1=function(r){var i=r.bytes;return __(i)},O1=function(r){var i="",t=void 0;for(t=0;t<r.length;t++)i+=k1(r,t)+" ";return i},L1=Object.freeze({createTransferableMessage:m_,initSegmentId:Qd,segmentKeyId:y_,hexDump:__,tagDump:P1,textRanges:O1}),b_=.25,I1=function(r,i){if(!i.dateTimeObject)return null;var t=i.videoTimingInfo.transmuxerPrependedSeconds,n=i.videoTimingInfo.transmuxedPresentationStart,a=n+t,s=r-a;return new Date(i.dateTimeObject.getTime()+s*1e3)},M1=function(r){return r.transmuxedPresentationEnd-r.transmuxedPresentationStart-r.transmuxerPrependedSeconds},N1=function(r,i){var t=void 0;try{t=new Date(r)}catch{return null}if(!i||!i.segments||i.segments.length===0)return null;var n=i.segments[0];if(t<n.dateTimeObject)return null;for(var a=0;a<i.segments.length-1;a++){n=i.segments[a];var s=i.segments[a+1].dateTimeObject;if(t<s)break}var o=i.segments[i.segments.length-1],l=o.dateTimeObject,u=o.videoTimingInfo?M1(o.videoTimingInfo):o.duration+o.duration*b_,g=new Date(l.getTime()+u*1e3);return t>g?null:(t>l&&(n=o),{segment:n,estimatedStart:n.videoTimingInfo?n.videoTimingInfo.transmuxedPresentationStart:zn.duration(i,i.mediaSequence+i.segments.indexOf(n)),type:n.videoTimingInfo?"accurate":"estimate"})},F1=function(r,i){if(!i||!i.segments||i.segments.length===0)return null;for(var t=0,n=void 0,a=0;a<i.segments.length&&(n=i.segments[a],t=n.videoTimingInfo?n.videoTimingInfo.transmuxedPresentationEnd:t+n.duration,!(r<=t));a++);var s=i.segments[i.segments.length-1];if(s.videoTimingInfo&&s.videoTimingInfo.transmuxedPresentationEnd<r)return null;if(r>t){if(r>t+s.duration*b_)return null;n=s}return{segment:n,estimatedStart:n.videoTimingInfo?n.videoTimingInfo.transmuxedPresentationStart:t-n.duration,type:n.videoTimingInfo?"accurate":"estimate"}},U1=function(r,i){var t=void 0,n=void 0;try{t=new Date(r),n=new Date(i)}catch{}var a=t.getTime(),s=n.getTime();return(s-a)/1e3},B1=function(r){if(!r.segments||r.segments.length===0)return!1;for(var i=0;i<r.segments.length;i++){var t=r.segments[i];if(!t.dateTimeObject)return!1}return!0},j1=function(r){var i=r.playlist,t=r.time,n=t===void 0?void 0:t,a=r.callback;if(!a)throw new Error("getProgramTime: callback must be provided");if(!i||n===void 0)return a({message:"getProgramTime: playlist and time must be provided"});var s=F1(n,i);if(!s)return a({message:"valid programTime was not found"});if(s.type==="estimate")return a({message:"Accurate programTime could not be determined. Please seek to e.seekTime and try again",seekTime:s.estimatedStart});var o={mediaSeconds:n},l=I1(n,s.segment);return l&&(o.programDateTime=l.toISOString()),a(null,o)},$1=function e(r){var i=r.programTime,t=r.playlist,n=r.retryCount,a=n===void 0?2:n,s=r.seekTo,o=r.pauseAfterSeek,l=o===void 0?!0:o,u=r.tech,g=r.callback;if(!g)throw new Error("seekToProgramTime: callback must be provided");if(typeof i>"u"||!t||!s)return g({message:"seekToProgramTime: programTime, seekTo and playlist must be provided"});if(!t.endList&&!u.hasStarted_)return g({message:"player must be playing a live stream to start buffering"});if(!B1(t))return g({message:"programDateTime tags must be provided in the manifest "+t.resolvedUri});var c=N1(i,t);if(!c)return g({message:i+" was not found in the stream"});var d=c.segment,f=U1(d.dateTimeObject,i);if(c.type==="estimate"){if(a===0)return g({message:i+" is not buffered yet. Try again"});s(c.estimatedStart+f),u.one("seeked",function(){e({programTime:i,playlist:t,retryCount:a-1,seekTo:s,pauseAfterSeek:l,tech:u,callback:g})});return}var T=d.start+f,p=function(){return g(null,u.currentTime())};u.one("seeked",p),l&&u.pause(),s(T)},Zd=1/30,Vs=Zd*3,T_=function(r,i){var t=[],n=void 0;if(r&&r.length)for(n=0;n<r.length;n++)i(r.start(n),r.end(n))&&t.push([r.start(n),r.end(n)]);return re.createTimeRanges(t)},S_=function(r,i){return T_(r,function(t,n){return t-Vs<=i&&n+Vs>=i})},E_=function(r,i){return T_(r,function(t){return t-Zd>=i})},H1=function(r){if(r.length<2)return re.createTimeRanges();for(var i=[],t=1;t<r.length;t++){var n=r.end(t-1),a=r.start(t);i.push([n,a])}return re.createTimeRanges(i)},eg=function(r){var i=[];if(!r||!r.length)return"";for(var t=0;t<r.length;t++)i.push(r.start(t)+" => "+r.end(t));return i.join(", ")},G1=function(r,i){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,n=r.length?r.end(r.length-1):0;return(n-i)/t},x_=function(r){for(var i=[],t=0;t<r.length;t++)i.push({start:r.start(t),end:r.end(t)});return i},V1=function(r,i,t){var n=i.player_;if(t.captions&&t.captions.length){r.inbandTextTracks_||(r.inbandTextTracks_={});for(var a in t.captionStreams)if(!r.inbandTextTracks_[a]){n.tech_.trigger({type:"usage",name:"hls-608"});var s=n.textTracks().getTrackById(a);s?r.inbandTextTracks_[a]=s:r.inbandTextTracks_[a]=n.addRemoteTextTrack({kind:"captions",id:a,label:a},!1).track}}t.metadata&&t.metadata.length&&!r.metadataTrack_&&(r.metadataTrack_=n.addRemoteTextTrack({kind:"metadata",label:"Timed Metadata"},!1).track,r.metadataTrack_.inBandMetadataTrackDispatchType=t.metadata.dispatchType)},Tl=function(r,i,t){var n=void 0,a=void 0;if(!!t&&!!t.cues)for(n=t.cues.length;n--;)a=t.cues[n],a.startTime<=i&&a.endTime>=r&&t.removeCue(a)},q1=function(r){Object.defineProperties(r.frame,{id:{get:function(){return re.log.warn("cue.frame.id is deprecated. Use cue.value.key instead."),r.value.key}},value:{get:function(){return re.log.warn("cue.frame.value is deprecated. Use cue.value.data instead."),r.value.data}},privateData:{get:function(){return re.log.warn("cue.frame.privateData is deprecated. Use cue.value.data instead."),r.value.data}}})},w_=function(r){var i=void 0;return isNaN(r)||Math.abs(r)===1/0?i=Number.MAX_VALUE:i=r,i},W1=function(r,i,t){var n=Be.WebKitDataCue||Be.VTTCue;if(i&&i.forEach(function(c){var d=c.stream;this.inbandTextTracks_[d].addCue(new n(c.startTime+this.timestampOffset,c.endTime+this.timestampOffset,c.text))},r),t){var a=w_(r.mediaSource_.duration);if(t.forEach(function(c){var d=c.cueTime+this.timestampOffset;typeof d!="number"||Be.isNaN(d)||d<0||!(d<1/0)||c.frames.forEach(function(f){var T=new n(d,d,f.value||f.url||f.data||"");T.frame=f,T.value=f,q1(T),this.metadataTrack_.addCue(T)},this)},r),r.metadataTrack_&&r.metadataTrack_.cues&&r.metadataTrack_.cues.length){for(var s=r.metadataTrack_.cues,o=[],l=0;l<s.length;l++)s[l]&&o.push(s[l]);var u=o.reduce(function(c,d){var f=c[d.startTime]||[];return f.push(d),c[d.startTime]=f,c},{}),g=Object.keys(u).sort(function(c,d){return Number(c)-Number(d)});g.forEach(function(c,d){var f=u[c],T=Number(g[d+1])||a;f.forEach(function(p){p.endTime=T})})}}},yu=typeof window<"u"?window:{},tg=typeof Symbol>"u"?"__target":Symbol(),Y1="application/javascript",K1=yu.BlobBuilder||yu.WebKitBlobBuilder||yu.MozBlobBuilder||yu.MSBlobBuilder,Sl=yu.URL||yu.webkitURL||Sl&&Sl.msURL,El=yu.Worker;function A_(e,r){return function(t){var n=this;if(r)if(El&&!t){var a=r.toString().replace(/^function.+?{/,"").slice(0,-1),s=R_(a);return this[tg]=new El(s),z1(this[tg],s),this[tg]}else{var o={postMessage:function(u){n.onmessage&&setTimeout(function(){n.onmessage({data:u,target:o})})}};r.call(o),this.postMessage=function(l){setTimeout(function(){o.onmessage({data:l,target:n})})},this.isThisThread=!0}else return new El(e)}}if(El){var ef,C_=R_("self.onmessage = function () {}"),k_=new Uint8Array(1);try{ef=new El(C_),ef.postMessage(k_,[k_.buffer])}catch{El=null}finally{Sl.revokeObjectURL(C_),ef&&ef.terminate()}}function R_(e){try{return Sl.createObjectURL(new Blob([e],{type:Y1}))}catch{var r=new K1;return r.append(e),Sl.createObjectURL(r.getBlob(type))}}function z1(e,r){if(!(!e||!r)){var i=e.terminate;e.objURL=r,e.terminate=function(){e.objURL&&Sl.revokeObjectURL(e.objURL),i.call(e)}}}var X1=new A_("./transmuxer-worker.worker.js",function(e,r){var i=this;(function(){var t=function(){this.init=function(){var q={};this.on=function(z,ie){q[z]||(q[z]=[]),q[z]=q[z].concat(ie)},this.off=function(z,ie){var ne;return q[z]?(ne=q[z].indexOf(ie),q[z]=q[z].slice(),q[z].splice(ne,1),ne>-1):!1},this.trigger=function(z){var ie,ne,pe,me;if(ie=q[z],!!ie)if(arguments.length===2)for(pe=ie.length,ne=0;ne<pe;++ne)ie[ne].call(this,arguments[1]);else{for(me=[],ne=arguments.length,ne=1;ne<arguments.length;++ne)me.push(arguments[ne]);for(pe=ie.length,ne=0;ne<pe;++ne)ie[ne].apply(this,me)}},this.dispose=function(){q={}}}};t.prototype.pipe=function(xe){return this.on("data",function(q){xe.push(q)}),this.on("done",function(q){xe.flush(q)}),this.on("partialdone",function(q){xe.partialFlush(q)}),this.on("endedtimeline",function(q){xe.endTimeline(q)}),this.on("reset",function(q){xe.reset(q)}),xe},t.prototype.push=function(xe){this.trigger("data",xe)},t.prototype.flush=function(xe){this.trigger("done",xe)},t.prototype.partialFlush=function(xe){this.trigger("partialdone",xe)},t.prototype.endTimeline=function(xe){this.trigger("endedtimeline",xe)},t.prototype.reset=function(xe){this.trigger("reset",xe)};var n=t,a=Math.pow(2,32)-1,s,o,l,u,g,c,d,f,T,p,y,b,v,h,S,E,A,x,m,C,k,D,P,N,j,O,M,F,H,K,J,le,ce,Z,ve,Ce;(function(){var xe;if(P={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],pasp:[],sdtp:[],smhd:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],styp:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[]},!(typeof Uint8Array>"u")){for(xe in P)P.hasOwnProperty(xe)&&(P[xe]=[xe.charCodeAt(0),xe.charCodeAt(1),xe.charCodeAt(2),xe.charCodeAt(3)]);N=new Uint8Array(["i".charCodeAt(0),"s".charCodeAt(0),"o".charCodeAt(0),"m".charCodeAt(0)]),O=new Uint8Array(["a".charCodeAt(0),"v".charCodeAt(0),"c".charCodeAt(0),"1".charCodeAt(0)]),j=new Uint8Array([0,0,0,1]),M=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),F=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]),H={video:M,audio:F},le=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),J=new Uint8Array([0,0,0,0,0,0,0,0]),ce=new Uint8Array([0,0,0,0,0,0,0,0]),Z=ce,ve=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),Ce=ce,K=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}})(),s=function(q){var z=[],ie=0,ne,pe,me;for(ne=1;ne<arguments.length;ne++)z.push(arguments[ne]);for(ne=z.length;ne--;)ie+=z[ne].byteLength;for(pe=new Uint8Array(ie+8),me=new DataView(pe.buffer,pe.byteOffset,pe.byteLength),me.setUint32(0,pe.byteLength),pe.set(q,4),ne=0,ie=8;ne<z.length;ne++)pe.set(z[ne],ie),ie+=z[ne].byteLength;return pe},o=function(){return s(P.dinf,s(P.dref,le))},l=function(q){return s(P.esds,new Uint8Array([0,0,0,0,3,25,0,0,0,4,17,64,21,0,6,0,0,0,218,192,0,0,218,192,5,2,q.audioobjecttype<<3|q.samplingfrequencyindex>>>1,q.samplingfrequencyindex<<7|q.channelcount<<3,6,1,2]))},u=function(){return s(P.ftyp,N,j,N,O)},E=function(q){return s(P.hdlr,H[q])},g=function(q){return s(P.mdat,q)},S=function(q){var z=new Uint8Array([0,0,0,0,0,0,0,2,0,0,0,3,0,1,95,144,q.duration>>>24&255,q.duration>>>16&255,q.duration>>>8&255,q.duration&255,85,196,0,0]);return q.samplerate&&(z[12]=q.samplerate>>>24&255,z[13]=q.samplerate>>>16&255,z[14]=q.samplerate>>>8&255,z[15]=q.samplerate&255),s(P.mdhd,z)},h=function(q){return s(P.mdia,S(q),E(q.type),d(q))},c=function(q){return s(P.mfhd,new Uint8Array([0,0,0,0,(q&4278190080)>>24,(q&16711680)>>16,(q&65280)>>8,q&255]))},d=function(q){return s(P.minf,q.type==="video"?s(P.vmhd,K):s(P.smhd,J),o(),x(q))},f=function(q,z){for(var ie=[],ne=z.length;ne--;)ie[ne]=C(z[ne]);return s.apply(null,[P.moof,c(q)].concat(ie))},T=function(q){for(var z=q.length,ie=[];z--;)ie[z]=b(q[z]);return s.apply(null,[P.moov,y(4294967295)].concat(ie).concat(p(q)))},p=function(q){for(var z=q.length,ie=[];z--;)ie[z]=k(q[z]);return s.apply(null,[P.mvex].concat(ie))},y=function(q){var z=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,2,0,1,95,144,(q&4278190080)>>24,(q&16711680)>>16,(q&65280)>>8,q&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return s(P.mvhd,z)},A=function(q){var z=q.samples||[],ie=new Uint8Array(4+z.length),ne,pe;for(pe=0;pe<z.length;pe++)ne=z[pe].flags,ie[pe+4]=ne.dependsOn<<4|ne.isDependedOn<<2|ne.hasRedundancy;return s(P.sdtp,ie)},x=function(q){return s(P.stbl,m(q),s(P.stts,Ce),s(P.stsc,Z),s(P.stsz,ve),s(P.stco,ce))},function(){var xe,q;m=function(ie){return s(P.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),ie.type==="video"?xe(ie):q(ie))},xe=function(ie){var ne=ie.sps||[],pe=ie.pps||[],me=[],we=[],Re,Ve;for(Re=0;Re<ne.length;Re++)me.push((ne[Re].byteLength&65280)>>>8),me.push(ne[Re].byteLength&255),me=me.concat(Array.prototype.slice.call(ne[Re]));for(Re=0;Re<pe.length;Re++)we.push((pe[Re].byteLength&65280)>>>8),we.push(pe[Re].byteLength&255),we=we.concat(Array.prototype.slice.call(pe[Re]));if(Ve=[P.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,(ie.width&65280)>>8,ie.width&255,(ie.height&65280)>>8,ie.height&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,19,118,105,100,101,111,106,115,45,99,111,110,116,114,105,98,45,104,108,115,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),s(P.avcC,new Uint8Array([1,ie.profileIdc,ie.profileCompatibility,ie.levelIdc,255].concat([ne.length],me,[pe.length],we))),s(P.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192]))],ie.sarRatio){var st=ie.sarRatio[0],Ft=ie.sarRatio[1];Ve.push(s(P.pasp,new Uint8Array([(st&4278190080)>>24,(st&16711680)>>16,(st&65280)>>8,st&255,(Ft&4278190080)>>24,(Ft&16711680)>>16,(Ft&65280)>>8,Ft&255])))}return s.apply(null,Ve)},q=function(ie){return s(P.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,(ie.channelcount&65280)>>8,ie.channelcount&255,(ie.samplesize&65280)>>8,ie.samplesize&255,0,0,0,0,(ie.samplerate&65280)>>8,ie.samplerate&255,0,0]),l(ie))}}(),v=function(q){var z=new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,(q.id&4278190080)>>24,(q.id&16711680)>>16,(q.id&65280)>>8,q.id&255,0,0,0,0,(q.duration&4278190080)>>24,(q.duration&16711680)>>16,(q.duration&65280)>>8,q.duration&255,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,(q.width&65280)>>8,q.width&255,0,0,(q.height&65280)>>8,q.height&255,0,0]);return s(P.tkhd,z)},C=function(q){var z,ie,ne,pe,me,we,Re;return z=s(P.tfhd,new Uint8Array([0,0,0,58,(q.id&4278190080)>>24,(q.id&16711680)>>16,(q.id&65280)>>8,q.id&255,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0])),we=Math.floor(q.baseMediaDecodeTime/(a+1)),Re=Math.floor(q.baseMediaDecodeTime%(a+1)),ie=s(P.tfdt,new Uint8Array([1,0,0,0,we>>>24&255,we>>>16&255,we>>>8&255,we&255,Re>>>24&255,Re>>>16&255,Re>>>8&255,Re&255])),me=32+20+8+16+8+8,q.type==="audio"?(ne=D(q,me),s(P.traf,z,ie,ne)):(pe=A(q),ne=D(q,pe.length+me),s(P.traf,z,ie,ne,pe))},b=function(q){return q.duration=q.duration||4294967295,s(P.trak,v(q),h(q))},k=function(q){var z=new Uint8Array([0,0,0,0,(q.id&4278190080)>>24,(q.id&16711680)>>16,(q.id&65280)>>8,q.id&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return q.type!=="video"&&(z[z.length-1]=0),s(P.trex,z)},function(){var xe,q,z;z=function(ne,pe){var me=0,we=0,Re=0,Ve=0;return ne.length&&(ne[0].duration!==void 0&&(me=1),ne[0].size!==void 0&&(we=2),ne[0].flags!==void 0&&(Re=4),ne[0].compositionTimeOffset!==void 0&&(Ve=8)),[0,0,me|we|Re|Ve,1,(ne.length&4278190080)>>>24,(ne.length&16711680)>>>16,(ne.length&65280)>>>8,ne.length&255,(pe&4278190080)>>>24,(pe&16711680)>>>16,(pe&65280)>>>8,pe&255]},q=function(ne,pe){var me,we,Re,Ve;for(we=ne.samples||[],pe+=8+12+16*we.length,me=z(we,pe),Ve=0;Ve<we.length;Ve++)Re=we[Ve],me=me.concat([(Re.duration&4278190080)>>>24,(Re.duration&16711680)>>>16,(Re.duration&65280)>>>8,Re.duration&255,(Re.size&4278190080)>>>24,(Re.size&16711680)>>>16,(Re.size&65280)>>>8,Re.size&255,Re.flags.isLeading<<2|Re.flags.dependsOn,Re.flags.isDependedOn<<6|Re.flags.hasRedundancy<<4|Re.flags.paddingValue<<1|Re.flags.isNonSyncSample,Re.flags.degradationPriority&240<<8,Re.flags.degradationPriority&15,(Re.compositionTimeOffset&4278190080)>>>24,(Re.compositionTimeOffset&16711680)>>>16,(Re.compositionTimeOffset&65280)>>>8,Re.compositionTimeOffset&255]);return s(P.trun,new Uint8Array(me))},xe=function(ne,pe){var me,we,Re,Ve;for(we=ne.samples||[],pe+=8+12+8*we.length,me=z(we,pe),Ve=0;Ve<we.length;Ve++)Re=we[Ve],me=me.concat([(Re.duration&4278190080)>>>24,(Re.duration&16711680)>>>16,(Re.duration&65280)>>>8,Re.duration&255,(Re.size&4278190080)>>>24,(Re.size&16711680)>>>16,(Re.size&65280)>>>8,Re.size&255]);return s(P.trun,new Uint8Array(me))},D=function(ne,pe){return ne.type==="audio"?xe(ne,pe):q(ne,pe)}}();var Ne={ftyp:u,mdat:g,moof:f,moov:T,initSegment:function(q){var z=u(),ie=T(q),ne;return ne=new Uint8Array(z.byteLength+ie.byteLength),ne.set(z),ne.set(ie,z.byteLength),ne}},ot=function(q){var z,ie,ne=[],pe=[];for(pe.byteLength=0,pe.nalCount=0,pe.duration=0,ne.byteLength=0,z=0;z<q.length;z++)ie=q[z],ie.nalUnitType==="access_unit_delimiter_rbsp"?(ne.length&&(ne.duration=ie.dts-ne.dts,pe.byteLength+=ne.byteLength,pe.nalCount+=ne.length,pe.duration+=ne.duration,pe.push(ne)),ne=[ie],ne.byteLength=ie.data.byteLength,ne.pts=ie.pts,ne.dts=ie.dts):(ie.nalUnitType==="slice_layer_without_partitioning_rbsp_idr"&&(ne.keyFrame=!0),ne.duration=ie.dts-ne.dts,ne.byteLength+=ie.data.byteLength,ne.push(ie));return pe.length&&(!ne.duration||ne.duration<=0)&&(ne.duration=pe[pe.length-1].duration),pe.byteLength+=ne.byteLength,pe.nalCount+=ne.length,pe.duration+=ne.duration,pe.push(ne),pe},ze=function(q){var z,ie,ne=[],pe=[];for(ne.byteLength=0,ne.nalCount=0,ne.duration=0,ne.pts=q[0].pts,ne.dts=q[0].dts,pe.byteLength=0,pe.nalCount=0,pe.duration=0,pe.pts=q[0].pts,pe.dts=q[0].dts,z=0;z<q.length;z++)ie=q[z],ie.keyFrame?(ne.length&&(pe.push(ne),pe.byteLength+=ne.byteLength,pe.nalCount+=ne.nalCount,pe.duration+=ne.duration),ne=[ie],ne.nalCount=ie.length,ne.byteLength=ie.byteLength,ne.pts=ie.pts,ne.dts=ie.dts,ne.duration=ie.duration):(ne.duration+=ie.duration,ne.nalCount+=ie.length,ne.byteLength+=ie.byteLength,ne.push(ie));return pe.length&&ne.duration<=0&&(ne.duration=pe[pe.length-1].duration),pe.byteLength+=ne.byteLength,pe.nalCount+=ne.nalCount,pe.duration+=ne.duration,pe.push(ne),pe},je=function(q){var z;return!q[0][0].keyFrame&&q.length>1&&(z=q.shift(),q.byteLength-=z.byteLength,q.nalCount-=z.nalCount,q[0][0].dts=z.dts,q[0][0].pts=z.pts,q[0][0].duration+=z.duration),q},Qe=function(){return{size:0,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0,degradationPriority:0,isNonSyncSample:1}}},Bt=function(q,z){var ie=Qe();return ie.dataOffset=z,ie.compositionTimeOffset=q.pts-q.dts,ie.duration=q.duration,ie.size=4*q.length,ie.size+=q.byteLength,q.keyFrame&&(ie.flags.dependsOn=2,ie.flags.isNonSyncSample=0),ie},qt=function(q,z){var ie,ne,pe,me,we,Re=z||0,Ve=[];for(ie=0;ie<q.length;ie++)for(me=q[ie],ne=0;ne<me.length;ne++)we=me[ne],pe=Bt(we,Re),Re+=pe.size,Ve.push(pe);return Ve},ir=function(q){var z,ie,ne,pe,me,we,Re=0,Ve=q.byteLength,st=q.nalCount,Ft=Ve+4*st,er=new Uint8Array(Ft),nr=new DataView(er.buffer);for(z=0;z<q.length;z++)for(pe=q[z],ie=0;ie<pe.length;ie++)for(me=pe[ie],ne=0;ne<me.length;ne++)we=me[ne],nr.setUint32(Re,we.data.byteLength),Re+=4,er.set(we.data,Re),Re+=we.data.byteLength;return er},We=function(q,z){var ie,ne=z||0,pe=[];return ie=Bt(q,ne),pe.push(ie),pe},vt=function(q){var z,ie,ne=0,pe=q.byteLength,me=q.length,we=pe+4*me,Re=new Uint8Array(we),Ve=new DataView(Re.buffer);for(z=0;z<q.length;z++)ie=q[z],Ve.setUint32(ne,ie.data.byteLength),ne+=4,Re.set(ie.data,ne),ne+=ie.data.byteLength;return Re},Tt={groupNalsIntoFrames:ot,groupFramesIntoGops:ze,extendFirstKeyFrame:je,generateSampleTable:qt,concatenateNalData:ir,generateSampleTableForFrame:We,concatenateNalDataForFrame:vt},wt=[33,16,5,32,164,27],Pt=[33,65,108,84,1,2,4,8,168,2,4,8,17,191,252],at=function(q){for(var z=[];q--;)z.push(0);return z},Ot=function(q){return Object.keys(q).reduce(function(z,ie){return z[ie]=new Uint8Array(q[ie].reduce(function(ne,pe){return ne.concat(pe)},[])),z},{})},It={96e3:[wt,[227,64],at(154),[56]],88200:[wt,[231],at(170),[56]],64e3:[wt,[248,192],at(240),[56]],48e3:[wt,[255,192],at(268),[55,148,128],at(54),[112]],44100:[wt,[255,192],at(268),[55,163,128],at(84),[112]],32e3:[wt,[255,192],at(268),[55,234],at(226),[112]],24e3:[wt,[255,192],at(268),[55,255,128],at(268),[111,112],at(126),[224]],16e3:[wt,[255,192],at(268),[55,255,128],at(268),[111,255],at(269),[223,108],at(195),[1,192]],12e3:[Pt,at(268),[3,127,248],at(268),[6,255,240],at(268),[13,255,224],at(268),[27,253,128],at(259),[56]],11025:[Pt,at(268),[3,127,248],at(268),[6,255,240],at(268),[13,255,224],at(268),[27,255,192],at(268),[55,175,128],at(108),[112]],8e3:[Pt,at(268),[3,121,16],at(47),[7]]},sr=Ot(It),lt=9e4,ii,ei,wr,_i,Vr,fi,hi;ii=function(q){return q*lt},ei=function(q,z){return q*z},wr=function(q){return q/lt},_i=function(q,z){return q/z},Vr=function(q,z){return ii(_i(q,z))},fi=function(q,z){return ei(wr(q),z)},hi=function(q,z,ie){return wr(ie?q:q-z)};var oi={ONE_SECOND_IN_TS:lt,secondsToVideoTs:ii,secondsToAudioTs:ei,videoTsToSeconds:wr,audioTsToSeconds:_i,audioTsToVideoTs:Vr,videoTsToAudioTs:fi,metadataTsToSeconds:hi},Kr=function(q){var z,ie,ne=0;for(z=0;z<q.length;z++)ie=q[z],ne+=ie.data.byteLength;return ne},gn=function(q,z,ie,ne){var pe,me=0,we=0,Re=0,Ve=0,st,Ft,er;if(!!z.length&&(pe=oi.audioTsToVideoTs(q.baseMediaDecodeTime,q.samplerate),me=Math.ceil(oi.ONE_SECOND_IN_TS/(q.samplerate/1024)),ie&&ne&&(we=pe-Math.max(ie,ne),Re=Math.floor(we/me),Ve=Re*me),!(Re<1||Ve>oi.ONE_SECOND_IN_TS/2))){for(st=sr[q.samplerate],st||(st=z[0].data),Ft=0;Ft<Re;Ft++)er=z[0],z.splice(0,0,{data:st,dts:er.dts-me,pts:er.pts-me});q.baseMediaDecodeTime-=Math.floor(oi.videoTsToAudioTs(Ve,q.samplerate))}},Pa=function(q,z,ie){return z.minSegmentDts>=ie?q:(z.minSegmentDts=1/0,q.filter(function(ne){return ne.dts>=ie?(z.minSegmentDts=Math.min(z.minSegmentDts,ne.dts),z.minSegmentPts=z.minSegmentDts,!0):!1}))},uo=function(q){var z,ie,ne=[];for(z=0;z<q.length;z++)ie=q[z],ne.push({size:ie.data.byteLength,duration:1024});return ne},es=function(q){var z,ie,ne=0,pe=new Uint8Array(Kr(q));for(z=0;z<q.length;z++)ie=q[z],pe.set(ie.data,ne),ne+=ie.data.byteLength;return pe},$n={prefixWithSilence:gn,trimAdtsFramesByEarliestDts:Pa,generateSampleTable:uo,concatenateFrameData:es},ts=oi.ONE_SECOND_IN_TS,lo=function(q,z){typeof z.pts=="number"&&(q.timelineStartInfo.pts===void 0&&(q.timelineStartInfo.pts=z.pts),q.minSegmentPts===void 0?q.minSegmentPts=z.pts:q.minSegmentPts=Math.min(q.minSegmentPts,z.pts),q.maxSegmentPts===void 0?q.maxSegmentPts=z.pts:q.maxSegmentPts=Math.max(q.maxSegmentPts,z.pts)),typeof z.dts=="number"&&(q.timelineStartInfo.dts===void 0&&(q.timelineStartInfo.dts=z.dts),q.minSegmentDts===void 0?q.minSegmentDts=z.dts:q.minSegmentDts=Math.min(q.minSegmentDts,z.dts),q.maxSegmentDts===void 0?q.maxSegmentDts=z.dts:q.maxSegmentDts=Math.max(q.maxSegmentDts,z.dts))},vn=function(q){delete q.minSegmentDts,delete q.maxSegmentDts,delete q.minSegmentPts,delete q.maxSegmentPts},ca=function(q,z){var ie,ne,pe=q.minSegmentDts;return z||(pe-=q.timelineStartInfo.dts),ie=q.timelineStartInfo.baseMediaDecodeTime,ie+=pe,ie=Math.max(0,ie),q.type==="audio"&&(ne=q.samplerate/ts,ie*=ne,ie=Math.floor(ie)),ie},Si={clearDtsInfo:vn,calculateTrackBaseMediaDecodeTime:ca,collectDtsInfo:lo},ws=4,qo=128,co=function(q){for(var z=0,ie={payloadType:-1,payloadSize:0},ne=0,pe=0;z<q.byteLength&&q[z]!==qo;){for(;q[z]===255;)ne+=255,z++;for(ne+=q[z++];q[z]===255;)pe+=255,z++;if(pe+=q[z++],!ie.payload&&ne===ws){ie.payloadType=ne,ie.payloadSize=pe,ie.payload=q.subarray(z,z+pe);break}z+=pe,ne=0,pe=0}return ie},rs=function(q){return q.payload[0]!==181||(q.payload[1]<<8|q.payload[2])!==49||String.fromCharCode(q.payload[3],q.payload[4],q.payload[5],q.payload[6])!=="GA94"||q.payload[7]!==3?null:q.payload.subarray(8,q.payload.length-1)},mn=function(q,z){var ie=[],ne,pe,me,we;if(!(z[0]&64))return ie;for(pe=z[0]&31,ne=0;ne<pe;ne++)me=ne*3,we={type:z[me+2]&3,pts:q},z[me+2]&4&&(we.ccData=z[me+3]<<8|z[me+4],ie.push(we));return ie},Oa=function(q){for(var z=q.byteLength,ie=[],ne=1,pe,me;ne<z-2;)q[ne]===0&&q[ne+1]===0&&q[ne+2]===3?(ie.push(ne+2),ne+=2):ne++;if(ie.length===0)return q;pe=z-ie.length,me=new Uint8Array(pe);var we=0;for(ne=0;ne<pe;we++,ne++)we===ie[0]&&(we++,ie.shift()),me[ne]=q[we];return me},La={parseSei:co,parseUserData:rs,parseCaptionPackets:mn,discardEmulationPreventionBytes:Oa,USER_DATA_REGISTERED_ITU_T_T35:ws},on=function xe(){xe.prototype.init.call(this),this.captionPackets_=[],this.ccStreams_=[new ui(0,0),new ui(0,1),new ui(1,0),new ui(1,1)],this.reset(),this.ccStreams_.forEach(function(q){q.on("data",this.trigger.bind(this,"data")),q.on("partialdone",this.trigger.bind(this,"partialdone")),q.on("done",this.trigger.bind(this,"done"))},this)};on.prototype=new n,on.prototype.push=function(xe){var q,z,ie;if(xe.nalUnitType==="sei_rbsp"&&(q=La.parseSei(xe.escapedRBSP),q.payloadType===La.USER_DATA_REGISTERED_ITU_T_T35&&(z=La.parseUserData(q),!!z))){if(xe.dts<this.latestDts_){this.ignoreNextEqualDts_=!0;return}else if(xe.dts===this.latestDts_&&this.ignoreNextEqualDts_){this.numSameDts_--,this.numSameDts_||(this.ignoreNextEqualDts_=!1);return}ie=La.parseCaptionPackets(xe.pts,z),this.captionPackets_=this.captionPackets_.concat(ie),this.latestDts_!==xe.dts&&(this.numSameDts_=0),this.numSameDts_++,this.latestDts_=xe.dts}},on.prototype.flushCCStreams=function(xe){this.ccStreams_.forEach(function(q){return xe==="flush"?q.flush():q.partialFlush()},this)},on.prototype.flushStream=function(xe){if(!this.captionPackets_.length){this.flushCCStreams(xe);return}this.captionPackets_.forEach(function(q,z){q.presortIndex=z}),this.captionPackets_.sort(function(q,z){return q.pts===z.pts?q.presortIndex-z.presortIndex:q.pts-z.pts}),this.captionPackets_.forEach(function(q){q.type<2&&this.dispatchCea608Packet(q)},this),this.captionPackets_.length=0,this.flushCCStreams(xe)},on.prototype.flush=function(){return this.flushStream("flush")},on.prototype.partialFlush=function(){return this.flushStream("partialFlush")},on.prototype.reset=function(){this.latestDts_=null,this.ignoreNextEqualDts_=!1,this.numSameDts_=0,this.activeCea608Channel_=[null,null],this.ccStreams_.forEach(function(xe){xe.reset()})},on.prototype.dispatchCea608Packet=function(xe){this.setsTextOrXDSActive(xe)?this.activeCea608Channel_[xe.type]=null:this.setsChannel1Active(xe)?this.activeCea608Channel_[xe.type]=0:this.setsChannel2Active(xe)&&(this.activeCea608Channel_[xe.type]=1),this.activeCea608Channel_[xe.type]!==null&&this.ccStreams_[(xe.type<<1)+this.activeCea608Channel_[xe.type]].push(xe)},on.prototype.setsChannel1Active=function(xe){return(xe.ccData&30720)===4096},on.prototype.setsChannel2Active=function(xe){return(xe.ccData&30720)===6144},on.prototype.setsTextOrXDSActive=function(xe){return(xe.ccData&28928)===256||(xe.ccData&30974)===4138||(xe.ccData&30974)===6186};var Wo={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,304:174,305:176,306:189,307:191,308:8482,309:162,310:163,311:9834,312:224,313:160,314:232,315:226,316:234,317:238,318:244,319:251,544:193,545:201,546:211,547:218,548:220,549:252,550:8216,551:161,552:42,553:39,554:8212,555:169,556:8480,557:8226,558:8220,559:8221,560:192,561:194,562:199,563:200,564:202,565:203,566:235,567:206,568:207,569:239,570:212,571:217,572:249,573:219,574:171,575:187,800:195,801:227,802:205,803:204,804:236,805:210,806:242,807:213,808:245,809:123,810:125,811:92,812:94,813:95,814:124,815:126,816:196,817:228,818:214,819:246,820:223,821:165,822:164,823:9474,824:197,825:229,826:216,827:248,828:9484,829:9488,830:9492,831:9496},As=function(q){return q===null?"":(q=Wo[q]||q,String.fromCharCode(q))},Cs=14,Yo=[4352,4384,4608,4640,5376,5408,5632,5664,5888,5920,4096,4864,4896,5120,5152],Hn=function(){for(var q=[],z=Cs+1;z--;)q.push("");return q},ui=function xe(q,z){xe.prototype.init.call(this),this.field_=q||0,this.dataChannel_=z||0,this.name_="CC"+((this.field_<<1|this.dataChannel_)+1),this.setConstants(),this.reset(),this.push=function(ie){var ne,pe,me,we,Re;if(ne=ie.ccData&32639,ne===this.lastControlCode_){this.lastControlCode_=null;return}if((ne&61440)===4096?this.lastControlCode_=ne:ne!==this.PADDING_&&(this.lastControlCode_=null),me=ne>>>8,we=ne&255,ne!==this.PADDING_)if(ne===this.RESUME_CAPTION_LOADING_)this.mode_="popOn";else if(ne===this.END_OF_CAPTION_)this.mode_="popOn",this.clearFormatting(ie.pts),this.flushDisplayed(ie.pts),pe=this.displayed_,this.displayed_=this.nonDisplayed_,this.nonDisplayed_=pe,this.startPts_=ie.pts;else if(ne===this.ROLL_UP_2_ROWS_)this.rollUpRows_=2,this.setRollUp(ie.pts);else if(ne===this.ROLL_UP_3_ROWS_)this.rollUpRows_=3,this.setRollUp(ie.pts);else if(ne===this.ROLL_UP_4_ROWS_)this.rollUpRows_=4,this.setRollUp(ie.pts);else if(ne===this.CARRIAGE_RETURN_)this.clearFormatting(ie.pts),this.flushDisplayed(ie.pts),this.shiftRowsUp_(),this.startPts_=ie.pts;else if(ne===this.BACKSPACE_)this.mode_==="popOn"?this.nonDisplayed_[this.row_]=this.nonDisplayed_[this.row_].slice(0,-1):this.displayed_[this.row_]=this.displayed_[this.row_].slice(0,-1);else if(ne===this.ERASE_DISPLAYED_MEMORY_)this.flushDisplayed(ie.pts),this.displayed_=Hn();else if(ne===this.ERASE_NON_DISPLAYED_MEMORY_)this.nonDisplayed_=Hn();else if(ne===this.RESUME_DIRECT_CAPTIONING_)this.mode_!=="paintOn"&&(this.flushDisplayed(ie.pts),this.displayed_=Hn()),this.mode_="paintOn",this.startPts_=ie.pts;else if(this.isSpecialCharacter(me,we))me=(me&3)<<8,Re=As(me|we),this[this.mode_](ie.pts,Re),this.column_++;else if(this.isExtCharacter(me,we))this.mode_==="popOn"?this.nonDisplayed_[this.row_]=this.nonDisplayed_[this.row_].slice(0,-1):this.displayed_[this.row_]=this.displayed_[this.row_].slice(0,-1),me=(me&3)<<8,Re=As(me|we),this[this.mode_](ie.pts,Re),this.column_++;else if(this.isMidRowCode(me,we))this.clearFormatting(ie.pts),this[this.mode_](ie.pts," "),this.column_++,(we&14)===14&&this.addFormatting(ie.pts,["i"]),(we&1)===1&&this.addFormatting(ie.pts,["u"]);else if(this.isOffsetControlCode(me,we))this.column_+=we&3;else if(this.isPAC(me,we)){var Ve=Yo.indexOf(ne&7968);this.mode_==="rollUp"&&(Ve-this.rollUpRows_+1<0&&(Ve=this.rollUpRows_-1),this.setRollUp(ie.pts,Ve)),Ve!==this.row_&&(this.clearFormatting(ie.pts),this.row_=Ve),we&1&&this.formatting_.indexOf("u")===-1&&this.addFormatting(ie.pts,["u"]),(ne&16)===16&&(this.column_=((ne&14)>>1)*4),this.isColorPAC(we)&&(we&14)===14&&this.addFormatting(ie.pts,["i"])}else this.isNormalChar(me)&&(we===0&&(we=null),Re=As(me),Re+=As(we),this[this.mode_](ie.pts,Re),this.column_+=Re.length)}};ui.prototype=new n,ui.prototype.flushDisplayed=function(xe){var q=this.displayed_.map(function(z){try{return z.trim()}catch{return console.error("Skipping malformed caption."),""}}).join(`
95
95
  `).replace(/^\n+|\n+$/g,"");q.length&&this.trigger("data",{startPts:this.startPts_,endPts:xe,text:q,stream:this.name_})},ui.prototype.reset=function(){this.mode_="popOn",this.topRow_=0,this.startPts_=0,this.displayed_=Hn(),this.nonDisplayed_=Hn(),this.lastControlCode_=null,this.column_=0,this.row_=Cs,this.rollUpRows_=2,this.formatting_=[]},ui.prototype.setConstants=function(){this.dataChannel_===0?(this.BASE_=16,this.EXT_=17,this.CONTROL_=(20|this.field_)<<8,this.OFFSET_=23):this.dataChannel_===1&&(this.BASE_=24,this.EXT_=25,this.CONTROL_=(28|this.field_)<<8,this.OFFSET_=31),this.PADDING_=0,this.RESUME_CAPTION_LOADING_=this.CONTROL_|32,this.END_OF_CAPTION_=this.CONTROL_|47,this.ROLL_UP_2_ROWS_=this.CONTROL_|37,this.ROLL_UP_3_ROWS_=this.CONTROL_|38,this.ROLL_UP_4_ROWS_=this.CONTROL_|39,this.CARRIAGE_RETURN_=this.CONTROL_|45,this.RESUME_DIRECT_CAPTIONING_=this.CONTROL_|41,this.BACKSPACE_=this.CONTROL_|33,this.ERASE_DISPLAYED_MEMORY_=this.CONTROL_|44,this.ERASE_NON_DISPLAYED_MEMORY_=this.CONTROL_|46},ui.prototype.isSpecialCharacter=function(xe,q){return xe===this.EXT_&&q>=48&&q<=63},ui.prototype.isExtCharacter=function(xe,q){return(xe===this.EXT_+1||xe===this.EXT_+2)&&q>=32&&q<=63},ui.prototype.isMidRowCode=function(xe,q){return xe===this.EXT_&&q>=32&&q<=47},ui.prototype.isOffsetControlCode=function(xe,q){return xe===this.OFFSET_&&q>=33&&q<=35},ui.prototype.isPAC=function(xe,q){return xe>=this.BASE_&&xe<this.BASE_+8&&q>=64&&q<=127},ui.prototype.isColorPAC=function(xe){return xe>=64&&xe<=79||xe>=96&&xe<=127},ui.prototype.isNormalChar=function(xe){return xe>=32&&xe<=127},ui.prototype.setRollUp=function(xe,q){if(this.mode_!=="rollUp"&&(this.row_=Cs,this.mode_="rollUp",this.flushDisplayed(xe),this.nonDisplayed_=Hn(),this.displayed_=Hn()),q!==void 0&&q!==this.row_)for(var z=0;z<this.rollUpRows_;z++)this.displayed_[q-z]=this.displayed_[this.row_-z],this.displayed_[this.row_-z]="";q===void 0&&(q=this.row_),this.topRow_=q-this.rollUpRows_+1},ui.prototype.addFormatting=function(xe,q){this.formatting_=this.formatting_.concat(q);var z=q.reduce(function(ie,ne){return ie+"<"+ne+">"},"");this[this.mode_](xe,z)},ui.prototype.clearFormatting=function(xe){if(!!this.formatting_.length){var q=this.formatting_.reverse().reduce(function(z,ie){return z+"</"+ie+">"},"");this.formatting_=[],this[this.mode_](xe,q)}},ui.prototype.popOn=function(xe,q){var z=this.nonDisplayed_[this.row_];z+=q,this.nonDisplayed_[this.row_]=z},ui.prototype.rollUp=function(xe,q){var z=this.displayed_[this.row_];z+=q,this.displayed_[this.row_]=z},ui.prototype.shiftRowsUp_=function(){var xe;for(xe=0;xe<this.topRow_;xe++)this.displayed_[xe]="";for(xe=this.row_+1;xe<Cs+1;xe++)this.displayed_[xe]="";for(xe=this.topRow_;xe<this.row_;xe++)this.displayed_[xe]=this.displayed_[xe+1];this.displayed_[this.row_]=""},ui.prototype.paintOn=function(xe,q){var z=this.displayed_[this.row_];z+=q,this.displayed_[this.row_]=z};var ks={CaptionStream:on,Cea608Stream:ui},Xi={H264_STREAM_TYPE:27,ADTS_STREAM_TYPE:15,METADATA_STREAM_TYPE:21},Rs=8589934592,Ia=4294967296,da="shared",is=function(q,z){var ie=1;for(q>z&&(ie=-1);Math.abs(z-q)>Ia;)q+=ie*Rs;return q},ns=function xe(q){var z,ie;xe.prototype.init.call(this),this.type_=q||da,this.push=function(ne){this.type_!==da&&ne.type!==this.type_||(ie===void 0&&(ie=ne.dts),ne.dts=is(ne.dts,ie),ne.pts=is(ne.pts,ie),z=ne.dts,this.trigger("data",ne))},this.flush=function(){ie=z,this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")},this.discontinuity=function(){ie=void 0,z=void 0},this.reset=function(){this.discontinuity(),this.trigger("reset")}};ns.prototype=new n;var Ei={TimestampRolloverStream:ns,handleRollover:is},yn=function(q,z,ie){var ne,pe="";for(ne=z;ne<ie;ne++)pe+="%"+("00"+q[ne].toString(16)).slice(-2);return pe},Ds=function(q,z,ie){return decodeURIComponent(yn(q,z,ie))},Ma=function(q,z,ie){return unescape(yn(q,z,ie))},Cn=function(q){return q[0]<<21|q[1]<<14|q[2]<<7|q[3]},Ps={TXXX:function(q){var z;if(q.data[0]===3){for(z=1;z<q.data.length;z++)if(q.data[z]===0){q.description=Ds(q.data,1,z),q.value=Ds(q.data,z+1,q.data.length).replace(/\0*$/,"");break}q.data=q.value}},WXXX:function(q){var z;if(q.data[0]===3){for(z=1;z<q.data.length;z++)if(q.data[z]===0){q.description=Ds(q.data,1,z),q.url=Ds(q.data,z+1,q.data.length);break}}},PRIV:function(q){var z;for(z=0;z<q.data.length;z++)if(q.data[z]===0){q.owner=Ma(q.data,0,z);break}q.privateData=q.data.subarray(z+1),q.data=q.privateData}},Qn;Qn=function(q){var z={debug:!!(q&&q.debug),descriptor:q&&q.descriptor},ie=0,ne=[],pe=0,me;if(Qn.prototype.init.call(this),this.dispatchType=Xi.METADATA_STREAM_TYPE.toString(16),z.descriptor)for(me=0;me<z.descriptor.length;me++)this.dispatchType+=("00"+z.descriptor[me].toString(16)).slice(-2);this.push=function(we){var Re,Ve,st,Ft,er,nr;if(we.type==="timed-metadata"){if(we.dataAlignmentIndicator&&(pe=0,ne.length=0),ne.length===0&&(we.data.length<10||we.data[0]!=="I".charCodeAt(0)||we.data[1]!=="D".charCodeAt(0)||we.data[2]!=="3".charCodeAt(0))){z.debug&&console.log("Skipping unrecognized metadata packet");return}if(ne.push(we),pe+=we.data.byteLength,ne.length===1&&(ie=Cn(we.data.subarray(6,10)),ie+=10),!(pe<ie)){for(Re={data:new Uint8Array(ie),frames:[],pts:ne[0].pts,dts:ne[0].dts},er=0;er<ie;)Re.data.set(ne[0].data.subarray(0,ie-er),er),er+=ne[0].data.byteLength,pe-=ne[0].data.byteLength,ne.shift();Ve=10,Re.data[5]&64&&(Ve+=4,Ve+=Cn(Re.data.subarray(10,14)),ie-=Cn(Re.data.subarray(16,20)));do{if(st=Cn(Re.data.subarray(Ve+4,Ve+8)),st<1)return console.log("Malformed ID3 frame encountered. Skipping metadata parsing.");if(nr=String.fromCharCode(Re.data[Ve],Re.data[Ve+1],Re.data[Ve+2],Re.data[Ve+3]),Ft={id:nr,data:Re.data.subarray(Ve+10,Ve+st+10)},Ft.key=Ft.id,Ps[Ft.id]&&(Ps[Ft.id](Ft),Ft.owner==="com.apple.streaming.transportStreamTimestamp")){var br=Ft.data,kr=(br[3]&1)<<30|br[4]<<22|br[5]<<14|br[6]<<6|br[7]>>>2;kr*=4,kr+=br[7]&3,Ft.timeStamp=kr,Re.pts===void 0&&Re.dts===void 0&&(Re.pts=Ft.timeStamp,Re.dts=Ft.timeStamp),this.trigger("timestamp",Ft)}Re.frames.push(Ft),Ve+=10,Ve+=st}while(Ve<ie);this.trigger("data",Re)}}}},Qn.prototype=new n;var Na=Qn,fo=Ei.TimestampRolloverStream,_n,as,fa,un=188,Os=71;_n=function(){var q=new Uint8Array(un),z=0;_n.prototype.init.call(this),this.push=function(ie){var ne=0,pe=un,me;for(z?(me=new Uint8Array(ie.byteLength+z),me.set(q.subarray(0,z)),me.set(ie,z),z=0):me=ie;pe<me.byteLength;){if(me[ne]===Os&&me[pe]===Os){this.trigger("data",me.subarray(ne,pe)),ne+=un,pe+=un;continue}ne++,pe++}ne<me.byteLength&&(q.set(me.subarray(ne),0),z=me.byteLength-ne)},this.flush=function(){z===un&&q[0]===Os&&(this.trigger("data",q),z=0),this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")},this.reset=function(){z=0,this.trigger("reset")}},_n.prototype=new n,as=function(){var q,z,ie,ne;as.prototype.init.call(this),ne=this,this.packetsWaitingForPmt=[],this.programMapTable=void 0,q=function(me,we){var Re=0;we.payloadUnitStartIndicator&&(Re+=me[Re]+1),we.type==="pat"?z(me.subarray(Re),we):ie(me.subarray(Re),we)},z=function(me,we){we.section_number=me[7],we.last_section_number=me[8],ne.pmtPid=(me[10]&31)<<8|me[11],we.pmtPid=ne.pmtPid},ie=function(me,we){var Re,Ve,st,Ft;if(!!(me[5]&1)){for(ne.programMapTable={video:null,audio:null,"timed-metadata":{}},Re=(me[1]&15)<<8|me[2],Ve=3+Re-4,st=(me[10]&15)<<8|me[11],Ft=12+st;Ft<Ve;){var er=me[Ft],nr=(me[Ft+1]&31)<<8|me[Ft+2];er===Xi.H264_STREAM_TYPE&&ne.programMapTable.video===null?ne.programMapTable.video=nr:er===Xi.ADTS_STREAM_TYPE&&ne.programMapTable.audio===null?ne.programMapTable.audio=nr:er===Xi.METADATA_STREAM_TYPE&&(ne.programMapTable["timed-metadata"][nr]=er),Ft+=((me[Ft+3]&15)<<8|me[Ft+4])+5}we.programMapTable=ne.programMapTable}},this.push=function(pe){var me={},we=4;if(me.payloadUnitStartIndicator=!!(pe[1]&64),me.pid=pe[1]&31,me.pid<<=8,me.pid|=pe[2],(pe[3]&48)>>>4>1&&(we+=pe[we]+1),me.pid===0)me.type="pat",q(pe.subarray(we),me),this.trigger("data",me);else if(me.pid===this.pmtPid)for(me.type="pmt",q(pe.subarray(we),me),this.trigger("data",me);this.packetsWaitingForPmt.length;)this.processPes_.apply(this,this.packetsWaitingForPmt.shift());else this.programMapTable===void 0?this.packetsWaitingForPmt.push([pe,we,me]):this.processPes_(pe,we,me)},this.processPes_=function(pe,me,we){we.pid===this.programMapTable.video?we.streamType=Xi.H264_STREAM_TYPE:we.pid===this.programMapTable.audio?we.streamType=Xi.ADTS_STREAM_TYPE:we.streamType=this.programMapTable["timed-metadata"][we.pid],we.type="pes",we.data=pe.subarray(me),this.trigger("data",we)}},as.prototype=new n,as.STREAM_TYPES={h264:27,adts:15},fa=function(){var q=this,z={data:[],size:0},ie={data:[],size:0},ne={data:[],size:0},pe,me=function(Ve,st){var Ft;st.packetLength=6+(Ve[4]<<8|Ve[5]),st.dataAlignmentIndicator=(Ve[6]&4)!==0,Ft=Ve[7],Ft&192&&(st.pts=(Ve[9]&14)<<27|(Ve[10]&255)<<20|(Ve[11]&254)<<12|(Ve[12]&255)<<5|(Ve[13]&254)>>>3,st.pts*=4,st.pts+=(Ve[13]&6)>>>1,st.dts=st.pts,Ft&64&&(st.dts=(Ve[14]&14)<<27|(Ve[15]&255)<<20|(Ve[16]&254)<<12|(Ve[17]&255)<<5|(Ve[18]&254)>>>3,st.dts*=4,st.dts+=(Ve[18]&6)>>>1)),st.data=Ve.subarray(9+Ve[8])},we=function(Ve,st,Ft){var er=new Uint8Array(Ve.size),nr={type:st},br=0,kr=0,Dt=!1,Li;if(!(!Ve.data.length||Ve.size<9)){for(nr.trackId=Ve.data[0].pid,br=0;br<Ve.data.length;br++)Li=Ve.data[br],er.set(Li.data,kr),kr+=Li.data.byteLength;me(er,nr),Dt=st==="video"||nr.packetLength<=Ve.size,(Ft||Dt)&&(Ve.size=0,Ve.data.length=0),Dt&&q.trigger("data",nr)}};fa.prototype.init.call(this),this.push=function(Re){({pat:function(){},pes:function(){var st,Ft;switch(Re.streamType){case Xi.H264_STREAM_TYPE:case Xi.H264_STREAM_TYPE:st=z,Ft="video";break;case Xi.ADTS_STREAM_TYPE:st=ie,Ft="audio";break;case Xi.METADATA_STREAM_TYPE:st=ne,Ft="timed-metadata";break;default:return}Re.payloadUnitStartIndicator&&we(st,Ft,!0),st.data.push(Re),st.size+=Re.data.byteLength},pmt:function(){var st={type:"metadata",tracks:[]};pe=Re.programMapTable,pe.video!==null&&st.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+pe.video,codec:"avc",type:"video"}),pe.audio!==null&&st.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+pe.audio,codec:"adts",type:"audio"}),q.trigger("data",st)}})[Re.type]()},this.reset=function(){z.size=0,z.data.length=0,ie.size=0,ie.data.length=0,this.trigger("reset")},this.flushStreams_=function(){we(z,"video"),we(ie,"audio"),we(ne,"timed-metadata")},this.flush=function(){this.flushStreams_(),this.trigger("done")}},fa.prototype=new n;var Fa={PAT_PID:0,MP2T_PACKET_LENGTH:un,TransportPacketStream:_n,TransportParseStream:as,ElementaryStream:fa,TimestampRolloverStream:fo,CaptionStream:ks.CaptionStream,Cea608Stream:ks.Cea608Stream,MetadataStream:Na};for(var Gn in Xi)Xi.hasOwnProperty(Gn)&&(Fa[Gn]=Xi[Gn]);var Vn=Fa,Ko=oi.ONE_SECOND_IN_TS,de,Ee=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];de=function(q){var z,ie=0;de.prototype.init.call(this),this.push=function(ne){var pe=0,me,we,Re,Ve,st,Ft;if(q||(ie=0),ne.type==="audio")for(z?(Ve=z,z=new Uint8Array(Ve.byteLength+ne.data.byteLength),z.set(Ve),z.set(ne.data,Ve.byteLength)):z=ne.data;pe+5<z.length;){if(z[pe]!==255||(z[pe+1]&246)!==240){pe++;continue}if(we=(~z[pe+1]&1)*2,me=(z[pe+3]&3)<<11|z[pe+4]<<3|(z[pe+5]&224)>>5,st=((z[pe+6]&3)+1)*1024,Ft=st*Ko/Ee[(z[pe+2]&60)>>>2],Re=pe+me,z.byteLength<Re)return;if(this.trigger("data",{pts:ne.pts+ie*Ft,dts:ne.dts+ie*Ft,sampleCount:st,audioobjecttype:(z[pe+2]>>>6&3)+1,channelcount:(z[pe+2]&1)<<2|(z[pe+3]&192)>>>6,samplerate:Ee[(z[pe+2]&60)>>>2],samplingfrequencyindex:(z[pe+2]&60)>>>2,samplesize:16,data:z.subarray(pe+7+we,Re)}),ie++,z.byteLength===Re){z=void 0;return}z=z.subarray(Re)}},this.flush=function(){ie=0,this.trigger("done")},this.reset=function(){z=void 0,this.trigger("reset")},this.endTimeline=function(){z=void 0,this.trigger("endedtimeline")}},de.prototype=new n;var ge=de,Me;Me=function(q){var z=q.byteLength,ie=0,ne=0;this.length=function(){return 8*z},this.bitsAvailable=function(){return 8*z+ne},this.loadWord=function(){var pe=q.byteLength-z,me=new Uint8Array(4),we=Math.min(4,z);if(we===0)throw new Error("no bytes available");me.set(q.subarray(pe,pe+we)),ie=new DataView(me.buffer).getUint32(0),ne=we*8,z-=we},this.skipBits=function(pe){var me;ne>pe?(ie<<=pe,ne-=pe):(pe-=ne,me=Math.floor(pe/8),pe-=me*8,z-=me,this.loadWord(),ie<<=pe,ne-=pe)},this.readBits=function(pe){var me=Math.min(ne,pe),we=ie>>>32-me;return ne-=me,ne>0?ie<<=me:z>0&&this.loadWord(),me=pe-me,me>0?we<<me|this.readBits(me):we},this.skipLeadingZeros=function(){var pe;for(pe=0;pe<ne;++pe)if((ie&2147483648>>>pe)!==0)return ie<<=pe,ne-=pe,pe;return this.loadWord(),pe+this.skipLeadingZeros()},this.skipUnsignedExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.skipExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.readUnsignedExpGolomb=function(){var pe=this.skipLeadingZeros();return this.readBits(pe+1)-1},this.readExpGolomb=function(){var pe=this.readUnsignedExpGolomb();return 1&pe?1+pe>>>1:-1*(pe>>>1)},this.readBoolean=function(){return this.readBits(1)===1},this.readUnsignedByte=function(){return this.readBits(8)},this.loadWord()};var He=Me,Le,et,yt;et=function(){var q=0,z,ie;et.prototype.init.call(this),this.push=function(ne){var pe;ie?(pe=new Uint8Array(ie.byteLength+ne.data.byteLength),pe.set(ie),pe.set(ne.data,ie.byteLength),ie=pe):ie=ne.data;for(var me=ie.byteLength;q<me-3;q++)if(ie[q+2]===1){z=q+5;break}for(;z<me;)switch(ie[z]){case 0:if(ie[z-1]!==0){z+=2;break}else if(ie[z-2]!==0){z++;break}q+3!==z-2&&this.trigger("data",ie.subarray(q+3,z-2));do z++;while(ie[z]!==1&&z<me);q=z-2,z+=3;break;case 1:if(ie[z-1]!==0||ie[z-2]!==0){z+=3;break}this.trigger("data",ie.subarray(q+3,z-2)),q=z-2,z+=3;break;default:z+=3;break}ie=ie.subarray(q),z-=q,q=0},this.reset=function(){ie=null,q=0,this.trigger("reset")},this.flush=function(){ie&&ie.byteLength>3&&this.trigger("data",ie.subarray(q+3)),ie=null,q=0,this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")}},et.prototype=new n,yt={100:!0,110:!0,122:!0,244:!0,44:!0,83:!0,86:!0,118:!0,128:!0,138:!0,139:!0,134:!0},Le=function(){var q=new et,z,ie,ne,pe,me,we,Re;Le.prototype.init.call(this),z=this,this.push=function(Ve){Ve.type==="video"&&(ie=Ve.trackId,ne=Ve.pts,pe=Ve.dts,q.push(Ve))},q.on("data",function(Ve){var st={trackId:ie,pts:ne,dts:pe,data:Ve};switch(Ve[0]&31){case 5:st.nalUnitType="slice_layer_without_partitioning_rbsp_idr";break;case 6:st.nalUnitType="sei_rbsp",st.escapedRBSP=me(Ve.subarray(1));break;case 7:st.nalUnitType="seq_parameter_set_rbsp",st.escapedRBSP=me(Ve.subarray(1)),st.config=we(st.escapedRBSP);break;case 8:st.nalUnitType="pic_parameter_set_rbsp";break;case 9:st.nalUnitType="access_unit_delimiter_rbsp";break}z.trigger("data",st)}),q.on("done",function(){z.trigger("done")}),q.on("partialdone",function(){z.trigger("partialdone")}),q.on("reset",function(){z.trigger("reset")}),q.on("endedtimeline",function(){z.trigger("endedtimeline")}),this.flush=function(){q.flush()},this.partialFlush=function(){q.partialFlush()},this.reset=function(){q.reset()},this.endTimeline=function(){q.endTimeline()},Re=function(st,Ft){var er=8,nr=8,br,kr;for(br=0;br<st;br++)nr!==0&&(kr=Ft.readExpGolomb(),nr=(er+kr+256)%256),er=nr===0?er:nr},me=function(st){for(var Ft=st.byteLength,er=[],nr=1,br,kr;nr<Ft-2;)st[nr]===0&&st[nr+1]===0&&st[nr+2]===3?(er.push(nr+2),nr+=2):nr++;if(er.length===0)return st;br=Ft-er.length,kr=new Uint8Array(br);var Dt=0;for(nr=0;nr<br;Dt++,nr++)Dt===er[0]&&(Dt++,er.shift()),kr[nr]=st[Dt];return kr},we=function(st){var Ft=0,er=0,nr=0,br=0,kr=1,Dt,Li,Wn,Ms,va,Jo,Hu,ss,Gu,Qo,Ji,wi,Vu,os;if(Dt=new He(st),Li=Dt.readUnsignedByte(),Ms=Dt.readUnsignedByte(),Wn=Dt.readUnsignedByte(),Dt.skipUnsignedExpGolomb(),yt[Li]&&(va=Dt.readUnsignedExpGolomb(),va===3&&Dt.skipBits(1),Dt.skipUnsignedExpGolomb(),Dt.skipUnsignedExpGolomb(),Dt.skipBits(1),Dt.readBoolean()))for(Ji=va!==3?8:12,os=0;os<Ji;os++)Dt.readBoolean()&&(os<6?Re(16,Dt):Re(64,Dt));if(Dt.skipUnsignedExpGolomb(),Jo=Dt.readUnsignedExpGolomb(),Jo===0)Dt.readUnsignedExpGolomb();else if(Jo===1)for(Dt.skipBits(1),Dt.skipExpGolomb(),Dt.skipExpGolomb(),Hu=Dt.readUnsignedExpGolomb(),os=0;os<Hu;os++)Dt.skipExpGolomb();if(Dt.skipUnsignedExpGolomb(),Dt.skipBits(1),ss=Dt.readUnsignedExpGolomb(),Gu=Dt.readUnsignedExpGolomb(),Qo=Dt.readBits(1),Qo===0&&Dt.skipBits(1),Dt.skipBits(1),Dt.readBoolean()&&(Ft=Dt.readUnsignedExpGolomb(),er=Dt.readUnsignedExpGolomb(),nr=Dt.readUnsignedExpGolomb(),br=Dt.readUnsignedExpGolomb()),Dt.readBoolean()&&Dt.readBoolean()){switch(Vu=Dt.readUnsignedByte(),Vu){case 1:wi=[1,1];break;case 2:wi=[12,11];break;case 3:wi=[10,11];break;case 4:wi=[16,11];break;case 5:wi=[40,33];break;case 6:wi=[24,11];break;case 7:wi=[20,11];break;case 8:wi=[32,11];break;case 9:wi=[80,33];break;case 10:wi=[18,11];break;case 11:wi=[15,11];break;case 12:wi=[64,33];break;case 13:wi=[160,99];break;case 14:wi=[4,3];break;case 15:wi=[3,2];break;case 16:wi=[2,1];break;case 255:{wi=[Dt.readUnsignedByte()<<8|Dt.readUnsignedByte(),Dt.readUnsignedByte()<<8|Dt.readUnsignedByte()];break}}wi&&(kr=wi[0]/wi[1])}return{profileIdc:Li,levelIdc:Wn,profileCompatibility:Ms,width:Math.ceil(((ss+1)*16-Ft*2-er*2)*kr),height:(2-Qo)*(Gu+1)*16-nr*2-br*2,sarRatio:wi}}},Le.prototype=new n;var gt={H264Stream:Le,NalByteStream:et},St=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],Rt=function(q){return q[0]==="I".charCodeAt(0)&&q[1]==="D".charCodeAt(0)&&q[2]==="3".charCodeAt(0)},Zt=function(q){return q[0]<<21|q[1]<<14|q[2]<<7|q[3]},_r=function(q,z,ie){var ne,pe="";for(ne=z;ne<ie;ne++)pe+="%"+("00"+q[ne].toString(16)).slice(-2);return pe},jr=function(q,z,ie){return unescape(_r(q,z,ie))},$r=function(q,z){var ie=q[z+6]<<21|q[z+7]<<14|q[z+8]<<7|q[z+9],ne=q[z+5],pe=(ne&16)>>4;return pe?ie+20:ie+10},xi=function(q,z){var ie=(q[z+5]&224)>>5,ne=q[z+4]<<3,pe=q[z+3]&3<<11;return pe|ne|ie},mr=function(q,z){return q[z]==="I".charCodeAt(0)&&q[z+1]==="D".charCodeAt(0)&&q[z+2]==="3".charCodeAt(0)?"timed-metadata":q[z]&!0&&(q[z+1]&240)===240?"audio":null},Wi=function(q){for(var z=0;z+5<q.length;){if(q[z]!==255||(q[z+1]&246)!==240){z++;continue}return St[(q[z+2]&60)>>>2]}return null},Zn=function(q){var z,ie,ne,pe;z=10,q[5]&64&&(z+=4,z+=Zt(q.subarray(10,14)));do{if(ie=Zt(q.subarray(z+4,z+8)),ie<1)return null;if(pe=String.fromCharCode(q[z],q[z+1],q[z+2],q[z+3]),pe==="PRIV"){ne=q.subarray(z+10,z+ie+10);for(var me=0;me<ne.byteLength;me++)if(ne[me]===0){var we=jr(ne,0,me);if(we==="com.apple.streaming.transportStreamTimestamp"){var Re=ne.subarray(me+1),Ve=(Re[3]&1)<<30|Re[4]<<22|Re[5]<<14|Re[6]<<6|Re[7]>>>2;return Ve*=4,Ve+=Re[7]&3,Ve}break}}z+=10,z+=ie}while(z<q.byteLength);return null},Ua={isLikelyAacData:Rt,parseId3TagSize:$r,parseAdtsSize:xi,parseType:mr,parseSampleRate:Wi,parseAacTimestamp:Zn},bn;bn=function(){var q=new Uint8Array,z=0;bn.prototype.init.call(this),this.setTimestamp=function(ie){z=ie},this.push=function(ie){var ne=0,pe=0,me,we,Re,Ve;for(q.length?(Ve=q.length,q=new Uint8Array(ie.byteLength+Ve),q.set(q.subarray(0,Ve)),q.set(ie,Ve)):q=ie;q.length-pe>=3;){if(q[pe]==="I".charCodeAt(0)&&q[pe+1]==="D".charCodeAt(0)&&q[pe+2]==="3".charCodeAt(0)){if(q.length-pe<10||(ne=Ua.parseId3TagSize(q,pe),pe+ne>q.length))break;we={type:"timed-metadata",data:q.subarray(pe,pe+ne)},this.trigger("data",we),pe+=ne;continue}else if((q[pe]&255)===255&&(q[pe+1]&240)===240){if(q.length-pe<7||(ne=Ua.parseAdtsSize(q,pe),pe+ne>q.length))break;Re={type:"audio",data:q.subarray(pe,pe+ne),pts:z,dts:z},this.trigger("data",Re),pe+=ne;continue}pe++}me=q.length-pe,me>0?q=q.subarray(pe):q=new Uint8Array},this.reset=function(){q=new Uint8Array,this.trigger("reset")},this.endTimeline=function(){q=new Uint8Array,this.trigger("endedtimeline")}},bn.prototype=new n;var Ba=bn,zo=gt.H264Stream,qn=Ua.isLikelyAacData,ea=oi.ONE_SECOND_IN_TS,ha=["audioobjecttype","channelcount","samplerate","samplingfrequencyindex","samplesize"],ho=["width","height","profileIdc","levelIdc","profileCompatibility","sarRatio"],Ls,pa,po,ga,Jl=function(q,z){var ie;if(q.length!==z.length)return!1;for(ie=0;ie<q.length;ie++)if(q[ie]!==z[ie])return!1;return!0},ta=function(q,z,ie,ne,pe,me){var we=ie-z,Re=ne-z,Ve=pe-ie;return{start:{dts:q,pts:q+we},end:{dts:q+Re,pts:q+Ve},prependedContentDuration:me,baseMediaDecodeTime:q}};pa=function(q,z){var ie=[],ne=0,pe=0,me=0,we=1/0;z=z||{},pa.prototype.init.call(this),this.push=function(Re){Si.collectDtsInfo(q,Re),q&&ha.forEach(function(Ve){q[Ve]=Re[Ve]}),ie.push(Re)},this.setEarliestDts=function(Re){pe=Re-q.timelineStartInfo.baseMediaDecodeTime},this.setVideoBaseMediaDecodeTime=function(Re){we=Re},this.setAudioAppendStart=function(Re){me=Re},this.flush=function(){var Re,Ve,st,Ft,er;if(ie.length===0){this.trigger("done","AudioSegmentStream");return}Re=$n.trimAdtsFramesByEarliestDts(ie,q,pe),q.baseMediaDecodeTime=Si.calculateTrackBaseMediaDecodeTime(q,z.keepOriginalTimestamps),$n.prefixWithSilence(q,Re,me,we),q.samples=$n.generateSampleTable(Re),st=Ne.mdat($n.concatenateFrameData(Re)),ie=[],Ve=Ne.moof(ne,[q]),Ft=new Uint8Array(Ve.byteLength+st.byteLength),ne++,Ft.set(Ve),Ft.set(st,Ve.byteLength),Si.clearDtsInfo(q),er=Math.ceil(ea*1024/q.samplerate),Re.length&&this.trigger("timingInfo",{start:Re[0].dts,end:Re[0].dts+Re.length*er}),this.trigger("data",{track:q,boxes:Ft}),this.trigger("done","AudioSegmentStream")},this.reset=function(){Si.clearDtsInfo(q),ie=[],this.trigger("reset")}},pa.prototype=new n,Ls=function(q,z){var ie=0,ne=[],pe=[],me,we;z=z||{},Ls.prototype.init.call(this),delete q.minPTS,this.gopCache_=[],this.push=function(Re){Si.collectDtsInfo(q,Re),Re.nalUnitType==="seq_parameter_set_rbsp"&&!me&&(me=Re.config,q.sps=[Re.data],ho.forEach(function(Ve){q[Ve]=me[Ve]},this)),Re.nalUnitType==="pic_parameter_set_rbsp"&&!we&&(we=Re.data,q.pps=[Re.data]),ne.push(Re)},this.flush=function(){for(var Re,Ve,st,Ft,er,nr,br=0,kr,Dt;ne.length&&ne[0].nalUnitType!=="access_unit_delimiter_rbsp";)ne.shift();if(ne.length===0){this.resetStream_(),this.trigger("done","VideoSegmentStream");return}if(Re=Tt.groupNalsIntoFrames(ne),st=Tt.groupFramesIntoGops(Re),st[0][0].keyFrame||(Ve=this.getGopForFusion_(ne[0],q),Ve?(br=Ve.duration,st.unshift(Ve),st.byteLength+=Ve.byteLength,st.nalCount+=Ve.nalCount,st.pts=Ve.pts,st.dts=Ve.dts,st.duration+=Ve.duration):st=Tt.extendFirstKeyFrame(st)),pe.length){var Li;if(z.alignGopsAtEnd?Li=this.alignGopsAtEnd_(st):Li=this.alignGopsAtStart_(st),!Li){this.gopCache_.unshift({gop:st.pop(),pps:q.pps,sps:q.sps}),this.gopCache_.length=Math.min(6,this.gopCache_.length),ne=[],this.resetStream_(),this.trigger("done","VideoSegmentStream");return}Si.clearDtsInfo(q),st=Li}Si.collectDtsInfo(q,st),q.samples=Tt.generateSampleTable(st),er=Ne.mdat(Tt.concatenateNalData(st)),q.baseMediaDecodeTime=Si.calculateTrackBaseMediaDecodeTime(q,z.keepOriginalTimestamps),this.trigger("processedGopsInfo",st.map(function(Wn){return{pts:Wn.pts,dts:Wn.dts,byteLength:Wn.byteLength}})),kr=st[0],Dt=st[st.length-1],this.trigger("segmentTimingInfo",ta(q.baseMediaDecodeTime,kr.dts,kr.pts,Dt.dts+Dt.duration,Dt.pts+Dt.duration,br)),this.trigger("timingInfo",{start:st[0].dts,end:st[st.length-1].dts+st[st.length-1].duration}),this.gopCache_.unshift({gop:st.pop(),pps:q.pps,sps:q.sps}),this.gopCache_.length=Math.min(6,this.gopCache_.length),ne=[],this.trigger("baseMediaDecodeTime",q.baseMediaDecodeTime),this.trigger("timelineStartInfo",q.timelineStartInfo),Ft=Ne.moof(ie,[q]),nr=new Uint8Array(Ft.byteLength+er.byteLength),ie++,nr.set(Ft),nr.set(er,Ft.byteLength),this.trigger("data",{track:q,boxes:nr}),this.resetStream_(),this.trigger("done","VideoSegmentStream")},this.reset=function(){this.resetStream_(),ne=[],this.gopCache_.length=0,pe.length=0,this.trigger("reset")},this.resetStream_=function(){Si.clearDtsInfo(q),me=void 0,we=void 0},this.getGopForFusion_=function(Re){var Ve=45e3,st=1e4,Ft=1/0,er,nr,br,kr,Dt;for(Dt=0;Dt<this.gopCache_.length;Dt++)kr=this.gopCache_[Dt],br=kr.gop,!(!(q.pps&&Jl(q.pps[0],kr.pps[0]))||!(q.sps&&Jl(q.sps[0],kr.sps[0])))&&(br.dts<q.timelineStartInfo.dts||(er=Re.dts-br.dts-br.duration,er>=-st&&er<=Ve&&(!nr||Ft>er)&&(nr=kr,Ft=er)));return nr?nr.gop:null},this.alignGopsAtStart_=function(Re){var Ve,st,Ft,er,nr,br,kr,Dt;for(nr=Re.byteLength,br=Re.nalCount,kr=Re.duration,Ve=st=0;Ve<pe.length&&st<Re.length&&(Ft=pe[Ve],er=Re[st],Ft.pts!==er.pts);){if(er.pts>Ft.pts){Ve++;continue}st++,nr-=er.byteLength,br-=er.nalCount,kr-=er.duration}return st===0?Re:st===Re.length?null:(Dt=Re.slice(st),Dt.byteLength=nr,Dt.duration=kr,Dt.nalCount=br,Dt.pts=Dt[0].pts,Dt.dts=Dt[0].dts,Dt)},this.alignGopsAtEnd_=function(Re){var Ve,st,Ft,er,nr,br;for(Ve=pe.length-1,st=Re.length-1,nr=null,br=!1;Ve>=0&&st>=0;){if(Ft=pe[Ve],er=Re[st],Ft.pts===er.pts){br=!0;break}if(Ft.pts>er.pts){Ve--;continue}Ve===pe.length-1&&(nr=st),st--}if(!br&&nr===null)return null;var kr;if(br?kr=st:kr=nr,kr===0)return Re;var Dt=Re.slice(kr),Li=Dt.reduce(function(Wn,Ms){return Wn.byteLength+=Ms.byteLength,Wn.duration+=Ms.duration,Wn.nalCount+=Ms.nalCount,Wn},{byteLength:0,duration:0,nalCount:0});return Dt.byteLength=Li.byteLength,Dt.duration=Li.duration,Dt.nalCount=Li.nalCount,Dt.pts=Dt[0].pts,Dt.dts=Dt[0].dts,Dt},this.alignGopsWith=function(Re){pe=Re}},Ls.prototype=new n,ga=function(q,z){this.numberOfTracks=0,this.metadataStream=z,q=q||{},typeof q.remux<"u"?this.remuxTracks=!!q.remux:this.remuxTracks=!0,typeof q.keepOriginalTimestamps=="boolean"?this.keepOriginalTimestamps=q.keepOriginalTimestamps:this.keepOriginalTimestamps=!1,this.pendingTracks=[],this.videoTrack=null,this.pendingBoxes=[],this.pendingCaptions=[],this.pendingMetadata=[],this.pendingBytes=0,this.emittedTracks=0,ga.prototype.init.call(this),this.push=function(ie){if(ie.text)return this.pendingCaptions.push(ie);if(ie.frames)return this.pendingMetadata.push(ie);this.pendingTracks.push(ie.track),this.pendingBytes+=ie.boxes.byteLength,ie.track.type==="video"&&(this.videoTrack=ie.track,this.pendingBoxes.push(ie.boxes)),ie.track.type==="audio"&&(this.audioTrack=ie.track,this.pendingBoxes.unshift(ie.boxes))}},ga.prototype=new n,ga.prototype.flush=function(xe){var q=0,z={captions:[],captionStreams:{},metadata:[],info:{}},ie,ne,pe,me=0,we;if(this.pendingTracks.length<this.numberOfTracks){if(xe!=="VideoSegmentStream"&&xe!=="AudioSegmentStream")return;if(this.remuxTracks)return;if(this.pendingTracks.length===0){this.emittedTracks++,this.emittedTracks>=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0);return}}if(this.videoTrack?(me=this.videoTrack.timelineStartInfo.pts,ho.forEach(function(Re){z.info[Re]=this.videoTrack[Re]},this)):this.audioTrack&&(me=this.audioTrack.timelineStartInfo.pts,ha.forEach(function(Re){z.info[Re]=this.audioTrack[Re]},this)),this.videoTrack||this.audioTrack){for(this.pendingTracks.length===1?z.type=this.pendingTracks[0].type:z.type="combined",this.emittedTracks+=this.pendingTracks.length,pe=Ne.initSegment(this.pendingTracks),z.initSegment=new Uint8Array(pe.byteLength),z.initSegment.set(pe),z.data=new Uint8Array(this.pendingBytes),we=0;we<this.pendingBoxes.length;we++)z.data.set(this.pendingBoxes[we],q),q+=this.pendingBoxes[we].byteLength;for(we=0;we<this.pendingCaptions.length;we++)ie=this.pendingCaptions[we],ie.startTime=oi.metadataTsToSeconds(ie.startPts,me,this.keepOriginalTimestamps),ie.endTime=oi.metadataTsToSeconds(ie.endPts,me,this.keepOriginalTimestamps),z.captionStreams[ie.stream]=!0,z.captions.push(ie);for(we=0;we<this.pendingMetadata.length;we++)ne=this.pendingMetadata[we],ne.cueTime=oi.metadataTsToSeconds(ne.pts,me,this.keepOriginalTimestamps),z.metadata.push(ne);for(z.metadata.dispatchType=this.metadataStream.dispatchType,this.pendingTracks.length=0,this.videoTrack=null,this.pendingBoxes.length=0,this.pendingCaptions.length=0,this.pendingBytes=0,this.pendingMetadata.length=0,this.trigger("data",z),we=0;we<z.captions.length;we++)ie=z.captions[we],this.trigger("caption",ie);for(we=0;we<z.metadata.length;we++)ne=z.metadata[we],this.trigger("id3Frame",ne)}this.emittedTracks>=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0)},ga.prototype.setRemux=function(xe){this.remuxTracks=xe},po=function(q){var z=this,ie=!0,ne,pe;po.prototype.init.call(this),q=q||{},this.baseMediaDecodeTime=q.baseMediaDecodeTime||0,this.transmuxPipeline_={},this.setupAacPipeline=function(){var me={};this.transmuxPipeline_=me,me.type="aac",me.metadataStream=new Vn.MetadataStream,me.aacStream=new Ba,me.audioTimestampRolloverStream=new Vn.TimestampRolloverStream("audio"),me.timedMetadataTimestampRolloverStream=new Vn.TimestampRolloverStream("timed-metadata"),me.adtsStream=new ge,me.coalesceStream=new ga(q,me.metadataStream),me.headOfPipeline=me.aacStream,me.aacStream.pipe(me.audioTimestampRolloverStream).pipe(me.adtsStream),me.aacStream.pipe(me.timedMetadataTimestampRolloverStream).pipe(me.metadataStream).pipe(me.coalesceStream),me.metadataStream.on("timestamp",function(we){me.aacStream.setTimestamp(we.timeStamp)}),me.aacStream.on("data",function(we){we.type==="timed-metadata"&&!me.audioSegmentStream&&(pe=pe||{timelineStartInfo:{baseMediaDecodeTime:z.baseMediaDecodeTime},codec:"adts",type:"audio"},me.coalesceStream.numberOfTracks++,me.audioSegmentStream=new pa(pe,q),me.audioSegmentStream.on("timingInfo",z.trigger.bind(z,"audioTimingInfo")),me.adtsStream.pipe(me.audioSegmentStream).pipe(me.coalesceStream)),z.trigger("trackinfo",{hasAudio:!!pe,hasVideo:!!ne})}),me.coalesceStream.on("data",this.trigger.bind(this,"data")),me.coalesceStream.on("done",this.trigger.bind(this,"done"))},this.setupTsPipeline=function(){var me={};this.transmuxPipeline_=me,me.type="ts",me.metadataStream=new Vn.MetadataStream,me.packetStream=new Vn.TransportPacketStream,me.parseStream=new Vn.TransportParseStream,me.elementaryStream=new Vn.ElementaryStream,me.timestampRolloverStream=new Vn.TimestampRolloverStream,me.adtsStream=new ge,me.h264Stream=new zo,me.captionStream=new Vn.CaptionStream,me.coalesceStream=new ga(q,me.metadataStream),me.headOfPipeline=me.packetStream,me.packetStream.pipe(me.parseStream).pipe(me.elementaryStream).pipe(me.timestampRolloverStream),me.timestampRolloverStream.pipe(me.h264Stream),me.timestampRolloverStream.pipe(me.adtsStream),me.timestampRolloverStream.pipe(me.metadataStream).pipe(me.coalesceStream),me.h264Stream.pipe(me.captionStream).pipe(me.coalesceStream),me.elementaryStream.on("data",function(we){var Re;if(we.type==="metadata"){for(Re=we.tracks.length;Re--;)!ne&&we.tracks[Re].type==="video"?(ne=we.tracks[Re],ne.timelineStartInfo.baseMediaDecodeTime=z.baseMediaDecodeTime):!pe&&we.tracks[Re].type==="audio"&&(pe=we.tracks[Re],pe.timelineStartInfo.baseMediaDecodeTime=z.baseMediaDecodeTime);ne&&!me.videoSegmentStream&&(me.coalesceStream.numberOfTracks++,me.videoSegmentStream=new Ls(ne,q),me.videoSegmentStream.on("timelineStartInfo",function(Ve){pe&&(pe.timelineStartInfo=Ve,me.audioSegmentStream.setEarliestDts(Ve.dts))}),me.videoSegmentStream.on("processedGopsInfo",z.trigger.bind(z,"gopInfo")),me.videoSegmentStream.on("segmentTimingInfo",z.trigger.bind(z,"videoSegmentTimingInfo")),me.videoSegmentStream.on("baseMediaDecodeTime",function(Ve){pe&&me.audioSegmentStream.setVideoBaseMediaDecodeTime(Ve)}),me.videoSegmentStream.on("timingInfo",z.trigger.bind(z,"videoTimingInfo")),me.h264Stream.pipe(me.videoSegmentStream).pipe(me.coalesceStream)),pe&&!me.audioSegmentStream&&(me.coalesceStream.numberOfTracks++,me.audioSegmentStream=new pa(pe,q),me.audioSegmentStream.on("timingInfo",z.trigger.bind(z,"audioTimingInfo")),me.adtsStream.pipe(me.audioSegmentStream).pipe(me.coalesceStream)),z.trigger("trackinfo",{hasAudio:!!pe,hasVideo:!!ne})}}),me.coalesceStream.on("data",this.trigger.bind(this,"data")),me.coalesceStream.on("id3Frame",function(we){we.dispatchType=me.metadataStream.dispatchType,z.trigger("id3Frame",we)}),me.coalesceStream.on("caption",this.trigger.bind(this,"caption")),me.coalesceStream.on("done",this.trigger.bind(this,"done"))},this.setBaseMediaDecodeTime=function(me){var we=this.transmuxPipeline_;q.keepOriginalTimestamps||(this.baseMediaDecodeTime=me),pe&&(pe.timelineStartInfo.dts=void 0,pe.timelineStartInfo.pts=void 0,Si.clearDtsInfo(pe),q.keepOriginalTimestamps||(pe.timelineStartInfo.baseMediaDecodeTime=me),we.audioTimestampRolloverStream&&we.audioTimestampRolloverStream.discontinuity()),ne&&(we.videoSegmentStream&&(we.videoSegmentStream.gopCache_=[]),ne.timelineStartInfo.dts=void 0,ne.timelineStartInfo.pts=void 0,Si.clearDtsInfo(ne),we.captionStream.reset(),q.keepOriginalTimestamps||(ne.timelineStartInfo.baseMediaDecodeTime=me)),we.timestampRolloverStream&&we.timestampRolloverStream.discontinuity()},this.setAudioAppendStart=function(me){pe&&this.transmuxPipeline_.audioSegmentStream.setAudioAppendStart(me)},this.setRemux=function(me){var we=this.transmuxPipeline_;q.remux=me,we&&we.coalesceStream&&we.coalesceStream.setRemux(me)},this.alignGopsWith=function(me){ne&&this.transmuxPipeline_.videoSegmentStream&&this.transmuxPipeline_.videoSegmentStream.alignGopsWith(me)},this.push=function(me){if(ie){var we=qn(me);we&&this.transmuxPipeline_.type!=="aac"?this.setupAacPipeline():!we&&this.transmuxPipeline_.type!=="ts"&&this.setupTsPipeline(),ie=!1}this.transmuxPipeline_.headOfPipeline.push(me)},this.flush=function(){ie=!0,this.transmuxPipeline_.headOfPipeline.flush()},this.endTimeline=function(){this.transmuxPipeline_.headOfPipeline.endTimeline()},this.reset=function(){this.transmuxPipeline_.headOfPipeline&&this.transmuxPipeline_.headOfPipeline.reset()},this.resetCaptions=function(){this.transmuxPipeline_.captionStream&&this.transmuxPipeline_.captionStream.reset()}},po.prototype=new n;var Is={Transmuxer:po,VideoSegmentStream:Ls,AudioSegmentStream:pa,AUDIO_PROPERTIES:ha,VIDEO_PROPERTIES:ho,generateVideoSegmentTimingInfo:ta},$u=function(q,z){if(!(q instanceof z))throw new TypeError("Cannot call a class as a function")},Xo=function(){function xe(q,z){for(var ie=0;ie<z.length;ie++){var ne=z[ie];ne.enumerable=ne.enumerable||!1,ne.configurable=!0,"value"in ne&&(ne.writable=!0),Object.defineProperty(q,ne.key,ne)}}return function(q,z,ie){return z&&xe(q.prototype,z),ie&&xe(q,ie),q}}(),Ql=function(q,z){z.on("data",function(ie){var ne=ie.initSegment;ie.initSegment={data:ne.buffer,byteOffset:ne.byteOffset,byteLength:ne.byteLength};var pe=ie.data;ie.data=pe.buffer,q.postMessage({action:"data",segment:ie,byteOffset:pe.byteOffset,byteLength:pe.byteLength},[ie.data])}),z.captionStream&&z.captionStream.on("data",function(ie){q.postMessage({action:"caption",data:ie})}),z.on("done",function(ie){q.postMessage({action:"done"})}),z.on("gopInfo",function(ie){q.postMessage({action:"gopInfo",gopInfo:ie})}),z.on("videoSegmentTimingInfo",function(ie){q.postMessage({action:"videoSegmentTimingInfo",videoSegmentTimingInfo:ie})})},Zl=function(){function xe(q,z){$u(this,xe),this.options=z||{},this.self=q,this.init()}return Xo(xe,[{key:"init",value:function(){this.transmuxer&&this.transmuxer.dispose(),this.transmuxer=new Is.Transmuxer(this.options),Ql(this.self,this.transmuxer)}},{key:"push",value:function(z){var ie=new Uint8Array(z.data,z.byteOffset,z.byteLength);this.transmuxer.push(ie)}},{key:"reset",value:function(){this.init()}},{key:"setTimestampOffset",value:function(z){var ie=z.timestampOffset||0;this.transmuxer.setBaseMediaDecodeTime(Math.round(ie*9e4))}},{key:"setAudioAppendStart",value:function(z){this.transmuxer.setAudioAppendStart(Math.ceil(z.appendStart*9e4))}},{key:"flush",value:function(z){this.transmuxer.flush()}},{key:"resetCaptions",value:function(){this.transmuxer.resetCaptions()}},{key:"alignGopsWith",value:function(z){this.transmuxer.alignGopsWith(z.gopsToAlignWith.slice())}}]),xe}(),sd=function(q){q.onmessage=function(z){if(z.data.action==="init"&&z.data.options){this.messageHandlers=new Zl(q,z.data.options);return}this.messageHandlers||(this.messageHandlers=new Zl(q)),z.data&&z.data.action&&z.data.action!=="init"&&this.messageHandlers[z.data.action]&&this.messageHandlers[z.data.action](z.data)}},od=new sd(i);return od})()}),D_={videoCodec:"avc1",videoObjectTypeIndicator:".4d400d",audioProfile:"2"},P_=function(r){return r.map(function(i){return i.replace(/avc1\.(\d+)\.(\d+)/i,function(t,n,a){var s=("00"+Number(n).toString(16)).slice(-2),o=("00"+Number(a).toString(16)).slice(-2);return"avc1."+s+"00"+o})})},Dc=function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",i={codecCount:0},t=void 0;return i.codecCount=r.split(",").length,i.codecCount=i.codecCount||2,t=/(^|\s|,)+(avc[13])([^ ,]*)/i.exec(r),t&&(i.videoCodec=t[2],i.videoObjectTypeIndicator=t[3]),i.audioProfile=/(^|\s|,)+mp4a.[0-9A-Fa-f]+\.([0-9A-Fa-f]+)/i.exec(r),i.audioProfile=i.audioProfile&&i.audioProfile[2],i},J1=function(r){return r.replace(/avc1\.(\d+)\.(\d+)/i,function(i){return P_([i])[0]})},rg=function(r,i,t){return r+"/"+i+'; codecs="'+t.filter(function(n){return!!n}).join(", ")+'"'},Q1=function(r){return r.segments&&r.segments.length&&r.segments[0].map?"mp4":"mp2t"},Z1=function(r){var i=r.attributes||{};return i.CODECS?Dc(i.CODECS):D_},ek=function(r,i){if(!r.mediaGroups.AUDIO||!i)return null;var t=r.mediaGroups.AUDIO[i];if(!t)return null;for(var n in t){var a=t[n];if(a.default&&a.playlists)return Dc(a.playlists[0].attributes.CODECS).audioProfile}return null},tk=function(r,i){var t=Q1(i),n=Z1(i),a=i.attributes||{},s=!0,o=!1;if(!i)return[];if(r.mediaGroups.AUDIO&&a.AUDIO){var l=r.mediaGroups.AUDIO[a.AUDIO];if(l){o=!0,s=!1;for(var u in l)if(!l[u].uri&&!l[u].playlists){s=!0;break}}}o&&!n.audioProfile&&(s||(n.audioProfile=ek(r,a.AUDIO)),n.audioProfile||(re.log.warn("Multiple audio tracks present but no audio codec string is specified. Attempting to use the default audio codec (mp4a.40.2)"),n.audioProfile=D_.audioProfile));var g={};n.videoCodec&&(g.video=""+n.videoCodec+n.videoObjectTypeIndicator),n.audioProfile&&(g.audio="mp4a.40."+n.audioProfile);var c=rg("audio",t,[g.audio]),d=rg("video",t,[g.video]),f=rg("video",t,[g.video,g.audio]);return o?!s&&g.video?[d,c]:!s&&!g.video?[c,c]:[f,c]:g.video?[f]:[c]},rk=function(r){var i={type:"",parameters:{}},t=r.trim().split(";");return i.type=t.shift().trim(),t.forEach(function(n){var a=n.trim().split("=");if(a.length>1){var s=a[0].replace(/"/g,"").trim(),o=a[1].replace(/"/g,"").trim();i.parameters[s]=o}}),i},O_=function(r){return/mp4a\.\d+.\d+/i.test(r)},L_=function(r){return/avc1\.[\da-f]+/i.test(r)},ik=function(r,i,t){if(typeof i>"u"||i===null||!r.length)return[];var n=Math.ceil((i-t+3)*9e4),a=void 0;for(a=0;a<r.length&&!(r[a].pts>n);a++);return r.slice(a)},nk=function(r,i,t){if(!i.length)return r;if(t)return i.slice();var n=i[0].pts,a=0;for(a;a<r.length&&!(r[a].pts>=n);a++);return r.slice(0,a).concat(i)},ak=function(r,i,t,n){for(var a=Math.ceil((i-n)*9e4),s=Math.ceil((t-n)*9e4),o=r.slice(),l=r.length;l--&&!(r[l].pts<=s););if(l===-1)return o;for(var u=l+1;u--&&!(r[u].pts<=a););return u=Math.max(u,0),o.splice(u,l-u+1),o},sk=function(r,i,t){var n=null,a=null,s=0,o=[],l=[];if(!r&&!i)return re.createTimeRange();if(!r)return i.buffered;if(!i||t)return r.buffered;if(r.buffered.length===0&&i.buffered.length===0)return re.createTimeRange();for(var u=r.buffered,g=i.buffered,c=u.length;c--;)o.push({time:u.start(c),type:"start"}),o.push({time:u.end(c),type:"end"});for(c=g.length;c--;)o.push({time:g.start(c),type:"start"}),o.push({time:g.end(c),type:"end"});for(o.sort(function(d,f){return d.time-f.time}),c=0;c<o.length;c++)o[c].type==="start"?(s++,s===2&&(n=o[c].time)):o[c].type==="end"&&(s--,s===1&&(a=o[c].time)),n!==null&&a!==null&&(l.push([n,a]),n=null,a=null);return re.createTimeRanges(l)},xl=9e4,ok=function(r,i){var t=r.addSourceBuffer(i),n=Object.create(null);n.updating=!1,n.realBuffer_=t;var a=function(l){typeof t[l]=="function"?n[l]=function(){return t[l].apply(t,arguments)}:typeof n[l]>"u"&&Object.defineProperty(n,l,{get:function(){return t[l]},set:function(g){return t[l]=g}})};for(var s in t)a(s);return n},uk=function(e){Gs(r,e);function r(i,t){Aa(this,r);var n=hs(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,re.EventTarget));n.timestampOffset_=0,n.pendingBuffers_=[],n.bufferUpdating_=!1,n.mediaSource_=i,n.codecs_=t,n.audioCodec_=null,n.videoCodec_=null,n.audioDisabled_=!1,n.appendAudioInitSegment_=!0,n.gopBuffer_=[],n.timeMapping_=0,n.safeAppend_=re.browser.IE_VERSION>=11;var a={remux:!1,alignGopsAtEnd:n.safeAppend_};return n.codecs_.forEach(function(s){O_(s)?n.audioCodec_=s:L_(s)&&(n.videoCodec_=s)}),n.transmuxer_=new X1,n.transmuxer_.postMessage({action:"init",options:a}),n.transmuxer_.onmessage=function(s){if(s.data.action==="data")return n.data_(s);if(s.data.action==="done")return n.done_(s);if(s.data.action==="gopInfo")return n.appendGopInfo_(s);if(s.data.action==="videoSegmentTimingInfo")return n.videoSegmentTimingInfo_(s.data.videoSegmentTimingInfo)},Object.defineProperty(n,"timestampOffset",{get:function(){return this.timestampOffset_},set:function(o){typeof o=="number"&&o>=0&&(this.timestampOffset_=o,this.appendAudioInitSegment_=!0,this.gopBuffer_.length=0,this.timeMapping_=0,this.transmuxer_.postMessage({action:"setTimestampOffset",timestampOffset:o}))}}),Object.defineProperty(n,"appendWindowStart",{get:function(){return(this.videoBuffer_||this.audioBuffer_).appendWindowStart},set:function(o){this.videoBuffer_&&(this.videoBuffer_.appendWindowStart=o),this.audioBuffer_&&(this.audioBuffer_.appendWindowStart=o)}}),Object.defineProperty(n,"updating",{get:function(){return!!(this.bufferUpdating_||!this.audioDisabled_&&this.audioBuffer_&&this.audioBuffer_.updating||this.videoBuffer_&&this.videoBuffer_.updating)}}),Object.defineProperty(n,"buffered",{get:function(){return sk(this.videoBuffer_,this.audioBuffer_,this.audioDisabled_)}}),n}return Va(r,[{key:"data_",value:function(t){var n=t.data.segment;n.data=new Uint8Array(n.data,t.data.byteOffset,t.data.byteLength),n.initSegment=new Uint8Array(n.initSegment.data,n.initSegment.byteOffset,n.initSegment.byteLength),V1(this,this.mediaSource_,n),this.pendingBuffers_.push(n)}},{key:"done_",value:function(t){if(this.mediaSource_.readyState==="closed"){this.pendingBuffers_.length=0;return}this.processPendingSegments_()}},{key:"videoSegmentTimingInfo_",value:function(t){var n={start:{decode:t.start.dts/xl,presentation:t.start.pts/xl},end:{decode:t.end.dts/xl,presentation:t.end.pts/xl},baseMediaDecodeTime:t.baseMediaDecodeTime/xl};t.prependedContentDuration&&(n.prependedContentDuration=t.prependedContentDuration/xl),this.trigger({type:"videoSegmentTimingInfo",videoSegmentTimingInfo:n})}},{key:"createRealSourceBuffers_",value:function(){var t=this,n=["audio","video"];n.forEach(function(a){if(!!t[a+"Codec_"]&&!t[a+"Buffer_"]){var s=null;if(t.mediaSource_[a+"Buffer_"])s=t.mediaSource_[a+"Buffer_"],s.updating=!1;else{var o=a+"Codec_",l=a+'/mp4;codecs="'+t[o]+'"';s=ok(t.mediaSource_.nativeMediaSource_,l),t.mediaSource_[a+"Buffer_"]=s}t[a+"Buffer_"]=s,["update","updatestart","updateend"].forEach(function(u){s.addEventListener(u,function(){if(!(a==="audio"&&t.audioDisabled_)){u==="updateend"&&(t[a+"Buffer_"].updating=!1);var g=n.every(function(c){return c==="audio"&&t.audioDisabled_?!0:!(a!==c&&t[c+"Buffer_"]&&t[c+"Buffer_"].updating)});if(g)return t.trigger(u)}})})}})}},{key:"appendBuffer",value:function(t){if(this.bufferUpdating_=!0,this.audioBuffer_&&this.audioBuffer_.buffered.length){var n=this.audioBuffer_.buffered;this.transmuxer_.postMessage({action:"setAudioAppendStart",appendStart:n.end(n.length-1)})}this.videoBuffer_&&this.transmuxer_.postMessage({action:"alignGopsWith",gopsToAlignWith:ik(this.gopBuffer_,this.mediaSource_.player_?this.mediaSource_.player_.currentTime():null,this.timeMapping_)}),this.transmuxer_.postMessage({action:"push",data:t.buffer,byteOffset:t.byteOffset,byteLength:t.byteLength},[t.buffer]),this.transmuxer_.postMessage({action:"flush"})}},{key:"appendGopInfo_",value:function(t){this.gopBuffer_=nk(this.gopBuffer_,t.data.gopInfo,this.safeAppend_)}},{key:"remove",value:function(t,n){if(this.videoBuffer_&&(this.videoBuffer_.updating=!0,this.videoBuffer_.remove(t,n),this.gopBuffer_=ak(this.gopBuffer_,t,n,this.timeMapping_)),!this.audioDisabled_&&this.audioBuffer_&&(this.audioBuffer_.updating=!0,this.audioBuffer_.remove(t,n)),Tl(t,n,this.metadataTrack_),this.inbandTextTracks_)for(var a in this.inbandTextTracks_)Tl(t,n,this.inbandTextTracks_[a])}},{key:"processPendingSegments_",value:function(){var t={video:{segments:[],bytes:0},audio:{segments:[],bytes:0},captions:[],metadata:[]};if(!this.pendingBuffers_.length){this.trigger("updateend"),this.bufferUpdating_=!1;return}t=this.pendingBuffers_.reduce(function(a,s){var o=s.type,l=s.data,u=s.initSegment;return a[o].segments.push(l),a[o].bytes+=l.byteLength,a[o].initSegment=u,s.captions&&(a.captions=a.captions.concat(s.captions)),s.info&&(a[o].info=s.info),s.metadata&&(a.metadata=a.metadata.concat(s.metadata)),a},t),!this.videoBuffer_&&!this.audioBuffer_&&(t.video.bytes===0&&(this.videoCodec_=null),t.audio.bytes===0&&(this.audioCodec_=null),this.createRealSourceBuffers_()),t.audio.info&&this.mediaSource_.trigger({type:"audioinfo",info:t.audio.info}),t.video.info&&this.mediaSource_.trigger({type:"videoinfo",info:t.video.info}),this.appendAudioInitSegment_&&(!this.audioDisabled_&&this.audioBuffer_&&(t.audio.segments.unshift(t.audio.initSegment),t.audio.bytes+=t.audio.initSegment.byteLength),this.appendAudioInitSegment_=!1);var n=!1;this.videoBuffer_&&t.video.bytes?(t.video.segments.unshift(t.video.initSegment),t.video.bytes+=t.video.initSegment.byteLength,this.concatAndAppendSegments_(t.video,this.videoBuffer_)):this.videoBuffer_&&(this.audioDisabled_||!this.audioBuffer_)&&(n=!0),W1(this,t.captions,t.metadata),!this.audioDisabled_&&this.audioBuffer_&&this.concatAndAppendSegments_(t.audio,this.audioBuffer_),this.pendingBuffers_.length=0,n&&this.trigger("updateend"),this.bufferUpdating_=!1}},{key:"concatAndAppendSegments_",value:function(t,n){var a=0,s=void 0;if(t.bytes){s=new Uint8Array(t.bytes),t.segments.forEach(function(o){s.set(o,a),a+=o.byteLength});try{n.updating=!0,n.appendBuffer(s)}catch(o){this.mediaSource_.player_&&this.mediaSource_.player_.error({code:-3,type:"APPEND_BUFFER_ERR",message:o.message,originalError:o})}}}},{key:"abort",value:function(){this.videoBuffer_&&this.videoBuffer_.abort(),!this.audioDisabled_&&this.audioBuffer_&&this.audioBuffer_.abort(),this.transmuxer_&&this.transmuxer_.postMessage({action:"reset"}),this.pendingBuffers_.length=0,this.bufferUpdating_=!1}}]),r}(re.EventTarget),ig=function(e){Gs(r,e);function r(){Aa(this,r);var i=hs(this,(r.__proto__||Object.getPrototypeOf(r)).call(this)),t=void 0;i.nativeMediaSource_=new Be.MediaSource;for(t in i.nativeMediaSource_)!(t in r.prototype)&&typeof i.nativeMediaSource_[t]=="function"&&(i[t]=i.nativeMediaSource_[t].bind(i.nativeMediaSource_));return i.duration_=NaN,Object.defineProperty(i,"duration",{get:function(){return this.duration_===1/0?this.duration_:this.nativeMediaSource_.duration},set:function(a){if(this.duration_=a,a!==1/0){this.nativeMediaSource_.duration=a;return}}}),Object.defineProperty(i,"seekable",{get:function(){return this.duration_===1/0?re.createTimeRanges([[0,this.nativeMediaSource_.duration]]):this.nativeMediaSource_.seekable}}),Object.defineProperty(i,"readyState",{get:function(){return this.nativeMediaSource_.readyState}}),Object.defineProperty(i,"activeSourceBuffers",{get:function(){return this.activeSourceBuffers_}}),i.sourceBuffers=[],i.activeSourceBuffers_=[],i.updateActiveSourceBuffers_=function(){if(i.activeSourceBuffers_.length=0,i.sourceBuffers.length===1){var n=i.sourceBuffers[0];n.appendAudioInitSegment_=!0,n.audioDisabled_=!n.audioCodec_,i.activeSourceBuffers_.push(n);return}for(var a=!1,s=!0,o=0;o<i.player_.audioTracks().length;o++){var l=i.player_.audioTracks()[o];if(l.enabled&&l.kind!=="main"){a=!0,s=!1;break}}i.sourceBuffers.forEach(function(u,g){if(u.appendAudioInitSegment_=!0,u.videoCodec_&&u.audioCodec_)u.audioDisabled_=a;else if(u.videoCodec_&&!u.audioCodec_)u.audioDisabled_=!0,s=!1;else if(!u.videoCodec_&&u.audioCodec_&&(u.audioDisabled_=g?s:!s,u.audioDisabled_))return;i.activeSourceBuffers_.push(u)})},i.onPlayerMediachange_=function(){i.sourceBuffers.forEach(function(n){n.appendAudioInitSegment_=!0})},i.onHlsReset_=function(){i.sourceBuffers.forEach(function(n){n.transmuxer_&&n.transmuxer_.postMessage({action:"resetCaptions"})})},i.onHlsSegmentTimeMapping_=function(n){i.sourceBuffers.forEach(function(a){return a.timeMapping_=n.mapping})},["sourceopen","sourceclose","sourceended"].forEach(function(n){this.nativeMediaSource_.addEventListener(n,this.trigger.bind(this))},i),i.on("sourceopen",function(n){var a=Mt.querySelector('[src="'+i.url_+'"]');!a||(i.player_=re(a.parentNode),i.player_&&(i.player_.tech_.on("hls-reset",i.onHlsReset_),i.player_.tech_.on("hls-segment-time-mapping",i.onHlsSegmentTimeMapping_),i.player_.audioTracks&&i.player_.audioTracks()&&(i.player_.audioTracks().on("change",i.updateActiveSourceBuffers_),i.player_.audioTracks().on("addtrack",i.updateActiveSourceBuffers_),i.player_.audioTracks().on("removetrack",i.updateActiveSourceBuffers_)),i.player_.on("mediachange",i.onPlayerMediachange_)))}),i.on("sourceended",function(n){for(var a=w_(i.duration),s=0;s<i.sourceBuffers.length;s++){var o=i.sourceBuffers[s],l=o.metadataTrack_&&o.metadataTrack_.cues;l&&l.length&&(l[l.length-1].endTime=a)}}),i.on("sourceclose",function(n){this.sourceBuffers.forEach(function(a){a.transmuxer_&&a.transmuxer_.terminate()}),this.sourceBuffers.length=0,this.player_&&(this.player_.audioTracks&&this.player_.audioTracks()&&(this.player_.audioTracks().off("change",this.updateActiveSourceBuffers_),this.player_.audioTracks().off("addtrack",this.updateActiveSourceBuffers_),this.player_.audioTracks().off("removetrack",this.updateActiveSourceBuffers_)),this.player_.el_&&this.player_.off("mediachange",this.onPlayerMediachange_),this.player_.tech_&&this.player_.tech_.el_&&(this.player_.tech_.off("hls-reset",this.onHlsReset_),this.player_.tech_.off("hls-segment-time-mapping",this.onHlsSegmentTimeMapping_)))}),i}return Va(r,[{key:"addSeekableRange_",value:function(t,n){var a=void 0;if(this.duration!==1/0)throw a=new Error("MediaSource.addSeekableRange() can only be invoked when the duration is Infinity"),a.name="InvalidStateError",a.code=11,a;(n>this.nativeMediaSource_.duration||isNaN(this.nativeMediaSource_.duration))&&(this.nativeMediaSource_.duration=n)}},{key:"addSourceBuffer",value:function(t){var n=void 0,a=rk(t);if(/^(video|audio)\/mp2t$/i.test(a.type)){var s=[];a.parameters&&a.parameters.codecs&&(s=a.parameters.codecs.split(","),s=P_(s),s=s.filter(function(o){return O_(o)||L_(o)})),s.length===0&&(s=["avc1.4d400d","mp4a.40.2"]),n=new uk(this,s),this.sourceBuffers.length!==0&&(this.sourceBuffers[0].createRealSourceBuffers_(),n.createRealSourceBuffers_(),this.sourceBuffers[0].audioDisabled_=!0)}else n=this.nativeMediaSource_.addSourceBuffer(t);return this.sourceBuffers.push(n),n}}]),r}(re.EventTarget),I_=0;re.mediaSources={};var M_=function(r,i){var t=re.mediaSources[r];if(t)t.trigger({type:"sourceopen",swfId:i});else throw new Error("Media Source not found (Video.js)")},ng=function(){return!!Be.MediaSource&&!!Be.MediaSource.isTypeSupported&&Be.MediaSource.isTypeSupported('video/mp4;codecs="avc1.4d400d,mp4a.40.2"')},Pc=function(){if(this.MediaSource={open:M_,supportsNativeMediaSources:ng},ng())return new ig;throw new Error("Cannot use create a virtual MediaSource for this video")};Pc.open=M_,Pc.supportsNativeMediaSources=ng;var N_={createObjectURL:function(r){var i="blob:vjs-media-source/",t=void 0;return r instanceof ig?(t=Be.URL.createObjectURL(r.nativeMediaSource_),r.url_=t,t):r instanceof ig?(t=i+I_,I_++,re.mediaSources[t]=r,t):(t=Be.URL.createObjectURL(r),r.url_=t,t)}};re.MediaSource=Pc,re.URL=N_;var lk=re.EventTarget,F_=re.mergeOptions,U_=function(r,i){for(var t=void 0,n=F_(r,{duration:i.duration,minimumUpdatePeriod:i.minimumUpdatePeriod}),a=0;a<i.playlists.length;a++){var s=Xp(n,i.playlists[a]);s?n=s:t=!0}return zd(i,function(o,l,u,g){if(o.playlists&&o.playlists.length){var c=o.playlists[0].uri,d=Xp(n,o.playlists[0]);d&&(n=d,n.mediaGroups[l][u][g].playlists[0]=n.playlists[c],t=!1)}}),t?null:n},ag=function(r){var i=r.byterange.offset+r.byterange.length-1;return r.uri+"-"+r.byterange.offset+"-"+i},ck=function(r,i){var t=Boolean(!r.map&&!i.map),n=t||Boolean(r.map&&i.map&&r.map.byterange.offset===i.map.byterange.offset&&r.map.byterange.length===i.map.byterange.length);return n&&r.uri===i.uri&&r.byterange.offset===i.byterange.offset&&r.byterange.length===i.byterange.length},B_=function(r,i){var t={};for(var n in r){var a=r[n],s=a.sidx;if(s){var o=ag(s);if(!i[o])break;var l=i[o].sidxInfo;ck(l,s)&&(t[o]=i[o])}}return t},dk=function(r,i,t,n){var a=Xm(r,{manifestUri:i,clientOffset:t}),s=B_(a.playlists,n),o=s;return zd(a,function(l,u,g,c){if(l.playlists&&l.playlists.length){var d=l.playlists;o=F_(o,B_(d,n))}}),o},j_=function(r,i,t,n,a){var s={uri:Kd(n.handleManifestRedirects,r.resolvedUri),byterange:r.byterange,playlist:i},o=re.mergeOptions(s,{responseType:"arraybuffer",headers:Zp(s)});return t(o,a)},sg=function(e){Gs(r,e);function r(i,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a=arguments[3];Aa(this,r);var s=hs(this,(r.__proto__||Object.getPrototypeOf(r)).call(this)),o=n.withCredentials,l=o===void 0?!1:o,u=n.handleManifestRedirects,g=u===void 0?!1:u;if(s.hls_=t,s.withCredentials=l,s.handleManifestRedirects=g,!i)throw new Error("A non-empty playlist URL or playlist is required");return s.on("minimumUpdatePeriod",function(){s.refreshXml_()}),s.on("mediaupdatetimeout",function(){s.refreshMedia_(s.media().uri)}),s.state="HAVE_NOTHING",s.loadedPlaylists_={},typeof i=="string"?(s.srcUrl=i,s.sidxMapping_={},hs(s)):(s.setupChildLoader(a,i),s)}return Va(r,[{key:"setupChildLoader",value:function(t,n){this.masterPlaylistLoader_=t,this.childPlaylist_=n}},{key:"dispose",value:function(){this.stopRequest(),this.loadedPlaylists_={},Be.clearTimeout(this.minimumUpdatePeriodTimeout_),Be.clearTimeout(this.mediaRequest_),Be.clearTimeout(this.mediaUpdateTimeout)}},{key:"hasPendingRequest",value:function(){return this.request||this.mediaRequest_}},{key:"stopRequest",value:function(){if(this.request){var t=this.request;this.request=null,t.onreadystatechange=null,t.abort()}}},{key:"sidxRequestFinished_",value:function(t,n,a,s){var o=this;return function(l,u){if(!!o.request){if(o.request=null,l)return o.error={status:u.status,message:"DASH playlist request error at URL: "+t.uri,response:u.response,code:2},a&&(o.state=a),o.trigger("error"),s(n,null);var g=new Uint8Array(u.response),c=iy.parseSidx(g.subarray(8));return s(n,c)}}}},{key:"media",value:function(t){var n=this;if(!t)return this.media_;if(this.state==="HAVE_NOTHING")throw new Error("Cannot switch media playlist from "+this.state);var a=this.state;if(typeof t=="string"){if(!this.master.playlists[t])throw new Error("Unknown playlist URI: "+t);t=this.master.playlists[t]}var s=!this.media_||t.uri!==this.media_.uri;if(s&&this.loadedPlaylists_[t.uri]&&this.loadedPlaylists_[t.uri].endList){this.state="HAVE_METADATA",this.media_=t,s&&(this.trigger("mediachanging"),this.trigger("mediachange"));return}if(!!s){if(this.media_&&this.trigger("mediachanging"),!t.sidx){this.mediaRequest_=Be.setTimeout(this.haveMetadata.bind(this,{startingState:a,playlist:t}),0);return}var o=void 0,l=void 0;this.masterPlaylistLoader_?(o=this.masterPlaylistLoader_.master,l=this.masterPlaylistLoader_.sidxMapping_):(o=this.master,l=this.sidxMapping_);var u=ag(t.sidx);l[u]={sidxInfo:t.sidx},this.request=j_(t.sidx,t,this.hls_.xhr,{handleManifestRedirects:this.handleManifestRedirects},this.sidxRequestFinished_(t,o,a,function(g,c){if(!g||!c)throw new Error("failed to request sidx");l[u].sidx=c,n.haveMetadata({startingState:a,playlist:g.playlists[t.uri]})}))}}},{key:"haveMetadata",value:function(t){var n=t.startingState,a=t.playlist;this.state="HAVE_METADATA",this.loadedPlaylists_[a.uri]=a,this.mediaRequest_=null,this.refreshMedia_(a.uri),n==="HAVE_MASTER"?this.trigger("loadedmetadata"):this.trigger("mediachange")}},{key:"pause",value:function(){this.stopRequest(),Be.clearTimeout(this.mediaUpdateTimeout),Be.clearTimeout(this.minimumUpdatePeriodTimeout_),this.state==="HAVE_NOTHING"&&(this.started=!1)}},{key:"load",value:function(t){var n=this;Be.clearTimeout(this.mediaUpdateTimeout),Be.clearTimeout(this.minimumUpdatePeriodTimeout_);var a=this.media();if(t){var s=a?a.targetDuration/2*1e3:5e3;this.mediaUpdateTimeout=Be.setTimeout(function(){return n.load()},s);return}if(!this.started){this.start();return}this.trigger("loadedplaylist")}},{key:"parseMasterXml",value:function(){var t=Xm(this.masterXml_,{manifestUri:this.srcUrl,clientOffset:this.clientOffset_,sidxMapping:this.sidxMapping_});t.uri=this.srcUrl;for(var n=0;n<t.playlists.length;n++){var a="placeholder-uri-"+n;t.playlists[n].uri=a,t.playlists[a]=t.playlists[n]}return zd(t,function(s,o,l,u){if(s.playlists&&s.playlists.length){var g="placeholder-uri-"+o+"-"+l+"-"+u;s.playlists[0].uri=g,t.playlists[g]=s.playlists[0]}}),n_(t),a_(t),t}},{key:"start",value:function(){var t=this;if(this.started=!0,this.masterPlaylistLoader_){this.mediaRequest_=Be.setTimeout(this.haveMaster_.bind(this),0);return}this.request=this.hls_.xhr({uri:this.srcUrl,withCredentials:this.withCredentials},function(n,a){if(!!t.request){if(t.request=null,n)return t.error={status:a.status,message:"DASH playlist request error at URL: "+t.srcUrl,responseText:a.responseText,code:2},t.state==="HAVE_NOTHING"&&(t.started=!1),t.trigger("error");t.masterXml_=a.responseText,a.responseHeaders&&a.responseHeaders.date?t.masterLoaded_=Date.parse(a.responseHeaders.date):t.masterLoaded_=Date.now(),t.srcUrl=Kd(t.handleManifestRedirects,t.srcUrl,a),t.syncClientServerClock_(t.onClientServerClockSync_.bind(t))}})}},{key:"syncClientServerClock_",value:function(t){var n=this,a=Mw(this.masterXml_);if(a===null)return this.clientOffset_=this.masterLoaded_-Date.now(),t();if(a.method==="DIRECT")return this.clientOffset_=a.value-Date.now(),t();this.request=this.hls_.xhr({uri:mu(this.srcUrl,a.value),method:a.method,withCredentials:this.withCredentials},function(s,o){if(!!n.request){if(s)return n.clientOffset_=n.masterLoaded_-Date.now(),t();var l=void 0;a.method==="HEAD"?!o.responseHeaders||!o.responseHeaders.date?l=n.masterLoaded_:l=Date.parse(o.responseHeaders.date):l=Date.parse(o.responseText),n.clientOffset_=l-Date.now(),t()}})}},{key:"haveMaster_",value:function(){this.state="HAVE_MASTER",this.mediaRequest_=null,this.masterPlaylistLoader_?this.media_||this.media(this.childPlaylist_):(this.master=this.parseMasterXml(),this.trigger("loadedplaylist"))}},{key:"onClientServerClockSync_",value:function(){var t=this;this.haveMaster_(),!this.hasPendingRequest()&&!this.media_&&this.media(this.master.playlists[0]),this.master&&this.master.minimumUpdatePeriod&&(this.minimumUpdatePeriodTimeout_=Be.setTimeout(function(){t.trigger("minimumUpdatePeriod")},this.master.minimumUpdatePeriod))}},{key:"refreshXml_",value:function(){var t=this;this.request=this.hls_.xhr({uri:this.srcUrl,withCredentials:this.withCredentials},function(n,a){if(!!t.request){if(t.request=null,n)return t.error={status:a.status,message:"DASH playlist request error at URL: "+t.srcUrl,responseText:a.responseText,code:2},t.state==="HAVE_NOTHING"&&(t.started=!1),t.trigger("error");t.masterXml_=a.responseText,t.sidxMapping_=dk(t.masterXml_,t.srcUrl,t.clientOffset_,t.sidxMapping_);var s=t.parseMasterXml(),o=U_(t.master,s),l=t.media().sidx;if(o)if(l){var u=ag(l);if(!t.sidxMapping_[u]){var g=t.media();t.request=j_(g.sidx,g,t.hls_.xhr,{handleManifestRedirects:t.handleManifestRedirects},t.sidxRequestFinished_(g,s,t.state,function(c,d){if(!c||!d)throw new Error("failed to request sidx on minimumUpdatePeriod");t.sidxMapping_[u].sidx=d,t.minimumUpdatePeriodTimeout_=Be.setTimeout(function(){t.trigger("minimumUpdatePeriod")},t.master.minimumUpdatePeriod),t.refreshMedia_(t.media().uri)}))}}else t.master=o;t.minimumUpdatePeriodTimeout_=Be.setTimeout(function(){t.trigger("minimumUpdatePeriod")},t.master.minimumUpdatePeriod)}})}},{key:"refreshMedia_",value:function(t){var n=this;if(!t)throw new Error("refreshMedia_ must take a media uri");var a=void 0,s=void 0;this.masterPlaylistLoader_?(a=this.masterPlaylistLoader_.master,s=this.masterPlaylistLoader_.parseMasterXml()):(a=this.master,s=this.parseMasterXml());var o=U_(a,s);o?(this.masterPlaylistLoader_?this.masterPlaylistLoader_.master=o:this.master=o,this.media_=o.playlists[t]):(this.media_=s.playlists[t],this.trigger("playlistunchanged")),this.media().endList||(this.mediaUpdateTimeout=Be.setTimeout(function(){n.trigger("mediaupdatetimeout")},s_(this.media(),!!o))),this.trigger("loadedplaylist")}}]),r}(lk),Oc=function(r){return re.log.debug?re.log.debug.bind(re,"VHS:",r+" >"):function(){}};function wl(){}var fk=function(){function e(r,i,t,n){Aa(this,e),this.callbacks_=[],this.pendingCallback_=null,this.timestampOffset_=0,this.mediaSource=r,this.processedAppend_=!1,this.type_=t,this.mimeType_=i,this.logger_=Oc("SourceUpdater["+t+"]["+i+"]"),r.readyState==="closed"?r.addEventListener("sourceopen",this.createSourceBuffer_.bind(this,i,n)):this.createSourceBuffer_(i,n)}return Va(e,[{key:"createSourceBuffer_",value:function(i,t){var n=this;if(this.sourceBuffer_=this.mediaSource.addSourceBuffer(i),this.logger_("created SourceBuffer"),t&&(t.trigger("sourcebufferadded"),this.mediaSource.sourceBuffers.length<2)){t.on("sourcebufferadded",function(){n.start_()});return}this.start_()}},{key:"start_",value:function(){var i=this;this.started_=!0,this.onUpdateendCallback_=function(){var t=i.pendingCallback_;i.pendingCallback_=null,i.sourceBuffer_.removing=!1,i.logger_("buffered ["+eg(i.buffered())+"]"),t&&t(),i.runCallback_()},this.sourceBuffer_.addEventListener("updateend",this.onUpdateendCallback_),this.runCallback_()}},{key:"abort",value:function(i){var t=this;this.processedAppend_&&this.queueCallback_(function(){t.sourceBuffer_.abort()},i)}},{key:"appendBuffer",value:function(i,t){var n=this;this.processedAppend_=!0,this.queueCallback_(function(){i.videoSegmentTimingInfoCallback&&n.sourceBuffer_.addEventListener("videoSegmentTimingInfo",i.videoSegmentTimingInfoCallback),n.sourceBuffer_.appendBuffer(i.bytes)},function(){i.videoSegmentTimingInfoCallback&&n.sourceBuffer_.removeEventListener("videoSegmentTimingInfo",i.videoSegmentTimingInfoCallback),t()})}},{key:"buffered",value:function(){return this.sourceBuffer_?this.sourceBuffer_.buffered:re.createTimeRanges()}},{key:"remove",value:function(i,t){var n=this,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:wl;this.processedAppend_&&this.queueCallback_(function(){n.logger_("remove ["+i+" => "+t+"]"),n.sourceBuffer_.removing=!0,n.sourceBuffer_.remove(i,t)},a)}},{key:"updating",value:function(){return!this.sourceBuffer_||this.sourceBuffer_.updating||!!this.pendingCallback_&&this.pendingCallback_!==wl}},{key:"timestampOffset",value:function(i){var t=this;return typeof i<"u"&&(this.queueCallback_(function(){t.sourceBuffer_.timestampOffset=i,t.runCallback_()}),this.timestampOffset_=i),this.timestampOffset_}},{key:"queueCallback_",value:function(i,t){this.callbacks_.push([i.bind(this),t]),this.runCallback_()}},{key:"runCallback_",value:function(){var i=void 0;!this.updating()&&this.callbacks_.length&&this.started_&&(i=this.callbacks_.shift(),this.pendingCallback_=i[1],i[0]())}},{key:"dispose",value:function(){var i=this,t=function n(){i.sourceBuffer_&&i.mediaSource.readyState==="open"&&i.sourceBuffer_.abort(),i.sourceBuffer_.removeEventListener("updateend",n)};this.sourceBuffer_.removeEventListener("updateend",this.onUpdateendCallback_),this.sourceBuffer_.removing?this.sourceBuffer_.addEventListener("updateend",t):t()}}]),e}(),ua={GOAL_BUFFER_LENGTH:30,MAX_GOAL_BUFFER_LENGTH:60,GOAL_BUFFER_LENGTH_RATE:1,INITIAL_BANDWIDTH:4194304,BANDWIDTH_VARIANCE:1.2,BUFFER_LOW_WATER_LINE:0,MAX_BUFFER_LOW_WATER_LINE:30,BUFFER_LOW_WATER_LINE_RATE:1},ko={FAILURE:2,TIMEOUT:-101,ABORTED:-102},$_=function(r){r.forEach(function(i){i.abort()})},hk=function(r){return{bandwidth:r.bandwidth,bytesReceived:r.bytesReceived||0,roundTripTime:r.roundTripTime||0}},pk=function(r){var i=r.target,t=Date.now()-i.requestTime,n={bandwidth:1/0,bytesReceived:0,roundTripTime:t||0};return n.bytesReceived=r.loaded,n.bandwidth=Math.floor(n.bytesReceived/n.roundTripTime*8*1e3),n},og=function(r,i){return i.timedout?{status:i.status,message:"HLS request timed-out at URL: "+i.uri,code:ko.TIMEOUT,xhr:i}:i.aborted?{status:i.status,message:"HLS request aborted at URL: "+i.uri,code:ko.ABORTED,xhr:i}:r?{status:i.status,message:"HLS request errored at URL: "+i.uri,code:ko.FAILURE,xhr:i}:null},gk=function(r,i){return function(t,n){var a=n.response,s=og(t,n);if(s)return i(s,r);if(a.byteLength!==16)return i({status:n.status,message:"Invalid HLS key at URL: "+n.uri,code:ko.FAILURE,xhr:n},r);var o=new DataView(a);return r.key.bytes=new Uint32Array([o.getUint32(0),o.getUint32(4),o.getUint32(8),o.getUint32(12)]),i(null,r)}},vk=function(r,i,t){return function(n,a){var s=a.response,o=og(n,a);return o?t(o,r):s.byteLength===0?t({status:a.status,message:"Empty HLS segment content at URL: "+a.uri,code:ko.FAILURE,xhr:a},r):(r.map.bytes=new Uint8Array(a.response),i&&!i.isInitialized()&&i.init(),r.map.timescales=al.timescale(r.map.bytes),r.map.videoTrackIds=al.videoTrackIds(r.map.bytes),t(null,r))}},mk=function(r,i,t){return function(n,a){var s=a.response,o=og(n,a),l=void 0;return o?t(o,r):s.byteLength===0?t({status:a.status,message:"Empty HLS segment content at URL: "+a.uri,code:ko.FAILURE,xhr:a},r):(r.stats=hk(a),r.key?r.encryptedBytes=new Uint8Array(a.response):r.bytes=new Uint8Array(a.response),i&&r.map&&r.map.bytes&&(i.isInitialized()||i.init(),l=i.parse(r.bytes,r.map.videoTrackIds,r.map.timescales),l&&l.captions&&(r.captionStreams=l.captionStreams,r.fmp4Captions=l.captions)),t(null,r))}},yk=function(r,i,t){var n=function s(o){if(o.data.source===i.requestId){r.removeEventListener("message",s);var l=o.data.decrypted;return i.bytes=new Uint8Array(l.bytes,l.byteOffset,l.byteLength),t(null,i)}};r.addEventListener("message",n);var a=void 0;i.key.bytes.slice?a=i.key.bytes.slice():a=new Uint32Array(Array.prototype.slice.call(i.key.bytes)),r.postMessage(m_({source:i.requestId,encrypted:i.encryptedBytes,key:a,iv:i.key.iv}),[i.encryptedBytes.buffer,a.buffer])},_k=function(r,i,t){var n=0,a=!1;return function(s,o){if(!a){if(s)return a=!0,$_(r),t(s,o);if(n+=1,n===r.length)return o.endOfAllRequests=Date.now(),o.encryptedBytes?yk(i,o,t):t(null,o)}}},bk=function(r,i){return function(t){return r.stats=re.mergeOptions(r.stats,pk(t)),!r.stats.firstBytesReceivedAt&&r.stats.bytesReceived&&(r.stats.firstBytesReceivedAt=Date.now()),i(t,r)}},Tk=function(r,i,t,n,a,s,o){var l=[],u=_k(l,t,o);if(a.key&&!a.key.bytes){var g=re.mergeOptions(i,{uri:a.key.resolvedUri,responseType:"arraybuffer"}),c=gk(a,u),d=r(g,c);l.push(d)}if(a.map&&!a.map.bytes){var f=re.mergeOptions(i,{uri:a.map.resolvedUri,responseType:"arraybuffer",headers:Zp(a.map)}),T=vk(a,n,u),p=r(f,T);l.push(p)}var y=re.mergeOptions(i,{uri:a.resolvedUri,responseType:"arraybuffer",headers:Zp(a)}),b=mk(a,n,u),v=r(y,b);return v.addEventListener("progress",bk(a,s)),l.push(v),function(){return $_(l)}},H_=function(r,i){var t=void 0;return!r||(t=Be.getComputedStyle(r),!t)?"":t[i]},Lc=function(r,i){var t=r.slice();r.sort(function(n,a){var s=i(n,a);return s===0?t.indexOf(n)-t.indexOf(a):s})},ug=function(r,i){var t=void 0,n=void 0;return r.attributes.BANDWIDTH&&(t=r.attributes.BANDWIDTH),t=t||Be.Number.MAX_VALUE,i.attributes.BANDWIDTH&&(n=i.attributes.BANDWIDTH),n=n||Be.Number.MAX_VALUE,t-n},Sk=function(r,i){var t=void 0,n=void 0;return r.attributes.RESOLUTION&&r.attributes.RESOLUTION.width&&(t=r.attributes.RESOLUTION.width),t=t||Be.Number.MAX_VALUE,i.attributes.RESOLUTION&&i.attributes.RESOLUTION.width&&(n=i.attributes.RESOLUTION.width),n=n||Be.Number.MAX_VALUE,t===n&&r.attributes.BANDWIDTH&&i.attributes.BANDWIDTH?r.attributes.BANDWIDTH-i.attributes.BANDWIDTH:t-n},Ek=function(r,i,t,n,a){var s=r.playlists.map(function(h){var S=void 0,E=void 0,A=void 0;return S=h.attributes.RESOLUTION&&h.attributes.RESOLUTION.width,E=h.attributes.RESOLUTION&&h.attributes.RESOLUTION.height,A=h.attributes.BANDWIDTH,A=A||Be.Number.MAX_VALUE,{bandwidth:A,width:S,height:E,playlist:h}});Lc(s,function(h,S){return h.bandwidth-S.bandwidth}),s=s.filter(function(h){return!zn.isIncompatible(h.playlist)});var o=s.filter(function(h){return zn.isEnabled(h.playlist)});o.length||(o=s.filter(function(h){return!zn.isDisabled(h.playlist)}));var l=o.filter(function(h){return h.bandwidth*ua.BANDWIDTH_VARIANCE<i}),u=l[l.length-1],g=l.filter(function(h){return h.bandwidth===u.bandwidth})[0];if(a===!1){var c=g||o[0]||s[0];return c?c.playlist:null}var d=l.filter(function(h){return h.width&&h.height});Lc(d,function(h,S){return h.width-S.width});var f=d.filter(function(h){return h.width===t&&h.height===n});u=f[f.length-1];var T=f.filter(function(h){return h.bandwidth===u.bandwidth})[0],p=void 0,y=void 0,b=void 0;T||(p=d.filter(function(h){return h.width>t||h.height>n}),y=p.filter(function(h){return h.width===p[0].width&&h.height===p[0].height}),u=y[y.length-1],b=y.filter(function(h){return h.bandwidth===u.bandwidth})[0]);var v=b||T||g||o[0]||s[0];return v?v.playlist:null},xk=function(){return Ek(this.playlists.master,this.systemBandwidth,parseInt(H_(this.tech_.el(),"width"),10),parseInt(H_(this.tech_.el(),"height"),10),this.limitRenditionByPlayerDimensions)},wk=function(r){var i=r.master,t=r.currentTime,n=r.bandwidth,a=r.duration,s=r.segmentDuration,o=r.timeUntilRebuffer,l=r.currentTimeline,u=r.syncController,g=i.playlists.filter(function(p){return!zn.isIncompatible(p)}),c=g.filter(zn.isEnabled);c.length||(c=g.filter(function(p){return!zn.isDisabled(p)}));var d=c.filter(zn.hasAttribute.bind(null,"BANDWIDTH")),f=d.map(function(p){var y=u.getSyncPoint(p,a,l,t),b=y?1:2,v=zn.estimateSegmentRequestTime(s,n,p),h=v*b-o;return{playlist:p,rebufferingImpact:h}}),T=f.filter(function(p){return p.rebufferingImpact<=0});return Lc(T,function(p,y){return ug(y.playlist,p.playlist)}),T.length?T[0]:(Lc(f,function(p,y){return p.rebufferingImpact-y.rebufferingImpact}),f[0]||null)},Ak=function(){var r=this.playlists.master.playlists.filter(zn.isEnabled);Lc(r,function(t,n){return ug(t,n)});var i=r.filter(function(t){return Dc(t.attributes.CODECS).videoCodec});return i[0]||null},Ck=function(r,i,t){for(var n in t)if(!r[n]){i.trigger({type:"usage",name:"hls-608"});var a=i.textTracks().getTrackById(n);a?r[n]=a:r[n]=i.addRemoteTextTrack({kind:"captions",id:n,label:n},!1).track}},kk=function(r){var i=r.inbandTextTracks,t=r.captionArray,n=r.timestampOffset;if(!!t){var a=window.WebKitDataCue||window.VTTCue;t.forEach(function(s){var o=s.stream,l=s.startTime,u=s.endTime;!i[o]||(l+=n,u+=n,i[o].addCue(new a(l,u,s.text)))})}},Rk=500,Dk=function(r,i,t){if(!r||!i)return!1;var n=r.segments,a=t===n.length;return r.endList&&i.readyState==="open"&&a},G_=function(r){return typeof r=="number"&&isFinite(r)},Pk=function(r,i,t){return r!=="main"||!i||!t?null:!t.containsAudio&&!t.containsVideo?"Neither audio nor video found in segment.":i.containsVideo&&!t.containsVideo?"Only audio found in segment when we expected video. We can't switch to audio only from a stream that had video. To get rid of this message, please add codec information to the manifest.":!i.containsVideo&&t.containsVideo?"Video found in segment when we expected only audio. We can't switch to a stream with video from an audio only stream. To get rid of this message, please add codec information to the manifest.":null},Ok=function(r,i,t){var n=void 0;return r.length&&r.start(0)>0&&r.start(0)<i?n=r.start(0):n=i-30,Math.min(n,i-t)},Lk=function(r){var i=r.segment,t=i.start,n=i.end,a=r.playlist,s=a.mediaSequence,o=a.id,l=a.segments,u=l===void 0?[]:l,g=r.mediaIndex,c=r.timeline;return["appending ["+g+"] of ["+s+", "+(s+u.length)+"] from playlist ["+o+"]","["+t+" => "+n+"] in timeline ["+c+"]"].join(" ")},lg=function(e){Gs(r,e);function r(i){Aa(this,r);var t=hs(this,(r.__proto__||Object.getPrototypeOf(r)).call(this));if(!i)throw new TypeError("Initialization settings are required");if(typeof i.currentTime!="function")throw new TypeError("No currentTime getter specified");if(!i.mediaSource)throw new TypeError("No MediaSource specified");return t.bandwidth=i.bandwidth,t.throughput={rate:0,count:0},t.roundTrip=NaN,t.resetStats_(),t.mediaIndex=null,t.hasPlayed_=i.hasPlayed,t.currentTime_=i.currentTime,t.seekable_=i.seekable,t.seeking_=i.seeking,t.duration_=i.duration,t.mediaSource_=i.mediaSource,t.hls_=i.hls,t.loaderType_=i.loaderType,t.startingMedia_=void 0,t.segmentMetadataTrack_=i.segmentMetadataTrack,t.goalBufferLength_=i.goalBufferLength,t.sourceType_=i.sourceType,t.inbandTextTracks_=i.inbandTextTracks,t.state_="INIT",t.checkBufferTimeout_=null,t.error_=void 0,t.currentTimeline_=-1,t.pendingSegment_=null,t.mimeType_=null,t.sourceUpdater_=null,t.xhrOptions_=null,t.activeInitSegmentId_=null,t.initSegments_={},t.cacheEncryptionKeys_=i.cacheEncryptionKeys,t.keyCache_={},t.loaderType_==="main"?t.captionParser_=new tA:t.captionParser_=null,t.decrypter_=i.decrypter,t.syncController_=i.syncController,t.syncPoint_={segmentIndex:0,time:0},t.syncController_.on("syncinfoupdate",function(){return t.trigger("syncinfoupdate")}),t.mediaSource_.addEventListener("sourceopen",function(){return t.ended_=!1}),t.fetchAtBuffer_=!1,t.logger_=Oc("SegmentLoader["+t.loaderType_+"]"),Object.defineProperty(t,"state",{get:function(){return this.state_},set:function(a){a!==this.state_&&(this.logger_(this.state_+" -> "+a),this.state_=a)}}),t}return Va(r,[{key:"resetStats_",value:function(){this.mediaBytesTransferred=0,this.mediaRequests=0,this.mediaRequestsAborted=0,this.mediaRequestsTimedout=0,this.mediaRequestsErrored=0,this.mediaTransferDuration=0,this.mediaSecondsLoaded=0}},{key:"dispose",value:function(){this.state="DISPOSED",this.pause(),this.abort_(),this.sourceUpdater_&&this.sourceUpdater_.dispose(),this.resetStats_(),this.captionParser_&&this.captionParser_.reset()}},{key:"abort",value:function(){if(this.state!=="WAITING"){this.pendingSegment_&&(this.pendingSegment_=null);return}this.abort_(),this.state="READY",this.paused()||this.monitorBuffer_()}},{key:"abort_",value:function(){this.pendingSegment_&&this.pendingSegment_.abortRequests(),this.pendingSegment_=null}},{key:"error",value:function(t){return typeof t<"u"&&(this.error_=t),this.pendingSegment_=null,this.error_}},{key:"endOfStream",value:function(){this.ended_=!0,this.pause(),this.trigger("ended")}},{key:"buffered_",value:function(){return this.sourceUpdater_?this.sourceUpdater_.buffered():re.createTimeRanges()}},{key:"initSegment",value:function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(!t)return null;var a=Qd(t),s=this.initSegments_[a];return n&&!s&&t.bytes&&(this.initSegments_[a]=s={resolvedUri:t.resolvedUri,byterange:t.byterange,bytes:t.bytes,timescales:t.timescales,videoTrackIds:t.videoTrackIds}),s||t}},{key:"segmentKey",value:function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(!t)return null;var a=y_(t),s=this.keyCache_[a];this.cacheEncryptionKeys_&&n&&!s&&t.bytes&&(this.keyCache_[a]=s={resolvedUri:t.resolvedUri,bytes:t.bytes});var o={resolvedUri:(s||t).resolvedUri};return s&&(o.bytes=s.bytes),o}},{key:"couldBeginLoading_",value:function(){return this.playlist_&&(this.sourceUpdater_||this.mimeType_&&this.state==="INIT")&&!this.paused()}},{key:"load",value:function(){if(this.monitorBuffer_(),!!this.playlist_){if(this.syncController_.setDateTimeMapping(this.playlist_),this.state==="INIT"&&this.couldBeginLoading_())return this.init_();!this.couldBeginLoading_()||this.state!=="READY"&&this.state!=="INIT"||(this.state="READY")}}},{key:"init_",value:function(){return this.state="READY",this.sourceUpdater_=new fk(this.mediaSource_,this.mimeType_,this.loaderType_,this.sourceBufferEmitter_),this.resetEverything(),this.monitorBuffer_()}},{key:"playlist",value:function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!!t){var a=this.playlist_,s=this.pendingSegment_;this.playlist_=t,this.xhrOptions_=n,this.hasPlayed_()||(t.syncInfo={mediaSequence:t.mediaSequence,time:0});var o=null;if(a&&(a.id?o=a.id:a.uri&&(o=a.uri)),this.logger_("playlist update ["+o+" => "+(t.id||t.uri)+"]"),this.trigger("syncinfoupdate"),this.state==="INIT"&&this.couldBeginLoading_())return this.init_();if(!a||a.uri!==t.uri){this.mediaIndex!==null&&this.resyncLoader();return}var l=t.mediaSequence-a.mediaSequence;this.logger_("live window shift ["+l+"]"),this.mediaIndex!==null&&(this.mediaIndex-=l),s&&(s.mediaIndex-=l,s.mediaIndex>=0&&(s.segment=t.segments[s.mediaIndex])),this.syncController_.saveExpiredSegmentInfo(a,t)}}},{key:"pause",value:function(){this.checkBufferTimeout_&&(Be.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=null)}},{key:"paused",value:function(){return this.checkBufferTimeout_===null}},{key:"mimeType",value:function(t,n){this.mimeType_||(this.mimeType_=t,this.sourceBufferEmitter_=n,this.state==="INIT"&&this.couldBeginLoading_()&&this.init_())}},{key:"resetEverything",value:function(t){this.ended_=!1,this.resetLoader(),this.remove(0,this.duration_(),t),this.captionParser_&&this.captionParser_.clearAllCaptions(),this.trigger("reseteverything")}},{key:"resetLoader",value:function(){this.fetchAtBuffer_=!1,this.resyncLoader()}},{key:"resyncLoader",value:function(){this.mediaIndex=null,this.syncPoint_=null,this.abort()}},{key:"remove",value:function(t,n,a){if(this.sourceUpdater_&&this.sourceUpdater_.remove(t,n,a),Tl(t,n,this.segmentMetadataTrack_),this.inbandTextTracks_)for(var s in this.inbandTextTracks_)Tl(t,n,this.inbandTextTracks_[s])}},{key:"monitorBuffer_",value:function(){this.checkBufferTimeout_&&Be.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=Be.setTimeout(this.monitorBufferTick_.bind(this),1)}},{key:"monitorBufferTick_",value:function(){this.state==="READY"&&this.fillBuffer_(),this.checkBufferTimeout_&&Be.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=Be.setTimeout(this.monitorBufferTick_.bind(this),Rk)}},{key:"fillBuffer_",value:function(){if(!this.sourceUpdater_.updating()){this.syncPoint_||(this.syncPoint_=this.syncController_.getSyncPoint(this.playlist_,this.duration_(),this.currentTimeline_,this.currentTime_()));var t=this.checkBuffer_(this.buffered_(),this.playlist_,this.mediaIndex,this.hasPlayed_(),this.currentTime_(),this.syncPoint_);if(!!t){if(this.isEndOfStream_(t.mediaIndex)){this.endOfStream();return}t.mediaIndex===this.playlist_.segments.length-1&&this.mediaSource_.readyState==="ended"&&!this.seeking_()||(t.timeline!==this.currentTimeline_&&(this.syncController_.reset(),t.timestampOffset=t.startOfSegment,this.captionParser_&&this.captionParser_.clearAllCaptions()),this.loadSegment_(t))}}}},{key:"isEndOfStream_",value:function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.playlist_;return Dk(n,this.mediaSource_,t)&&!this.sourceUpdater_.updating()}},{key:"checkBuffer_",value:function(t,n,a,s,o,l){var u=0,g=void 0;t.length&&(u=t.end(t.length-1));var c=Math.max(0,u-o);if(!n.segments.length||c>=this.goalBufferLength_()||!s&&c>=1)return null;if(l===null)return a=this.getSyncSegmentCandidate_(n),this.generateSegmentInfo_(n,a,null,!0);if(a!==null)return n.segments[a],g=u,this.generateSegmentInfo_(n,a+1,g,!1);if(this.fetchAtBuffer_){var d=zn.getMediaInfoForTime(n,u,l.segmentIndex,l.time);a=d.mediaIndex,g=d.startTime}else{var f=zn.getMediaInfoForTime(n,o,l.segmentIndex,l.time);a=f.mediaIndex,g=f.startTime}return this.generateSegmentInfo_(n,a,g,!1)}},{key:"getSyncSegmentCandidate_",value:function(t){var n=this;if(this.currentTimeline_===-1)return 0;var a=t.segments.map(function(s,o){return{timeline:s.timeline,segmentIndex:o}}).filter(function(s){return s.timeline===n.currentTimeline_});return a.length?a[Math.min(a.length-1,1)].segmentIndex:Math.max(t.segments.length-1,0)}},{key:"generateSegmentInfo_",value:function(t,n,a,s){if(n<0||n>=t.segments.length)return null;var o=t.segments[n];return{requestId:"segment-loader-"+Math.random(),uri:o.resolvedUri,mediaIndex:n,isSyncRequest:s,startOfSegment:a,playlist:t,bytes:null,encryptedBytes:null,timestampOffset:null,timeline:o.timeline,duration:o.duration,segment:o}}},{key:"abortRequestEarly_",value:function(t){if(this.hls_.tech_.paused()||!this.xhrOptions_.timeout||!this.playlist_.attributes.BANDWIDTH||Date.now()-(t.firstBytesReceivedAt||Date.now())<1e3)return!1;var n=this.currentTime_(),a=t.bandwidth,s=this.pendingSegment_.duration,o=zn.estimateSegmentRequestTime(s,a,this.playlist_,t.bytesReceived),l=G1(this.buffered_(),n,this.hls_.tech_.playbackRate())-1;if(o<=l)return!1;var u=wk({master:this.hls_.playlists.master,currentTime:n,bandwidth:a,duration:this.duration_(),segmentDuration:s,timeUntilRebuffer:l,currentTimeline:this.currentTimeline_,syncController:this.syncController_});if(!!u){var g=o-l,c=g-u.rebufferingImpact,d=.5;return l<=Zd&&(d=1),!u.playlist||u.playlist.uri===this.playlist_.uri||c<d?!1:(this.bandwidth=u.playlist.attributes.BANDWIDTH*ua.BANDWIDTH_VARIANCE+1,this.abort(),this.trigger("earlyabort"),!0)}}},{key:"handleProgress_",value:function(t,n){!this.pendingSegment_||n.requestId!==this.pendingSegment_.requestId||this.abortRequestEarly_(n.stats)||this.trigger("progress")}},{key:"loadSegment_",value:function(t){this.state="WAITING",this.pendingSegment_=t,this.trimBackBuffer_(t),t.abortRequests=Tk(this.hls_.xhr,this.xhrOptions_,this.decrypter_,this.captionParser_,this.createSimplifiedSegmentObj_(t),this.handleProgress_.bind(this),this.segmentRequestFinished_.bind(this))}},{key:"trimBackBuffer_",value:function(t){var n=Ok(this.seekable_(),this.currentTime_(),this.playlist_.targetDuration||10);n>0&&this.remove(0,n)}},{key:"createSimplifiedSegmentObj_",value:function(t){var n=t.segment,a={resolvedUri:n.resolvedUri,byterange:n.byterange,requestId:t.requestId};if(n.key){var s=n.key.iv||new Uint32Array([0,0,0,t.mediaIndex+t.playlist.mediaSequence]);a.key=this.segmentKey(n.key),a.key.iv=s}return n.map&&(a.map=this.initSegment(n.map)),a}},{key:"segmentRequestFinished_",value:function(t,n){if(this.mediaRequests+=1,n.stats&&(this.mediaBytesTransferred+=n.stats.bytesReceived,this.mediaTransferDuration+=n.stats.roundTripTime),!this.pendingSegment_){this.mediaRequestsAborted+=1;return}if(n.requestId===this.pendingSegment_.requestId){if(t){if(this.pendingSegment_=null,this.state="READY",t.code===ko.ABORTED){this.mediaRequestsAborted+=1;return}if(this.pause(),t.code===ko.TIMEOUT){this.mediaRequestsTimedout+=1,this.bandwidth=1,this.roundTrip=NaN,this.trigger("bandwidthupdate");return}this.mediaRequestsErrored+=1,this.error(t),this.trigger("error");return}this.bandwidth=n.stats.bandwidth,this.roundTrip=n.stats.roundTripTime,n.map&&(n.map=this.initSegment(n.map,!0)),n.key&&this.segmentKey(n.key,!0),this.processSegmentResponse_(n)}}},{key:"processSegmentResponse_",value:function(t){var n=this.pendingSegment_;n.bytes=t.bytes,t.map&&(n.segment.map.bytes=t.map.bytes),n.endOfAllRequests=t.endOfAllRequests,t.fmp4Captions&&(Ck(this.inbandTextTracks_,this.hls_.tech_,t.captionStreams),kk({inbandTextTracks:this.inbandTextTracks_,captionArray:t.fmp4Captions,timestampOffset:0}),this.captionParser_&&this.captionParser_.clearParsedCaptions()),this.handleSegment_()}},{key:"handleSegment_",value:function(){var t=this;if(!this.pendingSegment_){this.state="READY";return}var n=this.pendingSegment_,a=n.segment,s=this.syncController_.probeSegmentInfo(n);typeof this.startingMedia_>"u"&&s&&(s.containsAudio||s.containsVideo)&&(this.startingMedia_={containsAudio:s.containsAudio,containsVideo:s.containsVideo});var o=Pk(this.loaderType_,this.startingMedia_,s);if(o){this.error({message:o,blacklistDuration:1/0}),this.trigger("error");return}if(n.isSyncRequest){this.trigger("syncinfoupdate"),this.pendingSegment_=null,this.state="READY";return}if(n.timestampOffset!==null&&n.timestampOffset!==this.sourceUpdater_.timestampOffset()){if(s&&s.segmentTimestampInfo){var l=s.segmentTimestampInfo[0].ptsTime,u=s.segmentTimestampInfo[0].dtsTime;n.timestampOffset-=l-u}this.sourceUpdater_.timestampOffset(n.timestampOffset),this.trigger("timestampoffset")}var g=this.syncController_.mappingForTimeline(n.timeline);if(g!==null&&this.trigger({type:"segmenttimemapping",mapping:g}),this.state="APPENDING",a.map){var c=Qd(a.map);if(!this.activeInitSegmentId_||this.activeInitSegmentId_!==c){var d=this.initSegment(a.map);this.sourceUpdater_.appendBuffer({bytes:d.bytes},function(){t.activeInitSegmentId_=c})}}n.byteLength=n.bytes.byteLength,typeof a.start=="number"&&typeof a.end=="number"?this.mediaSecondsLoaded+=a.end-a.start:this.mediaSecondsLoaded+=a.duration,this.logger_(Lk(n)),this.sourceUpdater_.appendBuffer({bytes:n.bytes,videoSegmentTimingInfoCallback:this.handleVideoSegmentTimingInfo_.bind(this,n.requestId)},this.handleUpdateEnd_.bind(this))}},{key:"handleVideoSegmentTimingInfo_",value:function(t,n){if(!(!this.pendingSegment_||t!==this.pendingSegment_.requestId)){var a=this.pendingSegment_.segment;a.videoTimingInfo||(a.videoTimingInfo={}),a.videoTimingInfo.transmuxerPrependedSeconds=n.videoSegmentTimingInfo.prependedContentDuration||0,a.videoTimingInfo.transmuxedPresentationStart=n.videoSegmentTimingInfo.start.presentation,a.videoTimingInfo.transmuxedPresentationEnd=n.videoSegmentTimingInfo.end.presentation,a.videoTimingInfo.baseMediaDecodeTime=n.videoSegmentTimingInfo.baseMediaDecodeTime}}},{key:"handleUpdateEnd_",value:function(){if(!this.pendingSegment_){this.state="READY",this.paused()||this.monitorBuffer_();return}var t=this.pendingSegment_,n=t.segment,a=this.mediaIndex!==null;if(this.pendingSegment_=null,this.recordThroughput_(t),this.addSegmentMetadataCue_(t),this.state="READY",this.mediaIndex=t.mediaIndex,this.fetchAtBuffer_=!0,this.currentTimeline_=t.timeline,this.trigger("syncinfoupdate"),n.end&&this.currentTime_()-n.end>t.playlist.targetDuration*3){this.resetEverything();return}a&&this.trigger("bandwidthupdate"),this.trigger("progress"),this.isEndOfStream_(t.mediaIndex+1,t.playlist)&&this.endOfStream(),this.paused()||this.monitorBuffer_()}},{key:"recordThroughput_",value:function(t){var n=this.throughput.rate,a=Date.now()-t.endOfAllRequests+1,s=Math.floor(t.byteLength/a*8*1e3);this.throughput.rate+=(s-n)/++this.throughput.count}},{key:"addSegmentMetadataCue_",value:function(t){if(!!this.segmentMetadataTrack_){var n=t.segment,a=n.start,s=n.end;if(!(!G_(a)||!G_(s))){Tl(a,s,this.segmentMetadataTrack_);var o=Be.WebKitDataCue||Be.VTTCue,l={custom:n.custom,dateTimeObject:n.dateTimeObject,dateTimeString:n.dateTimeString,bandwidth:t.playlist.attributes.BANDWIDTH,resolution:t.playlist.attributes.RESOLUTION,codecs:t.playlist.attributes.CODECS,byteLength:t.byteLength,uri:t.uri,timeline:t.timeline,playlist:t.playlist.uri,start:a,end:s},u=JSON.stringify(l),g=new o(a,s,u);g.value=l,this.segmentMetadataTrack_.addCue(g)}}}}]),r}(re.EventTarget),V_=function(r){return decodeURIComponent(escape(String.fromCharCode.apply(null,r)))},q_=new Uint8Array(`
96
96
 
97
- `.split("").map(function(e){return e.charCodeAt(0)})),Ik=function(e){Gs(r,e);function r(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Aa(this,r);var n=hs(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,i,t));return n.mediaSource_=null,n.subtitlesTrack_=null,n}return Va(r,[{key:"buffered_",value:function(){if(!this.subtitlesTrack_||!this.subtitlesTrack_.cues.length)return re.createTimeRanges();var t=this.subtitlesTrack_.cues,n=t[0].startTime,a=t[t.length-1].startTime;return re.createTimeRanges([[n,a]])}},{key:"initSegment",value:function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(!t)return null;var a=Qd(t),s=this.initSegments_[a];if(n&&!s&&t.bytes){var o=q_.byteLength+t.bytes.byteLength,l=new Uint8Array(o);l.set(t.bytes),l.set(q_,t.bytes.byteLength),this.initSegments_[a]=s={resolvedUri:t.resolvedUri,byterange:t.byterange,bytes:l}}return s||t}},{key:"couldBeginLoading_",value:function(){return this.playlist_&&this.subtitlesTrack_&&!this.paused()}},{key:"init_",value:function(){return this.state="READY",this.resetEverything(),this.monitorBuffer_()}},{key:"track",value:function(t){return typeof t>"u"?this.subtitlesTrack_:(this.subtitlesTrack_=t,this.state==="INIT"&&this.couldBeginLoading_()&&this.init_(),this.subtitlesTrack_)}},{key:"remove",value:function(t,n){Tl(t,n,this.subtitlesTrack_)}},{key:"fillBuffer_",value:function(){var t=this;this.syncPoint_||(this.syncPoint_=this.syncController_.getSyncPoint(this.playlist_,this.duration_(),this.currentTimeline_,this.currentTime_()));var n=this.checkBuffer_(this.buffered_(),this.playlist_,this.mediaIndex,this.hasPlayed_(),this.currentTime_(),this.syncPoint_);if(n=this.skipEmptySegments_(n),!!n){if(this.syncController_.timestampOffsetForTimeline(n.timeline)===null){var a=function(){t.state="READY",t.paused()||t.monitorBuffer_()};this.syncController_.one("timestampoffset",a),this.state="WAITING_ON_TIMELINE";return}this.loadSegment_(n)}}},{key:"skipEmptySegments_",value:function(t){for(;t&&t.segment.empty;)t=this.generateSegmentInfo_(t.playlist,t.mediaIndex+1,t.startOfSegment+t.duration,t.isSyncRequest);return t}},{key:"handleSegment_",value:function(){var t=this;if(!this.pendingSegment_||!this.subtitlesTrack_){this.state="READY";return}this.state="APPENDING";var n=this.pendingSegment_,a=n.segment;if(typeof Be.WebVTT!="function"&&this.subtitlesTrack_&&this.subtitlesTrack_.tech_){var s=void 0,o=function(){t.subtitlesTrack_.tech_.off("vttjsloaded",s),t.error({message:"Error loading vtt.js"}),t.state="READY",t.pause(),t.trigger("error")};s=function(){t.subtitlesTrack_.tech_.off("vttjserror",o),t.handleSegment_()},this.state="WAITING_ON_VTTJS",this.subtitlesTrack_.tech_.one("vttjsloaded",s),this.subtitlesTrack_.tech_.one("vttjserror",o);return}a.requested=!0;try{this.parseVTTCues_(n)}catch(l){return this.error({message:l.message}),this.state="READY",this.pause(),this.trigger("error")}if(this.updateTimeMapping_(n,this.syncController_.timelines[n.timeline],this.playlist_),n.isSyncRequest){this.trigger("syncinfoupdate"),this.pendingSegment_=null,this.state="READY";return}n.byteLength=n.bytes.byteLength,this.mediaSecondsLoaded+=a.duration,n.cues.length&&this.remove(n.cues[0].endTime,n.cues[n.cues.length-1].endTime),n.cues.forEach(function(l){t.subtitlesTrack_.addCue(l)}),this.handleUpdateEnd_()}},{key:"parseVTTCues_",value:function(t){var n=void 0,a=!1;typeof Be.TextDecoder=="function"?n=new Be.TextDecoder("utf8"):(n=Be.WebVTT.StringDecoder(),a=!0);var s=new Be.WebVTT.Parser(Be,Be.vttjs,n);if(t.cues=[],t.timestampmap={MPEGTS:0,LOCAL:0},s.oncue=t.cues.push.bind(t.cues),s.ontimestampmap=function(u){return t.timestampmap=u},s.onparsingerror=function(u){re.log.warn("Error encountered when parsing cues: "+u.message)},t.segment.map){var o=t.segment.map.bytes;a&&(o=V_(o)),s.parse(o)}var l=t.bytes;a&&(l=V_(l)),s.parse(l),s.flush()}},{key:"updateTimeMapping_",value:function(t,n,a){var s=t.segment;if(!!n){if(!t.cues.length){s.empty=!0;return}var o=t.timestampmap,l=o.MPEGTS/9e4-o.LOCAL+n.mapping;if(t.cues.forEach(function(c){c.startTime+=l,c.endTime+=l}),!a.syncInfo){var u=t.cues[0].startTime,g=t.cues[t.cues.length-1].startTime;a.syncInfo={mediaSequence:a.mediaSequence+t.mediaIndex,time:Math.min(u,g-s.duration)}}}}}]),r}(lg),Mk=function(r,i){for(var t=r.cues,n=0;n<t.length;n++){var a=t[n];if(i>=a.adStartTime&&i<=a.adEndTime)return a}return null},Nk=function(r,i){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;if(!!r.segments)for(var n=t,a=void 0,s=0;s<r.segments.length;s++){var o=r.segments[s];if(a||(a=Mk(i,n+o.duration/2)),a){if("cueIn"in o){a.endTime=n,a.adEndTime=n,n+=o.duration,a=null;continue}if(n<a.endTime){n+=o.duration;continue}a.endTime+=o.duration}else if("cueOut"in o&&(a=new Be.VTTCue(n,n+o.duration,o.cueOut),a.adStartTime=n,a.adEndTime=n+parseFloat(o.cueOut),i.addCue(a)),"cueOutCont"in o){var l=void 0,u=void 0,g=o.cueOutCont.split("/").map(parseFloat),c=c1(g,2);l=c[0],u=c[1],a=new Be.VTTCue(n,n+o.duration,""),a.adStartTime=n-l,a.adEndTime=a.adStartTime+u,i.addCue(a)}n+=o.duration}},Fk=DA.inspect,W_=[{name:"VOD",run:function(r,i,t,n,a){if(t!==1/0){var s={time:0,segmentIndex:0};return s}return null}},{name:"ProgramDateTime",run:function(r,i,t,n,a){if(!r.datetimeToDisplayTime)return null;var s=i.segments||[],o=null,l=null;a=a||0;for(var u=0;u<s.length;u++){var g=s[u];if(g.dateTimeObject){var c=g.dateTimeObject.getTime()/1e3,d=c+r.datetimeToDisplayTime,f=Math.abs(a-d);if(l!==null&&(f===0||l<f))break;l=f,o={time:d,segmentIndex:u}}}return o}},{name:"Segment",run:function(r,i,t,n,a){var s=i.segments||[],o=null,l=null;a=a||0;for(var u=0;u<s.length;u++){var g=s[u];if(g.timeline===n&&typeof g.start<"u"){var c=Math.abs(a-g.start);if(l!==null&&l<c)break;(!o||l===null||l>=c)&&(l=c,o={time:g.start,segmentIndex:u})}}return o}},{name:"Discontinuity",run:function(r,i,t,n,a){var s=null;if(a=a||0,i.discontinuityStarts&&i.discontinuityStarts.length)for(var o=null,l=0;l<i.discontinuityStarts.length;l++){var u=i.discontinuityStarts[l],g=i.discontinuitySequence+l+1,c=r.discontinuities[g];if(c){var d=Math.abs(a-c.time);if(o!==null&&o<d)break;(!s||o===null||o>=d)&&(o=d,s={time:c.time,segmentIndex:u})}}return s}},{name:"Playlist",run:function(r,i,t,n,a){if(i.syncInfo){var s={time:i.syncInfo.time,segmentIndex:i.syncInfo.mediaSequence-i.mediaSequence};return s}return null}}],Uk=function(e){Gs(r,e);function r(){Aa(this,r);var i=hs(this,(r.__proto__||Object.getPrototypeOf(r)).call(this));return i.inspectCache_=void 0,i.timelines=[],i.discontinuities=[],i.datetimeToDisplayTime=null,i.logger_=Oc("SyncController"),i}return Va(r,[{key:"getSyncPoint",value:function(t,n,a,s){var o=this.runStrategies_(t,n,a,s);return o.length?this.selectSyncPoint_(o,{key:"time",value:s}):null}},{key:"getExpiredTime",value:function(t,n){if(!t||!t.segments)return null;var a=this.runStrategies_(t,n,t.discontinuitySequence,0);if(!a.length)return null;var s=this.selectSyncPoint_(a,{key:"segmentIndex",value:0});return s.segmentIndex>0&&(s.time*=-1),Math.abs(s.time+Rc(t,s.segmentIndex,0))}},{key:"runStrategies_",value:function(t,n,a,s){for(var o=[],l=0;l<W_.length;l++){var u=W_[l],g=u.run(this,t,n,a,s);g&&(g.strategy=u.name,o.push({strategy:u.name,syncPoint:g}))}return o}},{key:"selectSyncPoint_",value:function(t,n){for(var a=t[0].syncPoint,s=Math.abs(t[0].syncPoint[n.key]-n.value),o=t[0].strategy,l=1;l<t.length;l++){var u=Math.abs(t[l].syncPoint[n.key]-n.value);u<s&&(s=u,a=t[l].syncPoint,o=t[l].strategy)}return this.logger_("syncPoint for ["+n.key+": "+n.value+"] chosen with strategy"+(" ["+o+"]: [time:"+a.time+",")+(" segmentIndex:"+a.segmentIndex+"]")),a}},{key:"saveExpiredSegmentInfo",value:function(t,n){for(var a=n.mediaSequence-t.mediaSequence,s=a-1;s>=0;s--){var o=t.segments[s];if(o&&typeof o.start<"u"){n.syncInfo={mediaSequence:t.mediaSequence+s,time:o.start},this.logger_("playlist refresh sync: [time:"+n.syncInfo.time+","+(" mediaSequence: "+n.syncInfo.mediaSequence+"]")),this.trigger("syncinfoupdate");break}}}},{key:"setDateTimeMapping",value:function(t){if(!this.datetimeToDisplayTime&&t.segments&&t.segments.length&&t.segments[0].dateTimeObject){var n=t.segments[0].dateTimeObject.getTime()/1e3;this.datetimeToDisplayTime=-n}}},{key:"reset",value:function(){this.inspectCache_=void 0}},{key:"probeSegmentInfo",value:function(t){var n=t.segment,a=t.playlist,s=void 0;return n.map?s=this.probeMp4Segment_(t):s=this.probeTsSegment_(t),s&&this.calculateSegmentTimeMapping_(t,s)&&(this.saveDiscontinuitySyncInfo_(t),a.syncInfo||(a.syncInfo={mediaSequence:a.mediaSequence+t.mediaIndex,time:n.start})),s}},{key:"probeMp4Segment_",value:function(t){var n=t.segment,a=al.timescale(n.map.bytes),s=al.startTime(a,t.bytes);return t.timestampOffset!==null&&(t.timestampOffset-=s),{start:s,end:s+n.duration}}},{key:"probeTsSegment_",value:function(t){var n=Fk(t.bytes,this.inspectCache_),a=void 0,s=void 0,o=void 0;if(!n)return null;n.video&&n.video.length===2?(this.inspectCache_=n.video[1].dts,a=n.video[0].dtsTime,s=n.video[1].dtsTime,o=n.video):n.audio&&n.audio.length===2&&(this.inspectCache_=n.audio[1].dts,a=n.audio[0].dtsTime,s=n.audio[1].dtsTime,o=n.audio);var l={segmentTimestampInfo:o,start:a,end:s,containsVideo:n.video&&n.video.length===2,containsAudio:n.audio&&n.audio.length===2};return l}},{key:"timestampOffsetForTimeline",value:function(t){return typeof this.timelines[t]>"u"?null:this.timelines[t].time}},{key:"mappingForTimeline",value:function(t){return typeof this.timelines[t]>"u"?null:this.timelines[t].mapping}},{key:"calculateSegmentTimeMapping_",value:function(t,n){var a=t.segment,s=this.timelines[t.timeline];if(t.timestampOffset!==null)s={time:t.startOfSegment,mapping:t.startOfSegment-n.start},this.timelines[t.timeline]=s,this.trigger("timestampoffset"),this.logger_("time mapping for timeline "+t.timeline+": "+("[time: "+s.time+"] [mapping: "+s.mapping+"]")),a.start=t.startOfSegment,a.end=n.end+s.mapping;else if(s)a.start=n.start+s.mapping,a.end=n.end+s.mapping;else return!1;return!0}},{key:"saveDiscontinuitySyncInfo_",value:function(t){var n=t.playlist,a=t.segment;if(a.discontinuity)this.discontinuities[a.timeline]={time:a.start,accuracy:0};else if(n.discontinuityStarts&&n.discontinuityStarts.length)for(var s=0;s<n.discontinuityStarts.length;s++){var o=n.discontinuityStarts[s],l=n.discontinuitySequence+s+1,u=o-t.mediaIndex,g=Math.abs(u);if(!this.discontinuities[l]||this.discontinuities[l].accuracy>g){var c=void 0;u<0?c=a.start-Rc(n,t.mediaIndex,o):c=a.end+Rc(n,t.mediaIndex+1,o),this.discontinuities[l]={time:c,accuracy:g}}}}}]),r}(re.EventTarget),Bk=new A_("./decrypter-worker.worker.js",function(e,r){var i=this;(function(){function t(h){return h.subarray(0,h.byteLength-h[h.byteLength-1])}var n=function(S,E){if(!(S instanceof E))throw new TypeError("Cannot call a class as a function")},a=function(){function h(S,E){for(var A=0;A<E.length;A++){var x=E[A];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(S,x.key,x)}}return function(S,E,A){return E&&h(S.prototype,E),A&&h(S,A),S}}(),s=function(S,E){if(typeof E!="function"&&E!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof E);S.prototype=Object.create(E&&E.prototype,{constructor:{value:S,enumerable:!1,writable:!0,configurable:!0}}),E&&(Object.setPrototypeOf?Object.setPrototypeOf(S,E):S.__proto__=E)},o=function(S,E){if(!S)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return E&&(typeof E=="object"||typeof E=="function")?E:S},l=function(){var S=[[[],[],[],[],[]],[[],[],[],[],[]]],E=S[0],A=S[1],x=E[4],m=A[4],C=void 0,k=void 0,D=void 0,P=[],N=[],j=void 0,O=void 0,M=void 0,F=void 0,H=void 0,K=void 0;for(C=0;C<256;C++)N[(P[C]=C<<1^(C>>7)*283)^C]=C;for(k=D=0;!x[k];k^=j||1,D=N[D]||1)for(F=D^D<<1^D<<2^D<<3^D<<4,F=F>>8^F&255^99,x[k]=F,m[F]=k,M=P[O=P[j=P[k]]],K=M*16843009^O*65537^j*257^k*16843008,H=P[F]*257^F*16843008,C=0;C<4;C++)E[C][k]=H=H<<24^H>>>8,A[C][F]=K=K<<24^K>>>8;for(C=0;C<5;C++)E[C]=E[C].slice(0),A[C]=A[C].slice(0);return S},u=null,g=function(){function h(S){n(this,h),u||(u=l()),this._tables=[[u[0][0].slice(),u[0][1].slice(),u[0][2].slice(),u[0][3].slice(),u[0][4].slice()],[u[1][0].slice(),u[1][1].slice(),u[1][2].slice(),u[1][3].slice(),u[1][4].slice()]];var E=void 0,A=void 0,x=void 0,m=void 0,C=void 0,k=this._tables[0][4],D=this._tables[1],P=S.length,N=1;if(P!==4&&P!==6&&P!==8)throw new Error("Invalid aes key size");for(m=S.slice(0),C=[],this._key=[m,C],E=P;E<4*P+28;E++)x=m[E-1],(E%P===0||P===8&&E%P===4)&&(x=k[x>>>24]<<24^k[x>>16&255]<<16^k[x>>8&255]<<8^k[x&255],E%P===0&&(x=x<<8^x>>>24^N<<24,N=N<<1^(N>>7)*283)),m[E]=m[E-P]^x;for(A=0;E;A++,E--)x=m[A&3?E:E-4],E<=4||A<4?C[A]=x:C[A]=D[0][k[x>>>24]]^D[1][k[x>>16&255]]^D[2][k[x>>8&255]]^D[3][k[x&255]]}return h.prototype.decrypt=function(E,A,x,m,C,k){var D=this._key[1],P=E^D[0],N=m^D[1],j=x^D[2],O=A^D[3],M=void 0,F=void 0,H=void 0,K=D.length/4-2,J=void 0,le=4,ce=this._tables[1],Z=ce[0],ve=ce[1],Ce=ce[2],Ne=ce[3],ot=ce[4];for(J=0;J<K;J++)M=Z[P>>>24]^ve[N>>16&255]^Ce[j>>8&255]^Ne[O&255]^D[le],F=Z[N>>>24]^ve[j>>16&255]^Ce[O>>8&255]^Ne[P&255]^D[le+1],H=Z[j>>>24]^ve[O>>16&255]^Ce[P>>8&255]^Ne[N&255]^D[le+2],O=Z[O>>>24]^ve[P>>16&255]^Ce[N>>8&255]^Ne[j&255]^D[le+3],le+=4,P=M,N=F,j=H;for(J=0;J<4;J++)C[(3&-J)+k]=ot[P>>>24]<<24^ot[N>>16&255]<<16^ot[j>>8&255]<<8^ot[O&255]^D[le++],M=P,P=N,N=j,j=O,O=M},h}(),c=function(){function h(){n(this,h),this.listeners={}}return h.prototype.on=function(E,A){this.listeners[E]||(this.listeners[E]=[]),this.listeners[E].push(A)},h.prototype.off=function(E,A){if(!this.listeners[E])return!1;var x=this.listeners[E].indexOf(A);return this.listeners[E].splice(x,1),x>-1},h.prototype.trigger=function(E){var A=this.listeners[E];if(!!A)if(arguments.length===2)for(var x=A.length,m=0;m<x;++m)A[m].call(this,arguments[1]);else for(var C=Array.prototype.slice.call(arguments,1),k=A.length,D=0;D<k;++D)A[D].apply(this,C)},h.prototype.dispose=function(){this.listeners={}},h.prototype.pipe=function(E){this.on("data",function(A){E.push(A)})},h}(),d=function(h){s(S,h);function S(){n(this,S);var E=o(this,h.call(this,c));return E.jobs=[],E.delay=1,E.timeout_=null,E}return S.prototype.processJob_=function(){this.jobs.shift()(),this.jobs.length?this.timeout_=setTimeout(this.processJob_.bind(this),this.delay):this.timeout_=null},S.prototype.push=function(A){this.jobs.push(A),this.timeout_||(this.timeout_=setTimeout(this.processJob_.bind(this),this.delay))},S}(c),f=function(S){return S<<24|(S&65280)<<8|(S&16711680)>>8|S>>>24},T=function(S,E,A){var x=new Int32Array(S.buffer,S.byteOffset,S.byteLength>>2),m=new g(Array.prototype.slice.call(E)),C=new Uint8Array(S.byteLength),k=new Int32Array(C.buffer),D=void 0,P=void 0,N=void 0,j=void 0,O=void 0,M=void 0,F=void 0,H=void 0,K=void 0;for(D=A[0],P=A[1],N=A[2],j=A[3],K=0;K<x.length;K+=4)O=f(x[K]),M=f(x[K+1]),F=f(x[K+2]),H=f(x[K+3]),m.decrypt(O,M,F,H,k,K),k[K]=f(k[K]^D),k[K+1]=f(k[K+1]^P),k[K+2]=f(k[K+2]^N),k[K+3]=f(k[K+3]^j),D=O,P=M,N=F,j=H;return C},p=function(){function h(S,E,A,x){n(this,h);var m=h.STEP,C=new Int32Array(S.buffer),k=new Uint8Array(S.byteLength),D=0;for(this.asyncStream_=new d,this.asyncStream_.push(this.decryptChunk_(C.subarray(D,D+m),E,A,k)),D=m;D<C.length;D+=m)A=new Uint32Array([f(C[D-4]),f(C[D-3]),f(C[D-2]),f(C[D-1])]),this.asyncStream_.push(this.decryptChunk_(C.subarray(D,D+m),E,A,k));this.asyncStream_.push(function(){x(null,t(k))})}return h.prototype.decryptChunk_=function(E,A,x,m){return function(){var C=T(E,A,x);m.set(C,E.byteOffset)}},a(h,null,[{key:"STEP",get:function(){return 32e3}}]),h}(),y=function(S){var E={};return Object.keys(S).forEach(function(A){var x=S[A];ArrayBuffer.isView(x)?E[A]={bytes:x.buffer,byteOffset:x.byteOffset,byteLength:x.byteLength}:E[A]=x}),E},b=function(S){S.onmessage=function(E){var A=E.data,x=new Uint8Array(A.encrypted.bytes,A.encrypted.byteOffset,A.encrypted.byteLength),m=new Uint32Array(A.key.bytes,A.key.byteOffset,A.key.byteLength/4),C=new Uint32Array(A.iv.bytes,A.iv.byteOffset,A.iv.byteLength/4);new p(x,m,C,function(k,D){S.postMessage(y({source:A.source,decrypted:D}),[D.buffer])})}},v=new b(i);return v})()}),jk=function(r){var i=r.default?"main":"alternative";return r.characteristics&&r.characteristics.indexOf("public.accessibility.describes-video")>=0&&(i="main-desc"),i},tf=function(r,i){r.abort(),r.pause(),i&&i.activePlaylistLoader&&(i.activePlaylistLoader.pause(),i.activePlaylistLoader=null)},cg=function(r,i){i.activePlaylistLoader=r,r.load()},$k=function(r,i){return function(){var t=i.segmentLoaders,n=t[r],a=t.main,s=i.mediaTypes[r],o=s.activeTrack(),l=s.activeGroup(o),u=s.activePlaylistLoader;if(tf(n,s),!!l){if(!l.playlistLoader){u&&a.resetEverything();return}n.resyncLoader(),cg(l.playlistLoader,s)}}},Hk=function(r,i){return function(){var t=i.segmentLoaders,n=t[r],a=t.main,s=i.mediaTypes[r],o=s.activeTrack(),l=s.activeGroup(o),u=s.activePlaylistLoader;if(tf(n,s),!!l){if(!l.playlistLoader){a.resetEverything();return}if(u===l.playlistLoader){cg(l.playlistLoader,s);return}n.track&&n.track(o),n.resetEverything(),cg(l.playlistLoader,s)}}},rf={AUDIO:function(r,i){return function(){var t=i.segmentLoaders[r],n=i.mediaTypes[r],a=i.blacklistCurrentPlaylist;tf(t,n);var s=n.activeTrack(),o=n.activeGroup(),l=(o.filter(function(c){return c.default})[0]||o[0]).id,u=n.tracks[l];if(s===u){a({message:"Problem encountered loading the default audio track."});return}re.log.warn("Problem encountered loading the alternate audio track.Switching back to default.");for(var g in n.tracks)n.tracks[g].enabled=n.tracks[g]===u;n.onTrackChanged()}},SUBTITLES:function(r,i){return function(){var t=i.segmentLoaders[r],n=i.mediaTypes[r];re.log.warn("Problem encountered loading the subtitle track.Disabling subtitle track."),tf(t,n);var a=n.activeTrack();a&&(a.mode="disabled"),n.onTrackChanged()}}},Y_={AUDIO:function(r,i,t){if(!!i){var n=t.tech,a=t.requestOptions,s=t.segmentLoaders[r];i.on("loadedmetadata",function(){var o=i.media();s.playlist(o,a),(!n.paused()||o.endList&&n.preload()!=="none")&&s.load()}),i.on("loadedplaylist",function(){s.playlist(i.media(),a),n.paused()||s.load()}),i.on("error",rf[r](r,t))}},SUBTITLES:function(r,i,t){var n=t.tech,a=t.requestOptions,s=t.segmentLoaders[r],o=t.mediaTypes[r];i.on("loadedmetadata",function(){var l=i.media();s.playlist(l,a),s.track(o.activeTrack()),(!n.paused()||l.endList&&n.preload()!=="none")&&s.load()}),i.on("loadedplaylist",function(){s.playlist(i.media(),a),n.paused()||s.load()}),i.on("error",rf[r](r,t))}},Gk={AUDIO:function(r,i){var t=i.hls,n=i.sourceType,a=i.segmentLoaders[r],s=i.requestOptions,o=i.master.mediaGroups,l=i.mediaTypes[r],u=l.groups,g=l.tracks,c=i.masterPlaylistLoader;(!o[r]||Object.keys(o[r]).length===0)&&(o[r]={main:{default:{default:!0}}});for(var d in o[r]){u[d]||(u[d]=[]);for(var f in o[r][d]){var T=o[r][d][f],p=void 0;if(T.resolvedUri?p=new Xd(T.resolvedUri,t,s):T.playlists&&n==="dash"?p=new sg(T.playlists[0],t,s,c):p=null,T=re.mergeOptions({id:f,playlistLoader:p},T),Y_[r](r,T.playlistLoader,i),u[d].push(T),typeof g[f]>"u"){var y=new re.AudioTrack({id:f,kind:jk(T),enabled:!1,language:T.language,default:T.default,label:f});g[f]=y}}}a.on("error",rf[r](r,i))},SUBTITLES:function(r,i){var t=i.tech,n=i.hls,a=i.sourceType,s=i.segmentLoaders[r],o=i.requestOptions,l=i.master.mediaGroups,u=i.mediaTypes[r],g=u.groups,c=u.tracks,d=i.masterPlaylistLoader;for(var f in l[r]){g[f]||(g[f]=[]);for(var T in l[r][f])if(!l[r][f][T].forced){var p=l[r][f][T],y=void 0;if(a==="hls"?y=new Xd(p.resolvedUri,n,o):a==="dash"&&(y=new sg(p.playlists[0],n,o,d)),p=re.mergeOptions({id:T,playlistLoader:y},p),Y_[r](r,p.playlistLoader,i),g[f].push(p),typeof c[T]>"u"){var b=t.addRemoteTextTrack({id:T,kind:"subtitles",default:p.default&&p.autoselect,language:p.language,label:T},!1).track;c[T]=b}}}s.on("error",rf[r](r,i))},"CLOSED-CAPTIONS":function(r,i){var t=i.tech,n=i.master.mediaGroups,a=i.mediaTypes[r],s=a.groups,o=a.tracks;for(var l in n[r]){s[l]||(s[l]=[]);for(var u in n[r][l]){var g=n[r][l][u];if(!!g.instreamId.match(/CC\d/)&&(s[l].push(re.mergeOptions({id:u},g)),typeof o[u]>"u")){var c=t.addRemoteTextTrack({id:g.instreamId,kind:"captions",default:g.default&&g.autoselect,language:g.language,label:u},!1).track;o[u]=c}}}}},Vk=function(r,i){return function(t){var n=i.masterPlaylistLoader,a=i.mediaTypes[r].groups,s=n.media();if(!s)return null;var o=null;return s.attributes[r]&&(o=a[s.attributes[r]]),o=o||a.main,typeof t>"u"?o:t===null?null:o.filter(function(l){return l.id===t.id})[0]||null}},qk={AUDIO:function(r,i){return function(){var t=i.mediaTypes[r].tracks;for(var n in t)if(t[n].enabled)return t[n];return null}},SUBTITLES:function(r,i){return function(){var t=i.mediaTypes[r].tracks;for(var n in t)if(t[n].mode==="showing")return t[n];return null}}},Wk=function(r){["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(function(g){Gk[g](g,r)});var i=r.mediaTypes,t=r.masterPlaylistLoader,n=r.tech,a=r.hls;["AUDIO","SUBTITLES"].forEach(function(g){i[g].activeGroup=Vk(g,r),i[g].activeTrack=qk[g](g,r),i[g].onGroupChanged=$k(g,r),i[g].onTrackChanged=Hk(g,r)});var s=i.AUDIO.activeGroup(),o=(s.filter(function(g){return g.default})[0]||s[0]).id;i.AUDIO.tracks[o].enabled=!0,i.AUDIO.onTrackChanged(),t.on("mediachange",function(){["AUDIO","SUBTITLES"].forEach(function(g){return i[g].onGroupChanged()})});var l=function(){i.AUDIO.onTrackChanged(),n.trigger({type:"usage",name:"hls-audio-change"})};n.audioTracks().addEventListener("change",l),n.remoteTextTracks().addEventListener("change",i.SUBTITLES.onTrackChanged),a.on("dispose",function(){n.audioTracks().removeEventListener("change",l),n.remoteTextTracks().removeEventListener("change",i.SUBTITLES.onTrackChanged)}),n.clearTracks("audio");for(var u in i.AUDIO.tracks)n.audioTracks().addTrack(i.AUDIO.tracks[u])},Yk=function(){var r={};return["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(function(i){r[i]={groups:{},tracks:{},activePlaylistLoader:null,activeGroup:wl,activeTrack:wl,onGroupChanged:wl,onTrackChanged:wl}}),r},Kk=60*2,Ro=void 0,zk=["mediaRequests","mediaRequestsAborted","mediaRequestsTimedout","mediaRequestsErrored","mediaTransferDuration","mediaBytesTransferred"],Xk=function(r){return this.audioSegmentLoader_[r]+this.mainSegmentLoader_[r]},Jk=function(e){Gs(r,e);function r(i){Aa(this,r);var t=hs(this,(r.__proto__||Object.getPrototypeOf(r)).call(this)),n=i.url,a=i.handleManifestRedirects,s=i.withCredentials,o=i.tech,l=i.bandwidth,u=i.externHls,g=i.useCueTags,c=i.blacklistDuration,d=i.enableLowInitialPlaylist,f=i.sourceType,T=i.seekTo,p=i.cacheEncryptionKeys;if(!n)throw new Error("A non-empty playlist URL is required");Ro=u,t.withCredentials=s,t.tech_=o,t.hls_=o.hls,t.seekTo_=T,t.sourceType_=f,t.useCueTags_=g,t.blacklistDuration=c,t.enableLowInitialPlaylist=d,t.useCueTags_&&(t.cueTagsTrack_=t.tech_.addTextTrack("metadata","ad-cues"),t.cueTagsTrack_.inBandMetadataTrackDispatchType=""),t.requestOptions_={withCredentials:s,handleManifestRedirects:a,timeout:null},t.mediaTypes_=Yk(),t.mediaSource=new re.MediaSource,t.mediaSource.addEventListener("sourceopen",t.handleSourceOpen_.bind(t)),t.seekable_=re.createTimeRanges(),t.hasPlayed_=function(){return!1},t.syncController_=new Uk(i),t.segmentMetadataTrack_=o.addRemoteTextTrack({kind:"metadata",label:"segment-metadata"},!1).track,t.decrypter_=new Bk,t.inbandTextTracks_={};var y={hls:t.hls_,mediaSource:t.mediaSource,currentTime:t.tech_.currentTime.bind(t.tech_),seekable:function(){return t.seekable()},seeking:function(){return t.tech_.seeking()},duration:function(){return t.mediaSource.duration},hasPlayed:function(){return t.hasPlayed_()},goalBufferLength:function(){return t.goalBufferLength()},bandwidth:l,syncController:t.syncController_,decrypter:t.decrypter_,sourceType:t.sourceType_,inbandTextTracks:t.inbandTextTracks_,cacheEncryptionKeys:p};return t.masterPlaylistLoader_=t.sourceType_==="dash"?new sg(n,t.hls_,t.requestOptions_):new Xd(n,t.hls_,t.requestOptions_),t.setupMasterPlaylistLoaderListeners_(),t.mainSegmentLoader_=new lg(re.mergeOptions(y,{segmentMetadataTrack:t.segmentMetadataTrack_,loaderType:"main"}),i),t.audioSegmentLoader_=new lg(re.mergeOptions(y,{loaderType:"audio"}),i),t.subtitleSegmentLoader_=new Ik(re.mergeOptions(y,{loaderType:"vtt"}),i),t.setupSegmentLoaderListeners_(),zk.forEach(function(b){t[b+"_"]=Xk.bind(t,b)}),t.logger_=Oc("MPC"),t.masterPlaylistLoader_.load(),t}return Va(r,[{key:"setupMasterPlaylistLoaderListeners_",value:function(){var t=this;this.masterPlaylistLoader_.on("loadedmetadata",function(){var n=t.masterPlaylistLoader_.media(),a=n.targetDuration*1.5*1e3;Qp(t.masterPlaylistLoader_.master,t.masterPlaylistLoader_.media())?t.requestOptions_.timeout=0:t.requestOptions_.timeout=a,n.endList&&t.tech_.preload()!=="none"&&(t.mainSegmentLoader_.playlist(n,t.requestOptions_),t.mainSegmentLoader_.load()),Wk({sourceType:t.sourceType_,segmentLoaders:{AUDIO:t.audioSegmentLoader_,SUBTITLES:t.subtitleSegmentLoader_,main:t.mainSegmentLoader_},tech:t.tech_,requestOptions:t.requestOptions_,masterPlaylistLoader:t.masterPlaylistLoader_,hls:t.hls_,master:t.master(),mediaTypes:t.mediaTypes_,blacklistCurrentPlaylist:t.blacklistCurrentPlaylist.bind(t)}),t.triggerPresenceUsage_(t.master(),n);try{t.setupSourceBuffers_()}catch(s){return re.log.warn("Failed to create SourceBuffers",s),t.mediaSource.endOfStream("decode")}t.setupFirstPlay(),!t.mediaTypes_.AUDIO.activePlaylistLoader||t.mediaTypes_.AUDIO.activePlaylistLoader.media()?t.trigger("selectedinitialmedia"):t.mediaTypes_.AUDIO.activePlaylistLoader.one("loadedmetadata",function(){t.trigger("selectedinitialmedia")})}),this.masterPlaylistLoader_.on("loadedplaylist",function(){var n=t.masterPlaylistLoader_.media();if(!n){t.excludeUnsupportedVariants_();var a=void 0;t.enableLowInitialPlaylist&&(a=t.selectInitialPlaylist()),a||(a=t.selectPlaylist()),t.initialMedia_=a,t.masterPlaylistLoader_.media(t.initialMedia_);return}if(t.useCueTags_&&t.updateAdCues_(n),t.mainSegmentLoader_.playlist(n,t.requestOptions_),t.updateDuration(),t.tech_.paused()||(t.mainSegmentLoader_.load(),t.audioSegmentLoader_&&t.audioSegmentLoader_.load()),!n.endList){var s=function(){var u=t.seekable();u.length!==0&&t.mediaSource.addSeekableRange_(u.start(0),u.end(0))};if(t.duration()!==1/0){var o=function l(){t.duration()===1/0?s():t.tech_.one("durationchange",l)};t.tech_.one("durationchange",o)}else s()}}),this.masterPlaylistLoader_.on("error",function(){t.blacklistCurrentPlaylist(t.masterPlaylistLoader_.error)}),this.masterPlaylistLoader_.on("mediachanging",function(){t.mainSegmentLoader_.abort(),t.mainSegmentLoader_.pause()}),this.masterPlaylistLoader_.on("mediachange",function(){var n=t.masterPlaylistLoader_.media(),a=n.targetDuration*1.5*1e3;Qp(t.masterPlaylistLoader_.master,t.masterPlaylistLoader_.media())?t.requestOptions_.timeout=0:t.requestOptions_.timeout=a,t.mainSegmentLoader_.playlist(n,t.requestOptions_),t.mainSegmentLoader_.load(),t.tech_.trigger({type:"mediachange",bubbles:!0})}),this.masterPlaylistLoader_.on("playlistunchanged",function(){var n=t.masterPlaylistLoader_.media(),a=t.stuckAtPlaylistEnd_(n);a&&(t.blacklistCurrentPlaylist({message:"Playlist no longer updating."}),t.tech_.trigger("playliststuck"))}),this.masterPlaylistLoader_.on("renditiondisabled",function(){t.tech_.trigger({type:"usage",name:"hls-rendition-disabled"})}),this.masterPlaylistLoader_.on("renditionenabled",function(){t.tech_.trigger({type:"usage",name:"hls-rendition-enabled"})})}},{key:"triggerPresenceUsage_",value:function(t,n){var a=t.mediaGroups||{},s=!0,o=Object.keys(a.AUDIO);for(var l in a.AUDIO)for(var u in a.AUDIO[l]){var g=a.AUDIO[l][u];g.uri||(s=!1)}s&&this.tech_.trigger({type:"usage",name:"hls-demuxed"}),Object.keys(a.SUBTITLES).length&&this.tech_.trigger({type:"usage",name:"hls-webvtt"}),Ro.Playlist.isAes(n)&&this.tech_.trigger({type:"usage",name:"hls-aes"}),Ro.Playlist.isFmp4(n)&&this.tech_.trigger({type:"usage",name:"hls-fmp4"}),o.length&&Object.keys(a.AUDIO[o[0]]).length>1&&this.tech_.trigger({type:"usage",name:"hls-alternate-audio"}),this.useCueTags_&&this.tech_.trigger({type:"usage",name:"hls-playlist-cue-tags"})}},{key:"setupSegmentLoaderListeners_",value:function(){var t=this;this.mainSegmentLoader_.on("bandwidthupdate",function(){var n=t.selectPlaylist(),a=t.masterPlaylistLoader_.media(),s=t.tech_.buffered(),o=s.length?s.end(s.length-1)-t.tech_.currentTime():0,l=t.bufferLowWaterLine();(!a.endList||t.duration()<ua.MAX_BUFFER_LOW_WATER_LINE||n.attributes.BANDWIDTH<a.attributes.BANDWIDTH||o>=l)&&t.masterPlaylistLoader_.media(n),t.tech_.trigger("bandwidthupdate")}),this.mainSegmentLoader_.on("progress",function(){t.trigger("progress")}),this.mainSegmentLoader_.on("error",function(){t.blacklistCurrentPlaylist(t.mainSegmentLoader_.error())}),this.mainSegmentLoader_.on("syncinfoupdate",function(){t.onSyncInfoUpdate_()}),this.mainSegmentLoader_.on("timestampoffset",function(){t.tech_.trigger({type:"usage",name:"hls-timestamp-offset"})}),this.audioSegmentLoader_.on("syncinfoupdate",function(){t.onSyncInfoUpdate_()}),this.mainSegmentLoader_.on("ended",function(){t.onEndOfStream()}),this.mainSegmentLoader_.on("earlyabort",function(){t.blacklistCurrentPlaylist({message:"Aborted early because there isn't enough bandwidth to complete the request without rebuffering."},Kk)}),this.mainSegmentLoader_.on("reseteverything",function(){t.tech_.trigger("hls-reset")}),this.mainSegmentLoader_.on("segmenttimemapping",function(n){t.tech_.trigger({type:"hls-segment-time-mapping",mapping:n.mapping})}),this.audioSegmentLoader_.on("ended",function(){t.onEndOfStream()})}},{key:"mediaSecondsLoaded_",value:function(){return Math.max(this.audioSegmentLoader_.mediaSecondsLoaded+this.mainSegmentLoader_.mediaSecondsLoaded)}},{key:"load",value:function(){this.mainSegmentLoader_.load(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.load(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.load()}},{key:"smoothQualityChange_",value:function(){var t=this.selectPlaylist();t!==this.masterPlaylistLoader_.media()&&(this.masterPlaylistLoader_.media(t),this.mainSegmentLoader_.resetLoader())}},{key:"fastQualityChange_",value:function(){var t=this,n=this.selectPlaylist();n!==this.masterPlaylistLoader_.media()&&(this.masterPlaylistLoader_.media(n),this.mainSegmentLoader_.resetEverything(function(){re.browser.IE_VERSION||re.browser.IS_EDGE?t.tech_.setCurrentTime(t.tech_.currentTime()+.04):t.tech_.setCurrentTime(t.tech_.currentTime())}))}},{key:"play",value:function(){if(!this.setupFirstPlay()){this.tech_.ended()&&this.seekTo_(0),this.hasPlayed_()&&this.load();var t=this.tech_.seekable();if(this.tech_.duration()===1/0&&this.tech_.currentTime()<t.start(0))return this.seekTo_(t.end(t.length-1))}}},{key:"setupFirstPlay",value:function(){var t=this,n=this.masterPlaylistLoader_.media();if(!n||this.tech_.paused()||this.hasPlayed_())return!1;if(!n.endList){var a=this.seekable();if(!a.length)return!1;if(re.browser.IE_VERSION&&this.tech_.readyState()===0)return this.tech_.one("loadedmetadata",function(){t.trigger("firstplay"),t.seekTo_(a.end(0)),t.hasPlayed_=function(){return!0}}),!1;this.trigger("firstplay"),this.seekTo_(a.end(0))}return this.hasPlayed_=function(){return!0},this.load(),!0}},{key:"handleSourceOpen_",value:function(){try{this.setupSourceBuffers_()}catch(n){return re.log.warn("Failed to create Source Buffers",n),this.mediaSource.endOfStream("decode")}if(this.tech_.autoplay()){var t=this.tech_.play();typeof t<"u"&&typeof t.then=="function"&&t.then(null,function(n){})}this.trigger("sourceopen")}},{key:"onEndOfStream",value:function(){var t=this.mainSegmentLoader_.ended_;if(this.mediaTypes_.AUDIO.activePlaylistLoader&&(!this.mainSegmentLoader_.startingMedia_||this.mainSegmentLoader_.startingMedia_.containsVideo?t=t&&this.audioSegmentLoader_.ended_:t=this.audioSegmentLoader_.ended_),!!t){this.logger_("calling mediaSource.endOfStream()");try{this.mediaSource.endOfStream()}catch(n){re.log.warn("Failed to call media source endOfStream",n)}}}},{key:"stuckAtPlaylistEnd_",value:function(t){var n=this.seekable();if(!n.length)return!1;var a=this.syncController_.getExpiredTime(t,this.mediaSource.duration);if(a===null)return!1;var s=Ro.Playlist.playlistEnd(t,a),o=this.tech_.currentTime(),l=this.tech_.buffered();if(!l.length)return s-o<=Vs;var u=l.end(l.length-1);return u-o<=Vs&&s-u<=Vs}},{key:"blacklistCurrentPlaylist",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments[1],a=void 0,s=void 0;if(a=t.playlist||this.masterPlaylistLoader_.media(),n=n||t.blacklistDuration||this.blacklistDuration,!a){this.error=t;try{return this.mediaSource.endOfStream("network")}catch{return this.trigger("error")}}var o=this.masterPlaylistLoader_.master.playlists.filter(Jd).length===1,l=this.masterPlaylistLoader_.master.playlists;return l.length===1?(re.log.warn("Problem encountered with the current HLS playlist. Trying again since it is the only playlist."),this.tech_.trigger("retryplaylist"),this.masterPlaylistLoader_.load(o)):(o&&(re.log.warn("Removing all playlists from the blacklist because the last rendition is about to be blacklisted."),l.forEach(function(u){u.excludeUntil!==1/0&&delete u.excludeUntil}),this.tech_.trigger("retryplaylist")),a.excludeUntil=Date.now()+n*1e3,this.tech_.trigger("blacklistplaylist"),this.tech_.trigger({type:"usage",name:"hls-rendition-blacklisted"}),s=this.selectPlaylist(),re.log.warn("Problem encountered with the current HLS playlist."+(t.message?" "+t.message:"")+" Switching to another playlist."),this.masterPlaylistLoader_.media(s,o))}},{key:"pauseLoading",value:function(){this.mainSegmentLoader_.pause(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.pause(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.pause()}},{key:"setCurrentTime",value:function(t){var n=S_(this.tech_.buffered(),t);if(!(this.masterPlaylistLoader_&&this.masterPlaylistLoader_.media())||!this.masterPlaylistLoader_.media().segments)return 0;if(n&&n.length)return t;this.mainSegmentLoader_.resetEverything(),this.mainSegmentLoader_.abort(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.resetEverything(),this.audioSegmentLoader_.abort()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.resetEverything(),this.subtitleSegmentLoader_.abort()),this.load()}},{key:"duration",value:function(){return this.masterPlaylistLoader_?this.mediaSource?this.mediaSource.duration:Ro.Playlist.duration(this.masterPlaylistLoader_.media()):0}},{key:"seekable",value:function(){return this.seekable_}},{key:"onSyncInfoUpdate_",value:function(){var t=void 0,n=void 0;if(!!this.masterPlaylistLoader_){var a=this.masterPlaylistLoader_.media();if(!!a){var s=this.syncController_.getExpiredTime(a,this.mediaSource.duration);if(s!==null&&(t=Ro.Playlist.seekable(a,s),t.length!==0&&!(this.mediaTypes_.AUDIO.activePlaylistLoader&&(a=this.mediaTypes_.AUDIO.activePlaylistLoader.media(),s=this.syncController_.getExpiredTime(a,this.mediaSource.duration),s===null||(n=Ro.Playlist.seekable(a,s),n.length===0))))){var o=void 0,l=void 0;this.seekable_&&this.seekable_.length&&(o=this.seekable_.end(0),l=this.seekable_.start(0)),n?n.start(0)>t.end(0)||t.start(0)>n.end(0)?this.seekable_=t:this.seekable_=re.createTimeRanges([[n.start(0)>t.start(0)?n.start(0):t.start(0),n.end(0)<t.end(0)?n.end(0):t.end(0)]]):this.seekable_=t,!(this.seekable_&&this.seekable_.length&&this.seekable_.end(0)===o&&this.seekable_.start(0)===l)&&(this.logger_("seekable updated ["+eg(this.seekable_)+"]"),this.tech_.trigger("seekablechanged"))}}}}},{key:"updateDuration",value:function(){var t=this,n=this.mediaSource.duration,a=Ro.Playlist.duration(this.masterPlaylistLoader_.media()),s=this.tech_.buffered(),o=function l(){t.logger_("Setting duration from "+t.mediaSource.duration+" => "+a);try{t.mediaSource.duration=a}catch(u){re.log.warn("Failed to set media source duration",u)}t.tech_.trigger("durationchange"),t.mediaSource.removeEventListener("sourceopen",l)};s.length>0&&(a=Math.max(a,s.end(s.length-1))),n!==a&&(this.mediaSource.readyState!=="open"?this.mediaSource.addEventListener("sourceopen",o):o())}},{key:"dispose",value:function(){var t=this;this.decrypter_.terminate(),this.masterPlaylistLoader_.dispose(),this.mainSegmentLoader_.dispose(),["AUDIO","SUBTITLES"].forEach(function(n){var a=t.mediaTypes_[n].groups;for(var s in a)a[s].forEach(function(o){o.playlistLoader&&o.playlistLoader.dispose()})}),this.audioSegmentLoader_.dispose(),this.subtitleSegmentLoader_.dispose()}},{key:"master",value:function(){return this.masterPlaylistLoader_.master}},{key:"media",value:function(){return this.masterPlaylistLoader_.media()||this.initialMedia_}},{key:"setupSourceBuffers_",value:function(){var t=this.masterPlaylistLoader_.media(),n=void 0;if(!(!t||this.mediaSource.readyState!=="open")){if(n=tk(this.masterPlaylistLoader_.master,t),n.length<1)return this.error="No compatible SourceBuffer configuration for the variant stream:"+t.resolvedUri,this.mediaSource.endOfStream("decode");this.configureLoaderMimeTypes_(n),this.excludeIncompatibleVariants_(t)}}},{key:"configureLoaderMimeTypes_",value:function(t){var n=t.length>1&&t[0].indexOf(",")===-1&&t[0]!==t[1]?new re.EventTarget:null;this.mainSegmentLoader_.mimeType(t[0],n),t[1]&&this.audioSegmentLoader_.mimeType(t[1],n)}},{key:"excludeUnsupportedVariants_",value:function(){this.master().playlists.forEach(function(t){t.attributes.CODECS&&Be.MediaSource&&Be.MediaSource.isTypeSupported&&!Be.MediaSource.isTypeSupported('video/mp4; codecs="'+J1(t.attributes.CODECS)+'"')&&(t.excludeUntil=1/0)})}},{key:"excludeIncompatibleVariants_",value:function(t){var n=2,a=null,s=void 0;t.attributes.CODECS&&(s=Dc(t.attributes.CODECS),a=s.videoCodec,n=s.codecCount),this.master().playlists.forEach(function(o){var l={codecCount:2,videoCodec:null};o.attributes.CODECS&&(l=Dc(o.attributes.CODECS)),l.codecCount!==n&&(o.excludeUntil=1/0),l.videoCodec!==a&&(o.excludeUntil=1/0)})}},{key:"updateAdCues_",value:function(t){var n=0,a=this.seekable();a.length&&(n=a.start(0)),Nk(t,this.cueTagsTrack_,n)}},{key:"goalBufferLength",value:function(){var t=this.tech_.currentTime(),n=ua.GOAL_BUFFER_LENGTH,a=ua.GOAL_BUFFER_LENGTH_RATE,s=Math.max(n,ua.MAX_GOAL_BUFFER_LENGTH);return Math.min(n+t*a,s)}},{key:"bufferLowWaterLine",value:function(){var t=this.tech_.currentTime(),n=ua.BUFFER_LOW_WATER_LINE,a=ua.BUFFER_LOW_WATER_LINE_RATE,s=Math.max(n,ua.MAX_BUFFER_LOW_WATER_LINE);return Math.min(n+t*a,s)}}]),r}(re.EventTarget),Qk=function(r,i,t){return function(n){var a=r.master.playlists[i],s=Jp(a),o=Jd(a);return typeof n>"u"?o:(n?delete a.disabled:a.disabled=!0,n!==o&&!s&&(t(),n?r.trigger("renditionenabled"):r.trigger("renditiondisabled")),n)}},Zk=function e(r,i,t){Aa(this,e);var n=r.masterPlaylistController_,a=r.options_.smoothQualityChange,s=a?"smooth":"fast",o=n[s+"QualityChange_"].bind(n);if(i.attributes.RESOLUTION){var l=i.attributes.RESOLUTION;this.width=l.width,this.height=l.height}this.bandwidth=i.attributes.BANDWIDTH,this.id=t,this.enabled=Qk(r.playlists,i.uri,o)},eR=function(r){var i=r.playlists;r.representations=function(){return i.master.playlists.filter(function(t){return!Jp(t)}).map(function(t,n){return new Zk(r,t,t.uri)})}},K_=["seeking","seeked","pause","playing","error"],tR=function(){function e(r){var i=this;Aa(this,e),this.tech_=r.tech,this.seekable=r.seekable,this.seekTo=r.seekTo,this.allowSeeksWithinUnsafeLiveWindow=r.allowSeeksWithinUnsafeLiveWindow,this.media=r.media,this.consecutiveUpdates=0,this.lastRecordedTime=null,this.timer_=null,this.checkCurrentTimeTimeout_=null,this.logger_=Oc("PlaybackWatcher"),this.logger_("initialize");var t=function(){return i.monitorCurrentTime_()},n=function(){return i.techWaiting_()},a=function(){return i.cancelTimer_()},s=function(){return i.fixesBadSeeks_()};this.tech_.on("seekablechanged",s),this.tech_.on("waiting",n),this.tech_.on(K_,a),this.tech_.on("canplay",t),this.dispose=function(){i.logger_("dispose"),i.tech_.off("seekablechanged",s),i.tech_.off("waiting",n),i.tech_.off(K_,a),i.tech_.off("canplay",t),i.checkCurrentTimeTimeout_&&Be.clearTimeout(i.checkCurrentTimeTimeout_),i.cancelTimer_()}}return Va(e,[{key:"monitorCurrentTime_",value:function(){this.checkCurrentTime_(),this.checkCurrentTimeTimeout_&&Be.clearTimeout(this.checkCurrentTimeTimeout_),this.checkCurrentTimeTimeout_=Be.setTimeout(this.monitorCurrentTime_.bind(this),250)}},{key:"checkCurrentTime_",value:function(){if(this.tech_.seeking()&&this.fixesBadSeeks_()){this.consecutiveUpdates=0,this.lastRecordedTime=this.tech_.currentTime();return}if(!(this.tech_.paused()||this.tech_.seeking())){var i=this.tech_.currentTime(),t=this.tech_.buffered();if(this.lastRecordedTime===i&&(!t.length||i+Vs>=t.end(t.length-1)))return this.techWaiting_();this.consecutiveUpdates>=5&&i===this.lastRecordedTime?(this.consecutiveUpdates++,this.waiting_()):i===this.lastRecordedTime?this.consecutiveUpdates++:(this.consecutiveUpdates=0,this.lastRecordedTime=i)}}},{key:"cancelTimer_",value:function(){this.consecutiveUpdates=0,this.timer_&&(this.logger_("cancelTimer_"),clearTimeout(this.timer_)),this.timer_=null}},{key:"fixesBadSeeks_",value:function(){var i=this.tech_.seeking();if(!i)return!1;var t=this.seekable(),n=this.tech_.currentTime(),a=this.afterSeekableWindow_(t,n,this.media(),this.allowSeeksWithinUnsafeLiveWindow),s=void 0;if(a){var o=t.end(t.length-1);s=o}if(this.beforeSeekableWindow_(t,n)){var l=t.start(0);s=l+Vs}return typeof s<"u"?(this.logger_("Trying to seek outside of seekable at time "+n+" with "+("seekable range "+eg(t)+". Seeking to ")+(s+".")),this.seekTo(s),!0):!1}},{key:"waiting_",value:function(){if(!this.techWaiting_()){var i=this.tech_.currentTime(),t=this.tech_.buffered(),n=S_(t,i);if(n.length&&i+3<=n.end(0)){this.cancelTimer_(),this.seekTo(i),this.logger_("Stopped at "+i+" 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:"hls-unknown-waiting"});return}}}},{key:"techWaiting_",value:function(){var i=this.seekable(),t=this.tech_.currentTime();if(this.tech_.seeking()&&this.fixesBadSeeks_()||this.tech_.seeking()||this.timer_!==null)return!0;if(this.beforeSeekableWindow_(i,t)){var n=i.end(i.length-1);return this.logger_("Fell out of live window at time "+t+". Seeking to "+("live point (seekable end) "+n)),this.cancelTimer_(),this.seekTo(n),this.tech_.trigger({type:"usage",name:"hls-live-resync"}),!0}var a=this.tech_.buffered(),s=E_(a,t);if(this.videoUnderflow_(s,a,t))return this.cancelTimer_(),this.seekTo(t),this.tech_.trigger({type:"usage",name:"hls-video-underflow"}),!0;if(s.length>0){var o=s.start(0)-t;return this.logger_("Stopped at "+t+", setting timer for "+o+", seeking "+("to "+s.start(0))),this.timer_=setTimeout(this.skipTheGap_.bind(this),o*1e3,t),!0}return!1}},{key:"afterSeekableWindow_",value:function(i,t,n){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!i.length)return!1;var s=i.end(i.length-1)+Vs,o=!n.endList;return o&&a&&(s=i.end(i.length-1)+n.targetDuration*3),t>s}},{key:"beforeSeekableWindow_",value:function(i,t){return!!(i.length&&i.start(0)>0&&t<i.start(0)-Vs)}},{key:"videoUnderflow_",value:function(i,t,n){if(i.length===0){var a=this.gapFromVideoUnderflow_(t,n);if(a)return this.logger_("Encountered a gap in video from "+a.start+" to "+a.end+". "+("Seeking to current time "+n)),!0}return!1}},{key:"skipTheGap_",value:function(i){var t=this.tech_.buffered(),n=this.tech_.currentTime(),a=E_(t,n);this.cancelTimer_(),!(a.length===0||n!==i)&&(this.logger_("skipTheGap_:","currentTime:",n,"scheduled currentTime:",i,"nextRange start:",a.start(0)),this.seekTo(a.start(0)+Zd),this.tech_.trigger({type:"usage",name:"hls-gap-skip"}))}},{key:"gapFromVideoUnderflow_",value:function(i,t){for(var n=H1(i),a=0;a<n.length;a++){var s=n.start(a),o=n.end(a);if(t-s<4&&t-s>2)return{start:s,end:o}}return null}}]),e}(),rR={errorInterval:30,getSource:function(r){var i=this.tech({IWillNotUseThisInPlugins:!0}),t=i.currentSource_;return r(t)}},iR=function e(r,i){var t=0,n=0,a=re.mergeOptions(rR,i);r.ready(function(){r.trigger({type:"usage",name:"hls-error-reload-initialized"})});var s=function(){n&&r.currentTime(n)},o=function(d){d!=null&&(n=r.duration()!==1/0&&r.currentTime()||0,r.one("loadedmetadata",s),r.src(d),r.trigger({type:"usage",name:"hls-error-reload"}),r.play())},l=function(){if(Date.now()-t<a.errorInterval*1e3){r.trigger({type:"usage",name:"hls-error-reload-canceled"});return}if(!a.getSource||typeof a.getSource!="function"){re.log.error("ERROR: reloadSourceOnError - The option getSource must be a function!");return}return t=Date.now(),a.getSource.call(r,o)},u=function c(){r.off("loadedmetadata",s),r.off("error",l),r.off("dispose",c)},g=function(d){u(),e(r,d)};r.on("error",l),r.on("dispose",u),r.reloadSourceOnError=g},z_=function(r){iR(this,r)},nR="1.10.6";re.use("*",function(e){return{setSource:function(i,t){t(null,i)},setCurrentTime:function(i){return e.vhs&&e.currentSource().src===e.vhs.source_.src&&e.vhs.setCurrentTime(i),i},play:function(){e.vhs&&e.currentSource().src===e.vhs.source_.src&&e.vhs.setCurrentTime(e.tech_.currentTime())}}});var Xn={PlaylistLoader:Xd,Playlist:zn,Decrypter:FA,AsyncStream:yy,decrypt:_y,utils:L1,STANDARD_PLAYLIST_SELECTOR:xk,INITIAL_PLAYLIST_SELECTOR:Ak,comparePlaylistBandwidth:ug,comparePlaylistResolution:Sk,xhr:v_()};["GOAL_BUFFER_LENGTH","MAX_GOAL_BUFFER_LENGTH","GOAL_BUFFER_LENGTH_RATE","BUFFER_LOW_WATER_LINE","MAX_BUFFER_LOW_WATER_LINE","BUFFER_LOW_WATER_LINE_RATE","BANDWIDTH_VARIANCE"].forEach(function(e){Object.defineProperty(Xn,e,{get:function(){return re.log.warn("using Hls."+e+" is UNSAFE be sure you know what you are doing"),ua[e]},set:function(i){if(re.log.warn("using Hls."+e+" is UNSAFE be sure you know what you are doing"),typeof i!="number"||i<0){re.log.warn("value of Hls."+e+" must be greater than or equal to 0");return}ua[e]=i}})});var X_="videojs-vhs",J_=function(r){var i=/^(audio|video|application)\/(x-|vnd\.apple\.)?mpegurl/i;if(i.test(r))return"hls";var t=/^application\/dash\+xml/i;return t.test(r)?"dash":null},Q_=function(r,i){for(var t=i.media(),n=-1,a=0;a<r.length;a++)if(r[a].id===t.uri){n=a;break}r.selectedIndex_=n,r.trigger({selectedIndex:n,type:"change"})},aR=function(r,i){i.representations().forEach(function(t){r.addQualityLevel(t)}),Q_(r,i.playlists)};Xn.canPlaySource=function(){return re.log.warn("HLS is no longer a tech. Please remove it from your player's techOrder.")};var sR=function(r,i,t){if(!r)return r;var n={};for(var a in r)n[a]={audioContentType:'audio/mp4; codecs="'+t.attributes.CODECS+'"',videoContentType:'video/mp4; codecs="'+i.attributes.CODECS+'"'},i.contentProtection&&i.contentProtection[a]&&i.contentProtection[a].pssh&&(n[a].pssh=i.contentProtection[a].pssh),typeof r[a]=="string"&&(n[a].url=r[a]);return re.mergeOptions(r,n)},oR=function(r){if(r.options_.sourceType==="dash"){var i=re.players[r.tech_.options_.playerId];if(i.eme){var t=sR(r.source_.keySystems,r.playlists.media(),r.masterPlaylistController_.mediaTypes_.AUDIO.activePlaylistLoader.media());t&&(i.currentSource().keySystems=t,i.eme.initializeMediaKeys&&i.eme.initializeMediaKeys())}}},Z_=function(){if(!window.localStorage)return null;var r=window.localStorage.getItem(X_);if(!r)return null;try{return JSON.parse(r)}catch{return null}},uR=function(r){if(!window.localStorage)return!1;var i=Z_();i=i?re.mergeOptions(i,r):r;try{window.localStorage.setItem(X_,JSON.stringify(i))}catch{return!1}return i};Xn.supportsNativeHls=function(){var e=Mt.createElement("video");if(!re.getTech("Html5").isSupported())return!1;var r=["application/vnd.apple.mpegurl","audio/mpegurl","audio/x-mpegurl","application/x-mpegurl","video/x-mpegurl","video/mpegurl","application/mpegurl"];return r.some(function(i){return/maybe|probably/i.test(e.canPlayType(i))})}(),Xn.supportsNativeDash=function(){return re.getTech("Html5").isSupported()?/maybe|probably/i.test(Mt.createElement("video").canPlayType("application/dash+xml")):!1}(),Xn.supportsTypeNatively=function(e){return e==="hls"?Xn.supportsNativeHls:e==="dash"?Xn.supportsNativeDash:!1},Xn.isSupported=function(){return re.log.warn("HLS is no longer a tech. Please remove it from your player's techOrder.")};var lR=re.getComponent("Component"),eb=function(e){Gs(r,e);function r(i,t,n){Aa(this,r);var a=hs(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,t,n.hls));if(t.options_&&t.options_.playerId){var s=re(t.options_.playerId);s.hasOwnProperty("hls")||Object.defineProperty(s,"hls",{get:function(){return re.log.warn("player.hls is deprecated. Use player.tech().hls instead."),t.trigger({type:"usage",name:"hls-player-access"}),a},configurable:!0}),s.vhs=a,s.dash=a,a.player_=s}if(a.tech_=t,a.source_=i,a.stats={},a.setOptions_(),a.options_.overrideNative&&t.overrideNativeAudioTracks&&t.overrideNativeVideoTracks)t.overrideNativeAudioTracks(!0),t.overrideNativeVideoTracks(!0);else if(a.options_.overrideNative&&(t.featuresNativeVideoTracks||t.featuresNativeAudioTracks))throw new Error("Overriding native HLS requires emulated tracks. See https://git.io/vMpjB");return a.on(Mt,["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],function(o){var l=Mt.fullscreenElement||Mt.webkitFullscreenElement||Mt.mozFullScreenElement||Mt.msFullscreenElement;l&&l.contains(a.tech_.el())&&a.masterPlaylistController_.smoothQualityChange_()}),a.on(a.tech_,"seeking",function(){this.tech_.currentTime()===0&&this.tech_.player_.loop()&&this.setCurrentTime(0)}),a.on(a.tech_,"error",function(){this.masterPlaylistController_&&this.masterPlaylistController_.pauseLoading()}),a.on(a.tech_,"play",a.play),a}return Va(r,[{key:"setOptions_",value:function(){var t=this;if(this.options_.withCredentials=this.options_.withCredentials||!1,this.options_.handleManifestRedirects=this.options_.handleManifestRedirects||!1,this.options_.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions!==!1,this.options_.smoothQualityChange=this.options_.smoothQualityChange||!1,this.options_.useBandwidthFromLocalStorage=typeof this.source_.useBandwidthFromLocalStorage<"u"?this.source_.useBandwidthFromLocalStorage:this.options_.useBandwidthFromLocalStorage||!1,this.options_.customTagParsers=this.options_.customTagParsers||[],this.options_.customTagMappers=this.options_.customTagMappers||[],this.options_.cacheEncryptionKeys=this.options_.cacheEncryptionKeys||!1,typeof this.options_.blacklistDuration!="number"&&(this.options_.blacklistDuration=5*60),typeof this.options_.bandwidth!="number"&&this.options_.useBandwidthFromLocalStorage){var n=Z_();n&&n.bandwidth&&(this.options_.bandwidth=n.bandwidth,this.tech_.trigger({type:"usage",name:"hls-bandwidth-from-local-storage"})),n&&n.throughput&&(this.options_.throughput=n.throughput,this.tech_.trigger({type:"usage",name:"hls-throughput-from-local-storage"}))}typeof this.options_.bandwidth!="number"&&(this.options_.bandwidth=ua.INITIAL_BANDWIDTH),this.options_.enableLowInitialPlaylist=this.options_.enableLowInitialPlaylist&&this.options_.bandwidth===ua.INITIAL_BANDWIDTH,["withCredentials","limitRenditionByPlayerDimensions","bandwidth","smoothQualityChange","customTagParsers","customTagMappers","handleManifestRedirects","cacheEncryptionKeys"].forEach(function(a){typeof t.source_[a]<"u"&&(t.options_[a]=t.source_[a])}),this.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions}},{key:"src",value:function(t,n){var a=this;!t||(this.setOptions_(),this.options_.url=this.source_.src,this.options_.tech=this.tech_,this.options_.externHls=Xn,this.options_.sourceType=J_(n),this.options_.seekTo=function(s){a.tech_.setCurrentTime(s),a.setCurrentTime(s)},this.masterPlaylistController_=new Jk(this.options_),this.playbackWatcher_=new tR(re.mergeOptions(this.options_,{seekable:function(){return a.seekable()},media:function(){return a.masterPlaylistController_.media()}})),this.masterPlaylistController_.on("error",function(){var s=re.players[a.tech_.options_.playerId];s.error(a.masterPlaylistController_.error)}),this.masterPlaylistController_.selectPlaylist=this.selectPlaylist?this.selectPlaylist.bind(this):Xn.STANDARD_PLAYLIST_SELECTOR.bind(this),this.masterPlaylistController_.selectInitialPlaylist=Xn.INITIAL_PLAYLIST_SELECTOR.bind(this),this.playlists=this.masterPlaylistController_.masterPlaylistLoader_,this.mediaSource=this.masterPlaylistController_.mediaSource,Object.defineProperties(this,{selectPlaylist:{get:function(){return this.masterPlaylistController_.selectPlaylist},set:function(o){this.masterPlaylistController_.selectPlaylist=o.bind(this)}},throughput:{get:function(){return this.masterPlaylistController_.mainSegmentLoader_.throughput.rate},set:function(o){this.masterPlaylistController_.mainSegmentLoader_.throughput.rate=o,this.masterPlaylistController_.mainSegmentLoader_.throughput.count=1}},bandwidth:{get:function(){return this.masterPlaylistController_.mainSegmentLoader_.bandwidth},set:function(o){this.masterPlaylistController_.mainSegmentLoader_.bandwidth=o,this.masterPlaylistController_.mainSegmentLoader_.throughput={rate:0,count:0}}},systemBandwidth:{get:function(){var o=1/(this.bandwidth||1),l=void 0;this.throughput>0?l=1/this.throughput:l=0;var u=Math.floor(1/(o+l));return u},set:function(){re.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:function(){return a.bandwidth||0},enumerable:!0},mediaRequests:{get:function(){return a.masterPlaylistController_.mediaRequests_()||0},enumerable:!0},mediaRequestsAborted:{get:function(){return a.masterPlaylistController_.mediaRequestsAborted_()||0},enumerable:!0},mediaRequestsTimedout:{get:function(){return a.masterPlaylistController_.mediaRequestsTimedout_()||0},enumerable:!0},mediaRequestsErrored:{get:function(){return a.masterPlaylistController_.mediaRequestsErrored_()||0},enumerable:!0},mediaTransferDuration:{get:function(){return a.masterPlaylistController_.mediaTransferDuration_()||0},enumerable:!0},mediaBytesTransferred:{get:function(){return a.masterPlaylistController_.mediaBytesTransferred_()||0},enumerable:!0},mediaSecondsLoaded:{get:function(){return a.masterPlaylistController_.mediaSecondsLoaded_()||0},enumerable:!0},buffered:{get:function(){return x_(a.tech_.buffered())},enumerable:!0},currentTime:{get:function(){return a.tech_.currentTime()},enumerable:!0},currentSource:{get:function(){return a.tech_.currentSource_},enumerable:!0},currentTech:{get:function(){return a.tech_.name_},enumerable:!0},duration:{get:function(){return a.tech_.duration()},enumerable:!0},master:{get:function(){return a.playlists.master},enumerable:!0},playerDimensions:{get:function(){return a.tech_.currentDimensions()},enumerable:!0},seekable:{get:function(){return x_(a.tech_.seekable())},enumerable:!0},timestamp:{get:function(){return Date.now()},enumerable:!0},videoPlaybackQuality:{get:function(){return a.tech_.getVideoPlaybackQuality()},enumerable:!0}}),this.tech_.one("canplay",this.masterPlaylistController_.setupFirstPlay.bind(this.masterPlaylistController_)),this.tech_.on("bandwidthupdate",function(){a.options_.useBandwidthFromLocalStorage&&uR({bandwidth:a.bandwidth,throughput:Math.round(a.throughput)})}),this.masterPlaylistController_.on("selectedinitialmedia",function(){eR(a),oR(a)}),this.on(this.masterPlaylistController_,"progress",function(){this.tech_.trigger("progress")}),this.tech_.ready(function(){return a.setupQualityLevels_()}),this.tech_.el()&&this.tech_.src(re.URL.createObjectURL(this.masterPlaylistController_.mediaSource)))}},{key:"setupQualityLevels_",value:function(){var t=this,n=re.players[this.tech_.options_.playerId];n&&n.qualityLevels&&(this.qualityLevels_=n.qualityLevels(),this.masterPlaylistController_.on("selectedinitialmedia",function(){aR(t.qualityLevels_,t)}),this.playlists.on("mediachange",function(){Q_(t.qualityLevels_,t.playlists)}))}},{key:"play",value:function(){this.masterPlaylistController_.play()}},{key:"setCurrentTime",value:function(t){this.masterPlaylistController_.setCurrentTime(t)}},{key:"duration",value:function(){return this.masterPlaylistController_.duration()}},{key:"seekable",value:function(){return this.masterPlaylistController_.seekable()}},{key:"dispose",value:function(){this.playbackWatcher_&&this.playbackWatcher_.dispose(),this.masterPlaylistController_&&this.masterPlaylistController_.dispose(),this.qualityLevels_&&this.qualityLevels_.dispose(),this.player_&&(delete this.player_.vhs,delete this.player_.dash,delete this.player_.hls),this.tech_&&this.tech_.hls&&delete this.tech_.hls,l1(r.prototype.__proto__||Object.getPrototypeOf(r.prototype),"dispose",this).call(this)}},{key:"convertToProgramTime",value:function(t,n){return j1({playlist:this.masterPlaylistController_.media(),time:t,callback:n})}},{key:"seekToProgramTime",value:function(t,n){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:2;return $1({programTime:t,playlist:this.masterPlaylistController_.media(),retryCount:s,pauseAfterSeek:a,seekTo:this.options_.seekTo,tech:this.options_.tech,callback:n})}}]),r}(lR),dg={name:"videojs-http-streaming",VERSION:nR,canHandleSource:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=re.mergeOptions(re.options,i);return dg.canPlayType(r.type,t)},handleSource:function(r,i){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=re.mergeOptions(re.options,t);return i.hls=new eb(r,i,n),i.hls.xhr=v_(),i.hls.src(r.src,r.type),i.hls},canPlayType:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=re.mergeOptions(re.options,i),n=t.hls.overrideNative,a=J_(r),s=a&&(!Xn.supportsTypeNatively(a)||n);return s?"maybe":""}};(typeof re.MediaSource>"u"||typeof re.URL>"u")&&(re.MediaSource=Pc,re.URL=N_),Pc.supportsNativeMediaSources()&&re.getTech("Html5").registerSourceHandler(dg,0),re.HlsHandler=eb,re.HlsSourceHandler=dg,re.Hls=Xn,re.use||re.registerComponent("Hls",Xn),re.options.hls=re.options.hls||{},re.registerPlugin?re.registerPlugin("reloadSourceOnError",z_):re.plugin("reloadSourceOnError",z_);const cR=Object.freeze(Object.defineProperty({__proto__:null,default:re},Symbol.toStringTag,{value:"Module"})),tb={name:"stream-engine-player",version:"0.0.45",description:"Stream engine player",type:"module",files:["dist","src","index.js","README.md","LICENSE","package.json","vite.config.js"],exports:{".":{import:"./dist/stream-engine-player.mjs",require:"./dist/stream-engine-player.js"},"./style":{import:"./dist/style.css",require:"./dist/style.css"},"./bundle":{import:"./dist/stream-engine-player-bundle.mjs",require:"./dist/stream-engine-player-bundle.js"}},main:"dist/stream-engine-player.js",author:"Dok Umansky",scripts:{dev:"vite serve",build:'concurrently "vite build --mode bundle" "vite build"',serve:"vite preview",start:"npm run dev",prebuild:"rm -rf dist","version:patch":"npm version patch",lint:"./node_modules/.bin/eslint src",format:'prettier "src/**/*.{ts,js,json,scss,css}" --write',watch:'concurrently "vite build --watch" "vite serve"',"build:watch":"vite build --watch --minify=false"},dependencies:{"@fastpix/videojs-monitor":"^1.0.3",angular:"~1.4.8","angular-cookies":"~1.4.8","hls.js":"^0.12.4","include-media":"^2.0.0","infront-logger":"1.1.11",localforage:"^1.10.0","m3u8-parser":"^7.1.0","mixpanel-browser":"2.52.0",moment:"^2.30.1","video.js":"7.6.6","videojs-contrib-ads":"6.6.5","videojs-ima":"1.7.5","videojs-mux":"4.19.0","videojs-sprite-thumbnails":"^1.2.1","videojs-youtube":"^2.6.1"},devDependencies:{concurrently:"^8.2.1",eslint:"^8.24.0","eslint-config-prettier":"^8.5.0","eslint-plugin-angular":"^4.1.0","eslint-plugin-prettier":"^4.2.1",husky:"^8.0.1",hygen:"^6.2.11","lint-staged":"^13.0.3",prettier:"^2.7.1",sass:"^1.55.0",vite:"^3.2.7"},husky:{hooks:{"pre-commit":"lint-staged"}},"lint-staged":{"*.{ts,js,json,scss,css}":["prettier --write","git add"]}};var pn=[];for(let e=0;e<256;++e)pn.push((e+256).toString(16).slice(1));function dR(e,r=0){return(pn[e[r+0]]+pn[e[r+1]]+pn[e[r+2]]+pn[e[r+3]]+"-"+pn[e[r+4]]+pn[e[r+5]]+"-"+pn[e[r+6]]+pn[e[r+7]]+"-"+pn[e[r+8]]+pn[e[r+9]]+"-"+pn[e[r+10]]+pn[e[r+11]]+pn[e[r+12]]+pn[e[r+13]]+pn[e[r+14]]+pn[e[r+15]]).toLowerCase()}var fg,fR=new Uint8Array(16);function hR(){if(!fg){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");fg=crypto.getRandomValues.bind(crypto)}return fg(fR)}var pR=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),rb={randomUUID:pR};function gR(e,r,i){var n,a,s;if(rb.randomUUID&&!r&&!e)return rb.randomUUID();e=e||{};let t=(s=(a=e.random)!=null?a:(n=e.rng)==null?void 0:n.call(e))!=null?s:hR();if(t.length<16)throw new Error("Random bytes length must be >= 16");if(t[6]=t[6]&15|64,t[8]=t[8]&63|128,r){if(i=i||0,i<0||i+16>r.length)throw new RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`);for(let o=0;o<16;++o)r[i+o]=t[o];return r}return dR(t)}var vR=gR,ib="000000",nb=function(){let e=Math.random().toString(36).replace("0.","").slice(0,6);return ib.slice(e.length)+e},Al=function(){return vR()},mR=function(){return(ib+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},hg=e=>{if(!e)return["localhost","localhost"];try{let r=new URL(e).hostname,i=r.split("."),t=i.length>=2?i.slice(-2).join("."):r;return[r,t]}catch{}return["localhost","localhost"]},ps=e=>hg(e)[0],pg=e=>hg(e)[1],yR=e=>{var r,i;if(e&&e.nodeName)return(r=e.uniqueId)!=null?r:e.uniqueId=nb();try{let t=document.querySelector(e);return t&&!t.uniqueId&&(t.uniqueId=e),(i=t==null?void 0:t.uniqueId)!=null?i:e}catch{}return e},_R=e=>{var t;let r=null;e&&e.nodeName!==void 0?(r=e,e=yR(r)):r=document.querySelector(e);let i=((t=r==null?void 0:r.nodeName)==null?void 0:t.toLowerCase())||"";return[r,e,i]},ab=e=>{var i,t;let r=null;if(e&&e.nodeName!==void 0)return(i=e.elementId)!=null||(e.elementId=mR()),e.elementId;try{r=document.querySelector(e)}catch{}return r&&!r.elementId&&(r.elementId=e),(t=r==null?void 0:r.elementId)!=null?t:e};function bR(...e){return e.reduce((r,i)=>{for(let[t,n]of Object.entries(i))n!==void 0&&(r[t]=n);return r},{})}function nf(e,r,i=1){var t;e[r]=((t=e[r])!=null?t:0)+i}function TR(e,r){let{beaconDomain:i}=r;return`https://${e!=null?e:"collector"}.${i!=null?i:"metrix.ws"}`}function sb(){var r,i;let e=(i=(r=navigator.doNotTrack)!=null?r:window.doNotTrack)!=null?i:navigator.msDoNotTrack;return e==="1"||e==="yes"}var SR=class{constructor(){this.events={}}on(e,r){this.events[e]||(this.events[e]=[]),this.events[e].push(r)}off(e,r){this.events[e]&&(this.events[e]=this.events[e].filter(i=>i!==r))}emit(e,r){this.events[e]&&this.events[e].forEach(i=>{i(r)})}},Do={now:function(){return typeof Date.now=="function"?Date.now():new Date().getTime()}},af={isPerformanceAvailable:function(){let e=window.performance;return e&&e.timing!==void 0},getDomContentLoadedEnd:function(){var r;let e=(r=window.performance)==null?void 0:r.timing;return e?e.domContentLoadedEventEnd:null},getNavigationStartTime:function(){var r;let e=(r=window.performance)==null?void 0:r.timing;return e?e.navigationStart:null}};function ER(e){if(!e)return{};let r=af.getNavigationStartTime(),{loading:i,trequest:t,tfirst:n,tload:a,total:s}=e,o=i?i.start:t,l=i?i.first:n,u=i?i.end:a;return{bytesLoaded:s,requestStart:Math.round(r+o),responseStart:Math.round(r+l),responseEnd:Math.round(r+u)}}var xR=()=>{var r,i,t;let e=navigator;return(t=(i=(r=e==null?void 0:e.connection)!=null?r:e==null?void 0:e.mozConnection)!=null?i:e==null?void 0:e.webkitConnection)==null?void 0:t.type},wR=()=>{switch(xR()){case"cellular":return"cellular";case"ethernet":return"wired";case"wifi":return"wifi";case void 0:break;default:return"other"}},AR=["x-cdn","content-type","content-length","last-modified","server","x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"];function CR(e){let r={},i=new Set(AR.map(t=>t.toLowerCase()));return!e||typeof e!="string"?{}:(e.trim().split(/[\r\n]+/).forEach(t=>{let[n,...a]=t.split(": "),s=a.join(": ");n&&i.has(n.toLowerCase())&&(r[n]=s)}),r)}var sf=function(e){if(e&&typeof e.getAllResponseHeaders=="function")return CR(e.getAllResponseHeaders())},kR={convertSecToMs:function(e){return Math.floor(1e3*e)},isolateHostAndDomainName:hg,fetchDomain:pg,fetchHost:ps,generateIdToken:nb,buildUUID:Al,now:Do.now};function RR(e){let r=(window==null?void 0:window.URL)||(window==null?void 0:window.webkitURL),i=window==null?void 0:window.Blob,t=window==null?void 0:window.Worker;if(!r||!i||!t||!e)return null;let n=new i([e]);return new t(r.createObjectURL(n))}var DR=`
97
+ `.split("").map(function(e){return e.charCodeAt(0)})),Ik=function(e){Gs(r,e);function r(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Aa(this,r);var n=hs(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,i,t));return n.mediaSource_=null,n.subtitlesTrack_=null,n}return Va(r,[{key:"buffered_",value:function(){if(!this.subtitlesTrack_||!this.subtitlesTrack_.cues.length)return re.createTimeRanges();var t=this.subtitlesTrack_.cues,n=t[0].startTime,a=t[t.length-1].startTime;return re.createTimeRanges([[n,a]])}},{key:"initSegment",value:function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(!t)return null;var a=Qd(t),s=this.initSegments_[a];if(n&&!s&&t.bytes){var o=q_.byteLength+t.bytes.byteLength,l=new Uint8Array(o);l.set(t.bytes),l.set(q_,t.bytes.byteLength),this.initSegments_[a]=s={resolvedUri:t.resolvedUri,byterange:t.byterange,bytes:l}}return s||t}},{key:"couldBeginLoading_",value:function(){return this.playlist_&&this.subtitlesTrack_&&!this.paused()}},{key:"init_",value:function(){return this.state="READY",this.resetEverything(),this.monitorBuffer_()}},{key:"track",value:function(t){return typeof t>"u"?this.subtitlesTrack_:(this.subtitlesTrack_=t,this.state==="INIT"&&this.couldBeginLoading_()&&this.init_(),this.subtitlesTrack_)}},{key:"remove",value:function(t,n){Tl(t,n,this.subtitlesTrack_)}},{key:"fillBuffer_",value:function(){var t=this;this.syncPoint_||(this.syncPoint_=this.syncController_.getSyncPoint(this.playlist_,this.duration_(),this.currentTimeline_,this.currentTime_()));var n=this.checkBuffer_(this.buffered_(),this.playlist_,this.mediaIndex,this.hasPlayed_(),this.currentTime_(),this.syncPoint_);if(n=this.skipEmptySegments_(n),!!n){if(this.syncController_.timestampOffsetForTimeline(n.timeline)===null){var a=function(){t.state="READY",t.paused()||t.monitorBuffer_()};this.syncController_.one("timestampoffset",a),this.state="WAITING_ON_TIMELINE";return}this.loadSegment_(n)}}},{key:"skipEmptySegments_",value:function(t){for(;t&&t.segment.empty;)t=this.generateSegmentInfo_(t.playlist,t.mediaIndex+1,t.startOfSegment+t.duration,t.isSyncRequest);return t}},{key:"handleSegment_",value:function(){var t=this;if(!this.pendingSegment_||!this.subtitlesTrack_){this.state="READY";return}this.state="APPENDING";var n=this.pendingSegment_,a=n.segment;if(typeof Be.WebVTT!="function"&&this.subtitlesTrack_&&this.subtitlesTrack_.tech_){var s=void 0,o=function(){t.subtitlesTrack_.tech_.off("vttjsloaded",s),t.error({message:"Error loading vtt.js"}),t.state="READY",t.pause(),t.trigger("error")};s=function(){t.subtitlesTrack_.tech_.off("vttjserror",o),t.handleSegment_()},this.state="WAITING_ON_VTTJS",this.subtitlesTrack_.tech_.one("vttjsloaded",s),this.subtitlesTrack_.tech_.one("vttjserror",o);return}a.requested=!0;try{this.parseVTTCues_(n)}catch(l){return this.error({message:l.message}),this.state="READY",this.pause(),this.trigger("error")}if(this.updateTimeMapping_(n,this.syncController_.timelines[n.timeline],this.playlist_),n.isSyncRequest){this.trigger("syncinfoupdate"),this.pendingSegment_=null,this.state="READY";return}n.byteLength=n.bytes.byteLength,this.mediaSecondsLoaded+=a.duration,n.cues.length&&this.remove(n.cues[0].endTime,n.cues[n.cues.length-1].endTime),n.cues.forEach(function(l){t.subtitlesTrack_.addCue(l)}),this.handleUpdateEnd_()}},{key:"parseVTTCues_",value:function(t){var n=void 0,a=!1;typeof Be.TextDecoder=="function"?n=new Be.TextDecoder("utf8"):(n=Be.WebVTT.StringDecoder(),a=!0);var s=new Be.WebVTT.Parser(Be,Be.vttjs,n);if(t.cues=[],t.timestampmap={MPEGTS:0,LOCAL:0},s.oncue=t.cues.push.bind(t.cues),s.ontimestampmap=function(u){return t.timestampmap=u},s.onparsingerror=function(u){re.log.warn("Error encountered when parsing cues: "+u.message)},t.segment.map){var o=t.segment.map.bytes;a&&(o=V_(o)),s.parse(o)}var l=t.bytes;a&&(l=V_(l)),s.parse(l),s.flush()}},{key:"updateTimeMapping_",value:function(t,n,a){var s=t.segment;if(!!n){if(!t.cues.length){s.empty=!0;return}var o=t.timestampmap,l=o.MPEGTS/9e4-o.LOCAL+n.mapping;if(t.cues.forEach(function(c){c.startTime+=l,c.endTime+=l}),!a.syncInfo){var u=t.cues[0].startTime,g=t.cues[t.cues.length-1].startTime;a.syncInfo={mediaSequence:a.mediaSequence+t.mediaIndex,time:Math.min(u,g-s.duration)}}}}}]),r}(lg),Mk=function(r,i){for(var t=r.cues,n=0;n<t.length;n++){var a=t[n];if(i>=a.adStartTime&&i<=a.adEndTime)return a}return null},Nk=function(r,i){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;if(!!r.segments)for(var n=t,a=void 0,s=0;s<r.segments.length;s++){var o=r.segments[s];if(a||(a=Mk(i,n+o.duration/2)),a){if("cueIn"in o){a.endTime=n,a.adEndTime=n,n+=o.duration,a=null;continue}if(n<a.endTime){n+=o.duration;continue}a.endTime+=o.duration}else if("cueOut"in o&&(a=new Be.VTTCue(n,n+o.duration,o.cueOut),a.adStartTime=n,a.adEndTime=n+parseFloat(o.cueOut),i.addCue(a)),"cueOutCont"in o){var l=void 0,u=void 0,g=o.cueOutCont.split("/").map(parseFloat),c=c1(g,2);l=c[0],u=c[1],a=new Be.VTTCue(n,n+o.duration,""),a.adStartTime=n-l,a.adEndTime=a.adStartTime+u,i.addCue(a)}n+=o.duration}},Fk=DA.inspect,W_=[{name:"VOD",run:function(r,i,t,n,a){if(t!==1/0){var s={time:0,segmentIndex:0};return s}return null}},{name:"ProgramDateTime",run:function(r,i,t,n,a){if(!r.datetimeToDisplayTime)return null;var s=i.segments||[],o=null,l=null;a=a||0;for(var u=0;u<s.length;u++){var g=s[u];if(g.dateTimeObject){var c=g.dateTimeObject.getTime()/1e3,d=c+r.datetimeToDisplayTime,f=Math.abs(a-d);if(l!==null&&(f===0||l<f))break;l=f,o={time:d,segmentIndex:u}}}return o}},{name:"Segment",run:function(r,i,t,n,a){var s=i.segments||[],o=null,l=null;a=a||0;for(var u=0;u<s.length;u++){var g=s[u];if(g.timeline===n&&typeof g.start<"u"){var c=Math.abs(a-g.start);if(l!==null&&l<c)break;(!o||l===null||l>=c)&&(l=c,o={time:g.start,segmentIndex:u})}}return o}},{name:"Discontinuity",run:function(r,i,t,n,a){var s=null;if(a=a||0,i.discontinuityStarts&&i.discontinuityStarts.length)for(var o=null,l=0;l<i.discontinuityStarts.length;l++){var u=i.discontinuityStarts[l],g=i.discontinuitySequence+l+1,c=r.discontinuities[g];if(c){var d=Math.abs(a-c.time);if(o!==null&&o<d)break;(!s||o===null||o>=d)&&(o=d,s={time:c.time,segmentIndex:u})}}return s}},{name:"Playlist",run:function(r,i,t,n,a){if(i.syncInfo){var s={time:i.syncInfo.time,segmentIndex:i.syncInfo.mediaSequence-i.mediaSequence};return s}return null}}],Uk=function(e){Gs(r,e);function r(){Aa(this,r);var i=hs(this,(r.__proto__||Object.getPrototypeOf(r)).call(this));return i.inspectCache_=void 0,i.timelines=[],i.discontinuities=[],i.datetimeToDisplayTime=null,i.logger_=Oc("SyncController"),i}return Va(r,[{key:"getSyncPoint",value:function(t,n,a,s){var o=this.runStrategies_(t,n,a,s);return o.length?this.selectSyncPoint_(o,{key:"time",value:s}):null}},{key:"getExpiredTime",value:function(t,n){if(!t||!t.segments)return null;var a=this.runStrategies_(t,n,t.discontinuitySequence,0);if(!a.length)return null;var s=this.selectSyncPoint_(a,{key:"segmentIndex",value:0});return s.segmentIndex>0&&(s.time*=-1),Math.abs(s.time+Rc(t,s.segmentIndex,0))}},{key:"runStrategies_",value:function(t,n,a,s){for(var o=[],l=0;l<W_.length;l++){var u=W_[l],g=u.run(this,t,n,a,s);g&&(g.strategy=u.name,o.push({strategy:u.name,syncPoint:g}))}return o}},{key:"selectSyncPoint_",value:function(t,n){for(var a=t[0].syncPoint,s=Math.abs(t[0].syncPoint[n.key]-n.value),o=t[0].strategy,l=1;l<t.length;l++){var u=Math.abs(t[l].syncPoint[n.key]-n.value);u<s&&(s=u,a=t[l].syncPoint,o=t[l].strategy)}return this.logger_("syncPoint for ["+n.key+": "+n.value+"] chosen with strategy"+(" ["+o+"]: [time:"+a.time+",")+(" segmentIndex:"+a.segmentIndex+"]")),a}},{key:"saveExpiredSegmentInfo",value:function(t,n){for(var a=n.mediaSequence-t.mediaSequence,s=a-1;s>=0;s--){var o=t.segments[s];if(o&&typeof o.start<"u"){n.syncInfo={mediaSequence:t.mediaSequence+s,time:o.start},this.logger_("playlist refresh sync: [time:"+n.syncInfo.time+","+(" mediaSequence: "+n.syncInfo.mediaSequence+"]")),this.trigger("syncinfoupdate");break}}}},{key:"setDateTimeMapping",value:function(t){if(!this.datetimeToDisplayTime&&t.segments&&t.segments.length&&t.segments[0].dateTimeObject){var n=t.segments[0].dateTimeObject.getTime()/1e3;this.datetimeToDisplayTime=-n}}},{key:"reset",value:function(){this.inspectCache_=void 0}},{key:"probeSegmentInfo",value:function(t){var n=t.segment,a=t.playlist,s=void 0;return n.map?s=this.probeMp4Segment_(t):s=this.probeTsSegment_(t),s&&this.calculateSegmentTimeMapping_(t,s)&&(this.saveDiscontinuitySyncInfo_(t),a.syncInfo||(a.syncInfo={mediaSequence:a.mediaSequence+t.mediaIndex,time:n.start})),s}},{key:"probeMp4Segment_",value:function(t){var n=t.segment,a=al.timescale(n.map.bytes),s=al.startTime(a,t.bytes);return t.timestampOffset!==null&&(t.timestampOffset-=s),{start:s,end:s+n.duration}}},{key:"probeTsSegment_",value:function(t){var n=Fk(t.bytes,this.inspectCache_),a=void 0,s=void 0,o=void 0;if(!n)return null;n.video&&n.video.length===2?(this.inspectCache_=n.video[1].dts,a=n.video[0].dtsTime,s=n.video[1].dtsTime,o=n.video):n.audio&&n.audio.length===2&&(this.inspectCache_=n.audio[1].dts,a=n.audio[0].dtsTime,s=n.audio[1].dtsTime,o=n.audio);var l={segmentTimestampInfo:o,start:a,end:s,containsVideo:n.video&&n.video.length===2,containsAudio:n.audio&&n.audio.length===2};return l}},{key:"timestampOffsetForTimeline",value:function(t){return typeof this.timelines[t]>"u"?null:this.timelines[t].time}},{key:"mappingForTimeline",value:function(t){return typeof this.timelines[t]>"u"?null:this.timelines[t].mapping}},{key:"calculateSegmentTimeMapping_",value:function(t,n){var a=t.segment,s=this.timelines[t.timeline];if(t.timestampOffset!==null)s={time:t.startOfSegment,mapping:t.startOfSegment-n.start},this.timelines[t.timeline]=s,this.trigger("timestampoffset"),this.logger_("time mapping for timeline "+t.timeline+": "+("[time: "+s.time+"] [mapping: "+s.mapping+"]")),a.start=t.startOfSegment,a.end=n.end+s.mapping;else if(s)a.start=n.start+s.mapping,a.end=n.end+s.mapping;else return!1;return!0}},{key:"saveDiscontinuitySyncInfo_",value:function(t){var n=t.playlist,a=t.segment;if(a.discontinuity)this.discontinuities[a.timeline]={time:a.start,accuracy:0};else if(n.discontinuityStarts&&n.discontinuityStarts.length)for(var s=0;s<n.discontinuityStarts.length;s++){var o=n.discontinuityStarts[s],l=n.discontinuitySequence+s+1,u=o-t.mediaIndex,g=Math.abs(u);if(!this.discontinuities[l]||this.discontinuities[l].accuracy>g){var c=void 0;u<0?c=a.start-Rc(n,t.mediaIndex,o):c=a.end+Rc(n,t.mediaIndex+1,o),this.discontinuities[l]={time:c,accuracy:g}}}}}]),r}(re.EventTarget),Bk=new A_("./decrypter-worker.worker.js",function(e,r){var i=this;(function(){function t(h){return h.subarray(0,h.byteLength-h[h.byteLength-1])}var n=function(S,E){if(!(S instanceof E))throw new TypeError("Cannot call a class as a function")},a=function(){function h(S,E){for(var A=0;A<E.length;A++){var x=E[A];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(S,x.key,x)}}return function(S,E,A){return E&&h(S.prototype,E),A&&h(S,A),S}}(),s=function(S,E){if(typeof E!="function"&&E!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof E);S.prototype=Object.create(E&&E.prototype,{constructor:{value:S,enumerable:!1,writable:!0,configurable:!0}}),E&&(Object.setPrototypeOf?Object.setPrototypeOf(S,E):S.__proto__=E)},o=function(S,E){if(!S)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return E&&(typeof E=="object"||typeof E=="function")?E:S},l=function(){var S=[[[],[],[],[],[]],[[],[],[],[],[]]],E=S[0],A=S[1],x=E[4],m=A[4],C=void 0,k=void 0,D=void 0,P=[],N=[],j=void 0,O=void 0,M=void 0,F=void 0,H=void 0,K=void 0;for(C=0;C<256;C++)N[(P[C]=C<<1^(C>>7)*283)^C]=C;for(k=D=0;!x[k];k^=j||1,D=N[D]||1)for(F=D^D<<1^D<<2^D<<3^D<<4,F=F>>8^F&255^99,x[k]=F,m[F]=k,M=P[O=P[j=P[k]]],K=M*16843009^O*65537^j*257^k*16843008,H=P[F]*257^F*16843008,C=0;C<4;C++)E[C][k]=H=H<<24^H>>>8,A[C][F]=K=K<<24^K>>>8;for(C=0;C<5;C++)E[C]=E[C].slice(0),A[C]=A[C].slice(0);return S},u=null,g=function(){function h(S){n(this,h),u||(u=l()),this._tables=[[u[0][0].slice(),u[0][1].slice(),u[0][2].slice(),u[0][3].slice(),u[0][4].slice()],[u[1][0].slice(),u[1][1].slice(),u[1][2].slice(),u[1][3].slice(),u[1][4].slice()]];var E=void 0,A=void 0,x=void 0,m=void 0,C=void 0,k=this._tables[0][4],D=this._tables[1],P=S.length,N=1;if(P!==4&&P!==6&&P!==8)throw new Error("Invalid aes key size");for(m=S.slice(0),C=[],this._key=[m,C],E=P;E<4*P+28;E++)x=m[E-1],(E%P===0||P===8&&E%P===4)&&(x=k[x>>>24]<<24^k[x>>16&255]<<16^k[x>>8&255]<<8^k[x&255],E%P===0&&(x=x<<8^x>>>24^N<<24,N=N<<1^(N>>7)*283)),m[E]=m[E-P]^x;for(A=0;E;A++,E--)x=m[A&3?E:E-4],E<=4||A<4?C[A]=x:C[A]=D[0][k[x>>>24]]^D[1][k[x>>16&255]]^D[2][k[x>>8&255]]^D[3][k[x&255]]}return h.prototype.decrypt=function(E,A,x,m,C,k){var D=this._key[1],P=E^D[0],N=m^D[1],j=x^D[2],O=A^D[3],M=void 0,F=void 0,H=void 0,K=D.length/4-2,J=void 0,le=4,ce=this._tables[1],Z=ce[0],ve=ce[1],Ce=ce[2],Ne=ce[3],ot=ce[4];for(J=0;J<K;J++)M=Z[P>>>24]^ve[N>>16&255]^Ce[j>>8&255]^Ne[O&255]^D[le],F=Z[N>>>24]^ve[j>>16&255]^Ce[O>>8&255]^Ne[P&255]^D[le+1],H=Z[j>>>24]^ve[O>>16&255]^Ce[P>>8&255]^Ne[N&255]^D[le+2],O=Z[O>>>24]^ve[P>>16&255]^Ce[N>>8&255]^Ne[j&255]^D[le+3],le+=4,P=M,N=F,j=H;for(J=0;J<4;J++)C[(3&-J)+k]=ot[P>>>24]<<24^ot[N>>16&255]<<16^ot[j>>8&255]<<8^ot[O&255]^D[le++],M=P,P=N,N=j,j=O,O=M},h}(),c=function(){function h(){n(this,h),this.listeners={}}return h.prototype.on=function(E,A){this.listeners[E]||(this.listeners[E]=[]),this.listeners[E].push(A)},h.prototype.off=function(E,A){if(!this.listeners[E])return!1;var x=this.listeners[E].indexOf(A);return this.listeners[E].splice(x,1),x>-1},h.prototype.trigger=function(E){var A=this.listeners[E];if(!!A)if(arguments.length===2)for(var x=A.length,m=0;m<x;++m)A[m].call(this,arguments[1]);else for(var C=Array.prototype.slice.call(arguments,1),k=A.length,D=0;D<k;++D)A[D].apply(this,C)},h.prototype.dispose=function(){this.listeners={}},h.prototype.pipe=function(E){this.on("data",function(A){E.push(A)})},h}(),d=function(h){s(S,h);function S(){n(this,S);var E=o(this,h.call(this,c));return E.jobs=[],E.delay=1,E.timeout_=null,E}return S.prototype.processJob_=function(){this.jobs.shift()(),this.jobs.length?this.timeout_=setTimeout(this.processJob_.bind(this),this.delay):this.timeout_=null},S.prototype.push=function(A){this.jobs.push(A),this.timeout_||(this.timeout_=setTimeout(this.processJob_.bind(this),this.delay))},S}(c),f=function(S){return S<<24|(S&65280)<<8|(S&16711680)>>8|S>>>24},T=function(S,E,A){var x=new Int32Array(S.buffer,S.byteOffset,S.byteLength>>2),m=new g(Array.prototype.slice.call(E)),C=new Uint8Array(S.byteLength),k=new Int32Array(C.buffer),D=void 0,P=void 0,N=void 0,j=void 0,O=void 0,M=void 0,F=void 0,H=void 0,K=void 0;for(D=A[0],P=A[1],N=A[2],j=A[3],K=0;K<x.length;K+=4)O=f(x[K]),M=f(x[K+1]),F=f(x[K+2]),H=f(x[K+3]),m.decrypt(O,M,F,H,k,K),k[K]=f(k[K]^D),k[K+1]=f(k[K+1]^P),k[K+2]=f(k[K+2]^N),k[K+3]=f(k[K+3]^j),D=O,P=M,N=F,j=H;return C},p=function(){function h(S,E,A,x){n(this,h);var m=h.STEP,C=new Int32Array(S.buffer),k=new Uint8Array(S.byteLength),D=0;for(this.asyncStream_=new d,this.asyncStream_.push(this.decryptChunk_(C.subarray(D,D+m),E,A,k)),D=m;D<C.length;D+=m)A=new Uint32Array([f(C[D-4]),f(C[D-3]),f(C[D-2]),f(C[D-1])]),this.asyncStream_.push(this.decryptChunk_(C.subarray(D,D+m),E,A,k));this.asyncStream_.push(function(){x(null,t(k))})}return h.prototype.decryptChunk_=function(E,A,x,m){return function(){var C=T(E,A,x);m.set(C,E.byteOffset)}},a(h,null,[{key:"STEP",get:function(){return 32e3}}]),h}(),y=function(S){var E={};return Object.keys(S).forEach(function(A){var x=S[A];ArrayBuffer.isView(x)?E[A]={bytes:x.buffer,byteOffset:x.byteOffset,byteLength:x.byteLength}:E[A]=x}),E},b=function(S){S.onmessage=function(E){var A=E.data,x=new Uint8Array(A.encrypted.bytes,A.encrypted.byteOffset,A.encrypted.byteLength),m=new Uint32Array(A.key.bytes,A.key.byteOffset,A.key.byteLength/4),C=new Uint32Array(A.iv.bytes,A.iv.byteOffset,A.iv.byteLength/4);new p(x,m,C,function(k,D){S.postMessage(y({source:A.source,decrypted:D}),[D.buffer])})}},v=new b(i);return v})()}),jk=function(r){var i=r.default?"main":"alternative";return r.characteristics&&r.characteristics.indexOf("public.accessibility.describes-video")>=0&&(i="main-desc"),i},tf=function(r,i){r.abort(),r.pause(),i&&i.activePlaylistLoader&&(i.activePlaylistLoader.pause(),i.activePlaylistLoader=null)},cg=function(r,i){i.activePlaylistLoader=r,r.load()},$k=function(r,i){return function(){var t=i.segmentLoaders,n=t[r],a=t.main,s=i.mediaTypes[r],o=s.activeTrack(),l=s.activeGroup(o),u=s.activePlaylistLoader;if(tf(n,s),!!l){if(!l.playlistLoader){u&&a.resetEverything();return}n.resyncLoader(),cg(l.playlistLoader,s)}}},Hk=function(r,i){return function(){var t=i.segmentLoaders,n=t[r],a=t.main,s=i.mediaTypes[r],o=s.activeTrack(),l=s.activeGroup(o),u=s.activePlaylistLoader;if(tf(n,s),!!l){if(!l.playlistLoader){a.resetEverything();return}if(u===l.playlistLoader){cg(l.playlistLoader,s);return}n.track&&n.track(o),n.resetEverything(),cg(l.playlistLoader,s)}}},rf={AUDIO:function(r,i){return function(){var t=i.segmentLoaders[r],n=i.mediaTypes[r],a=i.blacklistCurrentPlaylist;tf(t,n);var s=n.activeTrack(),o=n.activeGroup(),l=(o.filter(function(c){return c.default})[0]||o[0]).id,u=n.tracks[l];if(s===u){a({message:"Problem encountered loading the default audio track."});return}re.log.warn("Problem encountered loading the alternate audio track.Switching back to default.");for(var g in n.tracks)n.tracks[g].enabled=n.tracks[g]===u;n.onTrackChanged()}},SUBTITLES:function(r,i){return function(){var t=i.segmentLoaders[r],n=i.mediaTypes[r];re.log.warn("Problem encountered loading the subtitle track.Disabling subtitle track."),tf(t,n);var a=n.activeTrack();a&&(a.mode="disabled"),n.onTrackChanged()}}},Y_={AUDIO:function(r,i,t){if(!!i){var n=t.tech,a=t.requestOptions,s=t.segmentLoaders[r];i.on("loadedmetadata",function(){var o=i.media();s.playlist(o,a),(!n.paused()||o.endList&&n.preload()!=="none")&&s.load()}),i.on("loadedplaylist",function(){s.playlist(i.media(),a),n.paused()||s.load()}),i.on("error",rf[r](r,t))}},SUBTITLES:function(r,i,t){var n=t.tech,a=t.requestOptions,s=t.segmentLoaders[r],o=t.mediaTypes[r];i.on("loadedmetadata",function(){var l=i.media();s.playlist(l,a),s.track(o.activeTrack()),(!n.paused()||l.endList&&n.preload()!=="none")&&s.load()}),i.on("loadedplaylist",function(){s.playlist(i.media(),a),n.paused()||s.load()}),i.on("error",rf[r](r,t))}},Gk={AUDIO:function(r,i){var t=i.hls,n=i.sourceType,a=i.segmentLoaders[r],s=i.requestOptions,o=i.master.mediaGroups,l=i.mediaTypes[r],u=l.groups,g=l.tracks,c=i.masterPlaylistLoader;(!o[r]||Object.keys(o[r]).length===0)&&(o[r]={main:{default:{default:!0}}});for(var d in o[r]){u[d]||(u[d]=[]);for(var f in o[r][d]){var T=o[r][d][f],p=void 0;if(T.resolvedUri?p=new Xd(T.resolvedUri,t,s):T.playlists&&n==="dash"?p=new sg(T.playlists[0],t,s,c):p=null,T=re.mergeOptions({id:f,playlistLoader:p},T),Y_[r](r,T.playlistLoader,i),u[d].push(T),typeof g[f]>"u"){var y=new re.AudioTrack({id:f,kind:jk(T),enabled:!1,language:T.language,default:T.default,label:f});g[f]=y}}}a.on("error",rf[r](r,i))},SUBTITLES:function(r,i){var t=i.tech,n=i.hls,a=i.sourceType,s=i.segmentLoaders[r],o=i.requestOptions,l=i.master.mediaGroups,u=i.mediaTypes[r],g=u.groups,c=u.tracks,d=i.masterPlaylistLoader;for(var f in l[r]){g[f]||(g[f]=[]);for(var T in l[r][f])if(!l[r][f][T].forced){var p=l[r][f][T],y=void 0;if(a==="hls"?y=new Xd(p.resolvedUri,n,o):a==="dash"&&(y=new sg(p.playlists[0],n,o,d)),p=re.mergeOptions({id:T,playlistLoader:y},p),Y_[r](r,p.playlistLoader,i),g[f].push(p),typeof c[T]>"u"){var b=t.addRemoteTextTrack({id:T,kind:"subtitles",default:p.default&&p.autoselect,language:p.language,label:T},!1).track;c[T]=b}}}s.on("error",rf[r](r,i))},"CLOSED-CAPTIONS":function(r,i){var t=i.tech,n=i.master.mediaGroups,a=i.mediaTypes[r],s=a.groups,o=a.tracks;for(var l in n[r]){s[l]||(s[l]=[]);for(var u in n[r][l]){var g=n[r][l][u];if(!!g.instreamId.match(/CC\d/)&&(s[l].push(re.mergeOptions({id:u},g)),typeof o[u]>"u")){var c=t.addRemoteTextTrack({id:g.instreamId,kind:"captions",default:g.default&&g.autoselect,language:g.language,label:u},!1).track;o[u]=c}}}}},Vk=function(r,i){return function(t){var n=i.masterPlaylistLoader,a=i.mediaTypes[r].groups,s=n.media();if(!s)return null;var o=null;return s.attributes[r]&&(o=a[s.attributes[r]]),o=o||a.main,typeof t>"u"?o:t===null?null:o.filter(function(l){return l.id===t.id})[0]||null}},qk={AUDIO:function(r,i){return function(){var t=i.mediaTypes[r].tracks;for(var n in t)if(t[n].enabled)return t[n];return null}},SUBTITLES:function(r,i){return function(){var t=i.mediaTypes[r].tracks;for(var n in t)if(t[n].mode==="showing")return t[n];return null}}},Wk=function(r){["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(function(g){Gk[g](g,r)});var i=r.mediaTypes,t=r.masterPlaylistLoader,n=r.tech,a=r.hls;["AUDIO","SUBTITLES"].forEach(function(g){i[g].activeGroup=Vk(g,r),i[g].activeTrack=qk[g](g,r),i[g].onGroupChanged=$k(g,r),i[g].onTrackChanged=Hk(g,r)});var s=i.AUDIO.activeGroup(),o=(s.filter(function(g){return g.default})[0]||s[0]).id;i.AUDIO.tracks[o].enabled=!0,i.AUDIO.onTrackChanged(),t.on("mediachange",function(){["AUDIO","SUBTITLES"].forEach(function(g){return i[g].onGroupChanged()})});var l=function(){i.AUDIO.onTrackChanged(),n.trigger({type:"usage",name:"hls-audio-change"})};n.audioTracks().addEventListener("change",l),n.remoteTextTracks().addEventListener("change",i.SUBTITLES.onTrackChanged),a.on("dispose",function(){n.audioTracks().removeEventListener("change",l),n.remoteTextTracks().removeEventListener("change",i.SUBTITLES.onTrackChanged)}),n.clearTracks("audio");for(var u in i.AUDIO.tracks)n.audioTracks().addTrack(i.AUDIO.tracks[u])},Yk=function(){var r={};return["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(function(i){r[i]={groups:{},tracks:{},activePlaylistLoader:null,activeGroup:wl,activeTrack:wl,onGroupChanged:wl,onTrackChanged:wl}}),r},Kk=60*2,Ro=void 0,zk=["mediaRequests","mediaRequestsAborted","mediaRequestsTimedout","mediaRequestsErrored","mediaTransferDuration","mediaBytesTransferred"],Xk=function(r){return this.audioSegmentLoader_[r]+this.mainSegmentLoader_[r]},Jk=function(e){Gs(r,e);function r(i){Aa(this,r);var t=hs(this,(r.__proto__||Object.getPrototypeOf(r)).call(this)),n=i.url,a=i.handleManifestRedirects,s=i.withCredentials,o=i.tech,l=i.bandwidth,u=i.externHls,g=i.useCueTags,c=i.blacklistDuration,d=i.enableLowInitialPlaylist,f=i.sourceType,T=i.seekTo,p=i.cacheEncryptionKeys;if(!n)throw new Error("A non-empty playlist URL is required");Ro=u,t.withCredentials=s,t.tech_=o,t.hls_=o.hls,t.seekTo_=T,t.sourceType_=f,t.useCueTags_=g,t.blacklistDuration=c,t.enableLowInitialPlaylist=d,t.useCueTags_&&(t.cueTagsTrack_=t.tech_.addTextTrack("metadata","ad-cues"),t.cueTagsTrack_.inBandMetadataTrackDispatchType=""),t.requestOptions_={withCredentials:s,handleManifestRedirects:a,timeout:null},t.mediaTypes_=Yk(),t.mediaSource=new re.MediaSource,t.mediaSource.addEventListener("sourceopen",t.handleSourceOpen_.bind(t)),t.seekable_=re.createTimeRanges(),t.hasPlayed_=function(){return!1},t.syncController_=new Uk(i),t.segmentMetadataTrack_=o.addRemoteTextTrack({kind:"metadata",label:"segment-metadata"},!1).track,t.decrypter_=new Bk,t.inbandTextTracks_={};var y={hls:t.hls_,mediaSource:t.mediaSource,currentTime:t.tech_.currentTime.bind(t.tech_),seekable:function(){return t.seekable()},seeking:function(){return t.tech_.seeking()},duration:function(){return t.mediaSource.duration},hasPlayed:function(){return t.hasPlayed_()},goalBufferLength:function(){return t.goalBufferLength()},bandwidth:l,syncController:t.syncController_,decrypter:t.decrypter_,sourceType:t.sourceType_,inbandTextTracks:t.inbandTextTracks_,cacheEncryptionKeys:p};return t.masterPlaylistLoader_=t.sourceType_==="dash"?new sg(n,t.hls_,t.requestOptions_):new Xd(n,t.hls_,t.requestOptions_),t.setupMasterPlaylistLoaderListeners_(),t.mainSegmentLoader_=new lg(re.mergeOptions(y,{segmentMetadataTrack:t.segmentMetadataTrack_,loaderType:"main"}),i),t.audioSegmentLoader_=new lg(re.mergeOptions(y,{loaderType:"audio"}),i),t.subtitleSegmentLoader_=new Ik(re.mergeOptions(y,{loaderType:"vtt"}),i),t.setupSegmentLoaderListeners_(),zk.forEach(function(b){t[b+"_"]=Xk.bind(t,b)}),t.logger_=Oc("MPC"),t.masterPlaylistLoader_.load(),t}return Va(r,[{key:"setupMasterPlaylistLoaderListeners_",value:function(){var t=this;this.masterPlaylistLoader_.on("loadedmetadata",function(){var n=t.masterPlaylistLoader_.media(),a=n.targetDuration*1.5*1e3;Qp(t.masterPlaylistLoader_.master,t.masterPlaylistLoader_.media())?t.requestOptions_.timeout=0:t.requestOptions_.timeout=a,n.endList&&t.tech_.preload()!=="none"&&(t.mainSegmentLoader_.playlist(n,t.requestOptions_),t.mainSegmentLoader_.load()),Wk({sourceType:t.sourceType_,segmentLoaders:{AUDIO:t.audioSegmentLoader_,SUBTITLES:t.subtitleSegmentLoader_,main:t.mainSegmentLoader_},tech:t.tech_,requestOptions:t.requestOptions_,masterPlaylistLoader:t.masterPlaylistLoader_,hls:t.hls_,master:t.master(),mediaTypes:t.mediaTypes_,blacklistCurrentPlaylist:t.blacklistCurrentPlaylist.bind(t)}),t.triggerPresenceUsage_(t.master(),n);try{t.setupSourceBuffers_()}catch(s){return re.log.warn("Failed to create SourceBuffers",s),t.mediaSource.endOfStream("decode")}t.setupFirstPlay(),!t.mediaTypes_.AUDIO.activePlaylistLoader||t.mediaTypes_.AUDIO.activePlaylistLoader.media()?t.trigger("selectedinitialmedia"):t.mediaTypes_.AUDIO.activePlaylistLoader.one("loadedmetadata",function(){t.trigger("selectedinitialmedia")})}),this.masterPlaylistLoader_.on("loadedplaylist",function(){var n=t.masterPlaylistLoader_.media();if(!n){t.excludeUnsupportedVariants_();var a=void 0;t.enableLowInitialPlaylist&&(a=t.selectInitialPlaylist()),a||(a=t.selectPlaylist()),t.initialMedia_=a,t.masterPlaylistLoader_.media(t.initialMedia_);return}if(t.useCueTags_&&t.updateAdCues_(n),t.mainSegmentLoader_.playlist(n,t.requestOptions_),t.updateDuration(),t.tech_.paused()||(t.mainSegmentLoader_.load(),t.audioSegmentLoader_&&t.audioSegmentLoader_.load()),!n.endList){var s=function(){var u=t.seekable();u.length!==0&&t.mediaSource.addSeekableRange_(u.start(0),u.end(0))};if(t.duration()!==1/0){var o=function l(){t.duration()===1/0?s():t.tech_.one("durationchange",l)};t.tech_.one("durationchange",o)}else s()}}),this.masterPlaylistLoader_.on("error",function(){t.blacklistCurrentPlaylist(t.masterPlaylistLoader_.error)}),this.masterPlaylistLoader_.on("mediachanging",function(){t.mainSegmentLoader_.abort(),t.mainSegmentLoader_.pause()}),this.masterPlaylistLoader_.on("mediachange",function(){var n=t.masterPlaylistLoader_.media(),a=n.targetDuration*1.5*1e3;Qp(t.masterPlaylistLoader_.master,t.masterPlaylistLoader_.media())?t.requestOptions_.timeout=0:t.requestOptions_.timeout=a,t.mainSegmentLoader_.playlist(n,t.requestOptions_),t.mainSegmentLoader_.load(),t.tech_.trigger({type:"mediachange",bubbles:!0})}),this.masterPlaylistLoader_.on("playlistunchanged",function(){var n=t.masterPlaylistLoader_.media(),a=t.stuckAtPlaylistEnd_(n);a&&(t.blacklistCurrentPlaylist({message:"Playlist no longer updating."}),t.tech_.trigger("playliststuck"))}),this.masterPlaylistLoader_.on("renditiondisabled",function(){t.tech_.trigger({type:"usage",name:"hls-rendition-disabled"})}),this.masterPlaylistLoader_.on("renditionenabled",function(){t.tech_.trigger({type:"usage",name:"hls-rendition-enabled"})})}},{key:"triggerPresenceUsage_",value:function(t,n){var a=t.mediaGroups||{},s=!0,o=Object.keys(a.AUDIO);for(var l in a.AUDIO)for(var u in a.AUDIO[l]){var g=a.AUDIO[l][u];g.uri||(s=!1)}s&&this.tech_.trigger({type:"usage",name:"hls-demuxed"}),Object.keys(a.SUBTITLES).length&&this.tech_.trigger({type:"usage",name:"hls-webvtt"}),Ro.Playlist.isAes(n)&&this.tech_.trigger({type:"usage",name:"hls-aes"}),Ro.Playlist.isFmp4(n)&&this.tech_.trigger({type:"usage",name:"hls-fmp4"}),o.length&&Object.keys(a.AUDIO[o[0]]).length>1&&this.tech_.trigger({type:"usage",name:"hls-alternate-audio"}),this.useCueTags_&&this.tech_.trigger({type:"usage",name:"hls-playlist-cue-tags"})}},{key:"setupSegmentLoaderListeners_",value:function(){var t=this;this.mainSegmentLoader_.on("bandwidthupdate",function(){var n=t.selectPlaylist(),a=t.masterPlaylistLoader_.media(),s=t.tech_.buffered(),o=s.length?s.end(s.length-1)-t.tech_.currentTime():0,l=t.bufferLowWaterLine();(!a.endList||t.duration()<ua.MAX_BUFFER_LOW_WATER_LINE||n.attributes.BANDWIDTH<a.attributes.BANDWIDTH||o>=l)&&t.masterPlaylistLoader_.media(n),t.tech_.trigger("bandwidthupdate")}),this.mainSegmentLoader_.on("progress",function(){t.trigger("progress")}),this.mainSegmentLoader_.on("error",function(){t.blacklistCurrentPlaylist(t.mainSegmentLoader_.error())}),this.mainSegmentLoader_.on("syncinfoupdate",function(){t.onSyncInfoUpdate_()}),this.mainSegmentLoader_.on("timestampoffset",function(){t.tech_.trigger({type:"usage",name:"hls-timestamp-offset"})}),this.audioSegmentLoader_.on("syncinfoupdate",function(){t.onSyncInfoUpdate_()}),this.mainSegmentLoader_.on("ended",function(){t.onEndOfStream()}),this.mainSegmentLoader_.on("earlyabort",function(){t.blacklistCurrentPlaylist({message:"Aborted early because there isn't enough bandwidth to complete the request without rebuffering."},Kk)}),this.mainSegmentLoader_.on("reseteverything",function(){t.tech_.trigger("hls-reset")}),this.mainSegmentLoader_.on("segmenttimemapping",function(n){t.tech_.trigger({type:"hls-segment-time-mapping",mapping:n.mapping})}),this.audioSegmentLoader_.on("ended",function(){t.onEndOfStream()})}},{key:"mediaSecondsLoaded_",value:function(){return Math.max(this.audioSegmentLoader_.mediaSecondsLoaded+this.mainSegmentLoader_.mediaSecondsLoaded)}},{key:"load",value:function(){this.mainSegmentLoader_.load(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.load(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.load()}},{key:"smoothQualityChange_",value:function(){var t=this.selectPlaylist();t!==this.masterPlaylistLoader_.media()&&(this.masterPlaylistLoader_.media(t),this.mainSegmentLoader_.resetLoader())}},{key:"fastQualityChange_",value:function(){var t=this,n=this.selectPlaylist();n!==this.masterPlaylistLoader_.media()&&(this.masterPlaylistLoader_.media(n),this.mainSegmentLoader_.resetEverything(function(){re.browser.IE_VERSION||re.browser.IS_EDGE?t.tech_.setCurrentTime(t.tech_.currentTime()+.04):t.tech_.setCurrentTime(t.tech_.currentTime())}))}},{key:"play",value:function(){if(!this.setupFirstPlay()){this.tech_.ended()&&this.seekTo_(0),this.hasPlayed_()&&this.load();var t=this.tech_.seekable();if(this.tech_.duration()===1/0&&this.tech_.currentTime()<t.start(0))return this.seekTo_(t.end(t.length-1))}}},{key:"setupFirstPlay",value:function(){var t=this,n=this.masterPlaylistLoader_.media();if(!n||this.tech_.paused()||this.hasPlayed_())return!1;if(!n.endList){var a=this.seekable();if(!a.length)return!1;if(re.browser.IE_VERSION&&this.tech_.readyState()===0)return this.tech_.one("loadedmetadata",function(){t.trigger("firstplay"),t.seekTo_(a.end(0)),t.hasPlayed_=function(){return!0}}),!1;this.trigger("firstplay"),this.seekTo_(a.end(0))}return this.hasPlayed_=function(){return!0},this.load(),!0}},{key:"handleSourceOpen_",value:function(){try{this.setupSourceBuffers_()}catch(n){return re.log.warn("Failed to create Source Buffers",n),this.mediaSource.endOfStream("decode")}if(this.tech_.autoplay()){var t=this.tech_.play();typeof t<"u"&&typeof t.then=="function"&&t.then(null,function(n){})}this.trigger("sourceopen")}},{key:"onEndOfStream",value:function(){var t=this.mainSegmentLoader_.ended_;if(this.mediaTypes_.AUDIO.activePlaylistLoader&&(!this.mainSegmentLoader_.startingMedia_||this.mainSegmentLoader_.startingMedia_.containsVideo?t=t&&this.audioSegmentLoader_.ended_:t=this.audioSegmentLoader_.ended_),!!t){this.logger_("calling mediaSource.endOfStream()");try{this.mediaSource.endOfStream()}catch(n){re.log.warn("Failed to call media source endOfStream",n)}}}},{key:"stuckAtPlaylistEnd_",value:function(t){var n=this.seekable();if(!n.length)return!1;var a=this.syncController_.getExpiredTime(t,this.mediaSource.duration);if(a===null)return!1;var s=Ro.Playlist.playlistEnd(t,a),o=this.tech_.currentTime(),l=this.tech_.buffered();if(!l.length)return s-o<=Vs;var u=l.end(l.length-1);return u-o<=Vs&&s-u<=Vs}},{key:"blacklistCurrentPlaylist",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments[1],a=void 0,s=void 0;if(a=t.playlist||this.masterPlaylistLoader_.media(),n=n||t.blacklistDuration||this.blacklistDuration,!a){this.error=t;try{return this.mediaSource.endOfStream("network")}catch{return this.trigger("error")}}var o=this.masterPlaylistLoader_.master.playlists.filter(Jd).length===1,l=this.masterPlaylistLoader_.master.playlists;return l.length===1?(re.log.warn("Problem encountered with the current HLS playlist. Trying again since it is the only playlist."),this.tech_.trigger("retryplaylist"),this.masterPlaylistLoader_.load(o)):(o&&(re.log.warn("Removing all playlists from the blacklist because the last rendition is about to be blacklisted."),l.forEach(function(u){u.excludeUntil!==1/0&&delete u.excludeUntil}),this.tech_.trigger("retryplaylist")),a.excludeUntil=Date.now()+n*1e3,this.tech_.trigger("blacklistplaylist"),this.tech_.trigger({type:"usage",name:"hls-rendition-blacklisted"}),s=this.selectPlaylist(),re.log.warn("Problem encountered with the current HLS playlist."+(t.message?" "+t.message:"")+" Switching to another playlist."),this.masterPlaylistLoader_.media(s,o))}},{key:"pauseLoading",value:function(){this.mainSegmentLoader_.pause(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.pause(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.pause()}},{key:"setCurrentTime",value:function(t){var n=S_(this.tech_.buffered(),t);if(!(this.masterPlaylistLoader_&&this.masterPlaylistLoader_.media())||!this.masterPlaylistLoader_.media().segments)return 0;if(n&&n.length)return t;this.mainSegmentLoader_.resetEverything(),this.mainSegmentLoader_.abort(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.resetEverything(),this.audioSegmentLoader_.abort()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.resetEverything(),this.subtitleSegmentLoader_.abort()),this.load()}},{key:"duration",value:function(){return this.masterPlaylistLoader_?this.mediaSource?this.mediaSource.duration:Ro.Playlist.duration(this.masterPlaylistLoader_.media()):0}},{key:"seekable",value:function(){return this.seekable_}},{key:"onSyncInfoUpdate_",value:function(){var t=void 0,n=void 0;if(!!this.masterPlaylistLoader_){var a=this.masterPlaylistLoader_.media();if(!!a){var s=this.syncController_.getExpiredTime(a,this.mediaSource.duration);if(s!==null&&(t=Ro.Playlist.seekable(a,s),t.length!==0&&!(this.mediaTypes_.AUDIO.activePlaylistLoader&&(a=this.mediaTypes_.AUDIO.activePlaylistLoader.media(),s=this.syncController_.getExpiredTime(a,this.mediaSource.duration),s===null||(n=Ro.Playlist.seekable(a,s),n.length===0))))){var o=void 0,l=void 0;this.seekable_&&this.seekable_.length&&(o=this.seekable_.end(0),l=this.seekable_.start(0)),n?n.start(0)>t.end(0)||t.start(0)>n.end(0)?this.seekable_=t:this.seekable_=re.createTimeRanges([[n.start(0)>t.start(0)?n.start(0):t.start(0),n.end(0)<t.end(0)?n.end(0):t.end(0)]]):this.seekable_=t,!(this.seekable_&&this.seekable_.length&&this.seekable_.end(0)===o&&this.seekable_.start(0)===l)&&(this.logger_("seekable updated ["+eg(this.seekable_)+"]"),this.tech_.trigger("seekablechanged"))}}}}},{key:"updateDuration",value:function(){var t=this,n=this.mediaSource.duration,a=Ro.Playlist.duration(this.masterPlaylistLoader_.media()),s=this.tech_.buffered(),o=function l(){t.logger_("Setting duration from "+t.mediaSource.duration+" => "+a);try{t.mediaSource.duration=a}catch(u){re.log.warn("Failed to set media source duration",u)}t.tech_.trigger("durationchange"),t.mediaSource.removeEventListener("sourceopen",l)};s.length>0&&(a=Math.max(a,s.end(s.length-1))),n!==a&&(this.mediaSource.readyState!=="open"?this.mediaSource.addEventListener("sourceopen",o):o())}},{key:"dispose",value:function(){var t=this;this.decrypter_.terminate(),this.masterPlaylistLoader_.dispose(),this.mainSegmentLoader_.dispose(),["AUDIO","SUBTITLES"].forEach(function(n){var a=t.mediaTypes_[n].groups;for(var s in a)a[s].forEach(function(o){o.playlistLoader&&o.playlistLoader.dispose()})}),this.audioSegmentLoader_.dispose(),this.subtitleSegmentLoader_.dispose()}},{key:"master",value:function(){return this.masterPlaylistLoader_.master}},{key:"media",value:function(){return this.masterPlaylistLoader_.media()||this.initialMedia_}},{key:"setupSourceBuffers_",value:function(){var t=this.masterPlaylistLoader_.media(),n=void 0;if(!(!t||this.mediaSource.readyState!=="open")){if(n=tk(this.masterPlaylistLoader_.master,t),n.length<1)return this.error="No compatible SourceBuffer configuration for the variant stream:"+t.resolvedUri,this.mediaSource.endOfStream("decode");this.configureLoaderMimeTypes_(n),this.excludeIncompatibleVariants_(t)}}},{key:"configureLoaderMimeTypes_",value:function(t){var n=t.length>1&&t[0].indexOf(",")===-1&&t[0]!==t[1]?new re.EventTarget:null;this.mainSegmentLoader_.mimeType(t[0],n),t[1]&&this.audioSegmentLoader_.mimeType(t[1],n)}},{key:"excludeUnsupportedVariants_",value:function(){this.master().playlists.forEach(function(t){t.attributes.CODECS&&Be.MediaSource&&Be.MediaSource.isTypeSupported&&!Be.MediaSource.isTypeSupported('video/mp4; codecs="'+J1(t.attributes.CODECS)+'"')&&(t.excludeUntil=1/0)})}},{key:"excludeIncompatibleVariants_",value:function(t){var n=2,a=null,s=void 0;t.attributes.CODECS&&(s=Dc(t.attributes.CODECS),a=s.videoCodec,n=s.codecCount),this.master().playlists.forEach(function(o){var l={codecCount:2,videoCodec:null};o.attributes.CODECS&&(l=Dc(o.attributes.CODECS)),l.codecCount!==n&&(o.excludeUntil=1/0),l.videoCodec!==a&&(o.excludeUntil=1/0)})}},{key:"updateAdCues_",value:function(t){var n=0,a=this.seekable();a.length&&(n=a.start(0)),Nk(t,this.cueTagsTrack_,n)}},{key:"goalBufferLength",value:function(){var t=this.tech_.currentTime(),n=ua.GOAL_BUFFER_LENGTH,a=ua.GOAL_BUFFER_LENGTH_RATE,s=Math.max(n,ua.MAX_GOAL_BUFFER_LENGTH);return Math.min(n+t*a,s)}},{key:"bufferLowWaterLine",value:function(){var t=this.tech_.currentTime(),n=ua.BUFFER_LOW_WATER_LINE,a=ua.BUFFER_LOW_WATER_LINE_RATE,s=Math.max(n,ua.MAX_BUFFER_LOW_WATER_LINE);return Math.min(n+t*a,s)}}]),r}(re.EventTarget),Qk=function(r,i,t){return function(n){var a=r.master.playlists[i],s=Jp(a),o=Jd(a);return typeof n>"u"?o:(n?delete a.disabled:a.disabled=!0,n!==o&&!s&&(t(),n?r.trigger("renditionenabled"):r.trigger("renditiondisabled")),n)}},Zk=function e(r,i,t){Aa(this,e);var n=r.masterPlaylistController_,a=r.options_.smoothQualityChange,s=a?"smooth":"fast",o=n[s+"QualityChange_"].bind(n);if(i.attributes.RESOLUTION){var l=i.attributes.RESOLUTION;this.width=l.width,this.height=l.height}this.bandwidth=i.attributes.BANDWIDTH,this.id=t,this.enabled=Qk(r.playlists,i.uri,o)},eR=function(r){var i=r.playlists;r.representations=function(){return i.master.playlists.filter(function(t){return!Jp(t)}).map(function(t,n){return new Zk(r,t,t.uri)})}},K_=["seeking","seeked","pause","playing","error"],tR=function(){function e(r){var i=this;Aa(this,e),this.tech_=r.tech,this.seekable=r.seekable,this.seekTo=r.seekTo,this.allowSeeksWithinUnsafeLiveWindow=r.allowSeeksWithinUnsafeLiveWindow,this.media=r.media,this.consecutiveUpdates=0,this.lastRecordedTime=null,this.timer_=null,this.checkCurrentTimeTimeout_=null,this.logger_=Oc("PlaybackWatcher"),this.logger_("initialize");var t=function(){return i.monitorCurrentTime_()},n=function(){return i.techWaiting_()},a=function(){return i.cancelTimer_()},s=function(){return i.fixesBadSeeks_()};this.tech_.on("seekablechanged",s),this.tech_.on("waiting",n),this.tech_.on(K_,a),this.tech_.on("canplay",t),this.dispose=function(){i.logger_("dispose"),i.tech_.off("seekablechanged",s),i.tech_.off("waiting",n),i.tech_.off(K_,a),i.tech_.off("canplay",t),i.checkCurrentTimeTimeout_&&Be.clearTimeout(i.checkCurrentTimeTimeout_),i.cancelTimer_()}}return Va(e,[{key:"monitorCurrentTime_",value:function(){this.checkCurrentTime_(),this.checkCurrentTimeTimeout_&&Be.clearTimeout(this.checkCurrentTimeTimeout_),this.checkCurrentTimeTimeout_=Be.setTimeout(this.monitorCurrentTime_.bind(this),250)}},{key:"checkCurrentTime_",value:function(){if(this.tech_.seeking()&&this.fixesBadSeeks_()){this.consecutiveUpdates=0,this.lastRecordedTime=this.tech_.currentTime();return}if(!(this.tech_.paused()||this.tech_.seeking())){var i=this.tech_.currentTime(),t=this.tech_.buffered();if(this.lastRecordedTime===i&&(!t.length||i+Vs>=t.end(t.length-1)))return this.techWaiting_();this.consecutiveUpdates>=5&&i===this.lastRecordedTime?(this.consecutiveUpdates++,this.waiting_()):i===this.lastRecordedTime?this.consecutiveUpdates++:(this.consecutiveUpdates=0,this.lastRecordedTime=i)}}},{key:"cancelTimer_",value:function(){this.consecutiveUpdates=0,this.timer_&&(this.logger_("cancelTimer_"),clearTimeout(this.timer_)),this.timer_=null}},{key:"fixesBadSeeks_",value:function(){var i=this.tech_.seeking();if(!i)return!1;var t=this.seekable(),n=this.tech_.currentTime(),a=this.afterSeekableWindow_(t,n,this.media(),this.allowSeeksWithinUnsafeLiveWindow),s=void 0;if(a){var o=t.end(t.length-1);s=o}if(this.beforeSeekableWindow_(t,n)){var l=t.start(0);s=l+Vs}return typeof s<"u"?(this.logger_("Trying to seek outside of seekable at time "+n+" with "+("seekable range "+eg(t)+". Seeking to ")+(s+".")),this.seekTo(s),!0):!1}},{key:"waiting_",value:function(){if(!this.techWaiting_()){var i=this.tech_.currentTime(),t=this.tech_.buffered(),n=S_(t,i);if(n.length&&i+3<=n.end(0)){this.cancelTimer_(),this.seekTo(i),this.logger_("Stopped at "+i+" 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:"hls-unknown-waiting"});return}}}},{key:"techWaiting_",value:function(){var i=this.seekable(),t=this.tech_.currentTime();if(this.tech_.seeking()&&this.fixesBadSeeks_()||this.tech_.seeking()||this.timer_!==null)return!0;if(this.beforeSeekableWindow_(i,t)){var n=i.end(i.length-1);return this.logger_("Fell out of live window at time "+t+". Seeking to "+("live point (seekable end) "+n)),this.cancelTimer_(),this.seekTo(n),this.tech_.trigger({type:"usage",name:"hls-live-resync"}),!0}var a=this.tech_.buffered(),s=E_(a,t);if(this.videoUnderflow_(s,a,t))return this.cancelTimer_(),this.seekTo(t),this.tech_.trigger({type:"usage",name:"hls-video-underflow"}),!0;if(s.length>0){var o=s.start(0)-t;return this.logger_("Stopped at "+t+", setting timer for "+o+", seeking "+("to "+s.start(0))),this.timer_=setTimeout(this.skipTheGap_.bind(this),o*1e3,t),!0}return!1}},{key:"afterSeekableWindow_",value:function(i,t,n){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!i.length)return!1;var s=i.end(i.length-1)+Vs,o=!n.endList;return o&&a&&(s=i.end(i.length-1)+n.targetDuration*3),t>s}},{key:"beforeSeekableWindow_",value:function(i,t){return!!(i.length&&i.start(0)>0&&t<i.start(0)-Vs)}},{key:"videoUnderflow_",value:function(i,t,n){if(i.length===0){var a=this.gapFromVideoUnderflow_(t,n);if(a)return this.logger_("Encountered a gap in video from "+a.start+" to "+a.end+". "+("Seeking to current time "+n)),!0}return!1}},{key:"skipTheGap_",value:function(i){var t=this.tech_.buffered(),n=this.tech_.currentTime(),a=E_(t,n);this.cancelTimer_(),!(a.length===0||n!==i)&&(this.logger_("skipTheGap_:","currentTime:",n,"scheduled currentTime:",i,"nextRange start:",a.start(0)),this.seekTo(a.start(0)+Zd),this.tech_.trigger({type:"usage",name:"hls-gap-skip"}))}},{key:"gapFromVideoUnderflow_",value:function(i,t){for(var n=H1(i),a=0;a<n.length;a++){var s=n.start(a),o=n.end(a);if(t-s<4&&t-s>2)return{start:s,end:o}}return null}}]),e}(),rR={errorInterval:30,getSource:function(r){var i=this.tech({IWillNotUseThisInPlugins:!0}),t=i.currentSource_;return r(t)}},iR=function e(r,i){var t=0,n=0,a=re.mergeOptions(rR,i);r.ready(function(){r.trigger({type:"usage",name:"hls-error-reload-initialized"})});var s=function(){n&&r.currentTime(n)},o=function(d){d!=null&&(n=r.duration()!==1/0&&r.currentTime()||0,r.one("loadedmetadata",s),r.src(d),r.trigger({type:"usage",name:"hls-error-reload"}),r.play())},l=function(){if(Date.now()-t<a.errorInterval*1e3){r.trigger({type:"usage",name:"hls-error-reload-canceled"});return}if(!a.getSource||typeof a.getSource!="function"){re.log.error("ERROR: reloadSourceOnError - The option getSource must be a function!");return}return t=Date.now(),a.getSource.call(r,o)},u=function c(){r.off("loadedmetadata",s),r.off("error",l),r.off("dispose",c)},g=function(d){u(),e(r,d)};r.on("error",l),r.on("dispose",u),r.reloadSourceOnError=g},z_=function(r){iR(this,r)},nR="1.10.6";re.use("*",function(e){return{setSource:function(i,t){t(null,i)},setCurrentTime:function(i){return e.vhs&&e.currentSource().src===e.vhs.source_.src&&e.vhs.setCurrentTime(i),i},play:function(){e.vhs&&e.currentSource().src===e.vhs.source_.src&&e.vhs.setCurrentTime(e.tech_.currentTime())}}});var Xn={PlaylistLoader:Xd,Playlist:zn,Decrypter:FA,AsyncStream:yy,decrypt:_y,utils:L1,STANDARD_PLAYLIST_SELECTOR:xk,INITIAL_PLAYLIST_SELECTOR:Ak,comparePlaylistBandwidth:ug,comparePlaylistResolution:Sk,xhr:v_()};["GOAL_BUFFER_LENGTH","MAX_GOAL_BUFFER_LENGTH","GOAL_BUFFER_LENGTH_RATE","BUFFER_LOW_WATER_LINE","MAX_BUFFER_LOW_WATER_LINE","BUFFER_LOW_WATER_LINE_RATE","BANDWIDTH_VARIANCE"].forEach(function(e){Object.defineProperty(Xn,e,{get:function(){return re.log.warn("using Hls."+e+" is UNSAFE be sure you know what you are doing"),ua[e]},set:function(i){if(re.log.warn("using Hls."+e+" is UNSAFE be sure you know what you are doing"),typeof i!="number"||i<0){re.log.warn("value of Hls."+e+" must be greater than or equal to 0");return}ua[e]=i}})});var X_="videojs-vhs",J_=function(r){var i=/^(audio|video|application)\/(x-|vnd\.apple\.)?mpegurl/i;if(i.test(r))return"hls";var t=/^application\/dash\+xml/i;return t.test(r)?"dash":null},Q_=function(r,i){for(var t=i.media(),n=-1,a=0;a<r.length;a++)if(r[a].id===t.uri){n=a;break}r.selectedIndex_=n,r.trigger({selectedIndex:n,type:"change"})},aR=function(r,i){i.representations().forEach(function(t){r.addQualityLevel(t)}),Q_(r,i.playlists)};Xn.canPlaySource=function(){return re.log.warn("HLS is no longer a tech. Please remove it from your player's techOrder.")};var sR=function(r,i,t){if(!r)return r;var n={};for(var a in r)n[a]={audioContentType:'audio/mp4; codecs="'+t.attributes.CODECS+'"',videoContentType:'video/mp4; codecs="'+i.attributes.CODECS+'"'},i.contentProtection&&i.contentProtection[a]&&i.contentProtection[a].pssh&&(n[a].pssh=i.contentProtection[a].pssh),typeof r[a]=="string"&&(n[a].url=r[a]);return re.mergeOptions(r,n)},oR=function(r){if(r.options_.sourceType==="dash"){var i=re.players[r.tech_.options_.playerId];if(i.eme){var t=sR(r.source_.keySystems,r.playlists.media(),r.masterPlaylistController_.mediaTypes_.AUDIO.activePlaylistLoader.media());t&&(i.currentSource().keySystems=t,i.eme.initializeMediaKeys&&i.eme.initializeMediaKeys())}}},Z_=function(){if(!window.localStorage)return null;var r=window.localStorage.getItem(X_);if(!r)return null;try{return JSON.parse(r)}catch{return null}},uR=function(r){if(!window.localStorage)return!1;var i=Z_();i=i?re.mergeOptions(i,r):r;try{window.localStorage.setItem(X_,JSON.stringify(i))}catch{return!1}return i};Xn.supportsNativeHls=function(){var e=Mt.createElement("video");if(!re.getTech("Html5").isSupported())return!1;var r=["application/vnd.apple.mpegurl","audio/mpegurl","audio/x-mpegurl","application/x-mpegurl","video/x-mpegurl","video/mpegurl","application/mpegurl"];return r.some(function(i){return/maybe|probably/i.test(e.canPlayType(i))})}(),Xn.supportsNativeDash=function(){return re.getTech("Html5").isSupported()?/maybe|probably/i.test(Mt.createElement("video").canPlayType("application/dash+xml")):!1}(),Xn.supportsTypeNatively=function(e){return e==="hls"?Xn.supportsNativeHls:e==="dash"?Xn.supportsNativeDash:!1},Xn.isSupported=function(){return re.log.warn("HLS is no longer a tech. Please remove it from your player's techOrder.")};var lR=re.getComponent("Component"),eb=function(e){Gs(r,e);function r(i,t,n){Aa(this,r);var a=hs(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,t,n.hls));if(t.options_&&t.options_.playerId){var s=re(t.options_.playerId);s.hasOwnProperty("hls")||Object.defineProperty(s,"hls",{get:function(){return re.log.warn("player.hls is deprecated. Use player.tech().hls instead."),t.trigger({type:"usage",name:"hls-player-access"}),a},configurable:!0}),s.vhs=a,s.dash=a,a.player_=s}if(a.tech_=t,a.source_=i,a.stats={},a.setOptions_(),a.options_.overrideNative&&t.overrideNativeAudioTracks&&t.overrideNativeVideoTracks)t.overrideNativeAudioTracks(!0),t.overrideNativeVideoTracks(!0);else if(a.options_.overrideNative&&(t.featuresNativeVideoTracks||t.featuresNativeAudioTracks))throw new Error("Overriding native HLS requires emulated tracks. See https://git.io/vMpjB");return a.on(Mt,["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],function(o){var l=Mt.fullscreenElement||Mt.webkitFullscreenElement||Mt.mozFullScreenElement||Mt.msFullscreenElement;l&&l.contains(a.tech_.el())&&a.masterPlaylistController_.smoothQualityChange_()}),a.on(a.tech_,"seeking",function(){this.tech_.currentTime()===0&&this.tech_.player_.loop()&&this.setCurrentTime(0)}),a.on(a.tech_,"error",function(){this.masterPlaylistController_&&this.masterPlaylistController_.pauseLoading()}),a.on(a.tech_,"play",a.play),a}return Va(r,[{key:"setOptions_",value:function(){var t=this;if(this.options_.withCredentials=this.options_.withCredentials||!1,this.options_.handleManifestRedirects=this.options_.handleManifestRedirects||!1,this.options_.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions!==!1,this.options_.smoothQualityChange=this.options_.smoothQualityChange||!1,this.options_.useBandwidthFromLocalStorage=typeof this.source_.useBandwidthFromLocalStorage<"u"?this.source_.useBandwidthFromLocalStorage:this.options_.useBandwidthFromLocalStorage||!1,this.options_.customTagParsers=this.options_.customTagParsers||[],this.options_.customTagMappers=this.options_.customTagMappers||[],this.options_.cacheEncryptionKeys=this.options_.cacheEncryptionKeys||!1,typeof this.options_.blacklistDuration!="number"&&(this.options_.blacklistDuration=5*60),typeof this.options_.bandwidth!="number"&&this.options_.useBandwidthFromLocalStorage){var n=Z_();n&&n.bandwidth&&(this.options_.bandwidth=n.bandwidth,this.tech_.trigger({type:"usage",name:"hls-bandwidth-from-local-storage"})),n&&n.throughput&&(this.options_.throughput=n.throughput,this.tech_.trigger({type:"usage",name:"hls-throughput-from-local-storage"}))}typeof this.options_.bandwidth!="number"&&(this.options_.bandwidth=ua.INITIAL_BANDWIDTH),this.options_.enableLowInitialPlaylist=this.options_.enableLowInitialPlaylist&&this.options_.bandwidth===ua.INITIAL_BANDWIDTH,["withCredentials","limitRenditionByPlayerDimensions","bandwidth","smoothQualityChange","customTagParsers","customTagMappers","handleManifestRedirects","cacheEncryptionKeys"].forEach(function(a){typeof t.source_[a]<"u"&&(t.options_[a]=t.source_[a])}),this.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions}},{key:"src",value:function(t,n){var a=this;!t||(this.setOptions_(),this.options_.url=this.source_.src,this.options_.tech=this.tech_,this.options_.externHls=Xn,this.options_.sourceType=J_(n),this.options_.seekTo=function(s){a.tech_.setCurrentTime(s),a.setCurrentTime(s)},this.masterPlaylistController_=new Jk(this.options_),this.playbackWatcher_=new tR(re.mergeOptions(this.options_,{seekable:function(){return a.seekable()},media:function(){return a.masterPlaylistController_.media()}})),this.masterPlaylistController_.on("error",function(){var s=re.players[a.tech_.options_.playerId];s.error(a.masterPlaylistController_.error)}),this.masterPlaylistController_.selectPlaylist=this.selectPlaylist?this.selectPlaylist.bind(this):Xn.STANDARD_PLAYLIST_SELECTOR.bind(this),this.masterPlaylistController_.selectInitialPlaylist=Xn.INITIAL_PLAYLIST_SELECTOR.bind(this),this.playlists=this.masterPlaylistController_.masterPlaylistLoader_,this.mediaSource=this.masterPlaylistController_.mediaSource,Object.defineProperties(this,{selectPlaylist:{get:function(){return this.masterPlaylistController_.selectPlaylist},set:function(o){this.masterPlaylistController_.selectPlaylist=o.bind(this)}},throughput:{get:function(){return this.masterPlaylistController_.mainSegmentLoader_.throughput.rate},set:function(o){this.masterPlaylistController_.mainSegmentLoader_.throughput.rate=o,this.masterPlaylistController_.mainSegmentLoader_.throughput.count=1}},bandwidth:{get:function(){return this.masterPlaylistController_.mainSegmentLoader_.bandwidth},set:function(o){this.masterPlaylistController_.mainSegmentLoader_.bandwidth=o,this.masterPlaylistController_.mainSegmentLoader_.throughput={rate:0,count:0}}},systemBandwidth:{get:function(){var o=1/(this.bandwidth||1),l=void 0;this.throughput>0?l=1/this.throughput:l=0;var u=Math.floor(1/(o+l));return u},set:function(){re.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:function(){return a.bandwidth||0},enumerable:!0},mediaRequests:{get:function(){return a.masterPlaylistController_.mediaRequests_()||0},enumerable:!0},mediaRequestsAborted:{get:function(){return a.masterPlaylistController_.mediaRequestsAborted_()||0},enumerable:!0},mediaRequestsTimedout:{get:function(){return a.masterPlaylistController_.mediaRequestsTimedout_()||0},enumerable:!0},mediaRequestsErrored:{get:function(){return a.masterPlaylistController_.mediaRequestsErrored_()||0},enumerable:!0},mediaTransferDuration:{get:function(){return a.masterPlaylistController_.mediaTransferDuration_()||0},enumerable:!0},mediaBytesTransferred:{get:function(){return a.masterPlaylistController_.mediaBytesTransferred_()||0},enumerable:!0},mediaSecondsLoaded:{get:function(){return a.masterPlaylistController_.mediaSecondsLoaded_()||0},enumerable:!0},buffered:{get:function(){return x_(a.tech_.buffered())},enumerable:!0},currentTime:{get:function(){return a.tech_.currentTime()},enumerable:!0},currentSource:{get:function(){return a.tech_.currentSource_},enumerable:!0},currentTech:{get:function(){return a.tech_.name_},enumerable:!0},duration:{get:function(){return a.tech_.duration()},enumerable:!0},master:{get:function(){return a.playlists.master},enumerable:!0},playerDimensions:{get:function(){return a.tech_.currentDimensions()},enumerable:!0},seekable:{get:function(){return x_(a.tech_.seekable())},enumerable:!0},timestamp:{get:function(){return Date.now()},enumerable:!0},videoPlaybackQuality:{get:function(){return a.tech_.getVideoPlaybackQuality()},enumerable:!0}}),this.tech_.one("canplay",this.masterPlaylistController_.setupFirstPlay.bind(this.masterPlaylistController_)),this.tech_.on("bandwidthupdate",function(){a.options_.useBandwidthFromLocalStorage&&uR({bandwidth:a.bandwidth,throughput:Math.round(a.throughput)})}),this.masterPlaylistController_.on("selectedinitialmedia",function(){eR(a),oR(a)}),this.on(this.masterPlaylistController_,"progress",function(){this.tech_.trigger("progress")}),this.tech_.ready(function(){return a.setupQualityLevels_()}),this.tech_.el()&&this.tech_.src(re.URL.createObjectURL(this.masterPlaylistController_.mediaSource)))}},{key:"setupQualityLevels_",value:function(){var t=this,n=re.players[this.tech_.options_.playerId];n&&n.qualityLevels&&(this.qualityLevels_=n.qualityLevels(),this.masterPlaylistController_.on("selectedinitialmedia",function(){aR(t.qualityLevels_,t)}),this.playlists.on("mediachange",function(){Q_(t.qualityLevels_,t.playlists)}))}},{key:"play",value:function(){this.masterPlaylistController_.play()}},{key:"setCurrentTime",value:function(t){this.masterPlaylistController_.setCurrentTime(t)}},{key:"duration",value:function(){return this.masterPlaylistController_.duration()}},{key:"seekable",value:function(){return this.masterPlaylistController_.seekable()}},{key:"dispose",value:function(){this.playbackWatcher_&&this.playbackWatcher_.dispose(),this.masterPlaylistController_&&this.masterPlaylistController_.dispose(),this.qualityLevels_&&this.qualityLevels_.dispose(),this.player_&&(delete this.player_.vhs,delete this.player_.dash,delete this.player_.hls),this.tech_&&this.tech_.hls&&delete this.tech_.hls,l1(r.prototype.__proto__||Object.getPrototypeOf(r.prototype),"dispose",this).call(this)}},{key:"convertToProgramTime",value:function(t,n){return j1({playlist:this.masterPlaylistController_.media(),time:t,callback:n})}},{key:"seekToProgramTime",value:function(t,n){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:2;return $1({programTime:t,playlist:this.masterPlaylistController_.media(),retryCount:s,pauseAfterSeek:a,seekTo:this.options_.seekTo,tech:this.options_.tech,callback:n})}}]),r}(lR),dg={name:"videojs-http-streaming",VERSION:nR,canHandleSource:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=re.mergeOptions(re.options,i);return dg.canPlayType(r.type,t)},handleSource:function(r,i){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=re.mergeOptions(re.options,t);return i.hls=new eb(r,i,n),i.hls.xhr=v_(),i.hls.src(r.src,r.type),i.hls},canPlayType:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=re.mergeOptions(re.options,i),n=t.hls.overrideNative,a=J_(r),s=a&&(!Xn.supportsTypeNatively(a)||n);return s?"maybe":""}};(typeof re.MediaSource>"u"||typeof re.URL>"u")&&(re.MediaSource=Pc,re.URL=N_),Pc.supportsNativeMediaSources()&&re.getTech("Html5").registerSourceHandler(dg,0),re.HlsHandler=eb,re.HlsSourceHandler=dg,re.Hls=Xn,re.use||re.registerComponent("Hls",Xn),re.options.hls=re.options.hls||{},re.registerPlugin?re.registerPlugin("reloadSourceOnError",z_):re.plugin("reloadSourceOnError",z_);const cR=Object.freeze(Object.defineProperty({__proto__:null,default:re},Symbol.toStringTag,{value:"Module"})),tb={name:"stream-engine-player",version:"0.0.46",description:"Stream engine player",type:"module",files:["dist","src","index.js","README.md","LICENSE","package.json","vite.config.js"],exports:{".":{import:"./dist/stream-engine-player.mjs",require:"./dist/stream-engine-player.js"},"./style":{import:"./dist/style.css",require:"./dist/style.css"},"./bundle":{import:"./dist/stream-engine-player-bundle.mjs",require:"./dist/stream-engine-player-bundle.js"}},main:"dist/stream-engine-player.js",author:"Dok Umansky",scripts:{dev:"vite serve",build:'concurrently "vite build --mode bundle" "vite build"',serve:"vite preview",start:"npm run dev",prebuild:"rm -rf dist","version:patch":"npm version patch",lint:"./node_modules/.bin/eslint src",format:'prettier "src/**/*.{ts,js,json,scss,css}" --write',watch:'concurrently "vite build --watch" "vite serve"',"build:watch":"vite build --watch --minify=false"},dependencies:{"@fastpix/videojs-monitor":"^1.0.3",angular:"~1.4.8","angular-cookies":"~1.4.8","hls.js":"^0.12.4","include-media":"^2.0.0","infront-logger":"1.1.11",localforage:"^1.10.0","m3u8-parser":"^7.1.0","mixpanel-browser":"2.52.0",moment:"^2.30.1","video.js":"7.6.6","videojs-contrib-ads":"6.6.5","videojs-ima":"1.7.5","videojs-mux":"4.19.0","videojs-sprite-thumbnails":"^1.2.1","videojs-youtube":"^2.6.1"},devDependencies:{concurrently:"^8.2.1",eslint:"^8.24.0","eslint-config-prettier":"^8.5.0","eslint-plugin-angular":"^4.1.0","eslint-plugin-prettier":"^4.2.1",husky:"^8.0.1",hygen:"^6.2.11","lint-staged":"^13.0.3",prettier:"^2.7.1",sass:"^1.55.0",vite:"^3.2.7"},husky:{hooks:{"pre-commit":"lint-staged"}},"lint-staged":{"*.{ts,js,json,scss,css}":["prettier --write","git add"]}};var pn=[];for(let e=0;e<256;++e)pn.push((e+256).toString(16).slice(1));function dR(e,r=0){return(pn[e[r+0]]+pn[e[r+1]]+pn[e[r+2]]+pn[e[r+3]]+"-"+pn[e[r+4]]+pn[e[r+5]]+"-"+pn[e[r+6]]+pn[e[r+7]]+"-"+pn[e[r+8]]+pn[e[r+9]]+"-"+pn[e[r+10]]+pn[e[r+11]]+pn[e[r+12]]+pn[e[r+13]]+pn[e[r+14]]+pn[e[r+15]]).toLowerCase()}var fg,fR=new Uint8Array(16);function hR(){if(!fg){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");fg=crypto.getRandomValues.bind(crypto)}return fg(fR)}var pR=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),rb={randomUUID:pR};function gR(e,r,i){var n,a,s;if(rb.randomUUID&&!r&&!e)return rb.randomUUID();e=e||{};let t=(s=(a=e.random)!=null?a:(n=e.rng)==null?void 0:n.call(e))!=null?s:hR();if(t.length<16)throw new Error("Random bytes length must be >= 16");if(t[6]=t[6]&15|64,t[8]=t[8]&63|128,r){if(i=i||0,i<0||i+16>r.length)throw new RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`);for(let o=0;o<16;++o)r[i+o]=t[o];return r}return dR(t)}var vR=gR,ib="000000",nb=function(){let e=Math.random().toString(36).replace("0.","").slice(0,6);return ib.slice(e.length)+e},Al=function(){return vR()},mR=function(){return(ib+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},hg=e=>{if(!e)return["localhost","localhost"];try{let r=new URL(e).hostname,i=r.split("."),t=i.length>=2?i.slice(-2).join("."):r;return[r,t]}catch{}return["localhost","localhost"]},ps=e=>hg(e)[0],pg=e=>hg(e)[1],yR=e=>{var r,i;if(e&&e.nodeName)return(r=e.uniqueId)!=null?r:e.uniqueId=nb();try{let t=document.querySelector(e);return t&&!t.uniqueId&&(t.uniqueId=e),(i=t==null?void 0:t.uniqueId)!=null?i:e}catch{}return e},_R=e=>{var t;let r=null;e&&e.nodeName!==void 0?(r=e,e=yR(r)):r=document.querySelector(e);let i=((t=r==null?void 0:r.nodeName)==null?void 0:t.toLowerCase())||"";return[r,e,i]},ab=e=>{var i,t;let r=null;if(e&&e.nodeName!==void 0)return(i=e.elementId)!=null||(e.elementId=mR()),e.elementId;try{r=document.querySelector(e)}catch{}return r&&!r.elementId&&(r.elementId=e),(t=r==null?void 0:r.elementId)!=null?t:e};function bR(...e){return e.reduce((r,i)=>{for(let[t,n]of Object.entries(i))n!==void 0&&(r[t]=n);return r},{})}function nf(e,r,i=1){var t;e[r]=((t=e[r])!=null?t:0)+i}function TR(e,r){let{beaconDomain:i}=r;return`https://${e!=null?e:"collector"}.${i!=null?i:"metrix.ws"}`}function sb(){var r,i;let e=(i=(r=navigator.doNotTrack)!=null?r:window.doNotTrack)!=null?i:navigator.msDoNotTrack;return e==="1"||e==="yes"}var SR=class{constructor(){this.events={}}on(e,r){this.events[e]||(this.events[e]=[]),this.events[e].push(r)}off(e,r){this.events[e]&&(this.events[e]=this.events[e].filter(i=>i!==r))}emit(e,r){this.events[e]&&this.events[e].forEach(i=>{i(r)})}},Do={now:function(){return typeof Date.now=="function"?Date.now():new Date().getTime()}},af={isPerformanceAvailable:function(){let e=window.performance;return e&&e.timing!==void 0},getDomContentLoadedEnd:function(){var r;let e=(r=window.performance)==null?void 0:r.timing;return e?e.domContentLoadedEventEnd:null},getNavigationStartTime:function(){var r;let e=(r=window.performance)==null?void 0:r.timing;return e?e.navigationStart:null}};function ER(e){if(!e)return{};let r=af.getNavigationStartTime(),{loading:i,trequest:t,tfirst:n,tload:a,total:s}=e,o=i?i.start:t,l=i?i.first:n,u=i?i.end:a;return{bytesLoaded:s,requestStart:Math.round(r+o),responseStart:Math.round(r+l),responseEnd:Math.round(r+u)}}var xR=()=>{var r,i,t;let e=navigator;return(t=(i=(r=e==null?void 0:e.connection)!=null?r:e==null?void 0:e.mozConnection)!=null?i:e==null?void 0:e.webkitConnection)==null?void 0:t.type},wR=()=>{switch(xR()){case"cellular":return"cellular";case"ethernet":return"wired";case"wifi":return"wifi";case void 0:break;default:return"other"}},AR=["x-cdn","content-type","content-length","last-modified","server","x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"];function CR(e){let r={},i=new Set(AR.map(t=>t.toLowerCase()));return!e||typeof e!="string"?{}:(e.trim().split(/[\r\n]+/).forEach(t=>{let[n,...a]=t.split(": "),s=a.join(": ");n&&i.has(n.toLowerCase())&&(r[n]=s)}),r)}var sf=function(e){if(e&&typeof e.getAllResponseHeaders=="function")return CR(e.getAllResponseHeaders())},kR={convertSecToMs:function(e){return Math.floor(1e3*e)},isolateHostAndDomainName:hg,fetchDomain:pg,fetchHost:ps,generateIdToken:nb,buildUUID:Al,now:Do.now};function RR(e){let r=(window==null?void 0:window.URL)||(window==null?void 0:window.webkitURL),i=window==null?void 0:window.Blob,t=window==null?void 0:window.Worker;if(!r||!i||!t||!e)return null;let n=new i([e]);return new t(r.createObjectURL(n))}var DR=`
98
98
  let pulseInterval = null;
99
99
  let throbInterval = null
100
100